From ac25003d33d27eae859bb15dc915b966bd1abdaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 11:39:54 +0200 Subject: [PATCH 01/16] Dolibarize module ticket --- htdocs/core/class/html.formfile.class.php | 32 +- htdocs/core/class/html.formticket.class.php | 161 ++-- htdocs/core/lib/ticket.lib.php | 5 +- htdocs/core/tpl/contacts.tpl.php | 2 +- htdocs/theme/eldy/global.inc.php | 9 +- htdocs/ticket/card.php | 438 ++++++++- htdocs/ticket/class/actions_ticket.class.php | 892 +------------------ htdocs/ticket/class/ticket.class.php | 418 ++++++++- htdocs/ticket/contact.php | 17 +- htdocs/ticket/document.php | 11 +- 10 files changed, 969 insertions(+), 1016 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5768a0e5ba6..ccf5c9de6b2 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1139,7 +1139,7 @@ class FormFile } print '
'; - print ''."\n"; + print '
'."\n"; if (! empty($addfilterfields)) { @@ -1156,10 +1156,10 @@ class FormFile print ''; //print $url.' sortfield='.$sortfield.' sortorder='.$sortorder; - print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, ' left'); - print_liste_field_titre('Size', $url, "size", "", $param, '', $sortfield, $sortorder, ' right'); - print_liste_field_titre('Date', $url, "date", "", $param, '', $sortfield, $sortorder, ' center'); - if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, ' center'); // Preview + print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Size', $url, "size", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('Date', $url, "date", "", $param, '', $sortfield, $sortorder, 'center '); + if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, 'center '); // Preview print_liste_field_titre(''); print_liste_field_titre(''); if (! $disablemove) print_liste_field_titre(''); @@ -1734,7 +1734,7 @@ class FormFile print ''; - print '
'; + print '
'; print ''; print_liste_field_titre( $langs->trans("Links"), @@ -1742,9 +1742,10 @@ class FormFile "name", "", $param, - 'class="left"', + '', $sortfield, - $sortorder + $sortorder, + '' ); print_liste_field_titre( "", @@ -1752,7 +1753,10 @@ class FormFile "", "", "", - 'class="right"' + '', + '', + '', + 'right ' ); print_liste_field_titre( $langs->trans("Date"), @@ -1760,9 +1764,10 @@ class FormFile "date", "", $param, - 'class="center"', + '', $sortfield, - $sortorder + $sortorder, + 'center ' ); print_liste_field_titre( '', @@ -1770,7 +1775,10 @@ class FormFile "", "", $param, - 'class="center"' + '', + '', + '', + 'center ' ); print_liste_field_titre('', '', ''); print ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 9e7f18957f7..59996942cd3 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -167,6 +167,85 @@ class FormTicket print ''; } + // TITLE + if ($this->withemail) { + print ''; + } + + // Si origin du ticket + if (isset($this->param['origin']) && $this->param['originid'] > 0) { + // Parse element/subelement (ex: project_task) + $element = $subelement = $this->param['origin']; + if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) { + $element = $regs[1]; + $subelement = $regs[2]; + } + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + $classname = ucfirst($subelement); + $objectsrc = new $classname($this->db); + $objectsrc->fetch(GETPOST('originid', 'int')); + + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { + $objectsrc->fetch_lines(); + } + + $objectsrc->fetch_thirdparty(); + $newclassname = $classname; + print ''; + } + + // Type + print ''; + + // Severity + print ''; + + // Group + print ''; + + // Subject + if ($this->withtitletopic) { + print ''; + } else { + if ($this->withthreadid > 0) { + $subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . ''; + } + print ''; + print ''; + } + } + + // MESSAGE + $msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : ''; + print ''; + // FK_USER_CREATE if ($this->withusercreate > 0 && $this->fk_user_create) { print ''; - } - - // Si origin du ticket - if (isset($this->param['origin']) && $this->param['originid'] > 0) { - // Parse element/subelement (ex: project_task) - $element = $subelement = $this->param['origin']; - if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) { - $element = $regs[1]; - $subelement = $regs[2]; - } - - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = ucfirst($subelement); - $objectsrc = new $classname($this->db); - $objectsrc->fetch(GETPOST('originid', 'int')); - - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { - $objectsrc->fetch_lines(); - } - - $objectsrc->fetch_thirdparty(); - $newclassname = $classname; - print ''; - } - - // Type - print ''; - - // Severity - print ''; - - // Group - print ''; - - // TITLE - if ($this->withtitletopic) { - print ''; - } else { - if ($this->withthreadid > 0) { - $subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . ''; - } - print ''; - print ''; - } - } - - // MESSAGE - $msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : ''; - print ''; - if (! empty($conf->projet->enabled) && ! $this->ispublic) { $formproject=new FormProjets($this->db); @@ -831,7 +831,8 @@ class FormTicket print '
' . $langs->trans("Ref") . '
'; + print ''; + print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
'; + $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); + print '
'; + $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); + print '
'; + $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); + print '
'; + + // Réponse à un ticket : affichage du titre du thread en readonly + if ($this->withtopicreadonly) { + print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title; + print '
'; + + // If public form, display more information + $toolbarname = 'dolibarr_notes'; + if ($this->ispublic) + { + $toolbarname = 'dolibarr_details'; + print '
' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '
'; + } + include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $uselocalbrowser = true; + $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser); + $doleditor->Create(); + print '
' . $langs->trans("CreatedBy") . ''; @@ -269,85 +348,6 @@ class FormTicket } } - // TITLE - if ($this->withemail) { - print '
'; - print ''; - print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
'; - $this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2'); - print '
'; - $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); - print '
'; - $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2'); - print '
'; - - // Réponse à un ticket : affichage du titre du thread en readonly - if ($this->withtopicreadonly) { - print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title; - print '
'; - - // If public form, display more information - $toolbarname = 'dolibarr_notes'; - if ($this->ispublic) - { - $toolbarname = 'dolibarr_details'; - print '
' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '
'; - } - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $uselocalbrowser = true; - $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser); - $doleditor->Create(); - print '
'; // External users can't send message email - if ($user->rights->ticket->write && !$user->socid) { + if ($user->rights->ticket->write && !$user->socid) + { print ''; // Year print ''; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 1aebd879fc2..17638c9a394 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -185,19 +185,19 @@ class Ticket extends CommonObject 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketGroup', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketGroup', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'), + 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), - 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"), + 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1), 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), - 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""), + 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>""), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) ); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index fe6ff269087..989bbda8072 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -85,7 +85,7 @@ if (! $sortorder) $sortorder="DESC"; if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][]='openall'; // For backward compatibility // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); +$search_all=trim(GETPOSTISSET("search_all")?GETPOSTISSET("search_all", 'alpha'):GETPOST('sall')); $search=array(); foreach($object->fields as $key => $val) { @@ -190,9 +190,6 @@ $socstatic = new Societe($db); $help_url = ''; $title = $langs->trans('TicketList'); -llxHeader('', $title, $help_url); - - // Build and execute select // -------------------------------------------------------------------- @@ -295,6 +292,9 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && // Output page // -------------------------------------------------------------------- +llxHeader('', $title, $help_url); + + if ($socid && !$projectid && $user->rights->societe->lire) { $socstat = new Societe($db); $res = $socstat->fetch($socid); @@ -468,10 +468,10 @@ $objecttmp=new Ticket($db); $trackid='tick'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) +if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; From 6a846f46f2b49b85ebef18928d2c13cf6ceda28d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 15:33:15 +0200 Subject: [PATCH 07/16] Debug module ticket --- htdocs/public/ticket/list.php | 52 +++++++++++++++++------------------ htdocs/public/ticket/view.php | 5 ++-- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index c341d32cf3e..c9786268f4f 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -197,7 +197,7 @@ if ($action == "view_ticketlist") $search_array_options = $extrafields->getOptionalsFromPost('ticket', '', 'search_'); $filter = array(); - $param = ''; + $param = 'action=view_ticketlist'; // Definition of fields for list $arrayfields = array( @@ -259,12 +259,10 @@ if ($action == "view_ticketlist") $param .= '&search_fk_user_create=' . $search_fk_user_create; } } - if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') { $filter['t.fk_statut'] = $search_fk_status; $param .= '&search_fk_status=' . $search_fk_status; } - if (isset($search_fk_status) && $search_fk_status == 'non_closed') { $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6); $param .= '&search_fk_status=non_closed'; @@ -372,9 +370,7 @@ if ($action == "view_ticketlist") $num = $db->num_rows($resql); print_barre_liste($langs->trans('TicketList'), $page, 'public/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); - /* - * Search bar - */ + // Search bar print '' . "\n"; print ''; print ''; @@ -399,9 +395,6 @@ if ($action == "view_ticketlist") if (!empty($arrayfields['t.ref']['checked'])) { print_liste_field_titre($arrayfields['t.ref']['label'], $url_page_current, 't.ref', '', $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['t.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['t.fk_statut']['label'], $url_page_current, 't.fk_statut', '', $param, '', $sortfield, $sortorder); - } if (!empty($arrayfields['t.subject']['checked'])) { print_liste_field_titre($arrayfields['t.subject']['label']); } @@ -435,6 +428,9 @@ if ($action == "view_ticketlist") } } } + if (!empty($arrayfields['t.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['t.fk_statut']['label'], $url_page_current, 't.fk_statut', '', $param, '', $sortfield, $sortorder); + } print_liste_field_titre($selectedfields, $url_page_current, "", '', '', 'align="right"', $sortfield, $sortorder, 'maxwidthsearch '); print ''; @@ -459,14 +455,6 @@ if ($action == "view_ticketlist") print ''; } - // Status - if (!empty($arrayfields['t.fk_statut']['checked'])) { - print ''; - } - if (!empty($arrayfields['t.subject']['checked'])) { print ''; + } + print ''; } - // ref + // Ref if (!empty($arrayfields['t.ref']['checked'])) { print ''; } - // Statut - if (!empty($arrayfields['t.fk_statut']['checked'])) { - print ''; - } - // Subject if (!empty($arrayfields['t.subject']['checked'])) { print ''; + } + print ''; + $i++; print ''; } @@ -680,7 +678,7 @@ if ($action == "view_ticketlist") print ''; print ''; print ''; - print ''; + //print ''; print '

'; print ''; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index af4585622dd..c7ee74715c3 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -118,7 +118,8 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" | $action = ''; } } -$object->doActions($action); + +//$object->doActions($action); @@ -261,7 +262,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" | print ''; print ''; print ''; - print ''; + //print ''; print "\n"; print '

'; From 2eeb4b8734728bf7cad2abf4cd3adca37ca37c9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 15:45:55 +0200 Subject: [PATCH 08/16] Debug ticket module --- htdocs/admin/agenda.php | 3 +-- htdocs/admin/agenda_extsites.php | 2 +- htdocs/admin/agenda_xcal.php | 2 +- htdocs/core/modules/modTicket.class.php | 1 - htdocs/core/tpl/admin_extrafields_view.tpl.php | 3 ++- htdocs/install/mysql/data/llx_c_action_trigger.sql | 3 ++- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 1 + htdocs/langs/en_US/ticket.lang | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index eb2f413b340..24b4766471d 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -134,8 +134,7 @@ $head=agenda_prepare_head(); dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); -print $langs->trans("AgendaAutoActionDesc")."
\n"; -print $langs->trans("OnlyActiveElementsAreShown", 'modules.php').'
'; +print ''.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'
'; print "
\n"; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 4a2d22e176d..6979c49aabc 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -140,7 +140,7 @@ $head=agenda_prepare_head(); dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action'); -print $langs->trans("AgendaExtSitesDesc")."
\n"; +print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index fe2a2ef84e7..8a771bfe492 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -84,7 +84,7 @@ $head=agenda_prepare_head(); dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action'); -print $langs->trans("AgendaSetupOtherDesc")."
\n"; +print ''.$langs->trans("AgendaSetupOtherDesc")."
\n"; print "
\n"; print '
'; $checkbox_selected = ( GETPOST('send_email') == "1" ? ' checked' : ''); print ' '; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 406f53c4762..bd449cc91e9 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -81,7 +81,6 @@ function ticket_prepare_head($object) $head[$h][2] = 'tabTicket'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) { $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); @@ -96,9 +95,9 @@ function ticket_prepare_head($object) // Attached files include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $upload_dir = $conf->ticket->dir_output . "/" . $object->track_id; + $upload_dir = $conf->ticket->dir_output . "/" . $object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files')); - $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?track_id=' . $object->track_id; + $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?id=' . $object->id; $head[$h][1] = $langs->trans("Documents"); if ($nbFiles > 0) { $head[$h][1] .= ' ' . $nbFiles . ''; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e3060f34bde..316e85a3ac6 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -63,7 +63,7 @@ $userstatic=new User($db);
-
+
); border-top-style: solid; } -/*.liste_titre_create td.nobottom, tr#trlinefordates td { - background-color: rgb() !important; -}*/ tr#trlinefordates td { border-bottom: 0px !important; } @@ -2932,6 +2929,9 @@ form.pair, form.impair { form.tagtr:last-of-type div.tagtd, tr.pair:last-of-type td, tr.impair:last-of-type td { border-bottom: 0px !important; } +div.tableforcontact form.tagtr:last-of-type div.tagtd { + border-bottom: 1px solid #ddd !important; +} tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { border-bottom: 0px !important; } @@ -2939,6 +2939,9 @@ table.nobottomiftotal tr.liste_total td { background-color: #fff; border-bottom: 0px !important; } +table.nobottom { + border-bottom: 0px !important; +} div.liste_titre .tagtd { vertical-align: middle; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index fd434ef395f..5aa09bee982 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -123,8 +123,428 @@ if ($cancel) $action='view'; } -// Do action -$actionobject->doActions($action, $object); +if (GETPOST('add', 'alpha') && $user->rights->ticket->write) { + $error = 0; + + if (!GETPOST("subject", 'alpha')) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors'); + $action = 'create'; + } elseif (!GETPOST("message", 'alpha')) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); + $action = 'create'; + } + + if (!$error) { + $db->begin(); + + $object->ref = GETPOST("ref", 'alpha'); + $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; + $object->subject = GETPOST("subject", 'alpha'); + $object->message = GETPOST("message", 'none'); + + $object->type_code = GETPOST("type_code", 'alpha'); + $object->category_code = GETPOST("category_code", 'alpha'); + $object->severity_code = GETPOST("severity_code", 'alpha'); + $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); + $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; + + $object->fk_project = GETPOST('projectid', 'int'); + + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + + $id = $object->create($user); + if ($id <= 0) { + $error++; + setEventMessage($object->error, $object->errors, 'errors'); + $action = 'create'; + } + + if (! $error) + { + // Add contact + $contactid = GETPOST('contactid', 'int'); + $type_contact = GETPOST("type", 'alpha'); + + if ($contactid > 0 && $type_contact) { + $result = $object->add_contact($contactid, GETPOST("type"), 'external'); + } + + // altairis: link ticket to project + if (GETPOST('projectid') > 0) { + $object->setProject(GETPOST('projectid')); + } + + // Auto assign user + if ($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE) { + $result = $object->assignUser($user, $user->id, 1); + $object->add_contact($user->id, "SUPPORTTEC", 'internal'); + } + + // Auto assign contrat + $contractid = 0; + if ($conf->global->TICKET_AUTO_ASSIGN_CONTRACT_CREATE) { + $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 { + } + } + } + + // Auto create fiche intervention + if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE) + { + $fichinter = new Fichinter($db); + $fichinter->socid = $object->fk_soc; + $fichinter->fk_project = GETPOST('projectid', 'int'); + $fichinter->fk_contrat = $contractid; + $fichinter->author = $user->id; + $fichinter->modelpdf = 'soleil'; + $fichinter->origin = $object->element; + $fichinter->origin_id = $object->id; + + // Extrafields + $extrafields = new ExtraFields($db); + $extralabels = $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'); + } + } + } + + if (! $error) + { + // File transfer + $object->copyFilesForTicket(); + } + + if (! $error) + { + $db->commit(); + + if (!empty($backtopage)) { + $url = $backtopage; + } else { + $url = 'card.php?track_id=' . $object->track_id; + } + + header("Location: " . $url); + exit; + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +if ($action == 'edit' && $user->rights->ticket->write) { + $error = 0; + + if ($object->fetch(GETPOST('id')) < 0) { + $error++; + array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); + $_GET["action"] = $_POST["action"] = ''; + } +} + +if (GETPOST('update') && GETPOST('id') && $user->rights->ticket->write) { + $error = 0; + + $ret = $object->fetch(GETPOST('id')); + if ($ret < 0) { + $error++; + array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); + $action = ''; + } elseif (!GETPOST("label")) { + $error++; + array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"))); + $action = 'edit'; + } elseif (!GETPOST("subject")) { + $error++; + array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"))); + $action = 'edit'; + } + + if (!$error) { + $db->begin(); + + $object->label = GETPOST("label"); + $object->description = GETPOST("description"); + + //... + $ret = $object->update($user); + if ($ret <= 0) { + $error++; + setEventMessage($object->error, $object->errors, 'errors'); + $action = 'edit'; + } + + if (!$error && $ret > 0) { + $db->commit(); + } else { + $db->rollback(); + } + } +} + +if ($action == "mark_ticket_read" && $user->rights->ticket->write) { + $object->fetch('', '', GETPOST("track_id", 'alpha')); + + if ($object->markAsRead($user) > 0) + { + setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); + + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = 'view'; +} + +if ($action == "assign_user" && GETPOST('btn_assign_user', 'aplha') && $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); + if ($ret < 0) $error++; + } + + if (! $error) // Update list of contacts + { + // 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']); + } + } + } + + if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); + } + + if (! $error) + { + // Log action in ticket logs table + $object->fetch_user($usertoassign); + $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); + + setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); + + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); + exit; + } else { + array_push($object->errors, $object->error); + } + $action = 'view'; +} + +if ($action == "new_message" && GETPOST('btn_add_message') && $user->rights->ticket->read) { + $ret = $object->newMessage($user, $action); + if ($ret) { + if (!empty($backtopage)) { + $url = $backtopage; + } else { + $url = 'card.php?action=view&track_id=' . $object->track_id; + } + + header("Location: " . $url); + exit; + } else { + setEventMessages($object->error, null, 'errors'); + $action = 'add_message'; + } +} + +if ($action == "new_public_message" && GETPOST('btn_add_message')) { + $object->newMessagePublic($user, $action); +} + +if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { + $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); + if ($object->close()) { + // Log action in ticket logs table + $log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs)); + + setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); + + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); + } else { + $action = ''; + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +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()) { + // Log action in ticket logs table + $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); + + setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); + + $url = 'view.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } +} + +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) { + setEventMessages('
' . $langs->trans('TicketDeletedSuccess') . '
', null, 'mesgs'); + Header("Location: ".DOL_URL_ROOT."/ticket/list.php"); + exit; + } else { + $langs->load("errors"); + $mesg = '
' . $langs->trans($object->error) . '
'; + $action = ''; + } + } +} + +// 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')); + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); + exit(); + } +} + +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')); + + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); + exit(); + } +} + +if ($action == 'setsubject') { + if ($object->fetch(GETPOST('id', 'int'))) { + if ($action == 'setsubject') { + $object->subject = trim(GETPOST('subject', 'alpha')); + } + + if ($action == 'setsubject' && empty($object->subject)) { + $mesg .= ($mesg ? '
' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); + } + + if (!$mesg) { + if ($object->update($user) >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); + exit; + } + $mesg = $object->error; + } + } +} + + +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 + if ($object->fk_statut == Ticket::STATUS_CLOSED) { + $res = $object->setStatut(Ticket::STATUS_ASSIGNED); + if ($res) { + // Log action in ticket logs table + $log_action = $langs->trans('TicketLogReopen'); + + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); + exit(); + } + } + } +} // Categorisation dans projet +elseif ($action == 'classin' && $user->rights->ticket->write) { + if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { + $object->setProject(GETPOST('projectid', 'int')); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); + exit(); + } +} // Categorisation dans contrat +elseif ($action == 'setcontract' && $user->rights->ticket->write) { + if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { + $object->setContract(GETPOST('contractid', 'int')); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); + 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; + $fieldtomodify = GETPOST('message_initial'); + + $object->message = $fieldtomodify; + $ret = $object->update($user); + if ($ret > 0) { + $log_action = $langs->trans('TicketInitialMessageModified') . " \n"; + // 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'); + } + } + + $action = 'view'; +} // Reopen ticket +elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { + 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); + if ($res) { + // Log action in ticket logs table + $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); + + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); + exit(); + } + } +} // Action to update one extrafield if ($action == "update_extras" && ! empty($permissiontoadd)) @@ -164,9 +584,21 @@ if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') & $action = 'view'; } + $permissiondellink = $user->rights->ticket->write; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once +// Actions to build doc +$upload_dir = $conf->ticket->dir_output; +$permissioncreate = $user->rights->ticket->write; +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + +// Actions to send emails +$trigger_name='TICKET_SENTBYMAIL'; +$paramname='id'; +$autocopy='MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add +$trackid='tic'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -184,7 +616,7 @@ $page_title = $actionobject->getTitle($action); llxHeader('', $page_title, $help_url); -if ($action == 'create') +if ($action == 'create' || $action == 'presend') { $formticket = new FormTicket($db); diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index f978642311c..f84426c03f9 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -102,849 +102,6 @@ class ActionsTicket } } - /** - * doActions - * - * @param string $action Action type - * @param Ticket $object Object Ticket - * @return int 0 - */ - public function doActions(&$action = '', Ticket $object = null) - { - global $conf, $user, $langs, $mysoc; - - /* - * Add file in email form - */ - if (GETPOST('addfile', 'alpha')) { - // altairis : allow files from public interface - if (GETPOST('track_id', 'alpha')) { - $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); - } - - ////if($res > 0) - ////{ - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp directory TODO Use a dedicated directory for temp mails files - $vardir = $conf->ticket->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : ''); - $upload_dir_tmp = $vardir . '/temp'; - if (!dol_is_dir($upload_dir_tmp)) { - dol_mkdir($upload_dir_tmp); - } - dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '-__file__'); - $action = !empty($object->track_id) ? 'add_message' : 'create'; - ////} - } - - /* - * Remove file in email form - */ - if (GETPOST('removedfile', 'alpha')) { - // altairis : allow files from public interface - if (GETPOST('track_id')) { - $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); - } - - ////if($res > 0) - ////{ - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp directory - $vardir = $conf->ticket->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : ''); - $upload_dir_tmp = $vardir . '/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST['removedfile'], 0); - $action = !empty($object->track_id) ? 'add_message' : 'create'; - ////} - } - - if (GETPOST('add', 'alpha') && $user->rights->ticket->write) { - $error = 0; - - if (!GETPOST("subject")) { - $error++; - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); - $action = 'create'; - } elseif (!GETPOST("message")) { - $error++; - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("message")); - $action = 'create'; - } - - if (!$error) { - $this->db->begin(); - - $object->track_id = generate_random_id(16); - - $object->ref = GETPOST("ref", 'alpha'); - $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; - $object->subject = GETPOST("subject", 'alpha'); - $object->message = GETPOST("message"); - - $object->type_code = GETPOST("type_code", 'alpha'); - $object->category_code = GETPOST("category_code", 'alpha'); - $object->severity_code = GETPOST("severity_code", 'alpha'); - $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); - $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; - - $object->fk_project = GETPOST('projectid', 'int'); - - $extrafields = new ExtraFields($this->db); - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - - $id = $object->create($user); - if ($id <= 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - $action = 'create'; - } - - if (!$error && $id > 0) - { - $this->db->commit(); - - // File transfer - $this->copyFilesForTicket(); - - // Add contact - $contactid = GETPOST('contactid', 'int'); - $type_contact = GETPOST("type", 'alpha'); - - if ($contactid > 0 && $type_contact) { - $result = $object->add_contact($contactid, GETPOST("type"), 'external'); - } - - // altairis: link ticket to project - if (GETPOST('projectid') > 0) { - $object->setProject(GETPOST('projectid')); - } - - // Auto assign user - if ($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE) { - $result = $object->assignUser($user, $user->id, 1); - $object->add_contact($user->id, "SUPPORTTEC", 'internal'); - } - - // Auto assign contrat - $contractid = 0; - if ($conf->global->TICKET_AUTO_ASSIGN_CONTRACT_CREATE) { - $contrat = new Contrat($this->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 { - } - } - } - - // Auto create fiche intervention - if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE) - { - $fichinter = new Fichinter($this->db); - $fichinter->socid = $object->fk_soc; - $fichinter->fk_project = GETPOST('projectid', 'int'); - $fichinter->fk_contrat = $contractid; - $fichinter->author = $user->id; - $fichinter->modelpdf = 'soleil'; - $fichinter->origin = $object->element; - $fichinter->origin_id = $object->id; - - // Extrafields - $extrafields = new ExtraFields($this->db); - $extralabels = $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'); - } - } - - if (!empty($backtopage)) { - $url = $backtopage; - } else { - $url = 'card.php?track_id=' . $object->track_id; - } - - header("Location: " . $url); - exit; - } else { - $this->db->rollback(); - setEventMessages($this->error, $this->errors, 'errors'); - } - } else { - setEventMessages($this->error, $this->errors, 'errors'); - } - } - - if ($action == 'edit' && $user->rights->ticket->write) { - $error = 0; - - if ($object->fetch(GETPOST('id')) < 0) { - $error++; - array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); - $_GET["action"] = $_POST["action"] = ''; - } - } - - if (GETPOST('update') && GETPOST('id') && $user->rights->ticket->write) { - $error = 0; - - $ret = $object->fetch(GETPOST('id')); - if ($ret < 0) { - $error++; - array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); - $action = ''; - } elseif (!GETPOST("label")) { - $error++; - array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"))); - $action = 'edit'; - } elseif (!GETPOST("subject")) { - $error++; - array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"))); - $action = 'edit'; - } - - if (!$error) { - $this->db->begin(); - - $object->label = GETPOST("label"); - $object->description = GETPOST("description"); - - //... - $ret = $object->update($user); - if ($ret <= 0) { - $error++; - $this->errors = $object->error; - $this->errors = $object->errors; - $action = 'edit'; - } - - if (!$error && $ret > 0) { - $this->db->commit(); - } else { - $this->db->rollback(); - } - } - } - - if ($action == "mark_ticket_read" && $user->rights->ticket->write) { - $object->fetch('', '', GETPOST("track_id", 'alpha')); - - if ($object->markAsRead($user) > 0) - { - setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); - - header("Location: card.php?track_id=" . $object->track_id . "&action=view"); - exit; - } else { - $this->errors = $object->error; - $this->error = $object->error; - } - $action = 'view'; - } - - if ($action == "assign_user" && GETPOST('btn_assign_user', 'aplha') && $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($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("AssignedTo"))); - $action = 'view'; - }*/ - - if (!$error) - { - $ret = $object->assignUser($user, $usertoassign); - if ($ret < 0) $error++; - } - - if (! $error) // Update list of contacts - { - // 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']); - } - } - } - - if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); - } - - if (! $error) - { - // Log action in ticket logs table - $object->fetch_user($usertoassign); - $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); - - setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); - - header("Location: card.php?track_id=" . $object->track_id . "&action=view"); - exit; - } else { - array_push($this->errors, $object->error); - } - $action = 'view'; - } - - if ($action == "new_message" && GETPOST('btn_add_message') && $user->rights->ticket->read) { - $ret = $this->newMessage($user, $action); - if ($ret) { - if (!empty($backtopage)) { - $url = $backtopage; - } else { - $url = 'card.php?action=view&track_id=' . $object->track_id; - } - - header("Location: " . $url); - exit; - } else { - setEventMessages($object->error, null, 'errors'); - $action = 'add_message'; - } - } - - if ($action == "new_public_message" && GETPOST('btn_add_message')) { - $this->newMessagePublic($user, $action); - } - - if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { - $this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - if ($object->close()) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs)); - - setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - - $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); - header("Location: " . $url); - } else { - $action = ''; - setEventMessages($this->error, $this->errors, 'errors'); - } - } - - if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') { - $this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - - setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); - - $url = 'view.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); - header("Location: " . $url); - } else { - setEventMessages($this->error, $this->errors, 'errors'); - $action = ''; - } - } - - if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { - if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - if ($object->delete($user) > 0) { - setEventMessages('
' . $langs->trans('TicketDeletedSuccess') . '
', null, 'mesgs'); - Header("Location: ".DOL_URL_ROOT."/ticket/list.php"); - exit; - } else { - $langs->load("errors"); - $mesg = '
' . $langs->trans($this->error) . '
'; - $action = ''; - } - } - } - - // Set parent company - if ($action == 'set_thirdparty' && $user->rights->societe->creer) { - if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); - header("Location: " . $url); - exit(); - } - } - - if ($action == 'set_progression' && $user->rights->ticket->write) { - if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setProgression(GETPOST('progress', 'alpha')); - - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); - exit(); - } - } - - if ($action == 'setsubject') { - if ($this->fetch(GETPOST('id', 'int'))) { - if ($action == 'setsubject') { - $object->subject = trim(GETPOST('subject', 'alpha')); - } - - if ($action == 'setsubject' && empty($object->subject)) { - $mesg .= ($mesg ? '
' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); - } - - if (!$mesg) { - if ($object->update($user) >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); - exit; - } - $mesg = $object->error; - } - } - } - - - if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) { - if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - // prevent browser refresh from reopening ticket several times - if ($object->fk_statut == Ticket::STATUS_CLOSED) { - $res = $object->setStatut(Ticket::STATUS_ASSIGNED); - if ($res) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogReopen'); - - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); - exit(); - } - } - } - } // Categorisation dans projet - elseif ($action == 'classin' && $user->rights->ticket->write) { - if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $object->setProject(GETPOST('projectid', 'int')); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); - exit(); - } - } // Categorisation dans contrat - elseif ($action == 'setcontract' && $user->rights->ticket->write) { - if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $object->setContract(GETPOST('contractid', 'int')); - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); - exit(); - } - } elseif ($action == "set_message" && $user->rights->ticket->manage) { - // altairis: manage cancel button - if (!GETPOST('cancel')) { - $this->fetch('', '', GETPOST('track_id', 'alpha')); - $oldvalue_message = $object->message; - $fieldtomodify = GETPOST('message_initial'); - - $object->message = $fieldtomodify; - $ret = $object->update($user); - if ($ret > 0) { - $log_action = $langs->trans('TicketInitialMessageModified') . " \n"; - // 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'); - } - } - - $action = 'view'; - } // Reopen ticket - elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { - if ($this->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); - if ($res) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - - $url = 'card.php?action=view&track_id=' . $object->track_id; - header("Location: " . $url); - exit(); - } - } - } - - return 0; - } - - /** - * Add new message on a ticket (private area) - * - * @param User $user User for action - * @param string $action Action string - * @return int - */ - private function newMessage($user, &$action) - { - global $mysoc, $conf, $langs; - - if (!class_exists('Contact')) { - include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - } - - $contactstatic = new Contact($this->db); - - $error = 0; - - $object = new Ticket($this->db); - $ret = $object->fetch('', '', GETPOST('track_id', 'alpha')); - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); - if ($ret < 0) { - $error++; - array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); - $action = ''; - } - - if (!GETPOST("message")) { - $error++; - array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message"))); - $action = 'add_message'; - } - - if (!$error) { - $object->message = GETPOST("message"); - $object->private = GETPOST("private_message"); - $send_email = GETPOST('send_email', 'int'); - - $id = $object->createTicketMessage($user); - if ($id <= 0) { - $error++; - $this->errors = $object->error; - $this->errors = $object->errors; - $action = 'add_message'; - } - - if (!$error && $id > 0) { - setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); - - /* - * Send email to linked contacts - */ - if ($send_email > 0) { - // Retrieve internal contact datas - $internal_contacts = $object->getInfosTicketInternalContact(); - $sendto = array(); - if (is_array($internal_contacts) && count($internal_contacts) > 0) { - // altairis: set default subject - $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - - $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id); - $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; - - $message = $langs->trans('TicketMessageMailIntroText'); - $message .= "\n\n"; - $message .= GETPOST('message'); - - // Coordonnées client - $message .= "\n\n"; - $message .= "==============================================\n"; - $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; - $message .= !empty($object->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; - $message .= !empty($object->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; - - // Build array to display recipient list - foreach ($internal_contacts as $key => $info_sendto) { - // altairis: avoid duplicate notifications - if ($info_sendto['id'] == $user->id) { - continue; - } - - if ($info_sendto['email'] != '') { - if(!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; - - //Contact type - $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; - $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); - } - } - $message .= "\n"; - // URL ticket - $url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; - - // altairis: make html link on url - $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '' . $object->track_id . '' . "\n"; - - // Add global email address recipient - // altairis: use new TICKET_NOTIFICATION_EMAIL_TO configuration variable - if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { - if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; - } - - // altairis: dont try to send email if no recipient - if (!empty($sendto)) { - $this->sendTicketMessageByEmail($subject, $message, '', $sendto); - } - } - - /* - * Email for externals users if not private - */ - if (empty($object->private)) { - // Retrieve email of all contacts (external) - $external_contacts = $object->getInfosTicketExternalContact(); - - // If no contact, get email from thirdparty - if (is_array($external_contacts) && count($external_contacts) === 0) { - if (!empty($object->fk_soc)) { - $object->fetch_thirdparty($object->fk_soc); - $array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id)); - $external_contacts = array_merge($external_contacts, $array_company); - } elseif (empty($object->fk_soc) && !empty($object->origin_email)) { - $array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id)); - $external_contacts = array_merge($external_contacts, $array_external); - } - } - - $sendto = array(); - if (is_array($external_contacts) && count($external_contacts) > 0) { - // altairis: get default subject for email to external contacts - $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - - $message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; - $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; - - // We put intro after - $message = GETPOST('message'); - $message .= "\n\n"; - - foreach ($external_contacts as $key => $info_sendto) { - // altairis: avoid duplicate emails to external contacts - if ($info_sendto['id'] == $user->contactid) { - continue; - } - - if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { - if(!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; - - $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; - $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); - } - } - - // If public interface is not enable, use link to internal page into mail - $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? - (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? - $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : - dol_buildpath('/public/ticket/view.php', 2) - ) : - dol_buildpath('/ticket/card.php', 2) - ) . '?track_id=' . $object->track_id; - $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; - - // Build final message - $message = $message_intro . $message; - - // Add signature - $message .= '
' . $message_signature; - - if (!empty($object->origin_email)) { - $sendto[] = $object->origin_email; - } - - if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); - if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; - } - - // altairis: Add global email address reciepient - if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { - if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; - } - - // altairis: dont try to send email when no recipient - if (!empty($sendto)) { - $this->sendTicketMessageByEmail($subject, $message, '', $sendto); - } - } - } - } - - $this->copyFilesForTicket(); - - // Set status to "answered" if not set yet, only for internal users - if ($object->fk_statut < 3 && !$user->societe_id) { - $object->setStatut(3); - } - - return 1; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - return -1; - } - } else { - setEventMessages($this->error, $this->errors, 'errors'); - return -1; - } - } - - /** - * Add new message on a ticket (public area) - * - * @param User $user User for action - * @param string $action Action string - * @return void - */ - private function newMessagePublic($user, &$action) - { - - global $mysoc, $conf, $langs; - - $object = new Ticket($this->db); - $error = 0; - $ret = $object->fetch('', '', GETPOST('track_id', 'alpha')); - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); - if ($ret < 0) { - $error++; - array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); - $action = ''; - } - - if (!GETPOST("message")) { - $error++; - array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message"))); - $action = 'add_message'; - } - - if (!$error) { - $object->message = (string) GETPOST("message"); - $id = $object->createTicketMessage($user); - if ($id <= 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - $action = 'add_message'; - } - - if (!$error && $id > 0) { - setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); - - // Retrieve internal contact datas - $internal_contacts = $object->getInfosTicketInternalContact(); - $sendto = array(); - if (is_array($internal_contacts) && count($internal_contacts) > 0) { - $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - - $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject); - $message .= "\n"; - $message .= GETPOST('message'); - $message .= "\n"; - - // Coordonnées client - if ($object->thirdparty->id > 0) { - $message .= "\n\n"; - $message .= "==============================================\n"; - $message .= $langs->trans('Thirparty') . " : " . $object->thirdparty->name; - $message .= !empty($object->thirdparty->town) ? $langs->trans('Town') . " : " . $object->thirdparty->town : ''; - $message .= "\n"; - $message .= !empty($object->thirdparty->phone) ? $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; - $message .= "\n"; - } - - // Build array to display recipient list - foreach ($internal_contacts as $key => $info_sendto) { - if ($info_sendto['email'] != '') { - $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; - } - - // Contact type - $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; - $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); - $message .= "\n"; - } - - // URL ticket - $url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; - $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $url_internal_ticket . "\n"; - - $message .= "\n\n"; - - $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; - - // Add global email address reciepient - if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_FROM, $sendto)) { - $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; - } - - $this->sendTicketMessageByEmail($subject, $message, '', $sendto); - } - - /* - * Email for externals users if not private - */ - - // Retrieve email of all contacts external - $external_contacts = $object->getInfosTicketExternalContact(); - $sendto = array(); - if (is_array($external_contacts) && count($external_contacts) > 0) { - $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - - $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject); - $message .= "\n"; - - $message .= GETPOST('message'); - $message .= "\n\n"; - - $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; - foreach ($external_contacts as $key => $info_sendto) { - if ($info_sendto['email'] != '') { - $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; - } - $recipient = ''; - $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; - $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); - } - - $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) . '?track_id=' . $object->track_id; - $message .= "\n\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . $url_public_ticket . "\n"; - - // Add signature - $message .= '\n\n' . $message_signature; - - if (!empty($object->origin_email) && !in_array($object->origin_email, $sendto)) { - $sendto[] = $object->origin_email; - } - if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) { - $sendto[] = $object->thirdparty->email; - } - $this->sendTicketMessageByEmail($subject, $message, '', $sendto); - } - - $this->copyFilesForTicket(); - - $url = 'view.php?action=view_ticket&track_id=' . $object->track_id; - header("Location: " . $url); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - setEventMessages($this->error, $this->errors, 'errors'); - } - } - /** * Fetch object * @@ -1405,53 +562,6 @@ class ActionsTicket } } - /** - * Copy files into ticket directory - * Used for files linked into messages - * - * @return void - */ - public function copyFilesForTicket() - { - global $conf, $object; - - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; - - $maxwidthsmall = 270; - $maxheightsmall = 150; - $maxwidthmini = 128; - $maxheightmini = 72; - - $formmail = new FormMail($this->db); - - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Copy files into ticket directory - $destdir = $conf->ticket->dir_output . '/' . $object->track_id; - - if (!dol_is_dir($destdir)) { - dol_mkdir($destdir); - } - foreach ($filename as $i => $val) { - $res = dol_move($filepath[$i], $destdir . '/' . $filename[$i]); - if (image_format_supported($destdir . '/' . $filename[$i]) == 1) { - // Create small thumbs for image (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($destdir . '/' . $filename[$i], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); - // Create mini thumbs for image (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($destdir . '/' . $filename[$i], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); - } - $formmail->remove_attached_files($i); - } - } - /** * Print html navbar with link to set ticket status * @@ -1490,7 +600,7 @@ class ActionsTicket $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; } - print ''; + print ''; print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]); print ''; print '
'; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 759360a8e84..0d0c6f2cb0d 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -25,8 +25,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . "/core/class/commonobject.class.php"; require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php'; -//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; -//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; +require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php'; /** @@ -66,7 +65,7 @@ class Ticket extends CommonObject /** - * @var string Hash to identify ticket + * @var string Hash to identify ticket publically */ public $track_id; @@ -327,11 +326,14 @@ class Ticket extends CommonObject global $conf, $langs; $error = 0; + // Clean parameters $this->datec = dol_now(); + if (empty($this->track_id)) $this->track_id = generate_random_id(16); // Check more parameters // If error, this->errors[] is filled $result = $this->verify(); + if ($result >= 0) { // Insert request $sql = "INSERT INTO " . MAIN_DB_PREFIX . "ticket("; @@ -2430,6 +2432,416 @@ class Ticket extends CommonObject } return false; } + + + /** + * Copy files into ticket directory + * Used for files linked into messages + * + * @return void + */ + public function copyFilesForTicket() + { + global $conf; + + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; + + $maxwidthsmall = 270; + $maxheightsmall = 150; + $maxwidthmini = 128; + $maxheightmini = 72; + + $formmail = new FormMail($this->db); + + $attachedfiles = $formmail->get_attached_files(); + + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Copy files into ticket directory + $destdir = $conf->ticket->dir_output . '/' . $this->ref; + + if (!dol_is_dir($destdir)) { + dol_mkdir($destdir); + } + foreach ($filename as $i => $val) { + $res = dol_move($filepath[$i], $destdir . '/' . $filename[$i]); + if (image_format_supported($destdir . '/' . $filename[$i]) == 1) { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($destdir . '/' . $filename[$i], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($destdir . '/' . $filename[$i], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } + $formmail->remove_attached_files($i); + } + } + + + /** + * Add new message on a ticket (private area) + * + * @param User $user User for action + * @param string $action Action string + * @return int + */ + public function newMessage($user, &$action) + { + global $mysoc, $conf, $langs; + + if (!class_exists('Contact')) { + include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + } + + $contactstatic = new Contact($this->db); + $object = new Ticket($this->db); + + $error = 0; + + $ret = $object->fetch('', '', GETPOST('track_id', 'alpha')); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); + if ($ret < 0) { + $error++; + array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); + $action = ''; + } + + if (!GETPOST("message")) { + $error++; + array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message"))); + $action = 'add_message'; + } + + if (!$error) { + $object->message = GETPOST("message"); + $object->private = GETPOST("private_message"); + $send_email = GETPOST('send_email', 'int'); + + $id = $object->createTicketMessage($user); + if ($id <= 0) { + $error++; + $this->errors = $object->error; + $this->errors = $object->errors; + $action = 'add_message'; + } + + if (!$error && $id > 0) { + setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); + + /* + * Send email to linked contacts + */ + if ($send_email > 0) { + // Retrieve internal contact datas + $internal_contacts = $object->getInfosTicketInternalContact(); + $sendto = array(); + if (is_array($internal_contacts) && count($internal_contacts) > 0) { + // altairis: set default subject + $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; + $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); + + $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id); + $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; + + $message = $langs->trans('TicketMessageMailIntroText'); + $message .= "\n\n"; + $message .= GETPOST('message'); + + // Coordonnées client + $message .= "\n\n"; + $message .= "==============================================\n"; + $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; + $message .= !empty($object->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; + $message .= !empty($object->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; + + // Build array to display recipient list + foreach ($internal_contacts as $key => $info_sendto) { + // altairis: avoid duplicate notifications + if ($info_sendto['id'] == $user->id) { + continue; + } + + if ($info_sendto['email'] != '') { + if(!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; + + //Contact type + $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; + $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); + } + } + $message .= "\n"; + // URL ticket + $url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; + + // altairis: make html link on url + $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '' . $object->track_id . '' . "\n"; + + // Add global email address recipient + // altairis: use new TICKET_NOTIFICATION_EMAIL_TO configuration variable + if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { + if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + } + + // altairis: dont try to send email if no recipient + if (!empty($sendto)) { + $this->sendTicketMessageByEmail($subject, $message, '', $sendto); + } + } + + /* + * Email for externals users if not private + */ + if (empty($object->private)) { + // Retrieve email of all contacts (external) + $external_contacts = $object->getInfosTicketExternalContact(); + + // If no contact, get email from thirdparty + if (is_array($external_contacts) && count($external_contacts) === 0) { + if (!empty($object->fk_soc)) { + $object->fetch_thirdparty($object->fk_soc); + $array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id)); + $external_contacts = array_merge($external_contacts, $array_company); + } elseif (empty($object->fk_soc) && !empty($object->origin_email)) { + $array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id)); + $external_contacts = array_merge($external_contacts, $array_external); + } + } + + $sendto = array(); + if (is_array($external_contacts) && count($external_contacts) > 0) { + // altairis: get default subject for email to external contacts + $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; + $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); + + $message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO; + $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; + + // We put intro after + $message = GETPOST('message'); + $message .= "\n\n"; + + foreach ($external_contacts as $key => $info_sendto) { + // altairis: avoid duplicate emails to external contacts + if ($info_sendto['id'] == $user->contactid) { + continue; + } + + if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { + if(!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; + + $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; + $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); + } + } + + // If public interface is not enable, use link to internal page into mail + $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? + (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? + $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : + dol_buildpath('/public/ticket/view.php', 2) + ) : + dol_buildpath('/ticket/card.php', 2) + ) . '?track_id=' . $object->track_id; + $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; + + // Build final message + $message = $message_intro . $message; + + // Add signature + $message .= '
' . $message_signature; + + if (!empty($object->origin_email)) { + $sendto[] = $object->origin_email; + } + + if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); + if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; + } + + // altairis: Add global email address reciepient + if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { + if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + } + + // altairis: dont try to send email when no recipient + if (!empty($sendto)) { + $this->sendTicketMessageByEmail($subject, $message, '', $sendto); + } + } + } + } + + $object->copyFilesForTicket(); + + // Set status to "answered" if not set yet, only for internal users + if ($object->fk_statut < 3 && !$user->societe_id) { + $object->setStatut(3); + } + + return 1; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + return -1; + } + } else { + setEventMessages($this->error, $this->errors, 'errors'); + return -1; + } + } + + /** + * Add new message on a ticket (public area) + * + * @param User $user User for action + * @param string $action Action string + * @return void + */ + public function newMessagePublic($user, &$action) + { + global $mysoc, $conf, $langs; + + $object = new Ticket($this->db); + + $error = 0; + $ret = $object->fetch('', '', GETPOST('track_id', 'alpha')); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); + if ($ret < 0) { + $error++; + array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); + $action = ''; + } + + if (!GETPOST("message")) { + $error++; + array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message"))); + $action = 'add_message'; + } + + if (!$error) { + $object->message = (string) GETPOST("message"); + $id = $object->createTicketMessage($user); + if ($id <= 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + $action = 'add_message'; + } + + if (!$error && $id > 0) { + setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); + + // Retrieve internal contact datas + $internal_contacts = $object->getInfosTicketInternalContact(); + $sendto = array(); + if (is_array($internal_contacts) && count($internal_contacts) > 0) { + $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); + + $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject); + $message .= "\n"; + $message .= GETPOST('message'); + $message .= "\n"; + + // Coordonnées client + if ($object->thirdparty->id > 0) { + $message .= "\n\n"; + $message .= "==============================================\n"; + $message .= $langs->trans('Thirparty') . " : " . $object->thirdparty->name; + $message .= !empty($object->thirdparty->town) ? $langs->trans('Town') . " : " . $object->thirdparty->town : ''; + $message .= "\n"; + $message .= !empty($object->thirdparty->phone) ? $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; + $message .= "\n"; + } + + // Build array to display recipient list + foreach ($internal_contacts as $key => $info_sendto) { + if ($info_sendto['email'] != '') { + $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; + } + + // Contact type + $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; + $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); + $message .= "\n"; + } + + // URL ticket + $url_internal_ticket = dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id; + $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $url_internal_ticket . "\n"; + + $message .= "\n\n"; + + $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; + + // Add global email address reciepient + if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_FROM, $sendto)) { + $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; + } + + $this->sendTicketMessageByEmail($subject, $message, '', $sendto); + } + + /* + * Email for externals users if not private + */ + + // Retrieve email of all contacts external + $external_contacts = $object->getInfosTicketExternalContact(); + $sendto = array(); + if (is_array($external_contacts) && count($external_contacts) > 0) { + $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); + + $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject); + $message .= "\n"; + + $message .= GETPOST('message'); + $message .= "\n\n"; + + $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; + foreach ($external_contacts as $key => $info_sendto) { + if ($info_sendto['email'] != '') { + $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; + } + $recipient = ''; + $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; + $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); + } + + $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) . '?track_id=' . $object->track_id; + $message .= "\n\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . $url_public_ticket . "\n"; + + // Add signature + $message .= '\n\n' . $message_signature; + + if (!empty($object->origin_email) && !in_array($object->origin_email, $sendto)) { + $sendto[] = $object->origin_email; + } + if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) { + $sendto[] = $object->thirdparty->email; + } + $this->sendTicketMessageByEmail($subject, $message, '', $sendto); + } + + $object->copyFilesForTicket(); + + $url = 'view.php?action=view_ticket&track_id=' . $object->track_id; + header("Location: " . $url); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } else { + setEventMessages($this->error, $this->errors, 'errors'); + } + } } diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 21c1087f276..f38a5abd910 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -50,9 +50,6 @@ $source = GETPOST('source', 'alpha'); $ligne = GETPOST('ligne', 'int'); $lineid = GETPOST('lineid', 'int'); - - - // Protection if external user if ($user->societe_id > 0) { $socid = $user->societe_id; @@ -64,8 +61,9 @@ $url_page_current = dol_buildpath('/ticket/contact.php', 1); $object = new Ticket($db); + /* - * Ajout d'un nouveau contact + * Actions */ if ($action == 'addcontact' && $user->rights->ticket->write) { @@ -110,9 +108,12 @@ if ($action == 'deletecontact' && $user->rights->ticket->write) { } } + + /* * View */ + $help_url = 'FR:DocumentationModuleTicket'; llxHeader('', $langs->trans("TicketContacts"), $help_url); @@ -121,12 +122,6 @@ $formcompany = new FormCompany($db); $contactstatic = new Contact($db); $userstatic = new User($db); -/* *************************************************************************** */ -/* */ -/* Mode vue et edition */ -/* */ -/* *************************************************************************** */ - if ($id > 0 || !empty($track_id) || !empty($ref)) { if ($object->fetch($id, $ref, $track_id) > 0) { @@ -146,7 +141,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $head = ticket_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("Ticket"), 0, 'ticket'); + dol_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticket'); $morehtmlref ='
'; $morehtmlref.= $object->subject; diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index b02b6ee07a7..16fabc6943c 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -61,15 +61,10 @@ if (! $sortfield) $sortfield="position_name"; $object = new Ticket($db); $result = $object->fetch($id, $ref, $track_id); -// to match document rules and compatibility -$old_ref = $object->ref; -$object->ref = $object->track_id; - - if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - $upload_dir = $conf->ticket->dir_output . "/" . dol_sanitizeFileName($object->track_id); + $upload_dir = $conf->ticket->dir_output . "/" . dol_sanitizeFileName($object->ref); } @@ -79,8 +74,6 @@ if ($result < 0) { include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; -$object->ref = $old_ref; - /* @@ -193,7 +186,7 @@ if ($object->id) $totalsize += $file['size']; } - $object->ref = $object->track_id; // For compatibility we use track ID for directory + //$object->ref = $object->track_id; // For compatibility we use track ID for directory $modulepart = 'ticket'; $permission = $user->rights->ticket->write; $permtoedit = $user->rights->ticket->write; From bb4da33fac2744fb5f67d93a655cc563270460cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 11:49:43 +0200 Subject: [PATCH 02/16] Add picto for BOM --- htdocs/theme/eldy/img/object_bom.png | Bin 0 -> 548 bytes htdocs/theme/md/img/object_bom.png | Bin 0 -> 548 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/theme/eldy/img/object_bom.png create mode 100644 htdocs/theme/md/img/object_bom.png diff --git a/htdocs/theme/eldy/img/object_bom.png b/htdocs/theme/eldy/img/object_bom.png new file mode 100644 index 0000000000000000000000000000000000000000..38b59646d710dfac4f94e01bbf41bb6b1779c0c6 GIT binary patch literal 548 zcmV+<0^9wGP)NCbZ?_my9^sP^Lq==>fRY)$Zp?_lD zm4N3MYAVYy+g(Qz_l6<+!_ZICIQp>xHv%7>!@AUfkS5^?d@B=4{3G}lxxXF++Oh+gwij(rEZ`+=bs!~^1 zJ=C%giU~|D3(2Rz|4_O4PGRIUz|zVW@yXQN-wZ(zYl%!YLVY0J1 mN5A$LDKQhLw=ZjNO#cI4PwLNUR3Co;0000NCbZ?_my9^sP^Lq==>fRY)$Zp?_lD zm4N3MYAVYy+g(Qz_l6<+!_ZICIQp>xHv%7>!@AUfkS5^?d@B=4{3G}lxxXF++Oh+gwij(rEZ`+=bs!~^1 zJ=C%giU~|D3(2Rz|4_O4PGRIUz|zVW@yXQN-wZ(zYl%!YLVY0J1 mN5A$LDKQhLw=ZjNO#cI4PwLNUR3Co;0000 Date: Wed, 10 Apr 2019 12:35:27 +0200 Subject: [PATCH 03/16] Fix debug ticket module --- htdocs/ticket/class/ticketstats.class.php | 6 +++--- htdocs/ticket/stats/index.php | 17 +++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 2f2e04baba9..469d44bc6d5 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -63,13 +63,13 @@ class TicketStats extends Stats $this->where = " fk_statut > 0"; $this->where .= " AND entity = " . $conf->entity; - if ($this->socid) { + if ($this->socid > 0) { $this->where .= " AND fk_soc = " . $this->socid; } if (is_array($this->userid) && count($this->userid) > 0) { - $this->where .= ' AND fk_user IN (' . join(',', $this->userid) . ')'; + $this->where .= ' AND fk_user_create IN (' . join(',', $this->userid) . ')'; } elseif ($this->userid > 0) { - $this->where .= ' AND fk_user = ' . $this->userid; + $this->where .= ' AND fk_user_create = ' . $this->userid; } } diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 15f3a3cb897..de4ad035faf 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -24,6 +24,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticketstats.class.php'; +require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); @@ -57,7 +58,7 @@ $langs->loadLangs(array('orders', 'companies', 'other', 'tickets')); */ $form=new Form($db); -//$formticket=new FormTicket($db); +$object=new Ticket($db); $title=$langs->trans("Statistics"); $dir=$conf->ticket->dir_temp; @@ -69,7 +70,7 @@ print load_fiche_titre($title, '', 'title_ticket.png'); dol_mkdir($dir); $stats = new TicketStats($db, $socid, ($userid>0?$userid:0)); -if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND c.fk_statut IN ('.$db->escape($object_status).')'; +if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND fk_statut IN ('.$db->escape($object_status).')'; // Build graphic number of object @@ -242,16 +243,8 @@ print '
'.$langs->trans("CreatedBy").' print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); // Status print '
'.$langs->trans("Status").''; -$liststatus=array( - Ticket::STATUS_NOT_READ=>$langs->trans("StatusNotRead"), - Ticket::STATUS_READ=>$langs->trans("StatusRead"), - Ticket::STATUS_ASSIGNED=>$langs->trans("StatusAssigned"), - Ticket::STATUS_IN_PROGRESS=>$langs->trans("StatusInProgress"), - Ticket::STATUS_ANSWERED=>$langs->trans("StatusAnswered"), - Ticket::STATUS_CLOSED=>$langs->trans("StatusClosed"), - Ticket::STATUS_WAITING=>$langs->trans("StatusWaiting") - ); -print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); +$liststatus = $object->fields['fk_statut']['arrayofkeyval']; +print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1); print '
'.$langs->trans("Year").''; From ed003914283b343b39998d48b59b14f9e651ba23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 12:43:26 +0200 Subject: [PATCH 04/16] Fix debug ticket module --- htdocs/ticket/list.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index eb74d91f22e..fe6ff269087 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -216,7 +216,7 @@ else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { - if ($key == 'fk_statut') + if ($key == 'fk_statut') { $tmpstatus=''; if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'0', '1', '3', '4', '5', '6'"; @@ -225,8 +225,13 @@ foreach($search as $key => $val) elseif (is_array($search[$key]) && count($search[$key])) $sql.=natural_search($key, join(',', $search[$key]), 2); continue; } + if ($key == 'fk_user_assign') + { + if ($search[$key] > 0) $sql.=natural_search($key, $search[$key], 2); + continue; + } $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'fk_statut')?2:$mode_search)); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], $mode_search); } if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_fk_soc) $sql.= natural_search('fk_soc', $search_fk_soc, 2); @@ -244,22 +249,6 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -/* If a group by is required -$sql.= " GROUP BY " -foreach($object->fields as $key => $val) -{ - $sql.='t.'.$key.', '; -} -// Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/','', $sql); -*/ - $sql.=$db->order($sortfield, $sortorder); // Count total nb of records From 1f6f6f6edb32817ae0ff2d22f4b156c1a5418bb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 13:21:06 +0200 Subject: [PATCH 05/16] Track action close for ticket --- .../interface_50_modAgenda_ActionsAuto.class.php | 2 +- htdocs/install/mysql/data/llx_c_action_trigger.sql | 3 ++- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 3 +++ htdocs/langs/en_US/agenda.lang | 1 + htdocs/langs/en_US/ticket.lang | 4 ++-- htdocs/ticket/card.php | 9 ++++++--- htdocs/ticket/class/ticket.class.php | 9 +++++---- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 095cd59ff55..0f219330669 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -786,7 +786,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // TODO Merge all previous cases into this generic one else // $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ... { - // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function) + // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). Key can be set in agenda setup if defined into c_action_trigger // Load translation files required by the page $langs->loadLangs(array("agenda","other")); diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index d8123d3ca8f..636a7fa227c 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -109,7 +109,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_DELETE','Project deleted','Executed when a project is deleted','project',143); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CREATE','Ticket created','Executed when a ticket is created','ticket',161); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_MODIFY','Ticket modified','Executed when a ticket is modified','ticket',163); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',164); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',164); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',165); -- actions not enabled by default (no constant created for that) when we enable module agenda insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',23); diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 0f2d1a66f86..8fbaf7a5669 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -280,3 +280,6 @@ ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN datelastok datetime; DELETE FROM llx_const WHERE name = 'THEME_ELDY_USE_HOVER' AND value = '0'; DELETE FROM llx_const WHERE name = 'THEME_ELDY_USE_CHECKED' AND value = '0'; + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',164); + diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index d4cce020d00..b928554b328 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -95,6 +95,7 @@ PROJECT_MODIFYInDolibarr=Project %s modified PROJECT_DELETEInDolibarr=Project %s deleted TICKET_CREATEInDolibarr=Ticket %s created TICKET_MODIFYInDolibarr=Ticket %s modified +TICKET_CLOSEInDolibarr=Ticket %s closed TICKET_DELETEInDolibarr=Ticket %s deleted ##### End agenda events ##### AgendaModelModule=Document templates for event diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 3759a9c881b..235abd885b6 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -152,7 +152,7 @@ TicketCategory=Analytic code SeeTicket=See ticket TicketMarkedAsRead=Ticket has been marked as read TicketReadOn=Read on -TicketCloseOn=Clotured on +TicketCloseOn=Closing date MarkAsRead=Mark ticket as read TicketHistory=Ticket history AssignUser=Assign to user @@ -253,7 +253,7 @@ TicketEmailPleaseDoNotReplyToThisEmail=Please do not reply directly to this emai TicketPublicInfoCreateTicket=This form allows you to record a support ticket in our management system. TicketPublicPleaseBeAccuratelyDescribe=Please accurately describe the problem. Provide the most information possible to allow us to correctly identify your request. TicketPublicMsgViewLogIn=Please enter ticket tracking ID -TicketTrackId=Tracking ID +TicketTrackId=Public Tracking ID OneOfTicketTrackId=One of yours tracking ID ErrorTicketNotFound=Ticket with tracking ID %s not found! Subject=Subject diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 5aa09bee982..99c7ba15279 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -390,9 +390,11 @@ if ($action == "new_public_message" && GETPOST('btn_add_message')) { $object->newMessagePublic($user, $action); } -if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { +if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) +{ $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - if ($object->close()) { + + if ($object->close($user)) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs)); @@ -1213,7 +1215,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $action = 'presend'; } - if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'delete' || $action == 'edit_message_init') + //if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'delete' || $action == 'edit_message_init') + if ($action != 'add_message') { print '
'; print ''; // ancre diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 0d0c6f2cb0d..1aebd879fc2 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1751,11 +1751,12 @@ class Ticket extends CommonObject /** * Close a ticket * - * @return int <0 if KO, >0 if OK + * @param User $user User that close + * @return int <0 if KO, >0 if OK */ - public function close() + public function close(User $user) { - global $conf, $user, $langs; + global $conf, $langs; if ($this->fk_statut != 9) { // not closed $this->db->begin(); @@ -1776,7 +1777,7 @@ class Ticket extends CommonObject foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { $fichinter = new Fichinter($this->db); $fichinter->fetch($fichinter_id); - if($fichinter->statut == 0) { + if ($fichinter->statut == 0) { $result = $fichinter->setValid($user); if (!$result) { $this->errors[] = $fichinter->error; From 26594fab98ff175e4e01badc075b4f92ab43aac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 15:11:38 +0200 Subject: [PATCH 06/16] Debug module ticket --- htdocs/admin/ticket.php | 2 +- htdocs/admin/ticket_extrafields.php | 2 +- htdocs/admin/ticket_public.php | 8 ++-- htdocs/admin/user.php | 4 +- htdocs/core/ajax/selectsearchbox.php | 4 ++ htdocs/core/lib/ticket.lib.php | 35 ++++++++++------- htdocs/core/modules/modTicket.class.php | 2 +- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/ticket.lang | 5 ++- htdocs/main.inc.php | 2 +- .../modulebuilder/template/myobject_list.php | 4 +- htdocs/public/ticket/list.php | 38 ++++++++++++------- htdocs/ticket/class/ticket.class.php | 10 ++--- htdocs/ticket/list.php | 12 +++--- 14 files changed, 75 insertions(+), 54 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index def9a30fc8d..f9e985cec94 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -181,7 +181,7 @@ $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index f63af3d2a82..3c65fcf693e 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -66,7 +66,7 @@ $help_url = "FR:Module_Ticket"; $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans("TicketSetup"), $linkback, 'title_setup'); $head = ticketAdminPrepareHead(); diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 939a357999b..1bcff705aef 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -103,7 +103,7 @@ if ($action == 'setvar') { } $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($mail_signature)) { + if (!empty($url_interface)) { $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); } else { $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); @@ -113,7 +113,7 @@ if ($action == 'setvar') { } $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); - if (!empty($mail_signature)) { + if (!empty($topic_interface)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); } else { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); @@ -123,7 +123,7 @@ if ($action == 'setvar') { } $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); - if (!empty($mail_signature)) { + if (!empty($text_home)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); } else { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); @@ -208,7 +208,7 @@ $page_name = "TicketSetup"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader -$linkback = '' . $langs->trans("BackToModuleList") . ''; +$linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 6f0003e3be5..f73c3d4ecf3 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -137,7 +137,7 @@ $form = new Form($db); $help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; llxHeader('', $langs->trans("UsersSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); @@ -183,8 +183,6 @@ print '
'; $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); -$form=new Form($db); - // Defini tableau def des modeles $def = array(); $sql = "SELECT nom"; diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index c8610224cb7..34dd24eef97 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -136,6 +136,10 @@ if (! empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOL { $arrayresult['searchintoleaves']=array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); } +if (! empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) +{ + $arrayresult['searchintotickets']=array('position'=>220, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); +} /* Do we really need this. We already have a select for users, and we should be able to filter into user list on employee flag diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index bd449cc91e9..c5791e5c89e 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -158,23 +158,30 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ global $user, $conf, $langs, $mysoc; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers + print ''; - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { - // Print logo - $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; + if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { + print '
'; + // Print logo + if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) + { + $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); - $width = 128; - } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { - $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; - } - print '
'; - print 'Logo
'; - print '' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ''; + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); + $width = 128; + } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { + $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; + } + print 'Logo
'; + } + if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) + { + print '' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ''; + } print '

'; } diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 3c1c6c43068..fdc92e70602 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -94,7 +94,7 @@ class modTicket extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->depends = array('modAgenda'); // List of module class names as string that must be enabled if this module is enabled $this->requiredby = array(); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5,4); // Minimum version of PHP required by module diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ba6a65c7b30..c739f8d5624 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -942,6 +942,7 @@ SearchIntoContracts=Contracts SearchIntoCustomerShipments=Customer shipments SearchIntoExpenseReports=Expense reports SearchIntoLeaves=Leave +SearchIntoTickets=Tickets CommentLink=Comments NbComments=Number of comments CommentPage=Comments space diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 235abd885b6..83786c55a87 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -124,7 +124,7 @@ TicketsAutoAssignTicketHelp=When creating a ticket, the user can be automaticall TicketNumberingModules=Tickets numbering module TicketNotifyTiersAtCreation=Notify third party at creation TicketGroup=Group -TicketsDisableCustomerEmail=Alsways disable emails when a ticket is created from public interface +TicketsDisableCustomerEmail=Always disable emails when a ticket is created from public interface # # Index & list page # @@ -254,7 +254,7 @@ TicketPublicInfoCreateTicket=This form allows you to record a support ticket in TicketPublicPleaseBeAccuratelyDescribe=Please accurately describe the problem. Provide the most information possible to allow us to correctly identify your request. TicketPublicMsgViewLogIn=Please enter ticket tracking ID TicketTrackId=Public Tracking ID -OneOfTicketTrackId=One of yours tracking ID +OneOfTicketTrackId=One of your tracking ID ErrorTicketNotFound=Ticket with tracking ID %s not found! Subject=Subject ViewTicket=View ticket @@ -264,6 +264,7 @@ TicketNewEmailSubjectAdmin=New ticket created TicketNewEmailBodyAdmin=

