dolibarr 25.0.0-alpha
mod_project_universal.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
27require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
28
29
34{
38 public $db;
39
44 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
45
49 public $error = '';
50
54 public $position = 20;
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 .= '<input type="hidden" name="page_y" value="">';
83
84 $texte .= '<table class="nobordernopadding centpercent">';
85
86 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
87 $tooltip .= $langs->trans("GenericMaskCodes1");
88 $tooltip .= $langs->trans("GenericMaskCodes2");
89 $tooltip .= $langs->trans("GenericMaskCodes3");
90 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
91 $tooltip .= $langs->trans("GenericMaskCodes5");
92 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
93
94 // Prefix settings
95 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
96 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskproject" value="'.getDolGlobalString('PROJECT_UNIVERSAL_MASK').'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
97
98 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
99
100 $texte .= '</tr>';
101
102 $texte .= '</table>';
103 $texte .= '</form>';
104
105 return $texte;
106 }
107
113 public function getExample()
114 {
115 global $db, $langs;
116
117 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
118 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
119
120 $project = new Project($db);
121 $project->initAsSpecimen();
122 $thirdparty = new Societe($db);
123 $thirdparty->initAsSpecimen();
124
125 $numExample = $this->getNextValue($thirdparty, $project);
126
127 if (!$numExample) {
128 $numExample = $langs->trans('NotConfigured');
129 }
130
131 return $numExample;
132 }
133
141 public function getNextValue($objsoc, $project)
142 {
143 global $db, $langs;
144
145 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
146
147 // We define criterion search counter
148 $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK');
149
150 if (!$mask) {
151 $this->error = $langs->trans('NotConfigured');
152 return 0;
153 }
154
155 // Get entities
156 $entity = getEntity('projectnumber', 1, $project);
157
158 $date = (empty($project->date_c) ? dol_now() : $project->date_c);
159 $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc : ''), $date, 'next', false, null, $entity);
160
161 return $numFinal;
162 }
163}
Class to manage generation of HTML components Only common components must be here.
Class parent for numbering modules of tasks.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage the numbering module Universal for project references.
getExample()
Return an example of numbering.
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, $objbookkeeping=null)
Return last or next value for a mask (according to area we should not reset)
dol_now($mode='gmt')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140