forked from goautodial/v4.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditsettingsvoicemail.php
332 lines (295 loc) · 14.1 KB
/
editsettingsvoicemail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<?php
/**
* @file editsettingsvoicemail.php
* @brief Modify Voicemail settings
* @copyright Copyright (c) 2018 GOautodial Inc.
* @author Alexander Jim H. Abenoja
* @author Demian Lizandro A. Biscocho
*
* @par <b>License</b>:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
require_once('./php/UIHandler.php');
require_once('./php/APIHandler.php');
require_once('./php/CRMDefaults.php');
require_once('./php/LanguageHandler.php');
include('./php/Session.php');
$ui = \creamy\UIHandler::getInstance();
$api = \creamy\APIHandler::getInstance();
$lh = \creamy\LanguageHandler::getInstance();
$user = \creamy\CreamyUser::currentUser();
$vmid = NULL;
if (isset($_POST["vmid"])) {
$vmid = $_POST["vmid"];
}else{
header("location: settingsvoicemails.php");
}
?>
<html>
<head>
<meta charset="UTF-8">
<title><?php $lh->translateText('portal_title'); ?> - <?php $lh->translateText("edit_voice_mail"); ?></title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php print $ui->standardizedThemeCSS(); ?>
<?php print $ui->creamyThemeCSS(); ?>
<script type="text/javascript">
$(window).ready(function() {
$(".preloader").fadeOut("slow");
})
</script>
</head>
<style>
select{
font-weight: normal;
}
</style>
<?php print $ui->creamyBody(); ?>
<div class="wrapper">
<!-- header logo: style can be found in header.less -->
<?php print $ui->creamyHeader($user); ?>
<!-- Left side column. contains the logo and sidebar -->
<?php print $ui->getSidebar($user->getUserId(), $user->getUserName(), $user->getUserRole(), $user->getUserAvatar()); ?>
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1 style="font-weight:normal;">
<?php $lh->translateText("settings"); ?>
<small><?php $lh->translateText("edit_voice_mail"); ?></small>
</h1>
<ol class="breadcrumb">
<li><a href="./index.php"><i class="fa fa-edit"></i> <?php $lh->translateText("home"); ?></a></li>
<li> <?php $lh->translateText("settings"); ?></li>
<?php
if(isset($_POST["vmid"])){
?>
<li><a href="./settingsvoicemails.php"><?php $lh->translateText("Voicemail"); ?></a></li>
<?php
}
?>
<li class="active"><?php $lh->translateText("modify"); ?></li>
</ol>
</section>
<!-- standard custom edition form -->
<?php
$errormessage = NULL;
$output = $api->API_getVoicemailInfo($vmid);
$voicefiles = $api->API_getAllVoiceFiles();
if ($output->result=="success") {
?>
<!-- Main content -->
<section class="content">
<div class="panel panel-default">
<div class="panel-body">
<legend>MODIFY VOICEMAIL ID: <u><?php echo $output->data->voicemail_id;?></u></legend>
<form id="modifyform">
<input type="hidden" name="modifyid" value="<?php echo $vmid;?>">
<input type="hidden" name="log_user" value="<?php echo $_SESSION['user'];?>" />
<input type="hidden" name="log_group" value="<?php echo $_SESSION['usergroup'];?>" />
<!-- Custom Tabs -->
<div role="tabpanel">
<!--<div class="nav-tabs-custom">-->
<ul role="tablist" class="nav nav-tabs nav-justified">
<li class="active"><a href="#tab_1" data-toggle="tab"> <?php $lh->translateText("basic_settings"); ?></a></li>
</ul>
<!-- Tab panes-->
<div class="tab-content">
<!-- BASIC SETTINGS -->
<div id="tab_1" class="tab-pane fade in active">
<fieldset>
<div class="form-group mt">
<label for="password" class="col-sm-3 control-label"><?php $lh->translateText("your_password"); ?></label>
<div class="col-sm-9 mb">
<input type="text" class="form-control" name="password" id="password" placeholder="Password" value="<?php echo $output->data->password;?>">
</div>
</div>
<div class="form-group">
<label for="fullname" class="col-sm-3 control-label"><?php $lh->translateText("name"); ?></label>
<div class="col-sm-9 mb">
<input type="text" class="form-control" name="fullname" id="fullname" value="<?php echo $output->data->fullname;?>">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label"><?php $lh->translateText("email"); ?></label>
<div class="col-sm-9 mb">
<input type="text" class="form-control" name="email" id="email" value="<?php echo $output->data->email;?>">
</div>
</div>
<div class="form-group">
<label for="active" class="col-sm-3 control-label"><?php $lh->translateText("active"); ?></label>
<div class="col-sm-9 mb">
<select class="form-control" name="active" id="active">
<?php
$active = NULL;
if($output->data->active == "Y"){
$active .= '<option value="Y" selected> '.$lh->translationFor("go_yes").' </option>';
}else{
$active .= '<option value="Y" > '.$lh->translationFor("go_yes").' </option>';
}
if($output->data->active == "N" || $output->data->active == NULL){
$active .= '<option value="N" selected> '.$lh->translationFor("go_no").' </option>';
}else{
$active .= '<option value="N" > '.$lh->translationFor("go_no").' </option>';
}
echo $active;
?>
</select>
</div>
</div>
<div class="form-group">
<label for="delete_vm_after_email" class="col-sm-3 control-label"><?php $lh->translateText("delete_voicemail_after_email"); ?></label>
<div class="col-sm-9 mb">
<select class="form-control" name="delete_vm_after_email" id="delete_vm_after_email">
<?php
$delete_vm_after_email = NULL;
if($output->data->delete_vm_after_email == "Y"){
$delete_vm_after_email .= '<option value="Y" selected> '.$lh->translationFor("go_yes").' </option>';
}else{
$delete_vm_after_email .= '<option value="Y" > '.$lh->translationFor("go_yes").' </option>';
}
if($output->data->delete_vm_after_email == "N" || $output->data->delete_vm_after_email == NULL){
$delete_vm_after_email .= '<option value="N" selected>'.$lh->translationFor("go_no").'</option>';
}else{
$delete_vm_after_email .= '<option value="N" > '.$lh->translationFor("go_no").'</option>';
}
echo $delete_vm_after_email;
?>
</select>
</div>
</div>
<?php
// Check if Voicemail Greeting is Enabled
$vg_result = $api->API_getSystemSettingInfo();
$vg_system_value = $vg_result->data->allow_voicemail_greeting;
if($vg_system_value){
?>
<div class="form-group">
<label for="voicemail_greeting" class="col-sm-3 control-label"><?php $lh->translateText("voicemail_greeting"); ?></label>
<div class="col-sm-9 mb">
<div class="input-group">
<input type="text" class="form-control" class="" id="voicemail_greeting" name="voicemail_greeting" value="<?php if ($output->data->voicemail_greeting == NULL )echo "sip-silence"; else echo $output->data->voicemail_greeting;?>">
<span class="input-group-btn">
<button class="btn btn-default show_voicemail_greeting" type="button"><?php $lh->translateText("audio_chooser"); ?></button>
</span>
</div><!-- /input-group -->
<div class="row col-sm-12 select_voicemail_greeting">
<select class="form-control select2" id="select_voicemail_greeting" style="width:100%;">
<option value="sip-silence"><?php $lh->translateText("default"); ?></option>
<?php
$voicemail_greeting = NULL;
for($x=0; $x < count($voicefiles->file_name);$x++) {
$this_file_name = preg_replace("/\.(wav|mp3)$/", "", $voicefiles->file_name[$x]);
if ($output->data->voicemail_greeting == $this_file_name) {
$voicemail_greeting .= '<option value="'.$this_file_name.'" selected> '.$this_file_name.' </option>';
} else {
$voicemail_greeting .= '<option value="'.$this_file_name.'"> '.$this_file_name.' </option>';
}
}
echo $voicemail_greeting;
?>
</select>
</div>
</div>
</div>
<?php
}
// End of Voicemail Greeting
?>
<div class="form-group">
<label class="col-sm-3 control-label"><?php $lh->translateText("new_message"); ?></label>
<span style="padding-left:20px; font-size: 20;"><?php echo $output->data->messages;?></span>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><?php $lh->translateText("old_message"); ?></label>
<span style="padding-left:20px; font-size: 20;"><?php echo $output->data->old_messages;?></span>
</div>
</fieldset>
</div><!-- end tab1 -->
<!-- FOOTER BUTTONS -->
<fieldset class="footer-buttons">
<div class="box-footer">
<div class="col-sm-3 pull-right">
<a href="settingsvoicemails.php" type="button" id="cancel" class="btn btn-danger"><i class="fa fa-close"></i> <?php $lh->translateText("cancel"); ?></a>
<button type="submit" class="btn btn-primary" id="modifyVoicemailOkButton" href=""> <span id="update_button"><i class="fa fa-check"></i> <?php $lh->translateText("update"); ?></span></button>
</div>
</div>
</fieldset>
</div><!-- end of tab content -->
</div><!-- tab panel -->
</form>
</div><!-- body -->
</div>
</section>
<?php
}
?>
<!-- /.content -->
</aside><!-- /.right-side -->
<?php print $ui->getRightSidebar($user->getUserId(), $user->getUserName(), $user->getUserAvatar()); ?>
</div><!-- ./wrapper -->
<!-- Modal Dialogs -->
<?php print $ui->standardizedThemeJS(); ?>
<?php include_once "./php/ModalPasswordDialogs.php" ?>
<script type="text/javascript">
$(document).ready(function() {
$('.select').select2({ theme: 'bootstrap' });
$.fn.select2.defaults.set( "theme", "bootstrap" );
// Voicemail greeting
$('.select_voicemail_greeting').hide();
$('.show_voicemail_greeting').on('click', function(event) {
$('.select_voicemail_greeting').toggle('show');
});
$(document).on('change', '#select_voicemail_greeting',function() {
var val = $(this).val();
$('#voicemail_greeting').val(val);
$('.select_voicemail_greeting').toggle('hide');
});
// for cancelling
$(document).on('click', '#cancel', function(){
swal("<?php $lh->translateText("cancelled"); ?>", "<?php $lh->translateText("cancel_msg"); ?>", "error");
});
/**
* Modifies a telephony list
*/
$("#modifyform").validate({
submitHandler: function() {
//submit the form
$('#update_button').html("<i class='fa fa-edit'></i> <?php $lh->translateText("updating"); ?>");
$('#modifyVoicemailOkButton').prop("disabled", true);
$("#resultmessage").html();
$("#resultmessage").fadeOut();
$.post("./php/ModifySettingsVoicemail.php", //post
$("#modifyform").serialize(),
function(data){
//if message is sent
if (data == 1) {
swal("<?php $lh->translateText("success"); ?>", "<?php $lh->translateText("voicemail_modify_success"); ?>", "success");
window.setTimeout(function(){location.replace("settingsvoicemails.php")},2000)
$('#update_button').html("<i class='fa fa-check'></i> <?php $lh->translateText("update"); ?>");
$('#modifyVoicemailOkButton').prop("disabled", false);
} else {
sweetAlert("<?php $lh->translateText("oups"); ?>", "<?php $lh->translateText("something_went_wrong"); ?>"+data, "error");
$('#update_button').html("<i class='fa fa-check'></i> <?php $lh->translateText("update"); ?>");
$('#modifyVoicemailOkButton').prop("disabled", false);
}
//
});
return false; //don't let the form refresh the page...
}
});
});
</script>
<?php print $ui->creamyFooter(); ?>
</body>
</html>