Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions if (!permission_exists('fax_log_view')) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the fax_uuid $fax_uuid = $_REQUEST["id"]; //get variables used to control the order $order_by = $_GET["order_by"] ?? null; $order = $_GET["order"] ?? null; //get the http post data if (!empty($_POST['fax_logs']) && is_array($_POST['fax_logs'])) { $action = $_POST['action']; $fax_logs = $_POST['fax_logs']; } //process the http post data by action if (!empty($action) && !empty($fax_logs) && is_array($fax_logs) && @sizeof($fax_logs) != 0) { switch ($action) { case 'delete': if (permission_exists('fax_log_delete')) { $obj = new fax; $obj->fax_uuid = $fax_uuid; $obj->delete_logs($fax_logs); } break; } header('Location: fax_logs.php?id='.urlencode($fax_uuid)); exit; } //add the search string $search = strtolower($_GET["search"] ?? ''); if (!empty($search)) { $sql_search = " and ("; $sql_search .= " lower(fax_result_text) like :search "; $sql_search .= " or lower(fax_file) like :search "; $sql_search .= " or lower(fax_local_station_id) like :search "; $sql_search .= " or fax_date::text like :search "; $sql_search .= " or fax_uri::text like :search "; $sql_search .= ") "; $parameters['search'] = '%'.$search.'%'; } //get the count $sql = "select count(fax_log_uuid) from v_fax_logs "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and fax_uuid = :fax_uuid "; $sql .= $sql_search ?? ''; $parameters['domain_uuid'] = $domain_uuid; $parameters['fax_uuid'] = $fax_uuid; $num_rows = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); //prepare to page the results $rows_per_page = $settings->get('domain', 'paging', 50); $param = "&id=".$fax_uuid."&order_by=".$order_by."&order=".$order."&search=".$search; if (isset($_GET['page'])) { $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; } //set the time zone $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); //set the time format options: 12h, 24h if ($settings->get('domain', 'time_format') == '24h') { $time_format = 'HH24:MI:SS'; } else { $time_format = 'HH12:MI:SS am'; } //get the list $sql = "select "; $sql .= " fax_epoch, "; $sql .= " to_char(timezone(:time_zone, to_timestamp(fax_epoch)), 'DD Mon YYYY') as fax_date_formatted, \n"; $sql .= " to_char(timezone(:time_zone, to_timestamp(fax_epoch)), '".$time_format."') as fax_time_formatted, \n"; $sql .= " fax_success, "; $sql .= " fax_result_code, "; $sql .= " fax_result_text, "; $sql .= " fax_file, "; $sql .= " fax_ecm_used, "; $sql .= " fax_local_station_id, "; //$sql .= " fax_document_transferred_pages, "; //$sql .= " fax_document_total_pages, "; //$sql .= " fax_image_resolution, "; //$sql .= " fax_image_size, "; $sql .= " fax_bad_rows, "; $sql .= " fax_transfer_rate, "; $sql .= " fax_retry_attempts, "; $sql .= " fax_retry_limit, "; $sql .= " fax_retry_sleep, "; $sql .= " fax_uri "; $sql .= "from v_fax_logs "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and fax_uuid = :fax_uuid "; $sql .= $sql_search ?? ''; $sql .= order_by($order_by, $order, 'fax_epoch', 'desc'); $sql .= limit_offset($rows_per_page, $offset ?? 0); $parameters['domain_uuid'] = $domain_uuid; $parameters['fax_uuid'] = $fax_uuid; $parameters['time_zone'] = $time_zone; $fax_logs = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //include the header $document['title'] = $text['title-fax_logs']; require_once "resources/header.php"; //show the content echo "
\n"; echo "
".$text['title-fax_logs']."
".number_format($num_rows)."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax.php']); if (permission_exists('fax_log_delete') && $fax_logs) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'name'=>'btn_delete','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$settings->get('theme', 'button_icon_refresh'),'style'=>'margin-left: 15px;','onclick'=>'document.location.reload(true);']); echo "\n"; echo "
\n"; echo "
\n"; echo "
\n"; if (permission_exists('fax_log_delete') && $fax_logs) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); } echo $text['description-fax_log']."\n"; echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; if (permission_exists('fax_log_delete')) { echo " \n"; } echo th_order_by('fax_epoch', $text['label-date'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_epoch', $text['label-time'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_success', $text['label-fax_success'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_result_code', $text['label-fax_result_code'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_result_text', $text['label-fax_result_text'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_file', $text['label-fax_file'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_ecm_used', $text['label-fax_ecm_used'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_local_station_id', $text['label-fax_local_station_id'], $order_by, $order, null, null, "&id=".$fax_uuid); //echo th_order_by('fax_document_transferred_pages', $text['label-fax_document_transferred_pages'], $order_by, $order); //echo th_order_by('fax_document_total_pages', $text['label-fax_document_total_pages'], $order_by, $order); //echo th_order_by('fax_image_resolution', $text['label-fax_image_resolution'], $order_by, $order); //echo th_order_by('fax_image_size', $text['label-fax_image_size'], $order_by, $order); echo th_order_by('fax_bad_rows', $text['label-fax_bad_rows'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_transfer_rate', $text['label-fax_transfer_rate'], $order_by, $order, null, null, "&id=".$fax_uuid); echo th_order_by('fax_retry_attempts', $text['label-fax_retry_attempts'], $order_by, $order, null, null, "&id=".$fax_uuid); //echo th_order_by('fax_retry_limit', $text['label-fax_retry_limit'], $order_by, $order); //echo th_order_by('fax_retry_sleep', $text['label-fax_retry_sleep'], $order_by, $order); echo th_order_by('fax_uri', $text['label-fax_destination'], $order_by, $order, null, null, "&id=".$fax_uuid); if ($settings->get('theme', 'list_row_edit_button', false)) { echo " \n"; } echo "\n"; if (is_array($fax_logs) && @sizeof($fax_logs) != 0) { $x = 0; foreach ($fax_logs as $row) { $list_row_url = "fax_log_view.php?id=".urlencode($row['fax_log_uuid'])."&fax_uuid=".$fax_uuid; echo "\n"; if (permission_exists('fax_log_delete')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; //echo " \n"; //echo " \n"; //echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo " \n"; //echo " \n"; //echo " \n"; echo " \n"; //echo " \n"; if ($settings->get('theme', 'list_row_edit_button', false)) { echo " \n"; } echo "\n"; $x++; } } unset($fax_logs); echo "
\n"; echo " \n"; echo "  
\n"; echo " \n"; echo " \n"; echo " ".$row['fax_date_formatted']." ".$row['fax_time_formatted']." ".$row['fax_success']." ".$row['fax_result_code']." ".$row['fax_result_text']." ".basename($row['fax_file'])." ".$row['fax_ecm_used']." ".$row['fax_local_station_id']." ".$row['fax_document_transferred_pages']." ".$row['fax_document_total_pages']." ".$row['fax_image_resolution']." ".$row['fax_image_size']." ".$row['fax_bad_rows']." ".$row['fax_transfer_rate']." ".$row['fax_retry_attempts']." ".$row['fax_retry_limit']." ".$row['fax_retry_sleep']." ".basename($row['fax_uri'])." ".$row['fax_epoch']." \n"; echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$settings->get('theme', 'button_icon_view'),'link'=>$list_row_url]); echo "
\n"; echo "
\n"; echo "
\n"; echo "
".($paging_controls ?? '')."
\n"; echo "\n"; echo "\n"; echo "
\n"; //include the footer require_once "resources/footer.php"; ?>