Usuário:AlexSP/Testes: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
Linha 1:
<?php
/*
* @version $Id: ticket.class.php 2059223252 20132014-0311-3027 1619:3059:22Z17Z yllen $
-------------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-20132014 by the INDEPNET Development Team.
 
http://indepnet.net/ http://glpi-project.org
Linha 28:
*/
 
/** @file
// ----------------------------------------------------------------------
* @brief
// Original Author of file:
*/
// Purpose of file:
// ----------------------------------------------------------------------
 
 
if (!defined('GLPI_ROOT')) {
Linha 38 ⟶ 36:
}
 
/**
/// Tracking class
* Ticket Class
**/
class Ticket extends CommonITILObject {
 
// From CommonDBTM
public $dohistory = true;
static protected $forward_entity_to = array('TicketValidation', 'TicketCost');
 
// From CommonITIL
public $userlinkclass = 'Ticket_User';
public $grouplinkclass = 'Group_Ticket';
public $supplierlinkclass = 'Supplier_Ticket';
 
static $rightname = 'ticket';
protected $userentity_oncreate = true;
 
protected $userentity_oncreate = true;
const MATRIX_FIELD = 'priority_matrix';
 
const URGENCY_MASK_FIELD = 'urgency_mask';
const IMPACT_MASK_FIELDMATRIX_FIELD = 'impact_maskpriority_matrix';
const STATUS_MATRIX_FIELDURGENCY_MASK_FIELD = 'ticket_statusurgency_mask';
const IMPACT_MASK_FIELD = 'impact_mask';
const STATUS_MATRIX_FIELD = 'ticket_status';
 
// HELPDESK LINK HARDWARE DEFINITION : CHECKSUM SYSTEM : BOTH=1*2^0+1*2^1=3
const HELPDESK_MY_HARDWARE = 0;
const HELPDESK_ALL_HARDWARE = 1;
 
// Specific ones
Linha 66 ⟶ 73:
// Demand type
const DEMAND_TYPE = 2;
 
const READMY = 1;
const READALL = 1024;
const READGROUP = 2048;
const READASSIGN = 4096;
const ASSIGN = 8192;
const STEAL = 16384;
const OWN = 32768;
const CHANGEPRIORITY = 65536;
 
 
function getForbiddenStandardMassiveAction() {
 
$forbidden = parent::getForbiddenStandardMassiveAction();
 
if (!Session::haveRightsOr(self::$rightname, array(DELETE, PURGE))) {
$forbidden[] = 'delete';
$forbidden[] = 'purge';
$forbidden[] = 'restore';
}
 
return $forbidden;
}
 
 
Linha 71 ⟶ 101:
* Name of the type
*
* @param $nb : number of item in the type (default 0)
*
* @return $LANG
**/
static function getTypeName($nb=0) {
globalreturn _n('Ticket','Tickets',$LANGnb);
 
if ($nb>1) {
return $LANG['Menu'][5];
}
return $LANG['job'][38];
}
 
 
/**
function canAdminActors(){
* @see CommonGLPI::getMenuShorcut()
return Session::haveRight('update_ticket', 1);
*
* @since version 0.85
**/
static function getMenuShorcut() {
return 't';
}
 
 
/**
function canAssign(){
* @see CommonGLPI::getAdditionalMenuOptions()
return Session::haveRight('assign_ticket', 1);
*
* @since version 0.85
**/
static function getAdditionalMenuOptions() {
 
if (TicketTemplate::canView()) {
$menu['TicketTemplate']['title'] = TicketTemplate::getTypeName(2);
$menu['TicketTemplate']['page'] = TicketTemplate::getSearchURL(false);
$menu['TicketTemplate']['links']['search'] = TicketTemplate::getSearchURL(false);
if (TicketTemplate::canCreate()) {
$menu['TicketTemplate']['links']['add'] = TicketTemplate::getFormURL(false);
}
return $menu;
}
return false;
}
 
 
/**
function canAssignToMe(){
* @see CommonGLPI::getAdditionalMenuContent()
*
* @since version 0.85
**/
static function getAdditionalMenuContent() {
 
returnif (Sessionstatic::haveRightcanCreate("steal_ticket","1")) {
$menu['create_ticket']['title'] = __('Create ticket');
|| (Session::haveRight("own_ticket","1") && $this->countUsers(parent::ASSIGN)==0));
$menu['create_ticket']['page'] = static::getFormURL(false);
return $menu;
}
}
 
 
/**
function canCreate() {
* @see CommonGLPI::getAdditionalMenuLinks()
return Session::haveRight('create_ticket', 1);
*
* @since version 0.85
**/
static function getAdditionalMenuLinks() {
global $CFG_GLPI;
 
$links = array();
if (TicketTemplate::canView()) {
$links['template'] = TicketTemplate::getSearchURL(false);
}
if (Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
$opt = array();
$opt['reset'] = 'reset';
$opt['criteria'][0]['field'] = 55; // validation status
$opt['criteria'][0]['searchtype'] = 'equals';
$opt['criteria'][0]['value'] = CommonITILValidation::WAITING;
$opt['criteria'][0]['link'] = 'AND';
 
$opt['criteria'][1]['field'] = 59; // validation aprobator
$opt['criteria'][1]['searchtype'] = 'equals';
$opt['criteria'][1]['value'] = Session::getLoginUserID();
$opt['criteria'][1]['link'] = 'AND';
 
$pic_validate = "<img title=\"".__s('Ticket waiting for your approval')."\" alt=\"".
__s('Ticket waiting for your approval')."\" src='".
$CFG_GLPI["root_doc"]."/pics/menu_showall.png'>";
 
$links[$pic_validate] = '/front/ticket.php?'.Toolbox::append_params($opt, '&amp;');
}
if (count($links)) {
return $links;
}
return false;
}
 
 
function canUpdatecanAdminActors() {
return Session::haveRight(self::$rightname, UPDATE);
}
 
 
function canAssign() {
return (Session::haveRight('update_ticket', 1)
||return Session::haveRight('create_ticket'self::$rightname, 1self::ASSIGN);
|| Session::haveRight('assign_ticket', 1)
|| Session::haveRight('own_ticket', 1)
|| Session::haveRight('steal_ticket', 1));
}
 
 
function canAssignToMe() {
/**
* @see inc/CommonDBTM::canMassiveAction()
**/
function canMassiveAction($action, $field, $value){
 
return (Session::haveRight(self::$rightname, self::STEAL)
switch ($action) {
|| (Session::haveRight(self::$rightname, self::OWN)
case 'update' :
switch && ($fieldthis->countUsers(CommonITILActor::ASSIGN) {== 0)));
case 'status' :
if (!self::isAllowedStatus($this->fields['status'], $value)) {
return false;
}
break;
}
break;
}
return true;
}
 
 
static function canViewcanUpdate() {
 
// To allow update of urgency and category for post-only
if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
return true;
return Session::haveRight(self::$rightname, CREATE);
}
return (Session::haveRighthaveRightsOr("show_all_ticket"self::$rightname,"1")
array(UPDATE, self::ASSIGN, self::STEAL, self::OWN));
|| Session::haveRight('create_ticket','1')
}
 
 
static function canView() {
|| Session::haveRight('update_ticket','1')
/*
|| Session::haveRight('show_all_ticket','1')
if (isset($_SESSION['glpiactiveprofile']['interface'])
|| Session::haveRight("show_assign_ticket",'1')
&& $_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
|| Session::haveRight("own_ticket",'1')
return true;
|| Session::haveRight('validate_ticket','1')
}*/
|| Session::haveRight("show_group_ticket",'1'));
return (Session::haveRightsOr(self::$rightname,
array(self::READALL, self::READMY, UPDATE, self::READASSIGN,
self::READGROUP, self::OWN))
|| Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights()));
}
 
Linha 164 ⟶ 243:
return false;
}
return (Session::haveRight(self::$rightname, self::READALL)
 
return || (Session::haveRight("show_all_ticket"self::$rightname,"1" self::READMY)
|| && (($this->fields["users_id_recipient"] === Session::getLoginUserID())
|| $this->isUser(parentCommonITILActor::REQUESTER, Session::getLoginUserID())
|| $this->isUser(parentCommonITILActor::OBSERVER, Session::getLoginUserID())))
|| (Session::haveRight("show_group_ticket"self::$rightname,'1' self::READGROUP)
&& isset($_SESSION["glpigroups"])
&& ($this->haveAGroup(parentCommonITILActor::REQUESTER, $_SESSION["glpigroups"])
|| $this->haveAGroup(parentCommonITILActor::OBSERVER, $_SESSION["glpigroups"])))
|| (Session::haveRight("show_assign_ticket"self::$rightname,'1' self::READASSIGN)
&& ($this->isUser(parentCommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::ASSIGN, $_SESSION["glpigroups"]))
|| (Session::haveRight('assign_ticket'self::$rightname,1) && $this->fields["status"]=='new'self::ASSIGN)
&& ($this->fields["status"] == self::INCOMING))))
|| (Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())
)
|| (Session && TicketValidation::haveRightcanValidate('validate_ticket','1'$this->fields["id"])));
&& TicketValidation::canValidate($this->fields["id"]))
);
}
 
Linha 192 ⟶ 269:
**/
function canSolve() {
 
/// TODO block solution edition on closed status ?
return ((Session::haveRight("update_ticket"self::$rightname,"1" UPDATE)
|| $this->isUser(parentCommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::ASSIGN, $_SESSION["glpigroups"])))
&& self::isAllowedStatus($this->fields['status'], 'solved'self::SOLVED));
// No edition on closed status
&& !in_array($this->fields['status'], $this->getClosedStatusArray()));
}
 
Linha 208 ⟶ 287:
function canApprove() {
 
return (($this->fields["users_id_recipient"] === Session::getLoginUserID())
|| $this->isUser(parentCommonITILActor::REQUESTER, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::REQUESTER, $_SESSION["glpigroups"])));
}
 
 
/**
* @see CommonDBTM::canMassiveAction()
**/
function canMassiveAction($action, $field, $value) {
 
switch ($action) {
case 'update' :
switch ($field) {
case 'status' :
if (!self::isAllowedStatus($this->fields['status'], $value)) {
return false;
}
break;
}
break;
}
return true;
}
 
Linha 218 ⟶ 317:
* Get Datas to be added for SLA add
*
* @param $slas_id SLA id
* @param $entities_id entity ID of the ticket
* @param $date begin date of the ticket
*
* @return array of datas to add in ticket
**/
function getDatasToAddSLA($slas_id, $entities_id, $date) {
 
$calendars_id = EntityDataEntity::getUsedConfig('calendars_id', $entities_id);
$data = array();
 
Linha 233 ⟶ 332:
$sla->setTicketCalendar($calendars_id);
// Get first SLA Level
$data["slalevels_id"] = SlaLevel::getFirstSlaLevel($slas_id);
// Compute due_date
$data['due_date'] = $sla->computeDueDate($date);
Linha 243 ⟶ 342:
$data['sla_waiting_duration'] = 0;
}
 
return $data;
 
Linha 261 ⟶ 359:
$input['slas_id'] = 0;
$input['slalevels_id'] = 0;
$input['sla_waiting_duration'] = 0;
$input['id'] = $id;
 
Linha 280 ⟶ 378:
return false;
}
return Sessionself::haveRightcanCreate('create_ticket', '1');
}
 
Linha 295 ⟶ 393:
}
 
if (($this->numberOfFollowups() == 0)
&& ($this->numberOfTasks() == 0)
&& ($this->isUser(parentCommonITILActor::REQUESTER,Session::getLoginUserID())
|| ($this->fields["users_id_recipient"] === Session::getLoginUserID()))) {
return true;
}
 
return $this->static::canUpdate();
}
 
 
/**
* @since version 0.85
**/
static function canDelete() {
 
// to allow delete for self-service only if no action on the ticket
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
return Session::haveRight(self::$rightname, CREATE);
}
return Session::haveRight(self::$rightname, DELETE);
}
 
Linha 318 ⟶ 429:
 
// user can delete his ticket if no action on it
if (($this->isUser(parentCommonITILActor::REQUESTER, Session::getLoginUserID())
|| ($this->fields["users_id_recipient"] === Session::getLoginUserID()))
&& ($this->numberOfFollowups() == 0)
&& ($this->numberOfTasks() == 0)
&& ($this->fields["date"] == $this->fields["date_mod"])) {
return true;
}
 
