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.
Dated = ".$newDate."
There are ".count($queryResult)." persons
"; foreach ($queryResult as $inx => $row) { + $status = $row['status']; $userFirstName = $row['first_name']; $userLastName = $row['last_name']; $fullName = $userFirstName . ' ' . $userLastName; @@ -496,7 +498,7 @@ class Notifications extends BaseController $this->logger->info('There is no subcription Name'); continue; } - + if ($status === 'Approved') { # EXPIRAY_NOTIFY_TEMPLATE_EMAIL $emailTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_EMAIL); if (count($emailTemplateName) && !empty($emailTemplateName)) { @@ -558,8 +560,13 @@ class Notifications extends BaseController echo $history_msg."
"; continue; } + + } + else{ + $this->logger->info("status is Draft"); + } # EXPIRAY_NOTIFY_TEMPLATE_EMAIL Closed - + if ($status === 'Approved') { # EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP $whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP); // print_r($whatsappTemplateName);die; @@ -644,11 +651,17 @@ class Notifications extends BaseController echo "There is no Whatsapp template
"; continue; } + # EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP Closed } + else{ + $this->logger->info("statsu is draft"); + } + # Loop Closed echo "Process Completed
"; } +} # getExpCustomerDetail fns Closed ################################################################ diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index f37d6911..d8865f4b 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -96,11 +96,11 @@
- +
- +
diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php index 62eaec85..b6a32203 100644 --- a/app/Views/invoice_pdf_template.php +++ b/app/Views/invoice_pdf_template.php @@ -233,13 +233,7 @@ td.invoice-number { quantity ?> ₹unit_price, 2, '.', ',') ?> - - discount_type === '%') : ?> - discount_amount ?>% - discount_type === '₹') : ?> - ₹discount_amount, 2, '.', ',') ?> - - + ₹subtotal, 2, '.', ',') ?> diff --git a/app/Views/report_expired_customers.php b/app/Views/report_expired_customers.php index 993c49c5..bd9a6559 100644 --- a/app/Views/report_expired_customers.php +++ b/app/Views/report_expired_customers.php @@ -73,7 +73,7 @@ $(document).ready(function() { buttons: [ { extend: 'print', - title: 'Experired Invoice Report', + title: 'Expired Invoice Report', text: 'Print', customize: function(win) { // Exclude the first and last columns diff --git a/app/Views/user_form.php b/app/Views/user_form.php index 951cd811..7b41ff4c 100644 --- a/app/Views/user_form.php +++ b/app/Views/user_form.php @@ -271,48 +271,56 @@ $(document).ready(function () {