dolibarr 21.0.0-alpha
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 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("GenericMaskCodes2");
81 $tooltip .= $langs->trans("GenericMaskCodes3");
82 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
83 $tooltip .= $langs->trans("GenericMaskCodes5");
84 //$tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
85
86 // Prefix settings
87 $text .= '<tr><td>'.$langs->trans("Mask").':</td>';
88 $text .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskticket" value="'.getDolGlobalString("TICKET_UNIVERSAL_MASK").'">', $tooltip, 1, 1).'</td>';
89
90 $text .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
91
92 $text .= '</tr>';
93
94 $text .= '</table>';
95 $text .= '</form>';
96
97 return $text;
98 }
99
105 public function getExample()
106 {
107 global $db, $langs;
108
109 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
110 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
111
112 $ticket = new Ticket($db);
113 $ticket->initAsSpecimen();
114 $thirdparty = new Societe($db);
115 $thirdparty->initAsSpecimen();
116
117 $numExample = $this->getNextValue($thirdparty, $ticket);
118
119 if (!$numExample) {
120 $numExample = $langs->trans('NotConfigured');
121 }
122
123 return $numExample;
124 }
125
133 public function getNextValue($objsoc, $ticket)
134 {
135 global $db, $langs;
136
137 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
138
139 // We define criterion search counter
140 $mask = getDolGlobalString("TICKET_UNIVERSAL_MASK");
141
142 if (!$mask) {
143 $this->error = $langs->trans('NotConfigured');
144 return 0;
145 }
146
147 // Get entities
148 $entity = getEntity('ticketnumber', 1, $ticket);
149
150 $date = empty($ticket->datec) ? dol_now() : $ticket->datec;
151 $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date, 'next', false, null, $entity);
152
153 return $numFinal;
154 }
155}
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.
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 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.