2018-03-10 04:23:59 +01:00
< ? php
2018-03-22 10:23:25 +01:00
/* Copyright ( C ) 2013 - 2016 Jean - François FERRY < hello @ librethic . io >
* Copyright ( C ) 2016 Christophe Battarel < christophe @ altairis . fr >
2018-04-13 12:52:23 +02:00
* Copyright ( C ) 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2021-05-11 08:01:13 +02:00
* Copyright ( C ) 2021 Frédéric France < frederic . france @ netlogic . fr >
2018-03-10 04:23:59 +01: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
2018-07-16 12:13:34 +02:00
* the Free Software Foundation ; either version 3 of the License , or
2018-03-10 04:23:59 +01:00
* ( 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 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-03-10 04:23:59 +01:00
*/
/**
2018-06-04 21:49:29 +02:00
* \file htdocs / ticket / card . php
* \ingroup ticket
2018-03-10 04:23:59 +01:00
*/
2018-03-11 10:34:21 +01:00
require '../main.inc.php' ;
2019-11-13 19:35:02 +01:00
require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2018-03-10 04:23:59 +01:00
if ( ! empty ( $conf -> projet -> enabled )) {
2020-04-16 00:42:57 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php' ;
2018-03-10 04:23:59 +01:00
}
if ( ! empty ( $conf -> contrat -> enabled )) {
2020-04-16 00:42:57 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/contract.lib.php' ;
include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php' ;
2018-03-10 04:23:59 +01:00
}
2018-05-26 16:35:29 +02:00
// Load translation files required by the page
2019-11-13 19:35:02 +01:00
$langs -> loadLangs ( array ( " companies " , " other " , " ticket " ));
2018-03-10 04:23:59 +01:00
// Get parameters
2018-04-30 10:33:36 +02:00
$id = GETPOST ( 'id' , 'int' );
2019-11-30 01:15:47 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2018-04-30 10:33:36 +02:00
$track_id = GETPOST ( 'track_id' , 'alpha' , 3 );
$ref = GETPOST ( 'ref' , 'alpha' );
2018-03-10 04:23:59 +01:00
$projectid = GETPOST ( 'projectid' , 'int' );
2019-03-05 12:18:36 +01:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2018-11-05 17:53:31 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
2021-06-05 02:18:45 +02:00
$backtopage = GETPOST ( '$backtopage' , 'alpha' );
2018-03-10 04:23:59 +01:00
2019-03-05 12:18:36 +01:00
$notifyTiers = GETPOST ( " notify_tiers_at_create " , 'alpha' );
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-05-07 12:22:13 +02:00
if ( GETPOST ( 'actioncode' , 'array' )) {
2020-10-31 14:32:18 +01:00
$actioncode = GETPOST ( 'actioncode' , 'array' , 3 );
2021-02-26 13:27:00 +01:00
if ( ! count ( $actioncode )) {
$actioncode = '0' ;
}
2020-05-07 12:22:13 +02:00
} else {
2020-10-31 14:32:18 +01:00
$actioncode = GETPOST ( " actioncode " , " alpha " , 3 ) ? GETPOST ( " actioncode " , " alpha " , 3 ) : ( GETPOST ( " actioncode " ) == '0' ? '0' : ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT ));
2020-05-07 12:22:13 +02:00
}
$search_agenda_label = GETPOST ( 'search_agenda_label' );
2018-06-04 21:49:29 +02:00
// Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array
2019-11-13 19:35:02 +01:00
$hookmanager -> initHooks ( array ( 'ticketcard' , 'globalcard' ));
2018-03-10 04:23:59 +01:00
2018-06-04 21:49:29 +02:00
$object = new Ticket ( $db );
2018-03-10 04:23:59 +01:00
$extrafields = new ExtraFields ( $db );
2019-10-06 14:41:52 +02:00
2018-10-01 03:19:21 +02:00
// Fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-11-13 19:35:02 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2018-03-18 19:13:42 +01:00
2018-10-01 03:19:21 +02:00
// Initialize array of search criterias
2020-08-28 21:27:50 +02:00
$search_all = GETPOST ( " search_all " , 'alpha' );
2019-11-13 19:35:02 +01:00
$search = array ();
2021-02-26 13:27:00 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( GETPOST ( 'search_' . $key , 'alpha' )) {
$search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
}
2018-03-10 04:23:59 +01:00
}
2018-10-01 03:19:21 +02:00
2021-02-26 13:27:00 +01:00
if ( empty ( $action ) && empty ( $id ) && empty ( $ref )) {
$action = 'view' ;
}
2018-10-01 03:19:21 +02:00
2018-03-10 04:23:59 +01:00
//Select mail models is same action as add_message
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'modelselected' , 'alpha' )) {
2019-07-19 23:11:00 +02:00
$action = 'presend' ;
2018-03-10 04:23:59 +01:00
}
2018-10-01 03:19:21 +02:00
// Load object
//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
2018-03-18 19:13:42 +01:00
if ( $id || $track_id || $ref ) {
2018-03-22 10:23:25 +01:00
$res = $object -> fetch ( $id , $ref , $track_id );
2021-02-26 13:27:00 +01:00
if ( $res >= 0 ) {
2018-10-01 03:19:21 +02:00
$id = $object -> id ;
$track_id = $object -> track_id ;
}
2018-03-13 13:26:03 +01:00
}
2018-10-01 03:19:21 +02:00
// Store current page url
$url_page_current = DOL_URL_ROOT . '/ticket/card.php' ;
// Security check - Protection if external user
2021-05-18 01:58:54 +02:00
$socid = 0 ;
if ( $user -> socid > 0 ) $socid = $user -> socid ;
2018-06-04 21:49:29 +02:00
$result = restrictedArea ( $user , 'ticket' , $object -> id );
2018-03-13 13:26:03 +01:00
2019-10-01 11:28:10 +02:00
$triggermodname = 'TICKET_MODIFY' ;
2018-06-04 21:49:29 +02:00
$permissiontoadd = $user -> rights -> ticket -> write ;
2018-04-13 12:52:23 +02:00
2018-06-19 08:51:25 +02:00
$actionobject = new ActionsTicket ( $db );
2018-03-13 13:26:03 +01:00
2018-07-16 11:14:39 +02:00
$now = dol_now ();
2018-03-13 13:26:03 +01:00
/*
* Actions
*/
2019-11-13 19:35:02 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 13:27:00 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2018-06-19 08:51:25 +02:00
2020-09-04 10:46:05 +02:00
$error = 0 ;
2020-05-07 12:22:13 +02:00
if ( empty ( $reshook )) {
// Purge search criteria
2021-02-26 13:27:00 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All test are required to be compatible with all browsers{
2020-05-07 12:22:13 +02:00
$actioncode = '' ;
$search_agenda_label = '' ;
2018-04-13 12:52:23 +02:00
}
2020-05-07 12:22:13 +02:00
if ( $cancel ) {
if ( ! empty ( $backtopage )) {
2020-09-08 21:27:28 +02:00
header ( " Location: " . $backtopage );
2020-05-07 12:22:13 +02:00
exit ;
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
$action = 'view' ;
2020-04-16 00:42:57 +02:00
}
2020-05-07 22:52:32 +02:00
// Action to add an action (not a message)
2021-06-05 02:18:45 +02:00
if ( GETPOST ( 'add' , 'alpha' ) && ! empty ( $user -> rights -> ticket -> write )) {
2020-05-07 12:22:13 +02:00
$error = 0 ;
2020-04-16 00:42:57 +02:00
2020-06-06 11:51:39 +02:00
if ( ! GETPOST ( " subject " , 'alphanohtml' )) {
2020-05-07 12:22:13 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Subject " )), null , 'errors' );
$action = 'create' ;
2020-06-06 11:51:39 +02:00
} elseif ( ! GETPOST ( " message " , 'restricthtml' )) {
2020-05-07 12:22:13 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Message " )), null , 'errors' );
$action = 'create' ;
}
2020-09-04 10:46:05 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 13:27:00 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( ! $error ) {
$db -> begin ();
2020-04-16 00:42:57 +02:00
2020-06-06 11:51:39 +02:00
$object -> ref = GETPOST ( " ref " , 'alphanohtml' );
2020-05-07 12:22:13 +02:00
$object -> fk_soc = GETPOST ( " socid " , 'int' ) > 0 ? GETPOST ( " socid " , 'int' ) : 0 ;
2020-06-06 11:51:39 +02:00
$object -> subject = GETPOST ( " subject " , 'alphanohtml' );
$object -> message = GETPOST ( " message " , 'restricthtml' );
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
$object -> type_code = GETPOST ( " type_code " , 'alpha' );
2020-10-07 16:48:50 +02:00
$object -> type_label = $langs -> trans ( $langs -> getLabelFromKey ( $db , $object -> type_code , 'c_ticket_type' , 'code' , 'label' ));
2020-05-07 12:22:13 +02:00
$object -> category_code = GETPOST ( " category_code " , 'alpha' );
2020-10-07 16:48:50 +02:00
$object -> category_label = $langs -> trans ( $langs -> getLabelFromKey ( $db , $object -> category_code , 'c_ticket_category' , 'code' , 'label' ));
2020-05-07 12:22:13 +02:00
$object -> severity_code = GETPOST ( " severity_code " , 'alpha' );
2020-10-07 16:48:50 +02:00
$object -> severity_label = $langs -> trans ( $langs -> getLabelFromKey ( $db , $object -> severity_code , 'c_ticket_severity' , 'code' , 'label' ));
$object -> email_from = $user -> email ;
2020-05-07 12:22:13 +02:00
$notifyTiers = GETPOST ( " notify_tiers_at_create " , 'alpha' );
$object -> notify_tiers_at_create = empty ( $notifyTiers ) ? 0 : 1 ;
2020-04-16 00:42:57 +02:00
2021-03-29 23:24:52 +02:00
$object -> fk_project = $projectid ;
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
$id = $object -> create ( $user );
if ( $id <= 0 ) {
$error ++ ;
2020-09-04 12:25:16 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-07 12:22:13 +02:00
$action = 'create' ;
2020-04-16 00:42:57 +02:00
}
2020-05-07 12:22:13 +02:00
if ( ! $error ) {
// Add contact
$contactid = GETPOST ( 'contactid' , 'int' );
$type_contact = GETPOST ( " type " , 'alpha' );
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( $contactid > 0 && $type_contact ) {
2020-11-30 15:18:58 +01:00
$typeid = ( GETPOST ( 'typecontact' ) ? GETPOST ( 'typecontact' ) : GETPOST ( 'type' ));
$result = $object -> add_contact ( $contactid , $typeid , 'external' );
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
2021-03-29 23:24:52 +02:00
// Link ticket to project
if ( $projectid > 0 ) {
$object -> setProject ( $projectid );
2020-05-07 12:22:13 +02:00
}
// Auto assign user
2021-05-11 08:13:40 +02:00
if ( ! empty ( $conf -> global -> TICKET_AUTO_ASSIGN_USER_CREATE )) {
2020-05-07 12:22:13 +02:00
$result = $object -> assignUser ( $user , $user -> id , 1 );
$object -> add_contact ( $user -> id , " SUPPORTTEC " , 'internal' );
}
// Auto assign contrat
$contractid = 0 ;
2021-05-11 08:13:40 +02:00
if ( ! empty ( $conf -> global -> TICKET_AUTO_ASSIGN_CONTRACT_CREATE )) {
2020-05-07 12:22:13 +02:00
$contrat = new Contrat ( $db );
$contrat -> socid = $object -> fk_soc ;
$list = $contrat -> getListOfContracts ();
if ( is_array ( $list ) && ! empty ( $list )) {
if ( count ( $list ) == 1 ) {
$contractid = $list [ 0 ] -> id ;
$object -> setContract ( $contractid );
} else {
}
2020-04-16 00:42:57 +02:00
}
}
2020-05-07 12:22:13 +02:00
// Auto create fiche intervention
2021-05-11 08:13:40 +02:00
if ( ! empty ( $conf -> global -> TICKET_AUTO_CREATE_FICHINTER_CREATE )) {
2020-05-07 12:22:13 +02:00
$fichinter = new Fichinter ( $db );
$fichinter -> socid = $object -> fk_soc ;
2021-03-29 23:24:52 +02:00
$fichinter -> fk_project = $projectid ;
2020-05-07 12:22:13 +02:00
$fichinter -> fk_contrat = $contractid ;
$fichinter -> author = $user -> id ;
2020-09-10 01:49:09 +02:00
$fichinter -> model_pdf = 'soleil' ;
2020-05-07 12:22:13 +02:00
$fichinter -> origin = $object -> element ;
$fichinter -> origin_id = $object -> id ;
// Extrafields
$extrafields -> fetch_name_optionals_label ( $fichinter -> table_element );
$array_options = $extrafields -> getOptionalsFromPost ( $fichinter -> table_element );
$fichinter -> array_options = $array_options ;
$id = $fichinter -> create ( $user );
if ( $id <= 0 ) {
setEventMessages ( $fichinter -> error , null , 'errors' );
}
2020-04-16 00:42:57 +02:00
}
}
2020-05-07 12:22:13 +02:00
if ( ! $error ) {
// File transfer
$object -> copyFilesForTicket ();
}
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( ! $error ) {
$db -> commit ();
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( ! empty ( $backtopage )) {
$url = $backtopage ;
} else {
2020-09-08 21:27:28 +02:00
$url = 'card.php?track_id=' . $object -> track_id ;
2020-05-07 12:22:13 +02:00
}
2020-09-08 21:27:28 +02:00
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ;
2020-04-16 00:42:57 +02:00
} else {
2020-05-07 12:22:13 +02:00
$db -> rollback ();
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-04-16 00:42:57 +02:00
}
} else {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2019-04-10 11:39:54 +02:00
2020-09-09 11:46:56 +02:00
if ( $action == 'update' && $user -> rights -> ticket -> write && $object -> fk_statut < Ticket :: STATUS_CLOSED ) {
2020-05-07 12:22:13 +02:00
$error = 0 ;
2019-04-10 11:39:54 +02:00
2020-09-09 11:46:56 +02:00
$ret = $object -> fetch ( GETPOST ( 'id' , 'int' ), GETPOST ( 'ref' , 'alpha' ), GETPOST ( 'track_id' , 'alpha' ));
if ( $ret < 0 ) {
2020-05-07 12:22:13 +02:00
$error ++ ;
2020-09-09 11:46:56 +02:00
array_push ( $object -> errors , $langs -> trans ( 'ErrorTicketIsNotValid' ));
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
2020-09-09 11:46:56 +02:00
// check fields
if ( ! $error ) {
2020-09-09 11:54:50 +02:00
if ( ! GETPOST ( 'subject' , 'alpha' )) {
2020-09-09 11:46:56 +02:00
$error ++ ;
array_push ( $object -> errors , $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Subject' )));
}
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 13:27:00 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2020-04-16 00:42:57 +02:00
}
2020-05-07 12:22:13 +02:00
if ( ! $error ) {
$db -> begin ();
2019-04-10 11:39:54 +02:00
2020-09-09 11:46:56 +02:00
$object -> subject = GETPOST ( 'subject' , 'alpha' );
$object -> type_code = GETPOST ( 'type_code' , 'alpha' );
$object -> category_code = GETPOST ( 'category_code' , 'alpha' );
$object -> severity_code = GETPOST ( 'severity_code' , 'alpha' );
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
$ret = $object -> update ( $user );
2021-02-26 13:27:00 +01:00
if ( $ret <= 0 ) {
$error ++ ;
}
2020-04-16 00:42:57 +02:00
2020-09-09 11:46:56 +02:00
if ( $error ) {
$db -> rollback ();
} else {
2020-05-07 12:22:13 +02:00
$db -> commit ();
2020-09-09 11:46:56 +02:00
}
}
if ( $error ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = 'edit' ;
} else {
if ( ! empty ( $backtopage )) {
$url = $backtopage ;
2020-05-07 12:22:13 +02:00
} else {
2020-09-14 04:30:04 +02:00
$url = 'card.php?track_id=' . $object -> track_id ;
2020-05-07 12:22:13 +02:00
}
2020-09-09 11:46:56 +02:00
2020-09-14 04:30:04 +02:00
header ( 'Location: ' . $url );
2020-09-09 11:46:56 +02:00
exit ();
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
// Mark as Read
if ( $action == " mark_ticket_read " && $user -> rights -> ticket -> write ) {
$object -> fetch ( '' , '' , GETPOST ( " track_id " , 'alpha' ));
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
if ( $object -> markAsRead ( $user ) > 0 ) {
setEventMessages ( $langs -> trans ( 'TicketMarkedAsRead' ), null , 'mesgs' );
2019-04-10 11:39:54 +02:00
2020-09-08 21:27:28 +02:00
header ( " Location: card.php?track_id= " . $object -> track_id . " &action=view " );
2020-05-07 12:22:13 +02:00
exit ;
} else {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
$action = 'view' ;
2020-04-16 00:42:57 +02:00
}
2020-05-07 12:22:13 +02:00
// Assign to someone
if ( $action == " assign_user " && GETPOST ( 'btn_assign_user' , 'alpha' ) && $user -> rights -> ticket -> write ) {
$object -> fetch ( '' , '' , GETPOST ( " track_id " , 'alpha' ));
$useroriginassign = $object -> fk_user_assign ;
$usertoassign = GETPOST ( 'fk_user_assign' , 'int' );
/* if ( ! ( $usertoassign > 0 )) {
$error ++ ;
array_push ( $object -> errors , $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " AssignedTo " )));
$action = 'view' ;
} */
if ( ! $error ) {
$ret = $object -> assignUser ( $user , $usertoassign );
2021-02-26 13:27:00 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
2021-02-26 13:27:00 +01:00
if ( ! $error ) { // Update list of contacts
2020-05-07 12:22:13 +02:00
// Si déjà un user assigné on le supprime des contacts
if ( $useroriginassign > 0 ) {
$internal_contacts = $object -> listeContact ( - 1 , 'internal' );
foreach ( $internal_contacts as $key => $contact ) {
if ( $contact [ 'code' ] == " SUPPORTTEC " && $contact [ 'id' ] == $useroriginassign ) {
}
{
//print "user à effacer : ".$useroriginassign;
$object -> delete_contact ( $contact [ 'rowid' ]);
}
2020-04-16 00:42:57 +02:00
}
}
2021-02-26 13:27:00 +01:00
if ( $usertoassign > 0 ) {
$object -> add_contact ( $usertoassign , " SUPPORTTEC " , 'internal' , $notrigger = 0 );
}
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( ! $error ) {
// Log action in ticket logs table
$object -> fetch_user ( $usertoassign );
$log_action = $langs -> trans ( 'TicketLogAssignedTo' , $object -> user -> getFullName ( $langs ));
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
setEventMessages ( $langs -> trans ( 'TicketAssigned' ), null , 'mesgs' );
2020-04-16 00:42:57 +02:00
2020-09-08 21:27:28 +02:00
header ( " Location: card.php?track_id= " . $object -> track_id . " &action=view " );
2020-05-07 12:22:13 +02:00
exit ;
} else {
array_push ( $object -> errors , $object -> error );
}
$action = 'view' ;
2020-04-16 00:42:57 +02:00
}
2019-04-10 11:39:54 +02:00
2020-05-07 22:52:32 +02:00
// Action to add an action (not a message)
2020-05-07 12:22:13 +02:00
if ( $action == 'add_message' && GETPOSTISSET ( 'btn_add_message' ) && $user -> rights -> ticket -> read ) {
$ret = $object -> newMessage ( $user , $action , ( GETPOST ( 'private_message' , 'alpha' ) == " on " ? 1 : 0 ));
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( $ret > 0 ) {
if ( ! empty ( $backtopage )) {
$url = $backtopage ;
} else {
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . $object -> track_id ;
2020-05-07 12:22:13 +02:00
}
2020-09-08 21:27:28 +02:00
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ;
2020-04-16 00:42:57 +02:00
} else {
2020-05-07 12:22:13 +02:00
setEventMessages ( $object -> error , null , 'errors' );
$action = 'presend' ;
2020-04-16 00:42:57 +02:00
}
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
if ( $action == " confirm_close " && GETPOST ( 'confirm' , 'alpha' ) == 'yes' && $user -> rights -> ticket -> write ) {
$object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' ));
2019-04-10 13:21:06 +02:00
2020-05-07 12:22:13 +02:00
if ( $object -> close ( $user )) {
setEventMessages ( $langs -> trans ( 'TicketMarkedAsClosed' ), null , 'mesgs' );
2019-04-10 11:39:54 +02:00
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . GETPOST ( 'track_id' , 'alpha' );
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
} else {
$action = '' ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2020-04-16 00:42:57 +02:00
}
2019-07-19 23:43:49 +02:00
2020-05-07 12:22:13 +02:00
if ( $action == " confirm_public_close " && GETPOST ( 'confirm' , 'alpha' ) == 'yes' ) {
$object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' ));
if ( $_SESSION [ 'email_customer' ] == $object -> origin_email || $_SESSION [ 'email_customer' ] == $object -> thirdparty -> email ) {
$object -> close ( $user );
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
// Log action in ticket logs table
$log_action = $langs -> trans ( 'TicketLogClosedBy' , $_SESSION [ 'email_customer' ]);
2019-04-10 11:39:54 +02:00
2020-09-08 21:27:28 +02:00
setEventMessages ( '<div class="confirm">' . $langs -> trans ( 'TicketMarkedAsClosed' ) . '</div>' , null , 'mesgs' );
2019-04-10 11:39:54 +02:00
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view_ticket&track_id=' . GETPOST ( 'track_id' , 'alpha' );
header ( " Location: " . $url );
2020-04-16 00:42:57 +02:00
} else {
2020-05-07 12:22:13 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-04-16 00:42:57 +02:00
$action = '' ;
}
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
if ( $action == 'confirm_delete_ticket' && GETPOST ( 'confirm' , 'alpha' ) == " yes " && $user -> rights -> ticket -> delete ) {
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
if ( $object -> delete ( $user ) > 0 ) {
2020-09-08 21:27:28 +02:00
setEventMessages ( '<div class="confirm">' . $langs -> trans ( 'TicketDeletedSuccess' ) . '</div>' , null , 'mesgs' );
Header ( " Location: " . DOL_URL_ROOT . " /ticket/list.php " );
2020-05-07 12:22:13 +02:00
exit ;
} else {
$langs -> load ( " errors " );
2020-09-08 21:27:28 +02:00
$mesg = '<div class="error">' . $langs -> trans ( $object -> error ) . '</div>' ;
2020-05-07 12:22:13 +02:00
$action = '' ;
}
}
2020-04-16 00:42:57 +02:00
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
// Set parent company
if ( $action == 'set_thirdparty' && $user -> rights -> societe -> creer ) {
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
$result = $object -> setCustomer ( GETPOST ( 'editcustomer' , 'int' ));
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . GETPOST ( 'track_id' , 'alpha' );
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ();
}
2020-04-16 00:42:57 +02:00
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
if ( $action == 'set_progression' && $user -> rights -> ticket -> write ) {
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
$result = $object -> setProgression ( GETPOST ( 'progress' , 'alpha' ));
2020-04-16 00:42:57 +02:00
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . $object -> track_id ;
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ();
2020-04-16 00:42:57 +02:00
}
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
if ( $action == 'setsubject' ) {
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ))) {
if ( $action == 'setsubject' ) {
2020-08-28 21:27:50 +02:00
$object -> subject = GETPOST ( 'subject' , 'alphanohtml' );
2020-05-07 12:22:13 +02:00
}
if ( $action == 'setsubject' && empty ( $object -> subject )) {
2020-10-15 19:36:08 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Subject " )), null , 'errors' );
2020-05-07 12:22:13 +02:00
}
2020-10-15 19:36:08 +02:00
if ( ! $error ) {
2020-05-07 12:22:13 +02:00
if ( $object -> update ( $user ) >= 0 ) {
2020-09-08 21:27:28 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?track_id= " . $object -> track_id );
2020-05-07 12:22:13 +02:00
exit ;
2020-10-15 19:36:08 +02:00
} else {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-07 12:22:13 +02:00
}
2020-04-16 00:42:57 +02:00
}
}
}
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
if ( $action == 'confirm_reopen' && $user -> rights -> ticket -> manage && ! GETPOST ( 'cancel' )) {
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
// prevent browser refresh from reopening ticket several times
2020-06-26 19:35:09 +02:00
if ( $object -> fk_statut == Ticket :: STATUS_CLOSED || $object -> fk_statut == Ticket :: STATUS_CANCELED ) {
2020-05-07 12:22:13 +02:00
$res = $object -> setStatut ( Ticket :: STATUS_ASSIGNED );
if ( $res ) {
// Log action in ticket logs table
$log_action = $langs -> trans ( 'TicketLogReopen' );
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . $object -> track_id ;
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ();
2020-10-15 19:36:08 +02:00
} else {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-07 12:22:13 +02:00
}
}
}
2021-02-26 13:27:00 +01:00
} elseif ( $action == 'classin' && $user -> rights -> ticket -> write ) {
// Categorisation dans projet
2020-05-07 12:22:13 +02:00
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
2021-03-29 23:24:52 +02:00
$object -> setProject ( $projectid );
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . $object -> track_id ;
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ();
}
2021-02-26 13:27:00 +01:00
} elseif ( $action == 'setcontract' && $user -> rights -> ticket -> write ) {
// Categorisation dans contrat
2020-05-07 12:22:13 +02:00
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
$object -> setContract ( GETPOST ( 'contractid' , 'int' ));
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . $object -> track_id ;
header ( " Location: " . $url );
2020-05-07 12:22:13 +02:00
exit ();
}
} elseif ( $action == " set_message " && $user -> rights -> ticket -> manage ) {
// altairis: manage cancel button
if ( ! GETPOST ( 'cancel' )) {
$object -> fetch ( '' , '' , GETPOST ( 'track_id' , 'alpha' ));
$oldvalue_message = $object -> message ;
2020-06-06 11:51:39 +02:00
$fieldtomodify = GETPOST ( 'message_initial' , 'restricthtml' );
2020-05-07 12:22:13 +02:00
$object -> message = $fieldtomodify ;
$ret = $object -> update ( $user );
if ( $ret > 0 ) {
2020-09-08 21:27:28 +02:00
$log_action = $langs -> trans ( 'TicketInitialMessageModified' ) . " \n " ;
2020-05-07 12:22:13 +02:00
// include the Diff class
dol_include_once ( '/ticket/class/utils_diff.class.php' );
// output the result of comparing two files as plain text
$log_action .= Diff :: toString ( Diff :: compare ( strip_tags ( $oldvalue_message ), strip_tags ( $object -> message )));
setEventMessages ( $langs -> trans ( 'TicketMessageSuccesfullyUpdated' ), null , 'mesgs' );
2020-10-15 19:36:08 +02:00
} else {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-07 12:22:13 +02:00
}
}
$action = 'view' ;
2021-02-26 13:27:00 +01:00
} elseif ( $action == 'confirm_set_status' && $user -> rights -> ticket -> write && ! GETPOST ( 'cancel' )) {
// Reopen ticket
2020-05-07 12:22:13 +02:00
if ( $object -> fetch ( GETPOST ( 'id' , 'int' ), GETPOST ( 'track_id' , 'alpha' )) >= 0 ) {
$new_status = GETPOST ( 'new_status' , 'int' );
$old_status = $object -> fk_statut ;
$res = $object -> setStatut ( $new_status );
2020-04-16 00:42:57 +02:00
if ( $res ) {
// Log action in ticket logs table
2020-05-07 12:22:13 +02:00
$log_action = $langs -> trans ( 'TicketLogStatusChanged' , $langs -> transnoentities ( $object -> statuts_short [ $old_status ]), $langs -> transnoentities ( $object -> statuts_short [ $new_status ]));
2020-04-16 00:42:57 +02:00
2020-09-08 21:27:28 +02:00
$url = 'card.php?action=view&track_id=' . $object -> track_id ;
header ( " Location: " . $url );
2020-04-16 00:42:57 +02:00
exit ();
2020-10-15 19:36:08 +02:00
} else {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-04-16 00:42:57 +02:00
}
}
}
2020-05-07 12:22:13 +02:00
// Action to update one extrafield
if ( $action == " update_extras " && ! empty ( $permissiontoadd )) {
$object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' ));
2020-09-04 10:46:05 +02:00
2020-09-18 01:29:17 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , GETPOST ( 'attribute' , 'restricthtml' ));
2021-02-26 13:27:00 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2020-09-04 10:46:05 +02:00
if ( ! $error ) {
$result = $object -> insertExtraFields ( empty ( $triggermodname ) ? '' : $triggermodname , $user );
2021-02-26 13:27:00 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-04-16 00:42:57 +02:00
}
2020-09-04 10:46:05 +02:00
2021-01-21 15:55:52 +01:00
if ( $error ) {
2020-05-07 12:22:13 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = 'edit_extras' ;
2021-01-21 15:55:52 +01:00
} else {
setEventMessages ( $langs -> trans ( 'RecordSaved' ), null , 'mesgs' );
$action = 'view' ;
2020-04-16 00:42:57 +02:00
}
}
2020-05-07 12:22:13 +02:00
if ( $action == " change_property " && GETPOST ( 'btn_update_ticket_prop' , 'alpha' ) && $user -> rights -> ticket -> write ) {
$object -> fetch ( GETPOST ( 'id' , 'int' ), '' , GETPOST ( 'track_id' , 'alpha' ));
2020-04-16 00:42:57 +02:00
2020-05-07 12:22:13 +02:00
$object -> type_code = GETPOST ( 'update_value_type' , 'aZ09' );
$object -> severity_code = GETPOST ( 'update_value_severity' , 'aZ09' );
$object -> category_code = GETPOST ( 'update_value_category' , 'aZ09' );
2018-03-18 19:13:42 +01:00
2020-05-07 12:22:13 +02:00
$ret = $object -> update ( $user );
if ( $ret > 0 ) {
$log_action = $langs -> trans ( 'TicketLogPropertyChanged' , $oldvalue_label , $newvalue_label );
2018-04-12 23:17:46 +02:00
2020-05-07 12:22:13 +02:00
setEventMessages ( $langs -> trans ( 'TicketUpdated' ), null , 'mesgs' );
2020-10-15 19:36:08 +02:00
} else {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-07 12:22:13 +02:00
}
2018-04-12 23:17:46 +02:00
$action = 'view' ;
}
2019-04-10 11:39:54 +02:00
2018-03-13 13:26:03 +01:00
2020-05-07 12:22:13 +02:00
$permissiondellink = $user -> rights -> ticket -> write ;
2020-09-08 21:27:28 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php' ; // Must be include, not include_once
2019-04-10 11:39:54 +02:00
2020-05-07 12:22:13 +02:00
// Actions to build doc
$upload_dir = $conf -> ticket -> dir_output ;
$permissiontoadd = $user -> rights -> ticket -> write ;
2020-09-08 21:27:28 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2018-03-13 13:26:03 +01:00
2020-05-07 12:22:13 +02:00
// Actions to send emails
$triggersendname = 'TICKET_SENTBYMAIL' ;
$paramname = 'id' ;
$autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO' ; // used to know the automatic BCC to add
2020-09-08 21:27:28 +02:00
$trackid = 'tic' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
2018-03-13 13:26:03 +01:00
2020-05-07 12:22:13 +02:00
// Set $action to correct value for the case we used presend action to add a message
2021-02-26 13:27:00 +01:00
if ( GETPOSTISSET ( 'actionbis' ) && $action == 'presend' ) {
$action = 'presend_addmessage' ;
}
2020-05-07 12:22:13 +02:00
}
2018-03-13 13:26:03 +01:00
2021-01-23 19:50:04 +01:00
2018-03-13 13:26:03 +01:00
/*
* View
*/
2018-03-10 04:23:59 +01:00
$userstat = new User ( $db );
$form = new Form ( $db );
2018-06-04 21:49:29 +02:00
$formticket = new FormTicket ( $db );
2021-02-26 13:27:00 +01:00
if ( ! empty ( $conf -> projet -> enabled )) {
$formproject = new FormProjets ( $db );
}
2018-04-18 10:13:20 +02:00
2021-03-16 16:44:33 +01:00
$help_url = 'EN:Module_Ticket|FR:DocumentationModuleTicket' ;
2018-10-01 03:19:21 +02:00
$page_title = $actionobject -> getTitle ( $action );
llxHeader ( '' , $page_title , $help_url );
2018-03-10 04:23:59 +01:00
2021-02-26 13:27:00 +01:00
if ( $action == 'create' || $action == 'presend' ) {
2020-04-16 00:42:57 +02:00
$formticket = new FormTicket ( $db );
print load_fiche_titre ( $langs -> trans ( 'NewTicket' ), '' , 'ticket' );
$formticket -> withfromsocid = $socid ? $socid : $user -> socid ;
$formticket -> withfromcontactid = $contactid ? $contactid : '' ;
$formticket -> withtitletopic = 1 ;
$formticket -> withnotifytiersatcreate = ( $notifyTiers ? 1 : 0 );
2020-09-08 01:53:37 +02:00
$formticket -> withusercreate = 0 ;
2020-04-16 00:42:57 +02:00
$formticket -> withref = 1 ;
$formticket -> fk_user_create = $user -> id ;
$formticket -> withfile = 2 ;
$formticket -> withextrafields = 1 ;
$formticket -> param = array ( 'origin' => GETPOST ( 'origin' ), 'originid' => GETPOST ( 'originid' ));
2021-03-24 13:16:17 +01:00
$formticket -> showForm ( 1 , 'create' , 0 );
2021-03-24 22:54:40 +01:00
/* } elseif ( $action == 'edit' && $user -> rights -> ticket -> write && $object -> fk_statut < Ticket :: STATUS_CLOSED ) {
2020-09-09 11:46:56 +02:00
$formticket = new FormTicket ( $db );
$head = ticket_prepare_head ( $object );
2020-09-14 04:30:04 +02:00
print '<form method="POST" name="form_ticket" id="form_edit_ticket" action="' . $_SERVER [ 'PHP_SELF' ] . '?track_id=' . $object -> track_id . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2020-09-09 11:46:56 +02:00
print '<input type="hidden" name="action" value="update">' ;
2020-09-14 04:30:04 +02:00
print '<input type="hidden" name="tack_id" value="' . $object -> track_id . '">' ;
2020-09-09 11:46:56 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( 'Ticket' ), 0 , 'ticket' );
2020-09-09 11:46:56 +02:00
print '<div class="fichecenter2">' ;
print '<table class="border" width="100%">' ;
2018-10-01 03:19:21 +02:00
2020-09-09 11:46:56 +02:00
// Type
2020-09-14 04:30:04 +02:00
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">' . $langs -> trans ( " TicketTypeRequest " ) . '</span></label></td><td>' ;
2021-03-24 22:54:40 +01:00
$formticket -> selectTypesTickets (( GETPOSTISSET ( 'type_code' ) ? GETPOST ( 'type_code' ) : $object -> type_code ), 'type_code' , '' , '2' );
2020-09-09 11:46:56 +02:00
print '</td></tr>' ;
// Severity
2020-09-14 04:30:04 +02:00
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">' . $langs -> trans ( " TicketSeverity " ) . '</span></label></td><td>' ;
2021-03-24 22:54:40 +01:00
$formticket -> selectSeveritiesTickets (( GETPOSTISSET ( 'severity_code' ) ? GETPOST ( 'severity_code' ) : $object -> severity_code ), 'severity_code' , '' , '2' );
2020-09-09 11:46:56 +02:00
print '</td></tr>' ;
// Group
2020-12-17 12:15:34 +01:00
print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">' . $langs -> trans ( " TicketCategory " ) . '</span></label></td><td>' ;
2021-03-24 22:54:40 +01:00
$formticket -> selectGroupTickets (( GETPOSTISSET ( 'category_code' ) ? GETPOST ( 'category_code' ) : $object -> category_code ), 'category_code' , '' , '2' );
2020-09-09 11:46:56 +02:00
print '</td></tr>' ;
// Subject
2020-09-14 04:30:04 +02:00
print '<tr><td><label for="subject"><span class="fieldrequired">' . $langs -> trans ( " Subject " ) . '</span></label></td><td>' ;
2021-06-13 01:27:04 +02:00
print '<input class="text minwidth200" id="subject" name="subject" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'subject' ) ? GETPOST ( 'subject' , 'alpha' ) : $object -> subject ) . '" />' ;
2020-09-09 11:46:56 +02:00
print '</td></tr>' ;
// Other attributes
$parameters = array ( 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' );
2020-09-14 04:30:04 +02:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-09-09 11:46:56 +02:00
print $hookmanager -> resPrint ;
if ( empty ( $reshook )) {
print $object -> showOptionals ( $extrafields , 'edit' );
}
print '</table>' ;
print '</div>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2020-09-09 11:46:56 +02:00
print '<div class="center">' ;
2020-11-23 15:12:52 +01:00
print '<input type="submit" class="button button-save" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
2020-09-09 11:46:56 +02:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input type="submit" class="button button-cancel" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2020-09-09 11:46:56 +02:00
print '</div>' ;
2021-03-24 22:54:40 +01:00
print '</form>' ; */
2021-02-26 13:27:00 +01:00
} elseif ( empty ( $action ) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'
|| $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink' ) {
if ( $res > 0 ) {
2020-04-16 00:42:57 +02:00
// or for unauthorized internals users
2021-05-11 08:01:13 +02:00
if ( ! $user -> socid && ( ! empty ( $conf -> global -> TICKET_LIMIT_VIEW_ASSIGNED_ONLY ) && $object -> fk_user_assign != $user -> id ) && ! $user -> rights -> ticket -> manage ) {
2020-04-16 00:42:57 +02:00
accessforbidden ( '' , 0 , 1 );
}
// Confirmation close
if ( $action == 'close' ) {
print $form -> formconfirm ( $url_page_current . " ?track_id= " . $object -> track_id , $langs -> trans ( " CloseATicket " ), $langs -> trans ( " ConfirmCloseAticket " ), " confirm_close " , '' , '' , 1 );
if ( $ret == 'html' ) {
print '<br>' ;
}
}
// Confirmation delete
if ( $action == 'delete' ) {
print $form -> formconfirm ( $url_page_current . " ?track_id= " . $object -> track_id , $langs -> trans ( " Delete " ), $langs -> trans ( " ConfirmDeleteTicket " ), " confirm_delete_ticket " , '' , '' , 1 );
}
// Confirm reopen
if ( $action == 'reopen' ) {
print $form -> formconfirm ( $url_page_current . '?track_id=' . $object -> track_id , $langs -> trans ( 'ReOpen' ), $langs -> trans ( 'ConfirmReOpenTicket' ), 'confirm_reopen' , '' , '' , 1 );
}
// Confirmation status change
if ( $action == 'set_status' ) {
$new_status = GETPOST ( 'new_status' );
//var_dump($url_page_current . "?track_id=" . $object->track_id);
print $form -> formconfirm ( $url_page_current . " ?track_id= " . $object -> track_id . " &new_status= " . GETPOST ( 'new_status' ), $langs -> trans ( " TicketChangeStatus " ), $langs -> trans ( " TicketConfirmChangeStatus " , $langs -> transnoentities ( $object -> statuts_short [ $new_status ])), " confirm_set_status " , '' , '' , 1 );
}
// project info
2021-03-29 23:24:52 +02:00
if ( $projectid > 0 ) {
2020-04-16 00:42:57 +02:00
$projectstat = new Project ( $db );
if ( $projectstat -> fetch ( $projectid ) > 0 ) {
$projectstat -> fetch_thirdparty ();
// To verify role of users
//$userAccess = $object->restrictedProjectArea($user,'read');
$userWrite = $projectstat -> restrictedProjectArea ( $user , 'write' );
//$userDelete = $object->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
$head = project_prepare_head ( $projectstat );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'ticket' , $langs -> trans ( " Project " ), 0 , ( $projectstat -> public ? 'projectpub' : 'project' ));
2020-04-16 00:42:57 +02:00
/*
2021-02-26 13:27:00 +01:00
* Projet synthese pour rappel
*/
2020-04-16 00:42:57 +02:00
print '<table class="border centpercent">' ;
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
// Ref
print '<tr><td width="30%">' . $langs -> trans ( 'Ref' ) . '</td><td colspan="3">' ;
// Define a complementary filter for search of next/prev ref.
if ( ! $user -> rights -> projet -> all -> lire ) {
$objectsListId = $projectstat -> getProjectsAuthorizedForUser ( $user , $mine , 0 );
2021-03-22 12:47:23 +01:00
$projectstat -> next_prev_filter = " rowid IN ( " . $db -> sanitize ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2020-04-16 00:42:57 +02:00
}
print $form -> showrefnav ( $projectstat , 'ref' , $linkback , 1 , 'ref' , 'ref' , '' );
print '</td></tr>' ;
// Label
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td>' . $projectstat -> title . '</td></tr>' ;
// Customer
print " <tr><td> " . $langs -> trans ( " ThirdParty " ) . " </td> " ;
print '<td colspan="3">' ;
if ( $projectstat -> thirdparty -> id > 0 ) {
print $projectstat -> thirdparty -> getNomUrl ( 1 );
} else {
print ' ' ;
}
print '</td></tr>' ;
// Visibility
print '<tr><td>' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
if ( $projectstat -> public ) {
print $langs -> trans ( 'SharedProject' );
} else {
print $langs -> trans ( 'PrivateProject' );
}
print '</td></tr>' ;
// Statut
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' . $projectstat -> getLibStatut ( 4 ) . '</td></tr>' ;
print " </table> " ;
print '</div>' ;
} else {
print " ErrorRecordNotFound " ;
}
} elseif ( $socid > 0 ) {
$object -> fetch_thirdparty ();
$head = societe_prepare_head ( $object -> thirdparty );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'ticket' , $langs -> trans ( " ThirdParty " ), 0 , 'company' );
2020-04-16 00:42:57 +02:00
dol_banner_tab ( $object -> thirdparty , 'socid' , '' , ( $user -> socid ? 0 : 1 ), 'rowid' , 'nom' );
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2020-04-16 00:42:57 +02:00
}
2021-05-11 08:01:13 +02:00
if ( ! $user -> socid && ! empty ( $conf -> global -> TICKET_LIMIT_VIEW_ASSIGNED_ONLY )) {
2020-04-16 00:42:57 +02:00
$object -> next_prev_filter = " te.fk_user_assign = ' " . $user -> id . " ' " ;
} elseif ( $user -> socid > 0 ) {
$object -> next_prev_filter = " te.fk_soc = ' " . $user -> socid . " ' " ;
}
$head = ticket_prepare_head ( $object );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'tabTicket' , $langs -> trans ( " Ticket " ), - 1 , 'ticket' );
2020-04-16 00:42:57 +02:00
$morehtmlref = '<div class="refidno">' ;
$morehtmlref .= $object -> subject ;
// Author
if ( $object -> fk_user_create > 0 ) {
$morehtmlref .= '<br>' . $langs -> trans ( " CreatedBy " ) . ' : ' ;
$langs -> load ( " users " );
$fuser = new User ( $db );
$fuser -> fetch ( $object -> fk_user_create );
$morehtmlref .= $fuser -> getNomUrl ( 0 );
}
if ( ! empty ( $object -> origin_email )) {
$morehtmlref .= '<br>' . $langs -> trans ( " CreatedBy " ) . ' : ' ;
$morehtmlref .= dol_escape_htmltag ( $object -> origin_email ) . ' <small>(' . $langs -> trans ( " TicketEmailOriginIssuer " ) . ')</small>' ;
}
// Thirdparty
2020-12-17 11:57:12 +01:00
if ( ! empty ( $conf -> societe -> enabled )) {
2020-04-16 00:42:57 +02:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' ' ;
if ( $action != 'editcustomer' && $object -> fk_statut < 8 && ! $user -> socid && $user -> rights -> ticket -> write ) {
$morehtmlref .= '<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&track_id=' . $object -> track_id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'Edit' ), 0 ) . '</a> : ' ;
}
if ( $action == 'editcustomer' ) {
$morehtmlref .= $form -> form_thirdparty ( $url_page_current . '?track_id=' . $object -> track_id , $object -> socid , 'editcustomer' , '' , 1 , 0 , 0 , array (), 1 );
} else {
$morehtmlref .= $form -> form_thirdparty ( $url_page_current . '?track_id=' . $object -> track_id , $object -> socid , 'none' , '' , 1 , 0 , 0 , array (), 1 );
}
}
// Project
2020-12-17 11:57:12 +01:00
if ( ! empty ( $conf -> projet -> enabled )) {
2020-04-16 00:42:57 +02:00
$langs -> load ( " projects " );
$morehtmlref .= '<br>' . $langs -> trans ( 'Project' ) . ' ' ;
2020-12-17 11:57:12 +01:00
if ( $user -> rights -> ticket -> write ) {
2021-02-26 13:27:00 +01:00
if ( $action != 'classify' ) {
2020-04-16 00:42:57 +02:00
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classify&id=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'SetProject' )) . '</a>' ;
2021-02-26 13:27:00 +01:00
}
$morehtmlref .= ' : ' ;
if ( $action == 'classify' ) {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '">' ;
$morehtmlref .= '<input type="hidden" name="action" value="classin">' ;
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$morehtmlref .= $formproject -> select_projects ( $object -> socid , $object -> fk_project , 'projectid' , 0 , 0 , 1 , 0 , 1 , 0 , 0 , '' , 1 , 0 , 'maxwidth500' );
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs -> trans ( " Modify " ) . '">' ;
$morehtmlref .= '</form>' ;
} else {
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> socid , $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
2020-04-16 00:42:57 +02:00
}
} else {
if ( ! empty ( $object -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
$morehtmlref .= $proj -> getNomUrl ( 1 );
} else {
$morehtmlref .= '' ;
}
}
}
$morehtmlref .= '</div>' ;
$linkback = '<a href="' . DOL_URL_ROOT . '/ticket/list.php?restore_lastsearch_values=1"><strong>' . $langs -> trans ( " BackToList " ) . '</strong></a> ' ;
dol_banner_tab ( $object , 'ref' , $linkback , ( $user -> socid ? 0 : 1 ), 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield centpercent">' ;
// Track ID
print '<tr><td class="titlefield">' . $langs -> trans ( " TicketTrackId " ) . '</td><td>' ;
if ( ! empty ( $object -> track_id )) {
if ( empty ( $object -> ref )) {
$object -> ref = $object -> id ;
print $form -> showrefnav ( $object , 'id' , $linkback , 1 , 'rowid' , 'track_id' );
} else {
print $object -> track_id ;
}
} else {
print $langs -> trans ( 'None' );
}
print '</td></tr>' ;
// Subject
print '<tr><td>' ;
print $form -> editfieldkey ( " Subject " , 'subject' , $object -> subject , $object , $user -> rights -> ticket -> write && ! $user -> socid , 'string' );
print '</td><td>' ;
print $form -> editfieldval ( " Subject " , 'subject' , $object -> subject , $object , $user -> rights -> ticket -> write && ! $user -> socid , 'string' );
print '</td></tr>' ;
// Creation date
print '<tr><td>' . $langs -> trans ( " DateCreation " ) . '</td><td>' ;
2021-02-02 00:19:41 +01:00
print dol_print_date ( $object -> datec , 'dayhour' , 'tzuser' );
2020-04-26 23:52:23 +02:00
print '<span class="opacitymedium"> - ' . $langs -> trans ( " TimeElapsedSince " ) . ': <i>' . convertSecondToTime ( roundUpToNextMultiple ( $now - $object -> datec , 60 )) . '</i></span>' ;
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Read date
print '<tr><td>' . $langs -> trans ( " TicketReadOn " ) . '</td><td>' ;
if ( ! empty ( $object -> date_read )) {
2021-02-02 00:19:41 +01:00
print dol_print_date ( $object -> date_read , 'dayhour' , 'tzuser' );
2020-04-16 00:42:57 +02:00
print '<span class="opacitymedium"> - ' . $langs -> trans ( " TicketTimeToRead " ) . ': <i>' . convertSecondToTime ( roundUpToNextMultiple ( $object -> date_read - $object -> datec , 60 )) . '</i>' ;
2020-04-27 00:09:21 +02:00
print ' - ' . $langs -> trans ( " TimeElapsedSince " ) . ': <i>' . convertSecondToTime ( roundUpToNextMultiple ( $now - $object -> date_read , 60 )) . '</i></span>' ;
2020-04-16 00:42:57 +02:00
}
print '</td></tr>' ;
// Close date
print '<tr><td>' . $langs -> trans ( " TicketCloseOn " ) . '</td><td>' ;
if ( ! empty ( $object -> date_close )) {
2021-02-02 00:19:41 +01:00
print dol_print_date ( $object -> date_close , 'dayhour' , 'tzuser' );
2020-04-16 00:42:57 +02:00
}
print '</td></tr>' ;
// User assigned
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">' ;
print $langs -> trans ( " AssignedTo " );
2020-12-17 11:57:12 +01:00
if ( $object -> fk_statut < $object :: STATUS_CLOSED && GETPOST ( 'set' , 'alpha' ) != " assign_ticket " && $user -> rights -> ticket -> manage ) {
2020-04-16 00:42:57 +02:00
print '<td class="right"><a class="editfielda" href="' . $url_page_current . '?track_id=' . $object -> track_id . '&action=view&set=assign_ticket">' . img_edit ( $langs -> trans ( 'Modify' ), '' ) . '</a></td>' ;
}
print '</tr></table>' ;
print '</td><td>' ;
if ( $object -> fk_user_assign > 0 ) {
$userstat -> fetch ( $object -> fk_user_assign );
print $userstat -> getNomUrl ( 1 );
}
// Show user list to assignate one if status is "read"
if ( GETPOST ( 'set' , 'alpha' ) == " assign_ticket " && $object -> fk_statut < 8 && ! $user -> socid && $user -> rights -> ticket -> write ) {
print '<form method="post" name="ticket" enctype="multipart/form-data" action="' . $url_page_current . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="assign_user">' ;
print '<input type="hidden" name="track_id" value="' . $object -> track_id . '">' ;
print '<label for="fk_user_assign">' . $langs -> trans ( " AssignUser " ) . '</label> ' ;
print $form -> select_dolusers ( $user -> id , 'fk_user_assign' , 1 );
print ' <input class="button" type="submit" name="btn_assign_user" value="' . $langs -> trans ( " Validate " ) . '" />' ;
print '</form>' ;
}
print '</td></tr>' ;
// Progression
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">' ;
print $langs -> trans ( 'Progression' ) . '</td><td class="left">' ;
print '</td>' ;
2020-12-17 11:57:12 +01:00
if ( $action != 'progression' && $object -> fk_statut < $object :: STATUS_CLOSED && ! $user -> socid ) {
2020-04-16 00:42:57 +02:00
print '<td class="right"><a class="editfielda" href="' . $url_page_current . '?action=progression&track_id=' . $object -> track_id . '">' . img_edit ( $langs -> trans ( 'Modify' )) . '</a></td>' ;
}
print '</tr></table>' ;
print '</td><td colspan="5">' ;
if ( $user -> rights -> ticket -> write && $action == 'progression' ) {
print '<form action="' . $url_page_current . '" method="post">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="track_id" value="' . $track_id . '">' ;
print '<input type="hidden" name="action" value="set_progression">' ;
print '<input type="text" class="flat" size="20" name="progress" value="' . $object -> progress . '">' ;
print ' <input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
} else {
print ( $object -> progress > 0 ? $object -> progress : '0' ) . '%' ;
}
print '</td>' ;
print '</tr>' ;
// Timing (Duration sum of linked fichinter)
2021-05-11 08:01:13 +02:00
if ( $conf -> ficheinter -> enabled ) {
2020-04-16 00:42:57 +02:00
$object -> fetchObjectLinked ();
$num = count ( $object -> linkedObjects );
$timing = 0 ;
if ( $num ) {
foreach ( $object -> linkedObjects as $objecttype => $objects ) {
if ( $objecttype = " fichinter " ) {
foreach ( $objects as $fichinter ) {
$timing += $fichinter -> duration ;
}
}
}
}
print '<tr><td valign="top">' ;
print $form -> textwithpicto ( $langs -> trans ( " TicketDurationAuto " ), $langs -> trans ( " TicketDurationAutoInfos " ), 1 );
print '</td><td>' ;
print convertSecondToTime ( $timing , 'all' , $conf -> global -> MAIN_DURATION_OF_WORKDAY );
print '</td></tr>' ;
}
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
print '</table>' ;
// Fin colonne gauche et début colonne droite
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
// View Original message
$actionobject -> viewTicketOriginalMessage ( $user , $action , $object );
// Classification of ticket
print '<form method="post" name="formticketproperties" action="' . $url_page_current . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="change_property">' ;
print '<input type="hidden" name="track_id" value="' . $track_id . '">' ;
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you dont need reserved height for your table
2020-12-16 19:05:27 +01:00
print '<table class="noborder tableforfield centpercent margintable">' ;
2020-04-16 00:42:57 +02:00
print '<tr class="liste_titre">' ;
print '<td>' ;
print $langs -> trans ( 'Properties' );
print '</td>' ;
print '<td>' ;
if ( GETPOST ( 'set' , 'alpha' ) == 'properties' && $user -> rights -> ticket -> write ) {
print '<input class="button" type="submit" name="btn_update_ticket_prop" value="' . $langs -> trans ( " Modify " ) . '" />' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-16 00:42:57 +02:00
// Button to edit Properties
2020-12-17 11:57:12 +01:00
if ( $object -> fk_statut < $object :: STATUS_NEED_MORE_INFO && $user -> rights -> ticket -> write ) {
2020-04-16 00:42:57 +02:00
print '<a class="editfielda" href="card.php?track_id=' . $object -> track_id . '&action=view&set=properties">' . img_edit ( $langs -> trans ( 'Modify' )) . '</a>' ;
}
}
print '</td>' ;
print '</tr>' ;
if ( GETPOST ( 'set' , 'alpha' ) == 'properties' && $user -> rights -> ticket -> write ) {
print '<tr>' ;
// Type
print '<td class="titlefield">' ;
print $langs -> trans ( 'TicketChangeType' );
print '</td><td>' ;
$formticket -> selectTypesTickets ( $object -> type_code , 'update_value_type' , '' , 2 );
print '</td>' ;
print '</tr>' ;
// Group
print '<tr>' ;
print '<td>' ;
print $langs -> trans ( 'TicketChangeCategory' );
print '</td><td>' ;
$formticket -> selectGroupTickets ( $object -> category_code , 'update_value_category' , '' , 2 );
print '</td>' ;
print '</tr>' ;
// Severity
print '<tr>' ;
print '<td>' ;
print $langs -> trans ( 'TicketChangeSeverity' );
print '</td><td>' ;
$formticket -> selectSeveritiesTickets ( $object -> severity_code , 'update_value_severity' , '' , 2 );
print '</td>' ;
print '</tr>' ;
} else {
// Type
print '<tr><td class="titlefield">' . $langs -> trans ( " Type " ) . '</td><td>' ;
2020-09-08 21:27:28 +02:00
print $langs -> getLabelFromKey ( $db , 'TicketTypeShort' . $object -> type_code , 'c_ticket_type' , 'code' , 'label' , $object -> type_code );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Group
2020-08-20 19:00:43 +02:00
print '<tr><td>' . $langs -> trans ( " TicketCategory " ) . '</td><td>' ;
2020-09-08 21:27:28 +02:00
print $langs -> getLabelFromKey ( $db , 'TicketCategoryShort' . $object -> category_code , 'c_ticket_category' , 'code' , 'label' , $object -> category_code );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Severity
print '<tr><td>' . $langs -> trans ( " TicketSeverity " ) . '</td><td>' ;
2020-09-08 21:27:28 +02:00
print $langs -> getLabelFromKey ( $db , 'TicketSeverityShort' . $object -> severity_code , 'c_ticket_severity' , 'code' , 'label' , $object -> severity_code );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
}
print '</table>' ; // End table actions
print '</div>' ;
print '</form>' ;
// Display navbar with links to change ticket status
print '<!-- navbar with status -->' ;
2020-12-17 11:57:12 +01:00
if ( ! $user -> socid && $user -> rights -> ticket -> write && $object -> fk_statut < $object :: STATUS_CLOSED && GETPOST ( 'set' ) !== 'properties' ) {
2020-04-16 00:42:57 +02:00
$actionobject -> viewStatusActions ( $object );
}
2021-02-26 13:27:00 +01:00
if ( ! empty ( $conf -> global -> MAIN_DISABLE_CONTACTS_TAB )) {
2020-04-16 00:42:57 +02:00
print load_fiche_titre ( $langs -> trans ( 'Contacts' ), '' , 'title_companies.png' );
print '<div class="div-table-responsive-no-min">' ;
print '<div class="tagtable centpercent noborder allwidth">' ;
print '<div class="tagtr liste_titre">' ;
print '<div class="tagtd">' . $langs -> trans ( " Source " ) . ' </ div >
2019-11-13 19:35:02 +01:00
< div class = " tagtd " > ' . $langs->trans("Company").' </ div >
< div class = " tagtd " > ' . $langs->trans("Contacts").' </ div >
< div class = " tagtd " > ' . $langs->trans("ContactType").' </ div >
< div class = " tagtd " > ' . $langs->trans("Phone").' </ div >
< div class = " tagtd center " > ' . $langs->trans("Status").' </ div > ' ;
2020-04-16 00:42:57 +02:00
print '</div><!-- tagtr -->' ;
// Contact list
$companystatic = new Societe ( $db );
$contactstatic = new Contact ( $db );
$userstatic = new User ( $db );
foreach ( array ( 'internal' , 'external' ) as $source ) {
$tmpobject = $object ;
$tab = $tmpobject -> listeContact ( - 1 , $source );
$num = count ( $tab );
$i = 0 ;
while ( $i < $num ) {
$var = ! $var ;
print '<div class="tagtr ' . ( $var ? 'pair' : 'impair' ) . '">' ;
print '<div class="tagtd left">' ;
if ( $tab [ $i ][ 'source' ] == 'internal' ) {
echo $langs -> trans ( " User " );
}
if ( $tab [ $i ][ 'source' ] == 'external' ) {
echo $langs -> trans ( " ThirdPartyContact " );
}
print '</div>' ;
print '<div class="tagtd left">' ;
if ( $tab [ $i ][ 'socid' ] > 0 ) {
$companystatic -> fetch ( $tab [ $i ][ 'socid' ]);
echo $companystatic -> getNomUrl ( 1 );
}
if ( $tab [ $i ][ 'socid' ] < 0 ) {
echo $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
}
if ( ! $tab [ $i ][ 'socid' ]) {
echo ' ' ;
}
print '</div>' ;
print '<div class="tagtd">' ;
if ( $tab [ $i ][ 'source' ] == 'internal' ) {
if ( $userstatic -> fetch ( $tab [ $i ][ 'id' ])) {
print $userstatic -> getNomUrl ( 1 );
}
}
if ( $tab [ $i ][ 'source' ] == 'external' ) {
if ( $contactstatic -> fetch ( $tab [ $i ][ 'id' ])) {
print $contactstatic -> getNomUrl ( 1 );
}
}
print ' </ div >
2019-11-13 19:35:02 +01:00
< div class = " tagtd " > ' . $tab[$i][' libelle '].' </ div > ' ;
2018-03-22 10:23:25 +01:00
2020-04-16 00:42:57 +02:00
print '<div class="tagtd">' ;
print dol_print_phone ( $tab [ $i ][ 'phone' ], '' , '' , '' , 'AC_TEL' ) . '<br>' ;
if ( ! empty ( $tab [ $i ][ 'phone_perso' ])) {
//print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
print '<br>' . dol_print_phone ( $tab [ $i ][ 'phone_perso' ], '' , '' , '' , 'AC_TEL' ) . '<br>' ;
}
if ( ! empty ( $tab [ $i ][ 'phone_mobile' ])) {
//print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
print dol_print_phone ( $tab [ $i ][ 'phone_mobile' ], '' , '' , '' , 'AC_TEL' ) . '<br>' ;
}
print '</div>' ;
print '<div class="tagtd center">' ;
if ( $object -> statut >= 0 ) {
echo '<a href="contact.php?track_id=' . $object -> track_id . '&action=swapstatut&ligne=' . $tab [ $i ][ 'rowid' ] . '">' ;
}
if ( $tab [ $i ][ 'source' ] == 'internal' ) {
$userstatic -> id = $tab [ $i ][ 'id' ];
$userstatic -> lastname = $tab [ $i ][ 'lastname' ];
$userstatic -> firstname = $tab [ $i ][ 'firstname' ];
echo $userstatic -> LibStatut ( $tab [ $i ][ 'statuscontact' ], 3 );
}
if ( $tab [ $i ][ 'source' ] == 'external' ) {
$contactstatic -> id = $tab [ $i ][ 'id' ];
$contactstatic -> lastname = $tab [ $i ][ 'lastname' ];
$contactstatic -> firstname = $tab [ $i ][ 'firstname' ];
echo $contactstatic -> LibStatut ( $tab [ $i ][ 'statuscontact' ], 3 );
}
if ( $object -> statut >= 0 ) {
echo '</a>' ;
}
print '</div>' ;
print '</div><!-- tagtr -->' ;
$i ++ ;
}
}
print '</div><!-- contact list -->' ;
2018-03-22 10:23:25 +01:00
print '</div>' ;
2020-04-16 00:42:57 +02:00
}
2018-03-10 04:23:59 +01:00
2020-04-16 00:42:57 +02:00
print '</div></div></div>' ;
print '<div style="clear:both"></div>' ;
2018-03-13 13:26:03 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2018-10-01 03:19:21 +02:00
// Buttons for actions
2019-07-19 23:11:00 +02:00
if ( $action != 'presend' && $action != 'presend_addmessage' && $action != 'editline' ) {
2018-10-01 03:19:21 +02:00
print '<div class="tabsAction">' . " \n " ;
2019-11-13 19:35:02 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 13:27:00 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2018-10-01 03:19:21 +02:00
2021-02-26 13:27:00 +01:00
if ( empty ( $reshook )) {
2018-10-01 03:19:21 +02:00
// Show link to add a message (if read and not closed)
2019-07-19 23:11:00 +02:00
if ( $object -> fk_statut < Ticket :: STATUS_CLOSED && $action != " presend " && $action != " presend_addmessage " ) {
2020-08-20 19:00:43 +02:00
print '<div class="inline-block divButAction"><a class="butAction reposition" href="card.php?track_id=' . $object -> track_id . '&action=presend_addmessage&mode=init">' . $langs -> trans ( 'TicketAddMessage' ) . '</a></div>' ;
2020-04-16 00:42:57 +02:00
}
// Link to create an intervention
// socid is needed otherwise fichinter ask it and forgot origin after form submit :\
if ( ! $object -> fk_soc && $user -> rights -> ficheinter -> creer ) {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( 'UnableToCreateInterIfNoSocid' ) . '">' . $langs -> trans ( 'TicketAddIntervention' ) . '</a></div>' ;
}
if ( $object -> fk_soc > 0 && $object -> fk_statut < Ticket :: STATUS_CLOSED && $user -> rights -> ficheinter -> creer ) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . dol_buildpath ( '/fichinter/card.php' , 1 ) . '?action=create&socid=' . $object -> fk_soc . '&origin=ticket_ticket&originid=' . $object -> id . '">' . $langs -> trans ( 'TicketAddIntervention' ) . '</a></div>' ;
}
2021-03-24 22:54:40 +01:00
/* This is useless . We can already modify each field individually
2020-09-09 11:46:56 +02:00
if ( $user -> rights -> ticket -> write && $object -> fk_statut < Ticket :: STATUS_CLOSED ) {
2020-09-14 04:30:04 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?track_id=' . $object -> track_id . '&action=edit">' . $langs -> trans ( 'Modify' ) . '</a></div>' ;
2020-09-09 11:46:56 +02:00
}
2021-03-24 22:54:40 +01:00
*/
2020-09-09 11:46:56 +02:00
2020-04-16 00:42:57 +02:00
// Close ticket if statut is read
if ( $object -> fk_statut > 0 && $object -> fk_statut < Ticket :: STATUS_CLOSED && $user -> rights -> ticket -> write ) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object -> track_id . '&action=close">' . $langs -> trans ( 'CloseTicket' ) . '</a></div>' ;
}
// Re-open ticket
if ( ! $user -> socid && $object -> fk_statut == Ticket :: STATUS_CLOSED && ! $user -> socid ) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object -> track_id . '&action=reopen">' . $langs -> trans ( 'ReOpen' ) . '</a></div>' ;
}
// Delete ticket
if ( $user -> rights -> ticket -> delete && ! $user -> socid ) {
2020-10-01 10:50:54 +02:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?track_id=' . $object -> track_id . '&action=delete&token=' . newToken () . '">' . $langs -> trans ( 'Delete' ) . '</a></div>' ;
2020-04-16 00:42:57 +02:00
}
2018-10-01 03:19:21 +02:00
}
2020-04-16 00:42:57 +02:00
print '</div>' . " \n " ;
2020-05-21 15:05:19 +02:00
} else {
2020-08-20 19:00:43 +02:00
//print '<br>';
2019-10-05 13:13:11 +02:00
}
2018-03-13 13:26:03 +01:00
2018-10-01 03:19:21 +02:00
// Select mail models is same action as presend
if ( GETPOST ( 'modelselected' )) {
$action = 'presend' ;
}
2019-07-19 23:11:00 +02:00
// Set $action to correct value for the case we used presend action to add a message
2021-02-26 13:27:00 +01:00
if ( GETPOSTISSET ( 'actionbis' ) && $action == 'presend' ) {
$action = 'presend_addmessage' ;
}
2018-03-13 13:26:03 +01:00
2020-05-07 12:22:13 +02:00
// add a message
2021-02-26 13:27:00 +01:00
if ( $action == 'presend' || $action == 'presend_addmessage' ) {
2021-05-17 07:37:01 +02:00
if ( $object -> fk_soc > 0 ) {
$object -> fetch_thirdparty ();
}
2021-05-17 07:38:46 +02:00
2021-05-16 19:07:36 +02:00
$outputlangs = $langs ;
$newlang = '' ;
2021-05-17 07:34:56 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && GETPOST ( 'lang_id' , 'aZ09' )) {
$newlang = GETPOST ( 'lang_id' , 'aZ09' );
2021-06-15 22:04:31 +02:00
} elseif ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && is_object ( $object -> thirdparty )) {
2021-05-16 19:07:36 +02:00
$newlang = $object -> thirdparty -> default_lang ;
}
2021-06-15 22:04:31 +02:00
if ( ! empty ( $newlang )) {
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( $newlang );
}
2021-06-15 22:06:48 +02:00
2021-05-16 19:07:36 +02:00
$arrayoffamiliestoexclude = array ( 'objectamount' );
2019-11-13 19:35:02 +01:00
$action = 'add_message' ; // action to use to post the message
$modelmail = 'ticket_send' ;
2018-10-01 03:19:21 +02:00
2019-05-01 17:53:41 +02:00
// Substitution array
2019-11-13 19:35:02 +01:00
$morehtmlright = '' ;
2020-04-16 00:42:57 +02:00
$help = " " ;
2021-06-15 12:04:24 +02:00
$substitutionarray = getCommonSubstitutionArray ( $outputlangs , 0 , $arrayoffamiliestoexclude , $object );
2020-04-16 00:42:57 +02:00
if ( $object -> fk_soc > 0 ) {
$substitutionarray [ '__THIRDPARTY_NAME__' ] = $object -> thirdparty -> name ;
}
2020-09-06 19:25:25 +02:00
$substitutionarray [ '__USER_SIGNATURE__' ] = $user -> signature ;
2020-04-16 00:42:57 +02:00
$substitutionarray [ '__TICKET_TRACKID__' ] = $object -> track_id ;
$substitutionarray [ '__TICKET_REF__' ] = $object -> ref ;
$substitutionarray [ '__TICKET_SUBJECT__' ] = $object -> subject ;
$substitutionarray [ '__TICKET_TYPE__' ] = $object -> type_code ;
$substitutionarray [ '__TICKET_SEVERITY__' ] = $object -> severity_code ;
$substitutionarray [ '__TICKET_CATEGORY__' ] = $object -> category_code ; // For backward compatibility
$substitutionarray [ '__TICKET_ANALYTIC_CODE__' ] = $object -> category_code ;
$substitutionarray [ '__TICKET_MESSAGE__' ] = $object -> message ;
$substitutionarray [ '__TICKET_PROGRESSION__' ] = $object -> progress ;
if ( $object -> fk_user_assign > 0 ) {
$userstat -> fetch ( $object -> fk_user_assign );
$substitutionarray [ '__TICKET_USER_ASSIGN__' ] = dolGetFirstLastname ( $userstat -> firstname , $userstat -> lastname );
}
if ( $object -> fk_user_create > 0 ) {
$userstat -> fetch ( $object -> fk_user_create );
$substitutionarray [ '__TICKET_USER_CREATE__' ] = dolGetFirstLastname ( $userstat -> firstname , $userstat -> lastname );
}
foreach ( $substitutionarray as $key => $val ) {
$help .= $key . ' -> ' . $langs -> trans ( $val ) . '<br>' ;
}
$morehtmlright .= $form -> textwithpicto ( '<span class="opacitymedium">' . $langs -> trans ( " TicketMessageSubstitutionReplacedByGenericValues " ) . '</span>' , $help , 1 , 'helpclickable' , '' , 0 , 3 , 'helpsubstitution' );
2019-05-01 17:53:41 +02:00
2018-10-01 03:19:21 +02:00
print '<div>' ;
2020-08-20 19:00:43 +02:00
2019-05-01 17:53:41 +02:00
print load_fiche_titre ( $langs -> trans ( 'TicketAddMessage' ), $morehtmlright , 'messages@ticket' );
2018-10-01 03:19:21 +02:00
2019-03-05 12:18:36 +01:00
print '<hr>' ;
2018-10-01 03:19:21 +02:00
$formticket = new FormTicket ( $db );
$formticket -> action = $action ;
$formticket -> track_id = $object -> track_id ;
2020-02-07 11:52:55 +01:00
$formticket -> ref = $object -> ref ;
2018-10-01 03:19:21 +02:00
$formticket -> id = $object -> id ;
$formticket -> withfile = 2 ;
2019-03-05 12:18:36 +01:00
$formticket -> withcancel = 1 ;
2018-10-01 03:19:21 +02:00
$formticket -> param = array ( 'fk_user_create' => $user -> id );
2019-11-13 19:35:02 +01:00
$formticket -> param [ 'langsmodels' ] = ( empty ( $newlang ) ? $langs -> defaultlang : $newlang );
2018-10-01 03:19:21 +02:00
// Tableau des parametres complementaires du post
2019-11-13 19:35:02 +01:00
$formticket -> param [ 'models' ] = $modelmail ;
$formticket -> param [ 'models_id' ] = GETPOST ( 'modelmailselected' , 'int' );
2018-10-01 03:19:21 +02:00
//$formticket->param['socid']=$object->fk_soc;
2019-11-13 19:35:02 +01:00
$formticket -> param [ 'returnurl' ] = $_SERVER [ " PHP_SELF " ] . '?track_id=' . $object -> track_id ;
2018-10-01 03:19:21 +02:00
$formticket -> withsubstit = 1 ;
2019-05-01 17:53:41 +02:00
$formticket -> substit = $substitutionarray ;
2018-10-01 03:19:21 +02:00
$formticket -> showMessageForm ( '100%' );
print '</div>' ;
2020-04-16 00:42:57 +02:00
}
2020-05-07 12:22:13 +02:00
2020-05-07 22:52:32 +02:00
// Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab)
2020-09-08 21:27:28 +02:00
if ( ! empty ( $conf -> global -> TICKET_SHOW_MESSAGES_ON_CARD )) {
2020-05-07 12:22:13 +02:00
$param = '&id=' . $object -> id ;
2021-02-26 13:27:00 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . $contextpage ;
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . $limit ;
}
if ( $actioncode ) {
$param .= '&actioncode=' . urlencode ( $actioncode );
}
if ( $search_agenda_label ) {
$param .= '&search_agenda_label=' . urlencode ( $search_agenda_label );
}
2020-05-07 12:22:13 +02:00
$morehtmlright = '' ;
2020-09-08 21:27:28 +02:00
$messagingUrl = DOL_URL_ROOT . '/ticket/agenda.php?track_id=' . $object -> track_id ;
2020-05-07 12:22:13 +02:00
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( 'MessageListViewType' ), '' , 'fal fa-list-alt imgforviewmode' , $messagingUrl , '' , 1 );
// Show link to add a message (if read and not closed)
$btnstatus = $object -> fk_statut < Ticket :: STATUS_CLOSED && $action != " presend " && $action != " presend_addmessage " && $action != " add_message " ;
2020-09-08 21:27:28 +02:00
$url = 'card.php?track_id=' . $object -> track_id . '&action=presend_addmessage&mode=init' ;
2020-05-07 12:22:13 +02:00
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( 'TicketAddMessage' ), '' , 'fal fa-comment-dots' , $url , 'add-new-ticket-title-button' , $btnstatus );
// Show link to add event (if read and not closed)
2020-09-08 21:27:28 +02:00
$btnstatus = $object -> fk_statut < Ticket :: STATUS_CLOSED && $action != " presend " && $action != " presend_addmessage " && $action != " add_message " ; ;
$url = dol_buildpath ( '/comm/action/card.php' , 1 ) . '?action=create&datep=' . date ( 'YmdHi' ) . '&origin=ticket&originid=' . $object -> id . '&projectid=' . $object -> fk_project . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?track_id=' . $object -> track_id );
2020-05-07 12:22:13 +02:00
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( 'AddAction' ), '' , 'fal fa-plus-circle' , $url , 'add-new-ticket-even-button' , $btnstatus );
print_barre_liste ( $langs -> trans ( " ActionsOnTicket " ), 0 , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , '' , 0 , - 1 , '' , 0 , $morehtmlright , '' , 0 , 1 , 1 );
// List of all actions
$filters = array ();
$filters [ 'search_agenda_label' ] = $search_agenda_label ;
show_ticket_messaging ( $conf , $langs , $db , $object , null , 0 , $actioncode , '' , $filters , $sortfield , $sortorder );
}
2020-05-07 14:35:04 +02:00
if ( $action != 'presend' && $action != 'presend_addmessage' && $action != 'add_message' ) {
2020-05-07 12:22:13 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
// Show links to link elements
$linktoelem = $form -> showLinkToObjectBlock ( $object , null , array ( 'ticket' ));
$somethingshown = $form -> showLinkedObjectBlock ( $object , $linktoelem );
// Show direct link to public interface
print '<br><!-- Link to public interface -->' . " \n " ;
print showDirectPublicLink ( $object ) . '<br>' ;
print '</div>' ;
2020-05-07 22:52:32 +02:00
if ( empty ( $conf -> global -> TICKET_SHOW_MESSAGES_ON_CARD )) {
2020-05-07 12:22:13 +02:00
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2020-05-07 22:52:32 +02:00
$MAXEVENT = 10 ;
$morehtmlcenter = dolGetButtonTitle ( $langs -> trans ( 'FullConversation' ), '' , 'fa fa-comments imgforviewmode' , DOL_URL_ROOT . '/ticket/messaging.php?id=' . $object -> id );
$morehtmlcenter .= ' ' ;
$morehtmlcenter .= dolGetButtonTitle ( $langs -> trans ( 'FullList' ), '' , 'fa fa-list-alt imgforviewmode' , DOL_URL_ROOT . '/ticket/agenda.php?id=' . $object -> id );
2020-05-07 12:22:13 +02:00
// List of actions on element
2020-09-08 21:27:28 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2020-05-07 12:22:13 +02:00
$formactions = new FormActions ( $db );
2020-05-07 22:52:32 +02:00
$somethingshown = $formactions -> showactions ( $object , 'ticket' , $socid , 1 , 'listactions' , $MAXEVENT , '' , $morehtmlcenter );
2020-05-07 12:22:13 +02:00
print '</div></div>' ;
}
2020-05-07 22:52:32 +02:00
2020-05-07 12:22:13 +02:00
print '</div>' ;
}
2018-10-01 03:19:21 +02:00
}
}
2018-03-10 04:23:59 +01:00
// End of page
2018-10-01 03:19:21 +02:00
llxFooter ();
2018-03-10 04:23:59 +01:00
$db -> close ();