FIX_PDF DOWNLOAD ISSUE
This commit is contained in:
parent
c26f52990b
commit
1d2935e946
@ -47,3 +47,4 @@ Options -Indexes
|
||||
# Disable server signature start
|
||||
ServerSignature Off
|
||||
# Disable server signature end
|
||||
AddType application/pdf .pdf
|
||||
|
||||
@ -33,7 +33,7 @@ class Invoice extends BaseController
|
||||
|
||||
$model = new InvoiceModel();
|
||||
$data['page_name'] = 'Online Invoice Details';
|
||||
$data['invoice'] = $model->getJoinedData($where, ['I.invoice_date', 'DESC']);
|
||||
$data['invoice'] = $model->getJoinedData($where, ['I.invoice_date', 'DESC']);
|
||||
$this->logger->info("Invoice: Listing Count ." . count($data['invoice']));
|
||||
$this->render_page('invoice_list', $data);
|
||||
} else {
|
||||
@ -889,7 +889,7 @@ public function create_or_update_subscription($invoice_id, $msg_flag_name = null
|
||||
$invoice_type = $data[0]->invoice_type;
|
||||
|
||||
// Create an mPDF object
|
||||
|
||||
ob_clean();
|
||||
$mpdf = new Mpdf([
|
||||
'mode' => '',
|
||||
'format' => [148, 210], // Set custom width and height in millimeters
|
||||
@ -916,6 +916,7 @@ public function create_or_update_subscription($invoice_id, $msg_flag_name = null
|
||||
<img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png"style=margin-top:70px;/> </div>';
|
||||
$mpdf->setHTMLFooter($htmlFooter);
|
||||
|
||||
|
||||
// Generate the PDF content (HTML)
|
||||
if ($data[0]->status === 'Draft') {
|
||||
// Set the watermark text and options
|
||||
@ -942,12 +943,24 @@ public function create_or_update_subscription($invoice_id, $msg_flag_name = null
|
||||
// echo $html;die;
|
||||
// Load HTML into the mPDF instance
|
||||
// print_r($html);die;
|
||||
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
|
||||
// Output the PDF to the browser for download
|
||||
// $mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
$mpdf->Output("invoice_" . $data[0]->invoice_number . '.pdf', 'D');
|
||||
//$mpdf->Output("invoice_" . $data[0]->invoice_number . '.pdf', 'D');
|
||||
|
||||
$filename = 'invoice_' . $data[0]->invoice_number.'.pdf'; // Filename based on invoice number
|
||||
// $mpdf->Output($filename . '.pdf', 'D'); // Generate and download the PDF with the specified filename
|
||||
$mpdf->Output($filename, 'D'); // Generate and download the PDF with the specified filename
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: inline; filename="invoice_' . $data[0]->invoice_number . '.pdf"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Cache-Control: private');
|
||||
header('Pragma: private');
|
||||
exit();
|
||||
// Set headers to force download with the correct filename
|
||||
|
||||
}
|
||||
|
||||
public function generate_invoice_pdf_preview($id)
|
||||
|
||||
@ -509,30 +509,75 @@ public function getInvoiceIdByMd5($md5Hash)
|
||||
|
||||
return null;
|
||||
}
|
||||
// public function getExpiredCustomers($f_date = null, $t_date = null)
|
||||
// {
|
||||
// $now = date('Y-m-d');
|
||||
// $futureDate = date('Y-m-d', strtotime($now . ' +30 days'));
|
||||
|
||||
// $query = $this->db->table('subscription as S'); // Define $query here
|
||||
|
||||
// if ($f_date !== null && $t_date !== null) {
|
||||
// $query->where('S.to_subscription >=', $f_date)
|
||||
// ->where('S.to_subscription <=', $t_date);
|
||||
// }
|
||||
|
||||
// $result = $query
|
||||
// ->select('S.customer_id,S.sub_id, S.from_subscription, S.to_subscription, C.first_name, C.last_name, C.email, C.mobile_no, S.scheme_id,B.short_code')
|
||||
// ->join('customers as C', 'C.customer_id = S.customer_id', 'left')
|
||||
// ->join('books as B', 'B.book_id = S.scheme_id', 'left')
|
||||
// ->where('S.isactive', 1)
|
||||
// ->where('S.to_subscription <', $futureDate)
|
||||
// ->get()
|
||||
// ->getResultArray();
|
||||
// // print_r($result);
|
||||
// // echo "<pre>";
|
||||
// // echo $this->db->getLastQuery();
|
||||
// // echo "</pre>";die;
|
||||
// echo $this->db->getLastQuery();
|
||||
// die();
|
||||
|
||||
// return $result;
|
||||
|
||||
// }
|
||||
public function getExpiredCustomers($f_date = null, $t_date = null)
|
||||
{
|
||||
$now = date('Y-m-d');
|
||||
$query = $this->db->table('subscription as S'); // Define $query here
|
||||
// Set timezone for accurate date calculation
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
|
||||
if ($f_date !== null && $t_date !== null) {
|
||||
// Calculate the date 30 days from now
|
||||
$futureDate = date('Y-m-d', strtotime('+30 days'));
|
||||
|
||||
// Initialize query builder
|
||||
$query = $this->db->table('subscription as S');
|
||||
|
||||
// Apply custom date range filter if both $f_date and $t_date are provided
|
||||
if (!empty($f_date) && !empty($t_date)) {
|
||||
$query->where('S.to_subscription >=', $f_date)
|
||||
->where('S.to_subscription <=', $t_date);
|
||||
|
||||
} else {
|
||||
$query->where('S.to_subscription >=', date('Y-m-d'))
|
||||
->where('S.to_subscription <=', $futureDate);
|
||||
}
|
||||
|
||||
// Build the query
|
||||
$result = $query
|
||||
->select('S.customer_id,S.sub_id, S.from_subscription, S.to_subscription, C.first_name, C.last_name, C.email, C.mobile_no, S.scheme_id,B.short_code')
|
||||
->select('S.customer_id, S.sub_id, S.from_subscription, S.to_subscription,
|
||||
C.first_name, C.last_name, C.email, C.mobile_no,
|
||||
S.scheme_id, B.short_code')
|
||||
->join('customers as C', 'C.customer_id = S.customer_id', 'left')
|
||||
->join('books as B', 'B.book_id = S.scheme_id', 'left')
|
||||
->where('S.isactive', 1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
// print_r($result);
|
||||
// echo "<pre>";
|
||||
// echo $this->db->getLastQuery();
|
||||
// echo "</pre>";die;
|
||||
return $result;
|
||||
->where('S.isactive', 1) // Only active subscriptions
|
||||
->get();
|
||||
|
||||
// Debugging: output the generated SQL query
|
||||
// echo $this->db->getLastQuery();
|
||||
// die();
|
||||
|
||||
// Fetch results as an associative array
|
||||
return $result->getResultArray();
|
||||
}
|
||||
|
||||
public function itemwise_report_data_with_publish_code($f_date = null, $t_date = null)
|
||||
{
|
||||
// Fetch invoice data
|
||||
|
||||
@ -10,29 +10,31 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.label-container {
|
||||
margin: 30px;
|
||||
/* margin: 30px;
|
||||
padding: 30px;
|
||||
border: 2px solid #000;
|
||||
/* border: 2px solid #000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
height: 100%; */
|
||||
/* position: relative; */
|
||||
}
|
||||
.from-address, .to-address {
|
||||
margin-bottom: 20px;
|
||||
/* margin-bottom: 20px; */
|
||||
|
||||
}
|
||||
.from-address {
|
||||
text-align: left;
|
||||
float: left;
|
||||
width: 100%;
|
||||
font-size: small;
|
||||
font-size: 11px;
|
||||
}
|
||||
.to-address {
|
||||
|
||||
float: right;
|
||||
width: 40%;
|
||||
clear: both;
|
||||
/* margin-top: 20px; Adjust for spacing in landscape */
|
||||
position: absolute;
|
||||
width: 48%;
|
||||
/* clear: both; */
|
||||
/* padding-left: 90%; */
|
||||
margin-top: 80px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@ -42,8 +44,8 @@
|
||||
<div class="label-container">
|
||||
<table width="100%" style="border-collapse: collapse;">
|
||||
<tr>
|
||||
<td width="30%" style="text-align: left;"><strong>From :</strong></td>
|
||||
<td width="70%" style="text-align: right;">
|
||||
<td width="30%" style="text-align: left;font-size: 11px;"><strong>From:</strong></td>
|
||||
<td width="70%" style="text-align: right;font-size: 11px;">
|
||||
<?php $label = $value->invoice_number == $value->wp_api_order_id ? "Order Number :" : "Invoice Number :"; ?>
|
||||
<b><?= $label; ?></b> <?= $value->invoice_number; ?>
|
||||
</td>
|
||||
@ -57,19 +59,20 @@
|
||||
<?= $value->company_state . "."; ?><br>
|
||||
<?= $value->company_mobile_no; ?>
|
||||
</div>
|
||||
|
||||
<!-- To Address -->
|
||||
<div class="to-address">
|
||||
<strong>To :</strong><br>
|
||||
<div class="to-address">
|
||||
<strong>To:</strong><br>
|
||||
<?= $value->customer_name ?><br>
|
||||
<?php if($value->customer_ship_address && ($value->saddr_id !== null || $value->saddr_id !== '')){ ?>
|
||||
<?= $value->customer_ship_address ? $value->customer_ship_address . " , <br>" : "" ?>
|
||||
<?= $value->customer_ship_address ? $value->customer_ship_address . ", <br>" : "" ?>
|
||||
<?= $value->customer_ship_city ? $value->customer_ship_city . " " : "" ?>
|
||||
<?= $value->customer_ship_postal_code ? " - " . $value->customer_ship_postal_code . "<br>" : ""; ?>
|
||||
<?= $value->customer_ship_state ? $value->customer_ship_state . ". <br>" : "" ?>
|
||||
<?php }else if ($value->saddr_id === null || $value->saddr_id === '') {
|
||||
echo $value->shipping_address ? $value->shipping_address.'<br>' : '';
|
||||
} ?>
|
||||
<?= $value->mobile_no ? "Mobile : " . $value->mobile_no . " ." : "" ?>
|
||||
<?= $value->mobile_no ? "Mobile : " . $value->mobile_no . "." : "" ?>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
|
||||
@ -171,15 +171,19 @@
|
||||
$notifications = $e['notifications'];
|
||||
$emailNotifications = array_filter($notifications, function($notification) {
|
||||
return $notification['mode'] === 'Email';
|
||||
});
|
||||
});
|
||||
|
||||
$lastNotification = end($emailNotifications);
|
||||
$lastStartDateTime = ($lastNotification && isset($lastNotification['start_date_time'])) ? $lastNotification['start_date_time'] : '';
|
||||
$startDateTime = $lastStartDateTime ? date('d/m/Y', strtotime($lastStartDateTime)) : '';
|
||||
|
||||
$startDateTime = $lastStartDateTime ? date('d/m/Y', strtotime($lastStartDateTime)) : '';
|
||||
$startDate = DateTime::createFromFormat('d/m/Y', $startDate); // Assuming format 'd/m/Y'
|
||||
$endDate = DateTime::createFromFormat('d/m/Y', $endDate); // Assuming format 'd/m/Y'
|
||||
$startDateTime = DateTime::createFromFormat('d/m/Y', $startDateTime);
|
||||
if(isset($lastNotification['receiving_status'])){
|
||||
//log_message('info','start date - '.$startDate.'end date - '.$endDate.'notification date - '.$startDateTime);
|
||||
if ($startDateTime >= $startDate && $startDateTime <= $endDate) {
|
||||
echo $startDateTime ;
|
||||
echo $startDateTime->format('d/m/Y');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -166,7 +166,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
|
||||
<div class="invalid-feedback"> Please select customer. </div>
|
||||
<div class="subscribedetails" style="display: none">
|
||||
<div id="schemeName"></div>
|
||||
<!-- <div id="schemeName"></div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1544,12 +1544,12 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
$(".subscribedetails").show(); // Change this line to use the class selector
|
||||
let message = "Earlier Membership : " + cm[0].title + " ( From: " + cm[0].formatted_from_subscription + " To: " + cm[0].formatted_to_subscription + " )" + text1 + text2;
|
||||
console.log(text1);
|
||||
$("#schemeName").text(message);
|
||||
// $("#schemeName").text(message);
|
||||
showAlert(message)
|
||||
} else {
|
||||
$(".subscribedetails").show(); // Change this line to use the class selector
|
||||
let message = "No Earlier Membership found";
|
||||
$("#schemeName").text(message);
|
||||
//$("#schemeName").text(message);
|
||||
showAlert(message)
|
||||
}
|
||||
},
|
||||
|
||||
@ -14,24 +14,25 @@
|
||||
}
|
||||
}
|
||||
#pdfPreviewModal .modal-dialog {
|
||||
width: 595px;
|
||||
/* width: 595px;
|
||||
height: 842px;
|
||||
top: -973px;
|
||||
left: 1018px;
|
||||
gap: 0px;
|
||||
opacity: 0px;
|
||||
opacity: 0px; */
|
||||
|
||||
/* max-width: 148mm; /* A5 width */
|
||||
/* width: auto;
|
||||
margin: 1.75rem auto; */
|
||||
max-width: 148mm;
|
||||
width: auto;
|
||||
margin: 1.75rem auto;
|
||||
}
|
||||
#pdfPreviewModal .modal-body {
|
||||
font-family: 'Times New Roman', Times, serif;
|
||||
font-size: 8pt;
|
||||
|
||||
}
|
||||
.table-responsive{
|
||||
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
font-size: 14npx;
|
||||
font-size: 14px;
|
||||
}
|
||||
#printPdfButton .ri-printer-line {
|
||||
font-size: 8px;
|
||||
@ -155,10 +156,10 @@
|
||||
|
||||
<!-- PDF content will be loaded here -->
|
||||
</div>
|
||||
<!-- <div class="modal-footer">
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -207,7 +208,8 @@
|
||||
<script>
|
||||
$(document).on('click', '.preview-pdf', function() {
|
||||
var invoiceId = $(this).data('invoice-id');
|
||||
|
||||
console.log('invoice id '+invoiceId);
|
||||
|
||||
// Send AJAX request to controller
|
||||
$.ajax({
|
||||
url: '<?= base_url('generate_invoice_pdf_preview/') ?>' + invoiceId,
|
||||
|
||||
@ -10,11 +10,11 @@
|
||||
}
|
||||
|
||||
/* Add your CSS styles here to format the invoice for mPDF */
|
||||
td {
|
||||
/* td { */
|
||||
/* display: flex;
|
||||
*/
|
||||
/* align-items: flex-start; */
|
||||
}
|
||||
/* } */
|
||||
|
||||
body {
|
||||
/* font-family: 'Times New Roman', Times, sans-serif; */
|
||||
@ -259,7 +259,7 @@
|
||||
<?php $serialNumber = 1; ?>
|
||||
<?php foreach ($invoiceItems as $item) : ?>
|
||||
<tr>
|
||||
<td style="display:flex;algin-items:flex-start">
|
||||
<td style="display:flex;align-items:flex-start">
|
||||
<?= $serialNumber++; ?>
|
||||
</td>
|
||||
<td><span style="font-size:10pt"><?= $item->title ?></span><br>
|
||||
|
||||
BIN
invoice_2024-2025-00000533.pdf
Normal file
BIN
invoice_2024-2025-00000533.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user