/** * Print the reminder form * * @param $ID integer Id of the item to print * @param $options array of possible options: * - target filename : where to go when done. **/ function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); // Show Reminder or blank form $onfocus = ""; if (!$ID > 0) { // Create item : do getempty before check right to set default values $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\""; } $canedit = $this->can($ID, 'w'); if ($canedit) { Html::initEditorSystem('text'); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_2'><td>" . __('Title') . "</td>"; echo "<td>"; if ($canedit) { Html::autocompletionTextField($this, "name", array('size' => 80, 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus)); } else { echo $this->fields['name']; } echo "</td>\n"; echo "<td>" . __('By') . "</td>"; echo "<td>"; echo getUserName($this->fields["users_id"]); if (!$ID) { echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n"; } echo "</td></tr>\n"; echo "<tr class='tab_bg_2'>"; echo "<td>" . _x('reminder', 'Visibility') . "</td>"; echo "<td>"; echo '<table><tr><td>'; echo __('Begin') . '</td><td>'; Html::showDateTimeFormItem("begin_view_date", $this->fields["begin_view_date"], 1, true, $canedit); echo '</td><td>' . __('End') . '</td><td>'; Html::showDateTimeFormItem("end_view_date", $this->fields["end_view_date"], 1, true, $canedit); echo '</td></tr></table>'; echo "</td>"; echo "<td>" . __('Status') . "</td>"; echo "<td>"; if ($canedit) { Planning::dropdownState("state", $this->fields["state"]); } else { echo Planning::getState($this->fields["state"]); } echo "</td>\n"; echo "</tr>\n"; echo "<tr class='tab_bg_2'><td >" . __('Calendar') . "</td>"; echo "<td class='center'>"; if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function showPlan() {\n"; echo "Ext.get('plan').setDisplayed('none');"; $params = array('form' => 'remind', 'users_id' => $this->fields["users_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); if ($ID && $this->fields["is_planned"]) { $params['begin'] = $this->fields["begin"]; $params['end'] = $this->fields["end"]; } Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; } if (!$ID || !$this->fields["is_planned"]) { if (Session::haveRight("show_planning", "1") || Session::haveRight("show_group_planning", "1") || Session::haveRight("show_all_planning", "1")) { echo "<div id='plan' onClick='showPlan()'>\n"; echo "<a href='#' class='vsubmit'>" . __('Add to schedule') . "</a>"; } } else { if ($canedit) { echo "<div id='plan' onClick='showPlan()'>\n"; echo "<span class='showplan'>"; } //TRANS: %1$s is the begin date, %2$s is the end date printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if ($canedit) { echo "</span>"; } } if ($canedit) { echo "</div>\n"; echo "<div id='viewplan'>\n</div>\n"; } echo "</td>"; if ($ID && $this->fields["is_planned"] && PlanningRecall::isAvailable()) { echo "<td>" . _x('Planning', 'Reminder') . "</td>"; echo "<td>"; if ($canedit) { PlanningRecall::dropdown(array('itemtype' => 'Reminder', 'items_id' => $ID)); } else { // No edit right : use specific Planning Recall Form PlanningRecall::specificForm(array('itemtype' => 'Reminder', 'items_id' => $ID)); } echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "</tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Description') . "</td>" . "<td colspan='3'>"; if ($canedit) { echo "<textarea cols='115' rows='15' name='text'>" . $this->fields["text"] . "</textarea>"; } else { echo "<div id='kbanswer'>"; echo Toolbox::unclean_html_cross_side_scripting_deep($this->fields["text"]); echo "</div>"; } echo "</td></tr>\n"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
} 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') . " "; 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();
/** 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'> "; 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") . " "; 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 " <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") . " "; echo _n('Group', 'Groups', 1) . " "; $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; }
/** 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'> "; } 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; }
/** * 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') . " "; 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"; }
/** * Print the reminder form * * @param $ID integer Id of the item to print * @param $options array of possible options: * - target filename : where to go when done. * - from_planning_ajax : set to disable planning form part **/ function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); $rand = mt_rand(); // Show Reminder or blank form $onfocus = ""; if (!$ID > 0) { // Create item : do getempty before check right to set default values $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\""; } $canedit = $this->can($ID, UPDATE); $this->showFormHeader($options); echo "<tr class='tab_bg_2'><td>" . __('Title') . "</td>"; echo "<td>"; if (!$ID) { echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n"; } if ($canedit) { Html::autocompletionTextField($this, "name", array('size' => '80', 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus)); } else { echo $this->fields['name']; } if (isset($options['from_planning_edit_ajax']) && $options['from_planning_edit_ajax']) { echo Html::hidden('from_planning_edit_ajax'); } echo "</td>"; echo "</tr>"; if (!isset($options['from_planning_ajax'])) { echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Visibility') . "</td>"; echo "<td>"; echo '<table><tr><td>'; echo __('Begin') . '</td><td>'; Html::showDateTimeField("begin_view_date", array('value' => $this->fields["begin_view_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo '</td><td>' . __('End') . '</td><td>'; Html::showDateTimeField("end_view_date", array('value' => $this->fields["end_view_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo '</td></tr></table>'; echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Status') . "</td>"; echo "<td>"; if ($canedit) { Planning::dropdownState("state", $this->fields["state"]); } else { echo Planning::getState($this->fields["state"]); } echo "</td>\n"; echo "</tr>\n"; echo "<tr class='tab_bg_2'><td >" . __('Calendar') . "</td>"; echo "<td>"; if (isset($options['from_planning_ajax']) && $options['from_planning_ajax']) { echo Html::hidden('plan[begin]', array('value' => $options['begin'])); echo Html::hidden('plan[end]', array('value' => $options['end'])); printf(__('From %1$s to %2$s'), Html::convDateTime($options["begin"]), Html::convDateTime($options["end"])); echo "</td>"; } else { if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function showPlan{$rand}() {\n"; echo Html::jsHide("plan{$rand}"); $params = array('action' => 'add_event_classic_form', 'form' => 'remind', 'users_id' => $this->fields["users_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); if ($ID && $this->fields["is_planned"]) { $params['begin'] = $this->fields["begin"]; $params['end'] = $this->fields["end"]; } Ajax::updateItemJsCode("viewplan{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; } if (!$ID || !$this->fields["is_planned"]) { if (Session::haveRightsOr("planning", array(Planning::READMY, Planning::READGROUP, Planning::READALL))) { echo "<div id='plan{$rand}' onClick='showPlan{$rand}()'>\n"; echo "<a href='#' class='vsubmit'>" . __('Add to schedule') . "</a>"; } } else { if ($canedit) { echo "<div id='plan{$rand}' onClick='showPlan{$rand}()'>\n"; echo "<span class='showplan'>"; } //TRANS: %1$s is the begin date, %2$s is the end date printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if ($canedit) { echo "</span>"; } } if ($canedit) { echo "</div>\n"; echo "<div id='viewplan{$rand}'>\n</div>\n"; } echo "</td>"; if ($ID && $this->fields["is_planned"] && PlanningRecall::isAvailable()) { echo "<td>" . _x('Planning', 'Reminder') . "</td>"; echo "<td>"; if ($canedit) { PlanningRecall::dropdown(array('itemtype' => 'Reminder', 'items_id' => $ID)); } else { // No edit right : use specific Planning Recall Form PlanningRecall::specificForm(array('itemtype' => 'Reminder', 'items_id' => $ID)); } echo "</td>"; } else { echo "<td colspan='2'></td>"; } } echo "</tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Description') . "</td>" . "<td colspan='3'>"; if ($canedit) { $rand = mt_rand(); echo "<textarea rows='15' name='text' id='text{$rand}'>" . $this->fields["text"] . "</textarea>"; Html::initEditorSystem('text' . $rand); } else { echo "<div id='kbanswer'>"; echo Toolbox::unclean_html_cross_side_scripting_deep($this->fields["text"]); echo "</div>"; } echo "</td></tr>\n"; $this->showFormButtons($options); return true; }
/** 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'> "; } 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; }