27require_once DOL_DOCUMENT_ROOT.
'/core/modules/holiday/modules_holiday.php';
35 public $name =
'Madonna';
36 public $version =
'dolibarr';
43 public $prefix =
'HL';
59 public function info($langs)
62 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
73 return $this->prefix.
"0501-0001";
85 global
$conf, $langs, $db;
90 $posindice = strlen($this->prefix) + 6;
91 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
93 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
94 $sql .=
" AND entity = ".$conf->entity;
96 $resql = $db->query($sql);
98 $row = $db->fetch_row($resql);
100 $coyymm = substr($row[0], 0, 6);
104 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
105 $langs->load(
"errors");
106 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
124 $posindice = strlen($this->prefix) + 6;
125 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
126 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday";
127 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
128 $sql .=
" AND entity = ".$conf->entity;
130 $resql = $db->query($sql);
132 $obj = $db->fetch_object($resql);
134 $max = intval($obj->max);
139 dol_syslog(
"mod_holiday_madonna::getNextValue", LOG_DEBUG);
143 $date = $holiday->date_debut;
146 if ($max >= (pow(10, 4) - 1)) {
149 $num = sprintf(
"%04d", $max + 1);
152 dol_syslog(
"mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm.
"-".$num);
153 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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)
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...