dolibarr  13.0.2
mod_holiday_immaculate.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011-2019 Juanjo Menent <jmenent@2byte.es>
3  * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  * or see https://www.gnu.org/
18  */
19 
26 require_once DOL_DOCUMENT_ROOT.'/core/modules/holiday/modules_holiday.php';
27 
32 {
37  public $version = 'dolibarr';
38 
42  public $error = '';
43 
49  public $nom = 'Immaculate';
50 
54  public $name = 'Immaculate';
55 
59  public $code_auto = 1;
60 
66  public function info()
67  {
68  global $db, $conf, $langs;
69 
70  $langs->load("bills");
71 
72  $form = new Form($db);
73 
74  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
75  $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
76  $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
77  $texte .= '<input type="hidden" name="action" value="updateMask">';
78  $texte .= '<input type="hidden" name="maskconstholiday" value="HOLIDAY_IMMACULATE_MASK">';
79  $texte .= '<table class="nobordernopadding" width="100%">';
80 
81  $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Holiday"), $langs->transnoentities("Holiday"));
82  $tooltip .= $langs->trans("GenericMaskCodes2");
83  $tooltip .= $langs->trans("GenericMaskCodes3");
84  $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Holiday"), $langs->transnoentities("Holiday"));
85  $tooltip .= $langs->trans("GenericMaskCodes5");
86 
87  $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
88  $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskholiday" value="'.$conf->global->HOLIDAY_IMMACULATE_MASK.'">', $tooltip, 1, 1).'</td>';
89  $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90  $texte .= '</tr>';
91  $texte .= '</table>';
92  $texte .= '</form>';
93 
94  return $texte;
95  }
96 
102  public function getExample()
103  {
104  global $conf, $langs, $user;
105 
106  $old_login = $user->login;
107  $user->login = 'UUUUUUU';
108  $numExample = $this->getNextValue($user, '');
109  $user->login = $old_login;
110 
111  if (!$numExample)
112  {
113  $numExample = $langs->trans('NotConfigured');
114  }
115  return $numExample;
116  }
117 
125  public function getNextValue($user, $holiday)
126  {
127  global $db, $conf;
128 
129  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
130 
131  $mask = $conf->global->HOLIDAY_IMMACULATE_MASK;
132 
133  if (!$mask)
134  {
135  $this->error = 'NotConfigured';
136  return 0;
137  }
138 
139  $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $user, $holiday->date_create);
140 
141  return $numFinal;
142  }
143 
144  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
152  public function holiday_get_num($fuser, $objforref)
153  {
154  // phpcs:enable
155  return $this->getNextValue($fuser, $objforref);
156  }
157 }
get_next_value($db, $mask, $table, $field, $where= '', $objsoc= '', $date= '', $mode= 'next', $bentityon=true, $objuser=null, $forceentity=null)
Return last or next value for a mask (according to area we should not reset)
holiday_get_num($fuser, $objforref)
Return next value.
Class to manage generation of HTML components Only common components must be here.
getNextValue($user, $holiday)
Return next value.
getExample()
Return numbering example.
Class to manage contract numbering rules Magre.
Parent class for all holidays numbering modules.
info()
Return default description of numbering model.