dolibarr  13.0.2
mod_chequereceipt_thyme.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
3  * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
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/cheque/modules_chequereceipts.php';
27 
28 
33 {
38  public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 
43  public $error = '';
44 
45  public $name = 'Thyme';
46 
47 
53  public function info()
54  {
55  global $conf, $langs, $db;
56 
57  $langs->load("bills");
58 
59  $form = new Form($db);
60 
61  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
62  $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
63  $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
64  $texte .= '<input type="hidden" name="action" value="updateMask">';
65  $texte .= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">';
66  $texte .= '<table class="nobordernopadding" width="100%">';
67 
68  $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
69  $tooltip .= $langs->trans("GenericMaskCodes2");
70  $tooltip .= $langs->trans("GenericMaskCodes3");
71  $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
72  $tooltip .= $langs->trans("GenericMaskCodes5");
73 
74  // Parametrage du prefix
75  $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
76  $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskchequereceipts" value="'.$conf->global->CHEQUERECEIPTS_THYME_MASK.'">', $tooltip, 1, 1).'</td>';
77 
78  $texte .= '<td class="left" rowspan="2">&nbsp;<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
79 
80  $texte .= '</tr>';
81 
82  $texte .= '</table>';
83  $texte .= '</form>';
84 
85  return $texte;
86  }
87 
93  public function getExample()
94  {
95  global $conf, $langs, $mysoc;
96 
97  $old_code_client = $mysoc->code_client;
98  $mysoc->code_client = 'CCCCCCCCCC';
99  $numExample = $this->getNextValue($mysoc, '');
100  $mysoc->code_client = $old_code_client;
101 
102  if (!$numExample)
103  {
104  $numExample = $langs->trans('NotConfigured');
105  }
106  return $numExample;
107  }
108 
116  public function getNextValue($objsoc, $object)
117  {
118  global $db, $conf;
119 
120  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
121 
122  // We get cursor rule
123  $mask = $conf->global->CHEQUERECEIPTS_THYME_MASK;
124 
125  if (!$mask)
126  {
127  $this->error = 'NotConfigured';
128  return 0;
129  }
130 
131  $numFinal = get_next_value($db, $mask, 'bordereau_cheque', 'ref', '', $objsoc, $object->date_bordereau);
132 
133  return $numFinal;
134  }
135 
136 
137  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
145  public function chequereceipt_get_num($objsoc, $objforref)
146  {
147  // phpcs:enable
148  return $this->getNextValue($objsoc, $objforref);
149  }
150 }
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)
getNextValue($objsoc, $object)
Return next free value.
Cheque Receipts numbering references mother class.
Class to manage generation of HTML components Only common components must be here.
getExample()
Return an example of numbering.
chequereceipt_get_num($objsoc, $objforref)
Return next free value.
info()
Returns the description of the numbering model.
Class to manage cheque receipts numbering rules Thyme.