25require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
36 public $version =
'dolibarr';
38 public $prefix =
'CO';
48 public $name =
'Marbre';
58 if ((
float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code !=
'FR') {
69 public function info($langs)
72 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
83 return $this->prefix.
"0501-0001";
96 global $conf, $langs, $db;
101 $posindice = strlen($this->prefix) + 6;
102 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
104 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
105 $sql .=
" AND entity = ".$conf->entity;
107 $resql = $db->query($sql);
109 $row = $db->fetch_row($resql);
111 $coyymm = substr($row[0], 0, 6);
115 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
116 $langs->load(
"errors");
117 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
136 $posindice = strlen($this->prefix) + 6;
137 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
139 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
140 $sql .=
" AND entity IN (".getEntity(
'ordernumber', 1, $object).
")";
142 $resql = $db->query($sql);
144 $obj = $db->fetch_object($resql);
146 $max = intval($obj->max);
151 dol_syslog(
"mod_commande_marbre::getNextValue", LOG_DEBUG);
156 $date = $object->date;
159 if ($max >= (pow(10, 4) - 1)) {
162 $num = sprintf(
"%04s", $max + 1);
165 dol_syslog(
"mod_commande_marbre::getNextValue return ".$this->prefix.$yymm.
"-".$num);
166 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of Sale Orders.
Class to manage Sales Order numbering rules Marbre.
__construct()
Constructor.
info($langs)
Return description of numbering module.
getNextValue($objsoc, $object)
Return next free value.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
commande_get_num($objsoc, $objforref)
Return next free value.
getExample()
Return an example of numbering.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.