dolibarr  13.0.2
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 
26 require_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" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">', $tooltip, 1, 1).'</td>';
84  $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></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  {
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 = $conf->global->EXPEDITION_RIBERA_MASK;
130 
131  if (!$mask)
132  {
133  $this->error = 'NotConfigured';
134  return 0;
135  }
136 
137  $date = $shipment->date_expedition;
138 
139  $numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
140 
141  return $numFinal;
142  }
143 
144  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
152  public function expedition_get_num($objsoc, $objforref)
153  {
154  // phpcs:enable
155  return $this->getNextValue($objsoc, $objforref);
156  }
157 }
Class to manage expedition numbering rules Ribera.
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)
Parent Class of numbering models of sending receipts references.
Class to manage generation of HTML components Only common components must be here.
expedition_get_num($objsoc, $objforref)
Return next free value.
info()
Return default description of numbering model.
getNextValue($objsoc, $shipment)
Return next value.