28require_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
39 public $version =
'dolibarr';
41 public $prefix =
'FI';
53 public $nom =
'pacific';
58 public $name =
'pacific';
67 public function info($langs)
70 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
80 return $this->prefix.
"0501-0001";
92 global $langs,
$conf, $db;
94 $langs->load(
"bills");
99 $posindice = strlen($this->prefix) + 6;
100 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
101 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter";
102 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
103 $sql .=
" WHERE entity = ".$conf->entity;
105 $resql = $db->query($sql);
107 $row = $db->fetch_row($resql);
109 $fayymm = substr($row[0], 0, 6);
113 if (!$fayymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $fayymm)) {
116 $langs->load(
"errors");
117 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
134 $posindice = strlen($this->prefix) + 6;
135 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter";
137 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
138 $sql .=
" AND entity = ".$conf->entity;
140 $resql = $db->query($sql);
142 $obj = $db->fetch_object($resql);
144 $max = intval($obj->max);
157 if ($max >= (pow(10, 4) - 1)) {
160 $num = sprintf(
"%04d", $max + 1);
163 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
getNextValue($objsoc='', $object='')
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...
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).
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...