';
- $formticket->showForm();
- }
+ if (empty($conf->global->TICKET_NOTIFICATION_EMAIL_FROM)) {
+ $langs->load("errors");
+ print '
';
+ print $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketEmailNotificationFrom")).'
';
+ print $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentities("Ticket"));
+ print '
';
+ }
+ else {
+ print '
'.$langs->trans('TicketPublicInfoCreateTicket').'
';
+ $formticket->showForm();
+ }
}
print '
';
diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php
index a4cc33f5506..1938c68de3e 100644
--- a/htdocs/public/ticket/view.php
+++ b/htdocs/public/ticket/view.php
@@ -23,15 +23,15 @@
*/
if (!defined('NOCSRFCHECK')) {
- define('NOCSRFCHECK', '1');
+ define('NOCSRFCHECK', '1');
}
// Do not check anti CSRF attack test
if (!defined('NOREQUIREMENU')) {
- define('NOREQUIREMENU', '1');
+ define('NOREQUIREMENU', '1');
}
// If there is no need to load and show top and left menu
if (!defined("NOLOGIN")) {
- define("NOLOGIN", '1');
+ define("NOLOGIN", '1');
}
// If this page is public (can be called outside logged session)
@@ -54,10 +54,10 @@ $action = GETPOST('action', 'aZ09');
$email = GETPOST('email', 'alpha');
if (GETPOST('btn_view_ticket')) {
- unset($_SESSION['email_customer']);
+ unset($_SESSION['email_customer']);
}
if (isset($_SESSION['email_customer'])) {
- $email = $_SESSION['email_customer'];
+ $email = $_SESSION['email_customer'];
}
$object = new ActionsTicket($db);
@@ -78,121 +78,121 @@ if ($cancel)
}
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close" || $action == "add_message") {
- $error = 0;
- $display_ticket = false;
- if (!strlen($track_id)) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
- $action = '';
- }
- if (!strlen($email)) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
- $action = '';
- } else {
- if (!isValidEmail($email)) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
- $action = '';
- }
- }
+ $error = 0;
+ $display_ticket = false;
+ if (!strlen($track_id)) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
+ $action = '';
+ }
+ if (!strlen($email)) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
+ $action = '';
+ } else {
+ if (!isValidEmail($email)) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorEmailInvalid"));
+ $action = '';
+ }
+ }
- if (!$error) {
- $ret = $object->fetch('', '', $track_id);
- if ($ret && $object->dao->id > 0) {
- // Check if emails provided is the one of author
- $emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2);
- if ($emailofticket == $email)
- {
- $display_ticket = true;
- $_SESSION['email_customer'] = $email;
- }
- // Check if emails provided is inside list of contacts
- else {
- $contacts = $object->dao->liste_contact(-1, 'external');
- foreach ($contacts as $contact) {
- if ($contact['email'] == $email) {
- $display_ticket = true;
- $_SESSION['email_customer'] = $email;
- break;
- } else {
- $display_ticket = false;
- }
- }
- }
- // Check email of thirdparty of ticket
- if ($object->dao->fk_soc > 0 || $object->dao->socid > 0) {
- $object->dao->fetch_thirdparty();
- if ($email == $object->dao->thirdparty->email) {
- $display_ticket = true;
- $_SESSION['email_customer'] = $email;
- }
- }
- // Check if email is email of creator
- if ($object->dao->fk_user_create > 0)
- {
- $tmpuser = new User($db);
- $tmpuser->fetch($object->dao->fk_user_create);
- if ($email == $tmpuser->email) {
- $display_ticket = true;
- $_SESSION['email_customer'] = $email;
- }
- }
- // Check if email is email of creator
- if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create)
- {
- $tmpuser = new User($db);
- $tmpuser->fetch($object->dao->fk_user_assign);
- if ($email == $tmpuser->email) {
- $display_ticket = true;
- $_SESSION['email_customer'] = $email;
- }
- }
- } else {
- $error++;
- array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id));
- $action = '';
- }
- }
+ if (!$error) {
+ $ret = $object->fetch('', '', $track_id);
+ if ($ret && $object->dao->id > 0) {
+ // Check if emails provided is the one of author
+ $emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2);
+ if ($emailofticket == $email)
+ {
+ $display_ticket = true;
+ $_SESSION['email_customer'] = $email;
+ }
+ // Check if emails provided is inside list of contacts
+ else {
+ $contacts = $object->dao->liste_contact(-1, 'external');
+ foreach ($contacts as $contact) {
+ if ($contact['email'] == $email) {
+ $display_ticket = true;
+ $_SESSION['email_customer'] = $email;
+ break;
+ } else {
+ $display_ticket = false;
+ }
+ }
+ }
+ // Check email of thirdparty of ticket
+ if ($object->dao->fk_soc > 0 || $object->dao->socid > 0) {
+ $object->dao->fetch_thirdparty();
+ if ($email == $object->dao->thirdparty->email) {
+ $display_ticket = true;
+ $_SESSION['email_customer'] = $email;
+ }
+ }
+ // Check if email is email of creator
+ if ($object->dao->fk_user_create > 0)
+ {
+ $tmpuser = new User($db);
+ $tmpuser->fetch($object->dao->fk_user_create);
+ if ($email == $tmpuser->email) {
+ $display_ticket = true;
+ $_SESSION['email_customer'] = $email;
+ }
+ }
+ // Check if email is email of creator
+ if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create)
+ {
+ $tmpuser = new User($db);
+ $tmpuser->fetch($object->dao->fk_user_assign);
+ if ($email == $tmpuser->email) {
+ $display_ticket = true;
+ $_SESSION['email_customer'] = $email;
+ }
+ }
+ } else {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id));
+ $action = '';
+ }
+ }
- if (!$error && $action == 'confirm_public_close' && $display_ticket)
- {
- if ($object->dao->close($user)) {
- setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
+ if (!$error && $action == 'confirm_public_close' && $display_ticket)
+ {
+ if ($object->dao->close($user)) {
+ setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
- $url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
- header("Location: ".$url);
- } else {
- $action = '';
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }
+ $url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
+ header("Location: ".$url);
+ } else {
+ $action = '';
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
- if (!$error && $action == "add_message" && $display_ticket && GETPOSTISSET('btn_add_message'))
- {
- // TODO Add message...
- $ret = $object->dao->newMessage($user, $action, 0);
+ if (!$error && $action == "add_message" && $display_ticket && GETPOSTISSET('btn_add_message'))
+ {
+ // TODO Add message...
+ $ret = $object->dao->newMessage($user, $action, 0);
- if (!$error)
- {
- $action = 'view_ticket';
- }
- }
+ if (!$error)
+ {
+ $action = 'view_ticket';
+ }
+ }
- if ($error || $errors) {
- setEventMessages($object->error, $object->errors, 'errors');
- if ($action == "add_message")
- {
- $action = 'presend';
- }
- else
- {
- $action = '';
- }
- }
+ if ($error || $errors) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ if ($action == "add_message")
+ {
+ $action = 'presend';
+ }
+ else
+ {
+ $action = '';
+ }
+ }
}
//var_dump($action);
//$object->doActions($action);
@@ -227,178 +227,178 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
print '
';
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") {
- if ($display_ticket)
- {
- // Confirmation close
- if ($action == 'close') {
- print $form->formconfirm($_SERVER["PHP_SELF"]."?track_id=".$track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1);
- }
+ if ($display_ticket)
+ {
+ // Confirmation close
+ if ($action == 'close') {
+ print $form->formconfirm($_SERVER["PHP_SELF"]."?track_id=".$track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1);
+ }
- print '
';
- print '
';
+ print '
';
- if ($action == 'presend') {
- print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket');
+ if ($action == 'presend') {
+ print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket');
- $formticket = new FormTicket($db);
+ $formticket = new FormTicket($db);
- $formticket->action = "add_message";
- $formticket->track_id = $object->dao->track_id;
- $formticket->id = $object->dao->id;
+ $formticket->action = "add_message";
+ $formticket->track_id = $object->dao->track_id;
+ $formticket->id = $object->dao->id;
- $formticket->param = array('track_id' => $object->dao->track_id, 'fk_user_create' => '-1', 'returnurl' => DOL_URL_ROOT.'/public/ticket/view.php');
+ $formticket->param = array('track_id' => $object->dao->track_id, 'fk_user_create' => '-1', 'returnurl' => DOL_URL_ROOT.'/public/ticket/view.php');
- $formticket->withfile = 2;
- $formticket->withcancel = 1;
+ $formticket->withfile = 2;
+ $formticket->withcancel = 1;
- $formticket->showMessageForm('100%');
- }
+ $formticket->showMessageForm('100%');
+ }
- if ($action != 'presend') {
- print '
\n";
+ if ($action != 'presend') {
+ print '
\n";
- print '
';
+ print '
';
- // List ticket
- print '
';
+ // List ticket
+ print '
';
- if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) {
- // New message
- print '
';
+ if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) {
+ // New message
+ print '
';
- // Close ticket
- if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) {
- print '
';
- }
- }
+ // Close ticket
+ if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) {
+ print '
';
+ }
+ }
- print '
';
- }
+ print '
';
+ }
- // Message list
- print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket');
- $object->viewTicketMessages(false, true, $object->dao);
- }
- else
- {
- print '
';
- }
+ // Message list
+ print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket');
+ $object->viewTicketMessages(false, true, $object->dao);
+ }
+ else
+ {
+ print '
';
+ }
} else {
- print '
'.$langs->trans("TicketPublicMsgViewLogIn").'
';
+ print '
'.$langs->trans("TicketPublicMsgViewLogIn").'
';
- print '
\n";
}
print "
";
diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php
index d8efc00f85e..bfaed41f21b 100644
--- a/htdocs/societe/class/api_contacts.class.php
+++ b/htdocs/societe/class/api_contacts.class.php
@@ -108,13 +108,14 @@ class Contacts extends DolibarrApi
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter contacts of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i}
+ * @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param int $includecount Count and return also number of elements the contact is used as a link for
* @return array Array of contact objects
*
* @throws RestException
*/
- public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $includecount = 0)
+ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $includecount = 0)
{
global $db, $conf;
@@ -135,6 +136,9 @@ class Contacts extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
+ if ($category > 0) {
+ $sql .= ", ".MAIN_DB_PREFIX."categorie_contact as c";
+ }
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as te ON te.fk_object = t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
// We need this table joined to the select in order to filter by sale
@@ -153,6 +157,13 @@ class Contacts extends DolibarrApi
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
+
+ // Select contacts of given category
+ if ($category > 0) {
+ $sql .= " AND c.fk_categorie = ".$db->escape($category);
+ $sql .= " AND c.fk_socpeople = t.rowid ";
+ }
+
// Add sql filters
if ($sqlfilters)
{
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index 5206e345193..1100432c854 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -107,10 +107,11 @@ class Thirdparties extends DolibarrApi
* Set to 2 to show only prospects
* Set to 3 to show only those are not customer neither prospect
* Set to 4 to show only suppliers
+ * @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.nom:like:'TheCompany%') and (t.date_creation:<:'20160101')"
* @return array Array of thirdparty objects
*/
- public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '')
+ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '')
{
global $db;
@@ -126,15 +127,27 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as t";
-
+ if ($category > 0) {
+ if ($mode != 4) $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
+ if (!in_array($mode, array(1,2,3))) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
+ }
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
- $sql .= " WHERE t.fk_stcomm = st.id";
+ $sql .= " WHERE t.entity IN ('.getEntity('societe').')";
+ $sql .= " AND t.fk_stcomm = st.id";
+
if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
if ($mode == 2) $sql .= " AND t.client IN (2, 3)";
if ($mode == 3) $sql .= " AND t.client IN (0)";
if ($mode == 4) $sql .= " AND t.fournisseur IN (1)";
- $sql .= ' AND t.entity IN ('.getEntity('societe').')';
+
+ // Select thirdparties of given category
+ if ($category > 0) {
+ if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$db->escape($category)." AND c.fk_soc = t.rowid"; }
+ elseif (!empty($mode) && $mode == 4) { $sql .= " AND cc.fk_categorie = ".$db->escape($category)." AND cc.fk_soc = t.rowid"; }
+ else { $sql .= " AND ((c.fk_categorie = ".$db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$db->escape($category)." AND cc.fk_soc = t.rowid))"; }
+ }
+
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
if ($socids) $sql .= " AND t.rowid IN (".$socids.")";
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index 561a491f1d1..dbdb15bfedc 100644
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -31,14 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
if (!empty($conf->projet->enabled)) {
- include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
- include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
}
if (!empty($conf->contrat->enabled)) {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
- include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php';
}
// Load translation files required by the page
@@ -127,422 +127,422 @@ if ($cancel)
}
if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
- $error = 0;
+ $error = 0;
- if (!GETPOST("subject", 'alpha')) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
- $action = 'create';
- } elseif (!GETPOST("message", 'alpha')) {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors');
- $action = 'create';
- }
+ if (!GETPOST("subject", 'alpha')) {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
+ $action = 'create';
+ } elseif (!GETPOST("message", 'alpha')) {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors');
+ $action = 'create';
+ }
- if (!$error) {
- $db->begin();
+ if (!$error) {
+ $db->begin();
- $object->ref = GETPOST("ref", 'alpha');
- $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
- $object->subject = GETPOST("subject", 'alpha');
- $object->message = GETPOST("message", 'none');
+ $object->ref = GETPOST("ref", 'alpha');
+ $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
+ $object->subject = GETPOST("subject", 'alpha');
+ $object->message = GETPOST("message", 'none');
- $object->type_code = GETPOST("type_code", 'alpha');
- $object->category_code = GETPOST("category_code", 'alpha');
- $object->severity_code = GETPOST("severity_code", 'alpha');
- $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
- $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
+ $object->type_code = GETPOST("type_code", 'alpha');
+ $object->category_code = GETPOST("category_code", 'alpha');
+ $object->severity_code = GETPOST("severity_code", 'alpha');
+ $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
+ $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
- $object->fk_project = GETPOST('projectid', 'int');
+ $object->fk_project = GETPOST('projectid', 'int');
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object);
- $id = $object->create($user);
- if ($id <= 0) {
- $error++;
- setEventMessage($object->error, $object->errors, 'errors');
- $action = 'create';
- }
+ $id = $object->create($user);
+ if ($id <= 0) {
+ $error++;
+ setEventMessage($object->error, $object->errors, 'errors');
+ $action = 'create';
+ }
- if (!$error)
- {
- // Add contact
- $contactid = GETPOST('contactid', 'int');
- $type_contact = GETPOST("type", 'alpha');
+ if (!$error)
+ {
+ // Add contact
+ $contactid = GETPOST('contactid', 'int');
+ $type_contact = GETPOST("type", 'alpha');
- if ($contactid > 0 && $type_contact) {
- $result = $object->add_contact($contactid, GETPOST("type"), 'external');
- }
+ if ($contactid > 0 && $type_contact) {
+ $result = $object->add_contact($contactid, GETPOST("type"), 'external');
+ }
- // altairis: link ticket to project
- if (GETPOST('projectid') > 0) {
- $object->setProject(GETPOST('projectid'));
- }
+ // altairis: link ticket to project
+ if (GETPOST('projectid') > 0) {
+ $object->setProject(GETPOST('projectid'));
+ }
- // Auto assign user
- if ($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE) {
- $result = $object->assignUser($user, $user->id, 1);
- $object->add_contact($user->id, "SUPPORTTEC", 'internal');
- }
+ // Auto assign user
+ if ($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE) {
+ $result = $object->assignUser($user, $user->id, 1);
+ $object->add_contact($user->id, "SUPPORTTEC", 'internal');
+ }
- // Auto assign contrat
- $contractid = 0;
- if ($conf->global->TICKET_AUTO_ASSIGN_CONTRACT_CREATE) {
- $contrat = new Contrat($db);
- $contrat->socid = $object->fk_soc;
- $list = $contrat->getListOfContracts();
+ // Auto assign contrat
+ $contractid = 0;
+ if ($conf->global->TICKET_AUTO_ASSIGN_CONTRACT_CREATE) {
+ $contrat = new Contrat($db);
+ $contrat->socid = $object->fk_soc;
+ $list = $contrat->getListOfContracts();
- if (is_array($list) && !empty($list)) {
- if (count($list) == 1) {
- $contractid = $list[0]->id;
- $object->setContract($contractid);
- } else {
- }
- }
- }
+ if (is_array($list) && !empty($list)) {
+ if (count($list) == 1) {
+ $contractid = $list[0]->id;
+ $object->setContract($contractid);
+ } else {
+ }
+ }
+ }
- // Auto create fiche intervention
- if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE)
- {
- $fichinter = new Fichinter($db);
- $fichinter->socid = $object->fk_soc;
- $fichinter->fk_project = GETPOST('projectid', 'int');
- $fichinter->fk_contrat = $contractid;
- $fichinter->author = $user->id;
- $fichinter->modelpdf = 'soleil';
- $fichinter->origin = $object->element;
- $fichinter->origin_id = $object->id;
+ // Auto create fiche intervention
+ if ($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE)
+ {
+ $fichinter = new Fichinter($db);
+ $fichinter->socid = $object->fk_soc;
+ $fichinter->fk_project = GETPOST('projectid', 'int');
+ $fichinter->fk_contrat = $contractid;
+ $fichinter->author = $user->id;
+ $fichinter->modelpdf = 'soleil';
+ $fichinter->origin = $object->element;
+ $fichinter->origin_id = $object->id;
- // Extrafields
- $extrafields->fetch_name_optionals_label($fichinter->table_element);
- $array_options = $extrafields->getOptionalsFromPost($fichinter->table_element);
- $fichinter->array_options = $array_options;
+ // Extrafields
+ $extrafields->fetch_name_optionals_label($fichinter->table_element);
+ $array_options = $extrafields->getOptionalsFromPost($fichinter->table_element);
+ $fichinter->array_options = $array_options;
- $id = $fichinter->create($user);
- if ($id <= 0) {
- setEventMessages($fichinter->error, null, 'errors');
- }
- }
- }
+ $id = $fichinter->create($user);
+ if ($id <= 0) {
+ setEventMessages($fichinter->error, null, 'errors');
+ }
+ }
+ }
- if (!$error)
- {
- // File transfer
- $object->copyFilesForTicket();
- }
+ if (!$error)
+ {
+ // File transfer
+ $object->copyFilesForTicket();
+ }
- if (!$error)
- {
- $db->commit();
+ if (!$error)
+ {
+ $db->commit();
- if (!empty($backtopage)) {
- $url = $backtopage;
- } else {
- $url = 'card.php?track_id='.$object->track_id;
- }
+ if (!empty($backtopage)) {
+ $url = $backtopage;
+ } else {
+ $url = 'card.php?track_id='.$object->track_id;
+ }
- header("Location: ".$url);
- exit;
- } else {
- $db->rollback();
- setEventMessages($object->error, $object->errors, 'errors');
- }
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
+ header("Location: ".$url);
+ exit;
+ } else {
+ $db->rollback();
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
if ($action == 'edit' && $user->rights->ticket->write) {
- $error = 0;
+ $error = 0;
- if ($object->fetch(GETPOST('id', 'int')) < 0) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
- $_GET["action"] = $_POST["action"] = '';
- }
+ if ($object->fetch(GETPOST('id', 'int')) < 0) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
+ $_GET["action"] = $_POST["action"] = '';
+ }
}
if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) {
- $error = 0;
+ $error = 0;
- $ret = $object->fetch(GETPOST('id', 'int'));
- if ($ret < 0) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
- $action = '';
- } elseif (!GETPOST("label")) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")));
- $action = 'edit';
- } elseif (!GETPOST("subject")) {
- $error++;
- array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
- $action = 'edit';
- }
+ $ret = $object->fetch(GETPOST('id', 'int'));
+ if ($ret < 0) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
+ $action = '';
+ } elseif (!GETPOST("label")) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")));
+ $action = 'edit';
+ } elseif (!GETPOST("subject")) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
+ $action = 'edit';
+ }
- if (!$error) {
- $db->begin();
+ if (!$error) {
+ $db->begin();
- $object->label = GETPOST("label", 'alphanohtml');
- $object->description = GETPOST("description", 'none');
+ $object->label = GETPOST("label", 'alphanohtml');
+ $object->description = GETPOST("description", 'none');
- //...
- $ret = $object->update($user);
- if ($ret <= 0) {
- $error++;
- setEventMessage($object->error, $object->errors, 'errors');
- $action = 'edit';
- }
+ //...
+ $ret = $object->update($user);
+ if ($ret <= 0) {
+ $error++;
+ setEventMessage($object->error, $object->errors, 'errors');
+ $action = 'edit';
+ }
- if (!$error && $ret > 0) {
- $db->commit();
- } else {
- $db->rollback();
- }
- }
+ if (!$error && $ret > 0) {
+ $db->commit();
+ } else {
+ $db->rollback();
+ }
+ }
}
// Mark as Read
if ($action == "mark_ticket_read" && $user->rights->ticket->write) {
- $object->fetch('', '', GETPOST("track_id", 'alpha'));
+ $object->fetch('', '', GETPOST("track_id", 'alpha'));
- if ($object->markAsRead($user) > 0)
- {
- setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
+ if ($object->markAsRead($user) > 0)
+ {
+ setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
- header("Location: card.php?track_id=".$object->track_id."&action=view");
- exit;
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- $action = 'view';
+ header("Location: card.php?track_id=".$object->track_id."&action=view");
+ exit;
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ $action = 'view';
}
// Assign to someone
if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) {
- $object->fetch('', '', GETPOST("track_id", 'alpha'));
- $useroriginassign = $object->fk_user_assign;
- $usertoassign = GETPOST('fk_user_assign', 'int');
+ $object->fetch('', '', GETPOST("track_id", 'alpha'));
+ $useroriginassign = $object->fk_user_assign;
+ $usertoassign = GETPOST('fk_user_assign', 'int');
- /*if (! ($usertoassign > 0)) {
+ /*if (! ($usertoassign > 0)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("AssignedTo")));
$action = 'view';
}*/
- if (!$error)
- {
- $ret = $object->assignUser($user, $usertoassign);
- if ($ret < 0) $error++;
- }
+ if (!$error)
+ {
+ $ret = $object->assignUser($user, $usertoassign);
+ if ($ret < 0) $error++;
+ }
- if (!$error) // Update list of contacts
- {
- // Si déjà un user assigné on le supprime des contacts
- if ($useroriginassign > 0) {
- $internal_contacts = $object->listeContact(-1, 'internal');
+ if (!$error) // Update list of contacts
+ {
+ // Si déjà un user assigné on le supprime des contacts
+ if ($useroriginassign > 0) {
+ $internal_contacts = $object->listeContact(-1, 'internal');
- foreach ($internal_contacts as $key => $contact) {
- if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) {
- }
- {
- //print "user à effacer : ".$useroriginassign;
- $object->delete_contact($contact['rowid']);
- }
- }
- }
+ foreach ($internal_contacts as $key => $contact) {
+ if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) {
+ }
+ {
+ //print "user à effacer : ".$useroriginassign;
+ $object->delete_contact($contact['rowid']);
+ }
+ }
+ }
- if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
- }
+ if ($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));
+ if (!$error)
+ {
+ // Log action in ticket logs table
+ $object->fetch_user($usertoassign);
+ $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
- setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
+ setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
- header("Location: card.php?track_id=".$object->track_id."&action=view");
- exit;
- } else {
- array_push($object->errors, $object->error);
- }
- $action = 'view';
+ header("Location: card.php?track_id=".$object->track_id."&action=view");
+ exit;
+ } else {
+ array_push($object->errors, $object->error);
+ }
+ $action = 'view';
}
if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) {
- $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
+ $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
- if ($ret > 0) {
- if (!empty($backtopage)) {
- $url = $backtopage;
- } else {
- $url = 'card.php?action=view&track_id='.$object->track_id;
- }
+ if ($ret > 0) {
+ if (!empty($backtopage)) {
+ $url = $backtopage;
+ } else {
+ $url = 'card.php?action=view&track_id='.$object->track_id;
+ }
- header("Location: ".$url);
- exit;
- } else {
- setEventMessages($object->error, null, 'errors');
- $action = 'presend';
- }
+ header("Location: ".$url);
+ exit;
+ } else {
+ setEventMessages($object->error, null, 'errors');
+ $action = 'presend';
+ }
}
if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write)
{
- $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
+ $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
- if ($object->close($user)) {
- setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
+ if ($object->close($user)) {
+ setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
- $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
- header("Location: ".$url);
- } else {
- $action = '';
- setEventMessages($object->error, $object->errors, 'errors');
- }
+ $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
+ header("Location: ".$url);
+ } else {
+ $action = '';
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
- $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
- if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
- $object->close($user);
+ $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
+ if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
+ $object->close($user);
- // Log action in ticket logs table
- $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
+ // Log action in ticket logs table
+ $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
- setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs');
+ setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs');
- $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
- header("Location: ".$url);
- } else {
- setEventMessages($object->error, $object->errors, 'errors');
- $action = '';
- }
+ $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
+ header("Location: ".$url);
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
+ }
}
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) {
- if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- if ($object->delete($user) > 0) {
- setEventMessages('
'.$langs->trans('TicketDeletedSuccess').'
', null, 'mesgs');
- Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
- exit;
- } else {
- $langs->load("errors");
- $mesg = '
'.$langs->trans($object->error).'
';
- $action = '';
- }
- }
+ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
+ if ($object->delete($user) > 0) {
+ setEventMessages('
'.$langs->trans('TicketDeletedSuccess').'
', null, 'mesgs');
+ Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
+ exit;
+ } else {
+ $langs->load("errors");
+ $mesg = '
'.$langs->trans($object->error).'
';
+ $action = '';
+ }
+ }
}
// Set parent company
if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
- if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
- $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
- header("Location: ".$url);
- exit();
- }
+ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
+ $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
+ $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
+ header("Location: ".$url);
+ exit();
+ }
}
if ($action == 'set_progression' && $user->rights->ticket->write) {
- if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- $result = $object->setProgression(GETPOST('progress', 'alpha'));
+ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
+ $result = $object->setProgression(GETPOST('progress', 'alpha'));
- $url = 'card.php?action=view&track_id='.$object->track_id;
- header("Location: ".$url);
- exit();
- }
+ $url = 'card.php?action=view&track_id='.$object->track_id;
+ header("Location: ".$url);
+ exit();
+ }
}
if ($action == 'setsubject') {
- if ($object->fetch(GETPOST('id', 'int'))) {
- if ($action == 'setsubject') {
- $object->subject = trim(GETPOST('subject', 'alpha'));
- }
+ if ($object->fetch(GETPOST('id', 'int'))) {
+ if ($action == 'setsubject') {
+ $object->subject = trim(GETPOST('subject', 'alpha'));
+ }
- if ($action == 'setsubject' && empty($object->subject)) {
- $mesg .= ($mesg ? '
' : '').$langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
- }
+ if ($action == 'setsubject' && empty($object->subject)) {
+ $mesg .= ($mesg ? '
' : '').$langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
+ }
- if (!$mesg) {
- if ($object->update($user) >= 0) {
- header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id);
- exit;
- }
- $mesg = $object->error;
- }
- }
+ if (!$mesg) {
+ if ($object->update($user) >= 0) {
+ header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id);
+ exit;
+ }
+ $mesg = $object->error;
+ }
+ }
}
if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
- if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- // prevent browser refresh from reopening ticket several times
- if ($object->fk_statut == Ticket::STATUS_CLOSED) {
- $res = $object->setStatut(Ticket::STATUS_ASSIGNED);
- if ($res) {
- // Log action in ticket logs table
- $log_action = $langs->trans('TicketLogReopen');
+ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
+ // prevent browser refresh from reopening ticket several times
+ if ($object->fk_statut == Ticket::STATUS_CLOSED) {
+ $res = $object->setStatut(Ticket::STATUS_ASSIGNED);
+ if ($res) {
+ // Log action in ticket logs table
+ $log_action = $langs->trans('TicketLogReopen');
- $url = 'card.php?action=view&track_id='.$object->track_id;
- header("Location: ".$url);
- exit();
- }
- }
- }
+ $url = 'card.php?action=view&track_id='.$object->track_id;
+ header("Location: ".$url);
+ exit();
+ }
+ }
+ }
} // Categorisation dans projet
elseif ($action == 'classin' && $user->rights->ticket->write) {
- if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- $object->setProject(GETPOST('projectid', 'int'));
- $url = 'card.php?action=view&track_id='.$object->track_id;
- header("Location: ".$url);
- exit();
- }
+ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
+ $object->setProject(GETPOST('projectid', 'int'));
+ $url = 'card.php?action=view&track_id='.$object->track_id;
+ header("Location: ".$url);
+ exit();
+ }
} // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticket->write) {
- if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
- $object->setContract(GETPOST('contractid', 'int'));
- $url = 'card.php?action=view&track_id='.$object->track_id;
- header("Location: ".$url);
- exit();
- }
+ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
+ $object->setContract(GETPOST('contractid', 'int'));
+ $url = 'card.php?action=view&track_id='.$object->track_id;
+ header("Location: ".$url);
+ exit();
+ }
} elseif ($action == "set_message" && $user->rights->ticket->manage) {
- // altairis: manage cancel button
- if (!GETPOST('cancel')) {
- $object->fetch('', '', GETPOST('track_id', 'alpha'));
- $oldvalue_message = $object->message;
- $fieldtomodify = GETPOST('message_initial');
+ // altairis: manage cancel button
+ if (!GETPOST('cancel')) {
+ $object->fetch('', '', GETPOST('track_id', 'alpha'));
+ $oldvalue_message = $object->message;
+ $fieldtomodify = GETPOST('message_initial');
- $object->message = $fieldtomodify;
- $ret = $object->update($user);
- if ($ret > 0) {
- $log_action = $langs->trans('TicketInitialMessageModified')." \n";
- // include the Diff class
- dol_include_once('/ticket/class/utils_diff.class.php');
- // output the result of comparing two files as plain text
- $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
+ $object->message = $fieldtomodify;
+ $ret = $object->update($user);
+ if ($ret > 0) {
+ $log_action = $langs->trans('TicketInitialMessageModified')." \n";
+ // include the Diff class
+ dol_include_once('/ticket/class/utils_diff.class.php');
+ // output the result of comparing two files as plain text
+ $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
- setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
- }
- }
+ setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
+ }
+ }
- $action = 'view';
+ $action = 'view';
} // Reopen ticket
elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) {
- if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
- $new_status = GETPOST('new_status', 'int');
- $old_status = $object->fk_statut;
- $res = $object->setStatut($new_status);
- if ($res) {
- // Log action in ticket logs table
- $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
+ if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
+ $new_status = GETPOST('new_status', 'int');
+ $old_status = $object->fk_statut;
+ $res = $object->setStatut($new_status);
+ if ($res) {
+ // Log action in ticket logs table
+ $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
- $url = 'card.php?action=view&track_id='.$object->track_id;
- header("Location: ".$url);
- exit();
- }
- }
+ $url = 'card.php?action=view&track_id='.$object->track_id;
+ header("Location: ".$url);
+ exit();
+ }
+ }
}
// Action to update one extrafield
@@ -619,544 +619,544 @@ llxHeader('', $page_title, $help_url);
if ($action == 'create' || $action == 'presend')
{
- $formticket = new FormTicket($db);
+ $formticket = new FormTicket($db);
- print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
+ print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
- $formticket->withfromsocid = $socid ? $socid : $user->socid;
- $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->withfromsocid = $socid ? $socid : $user->socid;
+ $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, 'create');
+ $formticket->showForm(1, 'create');
}
if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'
|| $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink')
{
- if ($res > 0)
- {
- // or for unauthorized internals users
- if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
- accessforbidden('', 0, 1);
- }
+ if ($res > 0)
+ {
+ // or for unauthorized internals users
+ if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
+ accessforbidden('', 0, 1);
+ }
- // Confirmation close
- if ($action == 'close') {
- print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1);
- if ($ret == 'html') {
- print '
';
- }
- }
- // Confirmation delete
- if ($action == 'delete') {
- print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1);
- }
- // Confirm reopen
- if ($action == 'reopen') {
- print $form->formconfirm($url_page_current.'?track_id='.$object->track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1);
- }
- // Confirmation status change
- if ($action == 'set_status') {
- $new_status = GETPOST('new_status');
- //var_dump($url_page_current . "?track_id=" . $object->track_id);
- print $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->statuts_short[$new_status])), "confirm_set_status", '', '', 1);
- }
+ // Confirmation close
+ if ($action == 'close') {
+ print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1);
+ if ($ret == 'html') {
+ print '
';
+ }
+ }
+ // Confirmation delete
+ if ($action == 'delete') {
+ print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1);
+ }
+ // Confirm reopen
+ if ($action == 'reopen') {
+ print $form->formconfirm($url_page_current.'?track_id='.$object->track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1);
+ }
+ // Confirmation status change
+ if ($action == 'set_status') {
+ $new_status = GETPOST('new_status');
+ //var_dump($url_page_current . "?track_id=" . $object->track_id);
+ print $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->statuts_short[$new_status])), "confirm_set_status", '', '', 1);
+ }
- // project info
- if ($projectid) {
- $projectstat = new Project($db);
- if ($projectstat->fetch($projectid) > 0) {
- $projectstat->fetch_thirdparty();
+ // project info
+ if ($projectid) {
+ $projectstat = new Project($db);
+ if ($projectstat->fetch($projectid) > 0) {
+ $projectstat->fetch_thirdparty();
- // To verify role of users
- //$userAccess = $object->restrictedProjectArea($user,'read');
- $userWrite = $projectstat->restrictedProjectArea($user, 'write');
- //$userDelete = $object->restrictedProjectArea($user,'delete');
- //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
+ // To verify role of users
+ //$userAccess = $object->restrictedProjectArea($user,'read');
+ $userWrite = $projectstat->restrictedProjectArea($user, 'write');
+ //$userDelete = $object->restrictedProjectArea($user,'delete');
+ //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
- $head = project_prepare_head($projectstat);
- dol_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project'));
+ $head = project_prepare_head($projectstat);
+ dol_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project'));
- /*
+ /*
* Projet synthese pour rappel
*/
- print '
';
+ print '';
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
- // Ref
- print '| '.$langs->trans('Ref').' | ';
- // Define a complementary filter for search of next/prev ref.
- if (!$user->rights->projet->all->lire) {
- $objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0);
- $projectstat->next_prev_filter = " rowid in (".(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
- }
- print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', '');
- print ' |
';
+ // Ref
+ print '| '.$langs->trans('Ref').' | ';
+ // Define a complementary filter for search of next/prev ref.
+ if (!$user->rights->projet->all->lire) {
+ $objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0);
+ $projectstat->next_prev_filter = " rowid in (".(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
+ }
+ print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', '');
+ print ' |
';
- // Label
- print '| '.$langs->trans("Label").' | '.$projectstat->title.' |
';
+ // Label
+ print '| '.$langs->trans("Label").' | '.$projectstat->title.' |
';
- // Customer
- print "| ".$langs->trans("ThirdParty")." | ";
- print '';
- if ($projectstat->thirdparty->id > 0) {
- print $projectstat->thirdparty->getNomUrl(1);
- } else {
- print ' ';
- }
+ // Customer
+ print " |
| ".$langs->trans("ThirdParty")." | ";
+ print '';
+ if ($projectstat->thirdparty->id > 0) {
+ print $projectstat->thirdparty->getNomUrl(1);
+ } else {
+ print ' ';
+ }
- print ' |
';
+ print '';
- // Visibility
- print '| '.$langs->trans("Visibility").' | ';
- if ($projectstat->public) {
- print $langs->trans('SharedProject');
- } else {
- print $langs->trans('PrivateProject');
- }
+ // Visibility
+ print ' |
| '.$langs->trans("Visibility").' | ';
+ if ($projectstat->public) {
+ print $langs->trans('SharedProject');
+ } else {
+ print $langs->trans('PrivateProject');
+ }
- print ' |
';
+ print '';
- // Statut
- print '| '.$langs->trans("Status").' | '.$projectstat->getLibStatut(4).' |
';
+ // Statut
+ print '| '.$langs->trans("Status").' | '.$projectstat->getLibStatut(4).' |
';
- print "
";
+ print "
";
- print '
';
- } else {
- print "ErrorRecordNotFound";
- }
- } elseif ($socid > 0) {
- $object->fetch_thirdparty();
- $head = societe_prepare_head($object->thirdparty);
+ print '