dolibarr 18.0.6
mod_project_universal.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.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 <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
25require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
26
27
32{
36 public $db;
37
42 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
43
47 public $error = '';
48
54 public $nom = 'Universal';
55
59 public $name = 'Universal';
60
61
67 public function info()
68 {
69 global $conf, $langs;
70
71 // Load translation files required by the page
72 $langs->loadLangs(array("projects", "admin"));
73
74 $form = new Form($this->db);
75
76 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
77 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
78 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
79 $texte .= '<input type="hidden" name="action" value="updateMask">';
80 $texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
81 $texte .= '<table class="nobordernopadding" width="100%">';
82
83 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
84 $tooltip .= $langs->trans("GenericMaskCodes2");
85 $tooltip .= $langs->trans("GenericMaskCodes3");
86 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
87 $tooltip .= $langs->trans("GenericMaskCodes5");
88
89 // Parametrage du prefix
90 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
91 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskproject" value="'.getDolGlobalString('PROJECT_UNIVERSAL_MASK').'">', $tooltip, 1, 1).'</td>';
92
93 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
94
95 $texte .= '</tr>';
96
97 $texte .= '</table>';
98 $texte .= '</form>';
99
100 return $texte;
101 }
102
108 public function getExample()
109 {
110 global $conf, $langs, $mysoc;
111
112 $old_code_client = $mysoc->code_client;
113 $mysoc->code_client = 'CCCCCCCCCC';
114 $numExample = $this->getNextValue($mysoc, '');
115 $mysoc->code_client = $old_code_client;
116
117 if (!$numExample) {
118 $numExample = $langs->trans('NotConfigured');
119 }
120 return $numExample;
121 }
122
130 public function getNextValue($objsoc, $project)
131 {
132 global $db, $conf;
133
134 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
135
136 // On defini critere recherche compteur
137 $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK');
138
139 if (!$mask) {
140 $this->error = 'NotConfigured';
141 return 0;
142 }
143
144 // Get entities
145 $entity = getEntity('projectnumber', 1, $project);
146
147 $date = (empty($project->date_c) ? dol_now() : $project->date_c);
148 $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc : ''), $date, 'next', false, null, $entity);
149
150 return $numFinal;
151 }
152
153
154 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
162 public function project_get_num($objsoc = 0, $project = '')
163 {
164 // phpcs:enable
165 return $this->getNextValue($objsoc, $project);
166 }
167}
Class to manage generation of HTML components Only common components must be here.
Classe mere des modeles de numerotation des references de projets.
Classe du modele de numerotation de reference de projet Universal.
info()
Returns the description of the numbering model.
getExample()
Return an example of numbering.
project_get_num($objsoc=0, $project='')
Return next reference not yet used as a reference.
getNextValue($objsoc, $project)
Return 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)
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.