27require_once DOL_DOCUMENT_ROOT.
'/core/modules/holiday/modules_holiday.php';
35 public $name =
'Madonna';
36 public $version =
'dolibarr';
38 public $position = 10;
46 public $prefix =
'HL';
62 public function info($langs)
65 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
76 return $this->prefix.
"0501-0001";
88 global $conf, $langs, $db;
93 $posindice = strlen($this->prefix) + 6;
94 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
96 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
97 $sql .=
" AND entity = ".$conf->entity;
99 $resql = $db->query($sql);
101 $row = $db->fetch_row($resql);
103 $coyymm = substr($row[0], 0, 6);
107 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
108 $langs->load(
"errors");
109 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
127 $posindice = strlen($this->prefix) + 6;
128 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
130 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
131 $sql .=
" AND entity = ".$conf->entity;
133 $resql = $db->query($sql);
135 $obj = $db->fetch_object($resql);
137 $max = intval($obj->max);
142 dol_syslog(
"mod_holiday_madonna::getNextValue", LOG_DEBUG);
146 $date = $holiday->date_debut;
149 if ($max >= (pow(10, 4) - 1)) {
152 $num = sprintf(
"%04d", $max + 1);
155 dol_syslog(
"mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm.
"-".$num);
156 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
Parent class for all holidays numbering modules.
Class to manage holiday 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.
__construct()
Constructor.
getNextValue($objsoc, $holiday)
Return next value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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.