dolibarr 24.0.0-beta
mod_ticket_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/ticket/modules_ticket.php';
28
33{
38 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39
43 public $error = '';
44
50 public $nom = 'Universal';
51
55 public $name = 'Universal';
56
63 public function info($langs)
64 {
65 global $db, $langs;
66
67 // Load translation files required by the page
68 $langs->loadLangs(array("ticket", "admin"));
69
70 $form = new Form($db);
71
72 $text = $langs->trans('GenericNumRefModelDesc')."<br>\n";
73 $text .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
74 $text .= '<input type="hidden" name="token" value="'.newToken().'">';
75 $text .= '<input type="hidden" name="action" value="updateMask">';
76 $text .= '<input type="hidden" name="maskconstticket" value="TICKET_UNIVERSAL_MASK">';
77 $text .= '<table class="nobordernopadding" width="100%">';
78
79 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
80 $tooltip .= $langs->trans("GenericMaskCodes1");
81 $tooltip .= '<br>';
82 $tooltip .= $langs->trans("GenericMaskCodes2");
83 $tooltip .= '<br>';
84 $tooltip .= $langs->trans("GenericMaskCodes3");
85 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
86 $tooltip .= $langs->trans("GenericMaskCodes5");
87 //$tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
88
89 // Prefix settings
90 $text .= '<tr><td>'.$langs->trans("Mask").':</td>';
91 $text .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskticket" value="'.getDolGlobalString("TICKET_UNIVERSAL_MASK").'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
92
93 $text .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
94
95 $text .= '</tr>';
96
97 $text .= '</table>';
98 $text .= '</form>';
99
100 return $text;
101 }
102
108 public function getExample()
109 {
110 global $db, $langs;
111
112 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
113 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
114
115 $ticket = new Ticket($db);
116 $ticket->initAsSpecimen();
117 $thirdparty = new Societe($db);
118 $thirdparty->initAsSpecimen();
119
120 $numExample = $this->getNextValue($thirdparty, $ticket);
121
122 if (!$numExample) {
123 $numExample = $langs->trans('NotConfigured');
124 }
125
126 return $numExample;
127 }
128
136 public function getNextValue($objsoc, $ticket)
137 {
138 global $db, $langs;
139
140 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
141
142 // We define criterion search counter
143 $mask = getDolGlobalString("TICKET_UNIVERSAL_MASK");
144
145 if (!$mask) {
146 $this->error = $langs->trans('NotConfigured');
147 return 0;
148 }
149
150 // Get entities
151 $entity = getEntity('ticketnumber', 1, $ticket);
152
153 $date = empty($ticket->datec) ? dol_now() : $ticket->datec;
154 $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date, 'next', false, null, $entity);
155
156 return $numFinal;
157 }
158}
Class to manage generation of HTML components Only common components must be here.
Parent Class of the project reference numbering model classes.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage the numbering module Universal for Ticket references.
getNextValue($objsoc, $ticket)
Return next value.
getExample()
Return an example of numbering.
info($langs)
Returns the description of the numbering model.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
Class to generate the form for creating a new ticket.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133