dolibarr  16.0.5
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 minwidth175" 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 button-edit" name="Button" value="'.$langs->trans("Modify").'"></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  $numExample = $langs->trans('NotConfigured');
92  }
93  return $numExample;
94  }
95 
103  public function getNextValue($objsoc, $reception)
104  {
105  global $db, $conf;
106 
107  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
108 
109  $mask = $conf->global->RECEPTION_MOONSTONE_MASK;
110 
111  if (!$mask) {
112  $this->error = 'NotConfigured';
113  return 0;
114  }
115 
116  $date = $reception->date_reception;
117 
118  $numFinal = get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date);
119 
120  return $numFinal;
121  }
122 
123  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
131  public function reception_get_num($objsoc, $objforref)
132  {
133  // phpcs:enable
134  return $this->getNextValue($objsoc, $objforref);
135  }
136 }
mod_reception_moonstone\info
info()
Return default description of numbering model.
Definition: mod_reception_moonstone.php:42
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
ModelNumRefReception
Parent Class of numbering models of sending receipts references.
Definition: modules_reception.php:62
mod_reception_moonstone\getNextValue
getNextValue($objsoc, $reception)
Return next value.
Definition: mod_reception_moonstone.php:103
mod_reception_moonstone\getExample
getExample()
Return numbering example.
Definition: mod_reception_moonstone.php:78
mod_reception_moonstone\reception_get_num
reception_get_num($objsoc, $objforref)
Return next free value.
Definition: mod_reception_moonstone.php:131
get_next_value
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)
Definition: functions2.lib.php:970
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
mod_reception_moonstone
Class to manage reception numbering rules Moonstone.
Definition: mod_reception_moonstone.php:31