File manager - Edit - /home/autoph/public_html/connectv1/print_nobcat_report.php
Back
<?php ini_set('max_execution_time', '0'); set_time_limit(0); //same code above ini_set('memory_limit','-1'); date_default_timezone_set('Asia/Manila'); include('cfg/db.php'); include_once("api/controllers/utility.php"); if(!isset($_SESSION['user']['id'])){ header('location: home.php'); return; } $utility = new Utility(); $current_user = $_SESSION['user']['id']; if(!(isset($global_action_permissions['5']['45']) && in_array("2", $global_action_permissions['5']['45']))){ echo "You are not allowed to do this action."; exit; } $generated_by = ""; $user_role = $db->select("SELECT employee_role_id FROM employee_account WHERE id = '$current_user'"); if($user_role == 45 || $user_role == 1){ $generated_by = $_SESSION['user']['first_name'] . " " . $_SESSION['user']['last_name']; } else { $generated_by = $_SESSION['user']['first_name'] . " " . $_SESSION['user']['last_name'] . " (" . $_SESSION['user']['company_code'] . ")"; } // GLOBAL VARIABLES $company = 0; $dealer = 0; $message_type = ""; $delivery_type = ""; $reason = ""; $company_q = ""; $dealer_q = ""; $message_type_q = ""; $delivery_type_q = ""; $reason_q = ""; $message_type_str = ""; $delivery_type_str = ""; $reason_str = ""; $message_type_str_2 = ""; $delivery_type_str_2 = ""; $reason_str_2 = ""; $uuid = $db->select("SELECT UUID()"); // if(isset($_REQUEST['company']) && $_REQUEST['company'] != 0){ // $company = $db->escape($_REQUEST['company']); // $company_q = " AND tbs.company_id = '$company' "; // } // if(isset($_REQUEST['dealer']) && $_REQUEST['dealer'] != 0){ // $dealer = $db->escape($_REQUEST['dealer']); // $dealer_q = " AND tbs.dealer_id = '$dealer' "; // } // if(isset($_REQUEST['message_type']) && $_REQUEST['message_type'] != ""){ // $message_type = $db->escape($_REQUEST['message_type']); // $message_type_q = " AND tbs.type = '$message_type' "; // } // if(isset($_REQUEST['delivery_type']) && $_REQUEST['delivery_type'] != ""){ // $delivery_type = $db->escape($_REQUEST['delivery_type']); // $delivery_type_q = " AND tbs.delivery_type = '$delivery_type' "; // } // if(isset($_REQUEST['reason']) && $_REQUEST['reason'] != ""){ // $reason = $db->escape($_REQUEST['reason']); // $reason_q = " AND tbs.reason = '$reason' "; // } // $mask_contact = $db->escape($_REQUEST['mask']); $count = " COUNT(*) "; // $fields = " concat(tbs.first_name, ' ', tbs.last_name) AS name, DATE_FORMAT(tbs.datetime, '%b %d, %Y') AS action_date, tbs.cited_contact, sc.code AS company, sd.name AS dealer, tbs.type, tbs.delivery_type, tbs.reason "; // $query_print = "SELECT %s // FROM `source_nature_of_business` snob // WHERE 1 %s %s %s %s %s GROUP BY tbs.cited_contact ORDER BY tbs.datetime DESC"; // echo sprintf($query_print, $fields, $company_q, $dealer_q, $message_type_q, $delivery_type_q, $reason_q); return; // $fetch_print_subs_list = $db->sql_query(sprintf($query_print, $fields, $company_q, $dealer_q, $message_type_q, $delivery_type_q, $reason_q)); // $fetch_print_subs_count = $db->select("SELECT COUNT(*) FROM (".sprintf($query_print, $count, $company_q, $dealer_q, $message_type_q, $delivery_type_q, $reason_q).") AS count"); $query = "SELECT `id`, `name` FROM `source_nature_of_business` WHERE 1 AND `status` = 1 ORDER BY `category_id`, `name` ASC "; $fetch = $db->sql_query($query); $fetch_count= $db->select("SELECT COUNT(1) FROM `source_nature_of_business` WHERE 1 AND `status` = 1 ORDER BY `category_id`, `name` ASC "); $pdf_file_name = strtr($db -> cipher($uuid, true), "+/=", "-_~" ).'.'.'pdf'; $filename = 'sms/report_generation/subscription/data/'.strtr($db->cipher($uuid, true), "+/", "-_" ).'.'.'php'; $fp = fopen($filename, 'w'); // $col_width = array(7, 46, 34, 29, 28, 28, 27); // $col_header = array('No.', 'Name','Company/Dealer','Cited Contact', 'Type', 'Delivery', 'Reason'); // $mask_contact == 0 ? $col_width = array(10, 46, 34, 29, 17, 10, 27, 26) : $col_width = array(10, 59, 47, 17, 13, 27, 26); // $mask_contact == 0 ? $col_header = array('No.', 'Name', 'Company/Dealer', 'Cited Contact', 'Type', 'Delivery', 'Reason', 'Action Date') : $col_header = array('No.', 'Name', 'Company/Dealer', 'Type', 'Delivery', 'Reason', 'Action Date'); $col_width = array(10, 90, 100); $col_header = array('No.', 'ID', 'Nature of Business'); $string = implode(';',array_map('replaceExistingSemiColon', $col_header)); fwrite($fp, $string.PHP_EOL); $data_to_insert = array(); $ctr = 1; foreach($fetch AS $data){ $data_to_insert = array( $ctr, $data['id'], $data['name'] ); $ctr++; $string = implode(';', array_map('replaceExistingSemiColon', $data_to_insert)); fwrite($fp, $string.PHP_EOL); } // foreach($fetch_print_subs_list AS $row){ // $eng_message_type = $row['type']; // $eng_delivery_type = $row['delivery_type']; // $eng_reason = $row['reason']; // if($eng_message_type == 1){ // $message_type_str = "Birthday"; // $message_type_str_2 = "Birthday"; // } // else if($eng_message_type == 2){ // $message_type_str = "Insurance"; // $message_type_str_2 = "Insurance"; // } // else if($eng_message_type == 3){ // $message_type_str = "Thank you"; // $message_type_str_2 = "TY"; // } // if($eng_delivery_type == 1){ // $delivery_type_str = "Email"; // } // else if($eng_delivery_type == 2){ // $delivery_type_str = "SMS"; // } // if($eng_reason == 1){ // $reason_str = "This is not me"; // $reason_str_2 = "Notme"; // } // else if($eng_reason == 2){ // $reason_str = "Just unsubscribe"; // $reason_str_2 = "Unsubs"; // } // if($mask_contact == 0){ // $data_to_insert = array( // $ctr, // $row['name'], // $row['company'] . "/" . $row['dealer'], // $row['cited_contact'], // $message_type_str, // $delivery_type_str, // $reason_str, // $row['action_date'] // ); // } // else { // $data_to_insert = array( // $ctr, // $row['name'], // $row['company'] . "/" . $row['dealer'], // $message_type_str, // $delivery_type_str, // $reason_str, // $row['action_date'] // ); // } // // if($mask == 0){ // // $data_to_insert = array( // // $ctr, // // $row['name'], // // $row['cited_contact'], // // $row['company'], // // $row['dealer'], // // $message_type_str // // ); // // } // // else if($mask == 1){ // // $data_to_insert = array( // // $ctr, // // $row['name'], // // "+" . mask($row['mobile_number'], 5, 1), // // $row['company'], // // $row['dealer'], // // $status_str // // ); // // } // $ctr++; // $string = implode(';', array_map('replaceExistingSemiColon', $data_to_insert)); // fwrite($fp, $string.PHP_EOL); // } fclose($fp); // $company_header = ""; $dealer_header = ""; $message_type_header = ""; $delivery_type_header = ""; $reason_header = ""; $other_filter_header = ""; // $company_filename = ""; $dealer_filename = ""; $other_filter_filename = ""; $mask_header = ""; $mask_filename = ""; // $company == 0 ? $company_header = "ALL" : $company_header = $db->select("SELECT code FROM source_company WHERE id = '$company'"); // $dealer == 0 ? $dealer_header = "ALL" : $dealer_header = $db->select("SELECT code FROM source_dealer WHERE id = '$dealer'"); // $message_type == "" ? $message_type_header = "" : $message_type_header = $message_type_str; // $delivery_type == "" ? $delivery_type_header = "" : $delivery_type_header = $delivery_type_str; // $reason == "" ? $reason_header = "" : $reason_header = $reason_str; // GENERATE PDF include('include/fpdf183/mc_table_nobcat.php'); // $col_width = array(7, 46, 34, 29, 28, 28, 27); // $company_header == "ALL" ? $company_filename = "" : $company_filename = "_" . $company_header; // $dealer_header == "ALL" ? $dealer_filename = "" : $dealer_filename = "_" . $dealer_header; // if($message_type_header == "") { $other_filter_header = ""; } else { $other_filter_header = strtoupper($message_type_str_2) . " "; } // if($delivery_type_header != "") { $other_filter_header = $other_filter_header . strtoupper($delivery_type_str) . " "; } // if($reason_header != "") { $other_filter_header = $other_filter_header . strtoupper($reason_str_2) . " "; } // if($other_filter_header == ""){ $other_filter_header = "None"; } else { $other_filter_header = strtr(trim($other_filter_header), " ", ", "); } // $other_filter_header == "ALL" ? $other_filter_filename = "" : $other_filter_filename = "_" . strtr(trim($other_filter_header), ",", "_"); $pdf = new PDF_MC_Table('P','mm','Legal'); $title = 'AutoHub - Subscription Report'; $pdf->SetTitle($title); $pdf->AddPage(); $pdf->SetFont('Arial', '', 10); // $pdf_request_data[] = array('Company', ': ', $company_header); // $pdf_request_data[] = array('Dealer', ': ', $dealer_header); // $pdf_request_data[] = array('Filters', ': ', $other_filter_header); // $pdf_request_data[] = array('Total Data Count', ': ', number_format($fetch_print_subs_count)); $pdf_request_data[] = array('Total Data Count', ': ', number_format($fetch_count)); // $pdf_request_data[] = array('Generated by', ': ', $generated_by); $request_header_widths = array(30, 10, 92, 25, 35); $pdf->SetWidths($request_header_widths); foreach($pdf_request_data as $row){ $pdf->Row($row, false); } $pdf->Ln(2); $pdf->SetFont('Arial', '', 11); $pdf->SetFillColor(255,255,255); $pdf->Ln(5); $pdf->SetFont('Arial', '', 8); $pdf_request_data = $pdf->LoadData('sms/report_generation/subscription/data/'.strtr($db -> cipher($uuid, true), "+/", "-_" ).'.'.'php'); $pdf->FancyTable($pdf_request_data, $col_width); $filename = "SUBSCRIPTION_REPORT.pdf"; // $filename = "SUBSCRIPTION_REPORT" . $company_filename . $dealer_filename . $other_filter_filename . ".pdf"; $pdf->Output($filename, 'D'); if($count > 0){ $return_array['status'] = 1; $return_array['message'] = "Request Generated"; $return_array['file'] = str_replace(".pdf", "", $pdf_file_name); $file = str_replace(".pdf", "", $pdf_file_name); } else { $return_array['status'] = 0; $return_array['message'] = "Request Generation Failed"; } echo json_encode($return_array); function replaceExistingSemiColon($s){ return str_replace(";", " ", $s); } function removeHyphen($s){ return str_replace("-", "", $s); } function cleanStr($string) { $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. } function mask($str, $first, $last) { $str = cleanStr($str); $len = strlen($str); $toShow = $first + $last; return substr($str, 0, $len <= $toShow ? 0 : $first).str_repeat("*", $len - ($len <= $toShow ? 0 : $toShow)).substr($str, $len - $last, $len <= $toShow ? 0 : $last); } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings