From 46d957f5b41bfa68b8e7a27474b720d70ef28e81 Mon Sep 17 00:00:00 2001 From: Jeroen Peelaerts Date: Thu, 21 May 2020 01:24:01 +0200 Subject: [PATCH] Quote improvements --- application/models/Sale.php | 18 ++++++++++--- .../models/tokens/Token_year_quote_count.php | 26 +++++++++++++++++++ application/views/sales/quote_email.php | 15 ++++++----- composer.json | 2 +- 4 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 application/models/tokens/Token_year_quote_count.php diff --git a/application/models/Sale.php b/application/models/Sale.php index fba5a0feb..6180f0aee 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -454,19 +454,29 @@ class Sale extends CI_Model return $this->db->get(); } + public function get_invoice_number_for_year($year = '', $start_from = 0) + { + return $this->_get_number_for_year('invoice_number', $year, $start_from); + } + + public function get_quote_number_for_year($year = '', $start_from = 0) + { + return $this->_get_number_for_year('quote_number', $year, $start_from); + } + /** * Gets invoice number by year */ - public function get_invoice_number_for_year($year = '', $start_from = 0) + public function _get_number_for_year($field, $year = '', $start_from = 0) { $year = $year == '' ? date('Y') : $year; - $this->db->select('COUNT( 1 ) AS invoice_number_year'); + $this->db->select('COUNT( 1 ) AS number_year'); $this->db->from('sales'); $this->db->where('DATE_FORMAT(sale_time, "%Y" ) = ', $year); - $this->db->where('invoice_number IS NOT NULL'); + $this->db->where("$field IS NOT NULL"); $result = $this->db->get()->row_array(); - return ($start_from + $result['invoice_number_year']); + return ($start_from + $result['number_year']); } /** diff --git a/application/models/tokens/Token_year_quote_count.php b/application/models/tokens/Token_year_quote_count.php new file mode 100644 index 000000000..18dce939a --- /dev/null +++ b/application/models/tokens/Token_year_quote_count.php @@ -0,0 +1,26 @@ +CI->load->model('Sale'); + } + + public function token_id() + { + return 'QCO'; + } + + public function get_value() + { + return $this->CI->Sale->get_quote_number_for_year(); + } +} +?> diff --git a/application/views/sales/quote_email.php b/application/views/sales/quote_email.php index fa2b180dc..a15f33a68 100644 --- a/application/views/sales/quote_email.php +++ b/application/views/sales/quote_email.php @@ -33,11 +33,13 @@ -
config->item('company'); ?>
-
+
+ config->item('company'); ?> + +
- +
@@ -135,11 +137,10 @@
lang->line('sales_quote_number');?>
- - - +
config->item('payment_message')); ?>
+
lang->line('sales_comments') . ': ' . (empty($comments) ? $this->config->item('quote_default_comments') : $comments); ?>
config->item('return_policy')); ?>
diff --git a/composer.json b/composer.json index af99eab87..569e8b537 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": "^5.6 || ^7.0", "codeigniter/framework": "^3.1.11", - "dompdf/dompdf": "^0.7", + "dompdf/dompdf": "^0.8.5", "tamtamchik/namecase": "^1.0", "paragonie/random_compat": "^2.0", "vlucas/phpdotenv": "^2.4"