Reminder::displayPlanningItem PHP Метод

displayPlanningItem() статический публичный Метод

Display a Planning Item
static public displayPlanningItem ( array $val, $who, $type = "", $complete ) : Nothing
$val array array of the item to display
$who ID of the user (0 if all)
$type position of the item in the time block (in, through, begin or end) (default '')
$complete complete display (more details) (default 0)
Результат Nothing (display function)
    static function displayPlanningItem(array $val, $who, $type = "", $complete = 0)
    {
        global $CFG_GLPI;
        $html = "";
        $rand = mt_rand();
        $users_id = "";
        // show users_id reminder
        $img = "rdv_private.png";
        // default icon for reminder
        if ($val["users_id"] != Session::getLoginUserID()) {
            $users_id = "<br>" . sprintf(__('%1$s: %2$s'), __('By'), getUserName($val["users_id"]));
            $img = "rdv_public.png";
        }
        $html .= "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $img . "' alt='' title=\"" . self::getTypeName(1) . "\">&nbsp;";
        $html .= "<a id='reminder_" . $val["reminders_id"] . $rand . "' href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $val["reminders_id"] . "'>";
        $html .= $users_id;
        $html .= "</a>";
        $recall = '';
        if (isset($val['reminders_id'])) {
            $pr = new PlanningRecall();
            if ($pr->getFromDBForItemAndUser($val['itemtype'], $val['reminders_id'], Session::getLoginUserID())) {
                $recall = "<br><span class='b'>" . sprintf(__('Recall on %s'), Html::convDateTime($pr->fields['when'])) . "<span>";
            }
        }
        if ($complete) {
            $html .= "<span>" . Planning::getState($val["state"]) . "</span><br>";
            $html .= "<div class='event-description'>" . $val["text"] . $recall . "</div>";
        } else {
            $html .= Html::showToolTip("<span class='b'>" . Planning::getState($val["state"]) . "</span><br>\n                                   " . $val["text"] . $recall, array('applyto' => "reminder_" . $val["reminders_id"] . $rand, 'display' => false));
        }
        return $html;
    }

Usage Example

Пример #1
0
 /**
  * Display a Planning Item
  *
  * @param $val Array of the item to display
  * @param $who ID of the user (0 if all)
  * @param $type position of the item in the time block (in, through, begin or end)
  * @param $complete complete display (more details)
  *
  * @return Nothing (display function)
  **/
 static function displayPlanningItem($val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI, $LANG, $PLUGIN_HOOKS;
     $color = "#e4e4e4";
     if (isset($val["state"])) {
         switch ($val["state"]) {
             case 0:
                 $color = "#efefe7";
                 // Information
                 break;
             case 1:
                 $color = "#fbfbfb";
                 // To be done
                 break;
             case 2:
                 $color = "#e7e7e2";
                 // Done
                 break;
         }
     }
     echo "<div style=' margin:auto; text-align:left; border:1px dashed #cccccc;\n             background-color: {$color}; font-size:9px; width:98%;'>";
     // Plugins case
     if (isset($val["plugin"]) && isset($PLUGIN_HOOKS['display_planning'][$val["plugin"]])) {
         $function = $PLUGIN_HOOKS['display_planning'][$val["plugin"]];
         if (is_callable($function)) {
             $val["type"] = $type;
             call_user_func($function, $val);
         }
     } else {
         if (isset($val["tickets_id"])) {
             // show tracking
             TicketPlanning::displayPlanningItem($val, $who, $type, $complete);
         } else {
             // show Reminder
             Reminder::displayPlanningItem($val, $who, $type, $complete);
         }
     }
     echo "</div><br>";
 }