/** * Used to display each status time used for each group/user * * * @param Ticket $ticket */ static function ShowDetail(Ticket $ticket, $type) { $ptState = new PluginTimelineticketState(); if ($type == 'group') { $ptItem = new PluginTimelineticketAssignGroup(); } else { if ($type == 'user') { $ptItem = new PluginTimelineticketAssignUser(); } } $a_states = $ptState->find("`tickets_id`='" . $ticket->getField('id') . "'", "`date`"); $a_state_delays = array(); $a_state_num = array(); $delay = 0; $list_status = Ticket::getAllStatusArray(); $status = "new"; foreach ($a_states as $array) { $delay += $array['delay']; $a_state_delays[$delay] = $array['old_status']; $a_state_num[] = $delay; } $a_state_num[] = $delay; $last_delay = $delay; $a_groups = $ptItem->find("`tickets_id`='" . $ticket->getField('id') . "'", "`date`"); echo "<table class='tab_cadre_fixe' width='100%'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='" . (count($list_status) + 1) . "'>"; _e('Result details'); if ($type == 'group') { echo " (" . __('Groups in charge of the ticket', 'timelineticket') . ")"; } else { if ($type == 'user') { echo " (" . __('Technicians in charge of the ticket', 'timelineticket') . ")"; } } echo "</th>"; echo "</tr>"; echo "</tr>"; echo "<th>"; echo "</th>"; foreach ($list_status as $name) { echo "<th>"; echo $name; echo "</th>"; } echo "</tr>"; if ($type == 'group') { $a_details = PluginTimelineticketToolbox::getDetails($ticket, 'group', false); } else { if ($type == 'user') { $a_details = PluginTimelineticketToolbox::getDetails($ticket, 'user', false); } } foreach ($a_details as $items_id => $a_detail) { $a_status = array(); foreach ($a_detail as $data) { if (!isset($a_status[$data['Status']])) { $a_status[$data['Status']] = 0; } $a_status[$data['Status']] += $data['End'] - $data['Start']; } echo "<tr class='tab_bg_1'>"; if ($type == 'group') { echo "<td>" . Dropdown::getDropdownName("glpi_groups", $items_id) . "</td>"; } else { if ($type == 'user') { echo "<td>" . Dropdown::getDropdownName("glpi_users", $items_id) . "</td>"; } } foreach ($list_status as $status => $name) { echo "<td>"; if (isset($a_status[$status])) { echo Html::timestampToString($a_status[$status], true); } echo "</td>"; } echo "</tr>"; } echo "</table>"; }
function showTimeline($ticket, $params = array()) { global $CFG_GLPI; /* Create and populate the pData object */ $MyData = new pData(); /* Create the pChart object */ $myPicture = new pImage(820, 29, $MyData); /* Create the pIndicator object */ $Indicator = new pIndicator($myPicture); $myPicture->setFontProperties(array("FontName" => GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the indicator sections */ $IndicatorSections = array(); $_usersfinished = array(); $a_users_list = array(); $IndicatorSections = PluginTimelineticketToolbox::getDetails($ticket, 'user'); foreach ($IndicatorSections as $users_id => $data) { $a_users_list[$users_id] = $users_id; $a_end = end($data); if ($a_end['R'] == 235 && $a_end['G'] == 235 && $a_end['B'] == 235) { $_usersfinished[$users_id] = true; } else { $_usersfinished[$users_id] = false; } } echo "<tr>"; echo "<th colspan='2'>"; if (count($a_users_list) > 1) { _e('Technicians in charge of the ticket', 'timelineticket'); } else { _e('Technician in charge of the ticket'); } echo "</th>"; echo "</tr>"; foreach ($IndicatorSections as $users_id => $array) { echo "<tr class='tab_bg_2'>"; echo "<td width='100'>"; echo getUsername($users_id); echo "</td>"; echo "<td>"; if ($ticket->fields['status'] != Ticket::CLOSED && $_usersfinished[$users_id] != 0) { $IndicatorSettings = array("Values" => array(100, 201), "CaptionPosition" => INDICATOR_CAPTION_BOTTOM, "CaptionLayout" => INDICATOR_CAPTION_DEFAULT, "CaptionR" => 0, "CaptionG" => 0, "CaptionB" => 0, "DrawLeftHead" => false, "DrawRightHead" => true, "ValueDisplay" => false, "IndicatorSections" => $array, "SectionsMargin" => 0); $Indicator->draw(2, 2, 805, 25, $IndicatorSettings); } else { $IndicatorSettings = array("Values" => array(100, 201), "CaptionPosition" => INDICATOR_CAPTION_BOTTOM, "CaptionLayout" => INDICATOR_CAPTION_DEFAULT, "CaptionR" => 0, "CaptionG" => 0, "CaptionB" => 0, "DrawLeftHead" => false, "DrawRightHead" => false, "ValueDisplay" => false, "IndicatorSections" => $array, "SectionsMargin" => 0); $Indicator->draw(2, 2, 814, 25, $IndicatorSettings); } $filename = $uid = Session::getLoginUserID(false) . "_testuser" . $users_id; $myPicture->render(GLPI_GRAPH_DIR . "/" . $filename . ".png"); echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file=" . $filename . ".png'><br/>"; echo "</td>"; echo "</tr>"; } }
function showTimeline(CommonGLPI $ticket, $params = array()) { global $CFG_GLPI; /* Create and populate the pData object */ $MyData = new pData(); /* Create the pChart object */ $myPicture = new pImage(820, 29, $MyData); /* Create the pIndicator object */ $Indicator = new pIndicator($myPicture); $myPicture->setFontProperties(array("FontName" => GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the indicator sections */ $IndicatorSections = array(); $_groupsfinished = array(); $a_groups_list = array(); $IndicatorSections = PluginTimelineticketToolbox::getDetails($ticket, 'group'); foreach ($IndicatorSections as $groups_id => $data) { $a_groups_list[$groups_id] = $groups_id; $a_end = end($data); if ($a_end['R'] == 235 && $a_end['G'] == 235 && $a_end['B'] == 235) { $_groupsfinished[$groups_id] = true; } else { $_groupsfinished[$groups_id] = false; } } echo "<tr>"; echo "<th colspan='2'>"; if (count($a_groups_list) > 1) { _e('Groups in charge of the ticket', 'timelineticket'); } else { _e('Group in charge of the ticket'); } echo "</th>"; echo "</tr>"; $mylevels = array(); $restrict = getEntitiesRestrictRequest('', "glpi_plugin_timelineticket_grouplevels", '', '', true); $restrict .= " ORDER BY rank"; $levels = getAllDatasFromTable("glpi_plugin_timelineticket_grouplevels", $restrict); if (!empty($levels)) { foreach ($levels as $level) { if (!empty($level["groups"])) { $groups = json_decode($level["groups"], true); $mylevels[$level["name"]] = $groups; } } } $ticketlevels = array(); foreach ($IndicatorSections as $groups_id => $array) { foreach ($mylevels as $name => $groups) { if (in_array($groups_id, $groups)) { $ticketlevels[$name][] = $groups_id; } } } //No levels if (sizeof($ticketlevels) == 0) { foreach ($IndicatorSections as $groups_id => $array) { $ticketlevels[0][] = $groups_id; } } ksort($ticketlevels); foreach ($ticketlevels as $name => $groups) { if (!isset($ticketlevels[0])) { echo "<tr>"; echo "<th colspan='2'>"; echo $name; echo "</th>"; echo "</tr>"; } foreach ($IndicatorSections as $groups_id => $array) { if (in_array($groups_id, $groups)) { echo "<tr class='tab_bg_2'>"; echo "<td width='100'>"; echo Dropdown::getDropdownName("glpi_groups", $groups_id); echo "</td>"; echo "<td>"; if ($ticket->fields['status'] != Ticket::CLOSED && $_groupsfinished[$groups_id] === false) { $IndicatorSettings = array("Values" => array(100, 201), "CaptionPosition" => INDICATOR_CAPTION_BOTTOM, "CaptionLayout" => INDICATOR_CAPTION_DEFAULT, "CaptionR" => 0, "CaptionG" => 0, "CaptionB" => 0, "DrawLeftHead" => false, "DrawRightHead" => true, "ValueDisplay" => false, "IndicatorSections" => $array, "SectionsMargin" => 0); $Indicator->draw(2, 2, 805, 25, $IndicatorSettings); } else { $IndicatorSettings = array("Values" => array(100, 201), "CaptionPosition" => INDICATOR_CAPTION_BOTTOM, "CaptionLayout" => INDICATOR_CAPTION_DEFAULT, "CaptionR" => 0, "CaptionG" => 0, "CaptionB" => 0, "DrawLeftHead" => false, "DrawRightHead" => false, "ValueDisplay" => false, "IndicatorSections" => $array, "SectionsMargin" => 0); $Indicator->draw(2, 2, 814, 25, $IndicatorSettings); } $filename = $uid = Session::getLoginUserID(false) . "_testgroup" . $groups_id; $myPicture->render(GLPI_GRAPH_DIR . "/" . $filename . ".png"); echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file=" . $filename . ".png'><br/>"; echo "</td>"; echo "</tr>"; } } } // Return list for unit tests return $IndicatorSections; }
private function displayGroups($closed = true) { global $DB, $CFG_GLPI; $DB->connect(); $CFG_GLPI['root_doc'] = "http://127.0.0.1/fusion0.83/"; Session::loadLanguage("en_GB"); $ticket = new Ticket(); $ptAssignGroup = new PluginTimelineticketAssignGroup(); $a_storedate_temp = self::$storedate; $ticket->getFromDB(1); // $a_data = PluginTimelineticketDisplay::getTotaltimeEnddate($ticket); // ob_start(); // $a_data = $ptAssignGroup->showTimeline($ticket, $a_data); // ob_end_clean(); $a_data = PluginTimelineticketToolbox::getDetails($ticket, 'group', 0); foreach ($a_data as $num => $data) { foreach ($data as $num2 => $data2) { unset($data2['Caption']); unset($data2['R']); unset($data2['G']); unset($data2['B']); $a_data[$num][$num2] = $data2; } } $ticket_date = $ticket->fields['date']; $a_ref = array(); $a_ref[1] = array(array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[3]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[5]), 'Status' => Ticket::ASSIGNED), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[5]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[7]), 'Status' => Ticket::WAITING), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[13]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[16]), 'Status' => Ticket::WAITING), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[16]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[18]), 'Status' => Ticket::ASSIGNED)); if ($closed) { $a_ref[1][] = array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[18]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[20]), 'Status' => Ticket::SOLVED); } $a_ref[2] = array(array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[9]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[11]), 'Status' => Ticket::ASSIGNED), array('Start' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[11]), 'End' => PluginTimelineticketDisplay::getPeriodTime($ticket, $ticket_date, $a_storedate_temp[13]), 'Status' => Ticket::WAITING)); $this->assertEquals($a_ref, $a_data, 'Data used to display groups in graph'); }