dolibarr  9.0.0
mod_chequereceipt_thyme.php
1 <?php
2 /* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
25 require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php';
26 
27 
32 {
37  public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 
42  public $error = '';
43 
44  public $name = 'Thyme';
45 
46 
52  function info()
53  {
54  global $conf, $langs;
55 
56  $langs->load("bills");
57 
58  $form = new Form($this->db);
59 
60  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
61  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
62  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
63  $texte.= '<input type="hidden" name="action" value="updateMask">';
64  $texte.= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">';
65  $texte.= '<table class="nobordernopadding" width="100%">';
66 
67  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort"));
68  $tooltip.=$langs->trans("GenericMaskCodes2");
69  $tooltip.=$langs->trans("GenericMaskCodes3");
70  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CheckReceiptShort"),$langs->transnoentities("CheckReceiptShort"));
71  $tooltip.=$langs->trans("GenericMaskCodes5");
72 
73  // Parametrage du prefix
74  $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
75  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskchequereceipts" value="'.$conf->global->CHEQUERECEIPTS_THYME_MASK.'">',$tooltip,1,1).'</td>';
76 
77  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
78 
79  $texte.= '</tr>';
80 
81  $texte.= '</table>';
82  $texte.= '</form>';
83 
84  return $texte;
85  }
86 
92  function getExample()
93  {
94  global $conf,$langs,$mysoc;
95 
96  $old_code_client=$mysoc->code_client;
97  $mysoc->code_client='CCCCCCCCCC';
98  $numExample = $this->getNextValue($mysoc,'');
99  $mysoc->code_client=$old_code_client;
100 
101  if (! $numExample)
102  {
103  $numExample = $langs->trans('NotConfigured');
104  }
105  return $numExample;
106  }
107 
115  function getNextValue($objsoc,$object)
116  {
117  global $db,$conf;
118 
119  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
120 
121  // We get cursor rule
122  $mask=$conf->global->CHEQUERECEIPTS_THYME_MASK;
123 
124  if (! $mask)
125  {
126  $this->error='NotConfigured';
127  return 0;
128  }
129 
130  $numFinal=get_next_value($db,$mask,'bordereau_cheque','ref','',$objsoc,$object->date_bordereau);
131 
132  return $numFinal;
133  }
134 
135 
136  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
144  function chequereceipt_get_num($objsoc,$objforref)
145  {
146  // phpcs:enable
147  return $this->getNextValue($objsoc,$objforref);
148  }
149 }
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.
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)
getExample()
Renvoi un exemple de numerotation.
chequereceipt_get_num($objsoc, $objforref)
Return next free value.
info()
Renvoi la description du modele de numerotation.
Class to manage cheque receipts numbering rules Thyme.
$version
Dolibarr version of the loaded document string.