Go to the documentation of this file.
26 require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
38 public $version =
'dolibarr';
40 public $prefix =
'PJ';
52 public $nom =
'Simple';
57 public $name =
'Simple';
68 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
79 return $this->prefix.
"0501-0001";
91 global $conf, $langs, $db;
96 $posindice = strlen($this->prefix) + 6;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet";
99 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
100 $sql .=
" AND entity = ".$conf->entity;
101 $resql = $db->query(
$sql);
103 $row = $db->fetch_row($resql);
105 $coyymm = substr($row[0], 0, 6);
109 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
112 $langs->load(
"errors");
113 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
131 $posindice = strlen($this->prefix) + 6;
132 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet";
134 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
135 $sql .=
" AND entity IN (".getEntity(
'projectnumber', 1, $project).
")";
137 $resql = $db->query(
$sql);
139 $obj = $db->fetch_object($resql);
141 $max = intval($obj->max);
146 dol_syslog(
"mod_project_simple::getNextValue", LOG_DEBUG);
150 $date = (empty($project->date_c) ?
dol_now() : $project->date_c);
156 if ($max >= (pow(10, 4) - 1)) {
159 $num = sprintf(
"%04s", $max + 1);
162 dol_syslog(
"mod_project_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
163 return $this->prefix.$yymm.
"-".$num;
info()
Return description of numbering module.
project_get_num($objsoc=0, $project='')
Return next reference not yet used as a reference.
Classe mere des modeles de numerotation des references de projets.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getExample()
Return an example of numbering module values.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
Class to manage the numbering module Simple for project references.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
dol_now($mode='auto')
Return date for now.
getNextValue($objsoc, $project)
Return next value.