} else {
    $end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP);
}
echo "<table class='tab_cadre'>";
echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
$rand_begin = Html::showDateTimeField("plan[begin]", array('value' => $begin, 'timestep' => -1, 'maybeempty' => false, 'canedit' => true, 'mindate' => '', 'maxdate' => '', 'mintime' => $CFG_GLPI["planning_begin"], 'maxtime' => $CFG_GLPI["planning_end"]));
echo "</td></tr>\n";
echo "<tr class='tab_bg_2'><td>" . __('Period') . "&nbsp;";
if (isset($_POST["rand_user"])) {
    echo "<span id='user_available" . $_POST["rand_user"] . "'>";
    include_once GLPI_ROOT . '/ajax/planningcheck.php';
    echo "</span>";
}
echo "</td><td>";
$default_delay = floor((strtotime($end) - strtotime($begin)) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP;
$rand = Dropdown::showTimeStamp("plan[_duration]", array('min' => 0, 'max' => 50 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
echo "<br><div id='date_end{$rand}'></div>";
$params = array('duration' => '__VALUE__', 'end' => $end, 'name' => "plan[end]", 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]);
Ajax::updateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
if ($default_delay == 0) {
    $params['duration'] = 0;
    Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
}
echo "</td></tr>\n";
if ((!isset($_POST["id"]) || $_POST["id"] == 0) && isset($_POST['itemtype']) && PlanningRecall::isAvailable()) {
    echo "<tr class='tab_bg_2'><td>" . _x('Planning', 'Reminder') . "</td><td>";
    PlanningRecall::dropdown(array('itemtype' => $_POST['itemtype'], 'items_id' => $_POST['items_id']));
    echo "</td></tr>";
}
echo "</table>\n";
Html::ajaxFooter();
Пример #2
0
    /** form for Task
     *
     * @param $ID        Integer : Id of the task
     * @param $options   array
     *     -  parent Object : the object
     **/
    function showForm($ID, $options = array())
    {
        global $DB, $CFG_GLPI;
        $rand_template = mt_rand();
        $rand_text = mt_rand();
        $rand_type = mt_rand();
        $rand_time = mt_rand();
        if (isset($options['parent']) && !empty($options['parent'])) {
            $item = $options['parent'];
        }
        $fkfield = $item->getForeignKeyField();
        if ($ID > 0) {
            $this->check($ID, READ);
        } else {
            // Create item
            $options[$fkfield] = $item->getField('id');
            $this->check(-1, CREATE, $options);
        }
        $rand = mt_rand();
        $this->showFormHeader($options);
        $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED);
        $rowspan = 5;
        if ($this->maybePrivate()) {
            $rowspan++;
        }
        if (isset($this->fields["state"])) {
            $rowspan++;
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td rowspan='{$rowspan}' style='width:100px'>" . __('Description') . "</td>";
        echo "<td rowspan='{$rowspan}' style='width:50%' id='content{$rand_text}'>" . "<textarea name='content' style='width: 95%; height: 160px' id='task{$rand_text}'>" . $this->fields["content"] . "</textarea>";
        echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });");
        echo "</td>";
        echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
        echo "</td></tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td style='width:100px'>" . _n('Task template', 'Task templates', 1) . "</td><td>";
        TaskTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'on_change' => 'tasktemplate_update(this.value)'));
        echo "</td>";
        echo "</tr>";
        echo Html::scriptBlock('
         function tasktemplate_update(value) {
            jQuery.ajax({
               url: "' . $CFG_GLPI["root_doc"] . '/ajax/task.php",
               type: "POST",
               data: {
                  tasktemplates_id: value
               }
            }).done(function(datas) {
               datas.taskcategories_id = isNaN(parseInt(datas.taskcategories_id)) ? 0 : parseInt(datas.taskcategories_id);
               datas.actiontime = isNaN(parseInt(datas.actiontime)) ? 0 : parseInt(datas.actiontime);

               $("#task' . $rand_text . '").html(datas.content);
               $("#dropdown_taskcategories_id' . $rand_type . '").select2("val", parseInt(datas.taskcategories_id));
               $("#dropdown_actiontime' . $rand_time . '").select2("val", parseInt(datas.actiontime));
            });
         }
      ');
        if ($ID > 0) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Date') . "</td>";
            echo "<td>";
            Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false));
            echo "</tr>";
        } else {
            echo "<tr class='tab_bg_1'>";
            echo "<td colspan='2'>&nbsp;";
            echo "</tr>";
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Category') . "</td><td>";
        TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'rand' => $rand_type, 'entity' => $item->fields["entities_id"], 'condition' => "`is_active` = '1'"));
        echo "</td></tr>\n";
        if (isset($this->fields["state"])) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Status') . "</td><td>";
            Planning::dropdownState("state", $this->fields["state"]);
            echo "</td></tr>\n";
        }
        if ($this->maybePrivate()) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Private') . "</td>";
            echo "<td>";
            Dropdown::showYesNo('is_private', $this->fields["is_private"]);
            echo "</td>";
            echo "</tr>";
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Duration') . "</td><td>";
        $toadd = array();
        for ($i = 9; $i <= 100; $i++) {
            $toadd[] = $i * HOUR_TIMESTAMP;
        }
        Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'rand' => $rand_time, 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
        echo "</td></tr>\n";
        if ($ID <= 0) {
            Document_Item::showSimpleAddForItem($item);
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('By') . "</td>";
        echo "<td colspan='2'>";
        echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . "&nbsp;";
        echo _n('User', 'Users', 1);
        $rand_user = mt_rand();
        $params = array('name' => "users_id_tech", 'value' => $ID > -1 ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"], 'width' => '');
        $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
        User::dropdown($params);
        echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
        echo "&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n             title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n             class='calendrier'>";
        echo "</a>";
        Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
        echo "<br />";
        echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . "&nbsp;";
        echo _n('Group', 'Groups', 1) . "&nbsp;";
        $rand_group = mt_rand();
        $params = array('name' => "groups_id_tech", 'value' => $ID > -1 ? $this->fields["groups_id_tech"] : Dropdown::EMPTY_VALUE, 'condition' => "is_task", 'rand' => $rand_group, 'entity' => $item->fields["entities_id"]);
        $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "group_available{$rand_group}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
        Group::dropdown($params);
        echo "</td>\n";
        echo "<td>";
        if ($canplan) {
            echo __('Planning');
        }
        if (!empty($this->fields["begin"])) {
            if (Session::haveRight('planning', Planning::READMY)) {
                echo "<script type='text/javascript' >\n";
                echo "function showPlan" . $ID . $rand_text . "() {\n";
                echo Html::jsHide("plan{$rand_text}");
                $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'groups_id' => $this->fields["groups_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
                Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
                echo "}";
                echo "</script>\n";
                echo "<div id='plan{$rand_text}' onClick='showPlan" . $ID . $rand_text . "()'>\n";
                echo "<span class='showplan'>";
            }
            if (isset($this->fields["state"])) {
                echo Planning::getState($this->fields["state"]) . "<br>";
            }
            printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
            if (isset($this->fields["users_id_tech"]) && $this->fields["users_id_tech"] > 0) {
                echo "<br>" . getUserName($this->fields["users_id_tech"]);
            }
            if (isset($this->fields["groups_id_tech"]) && $this->fields["groups_id_tech"] > 0) {
                echo "<br>" . Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"]);
            }
            if (Session::haveRight('planning', Planning::READMY)) {
                echo "</span>";
                echo "</div>\n";
                echo "<div id='viewplan{$rand_text}'></div>\n";
            }
        } else {
            if ($canplan) {
                echo "<script type='text/javascript' >\n";
                echo "function showPlanUpdate{$rand_text}() {\n";
                echo Html::jsHide("plan{$rand_text}");
                $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'entity' => $item->fields['entities_id'], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'itemtype' => $this->getType(), 'items_id' => $this->getID());
                Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
                echo "};";
                echo "</script>";
                if ($canplan) {
                    echo "<div id='plan{$rand_text}'  onClick='showPlanUpdate{$rand_text}()'>\n";
                    echo "<span class='vsubmit'>" . __('Plan this task') . "</span>";
                    echo "</div>\n";
                    echo "<div id='viewplan{$rand_text}'></div>\n";
                }
            } else {
                _e('None');
            }
        }
        echo "</td></tr>";
        if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
            echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>";
            PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
            echo "</td><td colspan='2'></td></tr>";
        }
        $this->showFormButtons($options);
        return true;
    }
