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);
153 $yymm = strftime(
"%y%m", $date);
155 if ($max >= (pow(10, 4) - 1)) {
158 $num = sprintf(
"%04s", $max + 1);
161 dol_syslog(
"mod_project_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
162 return $this->prefix.$yymm.
"-".$num;
Classe mere des modeles de numerotation des references de projets.
Class to manage the numbering module Simple for project references.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
project_get_num($objsoc=0, $project='')
Return next reference not yet used as a reference.
info()
Return description of numbering module.
getExample()
Return an example of numbering module values.
getNextValue($objsoc, $project)
Return next value.
if(isModEnabled('facture') &&!empty($user->rights->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') &&!empty($user->rights->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)) $resql
Social contributions to pay.
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.