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;
71 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
82 return $this->prefix.
"0501-0001";
93 global $conf, $langs, $db;
98 $posindice = strlen($this->prefix) + 6;
99 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
101 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
102 $sql .=
" AND entity = ".$conf->entity;
104 $resql = $db->query($sql);
106 $row = $db->fetch_row($resql);
108 $coyymm = substr($row[0], 0, 6);
112 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
113 $langs->load(
"errors");
114 $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.
"holiday";
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);
147 dol_syslog(
"mod_holiday_madonna::getNextValue", LOG_DEBUG);
151 $date = $holiday->date_debut;
152 $yymm = strftime(
"%y%m", $date);
154 if ($max >= (pow(10, 4) - 1)) {
157 $num = sprintf(
"%04s", $max + 1);
160 dol_syslog(
"mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm.
"-".$num);
161 return $this->prefix.$yymm.
"-".$num;
Parent class for all holidays numbering modules.
Class to manage contract numbering rules madonna.
getExample()
Return numbering example.
canBeActivated()
Test if existing numbers make problems with numbering.
holiday_get_num($fuser, $objforref)
Return next value.
info()
Return default description of numbering model.
getNextValue($objsoc, $holiday)
Return next value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.