diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 1e826af3..b3b5af8d 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -8,7 +8,7 @@ use App\Models\InvoiceModel; use App\Helpers\NotificationHelper; use Mpdf\Mpdf; - +use Dompdf\Dompdf; class Invoice extends BaseController { ## For Invoice Listing.. @@ -670,14 +670,30 @@ $encodedUrl = urlencode($url); // print_r($invoiceItems);die(); // Create an mPDF object - $mpdf = new Mpdf(); + $mpdf = new Mpdf([ + 'mode' => '', + 'format' => 'A5', + 'default_font_size' => 0, + 'default_font' => '', + 'margin_left' => 2, + 'margin_right' => 2, + 'margin_top' => 6, + 'margin_bottom' => 6, + 'margin_header' => 6, + 'margin_footer' =>-30, + 'orientation' => 'P', + ]); + + + $mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true; // Set PDF properties $mpdf->SetTitle('Invoice'); $mpdf->SetAuthor($data[0]->company_name); $mpdf->SetCreator(''); + $htmlFooter='
';
$mpdf->setHTMLFooter($htmlFooter);
// Generate the PDF content (HTML)
@@ -696,6 +712,50 @@ $encodedUrl = urlencode($url);
// Output the PDF to the browser for download
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
}
+ // public function generate_invoice_pdf($id)
+ // {
+ // // Fetch the invoice data based on $invoice_id
+ // $model = new InvoiceModel();
+ // $data = $model->getInvoiceData($id);
+ // $invoiceItems = $model->getInvoiceItems($id, 'groupby');
+
+ // foreach ($invoiceItems as $index => $singleItem) {
+ // $productImgs = $model->getProductImgs($singleItem->product);
+ // $invoiceItems[$index]->imgs = $productImgs;
+ // }
+ // $invoice_type = $data[0]->invoice_type;
+ // // Create a DOMPDF instance
+ // $dompdf = new Dompdf();
+
+ // // Set PDF properties
+ // $options = $dompdf->getOptions();
+ // $options->set("isHtml5ParserEnabled", true);
+
+ // // Set paper size and orientation
+ // $dompdf->setPaper('A5', 'portrait');
+
+ // // Generate the PDF content (HTML)
+ // if ($data[0]->status === 'Draft') {
+ // // Add a watermark for draft status
+ // $dompdf->set_option('page_script', function ($pageNumber, $pageCount, $canvas) {
+ // $canvas->text(20, 20, 'Draft');
+ // });
+
+ // }
+
+ // // Generate the PDF content (HTML) with data
+ // $html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems, 'invoice_type' => $invoice_type, 'invoiceTerms' => $data]);
+
+ // // Load HTML into the DOMPDF instance
+ // $dompdf->loadHtml($html);
+
+ // // Render PDF (first pass to get the number of pages)
+ // $dompdf->render();
+
+ // // Output the PDF to the browser for download
+ // $dompdf->stream('invoice_' . date('Y-m-d H-i-s') . '.pdf', array('Attachment' => 0));
+ // }
+
public function print_address($id)
{
// Fetch the invoice data based on $id
diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php
index b194dc34..bf162f0e 100755
--- a/app/Controllers/Notifications.php
+++ b/app/Controllers/Notifications.php
@@ -469,7 +469,7 @@ class Notifications extends BaseController
# Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
-
+// print_r($modifiedQuery);die;
if (empty($modifiedQuery)) {
$this->logger->info('There is no sub query');
return;
@@ -482,9 +482,11 @@ class Notifications extends BaseController
$this->logger->info("There is no customer expiring on date:{$newDate}");
return;
}
+
$emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL);
echo "Started.