dolibarr 19.0.3
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
68 public function info($langs)
69 {
70 global $langs;
71
72 // Load translation files required by the page
73 $langs->loadLangs(array("projects", "admin"));
74
75 $form = new Form($this->db);
76
77 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
78 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
80 $texte .= '<input type="hidden" name="action" value="updateMask">';
81 $texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
82 $texte .= '<table class="nobordernopadding" width="100%">';
83
84 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
85 $tooltip .= $langs->trans("GenericMaskCodes2");
86 $tooltip .= $langs->trans("GenericMaskCodes3");
87 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
88 $tooltip .= $langs->trans("GenericMaskCodes5");
89
90 // Prefix settings
91 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
92 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskproject" value="'.getDolGlobalString('PROJECT_UNIVERSAL_MASK').'">', $tooltip, 1, 1).'</td>';
93
94 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
95
96 $texte .= '</tr>';
97
98 $texte .= '</table>';
99 $texte .= '</form>';
100
101 return $texte;
102 }
103
109 public function getExample()
110 {
111 global $conf, $langs, $mysoc;
112
113 $old_code_client = $mysoc->code_client;
114 $mysoc->code_client = 'CCCCCCCCCC';
115 $numExample = $this->getNextValue($mysoc, '');
116 $mysoc->code_client = $old_code_client;
117
118 if (!$numExample) {
119 $numExample = $langs->trans('NotConfigured');
120 }
121 return $numExample;
122 }
123
131 public function getNextValue($objsoc, $project)
132 {
133 global $db, $conf;
134
135 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
136
137 // We define criterion search counter
138 $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK');
139
140 if (!$mask) {
141 $this->error = 'NotConfigured';
142 return 0;
143 }
144
145 // Get entities
146 $entity = getEntity('projectnumber', 1, $project);
147
148 $date = (empty($project->date_c) ? dol_now() : $project->date_c);
149 $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc : ''), $date, 'next', false, null, $entity);
150
151 return $numFinal;
152 }
153
154
155 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
163 public function project_get_num($objsoc = 0, $project = '')
164 {
165 // phpcs:enable
166 return $this->getNextValue($objsoc, $project);
167 }
168}
Class to manage generation of HTML components Only common components must be here.
Classe mere des modeles de numerotation des references de projets.
Class to manage the numbering module Universal for project references.
getExample()
Return an example of numbering.
project_get_num($objsoc=0, $project='')
Return next reference not yet used as a reference.
info($langs)
Returns the description of the numbering model.
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.