Portions created by the Initial Developer are Copyright (C) 2008-2017 the Initial Developer. All Rights Reserved. Contributor(s): Matthew Vale */ require_once "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (!permission_exists('number_translation_view')) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //handle enable toggle $number_translation_uuid = check_str($_REQUEST['id']); $number_translation_enabled = check_str($_REQUEST['enabled']); if ($number_translation_uuid != '' && $number_translation_enabled != '') { $array['number_translations'][0]['number_translation_uuid'] = $number_translation_uuid; $array['number_translations'][0]['number_translation_enabled'] = $number_translation_enabled; $database = new database; $database->app_name = 'number_translations'; $database->save($array); $number_translation = new number_translation; $number_translation->xml(); messages::add($text['message-update']); unset($array, $number_translation); } //set the http values as php variables if (isset($_REQUEST["search"])) { $search = check_str($_REQUEST["search"]); } else { $search = null; } if (isset($_REQUEST["order_by"])) { $order_by = check_str($_REQUEST["order_by"]); } else { $order_by = null; } if (isset($_REQUEST["order"])) { $order = check_str($_REQUEST["order"]); } else { $order = null; } //includes require_once "resources/header.php"; require_once "resources/paging.php"; //get the number of rows in the number_translation $sql = "select count(*) as num_rows from v_number_translations "; $sql .= "where true "; if (strlen($search) > 0) { $sql .= "and ("; $sql .= " number_translation_name like '%".$search."%' "; $sql .= " or number_translation_description like '%".$search."%' "; $sql .= ") "; } $prep_statement = $db->prepare(check_sql($sql)); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] > 0) { $num_rows = $row['num_rows']; } else { $num_rows = '0'; } } unset($prep_statement, $result); $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = ""; if (strlen($app_uuid) > 0) { $param = "&app_uuid=".$app_uuid; } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); $offset = $rows_per_page * $page; //get the list of number_translations $sql = "select * from v_number_translations "; $sql .= "where true "; if (strlen($search) > 0) { $sql .= "and ("; $sql .= " number_translation_name like '%".$search."%' "; $sql .= " or number_translation_description like '%".$search."%' "; $sql .= ") "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by number_translation_name asc "; } $sql .= " limit $rows_per_page offset $offset "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $number_translations = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($number_translations); unset ($prep_statement, $sql); //set the alternating row style $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; //set the title $document['title'] = $text['title-number_translation']; //show the content echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; echo "
\n"; echo " \n"; echo " ".$text['header-number_translation']."\n"; echo " \n"; echo "

\n"; echo "
\n"; echo "
\n"; echo " "; if (strlen($order_by) > 0) { echo " "; echo " "; } echo " "; echo " \n"; echo " \n"; echo "
\n"; echo "
\n"; echo " \n"; echo " " . $text['description-number_translation'] . "\n"; echo " \n"; echo "
"; echo "
"; echo "
\n"; echo "\n"; echo "\n"; if (permission_exists('number_translation_delete') && $result_count > 0) { echo ""; } echo th_order_by('number_translation_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo th_order_by('number_translation_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null)); echo th_order_by('number_translation_description', $text['label-description'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null)); echo "\n"; echo "\n"; if ($result_count > 0) { foreach($number_translations as $row) { $tr_link = "href='number_translation_edit.php?id=".$row['number_translation_uuid']."'"; echo "\n"; if (permission_exists("number_translation_delete")) { echo " \n"; $number_translation_ids[] = 'checkbox_'.$row['number_translation_uuid']; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results echo "\n"; echo "\n"; echo "\n"; echo "
"; if (permission_exists('number_translation_delete') && $result_count > 0) { echo "".$v_link_label_delete.""; } echo "
"; echo $row['number_translation_name']; echo " ".((strlen($row['number_translation_description']) > 0) ? $row['number_translation_description'] : " ")."\n"; if (permission_exists('number_translation_edit')) { echo " $v_link_label_edit"; } if (permission_exists('number_translation_delete')) { echo " $v_link_label_delete"; } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 ".$paging_controls.""; if (permission_exists('number_translation_edit')) { echo " $v_link_label_add"; } if (permission_exists('number_translation_delete') && $result_count > 0) { echo " ".$v_link_label_delete.""; } echo "
\n"; echo "
"; echo "

"; echo "
"; if (sizeof($number_translation_ids) > 0) { echo "\n"; } //include the footer require_once "resources/footer.php"; //unset the variables unset ($result_count); unset ($result); unset ($key); unset ($val); unset ($c); ?>