Update Call Broadcast

This commit is contained in:
Nate 2019-09-10 14:04:30 -06:00
parent d0226b3fc7
commit f943254593
3 changed files with 124 additions and 89 deletions

View File

@ -321,6 +321,46 @@ $text['label-accountcode']['ru-ru'] = "Код Авторизации";
$text['label-accountcode']['sv-se'] = "Accountcode"; $text['label-accountcode']['sv-se'] = "Accountcode";
$text['label-accountcode']['uk-ua'] = "Код облікового запису"; $text['label-accountcode']['uk-ua'] = "Код облікового запису";
$text['label-sample_file']['en-us'] = "Sample CSV File";
$text['label-sample_file']['ar-eg'] = "Sample CSV File";
$text['label-sample_file']['de-at'] = "Sample CSV File";
$text['label-sample_file']['de-ch'] = "Sample CSV File";
$text['label-sample_file']['de-de'] = "Sample CSV File";
$text['label-sample_file']['es-cl'] = "Sample CSV File";
$text['label-sample_file']['es-mx'] = "Sample CSV File";
$text['label-sample_file']['fr-ca'] = "Sample CSV File";
$text['label-sample_file']['fr-fr'] = "Sample CSV File";
$text['label-sample_file']['he-il'] = "Sample CSV File";
$text['label-sample_file']['it-it'] = "Sample CSV File";
$text['label-sample_file']['nl-nl'] = "Sample CSV File";
$text['label-sample_file']['pl-pl'] = "Sample CSV File";
$text['label-sample_file']['pt-br'] = "Sample CSV File";
$text['label-sample_file']['pt-pt'] = "Sample CSV File";
$text['label-sample_file']['ro-ro'] = "Sample CSV File";
$text['label-sample_file']['ru-ru'] = "Sample CSV File";
$text['label-sample_file']['sv-se'] = "Sample CSV File";
$text['label-sample_file']['uk-ua'] = "Sample CSV File";
$text['label-list_example']['en-us'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['ar-eg'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['de-at'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['de-ch'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['de-de'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['es-cl'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['es-mx'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['fr-ca'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['fr-fr'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['he-il'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['it-it'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['nl-nl'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['pl-pl'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['pt-br'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['pt-pt'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['ro-ro'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['ru-ru'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['sv-se'] = "Number|First,Last\nNumber|First,Last\n...";
$text['label-list_example']['uk-ua'] = "Number|First,Last\nNumber|First,Last\n...";
$text['description-timeout']['en-us'] = "Specify the absolute timeout in seconds."; $text['description-timeout']['en-us'] = "Specify the absolute timeout in seconds.";
$text['description-timeout']['ar-eg'] = ""; $text['description-timeout']['ar-eg'] = "";
$text['description-timeout']['de-at'] = "Geben Sie die absolute Zeitüberschreitung in Sekunden an."; //copied from de-de $text['description-timeout']['de-at'] = "Geben Sie die absolute Zeitüberschreitung in Sekunden an."; //copied from de-de
@ -341,25 +381,25 @@ $text['description-timeout']['ru-ru'] = "Время ожидания (в мил
$text['description-timeout']['sv-se'] = "Specificera den absoluta timeout:en i sekunder."; $text['description-timeout']['sv-se'] = "Specificera den absoluta timeout:en i sekunder.";
$text['description-timeout']['uk-ua'] = ""; $text['description-timeout']['uk-ua'] = "";
$text['description-phone']['en-us'] = "Optional, set a list of phone numbers one per row in the following format: 123-123-1234|Last Name, First Name"; $text['description-phone']['en-us'] = "Select a TXT/CSV file for upload, or enter Phone Numbers one per line in the format shown above.";
$text['description-phone']['ar-eg'] = ""; $text['description-phone']['ar-eg'] = "";
$text['description-phone']['de-at'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname, Vorname"; //copied from de-de $text['description-phone']['de-at'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname,Vorname"; //copied from de-de
$text['description-phone']['de-ch'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname, Vorname"; //copied from de-de $text['description-phone']['de-ch'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname,Vorname"; //copied from de-de
$text['description-phone']['de-de'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname, Vorname"; $text['description-phone']['de-de'] = "Optional: Ergänzen Sie eine Liste von Telefonnummern, eine Nummer pro Zeile im folgenden Format: 123-123-1234|Nachname,Vorname";
$text['description-phone']['es-cl'] = "Opcional, definir una lista de números de telefono, uno por línea en el siguiente formato:  123-123-1234 | Apellido, Nombre"; $text['description-phone']['es-cl'] = "Opcional, definir una lista de números de telefono, uno por línea en el siguiente formato: 123-123-1234|Apellido,Nombre";
$text['description-phone']['es-mx'] = "Opcional, definir una lista de números de telefono, uno por línea en el siguiente formato:  123-123-1234 | Apellido, Nombre"; //copied from es-cl $text['description-phone']['es-mx'] = "Opcional, definir una lista de números de telefono, uno por línea en el siguiente formato: 123-123-1234|Apellido,Nombre"; //copied from es-cl
$text['description-phone']['fr-ca'] = "Optionnel, Insérer une liste de numéros de téléphone, un par ligne, dans le format suivant ; 0123456789 | Nom, Prénom"; //copied from fr-fr $text['description-phone']['fr-ca'] = "Optionnel, Insérer une liste de numéros de téléphone, un par ligne, dans le format suivant ; 0123456789|Nom,Prénom"; //copied from fr-fr
$text['description-phone']['fr-fr'] = "Optionnel, Insérer une liste de numéros de téléphone, un par ligne, dans le format suivant ; 0123456789 | Nom, Prénom"; $text['description-phone']['fr-fr'] = "Optionnel, Insérer une liste de numéros de téléphone, un par ligne, dans le format suivant ; 0123456789|Nom,Prénom";
$text['description-phone']['he-il'] = ""; $text['description-phone']['he-il'] = "";
$text['description-phone']['it-it'] = "Opzionale, inserire una lista di numeri di telefono, uno per riga, nel formato 123-123-1234|Cognome, Nome"; $text['description-phone']['it-it'] = "Opzionale, inserire una lista di numeri di telefono, uno per riga, nel formato 123-123-1234|Cognome,Nome";
$text['description-phone']['nl-nl'] = ""; $text['description-phone']['nl-nl'] = "";
$text['description-phone']['pl-pl'] = "Opcjonalne - ułóż listę numerów (jeden pod drugim) w formacie: 123-123-1234|Nazwisko, Imię"; $text['description-phone']['pl-pl'] = "Opcjonalne - ułóż listę numerów (jeden pod drugim) w formacie: 123-123-1234|Nazwisko,Imię";
$text['description-phone']['pt-br'] = "Opcional, definir uma lista de números de telefone, um por linha, no seguinte formato: 210000000 | Apelido, Primeiro Nome."; $text['description-phone']['pt-br'] = "Opcional, definir uma lista de números de telefone, um por linha, no seguinte formato: 210000000|Apelido,Primeiro Nome.";
$text['description-phone']['pt-pt'] = "Opcional, definir uma lista de números de telefone, um por linha, no seguinte formato: 210000000 | Apelido, Primeiro Nome"; $text['description-phone']['pt-pt'] = "Opcional, definir uma lista de números de telefone, um por linha, no seguinte formato: 210000000|Apelido,Primeiro Nome";
$text['description-phone']['ro-ro'] = ""; $text['description-phone']['ro-ro'] = "";
$text['description-phone']['ru-ru'] = "Дополнительно, задайте список телефонных номеров, по одному в ряд, в формате: 123-123-1234 | Фамилия, Имя"; $text['description-phone']['ru-ru'] = "Дополнительно, задайте список телефонных номеров, по одному в ряд, в формате: 123-123-1234|Фамилия,Имя";
$text['description-phone']['sv-se'] = "Frivillig, fyll i en lista med nummer (ett per rad) i följande format: 123-123-1234|Efternamn, Förnamn"; $text['description-phone']['sv-se'] = "Frivillig, fyll i en lista med nummer (ett per rad) i följande format: 123-123-1234|Efternamn,Förnamn";
$text['description-phone']['uk-ua'] = "Додатково, задайте список телефонних номерів по одному на рядок в наступному форматі: 123-123-1234 | Прізвище, ім'я"; $text['description-phone']['uk-ua'] = "Додатково, задайте список телефонних номерів по одному на рядок в наступному форматі: 123-123-1234|Прізвище,ім'я";
$text['description-name']['en-us'] = "Enter the name here."; $text['description-name']['en-us'] = "Enter the name here.";
$text['description-name']['ar-eg'] = ""; $text['description-name']['ar-eg'] = "";

View File

@ -59,19 +59,19 @@
$filename=$_FILES["broadcast_phone_numbers_file"]["tmp_name"]; $filename=$_FILES["broadcast_phone_numbers_file"]["tmp_name"];
$file_extension = array('application/octet-stream','application/vnd.ms-excel','text/plain','text/csv','text/tsv'); $file_extension = array('application/octet-stream','application/vnd.ms-excel','text/plain','text/csv','text/tsv');
if (in_array($_FILES['broadcast_phone_numbers_file']['type'],$file_extension)) { if (in_array($_FILES['broadcast_phone_numbers_file']['type'],$file_extension)) {
$file = fopen($filename, "r"); $file = fopen($filename, "r");
$count = 0; $count = 0;
while (($getData = fgetcsv($file, 0, "\n")) !== FALSE) while (($getData = fgetcsv($file, 0, "\n")) !== FALSE)
{ {
$count++; $count++;
if ($count == 1) { continue; } if ($count == 1) { continue; }
$getData = preg_split('/[ ,|]/', $getData[0], null, PREG_SPLIT_NO_EMPTY); $getData = preg_split('/[ ,|]/', $getData[0], null, PREG_SPLIT_NO_EMPTY);
$separator = $getData[0]; $separator = $getData[0];
$separator .= (isset($getData[1]) && $getData[1] != '')? '|'.$getData[1] : ''; $separator .= (isset($getData[1]) && $getData[1] != '')? '|'.$getData[1] : '';
$separator .= (isset($getData[2]) && $getData[2] != '')? ','.$getData[2] : ''; $separator .= (isset($getData[2]) && $getData[2] != '')? ','.$getData[2] : '';
$separator .= '\n'; $separator .= '\n';
$upload_csv .= $separator; $upload_csv .= $separator;
} }
fclose($file); fclose($file);
} }
else { else {
@ -79,15 +79,13 @@
} }
} }
if (!empty($broadcast_phone_numbers) && !empty($upload_csv)) { if (!empty($broadcast_phone_numbers) && !empty($upload_csv)) {
$sql .= "E'";
$sql .= $broadcast_phone_numbers.'\n'.$upload_csv; $sql .= $broadcast_phone_numbers.'\n'.$upload_csv;
$sql .= "',";
} }
elseif (empty($broadcast_phone_numbers) && !empty($upload_csv)) { elseif (empty($broadcast_phone_numbers) && !empty($upload_csv)) {
$sql .= "E'$upload_csv', "; $sql .= $upload_csv;
} }
else { else {
$sql .= "E'$broadcast_phone_numbers', "; $sql .= $broadcast_phone_numbers;
} }
return array('code'=>true,'sql'=> $sql); return array('code'=>true,'sql'=> $sql);
} }
@ -270,8 +268,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " <input type='button' class='btn' name='back' alt='".$text['button-back']."' onclick=\"window.location='call_broadcast.php'\" value='".$text['button-back']."'>\n"; echo " <input type='button' class='btn' name='back' alt='".$text['button-back']."' onclick=\"window.location='call_broadcast.php'\" value='".$text['button-back']."'>\n";
if ($action == "update") { if ($action == "update") {
echo "<input type='hidden' name='call_broadcast_uuid' value='".escape($call_broadcast_uuid)."'>\n"; echo "<input type='hidden' name='call_broadcast_uuid' value='".escape($call_broadcast_uuid)."'>\n";
echo "<input type='button' class='btn' name='' alt='".$text['button-send']."' onclick=\"window.location='call_broadcast_send.php?id=".escape($call_broadcast_uuid)."'\" value='".$text['button-send']."'>\n"; echo "<input type='button' class='btn' name='' alt='".$text['button-send']."' onclick=\"window.location='call_broadcast_send.php?id=".urlencode($call_broadcast_uuid)."'\" value='".$text['button-send']."'>\n";
echo "<input type='button' class='btn' name='' alt='".$text['button-stop']."' onclick=\"window.location='call_broadcast_stop.php?id=".escape($call_broadcast_uuid)."'\" value='".$text['button-stop']."'>\n"; echo "<input type='button' class='btn' name='' alt='".$text['button-stop']."' onclick=\"window.location='call_broadcast_stop.php?id=".urlencode($call_broadcast_uuid)."'\" value='".$text['button-stop']."'>\n";
} }
echo " <input type='submit' class='btn' name='submit' value='".$text['button-save']."'>\n"; echo " <input type='submit' class='btn' name='submit' value='".$text['button-save']."'>\n";
echo "</td>\n"; echo "</td>\n";
@ -455,16 +453,11 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <textarea class='formfld' type='text' name='broadcast_phone_numbers' rows='10'>".$broadcast_phone_numbers."</textarea>"; echo " <textarea class='formfld' style='width: 300px; height: 200px;' type='text' name='broadcast_phone_numbers' placeholder=\"".$text['label-list_example']."\">".str_replace('\n', "\n", $broadcast_phone_numbers)."</textarea>";
echo "<br>"; echo "<br><br>";
echo " <span class='' style='margin-left: 37px;'>OR </span> "; echo " <input type='file' name='broadcast_phone_numbers_file' accept='.csv,.txt' style=\"display:inline-block;\"><a href='sample.csv' download><i class='fas fa-cloud-download-alt' style='margin-right: 5px;'></i>".$text['label-sample_file']."</a>";
echo "<br>"; echo "<br /><br />";
echo " <input type='file' name='broadcast_phone_numbers_file' accept='.csv,.txt' style=\"display:inline-block;\"><a href='sample.csv' download>Sample File <i class='fas fa-cloud-download-alt'></i></a>";
echo "<br>";
echo " (Upload TXT- Plain Text, CSV- Comma Separated Values file format only.)";
echo "<br>";
echo "<br />\n";
echo "".$text['description-phone']." <br /><br />\n"; echo "".$text['description-phone']." <br /><br />\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";

View File

@ -153,55 +153,57 @@ function cmd_async($cmd) {
//remove the number formatting //remove the number formatting
$phone_1 = preg_replace('{\D}', '', $tmp_value_array[0]); $phone_1 = preg_replace('{\D}', '', $tmp_value_array[0]);
//get the dialplan variables and bridge statement if (is_numeric($phone_1)) {
$dialplan = new dialplan; //get the dialplan variables and bridge statement
$dialplan->domain_uuid = $_SESSION['domain_uuid']; $dialplan = new dialplan;
$dialplan->outbound_routes($phone_1); $dialplan->domain_uuid = $_SESSION['domain_uuid'];
$dialplan_variables = $dialplan->variables; $dialplan->outbound_routes($phone_1);
$bridge_array[0] = $dialplan->bridges; $dialplan_variables = $dialplan->variables;
//echo "var: ".$variables."\n"; $bridge_array[0] = $dialplan->bridges;
//echo "bridges: ".$bridges."\n"; //echo "var: ".$variables."\n";
//echo "bridges: ".$bridges."\n";
//prepare the string //prepare the string
$channel_variables = $dialplan_variables."ignore_early_media=true"; $channel_variables = $dialplan_variables."ignore_early_media=true";
$channel_variables .= ",origination_number=$phone_1"; $channel_variables .= ",origination_number=$phone_1";
$channel_variables .= ",origination_caller_id_name='$broadcast_caller_id_name'"; $channel_variables .= ",origination_caller_id_name='$broadcast_caller_id_name'";
$channel_variables .= ",origination_caller_id_number=$broadcast_caller_id_number"; $channel_variables .= ",origination_caller_id_number=$broadcast_caller_id_number";
$channel_variables .= ",domain_uuid=".$_SESSION['domain_uuid']; $channel_variables .= ",domain_uuid=".$_SESSION['domain_uuid'];
$channel_variables .= ",domain=".$_SESSION['domain_name']; $channel_variables .= ",domain=".$_SESSION['domain_name'];
$channel_variables .= ",domain_name=".$_SESSION['domain_name']; $channel_variables .= ",domain_name=".$_SESSION['domain_name'];
$channel_variables .= ",accountcode='$broadcast_accountcode'"; $channel_variables .= ",accountcode='$broadcast_accountcode'";
if ($broadcast_avmd == "true") { if ($broadcast_avmd == "true") {
$channel_variables .= ",execute_on_answer='avmd start'"; $channel_variables .= ",execute_on_answer='avmd start'";
}
$origination_url = "{".$channel_variables."}".$bridge_array[0];
//get the context
$context = $_SESSION['domain_name'];
//set the command
$cmd = "bgapi sched_api +".$sched_seconds." ".$call_broadcast_uuid." bgapi originate ".$origination_url." ".$broadcast_destination_data." XML $context";
//if the event socket connection is lost then re-connect
if (!$fp) {
$fp = eventsocket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
}
//method 1
$response = trim(event_socket_request($fp, 'api '.$cmd));
//method 2
//cmd_async($_SESSION['switch']['bin']['dir']."/fs_cli -x \"".$cmd."\";");
//spread the calls out so that they are scheduled with different times
if (strlen($broadcast_concurrent_limit) > 0 && strlen($broadcast_timeout) > 0) {
if ($broadcast_concurrent_limit == $count) {
$sched_seconds = $sched_seconds + $broadcast_timeout;
$count=0;
} }
} $origination_url = "{".$channel_variables."}".$bridge_array[0];
$count++; //get the context
$context = $_SESSION['domain_name'];
//set the command
$cmd = "bgapi sched_api +".$sched_seconds." ".$call_broadcast_uuid." bgapi originate ".$origination_url." ".$broadcast_destination_data." XML $context";
//if the event socket connection is lost then re-connect
if (!$fp) {
$fp = eventsocket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
}
//method 1
$response = trim(event_socket_request($fp, 'api '.$cmd));
//method 2
//cmd_async($_SESSION['switch']['bin']['dir']."/fs_cli -x \"".$cmd."\";");
//spread the calls out so that they are scheduled with different times
if (strlen($broadcast_concurrent_limit) > 0 && strlen($broadcast_timeout) > 0) {
if ($broadcast_concurrent_limit == $count) {
$sched_seconds = $sched_seconds + $broadcast_timeout;
$count=0;
}
}
$count++;
}
} }
fclose($fp); fclose($fp);