27require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
38 public $version =
'dolibarr';
43 public $prefix =
'CO';
53 public $name =
'Marbre';
63 if ((
float)
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL') >= 16.0 && $mysoc->country_code !=
'FR') {
74 public function info($langs)
77 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
88 return $this->prefix.
"0501-0001";
101 global
$conf, $langs, $db;
106 $posindice = strlen($this->prefix) + 6;
107 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
109 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
110 $sql .=
" AND entity = ".$conf->entity;
112 $resql = $db->query($sql);
114 $row = $db->fetch_row($resql);
116 $coyymm = substr($row[0], 0, 6);
120 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
121 $langs->load(
"errors");
122 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
141 $posindice = strlen($this->prefix) + 6;
142 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande";
144 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
145 $sql .=
" AND entity IN (".getEntity(
'ordernumber', 1,
$object).
")";
147 $resql = $db->query($sql);
149 $obj = $db->fetch_object($resql);
151 $max = intval($obj->max);
156 dol_syslog(
"mod_commande_marbre::getNextValue", LOG_DEBUG);
164 if ($max >= (pow(10, 4) - 1)) {
167 $num = sprintf(
"%04d", $max + 1);
170 dol_syslog(
"mod_commande_marbre::getNextValue return ".$this->prefix.$yymm.
"-".$num);
171 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).
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...