Quote improvements

This commit is contained in:
Jeroen Peelaerts
2020-05-21 01:24:01 +02:00
committed by jekkos
parent 458856668d
commit 46d957f5b4
4 changed files with 49 additions and 12 deletions

View File

@@ -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']);
}
/**

View File

@@ -0,0 +1,26 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Token_year_quote_count class
*/
class Token_year_quote_count extends Token
{
public function __construct()
{
parent::__construct();
$this->CI->load->model('Sale');
}
public function token_id()
{
return 'QCO';
}
public function get_value()
{
return $this->CI->Sale->get_quote_number_for_year();
}
}
?>

View File

@@ -33,11 +33,13 @@
</tr>
<tr>
<td id="company-title">
<pre><?php echo $this->config->item('company'); ?></pre>
<pre><?php echo $company_info; ?></pre>
<div id="company">
<?php echo $this->config->item('company'); ?>
<?php echo nl2br($company_info); ?>
</div>
</td>
<td id="meta">
<table align="right">
<table id="meta-content" align="right">
<tr>
<td class="meta-head"><?php echo $this->lang->line('sales_quote_number');?> </td>
<td><div><?php echo $quote_number; ?></div></td>
@@ -135,11 +137,10 @@
</table>
<div id="terms">
<textarea id="sale_return_policy">
<div id="sale_return_policy">
<h5>
<textarea rows="5" cols="6"><?php echo nl2br($this->config->item('payment_message')); ?></textarea>
<textarea rows="5" cols="6"><?php echo empty($comments) ? '' : $this->lang->line('sales_comments') . ': ' . $comments; ?></textarea>
<textarea rows="5" cols="6"><?php echo $this->config->item('quote_default_comments'); ?></textarea>
<div><?php echo nl2br($this->config->item('payment_message')); ?></div>
<div><?php echo $this->lang->line('sales_comments') . ': ' . (empty($comments) ? $this->config->item('quote_default_comments') : $comments); ?></div>
</h5>
<?php echo nl2br($this->config->item('return_policy')); ?>
</div>

View File

@@ -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"