diff --git a/app/call_block/app_config.php b/app/call_block/app_config.php index 55de7f1379..4d5af2cadc 100644 --- a/app/call_block/app_config.php +++ b/app/call_block/app_config.php @@ -99,6 +99,10 @@ $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary"; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "call_block_direction"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Select the direction of the calls to block."; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "extension_uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; diff --git a/app/call_block/app_defaults.php b/app/call_block/app_defaults.php index 9160edc51e..56c8d4c733 100644 --- a/app/call_block/app_defaults.php +++ b/app/call_block/app_defaults.php @@ -30,8 +30,8 @@ if ($domains_processed == 1) { $database = new database; $database->execute("DROP VIEW view_call_block;", null); $sql = "CREATE VIEW view_call_block AS ( \n"; - $sql .= " select c.domain_uuid, call_block_uuid, c.extension_uuid, call_block_name, call_block_country_code, \n"; - $sql .= " call_block_number, extension, number_alias, call_block_count, call_block_app, call_block_data, date_added, call_block_enabled, call_block_description \n"; + $sql .= " select c.domain_uuid, call_block_uuid, c.call_block_direction, c.extension_uuid, c.call_block_name, c.call_block_country_code, \n"; + $sql .= " c.call_block_number, e.extension, e.number_alias, c.call_block_count, c.call_block_app, c.call_block_data, c.date_added, c.call_block_enabled, c.call_block_description \n"; $sql .= " from v_call_block as c \n"; $sql .= " left join v_extensions as e \n"; $sql .= " on c.extension_uuid = e.extension_uuid \n"; diff --git a/app/call_block/app_languages.php b/app/call_block/app_languages.php index 95d5faff28..eba6287e68 100644 --- a/app/call_block/app_languages.php +++ b/app/call_block/app_languages.php @@ -286,6 +286,48 @@ $text['label-inbound']['ru-ru'] = "Входящий"; $text['label-inbound']['sv-se'] = "Inkommande"; $text['label-inbound']['uk-ua'] = "Вихідний"; +$text['label-outbound']['en-us'] = "Outbound"; +$text['label-outbound']['en-gb'] = "Outbound"; +$text['label-outbound']['ar-eg'] = ""; +$text['label-outbound']['de-at'] = "Ausgehend"; //copied from de-de +$text['label-outbound']['de-ch'] = "Ausgehend"; //copied from de-de +$text['label-outbound']['de-de'] = "Ausgehend"; +$text['label-outbound']['es-cl'] = "Salida"; +$text['label-outbound']['es-mx'] = "Salida"; //copied from es-cl +$text['label-outbound']['fr-ca'] = "Sortant"; //copied from fr-fr +$text['label-outbound']['fr-fr'] = "Sortant"; +$text['label-outbound']['he-il'] = ""; +$text['label-outbound']['it-it'] = "In Uscita"; +$text['label-outbound']['nl-nl'] = ""; +$text['label-outbound']['pl-pl'] = "Wychodzące"; +$text['label-outbound']['pt-br'] = "Saída"; //copied from pt-pt +$text['label-outbound']['pt-pt'] = "Saída"; +$text['label-outbound']['ro-ro'] = ""; +$text['label-outbound']['ru-ru'] = "Исходящие"; +$text['label-outbound']['sv-se'] = "Utgående"; +$text['label-outbound']['uk-ua'] = ""; + +$text['label-destination']['en-us'] = "Destination"; +$text['label-destination']['en-gb'] = "Destination"; +$text['label-destination']['ar-eg'] = ""; +$text['label-destination']['de-at'] = "Ziel"; //copied from de-de +$text['label-destination']['de-ch'] = "Ziel"; //copied from de-de +$text['label-destination']['de-de'] = "Ziel"; +$text['label-destination']['es-cl'] = "Destino"; +$text['label-destination']['es-mx'] = "Destino"; //copied from es-cl +$text['label-destination']['fr-ca'] = "Destination"; //copied from fr-fr +$text['label-destination']['fr-fr'] = "Destination"; +$text['label-destination']['he-il'] = ""; +$text['label-destination']['it-it'] = "Destinazione"; +$text['label-destination']['nl-nl'] = ""; +$text['label-destination']['pl-pl'] = "Numer docelowy"; +$text['label-destination']['pt-br'] = "Número de destino"; +$text['label-destination']['pt-pt'] = "Destino"; +$text['label-destination']['ro-ro'] = ""; +$text['label-destination']['ru-ru'] = "Назначение"; +$text['label-destination']['sv-se'] = "Destination"; +$text['label-destination']['uk-ua'] = "Номер"; + $text['label-edit-note']['en-us'] = "Block calls from a number. Edit the name and enable/disable below."; $text['label-edit-note']['en-gb'] = "Block calls from a number. Edit the name and enable/disable below."; $text['label-edit-note']['ar-eg'] = ""; @@ -440,27 +482,27 @@ $text['label-count']['ru-ru'] = "Количество"; $text['label-count']['sv-se'] = "Räkna"; $text['label-count']['uk-ua'] = "Кількість"; -$text['label-called-on']['en-us'] = "Called on"; -$text['label-called-on']['en-gb'] = "Called on"; -$text['label-called-on']['ar-eg'] = "تم الأتصال علي"; -$text['label-called-on']['de-at'] = "Anruf am"; //copied from de-de -$text['label-called-on']['de-ch'] = "Anruf am"; //copied from de-de -$text['label-called-on']['de-de'] = "Anruf am"; -$text['label-called-on']['el-gr'] = "Η κλήση πραγματοποιήθηκε"; -$text['label-called-on']['es-cl'] = "Llamó en"; -$text['label-called-on']['es-mx'] = "Llamó en"; //copied from es-cl -$text['label-called-on']['fr-ca'] = "Appelé le"; //copied from fr-fr -$text['label-called-on']['fr-fr'] = "Appelé le"; -$text['label-called-on']['he-il'] = "Opgeroepen op"; -$text['label-called-on']['it-it'] = "Chiamato il"; -$text['label-called-on']['nl-nl'] = "Aangeroepen op"; -$text['label-called-on']['pl-pl'] = "Zadzwoniono na"; -$text['label-called-on']['pt-br'] = "Chamada em "; -$text['label-called-on']['pt-pt'] = "Chamado em"; -$text['label-called-on']['ro-ro'] = "Sunat pe"; -$text['label-called-on']['ru-ru'] = "Направление"; -$text['label-called-on']['sv-se'] = "Ringdes på"; -$text['label-called-on']['uk-ua'] = "Дзвінок здійснено"; +$text['label-called']['en-us'] = "Called"; +$text['label-called']['en-gb'] = "Called"; +$text['label-called']['ar-eg'] = "تم الأتصال علي"; +$text['label-called']['de-at'] = "Anruf"; //copied from de-de +$text['label-called']['de-ch'] = "Anruf"; //copied from de-de +$text['label-called']['de-de'] = "Anruf"; +$text['label-called']['el-gr'] = "Η κλήση πραγματοποιήθηκε"; +$text['label-called']['es-cl'] = "Llamó"; +$text['label-called']['es-mx'] = "Llamó"; //copied from es-cl +$text['label-called']['fr-ca'] = "Appelé"; //copied from fr-fr +$text['label-called']['fr-fr'] = "Appelé"; +$text['label-called']['he-il'] = "Opgeroepen"; +$text['label-called']['it-it'] = "Chiamato"; +$text['label-called']['nl-nl'] = "Aangeroepen"; +$text['label-called']['pl-pl'] = "Zadzwoniono"; +$text['label-called']['pt-br'] = "Chamada"; +$text['label-called']['pt-pt'] = "Chamado"; +$text['label-called']['ro-ro'] = "Sunat"; +$text['label-called']['ru-ru'] = "Направление"; +$text['label-called']['sv-se'] = "Ringdes"; +$text['label-called']['uk-ua'] = "Дзвінок здійснено"; $text['label-busy']['en-us'] = "Busy"; $text['label-busy']['en-gb'] = "Busy"; @@ -594,6 +636,49 @@ $text['label-action']['ru-ru'] = "Действие"; $text['label-action']['sv-se'] = "Åtgärd"; $text['label-action']['uk-ua'] = "Дія"; +$text['label-direction']['en-us'] = "Direction"; +$text['label-direction']['en-gb'] = "Direction"; +$text['label-direction']['ar-eg'] = ""; +$text['label-direction']['de-at'] = "Richtung"; //copied from de-de +$text['label-direction']['de-ch'] = "Richtung"; //copied from de-de +$text['label-direction']['de-de'] = "Richtung"; +$text['label-direction']['es-cl'] = "Dirección"; +$text['label-direction']['es-mx'] = "Dirección"; //copied from es-cl +$text['label-direction']['fr-ca'] = "Direction"; //copied from fr-fr +$text['label-direction']['fr-fr'] = "Direction"; +$text['label-direction']['he-il'] = ""; +$text['label-direction']['it-it'] = "Direzione"; +$text['label-direction']['nl-nl'] = ""; +$text['label-direction']['pl-pl'] = "Kierunek"; +$text['label-direction']['pt-br'] = "Direção"; +$text['label-direction']['pt-pt'] = "Direcção"; +$text['label-direction']['ro-ro'] = ""; +$text['label-direction']['ru-ru'] = "Направление"; +$text['label-direction']['sv-se'] = "Riktning"; +$text['label-direction']['uk-ua'] = "Напрям"; + +$text['description-direction']['en-us'] = "Select the direction of the calls to block."; +$text['description-direction']['en-gb'] = "Select the direction of the calls to block."; +$text['description-direction']['ar-eg'] = "Select the direction of the calls to block."; +$text['description-direction']['de-at'] = "Select the direction of the calls to block."; +$text['description-direction']['de-ch'] = "Select the direction of the calls to block."; +$text['description-direction']['de-de'] = "Select the direction of the calls to block."; +$text['description-direction']['el-gr'] = "Select the direction of the calls to block."; +$text['description-direction']['es-cl'] = "Select the direction of the calls to block."; +$text['description-direction']['es-mx'] = "Select the direction of the calls to block."; +$text['description-direction']['fr-ca'] = "Select the direction of the calls to block."; +$text['description-direction']['fr-fr'] = "Select the direction of the calls to block."; +$text['description-direction']['he-il'] = "Select the direction of the calls to block."; +$text['description-direction']['it-it'] = "Select the direction of the calls to block."; +$text['description-direction']['nl-nl'] = "Select the direction of the calls to block."; +$text['description-direction']['pl-pl'] = "Select the direction of the calls to block."; +$text['description-direction']['pt-br'] = "Select the direction of the calls to block."; +$text['description-direction']['pt-pt'] = "Select the direction of the calls to block."; +$text['description-direction']['ro-ro'] = "Select the direction of the calls to block."; +$text['description-direction']['ru-ru'] = "Select the direction of the calls to block."; +$text['description-direction']['sv-se'] = "Select the direction of the calls to block."; +$text['description-direction']['uk-ua'] = "Select the direction of the calls to block."; + $text['description-call_block_name']['en-us'] = "Enter the Caller ID Name to block."; $text['description-call_block_name']['en-gb'] = "Enter the Caller ID Name to block."; $text['description-call_block_name']['ar-eg'] = ""; @@ -659,8 +744,8 @@ $text['description-call_block_number']['ru-ru'] = ""; $text['description-call_block_number']['sv-se'] = ""; $text['description-call_block_number']['uk-ua'] = ""; -$text['description-extension']['en-us'] = "Select the extension to block."; -$text['description-extension']['en-gb'] = "Select the extension to block."; +$text['description-extension']['en-us'] = "Select the extension to be affected."; +$text['description-extension']['en-gb'] = "Select the extension to be affected."; $text['description-extension']['ar-eg'] = ""; $text['description-extension']['de-at'] = ""; $text['description-extension']['de-ch'] = ""; diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index c9212fc585..a4ab54e559 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -203,7 +203,8 @@ echo " \n"; echo " \n"; } - echo th_order_by('extension', $text['label-extension'], $order_by, $order); + echo th_order_by('call_block_direction', $text['label-direction'], $order_by, $order, null, "style='width: 1%;' class='center'"); + echo th_order_by('extension', $text['label-extension'], $order_by, $order, null, "class='center'"); echo th_order_by('call_block_name', $text['label-name'], $order_by, $order); echo th_order_by('call_block_country_code', $text['label-country_code'], $order_by, $order); echo th_order_by('call_block_number', $text['label-number'], $order_by, $order); @@ -230,7 +231,13 @@ echo " \n"; echo " \n"; } - echo " "; + echo " "; + switch ($row['call_block_direction']) { + case "inbound": echo "\n"; break; + case "outbound": echo "\n"; break; + } + echo " \n"; + echo " "; if (strlen($row['extension']) == 0) { echo $text['label-all']; } diff --git a/app/call_block/call_block_edit.php b/app/call_block/call_block_edit.php index c8232c6076..29f43c779c 100644 --- a/app/call_block/call_block_edit.php +++ b/app/call_block/call_block_edit.php @@ -52,6 +52,7 @@ //get http post variables and set them to php variables if (count($_POST) > 0) { + $call_block_direction = $_POST["call_block_direction"]; $extension_uuid = $_POST["extension_uuid"]; $call_block_name = $_POST["call_block_name"]; $call_block_country_code = $_POST["call_block_country_code"]; @@ -84,6 +85,7 @@ $xml_cdrs = $_POST['xml_cdrs']; if (permission_exists('call_block_add') && is_array($xml_cdrs) && @sizeof($xml_cdrs) != 0) { $obj = new call_block; + $obj->call_block_direction = $call_block_direction; $obj->extension_uuid = $extension_uuid; $obj->call_block_app = $call_block_app; $obj->call_block_data = $call_block_data; @@ -161,6 +163,7 @@ if ($action == "add") { $array['call_block'][0]['call_block_uuid'] = uuid(); $array['call_block'][0]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_block'][0]['call_block_direction'] = $call_block_direction; if (is_uuid($extension_uuid)) { $array['call_block'][0]['extension_uuid'] = $extension_uuid; } @@ -207,6 +210,7 @@ $array['call_block'][0]['call_block_uuid'] = $call_block_uuid; $array['call_block'][0]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_block'][0]['call_block_direction'] = $call_block_direction; if (is_uuid($extension_uuid)) { $array['call_block'][0]['extension_uuid'] = $extension_uuid; } @@ -244,6 +248,7 @@ $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && sizeof($row) != 0) { + $call_block_direction = $row["call_block_direction"]; $extension_uuid = $row["extension_uuid"]; $call_block_name = $row["call_block_name"]; $call_block_country_code = $row["call_block_country_code"]; @@ -322,6 +327,21 @@ echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if (permission_exists('call_block_all')) { echo "\n"; echo "
\n"; + echo " ".$text['label-direction']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-direction']."\n"; + echo "\n"; + echo "
\n"; @@ -465,57 +485,49 @@ //get recent calls from the db (if not editing an existing call block record) if (!is_uuid($_REQUEST["id"])) { - if (permission_exists('call_block_all')) { - $sql = "select caller_id_number, caller_id_name, caller_id_number, start_epoch, direction, hangup_cause, duration, billsec, xml_cdr_uuid "; - $sql .= "from v_xml_cdr where true "; - $sql .= "and domain_uuid = :domain_uuid "; - $sql .= "and direction != 'outbound' "; - $sql .= "order by start_stamp desc "; - $sql .= limit_offset($_SESSION['call_block']['recent_call_limit']['text']); - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; - $result = $database->select($sql, $parameters); - unset($sql, $parameters); - } - + //without block all permission, limit to assigned extension(s) if (!permission_exists('call_block_all') && is_array($_SESSION['user']['extension'])) { foreach ($_SESSION['user']['extension'] as $assigned_extension) { $assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user']; } - - $sql = "select caller_id_number, caller_id_name, caller_id_number, start_epoch, direction, hangup_cause, duration, billsec, xml_cdr_uuid "; - $sql .= "from v_xml_cdr "; - $sql .= "where domain_uuid = :domain_uuid "; - if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) { - $x = 0; - foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) { - $sql_where_array[] = "extension_uuid = :extension_uuid_".$x; - //$sql_where_array[] = "caller_id_number = :caller_id_number_".$x; - //$sql_where_array[] = "destination_number = :destination_number_1_".$x; - //$sql_where_array[] = "destination_number = :destination_number_2_".$x; - $parameters['extension_uuid_'.$x] = $assigned_extension_uuid; - //$parameters['caller_id_number_'.$x] = $assigned_extension; - //$parameters['destination_number_1_'.$x] = $assigned_extension; - //$parameters['destination_number_2_'.$x] = '*99'.$assigned_extension; - $x++; - } - if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) { - $sql .= "and (".implode(' or ', $sql_where_array).") "; - } - unset($sql_where_array); + if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) { + $x = 0; + foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) { + $sql_where_array[] = "extension_uuid = :extension_uuid_".$x; + $parameters['extension_uuid_'.$x] = $assigned_extension_uuid; + $x++; } - $sql .= "order by start_stamp desc"; - $sql .= limit_offset($_SESSION['call_block']['recent_call_limit']['text']); - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; - $result = $database->select($sql, $parameters, 'all'); + if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) { + $sql_where .= "and (".implode(' or ', $sql_where_array).") "; + } + unset($sql_where_array); + } } + //get recent calls + $sql = "select caller_id_name, caller_id_number, caller_destination, start_epoch, direction, hangup_cause, duration, billsec, xml_cdr_uuid "; + $sql .= "from v_xml_cdr where domain_uuid = :domain_uuid "; + $sql .= "and direction <> 'local' "; + $sql .= $sql_where; + $sql .= "order by start_stamp desc "; + $sql .= limit_offset($_SESSION['call_block']['recent_call_limit']['text']); + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $database = new database; + $result = $database->select($sql, $parameters); + unset($sql, $parameters); + echo "
\n"; echo "\n"; echo "
\n"; - echo "
".$text['heading-recent_calls']."
\n"; + echo "
"; + echo " ".$text['heading-recent_calls'].""; + echo " \n"; + echo "
\n"; echo "
\n"; echo button::create(['type'=>'button','id'=>'action_bar_sub_button_back','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-xs','style'=>'display: none;','link'=>'call_block.php']); if ($result) { @@ -544,83 +556,112 @@ echo modal::create(['id'=>'modal-block','type'=>'general','message'=>$text['confirm-block'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_block','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_form_submit('form_list');"])]); } - echo "\n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo th_order_by('caller_id_name', $text['label-name'], $order_by, $order); - echo th_order_by('caller_id_number', $text['label-number'], $order_by, $order); - echo th_order_by('start_stamp', $text['label-called-on'], $order_by, $order); - echo th_order_by('duration', $text['label-duration'], $order_by, $order, null, "class='right hide-sm-dn'"); - echo ""; + foreach (['inbound','outbound'] as $direction) { + echo "
\n"; - echo " \n"; - echo "  
\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo th_order_by('caller_id_name', $text['label-name'], $order_by, $order); + echo th_order_by('caller_id_number', $text['label-number'], $order_by, $order); + echo th_order_by('caller_id_number', $text['label-destination'], $order_by, $order); + echo th_order_by('start_stamp', $text['label-called'], $order_by, $order); + echo th_order_by('duration', $text['label-duration'], $order_by, $order, null, "class='right hide-sm-dn'"); + echo ""; - if (is_array($result) && @sizeof($result) != 0) { - $x = 0; - foreach ($result as $row) { - $list_row_onclick_uncheck = "if (!this.checked) { document.getElementById('checkbox_all').checked = false; }"; - $list_row_onclick_toggle = "onclick=\"document.getElementById('checkbox_".$x."').checked = document.getElementById('checkbox_".$x."').checked ? false : true; ".$list_row_onclick_uncheck."\""; - if (strlen($row['caller_id_number']) >= 7) { - if ($_SESSION['domain']['time_format']['text'] == '24h') { - $tmp_start_epoch = date('j M Y', $row['start_epoch'])." ".date('H:i:s', $row['start_epoch']).''; - } - else { - $tmp_start_epoch = date('j M Y', $row['start_epoch'])." ".date('h:i:s a', $row['start_epoch']).''; - } - echo "\n"; - echo " \n"; - if ( - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_voicemail.png") && - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_answered.png") && - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_local_failed.png") && - file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_local_answered.png") - ) { - echo " \n"; + echo " \n"; + if ( + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_voicemail.png") && + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_answered.png") && + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_failed.png") && + file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_answered.png") + ) { + echo " \n"; + } + else { + echo " "; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + $seconds = ($row['hangup_cause'] == "ORIGINATOR_CANCEL") ? $row['duration'] : $row['billsec']; //if they cancelled, show the ring time, not the bill time. + echo " \n"; + echo "\n"; } - echo " \n"; } - else { - echo " "; - } - echo " \n"; - echo " \n"; - echo " \n"; - $seconds = ($row['hangup_cause'] == "ORIGINATOR_CANCEL") ? $row['duration'] : $row['billsec']; //if they cancelled, show the ring time, not the bill time. - echo " \n"; - echo "\n"; - $x++; } } - unset($result); - + echo "
\n"; + echo " \n"; + echo "  
\n"; - echo " \n"; - echo " \n"; - echo " "; - switch ($row['direction']) { - case "inbound" : - if ($row['billsec'] == 0) { - echo "".$text[\n"; + if (is_array($result) && @sizeof($result) != 0) { + foreach ($result as $x => $row) { + if ($row['direction'] == $direction) { + $list_row_onclick_uncheck = "if (!this.checked) { document.getElementById('checkbox_all_".$direction."').checked = false; }"; + $list_row_onclick_toggle = "onclick=\"document.getElementById('checkbox_".$x."').checked = document.getElementById('checkbox_".$x."').checked ? false : true; ".$list_row_onclick_uncheck."\""; + if (strlen($row['caller_id_number']) >= 7) { + if ($_SESSION['domain']['time_format']['text'] == '24h') { + $tmp_start_epoch = date('j M Y', $row['start_epoch'])." ".date('H:i:s', $row['start_epoch']).''; + } + else { + $tmp_start_epoch = date('j M Y', $row['start_epoch'])." ".date('h:i:s a', $row['start_epoch']).''; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " "; + switch ($row['direction']) { + case "inbound": + if ($row['billsec'] == 0) { + $title_mod = " ".$text['label-missed']; + $file_mod = "_voicemail"; + } + else { + $file_mod = "_answered"; + } + echo "\n"; + break; + case "outbound": + if ($row['billsec'] == 0) { + $title_mod = " ".$text['label-failed']; + $file_mod = "_failed"; + } + else { + $file_mod = "_answered"; + } + echo "\n"; + break; } - else { - echo "".$text[\n"; - } - break; - case "local" : - if ($row['billsec'] == 0) { - echo "".$text[\n"; - } - else { - echo "".$text[\n"; - } - break; + echo "  ".$row['caller_id_name']." ".format_phone($row['caller_id_number'])."".format_phone($row['caller_destination'])."".$tmp_start_epoch."".gmdate("G:i:s", $seconds)."
 ".$row['caller_id_name']." ".format_phone($row['caller_id_number'])."".$tmp_start_epoch."".gmdate("G:i:s", $seconds)."
\n"; } + unset($result); - echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; + //handle hiding and showing of direction recent calls + echo "\n"; + } //make sub action bar sticky diff --git a/app/call_block/resources/classes/call_block.php b/app/call_block/resources/classes/call_block.php index fcb61a6555..947f123f65 100644 --- a/app/call_block/resources/classes/call_block.php +++ b/app/call_block/resources/classes/call_block.php @@ -23,6 +23,7 @@ if (!class_exists('call_block')) { /** * declare public variables */ + public $call_block_direction; public $extension_uuid; public $call_block_app; public $call_block_data; @@ -307,7 +308,7 @@ if (!class_exists('call_block')) { //get the caller id info from cdrs if (is_array($uuids) && @sizeof($uuids) != 0) { - $sql = "select caller_id_name, caller_id_number from v_xml_cdr "; + $sql = "select caller_id_name, caller_id_number, caller_destination from v_xml_cdr "; $sql .= "where xml_cdr_uuid in (".implode(', ', $uuids).") "; $database = new database; $rows = $database->select($sql, $parameters, 'all'); @@ -322,11 +323,17 @@ if (!class_exists('call_block')) { if (permission_exists('call_block_all')) { $array['call_block'][$x]['call_block_uuid'] = uuid(); $array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_block'][$x]['call_block_direction'] = $this->call_block_direction; if (is_uuid($this->extension_uuid)) { $array['call_block'][$x]['extension_uuid'] = $this->extension_uuid; } - $array['call_block'][$x]['call_block_name'] = trim($row["caller_id_name"]); - $array['call_block'][$x]['call_block_number'] = trim($row["caller_id_number"]); + if ($this->call_block_direction == 'inbound') { + $array['call_block'][$x]['call_block_name'] = trim($row["caller_id_name"]); + $array['call_block'][$x]['call_block_number'] = trim($row["caller_id_number"]); + } + if ($this->call_block_direction == 'outbound') { + $array['call_block'][$x]['call_block_number'] = trim($row["caller_destination"]); + } $array['call_block'][$x]['call_block_count'] = 0; $array['call_block'][$x]['call_block_app'] = $this->call_block_app; $array['call_block'][$x]['call_block_data'] = $this->call_block_data; @@ -340,9 +347,15 @@ if (!class_exists('call_block')) { if (is_uuid($field['extension_uuid'])) { $array['call_block'][$x]['call_block_uuid'] = uuid(); $array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_block'][$x]['call_block_direction'] = $this->call_block_direction; $array['call_block'][$x]['extension_uuid'] = $field['extension_uuid']; - $array['call_block'][$x]['call_block_name'] = trim($row["caller_id_name"]); - $array['call_block'][$x]['call_block_number'] = trim($row["caller_id_number"]); + if ($this->call_block_direction == 'inbound') { + $array['call_block'][$x]['call_block_name'] = trim($row["caller_id_name"]); + $array['call_block'][$x]['call_block_number'] = trim($row["caller_id_number"]); + } + if ($this->call_block_direction == 'outbound') { + $array['call_block'][$x]['call_block_number'] = trim($row["caller_destination"]); + } $array['call_block'][$x]['call_block_count'] = 0; $array['call_block'][$x]['call_block_app'] = $this->call_block_app; $array['call_block'][$x]['call_block_data'] = $this->call_block_data; diff --git a/app/dialplans/resources/switch/conf/dialplan/040_call_block.xml b/app/dialplans/resources/switch/conf/dialplan/040_call_block.xml index 6d144d73bb..a73a790960 100644 --- a/app/dialplans/resources/switch/conf/dialplan/040_call_block.xml +++ b/app/dialplans/resources/switch/conf/dialplan/040_call_block.xml @@ -1,6 +1,6 @@ - + diff --git a/app/scripts/resources/scripts/app/call_block/index.lua b/app/scripts/resources/scripts/app/call_block/index.lua index 00c9d32e6a..48aa13a589 100644 --- a/app/scripts/resources/scripts/app/call_block/index.lua +++ b/app/scripts/resources/scripts/app/call_block/index.lua @@ -44,8 +44,10 @@ if (session:ready()) then --session:setAutoHangup(false); domain_uuid = session:getVariable("domain_uuid"); + call_direction = session:getVariable("call_direction"); caller_id_name = session:getVariable("caller_id_name"); caller_id_number = session:getVariable("caller_id_number"); + destination_number = session:getVariable("destination_number"); context = session:getVariable("context"); call_block = session:getVariable("call_block"); extension_uuid = session:getVariable("extension_uuid"); @@ -93,6 +95,7 @@ sql = "select * from v_call_block\n"; sql = sql .. "where domain_uuid = :domain_uuid \n"; sql = sql .. "and call_block_enabled = 'true' \n"; + sql = sql .. "and call_block_direction = :call_block_direction \n"; sql = sql .. "and ( \n"; sql = sql .. " (\n"; sql = sql .. " call_block_name = :call_block_name \n"; @@ -118,9 +121,19 @@ sql = sql .. "and (extension_uuid is null or extension_uuid = :extension_uuid) "; end if (extension_uuid ~= nil) then - params = {domain_uuid = domain_uuid, call_block_name = caller_id_name, call_block_number = caller_id_number, extension_uuid = extension_uuid}; + if (call_direction == 'inbound') then + params = {domain_uuid = domain_uuid, call_block_direction = call_direction, call_block_name = caller_id_name, call_block_number = caller_id_number, extension_uuid = extension_uuid}; + end + if (call_direction == 'outbound') then + params = {domain_uuid = domain_uuid, call_block_direction = call_direction, call_block_name = caller_id_name, call_block_number = destination_number, extension_uuid = extension_uuid}; + end else - params = {domain_uuid = domain_uuid, call_block_name = caller_id_name, call_block_number = caller_id_number}; + if (call_direction == 'inbound') then + params = {domain_uuid = domain_uuid, call_block_direction = call_direction, call_block_name = caller_id_name, call_block_number = caller_id_number}; + end + if (call_direction == 'outbound') then + params = {domain_uuid = domain_uuid, call_block_direction = call_direction, call_block_name = caller_id_name, call_block_number = destination_number}; + end end if (debug["sql"]) then freeswitch.consoleLog("notice", "[dialplan] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); @@ -231,4 +244,4 @@ freeswitch.consoleLog("notice", "[call_block] " .. call_block_cache_key .. " source: cache\n"); end end - end + end \ No newline at end of file