Пример #1
0
 /**
  * Display linked tickets to a ticket
  *
  * @param $ID ID of the ticket id
  *
  * @return nothing display
  **/
 static function displayLinkedTicketsTo($ID)
 {
     global $DB, $CFG_GLPI;
     $tickets = self::getLinkedTicketsTo($ID);
     $canupdate = Session::haveRight('ticket', UPDATE);
     $ticket = new Ticket();
     if (is_array($tickets) && count($tickets)) {
         foreach ($tickets as $linkID => $data) {
             if ($ticket->getFromDB($data['tickets_id'])) {
                 $icons = "<img src='" . Ticket::getStatusIconURL($ticket->fields["status"]) . "' alt=\"" . Ticket::getStatus($ticket->fields["status"]) . "\"\n                             title=\"" . Ticket::getStatus($ticket->fields["status"]) . "\">";
                 if ($canupdate) {
                     $icons .= '&nbsp;' . Html::getSimpleForm(static::getFormURL(), 'purge', _x('button', 'Delete permanently'), array('id' => $linkID, 'tickets_id' => $ID), $CFG_GLPI["root_doc"] . "/pics/delete.png");
                 }
                 $text = sprintf(__('%1$s %2$s'), self::getLinkName($data['link']), $ticket->getLink(array('forceid' => true)));
                 printf(__('%1$s %2$s'), $text, $icons);
             }
             echo '<br>';
         }
     }
 }
 /**
  * Display linked tickets to a ticket
  *
  * @param $ID ID of the ticket id
  *
  * @return nothing display
  **/
 static function displayLinkedTicketsTo($ID)
 {
     global $DB, $LANG, $CFG_GLPI;
     $tickets = self::getLinkedTicketsTo($ID);
     $canupdate = haveRight('update_ticket', '1');
     $ticket = new Ticket();
     if (is_array($tickets) && count($tickets)) {
         foreach ($tickets as $linkID => $data) {
             echo self::getLinkName($data['link']) . "&nbsp;";
             if (!$_SESSION['glpiis_ids_visible']) {
                 echo $LANG['common'][2] . "&nbsp;" . $data['tickets_id'] . "&nbsp;:&nbsp;";
             }
             if ($ticket->getFromDB($data['tickets_id'])) {
                 echo $ticket->getLink();
                 echo "&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $ticket->fields["status"] . ".png' alt=\"" . Ticket::getStatus($ticket->fields["status"]) . "\"\n                             title=\"" . Ticket::getStatus($ticket->fields["status"]) . "\">";
                 if ($canupdate) {
                     echo "&nbsp;<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?delete_link=delete_link&amp;id={$linkID}" . "&amp;tickets_id={$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>';
         }
     }
 }
Пример #3
0
 /**
  * Print the item costs
  *
  * @param $item                  CommonITILObject object or Project
  * @param $withtemplate boolean  Template or basic item (default '')
  *
  * @return total cost
  **/
 static function showForObject($item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $forproject = false;
     if (Toolbox::is_a($item, 'Project')) {
         $forproject = true;
     }
     $ID = $item->fields['id'];
     if (!$item->getFromDB($ID) || !$item->canViewItem() || !static::canView()) {
         return false;
     }
     $canedit = false;
     if (!$forproject) {
         $canedit = $item->canUpdateItem();
     }
     echo "<div class='center'>";
     $condition = "= '{$ID}'";
     if ($forproject) {
         $condition = " IN ('" . implode("','", ProjectTask::getAllTicketsForProject($ID)) . "')";
     }
     $query = "SELECT *\n                FROM `" . static::getTable() . "`\n                WHERE `" . static::$items_id . "` {$condition}\n                ORDER BY `begin_date`";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function viewAddCost" . $ID . "_{$rand}() {\n";
         $params = array('type' => static::getType(), 'parenttype' => static::$itemtype, static::$items_id => $ID, 'id' => -1);
         Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>\n";
         if (static::canCreate()) {
             echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
             echo __('Add a new cost') . "</a></div>\n";
         }
     }
     $total = 0;
     $total_time = 0;
     $total_costtime = 0;
     $total_fixed = 0;
     $total_material = 0;
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'>";
         if ($forproject) {
             echo "<th colspan='10'>" . _n('Ticket cost', 'Ticket costs', $DB->numrows($result)) . "</th>";
         } else {
             echo "<th colspan='7'>" . self::getTypeName($DB->numrows($result)) . "</th>";
             echo "<th>" . __('Item duration') . "</th>";
             echo "<th>" . CommonITILObject::getActionTime($item->fields['actiontime']) . "</th>";
         }
         echo "</tr>";
         if ($DB->numrows($result)) {
             echo "<tr>";
             if ($forproject) {
                 echo "<th>" . __('Ticket') . "</th>";
                 $ticket = new Ticket();
             }
             echo "<th>" . __('Name') . "</th>";
             echo "<th>" . __('Begin date') . "</th>";
             echo "<th>" . __('End date') . "</th>";
             echo "<th>" . __('Budget') . "</th>";
             echo "<th>" . __('Duration') . "</th>";
             echo "<th>" . __('Time cost') . "</th>";
             echo "<th>" . __('Fixed cost') . "</th>";
             echo "<th>" . __('Material cost') . "</th>";
             echo "<th>" . __('Total cost') . "</th>";
             echo "</tr>";
             Session::initNavigateListItems(static::getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data[static::$items_id] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
                 $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
                 if ($forproject) {
                     $ticket->getFromDB($data['tickets_id']);
                     echo "<td>" . $ticket->getLink() . "</td>";
                 }
                 echo "<td>";
                 printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
                 if ($canedit) {
                     echo "\n<script type='text/javascript' >\n";
                     echo "function viewEditCost" . $data[static::$items_id] . "_" . $data["id"] . "_{$rand}() {\n";
                     $params = array('type' => static::getType(), 'parenttype' => static::$itemtype, static::$items_id => $data[static::$items_id], 'id' => $data["id"]);
                     Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                     echo "};";
                     echo "</script>\n";
                 }
                 echo "</td>";
                 echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
                 echo "<td>" . Html::convDate($data['end_date']) . "</td>";
                 echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
                 echo "<td>" . CommonITILObject::getActionTime($data['actiontime']) . "</td>";
                 $total_time += $data['actiontime'];
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost_time']) . "</td>";
                 $total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP;
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost_fixed']) . "</td>";
                 $total_fixed += $data['cost_fixed'];
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost_material']) . "</td>";
                 $total_material += $data['cost_material'];
                 $cost = self::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']);
                 echo "<td class='numeric'>" . Html::formatNumber($cost) . "</td>";
                 $total += $cost;
                 echo "</tr>";
                 Session::addToNavigateListItems(static::getType(), $data['id']);
             }
             $colspan = 4;
             if ($forproject) {
                 $colspan++;
             }
             echo "<tr class='b noHover'><td colspan='{$colspan}' class='right'>" . __('Total') . '</td>';
             echo "<td>" . CommonITILObject::getActionTime($total_time) . "</td>";
             echo "<td class='numeric'>" . Html::formatNumber($total_costtime) . "</td>";
             echo "<td class='numeric'>" . Html::formatNumber($total_fixed) . '</td>';
             echo "<td class='numeric'>" . Html::formatNumber($total_material) . '</td>';
             echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>';
         } else {
             echo "<tr><th colspan='9'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
     }
     echo "</div><br>";
     return $total;
 }
         }
     }
 }
 $row_num++;
 $num = 1;
 echo Search::showNewLine($output_type);
 echo Search::showItem($output_type, $data['id'], $num, $row_num);
 echo Search::showItem($output_type, Dropdown::getDropdownName('glpi_entities', $data['entities_id']), $num, $row_num);
 echo Search::showItem($output_type, Ticket::getStatus($data["status"]), $num, $row_num);
 echo Search::showItem($output_type, Html::convDateTime($data['date']), $num, $row_num);
 echo Search::showItem($output_type, Html::convDateTime($data['date_mod']), $num, $row_num);
 echo Search::showItem($output_type, Ticket::getPriorityName($data['priority']), $num, $row_num);
 echo Search::showItem($output_type, $userdata, $num, $row_num);
 echo Search::showItem($output_type, Ticket::getTicketTypeName($data['type']), $num, $row_num);
 echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_itilcategories", $data["itilcategories_id"]), $num, $row_num);
 $out = $ticket->getLink();
 echo Search::showItem($output_type, $out, $num, $row_num);
 echo Search::showItem($output_type, Html::convDateTime($data['closedate']), $num, $row_num);
 echo Search::showItem($output_type, Dropdown::getDropdownName('glpi_requesttypes', $data["requesttypes_id"]), $num, $row_num);
 if ($output_type == Search::HTML_OUTPUT || $output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
     echo Search::showItem($output_type, Html::timestampToString($data["takeintoaccount_delay_stat"]), $num, $row_num);
 } else {
     echo Search::showItem($output_type, Html::formatNumber($data["takeintoaccount_delay_stat"] / 3600, false, 5), $num, $row_num);
 }
 echo Search::showItem($output_type, Dropdown::getDropdownName('glpi_slas', $data["slas_id"]), $num, $row_num);
 $time = 0;
 if (!empty($mylevels)) {
     foreach ($mylevels as $key => $val) {
         if (array_key_exists($key, $timelevels)) {
             $time = $timelevels[$key];
         } else {