dolibarr 25.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-2025 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
48 public $name = 'Ribera';
49
53 public $position = 20;
54
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 .= '<input type="hidden" name="page_y" value="">';
76
77 $texte .= '<table class="nobordernopadding centpercent">';
78
79 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
80 $tooltip .= $langs->trans("GenericMaskCodes1");
81 $tooltip .= '<br>';
82 $tooltip .= $langs->trans("GenericMaskCodes2");
83 $tooltip .= '<br>';
84 $tooltip .= $langs->trans("GenericMaskCodes3");
85 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
86 $tooltip .= $langs->trans("GenericMaskCodes5");
87 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
88
89 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
90 $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>';
91 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
92 $texte .= '</tr>';
93 $texte .= '</table>';
94 $texte .= '</form>';
95
96 return $texte;
97 }
98
104 public function getExample()
105 {
106 global $db, $langs;
107
108 require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
109 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
110
111 $shipment = new Expedition($db);
112 $shipment->initAsSpecimen();
113 $thirdparty = new Societe($db);
114 $thirdparty->initAsSpecimen();
115
116 $numExample = $this->getNextValue($thirdparty, $shipment);
117
118 if (!$numExample) {
119 $numExample = $langs->trans('NotConfigured');
120 }
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 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:140