Dolibarize module ticket
This commit is contained in:
parent
2765cee005
commit
ac25003d33
@ -1139,7 +1139,7 @@ class FormFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table width="100%" id="tablelines" class="'.(($useinecm && $useinecm != 6)?'liste noborder':'liste').'">'."\n";
|
print '<table width="100%" id="tablelines" class="liste noborder nobottom">'."\n";
|
||||||
|
|
||||||
if (! empty($addfilterfields))
|
if (! empty($addfilterfields))
|
||||||
{
|
{
|
||||||
@ -1156,10 +1156,10 @@ class FormFile
|
|||||||
|
|
||||||
print '<tr class="liste_titre nodrag nodrop">';
|
print '<tr class="liste_titre nodrag nodrop">';
|
||||||
//print $url.' sortfield='.$sortfield.' sortorder='.$sortorder;
|
//print $url.' sortfield='.$sortfield.' sortorder='.$sortorder;
|
||||||
print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, ' left');
|
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('Size', $url, "size", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||||
print_liste_field_titre('Date', $url, "date", "", $param, '', $sortfield, $sortorder, ' center');
|
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
|
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('');
|
||||||
print_liste_field_titre('');
|
print_liste_field_titre('');
|
||||||
if (! $disablemove) print_liste_field_titre('');
|
if (! $disablemove) print_liste_field_titre('');
|
||||||
@ -1734,7 +1734,7 @@ class FormFile
|
|||||||
|
|
||||||
print '<form action="' . $_SERVER['PHP_SELF'] . ($param?'?'.$param:'') . '" method="POST">';
|
print '<form action="' . $_SERVER['PHP_SELF'] . ($param?'?'.$param:'') . '" method="POST">';
|
||||||
|
|
||||||
print '<table width="100%" class="liste">';
|
print '<table width="100%" class="liste noborder nobottom">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre(
|
print_liste_field_titre(
|
||||||
$langs->trans("Links"),
|
$langs->trans("Links"),
|
||||||
@ -1742,9 +1742,10 @@ class FormFile
|
|||||||
"name",
|
"name",
|
||||||
"",
|
"",
|
||||||
$param,
|
$param,
|
||||||
'class="left"',
|
'',
|
||||||
$sortfield,
|
$sortfield,
|
||||||
$sortorder
|
$sortorder,
|
||||||
|
''
|
||||||
);
|
);
|
||||||
print_liste_field_titre(
|
print_liste_field_titre(
|
||||||
"",
|
"",
|
||||||
@ -1752,7 +1753,10 @@ class FormFile
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
'class="right"'
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'right '
|
||||||
);
|
);
|
||||||
print_liste_field_titre(
|
print_liste_field_titre(
|
||||||
$langs->trans("Date"),
|
$langs->trans("Date"),
|
||||||
@ -1760,9 +1764,10 @@ class FormFile
|
|||||||
"date",
|
"date",
|
||||||
"",
|
"",
|
||||||
$param,
|
$param,
|
||||||
'class="center"',
|
'',
|
||||||
$sortfield,
|
$sortfield,
|
||||||
$sortorder
|
$sortorder,
|
||||||
|
'center '
|
||||||
);
|
);
|
||||||
print_liste_field_titre(
|
print_liste_field_titre(
|
||||||
'',
|
'',
|
||||||
@ -1770,7 +1775,10 @@ class FormFile
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
$param,
|
$param,
|
||||||
'class="center"'
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'center '
|
||||||
);
|
);
|
||||||
print_liste_field_titre('', '', '');
|
print_liste_field_titre('', '', '');
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@ -167,6 +167,85 @@ class FormTicket
|
|||||||
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("Ref") . '</span></td><td><input size="18" type="text" name="ref" value="' . (GETPOST("ref", 'alpha') ? GETPOST("ref", 'alpha') : $defaultref) . '"></td></tr>';
|
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("Ref") . '</span></td><td><input size="18" type="text" name="ref" value="' . (GETPOST("ref", 'alpha') ? GETPOST("ref", 'alpha') : $defaultref) . '"></td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TITLE
|
||||||
|
if ($this->withemail) {
|
||||||
|
print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">' . $langs->trans("Email") . '</span></label></td><td>';
|
||||||
|
print '<input class="text minwidth200" id="email" name="email" value="' . (GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $subject) . '" />';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2"><input name="' . $subelement . 'id" value="' . GETPOST('originid') . '" type="hidden" />' . $objectsrc->getNomUrl(1) . '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type
|
||||||
|
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">' . $langs->trans("TicketTypeRequest") . '</span></label></td><td>';
|
||||||
|
$this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Severity
|
||||||
|
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">' . $langs->trans("TicketSeverity") . '</span></label></td><td>';
|
||||||
|
$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Group
|
||||||
|
print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">' . $langs->trans("TicketGroup") . '</span></label></td><td>';
|
||||||
|
$this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Subject
|
||||||
|
if ($this->withtitletopic) {
|
||||||
|
print '<tr><td><label for="subject"><span class="fieldrequired">' . $langs->trans("Subject") . '</span></label></td><td>';
|
||||||
|
|
||||||
|
// Réponse à un ticket : affichage du titre du thread en readonly
|
||||||
|
if ($this->withtopicreadonly) {
|
||||||
|
print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title;
|
||||||
|
print '</td></tr>';
|
||||||
|
} else {
|
||||||
|
if ($this->withthreadid > 0) {
|
||||||
|
$subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . '';
|
||||||
|
}
|
||||||
|
print '<input class="text" size="50" id="subject" name="subject" value="' . (GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $subject) . '" />';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MESSAGE
|
||||||
|
$msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : '';
|
||||||
|
print '<tr><td><label for="message"><span class="fieldrequired">' . $langs->trans("Message") . '</span></label></td><td>';
|
||||||
|
|
||||||
|
// If public form, display more information
|
||||||
|
$toolbarname = 'dolibarr_notes';
|
||||||
|
if ($this->ispublic)
|
||||||
|
{
|
||||||
|
$toolbarname = 'dolibarr_details';
|
||||||
|
print '<div class="warning">' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '</div>';
|
||||||
|
}
|
||||||
|
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 '</td></tr>';
|
||||||
|
|
||||||
// FK_USER_CREATE
|
// FK_USER_CREATE
|
||||||
if ($this->withusercreate > 0 && $this->fk_user_create) {
|
if ($this->withusercreate > 0 && $this->fk_user_create) {
|
||||||
print '<tr><td class="titlefield">' . $langs->trans("CreatedBy") . '</td><td>';
|
print '<tr><td class="titlefield">' . $langs->trans("CreatedBy") . '</td><td>';
|
||||||
@ -269,85 +348,6 @@ class FormTicket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TITLE
|
|
||||||
if ($this->withemail) {
|
|
||||||
print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">' . $langs->trans("Email") . '</span></label></td><td>';
|
|
||||||
print '<input class="text minwidth200" id="email" name="email" value="' . (GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $subject) . '" />';
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2"><input name="' . $subelement . 'id" value="' . GETPOST('originid') . '" type="hidden" />' . $objectsrc->getNomUrl(1) . '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type
|
|
||||||
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">' . $langs->trans("TicketTypeRequest") . '</span></label></td><td>';
|
|
||||||
$this->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $this->type_code), 'type_code', '', '2');
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Severity
|
|
||||||
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">' . $langs->trans("TicketSeverity") . '</span></label></td><td>';
|
|
||||||
$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2');
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Group
|
|
||||||
print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">' . $langs->trans("TicketGroup") . '</span></label></td><td>';
|
|
||||||
$this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2');
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// TITLE
|
|
||||||
if ($this->withtitletopic) {
|
|
||||||
print '<tr><td><label for="subject"><span class="fieldrequired">' . $langs->trans("Subject") . '</span></label></td><td>';
|
|
||||||
|
|
||||||
// Réponse à un ticket : affichage du titre du thread en readonly
|
|
||||||
if ($this->withtopicreadonly) {
|
|
||||||
print $langs->trans('SubjectAnswerToTicket') . ' ' . $this->topic_title;
|
|
||||||
print '</td></tr>';
|
|
||||||
} else {
|
|
||||||
if ($this->withthreadid > 0) {
|
|
||||||
$subject = $langs->trans('SubjectAnswerToTicket') . ' ' . $this->withthreadid . ' : ' . $this->topic_title . '';
|
|
||||||
}
|
|
||||||
print '<input class="text" size="50" id="subject" name="subject" value="' . (GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $subject) . '" />';
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MESSAGE
|
|
||||||
$msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : '';
|
|
||||||
print '<tr><td><label for="message"><span class="fieldrequired">' . $langs->trans("Message") . '</span></label></td><td>';
|
|
||||||
|
|
||||||
// If public form, display more information
|
|
||||||
$toolbarname = 'dolibarr_notes';
|
|
||||||
if ($this->ispublic)
|
|
||||||
{
|
|
||||||
$toolbarname = 'dolibarr_details';
|
|
||||||
print '<div class="warning">' . ($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')) . '</div>';
|
|
||||||
}
|
|
||||||
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 '</td></tr>';
|
|
||||||
|
|
||||||
if (! empty($conf->projet->enabled) && ! $this->ispublic)
|
if (! empty($conf->projet->enabled) && ! $this->ispublic)
|
||||||
{
|
{
|
||||||
$formproject=new FormProjets($this->db);
|
$formproject=new FormProjets($this->db);
|
||||||
@ -831,7 +831,8 @@ class FormTicket
|
|||||||
print '<table class="border" width="' . $width . '">';
|
print '<table class="border" width="' . $width . '">';
|
||||||
|
|
||||||
// External users can't send message email
|
// External users can't send message email
|
||||||
if ($user->rights->ticket->write && !$user->socid) {
|
if ($user->rights->ticket->write && !$user->socid)
|
||||||
|
{
|
||||||
print '<tr><td width="30%"></td><td colspan="2">';
|
print '<tr><td width="30%"></td><td colspan="2">';
|
||||||
$checkbox_selected = ( GETPOST('send_email') == "1" ? ' checked' : '');
|
$checkbox_selected = ( GETPOST('send_email') == "1" ? ' checked' : '');
|
||||||
print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.'/> ';
|
print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.'/> ';
|
||||||
|
|||||||
@ -81,7 +81,6 @@ function ticket_prepare_head($object)
|
|||||||
$head[$h][2] = 'tabTicket';
|
$head[$h][2] = 'tabTicket';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid))
|
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid))
|
||||||
{
|
{
|
||||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||||
@ -96,9 +95,9 @@ function ticket_prepare_head($object)
|
|||||||
|
|
||||||
// Attached files
|
// Attached files
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
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'));
|
$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");
|
$head[$h][1] = $langs->trans("Documents");
|
||||||
if ($nbFiles > 0) {
|
if ($nbFiles > 0) {
|
||||||
$head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
|
$head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
|
||||||
|
|||||||
@ -63,7 +63,7 @@ $userstatic=new User($db);
|
|||||||
<!-- BEGIN PHP TEMPLATE CONTACTS -->
|
<!-- BEGIN PHP TEMPLATE CONTACTS -->
|
||||||
<div class="underbanner clearboth"></div>
|
<div class="underbanner clearboth"></div>
|
||||||
<div class="div-table-responsive">
|
<div class="div-table-responsive">
|
||||||
<div class="tagtable centpercent noborder nobordertop allwidth">
|
<div class="tagtable tableforcontact centpercent noborder nobordertop allwidth">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($permission) {
|
if ($permission) {
|
||||||
|
|||||||
@ -2631,9 +2631,6 @@ tr.liste_titre_filter td.liste_titre {
|
|||||||
border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);
|
border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);
|
||||||
border-top-style: solid;
|
border-top-style: solid;
|
||||||
}
|
}
|
||||||
/*.liste_titre_create td.nobottom, tr#trlinefordates td {
|
|
||||||
background-color: rgb(<?php echo $colorbacktitle1; ?>) !important;
|
|
||||||
}*/
|
|
||||||
tr#trlinefordates td {
|
tr#trlinefordates td {
|
||||||
border-bottom: 0px !important;
|
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 {
|
form.tagtr:last-of-type div.tagtd, tr.pair:last-of-type td, tr.impair:last-of-type td {
|
||||||
border-bottom: 0px !important;
|
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 {
|
tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td {
|
||||||
border-bottom: 0px !important;
|
border-bottom: 0px !important;
|
||||||
}
|
}
|
||||||
@ -2939,6 +2939,9 @@ table.nobottomiftotal tr.liste_total td {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-bottom: 0px !important;
|
border-bottom: 0px !important;
|
||||||
}
|
}
|
||||||
|
table.nobottom {
|
||||||
|
border-bottom: 0px !important;
|
||||||
|
}
|
||||||
div.liste_titre .tagtd {
|
div.liste_titre .tagtd {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,8 +123,428 @@ if ($cancel)
|
|||||||
$action='view';
|
$action='view';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do action
|
if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
|
||||||
$actionobject->doActions($action, $object);
|
$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('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', 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('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs');
|
||||||
|
Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$langs->load("errors");
|
||||||
|
$mesg = '<div class="error">' . $langs->trans($object->error) . '</div>';
|
||||||
|
$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 ? '<br>' : '') . $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
|
// Action to update one extrafield
|
||||||
if ($action == "update_extras" && ! empty($permissiontoadd))
|
if ($action == "update_extras" && ! empty($permissiontoadd))
|
||||||
@ -164,9 +584,21 @@ if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') &
|
|||||||
$action = 'view';
|
$action = 'view';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$permissiondellink = $user->rights->ticket->write;
|
$permissiondellink = $user->rights->ticket->write;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
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);
|
llxHeader('', $page_title, $help_url);
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create' || $action == 'presend')
|
||||||
{
|
{
|
||||||
$formticket = new FormTicket($db);
|
$formticket = new FormTicket($db);
|
||||||
|
|
||||||
|
|||||||
@ -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('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', 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('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs');
|
|
||||||
Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$langs->load("errors");
|
|
||||||
$mesg = '<div class="error">' . $langs->trans($this->error) . '</div>';
|
|
||||||
$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 ? '<br>' : '') . $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') . ' : ' . '<a href="' . $url_internal_ticket . '">' . $object->track_id . '</a>' . "\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') . ' : ' . '<a href="' . $url_public_ticket . '">' . $object->track_id . '</a>' . "\n";
|
|
||||||
|
|
||||||
// Build final message
|
|
||||||
$message = $message_intro . $message;
|
|
||||||
|
|
||||||
// Add signature
|
|
||||||
$message .= '<br>' . $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
|
* 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
|
* 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;
|
$urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<a class="button" href="' . $urlforbutton . '">';
|
print '<a class="button buttonticket" href="' . $urlforbutton . '">';
|
||||||
print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]);
|
print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]);
|
||||||
print '</a>';
|
print '</a>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
@ -25,8 +25,7 @@
|
|||||||
// Put here all includes required by your class file
|
// Put here all includes required by your class file
|
||||||
require_once DOL_DOCUMENT_ROOT . "/core/class/commonobject.class.php";
|
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 . '/fichinter/class/fichinter.class.php';
|
||||||
//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
|
||||||
//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.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;
|
public $track_id;
|
||||||
|
|
||||||
@ -327,11 +326,14 @@ class Ticket extends CommonObject
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
$this->datec = dol_now();
|
$this->datec = dol_now();
|
||||||
|
if (empty($this->track_id)) $this->track_id = generate_random_id(16);
|
||||||
|
|
||||||
// Check more parameters
|
// Check more parameters
|
||||||
// If error, this->errors[] is filled
|
// If error, this->errors[] is filled
|
||||||
$result = $this->verify();
|
$result = $this->verify();
|
||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "ticket(";
|
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "ticket(";
|
||||||
@ -2430,6 +2432,416 @@ class Ticket extends CommonObject
|
|||||||
}
|
}
|
||||||
return false;
|
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') . ' : ' . '<a href="' . $url_internal_ticket . '">' . $object->track_id . '</a>' . "\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') . ' : ' . '<a href="' . $url_public_ticket . '">' . $object->track_id . '</a>' . "\n";
|
||||||
|
|
||||||
|
// Build final message
|
||||||
|
$message = $message_intro . $message;
|
||||||
|
|
||||||
|
// Add signature
|
||||||
|
$message .= '<br>' . $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');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -50,9 +50,6 @@ $source = GETPOST('source', 'alpha');
|
|||||||
$ligne = GETPOST('ligne', 'int');
|
$ligne = GETPOST('ligne', 'int');
|
||||||
$lineid = GETPOST('lineid', 'int');
|
$lineid = GETPOST('lineid', 'int');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
if ($user->societe_id > 0) {
|
if ($user->societe_id > 0) {
|
||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
@ -64,8 +61,9 @@ $url_page_current = dol_buildpath('/ticket/contact.php', 1);
|
|||||||
|
|
||||||
$object = new Ticket($db);
|
$object = new Ticket($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajout d'un nouveau contact
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'addcontact' && $user->rights->ticket->write) {
|
if ($action == 'addcontact' && $user->rights->ticket->write) {
|
||||||
@ -110,9 +108,12 @@ if ($action == 'deletecontact' && $user->rights->ticket->write) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$help_url = 'FR:DocumentationModuleTicket';
|
$help_url = 'FR:DocumentationModuleTicket';
|
||||||
llxHeader('', $langs->trans("TicketContacts"), $help_url);
|
llxHeader('', $langs->trans("TicketContacts"), $help_url);
|
||||||
|
|
||||||
@ -121,12 +122,6 @@ $formcompany = new FormCompany($db);
|
|||||||
$contactstatic = new Contact($db);
|
$contactstatic = new Contact($db);
|
||||||
$userstatic = new User($db);
|
$userstatic = new User($db);
|
||||||
|
|
||||||
/* *************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* Mode vue et edition */
|
|
||||||
/* */
|
|
||||||
/* *************************************************************************** */
|
|
||||||
|
|
||||||
if ($id > 0 || !empty($track_id) || !empty($ref)) {
|
if ($id > 0 || !empty($track_id) || !empty($ref)) {
|
||||||
if ($object->fetch($id, $ref, $track_id) > 0)
|
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);
|
$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 ='<div class="refidno">';
|
$morehtmlref ='<div class="refidno">';
|
||||||
$morehtmlref.= $object->subject;
|
$morehtmlref.= $object->subject;
|
||||||
|
|||||||
@ -61,15 +61,10 @@ if (! $sortfield) $sortfield="position_name";
|
|||||||
$object = new Ticket($db);
|
$object = new Ticket($db);
|
||||||
$result = $object->fetch($id, $ref, $track_id);
|
$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) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
} else {
|
} 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';
|
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
|
||||||
|
|
||||||
$object->ref = $old_ref;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -193,7 +186,7 @@ if ($object->id)
|
|||||||
$totalsize += $file['size'];
|
$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';
|
$modulepart = 'ticket';
|
||||||
$permission = $user->rights->ticket->write;
|
$permission = $user->rights->ticket->write;
|
||||||
$permtoedit = $user->rights->ticket->write;
|
$permtoedit = $user->rights->ticket->write;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user