Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('sms_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the http values and set them as variables $search = check_str($_GET["search"]); $order_by = check_str($_GET["order_by"]); $order = check_str($_GET["order"]); require_once "resources/header.php"; $document['title'] = $text['title-sms']; require_once "resources/paging.php"; //get total extension count from the database $sql = "select "; $sql .= "(select count(*) from v_sms_destinations where domain_uuid = '".$_SESSION['domain_uuid']."' ".$sql_mod.") as num_rows "; if ($db_type == "pgsql") { $sql .= ",(select count(*) as count from v_sms_destinations "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= ") as numeric_sms "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); $total_sms_destinations = $row['num_rows']; if (($db_type == "pgsql") or ($db_type == "mysql")) { $numeric_sms = $row['numeric_sms']; } } unset($prep_statement, $row); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; if (!isset($_GET['page'])) { $_GET['page'] = 0; } $_GET['page'] = check_str($_GET['page']); list($paging_controls_mini, $rows_per_page, $var_3) = paging($total_sms_destinations, $param, $rows_per_page, true); //top list($paging_controls, $rows_per_page, $var_3) = paging($total_sms_destinations, $param, $rows_per_page); //bottom $offset = $rows_per_page * $_GET['page']; //to cast or not to cast if ($db_type == "pgsql") { $order_text = ($total_sms_destinations == $numeric_sms) ? "cast(destination as bigint)" : "destination asc"; } else { $order_text = "extension asc"; } //get the extensions $sql = "select * from v_sms_destinations "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= $sql_mod; //add search mod from above if (strlen($order_by) > 0) { $sql .= ($order_by == 'destination') ? "order by $order_text ".$order." " : "order by ".$order_by." ".$order." "; } else { $sql .= "order by $order_text "; } $sql .= "limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $sms_destinations = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset ($prep_statement, $sql); //show the content echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['header-sms']." (".$total_sms_destinations.")
\n"; echo " ".$text['description-sms']."\n"; echo "
\n"; if (if_group("superadmin")) { echo " \n"; } echo " "; echo " "; if ($paging_controls_mini != '') { echo "".$paging_controls_mini."\n"; } echo "
\n"; echo "
"; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; if (permission_exists('sms_delete') && is_array($sms_destinations)) { echo ""; } echo th_order_by('destination', $text['label-destination'], $order_by, $order); echo th_order_by('carrier', $text['label-carrier'], $order_by, $order); echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order); echo "\n"; echo "\n"; if (is_array($sms_destinations)) { foreach($sms_destinations as $row) { $tr_link = (permission_exists('sms_edit')) ? " href='sms_edit.php?id=".$row['sms_destination_uuid']."'" : null; echo "\n"; if (permission_exists('sms_delete')) { echo " "; $ext_ids[] = 'checkbox_'.$row['sms_destination_uuid']; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; $c = ($c) ? 0 : 1; } unset($sms_destinations, $row); } if (is_array($sms_destinations)) { echo "\n"; echo " \n"; echo "\n"; } echo "
\n"; if (permission_exists('sms_add')) { echo "".$v_link_label_add.""; } if (permission_exists('sms_delete') && is_array($sms_destinations)) { echo "".$v_link_label_delete.""; } echo "
"; if (permission_exists('sms_edit')) { echo "".$row['destination'].""; } else { echo $row['destination']; } echo "".$row['carrier']."".ucwords($row['enabled'])."".$row['description']." "; if (permission_exists('sms_edit')) { echo "$v_link_label_edit"; } if (permission_exists('sms_delete')) { echo "$v_link_label_delete"; } echo "
\n"; if (permission_exists('sms_add')) { echo "".$v_link_label_add.""; } if (permission_exists('sms_delete')) { echo "".$v_link_label_delete.""; } echo "
"; echo "
"; if (strlen($paging_controls) > 0) { echo "
".$paging_controls."
\n"; } echo "

".((is_array($sms_destinations)) ? "

" : null); // check or uncheck all checkboxes if (sizeof($ext_ids) > 0) { echo "\n"; } if (is_array($sms_destinations)) { // check all checkboxes key_press('ctrl+a', 'down', 'document', null, null, "check('all');", true); // delete checked key_press('delete', 'up', 'document', array('#search'), $text['confirm-delete'], 'document.forms.frm.submit();', true); } //show the footer require_once "resources/footer.php"; ?>