Call Flow - Edit: Add playback of selected Sound & Alternate Sound (Recordings and Sounds).
This commit is contained in:
parent
548ea55660
commit
22756de281
|
|
@ -368,151 +368,9 @@
|
|||
//set the defaults
|
||||
if (empty($call_flow_enabled)) { $call_flow_enabled = 'true'; }
|
||||
|
||||
//get the recordings
|
||||
$sql = "select recording_name, recording_filename from v_recordings ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "order by recording_name asc ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$recordings = $database->select($sql, $parameters, 'all');
|
||||
unset($parameters, $sql);
|
||||
|
||||
if (if_group("superadmin")) {
|
||||
echo "<script>\n";
|
||||
echo "var Objs;\n";
|
||||
echo "\n";
|
||||
echo "function changeToInput(obj){\n";
|
||||
echo " tb=document.createElement('INPUT');\n";
|
||||
echo " tb.type='text';\n";
|
||||
echo " tb.name=obj.name;\n";
|
||||
echo " tb.setAttribute('class', 'formfld');\n";
|
||||
//echo " tb.setAttribute('style', 'width: 380px;');\n";
|
||||
echo " tb.value=obj.options[obj.selectedIndex].value;\n";
|
||||
echo " tbb=document.createElement('INPUT');\n";
|
||||
echo " tbb.setAttribute('class', 'btn');\n";
|
||||
echo " tbb.setAttribute('style', 'margin-left: 4px;');\n";
|
||||
echo " tbb.type='button';\n";
|
||||
echo " tbb.value=$('<div />').html('◁').text();\n";
|
||||
echo " tbb.objs=[obj,tb,tbb];\n";
|
||||
echo " tbb.onclick=function(){ Replace(this.objs); }\n";
|
||||
echo " obj.parentNode.insertBefore(tb,obj);\n";
|
||||
echo " obj.parentNode.insertBefore(tbb,obj);\n";
|
||||
echo " obj.parentNode.removeChild(obj);\n";
|
||||
echo "}\n";
|
||||
echo "\n";
|
||||
echo "function Replace(obj){\n";
|
||||
echo " obj[2].parentNode.insertBefore(obj[0],obj[2]);\n";
|
||||
echo " obj[0].parentNode.removeChild(obj[1]);\n";
|
||||
echo " obj[0].parentNode.removeChild(obj[2]);\n";
|
||||
echo "}\n";
|
||||
echo "</script>\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
function sound_select_list($var, $name, $description_name, $load_sound=false) {
|
||||
global $text, $recordings, $db;
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
|
||||
echo " ".$text['label-' . $description_name]."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
|
||||
echo "<select name='".escape($name)."' class='formfld' ".((if_group("superadmin")) ? "onchange='changeToInput(this);'" : null).">\n";
|
||||
echo " <option value=''></option>\n";
|
||||
//misc optgroup
|
||||
if (if_group("superadmin")) {
|
||||
echo "<optgroup label=".$text['miscellaneous'].">\n";
|
||||
echo " <option value='say:'>say:</option>\n";
|
||||
echo " <option value='tone_stream:'>tone_stream:</option>\n";
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
//recordings
|
||||
$tmp_selected = false;
|
||||
if (!empty($recordings)) {
|
||||
echo "<optgroup label=".$text['recordings'].">\n";
|
||||
foreach ($recordings as &$row) {
|
||||
$recording_name = $row["recording_name"];
|
||||
$recording_filename = $row["recording_filename"];
|
||||
if ($var == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename && !empty($var)) {
|
||||
$tmp_selected = true;
|
||||
echo " <option value='".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".escape($recording_filename)."' selected='selected'>".escape($recording_name)."</option>\n";
|
||||
}
|
||||
else if ($var == $recording_filename && !empty($var)) {
|
||||
$tmp_selected = true;
|
||||
echo " <option value='".escape($recording_filename)."' selected='selected'>".escape($recording_name)."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='".escape($recording_filename)."'>".escape($recording_name)."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
//phrases
|
||||
$sql = "select * from v_phrases where domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
unset($parameters, $sql);
|
||||
if (!empty($result)) {
|
||||
echo "<optgroup label='Phrases'>\n";
|
||||
foreach ($result as &$row) {
|
||||
if ($var == "phrase:".$row["phrase_uuid"]) {
|
||||
$tmp_selected = true;
|
||||
echo " <option value='phrase:".escape($row["phrase_uuid"])."' selected='selected'>".escape($row["phrase_name"])."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='phrase:".escape($row["phrase_uuid"])."'>".escape($row["phrase_name"])."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
//sounds
|
||||
if ($load_sound) {
|
||||
$file = new file;
|
||||
$sound_files = $file->sounds();
|
||||
if (!empty($sound_files)) {
|
||||
echo "<optgroup label=".$text["sounds"].">\n";
|
||||
foreach ($sound_files as $value) {
|
||||
if (!empty($value)) {
|
||||
if (substr($var, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") {
|
||||
$var = substr($var, 71);
|
||||
}
|
||||
if ($var == $value) {
|
||||
$tmp_selected = true;
|
||||
echo " <option value='".escape($value)."' selected='selected'>".escape($value)."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='".escape($value)."'>".escape($value)."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
}
|
||||
//select
|
||||
if (if_group("superadmin")) {
|
||||
if (!$tmp_selected && !empty($var)) {
|
||||
echo "<optgroup label='Selected'>\n";
|
||||
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$var)) {
|
||||
echo " <option value='".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".escape($var)."' selected='selected'>".escape($var)."</option>\n";
|
||||
}
|
||||
else if (substr($var, -3) == "wav" || substr($var, -3) == "mp3") {
|
||||
echo " <option value='".escape($var)."' selected='selected'>".escape($var)."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='".escape($var)."' selected='selected'>".escape($var)."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
unset($tmp_selected);
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo " <br />\n";
|
||||
echo $text['description-' . $description_name]."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
//get the sounds
|
||||
$sounds = new sounds;
|
||||
$audio_files = $sounds->get();
|
||||
|
||||
//create token
|
||||
$object = new token;
|
||||
|
|
@ -523,6 +381,73 @@
|
|||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
if (permission_exists('recording_play') || permission_exists('recording_download')) {
|
||||
echo "<script type='text/javascript' language='JavaScript'>\n";
|
||||
echo " function set_playable(id, audio_selected, audio_type) {\n";
|
||||
echo " file_ext = audio_selected.split('.').pop();\n";
|
||||
echo " var mime_type = '';\n";
|
||||
echo " switch (file_ext) {\n";
|
||||
echo " case 'wav': mime_type = 'audio/wav'; break;\n";
|
||||
echo " case 'mp3': mime_type = 'audio/mpeg'; break;\n";
|
||||
echo " case 'ogg': mime_type = 'audio/ogg'; break;\n";
|
||||
echo " }\n";
|
||||
echo " if (mime_type != '' && (audio_type == 'recordings' || audio_type == 'sounds')) {\n";
|
||||
echo " if (audio_type == 'recordings') {\n";
|
||||
echo " $('#recording_audio_' + id).attr('src', '../recordings/recordings.php?action=download&type=rec&filename=' + audio_selected);\n";
|
||||
echo " }\n";
|
||||
echo " else if (audio_type == 'sounds') {\n";
|
||||
echo " $('#recording_audio_' + id).attr('src', '../switch/sounds.php?action=download&filename=' + audio_selected);\n";
|
||||
echo " }\n";
|
||||
echo " $('#recording_audio_' + id).attr('type', mime_type);\n";
|
||||
echo " $('#recording_button_' + id).show();\n";
|
||||
echo " }\n";
|
||||
echo " else {\n";
|
||||
echo " $('#recording_button_' + id).hide();\n";
|
||||
echo " $('#recording_audio_' + id).attr('src','').attr('type','');\n";
|
||||
echo " }\n";
|
||||
echo " }\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
if (if_group("superadmin")) {
|
||||
echo "<script type='text/javascript' language='JavaScript'>\n";
|
||||
echo " var objs;\n";
|
||||
echo " function toggle_select_input(obj, instance_id){\n";
|
||||
echo " tb=document.createElement('INPUT');\n";
|
||||
echo " tb.type='text';\n";
|
||||
echo " tb.name=obj.name;\n";
|
||||
echo " tb.className='formfld';\n";
|
||||
echo " tb.setAttribute('id', instance_id);\n";
|
||||
echo " tb.setAttribute('style', 'width: ' + obj.offsetWidth + 'px;');\n";
|
||||
if (!empty($on_change)) {
|
||||
echo " tb.setAttribute('onchange', \"".$on_change."\");\n";
|
||||
echo " tb.setAttribute('onkeyup', \"".$on_change."\");\n";
|
||||
}
|
||||
echo " tb.value=obj.options[obj.selectedIndex].value;\n";
|
||||
echo " document.getElementById('btn_select_to_input_' + instance_id).style.display = 'none';\n";
|
||||
echo " tbb=document.createElement('INPUT');\n";
|
||||
echo " tbb.setAttribute('class', 'btn');\n";
|
||||
echo " tbb.setAttribute('style', 'margin-left: 4px;');\n";
|
||||
echo " tbb.type='button';\n";
|
||||
echo " tbb.value=$('<div />').html('◁').text();\n";
|
||||
echo " tbb.objs=[obj,tb,tbb];\n";
|
||||
echo " tbb.onclick=function(){ replace_element(this.objs, instance_id); }\n";
|
||||
echo " obj.parentNode.insertBefore(tb,obj);\n";
|
||||
echo " obj.parentNode.insertBefore(tbb,obj);\n";
|
||||
echo " obj.parentNode.removeChild(obj);\n";
|
||||
echo " replace_element(this.objs, instance_id);\n";
|
||||
echo " }\n";
|
||||
echo " function replace_element(obj, instance_id){\n";
|
||||
echo " obj[2].parentNode.insertBefore(obj[0],obj[2]);\n";
|
||||
echo " obj[0].parentNode.removeChild(obj[1]);\n";
|
||||
echo " obj[0].parentNode.removeChild(obj[2]);\n";
|
||||
echo " document.getElementById('btn_select_to_input_' + instance_id).style.display = 'inline';\n";
|
||||
if (!empty($on_change)) {
|
||||
echo " ".$on_change.";\n";
|
||||
}
|
||||
echo " }\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
|
||||
echo "<form name='frm' id='frm' method='post'>\n";
|
||||
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
|
|
@ -636,20 +561,64 @@
|
|||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
sound_select_list($call_flow_sound, 'call_flow_sound', 'call_flow_sound', true);
|
||||
|
||||
/*
|
||||
$instance_id = 'call_flow_sound';
|
||||
$instance_label = 'call_flow_sound';
|
||||
$instance_value = $call_flow_sound;
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-call_flow_sound']."\n";
|
||||
echo "<td class='vncell' rowspan='2' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-'.$instance_label]."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable playback_progress_bar_background' id='recording_progress_bar_".$instance_id."' style='display: none; border-bottom: none; padding-top: 0 !important; padding-bottom: 0 !important;' align='left'><span class='playback_progress_bar' id='recording_progress_".$instance_id."'></span></td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='call_flow_sound' maxlength='255' value=\"".escape($call_flow_sound)."\">\n";
|
||||
echo "<select name='".$instance_id."' id='".$instance_id."' class='formfld' ".(permission_exists('recording_play') || permission_exists('recording_download') ? "onchange=\"recording_reset('".$instance_id."'); set_playable('".$instance_id."', this.value, this.options[this.selectedIndex].parentNode.getAttribute('data-type'));\"" : null).">\n";
|
||||
echo " <option value=''></option>\n";
|
||||
$found = $playable = false;
|
||||
if (!empty($audio_files) && is_array($audio_files) && @sizeof($audio_files) != 0) {
|
||||
foreach ($audio_files as $key => $value) {
|
||||
echo "<optgroup label=".$text['label-'.$key]." data-type='".$key."'>\n";
|
||||
foreach ($value as $row) {
|
||||
if (!empty($instance_value) && $instance_value == $row["value"]) {
|
||||
$selected = "selected='selected'";
|
||||
if ($key == 'recordings') {
|
||||
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"];
|
||||
}
|
||||
else if ($key == 'sounds') {
|
||||
$playable = '../switch/sounds.php?action=download&filename='.$row["value"];
|
||||
}
|
||||
$found = true;
|
||||
}
|
||||
else {
|
||||
unset($selected);
|
||||
}
|
||||
echo " <option value='".escape($row["value"])."' ".($selected ?? '').">".escape($row["name"])."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
}
|
||||
if (if_group("superadmin") && !empty($instance_value) && !$found) {
|
||||
echo " <option value='".escape($instance_value)."' selected='selected'>".escape($instance_value)."</option>\n";
|
||||
}
|
||||
unset($selected);
|
||||
echo " </select>\n";
|
||||
if (if_group("superadmin")) {
|
||||
echo "<input type='button' id='btn_select_to_input_".$instance_id."' class='btn' name='' alt='back' onclick='toggle_select_input(document.getElementById(\"".$instance_id."\"), \"".$instance_id."\"); this.style.visibility=\"hidden\";' value='◁'>";
|
||||
}
|
||||
if ((permission_exists('recording_play') || permission_exists('recording_download')) && !empty($playable)) {
|
||||
switch (pathinfo($playable, PATHINFO_EXTENSION)) {
|
||||
case 'wav' : $mime_type = 'audio/wav'; break;
|
||||
case 'mp3' : $mime_type = 'audio/mpeg'; break;
|
||||
case 'ogg' : $mime_type = 'audio/ogg'; break;
|
||||
}
|
||||
}
|
||||
echo "<audio id='recording_audio_".$instance_id."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$instance_id."')\" onended=\"recording_reset('".$instance_id."');\" src='".($playable ?? '')."' type='".($mime_type ?? '')."'></audio>";
|
||||
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."')"]);
|
||||
unset($playable, $mime_type);
|
||||
echo "<br />\n";
|
||||
echo $text['description-call_flow_sound']."\n";
|
||||
echo $text['description-'.$instance_label]."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
*/
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
|
|
@ -680,20 +649,64 @@
|
|||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
sound_select_list($call_flow_alternate_sound, 'call_flow_alternate_sound', 'call_flow_alternate_sound', true);
|
||||
|
||||
/*
|
||||
$instance_id = 'call_flow_alternate_sound';
|
||||
$instance_label = 'call_flow_alternate_sound';
|
||||
$instance_value = $call_flow_alternate_sound;
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-call_flow_alternate_sound']."\n";
|
||||
echo "<td class='vncell' rowspan='2' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-'.$instance_label]."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable playback_progress_bar_background' id='recording_progress_bar_".$instance_id."' style='display: none; border-bottom: none; padding-top: 0 !important; padding-bottom: 0 !important;' align='left'><span class='playback_progress_bar' id='recording_progress_".$instance_id."'></span></td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='call_flow_alternate_sound' maxlength='255' value=\"".escape($call_flow_alternate_sound)."\">\n";
|
||||
echo "<select name='".$instance_id."' id='".$instance_id."' class='formfld' ".(permission_exists('recording_play') || permission_exists('recording_download') ? "onchange=\"recording_reset('".$instance_id."'); set_playable('".$instance_id."', this.value, this.options[this.selectedIndex].parentNode.getAttribute('data-type'));\"" : null).">\n";
|
||||
echo " <option value=''></option>\n";
|
||||
$found = $playable = false;
|
||||
if (!empty($audio_files) && is_array($audio_files) && @sizeof($audio_files) != 0) {
|
||||
foreach ($audio_files as $key => $value) {
|
||||
echo "<optgroup label=".$text['label-'.$key]." data-type='".$key."'>\n";
|
||||
foreach ($value as $row) {
|
||||
if (!empty($instance_value) && $instance_value == $row["value"]) {
|
||||
$selected = "selected='selected'";
|
||||
if ($key == 'recordings') {
|
||||
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.$row["value"];
|
||||
}
|
||||
else if ($key == 'sounds') {
|
||||
$playable = '../switch/sounds.php?action=download&filename='.$row["value"];
|
||||
}
|
||||
$found = true;
|
||||
}
|
||||
else {
|
||||
unset($selected);
|
||||
}
|
||||
echo " <option value='".escape($row["value"])."' ".($selected ?? '').">".escape($row["name"])."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
}
|
||||
if (if_group("superadmin") && !empty($instance_value) && !$found) {
|
||||
echo " <option value='".escape($instance_value)."' selected='selected'>".escape($instance_value)."</option>\n";
|
||||
}
|
||||
unset($selected);
|
||||
echo " </select>\n";
|
||||
if (if_group("superadmin")) {
|
||||
echo "<input type='button' id='btn_select_to_input_".$instance_id."' class='btn' name='' alt='back' onclick='toggle_select_input(document.getElementById(\"".$instance_id."\"), \"".$instance_id."\"); this.style.visibility=\"hidden\";' value='◁'>";
|
||||
}
|
||||
if ((permission_exists('recording_play') || permission_exists('recording_download')) && !empty($playable)) {
|
||||
switch (pathinfo($playable, PATHINFO_EXTENSION)) {
|
||||
case 'wav' : $mime_type = 'audio/wav'; break;
|
||||
case 'mp3' : $mime_type = 'audio/mpeg'; break;
|
||||
case 'ogg' : $mime_type = 'audio/ogg'; break;
|
||||
}
|
||||
}
|
||||
echo "<audio id='recording_audio_".$instance_id."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$instance_id."')\" onended=\"recording_reset('".$instance_id."');\" src='".($playable ?? '')."' type='".($mime_type ?? '')."'></audio>";
|
||||
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."')"]);
|
||||
unset($playable, $mime_type);
|
||||
echo "<br />\n";
|
||||
echo $text['description-call_flow_alternate_sound']."\n";
|
||||
echo $text['description-'.$instance_label]."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
*/
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue