2018-03-10 03:23:59 +00:00
< ? php
2026-04-12 09:59:56 +00:00
/* Copyright ( C ) 2013 - 2018 Jean - François FERRY < hello @ librethic . io >
2024-10-29 22:06:25 +00:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2026-04-12 09:59:56 +00:00
* Copyright ( C ) 2024 - 2026 Frédéric France < frederic . france @ free . fr >
2018-03-10 03:23:59 +00:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-03-11 17:28:27 +00:00
*
* Module descriptor for ticket system
2018-03-10 03:23:59 +00:00
*/
/**
2019-02-03 17:47:55 +00:00
* \defgroup ticket Module Ticket
2019-09-04 13:11:06 +00:00
* \brief Module for ticket and request management .
2018-06-04 19:49:29 +00:00
* \file core / modules / modTicket . class . php
* \ingroup ticket
2021-03-20 12:55:43 +00:00
* \brief Description and activation file for the module Ticket
2018-03-10 03:23:59 +00:00
*/
2020-04-10 08:59:32 +00:00
require_once DOL_DOCUMENT_ROOT . " /core/modules/DolibarrModules.class.php " ;
2018-03-10 03:23:59 +00:00
2018-03-11 17:28:27 +00:00
2018-03-10 03:23:59 +00:00
/**
2018-06-04 19:49:29 +00:00
* Description and activation class for module Ticket
2018-03-10 03:23:59 +00:00
*/
2018-06-04 19:49:29 +00:00
class modTicket extends DolibarrModules
2018-03-10 03:23:59 +00:00
{
2020-10-31 13:32:18 +00:00
/**
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
*/
public function __construct ( $db )
{
global $langs , $conf ;
2022-04-17 01:56:36 +00:00
$langs -> load ( " ticket " );
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
$this -> db = $db ;
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Id for module (must be unique).
// Use a free id here
// (See in Home -> System information -> Dolibarr for list of used modules id).
$this -> numero = 56000 ;
// Key text used to identify module (for permissions, menus, etc...)
$this -> rights_class = 'ticket' ;
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this -> family = " crm " ;
// Module position in the family
$this -> module_position = '60' ;
// Module label (no space allowed)
// used if translation string 'ModuleXXXName' not found
// (where XXX is value of numeric property 'numero' of module)
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
// Module description
// used if translation string 'ModuleXXXDesc' not found
// (where XXX is value of numeric property 'numero' of module)
$this -> description = " Incident/support ticket management " ;
// Possible values for version are: 'development', 'experimental' or version
$this -> version = 'dolibarr' ;
// Key used in llx_const table to save module status enabled/disabled
// (where MYMODULE is value of property name of module in uppercase)
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png
// use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png
// use this->picto='pictovalue@module'
$this -> picto = 'ticket' ; // mypicto@ticket
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /ticket/core/xxxxx) (0=disable, 1=enable)
// for specific path of parts (eg: /ticket/core/modules/barcode)
// for specific css file (eg: /ticket/css/ticket.css.php)
2026-04-12 09:59:56 +00:00
$this -> module_parts = [
2020-10-31 13:32:18 +00:00
// Set this to 1 if module has its own trigger directory
'triggers' => 1 ,
2026-04-12 09:59:56 +00:00
];
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Data directories to create when module is enabled.
2026-04-12 09:59:56 +00:00
// Example: this->dirs = ["/ticket/temp"];
$this -> dirs = [];
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Config pages. Put here list of php pages
// stored into ticket/admin directory, used to setup module.
2026-04-12 09:59:56 +00:00
$this -> config_page_url = [ " ticket.php " ];
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Dependencies
$this -> hidden = false ; // A condition to hide module
2026-04-12 09:59:56 +00:00
$this -> depends = [ 'modAgenda' ]; // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = []; // List of module ids to disable if this one is disabled
$this -> conflictwith = []; // List of module class names as string this module is in conflict with
$this -> langfiles = [ " ticket " ];
2019-06-19 10:53:28 +00:00
2020-10-31 13:32:18 +00:00
// Constants
// List of particular constants to add when module is enabled
// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example:
2022-09-30 10:31:29 +00:00
$default_footer = $langs -> trans ( 'TicketMessageMailFooterText' , getDolGlobalString ( 'MAIN_INFO_SOCIETE_NOM' ));
2026-04-12 09:59:56 +00:00
$this -> const = [
[ 'TICKET_ENABLE_PUBLIC_INTERFACE' , 'chaine' , '0' , 'Enable ticket public interface' , 0 ],
[ 'TICKET_ADDON' , 'chaine' , 'mod_ticket_simple' , 'Ticket ref module' , 0 ],
[ 'TICKET_ADDON_PDF_ODT_PATH' , 'chaine' , 'DOL_DATA_ROOT' . ( $conf -> entity > 1 ? '/' . $conf -> entity : '' ) . '/doctemplates/tickets' , 'Ticket templates ODT/ODS directory for templates' , 0 ],
[ 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND' , 'chaine' , 0 , 'Automatically mark ticket as read when created from backend' , 0 ],
[ '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 ],
[ '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 ],
[ 'TICKET_NOTIFY_AT_CLOSING' , 'chaine' , '0' , 'Default notify contacts when closing a module' , 0 ],
[ 'TICKET_PRODUCT_CATEGORY' , 'chaine' , 0 , 'The category of product that is being used to find contract to link to created ticket' , 0 ],
[ 'TICKET_NOTIFICATION_EMAIL_FROM' , 'chaine' , getDolGlobalString ( 'MAIN_MAIL_EMAIL_FROM' ), 'Email to use by default as sender for messages sent from Dolibarr' , 0 ],
[ 'TICKET_MESSAGE_MAIL_INTRO' , 'chaine' , $langs -> trans ( 'TicketMessageMailIntroText' ), 'Introduction text of ticket replies sent from Dolibarr' , 0 ],
[ 'TICKET_MESSAGE_MAIL_SIGNATURE' , 'chaine' , $default_footer , 'Signature to use by default for messages sent from Dolibarr' , 0 ],
[ 'MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER' , 'chaine' , " 1 " , 'Disable the rendering of headers in tickets' , 0 ],
[ 'MAIN_SECURITY_ENABLECAPTCHA_TICKET' , 'chaine' , getDolGlobalInt ( 'MAIN_SECURITY_ENABLECAPTCHA_TICKET' ), 'Enable captcha code by default' , 0 ],
[ 'TICKET_SHOW_COMPANY_LOGO' , 'chaine' , getDolGlobalInt ( 'TICKET_SHOW_COMPANY_LOGO' , 1 ), 'Enable logo header on ticket public page' , 0 ],
[ 'TICKET_SHOW_COMPANY_FOOTER' , 'chaine' , getDolGlobalInt ( 'TICKET_SHOW_COMPANY_FOOTER' , 1 ), 'Enable footer on ticket public page' , 0 ],
];
2018-03-10 03:23:59 +00:00
2024-06-15 16:55:17 +00:00
/*
2026-04-12 09:59:56 +00:00
$this -> tabs = [
2024-05-23 11:43:03 +00:00
'thirdparty:+ticket:Tickets:ticket:$user->hasRight("ticket","read"):/ticket/list.php?socid=__ID__' ,
2026-04-12 09:59:56 +00:00
];
2024-06-15 16:55:17 +00:00
*/
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Dictionaries
if ( ! isset ( $conf -> ticket -> enabled )) {
$conf -> ticket = new stdClass ();
$conf -> ticket -> enabled = 0 ;
}
2024-05-03 17:03:00 +00:00
// Dictionary of ticket types
$this -> declareNewDictionary (
2026-04-12 09:59:56 +00:00
[
2024-05-03 17:03:00 +00:00
'name' => 'c_ticket_type' ,
'lib' => 'TicketDictType' ,
2024-05-04 16:28:34 +00:00
'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' ) . ')' ,
2024-05-03 17:03:00 +00:00
'sqlsort' => 'pos ASC' ,
'field' => 'code,label,pos,use_default' ,
'fieldvalue' => 'code,label,pos,use_default' ,
'fieldinsert' => 'code,label,pos,use_default,entity' ,
'rowid' => 'rowid' ,
'cond' => isModEnabled ( 'ticket' ),
2026-04-12 09:59:56 +00:00
'help' => [ 'code' => $langs -> trans ( 'EnterAnyCode' ), 'use_default' => $langs -> trans ( 'EnterYesOrNo' )],
]
2024-05-03 17:03:00 +00:00
);
// Dictionary of ticket severities
$this -> declareNewDictionary (
2026-04-12 09:59:56 +00:00
[
2024-05-03 17:03:00 +00:00
'name' => 'c_ticket_severity' ,
'lib' => 'TicketDictSeverity' ,
2024-05-04 16:28:34 +00:00
'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' ) . ')' ,
2024-05-03 17:03:00 +00:00
'sqlsort' => 'pos ASC' ,
'field' => 'code,label,pos,use_default' ,
'fieldvalue' => 'code,label,pos,use_default' ,
'fieldinsert' => 'code,label,pos,use_default,entity' ,
'rowid' => 'rowid' ,
'cond' => isModEnabled ( 'ticket' ),
2026-04-12 09:59:56 +00:00
'help' => [
'code' => $langs -> trans ( 'EnterAnyCode' ),
'use_default' => $langs -> trans ( 'EnterYesOrNo' ),
],
]
2024-05-03 17:03:00 +00:00
);
// Dictionary of ticket categories
$this -> declareNewDictionary (
2026-04-12 09:59:56 +00:00
[
2024-05-03 17:03:00 +00:00
'name' => 'c_ticket_category' ,
'lib' => 'TicketDictCategory' ,
2024-05-04 16:56:26 +00:00
'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' ) . ')' ,
2024-05-03 17:03:00 +00:00
'sqlsort' => 'pos ASC' ,
'field' => 'code,label,pos,use_default,public,fk_parent' ,
'fieldvalue' => 'code,label,pos,use_default,public,fk_parent' ,
'fieldinsert' => 'code,label,pos,use_default,public,fk_parent,entity' ,
'rowid' => 'rowid' ,
'cond' => isModEnabled ( 'ticket' ),
2026-04-12 09:59:56 +00:00
'help' => [
2024-05-03 17:03:00 +00:00
'code' => $langs -> trans ( 'EnterAnyCode' ),
2024-07-28 12:54:06 +00:00
'use_default' => $langs -> trans ( 'EnterYesOrNo' ),
2024-05-03 17:03:00 +00:00
'public' => $langs -> trans ( 'Enter0or1' ) . '<br>' . $langs -> trans ( 'TicketGroupIsPublicDesc' ),
2026-04-12 09:59:56 +00:00
'fk_parent' => $langs -> trans ( 'IfThisCategoryIsChildOfAnother' ),
],
]
2024-05-03 17:03:00 +00:00
);
2024-07-28 12:54:06 +00:00
// Dictionary of ticket resolutions (apparently unused except if TICKET_ENABLE_RESOLUTION is on)
2024-05-03 17:03:00 +00:00
$this -> declareNewDictionary (
2026-04-12 09:59:56 +00:00
[
2024-05-03 17:03:00 +00:00
'name' => 'c_ticket_resolution' ,
'lib' => 'TicketDictResolution' ,
2024-05-04 16:56:26 +00:00
'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' ) . ')' ,
2024-05-03 17:03:00 +00:00
'sqlsort' => 'pos ASC' ,
'field' => 'code,label,pos,use_default' ,
'fieldvalue' => 'code,label,pos,use_default' ,
'fieldinsert' => 'code,label,pos,use_default,entity' ,
'rowid' => 'rowid' ,
'cond' => isModEnabled ( 'ticket' ) && getDolGlobalString ( 'TICKET_ENABLE_RESOLUTION' ),
2026-04-12 09:59:56 +00:00
'help' => [
'code' => $langs -> trans ( 'EnterAnyCode' ),
'use_default' => $langs -> trans ( 'Enter0or1' ),
],
]
2020-10-31 13:32:18 +00:00
);
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Boxes
// Add here list of php file(s) stored in core/boxes that contains class to show a box.
2026-04-12 09:59:56 +00:00
$this -> boxes = [
[ 'file' => 'box_last_ticket.php' , 'enabledbydefaulton' => 'Home' ],
[ 'file' => 'box_last_modified_ticket.php' , 'enabledbydefaulton' => 'Home' ],
[ 'file' => 'box_graph_ticket_by_severity.php' , 'enabledbydefaulton' => 'ticketindex' ],
[ 'file' => 'box_graph_nb_ticket_last_x_days.php' , 'enabledbydefaulton' => 'ticketindex' ],
[ 'file' => 'box_graph_nb_tickets_type.php' , 'enabledbydefaulton' => 'ticketindex' ],
[ 'file' => 'box_new_vs_close_ticket.php' , 'enabledbydefaulton' => 'ticketindex' ],
];
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Permissions
2026-04-12 09:59:56 +00:00
$this -> rights = []; // Permission array used by this module
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
$r = 0 ;
$this -> rights [ $r ][ 0 ] = 56001 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Read ticket " ; // libelle de la permission
2024-01-13 18:48:20 +00:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2020-10-31 13:32:18 +00:00
$this -> rights [ $r ][ 4 ] = 'read' ;
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 56002 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Create les tickets " ; // libelle de la permission
2024-01-13 18:48:20 +00:00
$this -> rights [ $r ][ 2 ] = 'w' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2020-10-31 13:32:18 +00:00
$this -> rights [ $r ][ 4 ] = 'write' ;
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 56003 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Delete les tickets " ; // libelle de la permission
2024-01-13 18:48:20 +00:00
$this -> rights [ $r ][ 2 ] = 'd' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2020-10-31 13:32:18 +00:00
$this -> rights [ $r ][ 4 ] = 'delete' ;
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 56004 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Manage tickets " ; // libelle de la permission
2024-01-13 18:48:20 +00:00
//$this->rights[$r][2] = 'd'; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2026-03-12 13:26:48 +00:00
$this -> rights [ $r ][ 4 ] = 'manage_advance' ;
2018-03-10 03:23:59 +00:00
2023-01-25 15:56:27 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 56006 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Export ticket " ; // libelle de la permission
2024-01-13 18:48:20 +00:00
//$this->rights[$r][2] = 'd'; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2023-01-25 15:56:27 +00:00
$this -> rights [ $r ][ 4 ] = 'export' ;
2021-02-01 23:19:41 +00:00
/* Seems not used and in conflict with societe -> client -> voir ( see all thirdparties )
2020-10-31 13:32:18 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 56005 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)' ; // libelle de la permission
2024-01-13 18:48:20 +00:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecated)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par default
2020-10-31 13:32:18 +00:00
$this -> rights [ $r ][ 4 ] = 'view' ;
$this -> rights [ $r ][ 5 ] = 'all' ;
2021-02-01 23:19:41 +00:00
*/
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
// Main menu entries
2026-04-12 09:59:56 +00:00
$this -> menu = []; // List of menus to add
2020-10-31 13:32:18 +00:00
$r = 0 ;
2018-03-10 03:23:59 +00:00
2026-04-12 09:59:56 +00:00
$this -> menu [ $r ] = [
'fk_menu' => 'fk_mainmenu=ticket' ,
2020-10-31 13:32:18 +00:00
'type' => 'left' ,
'titre' => 'Ticket' ,
2021-02-15 19:13:38 +00:00
'prefix' => img_picto ( '' , $this -> picto , 'class="paddingright pictofixedwidth em092"' ),
2020-10-31 13:32:18 +00:00
'mainmenu' => 'ticket' ,
'leftmenu' => 'ticket' ,
'url' => '/ticket/index.php' ,
'langs' => 'ticket' ,
'position' => 101 ,
2023-04-18 18:23:34 +00:00
'enabled' => 'isModEnabled("ticket")' ,
2024-05-23 11:43:03 +00:00
'perms' => '$user->hasRight("ticket","read")' ,
2020-10-31 13:32:18 +00:00
'target' => '' ,
2026-04-12 09:59:56 +00:00
'user' => 2 ,
];
2020-10-31 13:32:18 +00:00
$r ++ ;
2018-03-10 03:23:59 +00:00
2026-04-12 09:59:56 +00:00
$this -> menu [ $r ] = [
'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2020-10-31 13:32:18 +00:00
'type' => 'left' ,
'titre' => 'NewTicket' ,
'mainmenu' => 'ticket' ,
2024-09-01 13:13:53 +00:00
'url' => '/ticket/card.php?action=create&mode=init' ,
2020-10-31 13:32:18 +00:00
'langs' => 'ticket' ,
'position' => 102 ,
2023-04-18 18:23:34 +00:00
'enabled' => 'isModEnabled("ticket")' ,
2025-12-06 02:27:49 +00:00
'perms' => '$user->hasRight("ticket", "write")' ,
2020-10-31 13:32:18 +00:00
'target' => '' ,
2026-04-12 09:59:56 +00:00
'user' => 2 ,
];
2020-10-31 13:32:18 +00:00
$r ++ ;
2018-03-10 03:23:59 +00:00
2026-04-12 09:59:56 +00:00
$this -> menu [ $r ] = [
'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2020-10-31 13:32:18 +00:00
'type' => 'left' ,
'titre' => 'List' ,
'mainmenu' => 'ticket' ,
'leftmenu' => 'ticketlist' ,
2025-03-19 13:14:33 +00:00
'url' => '/ticket/list.php?search_fk_statut=openall' ,
2020-10-31 13:32:18 +00:00
'langs' => 'ticket' ,
'position' => 103 ,
2023-04-18 18:23:34 +00:00
'enabled' => 'isModEnabled("ticket")' ,
2024-05-23 11:43:03 +00:00
'perms' => '$user->hasRight("ticket","read")' ,
2020-10-31 13:32:18 +00:00
'target' => '' ,
2026-04-12 09:59:56 +00:00
'user' => 2 ,
];
2020-10-31 13:32:18 +00:00
$r ++ ;
2018-03-10 03:23:59 +00:00
2026-04-12 09:59:56 +00:00
$this -> menu [ $r ] = [
'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2020-10-31 13:32:18 +00:00
'type' => 'left' ,
'titre' => 'MenuTicketMyAssign' ,
'mainmenu' => 'ticket' ,
'leftmenu' => 'ticketmy' ,
2025-03-19 13:14:33 +00:00
'url' => '/ticket/list.php?mode=mine&search_fk_statut=openall' ,
2020-10-31 13:32:18 +00:00
'langs' => 'ticket' ,
'position' => 105 ,
2023-04-18 18:23:34 +00:00
'enabled' => 'isModEnabled("ticket")' ,
2024-05-23 11:43:03 +00:00
'perms' => '$user->hasRight("ticket","read")' ,
2020-10-31 13:32:18 +00:00
'target' => '' ,
2026-04-12 09:59:56 +00:00
'user' => 0 ,
];
2020-10-31 13:32:18 +00:00
$r ++ ;
2018-03-10 03:23:59 +00:00
2026-04-12 09:59:56 +00:00
$this -> menu [ $r ] = [
'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2020-10-31 13:32:18 +00:00
'type' => 'left' ,
'titre' => 'Statistics' ,
'mainmenu' => 'ticket' ,
'url' => '/ticket/stats/index.php' ,
'langs' => 'ticket' ,
'position' => 107 ,
2026-07-09 21:37:45 +00:00
'enabled' => 'isModEnabled("ticket") && getDolGlobalString("MAIN_STATISTICS_IN_MENU")' ,
2024-05-23 11:43:03 +00:00
'perms' => '$user->hasRight("ticket","read")' ,
2020-10-31 13:32:18 +00:00
'target' => '' ,
2026-04-12 09:59:56 +00:00
'user' => 0 ,
];
2020-10-31 13:32:18 +00:00
$r ++ ;
2021-07-02 08:26:03 +00:00
2026-04-12 09:59:56 +00:00
$this -> menu [ $r ] = [
'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2021-07-02 08:26:03 +00:00
'type' => 'left' ,
'titre' => 'Categories' ,
'mainmenu' => 'ticket' ,
2025-04-26 10:06:45 +00:00
'url' => '/categories/categorie_list.php?type=12' ,
2021-07-02 08:26:03 +00:00
'langs' => 'ticket' ,
'position' => 107 ,
2026-04-04 10:15:13 +00:00
'enabled' => 'isModEnabled("ticket") && isModEnabled("categorie") && getDolGlobalString("CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP")' ,
2024-05-23 11:43:03 +00:00
'perms' => '$user->hasRight("ticket","read")' ,
2021-07-02 08:26:03 +00:00
'target' => '' ,
2026-04-12 09:59:56 +00:00
'user' => 0 ,
];
2021-07-02 08:26:03 +00:00
$r ++ ;
2023-01-25 15:56:27 +00:00
// Exports
//--------
$r = 1 ;
// Export list of tickets and attributes
$langs -> load ( " ticket " );
2024-03-12 23:32:02 +00:00
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'ExportDataset_ticket_1' ; // Translation key (used only if key ExportDataset_xxx_z not found)
2026-04-12 09:59:56 +00:00
$this -> export_permission [ $r ] = [[ " ticket " , " export " ]];
2024-03-12 23:32:02 +00:00
$this -> export_icon [ $r ] = 'ticket' ;
2023-12-04 11:07:31 +00:00
$keyforclass = 'Ticket' ;
2024-03-12 23:32:02 +00:00
$keyforclassfile = '/ticket/class/ticket.class.php' ;
$keyforelement = 'ticket' ;
2023-01-25 15:56:27 +00:00
include DOL_DOCUMENT_ROOT . '/core/commonfieldsinexport.inc.php' ;
2024-03-12 23:32:02 +00:00
$keyforselect = 'ticket' ;
$keyforaliasextra = 'extra' ;
2024-05-30 11:37:17 +00:00
$keyforelement = 'ticket' ;
2023-01-25 15:56:27 +00:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2024-03-12 23:32:02 +00:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'ticket as t' ;
2023-01-25 15:56:27 +00:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'ticket_extrafields as extra on (t.rowid = extra.fk_object)' ;
2024-03-12 23:32:02 +00:00
$this -> export_sql_end [ $r ] .= ' WHERE 1 = 1' ;
$this -> export_sql_end [ $r ] .= ' AND t.entity IN (' . getEntity ( 'ticket' ) . ')' ;
2023-01-25 15:56:27 +00:00
$r ++ ;
2020-10-31 13:32:18 +00:00
}
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
/**
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories
*
* @ param string $options Options when enabling module ( '' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
*/
public function init ( $options = '' )
{
2020-12-16 18:01:26 +00:00
global $conf , $langs ;
2022-05-08 13:18:34 +00:00
$result = $this -> _load_tables ( '/install/mysql/' , 'ticket' );
2022-02-17 18:30:18 +00:00
if ( $result < 0 ) {
return - 1 ; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
2020-12-16 18:01:26 +00:00
// Permissions
$this -> remove ( $options );
2026-04-12 09:59:56 +00:00
// ODT template
2020-12-16 18:01:26 +00:00
$src = DOL_DOCUMENT_ROOT . '/install/doctemplates/tickets/template_ticket.odt' ;
2025-02-13 17:20:47 +00:00
$dirodt = DOL_DATA_ROOT . ( $conf -> entity > 1 ? '/' . $conf -> entity : '' ) . '/doctemplates/tickets' ;
2024-02-07 18:36:23 +00:00
$dest = $dirodt . '/template_ticket.odt' ;
2020-12-16 18:01:26 +00:00
2021-02-23 21:03:23 +00:00
if ( file_exists ( $src ) && ! file_exists ( $dest )) {
2020-12-16 18:01:26 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
dol_mkdir ( $dirodt );
2024-09-22 23:59:14 +00:00
$result = dol_copy ( $src , $dest , '0' , 0 );
2021-02-23 21:03:23 +00:00
if ( $result < 0 ) {
2020-12-16 18:01:26 +00:00
$langs -> load ( " errors " );
$this -> error = $langs -> trans ( 'ErrorFailToCopyFile' , $src , $dest );
return 0 ;
}
}
2018-03-10 03:23:59 +00:00
2026-04-12 09:59:56 +00:00
$sql = [
[ " 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 ],
[ " sql " => " INSERT INTO " . $this -> db -> prefix () . " c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1); " , " ignoreerror " => 1 ],
[ " 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 ],
[ " sql " => " INSERT INTO " . $this -> db -> prefix () . " c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1); " , " ignoreerror " => 1 ],
2024-02-07 18:36:23 +00:00
// remove old settings
2026-07-09 21:37:45 +00:00
[ " sql " => " DELETE FROM " . $this -> db -> prefix () . " document_model WHERE nom = 'TICKET_ADDON_PDF_ODT_PATH' AND type = 'ticket' AND entity = " . (( int ) $conf -> entity ), " ignoreerror " => 1 ],
2024-02-07 18:36:23 +00:00
// activate default odt templates
2026-04-12 09:59:56 +00:00
[ " 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 ],
];
2018-03-10 03:23:59 +00:00
2020-10-31 13:32:18 +00:00
return $this -> _init ( $sql , $options );
}
2018-03-10 03:23:59 +00:00
}