dolibarr 18.0.6
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
61 public function info()
62 {
63 global $conf, $langs, $db;
64
65 $langs->load("bills");
66
67 $form = new Form($db);
68
69 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
70 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
71 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
72 $texte .= '<input type="hidden" name="action" value="updateMask">';
73 $texte .= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
74 $texte .= '<table class="nobordernopadding" width="100%">';
75
76 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
77 $tooltip .= $langs->trans("GenericMaskCodes2");
78 $tooltip .= $langs->trans("GenericMaskCodes3");
79 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
80 $tooltip .= $langs->trans("GenericMaskCodes5");
81
82 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
83 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskexpedition" value="'.getDolGlobalString('EXPEDITION_RIBERA_MASK').'">', $tooltip, 1, 1).'</td>';
84 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button" value="'.$langs->trans("Modify").'"></td>';
85 $texte .= '</tr>';
86 $texte .= '</table>';
87 $texte .= '</form>';
88
89 return $texte;
90 }
91
97 public function getExample()
98 {
99 global $conf, $langs, $mysoc;
100
101 $old_code_client = $mysoc->code_client;
102 $old_code_type = $mysoc->typent_code;
103 $mysoc->code_client = 'CCCCCCCCCC';
104 $mysoc->typent_code = 'TTTTTTTTTT';
105 $numExample = $this->getNextValue($mysoc, '');
106 $mysoc->code_client = $old_code_client;
107 $mysoc->typent_code = $old_code_type;
108
109 if (!$numExample) {
110 $numExample = $langs->trans('NotConfigured');
111 }
112 return $numExample;
113 }
114
122 public function getNextValue($objsoc, $shipment)
123 {
124 global $db, $conf;
125
126 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
127
128 $mask = getDolGlobalString('EXPEDITION_RIBERA_MASK');
129
130 if (empty($mask)) {
131 $this->error = 'NotConfigured';
132 return 0;
133 }
134
135 $date = $shipment->date_expedition;
136
137 $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
138
139 return $numFinal;
140 }
141
142 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
150 public function expedition_get_num($objsoc, $objforref)
151 {
152 // phpcs:enable
153 return $this->getNextValue($objsoc, $objforref);
154 }
155}
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()
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.