/** * 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; }
/** * 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; }
/** * @param $item CommonITILObject * @param $rand * @param $showprivate (false by default) **/ function showInObjectSumnary(CommonITILObject $item, $rand, $showprivate = false) { global $DB, $CFG_GLPI; $canedit = isset($this->fields['can_edit']) && !$this->fields['can_edit'] ? false : $this->canEdit($this->fields['id']); $canview = $this->canViewItem(); echo "<tr class='tab_bg_"; if ($this->maybePrivate() && $this->fields['is_private'] == 1) { echo "4' "; } else { echo "2' "; } if ($canedit) { echo "style='cursor:pointer' onClick=\"viewEditTask" . $item->fields['id'] . $this->fields['id'] . "{$rand}();\""; } echo " id='viewfollowup" . $this->fields[$item->getForeignKeyField()] . $this->fields["id"] . "{$rand}'>"; if ($canview) { echo "<td>"; switch ($this->fields['state']) { case Planning::INFO: echo Html::image($CFG_GLPI['root_doc'] . "/pics/faqedit.png", array('title' => _n('Information', 'Information', 1))); break; case Planning::TODO: if (empty($this->fields['begin'])) { echo Html::image($CFG_GLPI['root_doc'] . "/pics/redbutton.png", array('title' => __('To do'))); } else { echo Html::image($CFG_GLPI['root_doc'] . "/pics/rdv.png", array('title' => __('Planned'))); } break; case Planning::DONE: echo Html::image($CFG_GLPI['root_doc'] . "/pics/greenbutton.png", array('title' => __('Done'))); break; } echo "</td>"; echo "<td>"; $typename = $this->getTypeName(1); if ($this->fields['taskcategories_id']) { printf(__('%1$s - %2$s'), $typename, Dropdown::getDropdownName('glpi_taskcategories', $this->fields['taskcategories_id'])); } else { echo $typename; } echo "</td>"; echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditTask" . $item->fields['id'] . $this->fields["id"] . "{$rand}() {\n"; $params = array('type' => $this->getType(), 'parenttype' => $item->getType(), $item->getForeignKeyField() => $this->fields[$item->getForeignKeyField()], 'id' => $this->fields["id"]); Ajax::updateItemJsCode("viewfollowup" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } //else echo "--no--"; echo Html::convDateTime($this->fields["date"]) . "</td>"; echo "<td class='left'>" . nl2br(html_entity_decode($this->fields["content"])) . "</td>"; echo "<td>" . Html::timestampToString($this->fields["actiontime"], 0) . "</td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td>"; if ($this->maybePrivate() && $showprivate) { echo "<td>" . Dropdown::getYesNo($this->fields["is_private"]) . "</td>"; } echo "<td>"; if (empty($this->fields["begin"])) { if (isset($this->fields["state"])) { echo Planning::getState($this->fields["state"]) . "<br>"; } if ($this->fields["users_id_tech"] || $this->fields["groups_id_tech"]) { if (isset($this->fields["users_id_tech"])) { printf('%1$s %2$s', __('By user'), getUserName($this->fields["users_id_tech"])); } if (isset($this->fields["groups_id_tech"])) { $groupname = sprintf('%1$s %2$s', "<br />" . __('By group'), Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"])); if ($_SESSION['glpiis_ids_visible']) { $groupname = printf(__('%1$s (%2$s)'), $groupname, $this->fields["groups_id_tech"]); } echo $groupname; } } else { _e('None'); } } else { echo "<table width='100%'>"; if (isset($this->fields["state"])) { echo "<tr><td>" . _x('item', 'State') . "</td><td>"; echo Planning::getState($this->fields["state"]) . "</td></tr>"; } echo "<tr><td>" . __('Begin') . "</td><td>"; echo Html::convDateTime($this->fields["begin"]) . "</td></tr>"; echo "<tr><td>" . __('End') . "</td><td>"; echo Html::convDateTime($this->fields["end"]) . "</td></tr>"; echo "<tr><td>"; if ($this->fields["users_id_tech"]) { printf('%1$s %2$s', __('By user'), getUserName($this->fields["users_id_tech"])); } if ($this->fields["groups_id_tech"]) { $groupname = sprintf('%1$s %2$s', "<br />" . __('By group'), Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"])); if ($_SESSION['glpiis_ids_visible']) { $groupname = printf(__('%1$s (%2$s)'), $groupname, $this->fields["groups_id_tech"]); } echo $groupname; } if (PlanningRecall::isAvailable() && $_SESSION["glpiactiveprofile"]["interface"] == "central") { echo "<tr><td>" . _x('Planning', 'Reminder') . "</td><td>"; PlanningRecall::specificForm(array('itemtype' => $this->getType(), 'items_id' => $this->fields["id"])); } echo "</td></tr>"; echo "</table>"; } echo "</td></tr>\n"; } }
/** * @param $item CommonITILObject * @param $rand * @param $showprivate (false by default) **/ function showInObjectSumnary(CommonITILObject $item, $rand, $showprivate = false) { global $DB, $CFG_GLPI; $canedit = $this->can($this->fields['id'], 'w'); echo "<tr class='tab_bg_"; if ($this->maybePrivate() && $this->fields['is_private'] == 1) { echo "4' "; } else { echo "2' "; } if ($canedit) { echo "style='cursor:pointer' onClick=\"viewEditFollowup" . $item->fields['id'] . $this->fields['id'] . "{$rand}();\""; } echo " id='viewfollowup" . $this->fields[$item->getForeignKeyField()] . $this->fields["id"] . "{$rand}'>"; echo "<td>"; $typename = $this->getTypeName(1); if ($this->fields['taskcategories_id']) { printf(__('%1$s - %2$s'), $typename, Dropdown::getDropdownName('glpi_taskcategories', $this->fields['taskcategories_id'])); } else { echo $typename; } echo "</td>"; echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditFollowup" . $item->fields['id'] . $this->fields["id"] . "{$rand}() {\n"; $params = array('type' => $this->getType(), 'parenttype' => $item->getType(), $item->getForeignKeyField() => $this->fields[$item->getForeignKeyField()], 'id' => $this->fields["id"]); Ajax::updateItemJsCode("viewfollowup" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } //else echo "--no--"; echo Html::convDateTime($this->fields["date"]) . "</td>"; echo "<td class='left'>" . nl2br($this->fields["content"]) . "</td>"; echo "<td>"; echo Html::timestampToString($this->fields["actiontime"], 0); echo "</td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td>"; if ($this->maybePrivate() && $showprivate) { echo "<td>" . Dropdown::getYesNo($this->fields["is_private"]) . "</td>"; } echo "<td>"; if (empty($this->fields["begin"])) { if (isset($this->fields["state"])) { echo Planning::getState($this->fields["state"]) . "<br>"; } _e('None'); } else { echo "<table>"; if (isset($this->fields["state"])) { echo "<tr><td>" . _x('item', 'State') . "</td><td>"; echo Planning::getState($this->fields["state"]) . "</td></tr>"; } echo "<tr><td>" . __('Begin') . "</td><td>"; echo Html::convDateTime($this->fields["begin"]) . "</td></tr>"; echo "<tr><td>" . __('End') . "</td><td>"; echo Html::convDateTime($this->fields["end"]) . "</td></tr>"; echo "<tr><td>" . __('By') . "</td><td>"; echo getUserName($this->fields["users_id_tech"]) . "</td></tr>"; if (PlanningRecall::isAvailable()) { echo "<tr><td>" . _x('Planning', 'Reminder') . "</td><td>"; PlanningRecall::specificForm(array('itemtype' => $this->getType(), 'items_id' => $this->fields["id"])); echo "</td></tr>"; } echo "</table>"; } echo "</td>"; echo "</tr>\n"; }