dolibarr  9.0.0
mod_expedition_ribera.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  * or see http://www.gnu.org/
17  */
18 
25 require_once DOL_DOCUMENT_ROOT .'/core/modules/expedition/modules_expedition.php';
26 
31 {
36  public $version = 'dolibarr';
37 
41  public $error = '';
42 
48  public $nom='Ribera';
49 
53  public $name='Ribera';
54 
60  function info()
61  {
62  global $conf, $langs;
63 
64  $langs->load("bills");
65 
66  $form = new Form($this->db);
67 
68  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
69  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
70  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
71  $texte.= '<input type="hidden" name="action" value="updateMask">';
72  $texte.= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
73  $texte.= '<table class="nobordernopadding" width="100%">';
74 
75  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
76  $tooltip.=$langs->trans("GenericMaskCodes2");
77  $tooltip.=$langs->trans("GenericMaskCodes3");
78  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
79  $tooltip.=$langs->trans("GenericMaskCodes5");
80 
81  $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
82  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">',$tooltip,1,1).'</td>';
83  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
84  $texte.= '</tr>';
85  $texte.= '</table>';
86  $texte.= '</form>';
87 
88  return $texte;
89  }
90 
96  function getExample()
97  {
98  global $conf,$langs,$mysoc;
99 
100  $old_code_client=$mysoc->code_client;
101  $old_code_type=$mysoc->typent_code;
102  $mysoc->code_client='CCCCCCCCCC';
103  $mysoc->typent_code='TTTTTTTTTT';
104  $numExample = $this->getNextValue($mysoc,'');
105  $mysoc->code_client=$old_code_client;
106  $mysoc->typent_code=$old_code_type;
107 
108  if (! $numExample)
109  {
110  $numExample = $langs->trans('NotConfigured');
111  }
112  return $numExample;
113  }
114 
122  function getNextValue($objsoc,$shipment)
123  {
124  global $db,$conf;
125 
126  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
127 
128  $mask=$conf->global->EXPEDITION_RIBERA_MASK;
129 
130  if (! $mask)
131  {
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.NotCamelCaps
151  function expedition_get_num($objsoc,$objforref)
152  {
153  // phpcs:enable
154  return $this->getNextValue($objsoc,$objforref);
155  }
156 }
Class to manage expedition numbering rules Ribera.
getExample()
Return numbering example.
Parent Class of numbering models of sending receipts references.
$version
Dolibarr version of the loaded document string.
Class to manage generation of HTML components Only common components must be here.
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)
expedition_get_num($objsoc, $objforref)
Return next free value.
info()
Return default description of numbering model.
getNextValue($objsoc, $shipment)
Return next value.