dolibarr 21.0.0-alpha
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 * 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/expedition/modules_expedition.php';
28
33{
38 public $version = 'dolibarr';
39
43 public $error = '';
44
50 public $nom = 'Ribera';
51
55 public $name = 'Ribera';
56
63 public function info($langs)
64 {
65 global $langs, $db;
66
67 $langs->load("bills");
68
69 $form = new Form($db);
70
71 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
74 $texte .= '<input type="hidden" name="action" value="updateMask">';
75 $texte .= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
76 $texte .= '<table class="nobordernopadding" width="100%">';
77
78 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
79 $tooltip .= $langs->trans("GenericMaskCodes2");
80 $tooltip .= $langs->trans("GenericMaskCodes3");
81 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
82 $tooltip .= $langs->trans("GenericMaskCodes5");
83 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
84
85 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskexpedition" value="'.getDolGlobalString('EXPEDITION_RIBERA_MASK').'">', $tooltip, 1, 1).'</td>';
87 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
88 $texte .= '</tr>';
89 $texte .= '</table>';
90 $texte .= '</form>';
91
92 return $texte;
93 }
94
100 public function getExample()
101 {
102 global $db, $langs;
103
104 require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
105 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
106
107 $shipment = new Expedition($db);
108 $shipment->initAsSpecimen();
109 $thirdparty = new Societe($db);
110 $thirdparty->initAsSpecimen();
111
112 $numExample = $this->getNextValue($thirdparty, $shipment);
113
114 if (!$numExample) {
115 $numExample = $langs->trans('NotConfigured');
116 }
117
118 return $numExample;
119 }
120
128 public function getNextValue($objsoc, $shipment)
129 {
130 global $db;
131
132 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
133
134 $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK');
135
136 if (empty($mask)) {
137 $this->error = 'NotConfigured';
138 return 0;
139 }
140
141 $date = $shipment->date_shipping;
142
143 $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
144
145 return $numFinal;
146 }
147}
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 third parties objects (customers, suppliers, prospects...)
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 a Dolibarr global constant string value.