25require_once DOL_DOCUMENT_ROOT.
'/core/modules/holiday/modules_holiday.php';
36 public $version =
'dolibarr';
38 public $prefix =
'HL';
50 public $nom =
'Madonna';
55 public $name =
'Madonna';
60 public $code_auto = 1;
69 public function info($langs)
72 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
83 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.
"holiday";
103 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
104 $sql .=
" AND entity = ".$conf->entity;
106 $resql = $db->query($sql);
108 $row = $db->fetch_row($resql);
110 $coyymm = substr($row[0], 0, 6);
114 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
115 $langs->load(
"errors");
116 $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.
"holiday";
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);
149 dol_syslog(
"mod_holiday_madonna::getNextValue", LOG_DEBUG);
153 $date = $holiday->date_debut;
156 if ($max >= (pow(10, 4) - 1)) {
159 $num = sprintf(
"%04s", $max + 1);
162 dol_syslog(
"mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm.
"-".$num);
163 return $this->prefix.$yymm.
"-".$num;
Parent class for all holidays numbering modules.
Class to manage contract numbering rules madonna.
getExample()
Return numbering example.
canBeActivated($object)
Test if existing numbers make problems with numbering.
info($langs)
Return default description of numbering model.
holiday_get_num($fuser, $objforref)
Return next value.
getNextValue($objsoc, $holiday)
Return next 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).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.