dolibarr 23.0.3
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 .= '<input type="hidden" name="page_y" value="">';
69
70 $texte .= '<table class="nobordernopadding centpercent">';
71
72 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
73 $tooltip .= $langs->trans("GenericMaskCodes1");
74 $tooltip .= '<br>';
75 $tooltip .= $langs->trans("GenericMaskCodes2");
76 $tooltip .= '<br>';
77 $tooltip .= $langs->trans("GenericMaskCodes3");
78 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CheckReceiptShort"), $langs->transnoentities("CheckReceiptShort"));
79 $tooltip .= $langs->trans("GenericMaskCodes5");
80 //$tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
81
82 // Parametrage du prefix
83 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
84 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskchequereceipts" value="' . getDolGlobalString('CHEQUERECEIPTS_THYME_MASK').'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
85
86 $texte .= '<td class="left" rowspan="2">&nbsp;<input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
87
88 $texte .= '</tr>';
89
90 $texte .= '</table>';
91 $texte .= '</form>';
92
93 return $texte;
94 }
95
101 public function getExample()
102 {
103 global $db, $langs;
104
105 require_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php';
106 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
107
108 $remise = new RemiseCheque($db);
109 $remise->initAsSpecimen();
110 $thirdparty = new Societe($db);
111 $thirdparty->initAsSpecimen();
112
113 $numExample = $this->getNextValue($thirdparty, $remise);
114
115 if (!$numExample) {
116 $numExample = $langs->trans('NotConfigured');
117 }
118
119 return $numExample;
120 }
121
129 public function getNextValue($objsoc, $object)
130 {
131 global $db;
132
133 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
134
135 // We get cursor rule
136 $mask = getDolGlobalString('CHEQUERECEIPTS_THYME_MASK');
137
138 if (!$mask) {
139 $this->error = 'NotConfigured';
140 return 0;
141 }
142
143 $date = (empty($object) ? dol_now() : $object->date_bordereau);
144
145 $numFinal = get_next_value($db, $mask, 'bordereau_cheque', 'ref', '', $objsoc, $date);
146
147 return $numFinal;
148 }
149}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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, $objbookkeeping=null)
Return last or next value for a mask (according to area we should not reset)
dol_now($mode='gmt')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128