dolibarr  7.0.0-beta
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 {
32  var $version='dolibarr';
33  var $error = '';
34  var $nom = 'Magre';
35  var $code_auto=1;
36 
42  function info()
43  {
44  global $conf,$langs;
45 
46  $langs->load("bills");
47 
48  $form = new Form($this->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="'.$_SESSION['newtoken'].'">';
53  $texte.= '<input type="hidden" name="action" value="updateMask">';
54  $texte.= '<input type="hidden" name="maskconstcontract" value="CONTRACT_MAGRE_MASK">';
55  $texte.= '<table class="nobordernopadding" width="100%">';
56 
57  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
58  $tooltip.=$langs->trans("GenericMaskCodes2");
59  $tooltip.=$langs->trans("GenericMaskCodes3");
60  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Contract"),$langs->transnoentities("Contract"));
61  $tooltip.=$langs->trans("GenericMaskCodes5");
62 
63  $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
64  $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>';
65  $texte.= '<td align="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  function getExample()
79  {
80  global $conf,$langs,$mysoc;
81 
82  $old_code_client=$mysoc->code_client;
83  $mysoc->code_client='CCCCCCCCCC';
84  $numExample = $this->getNextValue($mysoc,'');
85  $mysoc->code_client=$old_code_client;
86 
87  if (! $numExample)
88  {
89  $numExample = $langs->trans('NotConfigured');
90  }
91  return $numExample;
92  }
93 
101  function getNextValue($objsoc,$contract)
102  {
103  global $db,$conf;
104 
105  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
106 
107  $mask=$conf->global->CONTRACT_MAGRE_MASK;
108 
109  if (! $mask)
110  {
111  $this->error='NotConfigured';
112  return 0;
113  }
114 
115  $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
116 
117  return $numFinal;
118  }
119 
127  function contract_get_num($objsoc,$objforref)
128  {
129  return $this->getNextValue($objsoc,$objforref);
130  }
131 
132 }
133 
Class to manage contract numbering rules Magre.
if(empty($reshook)) $form
View.
Definition: perms.php:103
contract_get_num($objsoc, $objforref)
Return next value.
Class to manage generation of HTML components Only common components must be here.
getNextValue($objsoc, $contract)
Return next value.
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null)
Return last or next value for a mask (according to area we should not reset)
getExample()
Return numbering example.
info()
Return default description of numbering model.
Parent class for all contract numbering modules.