dolibarr  13.0.2
mod_reception_moonstone.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
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/reception/modules_reception.php';
27 
32 {
33  public $version = 'dolibarr';
34  public $error = '';
35  public $nom = 'Moonstone';
36 
42  public function info()
43  {
44  global $conf, $langs, $db;
45 
46  $langs->load("bills");
47 
48  $form = new Form($db);
49 
50  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
51  $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
52  $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
53  $texte .= '<input type="hidden" name="action" value="updateMask">';
54  $texte .= '<input type="hidden" name="maskconstreception" value="RECEPTION_MOONSTONE_MASK">';
55  $texte .= '<table class="nobordernopadding" width="100%">';
56 
57  $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
58  $tooltip .= $langs->trans("GenericMaskCodes2");
59  $tooltip .= $langs->trans("GenericMaskCodes3");
60  $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Reception"), $langs->transnoentities("Reception"));
61  $tooltip .= $langs->trans("GenericMaskCodes5");
62 
63  $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
64  $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreception" value="'.$conf->global->RECEPTION_MOONSTONE_MASK.'">', $tooltip, 1, 1).'</td>';
65  $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
66  $texte .= '</tr>';
67  $texte .= '</table>';
68  $texte .= '</form>';
69 
70  return $texte;
71  }
72 
78  public function getExample()
79  {
80  global $conf, $langs, $mysoc;
81 
82  $old_code_client = $mysoc->code_client;
83  $old_code_type = $mysoc->typent_code;
84  $mysoc->code_client = 'CCCCCCCCCC';
85  $mysoc->typent_code = 'TTTTTTTTTT';
86  $numExample = $this->getNextValue($mysoc, '');
87  $mysoc->code_client = $old_code_client;
88  $mysoc->typent_code = $old_code_type;
89 
90  if (!$numExample)
91  {
92  $numExample = $langs->trans('NotConfigured');
93  }
94  return $numExample;
95  }
96 
104  public function getNextValue($objsoc, $reception)
105  {
106  global $db, $conf;
107 
108  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
109 
110  $mask = $conf->global->RECEPTION_MOONSTONE_MASK;
111 
112  if (!$mask)
113  {
114  $this->error = 'NotConfigured';
115  return 0;
116  }
117 
118  $date = $reception->date_reception;
119 
120  $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
121 
122  return $numFinal;
123  }
124 
125  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
133  public function reception_get_num($objsoc, $objforref)
134  {
135  // phpcs:enable
136  return $this->getNextValue($objsoc, $objforref);
137  }
138 }
Parent Class of numbering models of sending receipts references.
getNextValue($objsoc, $reception)
Return next value.
Class to manage reception numbering rules Moonstone.
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)
info()
Return default description of numbering model.
reception_get_num($objsoc, $objforref)
Return next free value.
getExample()
Return numbering example.
Class to manage generation of HTML components Only common components must be here.