2014-09-09 07:43:09 +02:00
< ? php
2018-12-18 02:26:21 +01:00
/*
FusionPBX
Version : MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 ( the " License " ); you may not use this file except in compliance with
the License . You may obtain a copy of the License at
http :// www . mozilla . org / MPL /
Software distributed under the License is distributed on an " AS IS " basis ,
WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
for the specific language governing rights and limitations under the
License .
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane < markjcrane @ fusionpbx . com >
2020-01-29 19:41:12 +01:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2020
2018-12-18 02:26:21 +01:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
*/
//includes
require_once " root.php " ;
require_once " resources/require.php " ;
require_once " resources/check_auth.php " ;
2020-01-06 19:43:43 +01:00
require_once " resources/paging.php " ;
2018-12-18 02:26:21 +01:00
//check permissions
if ( permission_exists ( 'fax_log_view' )) {
//access granted
}
else {
echo " access denied " ;
exit ;
}
2015-01-18 11:06:08 +01:00
2014-09-09 07:43:09 +02:00
//add multi-lingual support
2015-01-18 11:06:08 +01:00
$language = new text ;
$text = $language -> get ();
2014-09-09 07:43:09 +02:00
2020-01-29 19:41:12 +01:00
//get the fax_uuid
$fax_uuid = $_REQUEST [ " id " ];
2014-09-09 07:43:09 +02:00
//get variables used to control the order
$order_by = $_GET [ " order_by " ];
$order = $_GET [ " order " ];
2020-01-29 19:41:12 +01:00
//get the http post data
if ( is_array ( $_POST [ 'fax_logs' ])) {
$action = $_POST [ 'action' ];
$fax_logs = $_POST [ 'fax_logs' ];
}
2014-09-09 18:49:58 +02:00
2020-01-29 19:41:12 +01:00
//process the http post data by action
if ( $action != '' && 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 ;
}
2014-09-09 07:43:09 +02:00
2020-01-29 19:41:12 +01:00
header ( 'Location: fax_logs.php?id=' . urlencode ( $fax_uuid ));
exit ;
}
//add the search string
$search = strtolower ( $_GET [ " search " ]);
if ( strlen ( $search ) > 0 ) {
$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 .= " ) " ;
$parameters [ 'search' ] = '%' . $search . '%' ;
}
2014-09-09 07:43:09 +02:00
2018-12-18 02:26:21 +01:00
//prepare to page the results
2020-01-29 19:41:12 +01:00
$sql = " select count(fax_log_uuid) from v_fax_logs " ;
2019-08-08 02:59:26 +02:00
$sql .= " where domain_uuid = :domain_uuid " ;
$sql .= " and fax_uuid = :fax_uuid " ;
2020-01-29 19:41:12 +01:00
$sql .= $sql_search ;
2019-08-08 02:59:26 +02:00
$parameters [ 'domain_uuid' ] = $domain_uuid ;
$parameters [ 'fax_uuid' ] = $fax_uuid ;
$database = new database ;
$num_rows = $database -> select ( $sql , $parameters , 'column' );
2018-12-18 02:26:21 +01:00
//prepare to page the results
$rows_per_page = ( $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] != '' ) ? $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] : 50 ;
2020-01-29 19:41:12 +01:00
$param = " &id= " . $fax_uuid . " &order_by= " . $order_by . " &order= " . $order . " &search= " . $search ;
2019-12-19 04:15:02 +01:00
if ( isset ( $_GET [ 'page' ])) {
2020-01-29 19:41:12 +01:00
$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 );
2019-12-19 04:15:02 +01:00
$offset = $rows_per_page * $page ;
}
2014-09-09 07:43:09 +02:00
2018-12-18 02:26:21 +01:00
//get the list
2020-01-29 19:41:12 +01:00
$sql = str_replace ( 'count(fax_log_uuid)' , '*' , $sql );
2019-08-08 02:59:26 +02:00
$sql .= order_by ( $order_by , $order , 'fax_epoch' , 'desc' );
$sql .= limit_offset ( $rows_per_page , $offset );
$database = new database ;
$fax_logs = $database -> select ( $sql , $parameters , 'all' );
2020-01-29 19:41:12 +01:00
unset ( $sql , $parameters );
2014-09-09 07:43:09 +02:00
2020-01-29 19:41:12 +01:00
//create token
$object = new token ;
$token = $object -> create ( $_SERVER [ 'PHP_SELF' ]);
2014-09-09 07:43:09 +02:00
2020-01-29 19:41:12 +01:00
//include the header
$document [ 'title' ] = $text [ 'title-fax_logs' ];
require_once " resources/header.php " ;
//show the content
echo " <div class='action_bar' id='action_bar'> \n " ;
echo " <div class='heading'><b> " . $text [ 'title-fax_logs' ] . " ( " . $num_rows . " )</b></div> \n " ;
echo " <div class='actions'> \n " ;
2020-03-05 08:05:45 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-back' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_back' ], 'id' => 'btn_back' , 'link' => 'fax.php' ]);
2020-01-29 19:41:12 +01:00
if ( permission_exists ( 'fax_log_delete' ) && $fax_logs ) {
2020-03-26 16:38:50 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-delete' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_delete' ], 'name' => 'btn_delete' , 'style' => 'margin-left: 15px;' , 'onclick' => " modal_open('modal-delete','btn_delete'); " ]);
2020-01-29 19:41:12 +01:00
}
2020-01-29 19:49:49 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-refresh' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_refresh' ], 'style' => 'margin-left: 15px;' , 'onclick' => 'document.location.reload(true);' ]);
2020-01-29 19:41:12 +01:00
echo " <form id='form_search' class='inline' method='get'> \n " ;
echo " <input type='hidden' name='id' value=' " . escape ( $fax_uuid ) . " '> " ;
echo " <input type='text' class='txt list-search' name='search' id='search' value= \" " . escape ( $search ) . " \" placeholder= \" " . $text [ 'label-search' ] . " \" onkeydown='list_search_reset();'> " ;
echo button :: create ([ 'label' => $text [ 'button-search' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_search' ], 'type' => 'submit' , 'id' => 'btn_search' , 'style' => ( $search != '' ? 'display: none;' : null )]);
echo button :: create ([ 'label' => $text [ 'button-reset' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_reset' ], 'type' => 'button' , 'id' => 'btn_reset' , 'link' => 'fax_logs.php?id=' . $fax_uuid , 'style' => ( $search == '' ? 'display: none;' : null )]);
if ( $paging_controls_mini != '' ) {
echo " <span style='margin-left: 15px;'> " . $paging_controls_mini . " </span> \n " ;
}
echo " </form> \n " ;
echo " </div> \n " ;
echo " <div style='clear: both;'></div> \n " ;
echo " </div> \n " ;
2020-03-26 16:38:50 +01:00
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'); " ])]);
}
2020-01-29 19:41:12 +01:00
echo $text [ 'description-fax_log' ] . " \n " ;
echo " <br /><br /> \n " ;
echo " <form id='form_list' method='post'> \n " ;
echo " <input type='hidden' id='action' name='action' value=''> \n " ;
echo " <input type='hidden' name='search' value= \" " . escape ( $search ) . " \" > \n " ;
echo " <table class='list'> \n " ;
echo " <tr class='list-header'> \n " ;
if ( permission_exists ( 'fax_log_delete' )) {
echo " <th class='checkbox'> \n " ;
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' " . ( $fax_logs ? : " style='visibility: hidden;' " ) . " > \n " ;
echo " </th> \n " ;
}
echo th_order_by ( 'fax_epoch' , $text [ 'label-fax_date' ], $order_by , $order , null , null , " &id= " . $fax_uuid );
2015-03-19 01:45:22 +01:00
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 );
2014-09-09 07:43:09 +02:00
//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);
2015-03-19 01:45:22 +01:00
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 );
2014-09-09 07:43:09 +02:00
//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);
2015-03-19 01:45:22 +01:00
echo th_order_by ( 'fax_uri' , $text [ 'label-fax_destination' ], $order_by , $order , null , null , " &id= " . $fax_uuid );
2014-09-09 07:43:09 +02:00
//echo th_order_by('fax_epoch', $text['label-fax_epoch'], $order_by, $order);
2020-01-29 19:41:12 +01:00
if ( $_SESSION [ 'theme' ][ 'list_row_edit_button' ][ 'boolean' ] == 'true' ) {
echo " <td class='action-button'> </td> \n " ;
}
2015-02-26 05:18:16 +01:00
echo " </tr> \n " ;
2014-09-09 07:43:09 +02:00
2019-08-08 02:59:26 +02:00
if ( is_array ( $fax_logs ) && @ sizeof ( $fax_logs ) != 0 ) {
2020-01-29 19:41:12 +01:00
$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 " <tr class='list-row' href=' " . $list_row_url . " '> \n " ;
2014-09-09 07:43:09 +02:00
if ( permission_exists ( 'fax_log_delete' )) {
2020-01-29 19:41:12 +01:00
echo " <td class='checkbox'> \n " ;
echo " <input type='checkbox' name='fax_logs[ $x ][checked]' id='checkbox_ " . $x . " ' value='true' onclick= \" if (!this.checked) { document.getElementById('checkbox_all').checked = false; } \" > \n " ;
echo " <input type='hidden' name='fax_logs[ $x ][uuid]' value=' " . escape ( $row [ 'fax_log_uuid' ]) . " ' /> \n " ;
echo " </td> \n " ;
}
echo " <td><a href=' " . $list_row_url . " '> " . ( $_SESSION [ 'domain' ][ 'time_format' ][ 'text' ] == '12h' ? date ( " j M Y g:i:sa " , $row [ 'fax_epoch' ]) : date ( " j M Y H:i:s " , $row [ 'fax_epoch' ])) . " </a> </td> \n " ;
echo " <td> " . $row [ 'fax_success' ] . " </td> \n " ;
echo " <td> " . $row [ 'fax_result_code' ] . " </td> \n " ;
echo " <td> " . $row [ 'fax_result_text' ] . " </td> \n " ;
echo " <td> " . basename ( $row [ 'fax_file' ]) . " </td> \n " ;
echo " <td> " . $row [ 'fax_ecm_used' ] . " </td> \n " ;
echo " <td> " . $row [ 'fax_local_station_id' ] . " </td> \n " ;
//echo " <td>".$row['fax_document_transferred_pages']." </td>\n";
//echo " <td>".$row['fax_document_total_pages']." </td>\n";
//echo " <td>".$row['fax_image_resolution']." </td>\n";
//echo " <td>".$row['fax_image_size']." </td>\n";
echo " <td> " . $row [ 'fax_bad_rows' ] . " </td> \n " ;
echo " <td> " . $row [ 'fax_transfer_rate' ] . " </td> \n " ;
echo " <td> " . $row [ 'fax_retry_attempts' ] . " </td> \n " ;
//echo " <td>".$row['fax_retry_limit']." </td>\n";
//echo " <td>".$row['fax_retry_sleep']." </td>\n";
echo " <td> " . basename ( $row [ 'fax_uri' ]) . " </td> \n " ;
//echo " <td>".$row['fax_epoch']." </td>\n";
if ( $_SESSION [ 'theme' ][ 'list_row_edit_button' ][ 'boolean' ] == 'true' ) {
echo " <td class='action-button'> \n " ;
echo button :: create ([ 'type' => 'button' , 'title' => $text [ 'button-view' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_view' ], 'link' => $list_row_url ]);
echo " </td> \n " ;
2014-09-09 07:43:09 +02:00
}
echo " </tr> \n " ;
2020-01-29 19:41:12 +01:00
$x ++ ;
2019-08-08 02:59:26 +02:00
}
}
2020-01-29 19:41:12 +01:00
unset ( $fax_logs );
2014-09-09 07:43:09 +02:00
2020-01-29 19:41:12 +01:00
echo " </table> \n " ;
echo " <br /> \n " ;
echo " <div align='center'> " . $paging_controls . " </div> \n " ;
echo " <input type='hidden' name='id' value=' " . escape ( $fax_uuid ) . " '> \n " ;
echo " <input type='hidden' name=' " . $token [ 'name' ] . " ' value=' " . $token [ 'hash' ] . " '> \n " ;
echo " </form> \n " ;
2014-09-09 07:43:09 +02:00
//include the footer
require_once " resources/footer.php " ;
2018-12-18 02:26:21 +01:00
2020-01-29 19:41:12 +01:00
?>