dolibarr 25.0.0-alpha
mod_task_universal.php
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/task/modules_task.php';
28
29
34{
39 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
40
44 public $error = '';
45
49 public $position = 20;
50
54 public $name = 'Universal';
55
56
63 public function info($langs)
64 {
65 global $langs, $db;
66
67 // Load translation files required by the page
68 $langs->loadLangs(array("projects", "admin"));
69
70 $form = new Form($db);
71
72 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
73 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
74 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
75 $texte .= '<input type="hidden" name="action" value="updateMaskTask">';
76 $texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
77 $texte .= '<input type="hidden" name="page_y" value="">';
78
79 $texte .= '<table class="nobordernopadding centpercent">';
80
81 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
82 $tooltip .= $langs->trans("GenericMaskCodes1");
83 $tooltip .= '<br>';
84 $tooltip .= $langs->trans("GenericMaskCodes2");
85 $tooltip .= '<br>';
86 $tooltip .= $langs->trans("GenericMaskCodes3");
87 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
88 $tooltip .= $langs->trans("GenericMaskCodes5");
89 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
90
91 // Setting of prefix
92 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
93 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="masktask" value="'.getDolGlobalString('PROJECT_TASK_UNIVERSAL_MASK').'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
94
95 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
96
97 $texte .= '</tr>';
98
99 $texte .= '</table>';
100 $texte .= '</form>';
101
102 return $texte;
103 }
104
110 public function getExample()
111 {
112 global $langs, $mysoc;
113
114 $old_code_client = $mysoc->code_client;
115 $mysoc->code_client = 'CCCCCCCCCC';
116 $numExample = $this->getNextValue($mysoc, null);
117 $mysoc->code_client = $old_code_client;
118
119 if (!$numExample) {
120 $numExample = $langs->trans('NotConfigured');
121 }
122 return $numExample;
123 }
124
132 public function getNextValue($objsoc, $object)
133 {
134 global $db;
135
136 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
137
138 $mask = getDolGlobalString('PROJECT_TASK_UNIVERSAL_MASK');
139
140 if (!$mask) {
141 $this->error = 'NotConfigured';
142 return 0;
143 }
144
145 $date = empty($object->date_c) ? dol_now() : $object->date_c;
146 $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
147
148 return $numFinal;
149 }
150}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage generation of HTML components Only common components must be here.
Parent class of task reference numbering models.
Class du modele de numerotation de reference de projet Universal.
getExample()
Return an example of numbering.
info($langs)
Returns the description of the numbering model.
getNextValue($objsoc, $object)
Return next value.
global $mysoc
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140