dolibarr  16.0.5
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 
25 require_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 
60  public function info()
61  {
62  global $db, $conf, $langs;
63 
64  // Load translation files required by the page
65  $langs->loadLangs(array("ticket", "admin"));
66 
67  $form = new Form($db);
68 
69  $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
70  $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
71  $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
72  $texte .= '<input type="hidden" name="action" value="updateMask">';
73  $texte .= '<input type="hidden" name="maskconstticket" value="TICKET_UNIVERSAL_MASK">';
74  $texte .= '<table class="nobordernopadding" width="100%">';
75 
76  $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
77  $tooltip .= $langs->trans("GenericMaskCodes2");
78  $tooltip .= $langs->trans("GenericMaskCodes3");
79  $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Ticket"), $langs->transnoentities("Ticket"));
80  $tooltip .= $langs->trans("GenericMaskCodes5");
81 
82  // Parametrage du prefix
83  $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
84  $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskticket" value="'.$conf->global->TICKET_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
85 
86  $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
87 
88  $texte .= '</tr>';
89 
90  $texte .= '</table>';
91  $texte .= '</form>';
92 
93  return $texte;
94  }
95 
101  public function getExample()
102  {
103  global $conf, $langs, $mysoc;
104 
105  $old_code_client = $mysoc->code_client;
106  $mysoc->code_client = 'CCCCCCCCCC';
107  $numExample = $this->getNextValue($mysoc, '');
108  $mysoc->code_client = $old_code_client;
109 
110  if (!$numExample) {
111  $numExample = $langs->trans('NotConfigured');
112  }
113  return $numExample;
114  }
115 
123  public function getNextValue($objsoc, $ticket)
124  {
125  global $db, $conf;
126 
127  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
128 
129  // On defini critere recherche compteur
130  $mask = $conf->global->TICKET_UNIVERSAL_MASK;
131 
132  if (!$mask) {
133  $this->error = 'NotConfigured';
134  return 0;
135  }
136 
137  // Get entities
138  $entity = getEntity('ticketnumber', 1, $ticket);
139 
140  $date = empty($ticket->datec) ? dol_now() : $ticket->datec;
141  $numFinal = get_next_value($db, $mask, 'ticket', 'ref', '', $objsoc->code_client, $date, 'next', false, null, $entity);
142 
143  return $numFinal;
144  }
145 }
mod_ticket_universal\getNextValue
getNextValue($objsoc, $ticket)
Return next value.
Definition: mod_ticket_universal.php:123
mod_ticket_universal\info
info()
Returns the description of the numbering model.
Definition: mod_ticket_universal.php:60
ModeleNumRefTicket
Classe mere des modeles de numerotation des references de projets.
Definition: modules_ticket.php:63
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
mod_ticket_universal
Classe du modele de numerotation de reference de projet Universal.
Definition: mod_ticket_universal.php:30
getEntity
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Definition: functions.lib.php:148
get_next_value
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)
Definition: functions2.lib.php:970
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
mod_ticket_universal\getExample
getExample()
Return an example of numbering.
Definition: mod_ticket_universal.php:101