28require_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
39 public $version =
'dolibarr';
44 public $prefix =
'FI';
56 public $nom =
'pacific';
61 public $name =
'pacific';
70 public function info($langs)
73 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
83 return $this->prefix.
"0501-0001";
95 global $langs,
$conf, $db;
97 $langs->load(
"bills");
102 $posindice = strlen($this->prefix) + 6;
103 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
104 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter";
105 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
106 $sql .=
" WHERE entity = ".$conf->entity;
108 $resql = $db->query($sql);
110 $row = $db->fetch_row($resql);
112 $fayymm = substr($row[0], 0, 6);
116 if (!$fayymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $fayymm)) {
119 $langs->load(
"errors");
120 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
137 $posindice = strlen($this->prefix) + 6;
138 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter";
140 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
141 $sql .=
" AND entity = ".$conf->entity;
144 $resql = $db->query($sql);
146 $obj = $db->fetch_object($resql);
148 $max = intval($obj->max);
159 if ($max >= (pow(10, 4) - 1)) {
162 $num = sprintf(
"%04d", $max + 1);
165 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...