dolibarr 20.0.0
mod_ticket_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/ticket/modules_ticket.php';
26
31{
36 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
37
41 public $error = '';
42
48 public $nom = 'Universal';
49
53 public $name = 'Universal';
54
61 public function info($langs)
62 {
63 global $db, $langs;
64
65 // Load translation files required by the page
66 $langs->loadLangs(array("ticket", "admin"));
67
68 $form = new Form($db);
69
70 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
73 $texte .= '<input type="hidden" name="action" value="updateMask">';
74 $texte .= '<input type="hidden" name="maskconstticket" value="TICKET_UNIVERSAL_MASK">';
75 $texte .= '<table class="nobordernopadding" width="100%">';
76
77 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
78 $tooltip .= $langs->trans("GenericMaskCodes2");
79 $tooltip .= $langs->trans("GenericMaskCodes3");
80 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
81 $tooltip .= $langs->trans("GenericMaskCodes5");
82 //$tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
83
84 // Prefix settings
85 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskticket" value="'.getDolGlobalString("TICKET_UNIVERSAL_MASK").'">', $tooltip, 1, 1).'</td>';
87
88 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button"value="'.$langs->trans("Modify").'"></td>';
89
90 $texte .= '</tr>';
91
92 $texte .= '</table>';
93 $texte .= '</form>';
94
95 return $texte;
96 }
97
103 public function getExample()
104 {
105 global $conf, $langs, $mysoc;
106
107 $old_code_client = $mysoc->code_client;
108 $mysoc->code_client = 'CCCCCCCCCC';
109 $numExample = $this->getNextValue($mysoc, '');
110 $mysoc->code_client = $old_code_client;
111
112 if (!$numExample) {
113 $numExample = $langs->trans('NotConfigured');
114 }
115 return $numExample;
116 }
117
125 public function getNextValue($objsoc, $ticket)
126 {
127 global $db, $conf;
128
129 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
130
131 // We define criterion search counter
132 $mask = getDolGlobalString("TICKET_UNIVERSAL_MASK");
133
134 if (!$mask) {
135 $this->error = 'NotConfigured';
136 return 0;
137 }
138
139 // Get entities
140 $entity = getEntity('ticketnumber', 1, $ticket);
141
142 $date = empty($ticket->datec) ? dol_now() : $ticket->datec;
143 $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date, 'next', false, null, $entity);
144
145 return $numFinal;
146 }
147}
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 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 dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.