TicketFollowup::showShortForTicket PHP Method

showShortForTicket() static public method

static public showShortForTicket ( $ID )
$ID integer ID of the ticket
    static function showShortForTicket($ID)
    {
        global $DB, $CFG_GLPI;
        // Print Followups for a job
        $showprivate = Session::haveRight(self::$rightname, self::SEEPRIVATE);
        $RESTRICT = "";
        if (!$showprivate) {
            $RESTRICT = " AND (`is_private` = '0'\n                            OR `users_id` ='" . Session::getLoginUserID() . "') ";
        }
        // Get Number of Followups
        $query = "SELECT *\n                FROM `glpi_ticketfollowups`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
        $result = $DB->query($query);
        $out = "";
        if ($DB->numrows($result) > 0) {
            $out .= "<div class='center'><table class='tab_cadre' width='100%'>\n\n                  <tr><th>" . __('Date') . "</th><th>" . __('Requester') . "</th>\n                  <th>" . __('Description') . "</th></tr>\n";
            $showuserlink = 0;
            if (Session::haveRight('user', READ)) {
                $showuserlink = 1;
            }
            while ($data = $DB->fetch_assoc($result)) {
                $out .= "<tr class='tab_bg_3'>\n                     <td class='center'>" . Html::convDateTime($data["date"]) . "</td>\n                     <td class='center'>" . getUserName($data["users_id"], $showuserlink) . "</td>\n                     <td width='70%' class='b'>" . Html::resume_text($data["content"], $CFG_GLPI["cut"]) . "\n                     </td></tr>";
            }
            $out .= "</table></div>";
        }
        return $out;
    }

Usage Example

