dolibarr  17.0.4
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 minwidth175" 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 button-edit" name="Button"value="'.$langs->trans("Modify").'"></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  $numExample = $langs->trans('NotConfigured');
104  }
105  return $numExample;
106  }
107 
115  public 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  $this->error = 'NotConfigured';
126  return 0;
127  }
128 
129  $numFinal = get_next_value($db, $mask, 'bordereau_cheque', 'ref', '', $objsoc, $object->date_bordereau);
130 
131  return $numFinal;
132  }
133 
134 
135  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
143  public function chequereceipt_get_num($objsoc, $objforref)
144  {
145  // phpcs:enable
146  return $this->getNextValue($objsoc, $objforref);
147  }
148 }
Class to manage generation of HTML components Only common components must be here.
Cheque Receipts numbering references mother class.
Class to manage cheque receipts numbering rules Thyme.
getExample()
Return an example of numbering.
getNextValue($objsoc, $object)
Return next free value.
info()
Returns the description of the numbering model.
chequereceipt_get_num($objsoc, $objforref)
Return next free value.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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)