dolibarr  16.0.1
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 minwidth175" name="maskholiday" value="'.getDolGlobalString('HOLIDAY_IMMACULATE_MASK').'">', $tooltip, 1, 1).'</td>';
89  $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></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  $numExample = $langs->trans('NotConfigured');
113  }
114  return $numExample;
115  }
116 
124  public function getNextValue($objsoc, $holiday)
125  {
126  global $db, $conf;
127 
128  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
129 
130  $mask = getDolGlobalString('HOLIDAY_IMMACULATE_MASK');
131 
132  if (!$mask) {
133  $this->error = 'NotConfigured';
134  return 0;
135  }
136 
137  $numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $objsoc, $holiday->date_create);
138 
139  return $numFinal;
140  }
141 
142  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
150  public function holiday_get_num($fuser, $objforref)
151  {
152  // phpcs:enable
153  return $this->getNextValue($fuser, $objforref);
154  }
155 }
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
getNextValue($objsoc, $holiday)
Return next value.
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)
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
holiday_get_num($fuser, $objforref)
Return next value.
Class to manage generation of HTML components Only common components must be here.
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.