dolibarr 21.0.0-alpha
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-2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
27require_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php';
28
29
34{
39 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
40
44 public $error = '';
45
46 public $name = 'Thyme';
47
48
55 public function info($langs)
56 {
57 global $langs, $db;
58
59 $langs->load("bills");
60
61 $form = new Form($db);
62
63 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
64 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
65 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
66 $texte .= '<input type="hidden" name="action" value="updateMask">';
67 $texte .= '<input type="hidden" name="maskconstchequereceipts" value="CHEQUERECEIPTS_THYME_MASK">';
68 $texte .= '<table class="nobordernopadding" width="100%">';
69
70 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
71 $tooltip .= $langs->trans("GenericMaskCodes2");
72 $tooltip .= $langs->trans("GenericMaskCodes3");
73 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
74 $tooltip .= $langs->trans("GenericMaskCodes5");
75 //$tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
76
77 // Parametrage du prefix
78 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
79 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskchequereceipts" value="' . getDolGlobalString('CHEQUERECEIPTS_THYME_MASK').'">', $tooltip, 1, 1).'</td>';
80
81 $texte .= '<td class="left" rowspan="2">&nbsp;<input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
82
83 $texte .= '</tr>';
84
85 $texte .= '</table>';
86 $texte .= '</form>';
87
88 return $texte;
89 }
90
96 public function getExample()
97 {
98 global $db, $langs;
99
100 require_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php';
101 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
102
103 $remise = new RemiseCheque($db);
104 $remise->initAsSpecimen();
105 $thirdparty = new Societe($db);
106 $thirdparty->initAsSpecimen();
107
108 $numExample = $this->getNextValue($thirdparty, $remise);
109
110 if (!$numExample) {
111 $numExample = $langs->trans('NotConfigured');
112 }
113
114 return $numExample;
115 }
116
124 public function getNextValue($objsoc, $object)
125 {
126 global $db;
127
128 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
129
130 // We get cursor rule
131 $mask = getDolGlobalString('CHEQUERECEIPTS_THYME_MASK');
132
133 if (!$mask) {
134 $this->error = 'NotConfigured';
135 return 0;
136 }
137
138 $date = (empty($object) ? dol_now() : $object->date_bordereau);
139
140 $numFinal = get_next_value($db, $mask, 'bordereau_cheque', 'ref', '', $objsoc, $date);
141
142 return $numFinal;
143 }
144}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage generation of HTML components Only common components must be here.
Class parent for cheque Receipts numbering references mother class.
Class to manage cheque delivery receipts.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage cheque receipts numbering rules Thyme.
info($langs)
Returns the description of the numbering model.
getExample()
Return an example of numbering.
getNextValue($objsoc, $object)
Return next free 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)
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.