27require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
38 public $version =
'dolibarr';
43 public $prefix =
'CO';
53 public $position = 10;
58 public $name =
'Marbre';
79 public function info($langs)
82 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
93 return $this->prefix.
"0501-0001";
106 global $conf, $langs, $db;
111 $posindice = strlen($this->prefix) + 6;
112 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
113 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
114 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
115 $sql .=
" AND entity = ".$conf->entity;
117 $resql = $db->query($sql);
119 $row = $db->fetch_row($resql);
121 $coyymm = substr($row[0], 0, 6);
125 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
126 $langs->load(
"errors");
127 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
146 $posindice = strlen($this->prefix) + 6;
147 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
148 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
149 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
150 $sql .=
" AND entity IN (".getEntity(
'ordernumber', 1,
$object).
")";
152 $resql = $db->query($sql);
154 $obj = $db->fetch_object($resql);
156 $max = intval($obj->max);
161 dol_syslog(
"mod_commande_marbre::getNextValue", LOG_DEBUG);
169 if ($max >= (pow(10, 4) - 1)) {
172 $num = sprintf(
"%04d", $max + 1);
175 dol_syslog(
"mod_commande_marbre::getNextValue return ".$this->prefix.$yymm.
"-".$num);
176 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
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...
getExample()
Return an example of numbering.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.