Code comment
This commit is contained in:
parent
6708d4a4d4
commit
132d393d23
@ -177,12 +177,15 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next value not used or last value used
|
||||
* Return next value not used or last value used.
|
||||
* Note to increase perf of this numbering engine, you can create a calculated column and modify request to use this field instead for select:
|
||||
* ALTER TABLE llx_facture ADD COLUMN calculated_numrefonly INTEGER AS (CASE SUBSTRING(ref FROM 1 FOR 2) WHEN 'FA' THEN CAST(SUBSTRING(ref FROM 10) AS SIGNED) ELSE 0 END) PERSISTENT;
|
||||
* ALTER TABLE llx_facture ADD INDEX calculated_numrefonly_idx (calculated_numrefonly);
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Facture $invoice Object invoice
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @return string Value
|
||||
* @return string Next ref value or last ref if $mode is 'last'
|
||||
*/
|
||||
public function getNextValue($objsoc, $invoice, $mode = 'next')
|
||||
{
|
||||
|
||||
@ -63,17 +63,20 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
|
||||
{
|
||||
global $langs;
|
||||
|
||||
return $langs->trans('SimpleNumRefModelDesc', $this->prefix.'0-');
|
||||
$textinfo = $langs->trans('SimpleNumRefModelDesc', $this->prefix.'0-');
|
||||
$textinfo .= '<br>'.$langs->trans('EachTerminalHasItsOwnCounter');
|
||||
|
||||
return $textinfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an example of numbering module values
|
||||
* Return an example of numbering module values
|
||||
*
|
||||
* @return string Example
|
||||
* @return string Example.
|
||||
*/
|
||||
public function getExample()
|
||||
{
|
||||
return $this->prefix.'0-0501-0001';
|
||||
return $this->prefix.'0-0501-0001'; // TC0-0501-0001
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,14 +92,14 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
|
||||
$pryymm = '';
|
||||
$max = '';
|
||||
|
||||
$pos_source = 0;
|
||||
$pos_source = 0; // POS source = Terminal ID
|
||||
|
||||
// First, we get the max value
|
||||
$posindice = strlen($this->prefix.$pos_source.'-____-') + 1;
|
||||
$posindice = strlen($this->prefix.$pos_source.'-____-') + 1; // So posindice is position after TCX-YYMM-
|
||||
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix.$pos_source."-____-%")."'";
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -118,25 +121,29 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next value
|
||||
* Return next value.
|
||||
* Note to increase perf of this numbering engine:
|
||||
* ALTER TABLE llx_facture ADD COLUMN calculated_numrefonly INTEGER AS (CASE SUBSTRING(ref FROM 1 FOR 2) WHEN 'TC' THEN CAST(SUBSTRING(ref FROM 10) AS SIGNED) ELSE 0 END) PERSISTENT;
|
||||
* ALTER TABLE llx_facture ADD INDEX calculated_numrefonly_idx (calculated_numrefonly);
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Facture $invoice Object invoice
|
||||
* @param string $mode 'next' for next value or 'last' for last value
|
||||
* @return string Next value
|
||||
* @return string Next ref value or last ref if $mode is 'last'
|
||||
*/
|
||||
public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
|
||||
{
|
||||
global $db;
|
||||
|
||||
$pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0;
|
||||
$pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0; // POS source = Terminal ID
|
||||
|
||||
// First, we get the max value
|
||||
$posindice = strlen($this->prefix.$pos_source.'-____-') + 1;
|
||||
$posindice = strlen($this->prefix.$pos_source.'-____-') + 1; // So posindice is position after TCX-YYMM-
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix.$pos_source)."-____-%'";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix.$pos_source."-____-%")."'";
|
||||
$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
||||
//$sql .= " and module_source = 'takepos'";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
@ -161,7 +168,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
|
||||
$ref = '';
|
||||
$sql = "SELECT ref as ref";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix.$pos_source)."-____-".$num."'";
|
||||
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix.$pos_source."-____-".$num)."'";
|
||||
$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
||||
$sql .= " ORDER BY ref DESC";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user