dolibarr 22.0.5
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 .= '<input type="hidden" name="page_y" value="">';
77
78 $texte .= '<table class="nobordernopadding centpercent">';
79
80 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
81 $tooltip .= $langs->trans("GenericMaskCodes1");
82 $tooltip .= '<br>';
83 $tooltip .= $langs->trans("GenericMaskCodes2");
84 $tooltip .= '<br>';
85 $tooltip .= $langs->trans("GenericMaskCodes3");
86 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
87 $tooltip .= $langs->trans("GenericMaskCodes5");
88 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
89
90 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
91 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskexpedition" value="'.getDolGlobalString('EXPEDITION_RIBERA_MASK').'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
92 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
93 $texte .= '</tr>';
94 $texte .= '</table>';
95 $texte .= '</form>';
96
97 return $texte;
98 }
99
105 public function getExample()
106 {
107 global $db, $langs;
108
109 require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
110 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
111
112 $shipment = new Expedition($db);
113 $shipment->initAsSpecimen();
114 $thirdparty = new Societe($db);
115 $thirdparty->initAsSpecimen();
116
117 $numExample = $this->getNextValue($thirdparty, $shipment);
118
119 if (!$numExample) {
120 $numExample = $langs->trans('NotConfigured');
121 }
122
123 return $numExample;
124 }
125
133 public function getNextValue($objsoc, $shipment)
134 {
135 global $db;
136
137 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
138
139 $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK');
140
141 if (empty($mask)) {
142 $this->error = 'NotConfigured';
143 return 0;
144 }
145
146 $date = $shipment->date_shipping;
147
148 $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
149
150 return $numFinal;
151 }
152}
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, $objbookkeeping=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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161