dolibarr 19.0.4
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 Frédéric France <frederic.france@netlogic.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 $conf, $langs, $mysoc;
101
102 $old_code_client = $mysoc->code_client;
103 $old_code_type = $mysoc->typent_code;
104 $mysoc->code_client = 'CCCCCCCCCC';
105 $mysoc->typent_code = 'TTTTTTTTTT';
106 $numExample = $this->getNextValue($mysoc, '');
107 $mysoc->code_client = $old_code_client;
108 $mysoc->typent_code = $old_code_type;
109
110 if (!$numExample) {
111 $numExample = $langs->trans('NotConfigured');
112 }
113 return $numExample;
114 }
115
123 public function getNextValue($objsoc, $shipment)
124 {
125 global $db, $conf;
126
127 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
128
129 $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK');
130
131 if (empty($mask)) {
132 $this->error = 'NotConfigured';
133 return 0;
134 }
135
136 $date = $shipment->date_expedition;
137
138 $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
139
140 return $numFinal;
141 }
142
143 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
151 public function expedition_get_num($objsoc, $objforref)
152 {
153 // phpcs:enable
154 return $this->getNextValue($objsoc, $objforref);
155 }
156}
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.
expedition_get_num($objsoc, $objforref)
Return next free value.
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.