Exemplo n.º 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)
  *                         (default '')
  * @param $complete        complete display (more details) (default 0)
  *
  * @return Nothing (display function)
  **/
 static function displayPlanningItem(array $val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI;
     $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";
     }
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $img . "' alt='' title=\"" . self::getTypeName(1) . "\">&nbsp;";
     echo "<a id='reminder_" . $val["reminders_id"] . $rand . "' href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $val["reminders_id"] . "'>";
     switch ($type) {
         case "in":
             //TRANS: %1$s is the start time of a planned item, %2$s is the end
             $beginend = sprintf(__('From %1$s to %2$s'), date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"])));
             printf(__('%1$s: %2$s'), $beginend, Html::resume_text($val["name"], 80));
             break;
         case "through":
             echo Html::resume_text($val["name"], 80);
             break;
         case "begin":
             $start = sprintf(__('Start at %s'), date("H:i", strtotime($val["begin"])));
             printf(__('%1$s: %2$s'), $start, Html::resume_text($val["name"], 80));
             break;
         case "end":
             $end = sprintf(__('End at %s'), date("H:i", strtotime($val["end"])));
             printf(__('%1$s: %2$s'), $end, Html::resume_text($val["name"], 80));
             break;
     }
     echo $users_id;
     echo "</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) {
         echo "<br><span class='b'>" . Planning::getState($val["state"]) . "</span><br>";
         echo $val["text"] . $recall;
     } else {
         Html::showToolTip("<span class='b'>" . Planning::getState($val["state"]) . "</span><br>\n                              " . $val["text"] . $recall, array('applyto' => "reminder_" . $val["reminders_id"] . $rand));
     }
     echo "";
 }
