diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 043ef502092..ad9c15926cc 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -22,29 +22,31 @@ */ /** - * \file htdocs/ticket/card.php - * \ingroup ticket + * \file htdocs/ticket/card.php + * \ingroup ticket + * \brief Page to create/edit/view Tickets */ // Load Dolibarr environment 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/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; 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'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + if (isModEnabled('project')) { - 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'; } if (isModEnabled('contrat')) { + 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 @@ -52,20 +54,22 @@ $langs->loadLangs(array("companies", "other", "ticket")); // Get parameters $id = GETPOST('id', 'int'); -$socid = GETPOST('socid', 'int'); -$track_id = GETPOST('track_id', 'alpha', 3); $ref = GETPOST('ref', 'alpha'); +$track_id = GETPOST('track_id', 'alpha', 3); +$socid = GETPOST('socid', 'int'); +$contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); -$cancel = GETPOST('cancel', 'alpha'); +$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); + $action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$contactid = GETPOST('contactid', 'int'); - -$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); $sortfield = GETPOST('sortfield', 'aZ09comma') ? GETPOST('sortfield', 'aZ09comma') : "a.datep"; $sortorder = GETPOST('sortorder', 'aZ09comma') ? GETPOST('sortorder', 'aZ09comma') : "desc"; +$search_rowid = GETPOST('search_rowid'); +$search_agenda_label = GETPOST('search_agenda_label'); if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -75,8 +79,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } -$search_rowid = GETPOST('search_rowid'); -$search_agenda_label = GETPOST('search_agenda_label'); + // Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ticketcard', 'globalcard')); @@ -102,13 +105,13 @@ if (empty($action) && empty($id) && empty($ref)) { $action = 'view'; } -//Select mail models is same action as add_message +// Select mail models is same action as add_message if (GETPOST('modelselected', 'alpha')) { $action = 'presend'; } // Load object -//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id || $track_id || $ref) { $res = $object->fetch($id, $ref, $track_id); if ($res >= 0) { @@ -129,8 +132,10 @@ if ($user->socid > 0) $socid = $user->socid; $result = restrictedArea($user, 'ticket', $object->id); $triggermodname = 'TICKET_MODIFY'; -$permissiontoread = $user->hasRight('ticket', 'read'); -$permissiontoadd = $user->hasRight('ticket', 'write'); + +// Permissions +$permissiontoread = $user->hasRight('ticket', 'read'); +$permissiontoadd = $user->hasRight('ticket', 'write'); $permissiontodelete = $user->hasRight('ticket', 'delete'); $upload_dir = $conf->ticket->dir_output; @@ -416,7 +421,7 @@ if (empty($reshook)) { } if (!$error) { // Update list of contacts - // Si déjà un user assigné on le supprime des contacts + // If a user has already been assigned, we delete him from the contacts. if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); foreach ($internal_contacts as $key => $contact) { @@ -530,6 +535,7 @@ if (empty($reshook)) { } } + // Set progress status 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')); @@ -540,6 +546,7 @@ if (empty($reshook)) { } } + // Set categories if ($action == 'set_categories' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setCategories(GETPOST('categories', 'array')); @@ -550,6 +557,7 @@ if (empty($reshook)) { } } + // Set Subject if ($action == 'setsubject' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'))) { if ($action == 'setsubject') { @@ -650,7 +658,7 @@ if (empty($reshook)) { } } - // Action to update one extrafield + // Action to update an extrafield if ($action == "update_extras" && $permissiontoadd) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); @@ -910,7 +918,7 @@ if ($action == 'create' || $action == 'presend') { print ''; - // Statut + // Status print '