return Sessionstatic::haveRightcanDelete('delete_ticket', '1');
}
 
 
/**
* @see CommonITILObject::getDefaultActor()
**/
function getDefaultActor($type) {
 
if ($type == selfCommonITILActor::ASSIGN) {
if (Session::haveRight("own_ticket"self::$rightname,"1" self::OWN)
&& $_SESSION['glpiset_default_tech']) {
return Session::getLoginUserID();
Linha 342 ⟶ 456:
 
 
/**
* @see CommonITILObject::getDefaultActorRightSearch()
**/
function getDefaultActorRightSearch($type) {
 
$right = "all";
if ($type == selfCommonITILActor::ASSIGN) {
$right = "own_ticket";
if (!Session::haveRight("assign_ticket"self::$rightname,"1" self::ASSIGN)) {
$right = 'id';
}
Linha 363 ⟶ 480:
 
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
global $LANG;
 
if ($this->static::canView()) {
$nb = 0;
$title = $LANG['title'][28]self::getTypeName(2);
if ($_SESSION['glpishow_count_on_tabs']) {
switch ($item->getType()) {
// case 'Change' :
// $nb = countElementsInTable('glpi_changes_tickets',
// "`changes_id` = '".$item->getID()."'");
// break;
 
case 'Problem' :
$nb = countElementsInTable('glpi_problems_tickets',
"`problems_id` = '".$item->getID()."'");
break;
 
case 'User' :
$nb = countElementsInTable('glpi_tickets_users',
"`users_id` = '".$item->getID()."'
AND `type` = ".TicketCommonITILActor::REQUESTER);
$title = $LANG[__('joblistCreated tickets'][5]);
break;
 
case 'Supplier' :
$nb = countElementsInTable('glpi_ticketsglpi_suppliers_tickets',
"`suppliers_id_assignsuppliers_id` = '".$item->getID()."'");
break;
 
Linha 400 ⟶ 506:
$nb = countElementsInTable('glpi_groups_tickets',
"`groups_id` = '".$item->getID()."'
AND `type` = ".TicketCommonITILActor::REQUESTER);
$title = $LANG[__('joblistCreated tickets'][5]);
break;
 
Linha 410 ⟶ 516:
AND `items_id` = '".$item->getID()."'");
// Linked items
if ($subquerylinkeditems = $item->getSelectLinkedItemgetLinkedItems()) {;
 
$nb += countElementsInTable('glpi_tickets',
if "(`itemtype`,`items_id`) IN count(" . $subquery . "linkeditems)"); {
foreach ($linkeditems as $type => $tab) {
foreach ($tab as $ID) {
$nb += countElementsInTable('glpi_tickets',
" `itemtype` = '$type'
AND `items_id` = '$ID'");
}
}
}
break;
}
} // glpishow_count_on_tabs
 
} // glpishow_count_on_tabs
// Not for Ticket class
if ($item->getType() != __CLASS__) {
//toolbox::logdebug("RETURN1", self::createTabEntry($title, $nb));
return self::createTabEntry($title, $nb);
}
} // show_all_ticketself::READALL right check
 
// Not check show_all_ticketself::READALL for Ticket itself
switch ($item->getType()) {
case __CLASS__ :
$ong = array();
 
$ong[1] = $LANG['job'][47];
$ong[2] = $LANG[_n('jobresolutionSolution'][2], 'Solutions', 1);
// enquete si statut clos
if ($item->fields['status'] == 'closed'self::CLOSED) {
$satisfaction = new TicketSatisfaction();
if ($satisfaction->getFromDB($item->getID())) {
$ong[3] = $LANG[__('satisfactionSatisfaction'][0]);
}
}
if (Session::haveRight$item->canUpdate('observe_ticket','1')) {
$ong[4] = $LANG[__('MenuStatistics'][13]);
}
return $ong;
 
// default :
// return $LANG[_n('titleTicket'][28],'Tickets',2);
}
 
return '';
}
Linha 451 ⟶ 564:
 
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
global $LANG;
 
switch ($item->getType()) {
// case 'Change' :
// Change_Ticket::showForChange($item);
// break;
 
case 'Problem' :
Problem_Ticket::showForProblem($item);
break;
 
case __CLASS__ :
switch ($tabnum) {
case 1 :
$item->showCost();
break;
 
case 2 :
if (!isset($_POST_GET['load_kb_sol'])) {
$_POST_GET['load_kb_sol'] = 0;
}
$item->showSolutionForm($_POST_GET['load_kb_sol']);
 
if ($item->canApprove()) {
$fup = new TicketFollowup();
Linha 481 ⟶ 583:
case 3 :
$satisfaction = new TicketSatisfaction();
if (($item->fields['status'] == 'closed'self::CLOSED)
&& $satisfaction->getFromDB($_POST_GET["id"])) {
$satisfaction->showSatisfactionFormshowForm($item);
} else {
echo "<p class='center b'>".$LANG[__('satisfactionNo generated survey'][2])."</p>";
}
break;
Linha 504 ⟶ 607:
 
function defineTabs($options=array()) {
global $LANG, $CFG_GLPI, $DB;
 
$ong = array();
$this->addDefaultFormTab($ong);
$this->addStandardTab('TicketFollowup',$ong, $options);
$this->addStandardTab('TicketValidation', $ong, $options);
$this->addStandardTab('TicketTask', $ong, $options);
$this->addStandardTab(__CLASS__, $ong, $options);
$this->addStandardTab('DocumentTicketCost', $ong, $options);
$this->addStandardTab('ProblemDocument_Item', $ong, $options);
// $this->addStandardTab('ChangeProblem_Ticket', $ong, $options);
$this->addStandardTab('Change_Ticket', $ong, $options);
$this->addStandardTab('Log', $ong, $options);
 
Linha 527 ⟶ 631:
function getAdditionalDatas() {
 
if ($this->fields["itemtype"]
&& ($item = getItemForItemtype($this->fields["itemtype"]))) {
if ($item->getFromDB($this->fields["items_id"])) {
$this->hardwaredatas=$item;
}
 
} else {
$this->hardwaredatas = NULL;
}
}
Linha 551 ⟶ 655:
$DB->query($query1);
 
$query1ts = "DELETEnew TicketValidation();
$ts->cleanDBonItemDelete($this->getType(), $this->fields['id']);
FROM `glpi_ticketvalidations`
 
WHERE `tickets_id` = '".$this->fields['id']."'";
$DB->query($query1);
 
$query1 = "DELETE
Linha 560 ⟶ 663:
WHERE `tickets_id` = '".$this->fields['id']."'";
$DB->query($query1);
 
$pt = new Problem_Ticket();
$pt->cleanDBonItemDelete('Ticket', $this->fields['id']);
 
$ts = new TicketCost();
$ts->cleanDBonItemDelete($this->getType(), $this->fields['id']);
 
SlaLevel_Ticket::deleteForTicket($this->getID());
Linha 566 ⟶ 675:
FROM `glpi_tickets_tickets`
WHERE `tickets_id_1` = '".$this->fields['id']."'
OR `tickets_id_2` = '".$this->fields['id']."'";
$DB->query($query1);
 
$ct = new Change_Ticket();
$ct->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
 
parent::cleanDBonPurge();
Linha 575 ⟶ 687:
 
function prepareInputForUpdate($input) {
global $LANGCFG_GLPI, $CFG_GLPIDB;
 
// Get ticket : need for comparison
$this->getFromDB($input['id']);
 
// Clean new lines before passing to rules
if ($CFG_GLPI["use_rich_text"] && isset($input["content"])) {
$input["content"] = preg_replace('/\\\\r\\\\n/',"\n",$input['content']);
$input["content"] = preg_replace('/\\\\n/',"\n",$input['content']);
}
 
// automatic recalculate if user changes urgence or technician change impact
if (isset($input['urgency'])
&& isset($input['impact'])
&& (($input['urgency'] != $this->fields['urgency'])
|| $input['impact'] != $this->fields['impact'])
&& !isset($input['priority'])) {
$input['priority'] = self::computePriority($input['urgency'], $input['impact']);
}
 
// if ($CFG_GLPI["is_ticket_title_mandatory"] && isset($input['name']) ) {
// $title = trim($input['name']);
// if (empty($title)) {
// Session::addMessageAfterRedirect($LANG['tracking'][6], false, ERROR);
// unset($input['name']);
// }
// }
//
// if ($CFG_GLPI["is_ticket_content_mandatory"] && isset($input['content'])) {
// $content = trim($input['content']);
// if (empty($content)) {
// Session::addMessageAfterRedirect($LANG['tracking'][7], false, ERROR);
// unset($input['content']);
// }
// }
 
// Get ticket : need for comparison
$this->getFromDB($input['id']);
 
// Security checks
if (is_numeric(Session::getLoginUserID(false)) && !Session::haveRightisCron("assign_ticket","1")) {
&& !Session::haveRight(self::$rightname, self::ASSIGN)) {
if (isset($input["_itil_assign"])
&& isset($input['_itil_assign']['_type'])
&& ($input['_itil_assign']['_type'] == 'user')) {
 
// must own_ticket to grab a non assign ticket
if ($this->countUsers(parentCommonITILActor::ASSIGN) == 0) {
if ((!Session::haveRighthaveRightsOr("steal_ticket"self::$rightname,"1") && !Sessionarray(self::haveRight("own_ticket"STEAL,"1" self::OWN)))
|| !isset($input["_itil_assign"]['users_id'])
|| ($input["_itil_assign"]['users_id'] != Session::getLoginUserID())) {
Linha 621 ⟶ 724:
} else {
// Can not steal or can steal and not assign to me
if (!Session::haveRight("steal_ticket"self::$rightname,"1" self::STEAL)
|| !isset($input["_itil_assign"]['users_id'])
|| ($input["_itil_assign"]['users_id'] != Session::getLoginUserID())) {
Linha 630 ⟶ 733:
 
// No supplier assign
if (isset($input["suppliers_id_assign_itil_assign"])) {
unset && isset($input["suppliers_id_assign"'_itil_assign']['_type']);
&& ($input['_itil_assign']['_type'] == 'supplier')) {
unset($input["_itil_assign"]);
}
 
 
// No group
if (isset($input["_itil_assign"])
&& isset($input['_itil_assign']['_type'])
&& ($input['_itil_assign']['_type'] == 'group')) {
unset($input["_itil_assign"]);
}
}
 
$check_allowed_fields_for_template = false;
$allowed_fields = array();
if (is_numeric(Session::getLoginUserID(false)) && !Session::haveRight("update_ticket","1")) {
if (!Session::isCron()
&& !Session::haveRight(self::$rightname, UPDATE)) {
 
$allowed_fields = array('id');
$check_allowed_fields_for_template = true;
 
if ($this->canApprove()
&& isset($input["status"])) {
$allowed_fields[] = 'status';
}
// for post-only with validate right or validation created by rules
$ticketval = newif (TicketValidation::canValidate($this->fields['id']);
if (TicketValidation::canValidate($this->fields['id']) || $ticketval->TicketValidation::canCreate()
|| isset($input["_rule_process"])) {
$allowed_fields[] = 'global_validation';
}
// Manage assign and steal right
if (Session::haveRighthaveRightsOr('assign_ticket'self::$rightname,1) || Sessionarray(self::haveRight('steal_ticket'ASSIGN,1 self::STEAL))) {
$allowed_fields[] = '_itil_assign';
}
if (Session::haveRight('assign_ticket',1)) {
$allowed_fields[] = 'suppliers_id_assign';
}
 
// Can only update initial fields if no followup or task already added
if (($this->numberOfFollowups() == 0)
&& ($this->numberOfTasks() == 0)
&& $this->isUser(parentCommonITILActor::REQUESTER, Session::getLoginUserID())) {
//toolbox::logdebug ("champs", $allowed_fields);
$allowed_fields[] = 'content';
$allowed_fields[] = 'nome_cbmes';
$allowed_fields[] = 'posto_grad_cbmes';
$allowed_fields[] = 'funcional_cbmes';
$allowed_fields[] = 'obm_cbmes';
$allowed_fields[] = 'setor_cbmes';
$allowed_fields[] = 'tel_cbmes';
$allowed_fields[] = 'patrimonio_cbmes';
$allowed_fields[] = 'urgency';
$allowed_fields[] = 'priority'; // automatic recalculate if user changes urgence
Linha 685 ⟶ 780:
$allowed_fields[] = 'items_id';
$allowed_fields[] = 'name';
//toolbox::logdebug ("champs finaux", $allowed_fields);
}
 
Linha 701 ⟶ 795:
$input = $ret;
}
 
 
 
//// check mandatory fields
// First get ticket template associated : entity and type/category
$tt = new TicketTemplate();
 
if (isset($input['entities_id'])) {
$entid = $input['entities_id'];
} else {
$entid = $this->fields['entities_id'];
}
if ($template_id = EntityData::getUsedConfig('tickettemplates_id', $entid)) {
// with type and categ
$tt->getFromDBWithDatas($template_id, true);
}
 
Linha 730 ⟶ 817:
}
 
if$tt = $this->getTicketTemplateToUse(0, $type &&, $categid), {$entid);
$categ = new ITILCategory();
if ($categ->getFromDB($categid)) {
$field = '';
switch ($type) {
case self::INCIDENT_TYPE :
$field = 'tickettemplates_id_incident';
break;
 
case self::DEMAND_TYPE :
$field = 'tickettemplates_id_demand';
break;
}
 
if (!empty($field) && $categ->fields[$field]) {
// with type and categ
 
$tt->getFromDBWithDatas($categ->fields[$field], true);
}
}
}
 
if (count($tt->mandatory)) {
$mandatory_missing = array();
$fieldsname = $tt->getAllowedFieldsNames(true);
foreach ($tt->mandatory as $key => $val) {
if ((!$check_allowed_fields_for_template || in_array($key,$allowed_fields))
&& (isset($input[$key])
&& (empty($input[$key]) || ($input[$key] == 'NULL'))) {
// Take only into account already set items : do not block old tickets
&& (!empty($this->fields[$key]))
)) {
$mandatory_missing[$key] = $fieldsname[$val];
}
}
if (count($mandatory_missing)) {
//TRANS: %s are the fields concerned
$message = $LANG['job'][68]."&nbsp;".implode(", ",$mandatory_missing);
$message = sprintf(__('Mandatory fields are not filled. Please correct: %s'),
implode(", ",$mandatory_missing));
Session::addMessageAfterRedirect($message, false, ERROR);
return false;
Linha 768 ⟶ 841:
}
 
/// Process Business Rules
// Add actors on standard input
$rules = new RuleTicketCollection($entid);
$rule = $rules->getRuleClass();
$changes = array();
$tocleanafterrules = array();
$usertypes = array('assign', 'requester', 'observer');
foreach ($usertypes as $t) {
if (isset($input['_itil_'.$t]) && isset($input['_itil_'.$t]['_type'])) {
$field = $input['_itil_'.$t]['_type'].'s_id';
if (isset($input['_itil_'.$t][$field])
&& !isset($input[$field.'_'.$t])) {
$input['_'.$field.'_'.$t] = $input['_itil_'.$t][$field];
$tocleanafterrules['_'.$field.'_'.$t] = $input['_itil_'.$t][$field];
}
}
 
}
// Manage fields from auto update : map rule actions to standard ones
 
if (isset($input['_auto_update'])) {
foreach ($rule->getCriterias() as $key => $val) {
if (isset($input['_users_id_assign'])) {
if (array_key_exists($key,$input['_itil_assign']['_type'] =)) 'user';{
if (!isset($this->fields[$key])
$input['_itil_assign']['users_id'] = $input['_users_id_assign'];
|| ($DB->escape($this->fields[$key]) != $input[$key])) {
$changes[] = $key;
}
}
}
if (isset($input['_groups_id_assign'])) {
 
$input['_itil_assign']['_type'] = 'group';
// Business Rules do not override manual SLA
$input['_itil_assign']['groups_id'] = $input['_groups_id_assign'];
$manual_slas_id = 0;
if (isset($input['slas_id']) && ($input['slas_id'] > 0)) {
$manual_slas_id = $input['slas_id'];
}
 
// Only process rules on changes
if (count($changes)) {
// If itemtype changed : set items_locations
if (in_array('itemtype', $changes)) {
$item = NULL;
if (isset($input["items_id"]) && ($input["items_id"] > 0)
&& !empty($input["itemtype"])) {
if ($item = getItemForItemtype($input["itemtype"])) {
if ($item->getFromDB($input["items_id"])) {
if ($item->isField('locations_id')) {
$input['items_locations'] = $item->fields['locations_id'];
$changes[] = 'items_locations';
}
}
}
}
}
 
if (isset($input['_users_id_requester'])) {
if (in_array('_users_id_requester', $changes)) {
$input['_itil_requester']['_type'] = 'user';
$input['_itil_requester']['users_id']// =If $input['_users_id_requester']; changed : set users_locations
$user = new User();
if (isset($input["_users_id_requester"])
&& $user->getFromDB($input["_users_id_requester"])) {
$input['users_locations'] = $user->fields['locations_id'];
$changes[] = 'users_locations';
}
// If _users_id_requester changed : add _groups_id_of_requester to changes
$changes[] = '_groups_id_of_requester';
}
 
if (isset($input['_groups_id_requester'])) {
$input = $rules->processAllRules(Toolbox::stripslashes_deep($input),
$input['_itil_requester']['_type'] = 'group';
Toolbox::stripslashes_deep($input),
$input['_itil_requester']['groups_id'] = $input['_groups_id_requester'];
array('recursive' => true,
'entities_id' => $entid),
array('condition' => RuleTicket::ONUPDATE,
'only_criteria' => $changes));
}
 
// Restore slas_id
if ($manual_slas_id > 0) {
$input['slas_id'] = $manual_slas_id;
}
 
//Action for send_validation rule : do validation before clean
$this->manageValidationAdd($input);
 
// Clean actors fields added for rules
foreach ($tocleanafterrules as $key => $val) {
if ($input[$key] == $val) {
unset($input[$key]);
}
}
if (isset($input['_users_id_observer'])) {
 
$input['_itil_observer']['_type'] = 'user';
// Manage fields from auto update or rules : map rule actions to standard additional ones
$input['_itil_observer']['users_id'] = $input['_users_id_observer'];
$usertypes = array('assign', 'requester', 'observer');
}
$actortypes = array('user','group','supplier');
if (isset($input['_groups_id_observer'])) {
foreach ($usertypes as $t) {
$input['_itil_observer']['_type'] = 'group';
foreach ($actortypes as $a) {
$input['_itil_observer']['groups_id'] = $input['_groups_id_observer'];
if (isset($input['_'.$a.'s_id_'.$t])) {
switch ($a) {
case 'user' :
$additionalfield = '_additional_'.$t.'s';
$input[$additionalfield][] = array('users_id' => $input['_'.$a.'s_id_'.$t]);
break;
 
default :
$additionalfield = '_additional_'.$a.'s_'.$t.'s';
$input[$additionalfield][] = $input['_'.$a.'s_id_'.$t];
break;
}
}
}
}
Linha 800 ⟶ 952:
$ticket_ticket = new Ticket_Ticket();
if (!empty($input['_link']['tickets_id_2'])) {
if ($ticket_ticket->can(-1, 'w'CREATE, $input['_link'])) {
if ($ticket_ticket->add($input['_link'])) {
$input['_forcenotif'] = true;
}
} else {
Session::addMessageAfterRedirect($LANG[__('trackingUnknown ticket'][11]), false, ERROR);
}
}
}
 
if (isset($input["items_iditemtype"]) && empty($input["itemtype"])) {
&& $input["items_id"]> = 0;
&& isset($input["itemtype"])) {
 
if (isset($this->fields['groups_id'])
&& $this->fields['groups_id'] == 0
&& (!isset($input['groups_id']) || $input['groups_id'] == 0)) {
 
if ($input["itemtype"] && ($item = getItemForItemtype($input["itemtype"]))) {
$item->getFromDB($input["items_id"]);
if ($item->isField('groups_id')) {
$input["groups_id"] = $item->getField('groups_id');
}
}
}
 
} else if (isset($input["itemtype"]) && empty($input["itemtype"])) {
$input["items_id"]=0;
 
} else {
unset($input["items_id"]);
unset($input["itemtype"]);
}
//Action for send_validation rule
if (isset($this->input["_add_validation"]) && $this->input["_add_validation"]>0) {
$validation = new TicketValidation();
// if auto_update, tranfert it for validation
if (isset($this->input['_auto_update'])) {
$values['_auto_update'] = $this->input['_auto_update'];
}
$values['tickets_id'] = $this->input['id'];
$values['users_id_validate'] = $this->input["_add_validation"];
 
//// SLA affect by rules : reset due_date
if (!is_numeric(Session::getLoginUserID(false))
// Manual SLA defined : reset due date
|| $validation->can(-1, 'w', $values)) { // cron or allowed user
// No manual SLA and due date defined : reset auto SLA
$validation->add($values);
if (($manual_slas_id == 0)
 
&& Event::logisset($this->fieldsinput['id'], "ticketslas_id", 4, "tracking",])
&& ($input['slas_id'] > 0)
(is_numeric(Session::getLoginUserID(false))?$_SESSION["glpiname"]:'cron')
&& ($input['slas_id'] != ." ".$LANGthis->fields['logslas_id'][21]);) {
if (isset($input['due_date'])) {
// Unset due date
unset($input["due_date"]);
}
}
 
 
if (isset($this->input["slas_id"])
&& ($this->input["slas_id"] > 0)
&& ($input['slas_id'] != $this->fields['slas_id'] == 0)) {
 
$date = $this->fields['date'];
/// Use updated date if also done
if (isset($this->input["date"])) {
$date = $this->input["date"];
}
// Get datas to initialize SLA and set it
$sla_data = $this->getDatasToAddSLA($this->input["slas_id"], $this->fields['entities_id'],
$date);
if (count($sla_data)) {
Linha 873 ⟶ 999:
}
 
$inputif = parent::prepareInputForUpdate(isset($input['content']);) {
if (isset($input['_stock_image'])) {
$this->addImagePaste();
$input['content'] = $input['content'];
$input['_disablenotif'] = true;
} else if ($CFG_GLPI["use_rich_text"]) {
$input['content'] = $this->convertTagToImage($input['content']);
if (!isset($input['_filename'])) {
$input['_donotadddocs'] = true;
}
}
}
 
$input = parent::prepareInputForUpdate($input);
return $input;
}
Linha 880 ⟶ 1 018:
 
function pre_updateInDB() {
global $LANG, $CFG_GLPI;
 
// takeintoaccount :
// - update done by someone who have update right
// see also updatedatemod used by ticketfollowup updates
if (($this->fields['takeintoaccount_delay_stat'] == 0)
&& (Session::haveRight("global_add_taskstask", "1"TicketTask::ADDALLTICKET)
|| Session::haveRighthaveRightsOr("global_add_followups"'followup', "1")
array(TicketFollowup::ADDALLTICKET,
|| ($this->isUser(parent::ASSIGN, Session::getLoginUserID()))
TicketFollowup::ADDMYTICKET,
TicketFollowup::ADDGROUPTICKET))
|| $this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::ASSIGN, $_SESSION['glpigroups'])))) {
 
$this->updates[] = "takeintoaccount_delay_stat";
$this->fields['takeintoaccount_delay_stat'] = $this->computeTakeIntoAccountDelayStat();
Linha 902 ⟶ 1 044:
function computeTakeIntoAccountDelayStat() {
 
if (isset($this->fields['id'])
&& !empty($this->fields['date'])) {
$calendars_id = EntityDataEntity::getUsedConfig('calendars_id', $this->fields['entities_id']);
$calendar = new Calendar();
 
// Using calendar
if (($calendars_id > 0) && $calendar->getFromDB($calendars_id)) {
return max(0, $calendar->getActiveTimeBetween($this->fields['date'],
$_SESSION["glpi_currenttime"]));
}
// Not calendar defined
Linha 920 ⟶ 1 063:
 
function post_updateItem($history=1) {
global $CFG_GLPI, $LANG;
 
$donotif = count($this->updates);
Linha 927 ⟶ 1 070:
$donotif = true;
}
 
 
// Manage SLA Level : add actions
if (in_array("slas_id", $this->updates)
&& ($this->fields["slas_id"] > 0)) {
 
// Add First Level
$calendars_id = EntityDataEntity::getUsedConfig('calendars_id', $this->fields['entities_id']);
 
$sla = new SLA();
Linha 940 ⟶ 1 082:
$sla->setTicketCalendar($calendars_id);
// Add first level in working table
if ($this->fields["slalevels_id"] > 0) {
$sla->addLevelToDo($this);
}
Linha 950 ⟶ 1 092:
if (count($this->updates)) {
// Update Ticket Tco
if (in_array("actiontime", $this->updates)
|| in_array("cost_time", $this->updates)
|| in_array("cost_fixed", $this->updates)
|| in_array("cost_material", $this->updates)) {
 
if ($this->fields["itemtype"]
&& ($item = getItemForItemtype($this->fields["itemtype"]))) {
 
if ($item->getFromDB($this->fields["items_id"])) {
$newinput = array();
$newinput['id'] = $this->fields["items_id"];
$newinput['ticket_tco'] = self::computeTco($item);
Linha 967 ⟶ 1 110:
 
// Setting a solution type means the ticket is solved
if ((in_array("solutiontypes_id", $this->updates)
|| in_array("solution", $this->updates))
&& (in_array($this->input["status"], $this->getSolvedStatusArray())
|| in_array($this->input["status"], $this->getClosedStatusArray()))) { // auto close case
Ticket_Ticket::manageLinkedTicketsOnSolved($this->fields['id']);
}
 
// Clean content to mail
//$this->fields["content"] = stripslashes($this->fields["content"]);
$donotif = true;
 
}
Linha 989 ⟶ 1 132:
if (isset($this->input["status"])
&& $this->input["status"]
&& in_array("status", $this->updates)
&& in_array($this->input["status"], $this->getSolvedStatusArray())) {
 
Linha 1 002 ⟶ 1 145:
$mailtype = "closed";
}
 
// Read again ticket to be sure that all data are up to date
$this->getFromDB($this->fields['id']);
Linha 1 010 ⟶ 1 152:
// inquest created immediatly if delay = O
$inquest = new TicketSatisfaction();
$rate = EntityDataEntity::getUsedConfig('inquest_config', $this->fields['entities_id'],
'inquest_rate');
$delay = EntityDataEntity::getUsedConfig('inquest_config', $this->fields['entities_id'],
'inquest_delay');
$type = EntityDataEntity::getUsedConfig('inquest_config', $this->fields['entities_id']);
$max_closedate = $this->fields['closedate'];
 
Linha 1 032 ⟶ 1 174:
 
function prepareInputForAdd($input) {
global $CFG_GLPI, $LANG;
 
// save value before clean;
$title = ltrim($input['name']);
 
// Standard clean datas
$input = parent::prepareInputForAdd($input);
Linha 1 042 ⟶ 1 182:
// Do not check mandatory on auto import (mailgates)
if (!isset($input['_auto_import'])) {
$_SESSION["helpdeskSaved"] = $input;
if (isset($input['_tickettemplates_id']) && $input['_tickettemplates_id']) {
$tt = new TicketTemplate();
Linha 1 052 ⟶ 1 187:
if (count($tt->mandatory)) {
$mandatory_missing = array();
$fieldsname = $tt->getAllowedFieldsNames(true);
foreach ($tt->mandatory as $key => $val) {
// for title if mandatory (restore initial value)
if ($key == 'name') {
$input['name'] = $title;
$_SESSION["helpdeskSaved"]['name'] = $input['name'];
}
// Check only defined values : Not defined not in form
if (isset($input[$key])) {
// If content is also predefined need to be different from predefined value
if (($key == 'content')
&& isset($tt->predefined['content'])) {
// Clean new lines to be fix encoding
if (strcmp(preg_replace("/\r?\n/", "", $tt->predefined['content']),
preg_replace("/\r?\n/", "", Html::cleanPostForTextArea($input[$key])))==0) {,
preg_replace("/\r?\n/", "",
$tt->predefined['content'])) == 0) {
$mandatory_missing[$key] = $fieldsname[$val];
}
}
 
if (empty($input[$key]) || ($input[$key] == 'NULL')) {
$mandatory_missing[$key] = $fieldsname[$val];
}
}
// For due_date : check also slas_id
if (($key == 'due_date')
&& isset($input['slas_id']) && ($input['slas_id'] > 0)
&& isset($mandatory_missing['due_date'])) {
unset($mandatory_missing['due_date']);
}
}
if (count($mandatory_missing)) {
$message//TRANS: =%s $LANG['job'][68]."&nbsp;".implode(",are ",$mandatory_missing);the fields concerned
$message = sprintf(__('Mandatory fields are not filled. Please correct: %s'),
implode(", ",$mandatory_missing));
Session::addMessageAfterRedirect($message, false, ERROR);
return false;
Linha 1 082 ⟶ 1 228:
}
}
 
// $mandatory_ok = true;
//
// if (!isset($input["urgency"])) {
// Session::addMessageAfterRedirect($LANG['tracking'][4], false, ERROR);
// $mandatory_ok = false;
// }
//
// if ($CFG_GLPI["is_ticket_content_mandatory"]
// && (!isset($input['content']) || empty($input['content']))) {
//
// Session::addMessageAfterRedirect($LANG['tracking'][8], false, ERROR);
// $mandatory_ok = false;
// }
//
// if ($CFG_GLPI["is_ticket_title_mandatory"]
// && (!isset($input['name']) || empty($input['name']))) {
//
// Session::addMessageAfterRedirect($LANG['help'][40], false, ERROR);
// $mandatory_ok = false;
// }
//
// if ($CFG_GLPI["is_ticket_category_mandatory"]
// && (!isset($input['itilcategories_id']) || empty($input['itilcategories_id']))) {
//
// Session::addMessageAfterRedirect($LANG['help'][41], false, ERROR);
// $mandatory_ok = false;
// }
//
// if (!$mandatory_ok) {
// return false;
// }
}
 
unset($_SESSION["helpdeskSaved"]);
 
if (!isset($input["requesttypes_id"])) {
Linha 1 123 ⟶ 1 235:
 
if (!isset($input['global_validation'])) {
$input['global_validation'] = 'none'CommonITILValidation::NONE;
}
 
// Set additional default dropdown
$dropdown_fields = array('items_id', 'items_locations', 'users_locations');
foreach ($dropdown_fields as $field ) {
if (!isset($input[$field])) {
Linha 1 133 ⟶ 1 245:
}
}
if (!isset($input['itemtype']) || !($input['items_id'] > 0)) {
$input['itemtype'] = '';
}
 
$item = NULL;
if (($input["items_id"] > 0) && !empty($input["itemtype"])) {
if ($item = getItemForItemtype($input["itemtype"])) {
if (!$item->getFromDB($input["items_id"])) {
if ($item->isField('locations_id')) {
$input['items_locations'] = $item->fields['locations_id'];
}
} else {
$item = NULL;
}
Linha 1 148 ⟶ 1 264:
// Business Rules do not override manual SLA
$manual_slas_id = 0;
if (isset($input['slas_id']) && ($input['slas_id'] > 0)) {
$manual_slas_id = $input['slas_id'];
}
Linha 1 171 ⟶ 1 287:
}
 
$input = $rules->processAllRules(Toolbox::stripslashes_deep($input), $input, array('recursive' => true));
Toolbox::stripslashes_deep($input),
array('recursive' => true),
array('condition' => RuleTicket::ONADD));
 
// Recompute default values based on values computed by rules
$input = $this->computeDefaultValuesForAdd($input);
Linha 1 188 ⟶ 1 308:
// Manage auto assign
 
$auto_assign_mode = EntityDataEntity::getUsedConfig('auto_assign_mode', $input['entities_id']);
 
switch ($auto_assign_mode) {
case EntityDataEntity::CONFIG_NEVER :
break;
 
case EntityDataEntity::AUTO_ASSIGN_HARDWARE_CATEGORY :
if ($item != NULL) {
// Auto assign tech from item
if ((!isset($input['_users_id_assign']) || ($input['_users_id_assign'] == 0))
&& $item->isField('users_id_tech')) {
$input['_users_id_assign'] = $item->getField('users_id_tech');
}
// Auto assign group from item
if ((!isset($input['_groups_id_assign']) || ($input['_groups_id_assign'] == 0))
&& $item->isField('groups_id_tech')) {
$input['_groups_id_assign'] = $item->getField('groups_id_tech');
Linha 1 208 ⟶ 1 328:
}
// Auto assign tech/group from Category
if (($input['itilcategories_id'] > 0)
&& ((!isset($input['_users_id_assign']) || !$input['_users_id_assign'])
|| (!isset($input['_groups_id_assign']) || !$input['_groups_id_assign']))) {
Linha 1 225 ⟶ 1 345:
break;
 
case EntityDataEntity::AUTO_ASSIGN_CATEGORY_HARDWARE :
// Auto assign tech/group from Category
if (($input['itilcategories_id'] > 0)
&& ((!isset($input['_users_id_assign']) || !$input['_users_id_assign'])
|| (!isset($input['_groups_id_assign']) || !$input['_groups_id_assign']))) {
Linha 1 234 ⟶ 1 354:
$cat->getFromDB($input['itilcategories_id']);
if ((!isset($input['_users_id_assign']) || !$input['_users_id_assign'])
&& $cat->isField('users_id')) {
$input['_users_id_assign'] = $cat->getField('users_id');
}
Linha 1 242 ⟶ 1 362:
}
}
if ($item != NULL) {
// Auto assign tech from item
if ((!isset($input['_users_id_assign']) || ($input['_users_id_assign'] == 0))
&& $item->isField('users_id_tech')) {
$input['_users_id_assign'] = $item->getField('users_id_tech');
}
// Auto assign group from item
if ((!isset($input['_groups_id_assign']) || ($input['_groups_id_assign'] == 0))
&& $item->isField('groups_id_tech')) {
$input['_groups_id_assign'] = $item->getField('groups_id_tech');
Linha 1 258 ⟶ 1 378:
 
// Replay setting auto assign if set in rules engine or by auto_assign_mode
if (((isset($input["_users_id_assign"]) && ($input["_users_id_assign"] > 0))
|| (isset($input["_groups_id_assign"]) && ($input["_groups_id_assign"] > 0))
|| (isset($input["suppliers_id_assign_suppliers_id_assign"]) && ($input["suppliers_id_assign_suppliers_id_assign"] > 0)))
&& (in_array($input['status'], $this->getNewStatusArray()))) {
 
$input["status"] = "assign"self::ASSIGNED;
}
 
Linha 1 270 ⟶ 1 390:
// Manual SLA defined : reset due date
// No manual SLA and due date defined : reset auto SLA
if (($manual_slas_id == 0)
&& isset($input["due_date"]) && ($input['due_date'] != 'NULL')) {
// Valid due date
if ($input['due_date'] >= $input['date']) {
if (isset($input["slas_id"])) {
unset($input["slas_id"]);
Linha 1 283 ⟶ 1 403:
}
 
if (isset($input["slas_id"]) && ($input["slas_id"] > 0)) {
// Get datas to initialize SLA and set it
$sla_data = $this->getDatasToAddSLA($input["slas_id"], $input['entities_id'],
Linha 1 296 ⟶ 1 416:
// auto set type if not set
if (!isset($input["type"])) {
$input['type'] = EntityDataEntity::getUsedConfig('tickettype', $input['entities_id'], '',
'', Ticket::INCIDENT_TYPE);
}
 
return $input;
}
Linha 1 305 ⟶ 1 424:
 
function post_addItem() {
global $LANG, $CFG_GLPI;
 
if (isset($this->input['content'])) {
if (isset($this->input['_stock_image'])) {
$this->addImagePaste();
}
}
 
// Log this event
$username = 'anonymous';
if (isset($_SESSION["glpiname"])) {
$username = $_SESSION["glpiname"];
}
Event::log($this->fields['id'], "ticket", 4, "tracking",
getUserNamesprintf(Session::getLoginUserID__())."'%1$s ".adds the item %2$LANG[s'log'][20]);, $username,
$this->fields['id']));
 
if (isset($this->input["_followup"])
&& is_array($this->input["_followup"])
&& (strlen($this->input["_followup"]['content']) > 0)) {
 
$fup = new TicketFollowup();
$type = "new";
if (isset($this->fields["status"]) && ($this->fields["status"] =="solved" self::SOLVED)) {
$type = "solved";
}
Linha 1 324 ⟶ 1 454:
 
if (isset($this->input["_followup"]['content'])
&& (strlen($this->input["_followup"]['content']) > 0)) {
$toadd["content"] = $this->input["_followup"]['content'];
}
Linha 1 331 ⟶ 1 461:
$toadd["is_private"] = $this->input["_followup"]['is_private'];
}
// $toadd['_no_notif'] = true;
 
$fup->add($toadd);
Linha 1 337 ⟶ 1 467:
 
if ((isset($this->input["plan"]) && count($this->input["plan"]))
|| (isset($this->input["actiontime"]) && ($this->input["actiontime"] > 0))) {
 
$task = new TicketTask();
$type = "new";
if (isset($this->fields["status"]) && ($this->fields["status"] =="solved" self::SOLVED)) {
$type = "solved";
}
Linha 1 347 ⟶ 1 477:
"tickets_id" => $this->fields['id'],
"actiontime" => $this->input["actiontime"]);
 
if (isset($this->input["plan"]) && count($this->input["plan"])) {
$toadd["plan"] = $this->input["plan"];
}
 
if (isset($_SESSION['glpitask_private'])) {
Linha 1 352 ⟶ 1 486:
}
 
// $toadd['_no_notif'] = true;
if (isset($this->input["plan"]) && count($this->input["plan"])) {
$toadd["plan"] = $this->input["plan"];
}
$toadd['_no_notif'] = true;
 
$task->add($toadd);
Linha 1 367 ⟶ 1 498:
// message if ticket's ID doesn't exist
if (!empty($this->input['_link']['tickets_id_2'])) {
if ($ticket_ticket->can(-1, 'w'CREATE, $this->input['_link'])) {
$ticket_ticket->add($this->input['_link']);
} else {
Session::addMessageAfterRedirect($LANG[__('trackingUnknown ticket'][11]), false, ERROR);
}
}
Linha 1 384 ⟶ 1 515:
 
// Manage SLA Level : add actions
if (isset($this->input["slas_id"]) && ($this->input["slas_id"] > 0)
&& isset($this->input["slas_idslalevels_id"]) && ($this->input["slalevels_id"] > 0)) {
&& isset($this->input["slalevels_id"])
&& $this->input["slalevels_id"]>0) {
 
$calendars_id = EntityDataEntity::getUsedConfig('calendars_id', $this->fields['entities_id']);
 
$sla = new SLA();
Linha 1 395 ⟶ 1 524:
$sla->setTicketCalendar($calendars_id);
// Add first level in working table
if ($this->input["slalevels_id"] > 0) {
$sla->addLevelToDo($this);
}
Linha 1 403 ⟶ 1 532:
}
 
// Add project task link if needed
parent::post_addItem();
if (isset($this->input['_projecttasks_id'])) {
 
$projecttask = new ProjectTask();
//Action for send_validation rule
if (isset($thisprojecttask->input["_add_validation"]) && getFromDB($this->input["_add_validation"'_projecttasks_id']>0)) {
$pt = new ProjectTask_Ticket();
 
$pt->add(array('projecttasks_id' => $this->input['_projecttasks_id'],
$validation = new Ticketvalidation();
$values[ 'tickets_id'] => $this->fields['id'];,
/*'_no_notif' => true*/));
$values['users_id_validate'] = $this->input["_add_validation"];
// to know update by rules
if (isset($this->input["_rule_process"])) {
$values['_rule_process'] = $this->input["_rule_process"];
}
}
// if auto_import, tranfert it for validation
if (isset($this->input['_auto_import'])) {
$values['_auto_import'] = $this->input['_auto_import'];
}
$values['_ticket_add'] = true;
 
parent::post_addItem();
// Cron or rule process of hability to do
if (!is_numeric(Session::getLoginUserID(false))
|| isset($this->input["_rule_process"])
|| isset($this->input["_auto_import"])
|| $validation->can(-1, 'w', $values)) { // cron or allowed user
$validation->add($values);
 
$this->manageValidationAdd($this->input);
Event::log($this->fields['id'], "ticket", 4, "tracking",
$_SESSION["glpiname"]." ".$LANG['log'][21]);
}
}
 
// Processing Email
Linha 1 439 ⟶ 1 553:
 
$type = "new";
if (isset($this->fields["status"]) && ($this->fields["status"] =="solved" self::SOLVED)) {
$type = "solved";
}
Linha 1 446 ⟶ 1 560:
 
if (isset($_SESSION['glpiis_ids_visible']) && !$_SESSION['glpiis_ids_visible']) {
Session::addMessageAfterRedirect($LANG[sprintf(__('help'][18]."%1$s (".%2$LANG['jobs)'][38]."&nbsp;".),
__('Your ticket has been registered, its treatment is in "<a href=progress.'".$CFG_GLPI["root_doc"].),
"/front/ticket.form.php?id=". sprintf(__('%1$s: %2$this->fields[s'id), __(']."Ticket'>".),
$this->fields['id']. "</a>) href='");.$CFG_GLPI["root_doc"].
"/front/ticket.form.php?id=".
$this->fields['id']."'>".
$this->fields['id']."</a>")));
}
 
Linha 1 455 ⟶ 1 572:
 
 
/**
// SPECIFIC FUNCTIONS
* Manage Validation add from input
*
* @since version 0.85
*
* @param $input array : input array
*
* @return nothing
**/
function manageValidationAdd($input) {
 
//Action for send_validation rule
if (isset($input["_add_validation"])) {
if (isset($input['entities_id'])) {
$entid = $input['entities_id'];
} else if (isset($this->fields['entities_id'])){
$entid = $this->fields['entities_id'];
} else {
return false;
}
 
$validations_to_send = array();
if (!is_array($input["_add_validation"])) {
$input["_add_validation"] = array($input["_add_validation"]);
}
 
foreach ($input["_add_validation"] as $key => $validation) {
switch ($validation) {
case 'requester_supervisor' :
if (isset($input['_groups_id_requester'])
&& $input['_groups_id_requester']) {
$users = Group_User::getGroupUsers($input['_groups_id_requester'],
"is_manager='1'");
foreach ($users as $data) {
$validations_to_send[] = $data['id'];
}
}
// Add to already set groups
foreach ($this->getGroups(CommonITILActor::REQUESTER) as $d) {
$users = Group_User::getGroupUsers($d['groups_id'], "is_manager='1'");
foreach ($users as $data) {
$validations_to_send[] = $data['id'];
}
}
break;
 
case 'assign_supervisor' :
if (isset($input['_groups_id_assign'])
&& $input['_groups_id_assign']) {
$users = Group_User::getGroupUsers($input['_groups_id_assign'],
"is_manager='1'");
foreach ($users as $data) {
$validations_to_send[] = $data['id'];
}
}
foreach ($this->getGroups(CommonITILActor::ASSIGN) as $d) {
$users = Group_User::getGroupUsers($d['groups_id'], "is_manager='1'");
foreach ($users as $data) {
$validations_to_send[] = $data['id'];
}
}
break;
 
default :
// Group case from rules
if ($key === 'group') {
foreach ($validation as $groups_id) {
$validation_right = 'validate_incident';
if (isset($input['type'])
&& ($input['type'] == Ticket::DEMAND_TYPE)) {
$validation_right = 'validate_request';
}
$opt = array('groups_id' => $groups_id,
'right' => $validation_right,
'entity' => $entid);
 
$data_users = TicketValidation::getGroupUserHaveRights($opt);
 
foreach ($data_users as $user) {
$validations_to_send[] = $user['id'];
}
}
} else {
$validations_to_send[] = $validation;
}
}
 
}
 
// Validation user added on ticket form
if (isset($input['users_id_validate'])) {
if (array_key_exists('groups_id', $input['users_id_validate'])) {
foreach ($input['users_id_validate'] as $key => $validation_to_add){
if (is_numeric($key)) {
$validations_to_send[] = $validation_to_add;
}
}
} else {
foreach ($input['users_id_validate'] as $key => $validation_to_add) {
if (is_numeric($key)) {
$validations_to_send[] = $validation_to_add;
}
}
}
}
 
// Keep only one
$validations_to_send = array_unique($validations_to_send);
 
$validation = new TicketValidation();
 
if (count($validations_to_send)) {
$values = array();
$values['tickets_id'] = $this->fields['id'];
if ($input['id'] != $this->fields['id']) {
$values['_ticket_add'] = true;
}
 
// to know update by rules
if (isset($input["_rule_process"])) {
$values['_rule_process'] = $input["_rule_process"];
}
// if auto_import, tranfert it for validation
if (isset($input['_auto_import'])) {
$values['_auto_import'] = $input['_auto_import'];
}
 
// Cron or rule process of hability to do
if (Session::isCron()
|| isset($input["_auto_import"])
|| isset($input["_rule_process"])
|| $validation->can(-1, CREATE, $values)) { // cron or allowed user
 
$add_done = false;
foreach ($validations_to_send as $user) {
// Do not auto add twice same validation
if (!TicketValidation::alreadyExists($values['tickets_id'], $user)) {
$values["users_id_validate"] = $user;
if ($validation->add($values)) {
$add_done = true;
}
}
}
if ($add_done) {
Event::log($this->fields['id'], "ticket", 4, "tracking",
sprintf(__('%1$s updates the item %2$s'), $_SESSION["glpiname"],
$this->fields['id']));
}
}
}
}
return true;
}
 
 
/**
* Number of followups of the ticket
*
* @param $with_private boolean : true : all followups / false : only public ones (default 1)
*
* @return followup count
Linha 1 472 ⟶ 1 743:
 
// Set number of followups
$query = "SELECT countCOUNT(*)
FROM `glpi_ticketfollowups`
WHERE `tickets_id` = '".$this->fields["id"]."'
Linha 1 485 ⟶ 1 756:
* Number of tasks of the ticket
*
* @param $with_private boolean : true : all ticket / false : only public ones (default 1)
*
* @return followup count
Linha 1 498 ⟶ 1 769:
 
// Set number of followups
$query = "SELECT countCOUNT(*)
FROM `glpi_tickettasks`
WHERE `tickets_id` = '".$this->fields["id"]."'
Linha 1 513 ⟶ 1 784:
* @since version 0.83
*
* @param $itemtype string Item type
* @param $items_id integer ID of the Item
* @param $days integer day number
*
* @return integer
Linha 1 549 ⟶ 1 820:
* @since version 0.83
*
* @param $itemtype string Item type
* @param $items_id integer ID of the Item
*
* @return integer
Linha 1 572 ⟶ 1 843:
* @since version 0.83
*
* @param $itemtype string Item type
* @param $items_id integer ID of the Item
* @param $days integer day number
*
* @return integer
**/
function countSolvedTicketsForItemLastDays($itemtype, $items_id, $days) {
 
return countElementsInTable($this->getTable(),
Linha 1 597 ⟶ 1 868:
* Update date mod of the ticket
*
* @paramsince $IDversion ID0.83.3 ofnew the ticketproto
*
* @param $no_stat_computation boolean do not cumpute take into account stat
* @param $ID ID of the ticket
* @param $no_stat_computation boolean do not cumpute take into account stat (false by default)
* @param $users_id_lastupdater integer to force last_update id (default 0 = not used)
**/
Linha 1 606 ⟶ 1 879:
if ($this->getFromDB($ID)) {
if (!$no_stat_computation
&& (Session::haveRight("global_add_tasks"'task', "1"TicketTask::ADDALLTICKET)
|| Session::haveRighthaveRightsOr("global_add_followups"'followup', "1")
array(TicketFollowup::ADDALLTICKET,
|| ($this->isUser(parent::ASSIGN,Session::getLoginUserID()))
TicketFollowup::ADDMYTICKET,
TicketFollowup::ADDGROUPTICKET))
|| $this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID())
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::ASSIGN, $_SESSION['glpigroups'])))) {
 
if ($this->fields['takeintoaccount_delay_stat'] == 0) {
Linha 1 622 ⟶ 1 898:
parent::updateDateMod($ID, $no_stat_computation, $users_id_lastupdater);
}
}
 
 
/**
* Get text describing Followups
*
* @param $format text or html
* @param $sendprivate true if both public and private followups have to be printed in the email
**/
function textFollowups($format="text", $sendprivate=false) {
global $DB,$LANG;
 
// get the last followup for this job and give its content as
if (isset($this->fields["id"])) {
$query = "SELECT *
FROM `glpi_ticketfollowups`
WHERE `tickets_id` = '".$this->fields["id"]."' ".
($sendprivate?"":" AND `is_private` = '0' ")."
ORDER by `date` DESC";
 
$result = $DB->query($query);
$nbfollow = $DB->numrows($result);
 
$fup = new TicketFollowup();
 
if ($format == "html") {
$message = "<div class='description b'>".$LANG['mailing'][4]."&nbsp;: $nbfollow<br></div>\n";
 
if ($nbfollow > 0) {
while ($data = $DB->fetch_array($result)) {
$fup->getFromDB($data['id']);
$message .= "<span class='b'>[ ".Html::convDateTime($fup->fields["date"])." ] ".
($fup->fields["is_private"]?"<i>".$LANG['common'][77]."</i>":"").
"</span>\n";
$message .= "<span style='color:#8B8C8F; font-weight:bold; ".
"text-decoration:underline; '>".$LANG['job'][4]."teste1"."&nbsp;:</span> ".
$fup->getAuthorName()."\n";
$message .= "<span style='color:#8B8C8F; font-weight:bold; ".
"text-decoration:underline; '>".$LANG['knowbase'][15]."</span>&nbsp;:
<br>".str_replace("\n","<br>",$fup->fields["content"])."\n";
 
if ($fup->fields["actiontime"]>0) {
$message .= "<span style='color:#8B8C8F; font-weight:bold; ".
"text-decoration:underline; '>".$LANG['mailing'][104]."&nbsp;:".
".</span> ".parent::getActionTime($fup->fields["actiontime"])."\n";
}
$message .= "<span style='color:#8B8C8F; font-weight:bold; ".
"text-decoration:underline; '>".$LANG['job'][35]."&nbsp;:</span> ";
 
$message .= $LANG['mailing'][0]."\n";
}
}
 
} else { // text format
$message = $LANG['mailing'][1]."\n".$LANG['mailing'][4]." : $nbfollow\n".
$LANG['mailing'][1]."\n";
 
if ($nbfollow > 0) {
while ($data=$DB->fetch_array($result)) {
$fup->getFromDB($data['id']);
$message .= "[ ".Html::convDateTime($fup->fields["date"])." ]".
($fup->fields["is_private"]?"\t".$LANG['common'][77] :"")."\n";
$message .= $LANG['job'][4]."teste2"."&nbsp;: ".$fup->getAuthorName()."\n";
$message .= $LANG['knowbase'][15]."&nbsp;:\n".$fup->fields["content"]."\n";
if ($fup->fields["actiontime"]>0) {
$message .= $LANG['mailing'][104]."&nbsp;: ".
parent::getActionTime($fup->fields["actiontime"])."\n";
}
$message .= $LANG['job'][35]."&nbsp;: ";
 
$message .= $LANG['mailing'][0]."\n";
}
}
}
return $message;
}
return "";
}
 
Linha 1 713 ⟶ 1 912:
function canAddItem($type) {
 
if (($type == 'Document')
&& ($this->getField('status') == 'closed'self::CLOSED)) {
return false;
}
Linha 1 727 ⟶ 1 927:
function canAddFollowups() {
 
return ((Session::haveRight("add_followupsfollowup","1" TicketFollowup::ADDMYTICKET)
&& ($this->isUser(parentCommonITILActor::REQUESTER, Session::getLoginUserID())
|| ($this->fields["users_id_recipient"] === Session::getLoginUserID())))
|| Session::haveRight("global_add_followups"'followup',"1" TicketFollowup::ADDALLTICKET)
|| (Session::haveRight("group_add_followups"'followup',"1" TicketFollowup::ADDGROUPTICKET)
&& isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::REQUESTER, $_SESSION['glpigroups']))
|| ($this->isUser(parentCommonITILActor::ASSIGN, Session::getLoginUserID()))
|| (isset($_SESSION["glpigroups"])
&& $this->haveAGroup(parentCommonITILActor::ASSIGN, $_SESSION['glpigroups'])));
}
 
Linha 1 745 ⟶ 1 945:
static function getDefaultSearchRequest() {
 
$search = array('fieldcriteria' => array(0 => array(0'field' => 12),
'searchtype' => array(0 => 'equals'),
'containsvalue' => array(0 => 'notclosed')),
'sort' => 19,
'order' => 'DESC');
 
if (Session::haveRight('show_all_ticket'self::$rightname,1 self::READALL)) {
$search['containscriteria'] = array([0]['value'] => 'notold');
}
return $search;
Linha 1 758 ⟶ 1 958:
 
 
/**
function getSearchOptions() {
* @see CommonDBTM::getSpecificMassiveActions()
global $LANG;
**/
function getSpecificMassiveActions($checkitem=NULL) {
 
$tabisadmin = arraystatic::canUpdate();
$actions = parent::getSpecificMassiveActions($checkitem);
$tab['common'] = $LANG['common'][32];
 
if ($tab_SESSION[1'glpiactiveprofile']['tableinterface'] == $this->getTable('central'); {
if (TicketFollowup::canCreate()) {
$tab[1]['field'] = 'name';
$actions['TicketFollowup'.MassiveAction::CLASS_ACTION_SEPARATOR.'add_followup']
//cbmes alteração
//$tab[1]['name'] = $LANG[__('commonAdd a new followup'][57]);
$tab[1]['name'] = 'Assunto';}
//cbmes alteração fim
$tab[1]['searchtype'] = 'contains';
$tab[1]['datatype'] = 'string';
$tab[1]['forcegroupby'] = true;
$tab[1]['massiveaction'] = false;
//cbmes alteração
$tab[701]['table'] = $this->getTable();
$tab[701]['field'] = 'nome_cbmes';
$tab[701]['name'] = 'Nome';
$tab[701]['searchtype'] = 'contains';
$tab[701]['datatype'] = 'string';
$tab[701]['forcegroupby'] = true;
$tab[701]['massiveaction'] = false;
$tab[702]['table'] = $this->getTable();
$tab[702]['field'] = 'posto_grad_cbmes';
$tab[702]['name'] = 'Posto ou Graduação';
$tab[702]['searchtype'] = 'contains';
$tab[702]['datatype'] = 'string';
$tab[702]['forcegroupby'] = true;
$tab[702]['massiveaction'] = false;
 
if (TicketTask::canCreate()) {
$actions[__CLASS__.MassiveAction::CLASS_ACTION_SEPARATOR.'add_task'] = __('Add a new task');
}
 
if (TicketValidation::canCreate()) {
$tab[703]['table'] = $this->getTable();
$actions['TicketValidation'.MassiveAction::CLASS_ACTION_SEPARATOR.'submit_validation']
$tab[703]['field'] = 'funcional_cbmes';
$tab[703]['name'] = __('NºApproval Funcionalrequest');
}
$tab[703]['searchtype'] = 'contains';
$tab[703]['datatype'] = 'string';
$tab[703]['forcegroupby'] = true;
$tab[703]['massiveaction'] = false;
 
if (Session::haveRight(self::$rightname, UPDATE)) {
$actions[__CLASS__.MassiveAction::CLASS_ACTION_SEPARATOR.'add_actor']
= __('Add an actor');
$actions['Ticket_Ticket'.MassiveAction::CLASS_ACTION_SEPARATOR.'add']
= _x('button', 'Link tickets');
}
 
if (Session::haveRight(self::$rightname, UPDATE)) {
$tab[704]['table'] = $this->getTable();
MassiveAction::getAddTransferList($actions);
$tab[704]['field'] = 'obm_cbmes';
$tab[704]['name'] = 'OBM';}
}
$tab[704]['searchtype'] = 'contains';
return $actions;
$tab[704]['datatype'] = 'string';
}
$tab[704]['forcegroupby'] = true;
$tab[704]['massiveaction'] = false;
$tab[705]['table'] = $this->getTable();
$tab[705]['field'] = 'tel_cbmes';
$tab[705]['name'] = 'Telefone';
$tab[705]['searchtype'] = 'contains';
$tab[705]['datatype'] = 'string';
$tab[705]['forcegroupby'] = true;
$tab[705]['massiveaction'] = false;
$tab[706]['table'] = $this->getTable();
$tab[706]['field'] = 'patrimonio_cbmes';
$tab[706]['name'] = 'Patrimonio';
$tab[706]['searchtype'] = 'contains';
$tab[706]['datatype'] = 'string';
$tab[706]['forcegroupby'] = true;
$tab[706]['massiveaction'] = false;
$tab[708]['table'] = $this->getTable();
$tab[708]['field'] = 'setor_cbmes';
$tab[708]['name'] = 'Setor';
$tab[708]['searchtype'] = 'contains';
$tab[708]['datatype'] = 'string';
$tab[708]['forcegroupby'] = true;
$tab[708]['massiveaction'] = false;
//cbmes alteração fim
 
$tab[21]['table'] = $this->getTable();
$tab[21]['field'] = 'content';
$tab[21]['name'] = $LANG['joblist'][6];
$tab[21]['massiveaction'] = false;
$tab[21]['datatype'] = 'text';
 
$tab[2]['table'] = $this->getTable();
$tab[2]['field'] = 'id';
$tab[2]['name'] = $LANG['common'][2];
$tab[2]['massiveaction'] = false;
$tab[2]['datatype'] = 'number';
 
$tab[12]['table'] = $this->getTable();
$tab[12]['field'] = 'status';
$tab[12]['name'] = $LANG['joblist'][0];
$tab[12]['searchtype'] = 'equals';
 
$tab[14]['table'] = $this->getTable();
$tab[14]['field'] = 'type';
$tab[14]['name'] = $LANG['common'][17];
$tab[14]['searchtype'] = 'equals';
 
function getSearchOptions() {
$tab[10]['table'] = $this->getTable();
$tab[10]['field'] = 'urgency';
$tab[10]['name'] = $LANG['joblist'][29];
$tab[10]['searchtype'] = 'equals';
 
$tab[11]['table'] = $this->getTablearray();
$tab[11]['field'] = 'impact';
$tab[11]['name'] = $LANG['joblist'][30];
$tab[11]['searchtype'] = 'equals';
 
$tab[3]['table'] += $this->getTablegetSearchOptionsMain();
$tab[3]['field'] = 'priority';
$tab[3]['name'] = $LANG['joblist'][2];
$tab[3]['searchtype'] = 'equals';
 
$tab[1514]['table'] = $this->getTable();
$tab[1514]['field'] = 'datetype';
$tab[1514]['name'] = $LANG[__('reportsType'][60]);
$tab[1514]['datatypesearchtype'] = 'datetimeequals';
$tab[1514]['massiveactiondatatype'] = false'specific';
 
$tab[1613]['table'] = $this->getTable();
$tab[1613]['field'] = 'closedateitems_id';
$tab[1613]['name'] = $LANG[__('reportsAssociated element'][61]);
$tab[1613]['datatype'] = 'datetimespecific';
$tab[1613]['massiveactionnosearch'] = falsetrue;
$tab[13]['comments'] = true;
$tab[13]['nosort'] = true;
$tab[13]['massiveaction'] = false;
$tab[13]['additionalfields'] = array('itemtype');
 
$tab[18131]['table'] = $this->getTable();
$tab[18131]['field'] = 'due_dateitemtype';
$tab[18131]['name'] = $LANG[_n('slaAssociated item type'][5], 'Associated item types',1);
$tab[18131]['datatype'] = 'datetimeitemtypename';
$tab[18131]['maybefutureitemtype_list'] = true'ticket_types';
$tab[18131]['massiveactionnosort'] = falsetrue;
$tab[131]['massiveaction'] = false;
 
$tab[829]['table'] = $this->getTable()'glpi_requesttypes';
$tab[829]['field'] = 'is_latename';
$tab[829]['name'] = $LANG[__('jobRequest source'][17]);
$tab[829]['datatype'] = 'booldropdown';
$tab[82]['massiveaction'] = false;
 
// Can't use Location::getSearchOptionsToAdd because id conflicts
$tab[17]['table'] = $this->getTable();
$tab[1783]['fieldtable'] = 'solvedateglpi_locations';
$tab[1783]['namefield'] = $LANG['reportscompletename'][64];
$tab[1783]['datatypename'] = __('datetimeLocation');
$tab[1783]['massiveactiondatatype'] = false'dropdown';
 
$tab[1980]['table'] = $this->getTable()'glpi_entities';
$tab[1980]['field'] = 'date_modcompletename';
$tab[1980]['name'] = $LANG[__('commonEntity'][26]);
$tab[1980]['datatypemassiveaction'] = 'datetime'false;
$tab[1980]['massiveactiondatatype'] = false'dropdown';
 
// For ticket template
$tab[7]['table'] = 'glpi_itilcategories';
$tab[7142]['fieldtable'] = 'completenameglpi_documents';
$tab[7142]['namefield'] = $LANG['commonname'][36];
$tab[7142]['datatypename'] = _n('dropdownDocument', 'Documents', 2);
$tab[142]['forcegroupby'] = true;
 
$tab[142]['usehaving'] = true;
 
$tab[13142]['tablenosearch'] = $this->getTable()true;
$tab[13142]['fieldnodisplay'] = 'items_id'true;
$tab[13142]['namedatatype'] = $LANG['documentdropdown'][14];
$tab[13142]['nosearchmassiveaction'] = truefalse;
$tab[13142]['nosortjoinparams'] = array('jointype' => true;'items_id',
'beforejoin' => array('table'
$tab[13]['massiveaction'] = false;
=> 'glpi_documents_items',
 
'joinparams'
$tab[131]['table'] = $this->getTable();
$tab[131]['field'] => array('itemtypejointype';
=> 'itemtype_item')));
$tab[131]['name'] = $LANG['document'][14].' - '.$LANG['common'][17];
$tab[131]['datatype'] = 'itemtypename';
$tab[131]['itemtype_list'] = 'ticket_types';
$tab[131]['nosort'] = true;
$tab[131]['massiveaction'] = false;
 
$tab[9]['table'] = 'glpi_requesttypes';
$tab[9]['field'] = 'name';
$tab[9]['name'] = $LANG['job'][44];
$tab[9]['datatype'] = 'dropdown';
 
$tab[80]['table'] = 'glpi_entities';
$tab[80]['field'] = 'completename';
$tab[80]['name'] = $LANG['entity'][0];
$tab[80]['massiveaction'] = false;
$tab[80]['datatype'] = 'dropdown';
 
 
$tab[45]['table'] = $this->getTable();
$tab[45]['field'] = 'actiontime';
$tab[45]['name'] = $LANG['job'][20];
$tab[45]['datatype'] = 'timestamp';
$tab[45]['massiveaction'] = false;
$tab[45]['nosearch'] = true;
 
$tab[64]['table'] = 'glpi_users';
$tab[64]['field'] = 'name';
$tab[64]['linkfield'] = 'users_id_lastupdater';
$tab[64]['name'] = $LANG['common'][101];
$tab[64]['massiveaction'] = false;
 
$tab += $this->getSearchOptionsActors();
 
$tab['sla'] = $LANG['sla'][1];
 
$tab[30]['tablesla'] = __('glpi_slasSLA');
$tab[30]['field'] = 'name';
$tab[30]['name'] = $LANG['sla'][1];
$tab[30]['massiveaction'] = false;
$tab[30]['datatype'] = 'dropdown';
 
$tab[3230]['table'] = 'glpi_slalevelsglpi_slas';
$tab[3230]['field'] = 'name';
$tab[3230]['name'] = $LANG[__('slaSLA'][6]);
$tab[3230]['massiveaction'] = false;
$tab[30]['datatype'] = 'dropdown';
 
$tab[32]['table'] = 'glpi_slalevels';
$tab[32]['field'] = 'name';
$tab[32]['name'] = __('Escalation level');
$tab[32]['massiveaction'] = false;
$tab[32]['datatype'] = 'dropdown';
 
$tab += TicketValidation::getSearchOptionsToAdd();
$tab['validation'] = $LANG['validation'][0];
 
$tab[52]['tablesatisfaction'] = $this->getTable__('Satisfaction survey');
$tab[52]['field'] = 'global_validation';
$tab[52]['name'] = $LANG['validation'][0];
$tab[52]['searchtype'] = 'equals';
 
$tab[5331]['table'] = 'glpi_ticketvalidationsglpi_ticketsatisfactions';
$tab[5331]['field'] = 'comment_submissiontype';
$tab[5331]['name'] = $LANG['validation'][0]." - ".$LANG[ = __('validationType'][5]);
$tab[5331]['datatypemassiveaction'] = 'text'false;
$tab[5331]['forcegroupbysearchtype'] = truearray('equals', 'notequals');
$tab[5331]['massiveactionsearchequalsonfield'] = falsetrue;
$tab[5331]['joinparams'] = array('jointype' => 'child');
$tab[31]['datatype'] = 'specific';
 
$tab[5460]['table'] = 'glpi_ticketvalidationsglpi_ticketsatisfactions';
$tab[5460]['field'] = 'comment_validationdate_begin';
$tab[5460]['name'] = $LANG[__('validation'][0]."Creation - ".$LANG[date'validation'][6]);
$tab[5460]['datatype'] = 'textdatetime';
$tab[5460]['forcegroupbymassiveaction'] = truefalse;
$tab[5460]['massiveactionjoinparams'] = falsearray('jointype' => 'child');
$tab[54]['joinparams'] = array('jointype' => 'child');
 
$tab[5561]['table'] = 'glpi_ticketvalidationsglpi_ticketsatisfactions';
$tab[5561]['field'] = 'statusdate_answered';
$tab[5561]['name'] = $LANG[__('validation'][0]."Response - ".$LANG[date'joblist'][0]);
$tab[5561]['searchtypedatatype'] = 'equalsdatetime';
$tab[5561]['forcegroupbymassiveaction'] = truefalse;
$tab[5561]['massiveactionjoinparams'] = falsearray('jointype' => 'child');
$tab[55]['joinparams'] = array('jointype' => 'child');
 
$tab[5662]['table'] = 'glpi_ticketvalidationsglpi_ticketsatisfactions';
$tab[5662]['field'] = 'submission_datesatisfaction';
$tab[5662]['name'] = $LANG['validation'][0]." - ".$LANG[ = __('validationSatisfaction'][3]);
$tab[5662]['datatype'] = 'datetimenumber';
$tab[5662]['forcegroupbymassiveaction'] = truefalse;
$tab[5662]['massiveactionjoinparams'] = falsearray('jointype' => 'child');
$tab[56]['joinparams'] = array('jointype' => 'child');
 
$tab[5763]['table'] = 'glpi_ticketvalidationsglpi_ticketsatisfactions';
$tab[5763]['field'] = 'validation_datecomment';
$tab[5763]['name'] = $LANG['validation'][0]." - ".$LANG[ = __('validationComments'][4]);
$tab[5763]['datatype'] = 'datetimetext';
$tab[5763]['forcegroupbymassiveaction'] = truefalse;
$tab[5763]['massiveactionjoinparams'] = falsearray('jointype' => 'child');
$tab[57]['joinparams'] = array('jointype' => 'child');
 
$tab[58]['table'] = 'glpi_users';
$tab[58]['field'] = 'name';
$tab[58]['name'] = $LANG['validation'][0]." - ".$LANG['job'][4]."teste1";
$tab[58]['datatype'] = 'itemlink';
$tab[58]['itemlink_type'] = 'User';
$tab[58]['forcegroupby'] = true;
$tab[58]['massiveaction'] = false;
$tab[58]['joinparams'] = array('beforejoin'
=> array('table' => 'glpi_ticketvalidations',
'joinparams' => array('jointype' => 'child')));
 
$tab[59]['table'] = 'glpi_users';
$tab[59]['field'] = 'name';
$tab[59]['linkfield'] = 'users_id_validate';
$tab[59]['name'] = $LANG['validation'][0]." - ".$LANG['validation'][21];
$tab[59]['datatype'] = 'itemlink';
$tab[59]['itemlink_type'] = 'User';
$tab[59]['forcegroupby'] = true;
$tab[59]['massiveaction'] = false;
$tab[59]['joinparams'] = array('beforejoin'
=> array('table' => 'glpi_ticketvalidations',
'joinparams' => array('jointype' => 'child')));
 
 
$tab['satisfaction'] = $LANG['satisfaction'][3];
 
$tab[31]['table'] = 'glpi_ticketsatisfactions';
$tab[31]['field'] = 'type';
$tab[31]['name'] = $LANG['common'][17];
$tab[31]['searchtype'] = 'equals';
$tab[31]['massiveaction'] = false;
$tab[31]['joinparams'] = array('jointype' => 'child');
 
$tab[60]['table'] = 'glpi_ticketsatisfactions';
$tab[60]['field'] = 'date_begin';
$tab[60]['name'] = $LANG['satisfaction'][6];
$tab[60]['datatype'] = 'datetime';
$tab[60]['massiveaction'] = false;
$tab[60]['joinparams'] = array('jointype' => 'child');
 
$tab[61]['table'] = 'glpi_ticketsatisfactions';
$tab[61]['field'] = 'date_answered';
$tab[61]['name'] = $LANG['satisfaction'][4];
$tab[61]['datatype'] = 'datetime';
$tab[61]['massiveaction'] = false;
$tab[61]['joinparams'] = array('jointype' => 'child');
 
$tab[62]['table'] = 'glpi_ticketsatisfactions';
$tab[62]['field'] = 'satisfaction';
$tab[62]['name'] = $LANG['satisfaction'][7];
$tab[62]['datatype'] = 'number';
$tab[62]['massiveaction'] = false;
$tab[62]['joinparams'] = array('jointype' => 'child');
 
$tab[63]['table'] = 'glpi_ticketsatisfactions';
$tab[63]['field'] = 'comment';
$tab[63]['name'] = $LANG['satisfaction'][8];
$tab[63]['datatype'] = 'text';
$tab[63]['massiveaction'] = false;
$tab[63]['joinparams'] = array('jointype' => 'child');
 
 
 
$tab['followup'] = $LANG['mailing'][141];
 
$tab['followup'] = _n('Followup', 'Followups', 2);
 
$followup_condition = '';
if (!Session::haveRight('show_full_ticketfollowup', 1TicketFollowup::SEEPRIVATE)) {
$followup_condition = "AND (`NEWTABLE`.`is_private` = '0'
OR `NEWTABLE`.`users_id` = '".Session::getLoginUserID()."')";
}
 
$tab[25]['table'] = 'glpi_ticketfollowups';
$tab[25]['field'] = 'content';
$tab[25]['name'] = $LANG['job'][9]." - ".$LANG[ = __('joblistDescription'][6]);
$tab[25]['forcegroupby'] = true;
$tab[25]['splititems'] = true;
$tab[25]['massiveaction'] = false;
$tab[25]['joinparams'] = array('jointype' => 'child',
'condition' => $followup_condition);
$tab[25]['datatype'] = 'text';
 
$tab[27]['table'] = 'glpi_ticketfollowups';
$tab[27]['field'] = 'count';
$tab[27]['name'] = $LANG['job'][9]." - ".$LANG['tracking'][29];
$tab[27]['forcegroupby'] = true;
$tab[27]['usehaving'] = true;
$tab[27]['datatype'] = 'number';
$tab[27]['massiveaction'] = false;
$tab[27]['joinparams'] = array('jointype' => 'child',
'condition' => $followup_condition);
 
$tab[2936]['table'] = 'glpi_requesttypesglpi_ticketfollowups';
$tab[2936]['field'] = 'namedate';
$tab[2936]['name'] = $LANG['job'][9]." - ".$LANG[ = __('jobDate'][44]);
$tab[2936]['forcegroupbydatatype'] = true'datetime';
$tab[2936]['massiveaction'] = false;
$tab[2936]['joinparamsforcegroupby'] = array('beforejoin'true;
$tab[36]['joinparams'] => array('tablejointype' => 'glpi_ticketfollowupschild',
'joinparamscondition' => array('jointype' => 'child',$followup_condition);
'condition' => $followup_condition)));
 
$tab[9127]['table'] = 'glpi_ticketfollowups';
$tab[9127]['field'] = 'is_privateid';
$tab[9127]['name'] = $LANG[_x('jobquantity'][9].", -'Number ".$LANG[of followups'common'][77]);
$tab[9127]['datatypeforcegroupby'] = 'bool'true;
$tab[9127]['forcegroupbyusehaving'] = true;
$tab[9127]['splititemsdatatype'] = true'count';
$tab[9127]['massiveaction'] = false;
$tab[9127]['joinparams'] = array('jointype' => 'child',
'condition' => $followup_condition);
 
$tab[9329]['table'] = 'glpi_usersglpi_requesttypes';
$tab[9329]['field'] = 'name';
$tab[9329]['name'] = $LANG[__('job'][9]."Request - ".$LANG[source'common'][37]);
$tab[9329]['datatype'] = 'itemlinkdropdown';
$tab[9329]['itemlink_typeforcegroupby'] = 'User'true;
$tab[9329]['forcegroupbymassiveaction'] = truefalse;
$tab[9329]['massiveactionjoinparams'] = false;array('beforejoin'
$tab[93]['joinparams'] => array('beforejointable'
=> array('table' => 'glpi_ticketfollowups',
'joinparams'
=> array('jointype' => 'child',
'condition' => $followup_condition)));
 
$tab[91]['table'] = 'glpi_ticketfollowups';
$tab[91]['field'] = 'is_private';
$tab[91]['name'] = __('Private followup');
$tab[91]['datatype'] = 'bool';
$tab[91]['forcegroupby'] = true;
$tab[91]['splititems'] = true;
$tab[91]['massiveaction'] = false;
$tab[91]['joinparams'] = array('jointype' => 'child',
'condition' => $followup_condition);
 
$tab[93]['table'] = 'glpi_users';
$tab += $this->getSearchOptionsStats();
$tab[93]['field'] = 'name';
$tab[93]['name'] = __('Writer');
$tab[93]['datatype'] = 'itemlink';
$tab[93]['right'] = 'all';
$tab[93]['forcegroupby'] = true;
$tab[93]['massiveaction'] = false;
$tab[93]['joinparams'] = array('beforejoin'
=> array('table'
=> 'glpi_ticketfollowups',
'joinparams'
=> array('jointype' => 'child',
'condition' => $followup_condition)));
 
$tab[150]['table'] = $this->getTable();
$tab[150]['field'] = 'takeintoaccount_delay_stat';
$tab[150]['name'] = $LANG['stats'][24];
$tab[150]['datatype'] = 'timestamp';
$tab[150]['forcegroupby'] = true;
$tab[150]['massiveaction'] = false;
 
$tab += $this->getSearchOptionsStats();
 
if (Session::haveRight("show_all_ticket","1")
|| Session::haveRight("show_assign_ticket","1")
|| Session::haveRight("own_ticket","1")) {
 
$tab[150]['linkticketstable'] = $LANG['job'][55]this->getTable();
$tab[150]['field'] = 'takeintoaccount_delay_stat';
$tab[150]['name'] = __('Take into account time');
$tab[150]['datatype'] = 'timestamp';
$tab[150]['forcegroupby'] = true;
$tab[150]['massiveaction'] = false;
 
$tab[40]['table'] = 'glpi_tickets_tickets';
$tab[40]['field'] = 'tickets_id_1';
$tab[40]['name'] = $LANG['job'][55].' - '.$LANG['common'][66];
$tab[40]['massiveaction'] = false;
$tab[40]['searchtype'] = 'equals';
$tab[40]['joinparams'] = array('jointype' => 'item_item');
 
if (Session::haveRightsOr(self::$rightname,
$tab[47]['table'] = 'glpi_tickets_tickets';
array(self::READALL, self::READASSIGN, self::OWN))) {
$tab[47]['field'] = 'tickets_id_1';
$tab[47]['name'] = $LANG['job'][57];
$tab[47]['massiveaction'] = false;
$tab[47]['searchtype'] = 'equals';
$tab[47]['joinparams'] = array('jointype' => 'item_item',
'condition' => "AND NEWTABLE.`link` = ".
Ticket_Ticket::DUPLICATE_WITH);
 
$tab[41]['tablelinktickets'] = _n('glpi_tickets_ticketsLinked ticket', 'Linked tickets', 2);
$tab[41]['field'] = 'count';
$tab[41]['name'] = $LANG['job'][55].' - '.$LANG['common'][66]." - ".
$LANG['tracking'][29];
$tab[41]['massiveaction'] = false;
$tab[41]['datatype'] = 'number';
$tab[41]['usehaving'] = true;
$tab[41]['joinparams'] = array('jointype' => 'item_item');
 
$tab[4640]['table'] = 'glpi_tickets_tickets';
$tab[4640]['field'] = 'counttickets_id_1';
$tab[4640]['name'] = $LANG[__('job'][57]."All -linked ".$LANG[tickets'tracking'][29]);
$tab[4640]['massiveaction'] = false;
$tab[4640]['datatypeforcegroupby'] = 'number'true;
$tab[4640]['usehavingsearchtype'] = true'equals';
$tab[4640]['joinparams'] = array('jointype' => 'item_item',);
$tab[40]['additionalfields'] = array('tickets_id_2');
'condition' => "AND NEWTABLE.`link` = ".
Ticket_Ticket::DUPLICATE_WITH);
 
$tab[47]['table'] = 'glpi_tickets_tickets';
$tab[47]['field'] = 'tickets_id_1';
$tab[47]['name'] = __('Duplicated tickets');
$tab[47]['massiveaction'] = false;
$tab[47]['searchtype'] = 'equals';
$tab[47]['joinparams'] = array('jointype' => 'item_item',
'condition' => "AND NEWTABLE.`link` = ".
Ticket_Ticket::DUPLICATE_WITH);
$tab[47]['datatype'] = 'dropdown';
$tab[47]['forcegroupby'] = true;
 
$tab[41]['tasktable'] = $LANG['jobglpi_tickets_tickets'][7];
$tab[41]['field'] = 'id';
$tab[41]['name'] = __('Number of all linked tickets');
$tab[41]['massiveaction'] = false;
$tab[41]['datatype'] = 'count';
$tab[41]['usehaving'] = true;
$tab[41]['joinparams'] = array('jointype' => 'item_item');
 
$tab[2646]['table'] = 'glpi_tickettasksglpi_tickets_tickets';
$tab[2646]['field'] = 'contentid';
$tab[2646]['name'] = $LANG[__('job'][7]."Number -of ".$LANG[duplicated tickets'joblist'][6]);
$tab[2646]['forcegroupbymassiveaction'] = truefalse;
$tab[2646]['splititemsdatatype'] = true'count';
$tab[2646]['massiveactionusehaving'] = falsetrue;
$tab[2646]['joinparams'] = array('jointype' => 'childitem_item');,
'condition' => "AND NEWTABLE.`link` = ".
Ticket_Ticket::DUPLICATE_WITH);
 
$tab[28]['table'] += 'glpi_tickettasks'TicketTask::getSearchOptionsToAdd();
$tab[28]['field'] = 'count';
$tab[28]['name'] = $LANG['job'][7]." - ".$LANG['tracking'][29];
$tab[28]['forcegroupby'] = true;
$tab[28]['usehaving'] = true;
$tab[28]['datatype'] = 'number';
$tab[28]['massiveaction'] = false;
$tab[28]['joinparams'] = array('jointype' => 'child');
 
$tab[20]['table'] += 'glpi_taskcategories'$this->getSearchOptionsSolution();
$tab[20]['field'] = 'name';
$tab[20]['name'] = $LANG['job'][7]." - ".$LANG['common'][36];
$tab[20]['forcegroupby'] = true;
$tab[20]['splititems'] = true;
$tab[20]['massiveaction'] = false;
$tab[20]['joinparams'] = array('beforejoin'
=> array('table' => 'glpi_tickettasks',
'joinparams' => array('jointype' => 'child')));
 
if (Session::haveRight('ticketcost', READ)) {
$tab[92]['table'] = 'glpi_tickettasks';
$tab[92]['field'] $tab += 'is_private'TicketCost::getSearchOptionsToAdd();
}
$tab[92]['name'] = $LANG['job'][7]." - ".$LANG['common'][77];
$tab[92]['datatype'] = 'bool';
$tab[92]['forcegroupby'] = true;
$tab[92]['splititems'] = true;
$tab[92]['massiveaction'] = false;
$tab[92]['joinparams'] = array('jointype' => 'child');
 
$tab[94]['tableproblem'] = 'glpi_users'Problem::getTypeName(2);
$tab[94]['field'] = 'name';
$tab[94]['name'] = $LANG['job'][7]." - ".$LANG['common'][37];
$tab[94]['datatype'] = 'itemlink';
$tab[94]['itemlink_type'] = 'User';
$tab[94]['forcegroupby'] = true;
$tab[94]['massiveaction'] = false;
$tab[94]['joinparams'] = array('beforejoin'
=> array('table' => 'glpi_tickettasks',
'joinparams' => array('jointype' => 'child')));
 
$tab[95141]['table'] = 'glpi_usersglpi_problems_tickets';
$tab[95141]['field'] = 'nameid';
$tab[95141]['linkfieldname'] = _x('users_id_techquantity', 'Number of problems');
$tab[95141]['nameforcegroupby'] = $LANG['job'][7]." - ".$LANG['job'][6]true;
$tab[95141]['datatypeusehaving'] = 'itemlink'true;
$tab[95141]['itemlink_typedatatype'] = 'Usercount';
$tab[95141]['forcegroupbymassiveaction'] = truefalse;
$tab[95141]['massiveactionjoinparams'] = falsearray('jointype' => 'child');
$tab[95]['joinparams'] = array('beforejoin'
=> array('table' => 'glpi_tickettasks',
'joinparams' => array('jointype' => 'child')));
 
$tab[96]['table'] = 'glpi_tickettasks';
$tab[96]['field'] = 'actiontime';
$tab[96]['name'] = $LANG['job'][31];
$tab[96]['datatype'] = 'timestamp';
$tab[96]['massiveaction'] = false;
$tab[96]['joinparams'] = array('jointype' => 'child');
 
$tab[97]['table'] = 'glpi_tickettasks';
$tab[97]['field'] = 'date';
$tab[97]['name'] = $LANG['common'][27];
$tab[97]['datatype'] = 'datetime';
$tab[97]['massiveaction'] = false;
$tab[97]['joinparams'] = array('jointype' => 'child');
 
$tab['solution'] = $LANG['jobresolution'][1];
 
$tab[23]['table'] = 'glpi_solutiontypes';
$tab[23]['field'] = 'name';
$tab[23]['name'] = $LANG['job'][48];
 
$tab[24]['table'] = $this->getTable();
$tab[24]['field'] = 'solution';
$tab[24]['name'] = $LANG['jobresolution'][1]." - ".$LANG['joblist'][6];
$tab[24]['datatype'] = 'text';
$tab[24]['htmltext'] = true;
$tab[24]['massiveaction'] = false;
 
$tab['cost'] = $LANG['financial'][5];
 
$tab[42]['table'] = $this->getTable();
$tab[42]['field'] = 'cost_time';
$tab[42]['name'] = $LANG['job'][40];
$tab[42]['datatype'] = 'decimal';
 
$tab[43]['table'] = $this->getTable();
$tab[43]['field'] = 'cost_fixed';
$tab[43]['name'] = $LANG['job'][41];
$tab[43]['datatype'] = 'decimal';
 
$tab[44]['table'] = $this->getTable();
$tab[44]['field'] = 'cost_material';
$tab[44]['name'] = $LANG['job'][42];
$tab[44]['datatype'] = 'decimal';
}
 
 
// Filter search fields for helpdesk
if (!Session::getLoginUserIDisCron(true) === Session::getLoginUserID(false) // no filter for cron
&& (!isset($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
|| ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk'))) {
$tokeep = array('common');
$tokeep = array('common', 'requester');
if (Session::haveRight('validate_ticket',1) || Session::haveRight('create_validation',1)) {
if (Session::haveRightsOr('ticketvalidation',
array_merge(TicketValidation::getValidateRights(),
TicketValidation::getCreateRights()))) {
$tokeep[] = 'validation';
}
$keep = false;
foreach ($tab as $key => $val) {
if (!is_array($val)) {
$keep = in_array($key, $tokeep);
Linha 2 340 ⟶ 2 299:
}
 
 
static function getSpecificValueToDisplay($field, $values, $options=array()) {
/**
* @since version 0.84
*
* @param $field
* @param $values
* @param $options array
**/
static function getSpecificValueToDisplay($field, $values, array $options=array()) {
 
if (!is_array($values)) {
Linha 2 346 ⟶ 2 313:
}
switch ($field) {
case 'global_validationcontent' :
return$content TicketValidation= Toolbox::unclean_cross_side_scripting_deep(Html::getStatusentity_decode_deep($values[$field]));
$content = Html::clean($content);
 
case 'status': if (empty($content)) {
return self::getStatus( $values[$field])content = ' ';
break;}
return nl2br($content);
 
case 'type':
return self::getTicketTypeName($values[$field]);
break;
 
case 'itemtype':
if (class_exists($values[$field])) {
return call_user_func(array($values[$field], 'getTypeName'));
}
break;
 
case 'items_id':
Linha 2 368 ⟶ 2 329:
$tmp = Dropdown::getDropdownName(getTableForItemtype($values['itemtype']),
$values[$field], 1);
return sprintf(__('%1$s %2$s'), $tmp['name'].'&nbsp;'.,
Html::showToolTip($tmp['comment'], array('display' => false)));
 
}
Linha 2 377 ⟶ 2 338:
break;
}
return parent::getSpecificValueToDisplay($field, $values[$field], $options);
}
 
 
/**
* @since version 0.84
*
* @param $field
* @param $name (default '')
* @param $values (default '')
* @param $options array
*
* @return string
**/
static function getSpecificValueToSelect($field, $name='', $values='', array $options=array()) {
 
if (!is_array($values)) {
$values = array($field => $values);
}
$options['display'] = false;
switch ($field) {
case 'content' :
return "<textarea cols='90' rows='6' name='$name'>".$values['content']."</textarea>";
 
case 'items_id' :
if (isset($values['itemtype']) && !empty($values['itemtype'])) {
$options['name'] = $name;
$options['value'] = $values[$field];
return Dropdown::show($values['itemtype'], $options);
}
break;
 
case 'type':
$options['value'] = $values[$field];
return self::dropdownType($name, $options);
}
return parent::getSpecificValueToSelect($field, $name, $values, $options);
}
 
Linha 2 384 ⟶ 2 381:
* Dropdown of ticket type
*
* @param $name select name
* @param $options array of options:
* - value : integer / preselected value (default 0)
*
* - toadd : array / array of specific values to add at the begining
* Parameters which could be used in options array :
* - value : integer / preselected value (default 0)
* - toadd : array / array of specific values to add at the begining
* - on_change : string / value to transmit to "onChange"
* - display : boolean / display or get string (default true)
*
* @return string id of the select
**/
static function dropdownType($name, $options=array()) {
global $LANG;
 
$params['value'] = 0;
$params['toadd'] = array();
$params['on_change'] = '';
$params['display'] = true;
 
if (is_array($options) && count($options)) {
Linha 2 408 ⟶ 2 404:
 
$items = array();
if (count($params['toadd']) > 0) {
$items = $params['toadd'];
}
Linha 2 424 ⟶ 2 420:
**/
static function getTypes() {
global $LANG;
 
$options[self::INCIDENT_TYPE] = $LANG[__('jobIncident'][1]);
$options[self::DEMAND_TYPE] = $LANG[__('jobRequest'][2]);
 
return $options;
Linha 2 439 ⟶ 2 434:
**/
static function getTicketTypeName($value) {
global $LANG;
 
switch ($value) {
case self::INCIDENT_TYPE :
return $LANG[__('jobIncident'][1]);
 
case self::DEMAND_TYPE :
return $LANG[__('jobRequest'][2]);
 
default :
// Return $value if not defined
return $value;
}
}
 
 
/**
* get the Ticket status list
*
* @param $withmetaforsearch boolean (false by default)
*
* @return an array
**/
static function getAllStatusArray($withmetaforsearch=false) {
global $LANG;
 
// To be overridden by class
$tab = array('new' self::INCOMING => $LANG[_x('status', 'joblistNew'][9]),
'assign' self::ASSIGNED => $LANG[_x('jobliststatus', 'Processing (assigned)'][18]),
'plan' self::PLANNED => $LANG[_x('jobliststatus', 'Processing (planned)'][19]),
'waiting'self::WAITING => $LANG[__('joblistPending'][26]),
'solved'self::SOLVED => $LANG[_x('status', 'joblistSolved'][32]),
'closed'self::CLOSED => $LANG[_x('status', 'joblistClosed'][33]));
 
if ($withmetaforsearch) {
$tab['notold'] = $LANG[_x('jobliststatus'][34], 'Not solved');
$tab['notclosed'] = $LANG[_x('jobliststatus'][35], 'Not closed');
$tab['process'] = $LANG[__('joblistProcessing'][21]);
$tab['old'] = $LANG[_x('jobliststatus'][32].", 'Solved + ".$LANG['joblistClosed'][33]);
$tab['all'] = $LANG[__('commonAll'][66]);
}
return $tab;
Linha 2 485 ⟶ 2 483:
*
* @return an array
*
**/
static function getClosedStatusArray() {
return array('closed'self::CLOSED);
}
 
Linha 2 500 ⟶ 2 497:
**/
static function getSolvedStatusArray() {
return array('solved'self::SOLVED);
}
 
Linha 2 511 ⟶ 2 508:
**/
static function getNewStatusArray() {
return array('new'self::INCOMING);
}
 
Linha 2 522 ⟶ 2 519:
**/
static function getProcessStatusArray() {
return array('assign'self::ASSIGNED, 'plan'self::PLANNED);
}
 
 
/**
* Get ticket status Name
*
* @since version 0.83
*
* @param $value status ID
**/
static function getStatus($value) {
return parent::getGenericStatus('Ticket', $value);
}
 
 
/**
* Dropdown of ticket status
*
* @param $name select name
* @param $value default value
* @param $option list proposed 0:normal, 1:search, 2:allowed
*
* @return nothing (display)
**/
static function dropdownStatus($name, $value='new', $option=0) {
return parent::dropdownGenericStatus('Ticket',$name, $value, $option);
}
 
 
/**
* Compute Priority
*
* @param $urgency integer from 1 to 5
* @param $impact integer from 1 to 5
*
* @return integer from 1 to 5 (priority)
**/
static function computePriority($urgency, $impact) {
return parent::computeGenericPriority('Ticket', $urgency, $impact);
}
 
 
/**
* Dropdown of ticket Urgency
*
* @param $name select name
* @param $value default value
* @param $complete see also at least selection
*
* @return string id of the select
**/
static function dropdownUrgency($name, $value=0, $complete=false) {
return parent::dropdownGenericUrgency('Ticket',$name, $value, $complete);
}
 
 
/**
* Dropdown of ticket Impact
*
* @param $name select name
* @param $value default value
* @param $complete see also at least selection (major included)
*
* @return string id of the select
**/
static function dropdownImpact($name, $value=0, $complete=false) {
return parent::dropdownGenericImpact('Ticket',$name, $value, $complete);
}
 
 
/**
* check is the user can change from / to a status
*
* @param $old string value of old/current status
* @param $new string value of target status
*
* @return boolean
**/
static function isAllowedStatus($old, $new) {
return parent::genericIsAllowedStatus('Ticket',$old, $new);
}
 
 
 
Linha 2 610 ⟶ 2 526:
* Make a select box for Ticket my devices
*
* @param $userID User ID for my device section (default 0)
*
* @param $userIDentity_restrict Userrestrict IDto fora myspecific deviceentity section(default -1)
* @param $entity_restrictitemtype restrict to a specific entity of selected item (default 0)
* @param $itemtypeitems_id of selected item (default 0)
* @param $items_id of selected item
*
* @return nothing (print out an HTML select box)
**/
static function dropdownMyDevices($userID=0, $entity_restrict=-1, $itemtype=0, $items_id=0) {
global $DB, $LANG, $CFG_GLPI;
 
if ($userID == 0) {
Linha 2 628 ⟶ 2 543:
$already_add = array();
 
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"]&pow(2, self::HELPDESK_MY_HARDWARE)) {
$my_devices = ""array('' => __('General'));
$my_item = $itemtype.'_'.$items_id;
$devices = array();
 
// My items
Linha 2 637 ⟶ 2 553:
&& parent::isPossibleToAssignType($itemtype)) {
$itemtable = getTableForItemType($itemtype);
 
$query = "SELECT *
$query = "SELECT FROM `$itemtable`*
WHERE `users_id` = ' FROM `$userID'";itemtable`
WHERE `users_id` = '$userID'";
if ($item->maybeDeleted()) {
$query .= " AND `$itemtable`.`is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
$query .= " AND `$itemtable`.`is_template` = '0' ";
}
if (in_array($itemtype, $CFG_GLPI["helpdesk_visible_types"])) {
$query .= " AND `is_helpdesk_visible` = '1' ";
}
Linha 2 654 ⟶ 2 571:
ORDER BY `name` ";
 
$result = $DB->query($query);
$nb = $DB->numrows($result);
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName($nb);
 
while ($data = $DB->fetch_arrayfetch_assoc($result)) {
$output = $data["name"];
if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
$output .= "sprintf(__('%1$s (".%2$s)'), $output, $data['id'].")";
}
$output = sprintf(__('%1$type_name . "s - "%2$s'), .$type_name, $output);
if ($itemtype != 'Software') {
if (!empty($data['serial'])) {
$output .= "sprintf(__('%1$s - ".%2$s'), $output, $data['serial']);
}
if (!empty($data['otherserial'])) {
$output .= "sprintf(__('%1$s - ".%2$s'), $output, $data['otherserial']);
}
}
$my_devices .= "<option title=\"$output\" value='".devices[$itemtype."_".$data["id"].] = $output;
"' ".($my_item==$itemtype."_".$data["id"]?"selected":"").">".
Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]).
"</option>";
 
$already_add[$itemtype][] = $data["id"];
Linha 2 683 ⟶ 2 597:
}
}
if (!emptycount($my_devicesdevices)) {
$my_devices="<optgroup label=\"".$LANG[__('trackingMy devices')][1]."\">". = $my_devices."</optgroup>"devices;
}
 
// My group items
if (Session::haveRight("show_group_hardware","1")) {
$group_where = "";
$query = "SELECT `glpi_groups_users`.`groups_id`, `glpi_groups`.`name`
FROM `glpi_groups_users`
LEFT JOIN `glpi_groups`
ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`)
WHERE `glpi_groups_users`.`users_id` = '$userID' ".
getEntitiesRestrictRequest("AND", "glpi_groups", "",$entity_restrict,true);
$entity_restrict, true);
$result = $DB->query($query);
$result = $DB->query($query);
 
$first = true;
if$devices = array($DB->numrows($result)>0) {;
whileif ($data=$DB->fetch_arraynumrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
if ($first) {
$first = false;
Linha 2 706 ⟶ 2 621:
$group_where .= " OR ";
}
$a_groups = getAncestorsOf("glpi_groups", $data["groups_id"]);
$a_groups[$data["groups_id"]] = $data["groups_id"];
$group_where .= " `groups_id` IN (".implode(',', $a_groups).") ";
}
 
$tmp_device = "";
foreach ($CFG_GLPI["linkgroup_types"] as $itemtype) {
if (($item = getItemForItemtype($itemtype))
&& parent::isPossibleToAssignType($itemtype)) {
$itemtable = getTableForItemType($itemtype);
$query = "SELECT *
FROM `$itemtable`
WHERE ($group_where) ".
getEntitiesRestrictRequest("AND", $itemtable, "",
$entity_restrict,
$item->maybeRecursive());
 
if ($item->maybeDeleted()) {
Linha 2 729 ⟶ 2 643:
$query .= " AND `is_template` = '0' ";
}
$query .= ' ORDER BY `name`';
 
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName();
if (!isset($already_add[$itemtype])) {
$already_add[$itemtype] = array();
}
while ($data = $DB->fetch_arrayfetch_assoc($result)) {
if (!in_array($data["id"], $already_add[$itemtype])) {
$output = '';
if (isset($data["name"])) {
Linha 2 743 ⟶ 2 658:
}
if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
$output .= "sprintf(__('%1$s (".%2$s)'), $output, $data['id'].")";
}
$output = sprintf(__('%1$type_name . "s - "%2$s'), .$type_name, $output);
if (isset($data['serial'])) {
$output .= "sprintf(__('%1$s - ".%2$s'), $output, $data['serial']);
}
if (isset($data['otherserial'])) {
$output .= "sprintf(__('%1$s - ".%2$s'), $output, $data['otherserial']);
}
$tmp_device devices[$itemtype.= "<option title=\_".$output\data["id"]] value='". $itemtype."_".output;
$data["id"]."' ".
($my_item==$itemtype."_".$data["id"]?"selected":"").">".
Toolbox::substr($output,0,
$_SESSION["glpidropdown_chars_limit"]).
"</option>";
 
$already_add[$itemtype][] = $data["id"];
Linha 2 765 ⟶ 2 675:
}
}
if (!emptycount($tmp_devicedevices)) {
$my_devices[__('Devices .=own "<optgroupby label=\"".$LANG['trackingmy groups')][1]." -= ".$devices;
$LANG['common'][35]."\">".$tmp_device."</optgroup>";
}
}
Linha 2 774 ⟶ 2 683:
if (isset($already_add['Computer']) && count($already_add['Computer'])) {
$search_computer = " XXXX IN (".implode(',',$already_add['Computer']).') ';
$tmp_devicedevices = ""array();
 
// Direct Connection
$types = array('PeripheralMonitor', 'MonitorPeripheral', 'PrinterPhone', 'PhonePrinter');
foreach ($types as $itemtype) {
if (in_array($itemtype,$_SESSION["glpiactiveprofile"]["helpdesk_item_type"])
Linha 2 793 ⟶ 2 702:
$search_computer);
if ($item->maybeDeleted()) {
$query .= " AND `$itemtable`.`is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
$query .= " AND `$itemtable`.`is_template` = '0' ";
}
$query .= getEntitiesRestrictRequest("AND",$itemtable,"",$entity_restrict)."
Linha 2 804 ⟶ 2 713:
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName();
while ($data = $DB->fetch_arrayfetch_assoc($result)) {
if (!in_array($data["id"],$already_add[$itemtype])) {
$output = $data["name"];
if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
$output .= "sprintf(__('%1$s (".%2$s)'), $output, $data['id'].")";
}
$output = sprintf(__('%1$type_name . "s - "%2$s'), .$type_name, $output);
if ($itemtype != 'Software') {
$output .= "sprintf(__('%1$s - ".%2$data[s'serial']."), -$output, ".$data['otherserial']);
}
$tmp_device devices[$itemtype.= "<option title=\_".$output\data["id"]] value='". $itemtype."_".output;
$data["id"]."' ".
($my_item==$itemtype."_".$data["id"]?"selected":"").">".
Toolbox::substr($output,0,
$_SESSION["glpidropdown_chars_limit"]).
"</option>";
 
$already_add[$itemtype][] = $data["id"];
Linha 2 827 ⟶ 2 731:
}
}
if (!emptycount($tmp_devicedevices)) {
$my_devices .= "<optgroup label=\"".$LANG[__('reportsConnected devices')][36]."\">". = $tmp_device."</optgroup>"devices;
}
 
// Software
if (in_array('Software', $_SESSION["glpiactiveprofile"]["helpdesk_item_type"])) {
$query = "SELECT DISTINCT `glpi_softwareversions`.`name` AS version,
`glpi_softwares`.`name` AS name, `glpi_softwares`.`id`
Linha 2 847 ⟶ 2 751:
$entity_restrict)."
ORDER BY `glpi_softwares`.`name`";
$devices = array();
 
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$tmp_device = "";
$item = new Software();
$type_name = $item->getTypeName();
if (!isset($already_add['Software'])) {
$already_add['Software'] = array();
}
while ($data = $DB->fetch_arrayfetch_assoc($result)) {
if (!in_array($data["id"], $already_add['Software'])) {
$output = "sprintf(__('%1$type_names - ".%2$data["name"]."s'), (v.$type_name, ".$data["versionname"].")".;
$output = sprintf(__('%1$_SESSION["glpiis_ids_visible"]?"s (".%2$data["id"]."s)":""');, $output,
sprintf(__('%1$s: %2$s'), __('version'),
 
$tmp_device .= "<option title=\"$output\" value='Software_". $data["idversion"]."' ".));
if ($my_item == 'Software'."_".$data_SESSION["idglpiis_ids_visible"]?"selected":"").">". {
$output = sprintf(__('%1$s Toolbox::substr(%2$s)'), $output, 0,$data["id"]);
$_SESSION["glpidropdown_chars_limit"]).}
$devices["Software_".$data["id"]] = "</option>"$output;
 
$already_add['Software'][] = $data["id"];
}
}
if (!emptycount($tmp_devicedevices)) {
$my_devices .= "<optgroup label=\"".Toolbox::ucfirst[__($LANG['Installed software')][17])."\">" = $devices;
$my_devices .= $tmp_device."</optgroup>";
}
}
Linha 2 878 ⟶ 2 781:
}
echo "<div id='tracking_my_devices'>";
echo$rand "<select id='my_items' name=Dropdown::showFromArray('_my_items'>", $my_devices);
echo "<option value=''/div>--- ";
echo $LANG['help'][30]." ---</option>$my_devices</select></div>";
 
 
Linha 2 886 ⟶ 2 788:
$params = array('my_items' => '__VALUE__');
 
Ajax::updateItemOnSelectEvent("my_itemsdropdown__my_items$rand","item_ticket_selection_information",
$CFG_GLPI["root_doc"]."/ajax/ticketiteminformation.php",
$params);
Linha 2 897 ⟶ 2 799:
* Make a select box for Tracking All Devices
*
* @param $myname select name
* @param $itemtype preselected value.for item type
* @param $items_id preselected value for item ID (default 0)
* @param $admin is an admin access ? (default 0)
* @param $users_id user ID used to display my devices (default 0
* @param $entity_restrict Restrict to a defined entity (default -1)
*
* @return nothing (print out an HTML select box)
**/
static function dropdownAllDevices($myname, $itemtype, $items_id=0, $admin=0, $users_id=0,
$entity_restrict=-1) {
global $LANG, $CFG_GLPI, $DB;
 
$rand = mt_rand();
 
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] == 0) {
echo "<input type='hidden' name='$myname' value='0'>";
echo "<input type='hidden' name='items_id' value='0'>";
 
} else {
echo$rand "<div id='tracking_all_devices'>" mt_rand();
echo "<div id='tracking_all_devices$rand'>";
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"]&pow(2,HELPDESK_ALL_HARDWARE)) {
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"]&pow(2,
// Display a message if view my hardware
self::HELPDESK_ALL_HARDWARE)) {
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"]&pow(2,HELPDESK_MY_HARDWARE)) {
 
echo $LANG['tracking'][2]."&nbsp;: ";
if ($users_id
&&($_SESSION["glpiactiveprofile"]["helpdesk_hardware"]&pow(2,
self::HELPDESK_MY_HARDWARE))) {
echo __('Or complete search')."&nbsp;";
}
 
$types = parent::getAllTypesForHelpdesk();
echo "<select id='search_$myname$rand' name='$myname'>\n";
echo "<option value='-1' >".Dropdown::EMPTY_VALUE."</option>\n";
echo "<option value='' ".((empty($itemtype)|| $itemtype===0)?" selected":"").">".
$LANG['help'][30]."</option>";
$found_type = false;
foreach ($types as $type => $label) {
if (strcmp($type,$itemtype)==0) {
$found_type = true;
}
echo "<option value='".$type."' ".(strcmp($type,$itemtype)==0?" selected":"").">".$label;
echo "</option>\n";
}
echo "</select>";
 
$paramsrand = array('itemtype' = Dropdown::showItemTypes($myname, => '__VALUE__'array_keys($types),
array('entity_restrictemptylabel' => $entity_restrict__('General'),
'admin' 'value' => $admin,itemtype));
'myname' $found_type => "items_id",isset($types[$itemtype]);
 
$params = array('itemtype' => '__VALUE__',
'entity_restrict' => $entity_restrict,
'admin' => $admin,
'myname' => "items_id",);
 
Ajax::updateItemOnSelectEvent("search_dropdown_$myname$rand","results_$myname$rand",
$CFG_GLPI["root_doc"].
"/ajax/dropdownTrackingDeviceType.php",
$params);
echo "<span id='results_$myname$rand'>\n";
Linha 2 953 ⟶ 2 852:
&& $itemtype) {
if (($item = getItemForItemtype($itemtype))
&& $items_id) {
if ($item->getFromDB($items_id)) {
echo "<select name=Dropdown::showFromArray('items_id', array($items_id => $item->\n";getName()),
echo "<option array('value='$items_id' =>". $item->getName(items_id));
echo "</option></select>";
}
} else {
$params['itemtype'] = $itemtype;
echo "<script type='text/javascript' >\n";
Ajax::updateItemJsCode("results_$myname$rand", $CFG_GLPI["root_doc"]."/ajax/dropdownTrackingDeviceType.php",
$params);CFG_GLPI["root_doc"].
"/ajax/dropdownTrackingDeviceType.php",
$params);
echo '</script>';
}
Linha 2 972 ⟶ 2 872:
}
return $rand;
}
 
 
function showCost() {
global $LANG;
 
$this->check($this->getField('id'), 'r');
$canedit = Session::haveRight('update_ticket', 1);
 
$options = array('colspan' => 1);
$this->showFormHeader($options);
 
echo "<tr><th colspan='4'>".$LANG['job'][47]."</th></tr>";
 
echo "<tr class='tab_bg_1'>";
echo "<td width='50%'>".$LANG['job'][20]."&nbsp;: </td>";
echo "<td class='b'>".parent::getActionTime($this->fields["actiontime"])."</td>";
echo "</tr>";
 
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['job'][40]."&nbsp;: </td><td>";
if ($canedit) {
echo "<input type='text' maxlength='100' size='15' name='cost_time' value='".
Html::formatNumber($this->fields["cost_time"], true)."'>";
} else {
echo Html::formatNumber($this->fields["cost_time"]);
}
echo "</td></tr>\n";
 
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['job'][41]."&nbsp;: </td><td>";
if ($canedit) {
echo "<input type='text' maxlength='100' size='15' name='cost_fixed' value='".
Html::formatNumber($this->fields["cost_fixed"], true)."'>";
} else {
echo Html::formatNumber($this->fields["cost_fixed"]);
}
echo "</td></tr>\n";
 
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['job'][42]."&nbsp;: </td><td>";
if ($canedit) {
echo "<input type='text' maxlength='100' size='15' name='cost_material' value='".
Html::formatNumber($this->fields["cost_material"], true)."'>";
} else {
echo Html::formatNumber($this->fields["cost_material"]);
}
echo "</td></tr>\n";
 
echo "<tr class='tab_bg_1'>";
echo "<td >".$LANG['job'][43]."&nbsp;: </td>";
echo "<td class='b'>";
echo self::trackingTotalCost($this->fields["actiontime"], $this->fields["cost_time"],
$this->fields["cost_fixed"], $this->fields["cost_material"],false);
echo "</td></tr>\n";
 
$options['candel'] = false;
$options['canedit'] = $canedit;
$this->showFormButtons($options);
}
 
Linha 3 046 ⟶ 2 887:
$totalcost = 0;
 
$query = "SELECT `actiontime`, `cost_time`, `cost_fixed`, `cost_materialglpi_ticketcosts`.*
FROM `glpi_tickets`, `glpi_ticketcosts`
WHERE `itemtypeglpi_ticketcosts`.`tickets_id` = '"`glpi_tickets`.get_class($item)."'`id`
AND `items_idglpi_tickets`.`itemtype` = '".get_class($item->getField('id')."'
AND (`cost_timeglpi_tickets`.`items_id` >= '0".$item->getField('id')."'
AND OR (`glpi_ticketcosts`.`cost_fixedcost_time` > '0'
OR `cost_materialglpi_ticketcosts`.`cost_fixed` > '0')";
OR `glpi_ticketcosts`.`cost_material` > '0')";
$result = $DB->query($query);
 
$i = 0;
if ($DB->numrows($result)) {
while ($data = $DB->fetch_arrayfetch_assoc($result)) {
$totalcost += selfTicketCost::trackingTotalCostcomputeTotalCost($data["actiontime"], $data["cost_time"],
$data["cost_fixed"], $data["cost_material"]);
}
}
return $totalcost;
}
 
 
/**
* Computer total cost of a ticket
*
* @param $actiontime float : ticket actiontime
* @param $cost_time float : ticket time cost
* @param $cost_fixed float : ticket fixed cost
* @param $cost_material float : ticket material cost
* @param $edit boolean : used for edit of computation ?
*
* @return total cost formatted string
**/
static function trackingTotalCost($actiontime, $cost_time, $cost_fixed, $cost_material,
$edit = true) {
return Html::formatNumber(($actiontime*$cost_time/HOUR_TIMESTAMP)+$cost_fixed+$cost_material,
$edit);
}
 
Linha 3 087 ⟶ 2 911:
* Print the helpdesk form
*
* @param $ID int : integer ID of the user who want to display the Helpdesk
* @param $ticket_template intboolean : ID ticket template for preview : false if not used for preview
* (false by default)
*
* @return nothing (print the helpdesk)
**/
static function showFormHelpdesk($ID, $ticket_template=false) {
global $DB, $CFG_GLPI, $LANG;
 
if (!Sessionself::haveRightcanCreate("create_ticket","1")) {
return false;
}
 
if (!$ticket_template
if (Session::haveRight('validate_ticket',1)) {
&& Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
$opt = array();
 
$opt = array();
$opt['reset'] = 'reset';
$opt['fieldcriteria'][0]['field'] = 55; // validation status
$opt['searchtypecriteria'][0]['searchtype'] = 'equals';
$opt['containscriteria'][0]['value'] = 'waiting'CommonITILValidation::WAITING;
$opt['linkcriteria'][0]['link'] = 'AND';
 
$opt['fieldcriteria'][1]['field'] = 59; // validation aprobator
$opt['searchtypecriteria'][1]['searchtype'] = 'equals';
$opt['containscriteria'][1]['value'] = Session::getLoginUserID();
$opt['linkcriteria'][1]['link'] = 'AND';
 
$url_validate = $CFG_GLPI["root_doc"]."/front/ticket.php?".Toolbox::append_params($opt,
'&amp;');
 
if (TicketValidation::getNumberTicketsToValidategetNumberToValidate(Session::getLoginUserID()) > 0) {
echo "<a href='$url_validate' title=\"".$LANG[__s('validationTicket waiting for your approval'][15])."\"
alt=\"".$LANG[__s('validationTicket waiting for your approval'][15])."\">".$LANG['validation'][33]."</a><br><br>";
__('Tickets awaiting approval')."</a><br><br>";
}
}
Linha 3 131 ⟶ 2 959:
 
// Set default values...
$default_values = array('_users_id_requester_notif' => array('use_notification' => ($email==""?0:1),
'alternative_email' => array('use_notification'),
'nodelegate' => (($email == "")?0:1)),
'_users_id_requesternodelegate' => 01,
'name' '_users_id_requester' => ''0,
'_users_id_observer' => 0,
//cbmes alteração
'nome_cbmes' => '_users_id_observer_notif',
'posto_grad_cbmes' => array('use_notification' => 1),
'funcional_cbmesname' => '',
'obm_cbmes' 'content' => '',
'setor_cbmes' 'itilcategories_id' => ''0,
'tel_cbmes' 'locations_id' => ''0,
'patrimonio_cbmesurgency' => ''3,
'itemtype' => '',
//cbmes alteração fim
'content' 'items_id' => ''0,
'itilcategories_identities_id' => 0$_SESSION['glpiactive_entity'],
'urgency' 'plan' => 3array(),
'itemtype' 'global_validation' => ''CommonITILValidation::NONE,
'entities_id' '_add_validation' => $_SESSION['glpiactive_entity']0,
'items_id' 'type' => 0Entity::getUsedConfig('tickettype',
'plan' => array() $_SESSION['glpiactive_entity'],
'global_validation' => 'none', Ticket::INCIDENT_TYPE),
'due_date' '_right' => 'NULL'"id",
'slas_id' '_filename' => 0array(),
'_add_validation' '_tag_filename' => 0,array());
'type' => EntityData::getUsedConfig('tickettype',
$_SESSION['glpiactive_entity'],
'', Ticket::INCIDENT_TYPE),
'_right' => "id");
 
// Get default values from posted values on reload form
if (!$ticket_template) {
if (isset($options_POST)) = $_REQUEST;{
$values = Html::cleanPostForTextArea($_POST);
}
}
 
 
 
// Restore saved value or override with page parameter
$saved = $this->restoreInput();
foreach ($default_values as $name => $value) {
if (!isset($optionsvalues[$name])) {
if (isset($_SESSION["helpdeskSaved"]saved[$name])) {
$optionsvalues[$name] = $_SESSION["helpdeskSaved"]saved[$name];
} else {
$optionsvalues[$name] = $value;
}
}
}
// Clean text fields
$options['name'] = stripslashes($options['name']);
$options['content'] = Html::cleanPostForTextArea($options['content']);
 
if (!$ticket_template) {
Linha 3 191 ⟶ 3 010:
 
 
$delegating = User::getDelegateGroupsForUser($optionsvalues['entities_id']);
 
if (count($delegating)) {
echo "<div class='center'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>".$LANG[__('jobThis ticket concerns me'][69])."&nbsp;:&nbsp; ";
 
$rand = Dropdown::showYesNo("nodelegate", $optionsvalues['nodelegate']);
 
$params = array ('nodelegate' => '__VALUE__',
'rand' => $rand,
'right' => "delegate",
'_users_id_requester'
=> $optionsvalues['_users_id_requester'],
'_users_id_requester_notif'
=> $optionsvalues['_users_id_requester_notif'],
'use_notification'
=> $optionsvalues['_users_id_requester_notif']['use_notification'],
'entity_restrict'
=> $_SESSION["glpiactive_entity"]);
 
Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate".$rand, "show_result".$rand,
$CFG_GLPI["root_doc"]."/ajax/dropdownDelegationUsers.php",
$params);
 
if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
echo "</th><th>".__('Check your personnal information');
}
 
echo "</th></tr>";
Linha 3 220 ⟶ 3 043:
 
$self = new self();
if ($optionsvalues["_users_id_requester"] == 0) {
$optionsvalues['_users_id_requester'] = Session::getLoginUserID();
} else {
$optionsvalues['_right'] = "delegate";
}
$self->showActorAddFormOnCreate(selfCommonITILActor::REQUESTER, $optionsvalues);
echo "</div>";
if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
echo "</td><td class='center'>";
User::showPersonalInformation(Session::getLoginUserID());
}
echo "</td></tr>";
 
echo "</table></div>";
echo "<input type='hidden' name='_users_id_recipient' value='".Session::getLoginUserID()."'>";
 
} else {
// User as requester
$values['_users_id_requester'] = Session::getLoginUserID();
 
if ($CFG_GLPI['use_check_pref']) {
echo "<div class='center'><table class='tab_cadre_fixe'>";
echo "<tr><th>".__('Check your personnal information')."</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
User::showPersonalInformation(Session::getLoginUserID());
echo "</td></tr>";
echo "</table></div>";
}
}
 
Linha 3 239 ⟶ 3 079:
 
// Load ticket template if available :
$tt = $this->getTicketTemplateToUse($ticket_template, $values['type'],
$tt = new TicketTemplate();
$values['itilcategories_id'],
 
$_SESSION["glpiactive_entity"]);
// First load default entity one
if ($template_id = EntityData::getUsedConfig('tickettemplates_id', $_SESSION["glpiactive_entity"])) {
// with type and categ
$tt->getFromDBWithDatas($template_id, true);
}
 
$field = '';
if ($options['type'] && $options['itilcategories_id']) {
$categ = new ITILCategory();
if ($categ->getFromDB($options['itilcategories_id'])) {
switch ($options['type']) {
case self::INCIDENT_TYPE :
$field = 'tickettemplates_id_incident';
break;
 
case self::DEMAND_TYPE :
$field = 'tickettemplates_id_demand';
break;
}
 
if (!empty($field) && $categ->fields[$field]) {
// without type and categ
$tt->getFromDBWithDatas($categ->fields[$field], false);
}
}
}
if ($ticket_template) {
// with type and categ
$tt->getFromDBWithDatas($ticket_template, true);
}
 
// Predefined fields from template : reset them
if (isset($optionsvalues['_predefined_fields'])) {
$optionsvalues['_predefined_fields']
= unserialize(rawurldecode(stripslashesToolbox::decodeArrayFromInput($optionsvalues['_predefined_fields'])));
} else {
$optionsvalues['_predefined_fields'] = array();
}
 
Linha 3 285 ⟶ 3 096:
if (isset($tt->predefined) && count($tt->predefined)) {
foreach ($tt->predefined as $predeffield => $predefvalue) {
if (isset($optionsvalues[$predeffield]) && isset($default_values[$predeffield])) {
// Is always default value : not set
// Set if already predefined field
// Set if ticket template change
if (((count($optionsvalues[$predeffield'_predefined_fields']) == $default_values[$predeffield]0)
|| (isset&& ($optionsvalues['_predefined_fields'$predeffield] == $default_values[$predeffield]))
|| && $options[$predeffield] == (isset($optionsvalues['_predefined_fields'][$predeffield])
|| (isset && ($optionsvalues[$predeffield] == $values['_tickettemplates_id_predefined_fields'][$predeffield]))
|| && (isset($optionsvalues['_tickettemplates_id'] != $tt->getID())) {
$options[$predeffield] && ($values['_tickettemplates_id'] != $predefvalue;tt->getID()))) {
$values[$predeffield] = $predefvalue;
$predefined_fields[$predeffield] = $predefvalue;
}
Linha 3 301 ⟶ 3 113:
}
}
// All predefined override : add option to say predifined exists
 
if (count($predefined_fields) == 0) {
$predefined_fields['_all_predefined_override'] = 1;
}
} else { // No template load : reset predefined values
if (count($optionsvalues['_predefined_fields'])) {
foreach ($optionsvalues['_predefined_fields'] as $predeffield => $predefvalue) {
if ($optionsvalues[$predeffield] == $predefvalue) {
$optionsvalues[$predeffield] = $default_values[$predeffield];
}
}
}
}
unset($_SESSION["helpdeskSaved"]);
 
if (($CFG_GLPI['urgency_mask'] == (1<<3))
|| $tt->isHiddenField('urgency')) {
// Dont show dropdown if only 1 value enabled or field is hidden
echo "<input type='hidden' name='urgency' value='".$optionsvalues['urgency']."'>";
}
 
// Display predefined fields if hidden
if ($tt->isHiddenField('itemtype')) {
echo "<input type='hidden' name='itemtype' value='".$optionsvalues['itemtype']."'>";
echo "<input type='hidden' name='items_id' value='".$optionsvalues['items_id']."'>";
}
if ($tt->isHiddenField('locations_id')) {
echo "<input type='hidden' name='locations_id' value='".$values['locations_id']."'>";
}
 
echo "<input type='hidden' name='entities_id' value='".$_SESSION["glpiactive_entity"]."'>";
echo "<div class='center'><table class='tab_cadre_fixe'>";
 
echo "<tr><th colspan='2'>".$LANG[__('jobDescribe the incident or request'][11])."&nbsp;:&nbsp;</th><th>";
if (Session::isMultiEntitiesMode()) {
echo "&nbsp;(".Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]).")";
}
echo "</th></tr>";
 
 
 
//cbmes alteração (Campo Tipo)
//if ($_GET['Setor']=="RH")
if (false)
{
echo "<tr class='tab_bg_1'>";
echo "<td>".sprintf(__('%1$LANG[s%2$s'), __('commonType'][17]."&nbsp;:".), $tt->getMandatoryMark('type'))."</td>";
echo "<td>";
self::dropdownType('type', array('value' => $optionsvalues['type'],
'on_change' => 'this.form.submit()'));
echo "</td></tr>";
 
}
//cbmes alteração fim (Campo Tipo)
//cbmes alteração (Campo Categoria)
if(false)
{
echo "<tr class='tab_bg_1'>";
echo "<td>".sprintf(__('%1$LANG[s%2$s'), __('commonCategory'][36]."&nbsp;:";),
echo $tt->getMandatoryMark('itilcategories_id'))."</td>";
echo "</td><td>";
 
$condition = "`is_helpdeskvisible`='1'";
switch ($values['type']) {
 
switch ($options['type']) {
case self::DEMAND_TYPE :
$condition .= " AND `is_request`='1'";
Linha 3 369 ⟶ 3 171:
$condition .= " AND `is_incident`='1'";
}
$opt = array('value' => $values['itilcategories_id'],
'condition' => $condition,
'on_change' => 'this.form.submit()');
 
if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
$opt = array('value' => $options['itilcategories_id'],
'condition' => $condition,
'on_change' => 'submit()');
if ($options['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
$opt['display_emptychoice'] = false;
}
 
DropdownITILCategory::showdropdown('ITILCategory', $opt);
echo "</td></tr>";
}
//cbmes alteração fim (Campo Categoria)
 
 
if ($CFG_GLPI['urgency_mask'] != (1<<3)) {
 
//cbmes alteração Campo urgencia
if(false)
{
if ($CFG_GLPI['urgency_mask']!=(1<<3)) {
if (!$tt->isHiddenField('urgency')) {
echo "<tr class='tab_bg_1'>";
echo "<td>".sprintf(__('%1$LANG[s%2$s'joblist), __('][29]."&nbsp;:".Urgency'), $tt->getMandatoryMark('urgency'))."</td>";
"</td>";
echo "<td>";
self::dropdownUrgency("urgency",array('value' => $optionsvalues['"urgency'"]));
echo "</td></tr>";
}
}
}
//cbmes alteração Campo urgencia fim
 
if (empty($delegating)
//cbmes alteração (Informe das alterações feitas)
&& NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
 
if(true)
{
if (empty($delegating) && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG[__('helpInform me about the actions taken'][8])."&nbsp;:&nbsp;</td>";
echo "<td>";
if ($optionsvalues["_users_id_requester"] == 0) {
$optionsvalues['_users_id_requester'] = Session::getLoginUserID();
}
$_REQUEST_POST['value'] = $optionsvalues['_users_id_requester'];
$_REQUEST_POST['field'] = '_users_id_requester_notif';
$_REQUEST_POST['use_notification'] = $optionsvalues['_users_id_requester_notif']['use_notification'];
include (GLPI_ROOT."/ajax/uemailUpdate.php");
 
echo "</td></tr>";
}
if (($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0)
}
&& (count($_SESSION["glpiactiveprofile"]["helpdesk_item_type"]))) {
//cbmes alteração fim (Informe das alterações feitas)
if (!$tt->isHiddenField('itemtype')) {
 
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) {
//cbmes alteração
//não exibir o campo tipo
if (false) {
//if (!$tt->isHiddenField('itemtype')) {
//cbmes alteração fim
echo "<tr class='tab_bg_1'>";
echo "<td>".sprintf(__('%1$LANG[s%2$s'help'][24]."&nbsp;:), ".$tt->getMandatoryMark__('itemtypeHardware type')."</td>";,
$tt->getMandatoryMark('itemtype'))."</td>";
echo "<td>";
self::dropdownMyDevices($optionsvalues['_users_id_requester'], $_SESSION["glpiactive_entity"],
$optionsvalues['itemtype'], $optionsvalues['items_id']);
self::dropdownAllDevices("itemtype", $optionsvalues['itemtype'], $optionsvalues['items_id'], 0,
$optionsvalues['_users_id_requester'],
$_SESSION["glpiactive_entity"]);
echo "<span id='item_ticket_selection_information'></span>";
Linha 3 445 ⟶ 3 227:
}
 
if (!$tt->isHiddenField('locations_id')) {
//cbmes alteração CAMPO ESCOLHA SETOR
echo "<tr class='tab_bg_1'><td>";
printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
echo "</td><td>";
Location::dropdown(array('value' => $values["locations_id"]));
//recuperar os campos preenchidos quando clicar em voltar ao faltar preencher algum campo
echo "</td></tr>";
if ($options[itilcategories_id]=='2')
{
$_GET['Setor']="RH";
}
if ($options[itilcategories_id]=='1')
{
$_GET['Setor']="STI";
}
if ($options[itilcategories_id]=='3')
{
$_GET['Setor']="AJ";
}
 
 
if ($options[name]!='')
{
$_GET['Assunto']=$options[name];
}
//recuperar os campos preenchidos quando clicar em voltar ao faltar preencher algum campo FIM
if (!($_GET['Setor']=="RH" or $_GET['Setor']=="STI" or $_GET['Setor']=="AJ"))
{
if (true) {
echo "<tr class='tab_bg_1'>";
//echo "<td>"."Escolha o setor: "."</td>";
echo "<td>".""."</td>";
echo "<td><center>";
echo "<select onchange=\"window.open(this.value,'_self');\">";
echo "<option value=\"helpdesk.public.php?create_ticket=1\">DESEJA ABRIR CHAMADO PARA QUAL SETOR?</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI\">INFORMÁTICA</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH\">RH</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=AJ\">ASSESSORIA ESPECIAL</option>";
echo "</center></td></tr>";
}
}
 
if ($_GET['Setor']=="RH")
{
echo "<tr class='tab_bg_1'>";
echo "<td>"."Este chamado irá para o RH: "."</td>";
echo "<input type='hidden' name='itilcategories_id' value='2'>";
"</tr>";
}
 
if ($_GET['Setor']=="STI")
{
echo "<tr class='tab_bg_1'>";
echo "<td>"."Este chamado irá para a Informática: "."</td>";
echo "<input type='hidden' name='itilcategories_id' value='1'>";
"</tr>";
}
if ($_GET['Setor']=="AJ")
{
echo "<tr class='tab_bg_1'>";
echo "<td>"."Este chamado irá para a Assessoria Especial: "."</td>";
echo "<input type='hidden' name='itilcategories_id' value='3'>";
"</tr>";
}
 
if (!$tt->isHiddenField('_users_id_observer')
//cbmes alteração fim CAMPO ESCOLHA SETOR
|| $tt->isPredefinedField('_users_id_observer')) {
 
echo "<tr class='tab_bg_1'><td>".__('Watcher')."</td>";
 
 
 
//campo Assunto
// if ($_GET['Setor']=="RH" or $_GET['Setor']=="STI")
// {
// if (!$tt->isHiddenField('name')
// || $tt->isPredefinedField('name')) {
// echo "<tr class='tab_bg_1'>";
// echo "<td>"."Assunto: ".
// $tt->getMandatoryMark('name')."</td>";
// echo "<td><input type='text' maxlength='250' size='80' name='name'
// value=\"".$options['name']."\"></td></tr>";
// }
// }
 
 
if ($_GET['Setor']=="RH" or $_GET['Setor']=="STI" or $_GET['Setor']=="AJ")
{
if (!$tt->isHiddenField('name')
|| $tt->isPredefinedField('name')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Assunto: ".
$tt->getMandatoryMark('name')."</td>";
echo "<td>";
$values['_right'] = "groups";
//Opções para STI
// Observer
if ($_GET['Setor']=="STI" and $_GET['Assunto']=="")
if (!$tt->isHiddenField('_users_id_observer')) {
{
$this->showActorAddFormOnCreate(CommonITILActor::OBSERVER, $values);
echo "<select onchange=\"window.open(this.value,'_self');\">";
echo '<hr>';
echo "<option value=\"helpdesk.public.php?create_ticket=1\">ESCOLHA O ASSUNTO</option>";
} else { // predefined value
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Troca de senha\">Trocar de senha</option>";
if (isset($values["_users_id_observer"]) && $values["_users_id_observer"]) {
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Permissões de Pastas e Rede\">Permissões de Pastas e Rede</option>";
echo self::getActorIcon('user', CommonITILActor::OBSERVER)."&nbsp;";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=E-mail institucional\">E-mail institucional</option>";
echo Dropdown::getDropdownName("glpi_users", $values["_users_id_observer"]);
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=MGW\">MGW</option>";
echo "<input type='hidden' name='_users_id_observer' value=\"".
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Impressora\">Impressora</option>";
$values["_users_id_observer"]."\">";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Instalação de Programas\">Instalação de Programas</option>";
echo '<hr>';
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Manutenção de Computador\">Manutenção de Computador</option>";
}
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Solicitação de Material\">Solicitação de Material</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Solicitação de Ponto de Rede\">Solicitação de Ponto de Rede</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Design\">Design</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=SAAF\">SAAF</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=STI&Assunto=Outros\">Outros</option>";
}
echo "</td></tr>";
//Opções para STI
if ($_GET['Setor']=="STI" and $_GET['Assunto']!="" and $_GET['Assunto']!="Outros")
{
echo $_GET['Assunto'];
echo "<input type='hidden' name='name' value='".$_GET['Assunto']."'>";
 
}
 
if ($_GET['Setor']=="STI" and $_GET['Assunto']=="Outros")
{
echo "<input type='text' maxlength='250' size='80' name='name'
value=\"".$_GET['Assunto']."\">";
}
 
 
 
//Opções para RH
if ($_GET['Setor']=="RH" and $_GET['Assunto']=="")
{
echo "<select onchange=\"window.open(this.value,'_self');\">";
echo "<option value=\"helpdesk.public.php?create_ticket=1\">ESCOLHA O ASSUNTO</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Pagamento\">Pagamento</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Concursos\">Concursos</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Nucleo_de_expediente\">Núcleo de Expediente</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Beneficios\">Benefícios</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Pessoal\">Pessoal</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Publicacoes\">Publicações</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Estagiarios\">Estagiários</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Identificacao\">Identificação</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Movimentacao\">Movimentação</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Controle_do_efetivo\">Controle do efetivo</option>";
echo "<option value=\"helpdesk.public.php?create_ticket=1&Setor=RH&Assunto=Outros\">Outros</option>";
}
//Opções para RH
if ($_GET['Setor']=="RH" and $_GET['Assunto']!="" and $_GET['Assunto']!="Outros")
{
echo $_GET['Assunto'];
echo "<input type='hidden' name='name' value='".$_GET['Assunto']."'>";
 
}
 
if ($_GET['Setor']=="RH" and $_GET['Assunto']=="Outros")
{
echo "<input type='text' maxlength='250' size='80' name='name'
value=\"".$_GET['Assunto']."\">";
}
 
 
 
 
//assunto para AJ
if ($_GET['Setor']=="AJ")
{
echo "<input type='text' maxlength='250' size='80' name='name'
value=\"".$_GET['Assunto']."\">";
}
 
 
 
 
echo "</td></tr>";
}
}
 
if (!$tt->isHiddenField('name')
 
|| $tt->isPredefinedField('name')) {
//campo Assunto fim
 
 
 
 
 
 
//cbmes alteração NOME
if ( $_GET['Setor']=="RH" or ($_GET['Setor']=="STI" and $_GET['Assunto']!="") or $_GET['Setor']=="AJ")
{
if (!$tt->isHiddenField('nome_cbmes')
|| $tt->isPredefinedField('nome_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Nome:sprintf(__('%1$s%2$s'), __('Title'), ".$tt->getMandatoryMark('nome_cbmesname'))."</td>";
echo "<td><input type='text' maxlength='250' size='80' name='nome_cbmesname'
value=\"".$optionsvalues['nome_cbmesname']."\"></td></tr>";
}
}
//cbmes alteração fim
 
if (!$tt->isHiddenField('content')
 
|| $tt->isPredefinedField('content')) {
//cbmes alteração Graduação
if ($_GET['Setor']=="RH" or ($_GET['Setor']=="STI" and $_GET['Assunto']!="") or $_GET['Setor']=="AJ")
{
if (!$tt->isHiddenField('posto_grad_cbmes')
|| $tt->isPredefinedField('posto_grad_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Posto/Graduação:sprintf(__('%1$s%2$s'), __('Description'), ".$tt->getMandatoryMark('posto_grad_cbmescontent'))."</td>";
"</td><td>";
//echo "<td><input type='text' maxlength='250' size='80' name='posto_grad_cbmes'
$rand = mt_rand();
// value=\"".$options['posto_grad_cbmes']."\"></td></tr>";
$rand_text = mt_rand();
echo "<td> <select name=\"posto_grad_cbmes\" id=\"posto_grad_id\" value=\"inicial\">
<option>".$options['posto_grad_cbmes']."</option>
<option>Civil</option>
<option>AL SD</option>
<option>SD</option>
<option>AL CB</option>
<option>CB</option>
<option>AL SGT</option>
<option>3º SGT</option>
<option>2º SGT</option>
<option>1º SGT</option>
<option>SUB TEN</option>
<option>ASP OF</option>
<option>2º TEN</option>
<option>1º TEN</option>
<option>CAP</option>
<option>MAJ</option>
<option>TEN CEL</option>
<option>CEL</option>
</select>
</td></tr>";
}
}
//cbmes alteração Graduação fim
//cbmes alteração OBM
if ($_GET['Setor']=="RH" or ($_GET['Setor']=="STI" and $_GET['Assunto']!="") or $_GET['Setor']=="AJ")
{
if (!$tt->isHiddenField('obm_cbmes')
|| $tt->isPredefinedField('obm_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."OBM: ".$tt->getMandatoryMark('obm_cbmes')."</td>";
//echo "<td><input type='text' maxlength='250' size='80' name='obm_cbmes'
//value=\"".$options['obm_cbmes']."\"></td></tr>";
echo "<td> <select name=\"obm_cbmes\" id=\"obm_cbmes_id\" value=\"inicial\">
<option>".$options['obm_cbmes']."</option>
<option>1ºBBM</option>
<option>2ºBBM</option>
<option>3ºBBM</option>
<option>4ºBBM</option>
<option>5ºBBM</option>
<option>1ª Cia Ind</option>
<option>2ª Cia Ind</option>
<option>3ª Cia Ind</option>
<option>1ª Cia especializada</option>
<option>CAT</option>
<option>CSM</option>
<option>CEIB</option>
<option>BM1</option>
<option>BM2</option>
<option>BM3</option>
<option>BM4</option>
<option>BM5</option>
<option>BM6</option>
<option>AJUDANCIA</option>
<option>CORREGEDORIA</option>
<option>DEFESA CIVIL</option>
</select>
</td></tr>";
}
}
//cbmes alteração OBM fim
//cbmes alteração SETOR
if ($_GET['Setor']=="RH" or ($_GET['Setor']=="STI" and $_GET['Assunto']!="") or $_GET['Setor']=="AJ")
{
if (!$tt->isHiddenField('setor_cbmes')
|| $tt->isPredefinedField('setor_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Setor.: ".$tt->getMandatoryMark('setor_cbmes')."</td>";
echo "<td><input type='text' maxlength='250' size='80' name='setor_cbmes'
value=\"".$options['setor_cbmes']."\"></td></tr>";
}
}
//cbmes alteração SETOR fim
 
$cols = 90;
//cbmes alteração TELEFONE
$rows = 6;
if ($_GET['Setor']=="RH" or ($_GET['Setor']=="STI" and $_GET['Assunto']!="") or $_GET['Setor']=="AJ")
$content_id = "content$rand";
{
if (!$tt->isHiddenField('tel_cbmes')
|| $tt->isPredefinedField('tel_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Tel.: ".$tt->getMandatoryMark('tel_cbmes')."</td>";
echo "<td><input type='text' maxlength='250' size='80' name='tel_cbmes'
value=\"".$options['tel_cbmes']."\"></td></tr>";
}
}
//cbmes alteração TELEFONE fim
 
if ($CFG_GLPI["use_rich_text"]) {
$values["content"] = $this->setRichTextContent($content_id, $values["content"], $rand);
$cols = 100;
$rows = 10;
} else {
$values["content"] = $this->setSimpleTextContent($values["content"]);
}
 
echo "<div id='content$rand_text'>";
 
echo "<textarea id='$content_id' name='content' cols='$cols' rows='$rows'>".
//cbmes alteração PATRIMONIO
$values['content']."</textarea></div>";
if ( ($_GET['Setor']=="STI") and ($_GET['Assunto']=="Impressora" or $_GET['Assunto']=="Assistencia técnica" or $_GET['Assunto']=="Instalação de Programas" or $_GET['Assunto']=="Manutenção de Computador" or $_GET['Assunto']=="Outros") )
echo "</td></tr>";
{
if (!$tt->isHiddenField('patrimonio_cbmes')
|| $tt->isPredefinedField('patrimonio_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Nº patrimonio: ".$tt->getMandatoryMark('patrimonio_cbmes')."</td>";
echo "<td><input type='text' maxlength='250' size='80' name='patrimonio_cbmes'
value=\"".$options['patrimonio_cbmes']."\"></td></tr>";
}
}
//cbmes alteração fim
 
 
// File upload system
 
$width = '100%';
//cbmes alteração FUNCIONAL
if ($CFG_GLPI['use_rich_text']) {
if ( ($_GET['Setor']=="AJ" or $_GET['Setor']=="RH") or ( $_GET['Setor']=="STI" and ($_GET['Assunto']=="Permissões de Pastas e Rede" or $_GET['Assunto']=="Impressora" or $_GET['Assunto']=="Solicitação de Material" or $_GET['Assunto']=="Solicitação de Ponto de Rede" or $_GET['Assunto']=="Outros") ) )
$width = '50%';
{
if (!$tt->isHiddenField('funcional_cbmes')
|| $tt->isPredefinedField('funcional_cbmes')) {
echo "<tr class='tab_bg_1'>";
echo "<td>"."Nº Funcional: ".$tt->getMandatoryMark('funcional_cbmes')."</td>";
echo "<td><input type='text' maxlength='250' size='80' name='funcional_cbmes'
value=\"".$options['funcional_cbmes']."\"></td></tr>";
}
}
echo "<tr class='tab_bg_1'>";
//cbmes alteração FUNCIONAL fim
echo "<td class='top'>".sprintf(__('%1$s (%2$s)'), __('File'), Document::getMaxUploadSize());
DocumentType::showAvailableTypesLink();
echo "</td>";
echo "<td class='top'>";
echo "<div id='fileupload_info'></div>";
echo "</td>";
echo "</tr>";
 
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4'>";
echo "<table width='100%'><tr>";
echo "<td width='$width '>";
 
echo Html::file(array('multiple' => true,
'values' => array('filename' => $values['_filename'],
'tag' => $values['_tag_filename'])
));
// "<div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
echo "</td>";
if ($CFG_GLPI['use_rich_text']) {
echo "<td width='$width '>";
if (!isset($rand)) {
$rand = mt_rand();
}
echo Html::imagePaste(array('rand' => $rand));
echo "</td>";
}
echo "</tr></table>";
 
echo "</td>";
echo "</tr>";
 
//campo conteudo
if ($_GET['Setor']=="RH" or $_GET['Setor']=="AJ" or ($_GET['Setor']=="STI" and $_GET['Assunto']!=""))
{
if (!$tt->isHiddenField('content')
|| $tt->isPredefinedField('content')) {
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['joblist'][6]."&nbsp;:".
$tt->getMandatoryMark('content')."</td>";
echo "<td><textarea name='content' cols='80' rows='14'>".$options['content']."</textarea>";
echo "</td></tr>";
}
}
//campo conteudo fim
//campo arquivo
if ($_GET['Setor']=="RH" or $_GET['Setor']=="AJ" or ($_GET['Setor']=="STI" and $_GET['Assunto']!=""))
{
echo "<tr class='tab_bg_1'>";
echo "<td>".$LANG['document'][2]." (".Document::getMaxUploadSize().")&nbsp;:&nbsp;";
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/aide.png' class='pointer' alt='".
$LANG['central'][7]."' onclick=\"window.open('".$CFG_GLPI["root_doc"].
"/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
 
echo "&nbsp;";
self::showDocumentAddButton(60);
 
echo "</td>";
echo "<td><div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
 
echo "</td></tr>";
}
//campo arquivo fim
//campo ENVIAR
if ($_GET['Setor']=="RH" or $_GET['Setor']=="AJ" or ($_GET['Setor']=="STI" and $_GET['Assunto']!=""))
{
if (!$ticket_template) {
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' class='center'>";
 
if ($tt->isField('id') && ($tt->fields['id'] > 0)) {
echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
echo "<input type='hidden' name='_predefined_fields'
value=\"".rawurlencode(serializeToolbox::prepareArrayForInput($predefined_fields))."\">";
}
echo "<input type='submit' name='add' value=\"".__s('Submit message')."\" class='submit'>";
 
echo "<input type='submit' name='add' value=\"".$LANG['help'][14]."\" class='submit'>";
 
 
 
echo "</td></tr>";
}
}
//campo ENVIAR fim
 
echo "</table></div>";
Linha 3 858 ⟶ 3 353:
* @since version 0.83
*
* @param $entity integer entities_id usefull is function called by cron (default 0)
**/
static function getDefaultValues($entity=0) {
Linha 3 866 ⟶ 3 361:
$users_id_requester = Session::getLoginUserID();
// No default requester if own ticket right = tech and update_ticket right to update requester
if (Session::haveRighthaveRightsOr('own_ticket'self::$rightname,1) &&array(UPDATE, Sessionself::haveRight('update_ticket',1OWN))) {
$users_id_requester = 0;
}
Linha 3 876 ⟶ 3 371:
}
 
$type = EntityDataEntity::getUsedConfig('tickettype', $entity, '', Ticket::INCIDENT_TYPE);
 
// Set default values...
Linha 3 884 ⟶ 3 379:
'_groups_id_requester' => 0,
'_users_id_assign' => 0,
'_users_id_assign_notif' => array('use_notification' => 1,
'alternative_email' => ''),
'_groups_id_assign' => 0,
'_users_id_observer' => 0,
'_users_id_observer_notif' => array('use_notification' => 1,
'alternative_email' => ''),
'_groups_id_observer' => 0,
'_link' => array('tickets_id_2' => '',
'link' => ''),
'suppliers_id_assign_suppliers_id_assign' => 0,
'_suppliers_id_assign_notif' => array('use_notification' => 1,
'alternative_email' => ''),
'name' => '',
'content' => '',
Linha 3 904 ⟶ 3 401:
'date' => $_SESSION["glpi_currenttime"],
'entities_id' => $entity,
'status' => 'new'self::INCOMING,
'followup' => array(),
'itemtype' => '',
'items_id' => 0,
'locations_id' => 0,
'plan' => array(),
'global_validation' => 'none'CommonITILValidation::NONE,
'due_date' => 'NULL',
'slas_id' => 0,
'_add_validation' => 0,
'type' => $type);,
'_documents_id' => array(),
'_filename' => array(),
'_tag_filename' => array());
}
 
 
/**
* Get ticket template to use
* Use force_template first, then try on template define for type and category
* then use default template of active profile of connected user and then use default entity one
*
* @param $force_template integer tickettemplate_id to used (case of preview for example)
* (default 0)
* @param $type integer type of the ticket (default 0)
* @param $itilcategories_id integer ticket category (default 0)
* @param $entities_id integer (default -1)
*
* @since version 0.84
*
* @return ticket template object
**/
function getTicketTemplateToUse($force_template=0, $type=0, $itilcategories_id=0,
$entities_id=-1) {
 
// Load ticket template if available :
$tt = new TicketTemplate();
$template_loaded = false;
 
if ($force_template) {
// with type and categ
if ($tt->getFromDBWithDatas($force_template, true)) {
$template_loaded = true;
}
}
 
if (!$template_loaded
&& $type
&& $itilcategories_id) {
 
$categ = new ITILCategory();
if ($categ->getFromDB($itilcategories_id)) {
$field = '';
switch ($type) {
case self::INCIDENT_TYPE :
$field = 'tickettemplates_id_incident';
break;
 
case self::DEMAND_TYPE :
$field = 'tickettemplates_id_demand';
break;
}
 
if (!empty($field) && $categ->fields[$field]) {
// without type and categ
if ($tt->getFromDBWithDatas($categ->fields[$field], false)) {
$template_loaded = true;
}
}
}
}
 
// If template loaded from type and category do not check after
if ($template_loaded) {
return $tt;
}
 
if (!$template_loaded) {
// load default profile one if not already loaded
if (isset($_SESSION['glpiactiveprofile']['tickettemplates_id'])
&& $_SESSION['glpiactiveprofile']['tickettemplates_id']) {
// with type and categ
if ($tt->getFromDBWithDatas($_SESSION['glpiactiveprofile']['tickettemplates_id'],
true)) {
$template_loaded = true;
}
}
}
 
if (!$template_loaded
&& ($entities_id >= 0)) {
 
// load default entity one if not already loaded
if ($template_id = Entity::getUsedConfig('tickettemplates_id', $entities_id)) {
// with type and categ
if ($tt->getFromDBWithDatas($template_id, true)) {
$template_loaded = true;
}
}
}
 
// Check if profile / entity set type and category and try to load template for these values
if ($template_loaded) { // template loaded for profile or entity
$newtype = $type;
$newitilcategories_id = $itilcategories_id;
// Get predefined values for ticket template
if (isset($tt->predefined['itilcategories_id']) && $tt->predefined['itilcategories_id']) {
$newitilcategories_id = $tt->predefined['itilcategories_id'];
}
if (isset($tt->predefined['type']) && $tt->predefined['type']) {
$newtype = $tt->predefined['type'];
}
if ($newtype
&& $newitilcategories_id) {
 
$categ = new ITILCategory();
if ($categ->getFromDB($newitilcategories_id)) {
$field = '';
switch ($newtype) {
case self::INCIDENT_TYPE :
$field = 'tickettemplates_id_incident';
break;
 
case self::DEMAND_TYPE :
$field = 'tickettemplates_id_demand';
break;
}
 
if (!empty($field) && $categ->fields[$field]) {
// without type and categ
if ($tt->getFromDBWithDatas($categ->fields[$field], false)) {
$template_loaded = true;
}
}
}
}
}
return $tt;
}
 
 
function showForm($ID, $options=array()) {
global $DB, $CFG_GLPI, $LANG;
 
$default_values = self::getDefaultValues();
 
// Get default values from posted values on reload form
// On get because of tabs
if (!isset($options['template_preview'])) {
if (isset($values_GET)) = $_REQUEST;{
$values = Html::cleanPostForTextArea($_GET);
}
}
 
// Restore saved value or override with page parameter
$saved = $this->restoreInput();
 
foreach ($default_values as $name => $value) {
if (!isset($values[$name])) {
if (isset($_SESSION["helpdeskSaved"]saved[$name])) {
$values[$name] = $_SESSION["helpdeskSaved"]saved[$name];
} else {
$values[$name] = $value;
Linha 3 937 ⟶ 3 567:
}
}
// Clean text fields
$values['name'] = stripslashes($values['name']);
$values['content'] = Html::cleanPostForTextArea($values['content']);
 
if (isset($_SESSIONvalues["helpdeskSaved"'content'])) {
// Clean new lines to be fix encoding
unset($_SESSION["helpdeskSaved"]);
$order = array('\\r', '\\n', "\\");
$replace = array("", "", "");
 
$values['content'] = str_replace($order,$replace,$values['content']);
}
if (!$ID) {
// Override defaut values from projecttask if needed
if (isset($options['projecttasks_id'])) {
$pt = new ProjectTask();
if ($pt->getFromDB($options['projecttasks_id'])) {
$values['name'] = $pt->getField('name');
$values['content'] = $pt->getField('name');
}
}
}
 
// Check category / type validity
if ($values['itilcategories_id']) {
$cat = new ITILCategory();
if ($cat->getFromDB($values['itilcategories_id'])) {
switch ($values['type']) {
case self::INCIDENT_TYPE :
if (!$cat->getField('is_incident')) {
$values['itilcategories_id'] = 0;
}
break;
 
case self::DEMAND_TYPE :
if (!$cat->getField('is_request')) {
$values['itilcategories_id'] = 0;
}
break;
 
default :
break;
}
}
}
 
 
// Default check
if ($ID > 0) {
$this->check($ID,'r' READ);
} else {
// Create item
$this->check(-1,'w' CREATE, $values);
}
 
Linha 3 956 ⟶ 3 622:
if ($values["_users_id_requester"]) {
//Get all the user's entities
$all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
true);
//For each user's entity, check if the technician which creates the ticket have access to it
foreach ($all_entities as $tmp => $ID_entity) {
Linha 3 966 ⟶ 3 633:
$this->countentitiesforuser = count($this->userentities);
 
if (($this->countentitiesforuser > 0)
&& !in_array($this->fields["entities_id"], $this->userentities)) {
// If entity is not in the list of user's entities,
// then use as default value the first value of the user's entites list
$this->fields["entities_id"] = $this->userentities[0];
// Pass to values
$values['entities_id'] = $this->userentities[0];
}
}
 
// Clean text fields
$values['name'] = stripslashes($values['name']);
$values['content'] = Html::cleanPostForTextArea($values['content']);
 
if ($values['type'] <= 0) {
$values['type'] = EntityDataEntity::getUsedConfig('tickettype', $values['entities_id'], '',
'', Ticket::INCIDENT_TYPE);
}
 
if (!isset($options['template_preview'])) {
 
$options['template_preview'] = 0;
}
 
// Load ticket template if available :
$ttif = new TicketTemplate($ID); {
$tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'],
 
$this->fields['itilcategories_id'], $this->fields['entities_id']);
// First load default entity one
} else {
if ($template_id = EntityData::getUsedConfig('tickettemplates_id', $values['entities_id'])) {
$tt = $this->getTicketTemplateToUse($options['template_preview'], $values['type'],
// with type and categ
$values['itilcategories_id'], $values['entities_id']);
$tt->getFromDBWithDatas($template_id, true);
}
 
if ($values['type'] && $values['itilcategories_id']) {
$categ = new ITILCategory();
if ($categ->getFromDB($values['itilcategories_id'])) {
$field = '';
switch ($values['type']) {
case self::INCIDENT_TYPE :
$field = 'tickettemplates_id_incident';
break;
 
case self::DEMAND_TYPE :
$field = 'tickettemplates_id_demand';
break;
}
 
if (!empty($field) && $categ->fields[$field]) {
// without type and categ
$tt->getFromDBWithDatas($categ->fields[$field], false);
}
}
}
 
if (isset($options['template_preview'])) {
// with type and categ
$tt->getFromDBWithDatas($options['template_preview'], true);
}
 
Linha 4 025 ⟶ 3 664:
if (isset($values['_predefined_fields'])) {
$values['_predefined_fields']
= unserialize(rawurldecode(stripslashesToolbox::decodeArrayFromInput($values['_predefined_fields'])));
} else {
$values['_predefined_fields'] = array();
Linha 4 034 ⟶ 3 673:
$predefined_fields = array();
if (!$ID) {
 
if (isset($tt->predefined) && count($tt->predefined)) {
foreach ($tt->predefined as $predeffield => $predefvalue) {
Linha 4 040 ⟶ 3 680:
// Set if already predefined field
// Set if ticket template change
if (((count($values[$predeffield'_predefined_fields']) == $default_values[$predeffield]0)
|| (isset && ($values['_predefined_fields'$predeffield] == $default_values[$predeffield]))
|| && $values[$predeffield] == (isset($values['_predefined_fields'][$predeffield])
|| (isset && ($values[$predeffield] == $values['_tickettemplates_id_predefined_fields'][$predeffield]))
|| && (isset($values['_tickettemplates_id'] != $tt->getID())) {
&& ($values['_tickettemplates_id'] != $tt->getID()))) {
// Load template data
$values[$predeffield] = $predefvalue;
Linha 4 051 ⟶ 3 692:
}
}
}
// All predefined override : add option to say predifined exists
if (count($predefined_fields) == 0) {
$predefined_fields['_all_predefined_override'] = 1;
}
 
Linha 4 063 ⟶ 3 708:
}
}
 
// Put ticket template on $values for actors
$values['_tickettemplate'] = $tt;
 
$canupdate = Session::haveRight('update_ticket'self::$rightname, '1'UPDATE);
$canpriority = Session::haveRight('update_priority'self::$rightname, '1'self::CHANGEPRIORITY);
$showuserlinkcanstatus = 0$canupdate;
 
if (Session::haveRight('user','r')) {
if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) {
$canupdate = false;
// No update for actors
$values['_noupdate'] = true;
}
 
$showuserlink = 0;
if (Session::haveRight('user', READ)) {
$showuserlink = 1;
}
 
 
if ($options['template_preview']) {
 
// Add all values to fields of tickets for template preview
if (!isset($options['template_preview'])) {
foreach ($this-values as $key =>showTabs( $optionsval); {
if (!isset($this->fields[$key])) {
$this->fields[$key] = $val;
}
}
}
 
// In percent
$colsize1 = '13';
$colsize2 = '29';
$colsize3 = '13';
$colsize4 = '45';
 
$canupdate_descr = $canupdate
|| (($this->fields['status'] == 'new'self::INCOMING)
&& $this->isUser(parentCommonITILActor::REQUESTER, Session::getLoginUserID())
&& ($this->numberOfFollowups() == Session::getLoginUserID()0)
&& ($this->numberOfFollowupsnumberOfTasks() == 0));
&& $this->numberOfTasks() == 0);
 
if (!$options['template_preview']) {
 
 
if (!isset($options['template_preview'])) {
echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='".
$CFG_GLPI["root_doc"]."/front/ticket.form.php'>";
if (isset($options['projecttasks_id'])) {
echo "<input type='hidden' name='_projecttasks_id' value='".$options['projecttasks_id']."'>";
}
}
echo "<div class='spaced' id='tabsbody'>";
echo "<table class='tab_cadre_fixe' id='mainformtable'>";
 
// Optional line
$ismultientities = Session::isMultiEntitiesMode();
echo "<tr class='headerRow'>";
echo "<th colspan='4'>";
 
if ($ID) {
echo $this->getTypeNametext = sprintf()."__('%1$s - ".%2$LANG[s'common'][2]."), $ID ";this->getTypeName(1),
sprintf(__('%1$s: %2$s'), __('ID'), $ID));
if ($ismultientities) {
$text = sprintf(__('%1$s (%2$s)'), $text,
echo "(".Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']) . ")";
Dropdown::getDropdownName('glpi_entities',
$this->fields['entities_id']));
}
echo $text;
 
} else {
if ($ismultientities) {
printf(__('The ticket will be added in the entity %s'),
echo $LANG['job'][46]."&nbsp;:&nbsp;".
Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id']));
} else {
echo $LANG[_e('jobNew ticket'][13]);
}
}
Linha 4 123 ⟶ 3 783:
 
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$LANG['joblist'][11]."&nbsp;:</th>";
echo $tt->getBeginHiddenFieldText('date');
if (!$ID) {
printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date'));
} else {
_e('Opening date');
}
echo $tt->getEndHiddenFieldText('date');
echo "</th>";
echo "<td width='$colsize2%'>";
echo $tt->getBeginHiddenFieldValue('date');
$date = $this->fields["date"];
 
if ($canupdate) {
Html::showDateTimeFormItemshowDateTimeField("date", array('value' => $date, 1, false);
'timestep' => 1,
'maybeempty' => false));
} else {
echo Html::convDateTime($date);
}
echo $tt->getEndHiddenFieldValue('date', $this);
 
echo "</td>";
// SLA
echo "<th width='$colsize3%'>".$tt->getBeginHiddenFieldText('due_date');
 
echo $LANG['sla'][5]."&nbsp;:";
if (!$ID) {
echoprintf(__('%1$s%2$s'), __('Due date'), $tt->getMandatoryMark('due_date'));
} else {
_e('Due date');
}
echo $tt->getEndHiddenFieldText('due_date');
Linha 4 144 ⟶ 3 817:
echo "<td width='$colsize4%' class='nopadding'>";
if ($ID) {
if ($this->fields["slas_id"] > 0) {
echo "<table width='100%'><tr><td class='nopadding'>";
 
echo Html::convDateTime($this->fields["due_date"]);
echo "</td><td class='b'>".__('SLA')."</td>";
 
echo "</td><td>".$LANG[ class='slanopadding'][1]."&nbsp;:>";
echo "</td><td class='nopadding'>";
echo Dropdown::getDropdownName("glpi_slas", $this->fields["slas_id"]);
$commentsla = "";
$slalevel = new SlaLevel();
if ($slalevel->getFromDB($this->fields['slalevels_id'])) {
$commentsla .= '<span class="b spaced">'.$LANG['sla'][6]."&nbsp;:&nbsp;</span>".
$slalevel->getName sprintf(__('%1$s: %2$s')., __('<br><br>Escalation level';),
$slalevel->getName()).'</span><br>';
}
 
$nextaction = new SlaLevel_Ticket();
if ($nextaction->getFromDBForTicket($this->fields["id"])) {
$commentsla .= '<span class="b spaced">'.$LANG['sla'][8]."&nbsp;:&nbsp;</span>".
Html::convDateTime sprintf(__($nextaction->fields['dateNext escalation: %s']).'<br>';,
Html::convDateTime($nextaction->fields['date'])).
'</span><br>';
if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) {
$commentsla .= '<span class="b spaced">'.$LANG['sla'][6]."&nbsp;:&nbsp;</span>".
$slalevel->getName sprintf(__('%1$s: %2$s')., __('<br>Escalation level';),
$slalevel->getName()).'</span>';
}
}
$slaoptions = array();
if (Session::haveRight('config', 'r'READ)) {
$slaoptions['link'] = Toolbox::getItemTypeFormURL('SLA').
"?id=".$this->fields["slas_id"];
}
Html::showToolTip($commentsla,$slaoptions);
if ($canupdate) {
echo "&nbsp;<input type='submit' class='submit' name='sla_delete' value='".;
Html::showSimpleForm($this->getFormURL(), $LANG['buttonssla_delete'][6]."'>";,
_x('button', 'Delete permanently'),
array('id' => $this->getID()));
}
echo "</td></tr></table>";
echo "</tr></table>";
 
} else {
echo "<table width='100%'><tr><td class='nopadding'>";
echo $tt->getBeginHiddenFieldValue('due_date');
Html::showDateTimeFormItemif ("due_date", $this->fields["due_date"], 1, false, $canupdate); {
Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"],
'timestep' => 1,
'maybeempty' => true));
} else {
echo Html::convDateTime($this->fields["due_date"]);
}
echo $tt->getEndHiddenFieldValue('due_date',$this);
echo "</td>";
if ($this->fields['status'] != 'closed' && $canupdate) {
echo "<td>";
echo $tt->getBeginHiddenFieldText('slas_id');
echo "<span id='sla_action'>";
echo "<a class='pointervsubmit' ".Html::addConfirmationOnAction(array($LANG['sla'][13],
Html::addConfirmationOnAction(array(__('The assignment of a SLA to a ticket causes the recalculation of the due $LANG['sladate.'][14]),
__("Escalations defined in the SLA will be triggered under this new date."cleanhide('sla_action');cleandisplay('sla_choice');").,
">".$LANG[cleanhide('slasla_action'][12].);cleandisplay('</a>sla_choice');").
echo ">".__('Assign a SLA').'</spana>"';
echo "<span id='sla_choice' style='display:none'>".$LANG['sla'][1]."&nbsp;:&nbsp;";
Dropdown::show('Sla',array('entity' => $this->fields["entities_id"],
'value' => $this->fields["slas_id"]));
echo "</span>";
echo "<div id='sla_choice' style='display:none'>";
echo "<span class='b'>".__('SLA')."</span>&nbsp;";
Sla::dropdown(array('entity' => $this->fields["entities_id"],
'value' => $this->fields["slas_id"]));
echo "</div>";
echo $tt->getEndHiddenFieldText('slas_id');
echo "</td>";
Linha 4 205 ⟶ 3 892:
 
} else { // New Ticket
echo "<table width='100%'><tr><td width='40%' class='nopadding'>";
if ($this->fields["due_date"] == 'NULL') {
$this->fields["due_date"]='';
}
echo $tt->getBeginHiddenFieldValue('due_date');
Html::showDateTimeFormItemshowDateTimeField("due_date", array('value' => $this->fields["due_date"], 1, false, $canupdate);
'timestep' => 1,
'maybeempty' => false,
'canedit' => $canupdate));
echo $tt->getEndHiddenFieldValue('due_date',$this);
echo "</td>";
if ($canupdate) {
echo "<td class='nopadding b'>".$tt->getBeginHiddenFieldText('slas_id').$LANG['sla'][1]."&nbsp;:".
printf(__('%1$s%2$s'), __('SLA'), $tt->getMandatoryMark('slas_id').);
echo $tt->getEndHiddenFieldText('slas_id')."</td>";
echo "<td class='nopadding'>".$tt->getBeginHiddenFieldValue('slas_id');
DropdownSla::showdropdown('Sla',array('entity' => $this->fields["entities_id"],
'value' => $this->fields["slas_id"]));
echo $tt->getEndHiddenFieldValue('slas_id',$this);
echo "</td>";
Linha 4 225 ⟶ 3 915:
echo "</tr></table>";
}
 
echo "</td></tr>";
 
if ($ID) {
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$LANG[__('commonBy'][95])." &nbsp;:</th>";
echo "<td width='$colsize2%'>";
if ($canupdate) {
User::dropdown(array('name' => 'users_id_recipient',
Linha 4 240 ⟶ 3 929:
echo getUserName($this->fields["users_id_recipient"], $showuserlink);
}
 
echo "</td>";
echo "<th width='$colsize3%'>".$LANG[__('commonLast update'][26])."&nbsp;:</th>";
echo "<td>".Html::convDateTime( width='$this-colsize4%'>fields["date_mod"])."\n";
if ($this->fields['users_id_lastupdater'] > 0) {
//TRANS: %1$s is the update date, %2$s is the last updater name
echo $LANG['common'][95]."&nbsp;";
echoprintf(__('%1$s by %2$s'), getUserNameHtml::convDateTime($this->fields["users_id_lastupdaterdate_mod"], $showuserlink);,
getUserName($this->fields["users_id_lastupdater"], $showuserlink));
}
echo "</td>";
Linha 4 251 ⟶ 3 942:
}
 
if ($ID
&& (in_array($this->fields["status"], $this->getSolvedStatusArray())
|| in_array($this->fields["status"], $this->getClosedStatusArray()))) {
 
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$LANG[__('joblistResolution date'][14])."&nbsp;:</th>";
echo "<td width='$colsize2%'>";
Html::showDateTimeFormItemshowDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 1, false,
$canupdate); 'timestep' => 1,
'maybeempty' => false,
'canedit' => $canupdate));
echo "</td>";
if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
echo "<th width='$colsize3%'>".$LANG[__('joblistClose date'][12])."&nbsp;:</th>";
echo "<td width='$colsize4%'>";
Html::showDateTimeFormItemshowDateTimeField("closedate", array('value' => $this->fields["closedate"], 1, false,
$canupdate); 'timestep' => 1,
echo "</td 'maybeempty' =>"; false,
'canedit' => $canupdate));
echo "</td>";
} else {
echo "<td colspan='2'>&nbsp;</td>";
Linha 4 273 ⟶ 3 970:
if ($ID) {
echo "</table>";
echo "<table class='tab_cadre_fixe' id='mainformtable2'>";
}
 
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$LANG[sprintf(__('common'][17]."&nbsp;:".%1$tt->getMandatoryMarks%2$s'), __('typeType')."</th>";,
$tt->getMandatoryMark('type'))."</th>";
echo "<td width='$colsize2%'>";
// Permit to set type when creating ticket without update right
Linha 4 284 ⟶ 3 982:
/// Auto submit to load template
if (!$ID) {
$opt['on_change'] = 'this.form.submit()';
}
$rand = self::dropdownType('type', $opt);
Linha 4 301 ⟶ 3 999:
}
echo "</td>";
echo "<th width='$colsize3%'>".sprintf(__('%1$LANG[s%2$s'), __('commonCategory'][36]."&nbsp;:";),
echo $tt->getMandatoryMark('itilcategories_id'))."</th>";
echo "</th>";
echo "<td width='$colsize4%'>";
// Permit to set category when creating ticket without update right
if ($canupdate
|| !$ID
|| $canupdate_descr) {
 
$opt = array('value' => $this->fields["itilcategories_id"],
'entity' => $this->fields["entities_id"]);
Linha 4 316 ⟶ 4 016:
/// Auto submit to load template
if (!$ID) {
$opt['on_change'] = 'this.form.submit()';
}
/// if category mandatory, no empty choice
/// no empty choice is default value set on ticket creation, else yes
if (($ID || $values['itilcategories_id'])
&& $tt->isMandatoryField("itilcategories_id")
&& ($this->fields["itilcategories_id"] > 0)) {
$opt['display_emptychoice'] = false;
}
 
switch ($this->fields['"type'"]) {
case self::INCIDENT_TYPE :
$opt['condition'] .= "`is_incident`='1'";
Linha 4 338 ⟶ 4 038:
break;
}
 
echo "<span id='show_category_by_type'>";
DropdownITILCategory::showdropdown('ITILCategory', $opt);
echo "</span>";
} else {
Linha 4 350 ⟶ 4 049:
if (!$ID) {
echo "</table>";
$this->showActorsPartForm($ID, $values);
echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
}
 
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('status').$LANG['joblist'][0]."&nbsp;:".
printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status').);
echo $tt->getEndHiddenFieldText('status')."</th>";
echo "<td width='$colsize2%'>";
echo $tt->getBeginHiddenFieldValue('status');
if ($canupdatecanstatus) {
self::dropdownStatus("status",array('value' => $this->fields["status"], 2); // Allowed status
'showtype' => 'allowed'));
TicketValidation::alertValidation($this, 'status');
} else {
echo self::getStatus($this->fields["status"]);
if (in_array($this->fields["status"], $this->getClosedStatusArray())
&& $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) {
echo "&nbsp;<a class='vsubmit' href='".$this->getLinkURL().
"&amp;forcetab=TicketFollowup$1&amp;_openfollowup=1'>". __('Reopen')."</a>";
}
}
echo $tt->getEndHiddenFieldValue('status',$this);
 
echo "</td>";
echo "<th width='$colsize3%'>".$tt->getBeginHiddenFieldText('requesttypes_id').$LANG['job'][44].;
printf(__('%1$s%2$s'), __('Request source'), "&nbsp;:".$tt->getMandatoryMark('requesttypes_id').);
echo $tt->getEndHiddenFieldText('requesttypes_id')."</th>";
echo "<td width='$colsize4%'>";
echo $tt->getBeginHiddenFieldValue('requesttypes_id');
if ($canupdate) {
DropdownRequestType::showdropdown('RequestType', array('value' => $this->fields["requesttypes_id"]));
} else {
echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]);
Linha 4 382 ⟶ 4 089:
 
echo "<tr class='tab_bg_1'>";
echo "<th>".$tt->getBeginHiddenFieldText('urgency').$LANG['joblist'][29]."&nbsp;:".
printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency').);
echo $tt->getEndHiddenFieldText('urgency')."</th>";
echo "<td>";
 
Linha 4 391 ⟶ 4 099:
// Only change during creation OR when allowed to change priority OR when user is the creator
echo $tt->getBeginHiddenFieldValue('urgency');
$idurgency = self::dropdownUrgency("urgency",array('value' => $this->fields["urgency"]));
echo $tt->getEndHiddenFieldValue('urgency', $this);
 
} else {
$idurgency = "value_urgency".mt_rand();
echo "<input id='$idurgency' type='hidden' name='urgency' value='".
$this->fields["urgency"]."'>";
"'>";
echo parent::getUrgencyName($this->fields["urgency"]);
}
Linha 4 405 ⟶ 4 113:
if (!$ID) {
echo $tt->getBeginHiddenFieldText('_add_validation');
echo printf(__('%1$LANG[s%2$s'validation), __('][26]."&nbsp;:".Approval request'), $tt->getMandatoryMark('_add_validation'));
echo $tt->getEndHiddenFieldText('_add_validation');
} else {
echo $LANG[tt->getBeginHiddenFieldText('validationglobal_validation'][0]."&nbsp;:&nbsp;");
_e('Approval');
echo $tt->getEndHiddenFieldText('global_validation');
}
echo "</th>";
Linha 4 414 ⟶ 4 124:
if (!$ID) {
echo $tt->getBeginHiddenFieldValue('_add_validation');
$validation_right = '';
if (Session::haveRight('create_validation',1)) {
if User::dropdown(array($values['nametype'] =>= "_add_validation",self::INCIDENT_TYPE)
&& Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) {
'entity' => $this->fields['entities_id'],
'right' $validation_right => 'validate_ticketvalidate_incident',;
}
'value' => $values['_add_validation']));
if (($values['type'] == self::DEMAND_TYPE)
&& Session::haveRight('ticketvalidaton', TicketValidation::CREATEREQUEST)) {
$validation_right = 'validate_request';
}
 
if (!empty($validation_right)) {
echo "<input type='hidden' name='_add_validation' value='".
$values['_add_validation']."'>";
$users_id_validate = array();
$params = array('name' => "users_id_validate",
'entity' => $this->fields['entities_id'],
'right' => $validation_right,
'users_id_validate' => $users_id_validate);
TicketValidation::dropdownValidator($params);
}
echo $tt->getEndHiddenFieldValue('_add_validation',$this);
if ($tt->isPredefinedField('global_validation')) {
echo "<input type='hidden' name='global_validation' value='".
$tt->predefined['global_validation']."'>";
}
} else {
echo $tt->getBeginHiddenFieldValue('global_validation');
 
if ($canupdate) {
TicketValidation::dropdownStatus('global_validation',
Linha 4 429 ⟶ 4 159:
echo TicketValidation::getStatus($this->fields['global_validation']);
}
echo $tt->getEndHiddenFieldValue('global_validation',$this);
 
}
echo "</td></tr>";
 
echo "<tr class='tab_bg_1'>";
echo "<th>".$tt->getBeginHiddenFieldText('impact').$LANG['joblist'][30]."&nbsp;:".
printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact').);
echo $tt->getEndHiddenFieldText('impact')."</th>";
echo "<td>";
echo $tt->getBeginHiddenFieldValue('impact');
 
if ($canupdate) {
$idimpact = self::dropdownImpact("impact",array('value' => $this->fields["impact"]));
} else {
$idimpact = "value_impact".mt_rand();
Linha 4 447 ⟶ 4 181:
echo "</td>";
 
echo "<th rowspan='2'>".$tt->getBeginHiddenFieldText('itemtype').;
printf(__('%1$s%2$s'), __('Associated $LANG['documentelement'][14]."&nbsp;:), ".$tt->getMandatoryMark('itemtype'));
if ($ID && $canupdate) {
echo "&nbsp;<img title=\"'".$LANG[__s('buttonsUpdate'][14])."\"' alt=\"'".$LANG[__s('buttonsUpdate'][14])."\"'
onClick=\"Ext".getHtml::jsShow('"tickethardwareselection$ID'").setDisplayed('block')"\"
class='pointer' src='".$CFG_GLPI["root_doc"]."/pics/showselect.png'>";
}
echo $tt->getEndHiddenFieldText('itemtype');
Linha 4 460 ⟶ 4 194:
 
// Select hardware on creation or if have update right
if ($canupdate
|| !$ID
|| $canupdate_descr) {
 
if ($ID) {
if ($ID) {
if ($this->fields['itemtype']
&& ($item = getItemForItemtype($this->fields['itemtype']))
&& $this->fields["items_id"]) {
 
if ($item->can($this->fields["items_id"],'r')) {
if echo ($item->getTypeNamecan()." - ".$itemthis->getLink(truefields["items_id"], READ)); {
printf(__('%1$s - %2$s'), $item->getTypeName(),
$item->getLink(array('comments' => true)));
} else {
echoprintf(__('%1$s - %2$s'), $item->getTypeName().", - ".$item->getNameID());
}
}
}
$dev_user_id = 0;
$dev_itemtype = $this->fields["itemtype"];
$dev_items_id = $this->fields["items_id"];
Linha 4 479 ⟶ 4 218:
$dev_itemtype = $values["itemtype"];
$dev_items_id = $values["items_id"];
} else if (isset($this->users[CommonITILActor::REQUESTER])
 
} else if && (issetcount($this->users[parentCommonITILActor::REQUESTER]) == 1)) {
foreach && count($this->users[parentCommonITILActor::REQUESTER])==1 as $user_id_single) {
foreach ($this->users[parent::REQUESTER] as $user_id_single) {
$dev_user_id = $user_id_single['users_id'];
}
Linha 4 489 ⟶ 4 227:
echo "<div id='tickethardwareselection$ID' style='display:none'>";
}
 
if ($dev_user_id > 0) {
self::dropdownMyDevices($dev_user_id, $this->fields["entities_id"],
Linha 4 498 ⟶ 4 237:
echo "</div>";
}
 
echo "<span id='item_ticket_selection_information'></span>";
 
Linha 4 504 ⟶ 4 244:
&& $this->fields['itemtype']
&& ($item = getItemForItemtype($this->fields['itemtype']))) {
if ($item->getFromDBcan($this->fields['"items_id'"], READ)); {
echo $item->getTypeName printf()."__('%1$s - ".%2$s'), $item->getNameIDgetTypeName();,
$item->getLink(array('comments' => true)));
} else {
printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID());
}
} else {
echo $LANG[_e('helpGeneral'][30]);
}
}
Linha 4 516 ⟶ 4 260:
 
echo "<tr class='tab_bg_1'>";
echo "<th>".sprintf(__('%1$LANG[s%2$s'joblist), __('][2]."&nbsp;:".Priority'), $tt->getMandatoryMark('priority'))."</th>";
"</th>";
echo "<td>";
$idajax = 'change_priority_' . mt_rand();
 
if ($canupdate
&& $canpriority
&& !$tt->isHiddenField('priority')) {
$idpriority = parent::dropdownPriority("priority",array('value' => $this->fields["priority"], false, true);
'withmajor' => true));
echo "&nbsp;<span id='$idajax' style='display:none'></span>";
 
} else {
$idpriority = 0;
echo $tt->getBeginHiddenFieldValue('priority');
echo "<span id='$idajax'>".parent::getPriorityName($this->fields["priority"])."</span>";
echo $tt->getEndHiddenFieldValue('priority', $this);
}
 
if ($canupdate
|| $canupdate_descr) {
$params = array('urgency' => '__VALUE0__',
'impact' => '__VALUE1__',
'priority' => 'dropdown_priority'.$idpriority);
Ajax::updateItemOnSelectEvent(array('dropdown_urgency'.$idurgency, $idimpact), $idajax,
'dropdown_impact'.$idimpact),
$idajax,
$CFG_GLPI["root_doc"]."/ajax/priority.php", $params);
}
Linha 4 540 ⟶ 4 291:
echo "</tr>";
 
// Need comment right to add a followup with the actiontime
if (!$ID && Session::haveRight("global_add_followups","1")) {
echo "<tr class='tab_bg_1'>";
echo "<th>".$tt->getBeginHiddenFieldText('actiontime').$LANG['job'][20]."&nbsp;:".
$tt->getMandatoryMark('actiontime').$tt->getEndHiddenFieldText('actiontime').
"</th>";
echo "<td colspan='3'>";
 
echo "<tr class='tab_bg_1'>";
// Need comment right to add a followup with the actiontime
if (!$ID
&& Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) {
echo "<th>".$tt->getBeginHiddenFieldText('actiontime');
printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime'));
echo $tt->getEndHiddenFieldText('actiontime')."</th>";
echo "<td>";
echo $tt->getBeginHiddenFieldValue('actiontime');
Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'],
'addfirstminutes' => true));
echo $tt->getEndHiddenFieldValue('actiontime',$this);
echo "</td>";
} else echo "</tr>";{
echo "<th></th><td></td>";
}
echo "<th>".$tt->getBeginHiddenFieldText('locations_id');
printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
echo $tt->getEndHiddenFieldText('locations_id')."</th>";
echo "<td>";
echo $tt->getBeginHiddenFieldValue('locations_id');
if ($canupdate) {
Location::dropdown(array('value' => $this->fields['locations_id'],
'entity' => $this->fields['entities_id']));
} else {
echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]);
}
echo $tt->getEndHiddenFieldValue('locations_id', $this);
echo "</td></tr>";
 
echo "</table>";
if ($ID) {
$this->showActorsPartForm($ID, $values);
}
 
$view_linked_tickets = ($ID || $canupdate);
 
echo "<table class='tab_cadre_fixe' id='mainformtable4'>";
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('name')."Assunto"."&nbsp;: ".
printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name').);
echo $tt->getEndHiddenFieldText('name')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID
|| $canupdate_descr) {
echo $tt->getBeginHiddenFieldTextgetBeginHiddenFieldValue('name');
echo "<input type='text' size='90' maxlength=250 name='name' ".
 
" value=\"".Html::cleanInputText($this->fields["name"])."\">";
$rand = mt_rand();
echo "<script type=$tt->getEndHiddenFieldValue('text/javascriptname', >\n"$this);
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'name',
'data' => rawurlencode($this->fields["name"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["name"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["name"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('name');
 
} else {
if (empty($this->fields["name"])) {
echo $LANG[_e('reminderWithout title'][15]);
} else {
echo $this->fields["name"];
Linha 4 609 ⟶ 4 350:
echo "</td>";
echo "</tr>";
//cbmes alteração login usuário implementar no futuro
/*
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>"."ID - Usuário"."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
print_r($_SESSION[glpiname]);
echo "</td>";
echo "</tr>";
*/
//cbmes alteração
if ($this->fields["nome_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('nome_cbmes')."Nome"."&nbsp;: ".
$tt->getMandatoryMark('nome_cbmes').
$tt->getEndHiddenFieldText('nome_cbmes')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) {
echo $tt->getBeginHiddenFieldText('nome_cbmes');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'nome_cbmes',
'data' => rawurlencode($this->fields["nome_cbmes"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["nome_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["nome_cbmes"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('nome_cbmes');
 
} else {
if (empty($this->fields["nome_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["nome_cbmes"];
}
}
echo "</td>";
echo "</tr>";
}
 
//cbmes alteração fim
//cbmes alteração
 
 
 
 
 
if ($this->fields["posto_grad_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('posto_grad_cbmescontent')."Posto ou Graduação"."&nbsp;: ".
printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('posto_grad_cbmescontent').);
if (!$ID
$tt->getEndHiddenFieldText('posto_grad_cbmes')."</th>";
|| $canupdate_descr) {
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
$content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
if (!$ID || $canupdate_descr) {
Html::showTooltip(nl2br(Html::Clean($content)));
echo $tt->getBeginHiddenFieldText('posto_grad_cbmes');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'posto_grad_cbmes',
'data' => rawurlencode($this->fields["posto_grad_cbmes"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["posto_grad_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["posto_grad_cbmes"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('posto_grad_cbmes');
 
} else {
if (empty($this->fields["posto_grad_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["posto_grad_cbmes"];
}
}
echo $tt->getEndHiddenFieldText('content')."</tdth>";
echo "</tr>";
}
 
 
//cbmes alteração fim
//cbmes alteração
if ($this->fields["funcional_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('funcional_cbmes')."Nº Funcional"."&nbsp;: ".
$tt->getMandatoryMark('funcional_cbmes').
$tt->getEndHiddenFieldText('funcional_cbmes')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) {
|| $canupdate_descr) { // Admin =oui on autorise la modification de la description
echo $tt->getBeginHiddenFieldText('funcional_cbmes');
echo $tt->getBeginHiddenFieldValue('content');
 
$rand = mt_rand();
echo$rand_text "<script type='text/javascript' >\n"mt_rand();
echo$cols "function showName$rand() {\n" = 90;
$rows = 6;
echo "Ext.get('name$rand').setDisplayed('none');";
$paramscontent_id = array('maxlength' => 250,"content$rand";
if ($CFG_GLPI["use_rich_text"]) {
'size' => 90,
$this->fields["content"] = $this->setRichTextContent($content_id,
'name' => 'funcional_cbmes',
'data' => rawurlencode( $this->fields["funcional_cbmescontent"]));,
$rand);
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$cols = $params)100;
echo "}" $rows = 10;
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["funcional_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo$this->fields["content"] = $this->setSimpleTextContent($this->fields["funcional_cbmescontent"]);
}
echo "</div>\n";
 
echo "<div id='viewnamecontent$randrand_text'>\n";
echo "</divtextarea id='$content_id' name='content' cols='$cols' rows='$rows'>\n";.
$this->fields["content"]."</textarea></div>";
if (!$ID) {
echo "<script type=$tt->getEndHiddenFieldValue('text/javascriptcontent', >\n$this);
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('funcional_cbmes');
 
} else {
$content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
ifecho nl2br(emptyHtml::Clean($this->fields["funcional_cbmes"]content)) {;
echo $LANG['reminder'][15];
} else {
echo $this->fields["funcional_cbmes"];
}
}
echo "</td>";
echo "</tr>";
}
 
 
//cbmes alteração fim
//cbmes alteração
if ($this->fields["obm_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('obm_cbmes')."OBM"."&nbsp;: ".
$tt->getMandatoryMark('obm_cbmes').
$tt->getEndHiddenFieldText('obm_cbmes')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) {
echo $tt->getBeginHiddenFieldText('obm_cbmes');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'obm_cbmes',
'data' => rawurlencode($this->fields["obm_cbmes"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["obm_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["obm_cbmes"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('obm_cbmes');
 
} else {
if (empty($this->fields["obm_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["obm_cbmes"];
}
}
echo "</td>";
echo "</tr>";
}
 
 
//cbmes alteração fim
 
//cbmes alteração
if ($this->fields["setor_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('setor_cbmes')."Setor"."&nbsp;: ".
$tt->getMandatoryMark('setor_cbmes').
$tt->getEndHiddenFieldText('setor_cbmes')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) {
echo $tt->getBeginHiddenFieldText('setor_cbmes');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'setor_cbmes',
'data' => rawurlencode($this->fields["setor_cbmes"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["setor_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["setor_cbmes"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('setor_cbmes');
 
} else {
if (empty($this->fields["setor_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["setor_cbmes"];
}
}
echo "</td>";
echo "</tr>";
}
 
 
//cbmes alteração fim
 
//cbmes alteração
if ($this->fields["tel_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('tel_cbmes')."Tel."."&nbsp;: ".
$tt->getMandatoryMark('tel_cbmes').
$tt->getEndHiddenFieldText('tel_cbmes')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) {
echo $tt->getBeginHiddenFieldText('tel_cbmes');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'tel_cbmes',
'data' => rawurlencode($this->fields["tel_cbmes"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["tel_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["tel_cbmes"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('tel_cbmes');
 
} else {
if (empty($this->fields["tel_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["tel_cbmes"];
}
}
echo "</td>";
echo "</tr>";
}
 
 
//cbmes alteração fim
//cbmes alteração
if ($this->fields["patrimonio_cbmes"])
{
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('patrimonio_cbmes')."Nº Patrimonio"."&nbsp;: ".
$tt->getMandatoryMark('patrimonio_cbmes').
$tt->getEndHiddenFieldText('patrimonio_cbmes')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) {
echo $tt->getBeginHiddenFieldText('patrimonio_cbmes');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showName$rand() {\n";
echo "Ext.get('name$rand').setDisplayed('none');";
$params = array('maxlength' => 250,
'size' => 90,
'name' => 'patrimonio_cbmes',
'data' => rawurlencode($this->fields["patrimonio_cbmes"]));
Ajax::updateItemJsCode("viewname$rand", $CFG_GLPI["root_doc"]."/ajax/inputtext.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='name$rand' class='tracking left' onClick='showName$rand()'>\n";
if (empty($this->fields["patrimonio_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["patrimonio_cbmes"];
}
echo "</div>\n";
 
echo "<div id='viewname$rand'>\n";
echo "</div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showName$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('patrimonio_cbmes');
 
} else {
if (empty($this->fields["patrimonio_cbmes"])) {
echo $LANG['reminder'][15];
} else {
echo $this->fields["patrimonio_cbmes"];
}
}
echo "</td>";
echo "</tr>";
}
 
 
//cbmes alteração fim
 
echo "<tr class='tab_bg_1'>";
echo "<th width='$colsize1%'>".$tt->getBeginHiddenFieldText('content').$LANG['joblist'][6]."&nbsp;: ".
$tt->getMandatoryMark('content').
$tt->getEndHiddenFieldText('content')."</th>";
echo "<td width='".(100-$colsize1)."%' colspan='3'>";
if (!$ID || $canupdate_descr) { // Admin =oui on autorise la modification de la description
echo $tt->getBeginHiddenFieldText('content');
 
$rand = mt_rand();
echo "<script type='text/javascript' >\n";
echo "function showDesc$rand() {\n";
echo "Ext.get('desc$rand').setDisplayed('none');";
$params = array('rows' => 6,
'cols' => 90,
'name' => 'content',
'data' => rawurlencode($this->fields["content"]));
Ajax::updateItemJsCode("viewdesc$rand", $CFG_GLPI["root_doc"]."/ajax/textarea.php",
$params);
echo "}";
echo "</script>\n";
echo "<div id='desc$rand' class='tracking' onClick='showDesc$rand()'>\n";
if (!empty($this->fields["content"])) {
echo nl2br($this->fields["content"]);
} else {
echo $LANG['job'][33];
}
echo "</div>\n";
 
echo "<div id='viewdesc$rand'></div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n
showDesc$rand();
</script>";
}
echo $tt->getEndHiddenFieldText('content');
 
} else {
echo nl2br($this->fields["content"]);
}
echo "</td>";
echo "</tr>";
 
 
echo "<tr class='tab_bg_1'>";
// Permit to add doc when creating a ticket
if (!$ID) {
echo "<th width='$colsize1%'>".$LANG['document'][2]." (".Document::getMaxUploadSize().")&nbsp;:&nbsp;";
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/aide.png' class='pointer' alt=\"".
$LANG['central'][7]."\" onclick=\"window.open('".$CFG_GLPI["root_doc"].
"/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
echo "&nbsp;";
self::showDocumentAddButton();
 
echo "</th>";
echo "<td width='$colsize2%'><div id='uploadfiles'><input type='file' name='filename[]' size='20'>";
echo "</div></td>";
 
} else {
echo "<th colspan='2'>";
echo $LANG['document'][20].'&nbsp;:&nbsp;'.Document_Item::countForItem($this);
echo "</th>";
}
 
if ($view_linked_tickets) {
echo "<th width='$colsize3colsize1%'>". _n('Linked ticket', 'Linked tickets', 2);
echo $LANG['job'][55]."&nbsp;:";
 
$rand_linked_ticket = mt_rand();
 
if ($canupdate) {
echo "&nbsp;";
echo "<img onClick=\"Ext".getHtml::jsShow('"linkedticket$rand_linked_ticket'").setDisplayed('block')"\"
title=\"".$LANG[__s('buttonsAdd'][8])."\" alt=\"".$LANG[__s('buttonsAdd'][8])."\"
class='pointer' src='".$CFG_GLPI["root_doc"]."/pics/add_dropdown.png'>";
}
 
echo '</th>';
echo "<td width='".(100-$colsize4colsize1)."%' colspan='3'>";
if ($canupdate) {
echo "<div style='display:none' id='linkedticket$rand_linked_ticket'>";
echo "<table class='tab_format' width='100%'><tr><td width='30%'>";
Ticket_Ticket::dropdownLinks('_link[link]',
(isset($values["_link"])?$values["_link"]['link']:''));
echo "&nbsp;".$LANG['job'][38]."&nbsp;".$LANG['common'][2]."&nbsp;:&nbsp;";
echo "<input type='hidden' name='_link[tickets_id_1]' value='$ID'>\n";
echo "<input/td><td typewidth='text' name='_link[tickets_id_2]70%'>";
$linkparam = array('name' => value='".(isset($values["_link"])?$values["_link"]['tickets_id_2']:'')."',
size= '10entity' => $this->\n";getEntityID(),
echo "&nbsp;" 'displaywith' => array('id'));
 
if (isset($values["_link"])) {
$linkparam['value'] = $values["_link"]['tickets_id_2'];
}
Ticket::dropdown($linkparam);
echo "</td></tr></table>";
echo "</div>";
 
if (isset($values["_link"])
&& !empty($values["_link"]['tickets_id_2'])) {
echo "<script language='javascript'>Ext.get";
echo Html::jsShow('"linkedticket$rand_linked_ticket'").;
echo setDisplayed('block');"</script>";
}
}
Linha 5 139 ⟶ 4 432:
echo "</td>";
}
echo "</tr>";
 
// View files added
echo "<tr class='tab_bg_1'>";
// Permit to add doc when creating a ticket
echo "<th width='$colsize1%'>";
echo $tt->getBeginHiddenFieldText('_documents_id');
$doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize());
printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id'));
// Do not show if hidden.
if (!$tt->isHiddenField('_documents_id')) {
DocumentType::showAvailableTypesLink();
}
echo $tt->getEndHiddenFieldText('_documents_id');
echo "</th>";
echo "<td colspan='3' width='".(100-$colsize1)."%' >";
// Do not set values
echo $tt->getEndHiddenFieldValue('_documents_id');
if ($tt->isPredefinedField('_documents_id')) {
if (isset($values['_documents_id'])
&& is_array($values['_documents_id'])
&& count($values['_documents_id'])) {
 
echo "<span class='b'>".__('Default documents:').'</span>';
echo "<br>";
$doc = new Document();
foreach ($values['_documents_id'] as $key => $val) {
if ($doc->getFromDB($val)) {
echo "<input type='hidden' name='_documents_id[$key]' value='$val'>";
echo "- ".$doc->getNameID()."<br>";
}
}
}
}
echo "<div id='fileupload_info'></div>";
echo "</td>";
echo "</tr>";
 
Linha 5 145 ⟶ 4 473:
|| $canupdate
|| $canupdate_descr
|| Session::haveRighthaveRightsOr("assign_ticket"self::$rightname,"1" array(self::ASSIGN, self::STEAL)))
&& !$options['template_preview']) {
|| Session::haveRight("steal_ticket","1"))
&& !isset($options['template_preview'])) {
 
echo "<tr class='tab_bg_1'>";
 
if ($ID) {
if (Session::haveRighthaveRightsOr('delete_ticket'self::$rightname,1 array(UPDATE, DELETE, PURGE)) {
echo "<td|| class='tab_bg_2 center' colspan='2'$this->";canDeleteItem()
|| $this->canUpdateItem()) {
echo "<td class='tab_bg_2 center' colspan='4'>";
if ($this->fields["is_deleted"] == 1) {
if (self::canPurge()) {
echo "<input type='submit' class='submit' name='restore' value='".
$LANG[ _sx('buttonsbutton'][21], 'Restore')."'></td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
} else {
if (self::canUpdate() ) {
echo "<input type='submit' class='submit' name='update' value='".
$LANG[ _sx('buttonsbutton'][7], 'Save')."'></td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
}
echo "<td class='tab_bg_2 center' colspan='2'>";
if ($this->fields["is_deleted"] == 1) {
if (self::canPurge()) {
echo "<input type='submit' class='submit' name='purge' value='".
$LANG[ _sx('buttonsbutton'][22], 'Delete permanently')."' ".
Html::addConfirmationOnAction($LANG[__('commonConfirm the final deletion?'][50])).">";
}
} else {
if (self::canDelete()) {
echo "<input type='submit' class='submit' name='delete' value='".
$LANG[ _sx('buttonsbutton'][6], 'Put in dustbin')."'></td>";
}
}
echo "<input type='hidden' name='_read_date_mod' value='".$this->getField('date_mod')."'>";
 
} else { echo "</td>";
//alteração cbmes alterar botão atualizar
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' class='botao_atualizar' name='update' value='".
"GRAVAR ALTERAÇÕES"."'>";
}
 
echo "<input type='hidden' name='_read_date_mod' value='".$this->getField('date_mod')."'>";
 
} else {
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' name='add' value=\"".$LANG[_sx('buttonsbutton'][8],'Add')."\" class='submit'>";
if ($tt->isField('id') && ($tt->fields['id'] > 0)) {
echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
echo "<input type='hidden' name='_predefined_fields'
value=\"".rawurlencode(serializeToolbox::prepareArrayForInput($predefined_fields))."\">";
}
}
}
 
// File upload system
$colspan = 2;
if (!$CFG_GLPI['use_rich_text']) {
$colspan = 4;
}
echo "<tr class='tab_bg_1'>";
echo "<td colspan='$colspan'>";
echo $tt->getBeginHiddenFieldValue('_documents_id');
 
echo Html::file(array('multiple' => true,
'showfilecontainer' => 'fileupload_info',
'values' => array('filename' => $values['_filename'],
'tag' => $values['_tag_filename'])
));
echo "</td>";
if ($CFG_GLPI['use_rich_text']) {
echo "<td colspan='$colspan'>";
if (!isset($rand)) {
$rand = mt_rand();
}
echo Html::imagePaste(array('rand' => $rand));
echo "</td>";
}
echo "</tr>";
 
echo "</table>";
Linha 5 195 ⟶ 4 552:
echo "</div>";
 
if (!isset($options['template_preview'])) {
Html::closeForm();
$this->addDivForTabs();
}
 
return true;
}
 
 
/**
* @param $size (default 25)
**/
static function showDocumentAddButton($size=25) {
global $LANG, $CFG_GLPI;
 
echo "<script type='text/javascript'>var nbfiles=1; var maxfiles = 5;</script>";
echo "<span id='addfilebutton'><img title=\"".$LANG[__s('buttonsAdd'][8])."\" alt=\"".
$LANG[__s('buttonsAdd'][8])."\" onClick=\"if (nbfiles<maxfiles){
var row = Ext".getHtml::jsGetElementbyID('uploadfiles').";
row.createChildappend('<br><input type=\'file\' name=\'filename[]\' size=\'$size\'>');
nbfiles++;
if (nbfiles==maxfiles) {
Ext".getHtml::jsHide('addfilebutton').hide();"
}
}\"
Linha 5 220 ⟶ 4 580:
 
 
/**
* @param $start
* @param $status (default ''process)
* @param $showgrouptickets (true by default)
*/
static function showCentralList($start, $status="process", $showgrouptickets=true) {
global $DB, $CFG_GLPI, $LANG;
 
if (!Session::haveRightsOr(self::$rightname, array(CREATE, self::READALL, self::READASSIGN))
&& !Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
 
if (!Session::haveRight("show_all_ticket","1")
&& !Session::haveRight("show_assign_ticket","1")
&& !Session::haveRight("create_ticket","1")
&& !Session::haveRight("validate_ticket","1")) {
return false;
}
 
$search_users_id = " (`glpi_tickets_users`.`users_id` = '".Session::getLoginUserID()."'
AND `glpi_tickets_users`.`type` = '".parentCommonITILActor::REQUESTER."') ";
$search_assign = " (`glpi_tickets_users`.`users_id` = '".Session::getLoginUserID()."'
AND `glpi_tickets_users`.`type` = '".parentCommonITILActor::ASSIGN."')";
$search_observer = " (`glpi_tickets_users`.`users_id` = '".Session::getLoginUserID()."'
AND `glpi_tickets_users`.`type` = '".CommonITILActor::OBSERVER."')";
$is_deleted = " `glpi_tickets`.`is_deleted` = 0 ";
 
 
if ($showgrouptickets) {
Linha 5 241 ⟶ 4 608:
 
if (count($_SESSION['glpigroups'])) {
$groups = implode("','",$_SESSION['glpigroups']);
$search_assign = " (`glpi_groups_tickets`.`groups_id` IN ('".$groups'.")
AND `glpi_groups_tickets`.`type` = '".parentCommonITILActor::ASSIGN."')";
 
if (Session::haveRight("show_group_ticket"self::$rightname,1 self::READGROUP)) {
$search_users_id = " (`glpi_groups_tickets`.`groups_id` IN ('$groups')
AND `glpi_groups_tickets`.`type` = '".parent::REQUESTER."') ";
= '".CommonITILActor::REQUESTER."') ";
$search_observer = " (`glpi_groups_tickets`.`groups_id` IN ('$groups')
AND `glpi_groups_tickets`.`type`
= '".CommonITILActor::OBSERVER."') ";
}
}
Linha 5 261 ⟶ 4 632:
switch ($status) {
case "waiting" : // on affiche les tickets en attente
$query .= "WHERE $is_deleted
AND ($search_assign)
AND `status` = 'waiting".self::WAITING."' ".
getEntitiesRestrictRequest("AND", "glpi_tickets");
break;
 
case "process" : // on affiche les tickets planifiés ou assignés au user
$query .= "WHERE $is_deleted
AND ( $search_assign )
AND (`status` IN ('plan".implode("','assign", self::getProcessStatusArray())."')) ".
getEntitiesRestrictRequest("AND", "glpi_tickets");
break;
 
case "toapprove" : // on affiche les tickets planifiés ou assignés au user
$query .= "WHERE $is_deleted AND (`status` = 'solved')
AND (`status` = '".self::SOLVED."')
AND ($search_users_id";
if (!$showgrouptickets) {
Linha 5 281 ⟶ 4 655:
getEntitiesRestrictRequest("AND", "glpi_tickets");
break;
 
case "tovalidate" : // on affiche les tickets à valider
$query .= " LEFT JOIN `glpi_ticketvalidations`
ON (`glpi_tickets`.`id` = `glpi_ticketvalidations`.`tickets_id`)
WHERE $is_deleted
AND `users_id_validate` = '".Session::getLoginUserID()."'
AND `glpi_ticketvalidations`.`status` = 'waiting".CommonITILValidation::WAITING."'
AND (`glpi_tickets`.`status` NOT IN ('closed".self::CLOSED."', 'solved') ".
getEntitiesRestrictRequest("AND", '"glpi_tickets.self::SOLVED."');) ".
getEntitiesRestrictRequest("AND", "glpi_tickets");
break;
 
case "rejected" : // on affiche les tickets rejetés
$query .= "WHERE $is_deleted
AND ($search_assign)
AND `status` <> 'closed".self::CLOSED."'
AND `global_validation` = 'rejected".CommonITILValidation::REFUSED."' ".
getEntitiesRestrictRequest("AND", "glpi_tickets");
break;
 
case "observed" :
$query .= "WHERE $is_deleted
AND ($search_observer)
AND (`status` IN ('".self::INCOMING."',
'".self::PLANNED."',
'".self::ASSIGNED."',
'".self::WAITING."'))
AND NOT ( $search_assign )
AND NOT ( $search_users_id ) ".
getEntitiesRestrictRequest("AND","glpi_tickets");
break;
 
case "requestbyself" : // on affiche les tickets demandés le user qui sont planifiés ou assignés
Linha 5 303 ⟶ 4 690:
 
default :
$query .= "WHERE $is_deleted
AND ($search_users_id)
AND (`status` IN ('new".self::INCOMING."', 'plan', 'assign', 'waiting'))
AND NOT ( $search_assign ) '".self::PLANNED."',
getEntitiesRestrictRequest( '"AND.self::ASSIGNED."',"glpi_tickets");
'".self::WAITING."'))
AND NOT ( $search_assign ) ".
getEntitiesRestrictRequest("AND","glpi_tickets");
}
 
Linha 5 316 ⟶ 4 707:
$query .= " LIMIT ".intval($start).','.intval($_SESSION['glpidisplay_count_on_home']);
$result = $DB->query($query);
$number = $DB->numrows($result);
} else {
$number = 0;
Linha 5 322 ⟶ 4 713:
 
if ($numrows > 0) {
echo "<table class='tab_cadrehov' style='width:420px'>";
echo "<tr class='noHover'><th colspan='54'>";
 
$options['reset'] = 'reset';
$forcetab = '';
$num = 0;
if ($showgrouptickets) {
switch ($status) {
case "toapprove" :
foreach ($_SESSIONoptions['glpigroupscriteria'][0]['field'] as $gID) { = 12; // status
$options['fieldcriteria'][$num0]['searchtype'] = 71'equals'; // groups_id
$options['searchtypecriteria'][$num0]['value'] = 'equals'self::SOLVED;
$options['containscriteria'][$num0]['link'] = $gID'AND';
 
$options['link'][$num] = ($num==0?'AND':'OR');
$options['criteria'][1]['field'] $num++ = 71; // groups_id
$options['fieldcriteria'][$num1]['searchtype'] = 12'equals'; // status
$options['searchtypecriteria'][$num1]['value'] = 'equalsmygroups';
$options['containscriteria'][$num1]['link'] = 'solvedAND';
$forcetab $options['link'][$num] = 'ANDTicket$2';
 
$num++;
$forcetab = 'Ticket$2';
}
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('centralYour tickets to close'][18]), $number, $numrows)."</a>";
break;
 
case "waiting" :
foreach ($_SESSIONoptions['glpigroupscriteria'][0]['field'] as $gID) { = 12; // status
$options['fieldcriteria'][$num0]['searchtype'] = 8'equals'; // groups_id_assign
$options['searchtypecriteria'][$num0]['value'] = 'equals'self::WAITING;
$options['containscriteria'][$num0]['link'] = $gID'AND';
 
$options['link'][$num] = ($num==0?'AND':'OR');
$options['criteria'][1]['field'] $num++ = 8; // groups_id_assign
$options['fieldcriteria'][$num1]['searchtype'] = 12'equals'; // status
$options['searchtypecriteria'][$num1]['value'] = 'equalsmygroups';
$options['containscriteria'][$num1]['link'] = 'waitingAND';
 
$options['link'][$num] = 'AND';
$num++;
}
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('joblistTickets on pending status'][13]."), (".$LANG['joblist'][26]number, $numrows).")</a>",;
$number, $numrows)."</a>";
break;
 
case "process" :
foreach ($_SESSIONoptions['glpigroupscriteria'][0]['field'] as $gID) { = 12; // status
$options['fieldcriteria'][$num0]['searchtype'] = 8'equals'; // groups_id_assign
$options['searchtypecriteria'][$num0]['value'] = 'equalsprocess';
$options['containscriteria'][$num0]['link'] = $gID'AND';
 
$options['link'][$num] = ($num==0?'AND':'OR');
$options['criteria'][1]['field'] $num++ = 8; // groups_id_assign
$options['fieldcriteria'][$num1]['searchtype'] = 12'equals'; // status
$options['searchtypecriteria'][$num1]['value'] = 'equalsmygroups';
$options['containscriteria'][$num1]['link'] = 'processAND';
 
$options['link'][$num] = 'AND';
$num++;
}
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('joblistTickets to be processed'][13]), $number, $numrows)."</a>";
break;
 
case "observed":
$options['criteria'][0]['field'] = 12; // status
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = 'notold';
$options['criteria'][0]['link'] = 'AND';
 
$options['criteria'][1]['field'] = 65; // groups_id
$options['criteria'][1]['searchtype'] = 'equals';
$options['criteria'][1]['value'] = 'mygroups';
$options['criteria'][1]['link'] = 'AND';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle(__('Your observed tickets'), $number, $numrows)."</a>";
break;
 
case "requestbyself" :
default :
foreach ($_SESSIONoptions['glpigroupscriteria'][0]['field'] as $gID) { = 12; // status
$options['fieldcriteria'][$num0]['searchtype'] = 71'equals'; // groups_id
$options['searchtypecriteria'][$num0]['value'] = 'equalsnotold';
$options['containscriteria'][$num0]['link'] = $gID'AND';
 
$options['link'][$num] = ($num==0?'AND':'OR');
$options['criteria'][1]['field'] $num++ = 71; // groups_id
$options['fieldcriteria'][$num1]['searchtype'] = 12'equals'; // status
$options['searchtypecriteria'][$num1]['value'] = 'equalsmygroups';
$options['containscriteria'][$num1]['link'] = 'processAND';
 
$options['link'][$num] = 'AND';
$num++;
}
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('centralYour tickets in progress'][9]), $number, $numrows)."</a>";
}
 
Linha 5 408 ⟶ 4 806:
switch ($status) {
case "waiting" :
$options['fieldcriteria'][0]['field'] = 12; // status
$options['searchtypecriteria'][0]['searchtype'] = 'equals';
$options['containscriteria'][0]['value'] = 'waiting'self::WAITING;
$options['linkcriteria'][0]['link'] = 'AND';
 
$options['fieldcriteria'][1]['field'] = 5; // users_id_assign
$options['searchtypecriteria'][1]['searchtype'] = 'equals';
$options['containscriteria'][1]['value'] = Session::getLoginUserID();
$options['linkcriteria'][1]['link'] = 'AND';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('joblistTickets on pending status'][13]."), (".$LANG['joblist'][26]number, $numrows).")</a>",;
$number, $numrows)."</a>";
break;
 
case "process" :
$options['fieldcriteria'][0]['field'] = 5; // users_id_assign
$options['searchtypecriteria'][0]['searchtype'] = 'equals';
$options['containscriteria'][0]['value'] = Session::getLoginUserID();
$options['linkcriteria'][0]['link'] = 'AND';
 
$options['fieldcriteria'][1]['field'] = 12; // status
$options['searchtypecriteria'][1]['searchtype'] = 'equals';
$options['containscriteria'][1]['value'] = 'process';
$options['linkcriteria'][1]['link'] = 'AND';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('joblistTickets to be processed'][13]), $number, $numrows)."</a>";
break;
 
case "tovalidate" :
$options['fieldcriteria'][0]['field'] = 55; // validation status
$options['searchtypecriteria'][0]['searchtype'] = 'equals';
$options['containscriteria'][0]['value'] = 'waiting'CommonITILValidation::WAITING;
$options['linkcriteria'][0] ['link'] = 'AND';
 
$options['field'][1] = 59; // validation aprobator
$options['searchtype'][1] = 'equals';
$options['contains'][1] = Session::getLoginUserID();
$options['link'][1] = 'AND';
 
$options['fieldcriteria'][21]['field'] = 1259; // validation aprobator
$options['searchtypecriteria'][21]['searchtype'] = 'equals';
$options['containscriteria'][21]['value'] = 'old'Session::getLoginUserID();
$options['linkcriteria'][21]['link'] = 'AND NOT';
 
$forcetaboptions['criteria'][2]['field'] = 'TicketValidation$1'12; // validation aprobator
$options['criteria'][2]['searchtype'] = 'equals';
$options['criteria'][2]['value'] = 'old';
$options['criteria'][2]['link'] = 'AND NOT';
$forcetab = 'TicketValidation$1';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('centralYour tickets to validate'][19]), $number, $numrows)."</a>";
 
break;
 
case "rejected" :
$options['fieldcriteria'][0]['field'] = 52; // validation status
$options['searchtypecriteria'][0]['searchtype'] = 'equals';
$options['containscriteria'][0]['value'] = 'rejected'CommonITILValidation::REFUSED;
$options['linkcriteria'][0] ['link'] = 'AND';
 
$options['fieldcriteria'][1]['field'] = 5; // assign user
$options['searchtypecriteria'][1]['searchtype'] = 'equals';
$options['containscriteria'][1]['value'] = Session::getLoginUserID();
$options['linkcriteria'][1]['link'] = 'AND';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('centralYour rejected tickets'][17]), $number, $numrows)."</a>";
 
break;
 
case "toapprove" :
$options['fieldcriteria'][0]['field'] = 12; // status
$options['searchtypecriteria'][0]['searchtype'] = 'equals';
$options['containscriteria'][0]['value'] = 'solved'self::SOLVED;
$options['linkcriteria'][0] ['link'] = 'AND';
 
$options['fieldcriteria'][1]['field'] = 4; // users_id_assign
$options['searchtypecriteria'][1]['searchtype'] = 'equals';
$options['containscriteria'][1]['value'] = Session::getLoginUserID();
$options['linkcriteria'][1]['link'] = 'AND';
 
$options['fieldcriteria'][2]['field'] = 22; // users_id_recipient
$options['searchtypecriteria'][2]['searchtype'] = 'equals';
$options['containscriteria'][2]['value'] = Session::getLoginUserID();
$options['linkcriteria'][2]['link'] = 'OR';
 
$options['fieldcriteria'][3]['field'] = 12; // status
$options['searchtypecriteria'][3]['searchtype'] = 'equals';
$options['containscriteria'][3]['value'] = 'solved'self::SOLVED;
$options['linkcriteria'][3]['link'] = 'AND';
 
$forcetab = 'Ticket$2';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('centralYour tickets to close'][18]), $number, $numrows)."</a>";
break;
 
case "observed" :
$options['criteria'][0]['field'] = 66; // users_id
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = Session::getLoginUserID();
$options['criteria'][0]['link'] = 'AND';
 
$options['criteria'][1]['field'] = 12; // status
$options['criteria'][1]['searchtype'] = 'equals';
$options['criteria'][1]['value'] = 'notold';
$options['criteria'][1]['link'] = 'AND';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle(__('Your observed tickets'), $number, $numrows)."</a>";
break;
 
case "requestbyself" :
default :
$options['fieldcriteria'][0]['field'] = 4; // users_id
$options['searchtypecriteria'][0]['searchtype'] = 'equals';
$options['containscriteria'][0]['value'] = Session::getLoginUserID();
$options['linkcriteria'][0]['link'] = 'AND';
 
$options['fieldcriteria'][1]['field'] = 12; // status
$options['searchtypecriteria'][1]['searchtype'] = 'equals';
$options['containscriteria'][1]['value'] = 'notold';
$options['linkcriteria'][1]['link'] = 'AND';
 
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".
Html::makeTitle($LANG[__('centralYour tickets in progress'][9]), $number, $numrows)."</a>";
}
}
Linha 5 530 ⟶ 4 942:
if ($number) {
echo "<tr><th></th>";
echo "<th>".$LANG[__('jobRequester'][4]."teste1")."</th>";
echo "<th>".$LANG[__('documentAssociated element'][14])."</th>";
echo "<th>".$LANG[__('joblistDescription'][6])."</th></tr>";
for ($i = 0 ; $i < $number ; $i++) {
$ID = $DB->result($result, $i, "id");
Linha 5 540 ⟶ 4 952:
echo "</table>";
 
} else {
echo "<table class='tab_cadrehov' style='width:420px'>";
echo "<tr><th>";
switch ($status) {
case 'waiting' :
echo $LANG['joblist'][13]." (".$LANG['joblist'][26].")";
break;
 
case 'process' :
echo $LANG['joblist'][13];
break;
 
case 'tovalidate' :
echo $LANG['central'][19];
break;
 
case 'rejected' :
echo $LANG['central'][17];
break;
 
case 'toapprove' :
echo $LANG['central'][18];
break;
 
case 'requestbyself' :
default :
echo $LANG['central'][9];
}
echo "</th></tr>";
echo "</table>";
}
}
 
/**
* Get tickets count
*
* @param $foruser boolean : only for current login user as requester (false by default)
**/
static function showCentralCount($foruser=false) {
global $DB, $CFG_GLPI, $LANG;
 
// show a tab with count of jobs in the central and give link
if (!Session::haveRight("show_all_ticket"self::$rightname,"1" self::READALL) && !Sessionself::haveRightcanCreate("create_ticket",1)) {
return false;
}
if (!Session::haveRight("show_all_ticket"self::$rightname,"1" self::READALL)) {
$foruser = true;
}
Linha 5 596 ⟶ 4 978:
$query .= " LEFT JOIN `glpi_tickets_users`
ON (`glpi_tickets`.`id` = `glpi_tickets_users`.`tickets_id`
AND `glpi_tickets_users`.`type` = '".parentCommonITILActor::REQUESTER."')";
 
if (Session::haveRight("show_group_ticket"self::$rightname,'1' self::READGROUP)
&& isset($_SESSION["glpigroups"])
&& count($_SESSION["glpigroups"])) {
$query .= " LEFT JOIN `glpi_groups_tickets`
ON (`glpi_tickets`.`id` = `glpi_groups_tickets`.`tickets_id`
AND `glpi_groups_tickets`.`type` = '".parentCommonITILActor::REQUESTER."')";
}
}
Linha 5 611 ⟶ 4 993:
$query .= " AND (`glpi_tickets_users`.`users_id` = '".Session::getLoginUserID()."' ";
 
if (Session::haveRight("show_group_ticket"self::$rightname,'1' self::READGROUP)
&& isset($_SESSION["glpigroups"])
&& count($_SESSION["glpigroups"])) {
$groups = implode("','",$_SESSION['glpigroups']);
$query .= " OR `glpi_groups_tickets`.`groups_id` IN ('".$groups'.") ";
}
$query.= ")";
Linha 5 621 ⟶ 5 003:
$query_deleted = $query;
 
$query .= " AND NOT `glpi_tickets`.`is_deleted` ";
GROUP BY `status`";
$query_deleted .= " AND `glpi_tickets`.`is_deleted` ";
$queryquery_deleted .= " GROUP BYAND `statusglpi_tickets`.`is_deleted`";
$query_deleted .= " GROUP BY `status`";
 
$result = $DB->query($query);
$result_deleted = $DB->query($query_deleted);
 
$status = array('new' => 0,);
foreach (self::getAllStatusArray() as $key => $val) {
'assign' => 0,
'plan' $status[$key] => 0,;
}
'waiting' => 0,
'solved' => 0,
'closed' => 0);
 
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
$status[$data["status"]] = $data["COUNT"];
}
}
 
$number_deleted = 0;
if ($DB->numrows($result_deleted) > 0) {
while ($data = $DB->fetch_assoc($result_deleted)) {
$number_deleted += $data["COUNT"];
}
}
$options['criteria'][0]['field'] = 12;
 
$options['fieldcriteria'][0] ['searchtype'] = 12'equals';
$options['searchtypecriteria'][0]['value'] = 'equalsprocess';
$options['containscriteria'][0]['link'] = 'processAND';
$options['link'][0] = 'AND';
$options['reset'] ='reset';
 
echo "<table class='tab_cadrehov' >";
echo "<tr class='noHover'><th colspan='2'>";
 
if ($foruser_SESSION["glpiactiveprofile"]["interface"] != "central") {
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1\">".
$LANG[__('profilesCreate a ticket'][5])."&nbsp;<img src='".$CFG_GLPI["root_doc"].
"/pics/menu_add.png' title=\"". $LANG[__s('buttonsAdd'][8])."\" alt=\"".$LANG[__s('buttonsAdd'][8])."\"></a>";
"\"></a>";
} else {
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".__('Ticket followup')."</a>";
"\">".$LANG['title'][10]."</a></th></tr>";
}
echo "</th></tr>";
echo "<tr><th>".$LANG[_n('titleTicket'][28],'Tickets',2)."</th><th>".$LANG[_x('quantity', 'trackingNumber'][29])."</th></tr>";
 
foreach ($status as $key => $val) {
$options['contains'][0] = 'new';
$options['criteria'][0]['value'] = $key;
echo "<tr class='tab_bg_2'>";
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".self::getStatus($LANG['tracking'][30]key)."</a></td>";
echo "<td class='numeric'>".$status["new"]."val</td></tr>";
}
 
$options['containscriteria'][0] ['value'] = 'assignall';
$options['is_deleted'] = 1;
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".$LANG[__('trackingDeleted'][31])."</a></td>";
echo "<td class='numeric'>".$status["assign"]number_deleted."</td></tr>";
 
$options['contains'][0] = 'plan';
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".$LANG['tracking'][32]."</a></td>";
echo "<td>".$status["plan"]."</td></tr>";
 
$options['contains'][0] = 'waiting';
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".$LANG['joblist'][26]."</a></td>";
echo "<td>".$status["waiting"]."</td></tr>";
 
$options['contains'][0] = 'solved';
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".$LANG['job'][15]."</a></td>";
echo "<td>".$status["solved"]."</td></tr>";
 
$options['contains'][0] = 'closed';
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".$LANG['joblist'][33]."</a></td>";
echo "<td>".$status["closed"]."</td></tr>";
 
$options['contains'][0] = 'all';
$options['is_deleted'] = 1;
echo "<tr class='tab_bg_2'>";
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."\">".$LANG['common'][28]."</a></td>";
echo "<td>".$number_deleted."</td></tr>";
 
echo "</table><br>";
Linha 5 718 ⟶ 5 068:
 
static function showCentralNewList() {
global $DB, $CFG_GLPI, $LANG;
 
if (!Session::haveRight("show_all_ticket"self::$rightname,"1" self::READALL)) {
return false;
}
Linha 5 726 ⟶ 5 076:
$query = "SELECT ".self::getCommonSelect()."
FROM `glpi_tickets` ".self::getCommonLeftJoin()."
WHERE `status` = 'new".self::INCOMING."' ".
getEntitiesRestrictRequest("AND","glpi_tickets")."
AND NOT `is_deleted`
ORDER BY `glpi_tickets`.`date_mod` DESC
LIMIT ".intval($_SESSION['glpilist_limit']);
 
$result = $DB->query($query);
$number = $DB->numrows($result);
Linha 5 736 ⟶ 5 087:
if ($number > 0) {
Session::initNavigateListItems('Ticket');
$options['criteria'][0]['field'] = 12;
 
$options['fieldcriteria'][0] ['searchtype'] = 12'equals';
$options['searchtypecriteria'][0]['value'] = 'equals'self::INCOMING;
$options['containscriteria'][0]['link'] = 'newAND';
$options['link'][0] = 'AND';
$options['reset'] ='reset';
 
echo "<div class='center'><table class='tab_cadre_fixe'>";
//TRANS: %d is the number of new tickets
echo "<tr><th colspan='10'>".$LANG['central'][10]." ($number)&nbsp;: &nbsp;";
echo "<tr><th colspan='12'>".sprintf(_n('%d new ticket','%d new tickets', $number), $number);
echo "<a href='".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."'>".$LANG[__('buttonsShow all'][40])."</a>";
echo "</th></tr>";
 
self::commonListHeader(Search::HTML_OUTPUT);
 
while ($data = $DB->fetch_assoc($result)) {
Session::addToNavigateListItems('Ticket',$data["id"]);
self::showShort($data["id"], 0);
}
echo "</table></div>";
Linha 5 760 ⟶ 5 111:
echo "<div class='center'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>".$LANG[__('joblistNo ticket found.'][8])."</th></tr>";
echo "</table>";
echo "</div><br>";
}
}
 
 
static function commonListHeader($output_type=HTML_OUTPUT) {
global $LANG;
 
// New Line for Header Items Line
echo Search::showNewLine($output_type);
// $show_sort if
$header_num = 1;
 
$items = array();
 
$items[$LANG['joblist'][0]] = "glpi_tickets.status";
$items[$LANG['common'][27]] = "glpi_tickets.date";
$items[$LANG['common'][26]] = "glpi_tickets.date_mod";
 
if (count($_SESSION["glpiactiveentities"])>1) {
$items[$LANG['Menu'][37]] = "glpi_entities.completename";
}
 
$items[$LANG['joblist'][2]] = "glpi_tickets.priority";
$items[$LANG['job'][4]] = "glpi_tickets.users_id";
$items[$LANG['joblist'][4]] = "glpi_tickets.users_id_assign";
$items[$LANG['document'][14]] = "glpi_tickets.itemtype, glpi_tickets.items_id";
$items[$LANG['common'][36]] = "glpi_itilcategories.completename";
$items[$LANG['common'][57]] = "glpi_tickets.name";
 
foreach ($items as $key => $val) {
$issort = 0;
$link = "";
echo Search::showHeaderItem($output_type,$key,$header_num,$link);
}
 
// End Line for column headers
echo Search::showEndLine($output_type);
}
 
 
/**
Linha 5 813 ⟶ 5 127:
**/
static function showListForItem(CommonDBTM $item) {
global $DB, $CFG_GLPI, $LANG;
 
if (!Session::haveRighthaveRightsOr("show_all_ticket"self::$rightname,"1")) {
array(self::READALL, self::READMY, self::READASSIGN, CREATE))) {
return false;
}
Linha 5 829 ⟶ 5 144:
switch ($item->getType()) {
case 'User' :
$restrict = "(`glpi_tickets_users`.`users_id` = '".$item->getID()."' ".
" AND `glpi_tickets_users`.`type` = ".parentCommonITILActor::REQUESTER.")";
$order = '`glpi_tickets`.`date_mod` DESC';
 
$options['reset'] = 'reset';
$options['fieldreset'][0] = 4'reset'; // status
 
$options['searchtype'][0] = 'equals';
$options['containscriteria'][0]['field'] = $item->getID()4; // status
$options['linkcriteria'][0] ['searchtype'] = 'ANDequals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
 
case 'SLA' :
$restrict = "(`slas_id` = '".$item->getID()."')";
$order = '`glpi_tickets`.`due_date` DESC';
 
$options['field'][0] = 30;
$options['searchtypecriteria'][0]['field'] = 'equals'30;
$options['containscriteria'][0] ['searchtype'] = $item->getID()'equals';
$options['linkcriteria'][0] ['value'] = 'AND'$item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
 
case 'Supplier' :
$restrict = "(`suppliers_id_assignglpi_suppliers_tickets`.`suppliers_id` = '".$item->getID()."') ";.
$order " AND = '`glpi_ticketsglpi_suppliers_tickets`.`date_modtype` DESC'= ".CommonITILActor::ASSIGN.")";
$options['field'][0]order = '`glpi_tickets`.`date_mod` = 6DESC';
 
$options['searchtype'][0] = 'equals';
$options['containscriteria'][0]['field'] = $item->getID()6;
$options['linkcriteria'][0] ['searchtype'] = 'ANDequals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
 
Linha 5 862 ⟶ 5 182:
$tree = Session::getSavedOption(__CLASS__, 'tree', 0);
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>".$LANG[__('jobLast tickets'][8])."</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
echo $LANG[__('groupChild groups'][3])."&nbsp;:&nbsp;";
Dropdown::showYesNo('tree', $tree, -1,
array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
Linha 5 877 ⟶ 5 197:
$restrict = "='".$item->getID()."'";
}
$restrict = "(`glpi_groups_tickets`.`groups_id` $restrict".
" AND `glpi_groups_tickets`.`type` = ".TicketCommonITILActor::REQUESTER.")";
$order = '`glpi_tickets`.`date_mod` DESC';
 
$options['field'][0] = 71;
$options['searchtypecriteria'][0]['field'] = ($tree ? 'under' : 'equals')= 71;
$options['containscriteria'][0] ['searchtype'] = $item->getID($tree ? 'under' : 'equals');
$options['linkcriteria'][0] ['value'] = 'AND'$item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
 
default :
$restrict = "(`items_id` = '".$item->getID()."' ".
" AND `itemtype` = '".$item->getType()."')";
$order = '`glpi_tickets`.`date_mod` DESC';
 
$options['field'][0]// you can only see your = 12;tickets
if (!Session::haveRight(self::$rightname, self::READALL)) {
$options['searchtype'][0] = 'equals';
$restrict .= " AND (`glpi_tickets`.`users_id_recipient` = '".Session::getLoginUserID()."'
$options['contains'][0] = 'all';
OR (`glpi_tickets_users`.`tickets_id` = '".$item->getID()."'
$options['link'][0] = 'AND';
AND `glpi_tickets_users`.`users_id`
= '".Session::getLoginUserID()."'))";
}
$order = '`glpi_tickets`.`date_mod` DESC';
 
$options['criteria'][0]['field'] = 12;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = 'all';
$options['criteria'][0]['link'] = 'AND';
 
$options['itemtype2metacriteria'][0]['itemtype'] = $item->getType();
$options['field2metacriteria'][0]['field'] = Search::getOptionNumber($item->getType(), 'id');
'id');
$options['searchtype2'][0] = 'equals';
$options['contains2metacriteria'][0] ['searchtype'] = $item->getID()'equals';
$options['link2metacriteria'][0] ['value'] = 'AND'$item->getID();
$options['metacriteria'][0]['link'] = 'AND';
break;
}
Linha 5 912 ⟶ 5 243:
$result = $DB->query($query);
$number = $DB->numrows($result);
 
 
$colspan = 11;
if (count($_SESSION["glpiactiveentities"]) > 1) {
$colspan++;
}
 
// Ticket for the item
echo "<div class='firstbloc'><table class='tab_cadre_fixe'>";
// Link to open a new ticket
if ($item->getID()
&& Ticket::isPossibleToAssignType($item->getType())
&& self::canCreate()) {
Html::showSimpleForm($CFG_GLPI["root_doc"]."/front/ticket.form.php",
'_add_fromitem', __('New ticket for this item...'),
array('itemtype' => $item->getType(),
'items_id' => $item->getID()));
}
echo "</div><div>";
echo "<table class='tab_cadre_fixehov'>";
 
if ($number > 0) {
if (Session::initNavigateListItemshaveRight('Ticket'self::$rightname, $item->getTypeName(self::READALL)." = ".$item->getName()); {
Session::initNavigateListItems('Ticket',
//TRANS : %1$s is the itemtype name, %2$s is the name of the item (used for headings of a list)
sprintf(__('%1$s = %2$s'), $item->getTypeName(1),
$item->getName()));
 
echo "<tr class='noHover'><th colspan='10$colspan'>";
if $title = sprintf(_n('Last %d ticket', 'Last %d tickets', $number==1), {$number);
echo$link = "<a href='".$LANGCFG_GLPI['job'][10"root_doc"]."&nbsp;:&nbsp;/front/ticket.php?".$number;
Toolbox::append_params($options,'&amp;')."'>".__('Show all')."</a>";
echo "<span class='small_space'><a href='".$CFG_GLPI["root_doc"]."/front/ticket.php?".
$title = printf(__('%1$s (%2$s)'), $title, $link);
Toolbox::append_params($options,'&amp;')."'>".$LANG['buttons'][40]."</a></span>";
echo "</th></tr>";
} else {
echo "<tr><th colspan='$LANG[colspan'job'][8]>".__("&nbsp;:&nbsp;You don't have right to see all tickets").$number"</th></tr>";
echo "<span class='small_space'><a href='".$CFG_GLPI["root_doc"]."/front/ticket.php?".
Toolbox::append_params($options,'&amp;')."'>".$LANG['buttons'][40]."</a></span>";
}
echo "</th></tr>";
 
} else {
echo "<tr><th>".$LANG[__('joblistNo ticket found.'][8])."</th></tr>";
}
 
// Link to open a new ticket
if ($item->getID()
&& Ticket::isPossibleToAssignType($item->getType() == 'User')
&& Sessionself::haveRightcanCreate('create_ticket', 1)) {
echo "<tr><td class='tab_bg_2 center b' colspan='10$colspan'>";
echo "<a href=\"".Html::showSimpleForm($CFG_GLPI["root_doc"]."/front/ticket.form.php?items_id=".$item->getID().,
'_add_fromitem', __('New ticket for this item...'),
"&amp;itemtype=".$item->getType()."\">".$LANG['joblist'][7]."</a>";
array('_users_id_requester' => $item->getID()));
echo "</td></tr>";
}
if ($item->getID()
&& ( $item->getType() == 'User')
&& Session::haveRight('create_ticket', 1)) {
echo "<tr><td class='tab_bg_2 center b' colspan='10'>";
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/ticket.form.php?_users_id_requester=".
$item->getID()."\">".$LANG['joblist'][7]."</a>";
echo "</td></tr>";
}
Linha 5 955 ⟶ 5 297:
// Ticket list
if ($number > 0) {
self::commonListHeader(Search::HTML_OUTPUT);
 
while ($data = $DB->fetch_assoc($result)) {
Session::addToNavigateListItems('Ticket',$data["id"]);
self::showShort($data["id"], 0);
}
self::commonListHeader(Search::HTML_OUTPUT);
}
 
Linha 5 966 ⟶ 5 309:
 
// Tickets for linked items
if ($subquerylinkeditems = $item->getSelectLinkedItemgetLinkedItems()) {;
$restrict = array();
if (count($linkeditems)) {
foreach ($linkeditems as $ltype => $tab) {
foreach ($tab as $lID) {
$restrict[] = "(`itemtype` = '$ltype' AND `items_id` = '$lID')";
}
}
}
 
if (count($restrict)
&& Session::haveRight(self::$rightname, self::READALL)) {
$query = "SELECT ".self::getCommonSelect()."
FROM `glpi_tickets` ".self::getCommonLeftJoin()."
WHERE ".implode(`itemtype`,`items_id`)' INOR (" .', $subquery . "restrict)".
getEntitiesRestrictRequest(' AND ', 'glpi_tickets') . "
ORDER BY `glpi_tickets`.`date_mod` DESC
Linha 5 977 ⟶ 5 331:
 
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='1012'>";
ifecho _n('Ticket on linked items', 'Tickets on linked items', $number>1) {;
echo $LANG['joblist'][28];
} else {
echo $LANG['joblist'][25];
}
echo "</th></tr>";
if ($number > 0) {
self::commonListHeader(Search::HTML_OUTPUT);
while ($data = $DB->fetch_assoc($result)) {
 
while ($data=$DB->fetch_assoc($result)) {
// Session::addToNavigateListItems(TRACKING_TYPE,$data["id"]);
self::showShort($data["id"], 0);
}
self::commonListHeader(Search::HTML_OUTPUT);
} else {
echo "<tr><th>".$LANG[__('joblistNo ticket found.'][8])."</th></tr>";
}
echo "</table></div>";
Linha 5 999 ⟶ 5 349:
 
}
 
 
/**
* Display@param a line for a ticket$ID
* @param $forcetab string name of the tab to force at the display (default '')
*
**/
* @param $id Integer ID of the ticket
static function showVeryShort($ID, $forcetab='') {
* @param $followups Boolean show followup columns
global $CFG_GLPI;
* @param $output_type Integer type of output
* @param $row_num Integer row number
* @param $id_for_massaction Integer default 0 means no massive action
*
*/
static function showShort($id, $followups, $output_type=HTML_OUTPUT, $row_num=0, $id_for_massaction=0) {
global $CFG_GLPI, $LANG;
 
$rand = mt_rand();
 
/// TODO to be cleaned. Get datas and clean display links
 
// Prints a job in short form
Linha 6 022 ⟶ 5 361:
// Print links or not in case of user view
// Make new job object and fill it from database, if success, print it
$jobshowprivate = new self()false;
if (Session::haveRight('followup', TicketFollowup::SEEPRIVATE)) {
 
$showprivate = true;
$candelete = Session::haveRight("delete_ticket", "1");
$canupdate = Session::haveRight("update_ticket", "1");
$showprivate = Session::haveRight("show_full_ticket", "1");
$align = "class='center";
$align_desc = "class='left";
 
if ($followups) {
$align .= " top'";
$align_desc .= " top'";
} else {
$align .= "'";
$align_desc .= "'";
}
 
if ($job->getFromDB($id)) {
$item_num = 1;
$bgcolor = $_SESSION["glpipriority_".$job->fields["priority"]];
 
echo Search::showNewLine($output_type,$row_num%2);
 
// First column
$first_col = "ID : ".$job->fields["id"];
if ($output_type == HTML_OUTPUT) {
$first_col .= "<br><img src='".$CFG_GLPI["root_doc"]."/pics/".$job->fields["status"].".png'
alt=\"".self::getStatus($job->fields["status"])."\" title=\"".
self::getStatus($job->fields["status"])."\">";
} else {
$first_col .= " - ".self::getStatus($job->fields["status"]);
}
 
if (($candelete || $canupdate)
&& $output_type == HTML_OUTPUT && $id_for_massaction) {
 
$sel = "";
if (isset($_GET["select"]) && $_GET["select"] == "all") {
$sel = "checked";
}
if (isset($_SESSION['glpimassiveactionselected'][$id_for_massaction])) {
$sel = "checked";
}
$first_col .= "&nbsp;<input type='checkbox' name='item[$id_for_massaction]'
value='1' $sel>";
}
 
echo Search::showItem($output_type,$first_col,$item_num,$row_num,$align);
 
// Second column
if ($job->fields['status']=='closed') {
$second_col = $LANG['joblist'][12];
if ($output_type == HTML_OUTPUT) {
$second_col .= "&nbsp;:<br>";
} else {
$second_col .= " : ";
}
$second_col .= Html::convDateTime($job->fields['closedate']);
 
} else if ($job->fields['status']=='solved') {
$second_col = $LANG['joblist'][14];
if ($output_type == HTML_OUTPUT) {
$second_col .= "&nbsp;:<br>";
} else {
$second_col .= " : ";
}
$second_col .= Html::convDateTime($job->fields['solvedate']);
 
} else if ($job->fields['begin_waiting_date']) {
$second_col = $LANG['joblist'][15];
if ($output_type == HTML_OUTPUT) {
$second_col .= "&nbsp;:<br>";
} else {
$second_col .= " : ";
}
$second_col .= Html::convDateTime($job->fields['begin_waiting_date']);
 
} else if ($job->fields['due_date']) {
$second_col = $LANG['sla'][5];
if ($output_type == HTML_OUTPUT) {
$second_col .= "&nbsp;:<br>";
} else {
$second_col .= " : ";
}
$second_col .= Html::convDateTime($job->fields['due_date']);
 
} else {
$second_col = $LANG['joblist'][11];
if ($output_type == HTML_OUTPUT) {
$second_col .= "&nbsp;:<br>";
} else {
$second_col .= " : ";
}
$second_col .= Html::convDateTime($job->fields['date']);
}
 
echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align." width=130");
 
// Second BIS column
$second_col = Html::convDateTime($job->fields["date_mod"]);
echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align." width=90");
 
// Second TER column
if (count($_SESSION["glpiactiveentities"]) > 1) {
if ($job->fields['entities_id'] == 0) {
$second_col = $LANG['entity'][2];
} else {
$second_col = Dropdown::getDropdownName('glpi_entities', $job->fields['entities_id']);
}
echo Search::showItem($output_type, $second_col, $item_num, $row_num,
$align." width=100");
}
 
// Third Column
echo Search::showItem($output_type,
"<span class='b'>".parent::getPriorityName($job->fields["priority"]).
"</span>",
$item_num, $row_num, "$align bgcolor='$bgcolor'");
 
// Fourth Column
$fourth_col = "";
 
if (isset($job->users[parent::REQUESTER]) && count($job->users[parent::REQUESTER])) {
foreach ($job->users[parent::REQUESTER] as $d) {
$userdata = getUserName($d["users_id"],2);
$fourth_col .= "<span class='b'>".$userdata['name']."</span>&nbsp;";
$fourth_col .= Html::showToolTip($userdata["comment"],
array('link' => $userdata["link"],
'display' => false));
$fourth_col .= "<br>";
}
}
 
if (isset($job->groups[parent::REQUESTER]) && count($job->groups[parent::REQUESTER])) {
foreach ($job->groups[parent::REQUESTER] as $d) {
$fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
$fourth_col .= "<br>";
}
}
 
echo Search::showItem($output_type, $fourth_col, $item_num, $row_num, $align);
 
// Fifth column
$fifth_col = "";
 
if (isset($job->users[parent::ASSIGN]) && count($job->users[parent::ASSIGN])) {
foreach ($job->users[parent::ASSIGN] as $d) {
$userdata = getUserName($d["users_id"], 2);
$fifth_col .= "<span class='b'>".$userdata['name']."</span>&nbsp;";
$fifth_col .= Html::showToolTip($userdata["comment"],
array('link' => $userdata["link"],
'display' => false));
$fifth_col .= "<br>";
}
}
 
if (isset($job->groups[parent::ASSIGN]) && count($job->groups[parent::ASSIGN])) {
foreach ($job->groups[parent::ASSIGN] as $d) {
$fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
$fifth_col .= "<br>";
}
}
 
 
if ($job->fields["suppliers_id_assign"]>0) {
if (!empty($fifth_col)) {
$fifth_col .= "<br>";
}
$fifth_col .= parent::getAssignName($job->fields["suppliers_id_assign"], 'Supplier', 1);
}
echo Search::showItem($output_type,$fifth_col,$item_num,$row_num,$align);
 
// Sixth Colum
$sixth_col = "";
$is_deleted = false;
if (!empty($job->fields["itemtype"]) && $job->fields["items_id"]>0) {
if ($item = getItemForItemtype($job->fields["itemtype"])) {
if ($item->getFromDB($job->fields["items_id"])) {
$is_deleted = $item->isDeleted();
 
$sixth_col .= $item->getTypeName();
$sixth_col .= "<br><span class='b'>";
if ($item->canView()) {
$sixth_col .= $item->getLink($output_type==HTML_OUTPUT);
} else {
$sixth_col .= $item->getNameID();
}
$sixth_col .= "</span>";
}
}
 
} else if (empty($job->fields["itemtype"])) {
$sixth_col = $LANG['help'][30];
}
 
echo Search::showItem($output_type, $sixth_col, $item_num, $row_num,
($is_deleted?" class='center deleted' ":$align));
 
// Seventh column
echo Search::showItem($output_type,
"<span class='b'>".
Dropdown::getDropdownName('glpi_itilcategories',
$job->fields["itilcategories_id"]).
"</span>",
$item_num, $row_num, $align);
 
// Eigth column
$eigth_column = "<span class='b'>".$job->fields["name"]."</span>&nbsp;";
 
// Add link
if ($job->canViewItem()) {
$eigth_column = "<a id='ticket".$job->fields["id"]."$rand' href=\"".$CFG_GLPI["root_doc"].
"/front/ticket.form.php?id=".$job->fields["id"]."\">$eigth_column</a>";
 
if ($followups && $output_type == HTML_OUTPUT) {
$eigth_column .= TicketFollowup::showShortForTicket($job->fields["id"]);
} else {
$eigth_column .= "&nbsp;(".$job->numberOfFollowups($showprivate)."-".
$job->numberOfTasks($showprivate).")";
}
}
 
if ($output_type == HTML_OUTPUT) {
$eigth_column .= "&nbsp;".Html::showToolTip($job->fields['content'],
array('display' => false,
'applyto' => "ticket".
$job->fields["id"]. $rand));
}
 
echo Search::showItem($output_type, $eigth_column, $item_num, $row_num,
$align_desc."width='300'");
 
// Finish Line
echo Search::showEndLine($output_type);
 
} else {
echo "<tr class='tab_bg_2'><td colspan='6' ><i>".$LANG['joblist'][16]."</i></td></tr>";
}
}
 
 
static function showVeryShort($ID, $forcetab='') {
global $CFG_GLPI, $LANG;
 
// Prints a job in short form
// Should be called in a <table>-segment
// Print links or not in case of user view
// Make new job object and fill it from database, if success, print it
$viewusers = Session::haveRight("user", "r");
$showprivate = Session::haveRight("show_full_ticket", 1);
 
$job = new self();
$rand = mt_rand();
if ($job->getFromDBwithData($ID, 0)) {
$bgcolor = $_SESSION["glpipriority_".$job->fields["priority"]];
// $rand = mt_rand();
echo "<tr class='tab_bg_2'>";
echo "<td class='center' bgcolor='$bgcolor' >ID : ".sprintf(__('%1$job->fields["id"]."</td>";s: %2$s'), __('ID'),
$job->fields["id"])."</td>";
echo "<td class='center'>";
 
if (isset($job->users[parentCommonITILActor::REQUESTER])
&& count($job->users[parentCommonITILActor::REQUESTER])) {
foreach ($job->users[parentCommonITILActor::REQUESTER] as $d) {
if ($d["users_id"] > 0) {
$userdata = getUserName($d["users_id"],2);
echo$name = "<span class='b'>".$userdata['name']."</span>&nbsp;";
if$name = sprintf(__('%1$viewuserss %2$s'), {$name,
Html::showToolTip($userdata["comment"], array('link' => $userdata["link"]));
array('link' => $userdata["link"],
}
'display' => false)));
echo $name;
} else {
echo $d['alternative_email']."&nbsp;";
Linha 6 297 ⟶ 5 395:
 
 
if (isset($job->groups[parentCommonITILActor::REQUESTER])
&& count($job->groups[parentCommonITILActor::REQUESTER])) {
foreach ($job->groups[parentCommonITILActor::REQUESTER] as $d) {
echo Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
echo "<br>";
Linha 6 306 ⟶ 5 405:
echo "</td>";
 
if ($job->hardwaredatas
&& $job->hardwaredatas->canView()) {
echo "<td class='center";
if ($job->hardwaredatas->isDeleted()) {
Linha 6 321 ⟶ 5 421:
 
} else {
echo "<td class='center' >".$LANG[__('helpGeneral'][30])."</td>";
}
echo "<td>";
 
echo$link = "<a id='ticket".$job->fields["id"].$rand."' href='".$CFG_GLPI["root_doc"].
"/front/ticket.form.php?id=".$job->fields["id"];
if ($forcetab != '') {
echo$link .= "&amp;forcetab=".$forcetab;
}
echo$link .= "'>";
echo$link .= "<span class='b'>".$job->fields["name"]getNameID()."</span></a>&nbsp;";
$link = sprintf(__('%1$s (%2$s)'), $link,
echo "(".$job->numberOfFollowups($showprivate)."-".$job->numberOfTasks($showprivate).
sprintf(__('%1$s - %2$s'), $job->numberOfFollowups($showprivate),
")&nbsp;";
Html::showToolTip( $job->fields['content'],numberOfTasks($showprivate)));
$content = Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($job->fields['content'],
array('applyto' => 'ticket'.$job->fields["id"].$rand));
ENT_QUOTES,
 
"UTF-8"));
$link = printf(__('%1$s %2$s'), $link,
Html::showToolTip(nl2br(Html::Clean($content)),
array('applyto' => 'ticket'.$job->fields["id"].$rand,
'display' => false)));
echo "</td>";
 
Linha 6 342 ⟶ 5 447:
echo "</tr>";
} else {
echo "<tr class='tab_bg_2'>";
echo "<td colspan='6' ><i>".$LANG[__('joblistNo ticket in progress.'][16])."</i></td></tr>";
}
}
Linha 6 357 ⟶ 5 463:
return " DISTINCT `glpi_tickets`.*,
`glpi_itilcategories`.`completename` AS catname
$SELECT";
}
 
Linha 6 373 ⟶ 5 479:
LEFT JOIN `glpi_tickets_users`
ON (`glpi_tickets`.`id` = `glpi_tickets_users`.`tickets_id`)
LEFT JOIN `glpi_suppliers_tickets`
ON (`glpi_tickets`.`id` = `glpi_suppliers_tickets`.`tickets_id`)
LEFT JOIN `glpi_itilcategories`
ON (`glpi_tickets`.`itilcategories_id` = `glpi_itilcategories`.`id`)
LEFT JOIN `glpi_tickettasks`
ON (`glpi_tickets`.`id` = `glpi_tickettasks`.`tickets_id`)
$FROM";
}
 
 
/**
* @param $output
**/
static function showPreviewAssignAction($output) {
global $LANG;
 
//If ticket is assign to an object, display this information first
Linha 6 390 ⟶ 5 502:
if ($item->getFromDB($output["items_id"])) {
echo "<tr class='tab_bg_2'>";
echo "<td>".$LANG[__('rulesengineAssign equipment'][48])."</td>";
 
echo "<td>".$item->getLink(array('comments' => true))."</td>";
echo $item->getLink(true);
echo "</td>";
echo "</tr>";
}
}
 
unset($output["items_id"]);
//Clean output of unnecessary fields (already processed)
unset($output["items_iditemtype"]);
unset($output["itemtype"]);
}
unset($output["entities_id"]);
return $output;
}
 
 
/**
* Give cron informationsinformation
*
* @param $name : task's name
*
* @return arrray of informationsinformation
**/
static function cronInfo($name) {
global $LANG;
 
switch ($name) {
case 'closeticket' :
return array('description' => $LANG[__('crontaskAutomatic tickets closing'][14]));
 
case 'alertnotclosed' :
return array('description' => $LANG[__('crontaskNot solved tickets'][15]));
 
case 'createinquest' :
return array('description' => $LANG[__('crontaskGeneration of satisfaction surveys'][18]));
}
return array();
Linha 6 450 ⟶ 5 559:
FROM `glpi_tickets`
WHERE `entities_id` = '".$entity."'
AND `status` = 'solved".self::SOLVED."'
AND `is_deleted` = 0";
 
if ($delay > 0) {
$query .= " AND ADDDATE(`solvedate`, INTERVAL ".$delay." DAY) < CURDATE()";
}
Linha 6 460 ⟶ 5 569:
foreach ($DB->request($query) as $tick) {
$ticket->update(array('id' => $tick['id'],
'status' => 'closed'self::CLOSED,
'_auto_update' => true));
$nb++;
Linha 6 492 ⟶ 5 601:
// Recherche des entités
$tot = 0;
 
foreach (Entity::getEntitiesToNotify('notclosed_delay') as $entity => $value) {
/* $query = "SELECT `glpi_tickets`.*
FROM `glpi_tickets`
LEFT JOIN `glpi_alerts` ON (`glpi_tickets`.`id` = `glpi_alerts`.`items_id`
AND `glpi_alerts`.`itemtype` = 'Ticket'
AND `glpi_alerts`.`type`='".Alert::NOTCLOSED."')
WHERE `glpi_tickets`.`entities_id` = '".$entity."'
AND `glpi_tickets`.`status` IN ('new','assign','plan','waiting')
AND `glpi_tickets`.`closedate` IS NULL
AND ADDDATE(`glpi_tickets`.`date`, INTERVAL ".$value." DAY) < CURDATE()
AND `glpi_alerts`.`date` IS NULL";*/
$query = "SELECT `glpi_tickets`.*
FROM `glpi_tickets`
WHERE `glpi_tickets`.`entities_id` = '".$entity."'
AND `glpi_tickets`.`is_deleted` = 0
AND `glpi_tickets`.`status` IN ('new".self::INCOMING."','assign','plan','waiting')
'".self::ASSIGNED."',
'".self::PLANNED."',
'".self::WAITING."')
AND `glpi_tickets`.`closedate` IS NULL
AND ADDDATE(`glpi_tickets`.`date`, INTERVAL ".$value." DAY) < CURDATENOW()";
$tickets = array();
foreach ($DB->request($query) as $tick) {
Linha 6 520 ⟶ 5 621:
array('items' => $tickets,
'entities_id' => $entity))) {
// To be clean : do not mark ticket as already send : always send all
// $alert = new Alert();
// $input["itemtype"] = 'Ticket';
// $input["type"] = Alert::NOTCLOSED;
// foreach ($tickets as $ticket) {
// $input["items_id"] = $ticket['id'];
// $alert->add($input);
// unset($alert->fields['id']);
// }
 
// To be clean : do not mark ticket as already send : always send all
// $alert = new Alert();
// $input["itemtype"] = 'Ticket';
// $input["type"] = Alert::NOTCLOSED;
// foreach ($tickets as $ticket) {
// $input["items_id"] = $ticket['id'];
// $alert->add($input);
// unset($alert->fields['id']);
// }
 
$tot += count($tickets);
$task->addVolume(count($tickets));
$task->log(Dropdown::getDropdownNamesprintf(__('glpi_entities', %1$entity)." s: ".count(%2$ticketss'));,
Dropdown::getDropdownName('glpi_entities', $entity),
count($tickets)));
}
}
Linha 6 561 ⟶ 5 645:
global $DB;
 
$conf = new EntitydataEntity();
$inquest = new TicketSatisfaction();
$tot = 0;
$maxentity = array();
$tabentities = array();
 
$rate = EntityDataEntity::getUsedConfig('inquest_config', 0, 'inquest_rate');
if ($rate > 0) {
$tabentities[0] = $rate;
}
 
foreach ($DB->request('glpi_entities') as $entity) {
$rate = EntityDataEntity::getUsedConfig('inquest_config', $entity['id'], 'inquest_rate');
$parent = EntityDataEntity::getUsedConfig('inquest_config', $entity['id'], 'entities_id');
 
if ($rate > 0) {
$tabentities[$entity['id']] = $rate;
}
Linha 6 582 ⟶ 5 666:
 
foreach ($tabentities as $entity => $rate) {
$parent = EntityDataEntity::getUsedConfig('inquest_config', $entity, 'entities_id');
$delay = EntityDataEntity::getUsedConfig('inquest_config', $entity, 'inquest_delay');
$type = EntityDataEntity::getUsedConfig('inquest_config', $entity);
$max_closedate = EntityDataEntity::getUsedConfig('inquest_config', $entity, 'max_closedate');
 
$query = "SELECT `glpi_tickets`.`id`,
Linha 6 595 ⟶ 5 679:
WHERE `glpi_tickets`.`entities_id` = '$entity'
AND `glpi_tickets`.`is_deleted` = 0
AND `glpi_tickets`.`status` = 'closed".self::CLOSED."'
AND `glpi_tickets`.`closedate` > '$max_closedate'
AND ADDDATE(`glpi_tickets`.`closedate`, INTERVAL $delay DAY)<=NOW()
Linha 6 601 ⟶ 5 685:
ORDER BY `closedate` ASC";
 
$nb = 0;
$max_closedate = '';
 
Linha 6 618 ⟶ 5 702:
// conservation de toutes les max_closedate des entites filles
if (!empty($max_closedate)
&& (!isset($maxentity[$parent])
|| ($max_closedate > $maxentity[$parent]))) {
 
$maxentity[$parent] = $max_closedate;
}
Linha 6 626 ⟶ 5 710:
$tot += $nb;
$task->addVolume($nb);
$task->log(Dropdown::getDropdownNamesprintf(__('glpi_entities', %1$entity)." s: %2$nb"s');,
Dropdown::getDropdownName('glpi_entities', $entity), $nb));
}
}
Linha 6 634 ⟶ 5 719:
$conf->getFromDB($parent);
$conf->update(array('id' => $conf->fields['id'],
//'entities_id' => $parent,
'max_closedate' => $maxdate));
}
Linha 6 640 ⟶ 5 725:
return ($tot > 0);
}
 
 
 
 
 
Linha 6 650 ⟶ 5 732:
function showDebug() {
NotificationEvent::debugEvent($this);
}
 
 
/**
* @since version 0.85
*
* @see commonDBTM::getRights()
**/
function getRights($interface='central') {
 
$values = parent::getRights();
unset($values[READ]);
$values[self::READMY] = __('See my ticket');
//TRANS: short for : See tickets created by my groups
$values[self::READGROUP] = array('short' => __('See group ticket'),
'long' => __('See tickets created by my groups'));
if ($interface == 'central') {
$values[self::READALL] = __('See all tickets');
//TRANS: short for : See assigned tickets (group associated)
$values[self::READASSIGN] = array('short' => __('See assigned'),
'long' => __('See assigned tickets'));
//TRANS: short for : Assign a ticket
$values[self::ASSIGN] = array('short' => __('Assign'),
'long' => __('Assign a ticket'));
//TRANS: short for : Steal a ticket
$values[self::STEAL] = array('short' => __('Steal'),
'long' => __('Steal a ticket'));
//TRANS: short for : To be in charge of a ticket
$values[self::OWN] = array('short' => __('Beeing in charge'),
'long' => __('To be in charge of a ticket'));
$values[self::CHANGEPRIORITY] = __('Change the priority');
}
if ($interface == 'helpdesk') {
unset($values[UPDATE], $values[DELETE], $values[PURGE]);
}
return $values;
}
 
 
/**
* Add image pasted to GLPI doc after ADD and before UPDATE of the item in the database
*
* @since version 0.85
*
* @return nothing
**/
function addImagePaste() {
 
if (count($this->input['_stock_image']) > 0) {
$count_files = 0;
// Filename
if (isset($this->input['_filename'])) {
$count_files = count($this->input['_stock_image']);
foreach($this->input['_filename'] as $key => $filename){
$this->input['_filename'][$count_files] = $filename;
$count_files++;
}
$count_files = count($this->input['_stock_image']);
foreach($this->input['_tag_filename'] as $key => $tag){
$this->input['_tag'][$count_files] = $tag;
$count_files++;
}
unset($this->input['_tag_filename']);
}
 
// Stock_image
foreach ($this->input['_stock_image'] as $key => $filename) {
$this->input['_filename'][$key] = $filename;
}
unset($this->input['_stock_image']);
foreach($this->input['_tag_stock_image'] as $key => $tag){
$this->input['_tag'][$key] = $tag;
$count_files++;
}
unset($this->input['_tag_stock_image']);
 
ksort($this->input['_filename']);
ksort($this->input['_tag']);
 
// $this->input['_forcenotif'] = 1;
}
 
}
 
 
/**
* Convert tag to image
*
* @since version 0.85
*
* @param $content_text text content of input
* @param $force_update force update of content in item (false by default
* @param $doc_data array of filenames and tags
*
* @return nothing
**/
function convertTagToImage($content_text, $force_update=false, $doc_data=array()) {
global $CFG_GLPI;
 
$matches = array();
 
// If no doc data available we match all tags in content
if (!count($doc_data)) {
$doc = new Document();
preg_match_all('/'.Document::getImageTag('(([a-z0-9]+|[\.\-]?)+)').'/', $content_text,
$matches, PREG_PATTERN_ORDER);
if (isset($matches[1]) && count($matches[1])) {
$doc_data = $doc->find("`tag` IN('".implode("','", array_unique($matches[1]))."')");
}
}
 
if (count($doc_data)) {
foreach ($doc_data as $id => $image) {
// Add only image files : try to detect mime type
$ok = false;
$mime = '';
if (isset($image['filepath'])) {
$fullpath = GLPI_DOC_DIR."/".$image['filepath'];
if (function_exists('finfo_open')
&& ($finfo = finfo_open(FILEINFO_MIME))) {
$mime = finfo_file($finfo, $fullpath);
finfo_close($finfo);
 
} else if (function_exists('mime_content_type')) {
$mime = mime_content_type($fullpath);
}
switch (substr($mime, 0, strrpos($mime, ';'))) {
case 'image/gif':case 'image/jpg':case 'image/jpeg':case 'image/png' :
$ok = true;
break;
}
}
if (isset($image['tag'])
&& ($ok || empty($mime))) {
// Replace tags by image in textarea
$img = "<img alt='".$image['tag']."' src='".$CFG_GLPI['root_doc'].
"/front/document.send.php?docid=".$id."&tickets_id=".$this->fields['id']."'/>";
 
// Replace tag by the image
$content_text = preg_replace('/'.Document::getImageTag($image['tag']).'/',
Html::entities_deep($img), $content_text);
 
// Replace <br> TinyMce bug
$content_text = str_replace(array('&gt;rn&lt;','&gt;\r\n&lt;','&gt;\r&lt;','&gt;\n&lt;'),
'&gt;&lt;', $content_text);
 
// If the tag is from another ticket : link document to ticket
/// TODO : comment maybe not used
// if($image['tickets_id'] != $this->fields['id']){
// $docitem = new Document_Item();
// $docitem->add(array('documents_id' => $image['id'],
// '_do_notif' => false,
// '_disablenotif' => true,
// 'itemtype' => $this->getType(),
// 'items_id' => $this->fields['id']));
// }
 
} else {
// Remove tag
$content_text = preg_replace('/'.Document::getImageTag($image['tag']).'/',
'', $content_text);
}
}
}
 
if ($force_update) {
$this->fields['content'] = $content_text;
$this->updateInDB(array('content'));
}
 
return $content_text;
}
 
 
/**
* Convert image to tag
*
* @since version 0.85
*
* @param $content_html html content of input
* @param $force_update force update of content in item (false by default
*
* @return htlm content
**/
function convertImageToTag($content_html, $force_update=false) {
 
$html = str_replace('&', '&amp;', $content_html);
if (!empty($html)) {
// We parse HTML with dom
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
 
// We replace each html element by its tag
$htmlTags = array('img', 'object');
foreach ($htmlTags as $htmlTag) {
$nodes = $dom->getElementsByTagName($htmlTag);
$nodeListLength = $nodes->length;
// If config display image
for ($i = 0; $i < $nodeListLength; $i ++) {
$node = $nodes->item(0);
if ($node->getAttribute('alt')) {
$tag = $dom->createTextNode(Document::getImageTag($node->getAttribute('alt')));
}
$p = $dom->createElement('p');
$p->appendChild($tag);
$node->parentNode->replaceChild($p, $node);
}
}
 
// Get only body content
$doc = new DOMDocument();
$body = $dom->getElementsByTagName('body')->item(0);
foreach ($body->childNodes as $child)
$doc->appendChild($doc->importNode($child, true));
 
if ($force_update) {
$this->fields['content'] = utf8_decode(Html::entity_decode_deep($doc->saveHTML()));
$this->updateInDB(array('content'));
}
 
return utf8_decode(Html::entity_decode_deep($doc->saveHTML()));
}
}
 
 
/**
* Convert img of the collector for ticket
*
* @since version 0.85
*
* @param $content_html html content of input
* @param $files array of filename
* @param $tags array of image tag
*
* @return htlm content
**/
static function convertContentForTicket($content_html, $files, $tags) {
 
// We inject another meta tag
$contentType = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
$html = str_replace('<head>', '<head>'.$contentType, Html::entity_decode_deep($content_html));
 
// We parse HTML with dom
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
 
// We replace each img by a compatible tag for tickets
$nodes = $dom->getElementsByTagName('img');
$nodeListLength = $nodes->length;
// If config display image
for ($i = 0; $i < $nodeListLength; $i ++) {
$node = $nodes->item(0);
$src = $node->getAttribute('src');
foreach ($files as $id => $data) {
if (preg_match("/".$data."/i", $src)) {
$p = $dom->createElement('p');
$tag = $dom->createTextNode(Document::getImageTag($tags[$id]));
$p->appendChild($tag);
 
$node->parentNode->replaceChild($p, $node);
}
}
}
 
// Get only body content
$doc = new DOMDocument();
$body = $dom->getElementsByTagName('body')->item(0);
foreach ($body->childNodes as $child)
$doc->appendChild($doc->importNode($child, true));
 
return Html::entity_decode_deep($doc->saveHTML());
}
 
 
/**
* Convert img or tag of ticket for notification mails
*
* @since version 0.85
*
* @param $content : html content of input
* @param $item : item to store filenames and tags found for each image in $content
*
* @return htlm content
**/
function convertContentForNotification($content, $item) {
global $CFG_GLPI, $DB;
 
$tag = '';
$html = str_replace(array('&','&amp;nbsp;'), array('&amp;',' '),
html_entity_decode($content, ENT_QUOTES, "ISO-8859-1"));
 
// If is html content
if ($CFG_GLPI["use_rich_text"]) {
// We parse HTML with dom
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
 
// We replace each img by compatible embeded img for mail
$nodes = $dom->getElementsByTagName('img');
$nodeListLength = $nodes->length;
// If config display image
for ($i = 0; $i < $nodeListLength; $i++) {
$node = $nodes->item($i);
if ($node->getAttribute('alt')) {
$tag = Document::getImageTag($node->getAttribute('alt'));
$img = $dom->createElement('img');
$img->setAttribute('src', 'cid:'.$tag);
 
$node->parentNode->replaceChild($img, $node);
}
}
 
$content = $dom->saveHTML();
// If is text content
} else {
$doc = new Document();
$doc_data = array();
 
preg_match_all('/'.Document::getImageTag('(([a-z0-9]+|[\.\-]?)+)').'/', $content,
$matches, PREG_PATTERN_ORDER);
if (isset($matches[1]) && count($matches[1])) {
$doc_data = $doc->find("tag IN('".implode("','", array_unique($matches[1]))."')");
}
 
if (count($doc_data)) {
foreach ($doc_data as $image) {
// Replace tags by image in textarea
$img = "<img src='cid:".Document::getImageTag($image['tag'])."'/>";
 
// Replace tag by the image
$content = preg_replace('/'.Document::getImageTag($image['tag']).'/', $img,
$content);
}
}
}
 
// Get all attached documents of ticket
$query = "SELECT `glpi_documents_items`.`id` AS assocID,
`glpi_entities`.`id` AS entity,
`glpi_documents`.`name` AS assocName,
`glpi_documents`.*
FROM `glpi_documents_items`
LEFT JOIN `glpi_documents`
ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)
LEFT JOIN `glpi_entities`
ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)
WHERE `glpi_documents_items`.`items_id` = '".$item->fields['id']."'
AND `glpi_documents_items`.`itemtype` = '".$item->getType()."' ";
 
$query .= getEntitiesRestrictRequest(" AND","glpi_documents",'','',true);
$result = $DB->query($query);
 
if ($DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
if (!empty($data['id'])) {
// Image document
if (!empty($data['tag'])) {
$item->documents[] = $data['id'];
// Other document
} else if ($CFG_GLPI['attach_ticket_documents_to_mail']) {
$item->documents[] = $data['id'];
}
}
}
}
 
return $content;
}
 
 
/**
* Delete tag or image from ticket content
*
* @since version 0.85
*
* @param $content html content of input
* @param $tags
*
* @return htlm content
**/
function cleanTagOrImage($content, $tags){
global $CFG_GLPI;
 
// RICH TEXT : delete img tag
if ($CFG_GLPI["use_rich_text"]) {
$html = str_replace(array('&','&amp;nbsp;'), array('&amp;',' '),
html_entity_decode($content, ENT_QUOTES, "ISO-8859-1"));
 
// We parse HTML with dom
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->loadHTML('<html>'.$html.'</html>');
$dom->preserveWhiteSpace = false;
 
// We replace each <img> by a <p>
$nodes = $dom->getElementsByTagName('img');
$nodeListLength = $nodes->length;
 
$nodesToDelete = array();
for ($i=0 ; $i<$nodeListLength ; $i++) {
$node = $nodes->item($i);
if ($id = $node->getAttribute('alt')) {
foreach ($tags as $tag) {
if (preg_match("/".$tag."/i", $id)) {
$nodesToDelete[] = $node;
}
}
}
}
 
foreach($nodesToDelete as $node){
$p = $dom->createElement('p');
$node->parentNode->replaceChild($p, $node);
}
 
// Get only body content
$doc = new DOMDocument();
$body = $dom->getElementsByTagName('body')->item(0);
foreach ($body->childNodes as $child)
$doc->appendChild($doc->importNode($child, true));
 
return utf8_decode(Html::entity_decode_deep($doc->saveHTML()));
 
// SIMPLE TEXT : delete tag
} else {
foreach ($tags as $tag) {
$content = preg_replace('/'.Document::getImageTag($tag).'/', '\r\n', $content);
}
 
return $content;
}
}
 
 
/**
* Convert rich text content to simple text content
*
* @since version 0.85
*
* @param $content : content to convert in html
*
* @return $content
**/
function setSimpleTextContent($content) {
 
$content = Html::entity_decode_deep($content);
 
// If is html content
if ($content != strip_tags($content)) {
$content = Html::clean($this->convertImageToTag($content));
}
 
return $content;
}
 
 
/**
* Convert simple text content to rich text content, init html editor
*
* @since version 0.85
*
* @param $name name of textarea
* @param $content content to convert in html
* @param $rand
*
* @return $content
**/
function setRichTextContent($name, $content, $rand) {
 
$content = Html::entity_decode_deep($content);
 
// Init html editor
Html::initEditorSystem($name, $rand);
 
// If no html
if ($content == strip_tags($content)) {
$content = $this->convertTagToImage($content);
}
 
// If content does not contain <br> or <p> html tag, use nl2br
$content = Html::entity_decode_deep($content);
if (!preg_match("/<br\s?\/?>/", $content) && !preg_match("/<p>/", $content)) {
$content = nl2br($content);
}
 
return $content;
}