29require_once DOL_DOCUMENT_ROOT.
"/core/modules/DolibarrModules.class.php";
45 $langs->load(
"ticket");
52 $this->numero = 56000;
54 $this->rights_class =
'ticket';
58 $this->family =
"crm";
60 $this->module_position =
'60';
64 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
68 $this->
description =
"Incident/support ticket management";
70 $this->version =
'dolibarr';
73 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
79 $this->picto =
'ticket';
84 $this->module_parts = array(
91 $this->dirs = array();
95 $this->config_page_url = array(
"ticket.php");
98 $this->hidden =
false;
99 $this->depends = array(
'modAgenda');
100 $this->requiredby = array();
101 $this->conflictwith = array();
102 $this->phpmin = array(7, 0);
103 $this->langfiles = array(
"ticket");
109 $default_footer = $langs->trans(
'TicketMessageMailFooterText',
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'));
110 $this->
const = array(
111 1 => array(
'TICKET_ENABLE_PUBLIC_INTERFACE',
'chaine',
'0',
'Enable ticket public interface', 0),
112 2 => array(
'TICKET_ADDON',
'chaine',
'mod_ticket_simple',
'Ticket ref module', 0),
113 3 => array(
'TICKET_ADDON_PDF_ODT_PATH',
'chaine',
'DOL_DATA_ROOT/doctemplates/tickets',
'Ticket templates ODT/ODS directory for templates', 0),
114 4 => array(
'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND',
'chaine', 0,
'Automatically mark ticket as read when created from backend', 0),
115 5 => array(
'TICKET_DELAY_BEFORE_FIRST_RESPONSE',
'chaine',
'0',
'Maximum wanted elapsed time before a first answer to a ticket (in hours). Display a warning in tickets list if not respected.', 0),
116 6 => array(
'TICKET_DELAY_SINCE_LAST_RESPONSE',
'chaine',
'0',
'Maximum wanted elapsed time between two answers on the same ticket (in hours). Display a warning in tickets list if not respected.', 0),
117 7 => array(
'TICKET_NOTIFY_AT_CLOSING',
'chaine',
'0',
'Default notify contacts when closing a module', 0),
118 8 => array(
'TICKET_PRODUCT_CATEGORY',
'chaine', 0,
'The category of product that is being used to find contract to link to created ticket', 0),
119 9 => array(
'TICKET_NOTIFICATION_EMAIL_FROM',
'chaine',
getDolGlobalString(
'MAIN_MAIL_EMAIL_FROM'),
'Email to use by default as sender for messages sent from Dolibarr', 0),
120 10 => array(
'TICKET_MESSAGE_MAIL_INTRO',
'chaine', $langs->trans(
'TicketMessageMailIntroText'),
'Introduction text of ticket replies sent from Dolibarr', 0),
121 11 => array(
'TICKET_MESSAGE_MAIL_SIGNATURE',
'chaine', $default_footer,
'Signature to use by default for messages sent from Dolibarr', 0),
122 12 => array(
'MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER',
'chaine',
"1",
'Disable the rendering of headers in tickets', 0),
123 13 => array(
'MAIN_SECURITY_ENABLECAPTCHA_TICKET',
'chaine',
getDolGlobalInt(
'MAIN_SECURITY_ENABLECAPTCHA_TICKET'),
'Enable captcha code by default', 0),
124 14 => array(
'TICKET_SHOW_COMPANY_LOGO',
'chaine',
getDolGlobalInt(
'TICKET_SHOW_COMPANY_LOGO', 1),
'Enable logo header on ticket public page', 0),
125 15 => array(
'TICKET_SHOW_COMPANY_FOOTER',
'chaine',
getDolGlobalInt(
'TICKET_SHOW_COMPANY_FOOTER', 1),
'Enable footer on ticket public page', 0)
135 if (!isset($conf->ticket->enabled)) {
137 $conf->ticket->enabled = 0;
143 'name' =>
'c_ticket_type',
144 'lib' =>
'TicketDictType',
145 'sql' =>
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.entity FROM '.$this->db->prefix().
'c_ticket_type as f WHERE f.entity IN ('.
getEntity(
'c_ticket_type').
')',
146 'sqlsort' =>
'pos ASC',
147 'field' =>
'code,label,pos,use_default',
148 'fieldvalue' =>
'code,label,pos,use_default',
149 'fieldinsert' =>
'code,label,pos,use_default,entity',
151 'cond' => isModEnabled(
'ticket'),
152 'help' => array(
'code' => $langs->trans(
'EnterAnyCode'),
'use_default' => $langs->trans(
'EnterYesOrNo'))
159 'name' =>
'c_ticket_severity',
160 'lib' =>
'TicketDictSeverity',
161 'sql' =>
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.entity FROM '.$this->db->prefix().
'c_ticket_severity as f WHERE f.entity IN ('.
getEntity(
'c_ticket_severity').
')',
162 'sqlsort' =>
'pos ASC',
163 'field' =>
'code,label,pos,use_default',
164 'fieldvalue' =>
'code,label,pos,use_default',
165 'fieldinsert' =>
'code,label,pos,use_default,entity',
167 'cond' => isModEnabled(
'ticket'),
168 'help' => array(
'code' => $langs->trans(
'EnterAnyCode'),
'use_default' => $langs->trans(
'EnterYesOrNo'))
175 'name' =>
'c_ticket_category',
176 'lib' =>
'TicketDictCategory',
177 'sql' =>
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.public, f.fk_parent, f.entity FROM '.$this->db->prefix().
'c_ticket_category as f WHERE f.entity IN ('.
getEntity(
'c_ticket_category').
')',
178 'sqlsort' =>
'pos ASC',
179 'field' =>
'code,label,pos,use_default,public,fk_parent',
180 'fieldvalue' =>
'code,label,pos,use_default,public,fk_parent',
181 'fieldinsert' =>
'code,label,pos,use_default,public,fk_parent,entity',
183 'cond' => isModEnabled(
'ticket'),
185 'code' => $langs->trans(
'EnterAnyCode'),
186 'use_default' => $langs->trans(
'EnterYesOrNo'),
187 'public' => $langs->trans(
'Enter0or1').
'<br>'.$langs->trans(
'TicketGroupIsPublicDesc'),
188 'fk_parent' => $langs->trans(
'IfThisCategoryIsChildOfAnother')
196 'name' =>
'c_ticket_resolution',
197 'lib' =>
'TicketDictResolution',
198 'sql' =>
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.entity FROM '.$this->db->prefix().
'c_ticket_resolution as f WHERE f.entity IN ('.
getEntity(
'c_ticket_resolution').
')',
199 'sqlsort' =>
'pos ASC',
200 'field' =>
'code,label,pos,use_default',
201 'fieldvalue' =>
'code,label,pos,use_default',
202 'fieldinsert' =>
'code,label,pos,use_default,entity',
205 'help' => array(
'code' => $langs->trans(
'EnterAnyCode'),
'use_default' => $langs->trans(
'Enter0or1'))
211 $this->boxes = array(
212 0 => array(
'file' =>
'box_last_ticket.php',
'enabledbydefaulton' =>
'Home'),
213 1 => array(
'file' =>
'box_last_modified_ticket.php',
'enabledbydefaulton' =>
'Home'),
214 2 => array(
'file' =>
'box_ticket_by_severity.php',
'enabledbydefaulton' =>
'ticketindex'),
215 3 => array(
'file' =>
'box_graph_nb_ticket_last_x_days.php',
'enabledbydefaulton' =>
'ticketindex'),
216 4 => array(
'file' =>
'box_graph_nb_tickets_type.php',
'enabledbydefaulton' =>
'ticketindex'),
217 5 => array(
'file' =>
'box_new_vs_close_ticket.php',
'enabledbydefaulton' =>
'ticketindex')
221 $this->rights = array();
224 $this->rights[$r][0] = 56001;
225 $this->rights[$r][1] =
"Read ticket";
226 $this->rights[$r][2] =
'r';
227 $this->rights[$r][3] = 0;
228 $this->rights[$r][4] =
'read';
231 $this->rights[$r][0] = 56002;
232 $this->rights[$r][1] =
"Create les tickets";
233 $this->rights[$r][2] =
'w';
234 $this->rights[$r][3] = 0;
235 $this->rights[$r][4] =
'write';
238 $this->rights[$r][0] = 56003;
239 $this->rights[$r][1] =
"Delete les tickets";
240 $this->rights[$r][2] =
'd';
241 $this->rights[$r][3] = 0;
242 $this->rights[$r][4] =
'delete';
245 $this->rights[$r][0] = 56004;
246 $this->rights[$r][1] =
"Manage tickets";
248 $this->rights[$r][3] = 0;
249 $this->rights[$r][4] =
'manage';
252 $this->rights[$r][0] = 56006;
253 $this->rights[$r][1] =
"Export ticket";
255 $this->rights[$r][3] = 0;
256 $this->rights[$r][4] =
'export';
269 $this->menu = array();
287 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket',
290 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth em092"'),
291 'mainmenu' =>
'ticket',
292 'leftmenu' =>
'ticket',
293 'url' =>
'/ticket/index.php',
296 'enabled' =>
'isModEnabled("ticket")',
297 'perms' =>
'$user->hasRight("ticket","read")',
302 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
304 'titre' =>
'NewTicket',
305 'mainmenu' =>
'ticket',
306 'url' =>
'/ticket/card.php?action=create&mode=init',
309 'enabled' =>
'isModEnabled("ticket")',
310 'perms' =>
'$user->rights->ticket->write',
315 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
318 'mainmenu' =>
'ticket',
319 'leftmenu' =>
'ticketlist',
320 'url' =>
'/ticket/list.php?search_fk_status=non_closed',
323 'enabled' =>
'isModEnabled("ticket")',
324 'perms' =>
'$user->hasRight("ticket","read")',
329 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
331 'titre' =>
'MenuTicketMyAssign',
332 'mainmenu' =>
'ticket',
333 'leftmenu' =>
'ticketmy',
334 'url' =>
'/ticket/list.php?mode=mine&search_fk_status=non_closed',
337 'enabled' =>
'isModEnabled("ticket")',
338 'perms' =>
'$user->hasRight("ticket","read")',
343 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
345 'titre' =>
'Statistics',
346 'mainmenu' =>
'ticket',
347 'url' =>
'/ticket/stats/index.php',
350 'enabled' =>
'isModEnabled("ticket")',
351 'perms' =>
'$user->hasRight("ticket","read")',
356 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
358 'titre' =>
'Categories',
359 'mainmenu' =>
'ticket',
360 'url' =>
'/categories/index.php?type=12',
363 'enabled' =>
'isModEnabled("ticket") && isModEnabled("categorie")',
364 'perms' =>
'$user->hasRight("ticket","read")',
374 $langs->load(
"ticket");
375 $this->export_code[$r] = $this->rights_class.
'_'.$r;
376 $this->export_label[$r] =
'ExportDataset_ticket_1';
377 $this->export_permission[$r] = array(array(
"ticket",
"export"));
378 $this->export_icon[$r] =
'ticket';
379 $keyforclass =
'Ticket';
380 $keyforclassfile =
'/ticket/class/ticket.class.php';
381 $keyforelement =
'ticket';
382 include DOL_DOCUMENT_ROOT.
'/core/commonfieldsinexport.inc.php';
383 $keyforselect =
'ticket';
384 $keyforaliasextra =
'extra';
385 $keyforelement =
'ticket';
386 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
387 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
388 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'ticket as t';
389 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'ticket_extrafields as extra on (t.rowid = extra.fk_object)';
390 $this->export_sql_end[$r] .=
' WHERE 1 = 1';
391 $this->export_sql_end[$r] .=
' AND t.entity IN ('.getEntity(
'ticket').
')';
403 public function init($options =
'')
405 global $conf, $langs;
407 $result = $this->
_load_tables(
'/install/mysql/',
'ticket');
413 $this->
remove($options);
416 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/tickets/template_ticket.odt';
417 $dirodt = DOL_DATA_ROOT.
'/doctemplates/tickets';
418 $dest = $dirodt.
'/template_ticket.odt';
420 if (file_exists($src) && !file_exists($dest)) {
421 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
423 $result =
dol_copy($src, $dest, 0, 0);
425 $langs->load(
"errors");
426 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
432 array(
"sql" =>
"insert into ".$this->db->prefix().
"c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1);",
"ignoreerror" => 1),
433 array(
"sql" =>
"insert into ".$this->db->prefix().
"c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);",
"ignoreerror" => 1),
434 array(
"sql" =>
"insert into ".$this->db->prefix().
"c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);",
"ignoreerror" => 1),
435 array(
"sql" =>
"insert into ".$this->db->prefix().
"c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1);",
"ignoreerror" => 1),
437 "DELETE FROM ".$this->db->prefix().
"document_model WHERE nom = 'TICKET_ADDON_PDF_ODT_PATH' AND type = 'ticket' AND entity = ".((
int) $conf->entity),
439 array(
"sql" =>
"INSERT INTO ".$this->db->prefix().
"document_model (nom, type, libelle, entity, description) VALUES('generic_ticket_odt','ticket','ODT templates',".((
int) $conf->entity).
",'TICKET_ADDON_PDF_ODT_PATH');",
"ignoreerror" => 1),
442 return $this->
_init($sql, $options);
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
declareNewDictionary($dictionaryArray, $langs='')
Helper method to declare dictionaries one at a time (rather than declaring dictionaries property by p...
Description and activation class for module Ticket.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.