/**
* 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;
}