';
print '
'; // ancre
@@ -786,6 +809,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
print '
';
print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket');
+ print '
';
+
// Define output language
$outputlangs = $langs;
$newlang = '';
@@ -803,6 +828,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
$formticket->id = $object->id;
$formticket->withfile = 2;
+ $formticket->withcancel = 1;
$formticket->param = array('fk_user_create' => $user->id);
$formticket->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
@@ -839,7 +865,6 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
$formticket->substit['__TICKETSUP_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
}
-
$formticket->showMessageForm('100%');
print '';
}
diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php
index 395ab2078c7..f978642311c 100644
--- a/htdocs/ticket/class/actions_ticket.class.php
+++ b/htdocs/ticket/class/actions_ticket.class.php
@@ -116,9 +116,9 @@ class ActionsTicket
/*
* Add file in email form
*/
- if (GETPOST('addfile')) {
+ if (GETPOST('addfile', 'alpha')) {
// altairis : allow files from public interface
- if (GETPOST('track_id')) {
+ if (GETPOST('track_id', 'alpha')) {
$res = $object->fetch('', '', GETPOST('track_id', 'alpha'));
}
@@ -133,14 +133,14 @@ class ActionsTicket
dol_mkdir($upload_dir_tmp);
}
dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '-__file__');
- $action = !empty($object->track_id) ? 'add_message' : 'create_ticket';
+ $action = !empty($object->track_id) ? 'add_message' : 'create';
////}
}
/*
* Remove file in email form
*/
- if (GETPOST('removedfile')) {
+ if (GETPOST('removedfile', 'alpha')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
$res = $object->fetch('', '', GETPOST('track_id', 'alpha'));
@@ -156,21 +156,21 @@ class ActionsTicket
// TODO Delete only files that was uploaded from email form
dol_remove_file_process($_POST['removedfile'], 0);
- $action = !empty($object->track_id) ? 'add_message' : 'create_ticket';
+ $action = !empty($object->track_id) ? 'add_message' : 'create';
////}
}
- if (GETPOST('add_ticket') && $user->rights->ticket->write) {
+ if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
$error = 0;
if (!GETPOST("subject")) {
$error++;
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
- $action = 'create_ticket';
+ $action = 'create';
} elseif (!GETPOST("message")) {
$error++;
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("message"));
- $action = 'create_ticket';
+ $action = 'create';
}
if (!$error) {
@@ -189,6 +189,8 @@ class ActionsTicket
$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
$object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
+ $object->fk_project = GETPOST('projectid', 'int');
+
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
@@ -198,7 +200,7 @@ class ActionsTicket
$error++;
$this->error = $object->error;
$this->errors = $object->errors;
- $action = 'create_ticket';
+ $action = 'create';
}
if (!$error && $id > 0)
@@ -338,19 +340,15 @@ class ActionsTicket
if ($action == "mark_ticket_read" && $user->rights->ticket->write) {
$object->fetch('', '', GETPOST("track_id", 'alpha'));
- if ($object->markAsRead($user) > 0) {
- // Log action in ticket logs table
- $log_action = $langs->trans('TicketLogMesgReadBy', $user->getFullName($langs));
- $ret = $object->createTicketLog($user, $log_action);
- if ($ret > 0) {
- setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
- } else {
- setEventMessages($langs->trans('TicketMarkedAsReadButLogActionNotSaved'), null, 'errors');
- }
+ if ($object->markAsRead($user) > 0)
+ {
+ setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
+
header("Location: card.php?track_id=" . $object->track_id . "&action=view");
exit;
} else {
- array_push($this->errors, $object->error);
+ $this->errors = $object->error;
+ $this->error = $object->error;
}
$action = 'view';
}
@@ -396,12 +394,9 @@ class ActionsTicket
// Log action in ticket logs table
$object->fetch_user($usertoassign);
$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
- $ret = $object->createTicketLog($user, $log_action);
- if ($ret > 0) {
- setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
- } else {
- setEventMessages($langs->trans('TicketAssignedButLogActionNotSaved'), null, 'errors');
- }
+
+ setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
+
header("Location: card.php?track_id=" . $object->track_id . "&action=view");
exit;
} else {
@@ -436,12 +431,9 @@ class ActionsTicket
if ($object->close()) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs));
- $ret = $object->createTicketLog($user, $log_action);
- if ($ret > 0) {
- setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
- } else {
- setEventMessages($langs->trans('TicketMarkedAsClosedButLogActionNotSaved'), null, 'warnings');
- }
+
+ setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
+
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url);
} else {
@@ -455,12 +447,9 @@ class ActionsTicket
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']);
- $ret = $object->createTicketLog($user, $log_action);
- if ($ret > 0) {
- setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs');
- } else {
- setEventMessages($langs->trans('TicketMarkedAsClosedButLogActionNotSaved'), null, 'warnings');
- }
+
+ setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs');
+
$url = 'view.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url);
} else {
@@ -495,10 +484,8 @@ class ActionsTicket
if ($action == 'set_progression' && $user->rights->ticket->write) {
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'));
- $ret = $object->createTicketLog($user, $log_action);
+ $result = $object->setProgression(GETPOST('progress', 'alpha'));
+
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
@@ -529,12 +516,12 @@ class ActionsTicket
if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
// prevent browser refresh from reopening ticket several times
- if ($object->fk_statut == 8) {
- $res = $object->setStatut(4);
+ if ($object->fk_statut == Ticket::STATUS_CLOSED) {
+ $res = $object->setStatut(Ticket::STATUS_ASSIGNED);
if ($res) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogReopen');
- $ret = $object->createTicketLog($user, $log_action);
+
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
@@ -544,7 +531,7 @@ class ActionsTicket
} // Categorisation dans projet
elseif ($action == 'classin' && $user->rights->ticket->write) {
if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- $object->setProject(GETPOST('projectid'));
+ $object->setProject(GETPOST('projectid', 'int'));
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
@@ -552,7 +539,7 @@ class ActionsTicket
} // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticket->write) {
if ($this->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- $object->setContract(GETPOST('contractid'));
+ $object->setContract(GETPOST('contractid', 'int'));
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
@@ -573,10 +560,7 @@ class ActionsTicket
// output the result of comparing two files as plain text
$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
- $ret = $object->createTicketLog($user, $log_action);
- if ($ret > 0) {
- setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
- }
+ setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
}
}
@@ -590,7 +574,7 @@ class ActionsTicket
if ($res) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
- $ret = $object->createTicketLog($user, $log_action);
+
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
@@ -1013,7 +997,7 @@ class ActionsTicket
{
global $langs;
- if ($action == 'create_ticket') {
+ if ($action == 'create') {
return $langs->trans("CreateTicket");
} elseif ($action == 'edit') {
return $langs->trans("EditTicket");
@@ -1498,9 +1482,13 @@ class ActionsTicket
print '
';
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;
+ }
+ else
+ {
+ $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status;
+ }
print '
';
print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]);
diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php
index 6076cdc4b1b..0eb1de8f8d2 100644
--- a/htdocs/ticket/class/ticket.class.php
+++ b/htdocs/ticket/class/ticket.class.php
@@ -1396,19 +1396,22 @@ class Ticket extends CommonObject
{
global $conf, $langs;
- if ($this->statut != 9) { // no closed
+ if ($this->statut != self::STATUS_CANCELED) { // no closed
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "ticket";
$sql .= " SET fk_statut = 1, date_read='" . $this->db->idate(dol_now()) . "'";
$sql .= " WHERE rowid = " . $this->id;
- dol_syslog(get_class($this) . "::markAsRead sql=" . $sql);
+ dol_syslog(get_class($this) . "::markAsRead");
$resql = $this->db->query($sql);
if ($resql) {
+ $this->actionmsg = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs));
+ $this->actionmsg2 = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs));
+
if (!$error && !$notrigger) {
// Call trigger
- $result=$this->call_trigger('TICKET_MARK_READ', $user);
+ $result=$this->call_trigger('TICKET_MODIFY', $user);
if ($result < 0) {
$error++;
}
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index 0b3a1c101e8..89dbd0acedc 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -49,13 +49,13 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicate
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int');
-$msg_id = GETPOST('msg_id', 'int');
-$socid = GETPOST('socid', 'int');
-$projectid = GETPOST('projectid', 'int');
+$msg_id = GETPOST('msg_id', 'int');
+$socid = GETPOST('socid', 'int');
+$projectid = GETPOST('projectid', 'int');
$search_fk_soc=GETPOST('$search_fk_soc', 'int')?GETPOST('$search_fk_soc', 'int'):GETPOST('socid', 'int');
$search_fk_project=GETPOST('search_fk_project', 'int')?GETPOST('search_fk_project', 'int'):GETPOST('projectid', 'int');
$search_fk_status = GETPOST('search_fk_statut', 'array');
-$mode = GETPOST('mode', 'alpha');
+$mode = GETPOST('mode', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
@@ -79,8 +79,8 @@ $extralabels = $extrafields->fetch_name_optionals_label('ticket');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
-if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition.
-if (! $sortorder) $sortorder="ASC";
+if (! $sortfield) $sortfield="t.datec";
+if (! $sortorder) $sortorder="DESC";
if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][]='openall'; // For backward compatibility
@@ -462,7 +462,7 @@ if ($projectid) print '' . $langs->trans('NewTicket').' ';
+ $newcardbutton = ' ' . $langs->trans('NewTicket').' ';
$newcardbutton.= ' ';
$newcardbutton.= '';
}
diff --git a/htdocs/ticket/new.php b/htdocs/ticket/new.php
deleted file mode 100644
index 267e3e63847..00000000000
--- a/htdocs/ticket/new.php
+++ /dev/null
@@ -1,96 +0,0 @@
-
- * Copyright (C) 2016 Christophe Battarel
- *
- * 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/ticket/new.php
- * \ingroup ticket
- */
-
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array('companies', 'other', 'ticket'));
-
-// Get parameters
-$id = GETPOST('id', 'int');
-$socid = GETPOST('socid', 'int');
-$contactid = GETPOST('contactid', 'int');
-$msg_id = GETPOST('msg_id', 'int');
-$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
-
-$action = GETPOST('action', 'aZ09');
-
-// Protection if external user
-if (!$user->rights->ticket->read || !$user->rights->ticket->write) {
- accessforbidden();
-}
-
-$object = new Ticket($db);
-$actionobject = new ActionsTicket($db);
-
-
-/*
- * Actions
- */
-
-$actionobject->doActions($action, $object);
-
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-$help_url = 'FR:DocumentationModuleTicket';
-$page_title = $actionobject->getTitle($action);
-llxHeader('', $page_title, $help_url);
-
-
-if ($action == 'create_ticket') {
- $formticket = new FormTicket($db);
-
- print load_fiche_titre($langs->trans('NewTicket'), '', 'title_ticket');
-
- $formticket->withfromsocid = $socid ? $socid : $user->societe_id;
- $formticket->withfromcontactid = $contactid ? $contactid : '';
- $formticket->withtitletopic = 1;
- $formticket->withnotifytiersatcreate = ($notifyTiers?1:0);
- $formticket->withusercreate = 1;
- $formticket->withref = 1;
- $formticket->fk_user_create = $user->id;
- $formticket->withfile = 2;
- $formticket->withextrafields = 1;
- $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid'));
- if (empty($defaultref)) {
- $defaultref = '';
- }
-
- $formticket->showForm(1);
-}
-
-//$somethingshown=$object->showLinkedObjectBlock();
-
-// End of page
-llxFooter('');
-$db->close();
diff --git a/test/phpunit/TicketTest.php b/test/phpunit/TicketTest.php
index b5bfd9212e9..4f3d06fc7cc 100644
--- a/test/phpunit/TicketTest.php
+++ b/test/phpunit/TicketTest.php
@@ -332,33 +332,6 @@ class TicketTest extends PHPUnit_Framework_TestCase
return $localobject;
}
- /**
- * testTicketcreateTicketLog
- *
- * @param Ticket $localobject Ticket
- * @return int
- *
- * @depends testTicketFetch
- * The depends says test is run only if previous is ok
- */
- /*public function testTicketcreateTicketLog($localobject)
- {
- global $conf,$user,$langs,$db;
- $conf=$this->savconf;
- $user=$this->savuser;
- $langs=$this->savlangs;
- $db=$this->savdb;
-
-
- $message = 'Test ticket log';
- $noemail = 1;
- $result=$localobject->createTicketLog($user, $message, $noemail);
- print __METHOD__." id=".$localobject->id." result=".$result."\n";
-
- $this->assertGreaterThan(0, $result);
- return $localobject;
- }*/
-
/**
* testTicketclose
*