diff --git a/app/fax/fax_files.php b/app/fax/fax_files.php index cdda50ad6c..ad246990ae 100644 --- a/app/fax/fax_files.php +++ b/app/fax/fax_files.php @@ -205,11 +205,11 @@ else { echo "
\n"; echo "\n"; echo "\n"; - //echo th_order_by('fax_uuid', $text['label-fax_uuid'], $order_by, $order); - //echo th_order_by('fax_mode', $text['label-fax_mode'], $order_by, $order); + echo "\n"; + echo "\n"; echo th_order_by('fax_number', $text['label-fax_number'], $order_by, $order); //echo th_order_by('fax_file_type', $text['label-fax_file_type'], $order_by, $order); - echo th_order_by('fax_file_path', $text['label-fax_file_path'], $order_by, $order); + //echo th_order_by('fax_file_path', $text['label-fax_file_path'], $order_by, $order); echo th_order_by('fax_caller_id_name', $text['label-fax_caller_id_name'], $order_by, $order); echo th_order_by('fax_caller_id_number', $text['label-fax_caller_id_number'], $order_by, $order); echo th_order_by('fax_date', $text['label-fax_date'], $order_by, $order); @@ -219,21 +219,90 @@ else { echo "\n"; if ($result_count > 0) { foreach($result as $row) { - //if (permission_exists('fax_file_edit')) { - // $tr_link = "href='fax_file_edit.php?id=".$row['fax_file_uuid']."'"; - //} + $file = basename($row['fax_file_path']); + if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") { + $file_name = substr($file, 0, (strlen($file) -4)); + } + $file_ext = $row['fax_file_type']; + + //decode the base64 + if (strlen($row['fax_base64']) > 0) { + if ($_REQUEST['box'] == 'inbox') { + if (!file_exists($dir_fax_inbox.'/'.$file)) { + file_put_contents($dir_fax_inbox.'/'.$file, base64_decode($row['fax_base64'])); + } + } + if ($_REQUEST['box'] == 'sent') { + if (!file_exists($dir_fax_sent.'/'.$file)) { + //decode the base64 + file_put_contents($dir_fax_sent.'/'.$file, base64_decode($row['fax_base64'])); + } + } + + } + //convert the tif to pdf + if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) { + if ($_REQUEST['box'] == 'inbox') { + chdir($dir_fax_inbox); + if (is_file("/usr/local/bin/tiff2pdf")) { + exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif"); + } + if (is_file("/usr/bin/tiff2pdf")) { + exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif"); + } + } + if ($_REQUEST['box'] == 'sent') { + chdir($dir_fax_sent); + if (is_file("/usr/local/bin/tiff2pdf")) { + exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif"); + } + if (is_file("/usr/bin/tiff2pdf")) { + exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif"); + } + } + } + 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 "
".$text['table-file']."".$text['table-view']."
".$row['fax_uuid']." ".$row['fax_mode']." 
\n"; + if ($_REQUEST['box'] == 'inbox') { + echo " \n"; + } + if ($_REQUEST['box'] == 'sent') { + echo " \n"; + } + echo " $file_name"; + echo " "; + echo " \n"; + if ($_REQUEST['box'] == 'inbox') { + $dir_fax = $dir_fax_inbox; + $type = "fax_inbox"; + } + if ($_REQUEST['box'] == 'sent') { + $dir_fax = $dir_fax_sent; + $type = "fax_sent"; + } + if (file_exists($dir_fax.'/'.$file_name.".pdf")) { + echo " \n"; + echo " PDF"; + echo " "; + } + else { + echo " \n"; + } + echo " ".basename($row['fax_file_path'])." PDF ".$row['fax_number']." ".$row['fax_file_type']." ".basename($row['fax_file_path'])." ".$row['fax_caller_id_name']." ".$row['fax_caller_id_number']." ".date("F d Y H:i:s", strtotime($row['fax_date']))." ".$row['fax_epoch']." ".$row['fax_base64']." "; + echo " "; //if (permission_exists('fax_file_edit')) { // echo "$v_link_label_edit"; //}