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') {
71 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
82 return $this->prefix.
"0501-0001";
94 global $conf, $langs, $db;
99 $posindice = strlen($this->prefix) + 6;
100 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
101 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
102 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
103 $sql .=
" AND entity = ".$conf->entity;
105 $resql = $db->query($sql);
107 $row = $db->fetch_row($resql);
109 $coyymm = substr($row[0], 0, 6);
113 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
114 $langs->load(
"errors");
115 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
134 $posindice = strlen($this->prefix) + 6;
135 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
137 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
138 $sql .=
" AND entity IN (".getEntity(
'ordernumber', 1, $object).
")";
140 $resql = $db->query($sql);
142 $obj = $db->fetch_object($resql);
144 $max = intval($obj->max);
149 dol_syslog(
"mod_commande_marbre::getNextValue", LOG_DEBUG);
154 $date = $object->date;
155 $yymm = strftime(
"%y%m", $date);
157 if ($max >= (pow(10, 4) - 1)) {
160 $num = sprintf(
"%04s", $max + 1);
163 dol_syslog(
"mod_commande_marbre::getNextValue return ".$this->prefix.$yymm.
"-".$num);
164 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of Sale Orders.
Class to manage Sales Order numbering rules Marbre.
info()
Return description of numbering module.
__construct()
Constructor.
getNextValue($objsoc, $object)
Return next free value.
canBeActivated()
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.