27require_once DOL_DOCUMENT_ROOT.
'/core/modules/holiday/modules_holiday.php';
35 public $name =
'Madonna';
36 public $version =
'dolibarr';
41 public $position = 10;
49 public $prefix =
'HL';
65 public function info($langs)
68 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
79 return $this->prefix.
"0501-0001";
91 global
$conf, $langs, $db;
96 $posindice = strlen($this->prefix) + 6;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
99 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
100 $sql .=
" AND entity = ".$conf->entity;
102 $resql =
$db->query($sql);
104 $row =
$db->fetch_row($resql);
106 $coyymm = substr($row[0], 0, 6);
110 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
111 $langs->load(
"errors");
112 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
130 $posindice = strlen($this->prefix) + 6;
131 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
133 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
134 $sql .=
" AND entity = ".$conf->entity;
136 $resql =
$db->query($sql);
138 $obj =
$db->fetch_object($resql);
140 $max = intval($obj->max);
145 dol_syslog(
"mod_holiday_madonna::getNextValue", LOG_DEBUG);
149 $date = $holiday->date_debut;
152 if ($max >= (pow(10, 4) - 1)) {
155 $num = sprintf(
"%04d", $max + 1);
158 dol_syslog(
"mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm.
"-".$num);
159 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.