--- /tmp/dsg/dolibarr/htdocs/ticket/github_19.0.3_agenda.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_agenda.php @@ -24 +23,0 @@ -// Load Dolibarr environment @@ -29 +28 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"; @@ -33,5 +31,0 @@ -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'; -} @@ -49,6 +43,3 @@ -// Store current page url -$url_page_current = DOL_URL_ROOT.'/ticket/agenda.php'; - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", "alpha"); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -58,6 +49,2 @@ -if (!$sortfield) { - $sortfield = "a.datep,a.id"; -} -if (!$sortorder) { - $sortorder = "DESC"; -} +if (!$sortfield) $sortfield = "a.datep,a.id"; +if (!$sortorder) $sortorder = "DESC"; @@ -68 +55,2 @@ -if (GETPOST('actioncode', 'array')) { +if (GETPOST('actioncode', 'array')) +{ @@ -70,8 +58,6 @@ - if (!count($actioncode)) { - $actioncode = '0'; - } -} 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'); + if (!count($actioncode)) $actioncode = '0'; +} +else +{ + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} @@ -94,5 +80,7 @@ -if ($user->socid > 0) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'ticket', $object->id, ''); - +$socid = 0; +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +$result = restrictedArea($user, 'ticket', $id, ''); + +if (!$user->rights->ticket->read) { + accessforbidden(); +} @@ -100 +88,2 @@ -if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { +if ($user->socid > 0 && ($object->fk_soc != $user->socid)) +{ @@ -104 +93 @@ -if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) { +if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { @@ -108 +96,0 @@ -$permissiontoadd = $user->rights->ticket->write; @@ -117,5 +105,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -127 +114,2 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers +{ @@ -132,9 +119,0 @@ -// Set parent company -if ($action == 'set_thirdparty' && $user->hasRight('ticket', 'write')) { - if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = $_SERVER["PHP_SELF"].'?track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); - exit(); - } -} @@ -152,5 +131,2 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/ticketnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) { - $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); -} -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|DE:Modul_Terminplanung'; - +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); +$help_url = 'FR:DocumentationModuleTicket'; @@ -160,12 +136,12 @@ - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - - dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print dol_get_fiche_end(); -} - -if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) { - $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id); + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + + dol_fiche_end(); +} + +if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; @@ -173 +149 @@ - $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid); + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; @@ -177 +153 @@ -print dol_get_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); +dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); @@ -188,2 +164,3 @@ - $morehtmlref .= $fuser->getNomUrl(-1); -} elseif (!empty($object->email_msgid)) { + $morehtmlref .= $fuser->getNomUrl(0); +} +if (!empty($object->origin_email)) { @@ -191,6 +168 @@ - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')'; -} elseif (!empty($object->origin_email)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("CreatedByPublicPortal").')'; + $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; @@ -200,5 +172,11 @@ -if (isModEnabled("societe")) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"'); - if ($action != 'editcustomer' && $permissiontoadd) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; +if (!empty($conf->societe->enabled)) +{ + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + }*/ + $morehtmlref .= ' : '; + if ($action == 'editcustomer') { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); @@ -206 +183,0 @@ - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); @@ -210 +187,2 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) +{ @@ -212,3 +190,3 @@ - if (0) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + $morehtmlref .= '
'.$langs->trans('Project'); + if ($user->rights->ticket->write) + { @@ -216 +194,2 @@ - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; @@ -218 +197,11 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } @@ -221 +209,0 @@ - $morehtmlref .= '
'; @@ -225,3 +213,2 @@ - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + } else { + $morehtmlref .= ''; @@ -234 +221 @@ -$linkback = ''.$langs->trans("BackToList").' '; +$linkback = ''.$langs->trans("BackToList").' '; @@ -238 +225 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -243 +230,2 @@ -if (!empty($object->id)) { +if (!empty($object->id)) +{ @@ -245,8 +233,4 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.$contextpage; - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.$limit; - } - - $morehtmlright = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + + $morehtmlright = ''; @@ -255,13 +239,6 @@ - $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); - $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; - $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1, array('morecss'=>'btnTitleSelected')); - - // Show link to send an email (if read and not closed) - $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; - $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle'; - $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus); - - // Show link to add a message (if read and not closed) - $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; - $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle'; - $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); + $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); + + // Show link to add a message (if read and not closed) + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init'; + $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); @@ -270,2 +247,2 @@ - $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; - $url = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep=now&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"]); @@ -274,7 +251,2 @@ - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $cachekey = 'count_events_ticket_'.$object->id; - $nbEvent = dol_getcache($cachekey); - - $titlelist = $langs->trans("ActionsOnTicket").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); - - print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); + + print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); @@ -285,2 +256,0 @@ - $filters['search_rowid'] = $search_rowid; - --- /tmp/dsg/dolibarr/htdocs/ticket/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_card.php @@ -2,7 +2,3 @@ -/* Copyright (C) 2013-2016 Jean-François FERRY - * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2018 Laurent Destailleur - * Copyright (C) 2021 Frédéric France - * Copyright (C) 2021 Alexandre Spangaro - * Copyright (C) 2022-2023 Charlene Benke - * Copyright (C) 2023 Benjamin Falière +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2018 Laurent Destailleur @@ -25,3 +21,2 @@ - * \file htdocs/ticket/card.php - * \ingroup ticket - * \brief Page to create/edit/view Tickets + * \file htdocs/ticket/card.php + * \ingroup ticket @@ -30 +24,0 @@ -// Load Dolibarr environment @@ -34 +27,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -37,0 +31 @@ +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -39,3 +33,2 @@ -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -44 +36,0 @@ - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -46,2 +38 @@ -if (isModEnabled('contrat')) { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php'; +if (!empty($conf->contrat->enabled)) { @@ -49,0 +41 @@ + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php'; @@ -56,0 +49,2 @@ +$socid = GETPOST('socid', 'int'); +$track_id = GETPOST('track_id', 'alpha', 3); @@ -58,3 +51,0 @@ -$track_id = GETPOST('track_id', 'alpha', 3); -$socid = GETPOST('socid', 'int'); -$contactid = GETPOST('contactid', 'int'); @@ -61,0 +53,3 @@ +$cancel = GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'aZ09'); + @@ -64,8 +58,9 @@ -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); - -$sortfield = GETPOST('sortfield', 'aZ09comma') ? GETPOST('sortfield', 'aZ09comma') : "a.datep"; -$sortorder = GETPOST('sortorder', 'aZ09comma') ? GETPOST('sortorder', 'aZ09comma') : "desc"; -$search_rowid = GETPOST('search_rowid'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); + +if (GETPOST('actioncode', 'array')) { + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} else { + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} @@ -73,10 +67,0 @@ - -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); -} - @@ -96 +81 @@ -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); @@ -98,4 +83,3 @@ -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -104,5 +88,3 @@ -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} - -// Select mail models is same action as add_message +if (empty($action) && empty($id) && empty($ref)) $action = 'view'; + +//Select mail models is same action as add_message @@ -114 +96 @@ -//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // 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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -117 +99,2 @@ - if ($res >= 0) { + if ($res >= 0) + { @@ -123,4 +105,0 @@ -$now = dol_now(); - -$actionobject = new ActionsTicket($db); - @@ -131,3 +110,2 @@ -if ($user->socid > 0) { - $socid = $user->socid; -} +//if ($user->socid > 0) accessforbidden(); +//if ($user->socid > 0) $socid = $user->socid; @@ -137,8 +115,5 @@ - -// Permissions -$permissiontoread = $user->hasRight('ticket', 'read'); -$permissiontoadd = $user->hasRight('ticket', 'write'); -$permissiontodelete = $user->hasRight('ticket', 'delete'); - -$upload_dir = $conf->ticket->dir_output; - +$permissiontoadd = $user->rights->ticket->write; + +$actionobject = new ActionsTicket($db); + +$now = dol_now(); @@ -153,5 +128,2 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -$error = 0; +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + @@ -160 +132,2 @@ - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers{ + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers{ + { @@ -165,12 +137,0 @@ - $backurlforlist = DOL_URL_ROOT.'/ticket/list.php'; - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/ticket/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - @@ -178,2 +139,2 @@ - if (!empty($backtopageforcancel)) { - header("Location: ".$backtopageforcancel); + if (!empty($backtopage)) { + header("Location: " . $backtopage); @@ -181,4 +142,2 @@ - } elseif (!empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } + } + @@ -189 +148 @@ - if (GETPOST('save', 'alpha') && $permissiontoadd) { + if (GETPOST('add', 'alpha') && $user->rights->ticket->write) { @@ -192,13 +151 @@ - if (!GETPOST("type_code", 'alpha')) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTypeRequest")), null, 'errors'); - $action = 'create'; - } elseif (!GETPOST("category_code", 'alpha')) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketCategory")), null, 'errors'); - $action = 'create'; - } elseif (!GETPOST("severity_code", 'alpha')) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketSeverity")), null, 'errors'); - $action = 'create'; - } elseif (!GETPOST("subject", 'alphanohtml')) { + if (!GETPOST("subject", 'alphanohtml')) { @@ -213,4 +159,0 @@ - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) { - $error++; - } @@ -221,37 +164,14 @@ - $getRef = GETPOST("ref", 'alphanohtml'); - - $test = new Ticket($db); - if ($test->fetch('', $getRef) > 0) { - $object->ref = $object->getDefaultRef(); - $object->track_id = null; - setEventMessage($langs->trans('TicketRefAlreadyUsed', $getRef, $object->ref)); - } else { - $object->ref = $getRef; - } - - $object->fk_soc = $object->socid = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; - $object->subject = GETPOST("subject", 'alphanohtml'); - $object->message = GETPOST("message", 'restricthtml'); - - $object->type_code = GETPOST("type_code", 'alpha'); - $object->type_label = $langs->trans($langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label')); - $object->category_code = GETPOST("category_code", 'alpha'); - $object->category_label = $langs->trans($langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label')); - $object->severity_code = GETPOST("severity_code", 'alpha'); - $object->severity_label = $langs->trans($langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label')); - $object->fk_user_create = $user->id; - $object->email_from = $user->email; - $object->origin_email = null; - - $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); - $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; - - $fk_user_assign = GETPOST("fk_user_assign", 'int'); - if ($fk_user_assign > 0) { - $object->fk_user_assign = $fk_user_assign; - $object->status = $object::STATUS_ASSIGNED; - } - - $object->fk_project = $projectid; - $object->fk_contract = GETPOST('fk_contract', 'int'); - + $object->ref = GETPOST("ref", 'alphanohtml'); + $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; + $object->subject = GETPOST("subject", 'alphanohtml'); + $object->message = GETPOST("message", 'restricthtml'); + + $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'); + + $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -262 +182 @@ - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessage($object->error, $object->errors, 'errors'); @@ -271,4 +190,0 @@ - // Category association - $categories = GETPOST('categories', 'array'); - $object->setCategories($categories); - @@ -276,20 +192,6 @@ - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, 'external'); - } - - // Link ticket to project - if (GETPOST('origin', 'alpha') == 'projet') { - $projectid = GETPOST('originid', 'int'); - } else { - $projectid = GETPOST('projectid', 'int'); - } - - if ($projectid > 0) { - $object->setProject($projectid); - } - - // Auto mark as read if created from backend - if (getDolGlobalString('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND') && $user->hasRight('ticket', 'write')) { - if (! $object->markAsRead($user) > 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + $result = $object->add_contact($contactid, GETPOST("type"), 'external'); + } + + // altairis: link ticket to project + if (GETPOST('projectid') > 0) { + $object->setProject(GETPOST('projectid')); @@ -299 +201 @@ - if (getDolGlobalString('TICKET_AUTO_ASSIGN_USER_CREATE')) { + if ($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE) { @@ -302,0 +205,38 @@ + + // 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 { + } + } + } + + // 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; + + $id = $fichinter->create($user); + if ($id <= 0) { + setEventMessages($fichinter->error, null, 'errors'); + } + } @@ -307 +247 @@ - $object->copyFilesForTicket(''); // trackid is forced to '' because files were uploaded when no id for ticket exists yet and trackid was '' + $object->copyFilesForTicket(); @@ -314,5 +254 @@ - if (empty($id)) { - $url = $backtopage; - } else { - $url = 'card.php?track_id='.urlencode($object->track_id); - } + $url = $backtopage; @@ -320,4 +256,4 @@ - $url = 'card.php?track_id='.urlencode($object->track_id); - } - - header("Location: ".$url); + $url = 'card.php?track_id=' . $object->track_id; + } + + header("Location: " . $url); @@ -331,5 +267,4 @@ - $action = 'create'; - } - } - - if ($action == 'update' && $permissiontoadd && $object->status < Ticket::STATUS_CLOSED) { + } + } + + if ($action == 'edit' && $user->rights->ticket->write) { @@ -338 +273,11 @@ - $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha')); + 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; + + $ret = $object->fetch(GETPOST('id', 'int')); @@ -341,13 +286,10 @@ - array_push($object->errors, $langs->trans('ErrorTicketIsNotValid')); - } - - // check fields - if (!$error) { - if (!GETPOST('subject', 'alpha')) { - $error++; - array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject'))); - } - $ret = $extrafields->setOptionalsFromPost(null, $object); - 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", 'alphanohtml')) { + $error++; + array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"))); + $action = 'edit'; @@ -359,5 +301,4 @@ - $object->subject = GETPOST('subject', 'alpha'); - $object->type_code = GETPOST('type_code', 'alpha'); - $object->category_code = GETPOST('category_code', 'alpha'); - $object->severity_code = GETPOST('severity_code', 'alpha'); - + $object->label = GETPOST("label", 'alphanohtml'); + $object->description = GETPOST("description", 'restricthtml'); + + //... @@ -365,4 +306,8 @@ - if ($ret > 0) { - // Category association - $categories = GETPOST('categories', 'array'); - $object->setCategories($categories); + if ($ret <= 0) { + $error++; + setEventMessage($object->error, $object->errors, 'errors'); + $action = 'edit'; + } + + if (!$error && $ret > 0) { + $db->commit(); @@ -370,4 +314,0 @@ - $error++; - } - - if ($error) { @@ -375,21 +316 @@ - } else { - $db->commit(); - } - } - - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } else { - if (!empty($backtopage)) { - if (empty($id)) { - $url = $backtopage; - } else { - $url = 'card.php?track_id='.urlencode($object->track_id); - } - } else { - $url = 'card.php?track_id='.urlencode($object->track_id); - } - - header('Location: '.$url); - exit(); + } @@ -400 +321 @@ - if ($action == "set_read" && $permissiontoadd) { + if ($action == "mark_ticket_read" && $user->rights->ticket->write) { @@ -406 +327 @@ - header("Location: card.php?track_id=".$object->track_id); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); @@ -415 +336 @@ - if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $permissiontoadd) { + if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) { @@ -428,7 +349,6 @@ - if ($ret < 0) { - $error++; - } - } - - if (!$error) { // Update list of contacts - // If a user has already been assigned, we delete him from the contacts. + if ($ret < 0) $error++; + } + + if (!$error) // Update list of contacts + { + // Si déjà un user assigné on le supprime des contacts @@ -436 +356,2 @@ - $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); + $internal_contacts = $object->listeContact(-1, 'internal'); + @@ -438,17 +359,10 @@ - if ($contact['id'] !== $usertoassign) { - $result = $object->delete_contact($contact['rowid']); - if ($result<0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - } - - if ($usertoassign > 0 && $usertoassign!==$useroriginassign) { - $result = $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); - if ($result<0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } + 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); @@ -459,0 +374 @@ + $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); @@ -462 +377,2 @@ - header("Location: card.php?track_id=".$object->track_id); + + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); @@ -470,4 +386,3 @@ - // Action to add a message (private or not, with email or not). - // This may also send an email (concatenated with email_intro and email footer if checkbox was selected) - if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $permissiontoread) { - $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0), 0); + // Action to add an action (not a message) + if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) { + $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0)); @@ -479,4 +394,4 @@ - $url = 'card.php?track_id='.urlencode($object->track_id); - } - - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + } + + header("Location: " . $url); @@ -485 +400 @@ - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($object->error, null, 'errors'); @@ -490 +405 @@ - if (($action == "confirm_close" || $action == "confirm_abandon") && GETPOST('confirm', 'alpha') == 'yes' && $permissiontoadd) { + if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) { @@ -493 +408 @@ - if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0))) { + if ($object->close($user)) { @@ -496,2 +411,2 @@ - $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); @@ -504 +419 @@ - if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes' && $permissiontoadd) { + if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') { @@ -509,4 +424,7 @@ - setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs'); - - $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); + // Log action in ticket logs table + $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); + + setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); + + $url = 'card.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); @@ -519 +437 @@ - if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $permissiontodelete) { + if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { @@ -522,2 +440,2 @@ - setEventMessages('
'.$langs->trans('TicketDeletedSuccess').'
', null, 'mesgs'); - Header("Location: ".DOL_URL_ROOT."/ticket/list.php"); + setEventMessages('
' . $langs->trans('TicketDeletedSuccess') . '
', null, 'mesgs'); + Header("Location: " . DOL_URL_ROOT . "/ticket/list.php"); @@ -527 +445 @@ - $mesg = '
'.$langs->trans($object->error).'
'; + $mesg = '
' . $langs->trans($object->error) . '
'; @@ -534 +452 @@ - if ($action == 'set_thirdparty' && $user->hasRight('ticket', 'write')) { + if ($action == 'set_thirdparty' && $user->rights->societe->creer) { @@ -537,2 +455,2 @@ - $url = $_SERVER["PHP_SELF"].'?track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); @@ -543,2 +461 @@ - // Set progress status - if ($action == 'set_progression' && $user->hasRight('ticket', 'write')) { + if ($action == 'set_progression' && $user->rights->ticket->write) { @@ -548,2 +465,2 @@ - $url = 'card.php?track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); @@ -554,13 +471 @@ - // Set categories - if ($action == 'set_categories' && $user->hasRight('ticket', 'write')) { - if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setCategories(GETPOST('categories', 'array')); - - $url = 'card.php?track_id='.$object->track_id; - header("Location: ".$url); - exit(); - } - } - - // Set Subject - if ($action == 'setsubject' && $user->hasRight('ticket', 'write')) { + if ($action == 'setsubject') { @@ -569 +474 @@ - $object->subject = GETPOST('subject', 'alphanohtml'); + $object->subject = trim(GETPOST('subject', 'alphanohtml')); @@ -573,5 +478,4 @@ - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors'); - } - - if (!$error) { + $mesg .= ($mesg ? '
' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); + } + + if (!$mesg) { @@ -579 +483 @@ - header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id); + header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); @@ -581,9 +485,7 @@ - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - } - - if ($action == 'confirm_reopen' && $user->hasRight('ticket', 'manage') && !GETPOST('cancel')) { + } + $mesg = $object->error; + } + } + } + + if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) { @@ -592 +494 @@ - if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) { + if ($object->fk_statut == Ticket::STATUS_CLOSED || $object->fk_statut == Ticket::STATUS_CANCELED) { @@ -595,2 +497,5 @@ - $url = 'card.php?track_id='.$object->track_id; - header("Location: ".$url); + // Log action in ticket logs table + $log_action = $langs->trans('TicketLogReopen'); + + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); @@ -598,8 +503,5 @@ - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - } elseif ($action == 'classin' && $permissiontoadd) { - // Categorisation dans projet + } + } + } + } // Categorisation dans projet + elseif ($action == 'classin' && $user->rights->ticket->write) { @@ -607,3 +509,3 @@ - $object->setProject($projectid); - $url = 'card.php?track_id='.$object->track_id; - header("Location: ".$url); + $object->setProject(GETPOST('projectid', 'int')); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); @@ -612,2 +514,2 @@ - } elseif ($action == 'setcontract' && $permissiontoadd) { - // Categorisation dans contrat + } // Categorisation dans contrat + elseif ($action == 'setcontract' && $user->rights->ticket->write) { @@ -616,2 +518,2 @@ - $url = 'card.php?track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); @@ -620 +522,2 @@ - } elseif ($action == "set_message" && $user->hasRight('ticket', 'manage')) { + } elseif ($action == "set_message" && $user->rights->ticket->manage) { + // altairis: manage cancel button @@ -623 +526 @@ - //$oldvalue_message = $object->message; + $oldvalue_message = $object->message; @@ -629 +532,3 @@ - //include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php'; + $log_action = $langs->trans('TicketInitialMessageModified') . " \n"; + // include the Diff class + dol_include_once('/ticket/class/utils_diff.class.php'); @@ -631 +536 @@ - //$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); + $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); @@ -634,3 +538,0 @@ - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); @@ -641,2 +543,2 @@ - } elseif ($action == 'confirm_set_status' && $permissiontoadd && !GETPOST('cancel')) { - // Reopen ticket + } // Reopen ticket + elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { @@ -645 +547 @@ - //$old_status = $object->status; + $old_status = $object->fk_statut; @@ -648,2 +550,5 @@ - $url = 'card.php?track_id='.$object->track_id; - header("Location: ".$url); + // 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); @@ -651,9 +556,6 @@ - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - - // Action to update an extrafield - if ($action == "update_extras" && $permissiontoadd) { + } + } + } + + // Action to update one extrafield + if ($action == "update_extras" && !empty($permissiontoadd)) { @@ -661,14 +563,9 @@ - - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - - if (!$error) { - $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result < 0) { - $error++; - } - } - - if ($error) { + $attributekey = GETPOST('attribute', 'alpha'); + $attributekeylong = 'options_' . $attributekey; + $object->array_options['options_' . $attributekey] = GETPOST($attributekeylong, ' alpha'); + + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { @@ -677,7 +574,4 @@ - } else { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - $action = 'view'; - } - } - - if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $permissiontoadd) { + } + } + + if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) { @@ -691,0 +586,2 @@ + $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); + @@ -693,3 +588,0 @@ - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); @@ -701,2 +594,2 @@ - $permissiondellink = $user->hasRight('ticket', 'write'); - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + $permissiondellink = $user->rights->ticket->write; + include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -705,2 +598,3 @@ - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - //var_dump($action);exit; + $upload_dir = $conf->ticket->dir_output; + $permissiontoadd = $user->rights->ticket->write; + include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; @@ -712,2 +606,2 @@ - $trackid = 'tic'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + $trackid = 'tic' . $object->id; + include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; @@ -716,3 +610 @@ - if (GETPOSTISSET('actionbis') && $action == 'presend') { - $action = 'presend_addmessage'; - } + if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; @@ -720 +611,0 @@ - @@ -729,11 +620,9 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} - -$help_url = 'EN:Module_Ticket|FR:DocumentationModuleTicket'; - -$title = $actionobject->getTitle($action); - -llxHeader('', $title, $help_url); - -if ($action == 'create' || $action == 'presend') { +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); + +$help_url = 'FR:DocumentationModuleTicket'; +$page_title = $actionobject->getTitle($action); + +llxHeader('', $page_title, $help_url); + +if ($action == 'create' || $action == 'presend') +{ @@ -744 +632,0 @@ - $formticket->trackid = ''; // TODO Use a unique key 'tic' to avoid conflict in upload file feature @@ -748,2 +636,2 @@ - $formticket->withnotifytiersatcreate = ($notifyTiers ? 1 : (getDolGlobalString('TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION') ? 1 : 0)); - $formticket->withusercreate = 0; + $formticket->withnotifytiersatcreate = ($notifyTiers ? 1 : 0); + $formticket->withusercreate = 1; @@ -755,58 +643,12 @@ - - $formticket->withcancel = 1; - - $formticket->showForm(1, 'create', 0, null, $action); - /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { - $formticket = new FormTicket($db); - - $head = ticket_prepare_head($object); - - print '
'; - print ''; - print ''; - print ''; - - print dol_get_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); - - print '
'; - print ''; - - // Type - print ''; - - // Severity - print ''; - - // Group - print ''; - - // Subject - print ''; - - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); - } - - print '
'; - $formticket->selectTypesTickets((GETPOSTISSET('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); - print '
'; - $formticket->selectSeveritiesTickets((GETPOSTISSET('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); - print '
'; - $formticket->selectGroupTickets((GETPOSTISSET('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); - print '
'; - print ''; - print '
'; - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); - - print '
'; */ -} elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'abandon' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'categories' || $action == 'reopen' - || $action== 'edit_contrat' || $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) { + if (empty($defaultref)) { + $defaultref = ''; + } + + $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) + { @@ -814 +656 @@ - if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) { + if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { @@ -820,26 +662,4 @@ - $thirdparty_contacts = $object->getInfosTicketExternalContact(1); - $contacts_select = array( - '-2' => $langs->trans('TicketNotifyAllTiersAtClose'), - '-3' => $langs->trans('TicketNotNotifyTiersAtClose') - ); - foreach ($thirdparty_contacts as $thirdparty_contact) { - $contacts_select[$thirdparty_contact['id']] = $thirdparty_contact['civility'] . ' ' . $thirdparty_contact['lastname'] . ' ' . $thirdparty_contact['firstname']; - } - - // Default select all or no contact - $default = (getDolGlobalString('TICKET_NOTIFY_AT_CLOSING') ? -2 : -3); - $formquestion = array( - array( - 'name' => 'contactid', - 'type' => 'select', - 'label' => $langs->trans('NotifyThirdpartyOnTicketClosing'), - 'values' => $contacts_select, - 'default' => $default - ), - ); - - print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", $formquestion, '', 1); - } - // Confirmation abandon - if ($action == 'abandon') { - print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("AbandonTicket"), $langs->trans("ConfirmAbandonTicket"), "confirm_abandon", '', '', 1); + print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1); + if ($ret == 'html') { + print '
'; + } @@ -859 +679 @@ - 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->labelStatusShort[$new_status])), "confirm_set_status", '', '', 1); + 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); @@ -863 +683 @@ - if ($projectid > 0) { + if ($projectid) { @@ -875,3 +695,5 @@ - - print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); - + dol_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); + + /* + * Projet synthese pour rappel + */ @@ -885 +707 @@ - if (!$user->hasRight('projet', 'all', 'lire')) { + if (!$user->rights->projet->all->lire) { @@ -887 +709 @@ - $projectstat->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; + $projectstat->next_prev_filter = " rowid in (".(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; @@ -916 +738 @@ - // Status + // Statut @@ -921 +743 @@ - print dol_get_fiche_end(); + print ''; @@ -929 +751 @@ - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); @@ -933,5 +755,5 @@ - print dol_get_fiche_end(); - } - - if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) { - $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id); + dol_fiche_end(); + } + + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; @@ -939 +761 @@ - $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid); + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; @@ -944 +766 @@ - print dol_get_fiche_head($head, 'tabTicket', $langs->trans("Ticket"), -1, 'ticket'); + dol_fiche_head($head, 'tabTicket', $langs->trans("Ticket"), -1, 'ticket'); @@ -951,0 +774 @@ + $langs->load("users"); @@ -954,2 +777,3 @@ - $morehtmlref .= $fuser->getNomUrl(-1); - } elseif (!empty($object->email_msgid)) { + $morehtmlref .= $fuser->getNomUrl(0); + } + if (!empty($object->origin_email)) { @@ -957,13 +781,2 @@ - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $htmltooltip = $langs->trans("EmailMsgID").': '.$object->email_msgid; - $htmltooltip .= '
'.$langs->trans("EmailDate").': '.dol_print_date($object->email_date, 'dayhour'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' - '.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $htmltooltip, 1, 'help', '', 0, 3, 'tooltip').''; - } elseif (!empty($object->origin_email)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $htmltooptip = $langs->trans("IP").': '.$object->ip; - $morehtmlref .= dol_escape_htmltag($object->origin_email).' - '.$form->textwithpicto($langs->trans("CreatedByPublicPortal"), $htmltooptip, 1, 'help', '', 0, 3, 'tooltip').''; - } - - $permissiontoedit = $object->status < 8 && !$user->socid && $user->rights->ticket->write; - //$permissiontoedit = 0; + $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("TicketEmailOriginIssuer").')'; + } @@ -972,9 +785,10 @@ - if (isModEnabled("societe")) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"'); - if ($action != 'editcustomer' && $permissiontoedit) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; - } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); - if (!empty($object->socid)) { - $morehtmlref .= ' - '.img_picto($langs->trans("Tickets"), 'ticket', 'class="pictofixedwidth"').' '.$langs->trans("TicketHistory").''; + if (!empty($conf->societe->enabled)) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' '; + if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('Edit'), 0).' : '; + } + if ($action == 'editcustomer') { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); @@ -985 +799,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -987,8 +802,17 @@ - $morehtmlref .= '
'; - if ($permissiontoedit) { - $object->fetch_project(); - $morehtmlref .= img_picto($langs->trans("Project"), 'project'.((is_object($object->project) && $object->project->public) ? 'pub' : ''), 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).''; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } @@ -997,25 +821,3 @@ - $object->fetch_project(); - $morehtmlref .= $object->project->getNomUrl(1); - if ($object->project->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($object->project->title).''; - } - } - } - } - - // Contract - if (getDolGlobalString('TICKET_LINK_TO_CONTRACT_WITH_HARDLINK')) { - // Deprecated. Duplicate feature. Ticket can already be linked to contract with the generic "Link to" feature. - if (isModEnabled('contrat')) { - $langs->load('contracts'); - $morehtmlref .= '
'; - if ($permissiontoedit) { - $morehtmlref .= img_picto($langs->trans("Contract"), 'contract', 'class="pictofixedwidth"'); - if ($action == 'edit_contrat') { - $formcontract = new FormContract($db); - $morehtmlref .= $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contract, 'contratid', 0, 1, 1, 1); - } else { - $morehtmlref .= 'id.'">'; - $morehtmlref .= img_edit($langs->trans('SetContract')); - $morehtmlref .= ''; - } + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); @@ -1023,6 +825 @@ - if (!empty($object->fk_contract)) { - $contratstatic = new Contrat($db); - $contratstatic->fetch($object->fk_contract); - //print ''.$projet->title.''; - $morehtmlref .= $contratstatic->getNomUrl(0, '', 1); - } + $morehtmlref .= ''; @@ -1052 +849 @@ - print dolPrintLabel($object->track_id); + print $object->track_id; @@ -1061 +858 @@ - print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->hasRight('ticket', 'write') && !$user->socid, 'string'); + print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string'); @@ -1063 +860 @@ - print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->hasRight('ticket', 'write') && !$user->socid, 'string'); + print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string'); @@ -1068 +865 @@ - print dol_print_date($object->datec, 'dayhour', 'tzuser'); + print dol_print_date($object->datec, 'dayhour'); @@ -1071,17 +867,0 @@ - - // Origin - /* - if ($object->email_msgid) { - $texttoshow = $langs->trans("CreatedByEmailCollector"); - } elseif ($object->origin_email) { - $texttoshow = $langs->trans("FromPublicEmail"); - } - if ($texttoshow) { - print ''; - print $langs->trans("Origin"); - print ''; - print ''; - print $texttoshow; - print ''; - } - */ @@ -1092,3 +872,3 @@ - print dol_print_date($object->date_read, 'dayhour', 'tzuser'); - print ' - '.$langs->trans("TicketTimeElapsedBeforeSince").': '.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).''; - print ' / '.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).''; + print dol_print_date($object->date_read, 'dayhour'); + print ' - '.$langs->trans("TicketTimeToRead").': '.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).''; + print ' - '.$langs->trans("TimeElapsedSince").': '.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).''; @@ -1101 +881 @@ - print dol_print_date($object->date_close, 'dayhour', 'tzuser'); + print dol_print_date($object->date_close, 'dayhour'); @@ -1109,4 +889,4 @@ - if (isset($object->status) && $object->status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->hasRight('ticket', 'manage')) { - print ''.img_edit($langs->trans('Modify'), '').''; - } - print ''; + if ($object->fk_statut < 8 && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) { + print ''.img_edit($langs->trans('Modify'), '').''; + } + print ''; @@ -1114 +894 @@ - if (GETPOST('set', 'alpha') != "assign_ticket" && $object->fk_user_assign > 0) { + if ($object->fk_user_assign > 0) { @@ -1116 +896,3 @@ - print $userstat->getNomUrl(-1); + print $userstat->getNomUrl(1); + } else { + print $langs->trans('None'); @@ -1120 +902 @@ - if (GETPOST('set', 'alpha') == "assign_ticket" && $object->status < 8 && !$user->socid && $user->hasRight('ticket', 'write')) { + if (GETPOST('set', 'alpha') == "assign_ticket" && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { @@ -1125,3 +907,3 @@ - //print ' '; - print $form->select_dolusers(empty($object->fk_user_assign) ? $user->id : $object->fk_user_assign, 'fk_user_assign', 1); - print ' '; + print ' '; + print $form->select_dolusers($user->id, 'fk_user_assign', 1); + print ' '; @@ -1134 +916 @@ - print '
'; + print ''; + if ($action != 'progression' && $object->fk_statut < 8 && !$user->socid) { + print ''; @@ -1141,2 +923,2 @@ - print '
'; @@ -1137,2 +919,2 @@ - if ($action != 'progression' && isset($object->status) && $object->status < $object::STATUS_CLOSED && !$user->socid) { - print ''.img_edit($langs->trans('Modify')).''.img_edit($langs->trans('Modify')).''; - if ($user->hasRight('ticket', 'write') && $action == 'progression') { + print ''; + if ($user->rights->ticket->write && $action == 'progression') { @@ -1147,2 +929,2 @@ - print ''; - print ' '; + print ''; + print ' '; @@ -1157 +939,2 @@ - if (isModEnabled('ficheinter')) { + if ($conf->fichinter->enabled) + { @@ -1161 +943,0 @@ - $foundinter = 0; @@ -1164 +946 @@ - if ($objecttype == "fichinter") { + if ($objecttype = "fichinter") { @@ -1166 +947,0 @@ - $foundinter++; @@ -1172 +953,2 @@ - print '
'; + print '
'; + @@ -1175 +957 @@ - print $foundinter ? convertSecondToTime($timing, 'all', getDolGlobalString('MAIN_DURATION_OF_WORKDAY')) : ''; + print convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); @@ -1185,4 +967,8 @@ - // End of left column and beginning of right column - print '
'; - - + // Fin colonne gauche et début colonne droite + print '
'; + + + // View Original message + $actionobject->viewTicketOriginalMessage($user, $action, $object); + + // Classification of ticket @@ -1191,0 +978 @@ + print ''; @@ -1193,51 +980 @@ - print ''; - - // Categories - if (isModEnabled('categorie')) { - print '
'; - print ''; - print ''; - print ''; - - if ($user->hasRight('ticket', 'write') && $action == 'categories') { - $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1); - if (is_array($cate_arbo)) { - // Categories - print '"; - } - } else { - print '"; - } - - print '
'; - print ''; - } - print '
'; - print $langs->trans("Categories"); - if ($action != 'categories' && !$user->socid) { - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'; - print '
'; - print ''; - print ''; - print ''; - - $category = new Categorie($db); - $cats = $category->containing($object->id, 'ticket'); - $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; - } - - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print ''; - print '
'; - print "
'; - print $form->showCategories($object->id, Categorie::TYPE_TICKET, 1); - print "
'; - } - - // View Original message - $actionobject->viewTicketOriginalMessage($user, $action, $object); - - // Classification of ticket + @@ -1245 +982 @@ - print ''; + print '
'; @@ -1248 +985 @@ - print $langs->trans('TicketProperties'); + print $langs->trans('Properties'); @@ -1251,6 +988,7 @@ - if (GETPOST('set', 'alpha') == 'properties' && $user->hasRight('ticket', 'write')) { - print ''; - } else { - // Button to edit Properties - if (isset($object->status) && ($object->status < $object::STATUS_NEED_MORE_INFO || getDolGlobalString('TICKET_ALLOW_CLASSIFICATION_MODIFICATION_EVEN_IF_CLOSED')) && $user->hasRight('ticket', 'write')) { - print ' '.img_edit($langs->trans('Modify')).''; + if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { + print ''; + } + else { + // Button to edit Properties + if ($object->fk_statut < 5 && $user->rights->ticket->write) { + print ''.img_edit($langs->trans('Modify')).''; @@ -1262 +1000 @@ - if (GETPOST('set', 'alpha') == 'properties' && $user->hasRight('ticket', 'write')) { + if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { @@ -1266 +1004 @@ - print $langs->trans('Type'); + print $langs->trans('TicketChangeType'); @@ -1274 +1012 @@ - print $langs->trans('TicketCategory'); + print $langs->trans('TicketChangeCategory'); @@ -1276 +1014 @@ - $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2, 0, 0, 0, 'maxwidth500 widthcentpercentminusxx'); + $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2); @@ -1282 +1020 @@ - print $langs->trans('TicketSeverity'); + print $langs->trans('TicketChangeSeverity'); @@ -1290,3 +1028 @@ - if (!empty($object->type_code)) { - print $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); - } + print $langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'); @@ -1295,6 +1031,2 @@ - $s = ''; - if (!empty($object->category_code)) { - $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); - } - print '
'.$langs->trans("TicketCategory").''; - print dol_escape_htmltag($s); + print '
'.$langs->trans("TicketGroup").''; + print $langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'); @@ -1304,3 +1036 @@ - if (!empty($object->severity_code)) { - print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); - } + print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); @@ -1316 +1046 @@ - if (!$user->socid && $user->hasRight('ticket', 'write') && isset($object->status) && $object->status < $object::STATUS_CLOSED && GETPOST('set') !== 'properties') { + if (!$user->socid && $user->rights->ticket->write && $object->fk_statut < 8 && GETPOST('set') !== 'properties') { @@ -1321 +1051,2 @@ - if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { @@ -1340 +1070,0 @@ - $var = false; @@ -1364 +1094 @@ - echo $companystatic->getNomUrl(-1); + echo $companystatic->getNomUrl(1); @@ -1367 +1097 @@ - echo getDolGlobalString('MAIN_INFO_SOCIETE_NOM'); + echo $conf->global->MAIN_INFO_SOCIETE_NOM; @@ -1377 +1107 @@ - print $userstatic->getNomUrl(-1); + print $userstatic->getNomUrl(1); @@ -1382 +1112 @@ - print $contactstatic->getNomUrl(-1); + print $contactstatic->getNomUrl(1); @@ -1403 +1133 @@ - if ($object->status >= 0) { + if ($object->statut >= 0) { @@ -1419 +1149 @@ - if ($object->status >= 0) { + if ($object->statut >= 0) { @@ -1435,4 +1165,4 @@ - print ''; - print '
'; - - print dol_get_fiche_end(); + print ''; + print '
'; + + dol_fiche_end(); @@ -1446,10 +1176,4 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - // Email - if (isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { - print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&send_email=1&private_message=0&mode=init&token='.newToken().'&track_id='.$object->track_id.'#formmailbeforetitle', ''); - } - + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { @@ -1457,2 +1181,2 @@ - if (isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { - print dolGetButtonAction('', $langs->trans('TicketAddPrivateMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id.'#formmailbeforetitle', ''); + if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { + print ''; @@ -1463,15 +1187,10 @@ - if (!$object->fk_soc && $user->hasRight("ficheinter", "creer")) { - print dolGetButtonAction($langs->trans('UnableToCreateInterIfNoSocid'), $langs->trans('TicketAddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false); - } - if ($object->fk_soc > 0 && isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $user->hasRight('ficheinter', 'creer')) { - print dolGetButtonAction('', $langs->trans('TicketAddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&token='.newToken().'&socid='. $object->fk_soc.'&origin=ticket_ticket&originid='. $object->id, ''); - } - - // Close ticket if status is read - if (isset($object->status) && $object->status > 0 && $object->status < Ticket::STATUS_CLOSED && $user->hasRight('ticket', 'write')) { - print dolGetButtonAction('', $langs->trans('CloseTicket'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&track_id='.$object->track_id, ''); - } - - // Abandon ticket if status is read - if (isset($object->status) && $object->status > 0 && $object->status < Ticket::STATUS_CLOSED && $user->hasRight('ticket', 'write')) { - print dolGetButtonAction('', $langs->trans('AbandonTicket'), 'default', $_SERVER["PHP_SELF"].'?action=abandon&token='.newToken().'&track_id='.$object->track_id, ''); + if (!$object->fk_soc && $user->rights->ficheinter->creer) { + print ''; + } + if ($object->fk_soc > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ficheinter->creer) { + print ''; + } + + // Close ticket if statut is read + if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { + print ''; @@ -1481,2 +1200,2 @@ - if (!$user->socid && (isset($object->status) && ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED)) && !$user->socid) { - print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&track_id='.$object->track_id, ''); + if (!$user->socid && $object->fk_statut == Ticket::STATUS_CLOSED && !$user->socid) { + print ''; @@ -1486,2 +1205,2 @@ - if ($user->hasRight('ticket', 'delete') && !$user->socid) { - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&track_id='.$object->track_id, ''); + if ($user->rights->ticket->delete && !$user->socid) { + print ''; @@ -1491,2 +1210,4 @@ - } else { - //print '
'; + } + else + { + print '
'; @@ -1500,3 +1221 @@ - if (GETPOSTISSET('actionbis') && $action == 'presend') { - $action = 'presend_addmessage'; - } + if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; @@ -1505,19 +1224,2 @@ - if ($action == 'presend' || $action == 'presend_addmessage') { - if ($object->fk_soc > 0) { - $object->fetch_thirdparty(); - } - - $outputlangs = $langs; - $newlang = ''; - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } elseif (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && is_object($object->thirdparty)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $arrayoffamiliestoexclude = array('objectamount'); - + if ($action == 'presend' || $action == 'presend_addmessage') + { @@ -1530 +1232,27 @@ - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); + $substitutionarray = array(); + if ($object->fk_soc > 0) { + $object->fetch_thirdparty(); + $substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name; + } + $substitutionarray['__SIGNATURE__'] = $user->signature; + $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; + $substitutionarray['__TICKET_REF__'] = $object->ref; + $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; + $substitutionarray['__TICKET_TYPE__'] = $object->type_code; + $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; + $substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility + $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; + $substitutionarray['__TICKET_MESSAGE__'] = $object->message; + $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; + if ($object->fk_user_assign > 0) { + $userstat->fetch($object->fk_user_assign); + $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + } + + if ($object->fk_user_create > 0) { + $userstat->fetch($object->fk_user_create); + $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + } + foreach ($substitutionarray as $key => $val) { + $help .= $key.' -> '.$langs->trans($val).'
'; + } @@ -1534,3 +1261,0 @@ - - print '
'; - @@ -1539,0 +1265,10 @@ + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) { + $newlang = $_REQUEST['lang_id']; + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->default_lang; + } @@ -1547 +1281,0 @@ - $formticket->trackid = 'tic'.$object->id; @@ -1554 +1288 @@ - // Table of additional post parameters + // Tableau des parametres complementaires du post @@ -1562,2 +1295,0 @@ - $formticket->backtopage = $backtopage; - @@ -1569 +1301 @@ - if (getDolGlobalString('TICKET_SHOW_MESSAGES_ON_CARD')) { + if (! empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { @@ -1571,12 +1303,4 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.$contextpage; - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.$limit; - } - if ($actioncode) { - $param .= '&actioncode='.urlencode($actioncode); - } - if ($search_agenda_label) { - $param .= '&search_agenda_label='.urlencode($search_agenda_label); - } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($actioncode) $param .= '&actioncode='.urlencode($actioncode); + if ($search_agenda_label) $param .= '&search_agenda_label='.urlencode($search_agenda_label); @@ -1586,2 +1310,2 @@ - $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; - $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1); + $messagingUrl = DOL_URL_ROOT . '/ticket/agenda.php?track_id=' . $object->track_id; + $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fal fa-list-alt imgforviewmode', $messagingUrl, '', 1); @@ -1590,3 +1314,3 @@ - $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; - $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init'; - $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; + $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; + $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fal fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); @@ -1595,3 +1319,3 @@ - $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; - $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id); - $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus); + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";; + $url = dol_buildpath('/comm/action/card.php', 1) . '?action=create&datep=' . date('YmdHi') . '&origin=ticket&originid=' . $object->id . '&projectid=' . $object->fk_project . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?track_id=' . $object->track_id); + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fal fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus); @@ -1604,3 +1328 @@ - $filters['search_rowid'] = $search_rowid; - - show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + show_ticket_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); @@ -1622,2 +1344,2 @@ - if (getDolGlobalString('TICKET_SHOW_MESSAGES_ON_CARD')) { - print '
'; + if (empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { + print '
'; @@ -1627,4 +1349,3 @@ - $morehtmlcenter = '
'; - $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/ticket/messaging.php?id='.$object->id); - $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id); - $morehtmlcenter .= '
'; + $morehtmlcenter = dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/ticket/messaging.php?id='.$object->id); + $morehtmlcenter .= ' '; + $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id); @@ -1633 +1354 @@ - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; @@ -1637 +1358 @@ - print '
'; + print '
'; --- /tmp/dsg/dolibarr/htdocs/ticket/github_19.0.3_contact.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_contact.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -37,5 +35,0 @@ -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'; -} @@ -58,0 +53,5 @@ +// Protection if external user +if ($user->socid > 0) { + $socid = $user->socid; + accessforbidden(); +} @@ -61 +60 @@ -$url_page_current = DOL_URL_ROOT.'/ticket/contact.php'; +$url_page_current = dol_buildpath('/ticket/contact.php', 1); @@ -64,18 +62,0 @@ - -// Security check -$id = GETPOST("id", 'int'); -if ($user->socid > 0) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'ticket', $object->id, ''); - -// restrict access for externals users -if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { - accessforbidden(); -} -// or for unauthorized internals users -if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) { - accessforbidden(); -} - -$permissiontoadd = $user->rights->ticket->write; @@ -88,45 +69,19 @@ -if ($action == 'addcontact' && $user->hasRight('ticket', 'write')) { - $result = $object->fetch($id, '', $track_id); - - if ($result > 0 && ($id > 0 || (!empty($track_id)))) { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - - $error = 0; - - $codecontact = dol_getIdFromCode($db, $typeid, 'c_type_contact', 'rowid', 'code'); - if ($codecontact=='SUPPORTTEC') { - $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); - foreach ($internal_contacts as $key => $contact) { - if ($contact['id'] !== $contactid) { - //print "user à effacer : ".$useroriginassign; - $result = $object->delete_contact($contact['rowid']); - if ($result<0) { - $error ++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - $ret = $object->assignUser($user, $contactid); - if ($ret < 0) { - $error ++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if (empty($error)) { - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - } - } - - if ($result >= 0) { - header("Location: ".$url_page_current."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } +if ($action == 'addcontact' && $user->rights->ticket->write) { + $result = $object->fetch($id, '', $track_id); + + if ($result > 0 && ($id > 0 || (!empty($track_id)))) { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $result = $object->add_contact($contactid, $type, $source); + } + + if ($result >= 0) { + Header("Location: ".$url_page_current."?id=".$object->id); + exit; + } else { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } @@ -136,6 +91,6 @@ -if ($action == 'swapstatut' && $user->hasRight('ticket', 'write')) { - if ($object->fetch($id, '', $track_id)) { - $result = $object->swapContactStatus($ligne); - } else { - dol_print_error($db, $object->error); - } +if ($action == 'swapstatut' && $user->rights->ticket->write) { + if ($object->fetch($id, '', $track_id)) { + $result = $object->swapContactStatus($ligne); + } else { + dol_print_error($db, $object->error); + } @@ -145,30 +100,11 @@ -if ($action == 'deletecontact' && $user->hasRight('ticket', 'write')) { - if ($object->fetch($id, '', $track_id)) { - $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); - foreach ($internal_contacts as $key => $contact) { - if ($contact['rowid'] == $lineid && $object->fk_user_assign==$contact['id']) { - $ret = $object->assignUser($user, null); - if ($ret < 0) { - $error ++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - Header("Location: ".$url_page_current."?id=".$object->id); - exit; - } - } -} - -// Set parent company -if ($action == 'set_thirdparty' && $user->hasRight('ticket', 'write')) { - if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = $_SERVER["PHP_SELF"].'?track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); - exit(); - } -} +if ($action == 'deletecontact' && $user->rights->ticket->write) { + if ($object->fetch($id, '', $track_id)) { + $result = $object->delete_contact($lineid); + + if ($result >= 0) { + Header("Location: ".$url_page_current."?id=".$object->id); + exit; + } + } +} + @@ -190,56 +126,61 @@ - if ($object->fetch($id, $ref, $track_id) > 0) { - if ($socid > 0) { - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print dol_get_fiche_end(); - } - - if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) { - $object->next_prev_filter = "te.fk_user_assign ='".((int) $user->id); - } elseif ($user->socid > 0) { - $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid); - } - - $head = ticket_prepare_head($object); - - print dol_get_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticket'); - - $morehtmlref = '
'; - $morehtmlref .= $object->subject; - // Author - if ($object->fk_user_create > 0) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $morehtmlref .= $fuser->getNomUrl(-1); - } elseif (!empty($object->email_msgid)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')'; - } elseif (!empty($object->origin_email)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("CreatedByPublicPortal").')'; - } - - // Thirdparty - if (isModEnabled("societe")) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"'); - if ($action != 'editcustomer' && $permissiontoadd) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; - } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); - } - - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - if (0) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + if ($object->fetch($id, $ref, $track_id) > 0) + { + if ($socid > 0) { + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_fiche_end(); + } + + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; + } + + $head = ticket_prepare_head($object); + + dol_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticket'); + + $morehtmlref = '
'; + $morehtmlref .= $object->subject; + // Author + if ($object->fk_user_create > 0) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + + $langs->load("users"); + $fuser = new User($db); + $fuser->fetch($object->fk_user_create); + $morehtmlref .= $fuser->getNomUrl(0); + } + if (!empty($object->origin_email)) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; + } + + // Thirdparty + if (!empty($conf->societe->enabled)) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + }*/ + $morehtmlref .= ' : '; + if ($action == 'editcustomer') { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; @@ -247,37 +188,45 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $morehtmlref .= '
'; - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } - } - - $morehtmlref .= '
'; - - $linkback = ''.$langs->trans("BackToList").' '; - - dol_banner_tab($object, 'ref', $linkback, (empty($user->socid) ? 1 : 0), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1, ''); - - print dol_get_fiche_end(); - - //print '
'; - - $permission = $user->rights->ticket->write; - - // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) { - break; - } - } - } else { - print "ErrorRecordNotFound"; - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } 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 .= $proj->getNomUrl(1); + } else { + $morehtmlref .= ''; + } + } + } + + $morehtmlref .= '
'; + + $linkback = ''.$langs->trans("BackToList").' '; + + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); + + dol_fiche_end(); + + //print '
'; + + $permission = $user->rights->ticket->write; + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) { + break; + } + } + } else { + print "ErrorRecordNotFound"; + } --- /tmp/dsg/dolibarr/htdocs/ticket/github_19.0.3_document.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_document.php @@ -28 +27,0 @@ -// Load Dolibarr environment @@ -36,5 +34,0 @@ -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'; -} @@ -46 +39,0 @@ -$socid = GETPOST('socid', 'int'); @@ -52,2 +45,4 @@ -// Store current page url -$url_page_current = DOL_URL_ROOT.'/ticket/document.php'; +// Security check +if (!$user->rights->ticket->read) { + accessforbidden(); +} @@ -57,2 +52,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -60,3 +55 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -66,6 +59,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "position_name"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; @@ -79,16 +68,2 @@ - $upload_dir = $conf->ticket->dir_output."/".dol_sanitizeFileName($object->ref); -} - -// Security check - Protection if external user -$result = restrictedArea($user, 'ticket', $object->id); - -// restrict access for externals users -if ($user->socid > 0 && ($object->fk_soc != $user->socid)) { - accessforbidden(); -} -// or for unauthorized internals users -if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id && !$user->hasRight('ticket', 'manage')) { - accessforbidden(); -} - -$permissiontoadd = $user->rights->ticket->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles + $upload_dir = $conf->ticket->dir_output."/".dol_sanitizeFileName($object->ref); +} @@ -101,11 +76,2 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; - -// Set parent company -if ($action == 'set_thirdparty' && $user->hasRight('ticket', 'write')) { - if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { - $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = $_SERVER["PHP_SELF"].'?track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); - exit(); - } -} +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; + @@ -123 +89,2 @@ -if ($object->id) { +if ($object->id) +{ @@ -127,55 +94,59 @@ - if ($socid > 0) { - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print dol_get_fiche_end(); - } - - if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) { - $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id); - } elseif ($user->socid > 0) { - $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid); - } - - $head = ticket_prepare_head($object); - - print dol_get_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticket'); - - $morehtmlref = '
'; - $morehtmlref .= $object->subject; - // Author - if ($object->fk_user_create > 0) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $morehtmlref .= $fuser->getNomUrl(-1); - } elseif (!empty($object->email_msgid)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')'; - } elseif (!empty($object->origin_email)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); - $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("CreatedByPublicPortal").')'; - } - - // Thirdparty - if (isModEnabled("societe")) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"'); - if ($action != 'editcustomer' && $permissiontoadd) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; - } - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); - } - - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - if (0) { - $morehtmlref .= '
'; - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + if ($socid > 0) { + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_fiche_end(); + } + + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; + } + + $head = ticket_prepare_head($object); + + dol_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticket'); + + $morehtmlref = '
'; + $morehtmlref .= $object->subject; + // Author + if ($object->fk_user_create > 0) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + + $langs->load("users"); + $fuser = new User($db); + $fuser->fetch($object->fk_user_create); + $morehtmlref .= $fuser->getNomUrl(0); + } + if (!empty($object->origin_email)) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; + } + + // Thirdparty + if (!empty($conf->societe->enabled)) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + }*/ + $morehtmlref .= ' : '; + if ($action == 'editcustomer') { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; @@ -183,38 +154,48 @@ - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $morehtmlref .= '
'; - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } - } - - $morehtmlref .= '
'; - - $linkback = ''.$langs->trans("BackToList").' '; - - dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - - print dol_get_fiche_end(); - - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } - - //$object->ref = $object->track_id; // For compatibility we use track ID for directory - $modulepart = 'ticket'; - $permissiontoadd = $user->rights->ticket->write; - $permtoedit = $user->rights->ticket->write; - $param = '&id='.$object->id; - - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - accessforbidden('', 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 .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } 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 .= $proj->getNomUrl(1); + } else { + $morehtmlref .= ''; + } + } + } + + $morehtmlref .= '
'; + + $linkback = ''.$langs->trans("BackToList").' '; + + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + + dol_fiche_end(); + + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { + $totalsize += $file['size']; + } + + //$object->ref = $object->track_id; // For compatibility we use track ID for directory + $modulepart = 'ticket'; + $permission = $user->rights->ticket->write; + $permtoedit = $user->rights->ticket->write; + $param = '&id='.$object->id; + + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + accessforbidden('', 0, 1); --- /tmp/dsg/dolibarr/htdocs/ticket/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_index.php @@ -4 +3,0 @@ - * Copyright (C) 2021 Frédéric France @@ -21,5 +20,4 @@ - * \file htdocs/ticket/index.php - * \ingroup ticket - */ - -// Load Dolibarr environment + * \file htdocs/ticket/agenda.php + * \ingroup ticket + */ + @@ -27,3 +24,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -32 +27,2 @@ - +require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -51 +46,0 @@ -$socid = 0; @@ -53,8 +48,10 @@ - $socid = $user->socid; -} -$userid = $user->id; - -$nowarray = dol_getdate(dol_now(), true); -$nowyear = $nowarray['year']; -$year = GETPOST('year', 'int') > 0 ? GETPOST('year', 'int') : $nowyear; -$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); + $socid = $user->socid; +} + +// Security check +$result = restrictedArea($user, 'ticket', 0, '', '', '', ''); + +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; +//$startyear=$year-2; +$startyear = $year - 1; @@ -63 +59,0 @@ -// Initialize objects @@ -65,7 +60,0 @@ - -// Security check -//$result = restrictedArea($user, 'ticket|knowledgemanagement', 0, '', '', '', ''); -if (!$user->hasRight('ticket', 'read') && !$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { - accessforbidden('Not enought permissions'); -} - @@ -81 +69,0 @@ - @@ -86,2 +73,0 @@ -$resultboxes = FormOther::getBoxesArea($user, "11"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - @@ -88,0 +75 @@ +$tickesupstatic = new Ticket($db); @@ -93 +80 @@ -print load_fiche_titre($langs->trans('TicketsIndex'), $resultboxes['selectboxlist'], 'ticket'); +print load_fiche_titre($langs->trans('TicketsIndex'), $linkback, 'ticket'); @@ -106,8 +93,8 @@ - $endyear = GETPOST($param_year, 'int'); - $shownb = GETPOST($param_shownb, 'alpha'); - $showtot = GETPOST($param_showtot, 'alpha'); -} elseif (!empty($_COOKIE['DOLUSERCOOKIE_ticket_by_status'])) { - $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_ticket_by_status'], true); - $endyear = $tmparray['year']; - $shownb = empty($tmparray['shownb']) ? 0 : $tmparray['shownb']; - $showtot = empty($tmparray['showtot']) ? 0 : $tmparray['showtot']; + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); +} else { + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_ticket_by_status'], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; @@ -116,4 +103,4 @@ - $showtot = 1; - $shownb = 0; -} - + $showtot = 1; +} + +$nowarray = dol_getdate(dol_now(), true); @@ -121 +108 @@ - $endyear = $nowarray['year']; + $endyear = $nowarray['year']; @@ -125,2 +111,0 @@ - -// Change default WIDHT and HEIGHT (we need a smaller than default for both desktop and smartphone) @@ -128,12 +113,3 @@ -if (empty($conf->dol_optimize_smallscreen)) { - $HEIGHT = '200'; -} else { - $HEIGHT = '160'; -} - -print '
'; -print '
'; - -print '
'; - -print '
'; +$HEIGHT = '200'; + +print '
'; @@ -145,10 +121,8 @@ - 'unread' => 0, - 'read' => 0, - 'needmoreinfo' => 0, - 'answered' => 0, - 'assigned' => 0, - 'inprogress' => 0, - 'waiting' => 0, - 'closed' => 0, - 'canceled' => 0, - 'deleted' => 0, + 'unread' => 0, + 'read' => 0, + 'answered' => 0, + 'assigned' => 0, + 'inprogress' => 0, + 'waiting' => 0, + 'closed' => 0, + 'deleted' => 0, @@ -159,2 +133,2 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -165,2 +139,2 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); +if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -171 +145 @@ - $sql .= " AND t.fk_soc= ".((int) $user->socid); + $sql .= " AND t.fk_soc='".$user->socid."'"; @@ -173,4 +147,4 @@ - // For internals users, - if (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && !$user->hasRight('ticket', 'manage')) { - $sql .= " AND t.fk_user_assign = ".((int) $user->id); - } + // For internals users, + if (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && !$user->rights->ticket->manage) { + $sql .= " AND t.fk_user_assign=".$user->id; + } @@ -182,49 +156,49 @@ - while ($objp = $db->fetch_object($result)) { - $found = 0; - if ($objp->fk_statut == Ticket::STATUS_NOT_READ) { - $tick['unread'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_READ) { - $tick['read'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) { - $tick['needmoreinfo'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) { - $tick['assigned'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) { - $tick['inprogress'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_WAITING) { - $tick['waiting'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_CLOSED) { - $tick['closed'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_CANCELED) { - $tick['canceled'] = $objp->nb; - } - } - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - $dataseries = array(); - $colorseries = array(); - - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_NOT_READ]), 'data' => round($tick['unread'])); - $colorseries[Ticket::STATUS_NOT_READ] = '-'.$badgeStatus0; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_READ]), 'data' => round($tick['read'])); - $colorseries[Ticket::STATUS_READ] = $badgeStatus1; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_ASSIGNED]), 'data' => round($tick['assigned'])); - $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_IN_PROGRESS]), 'data' => round($tick['inprogress'])); - $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_WAITING]), 'data' => round($tick['waiting'])); - $colorseries[Ticket::STATUS_WAITING] = '-'.$badgeStatus4; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_NEED_MORE_INFO]), 'data' => round($tick['needmoreinfo'])); - $colorseries[Ticket::STATUS_NEED_MORE_INFO] = '-'.$badgeStatus3; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_CANCELED]), 'data' => round($tick['canceled'])); - $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_CLOSED]), 'data' => round($tick['closed'])); - $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6; + while ($objp = $db->fetch_object($result)) { + $found = 0; + if ($objp->fk_statut == Ticket::STATUS_NOT_READ) { + $tick['unread'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_READ) { + $tick['read'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) { + $tick['needmoreinfo'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) { + $tick['assigned'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) { + $tick['inprogress'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_WAITING) { + $tick['waiting'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_CLOSED) { + $tick['closed'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_CANCELED) { + $tick['canceled'] = $objp->nb; + } + } + + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $dataseries = array(); + $colorseries = array(); + + $dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread'])); + $colorseries[Ticket::STATUS_NOT_READ] = '-'.$badgeStatus0; + $dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read'])); + $colorseries[Ticket::STATUS_READ] = $badgeStatus1; + $dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned'])); + $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3; + $dataseries[] = array('label' => $langs->trans("InProgress"), 'data' => round($tick['inprogress'])); + $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4; + $dataseries[] = array('label' => $langs->trans("Suspended"), 'data' => round($tick['waiting'])); + $colorseries[Ticket::STATUS_WAITING] = '-'.$badgeStatus3; + $dataseries[] = array('label' => $langs->trans("NeedMoreInformation"), 'data' => round($tick['needmoreinfo'])); + $colorseries[Ticket::STATUS_NEED_MORE_INFO] = $badgeStatus9; + $dataseries[] = array('label' => $langs->trans("Canceled"), 'data' => round($tick['canceled'])); + $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9; + $dataseries[] = array('label' => $langs->trans("Closed"), 'data' => round($tick['closed'])); + $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6; @@ -232,4 +206,4 @@ - dol_print_error($db); -} - -$stringtoshow = '