/**
  * 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>";
 }
 static function getTotaltimeEnddate(CommonGLPI $ticket)
 {
     $totaltime = 0;
     $ptState = new PluginTimelineticketState();
     $a_states = $ptState->find("`tickets_id`='" . $ticket->getField('id') . "'", "date");
     $last_date = '';
     foreach ($a_states as $a_state) {
         $totaltime += $a_state['delay'];
         $last_date = $a_state['date'];
     }
     if ($ticket->fields['status'] != Ticket::CLOSED && isset($a_state['date'])) {
         $totaltime += PluginTimelineticketDisplay::getPeriodTime($ticket, $a_state['date'], date("Y-m-d H:i:s"));
     }
     $end_date = $totaltime;
     return array('totaltime' => $totaltime, 'end_date' => $end_date);
 }
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://github.com/pluginsGLPI/timelineticket
  @since     2013

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Html::header(PluginTimelineticketDisplay::getTypeName(2), $_SERVER["PHP_SELF"], "plugins", "timelineticket");
if (Session::haveRight("config", READ) || Session::haveRight("plugin_timelineticket_ticket", UPDATE)) {
    $ptConfig = new PluginTimelineticketConfig();
    $grplevel = new PluginTimelineticketGroupLevel();
    if (isset($_POST["reconstructStates"])) {
        ini_set("max_execution_time", "0");
        ini_set("memory_limit", "-1");
        $ptState = new PluginTimelineticketState();
        $ptState->reconstructTimeline();
        Html::back();
    } else {
        if (isset($_POST["reconstructGroups"])) {
            ini_set("max_execution_time", "0");
            ini_set("memory_limit", "-1");
            $ptGroup = new PluginTimelineticketAssignGroup();
            $ptGroup->reconstrucTimeline();
            Html::back();
        } else {
            if (isset($_POST["add_groups"]) || isset($_POST["delete_groups"])) {
                $grplevel->update($_POST);
                Html::back();
            } else {
                if (isset($_POST["update"])) {
示例#4
0
function plugin_timelineticket_ticket_purge(Ticket $item)
{
    // Instantiation of the object from the class PluginTimelineticketStates
    $ticketstate = new PluginTimelineticketState();
    $user = new PluginTimelineticketAssignUser();
    $group = new PluginTimelineticketAssignUser();
    $ticketstate->deleteByCriteria(array('tickets_id' => $item->getField("id")));
    $user->deleteByCriteria(array('tickets_id' => $item->getField("id")));
    $group->deleteByCriteria(array('tickets_id' => $item->getField("id")));
}