Пример #3
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 "";
 }
Пример #4
0
LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84.3
*/
include '../inc/includes.php';
Session::checkLoginUser();
$pr = new PlanningRecall();
if (isset($_POST["update"])) {
    $pr->manageDatas($_POST['_planningrecall']);
    Html::back();
}
Html::displayErrorAndDie("lost");
Пример #5
0
 /** form for Task
  *
  * @param $ID        Integer : Id of the task
  * @param $options   array
  *     -  parent Object : the object
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     $fkfield = $item->getForeignKeyField();
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options[$fkfield] = $item->getField('id');
         $this->check(-1, CREATE, $options);
     }
     $rand = mt_rand();
     $this->showFormHeader($options);
     $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED);
     $rowspan = 3;
     if ($this->maybePrivate()) {
         $rowspan++;
     }
     if (isset($this->fields["state"])) {
         $rowspan++;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='{$rowspan}' class='middle'>" . __('Description') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea id ='content{$rand}' name='content' cols='50' rows='{$rowspan}'>" . $this->fields["content"] . "</textarea>";
     echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });");
     echo "</td>";
     if ($ID > 0) {
         echo "<td>" . __('Date') . "</td>";
         echo "<td>";
         Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Category') . "</td><td>";
     TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"]));
     echo "</td></tr>\n";
     if (isset($this->fields["state"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Status') . "</td><td>";
         Planning::dropdownState("state", $this->fields["state"]);
         echo "</td></tr>\n";
     }
     if ($this->maybePrivate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Private') . "</td>";
         echo "<td>";
         Dropdown::showYesNo('is_private', $this->fields["is_private"]);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     Document_Item::showSimpleAddForItem($item);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('By');
     echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n             title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n             class='calendrier'>";
     echo "</a>";
     Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
     echo "</td>";
     echo "<td class='center'>";
     $rand_user = mt_rand();
     $params = array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"] ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"]);
     $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
     User::dropdown($params);
     echo "</td>\n";
     if ($canplan) {
         echo "<td>" . __('Planning') . "</td>";
     }
     echo "<td>";
     if (!empty($this->fields["begin"])) {
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $ID . "() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n";
             echo "<span class='showplan'>";
         }
         if (isset($this->fields["state"])) {
             echo Planning::getState($this->fields["state"]) . "<br>";
         }
         printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
         echo "<br>" . getUserName($this->fields["users_id_tech"]);
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if ($canplan) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'entity' => $_SESSION["glpiactive_entity"], 'rand_user' => $rand_user, 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             if ($canplan) {
                 echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
                 echo "<span class='vsubmit'>" . __('Plan this task') . "</span>";
                 echo "</div>\n";
                 echo "<div id='viewplan'></div>\n";
             }
         } else {
             _e('None');
         }
     }
     echo "</td></tr>";
     if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>";
         PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
Пример #6
0
 /**
  * Former front/planning.php before 9.1.
  * Display a classic form to plan an event (with begin fiel and duration)
  *
  * @since 9.1
  *
  * @param $params (array): array of parameters whou should contain :
  *   - id (integer): id of item who receive the planification
  *   - itemtype (string): itemtype of item who receive the planification
  *   - begin (string) : start date of event
  *   - end (optionnal) (string) : end date of event. Ifg missing, it will computerd from begin+1hour
  *   - rand_user (integer) : users_id to check planning avaibility
  */
 static function showAddEventClassicForm($params = array())
 {
     global $CFG_GLPI;
     if (isset($params["id"]) && $params["id"] > 0) {
         echo "<input type='hidden' name='plan[id]' value='" . $params["id"] . "'>";
     }
     $mintime = $CFG_GLPI["planning_begin"];
     if (isset($params["begin"]) && !empty($params["begin"])) {
         $begin = $params["begin"];
         $begintime = date("H:i:s", strtotime($begin));
         if ($begintime < $mintime) {
             $mintime = $begintime;
         }
     } else {
         $ts = $CFG_GLPI['time_step'] * 60;
         // passage en minutes
         $time = time() + $ts - 60;
         $time = floor($time / $ts) * $ts;
         $begin = date("Y-m-d H:i", $time);
     }
     if (isset($params["end"]) && !empty($params["end"])) {
         $end = $params["end"];
     } else {
         $end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP);
     }
     echo "<table class='tab_cadre'>";
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     $rand_begin = Html::showDateTimeField("plan[begin]", array('value' => $begin, 'timestep' => -1, 'maybeempty' => false, 'canedit' => true, 'mindate' => '', 'maxdate' => '', 'mintime' => $mintime, 'maxtime' => $CFG_GLPI["planning_end"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'><td>" . __('Period') . "&nbsp;";
     if (isset($params["rand_user"])) {
         echo "<span id='user_available" . $params["rand_user"] . "'>";
         include_once GLPI_ROOT . '/ajax/planningcheck.php';
         echo "</span>";
     }
     echo "</td><td>";
     $default_delay = floor((strtotime($end) - strtotime($begin)) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP;
     $rand = Dropdown::showTimeStamp("plan[_duration]", array('min' => 0, 'max' => 50 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $event_options = array('duration' => '__VALUE__', 'end' => $end, 'name' => "plan[end]", 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]);
     Ajax::updateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $event_options);
     if ($default_delay == 0) {
         $params['duration'] = 0;
         Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     }
     echo "</td></tr>\n";
     if ((!isset($params["id"]) || $params["id"] == 0) && isset($params['itemtype']) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_2'><td>" . _x('Planning', 'Reminder') . "</td><td>";
         PlanningRecall::dropdown(array('itemtype' => $params['itemtype'], 'items_id' => $params['items_id']));
         echo "</td></tr>";
     }
     echo "</table>\n";
 }
Пример #7
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;
 }
Пример #8
0
 /** form for Task
  *
  * @param $ID        Integer : Id of the task
  * @param $options   array
  *     -  parent Object : the object
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     $fkfield = $item->getForeignKeyField();
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $options[$fkfield] = $item->getField('id');
         $this->check(-1, 'w', $options);
     }
     $canplan = Session::haveRight("show_planning", "1");
     $this->showFormHeader($options);
     $rowspan = 5;
     if ($this->maybePrivate()) {
         $rowspan++;
     }
     // Recall
     if (!empty($this->fields["begin"])) {
         $rowspan++;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='{$rowspan}' class='middle right'>" . __('Description') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea name='content' cols='50' rows='{$rowspan}'>" . $this->fields["content"] . "</textarea></td>";
     if ($ID > 0) {
         echo "<td>" . __('Date') . "</td>";
         echo "<td>";
         Html::showDateTimeFormItem("date", $this->fields["date"], 1, false);
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Category') . "</td><td>";
     TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"]));
     echo "</td></tr>\n";
     if (isset($this->fields["state"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Status') . "</td><td>";
         Planning::dropdownState("state", $this->fields["state"]);
         echo "</td></tr>\n";
     }
     if ($this->maybePrivate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Private') . "</td>";
         echo "<td>";
         Dropdown::showYesNo('is_private', $this->fields["is_private"]);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Planning') . "</td>";
     echo "<td>";
     if (!empty($this->fields["begin"])) {
         if (Session::haveRight('show_planning', 1)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $ID . "() {\n";
             echo "Ext.get('plan').setDisplayed('none');";
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n";
             echo "<span class='showplan'>";
         }
         if (isset($this->fields["state"])) {
             echo Planning::getState($this->fields["state"]) . "<br>";
         }
         printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
         echo "<br>" . getUserName($this->fields["users_id_tech"]);
         if (Session::haveRight('show_planning', 1)) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if (Session::haveRight('show_planning', 1)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo "Ext.get('plan').setDisplayed('none');";
             $params = array('form' => 'followups', 'users_id' => Session::getLoginUserID(), 'entity' => $_SESSION["glpiactive_entity"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
             echo "<span class='showplan'>" . __('Plan this task') . "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         } else {
             _e('None');
         }
     }
     echo "</td></tr>";
     if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td>";
         PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }