27require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
38 public $version =
'dolibarr';
40 public $prefix =
'CO';
50 public $name =
'Marbre';
60 if ((
float)
$conf->global->MAIN_VERSION_LAST_INSTALL >= 16.0 && $mysoc->country_code !=
'FR') {
71 public function info($langs)
74 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
85 return $this->prefix.
"0501-0001";
98 global
$conf, $langs, $db;
103 $posindice = strlen($this->prefix) + 6;
104 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
105 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
106 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
107 $sql .=
" AND entity = ".$conf->entity;
109 $resql = $db->query($sql);
111 $row = $db->fetch_row($resql);
113 $coyymm = substr($row[0], 0, 6);
117 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
118 $langs->load(
"errors");
119 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
138 $posindice = strlen($this->prefix) + 6;
139 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
141 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
142 $sql .=
" AND entity IN (".getEntity(
'ordernumber', 1,
$object).
")";
144 $resql = $db->query($sql);
146 $obj = $db->fetch_object($resql);
148 $max = intval($obj->max);
153 dol_syslog(
"mod_commande_marbre::getNextValue", LOG_DEBUG);
161 if ($max >= (pow(10, 4) - 1)) {
164 $num = sprintf(
"%04d", $max + 1);
167 dol_syslog(
"mod_commande_marbre::getNextValue return ".$this->prefix.$yymm.
"-".$num);
168 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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)
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...