Dolibarrize module ticket

This commit is contained in:
Laurent Destailleur 2018-03-22 10:23:25 +01:00
parent 7b6104de38
commit 3b55049895
9 changed files with 363 additions and 311 deletions

View File

@ -284,23 +284,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->mymodule->creer) if ($user->rights->mymodule->write)
{ {
if ($action != 'classify') if ($action != 'classify')
{
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
}
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) - 2013-2016 Jean-François FERRY <hello@librethic.io> /* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr> * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,8 +18,7 @@
/** /**
* Card of ticket * Card of ticket
* * @ingroup ticketsup
* @package ticketsup
*/ */
require '../main.inc.php'; require '../main.inc.php';
@ -71,7 +70,7 @@ if (GETPOST('modelselected')) {
$url_page_current = DOL_URL_ROOT.'/ticketsup/card.php'; $url_page_current = DOL_URL_ROOT.'/ticketsup/card.php';
if ($id || $track_id || $ref) { if ($id || $track_id || $ref) {
$res = $object->fetch($id, $track_id, $ref); $res = $object->fetch($id, $ref, $track_id);
} }
// Security check // Security check
@ -99,6 +98,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be inc
$userstat = new User($db); $userstat = new User($db);
$form = new Form($db); $form = new Form($db);
$formticket = new FormTicketsup($db); $formticket = new FormTicketsup($db);
$formproject = new FormProjets($db);
if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') {
@ -234,6 +234,40 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' '; $morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>'; $morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
} }
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->ticketsup->write)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>'; $morehtmlref.='</div>';
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> '; $linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
@ -308,27 +342,6 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
} }
print '</td></tr>'; print '</td></tr>';
// Project
if (!empty($conf->projet->enabled)) {
$langs->load('projects');
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project');
print '</td>';
if ($action != 'classify' && $user->rights->ticketsup->write) {
print '<td align="right"><a href="' . $url_page_current . '?action=classify&amp;track_id=' . $object->track_id . '">' . img_edit($langs->trans('SetProject')) . '</a></td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'classify') {
$form->form_project($url_page_current . '?track_id=' . $object->track_id, $object->socid, $object->fk_project, 'projectid');
} else {
$form->form_project($url_page_current . '?track_id=' . $object->track_id, $object->socid, $object->fk_project, 'none');
}
print '</td></tr>';
}
// User assigned // User assigned
print '<tr><td>' . $langs->trans("UserAssignedTo") . '</td><td>'; print '<tr><td>' . $langs->trans("UserAssignedTo") . '</td><td>';
if ($object->fk_user_assign > 0) { if ($object->fk_user_assign > 0) {
@ -339,17 +352,17 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
} }
// Show user list to assignate one if status is "read" // Show user list to assignate one if status is "read"
if (GETPOST('set') == "assign_ticket" && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) { if (GETPOST('set','alpha') == "assign_ticket" && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) {
print '<form method="post" name="ticketsup" enctype="multipart/form-data" action="' . $url_page_current . '">'; print '<form method="post" name="ticketsup" enctype="multipart/form-data" action="' . $url_page_current . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="assign_user">'; print '<input type="hidden" name="action" value="assign_user">';
print '<input type="hidden" name="track_id" value="' . $object->track_id . '">'; print '<input type="hidden" name="track_id" value="' . $object->track_id . '">';
print '<label for="fk_user_assign">' . $langs->trans("AssignUser") . '</label> '; print '<label for="fk_user_assign">' . $langs->trans("AssignUser") . '</label> ';
print $form->select_dolusers($user->id, 'fk_user_assign', 0); print $form->select_dolusers($user->id, 'fk_user_assign', 1);
print ' <input class="button" type="submit" name="btn_assign_user" value="' . $langs->trans("Validate") . '" />'; print ' <input class="button" type="submit" name="btn_assign_user" value="' . $langs->trans("Validate") . '" />';
print '</form>'; print '</form>';
} }
if ($object->fk_statut < 8 && GETPOST('set') != "assign_ticket" && $user->rights->ticketsup->manage) { if ($object->fk_statut < 8 && GETPOST('set','alpha') != "assign_ticket" && $user->rights->ticketsup->manage) {
print '<a href="' . $url_page_current . '?track_id=' . $object->track_id . '&action=view&set=assign_ticket">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>'; print '<a href="' . $url_page_current . '?track_id=' . $object->track_id . '&action=view&set=assign_ticket">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
} }
print '</td></tr>'; print '</td></tr>';
@ -425,13 +438,14 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</table>'; print '</table>';
// View Original message
$actionobject->viewTicketOriginalMessage($user, $action);
// Fin colonne gauche et début colonne droite // Fin colonne gauche et début colonne droite
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// View Original message
$actionobject->viewTicketOriginalMessage($user, $action, $object);
/*************************************************** /***************************************************
* *
* Classification and actions on ticket * Classification and actions on ticket
@ -440,7 +454,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
/* /*
* Ticket properties * Ticket properties
*/ */
print '<table class="border" style="width:100%;" >'; print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="border centpercent margintable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="2">'; print '<td colspan="2">';
print $langs->trans('Properties'); print $langs->trans('Properties');
@ -496,31 +511,32 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Type // Type
print '<tr><td width="40%">' . $langs->trans("Type") . '</td><td>'; print '<tr><td width="40%">' . $langs->trans("Type") . '</td><td>';
print $object->type_label; print $object->type_label;
if ($user->admin && !$noadmininfo) { /*if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
} }*/
print '</td></tr>'; print '</td></tr>';
// Category // Category
print '<tr><td>' . $langs->trans("Category") . '</td><td>'; print '<tr><td>' . $langs->trans("Category") . '</td><td>';
print $object->category_label; print $object->category_label;
if ($user->admin && !$noadmininfo) { /*if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
} }*/
print '</td></tr>'; print '</td></tr>';
// Severity // Severity
print '<tr><td>' . $langs->trans("TicketSeverity") . '</td><td>'; print '<tr><td>' . $langs->trans("TicketSeverity") . '</td><td>';
print $object->severity_label; print $object->severity_label;
if ($user->admin && !$noadmininfo) { /*if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
} }*/
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; // End table actions print '</table>'; // End table actions
print '</div>';
// Display navbar with links to change ticket status // Display navbar with links to change ticket status
print '<!-- navbar with status -->'; print '<!-- navbar with status -->';
@ -529,13 +545,15 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
} }
if (! empty($conf->global->TICKETSUP_SHOW_CONTACT_ON_MAIN_TAB))
{
print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png'); print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<div class="tagtable centpercent noborder allwidth">'; print '<div class="tagtable centpercent noborder allwidth">';
print '<div class="tagtr liste_titre">';
print '<div class="tagtd ">' . $langs->trans("Source") . '</div> print '<div class="tagtr liste_titre">';
print '<div class="tagtd">' . $langs->trans("Source") . '</div>
<div class="tagtd">' . $langs->trans("Company") . '</div> <div class="tagtd">' . $langs->trans("Company") . '</div>
<div class="tagtd">' . $langs->trans("Contacts") . '</div> <div class="tagtd">' . $langs->trans("Contacts") . '</div>
<div class="tagtd">' . $langs->trans("ContactType") . '</div> <div class="tagtd">' . $langs->trans("ContactType") . '</div>
@ -639,6 +657,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</div><!-- contact list -->'; print '</div><!-- contact list -->';
print '</div>'; print '</div>';
}
// Contract // Contract
if ($action == 'sel_contract') { if ($action == 'sel_contract') {
@ -706,8 +725,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</div>'; print '</div>';
if ($action == 'view' || $action == 'edit_message_init') { if ($action == 'view' || $action == 'edit_message_init') {
print '<div class="fichecenter">' print '<div class="fichecenter"><div class="">';
. '<div class="">';
//print '<div style="float: left; width:49%; margin-right: 1%;">'; //print '<div style="float: left; width:49%; margin-right: 1%;">';
// Message list // Message list
@ -716,7 +734,6 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$actionobject->viewTicketTimelineMessages($show_private_message, true, $object); $actionobject->viewTicketTimelineMessages($show_private_message, true, $object);
print '</div><!-- fichehalfleft --> '; print '</div><!-- fichehalfleft --> ';
print '</div><!-- fichecenter -->'; print '</div><!-- fichecenter -->';
print '<br style="clear: both">'; print '<br style="clear: both">';
} elseif ($action == 'add_message') { } elseif ($action == 'add_message') {

View File

@ -92,7 +92,7 @@ class ActionsTicketsup
if (GETPOST('addfile')) { if (GETPOST('addfile')) {
// altairis : allow files from public interface // altairis : allow files from public interface
if (GETPOST('track_id')) { if (GETPOST('track_id')) {
$res = $object->fetch('', GETPOST('track_id','alpha')); $res = $object->fetch('', '', GETPOST('track_id','alpha'));
} }
////if($res > 0) ////if($res > 0)
@ -116,7 +116,7 @@ class ActionsTicketsup
if (GETPOST('removedfile')) { if (GETPOST('removedfile')) {
// altairis : allow files from public interface // altairis : allow files from public interface
if (GETPOST('track_id')) { if (GETPOST('track_id')) {
$res = $object->fetch('', GETPOST('track_id')); $res = $object->fetch('', '', GETPOST('track_id','alpha'));
} }
////if($res > 0) ////if($res > 0)
@ -309,7 +309,7 @@ class ActionsTicketsup
} }
if ($action == "mark_ticket_read" && $user->rights->ticketsup->write) { if ($action == "mark_ticket_read" && $user->rights->ticketsup->write) {
$object->fetch('', GETPOST("track_id")); $object->fetch('', '', GETPOST("track_id",'alpha'));
if ($object->markAsRead($user) > 0) { if ($object->markAsRead($user) > 0) {
// Log action in ticket logs table // Log action in ticket logs table
@ -328,21 +328,25 @@ class ActionsTicketsup
$action = 'view'; $action = 'view';
} }
if ($action == "assign_user" && GETPOST('btn_assign_user') && $user->rights->ticketsup->write) { if ($action == "assign_user" && GETPOST('btn_assign_user','aplha') && $user->rights->ticketsup->write) {
$object->fetch('', GETPOST("track_id")); $object->fetch('', '', GETPOST("track_id",'alpha'));
$useroriginassign = $object->fk_user_assign; $useroriginassign = $object->fk_user_assign;
$usertoassign = GETPOST('fk_user_assign'); $usertoassign = GETPOST('fk_user_assign','int');
if (!$usertoassign) {
/*if (! ($usertoassign > 0)) {
$error++; $error++;
array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("UserAssignedTo"))); array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("UserAssignedTo")));
$action = 'view'; $action = 'view';
}*/
if (!$error)
{
$ret = $object->assignUser($user, $usertoassign);
if ($ret < 0) $error++;
} }
if (!$error) { if (! $error) // Update list of contacts
$ret = $object->assignUser($user, $usertoassign); {
if ($ret) {
// Si déjà un user assigné on le supprime des contacts // Si déjà un user assigné on le supprime des contacts
if ($useroriginassign > 0) { if ($useroriginassign > 0) {
$internal_contacts = $object->listeContact(-1, 'internal'); $internal_contacts = $object->listeContact(-1, 'internal');
@ -356,9 +360,12 @@ class ActionsTicketsup
} }
} }
} }
$object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
} }
if (! $error)
{
// Log action in ticket logs table // Log action in ticket logs table
$object->fetch_user($usertoassign); $object->fetch_user($usertoassign);
$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
@ -377,7 +384,7 @@ class ActionsTicketsup
} }
if ($action == "change_property" && GETPOST('btn_update_ticket_prop') && $user->rights->ticketsup->write) { if ($action == "change_property" && GETPOST('btn_update_ticket_prop') && $user->rights->ticketsup->write) {
$this->fetch('', GETPOST('track_id')); $this->fetch('', '', GETPOST('track_id','alpha'));
$fieldtomodify = GETPOST('property') . '_code'; $fieldtomodify = GETPOST('property') . '_code';
$fieldtomodify_label = GETPOST('property') . '_label'; $fieldtomodify_label = GETPOST('property') . '_label';
@ -423,7 +430,7 @@ class ActionsTicketsup
} }
if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticketsup->write) { if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticketsup->write) {
$this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')); $this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
if ($object->close()) { if ($object->close()) {
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs)); $log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs));
@ -442,7 +449,7 @@ class ActionsTicketsup
} }
if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') { if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
$this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')); $this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) { if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) {
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
@ -461,7 +468,7 @@ class ActionsTicketsup
} }
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticketsup->delete) { if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticketsup->delete) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
if ($object->delete($user) > 0) { if ($object->delete($user) > 0) {
setEventMessages('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs'); setEventMessages('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs');
Header("Location: ".DOL_URL_ROOT."/ticketsup/list.php"); Header("Location: ".DOL_URL_ROOT."/ticketsup/list.php");
@ -476,7 +483,7 @@ class ActionsTicketsup
// Set parent company // Set parent company
if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setCustomer(GETPOST('editcustomer', 'int')); $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url); header("Location: " . $url);
@ -485,7 +492,7 @@ class ActionsTicketsup
} }
if ($action == 'set_progression' && $user->rights->ticketsup->write) { if ($action == 'set_progression' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setProgression(GETPOST('progress')); $result = $object->setProgression(GETPOST('progress'));
// Log action in ticket logs table // Log action in ticket logs table
$log_action = $langs->trans('TicketLogProgressSetTo', GETPOST('progress')); $log_action = $langs->trans('TicketLogProgressSetTo', GETPOST('progress'));
@ -517,7 +524,7 @@ class ActionsTicketsup
} }
if ($action == "set_extrafields" && GETPOST('btn_edit_extrafields') && $user->rights->ticketsup->write && !GETPOST('cancel')) { if ($action == "set_extrafields" && GETPOST('btn_edit_extrafields') && $user->rights->ticketsup->write && !GETPOST('cancel')) {
$res = $this->fetch('', GETPOST('track_id')); $res = $this->fetch('', '', GETPOST('track_id','alpha'));
$extrafields = new ExtraFields($this->db); $extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
@ -534,7 +541,7 @@ class ActionsTicketsup
$action = 'view'; $action = 'view';
} // Reopen ticket } // Reopen ticket
elseif ($action == 'confirm_reopen' && $user->rights->ticketsup->manage && !GETPOST('cancel')) { elseif ($action == 'confirm_reopen' && $user->rights->ticketsup->manage && !GETPOST('cancel')) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
// prevent browser refresh from reopening ticket several times // prevent browser refresh from reopening ticket several times
if ($object->fk_statut == 8) { if ($object->fk_statut == 8) {
$res = $object->setStatut(4); $res = $object->setStatut(4);
@ -550,7 +557,7 @@ class ActionsTicketsup
} }
} // Categorisation dans projet } // Categorisation dans projet
elseif ($action == 'classin' && $user->rights->ticketsup->write) { elseif ($action == 'classin' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setProject(GETPOST('projectid')); $object->setProject(GETPOST('projectid'));
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url); header("Location: " . $url);
@ -558,7 +565,7 @@ class ActionsTicketsup
} }
} // Categorisation dans contrat } // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticketsup->write) { elseif ($action == 'setcontract' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setContract(GETPOST('contractid')); $object->setContract(GETPOST('contractid'));
$url = 'card.php?action=view&track_id=' . $object->track_id; $url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url); header("Location: " . $url);
@ -567,7 +574,7 @@ class ActionsTicketsup
} elseif ($action == "set_message" && $user->rights->ticketsup->manage) { } elseif ($action == "set_message" && $user->rights->ticketsup->manage) {
// altairis: manage cancel button // altairis: manage cancel button
if (!GETPOST('cancel')) { if (!GETPOST('cancel')) {
$this->fetch('', GETPOST('track_id')); $this->fetch('', '', GETPOST('track_id','alpha'));
$oldvalue_message = $object->message; $oldvalue_message = $object->message;
$fieldtomodify = GETPOST('message_initial'); $fieldtomodify = GETPOST('message_initial');
@ -627,7 +634,7 @@ class ActionsTicketsup
$error = 0; $error = 0;
$object = new Ticketsup($this->db); $object = new Ticketsup($this->db);
$ret = $object->fetch('', GETPOST('track_id')); $ret = $object->fetch('', '', GETPOST('track_id','alpha'));
$object->socid = $object->fk_soc; $object->socid = $object->fk_soc;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if ($ret < 0) { if ($ret < 0) {
@ -833,7 +840,7 @@ class ActionsTicketsup
global $mysoc, $conf, $langs; global $mysoc, $conf, $langs;
$error = 0; $error = 0;
$ret = $object->fetch('', GETPOST('track_id')); $ret = $object->fetch('', '', GETPOST('track_id','alpha'));
$object->socid = $object->fk_soc; $object->socid = $object->fk_soc;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if ($ret < 0) { if ($ret < 0) {
@ -969,14 +976,14 @@ class ActionsTicketsup
* Fetch object * Fetch object
* *
* @param int $id ID of ticket * @param int $id ID of ticket
* @param int $track_id Track ID of ticket (for public area)
* @param string $ref Reference of ticket * @param string $ref Reference of ticket
* @param string $track_id Track ID of ticket (for public area)
* @return void * @return void
*/ */
public function fetch($id = 0, $track_id = 0, $ref = '') public function fetch($id = 0, $ref = '', $track_id = '')
{ {
$this->getInstanceDao(); $this->getInstanceDao();
return $this->dao->fetch($id, $track_id, $ref); return $this->dao->fetch($id, $ref, $track_id);
} }
/** /**
@ -1000,7 +1007,7 @@ class ActionsTicketsup
public function getInfo($id) public function getInfo($id)
{ {
$this->getInstanceDao(); $this->getInstanceDao();
$this->dao->fetch($id, $track_id); $this->dao->fetch($id, '', $track_id);
$this->label = $this->dao->label; $this->label = $this->dao->label;
$this->description = $this->dao->description; $this->description = $this->dao->description;
@ -1140,10 +1147,12 @@ class ActionsTicketsup
/** /**
* Show ticket original message * Show ticket original message
* *
* @param User $user $user wich display * @param User $user User wich display
* @param string $action Action mode * @param string $action Action mode
* @param TicketSup $object Object ticket
* @return void
*/ */
public function viewTicketOriginalMessage($user, $action = '') public function viewTicketOriginalMessage($user, $action, $object)
{ {
global $langs; global $langs;
if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') { if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') {
@ -1151,16 +1160,18 @@ class ActionsTicketsup
print '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">'; print '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="track_id" value="' . $this->dao->track_id . '">'; print '<input type="hidden" name="track_id" value="' . $object->track_id . '">';
print '<input type="hidden" name="action" value="set_message">'; print '<input type="hidden" name="action" value="set_message">';
} }
// Initial message // Initial message
print '<table class="border" width="100%">'; print '<div class="underbanner clearboth"></div>';
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="border centpercent margintable">';
print '<tr class="liste_titre"><td class="nowrap" colspan="2">'; print '<tr class="liste_titre"><td class="nowrap" colspan="2">';
print '<strong>' . $langs->trans("InitialMessage") . '</strong> '; print '<strong>' . $langs->trans("InitialMessage") . '</strong> ';
if ($user->rights->ticketsup->manage) { if ($user->rights->ticketsup->manage) {
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=edit_message_init&amp;track_id=' . $this->dao->track_id . '">' . img_edit($langs->trans('Modify')) . ' ' . $langs->trans('Modify') . '</a>'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=edit_message_init&amp;track_id=' . $object->track_id . '">' . img_edit($langs->trans('Modify')) . ' ' . $langs->trans('Modify') . '</a>';
} }
print '</td></tr>'; print '</td></tr>';
@ -1169,20 +1180,20 @@ class ActionsTicketsup
print '<td>'; print '<td>';
if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') { if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') {
// MESSAGE // MESSAGE
$msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $this->dao->message; $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message;
include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
$uselocalbrowser = true; $uselocalbrowser = true;
$doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser);
$doleditor->Create(); $doleditor->Create();
} else { } else {
// Deal with format differences (text / HTML) // Deal with format differences (text / HTML)
if (dol_textishtml($this->dao->message)) { if (dol_textishtml($object->message)) {
print $this->dao->message; print $object->message;
} else { } else {
print dol_nl2br($this->dao->message); print dol_nl2br($object->message);
} }
//print '<div>' . $this->dao->message . '</div>'; //print '<div>' . $object->message . '</div>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -1202,14 +1213,15 @@ class ActionsTicketsup
public function viewTicketMessages($show_private, $show_user = true) public function viewTicketMessages($show_private, $show_user = true)
{ {
global $conf, $langs, $user, $bc; global $conf, $langs, $user, $bc;
global $object;
// Load logs in cache // Load logs in cache
$ret = $this->dao->loadCacheMsgsTicket(); $ret = $object->loadCacheMsgsTicket();
$action = GETPOST('action'); $action = GETPOST('action');
$this->viewTicketOriginalMessage($user, $action); $this->viewTicketOriginalMessage($user, $action);
if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) {
print_titre($langs->trans('TicketMailExchanges')); print_titre($langs->trans('TicketMailExchanges'));
print '<table class="border" style="width:100%;">'; print '<table class="border" style="width:100%;">';
@ -1226,7 +1238,7 @@ class ActionsTicketsup
print '</td>'; print '</td>';
} }
foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) { foreach ($object->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private'] if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private) || ($arraymsgs['private'] == "1" && $show_private)
) { ) {
@ -1331,7 +1343,7 @@ class ActionsTicketsup
function load_previous_next_ref($filter, $fieldid) function load_previous_next_ref($filter, $fieldid)
{ {
$this->getInstanceDao(); $this->getInstanceDao();
return $this->dao->load_previous_next_ref($filter, $fieldid); return $object->load_previous_next_ref($filter, $fieldid);
} }
/** /**
@ -1361,8 +1373,8 @@ class ActionsTicketsup
// If no receiver defined, load all ticket linked contacts // If no receiver defined, load all ticket linked contacts
if (!is_array($array_receiver) || !count($array_receiver) > 0) { if (!is_array($array_receiver) || !count($array_receiver) > 0) {
$array_receiver = $this->dao->getInfosTicketInternalContact(); $array_receiver = $object->getInfosTicketInternalContact();
$array_receiver = array_merge($array_receiver, $this->dao->getInfosTicketExternalContact()); $array_receiver = array_merge($array_receiver, $object->getInfosTicketExternalContact());
} }
if ($send_internal_cc) { if ($send_internal_cc) {
@ -1424,7 +1436,7 @@ class ActionsTicketsup
*/ */
public function copyFilesForTicket() public function copyFilesForTicket()
{ {
global $conf; global $conf, $object;
// Create form object // Create form object
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
@ -1444,7 +1456,7 @@ class ActionsTicketsup
$mimetype = $attachedfiles['mimes']; $mimetype = $attachedfiles['mimes'];
// Copy files into ticket directory // Copy files into ticket directory
$destdir = $conf->ticketsup->dir_output . '/' . $this->dao->track_id; $destdir = $conf->ticketsup->dir_output . '/' . $object->track_id;
if (!dol_is_dir($destdir)) { if (!dol_is_dir($destdir)) {
dol_mkdir($destdir); dol_mkdir($destdir);
@ -1492,8 +1504,10 @@ class ActionsTicketsup
if (!in_array($status, $exclude_status)) { if (!in_array($status, $exclude_status)) {
print '<div class="tagtd">'; print '<div class="tagtd">';
if ($object->fk_statut == Ticketsup::STATUS_READ || $status == Ticketsup::STATUS_READ|| empty($object->date_read)) $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action if ($status == 1)
else $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=mark_ticket_read'; // To set as read, we use a dedicated action
else
$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" href="' . $urlforbutton . '">';
print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticketsup') . ' ' . $langs->trans($object->statuts_short[$status]); print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticketsup') . ' ' . $langs->trans($object->statuts_short[$status]);

View File

@ -90,7 +90,7 @@ class Ticketsups extends DolibarrApi
throw new RestException(401, 'Wrong parameters'); throw new RestException(401, 'Wrong parameters');
} }
$result = $this->ticketsup->fetch($id, $track_id, $ref); $result = $this->ticketsup->fetch($id, $ref, $track_id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Ticketsup not found'); throw new RestException(404, 'Ticketsup not found');
} }
@ -344,7 +344,7 @@ class Ticketsups extends DolibarrApi
$this->ticketsup->$field = $value; $this->ticketsup->$field = $value;
} }
$ticketMessageText = $this->ticketsup->message; $ticketMessageText = $this->ticketsup->message;
$result = $this->ticketsup->fetch('', $this->ticketsup->track_id); $result = $this->ticketsup->fetch('', '', $this->ticketsup->track_id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Ticketsup not found'); throw new RestException(404, 'Ticketsup not found');
} }

View File

@ -174,9 +174,9 @@ class Ticketsup extends CommonObject
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"),
'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-2, 'enabled'=>0, 'position'=>20, 'notnull'=>1, 'index'=>1), 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-2, 'enabled'=>0, 'position'=>20, 'notnull'=>1, 'index'=>1),
'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), 'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"),
'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>1, 'enabled'=>1, 'position'=>49, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"),
'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>1, 'enabled'=>1, 'position'=>11, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"),
'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AuthorAssign', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AuthorAssign', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>12, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>12, 'notnull'=>-1, 'searchall'=>1, 'help'=>""),
@ -428,11 +428,11 @@ class Ticketsup extends CommonObject
* Load object in memory from the database * Load object in memory from the database
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref
* @param string $track_id Track id, a hash like ref
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetch($id = '', $ref = '', $track_id = '')
// possible to change the order of value, standard welcome is = id, ref, track_id ???
public function fetch($id = '', $track_id = '', $ref = '')
{ {
global $langs; global $langs;
@ -524,15 +524,7 @@ class Ticketsup extends CommonObject
$this->date_close = $this->db->jdate($obj->date_close); $this->date_close = $this->db->jdate($obj->date_close);
$this->tms = $this->db->jdate($obj->tms); $this->tms = $this->db->jdate($obj->tms);
if (!class_exists('ExtraFields')) { $this->fetch_optionals();
include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
}
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
if (count($extralabels) > 0) {
$this->fetch_optionals($this->id, $extralabels);
}
} }
$this->db->free($resql); $this->db->free($resql);
@ -1318,43 +1310,71 @@ class Ticketsup extends CommonObject
} }
} }
/** /**
* Return clickable link to object * Return a link to the object card (with optionaly the picto)
* *
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option Sur quoi pointe le lien * @param string $option On what the link point to ('nolink', ...)
* @return string Chaine avec URL * @param int $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $option = '') function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
{ {
global $langs; global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = ''; $result = '';
$companylink = '';
$lien = '<a href="' . dol_buildpath("/ticketsup/card.php?track_id=" . $this->track_id, 1) . '">'; $label = '<u>' . $langs->trans("ShowTicket") . '</u>';
$lienfin = '</a>'; $label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref.'<br>';
$label.= '<b>' . $langs->trans('TrackID') . ':</b> ' . $this->track_id.'<br>';
$label.= '<b>' . $langs->trans('Subject') . ':</b> ' . $this->subject;
$picto = 'ticketsup'; $url = dol_buildpath('/ticketsup/card.php',1).'?id='.$this->id;
if (!$this->public) {
$picto = 'ticketsup'; if ($option != 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
} }
$label = $langs->trans("ShowTicket") . ': ' . $this->ref . ' - ' . $this->subject; $linkclose='';
if ($withpicto) { if (empty($notooltip))
$result .= ($lien . img_object($label, $picto) . $lienfin); {
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowTicket");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
if ($withpicto && $withpicto != 2) { $linkstart = '<a href="'.$url.'"';
$result .= ' '; $linkstart.=$linkclose.'>';
} $linkend='</a>';
if ($withpicto != 2) { $result .= $linkstart;
$result .= $lien . $this->ref . ' - ' . dol_trunc($this->subject) . $lienfin; if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
} if ($withpicto != 2) $result.= $this->ref;
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
return $result; return $result;
} }
/** /**
* Mark a message as read * Mark a message as read
* *
@ -1416,44 +1436,47 @@ class Ticketsup extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
if ($id_assign_user > 0) {
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "ticketsup"; $sql = "UPDATE " . MAIN_DB_PREFIX . "ticketsup";
$sql .= " SET fk_user_assign=" . $id_assign_user; if ($id_assign_user > 0)
$sql .= " , fk_statut=4"; {
$sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4";
}
else
{
$sql .= " SET fk_user_assign=null, fk_statut=1";
}
$sql .= " WHERE rowid = " . $this->id; $sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::assignUser sql=" . $sql); dol_syslog(get_class($this) . "::assignUser sql=" . $sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$this->fk_user_assign = $id_assign_user; // May be used by trigger $this->fk_user_assign = $id_assign_user; // May be used by trigger
if (!$notrigger) { if (! $notrigger) {
// Call trigger // Call trigger
$result=$this->call_trigger('TICKET_ASSIGNED', $user); $result = $this->call_trigger('TICKET_ASSIGNED', $user);
if ($result < 0) { if ($result < 0) {
$error++; $error ++;
} }
// End call triggers // End call triggers
} }
if (!$error) { if (! $error) {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {
$this->db->rollback(); $this->db->rollback();
$this->error = join(',', $this->errors); $this->error = join(',', $this->errors);
dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR);
return -1; return - 1;
} }
} else { } else {
$this->db->rollback(); $this->db->rollback();
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR);
return -1; return - 1;
}
} }
return 0; return 0;

View File

@ -70,7 +70,7 @@ $object = new Ticketsup($db);
*/ */
if ($action == 'addcontact' && $user->rights->ticketsup->write) { if ($action == 'addcontact' && $user->rights->ticketsup->write) {
$result = $object->fetch($id, $track_id); $result = $object->fetch($id, '', $track_id);
if ($result > 0 && ($id > 0 || (!empty($track_id)))) { if ($result > 0 && ($id > 0 || (!empty($track_id)))) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
@ -92,7 +92,7 @@ if ($action == 'addcontact' && $user->rights->ticketsup->write) {
// bascule du statut d'un contact // bascule du statut d'un contact
if ($action == 'swapstatut' && $user->rights->ticketsup->write) { if ($action == 'swapstatut' && $user->rights->ticketsup->write) {
if ($object->fetch($id, $track_id)) { if ($object->fetch($id, '', $track_id)) {
$result = $object->swapContactStatus($ligne); $result = $object->swapContactStatus($ligne);
} else { } else {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
@ -101,7 +101,7 @@ if ($action == 'swapstatut' && $user->rights->ticketsup->write) {
// Efface un contact // Efface un contact
if ($action == 'deletecontact' && $user->rights->ticketsup->write) { if ($action == 'deletecontact' && $user->rights->ticketsup->write) {
if ($object->fetch($id, $track_id)) { if ($object->fetch($id, '', $track_id)) {
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) { if ($result >= 0) {
@ -129,7 +129,7 @@ $userstatic = new User($db);
/* *************************************************************************** */ /* *************************************************************************** */
if ($id > 0 || !empty($track_id) || !empty($ref)) { if ($id > 0 || !empty($track_id) || !empty($ref)) {
if ($object->fetch($id, $track_id, $ref) > 0) if ($object->fetch($id, $ref, $track_id) > 0)
{ {
if ($socid > 0) { if ($socid > 0) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();

View File

@ -64,7 +64,7 @@ if (!$sortfield) {
} }
$object = new Ticketsup($db); $object = new Ticketsup($db);
$result = $object->fetch($id, $track_id, $ref); $result = $object->fetch($id, $ref, $track_id);
// to match document rules and compatibility // to match document rules and compatibility
$old_ref = $object->ref; $old_ref = $object->ref;

View File

@ -57,7 +57,7 @@ if (!$action) {
} }
$object = new Ticketsup($db); $object = new Ticketsup($db);
$object->fetch($id, $track_id, $ref); $object->fetch($id, $ref, $track_id);
/* /*
@ -83,7 +83,7 @@ $form = new Form($db);
$formticket = new FormTicketsup($db); $formticket = new FormTicketsup($db);
if ($action == 'view') { if ($action == 'view') {
$res = $object->fetch($id, $track_id, $ref); $res = $object->fetch($id, $ref, $track_id);
if ($res > 0) { if ($res > 0) {
// restrict access for externals users // restrict access for externals users