26require_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
37 public $version =
'dolibarr';
39 public $prefix =
'FI';
51 public $nom =
'pacific';
56 public $name =
'pacific';
65 public function info($langs)
68 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
78 return $this->prefix.
"0501-0001";
90 global $langs, $conf, $db;
92 $langs->load(
"bills");
97 $posindice = strlen($this->prefix) + 6;
98 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter";
100 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
101 $sql .=
" WHERE entity = ".$conf->entity;
103 $resql = $db->query($sql);
105 $row = $db->fetch_row($resql);
107 $fayymm = substr($row[0], 0, 6);
111 if (!$fayymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $fayymm)) {
114 $langs->load(
"errors");
115 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
132 $posindice = strlen($this->prefix) + 6;
133 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter";
135 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
136 $sql .=
" AND entity = ".$conf->entity;
138 $resql = $db->query($sql);
140 $obj = $db->fetch_object($resql);
142 $max = intval($obj->max);
149 $date = $object->datec;
152 if ($max >= (pow(10, 4) - 1)) {
155 $num = sprintf(
"%04s", $max + 1);
158 return $this->prefix.$yymm.
"-".$num;
Parent class numbering models of intervention sheet references.
Class to manage numbering of intervention cards with rule Pacific.
getNumRef($objsoc, $objforref)
Return next free value.
info($langs)
Return description of numbering module.
getExample()
Return an example of numbering.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objsoc=0, $object='')
Return next free value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).