diff --git a/.htaccess b/.htaccess
index dbed322f..b917c5b9 100755
--- a/.htaccess
+++ b/.htaccess
@@ -47,3 +47,4 @@ Options -Indexes
# Disable server signature start
ServerSignature Off
# Disable server signature end
+AddType application/pdf .pdf
diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php
index 33fdc897..3ebc0645 100755
--- a/app/Controllers/Invoice.php
+++ b/app/Controllers/Invoice.php
@@ -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
';
$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)
diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php
index 84437ed1..540e2a58 100755
--- a/app/Models/InvoiceModel.php
+++ b/app/Models/InvoiceModel.php
@@ -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 "
"; +// // echo $this->db->getLastQuery(); +// // echo "";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 "
"; - // echo $this->db->getLastQuery(); - // echo "";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 diff --git a/app/Views/address_pdf_landscape_template.php b/app/Views/address_pdf_landscape_template.php index 2a3bff7e..68479364 100755 --- a/app/Views/address_pdf_landscape_template.php +++ b/app/Views/address_pdf_landscape_template.php @@ -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; } @@ -42,8 +44,8 @@
| From : | -+ | From: | +invoice_number == $value->wp_api_order_id ? "Order Number :" : "Invoice Number :"; ?> = $label; ?> = $value->invoice_number; ?> | @@ -57,19 +59,20 @@ = $value->company_state . "."; ?>