コード例 #1
0
ファイル: ticket.class.php プロジェクト: gaforeror/glpi
 /**
  * Display a line for a ticket
  *
  * @param $id                 Integer  ID of the ticket
  * @param $followups          Boolean  show followup columns
  * @param $output_type        Integer  type of output (default Search::HTML_OUTPUT)
  * @param $row_num            Integer  row number (default 0)
  * @param $id_for_massaction  Integer  default 0 means no massive action (default 0)
  *
  */
 static function showShort($id, $followups, $output_type = Search::HTML_OUTPUT, $row_num = 0, $id_for_massaction = 0)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     /// TODO to be cleaned. Get datas and clean display links
     // Prints a job in short form
     // Should be called in a <table>-segment
     // Print links or not in case of user view
     // Make new job object and fill it from database, if success, print it
     $job = new self();
     $candelete = Session::haveRight("delete_ticket", "1");
     $canupdate = Session::haveRight("update_ticket", "1");
     $showprivate = Session::haveRight("show_full_ticket", "1");
     $align = "class='center";
     $align_desc = "class='left";
     if ($followups) {
         $align .= " top'";
         $align_desc .= " top'";
     } else {
         $align .= "'";
         $align_desc .= "'";
     }
     if ($job->getFromDB($id)) {
         $item_num = 1;
         $bgcolor = $_SESSION["glpipriority_" . $job->fields["priority"]];
         echo Search::showNewLine($output_type, $row_num % 2);
         $check_col = '';
         if (($candelete || $canupdate) && $output_type == Search::HTML_OUTPUT && $id_for_massaction) {
             $check_col = Html::getMassiveActionCheckBox(__CLASS__, $id_for_massaction);
         }
         echo Search::showItem($output_type, $check_col, $item_num, $row_num, $align);
         // First column
         $first_col = sprintf(__('%1$s: %2$s'), __('ID'), $job->fields["id"]);
         if ($output_type == Search::HTML_OUTPUT) {
             $first_col .= "<br><img src='" . self::getStatusIconURL($job->fields["status"]) . "'\n                                alt=\"" . self::getStatus($job->fields["status"]) . "\" title=\"" . self::getStatus($job->fields["status"]) . "\">";
         } else {
             $first_col = sprintf(__('%1$s - %2$s'), $first_col, self::getStatus($job->fields["status"]));
         }
         echo Search::showItem($output_type, $first_col, $item_num, $row_num, $align);
         // Second column
         if ($job->fields['status'] == self::CLOSED) {
             $second_col = sprintf(__('Closed on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['closedate']));
         } else {
             if ($job->fields['status'] == self::SOLVED) {
                 $second_col = sprintf(__('Solved on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['solvedate']));
             } else {
                 if ($job->fields['begin_waiting_date']) {
                     $second_col = sprintf(__('Put on hold on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['begin_waiting_date']));
                 } else {
                     if ($job->fields['due_date']) {
                         $second_col = sprintf(__('%1$s: %2$s'), __('Due date'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['due_date']));
                     } else {
                         $second_col = sprintf(__('Opened on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['date']));
                     }
                 }
             }
         }
         echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=130");
         // Second BIS column
         $second_col = Html::convDateTime($job->fields["date_mod"]);
         echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=90");
         // Second TER column
         if (count($_SESSION["glpiactiveentities"]) > 1) {
             $second_col = Dropdown::getDropdownName('glpi_entities', $job->fields['entities_id']);
             echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=100");
         }
         // Third Column
         echo Search::showItem($output_type, "<span class='b'>" . parent::getPriorityName($job->fields["priority"]) . "</span>", $item_num, $row_num, "{$align} bgcolor='{$bgcolor}'");
         // Fourth Column
         $fourth_col = "";
         if (isset($job->users[CommonITILActor::REQUESTER]) && count($job->users[CommonITILActor::REQUESTER])) {
             foreach ($job->users[CommonITILActor::REQUESTER] as $d) {
                 $userdata = getUserName($d["users_id"], 2);
                 $fourth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
                 $fourth_col .= "<br>";
             }
         }
         if (isset($job->groups[CommonITILActor::REQUESTER]) && count($job->groups[CommonITILActor::REQUESTER])) {
             foreach ($job->groups[CommonITILActor::REQUESTER] as $d) {
                 $fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
                 $fourth_col .= "<br>";
             }
         }
         echo Search::showItem($output_type, $fourth_col, $item_num, $row_num, $align);
         // Fifth column
         $fifth_col = "";
         if (isset($job->users[CommonITILActor::ASSIGN]) && count($job->users[CommonITILActor::ASSIGN])) {
             foreach ($job->users[CommonITILActor::ASSIGN] as $d) {
                 $userdata = getUserName($d["users_id"], 2);
                 $fifth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
                 $fifth_col .= "<br>";
             }
         }
         if (isset($job->groups[CommonITILActor::ASSIGN]) && count($job->groups[CommonITILActor::ASSIGN])) {
             foreach ($job->groups[CommonITILActor::ASSIGN] as $d) {
                 $fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
                 $fifth_col .= "<br>";
             }
         }
         if (isset($job->suppliers[CommonITILActor::ASSIGN]) && count($job->suppliers[CommonITILActor::ASSIGN])) {
             foreach ($job->suppliers[CommonITILActor::ASSIGN] as $d) {
                 $fifth_col .= Dropdown::getDropdownName("glpi_suppliers", $d["suppliers_id"]);
                 $fifth_col .= "<br>";
             }
         }
         echo Search::showItem($output_type, $fifth_col, $item_num, $row_num, $align);
         // Sixth Colum
         $sixth_col = "";
         $is_deleted = false;
         if (!empty($job->fields["itemtype"]) && $job->fields["items_id"] > 0) {
             if ($item = getItemForItemtype($job->fields["itemtype"])) {
                 if ($item->getFromDB($job->fields["items_id"])) {
                     $is_deleted = $item->isDeleted();
                     $sixth_col .= $item->getTypeName();
                     $sixth_col .= "<br><span class='b'>";
                     if ($item->canView()) {
                         $sixth_col .= $item->getLink(array('linkoption' => $output_type == Search::HTML_OUTPUT));
                     } else {
                         $sixth_col .= $item->getNameID();
                     }
                     $sixth_col .= "</span>";
                 }
             }
         } else {
             if (empty($job->fields["itemtype"])) {
                 $sixth_col = __('General');
             }
         }
         echo Search::showItem($output_type, $sixth_col, $item_num, $row_num, $is_deleted ? " class='center deleted' " : $align);
         // Seventh column
         echo Search::showItem($output_type, "<span class='b'>" . Dropdown::getDropdownName('glpi_itilcategories', $job->fields["itilcategories_id"]) . "</span>", $item_num, $row_num, $align);
         // Eigth column
         $eigth_column = "<span class='b'>" . $job->fields["name"] . "</span>&nbsp;";
         // Add link
         if ($job->canViewItem()) {
             $eigth_column = "<a id='ticket" . $job->fields["id"] . "{$rand}' href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $job->fields["id"] . "\">{$eigth_column}</a>";
             if ($followups && $output_type == Search::HTML_OUTPUT) {
                 $eigth_column .= TicketFollowup::showShortForTicket($job->fields["id"]);
             } else {
                 $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, sprintf(__('%1$s - %2$s'), $job->numberOfFollowups($showprivate), $job->numberOfTasks($showprivate)));
             }
         }
         if ($output_type == Search::HTML_OUTPUT) {
             $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip($job->fields['content'], array('display' => false, 'applyto' => "ticket" . $job->fields["id"] . $rand)));
         }
         echo Search::showItem($output_type, $eigth_column, $item_num, $row_num, $align_desc . "width='300'");
         // Finish Line
         echo Search::showEndLine($output_type);
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' ><i>" . __('No ticket in progress.') . "</i></td></tr>";
     }
 }
All Usage Examples Of TicketFollowup::showShortForTicket