static function getHistory($tickets_id, $full_history = false) { global $CFG_GLPI; $filter_groups_id = array(); if ($_SESSION['plugins']['escalade']['config']['use_filter_assign_group']) { $groups_groups = new PluginEscaladeGroup_Group(); $filter_groups_id = $groups_groups->getGroups($tickets_id); $use_filter_assign_group = true; } else { $use_filter_assign_group = false; } $plugin_dir = $full_history ? ".." : "../plugins/escalade"; //get all line for this ticket $group = new Group(); $history = new self(); $found = $history->find("tickets_id = {$tickets_id}", "date_mod DESC"); $nb_histories = count($found); //remove first line (current assign) $first_group = array_shift($found); if ($full_history) { //show 1st group echo "<div class='escalade_active'>"; echo " <img src='" . $CFG_GLPI['root_doc'] . "/pics/group.png' /> "; if ($group->getFromDB($first_group['groups_id'])) { echo $group->getLink(true); } echo "</div>"; } echo "<div class='escalade'>"; //parse all lines $i = 0; foreach ($found as $key => $hline) { echo "<div class='escalade_history'>"; if (!$use_filter_assign_group || isset($filter_groups_id[$hline['groups_id']])) { //up link and image echo "<a href='{$plugin_dir}/front/climb_group.php?tickets_id=" . $tickets_id . "&groups_id=" . $hline['groups_id']; if ($full_history) { echo "&full_history=true"; } echo "' title='" . __("Reassign the ticket to group", "escalade") . "' class='up_a'></a>"; } else { echo " "; } //group link echo " <img src='" . $CFG_GLPI['root_doc'] . "/pics/group.png' /> "; if ($group->getFromDB($hline['groups_id'])) { echo self::showGroupLink($group, $full_history); } echo "</div>"; $i++; if ($i == self::HISTORY_LIMIT && !$full_history) { break; } } //In case there are more than 10 group changes, a popup can display historical if ($nb_histories - 1 > self::HISTORY_LIMIT && !$full_history) { echo "<a href='#' onclick='var w=window.open(\"" . $plugin_dir . "/front/popup_histories.php?tickets_id=" . $tickets_id . "\" ,\"\", \"height=500, width=250, top=100, left=100, scrollbars=yes\" ); " . "w.focus();' title='" . __("View full history", "escalade") . "'>...</a>"; } echo "</div>"; }
function manageGroup($groups_id) { global $CFG_GLPI; $group = new Group(); if (Session::haveRight('group', 'w')) { echo "<form method='post' name='' id='manageGroup' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/escalade/front/group_group.form.php\">"; } echo "<table width='950' class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='2'>"; echo "Escalade"; echo "</th>"; echo "</tr>"; $gg_found = $this->find("groups_id_source='{$groups_id}'"); if (Session::haveRight('group', 'w')) { $groups_id_used = array(); foreach ($gg_found as $gg) { $groups_id_used[] = $gg['groups_id_destination']; } echo "<tr>"; echo "<td colspan='2' align='center'>"; Dropdown::show('Group', array('name' => 'groups_id_destination', 'condition' => "is_assign=1", 'used' => $groups_id_used)); echo "<input type='hidden' name='groups_id_source' value='" . $groups_id . "' />"; echo " <input type='submit' class='submit' name='addgroup' value='" . _sx('button', 'Add') . "'/>"; echo "</td>"; echo "</tr>"; } foreach ($gg_found as $gg_id => $gg) { $group->getFromDB($gg['groups_id_destination']); echo "<tr class='tab_bg_1'>"; echo "<td width='30'>"; if (Session::haveRight('group', 'w')) { echo "<input type='checkbox' name='delgroup[]' value='{$gg_id}' />"; } echo "</td>"; echo "<td>"; echo $group->getLink(true); echo "</td>"; echo "</tr>"; } echo "</table>"; if (Session::haveRight('group', 'w')) { Html::openArrowMassives("manageGroup", true); Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently'))); } Html::closeForm(); }
/** * show groups asociated * * @param $type integer : user type * @param $canedit boolean : can edit ? * @param $options array options for default values ($options of showForm) * * @return nothing display **/ function showGroupsAssociated($type, $canedit, array $options = array()) { global $CFG_GLPI; $groupicon = self::getActorIcon('group', $type); $group = new Group(); $linkclass = new $this->grouplinkclass(); $itemtype = $this->getType(); $typename = self::getActorFieldNameType($type); $candelete = true; $mandatory = ''; // For ticket templates : mandatories if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) { $mandatory = $options['_tickettemplate']->getMandatoryMark("_groups_id_" . $typename); if ($options['_tickettemplate']->isMandatoryField("_groups_id_" . $typename) && isset($this->groups[$type]) && count($this->groups[$type]) == 1) { $candelete = false; } } if (isset($this->groups[$type]) && count($this->groups[$type])) { foreach ($this->groups[$type] as $d) { $k = $d['groups_id']; echo "{$mandatory}{$groupicon} "; if ($group->getFromDB($k)) { echo $group->getLink(array('comments' => true)); } if ($canedit && $candelete) { echo " "; Html::showSimpleForm($linkclass->getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $d['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png"); } echo '<br>'; } } }
/** * @since version 0.90 * * @param $rand **/ function showTimeline($rand) { global $CFG_GLPI, $DB, $autolink_options; //get ticket actors $ticket_users_keys = $this->getTicketActors(); $user = new User(); $group = new Group(); $followup_obj = new TicketFollowup(); $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline"; $timeline = $this->getTimelineItems(); $autolink_options['strip_protocols'] = false; //display timeline echo "<div class='timeline_history'>"; $tmp = array_values($timeline); $first_item = array_shift($tmp); // show approbation form on top when ticket is solved if ($this->fields["status"] == CommonITILObject::SOLVED) { echo "<div class='approbation_form' id='approbation_form{$rand}'>"; $followup_obj->showApprobationForm($this); echo "</div>"; } // show title for timeline self::showTimelineHeader(); $timeline_index = 0; foreach ($timeline as $item) { $options = array('parent' => $this, 'rand' => $rand); if ($obj = getItemForItemtype($item['type'])) { $obj->fields = $item['item']; } else { $obj = $item; } Plugin::doHook('pre_show_item', array('item' => &$obj, 'options' => &$options)); if (is_array($obj)) { $item_i = $obj['item']; } else { $item_i = $obj->fields; } $date = ""; if (isset($item_i['date'])) { $date = $item_i['date']; } if (isset($item_i['date_mod'])) { $date = $item_i['date_mod']; } // check if curent item user is assignee or requester $user_position = 'left'; if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') { $user_position = 'right'; } //display solution in middle if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) { $user_position .= ' middle'; } echo "<div class='h_item {$user_position}'>"; echo "<div class='h_info'>"; echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>"; if ($item_i['users_id'] !== false) { echo "<div class='h_user'>"; if (isset($item_i['users_id']) && $item_i['users_id'] != 0) { $user->getFromDB($item_i['users_id']); echo "<div class='tooltip_picture_border'>"; echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>"; echo "</div>"; echo "<span class='h_user_name'>"; $userdata = getUserName($item_i['users_id'], 2); echo $user->getLink() . " "; echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link'])); echo "</span>"; } else { _e("Requester"); } echo "</div>"; // h_user } echo "</div>"; //h_date echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'" . "id='viewitem" . $item['type'] . $item_i['id'] . $rand . "'>"; if (isset($item_i['can_edit']) && $item_i['can_edit']) { echo "<div class='edit_item_content'></div>"; echo "<span class='cancel_edit_item_content'></span>"; } echo "<div class='displayed_content'>"; if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) { echo "<span class='edit_item' "; echo "onclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this, \"viewitem" . $item['type'] . $item_i['id'] . $rand . "\")'"; echo "></span>"; } if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) { echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />"; } if (isset($item_i['content'])) { $content = $item_i['content']; $content = autolink($content, 40); //$content = nl2br($content); $long_text = ""; if (substr_count($content, "<br") > 30 || strlen($content) > 2000) { $long_text = "long_text"; } echo "<div class='item_content {$long_text}'>"; echo "<p>"; if (isset($item_i['state'])) { $onClick = "onclick='change_task_state(" . $item_i['id'] . ", this)'"; if (!$item_i['can_edit']) { $onClick = "style='cursor: not-allowed;'"; } echo "<span class='state state_" . $item_i['state'] . "'\n {$onClick}\n title='" . Planning::getState($item_i['state']) . "'>"; echo "</span>"; } echo $content; echo "</p>"; if (!empty($long_text)) { echo "<p class='read_more'>"; echo "<a class='read_more_button'>.....</a>"; echo "</p>"; } echo "</div>"; } echo "<div class='b_right'>"; if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) { echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>"; } if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) { echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>"; } if (isset($item_i['requesttypes_id']) && !empty($item_i['requesttypes_id'])) { echo Dropdown::getDropdownName("glpi_requesttypes", $item_i['requesttypes_id']) . "<br>"; } if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) { echo "<span class='actiontime'>"; echo Html::timestampToString($item_i['actiontime'], false); echo "</span>"; } if (isset($item_i['begin'])) { echo "<span class='planification'>"; echo Html::convDateTime($item_i["begin"]); echo " ⇒ "; echo Html::convDateTime($item_i["end"]); echo "</span>"; } if (isset($item_i['users_id_tech']) && $item_i['users_id_tech'] > 0) { echo "<div class='users_id_tech' id='users_id_tech_" . $item_i['users_id_tech'] . "'>"; $user->getFromDB($item_i['users_id_tech']); echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . " "; $userdata = getUserName($item_i['users_id_tech'], 2); echo $user->getLink() . " "; echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link'])); echo "</div>"; } if (isset($item_i['groups_id_tech']) && $item_i['groups_id_tech'] > 0) { echo "<div class='groups_id_tech'>"; $group->getFromDB($item_i['groups_id_tech']); echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . " "; echo $group->getLink() . " "; echo Html::showToolTip($group->getComments(), array('link' => $group->getLinkURL())); echo "</div>"; } // show "is_private" icon if (isset($item_i['is_private']) && $item_i['is_private']) { echo "<div class='private'>" . __('Private') . "</div>"; } echo "</div>"; // b_right if ($item['type'] == 'Document_Item') { $filename = $item_i['filename']; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); echo "<img src='"; if (empty($filename)) { $filename = $item_i['name']; } if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) { echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png"; } else { echo "{$pics_url}/file.png"; } echo "' title='file' /> "; echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}"; if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) { echo "<div class='timeline_img_preview'>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>"; echo "</div>"; } echo "</a>"; if (!empty($item_i['mime'])) { echo " (" . $item_i['mime'] . ")"; } echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>"; echo "<img src='{$pics_url}/edit.png' /></a>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>"; echo "<img src='{$pics_url}/delete.png' /></a>"; } echo "</div>"; // displayed_content echo "</div>"; //end h_content echo "</div>"; //end h_info $timeline_index++; Plugin::doHook('post_show_item', array('item' => $obj, 'options' => $options)); } // end foreach timeline echo "<div class='break'></div>"; // recall ticket content (not needed in classic and splitted layout) if (!CommonGLPI::isLayoutWithMain()) { echo "<div class='h_item middle'>"; echo "<div class='h_info'>"; echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>"; echo "<div class='h_user'>"; $dem = '0'; foreach ($DB->request("glpi_tickets_users", "`tickets_id` = " . $this->fields['id'] . " AND `type` = 1") as $req) { $dem = $req['users_id']; } if ((!isset($item_i['users_id_recipient']) || $item_i['users_id_recipient'] == 0) && $dem == 0) { _e("Requester"); } else { if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) { $user->getFromDB($this->fields['users_id_recipient']); } else { if ($dem > 0) { $requester = new User(); if ($requester->getFromDB($dem)) { $user = $requester; } } } echo "<div class='tooltip_picture_border'>"; $picture = ""; if (isset($user->fields['picture'])) { $picture = $user->fields['picture']; } echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>"; echo "</div>"; echo $user->getLink(); } echo "</div>"; // h_user echo "</div>"; //h_info echo "<div class='h_content TicketContent'>"; echo "<div class='b_right'>" . __("Ticket recall") . "</div>"; echo "<div class='ticket_title'>"; echo html_entity_decode($this->fields['name']); echo "</div>"; echo "<div class='ticket_description'>"; echo $this->setSimpleTextContent($this->fields['content']); echo "</div>"; echo "</div>"; // h_content TicketContent echo "</div>"; // h_item middle echo "<div class='break'></div>"; } // end timeline echo "</div>"; // h_item $user_position echo "<script type='text/javascript'>read_more();</script>"; }
/** * Show items for the group * * @param $tech boolean false search groups_id, true, search groups_id_tech **/ function showItems($tech) { global $DB, $CFG_GLPI; $rand = mt_rand(); $ID = $this->fields['id']; if ($tech) { $types = $CFG_GLPI['linkgroup_tech_types']; $field = 'groups_id_tech'; $title = __('Managed items'); } else { $types = $CFG_GLPI['linkgroup_types']; $field = 'groups_id'; $title = __('Used items'); } $tree = Session::getSavedOption(__CLASS__, 'tree', 0); $user = Session::getSavedOption(__CLASS__, 'user', 0); $type = Session::getSavedOption(__CLASS__, 'onlytype', ''); if (!in_array($type, $types)) { $type = ''; } echo "<div class='spaced'>"; // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='3'>{$title}</tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo __('Type') . " "; Dropdown::showItemType($types, array('value' => $type, 'name' => 'onlytype', 'plural' => true, 'on_change' => 'reloadTab("start=0&onlytype="+this.value)', 'checkright' => true)); if ($this->haveChildren()) { echo "</td><td class='center'>" . __('Child groups') . " "; Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)')); } else { $tree = 0; } if ($this->getField('is_usergroup')) { echo "</td><td class='center'>" . User::getTypeName(Session::getPluralNumber()) . " "; Dropdown::showYesNo('user', $user, -1, array('on_change' => 'reloadTab("start=0&user="******"</td></tr></table>"; $datas = array(); if ($type) { $types = array($type); } $start = isset($_GET['start']) ? intval($_GET['start']) : 0; $nb = $this->getDataItems($types, $field, $tree, $user, $start, $datas); $nbcan = 0; if ($nb) { Html::printAjaxPager('', $start, $nb); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); echo Html::hidden('field', array('value' => $field, 'data-glpicore-ma-tags' => 'common')); $massiveactionparams = array('num_displayed' => $nb, 'check_itemtype' => 'Group', 'check_items_id' => $ID, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('is_tech' => $tech, 'massive_action_fields' => array('field')), 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'changegroup' => __('Move'))); Html::showMassiveActions($massiveactionparams); echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr><th width='10'>"; $header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end = '</th>'; $header_end .= "<th>" . __('Type') . "</th><th>" . __('Name') . "</th><th>" . __('Entity') . "</th>"; if ($tree || $user) { $header_end .= "<th>" . sprintf(__('%1$s / %2$s'), self::getTypeName(1), User::getTypeName(1)) . "</th>"; } $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; $tuser = new User(); $group = new Group(); foreach ($datas as $data) { if (!($item = getItemForItemtype($data['itemtype']))) { continue; } echo "<tr class='tab_bg_1'><td>"; if ($item->canEdit($data['items_id'])) { Html::showMassiveActionCheckBox($data['itemtype'], $data['items_id']); } echo "</td><td>" . $item->getTypeName(1); echo "</td><td>" . $item->getLink(array('comments' => true)); echo "</td><td>" . Dropdown::getDropdownName("glpi_entities", $item->getEntityID()); if ($tree || $user) { echo "</td><td>"; if ($grp = $item->getField($field)) { if ($group->getFromDB($grp)) { echo $group->getLink(array('comments' => true)); } } else { if ($usr = $item->getField(str_replace('groups', 'users', $field))) { if ($tuser->getFromDB($usr)) { echo $tuser->getLink(array('comments' => true)); } } } } echo "</td></tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } if ($nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); } Html::closeForm(); if ($nb) { Html::printAjaxPager('', $start, $nb); } echo "</div>"; }
/** * show tooltip for user notification informations * * @param $type integer : user type * @param $canedit boolean : can edit ? * * @return nothing display **/ function showGroupsAssociated($type, $canedit) { global $CFG_GLPI, $LANG; $showgrouplink = 0; if (haveRight('group', 'r')) { $showgrouplink = 1; } $groupicon = self::getActorIcon('group', $type); $group = new Group(); if (isset($this->groups[$type]) && count($this->groups[$type])) { foreach ($this->groups[$type] as $k => $d) { echo "{$groupicon} "; if ($group->getFromDB($k)) { echo $group->getLink($showgrouplink); } if ($canedit) { echo " <a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?delete_group=delete_group&id=" . $d['id'] . "&tickets_id=" . $this->fields['id'] . "' title=\"" . $LANG['reservation'][6] . "\">\n <img src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png'\n alt=\"" . $LANG['buttons'][6] . "\" title=\"" . $LANG['buttons'][6] . "\"></a>"; } echo '<br>'; } } }
/** * Show users of a group * * @since version 0.83 * * @param $group Group object: the group **/ static function showForGroup(Group $group) { global $DB, $CFG_GLPI; $ID = $group->getID(); if (!User::canView() || !$group->can($ID, READ)) { return false; } // Have right to manage members $canedit = self::canUpdate(); $rand = mt_rand(); $user = new User(); $crit = Session::getSavedOption(__CLASS__, 'criterion', ''); $tree = Session::getSavedOption(__CLASS__, 'tree', 0); $used = array(); $ids = array(); // Retrieve member list $entityrestrict = self::getDataForGroup($group, $used, $ids, $crit, $tree); if ($canedit) { self::showAddUserForm($group, $ids, $entityrestrict, $crit); } // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . User::getTypeName(Session::getPluralNumber()) . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo _n('Criterion', 'Criteria', 1) . " "; $crits = array('' => Dropdown::EMPTY_VALUE, 'is_manager' => __('Manager'), 'is_userdelegate' => __('Delegatee')); Dropdown::showFromArray('crit', $crits, array('value' => $crit, 'on_change' => 'reloadTab("start=0&criterion="+this.value)')); if ($group->haveChildren()) { echo "</td><td class='center'>" . __('Child groups'); Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)')); } else { $tree = 0; } echo "</td></tr></table>"; $number = count($used); $start = isset($_GET['start']) ? intval($_GET['start']) : 0; if ($start >= $number) { $start = 0; } // Display results if ($number) { echo "<div class='spaced'>"; Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number); Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName())); if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => min($number - $start, $_SESSION['glpilist_limit']), 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov table-striped table-hover'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . User::getTypeName(1) . "</th>"; if ($tree) { $header_end .= "<th>" . Group::getTypeName(1) . "</th>"; } $header_end .= "<th>" . __('Dynamic') . "</th>"; $header_end .= "<th>" . __('Manager') . "</th>"; $header_end .= "<th>" . __('Delegatee') . "</th></tr>"; echo $header_begin . $header_top . $header_end; $tmpgrp = new Group(); for ($i = $start, $j = 0; $i < $number && $j < $_SESSION['glpilist_limit']; $i++, $j++) { $data = $used[$i]; $user->getFromDB($data["id"]); Session::addToNavigateListItems('User', $data["id"]); echo "\n<tr class='tab_bg_" . ($user->isDeleted() ? '1_2' : '1') . "'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } echo "<td>" . $user->getLink(); if ($tree) { echo "</td><td>"; if ($tmpgrp->getFromDB($data['groups_id'])) { echo $tmpgrp->getLink(array('comments' => true)); } } echo "</td><td class='center'>"; if ($data['is_dynamic']) { echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Dynamic') . "\">"; } echo "</td><td class='center'>"; if ($data['is_manager']) { echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Manager') . "\">"; } echo "</td><td class='center'>"; if ($data['is_userdelegate']) { echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Delegatee') . "\">"; } echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number); echo "</div>"; } else { echo "<p class='center b'>" . __('No item found') . "</p>"; } }
/** * show groups asociated * * @param $type integer : user type * @param $canedit boolean : can edit ? * * @return nothing display **/ function showGroupsAssociated($type, $canedit) { global $CFG_GLPI; $groupicon = self::getActorIcon('group', $type); $group = new Group(); if (isset($this->groups[$type]) && count($this->groups[$type])) { foreach ($this->groups[$type] as $d) { $k = $d['groups_id']; echo "{$groupicon} "; if ($group->getFromDB($k)) { echo $group->getLink(array('comments' => true)); } if ($canedit) { echo " "; Html::showSimpleForm($this->getFormURL(), 'delete_group', _x('button', 'Delete permanently'), array('id' => $d['id'], $this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png"); } echo '<br>'; } } }
function showContacts($itemtype, $items_id) { global $DB, $LANG, $CFG_GLPI; $this->addContact($itemtype, $items_id); $group = new Group(); $user = new User(); $rand = mt_rand(); echo "<form method='post' name='contact_item_form{$rand}' id='contact_item_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/contact_item.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>"; echo $LANG['plugin_monitoring']['contact'][20]; echo "</th>"; echo "</tr>"; echo "</table>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'> </th>"; echo "<th>" . $LANG['common'][35] . " - " . $LANG['common'][16] . "</th>"; echo "<th colspan='3'></th>"; echo "</tr>"; $used = array(); // Display groups first $query = "SELECT * FROM `" . $this->getTable() . "`\n WHERE `items_id`='" . $items_id . "'\n AND `itemtype`='" . $itemtype . "'\n AND `groups_id` > 0"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $group->getFromDB($data['groups_id']); echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>"; echo "</td>"; echo "<td class='center'>"; echo $group->getLink(1); echo "</td>"; echo "<td colspan='3'>"; echo "</td>"; echo "</tr>"; } echo "<tr>"; echo "<th width='10'> </th>"; echo "<th>" . $LANG['common'][34] . " - " . $LANG['common'][16] . "</th>"; echo "<th>" . $LANG['entity'][0] . "</th>"; echo "<th>" . $LANG['setup'][14] . "</th>"; echo "<th>" . $LANG['help'][35] . "</th>"; echo "</tr>"; $entity = new Entity(); $used = array(); // Display Users $query = "SELECT * FROM `" . $this->getTable() . "`\n WHERE `items_id`='" . $items_id . "'\n AND `itemtype`='" . $itemtype . "'\n AND `users_id` > 0"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $user->getFromDB($data['users_id']); echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>"; echo "</td>"; echo "<td class='center'>"; echo $user->getLink(1); echo "</td>"; $entity->getFromDB($data['entities_id']); echo "<td class='center'>"; echo $entity->getName() . " <strong>(R)</strong>"; echo "</td>"; echo "<td class='center'>"; echo $user->fields['email']; echo "</td>"; echo "<td class='center'>"; echo $user->fields['phone']; echo "</td>"; echo "</tr>"; } openArrowMassive("contact_item_form{$rand}", true); closeArrowMassive('deleteitem', $LANG['buttons'][6]); echo "</table>"; }
function showContacts($itemtype, $items_id) { global $DB,$CFG_GLPI; $this->addContact($itemtype, $items_id); $group = new Group(); $user = new User(); $rand = mt_rand(); echo "<form method='post' name='contact_item_form$rand' id='contact_item_form$rand' action=\"". $CFG_GLPI["root_doc"]."/plugins/monitoring/front/contact_item.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>"; echo __('Contacts', 'monitoring'); echo "</th>"; echo "</tr>"; echo "</table>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'> </th>"; echo "<th>".__('Group')." - ".__('Name')."</th>"; echo "<th colspan='3'></th>"; echo "</tr>"; $used = array(); // Display groups first $query = "SELECT * FROM `".$this->getTable()."` WHERE `items_id`='".$items_id."' AND `itemtype`='".$itemtype."' AND `groups_id` > 0"; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $group->getFromDB($data['groups_id']); echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>"; echo "</td>"; echo "<td class='center'>"; echo $group->getLink(1); echo "</td>"; echo "<td colspan='3'>"; echo "</td>"; echo "</tr>"; } echo "<tr>"; echo "<th width='10'> </th>"; echo "<th>".__('User')." - ".__('Name')."</th>"; echo "<th>".__('Entity')."</th>"; echo "<th>".__('Email address')."</th>"; echo "<th>".__('Phone')."</th>"; echo "</tr>"; $entity = new Entity(); $used = array(); // Display Users $query = "SELECT * FROM `".$this->getTable()."` WHERE `items_id`='".$items_id."' AND `itemtype`='".$itemtype."' AND `users_id` > 0"; $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { $user->getFromDB($data['users_id']); echo "<tr>"; echo "<td>"; echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>"; echo "</td>"; echo "<td class='center'>"; echo $user->getLink(1); echo "</td>"; $entity->getFromDB($data['entities_id']); echo "<td class='center'>"; echo $entity->getName()." <strong>(R)</strong>"; echo "</td>"; echo "<td class='center'>"; $a_emails = UserEmail::getAllForUser($data['users_id']); $first = 0; foreach ($a_emails as $email) { if ($first == 0) { echo $email; } $first++; } echo "</td>"; echo "<td class='center'>"; echo $user->fields['phone']; echo "</td>"; echo "</tr>"; } Html::openArrowMassives("contact_item_form$rand", true); Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently'))); Html::closeForm(); echo "</table>"; }
function plugin_timelineticket_giveItem($type, $ID, $data, $num) { global $CFG_GLPI, $DB; $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; switch ($table . '.' . $field) { case "glpi_plugin_timelineticket_grouplevels.groups": if (empty($data["ITEM_{$num}"])) { $out = __('None'); } else { $out = ""; $groups = json_decode($data["ITEM_{$num}"], true); if (!empty($groups)) { foreach ($groups as $key => $val) { $out .= Dropdown::getDropdownName("glpi_groups", $val) . "<br>"; } } } return $out; break; case "glpi_plugin_timelineticket_assigngroups.groups_id": $ptAssignGroup = new PluginTimelineticketAssignGroup(); $group = new Group(); $ticket = new Ticket(); $out = ""; $a_out = array(); $a_groupname = array(); if (!isset($data["ITEM_{$num}"]) or !strstr($data["ITEM_{$num}"], '$$')) { return ""; } $splitg = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($splitg as $datag) { $split = explode("\$\$", $datag); $group->getFromDB($split[0]); $ptAssignGroup->getFromDB($split[1]); $time = $ptAssignGroup->fields['delay']; if ($ptAssignGroup->fields['delay'] === NULL) { $ticket->getFromDB($data["ITEM_0"]); $calendar = new Calendar(); $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']); $datedebut = $ptAssignGroup->fields['date']; $enddate = $_SESSION["glpi_currenttime"]; if ($ticket->fields['status'] == Ticket::CLOSED) { $enddate = $ticket->fields['closedate']; } if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) { $time = $calendar->getActiveTimeBetween($datedebut, $enddate); } else { // cas 24/24 - 7/7 $time = strtotime($enddate) - strtotime($datedebut); } } else { if ($ptAssignGroup->fields['delay'] == 0) { $time = 0; } } $a_groupname[$group->fields['id']] = $group->getLink(); if (isset($a_out[$group->fields['id']])) { $a_out[$group->fields['id']] += $time; } else { $a_out[$group->fields['id']] = $time; } } $a_out_comp = array(); foreach ($a_out as $groups_id => $time) { $a_out_comp[] = $a_groupname[$groups_id] . " : " . Html::timestampToString($time, TRUE, FALSE); } $out = implode("<hr/>", $a_out_comp); return $out; break; } return ""; }
static function showGrupos(CommonDBTM $item, $withtemplate = '') { global $DB, $CFG_GLPI; $objeto = $item->getType(); $appli = new $objeto(); $ID = $item->fields['id']; $appli->getFromDB($item->fields['id']); //$canedit = $appli->can($appli->fields['id'],'w'); $canedit = $appli->canCreate(); //$canedit = Session::haveRight('update_ticket', 1); $rand = mt_rand(); $groups = self::getFormGroups($ID); $used = array(); if (!empty($groups)) { foreach ($groups as $data) { $used[$data["id"]] = $data["id"]; } } echo "<div class='center'>"; echo "<form name='form_grupo' id='form_grupo' method='post' action='../front/formgroup.form.php'>"; echo "<table class='tab_cadre_fixe'>"; echo "<th colspan=2>" . __('Grupos', 'Grupos') . "</th>"; echo "<tr>"; echo "<th>" . __('Grupo', 'Grupo') . " :" . "</th>"; echo "<td>"; if ($canedit) { Group::dropdown(array('name' => 'groups_id', 'entity' => $_SESSION['glpiactive_entity'], 'condition' => '`is_assign`')); } echo "</td>"; //----------------------------- echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' align = 'center'>"; echo "<input type='submit' name='agregarGrupo' value='Agregar' class='submit'>"; echo "</td></tr>"; echo "</table>"; echo "<input type='hidden' name='itemtype' value='Group'>"; echo "<input type='hidden' name='peticion_id' value='" . $item->fields['id'] . "'>"; //echo "</form>"; Html::closeForm(); echo "</div>"; // Listado de Grupos echo "<div class='spaced'>"; /* if ($canedit && count($used)) { $rand = mt_rand(); Html::openMassiveActionsForm('mass'.__CLASS__.$rand); echo "<input type='hidden' name='plugin_formcreator_forms_id' value='".$item->fields['id']."'>"; $massiveactionparams = array('num_displayed' => count($used), 'container' => 'mass'.__CLASS__.$rand); Html::showMassiveActions($massiveactionparams); }*/ if ($canedit && $withtemplate < 2) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => count($used)); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && count($used)) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . Group::getTypeName(1) . "</th>"; echo $header_begin . $header_top . $header_end; $group = new Group(); if (!empty($groups)) { Session::initNavigateListItems('PluginFormcreatorForm', sprintf(__('%1$s = %2$s'), $item::getTypeName(1), $item->getName())); foreach ($groups as $data) { if (!$group->getFromDB($data["id"])) { continue; } Session::addToNavigateListItems('PluginFormcreatorForm', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit && count($used)) { echo "<td width='10'>"; // echo __CLASS__; Html::showMassiveActionCheckBox('PluginFormcreatorForm_Item', $data["linkID"]); echo "</td>"; } $link = $data["completename"]; if ($_SESSION["glpiis_ids_visible"]) { $link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]); } $href = "<a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $link . "</a>"; echo "<td>" . $group->getLink() . "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; } else { echo "<tr class='tab_bg_1'>"; echo "<td colspan='5' class='center'>" . __('None') . "</td></tr>"; } echo "</table>"; if ($canedit && count($used)) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }