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

@ -1980,17 +1980,17 @@ if ($action == 'create' && $user->rights->commande->creer)
{
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', $maxlength, 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);
}
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', $maxlength, 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);

View File

@ -284,22 +284,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->mymodule->creer)
if ($user->rights->mymodule->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', $maxlength, 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);
}
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)) {

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) - 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,9 +17,8 @@
*/
/**
* Card of ticket
*
* @package ticketsup
* Card of ticket
* @ingroup ticketsup
*/
require '../main.inc.php';
@ -71,7 +70,7 @@ if (GETPOST('modelselected')) {
$url_page_current = DOL_URL_ROOT.'/ticketsup/card.php';
if ($id || $track_id || $ref) {
$res = $object->fetch($id, $track_id, $ref);
$res = $object->fetch($id, $ref, $track_id);
}
// Security check
@ -99,6 +98,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be inc
$userstat = new User($db);
$form = new Form($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') {
@ -234,6 +234,40 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$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>';
$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>';
// 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
print '<tr><td>' . $langs->trans("UserAssignedTo") . '</td><td>';
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"
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 '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="assign_user">';
print '<input type="hidden" name="track_id" value="' . $object->track_id . '">';
print '<label for="fk_user_assign">' . $langs->trans("AssignUser") . '</label> ';
print $form->select_dolusers($user->id, 'fk_user_assign', 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 '</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 '</td></tr>';
@ -425,13 +438,14 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</table>';
// View Original message
$actionobject->viewTicketOriginalMessage($user, $action);
// Fin colonne gauche et début colonne droite
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// View Original message
$actionobject->viewTicketOriginalMessage($user, $action, $object);
/***************************************************
*
* Classification and actions on ticket
@ -440,7 +454,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
/*
* 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 '<td colspan="2">';
print $langs->trans('Properties');
@ -496,31 +511,32 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Type
print '<tr><td width="40%">' . $langs->trans("Type") . '</td><td>';
print $object->type_label;
if ($user->admin && !$noadmininfo) {
/*if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
}*/
print '</td></tr>';
// Category
print '<tr><td>' . $langs->trans("Category") . '</td><td>';
print $object->category_label;
if ($user->admin && !$noadmininfo) {
/*if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
}*/
print '</td></tr>';
// Severity
print '<tr><td>' . $langs->trans("TicketSeverity") . '</td><td>';
print $object->severity_label;
if ($user->admin && !$noadmininfo) {
/*if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
}*/
print '</td></tr>';
}
print '</table>'; // End table actions
print '</div>';
// Display navbar with links to change ticket status
print '<!-- navbar with status -->';
@ -529,117 +545,120 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
}
print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
if (! empty($conf->global->TICKETSUP_SHOW_CONTACT_ON_MAIN_TAB))
{
print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
print '<div class="div-table-responsive-no-min">';
print '<div class="tagtable centpercent noborder allwidth">';
print '<div class="tagtr liste_titre">';
print '<div class="div-table-responsive-no-min">';
print '<div class="tagtable centpercent noborder allwidth">';
print '<div class="tagtd ">' . $langs->trans("Source") . '</div>
<div class="tagtd">' . $langs->trans("Company") . '</div>
<div class="tagtd">' . $langs->trans("Contacts") . '</div>
<div class="tagtd">' . $langs->trans("ContactType") . '</div>
<div class="tagtd">' . $langs->trans("Phone") . '</div>
<div class="tagtd" align="center">' . $langs->trans("Status") . '</div>';
print '</div><!-- tagtr -->';
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("Contacts") . '</div>
<div class="tagtd">' . $langs->trans("ContactType") . '</div>
<div class="tagtd">' . $langs->trans("Phone") . '</div>
<div class="tagtd" align="center">' . $langs->trans("Status") . '</div>';
print '</div><!-- tagtr -->';
// Contact list
$companystatic = new Societe($db);
$contactstatic = new Contact($db);
$userstatic = new User($db);
foreach (array('internal', 'external') as $source) {
$tmpobject = $object;
$tab = $tmpobject->listeContact(-1, $source);
$num = count($tab);
$i = 0;
while ($i < $num) {
$var = !$var;
print '<div class="tagtr ' . ($var ? 'pair' : 'impair') . '">';
// Contact list
$companystatic = new Societe($db);
$contactstatic = new Contact($db);
$userstatic = new User($db);
foreach (array('internal', 'external') as $source) {
$tmpobject = $object;
$tab = $tmpobject->listeContact(-1, $source);
$num = count($tab);
$i = 0;
while ($i < $num) {
$var = !$var;
print '<div class="tagtr ' . ($var ? 'pair' : 'impair') . '">';
print '<div class="tagtd" align="left">';
if ($tab[$i]['source'] == 'internal') {
echo $langs->trans("User");
}
print '<div class="tagtd" align="left">';
if ($tab[$i]['source'] == 'internal') {
echo $langs->trans("User");
}
if ($tab[$i]['source'] == 'external') {
echo $langs->trans("ThirdPartyContact");
}
if ($tab[$i]['source'] == 'external') {
echo $langs->trans("ThirdPartyContact");
}
print '</div>';
print '<div class="tagtd" align="left">';
print '</div>';
print '<div class="tagtd" align="left">';
if ($tab[$i]['socid'] > 0) {
$companystatic->fetch($tab[$i]['socid']);
echo $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0) {
echo $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (!$tab[$i]['socid']) {
echo '&nbsp;';
}
print '</div>';
if ($tab[$i]['socid'] > 0) {
$companystatic->fetch($tab[$i]['socid']);
echo $companystatic->getNomUrl(1);
}
if ($tab[$i]['socid'] < 0) {
echo $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (!$tab[$i]['socid']) {
echo '&nbsp;';
}
print '</div>';
print '<div class="tagtd">';
if ($tab[$i]['source'] == 'internal') {
if ($userstatic->fetch($tab[$i]['id'])) {
print $userstatic->getNomUrl(1);
}
}
if ($tab[$i]['source'] == 'external') {
if ($contactstatic->fetch($tab[$i]['id'])) {
print $contactstatic->getNomUrl(1);
}
}
print ' </div>
<div class="tagtd">' . $tab[$i]['libelle'] . '</div>';
print '<div class="tagtd">';
if ($tab[$i]['source'] == 'internal') {
if ($userstatic->fetch($tab[$i]['id'])) {
print $userstatic->getNomUrl(1);
}
}
if ($tab[$i]['source'] == 'external') {
if ($contactstatic->fetch($tab[$i]['id'])) {
print $contactstatic->getNomUrl(1);
}
}
print ' </div>
<div class="tagtd">' . $tab[$i]['libelle'] . '</div>';
print '<div class="tagtd">';
print '<div class="tagtd">';
print dol_print_phone($tab[$i]['phone'], '', '', '', AC_TEL).'<br>';
print dol_print_phone($tab[$i]['phone'], '', '', '', AC_TEL).'<br>';
if (! empty($tab[$i]['phone_perso'])) {
//print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', '', '', AC_TEL).'<br>';
}
if (! empty($tab[$i]['phone_mobile'])) {
//print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
print dol_print_phone($tab[$i]['phone_mobile'], '', '', '', AC_TEL).'<br>';
}
print '</div>';
if (! empty($tab[$i]['phone_perso'])) {
//print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', '', '', AC_TEL).'<br>';
}
if (! empty($tab[$i]['phone_mobile'])) {
//print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
print dol_print_phone($tab[$i]['phone_mobile'], '', '', '', AC_TEL).'<br>';
}
print '</div>';
print '<div class="tagtd" align="center">';
if ($object->statut >= 0) {
echo '<a href="contact.php?track_id=' . $object->track_id . '&amp;action=swapstatut&amp;ligne=' . $tab[$i]['rowid'] . '">';
}
print '<div class="tagtd" align="center">';
if ($object->statut >= 0) {
echo '<a href="contact.php?track_id=' . $object->track_id . '&amp;action=swapstatut&amp;ligne=' . $tab[$i]['rowid'] . '">';
}
if ($tab[$i]['source'] == 'internal') {
$userstatic->id = $tab[$i]['id'];
$userstatic->lastname = $tab[$i]['lastname'];
$userstatic->firstname = $tab[$i]['firstname'];
echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
}
if ($tab[$i]['source'] == 'external') {
$contactstatic->id = $tab[$i]['id'];
$contactstatic->lastname = $tab[$i]['lastname'];
$contactstatic->firstname = $tab[$i]['firstname'];
echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
}
if ($object->statut >= 0) {
echo '</a>';
}
if ($tab[$i]['source'] == 'internal') {
$userstatic->id = $tab[$i]['id'];
$userstatic->lastname = $tab[$i]['lastname'];
$userstatic->firstname = $tab[$i]['firstname'];
echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
}
if ($tab[$i]['source'] == 'external') {
$contactstatic->id = $tab[$i]['id'];
$contactstatic->lastname = $tab[$i]['lastname'];
$contactstatic->firstname = $tab[$i]['firstname'];
echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
}
if ($object->statut >= 0) {
echo '</a>';
}
print '</div>';
print '</div>';
print '</div><!-- tagtr -->';
print '</div><!-- tagtr -->';
$i++;
}
$i++;
}
}
print '</div><!-- contact list -->';
print '</div>';
}
print '</div><!-- contact list -->';
print '</div>';
// Contract
if ($action == 'sel_contract') {
if (!empty($conf->contrat->enabled)) {
@ -706,8 +725,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</div>';
if ($action == 'view' || $action == 'edit_message_init') {
print '<div class="fichecenter">'
. '<div class="">';
print '<div class="fichecenter"><div class="">';
//print '<div style="float: left; width:49%; margin-right: 1%;">';
// Message list
@ -716,7 +734,6 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$actionobject->viewTicketTimelineMessages($show_private_message, true, $object);
print '</div><!-- fichehalfleft --> ';
print '</div><!-- fichecenter -->';
print '<br style="clear: both">';
} elseif ($action == 'add_message') {

View File

@ -92,7 +92,7 @@ class ActionsTicketsup
if (GETPOST('addfile')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
$res = $object->fetch('', GETPOST('track_id','alpha'));
$res = $object->fetch('', '', GETPOST('track_id','alpha'));
}
////if($res > 0)
@ -116,7 +116,7 @@ class ActionsTicketsup
if (GETPOST('removedfile')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
$res = $object->fetch('', GETPOST('track_id'));
$res = $object->fetch('', '', GETPOST('track_id','alpha'));
}
////if($res > 0)
@ -309,7 +309,7 @@ class ActionsTicketsup
}
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) {
// Log action in ticket logs table
@ -328,22 +328,26 @@ class ActionsTicketsup
$action = 'view';
}
if ($action == "assign_user" && GETPOST('btn_assign_user') && $user->rights->ticketsup->write) {
$object->fetch('', GETPOST("track_id"));
if ($action == "assign_user" && GETPOST('btn_assign_user','aplha') && $user->rights->ticketsup->write) {
$object->fetch('', '', GETPOST("track_id",'alpha'));
$useroriginassign = $object->fk_user_assign;
$usertoassign = GETPOST('fk_user_assign');
if (!$usertoassign) {
$usertoassign = GETPOST('fk_user_assign','int');
/*if (! ($usertoassign > 0)) {
$error++;
array_push($this->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("UserAssignedTo")));
$action = 'view';
}*/
if (!$error)
{
$ret = $object->assignUser($user, $usertoassign);
if ($ret < 0) $error++;
}
if (!$error) {
$ret = $object->assignUser($user, $usertoassign);
if ($ret) {
// Si déjà un user assigné on le supprime des contacts
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');
@ -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
$object->fetch_user($usertoassign);
$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) {
$this->fetch('', GETPOST('track_id'));
$this->fetch('', '', GETPOST('track_id','alpha'));
$fieldtomodify = GETPOST('property') . '_code';
$fieldtomodify_label = GETPOST('property') . '_label';
@ -423,7 +430,7 @@ class ActionsTicketsup
}
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()) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs));
@ -442,7 +449,7 @@ class ActionsTicketsup
}
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()) {
// Log action in ticket logs table
$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 ($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) {
setEventMessages('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs');
Header("Location: ".DOL_URL_ROOT."/ticketsup/list.php");
@ -476,7 +483,7 @@ class ActionsTicketsup
// Set parent company
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'));
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url);
@ -485,7 +492,7 @@ class ActionsTicketsup
}
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'));
// Log action in ticket logs table
$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')) {
$res = $this->fetch('', GETPOST('track_id'));
$res = $this->fetch('', '', GETPOST('track_id','alpha'));
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
@ -534,7 +541,7 @@ class ActionsTicketsup
$action = 'view';
} // Reopen ticket
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
if ($object->fk_statut == 8) {
$res = $object->setStatut(4);
@ -550,7 +557,7 @@ class ActionsTicketsup
}
} // Categorisation dans projet
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'));
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
@ -558,7 +565,7 @@ class ActionsTicketsup
}
} // Categorisation dans contrat
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'));
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
@ -567,7 +574,7 @@ class ActionsTicketsup
} elseif ($action == "set_message" && $user->rights->ticketsup->manage) {
// altairis: manage cancel button
if (!GETPOST('cancel')) {
$this->fetch('', GETPOST('track_id'));
$this->fetch('', '', GETPOST('track_id','alpha'));
$oldvalue_message = $object->message;
$fieldtomodify = GETPOST('message_initial');
@ -627,7 +634,7 @@ class ActionsTicketsup
$error = 0;
$object = new Ticketsup($this->db);
$ret = $object->fetch('', GETPOST('track_id'));
$ret = $object->fetch('', '', GETPOST('track_id','alpha'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();
if ($ret < 0) {
@ -833,7 +840,7 @@ class ActionsTicketsup
global $mysoc, $conf, $langs;
$error = 0;
$ret = $object->fetch('', GETPOST('track_id'));
$ret = $object->fetch('', '', GETPOST('track_id','alpha'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();
if ($ret < 0) {
@ -969,14 +976,14 @@ class ActionsTicketsup
* Fetch object
*
* @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 $track_id Track ID of ticket (for public area)
* @return void
*/
public function fetch($id = 0, $track_id = 0, $ref = '')
public function fetch($id = 0, $ref = '', $track_id = '')
{
$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)
{
$this->getInstanceDao();
$this->dao->fetch($id, $track_id);
$this->dao->fetch($id, '', $track_id);
$this->label = $this->dao->label;
$this->description = $this->dao->description;
@ -1140,10 +1147,12 @@ class ActionsTicketsup
/**
* Show ticket original message
*
* @param User $user $user wich display
* @param string $action Action mode
* @param User $user User wich display
* @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;
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 '<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">';
}
// 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 '<strong>' . $langs->trans("InitialMessage") . '</strong> ';
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>';
@ -1169,20 +1180,20 @@ class ActionsTicketsup
print '<td>';
if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') {
// 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';
$uselocalbrowser = true;
$doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser);
$doleditor->Create();
} else {
// Deal with format differences (text / HTML)
if (dol_textishtml($this->dao->message)) {
print $this->dao->message;
if (dol_textishtml($object->message)) {
print $object->message;
} 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 '</tr>';
@ -1202,14 +1213,15 @@ class ActionsTicketsup
public function viewTicketMessages($show_private, $show_user = true)
{
global $conf, $langs, $user, $bc;
global $object;
// Load logs in cache
$ret = $this->dao->loadCacheMsgsTicket();
$ret = $object->loadCacheMsgsTicket();
$action = GETPOST('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 '<table class="border" style="width:100%;">';
@ -1226,7 +1238,7 @@ class ActionsTicketsup
print '</td>';
}
foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) {
foreach ($object->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
@ -1331,7 +1343,7 @@ class ActionsTicketsup
function load_previous_next_ref($filter, $fieldid)
{
$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 (!is_array($array_receiver) || !count($array_receiver) > 0) {
$array_receiver = $this->dao->getInfosTicketInternalContact();
$array_receiver = array_merge($array_receiver, $this->dao->getInfosTicketExternalContact());
$array_receiver = $object->getInfosTicketInternalContact();
$array_receiver = array_merge($array_receiver, $object->getInfosTicketExternalContact());
}
if ($send_internal_cc) {
@ -1424,7 +1436,7 @@ class ActionsTicketsup
*/
public function copyFilesForTicket()
{
global $conf;
global $conf, $object;
// Create form object
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
@ -1444,7 +1456,7 @@ class ActionsTicketsup
$mimetype = $attachedfiles['mimes'];
// 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)) {
dol_mkdir($destdir);
@ -1492,8 +1504,10 @@ class ActionsTicketsup
if (!in_array($status, $exclude_status)) {
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
else $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status;
if ($status == 1)
$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 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');
}
$result = $this->ticketsup->fetch($id, $track_id, $ref);
$result = $this->ticketsup->fetch($id, $ref, $track_id);
if (! $result) {
throw new RestException(404, 'Ticketsup not found');
}
@ -344,7 +344,7 @@ class Ticketsups extends DolibarrApi
$this->ticketsup->$field = $value;
}
$ticketMessageText = $this->ticketsup->message;
$result = $this->ticketsup->fetch('', $this->ticketsup->track_id);
$result = $this->ticketsup->fetch('', '', $this->ticketsup->track_id);
if (! $result) {
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"),
'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"),
'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"),
'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_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_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'=>""),
@ -427,12 +427,12 @@ class Ticketsup extends CommonObject
/**
* Load object in memory from the database
*
* @param int $id Id object
* @return int <0 if KO, >0 if OK
* @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
*/
// possible to change the order of value, standard welcome is = id, ref, track_id ???
public function fetch($id = '', $track_id = '', $ref = '')
public function fetch($id = '', $ref = '', $track_id = '')
{
global $langs;
@ -524,15 +524,7 @@ class Ticketsup extends CommonObject
$this->date_close = $this->db->jdate($obj->date_close);
$this->tms = $this->db->jdate($obj->tms);
if (!class_exists('ExtraFields')) {
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->fetch_optionals();
}
$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 string $option Sur quoi pointe le lien
* @return string Chaine avec URL
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to ('nolink', ...)
* @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;
$result = '';
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$lien = '<a href="' . dol_buildpath("/ticketsup/card.php?track_id=" . $this->track_id, 1) . '">';
$lienfin = '</a>';
$result = '';
$companylink = '';
$picto = 'ticketsup';
if (!$this->public) {
$picto = 'ticketsup';
}
$label = '<u>' . $langs->trans("ShowTicket") . '</u>';
$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;
$label = $langs->trans("ShowTicket") . ': ' . $this->ref . ' - ' . $this->subject;
if ($withpicto) {
$result .= ($lien . img_object($label, $picto) . $lienfin);
}
$url = dol_buildpath('/ticketsup/card.php',1).'?id='.$this->id;
if ($withpicto && $withpicto != 2) {
$result .= ' ';
}
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';
}
if ($withpicto != 2) {
$result .= $lien . $this->ref . ' - ' . dol_trunc($this->subject) . $lienfin;
}
$linkclose='';
if (empty($notooltip))
{
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.'"':'');
return $result;
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$result .= $linkstart;
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;
}
/**
* Mark a message as read
*
@ -1404,60 +1424,63 @@ class Ticketsup extends CommonObject
}
}
/**
* Mark a message as read
*
* @param User $user Object user
* @param int $id_assign_user ID of user assigned
* @param int $notrigger Disable trigger
* @return int <0 if KO, 0=Nothing done, >0 if OK
*/
public function assignUser($user, $id_assign_user, $notrigger = 0)
{
global $conf, $langs;
/**
* Mark a message as read
*
* @param User $user Object user
* @param int $id_assign_user ID of user assigned
* @param int $notrigger Disable trigger
* @return int <0 if KO, 0=Nothing done, >0 if OK
*/
public function assignUser($user, $id_assign_user, $notrigger = 0)
{
global $conf, $langs;
if ($id_assign_user > 0) {
$this->db->begin();
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "ticketsup";
$sql .= " SET fk_user_assign=" . $id_assign_user;
$sql .= " , fk_statut=4";
$sql .= " WHERE rowid = " . $this->id;
$sql = "UPDATE " . MAIN_DB_PREFIX . "ticketsup";
if ($id_assign_user > 0)
{
$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;
dol_syslog(get_class($this) . "::assignUser sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql)
{
$this->fk_user_assign = $id_assign_user; // May be used by trigger
dol_syslog(get_class($this) . "::assignUser sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql) {
$this->fk_user_assign = $id_assign_user; // May be used by trigger
if (!$notrigger) {
// Call trigger
$result=$this->call_trigger('TICKET_ASSIGNED', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (! $notrigger) {
// Call trigger
$result = $this->call_trigger('TICKET_ASSIGNED', $user);
if ($result < 0) {
$error ++;
}
// End call triggers
}
if (!$error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
$this->error = join(',', $this->errors);
dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR);
return -1;
}
} else {
$this->db->rollback();
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR);
return -1;
}
}
if (! $error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
$this->error = join(',', $this->errors);
dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR);
return - 1;
}
} else {
$this->db->rollback();
$this->error = $this->db->lasterror();
dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR);
return - 1;
}
return 0;
}
return 0;
}
/**
* Create log for the ticket

View File

@ -70,7 +70,7 @@ $object = new Ticketsup($db);
*/
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)))) {
$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
if ($action == 'swapstatut' && $user->rights->ticketsup->write) {
if ($object->fetch($id, $track_id)) {
if ($object->fetch($id, '', $track_id)) {
$result = $object->swapContactStatus($ligne);
} else {
dol_print_error($db, $object->error);
@ -101,7 +101,7 @@ if ($action == 'swapstatut' && $user->rights->ticketsup->write) {
// Efface un contact
if ($action == 'deletecontact' && $user->rights->ticketsup->write) {
if ($object->fetch($id, $track_id)) {
if ($object->fetch($id, '', $track_id)) {
$result = $object->delete_contact($lineid);
if ($result >= 0) {
@ -129,7 +129,7 @@ $userstatic = new User($db);
/* *************************************************************************** */
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) {
$object->fetch_thirdparty();

View File

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

View File

@ -57,7 +57,7 @@ if (!$action) {
}
$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);
if ($action == 'view') {
$res = $object->fetch($id, $track_id, $ref);
$res = $object->fetch($id, $ref, $track_id);
if ($res > 0) {
// restrict access for externals users