dolibarr 20.0.0
mod_expedition_ribera.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
3 * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.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
26require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
27
32{
37 public $version = 'dolibarr';
38
42 public $error = '';
43
49 public $nom = 'Ribera';
50
54 public $name = 'Ribera';
55
62 public function info($langs)
63 {
64 global $langs, $db;
65
66 $langs->load("bills");
67
68 $form = new Form($db);
69
70 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
73 $texte .= '<input type="hidden" name="action" value="updateMask">';
74 $texte .= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
75 $texte .= '<table class="nobordernopadding" width="100%">';
76
77 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
78 $tooltip .= $langs->trans("GenericMaskCodes2");
79 $tooltip .= $langs->trans("GenericMaskCodes3");
80 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
81 $tooltip .= $langs->trans("GenericMaskCodes5");
82 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
83
84 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
85 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskexpedition" value="'.getDolGlobalString('EXPEDITION_RIBERA_MASK').'">', $tooltip, 1, 1).'</td>';
86 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
87 $texte .= '</tr>';
88 $texte .= '</table>';
89 $texte .= '</form>';
90
91 return $texte;
92 }
93
99 public function getExample()
100 {
101 global $langs, $mysoc, $db;
102
103 $old_code_client = $mysoc->code_client;
104 $old_code_type = $mysoc->typent_code;
105 $mysoc->code_client = 'CCCCCCCCCC';
106 $mysoc->typent_code = 'TTTTTTTTTT';
107
108
109 if (!class_exists('Expedition')) {
110 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
111 }
112
113 $expedition = new Expedition($db);
114
115 $numExample = $this->getNextValue($mysoc, $expedition);
116 $mysoc->code_client = $old_code_client;
117 $mysoc->typent_code = $old_code_type;
118
119 if (!$numExample) {
120 $numExample = $langs->trans('NotConfigured');
121 }
122 return $numExample;
123 }
124
132 public function getNextValue($objsoc, $shipment)
133 {
134 global $db;
135
136 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
137
138 $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK');
139
140 if (empty($mask)) {
141 $this->error = 'NotConfigured';
142 return 0;
143 }
144
145 $date = $shipment->date_shipping;
146
147 $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
148
149 return $numFinal;
150 }
151}
Class to manage shipments.
Class to manage generation of HTML components Only common components must be here.
Parent Class of numbering models of sending receipts references.
Class to manage expedition numbering rules Ribera.
info($langs)
Return default description of numbering model.
getNextValue($objsoc, $shipment)
Return next value.
getExample()
Return numbering example.
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)
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.