dolibarr  9.0.0
mod_contract_magre.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/contract/modules_contract.php';
26 
31 {
36  public $version = 'dolibarr';
37 
41  public $error = '';
42 
48  public $nom='Magre';
49 
53  public $name='Magre';
54 
55  public $code_auto=1;
56 
62  function info()
63  {
64  global $conf,$langs;
65 
66  $langs->load("bills");
67 
68  $form = new Form($this->db);
69 
70  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
73  $texte.= '<input type="hidden" name="action" value="updateMask">';
74  $texte.= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
75  $texte.= '<table class="nobordernopadding" width="100%">';
76 
77  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
78  $tooltip.=$langs->trans("GenericMaskCodes2");
79  $tooltip.=$langs->trans("GenericMaskCodes3");
80  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
81  $tooltip.=$langs->trans("GenericMaskCodes5");
82 
83  $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
84  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcontract" value="'.$conf->global->CONTRACT_MAGRE_MASK.'">',$tooltip,1,1).'</td>';
85  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
86  $texte.= '</tr>';
87  $texte.= '</table>';
88  $texte.= '</form>';
89 
90  return $texte;
91  }
92 
98  function getExample()
99  {
100  global $conf,$langs,$mysoc;
101 
102  $old_code_client=$mysoc->code_client;
103  $mysoc->code_client='CCCCCCCCCC';
104  $numExample = $this->getNextValue($mysoc,'');
105  $mysoc->code_client=$old_code_client;
106 
107  if (! $numExample)
108  {
109  $numExample = $langs->trans('NotConfigured');
110  }
111  return $numExample;
112  }
113 
121  function getNextValue($objsoc,$contract)
122  {
123  global $db,$conf;
124 
125  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
126 
127  $mask=$conf->global->CONTRACT_MAGRE_MASK;
128 
129  if (! $mask)
130  {
131  $this->error='NotConfigured';
132  return 0;
133  }
134 
135  $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
136 
137  return $numFinal;
138  }
139 
140  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
148  function contract_get_num($objsoc,$objforref)
149  {
150  // phpcs:enable
151  return $this->getNextValue($objsoc,$objforref);
152  }
153 }
Class to manage contract numbering rules Magre.
contract_get_num($objsoc, $objforref)
Return next value.
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)
getNextValue($objsoc, $contract)
Return next value.
getExample()
Return numbering example.
info()
Return default description of numbering model.
Parent class for all contract numbering modules.
$version
Dolibarr version of the loaded document string.