28require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
40 public $version =
'dolibarr';
42 public $prefix =
'PJ';
54 public $nom =
'Simple';
59 public $name =
'Simple';
68 public function info($langs)
71 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
82 return $this->prefix.
"0501-0001";
95 global
$conf, $langs, $db;
100 $posindice = strlen($this->prefix) + 6;
101 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
102 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet";
103 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
104 $sql .=
" AND entity = ".$conf->entity;
105 $resql = $db->query($sql);
107 $row = $db->fetch_row($resql);
109 $coyymm = substr($row[0], 0, 6);
113 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
116 $langs->load(
"errors");
117 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
135 $posindice = strlen($this->prefix) + 6;
136 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet";
138 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
139 $sql .=
" AND entity IN (".getEntity(
'projectnumber', 1, $project).
")";
141 $resql = $db->query($sql);
143 $obj = $db->fetch_object($resql);
145 $max = intval($obj->max);
150 dol_syslog(
"mod_project_simple::getNextValue", LOG_DEBUG);
154 $date = (empty($project->date_c) ?
dol_now() : $project->date_c);
160 if ($max >= (pow(10, 4) - 1)) {
163 $num = sprintf(
"%04d", $max + 1);
166 dol_syslog(
"mod_project_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
167 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class parent for numbering modules of tasks.
Class to manage the numbering module Simple for project references.
info($langs)
Return description of numbering module.
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 module values.
getNextValue($objsoc, $project)
Return next value.
dol_now($mode='auto')
Return date for now.
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...