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 *
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
83 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
84 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskexpedition" value="'.getDolGlobalString('EXPEDITION_RIBERA_MASK').'">', $tooltip, 1, 1).'</td>';
85 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Modify").'"></td>';
86 $texte .= '</tr>';
87 $texte .= '</table>';
88 $texte .= '</form>';
89
90 return $texte;
91 }
92
98 public function getExample()
99 {
100 global $db, $langs;
101
102 require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
103 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
104
105 $shipment = new Expedition($db);
106 $shipment->initAsSpecimen();
107 $thirdparty = new Societe($db);
108 $thirdparty->initAsSpecimen();
109
110 $numExample = $this->getNextValue($thirdparty, $shipment);
111
112 if (!$numExample) {
113 $numExample = $langs->trans('NotConfigured');
114 }
115
116 return $numExample;
117 }
118
126 public function getNextValue($objsoc, $shipment)
127 {
128 global $db, $conf;
129
130 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
131
132 $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK');
133
134 if (empty($mask)) {
135 $this->error = 'NotConfigured';
136 return 0;
137 }
138
139 $date = $shipment->date_expedition;
140
141 $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
142
143 return $numFinal;
144 }
145}
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 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 dolibarr global constant string value.