Ticket has just been created with ID #%s, see information:

SeeThisTicketIntomanagementInterface=See ticket in management interface TicketPublicInterfaceForbidden=The public interface for the tickets was not enabled +ErrorEmailOrTrackingInvalid=Bad value for tracking ID or email # notifications TicketNotificationEmailSubject=Ticket %s updated diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1b16fd77239..6355c7e3e7f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1903,11 +1903,11 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ if (! is_object($form)) $form=new Form($db); $selected=-1; $usedbyinclude=1; + $arrayresult=null; include_once DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { - //$searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); $searchform.=$form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY)?1:0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); } else diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 85605e2a977..8cae415c6e1 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -370,10 +370,10 @@ $objecttmp=new MyObject($db); $trackid='xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) +if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 73b691500fd..c341d32cf3e 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -58,7 +58,7 @@ if (isset($_SESSION['email_customer'])) { $email = $_SESSION['email_customer']; } -$object = new ActionsTicket($db); +$object = new Ticket($db); @@ -83,7 +83,7 @@ if ($action == "view_ticketlist") { } else { if (!isValidEmail($email)) { $error++; - array_push($object->errors, $langs->trans("ErrorEmailInvalid")); + array_push($object->errors, $langs->trans("ErrorEmailOrTrackingInvalid")); $action = ''; } } @@ -91,9 +91,9 @@ if ($action == "view_ticketlist") { if (!$error) { $ret = $object->fetch('', '', $track_id); - if ($ret && $object->dao->id > 0) { + if ($ret && $object->id > 0) { // vérifie si l'adresse email est bien dans les contacts du ticket - $contacts = $object->dao->liste_contact(-1, 'external'); + $contacts = $object->liste_contact(-1, 'external'); foreach ($contacts as $contact) { if ($contact['email'] == $email) { $display_ticket_list = true; @@ -104,12 +104,24 @@ if ($action == "view_ticketlist") { $display_ticket_list = false; } } - - if ($object->dao->fk_soc > 0) { - $object->dao->fetch_thirdparty(); + if ($object->fk_soc > 0) { + $object->fetch_thirdparty(); + if ($email == $object->thirdparty->email) { + $display_ticket_list = true; + $_SESSION['email_customer'] = $email; + $_SESSION['track_id_customer'] = $track_id; + } } - - if ($email == $object->dao->origin_email || $email == $object->dao->thirdparty->email) { + if ($object->fk_user_create > 0) { + $tmpuser=new User($db); + $tmpuser->fetch($object->fk_user_create); + if ($email == $tmpuser->email) { + $display_ticket_list = true; + $_SESSION['email_customer'] = $email; + $_SESSION['track_id_customer'] = $track_id; + } + } + if ($email == $object->origin_email) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -127,7 +139,7 @@ if ($action == "view_ticketlist") { } } -$object->doActions($action); +//$object->doActions($action); @@ -138,10 +150,11 @@ $object->doActions($action); $form = new Form($db); $user_assign = new User($db); $user_create = new User($db); -$formticket = new FormTicket($db); +$formTicket = new FormTicket($db); $arrayofjs = array(); $arrayofcss = array('/ticket/css/styles.css.php'); + llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) { @@ -154,7 +167,6 @@ print '
'; if ($action == "view_ticketlist") { - if ($display_ticket_list) { // Filters $search_fk_status = GETPOST("search_fk_status", 'alpha'); @@ -266,7 +278,6 @@ if ($action == "view_ticketlist") if (!$sortfield) { $sortfield = 't.datec'; } - if (!$sortorder) { $sortorder = 'DESC'; } @@ -430,7 +441,6 @@ if ($action == "view_ticketlist") /* * Filter bar */ - $formTicket = new FormTicket($db); print '
'; - $selected = ($search_fk_status != "non_closed" ? $search_fk_status : ''); - //$object->printSelectStatus($selected); - print ''; print ''; @@ -516,6 +504,14 @@ if ($action == "view_ticketlist") } } + // Status + if (!empty($arrayfields['t.fk_statut']['checked'])) { + print ''; + $selected = ($search_fk_status != "non_closed" ? $search_fk_status : ''); + //$object->printSelectStatus($selected); + print ''; print ''; print ''; @@ -547,21 +543,13 @@ if ($action == "view_ticketlist") print ''; print $obj->ref; print ''; - $object->fk_statut = $obj->fk_statut; - print $object->getLibStatut(2); - print ''; @@ -645,7 +633,17 @@ if ($action == "view_ticketlist") } } } + + // Statut + if (!empty($arrayfields['t.fk_statut']['checked'])) { + print ''; + $object->fk_statut = $obj->fk_statut; + print $object->getLibStatut(2); + print '
'; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index fdc92e70602..5aef264a11e 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -285,7 +285,6 @@ class modTicket extends DolibarrModules array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1);", "ignoreerror" => 1), array("sql" => "insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1);", "ignoreerror" => 1), - array("sql" => "insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values ('','TICKETMESSAGE_SENTBYMAIL','Send email for ticket','Executed when a response is made on a ticket','ticket','');", "ignoreerror" => 1), ); return $this->_init($sql, $options); diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 493c7b65295..3eaba0a6e1d 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -103,7 +103,8 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel } else { - $colspan=9; + $colspan=13; + if (! empty($conf->multicompany->enabled)) $colspan++; print ''; print '\n"; $grouptemp = new UserGroup($db); @@ -212,7 +213,8 @@ if ($resql) } print ''; print ''; - print ''; + print ''; + print ''; print "\n"; $i++; } From 4f2a3d6bdd325674542a3165481e6fc286c22928 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 16:23:16 +0200 Subject: [PATCH 10/16] Debug ticket module --- .../class/emailcollector.class.php | 6 +-- htdocs/langs/en_US/other.lang | 7 +-- htdocs/ticket/card.php | 44 ++++++++----------- htdocs/ticket/class/actions_ticket.class.php | 13 +++--- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 4a8836b34f7..3e2e2126ff2 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1265,7 +1265,6 @@ class EmailCollector extends CommonObject } - // Do operations foreach($this->actions as $operation) { @@ -1476,7 +1475,7 @@ class EmailCollector extends CommonObject //$actioncomm->extraparams = $extraparams; // Overwrite values with values extracted from source email - $errorforthisaction = $this->overwritePropertiesOfObject($actioncommn, $operation['actionparam'], $messagetext, $subject, $header); + $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); if ($errorforthisaction) { @@ -1610,10 +1609,11 @@ class EmailCollector extends CommonObject $descriptionfull = dol_concatdesc($descriptionfull, $header); $tickettocreate->title = $subject; + $tickettocreate->message = $description; $tickettocreate->type_code = 0; $tickettocreate->category_code = 0; $tickettocreate->severity_code = 0; - $tickettocreate->origin_email = $fromstring; + $tickettocreate->origin_email = $from; $tickettocreate->fk_user_create = $user->id; $tickettocreate->entity = $conf->entity; $tickettocreate->datec = $date; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index d85d7973305..0ad4c5dfc83 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -246,9 +246,10 @@ YourPasswordHasBeenReset=Your password has been reset successfully ApplicantIpAddress=IP address of applicant SMSSentTo=SMS sent to %s MissingIds=Missing ids -ThirdPartyCreatedByEmailCollector=Third party created by email collector from email ID %s -ContactCreatedByEmailCollector=Contact/address created by email collector from email ID %s -ProjectCreatedByEmailCollector=Project created by email collector from email ID %s +ThirdPartyCreatedByEmailCollector=Third party created by email collector from email MSGID %s +ContactCreatedByEmailCollector=Contact/address created by email collector from email MSGID %s +ProjectCreatedByEmailCollector=Project created by email collector from email MSGID %s +TicketCreatedByEmailCollector=Ticket created by email collector from email MSGID %s ##### Export ##### ExportsArea=Exports area diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 99c7ba15279..44abe008d34 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -644,7 +644,6 @@ if ($action == 'create' || $action == 'presend') if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'add_message' || $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) { // or for unauthorized internals users @@ -959,12 +958,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $actionobject->viewTicketOriginalMessage($user, $action, $object); - /*************************************************** - * - * Classification and actions on ticket - * - ***************************************************/ - + // Classification of ticket print '
'; print ''; print ''; @@ -991,19 +985,14 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print ''; if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { print '
'; + // Type print ''; print ''; - print ''; - print ''; - print ''; + // Group print ''; print ''; print ''; + // Severity + print ''; + print ''; + print ''; } else { // Type print ''; - - // Severity - print ''; - // Group print ''; + // Severity + print ''; } print '
'; diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 636a7fa227c..c1f7ec24ef1 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -110,7 +110,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CREATE','Ticket created','Executed when a ticket is created','ticket',161); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_MODIFY','Ticket modified','Executed when a ticket is modified','ticket',163); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',164); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',165); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_SENTBYMAIL','Ticket message sent by email','Executed when a message is sent from the ticket record','ticket',165); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',166); -- actions not enabled by default (no constant created for that) when we enable module agenda insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',23); diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 8fbaf7a5669..e831eccb4ce 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -282,4 +282,5 @@ DELETE FROM llx_const WHERE name = 'THEME_ELDY_USE_HOVER' AND value = '0'; DELETE FROM llx_const WHERE name = 'THEME_ELDY_USE_CHECKED' AND value = '0'; insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CLOSE','Ticket closed','Executed when a ticket is closed','ticket',164); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_SENTBYMAIL','Ticket message sent by email','Executed when a message is sent from the ticket record','ticket',166); diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 83786c55a87..8265df1b370 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -53,7 +53,7 @@ TypeContact_ticket_external_SUPPORTCLI=Customer contact / incident tracking TypeContact_ticket_external_CONTRIBUTOR=External contributor OriginEmail=Email source -Notify_TICKETMESSAGE_SENTBYMAIL=Send ticket answer by email +Notify_TICKET_SENTBYMAIL=Send ticket message by email # Status NotRead=Not read From 05c14e4f2f75c545d0046cc848fa00465d5696b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 15:54:29 +0200 Subject: [PATCH 09/16] Look and feel v10 --- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/admin/tools/dolibarr_import.php | 2 +- htdocs/user/group/list.php | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index fb9eababad8..8d753840ad7 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -113,7 +113,7 @@ jQuery(document).ready(function() { print load_fiche_titre($langs->trans("Backup"), '', 'title_setup'); //print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup'); -print '
'; +print '
'; print $langs->trans("BackupDesc", DOL_DATA_ROOT); print '
'; print '
'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index b30494cc1c3..f5afa6c9bbd 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -67,7 +67,7 @@ jQuery(document).ready(function() { print load_fiche_titre($langs->trans("Restore"), '', 'title_setup'); -print '
'; +print '
'; print $langs->trans("RestoreDesc", DOL_DATA_ROOT); print '
'; print '
'; diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index ce1caf8762a..0651e7aeff8 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -184,6 +184,7 @@ if ($resql) print_liste_field_titre("NbOfUsers", $_SERVER["PHP_SELF"], "nb", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("NbOfPermissions", $_SERVER["PHP_SELF"], "nbpermissions", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", $param, "", '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("", $_SERVER["PHP_SELF"]); print "
'.$obj->nb.''.$obj->nbpermissions.''.dol_print_date($db->jdate($obj->datec), "dayhour").''.dol_print_date($db->jdate($obj->datec), "dayhour").'
'; print $langs->trans('TicketChangeType'); print ''; print $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2); print '
'; - print $langs->trans('TicketChangeSeverity'); - print ''; - print $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); - print '
'; print $langs->trans('TicketChangeCategory'); @@ -1011,6 +1000,14 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2); print '
'; + print $langs->trans('TicketChangeSeverity'); + print ''; + print $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); + print '
' . $langs->trans("Type") . ''; @@ -1019,15 +1016,6 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ print '
' . $langs->trans("TicketSeverity") . ''; - print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); - /*if ($user->admin && !$noadmininfo) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - }*/ - print '
' . $langs->trans("TicketGroup") . ''; print $langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'); @@ -1035,6 +1023,13 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ print '
' . $langs->trans("TicketSeverity") . ''; + print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); + /*if ($user->admin && !$noadmininfo) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + }*/ + print '
'; // End table actions @@ -1215,7 +1210,6 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $action = 'presend'; } - //if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'delete' || $action == 'edit_message_init') if ($action != 'add_message') { print '
'; @@ -1236,7 +1230,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print '
'; print '
'; } - elseif ($action == 'add_message') + else { $action='new_message'; $modelmail='ticket_send'; diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index f84426c03f9..ccf2de50971 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -286,6 +286,8 @@ class ActionsTicket public function viewTicketOriginalMessage($user, $action, $object) { global $langs; + + print ''."\n"; if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { // MESSAGE @@ -326,14 +328,15 @@ class ActionsTicket //print '
' . $object->message . '
'; } + if ($user->rights->ticket->manage && $action == 'edit_message_init') { + print '
'; + print ' '; + print ' '; + print '
'; + } print ''; print ''; print ''; - if ($user->rights->ticket->manage && $action == 'edit_message_init') { - print ' '; - print ' '; - print ''; - } } /** * View html list of message for ticket From cfa414b2de51c08ad9c110bf7a0a3d7b51d3a093 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 16:42:45 +0200 Subject: [PATCH 11/16] Better log --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 942f9f7ecfe..35d29e15988 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6694,7 +6694,7 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = return $cache_codes[$tablename][$key][$fieldid]; // Found in cache } - dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG); + dol_syslog('dol_getIdFromCode (value for field '.$fieldid.' from key '.$key.' not found into cache)', LOG_DEBUG); $sql = "SELECT ".$fieldid." as valuetoget"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; From 621709ed421eceb95ae90e36060418d7b8dbe271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 16:54:20 +0200 Subject: [PATCH 12/16] FIX check thirdparty defined when PROJECT_THIRDPARTY_REQUIRED is set --- htdocs/projet/class/project.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 779666b4b9d..59d24e5eb3d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -190,10 +190,10 @@ class Project extends CommonObject dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); return -1; } - if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! $this->socid > 0) + if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! ($this->socid > 0)) { $this->error = 'ErrorFieldsRequired'; - dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); + dol_syslog(get_class($this)."::create error -1 thirdparty not defined and option PROJECT_THIRDPARTY_REQUIRED is set", LOG_ERR); return -1; } From 203cbd56c2817cd34ffa39087b77ebae7a30a919 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 17:35:33 +0200 Subject: [PATCH 13/16] Finished debug of emailcollector module --- htdocs/admin/emailcollector_card.php | 4 ++-- .../class/emailcollector.class.php | 18 +++++++++++------- htdocs/langs/en_US/admin.lang | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index cbf544bcad3..b098f090fa5 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -520,8 +520,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; $arrayoftypes=array( - 'loadthirdparty'=>'LoadThirdPartyFromName', - 'loadandcreatethirdparty'=>'LoadThirdPartyFromNameOrCreate', + 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), + 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), 'recordevent'=>'RecordEvent'); if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; if ($conf->ticket->enabled) $arrayoftypes['ticket']='CreateTicketAndThirdParty'; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 3e2e2126ff2..d89f0bc2bbd 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1380,7 +1380,15 @@ class EmailCollector extends CommonObject } elseif ($result == 0) { - if ($operation['type'] == 'loadandcreatethirdparty') + if ($operation['type'] == 'loadthirdparty') + { + dol_syslog("Third party with name ".$nametouseforthirdparty." was not found"); + + $errorforactions++; + $this->error = 'ErrorFailedToLoadThirdParty'; + $this->errors[] = 'ErrorFailedToLoadThirdParty'; + } + elseif ($operation['type'] == 'loadandcreatethirdparty') { dol_syslog("Third party with name ".$nametouseforthirdparty." was not found. We try to create it."); @@ -1407,10 +1415,6 @@ class EmailCollector extends CommonObject } } } - else - { - dol_syslog("Third party with name ".$nametouseforthirdparty." was not found"); - } } } } @@ -1565,10 +1569,10 @@ class EmailCollector extends CommonObject } else { - if (is_numeric($projecttocreate->ref) && $projecttocreate->ref <= 0) + if (empty($projecttocreate->ref) || (is_numeric($projecttocreate->ref) && $projecttocreate->ref <= 0)) { $errorforactions++; - $this->error = 'Failed to create project: Can\'t get a valid value for project Ref'; + $this->error = 'Failed to create project: Can\'t get a valid value for project Ref with numbering template '.$modele; } else { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d2042494191..9f8162deb8f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1842,8 +1842,8 @@ CreateLeadAndThirdParty=Create lead (and third party if necessary) CreateTicketAndThirdParty=Create ticket (and third party if necessary) CodeLastResult=Latest result code NbOfEmailsInInbox=Number of emails in source directory -LoadThirdPartyFromName=Load third party from name (load only) -LoadThirdPartyFromNameOrCreate=Load third party from name (create if not found) +LoadThirdPartyFromName=Load third party searching on %s (load only) +LoadThirdPartyFromNameOrCreate=Load third party searching on %s (create if not found) WithDolTrackingID=Dolibarr Tracking ID found WithoutDolTrackingID=Dolibarr Tracking ID not found FormatZip=Zip From 05ae0c370fbd37ec8ecea64ec39121a921e1fe74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 17:59:22 +0200 Subject: [PATCH 14/16] Fix bad property set --- htdocs/emailcollector/class/emailcollector.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index d89f0bc2bbd..55a74224e77 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1612,7 +1612,7 @@ class EmailCollector extends CommonObject $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); $descriptionfull = dol_concatdesc($descriptionfull, $header); - $tickettocreate->title = $subject; + $tickettocreate->subject = $subject; $tickettocreate->message = $description; $tickettocreate->type_code = 0; $tickettocreate->category_code = 0; From 862917edffed600defd1f1e296bb8aa10240c932 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Apr 2019 21:24:23 +0200 Subject: [PATCH 15/16] NEW Tooltip with vat amount and price incl tax on lines of objects. --- htdocs/core/tpl/objectline_view.tpl.php | 28 ++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 55accb3043e..a3bf7d587af 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -260,16 +260,34 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; ?> special_code == 3) { ?> - trans('Option'); ?> + trans('Option'); ?> - total_ht); ?> + global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + print 'country_code).'='.price($line->total_ht); + print '
'.$langs->transcountry("TotalVAT", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_tva); + if (price2num($line->total_localtax1)) print '
'.$langs->transcountry("TotalLT1", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax1); + if (price2num($line->total_localtax2)) print '
'.$langs->transcountry("TotalLT2", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax2); + print '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); + print '">'; + } + print price($line->total_ht); + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + print '
'; + } + ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> - multicurrency_total_ht); ?> + multicurrency_total_ht); ?> - + total_ttc); ?> - + Date: Wed, 10 Apr 2019 21:25:37 +0200 Subject: [PATCH 16/16] Fix phpcs --- htdocs/expensereport/tpl/expensereport_addfile.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php index 5bca1ba8f81..46348944ff4 100644 --- a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php @@ -37,4 +37,4 @@ $formfile->form_attach_new_file( 1 ); -print ''; \ No newline at end of file +print '';