27 require_once DOL_DOCUMENT_ROOT.
"/core/modules/DolibarrModules.class.php";
43 $langs->load(
"ticket");
50 $this->numero = 56000;
52 $this->rights_class =
'ticket';
56 $this->family =
"crm";
58 $this->module_position =
'60';
62 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
66 $this->
description =
"Incident/support ticket management";
68 $this->version =
'dolibarr';
71 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
77 $this->picto =
'ticket';
82 $this->module_parts = array(
89 $this->dirs = array();
93 $this->config_page_url = array(
"ticket.php");
96 $this->hidden =
false;
97 $this->depends = array(
'modAgenda');
98 $this->requiredby = array();
99 $this->conflictwith = array();
100 $this->phpmin = array(7, 0);
101 $this->langfiles = array(
"ticket");
107 $default_footer = $langs->trans(
'TicketMessageMailFooterText',
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'));
108 $this->
const = array(
109 1 => array(
'TICKET_ENABLE_PUBLIC_INTERFACE',
'chaine',
'0',
'Enable ticket public interface', 0),
110 2 => array(
'TICKET_ADDON',
'chaine',
'mod_ticket_simple',
'Ticket ref module', 0),
111 3 => array(
'TICKET_ADDON_PDF_ODT_PATH',
'chaine',
'DOL_DATA_ROOT/doctemplates/tickets',
'Ticket templates ODT/ODS directory for templates', 0),
112 4 => array(
'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND',
'chaine', 0,
'Automatically mark ticket as read when created from backend', 0),
113 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),
114 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),
115 7 => array(
'TICKET_NOTIFY_AT_CLOSING',
'chaine',
'0',
'Default notify contacts when closing a module', 0),
116 8 => array(
'TICKET_PRODUCT_CATEGORY',
'chaine', 0,
'The category of product that is being used for ticket accounting', 0),
117 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),
118 10 => array(
'TICKET_MESSAGE_MAIL_INTRO',
'chaine', $langs->trans(
'TicketMessageMailIntroText'),
'Introduction text of ticket replies sent from Dolibarr', 0),
119 11 => array(
'TICKET_MESSAGE_MAIL_SIGNATURE',
'chaine', $default_footer,
'Signature to use by default for messages sent from Dolibarr', 0),
120 12 => array(
'MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER',
'chaine',
"1",
'Disable the rendering of headers in tickets', 0),
121 13 => array(
'MAIN_SECURITY_ENABLECAPTCHA_TICKET',
'chaine',
getDolGlobalInt(
'MAIN_SECURITY_ENABLECAPTCHA_TICKET'),
'Enable captcha code by default', 0),
122 14 => array(
'TICKET_SHOW_COMPANY_LOGO',
'chaine',
getDolGlobalInt(
'TICKET_SHOW_COMPANY_LOGO'),
'Enable logo header on ticket public page', 0)
127 'thirdparty:+ticket:Tickets:ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__',
131 if (!isset($conf->ticket->enabled)) {
132 $conf->ticket =
new stdClass();
133 $conf->ticket->enabled = 0;
135 $this->dictionaries = array(
141 "c_ticket_resolution"
145 "TicketDictSeverity",
146 "TicketDictCategory",
147 "TicketDictResolution"
150 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.
'c_ticket_type as f',
151 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.
'c_ticket_severity as f',
152 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default, f.public, f.fk_parent FROM '.MAIN_DB_PREFIX.
'c_ticket_category as f',
153 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.
'c_ticket_resolution as f'
155 'tabsqlsort' => array(
"pos ASC",
"pos ASC",
"pos ASC",
"pos ASC"),
156 'tabfield' => array(
"code,label,pos,use_default",
"code,label,pos,use_default",
"code,label,pos,use_default,public,fk_parent",
"code,label,pos,use_default"),
157 'tabfieldvalue' => array(
"code,label,pos,use_default",
"code,label,pos,use_default",
"code,label,pos,use_default,public,fk_parent",
"code,label,pos,use_default"),
158 'tabfieldinsert' => array(
"code,label,pos,use_default",
"code,label,pos,use_default",
"code,label,pos,use_default,public,fk_parent",
"code,label,pos,use_default"),
159 'tabrowid' => array(
"rowid",
"rowid",
"rowid",
"rowid"),
160 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled && !empty($conf->global->TICKET_ENABLE_RESOLUTION)),
162 array(
'code'=>$langs->trans(
"EnterAnyCode"),
'use_default'=>$langs->trans(
"Enter0or1")),
163 array(
'code'=>$langs->trans(
"EnterAnyCode"),
'use_default'=>$langs->trans(
"Enter0or1")),
164 array(
'code'=>$langs->trans(
"EnterAnyCode"),
'use_default'=>$langs->trans(
"Enter0or1"),
'public'=>$langs->trans(
"Enter0or1").
'<br>'.$langs->trans(
"TicketGroupIsPublicDesc"),
'fk_parent'=>$langs->trans(
"IfThisCategoryIsChildOfAnother")),
165 array(
'code'=>$langs->trans(
"EnterAnyCode"),
'use_default'=>$langs->trans(
"Enter0or1"))
171 $this->boxes = array(
172 0=>array(
'file'=>
'box_last_ticket.php',
'enabledbydefaulton'=>
'Home'),
173 1=>array(
'file'=>
'box_last_modified_ticket.php',
'enabledbydefaulton'=>
'Home'),
174 2=>array(
'file'=>
'box_ticket_by_severity.php',
'enabledbydefaulton'=>
'ticketindex'),
175 3=>array(
'file'=>
'box_graph_nb_ticket_last_x_days.php',
'enabledbydefaulton'=>
'ticketindex'),
176 4=>array(
'file'=>
'box_graph_nb_tickets_type.php',
'enabledbydefaulton'=>
'ticketindex'),
177 5=>array(
'file'=>
'box_new_vs_close_ticket.php',
'enabledbydefaulton'=>
'ticketindex')
181 $this->rights = array();
184 $this->rights[$r][0] = 56001;
185 $this->rights[$r][1] =
"Read ticket";
186 $this->rights[$r][2] =
'r';
187 $this->rights[$r][3] = 0;
188 $this->rights[$r][4] =
'read';
191 $this->rights[$r][0] = 56002;
192 $this->rights[$r][1] =
"Create les tickets";
193 $this->rights[$r][2] =
'w';
194 $this->rights[$r][3] = 0;
195 $this->rights[$r][4] =
'write';
198 $this->rights[$r][0] = 56003;
199 $this->rights[$r][1] =
"Delete les tickets";
200 $this->rights[$r][2] =
'd';
201 $this->rights[$r][3] = 0;
202 $this->rights[$r][4] =
'delete';
205 $this->rights[$r][0] = 56004;
206 $this->rights[$r][1] =
"Manage tickets";
208 $this->rights[$r][3] = 0;
209 $this->rights[$r][4] =
'manage';
222 $this->menus = array();
240 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket',
243 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth em092"'),
244 'mainmenu' =>
'ticket',
245 'leftmenu' =>
'ticket',
246 'url' =>
'/ticket/index.php',
249 'enabled' =>
'$conf->ticket->enabled',
250 'perms' =>
'$user->rights->ticket->read',
255 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
257 'titre' =>
'NewTicket',
258 'mainmenu' =>
'ticket',
259 'url' =>
'/ticket/card.php?action=create',
262 'enabled' =>
'$conf->ticket->enabled',
263 'perms' =>
'$user->rights->ticket->write',
268 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
271 'mainmenu' =>
'ticket',
272 'leftmenu' =>
'ticketlist',
273 'url' =>
'/ticket/list.php?search_fk_status=non_closed',
276 'enabled' =>
'$conf->ticket->enabled',
277 'perms' =>
'$user->rights->ticket->read',
282 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
284 'titre' =>
'MenuTicketMyAssign',
285 'mainmenu' =>
'ticket',
286 'leftmenu' =>
'ticketmy',
287 'url' =>
'/ticket/list.php?mode=mine&search_fk_status=non_closed',
290 'enabled' =>
'$conf->ticket->enabled',
291 'perms' =>
'$user->rights->ticket->read',
296 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
298 'titre' =>
'Statistics',
299 'mainmenu' =>
'ticket',
300 'url' =>
'/ticket/stats/index.php',
303 'enabled' =>
'$conf->ticket->enabled',
304 'perms' =>
'$user->rights->ticket->read',
309 $this->menu[$r] = array(
'fk_menu' =>
'fk_mainmenu=ticket,fk_leftmenu=ticket',
311 'titre' =>
'Categories',
312 'mainmenu' =>
'ticket',
313 'url' =>
'/categories/index.php?type=12',
316 'enabled' =>
'$conf->categorie->enabled',
317 'perms' =>
'$user->rights->ticket->read',
331 public function init($options =
'')
333 global $conf, $langs;
335 $result = $this->
_load_tables(
'/install/mysql/',
'ticket');
341 $this->
remove($options);
344 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/tickets/template_ticket.odt';
345 $dirodt = DOL_DATA_ROOT.
'/doctemplates/tickets';
346 $dest = $dirodt.
'/template_order.odt';
348 if (file_exists($src) && !file_exists($dest)) {
349 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
351 $result =
dol_copy($src, $dest, 0, 0);
353 $langs->load(
"errors");
354 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
360 array(
"sql" =>
"insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1);",
"ignoreerror" => 1),
361 array(
"sql" =>
"insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);",
"ignoreerror" => 1),
362 array(
"sql" =>
"insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);",
"ignoreerror" => 1),
363 array(
"sql" =>
"insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1);",
"ignoreerror" => 1),
364 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'TICKET_ADDON_PDF_ODT_PATH' AND type = 'ticket' AND entity = ".((
int) $conf->entity),
365 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('TICKET_ADDON_PDF_ODT_PATH','ticket',".((
int) $conf->entity).
")"
368 return $this->
_init($sql, $options);
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module Ticket.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
print *****$script_file(".$version.") pid 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)
Copy a file to another file.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
$conf db
API class for accounts.