本文整理汇总了PHP中TicketValidation::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP TicketValidation::getStatus方法的具体用法?PHP TicketValidation::getStatus怎么用?PHP TicketValidation::getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TicketValidation
的用法示例。
在下文中一共展示了TicketValidation::getStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: geTimelineItems
//.........这里部分代码省略.........
if (!Session::haveRight("ticket", TicketFollowup::SEEPRIVATE)) {
$restrict_fup = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!Session::haveRight("ticket", TicketTask::SEEPRIVATE)) {
$restrict_task = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!$showpublic) {
$restrict = " AND 1 = 0";
}
//add ticket followups to timeline
$followups = $followup_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_fup}", 'date DESC');
foreach ($followups as $followups_id => $followup) {
$followup_obj->getFromDB($followups_id);
$can_edit = $followup_obj->canUpdateItem();
$followup['can_edit'] = $can_edit;
$timeline[$followup['date'] . "_followup_" . $followups_id] = array('type' => 'TicketFollowup', 'item' => $followup);
}
//add ticket tasks to timeline
$tasks = $task_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_task}", 'date DESC');
foreach ($tasks as $tasks_id => $task) {
$task_obj->getFromDB($tasks_id);
$can_edit = $task_obj->canUpdateItem();
$task['can_edit'] = $can_edit;
$timeline[$task['date'] . "_task_" . $tasks_id] = array('type' => 'TicketTask', 'item' => $task);
}
//add ticket documents to timeline
$document_obj = new Document();
$document_items = $document_item_obj->find("itemtype = 'Ticket' AND items_id = " . $ticket->getID());
foreach ($document_items as $document_item) {
$document_obj->getFromDB($document_item['documents_id']);
$timeline[$document_obj->fields['date_mod'] . "_document_" . $document_item['documents_id']] = array('type' => 'Document_Item', 'item' => $document_obj->fields);
}
//add assign changes
/*$log_obj = new Log;
$gassign_items = $log_obj->find("itemtype = 'Ticket' AND items_id = ".$ticket->getID()."
AND itemtype_link = 'Group' AND linked_action = '15'");
foreach ($gassign_items as $logs_id => $gassign) {
//find group
$group_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['new_value']);
$groups = $group->find("name = '$group_name'");
$first_group = array_shift($groups);
$group->getFromDB($first_group['id']);
$content = __("Assigned to")." : ".
"<img src='".$CFG_GLPI['root_doc']."/plugins/talk/pics/group.png' class='group_assign' />".
" <strong>".$group->getLink()."</strong>";
//find user
$user_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['user_name']);
$users = $user->find("CONCAT(firstname, ' ', realname) = '$user_name'");
$first_user = array_shift($users);
if ($first_user == NULL) {
$first_user['id'] = false;
}
$timeline[$gassign['date_mod']."_assign_".$logs_id] = array('type' => 'Assign',
'item' => array(
'date' => $gassign['date_mod'],
'content' => $content,
'can_edit' => false,
'users_id' => $first_user['id']
));
}*/
//add existing solution
if (!empty($ticket->fields['solution'])) {
$users_id = 0;
$solution_date = $ticket->fields['solvedate'];
//search date and user of last solution in glpi_logs
if ($res_solution = $DB->query("SELECT date_mod AS solution_date, user_name FROM glpi_logs\n WHERE itemtype = 'Ticket' \n AND items_id = " . $ticket->getID() . "\n AND id_search_option = 24\n ORDER BY id DESC\n LIMIT 1")) {
$data_solution = $DB->fetch_assoc($res_solution);
if (!empty($data_solution['solution_date'])) {
$solution_date = $data_solution['solution_date'];
}
// find user
if (!empty($data_solution['user_name'])) {
$users_id = addslashes(trim(preg_replace("/.*\\(([0-9]+)\\)/", "\$1", $data_solution['user_name'])));
}
}
// fix trouble with html_entity_decode who skip accented characters (on windows browser)
$solution_content = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $ticket->fields['solution']);
$timeline[$solution_date . "_solution"] = array('type' => 'Solution', 'item' => array('id' => 0, 'content' => Html::clean(html_entity_decode($solution_content)), 'date' => $solution_date, 'users_id' => $users_id, 'solutiontypes_id' => $ticket->fields['solutiontypes_id'], 'can_edit' => Ticket::canUpdate() && $ticket->canSolve()));
}
// add ticket validation to timeline
if ($ticket->fields['type'] == Ticket::DEMAND_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST) || Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) || $ticket->fields['type'] == Ticket::INCIDENT_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT))) {
$ticket_validations = $ticket_valitation_obj->find('tickets_id = ' . $ticket->getID());
foreach ($ticket_validations as $validations_id => $validation) {
$canedit = $ticket_valitation_obj->can($validations_id, UPDATE);
$user->getFromDB($validation['users_id_validate']);
$timeline[$validation['submission_date'] . "_validation_" . $validations_id] = array('type' => 'TicketValidation', 'item' => array('id' => $validations_id, 'date' => $validation['submission_date'], 'content' => __('Validation request') . " => " . $user->getlink() . "<br>" . $validation['comment_submission'], 'users_id' => $validation['users_id'], 'can_edit' => $canedit));
if (!empty($validation['validation_date'])) {
$timeline[$validation['validation_date'] . "_validation_" . $validations_id] = array('type' => 'TicketValidation', 'item' => array('id' => $validations_id, 'date' => $validation['validation_date'], 'content' => __('Validation request answer') . " : " . _sx('status', ucfirst(TicketValidation::getStatus($validation['status']))) . "<br>" . $validation['comment_validation'], 'users_id' => $validation['users_id_validate'], 'status' => "status_" . $validation['status'], 'can_edit' => $canedit));
}
}
}
//reverse sort timeline items by key (date)
krsort($timeline);
return $timeline;
}
示例2: pdfForTicket
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
{
global $CFG_GLPI, $DB;
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Approvals for the ticket') . "</b>");
if (!Session::haveRight('validate_request', 1) && !Session::haveRight('validate_incident', 1) && !Session::haveRight('create_incident_validation', 1) && !Session::haveRight('create_request_validation', 1)) {
return false;
}
$ID = $ticket->getField('id');
$query = "SELECT *\n FROM `glpi_ticketvalidations`\n WHERE `tickets_id` = '" . $ticket->getField('id') . "'\n ORDER BY submission_date DESC";
$result = $DB->query($query);
$number = $DB->numrows($result);
if ($number) {
$pdf->setColumnsSize(20, 19, 21, 19, 21);
$pdf->displayTitle(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Approval date'), __('Approver'));
while ($row = $DB->fetch_assoc($result)) {
$pdf->setColumnsSize(20, 19, 21, 19, 21);
$pdf->displayLine(TicketValidation::getStatus($row['status']), Html::convDateTime($row["submission_date"]), getUserName($row["users_id"]), Html::convDateTime($row["validation_date"]), getUserName($row["users_id_validate"]));
$tmp = trim($row["comment_submission"]);
$pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Request comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
if ($row["validation_date"]) {
$tmp = trim($row["comment_validation"]);
$pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Approval comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
}
}
} else {
$pdf->displayLine(__('No item found'));
}
$pdf->displaySpace();
}
示例3: showForm
//.........这里部分代码省略.........
echo "</td></tr>";
if ($ID) {
switch ($this->fields["status"]) {
case 'closed':
echo "<tr>";
echo "<td><span class='tracking_small'>" . $LANG['joblist'][12] . " : </span></td>";
echo "<td>";
showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false, $canupdate);
echo "</td></tr>";
break;
case 'solved':
echo "<tr>";
echo "<td><span class='tracking_small'>" . $LANG['joblist'][14] . " : </span></td>";
echo "<td>";
showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false, $canupdate);
echo "</td></tr>";
break;
}
}
echo "</table>";
echo "</th></tr>";
echo "</table>";
if (!$ID) {
$this->showActorsPartForm($ID, $options);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th width='10%'>" . $LANG['joblist'][0] . " : </th>";
echo "<td width='40%'>";
if ($canupdate) {
self::dropdownStatus("status", $this->fields["status"], 2);
// Allowed status
} else {
echo self::getStatus($this->fields["status"]);
}
echo "</td>";
echo "<th>" . $LANG['common'][17] . " : </th>";
echo "<td >";
// Permit to set type when creating ticket without update right
if ($canupdate || !$ID) {
self::dropdownType('type', $this->fields["type"]);
} else {
echo self::getTicketTypeName($this->fields["type"]);
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<th>" . $LANG['joblist'][29] . " : </th>";
echo "<td>";
if ($canupdate && $canpriority || !$ID || $canupdate_descr) {
// Only change during creation OR when allowed to change priority OR when user is the creator
$idurgency = self::dropdownUrgency("urgency", $this->fields["urgency"]);
} else {
$idurgency = "value_urgency" . mt_rand();
echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>";
echo self::getUrgencyName($this->fields["urgency"]);
}
echo "</td>";
echo "<th>" . $LANG['common'][36] . " : </th>";
echo "<td >";
// Permit to set category when creating ticket without update right
if ($canupdate || !$ID || $canupdate_descr) {
$opt = array('value' => $this->fields["ticketcategories_id"], 'entity' => $this->fields["entities_id"]);
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
$opt['condition'] = '`is_helpdeskvisible`=1';
}
示例4: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
$datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']);
$datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item);
$datas['##ticket.content##'] = $datas['##ticket.description##'];
// Specific datas
$datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1");
$datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation'));
$datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type'));
$datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id'));
$autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER);
$datas['##ticket.autoclose##'] = __('Never');
$datas['##lang.ticket.autoclosewarning##'] = "";
if ($autoclose_value > 0) {
$datas['##ticket.autoclose##'] = $autoclose_value;
$datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value);
}
$datas['##ticket.sla##'] = '';
if ($item->getField('slas_id')) {
$datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
}
$datas['##ticket.location##'] = '';
if ($item->getField('locations_id')) {
$datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id'));
}
// is ticket deleted
$datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
//Tags associated with the object linked to the ticket
$datas['##ticket.itemtype##'] = '';
$datas['##ticket.item.name##'] = '';
$datas['##ticket.item.serial##'] = '';
$datas['##ticket.item.otherserial##'] = '';
$datas['##ticket.item.location##'] = '';
$datas['##ticket.item.contact##'] = '';
$datas['##ticket.item.contactnumber##'] = '';
$datas['##ticket.item.user##'] = '';
$datas['##ticket.item.group##'] = '';
$datas['##ticket.item.model##'] = '';
$item_ticket = new Item_Ticket();
$items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'");
$datas['items'] = array();
if (count($items)) {
foreach ($items as $val) {
if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) {
$tmp = array();
//Object type
$tmp['##ticket.itemtype##'] = $hardware->getTypeName();
//Object name
$tmp['##ticket.item.name##'] = $hardware->getField('name');
//Object serial
if ($hardware->isField('serial')) {
$tmp['##ticket.item.serial##'] = $hardware->getField('serial');
}
//Object contact
if ($hardware->isField('contact')) {
$tmp['##ticket.item.contact##'] = $hardware->getField('contact');
}
//Object contact num
if ($hardware->isField('contact_num')) {
$tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num');
}
//Object otherserial
if ($hardware->isField('otherserial')) {
$tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial');
}
//Object location
if ($hardware->isField('locations_id')) {
$tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id'));
}
//Object user
if ($hardware->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($hardware->getField('users_id'))) {
$tmp['##ticket.item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($hardware->getField('groups_id')) {
$tmp['##ticket.item.group##'] = Dropdown::getDropdownName('glpi_groups', $hardware->getField('groups_id'));
}
$modeltable = getSingular($hardware->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($hardware->isField($modelfield)) {
$tmp['##ticket.item.model##'] = Dropdown::getDropdownName($modeltable, $hardware->getField($modelfield));
}
$datas['items'][] = $tmp;
}
}
}
$datas['##ticket.numberofitems##'] = count($datas['items']);
// Get followups, log, validation, satisfaction, linked tickets
if (!$simple) {
// Linked tickets
$linked_tickets = Ticket_Ticket::getLinkedTicketsTo($item->getField('id'));
//.........这里部分代码省略.........
示例5: methodGetTicket
/**
* Get a ticket information, with its followup
* for an authenticated user
*
* @param $params array of options (ticket, id2name)
* @param $protocol the communication protocol used
*
* @return array of hashtable
**/
static function methodGetTicket($params, $protocol)
{
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('ticket' => 'integer,mandatory', 'id2name' => 'bool,optional', 'help' => 'bool,optional');
}
if (!Session::getLoginUserID()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
}
$ticket = new Ticket();
if (!isset($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
}
if (!is_numeric($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket=' . $params['ticket']);
}
if (!$ticket->can($params['ticket'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
$resp = $ticket->fields;
if ($resp['itemtype']) {
$item = getItemForItemtype($resp['itemtype']);
} else {
$item = false;
}
$resp['solution'] = Html::clean(Toolbox::unclean_cross_side_scripting_deep($resp['solution']));
$nextaction = new SlaLevel_Ticket();
if ($ticket->fields['slas_id'] && $nextaction->getFromDBForTicket($ticket->fields['id'])) {
$resp['slalevels_next_id'] = $nextaction->fields['slalevels_id'];
$resp['slalevels_next_date'] = $nextaction->fields['date'];
} else {
$resp['slalevels_next_id'] = 0;
$resp['slalevels_next_date'] = '';
}
if (isset($params['id2name'])) {
$resp['users_name_recipient'] = Html::clean(getUserName($ticket->fields['users_id_recipient']));
$resp['users_name_lastupdater'] = Html::clean(getUserName($ticket->fields['users_id_lastupdater']));
$resp['ticketcategories_name'] = Html::clean(Dropdown::getDropdownName('glpi_itilcategories', $ticket->fields['itilcategories_id']));
$resp['entities_name'] = Html::clean(Dropdown::getDropdownName('glpi_entities', $resp['entities_id']));
$resp['status_name'] = Html::clean($ticket->getStatus($resp['status']));
$resp['requesttypes_name'] = Html::clean(Dropdown::getDropdownName('glpi_requesttypes', $resp['requesttypes_id']));
$resp['solutiontypes_name'] = Html::clean(Dropdown::getDropdownName('glpi_solutiontypes', $resp['solutiontypes_id']));
$resp['slas_name'] = Html::clean(Dropdown::getDropdownName('glpi_slas', $resp['slas_id']));
$resp['slalevels_name'] = Html::clean(Dropdown::getDropdownName('glpi_slalevels', $resp['slalevels_id']));
$resp['slalevels_next_name'] = Html::clean(Dropdown::getDropdownName('glpi_slalevels', $resp['slalevels_next_id']));
$resp['urgency_name'] = Ticket::getUrgencyName($resp['urgency']);
$resp['impact_name'] = Ticket::getImpactName($resp['impact']);
$resp['priority_name'] = Ticket::getPriorityName($resp['priority']);
$resp['type_name'] = Ticket::getTicketTypeName($resp['type']);
$resp['global_validation_name'] = TicketValidation::getStatus($resp['global_validation']);
$resp['locations_name'] = Html::clean(Dropdown::getDropdownName('glpi_locations', $resp['locations_id']));
if ($item && $item->getFromDB($resp['items_id'])) {
$resp['items_name'] = Html::clean($item->getNameID());
$resp['itemtype_name'] = Html::clean($item->getTypeName());
} else {
$resp['items_name'] = __('General');
$resp['itemtype_name'] = '';
}
}
$resp['users'] = array();
$resp['groups'] = array();
$resp['followups'] = array();
$resp['tasks'] = array();
$resp['documents'] = array();
$resp['events'] = array();
$resp['validations'] = array();
$resp['satisfaction'] = array();
if (Session::haveRight('observe_ticket', '1')) {
// Followups
$query = "SELECT *\n FROM `glpi_ticketfollowups`\n WHERE `tickets_id` = '" . $params['ticket'] . "' ";
if (!Session::haveRight("show_full_ticket", "1")) {
$query .= " AND (`is_private`='0'\n OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
}
$query .= " ORDER BY `date` DESC";
foreach ($DB->request($query) as $data) {
if (isset($params['id2name'])) {
$data['users_name'] = Html::clean(getUserName($data['users_id']));
$data['requesttypes_name'] = Html::clean(Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']));
}
$resp['followups'][] = $data;
}
// Tasks
$query = "SELECT *\n FROM `glpi_tickettasks`\n WHERE `tickets_id` = '" . $params['ticket'] . "' ";
if (!Session::haveRight("show_full_ticket", "1")) {
$query .= " AND (`is_private`='0'\n OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
}
$query .= " ORDER BY `date` DESC";
foreach ($DB->request($query) as $data) {
if (isset($params['id2name'])) {
$data['users_name'] = Html::clean(getUserName($data['users_id']));
$data['taskcategories_name'] = Html::clean(Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']));
//.........这里部分代码省略.........
示例6: giveItem
//.........这里部分代码省略.........
case "glpi_auth_tables.name":
return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
case "glpi_reservationitems.comment":
if (empty($data[$NAME . $num])) {
return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>";
}
return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$NAME . $num]) . "</a>";
case 'glpi_notifications.mode':
return Notification::getMode($data[$NAME . $num]);
case 'glpi_notifications.event':
$item = NotificationTarget::getInstanceByType($data['itemtype']);
if ($item) {
$events = $item->getAllEvents();
if (isset($events[$data[$NAME . $num]])) {
return $events[$data[$NAME . $num]];
}
}
return '';
case 'glpi_reminders.state':
return Planning::getState($data[$NAME . $num]);
case 'glpi_crontasks.description':
$tmp = new CronTask();
return $tmp->getDescription($data['id']);
case 'glpi_crontasks.state':
return CronTask::getStateName($data[$NAME . $num]);
case 'glpi_crontasks.mode':
return CronTask::getModeName($data[$NAME . $num]);
case 'glpi_crontasks.itemtype':
if ($plug = isPluginItemType($data[$NAME . $num])) {
return $plug['plugin'];
}
return '';
case 'glpi_changes.status':
$status = Change::getStatus($data[$NAME . $num]);
return "<img src=\"" . Change::getStatusIconURL($data[$NAME . $num]) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}";
case 'glpi_problems.status':
$status = Problem::getStatus($data[$NAME . $num]);
return "<img src=\"" . Problem::getStatusIconURL($data[$NAME . $num]) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}";
case 'glpi_tickets.status':
$status = Ticket::getStatus($data[$NAME . $num]);
return "<img src=\"" . Ticket::getStatusIconURL($data[$NAME . $num]) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}";
case 'glpi_tickets.items_id':
if (!empty($data[$NAME . $num . "_2"]) && ($item = getItemForItemtype($data[$NAME . $num . "_2"]))) {
if ($item->getFromDB($data[$NAME . $num])) {
return $item->getLink(array('comments' => true));
}
}
return ' ';
case 'glpi_tickets.name':
if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
$split = explode("\$\$\$\$", $data[$NAME . $num]);
$out = '';
$link = Toolbox::getItemTypeFormURL('Ticket');
foreach ($split as $val) {
if (!empty($val)) {
$split2 = self::explodeWithID("\$\$", $val);
$out .= "<a id='ticket" . $split2[1] . "' href=\"" . $link;
$out .= strstr($link, '?') ? '&' : '?';
$out .= 'id=' . $split2[1];
$out .= "\">";
$name = $split2[0];
if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $split2[1]);
}
$out .= $name . "</a><br>";
}
示例7: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
// Specific datas
$datas['##change.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $item->getField("id") . "_ChangeValidation\$1");
$datas['##change.globalvalidation##'] = ChangeValidation::getStatus($item->getField('global_validation'));
// $datas["##problem.impacts##"] = $item->getField('impactcontent');
// $datas["##problem.causes##"] = $item->getField('causecontent');
// $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
// Complex mode
if (!$simple) {
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$tickets = getAllDatasFromTable('glpi_changes_tickets', $restrict);
$datas['tickets'] = array();
if (count($tickets)) {
$ticket = new Ticket();
foreach ($tickets as $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$tmp = array();
$tmp['##ticket.id##'] = $data['tickets_id'];
$tmp['##ticket.date##'] = $ticket->getField('date');
$tmp['##ticket.title##'] = $ticket->getField('name');
$tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
$tmp['##ticket.content##'] = $ticket->getField('content');
$datas['tickets'][] = $tmp;
}
}
}
$datas['##change.numberoftickets##'] = count($datas['tickets']);
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$problems = getAllDatasFromTable('glpi_changes_problems', $restrict);
$datas['problems'] = array();
if (count($problems)) {
$problem = new Problem();
foreach ($problems as $data) {
if ($problem->getFromDB($data['problems_id'])) {
$tmp = array();
$tmp['##problem.id##'] = $data['problems_id'];
$tmp['##problem.date##'] = $problem->getField('date');
$tmp['##problem.title##'] = $problem->getField('name');
$tmp['##problem.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Problem_" . $data['problems_id']);
$tmp['##problem.content##'] = $problem->getField('content');
$datas['problems'][] = $tmp;
}
}
}
$datas['##change.numberofproblems##'] = count($datas['problems']);
$restrict = "`changes_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_changes_items', $restrict);
$datas['items'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$datas['items'][] = $tmp;
}
}
}
}
$datas['##change.numberofitems##'] = count($datas['items']);
//Validation infos
$restrict = "`changes_id`='" . $item->getField('id') . "'";
if (isset($options['validation_id']) && $options['validation_id']) {
$restrict .= " AND `glpi_changevalidations`.`id` = '" . $options['validation_id'] . "'";
//.........这里部分代码省略.........
示例8: getDatasForTemplate
/**
* Get all data needed for template processing
**/
function getDatasForTemplate($event, $options = array())
{
global $LANG, $CFG_GLPI;
//----------- Ticket infos -------------- //
if ($event != 'alertnotclosed') {
$fields = array('ticket.title' => 'name', 'ticket.content' => 'content', 'ticket.description' => 'content', 'ticket.costfixed' => 'cost_fixed', 'ticket.costmaterial' => 'cost_material');
foreach ($fields as $tag => $table_field) {
$this->datas['##' . $tag . '##'] = $this->obj->getField($table_field);
}
$this->datas['##ticket.id##'] = sprintf("%07d", $this->obj->getField("id"));
$this->datas['##ticket.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id"));
$this->datas['##ticket.urlapprove##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id") . "_4");
$this->datas['##ticket.urlvalidation##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id") . "_7");
$this->datas['##ticket.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->getEntity());
$events = $this->getAllEvents();
if ($event == 'validation' && isset($options['validation_status'])) {
$this->datas['##ticket.action##'] = $LANG['validation'][0] . ' - ' . TicketValidation::getStatus($options['validation_status']);
} else {
$this->datas['##ticket.action##'] = $events[$event];
}
$this->datas['##ticket.storestatus##'] = $this->obj->getField('status');
$this->datas['##ticket.status##'] = Ticket::getStatus($this->obj->getField('status'));
$this->datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($this->obj->getField('global_validation'));
$this->datas['##ticket.type##'] = Ticket::getTicketTypeName($this->obj->getField('type'));
$this->datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $this->obj->getField('requesttypes_id'));
$this->datas['##ticket.urgency##'] = Ticket::getUrgencyName($this->obj->getField('urgency'));
$this->datas['##ticket.impact##'] = Ticket::getImpactName($this->obj->getField('impact'));
$this->datas['##ticket.priority##'] = Ticket::getPriorityName($this->obj->getField('priority'));
$this->datas['##ticket.time##'] = Ticket::getActionTime($this->obj->getField('actiontime'));
$this->datas['##ticket.costtime##'] = $this->obj->getField('cost_time');
$this->datas['##ticket.creationdate##'] = convDateTime($this->obj->getField('date'));
$this->datas['##ticket.closedate##'] = convDateTime($this->obj->getField('closedate'));
$this->datas['##ticket.solvedate##'] = convDateTime($this->obj->getField('solvedate'));
$this->datas['##ticket.duedate##'] = convDateTime($this->obj->getField('due_date'));
$entitydata = new EntityData();
$autoclose_value = $CFG_GLPI['autoclose_delay'];
if ($entitydata->getFromDB($this->getEntity())) {
$autoclose_value = $entitydata->getField('autoclose_delay');
// Set global config value
if ($autoclose_value == -1) {
$autoclose_value = $CFG_GLPI['autoclose_delay'];
}
}
if ($autoclose_value > 0) {
$this->datas['##ticket.autoclose##'] = $autoclose_value;
$this->datas['##lang.ticket.autoclosewarning##'] = $LANG['job'][54] . " " . $autoclose_value . " " . $LANG['stats'][31];
} else {
$this->datas['##ticket.autoclose##'] = $LANG['setup'][307];
$this->datas['##lang.ticket.autoclosewarning##'] = "";
}
if ($this->obj->getField('ticketcategories_id')) {
$this->datas['##ticket.category##'] = Dropdown::getDropdownName('glpi_ticketcategories', $this->obj->getField('ticketcategories_id'));
} else {
$this->datas['##ticket.category##'] = '';
}
if ($this->obj->getField('slas_id')) {
$this->datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $this->obj->getField('slas_id'));
} else {
$this->datas['##ticket.sla##'] = '';
}
if ($this->obj->countUsers(Ticket::REQUESTER)) {
$users = array();
foreach ($this->obj->getUsers(Ticket::REQUESTER) as $uid => $tmp) {
$user_tmp = new User();
$user_tmp->getFromDB($uid);
$users[$uid] = $user_tmp->getName();
$tmp = array();
$tmp['##author.id##'] = $uid;
$tmp['##author.name##'] = $user_tmp->getName();
if ($user_tmp->getField('locations_id')) {
$tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id'));
} else {
$tmp['##author.location##'] = '';
}
$tmp['##author.phone##'] = $user_tmp->getField('phone');
$tmp['##author.phone2##'] = $user_tmp->getField('phone2');
$this->datas['authors'][] = $tmp;
}
$this->datas['##ticket.authors##'] = implode(', ', $users);
} else {
$this->datas['##ticket.authors##'] = '';
}
if ($this->obj->getField('users_id_recipient')) {
$user_tmp = new User();
$user_tmp->getFromDB($this->obj->getField('users_id_recipient'));
$this->datas['##ticket.openbyuser##'] = $user_tmp->getName();
} else {
$this->datas['##ticket.openbyuser##'] = '';
}
if ($this->obj->countUsers(Ticket::ASSIGN)) {
$users = array();
foreach ($this->obj->getUsers(Ticket::ASSIGN) as $uid => $tmp) {
$user_tmp = new User();
$user_tmp->getFromDB($uid);
$users[$uid] = $user_tmp->getName();
}
$this->datas['##ticket.assigntousers##'] = implode(', ', $users);
//.........这里部分代码省略.........
示例9: getTimelineItems
/**
* @since version 0.90
*
**/
function getTimelineItems()
{
global $DB, $CFG_GLPI;
$timeline = array();
$user = new User();
$group = new Group();
$followup_obj = new TicketFollowup();
$task_obj = new TicketTask();
$document_item_obj = new Document_Item();
$ticket_valitation_obj = new TicketValidation();
//checks rights
$showpublic = Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE)) || Session::haveRightsOr("task", array(TicketTask::SEEPUBLIC, TicketTask::SEEPRIVATE));
$restrict_fup = $restrict_task = "";
if (!Session::haveRight("followup", TicketFollowup::SEEPRIVATE)) {
$restrict_fup = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!Session::haveRight("task", TicketTask::SEEPRIVATE)) {
$restrict_task = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!$showpublic) {
$restrict = " AND 1 = 0";
}
//add ticket followups to timeline
if ($followup_obj->canview()) {
$followups = $followup_obj->find("tickets_id = " . $this->getID() . " {$restrict_fup}", 'date DESC');
foreach ($followups as $followups_id => $followup) {
$followup_obj->getFromDB($followups_id);
$followup['can_edit'] = $followup_obj->canUpdateItem();
$timeline[$followup['date'] . "_followup_" . $followups_id] = array('type' => 'TicketFollowup', 'item' => $followup);
}
}
//add ticket tasks to timeline
if ($task_obj->canview()) {
$tasks = $task_obj->find("tickets_id = " . $this->getID() . " {$restrict_task}", 'date DESC');
foreach ($tasks as $tasks_id => $task) {
$task_obj->getFromDB($tasks_id);
$task['can_edit'] = $task_obj->canUpdateItem();
$timeline[$task['date'] . "_task_" . $tasks_id] = array('type' => 'TicketTask', 'item' => $task);
}
}
//add ticket documents to timeline
$document_obj = new Document();
$document_items = $document_item_obj->find("itemtype = 'Ticket' AND items_id = " . $this->getID());
foreach ($document_items as $document_item) {
$document_obj->getFromDB($document_item['documents_id']);
$timeline[$document_obj->fields['date_mod'] . "_document_" . $document_item['documents_id']] = array('type' => 'Document_Item', 'item' => $document_obj->fields);
}
//add existing solution
if (!empty($this->fields['solution']) || !empty($this->fields['solutiontypes_id'])) {
$users_id = 0;
$solution_date = $this->fields['solvedate'];
//search date and user of last solution in glpi_logs
if ($res_solution = $DB->query("SELECT `date_mod` AS solution_date, `user_name`, `id`\n FROM `glpi_logs`\n WHERE `itemtype` = 'Ticket'\n AND `items_id` = " . $this->getID() . "\n AND `id_search_option` = 24\n ORDER BY `id` DESC\n LIMIT 1")) {
$data_solution = $DB->fetch_assoc($res_solution);
if (!empty($data_solution['solution_date'])) {
$solution_date = $data_solution['solution_date'];
}
// find user
if (!empty($data_solution['user_name'])) {
$users_id = addslashes(trim(preg_replace("/.*\\(([0-9]+)\\)/", "\$1", $data_solution['user_name'])));
}
}
// fix trouble with html_entity_decode who skip accented characters (on windows browser)
$solution_content = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $this->fields['solution']);
$timeline[$solution_date . "_solution"] = array('type' => 'Solution', 'item' => array('id' => 0, 'content' => Toolbox::unclean_cross_side_scripting_deep($solution_content), 'date' => $solution_date, 'users_id' => $users_id, 'solutiontypes_id' => $this->fields['solutiontypes_id'], 'can_edit' => Ticket::canUpdate() && $this->canSolve()));
}
// add ticket validation to timeline
if ($this->fields['type'] == Ticket::DEMAND_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST) || Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) || $this->fields['type'] == Ticket::INCIDENT_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT))) {
$ticket_validations = $ticket_valitation_obj->find('tickets_id = ' . $this->getID());
foreach ($ticket_validations as $validations_id => $validation) {
$canedit = $ticket_valitation_obj->can($validations_id, UPDATE);
$user->getFromDB($validation['users_id_validate']);
$timeline[$validation['submission_date'] . "_validation_" . $validations_id] = array('type' => 'TicketValidation', 'item' => array('id' => $validations_id, 'date' => $validation['submission_date'], 'content' => __('Validation request') . " => " . $user->getlink() . "<br>" . $validation['comment_submission'], 'users_id' => $validation['users_id'], 'can_edit' => $canedit));
if (!empty($validation['validation_date'])) {
$timeline[$validation['validation_date'] . "_validation_" . $validations_id] = array('type' => 'TicketValidation', 'item' => array('id' => $validations_id, 'date' => $validation['validation_date'], 'content' => __('Validation request answer') . " : " . _sx('status', ucfirst(TicketValidation::getStatus($validation['status']))) . "<br>" . $validation['comment_validation'], 'users_id' => $validation['users_id_validate'], 'status' => "status_" . $validation['status'], 'can_edit' => $canedit));
}
}
}
//reverse sort timeline items by key (date)
krsort($timeline);
return $timeline;
}
示例10: showEquals
public function showEquals($searchopt, $value, $edit = true)
{
$inputname = $searchopt['linkfield'];
switch ($searchopt['table'] . "." . $searchopt['linkfield']) {
case "glpi_tickets.status":
if ($edit) {
Ticket::dropdownStatus($inputname, $value, 1);
} else {
echo Ticket::getStatus($value);
}
break;
case "glpi_tickets.priority":
if ($edit) {
Ticket::dropdownPriority($inputname, $value, true, true);
} else {
echo Ticket::getPriorityName(trim($value));
}
break;
case "glpi_tickets.impact":
if ($edit) {
Ticket::dropdownImpact($inputname, $value, true);
} else {
echo Ticket::getImpactName($value);
}
break;
case "glpi_tickets.urgency":
if ($edit) {
Ticket::dropdownUrgency($inputname, $value, true);
} else {
echo Ticket::getUrgencyName($value);
}
break;
case "glpi_tickets.global_validation":
if ($edit) {
TicketValidation::dropdownStatus($inputname, array('value' => $value, 'all' => 1));
} else {
TicketValidation::getStatus($value);
}
break;
case "glpi_users.name":
if ($edit) {
User::dropdown(array('name' => $inputname, 'value' => $value, 'comments' => false, 'all' => -1, 'right' => 'all'));
} else {
echo getUserName($value);
}
break;
case "glpi_ticketvalidations.status":
if ($edit) {
TicketValidation::dropdownStatus($inputname, array('value' => $value, 'all' => 1));
} else {
echo TicketValidation::getStatus($value);
}
break;
}
}
示例11: constructHistory
/**
* Construct history for an item
*
* @param $item CommonDBTM object
* @param $oldvalues array of old values updated
* @param $values array of all values of the item
*
* @return boolean for success (at least 1 log entry added)
**/
static function constructHistory(CommonDBTM $item, &$oldvalues, &$values)
{
global $LANG;
if (!count($oldvalues)) {
return false;
}
// needed to have $SEARCHOPTION
if ($item->getType() == 'TicketSatisfaction') {
$real_type = 'Ticket';
$real_id = $item->fields['tickets_id'];
} else {
if ($item->getType() == 'Infocom') {
$real_type = $item->fields['itemtype'];
$real_id = $item->fields['items_id'];
} else {
$real_type = $item->getType();
$real_id = $item->fields['id'];
}
}
$searchopt = Search::getOptions($real_type);
if (!is_array($searchopt)) {
return false;
}
$result = 0;
foreach ($oldvalues as $key => $oldval) {
$changes = array();
if ($real_type == 'Infocom') {
// Parsing $SEARCHOPTION to find infocom
foreach ($searchopt as $key2 => $val2) {
if ($val2["field"] == $key && strpos($val2['table'], 'infocoms') || $key == 'budgets_id' && $val2['table'] == 'glpi_budgets' || $key == 'suppliers_id' && $val2['table'] == 'glpi_suppliers') {
$id_search_option = $key2;
// Give ID of the $SEARCHOPTION
if ($val2["table"] == "glpi_infocoms") {
// 1st case : text field -> keep datas
$changes = array($id_search_option, addslashes($oldval), $values[$key]);
} else {
if ($val2["table"] == "glpi_suppliers") {
// 2nd case ; link field -> get data from glpi_suppliers
$changes = array($id_search_option, addslashes(Dropdown::getDropdownName("glpi_suppliers", $oldval)), addslashes(Dropdown::getDropdownName("glpi_suppliers", $values[$key])));
} else {
// 3rd case ; link field -> get data from dropdown (budget)
$changes = array($id_search_option, addslashes(Dropdown::getDropdownName($val2["table"], $oldval)), addslashes(Dropdown::getDropdownName($val2["table"], $values[$key])));
}
}
break;
// foreach exit
}
}
} else {
// Not an Infocom
// Parsing $SEARCHOPTION to find changed field
foreach ($searchopt as $key2 => $val2) {
// Linkfield or standard field not massive action enable
if ($val2["linkfield"] == $key || $key == $val2["field"] && $val2["table"] == $item->getTable()) {
$id_search_option = $key2;
// Give ID of the $SEARCHOPTION
// 1st case : Ticket specific dropdown case (without table)
if ($real_type == 'Ticket' && in_array($key, array('status', 'urgency', 'impact', 'priority', 'global_validation'))) {
switch ($key) {
case 'global_validation':
$changes = array($id_search_option, addslashes(TicketValidation::getStatus($oldval)), addslashes(TicketValidation::getStatus($values[$key])));
break;
case 'status':
$changes = array($id_search_option, addslashes(Ticket::getStatus($oldval)), addslashes(Ticket::getStatus($values[$key])));
break;
case 'urgency':
$changes = array($id_search_option, addslashes(Ticket::getUrgencyName($oldval)), addslashes(Ticket::getUrgencyName($values[$key])));
break;
case 'impact':
$changes = array($id_search_option, addslashes(Ticket::getImpactName($oldval)), addslashes(Ticket::getImpactName($values[$key])));
break;
case 'priority':
$changes = array($id_search_option, addslashes(Ticket::getPriorityName($oldval)), addslashes(Ticket::getPriorityName($values[$key])));
break;
}
} else {
if ($val2["table"] == $item->getTable()) {
// 2nd case : text field -> keep datas
$changes = array($id_search_option, addslashes($oldval), $values[$key]);
} else {
// if ($val2['table'] == 'glpi_users_validation') {
// $val2['table'] = 'glpi_users';
// }
// other cases ; link field -> get data from dropdown
if ($val2["table"] != 'glpi_complete_entities') {
$changes = array($id_search_option, addslashes(Dropdown::getDropdownName($val2["table"], $oldval)), addslashes(Dropdown::getDropdownName($val2["table"], $values[$key])));
}
}
}
break;
}
//.........这里部分代码省略.........
示例12: giveItem
//.........这里部分代码省略.........
if (empty($data[$NAME . $num])) {
return 0;
}
return $data[$NAME . $num];
case "glpi_auth_tables.name":
return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
case "glpi_reservationitems.comment":
if (empty($data[$NAME . $num])) {
return "<a title='" . $LANG['reservation'][22] . "'\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' data-back='false'>" . $LANG['common'][49] . "</a>";
}
return "<a title='" . $LANG['reservation'][22] . "'\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' data-back='false'>" . resume_text($data[$NAME . $num]) . "</a>";
case 'glpi_notifications.mode':
return Notification::getMode($data[$NAME . $num]);
case 'glpi_notifications.event':
$item = NotificationTarget::getInstanceByType($data['itemtype']);
if ($item) {
$events = $item->getAllEvents();
return $events[$data[$NAME . $num]];
}
return '';
case 'glpi_crontasks.description':
$tmp = new CronTask();
return $tmp->getDescription($data['id']);
case 'glpi_crontasks.state':
return CronTask::getStateName($data[$NAME . $num]);
case 'glpi_crontasks.mode':
return CronTask::getModeName($data[$NAME . $num]);
case 'glpi_crontasks.itemtype':
if ($plug = isPluginItemType($data[$NAME . $num])) {
return $plug['plugin'];
}
return '';
case 'glpi_tickets.status':
$status = Ticket::getStatus($data[$NAME . $num]);
// status Stevenes Donato
if ($data[$NAME . $num] == "1") {
$data[$NAME . $num] = "new";
}
if ($data[$NAME . $num] == "2") {
$data[$NAME . $num] = "assign";
}
if ($data[$NAME . $num] == "3") {
$data[$NAME . $num] = "plan";
}
if ($data[$NAME . $num] == "4") {
$data[$NAME . $num] = "waiting";
}
if ($data[$NAME . $num] == "5") {
$data[$NAME . $num] = "solved";
}
if ($data[$NAME . $num] == "6") {
$data[$NAME . $num] = "closed";
}
//
return "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . $data[$NAME . $num] . ".png\"\n alt='{$status}' title='{$status}'> {$status}";
case 'glpi_tickets.priority':
return Ticket::getPriorityName($data[$NAME . $num]);
case 'glpi_tickets.urgency':
return Ticket::getUrgencyName($data[$NAME . $num]);
case 'glpi_tickets.impact':
return Ticket::getImpactName($data[$NAME . $num]);
case 'glpi_tickets.items_id':
if (!empty($data[$NAME . $num . "_2"]) && class_exists($data[$NAME . $num . "_2"])) {
$item = new $data[$NAME . $num . "_2"]();
if ($item->getFromDB($data[$NAME . $num])) {
return $item->getLink(true);
示例13: getDatasForTemplate
/**
* Get all data needed for template processing
*
* @param $event
* @param $options array
**/
function getDatasForTemplate($event, $options = array())
{
global $CFG_GLPI;
$events = $this->getAllEvents();
$objettype = strtolower($this->obj->getType());
// Get datas from ITIL objects
if ($event != 'alertnotclosed') {
$this->datas = $this->getDatasForObject($this->obj, $options);
} else {
if (isset($options['entities_id']) && isset($options['items'])) {
$entity = new Entity();
if ($entity->getFromDB($options['entities_id'])) {
$this->datas["##{$objettype}.entity##"] = $entity->getField('completename');
$this->datas["##{$objettype}.shortentity##"] = $entity->getField('name');
}
if ($item = getItemForItemtype($objettype)) {
$objettypes = Toolbox::strtolower(getPlural($objettype));
$items = array();
foreach ($options['items'] as $object) {
$item->getFromDB($object['id']);
$tmp = $this->getDatasForObject($item, $options, true);
$this->datas[$objettypes][] = $tmp;
}
}
}
}
if ($event == 'validation' && isset($options['validation_status'])) {
$this->datas["##{$objettype}.action##"] = sprintf(__('%1$s - %2$s'), __('Approval'), TicketValidation::getStatus($options['validation_status']));
} else {
$this->datas["##{$objettype}.action##"] = $events[$event];
}
$this->getTags();
foreach ($this->tag_descriptions[parent::TAG_LANGUAGE] as $tag => $values) {
if (!isset($this->datas[$tag])) {
$this->datas[$tag] = $values['label'];
}
}
}
示例14: giveItem
//.........这里部分代码省略.........
if (empty($data[$NAME . $num])) {
return 0;
}
return $data[$NAME . $num];
case "glpi_auth_tables.name":
return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
case "glpi_reservationitems.comment":
if (empty($data[$NAME . $num])) {
return "<a title=\"" . $LANG['reservation'][22] . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . $LANG['common'][49] . "</a>";
}
return "<a title=\"" . $LANG['reservation'][22] . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . resume_text($data[$NAME . $num]) . "</a>";
case 'glpi_notifications.mode':
return Notification::getMode($data[$NAME . $num]);
case 'glpi_notifications.event':
$item = NotificationTarget::getInstanceByType($data['itemtype']);
if ($item) {
$events = $item->getAllEvents();
return $events[$data[$NAME . $num]];
}
return '';
case 'glpi_crontasks.description':
$tmp = new CronTask();
return $tmp->getDescription($data['id']);
case 'glpi_crontasks.state':
return CronTask::getStateName($data[$NAME . $num]);
case 'glpi_crontasks.mode':
return CronTask::getModeName($data[$NAME . $num]);
case 'glpi_crontasks.itemtype':
if ($plug = isPluginItemType($data[$NAME . $num])) {
return $plug['plugin'];
}
return '';
case 'glpi_tickets.status':
$status = Ticket::getStatus($data[$NAME . $num]);
return "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . $data[$NAME . $num] . ".png\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}";
case 'glpi_tickets.type':
return Ticket::getTicketTypeName($data[$NAME . $num]);
case 'glpi_tickets.priority':
return Ticket::getPriorityName($data[$NAME . $num]);
case 'glpi_tickets.urgency':
return Ticket::getUrgencyName($data[$NAME . $num]);
case 'glpi_tickets.impact':
return Ticket::getImpactName($data[$NAME . $num]);
case 'glpi_tickets.items_id':
if (!empty($data[$NAME . $num . "_2"]) && class_exists($data[$NAME . $num . "_2"])) {
$item = new $data[$NAME . $num . "_2"]();
if ($item->getFromDB($data[$NAME . $num])) {
return $item->getLink(true);
}
}
return ' ';
case 'glpi_tickets.name':
$link = getItemTypeFormURL('Ticket');
$out = "<a id='ticket" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
$out .= strstr($link, '?') ? '&' : '?';
$out .= 'id=' . $data[$NAME . $num . "_2"];
// Force solution tab if solved
if ($data[$NAME . $num . "_4"] == 'solved') {
$out .= "&forcetab=4";
}
$out .= "\">" . $data[$NAME . $num];
if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
$out .= " (" . $data[$NAME . $num . "_2"] . ")";
}
$out .= "</a>";
$out .= showToolTip(nl2br($data[$NAME . $num . "_3"]), array('applyto' => 'ticket' . $data[$NAME . $num . "_2"], 'display' => false));
示例15: methodListTickets
//.........这里部分代码省略.........
if (is_array($params['order'])) {
$tab = $params['order'];
} else {
$tab = array($params['order'] => 'DESC');
}
foreach ($tab as $key => $val) {
if ($val != 'ASC') {
$val = 'DESC';
}
$sqlkey = array('id' => '`glpi_tickets`.`id`', 'date' => '`glpi_tickets`.`date`', 'closedate' => '`glpi_tickets`.`closedate`', 'date_mod' => '`glpi_tickets`.`date_mod`', 'status' => '`glpi_tickets`.`status`', 'entities_id' => '`glpi_tickets`.`entities_id`', 'priority' => '`glpi_tickets`.`priority`');
if (isset($sqlkey[$key])) {
$orders[] = $sqlkey[$key] . " {$val}";
} else {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'order=$key');
}
}
}
if (count($orders)) {
$order = implode(',', $orders);
} else {
$order = "`glpi_tickets`.`date_mod` DESC";
}
$resp = array();
if (isset($params['count'])) {
$query = "SELECT COUNT(DISTINCT `glpi_tickets`.`id`) AS count\n FROM `glpi_tickets`\n {$join}\n LEFT JOIN `glpi_tickets_users` AS glpi_tickets_users_request\n ON (`glpi_tickets`.`id` = `glpi_tickets_users_request`.`tickets_id`\n AND `glpi_tickets_users_request`.`type` = 1)\n LEFT JOIN `glpi_groups_tickets` AS glpi_groups_tickets_request\n ON (`glpi_tickets`.`id` = `glpi_groups_tickets_request`.`tickets_id`\n AND `glpi_groups_tickets_request`.`type` = 1 )\n {$where}";
$resp = $DB->request($query)->next();
//debug $resp['query'] = $query;
} else {
$query = "SELECT `glpi_tickets`.*,\n GROUP_CONCAT(DISTINCT `glpi_tickets_users_request`.`users_id` SEPARATOR ',')\n AS users_id_request,\n GROUP_CONCAT(DISTINCT `glpi_tickets_users_observer`.`users_id` SEPARATOR ',')\n AS users_id_observer,\n GROUP_CONCAT(DISTINCT `glpi_tickets_users_assign`.`users_id` SEPARATOR ',')\n AS users_id_assign,\n GROUP_CONCAT(DISTINCT `glpi_groups_tickets_request`.`groups_id` SEPARATOR ',')\n AS groups_id_request,\n GROUP_CONCAT(DISTINCT `glpi_groups_tickets_observer`.`groups_id` SEPARATOR ',')\n AS groups_id_observer,\n GROUP_CONCAT(DISTINCT `glpi_groups_tickets_assign`.`groups_id` SEPARATOR ',')\n AS groups_id_assign\n FROM `glpi_tickets`\n {$join}\n LEFT JOIN `glpi_tickets_users` AS glpi_tickets_users_request\n ON (`glpi_tickets`.`id` = `glpi_tickets_users_request`.`tickets_id`\n AND `glpi_tickets_users_request`.`type` = 1)\n LEFT JOIN `glpi_tickets_users` AS glpi_tickets_users_assign\n ON (`glpi_tickets`.`id` = `glpi_tickets_users_assign`.`tickets_id`\n AND `glpi_tickets_users_assign`.`type` = 2)\n LEFT JOIN `glpi_tickets_users` AS glpi_tickets_users_observer\n ON (`glpi_tickets`.`id` = `glpi_tickets_users_observer`.`tickets_id`\n AND `glpi_tickets_users_observer`.`type` = 3)\n LEFT JOIN `glpi_groups_tickets` AS glpi_groups_tickets_request\n ON (`glpi_tickets`.`id` = `glpi_groups_tickets_request`.`tickets_id`\n AND `glpi_groups_tickets_request`.`type` = 1)\n LEFT JOIN `glpi_groups_tickets` AS glpi_groups_tickets_assign\n ON (`glpi_tickets`.`id` = `glpi_groups_tickets_assign`.`tickets_id`\n AND `glpi_groups_tickets_assign`.`type` = 2)\n LEFT JOIN `glpi_groups_tickets` AS glpi_groups_tickets_observer\n ON (`glpi_tickets`.`id` = `glpi_groups_tickets_observer`.`tickets_id`\n AND `glpi_groups_tickets_observer`.`type` = 3)\n {$where}\n GROUP BY `glpi_tickets`.`id`\n ORDER BY {$order}\n LIMIT {$start},{$limit}";
foreach ($DB->request($query) as $data) {
$tmp = explode(',', $data['users_id_request']);
$data['users']['requester'] = array();
foreach ($tmp as $id) {
$data['users']['requester'][]['id'] = $id;
}
$tmp = explode(',', $data['users_id_observer']);
$data['users']['observer'] = array();
foreach ($tmp as $id) {
$data['users']['observer'][]['id'] = $id;
}
$tmp = explode(',', $data['users_id_assign']);
$data['users']['assign'] = array();
foreach ($tmp as $id) {
$data['users']['assign'][]['id'] = $id;
}
$tmp = explode(',', $data['groups_id_request']);
$data['groups']['requester'] = array();
foreach ($tmp as $id) {
$data['groups']['requester'][]['id'] = $id;
}
$tmp = explode(',', $data['groups_id_observer']);
$data['groups']['observer'] = array();
foreach ($tmp as $id) {
$data['groups']['observer'][]['id'] = $id;
}
$tmp = explode(',', $data['groups_id_assign']);
$data['groups']['assign'] = array();
foreach ($tmp as $id) {
$data['groups']['assign'][]['id'] = $id;
}
unset($data['groups_id_request'], $data['groups_id_observer'], $data['groups_id_assign'], $data['users_id_request'], $data['users_id_observer'], $data['users_id_assign']);
$data['solution'] = Html::clean(Toolbox::unclean_cross_side_scripting_deep($data['solution']));
if (isset($params['id2name'])) {
if ($data['itemtype'] && ($item = getItemForItemtype($data['itemtype']))) {
$data['itemtype_name'] = Html::clean($item->getTypeName());
if ($item->getFromDB($data['items_id'])) {
$data['items_name'] = Html::clean($item->getNameID());
} else {
$data['items_name'] = NOT_AVAILABLE;
}
}
foreach ($data['groups'] as $type => $tab) {
foreach ($tab as $key => $grp) {
$data['groups'][$type][$key]['name'] = Html::clean(Dropdown::getDropdownName('glpi_groups', $grp['id']));
}
}
foreach ($data['users'] as $type => $tab) {
foreach ($tab as $key => $usr) {
$data['users'][$type][$key]['name'] = Html::clean(getUserName($usr['id']));
}
}
$data['status_name'] = Html::clean(Ticket::getStatus($data['status']));
$data['urgency_name'] = Ticket::getUrgencyName($data['urgency']);
$data['impact_name'] = Ticket::getImpactName($data['impact']);
$data['priority_name'] = Ticket::getPriorityName($data['priority']);
$data['users_name_recipient'] = Html::clean(getUserName($data['users_id_recipient']));
$data['entities_name'] = Html::clean(Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
$data['suppliers_name_assign'] = Html::clean(Dropdown::getDropdownName('glpi_suppliers', $data['suppliers_id_assign']));
$data['ticketcategories_name'] = Html::clean(Dropdown::getDropdownName('glpi_itilcategories', $data['itilcategories_id']));
$data['requesttypes_name'] = Html::clean(Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']));
$data['solutiontypes_name'] = Html::clean(Dropdown::getDropdownName('glpi_solutiontypes', $data['solutiontypes_id']));
$data['slas_name'] = Html::clean(Dropdown::getDropdownName('glpi_slas', $data['slas_id']));
$data['slalevels_name'] = Html::clean(Dropdown::getDropdownName('glpi_slalevels', $data['slalevels_id']));
$data['global_validation_name'] = Html::clean(TicketValidation::getStatus($data['global_validation']));
}
$resp[] = $data;
}
}
return $resp;
}