Exemplo n.º 2
0
 /**
  * Display a Planning Item
  *
  * @param $itemtype  itemtype
  * @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)
  *                         (default '')
  * @param $complete        complete display (more details) (default 0)
  *
  * @return Nothing (display function)
  **/
 static function genericDisplayPlanningItem($itemtype, array $val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     $styleText = "";
     if (isset($val["state"])) {
         switch ($val["state"]) {
             case 2:
                 // Done
                 $styleText = "color:#747474;";
                 break;
         }
     }
     $parenttype = str_replace('Task', '', $itemtype);
     if ($parent = getItemForItemtype($parenttype)) {
         $parenttype_fk = $parent->getForeignKeyField();
     } else {
         return;
     }
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv_interv.png' alt='' title=\"" . Html::entities_deep($parent->getTypeName(1)) . "\">&nbsp;&nbsp;";
     echo "<img src='" . $parent->getStatusIconURL($val["status"]) . "' alt='" . Html::entities_deep($parent->getStatus($val["status"])) . "' title=\"" . Html::entities_deep($parent->getStatus($val["status"])) . "\">";
     echo "&nbsp;<a id='content_tracking_" . $val["id"] . $rand . "'\n                   href='" . Toolbox::getItemTypeFormURL($parenttype) . "?id=" . $val[$parenttype_fk] . "'\n                   style='{$styleText}'>";
     switch ($type) {
         case "in":
             //TRANS: %1$s is the start time of a planned item, %2$s is the end
             printf(__('From %1$s to %2$s :'), date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"])));
             break;
         case "through":
             break;
         case "begin":
             //TRANS: %s is the start time of a planned item
             printf(__('Start at %s:'), date("H:i", strtotime($val["begin"])));
             break;
         case "end":
             //TRANS: %s is the end time of a planned item
             printf(__('End at %s:'), date("H:i", strtotime($val["end"])));
             break;
     }
     echo "<br>";
     //TRANS: %1$s is name of the item, %2$d is its ID
     printf(__('%1$s (#%2$d)'), Html::resume_text($val["name"], 80), $val[$parenttype_fk]);
     if (!empty($val["device"])) {
         echo "<br>" . $val["device"];
     }
     if ($who <= 0) {
         // show tech for "show all and show group"
         echo "<br>";
         //TRANS: %s is user name
         printf(__('By %s'), getUserName($val["users_id_tech"]));
     }
     echo "</a>";
     $recall = '';
     if (isset($val[getForeignKeyFieldForItemType($itemtype)]) && PlanningRecall::isAvailable()) {
         $pr = new PlanningRecall();
         if ($pr->getFromDBForItemAndUser($val['itemtype'], $val[getForeignKeyFieldForItemType($itemtype)], Session::getLoginUserID())) {
             $recall = "<br><span class='b'>" . sprintf(__('Recall on %s'), Html::convDateTime($pr->fields['when'])) . "<span>";
         }
     }
     if ($complete) {
         echo "<br><span class='b'>";
         if (isset($val["state"])) {
             echo Planning::getState($val["state"]) . "<br>";
         }
         echo sprintf(__('%1$s: %2$s'), __('Priority'), $parent->getPriorityName($val["priority"]));
         echo "<br>" . __('Description') . "</span><br>" . $val["content"];
         echo $recall;
     } else {
         $content = "<span class='b'>";
         if (isset($val["state"])) {
             $content .= Planning::getState($val["state"]) . "<br>";
         }
         $content .= sprintf(__('%1$s: %2$s'), __('Priority'), $parent->getPriorityName($val["priority"])) . "<br>" . __('Description') . "</span><br>" . $val["content"] . $recall;
         Html::showToolTip($content, array('applyto' => "content_tracking_" . $val["id"] . $rand));
     }
 }
Exemplo n.º 3
0
 /**
  * Display a Planning Item
  *
  * @param $itemtype  itemtype
  * @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)
  *                         (default '')
  * @param $complete        complete display (more details) (default 0)
  *
  * @return Nothing (display function)
  **/
 static function genericDisplayPlanningItem($itemtype, array $val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI;
     $html = "";
     $rand = mt_rand();
     $styleText = "";
     if (isset($val["state"])) {
         switch ($val["state"]) {
             case 2:
                 // Done
                 $styleText = "color:#747474;";
                 break;
         }
     }
     $parenttype = str_replace('Task', '', $itemtype);
     if ($parent = getItemForItemtype($parenttype)) {
         $parenttype_fk = $parent->getForeignKeyField();
     } else {
         return;
     }
     $html .= "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv_interv.png' alt='' title=\"" . Html::entities_deep($parent->getTypeName(1)) . "\">&nbsp;&nbsp;";
     $html .= "<img src='" . $parent->getStatusIconURL($val["status"]) . "' alt='" . Html::entities_deep($parent->getStatus($val["status"])) . "' title=\"" . Html::entities_deep($parent->getStatus($val["status"])) . "\">";
     $html .= "&nbsp;<a id='content_tracking_" . $val["id"] . $rand . "'\n                   href='" . Toolbox::getItemTypeFormURL($parenttype) . "?id=" . $val[$parenttype_fk] . "'\n                   style='{$styleText}'>";
     if (!empty($val["device"])) {
         $html .= "<br>" . $val["device"];
     }
     if ($who <= 0) {
         // show tech for "show all and show group"
         $html .= "<br>";
         //TRANS: %s is user name
         $html .= sprintf(__('By %s'), getUserName($val["users_id_tech"]));
     }
     $html .= "</a>";
     $recall = '';
     if (isset($val[getForeignKeyFieldForItemType($itemtype)]) && PlanningRecall::isAvailable()) {
         $pr = new PlanningRecall();
         if ($pr->getFromDBForItemAndUser($val['itemtype'], $val[getForeignKeyFieldForItemType($itemtype)], Session::getLoginUserID())) {
             $recall = "<span class='b'>" . sprintf(__('Recall on %s'), Html::convDateTime($pr->fields['when'])) . "<span>";
         }
     }
     if (isset($val["state"])) {
         $html .= "<span>";
         $html .= Planning::getState($val["state"]);
         $html .= "</span>";
     }
     $html .= "<div>";
     $html .= sprintf(__('%1$s: %2$s'), __('Priority'), $parent->getPriorityName($val["priority"]));
     $html .= "</div>";
     $html .= "<div class='event-description'>" . html_entity_decode($val["content"]) . "</div>";
     $html .= $recall;
     return $html;
 }
Exemplo n.º 4
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)
  *                         (default '')
  * @param $complete        complete display (more details) (default 0)
  *
  * @return 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;
 }