dolibarr  7.0.0-beta
mod_task_universal.php
1 <?php
2 /* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
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/project/task/modules_task.php';
26 
27 
32 {
33  var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
34  var $error = '';
35  var $nom = 'Universal';
36  var $name = 'Universal';
37 
38 
44  function info()
45  {
46  global $conf,$langs;
47 
48  $langs->load("projects");
49  $langs->load("admin");
50 
51  $form = new Form($this->db);
52 
53  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
54  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
55  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
56  $texte.= '<input type="hidden" name="action" value="updateMaskTask">';
57  $texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
58  $texte.= '<table class="nobordernopadding" width="100%">';
59 
60  $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
61  $tooltip.=$langs->trans("GenericMaskCodes2");
62  $tooltip.=$langs->trans("GenericMaskCodes3");
63  $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
64  $tooltip.=$langs->trans("GenericMaskCodes5");
65 
66  // Parametrage du prefix
67  $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
68  $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
69 
70  $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
71 
72  $texte.= '</tr>';
73 
74  $texte.= '</table>';
75  $texte.= '</form>';
76 
77  return $texte;
78  }
79 
85  function getExample()
86  {
87  global $conf,$langs,$mysoc;
88 
89  $old_code_client=$mysoc->code_client;
90  $mysoc->code_client='CCCCCCCCCC';
91  $numExample = $this->getNextValue($mysoc,'');
92  $mysoc->code_client=$old_code_client;
93 
94  if (! $numExample)
95  {
96  $numExample = $langs->trans('NotConfigured');
97  }
98  return $numExample;
99  }
100 
108  function getNextValue($objsoc,$object)
109  {
110  global $db,$conf;
111 
112  require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
113 
114  // On defini critere recherche compteur
115  $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
116 
117  if (! $mask)
118  {
119  $this->error='NotConfigured';
120  return 0;
121  }
122 
123  $date=empty($object->date_c)?dol_now():$object->date_c;
124  $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
125 
126  return $numFinal;
127  }
128 
129 
137  function project_get_num($objsoc=0,$object='')
138  {
139  return $this->getNextValue($objsoc,$object);
140  }
141 }
142 
Classe mere des modeles de numerotation des references de projets.
info()
Renvoi la description du modele de numerotation.
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to manage generation of HTML components Only common components must be here.
getNextValue($objsoc, $object)
Return next value.
project_get_num($objsoc=0, $object='')
Return next reference not yet used as a reference.
dol_now($mode='gmt')
Return date for now.
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)
Classe du modele de numerotation de reference de projet Universal.
getExample()
Renvoi un exemple de numerotation.