Display DateTime form with calendar
static public showDateTimeFormItem ( $element, $value = '', $time_step, $maybeempty = true, $can_edit = true, $minDate = '', $maxDate = '', $minTime = '', $maxTime = '' ) : rand | ||
$element | name of the element | |
$value | default value to display (default '') | |
$time_step | step for time in minute (-1 use default config) (default -1) | |
$maybeempty | may be empty ? (true by default) | |
$can_edit | could not modify element (true by default) | |
$minDate | minimum allowed date (default '') | |
$maxDate | maximum allowed date (default '') | |
$minTime | minimum allowed time (default '') | |
$maxTime | maximum allowed time (default '') | |
return | rand | value used \deprecated since 0.84 used Html::showDateTimeField instead |
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 */ $AJAX_INCLUDE = 1; include '../inc/includes.php'; // Send UTF8 Headers header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); if (isset($_POST['value']) && strcmp($_POST['value'], '0') == 0) { if ($_POST['withtime']) { Html::showDateTimeFormItem($_POST['name'], $_POST['specificvalue']); } else { Html::showDateFormItem($_POST['name'], $_POST['specificvalue']); } } else { echo "<input type='hidden' name='" . $_POST['name'] . "' value='" . $_POST['value'] . "'>"; }
/** * 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; }
$end = $_POST["end"]; } else { $end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP); } echo "<table class='tab_cadre'>"; $rand_user = mt_rand(); if (isset($_POST["users_id"]) && isset($_POST["entity"])) { echo "<tr class='tab_bg_2'><td>" . __('By') . "</td>"; echo "<td class='center'>"; $params = array('name' => "plan[users_id]", 'value' => $_POST["users_id"], 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $_POST["entity"]); $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></tr>\n"; } echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>"; $rand_begin = Html::showDateTimeFormItem("plan[begin]", $begin, -1, false, true, '', '', $CFG_GLPI["planning_begin"], $CFG_GLPI["planning_end"]); echo "</td></tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Period') . " "; if (isset($_POST["users_id"])) { echo "<span id='user_available{$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;
/** * @param $ID * @param $options array **/ function showForm($ID, $options = array()) { global $CFG_GLPI, $DB; if (!static::canView()) { return false; } // In percent $colsize1 = '13'; $colsize2 = '37'; // Set default options if (!$ID) { $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'name' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'itilcategories_id' => 0); foreach ($values as $key => $val) { if (!isset($options[$key])) { $options[$key] = $val; } } if (isset($options['tickets_id'])) { $ticket = new Ticket(); if ($ticket->getFromDB($options['tickets_id'])) { $options['content'] = $ticket->getField('content'); $options['name'] = $ticket->getField('name'); $options['impact'] = $ticket->getField('impact'); $options['urgency'] = $ticket->getField('urgency'); $options['priority'] = $ticket->getField('priority'); $options['itilcategories_id'] = $ticket->getField('itilcategories_id'); } } } $this->initForm($ID, $options); $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>"; echo "<td class='left' width='{$colsize2}%'>"; if (isset($options['tickets_id'])) { echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>"; } $date = $this->fields["date"]; if (!$ID) { $date = date("Y-m-d H:i:s"); } Html::showDateTimeFormItem("date", $date, 1, false); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>"; echo "<td width='{$colsize2}%' class='left'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true); echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>"; User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); echo "</td>"; echo "<th>" . __('Last update') . "</th>"; echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n"; if ($this->fields['users_id_lastupdater'] > 0) { printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td></tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Date of solving') . "</th>"; echo "<td>"; Html::showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th>" . __('Closing date') . "</th>"; echo "<td>"; Html::showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Status') . "</th>"; echo "<td width='{$colsize2}%'>"; self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>"; echo "<td width='{$colsize2}%'>"; // Only change during creation OR when allowed to change priority OR when user is the creator $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Category') . "</th>"; echo "<td >"; $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_problem`='1'"); ITILCategory::dropdown($opt); echo "</td>"; echo "<th>" . __('Impact') . "</th>"; echo "<td>"; $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Total duration') . "</th>"; echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>"; echo "<th class='left'>" . __('Priority') . "</th>"; echo "<td>"; $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idajax = 'change_priority_' . mt_rand(); echo " <span id='{$idajax}' style='display:none'></span>"; $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); echo "</td>"; echo "</tr>"; echo "</table>"; $this->showActorsPartForm($ID, $options); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Title') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showName{$rand}() {\n"; echo "Ext.get('name{$rand}').setDisplayed('none');"; $params = array('maxlength' => 250, 'size' => 110, 'name' => 'name', 'data' => rawurlencode($this->fields["name"])); Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params); echo "}"; echo "</script>\n"; echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n"; if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->fields["name"]; } echo "</div>\n"; echo "<div id='viewname{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showName{$rand}();\n </script>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Description') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showDesc{$rand}() {\n"; echo "Ext.get('desc{$rand}').setDisplayed('none');"; $params = array('rows' => 6, 'cols' => 110, 'name' => 'content', 'data' => rawurlencode($this->fields["content"])); Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params); echo "}"; echo "</script>\n"; echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n"; if (!empty($this->fields["content"])) { echo nl2br($this->fields["content"]); } else { _e('Empty description'); } echo "</div>\n"; echo "<div id='viewdesc{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>"; } echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th colspan='2' width='" . ($colsize1 + $colsize2) . "%'>"; $docnb = Document_Item::countForItem($this); echo "<a href=\"" . $this->getLinkURL() . "&forcetab=Document_Item\$1\">"; //TRANS: %d is the document number echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb); echo "</a></th>"; echo "<td colspan='2'></td>"; echo "</tr>"; } $options['colspan'] = 2; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
/** * Clone of Ticket::showForm() * Change '$this' by '$ticket', 'self' by 'Ticket' and 'parent' by 'Ticket' */ static function getCentral($ID = 0, $options = array()) { global $CFG_GLPI; // * Added by plugin survey ticket $ticket = new Ticket(); // * End of adding $default_values = Ticket::getDefaultValues(); // Get default values from posted values on reload form if (!isset($options['template_preview'])) { if (isset($_POST)) { $values = $_POST; } } // Restore saved value or override with page parameter $saved = $ticket->restoreInput(); foreach ($default_values as $name => $value) { if (!isset($values[$name])) { if (isset($saved[$name])) { $values[$name] = $saved[$name]; } else { $values[$name] = $value; } } } // Default check if ($ID > 0) { $ticket->check($ID, 'r'); } else { // Create item $ticket->check(-1, 'w', $values); } if (!$ID) { $ticket->userentities = array(); if ($values["_users_id_requester"]) { //Get all the user's entities $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true); //For each user's entity, check if the technician which creates the ticket have access to it foreach ($all_entities as $tmp => $ID_entity) { if (Session::haveAccessToEntity($ID_entity)) { $ticket->userentities[] = $ID_entity; } } } $ticket->countentitiesforuser = count($ticket->userentities); if ($ticket->countentitiesforuser > 0 && !in_array($ticket->fields["entities_id"], $ticket->userentities)) { // If entity is not in the list of user's entities, // then use as default value the first value of the user's entites list $ticket->fields["entities_id"] = $ticket->userentities[0]; // Pass to values $values['entities_id'] = $ticket->userentities[0]; } } if ($values['type'] <= 0) { $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE); } if (!isset($options['template_preview'])) { $options['template_preview'] = 0; } // Load ticket template if available : $tt = $ticket->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']); // Predefined fields from template : reset them if (isset($values['_predefined_fields'])) { $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']); } else { $values['_predefined_fields'] = array(); } // Store predefined fields to be able not to take into account on change template // Only manage predefined values on ticket creation $predefined_fields = array(); if (!$ID) { if (isset($tt->predefined) && count($tt->predefined)) { foreach ($tt->predefined as $predeffield => $predefvalue) { if (isset($default_values[$predeffield])) { // Is always default value : not set // Set if already predefined field // Set if ticket template change if ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) { // Load template data $values[$predeffield] = $predefvalue; $ticket->fields[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } } } else { // No template load : reset predefined values if (count($values['_predefined_fields'])) { foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) { if ($values[$predeffield] == $predefvalue) { $values[$predeffield] = $default_values[$predeffield]; } } } } } // Put ticket template on $values for actors $values['_tickettemplate'] = $tt; $canupdate = Session::haveRight('update_ticket', '1'); $canpriority = Session::haveRight('update_priority', '1'); $canstatus = $canupdate; if (in_array($ticket->fields['status'], $ticket->getClosedStatusArray())) { $canupdate = false; } $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } if (!$options['template_preview']) { $ticket->showTabs($options); } else { // Add all values to fields of tickets for template preview foreach ($values as $key => $val) { if (!isset($ticket->fields[$key])) { $ticket->fields[$key] = $val; } } } // In percent $colsize1 = '13'; $colsize2 = '29'; $colsize3 = '13'; $colsize4 = '45'; $canupdate_descr = $canupdate || $ticket->fields['status'] == Ticket::INCOMING && $ticket->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $ticket->numberOfFollowups() == 0 && $ticket->numberOfTasks() == 0; if (!$options['template_preview']) { echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>"; } echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe' id='mainformtable'>"; // Optional line $ismultientities = Session::isMultiEntitiesMode(); echo "<tr class='headerRow'>"; echo "<th colspan='4'>"; if ($ID) { $text = sprintf(__('%1$s - %2$s'), $ticket->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID)); if ($ismultientities) { $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $ticket->fields['entities_id'])); } echo $text; } else { if ($ismultientities) { printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $ticket->fields['entities_id'])); } else { _e('New ticket'); } } echo "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('date'); if (!$ID) { printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date')); } else { _e('Opening date'); } echo $tt->getEndHiddenFieldText('date'); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('date'); $date = $ticket->fields["date"]; if ($canupdate) { Html::showDateTimeFormItem("date", $date, 1, false); } else { echo Html::convDateTime($date); } echo $tt->getEndHiddenFieldValue('date', $ticket); echo "</td>"; // SLA echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date'); if (!$ID) { printf(__('%1$s%2$s'), __('Due date'), $tt->getMandatoryMark('due_date')); } else { _e('Due date'); } echo $tt->getEndHiddenFieldText('due_date'); echo "</th>"; echo "<td width='{$colsize4}%' class='nopadding'>"; if ($ID) { if ($ticket->fields["slas_id"] > 0) { echo "<table width='100%'><tr><td class='nopadding'>"; echo Html::convDateTime($ticket->fields["due_date"]); echo "</td><td class='b'>" . __('SLA') . "</td>"; echo "<td class='nopadding'>"; echo Dropdown::getDropdownName("glpi_slas", $ticket->fields["slas_id"]); $commentsla = ""; $slalevel = new SlaLevel(); if ($slalevel->getFromDB($ticket->fields['slalevels_id'])) { $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span><br>'; } $nextaction = new SlaLevel_Ticket(); if ($nextaction->getFromDBForTicket($ticket->fields["id"])) { $commentsla .= '<span class="b spaced">' . sprintf(__('Next escalation: %s'), Html::convDateTime($nextaction->fields['date'])) . '</span>'; if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) { $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span>'; } } $slaoptions = array(); if (Session::haveRight('config', 'r')) { $slaoptions['link'] = Toolbox::getItemTypeFormURL('SLA') . "?id=" . $ticket->fields["slas_id"]; } Html::showToolTip($commentsla, $slaoptions); if ($canupdate) { echo " <input type='submit' class='submit' name='sla_delete' value='" . _sx('button', 'Delete permanently') . "'>"; } echo "</td>"; echo "</tr></table>"; } else { echo "<table><tr><td class='nopadding'>"; echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeFormItem("due_date", $ticket->fields["due_date"], 1, true, $canupdate); echo $tt->getEndHiddenFieldValue('due_date', $ticket); echo "</td>"; if ($canupdate) { echo "<td>"; echo $tt->getBeginHiddenFieldText('slas_id'); echo "<span id='sla_action'>"; echo "<a class='vsubmit' " . Html::addConfirmationOnAction(array(__('The assignment of a SLA to a ticket causes the recalculation of the due date.'), __("Escalations defined in the SLA will be triggered under this new date.")), "cleanhide('sla_action');cleandisplay('sla_choice');") . ">" . __('Assign a SLA') . '</a>'; echo "</span>"; echo "<span id='sla_choice' style='display:none'>"; echo "<span class='b'>" . __('SLA') . "</span> "; Sla::dropdown(array('entity' => $ticket->fields["entities_id"], 'value' => $ticket->fields["slas_id"])); echo "</span>"; echo $tt->getEndHiddenFieldText('slas_id'); echo "</td>"; } echo "</tr></table>"; } } else { // New Ticket echo "<table><tr><td class='nopadding'>"; if ($ticket->fields["due_date"] == 'NULL') { $ticket->fields["due_date"] = ''; } echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeFormItem("due_date", $ticket->fields["due_date"], 1, false, $canupdate); echo $tt->getEndHiddenFieldValue('due_date', $ticket); echo "</td>"; if ($canupdate) { echo "<td class='nopadding b'>" . $tt->getBeginHiddenFieldText('slas_id'); printf(__('%1$s%2$s'), __('SLA'), $tt->getMandatoryMark('slas_id')); echo $tt->getEndHiddenFieldText('slas_id') . "</td>"; echo "<td class='nopadding'>" . $tt->getBeginHiddenFieldValue('slas_id'); Sla::dropdown(array('entity' => $ticket->fields["entities_id"], 'value' => $ticket->fields["slas_id"])); echo $tt->getEndHiddenFieldValue('slas_id', $ticket); echo "</td>"; } echo "</tr></table>"; } echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('By') . "</th>"; echo "<td width='{$colsize2}%'>"; if ($canupdate) { User::dropdown(array('name' => 'users_id_recipient', 'value' => $ticket->fields["users_id_recipient"], 'entity' => $ticket->fields["entities_id"], 'right' => 'all')); } else { echo getUserName($ticket->fields["users_id_recipient"], $showuserlink); } echo "</td>"; echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>"; echo "<td width='{$colsize4}%'>"; if ($ticket->fields['users_id_lastupdater'] > 0) { //TRANS: %1$s is the update date, %2$s is the last updater name printf(__('%1$s by %2$s'), Html::convDateTime($ticket->fields["date_mod"]), getUserName($ticket->fields["users_id_lastupdater"], $showuserlink)); } echo "</td>"; echo "</tr>"; } if ($ID && (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) || in_array($ticket->fields["status"], $ticket->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>"; echo "<td width='{$colsize2}%'>"; Html::showDateTimeFormItem("solvedate", $ticket->fields["solvedate"], 1, false, $canupdate); echo "</td>"; if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) { echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>"; echo "<td width='{$colsize4}%'>"; Html::showDateTimeFormItem("closedate", $ticket->fields["closedate"], 1, false, $canupdate); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } if ($ID) { echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>"; echo "<td width='{$colsize2}%'>"; // Permit to set type when creating ticket without update right if ($canupdate || !$ID) { $opt = array('value' => $ticket->fields["type"]); /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'submit()'; } $rand = Ticket::dropdownType('type', $opt); if ($ID) { $params = array('type' => '__VALUE__', 'entity_restrict' => $ticket->fields['entities_id'], 'value' => $ticket->fields['itilcategories_id'], 'currenttype' => $ticket->fields['type']); Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params); } } else { echo Ticket::getTicketTypeName($ticket->fields["type"]); } echo "</td>"; echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>"; echo "<td width='{$colsize4}%'>"; // Permit to set category when creating ticket without update right if ($canupdate || !$ID || $canupdate_descr) { $opt = array('value' => $ticket->fields["itilcategories_id"], 'entity' => $ticket->fields["entities_id"]); if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { $opt['condition'] = "`is_helpdeskvisible`='1' AND "; } else { $opt['condition'] = ''; } /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'submit()'; } /// if category mandatory, no empty choice /// no empty choice is default value set on ticket creation, else yes if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $ticket->fields["itilcategories_id"] > 0) { $opt['display_emptychoice'] = false; } switch ($ticket->fields["type"]) { case Ticket::INCIDENT_TYPE: $opt['condition'] .= "`is_incident`='1'"; break; case Ticket::DEMAND_TYPE: $opt['condition'] .= "`is_request`='1'"; break; default: break; } echo "<span id='show_category_by_type'>"; ITILCategory::dropdown($opt); echo "</span>"; } else { echo Dropdown::getDropdownName("glpi_itilcategories", $ticket->fields["itilcategories_id"]); } echo "</td>"; echo "</tr>"; if (!$ID) { echo "</table>"; $ticket->showActorsPartForm($ID, $values); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status'); printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status')); echo $tt->getEndHiddenFieldText('status') . "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('status'); if ($canstatus) { Ticket::dropdownStatus(array('value' => $ticket->fields["status"], 'showtype' => 'allowed')); } else { echo Ticket::getStatus($ticket->fields["status"]); } echo $tt->getEndHiddenFieldValue('status', $ticket); echo "</td>"; echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id'); printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id')); echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>"; echo "<td width='{$colsize4}%'>"; echo $tt->getBeginHiddenFieldValue('requesttypes_id'); if ($canupdate) { RequestType::dropdown(array('value' => $ticket->fields["requesttypes_id"])); } else { echo Dropdown::getDropdownName('glpi_requesttypes', $ticket->fields["requesttypes_id"]); } echo $tt->getEndHiddenFieldValue('requesttypes_id', $ticket); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('urgency'); printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')); echo $tt->getEndHiddenFieldText('urgency') . "</th>"; echo "<td>"; if ($canupdate && $canpriority || !$ID || $canupdate_descr) { // Only change during creation OR when allowed to change priority OR when user is the creator echo $tt->getBeginHiddenFieldValue('urgency'); $idurgency = Ticket::dropdownUrgency(array('value' => $ticket->fields["urgency"])); echo $tt->getEndHiddenFieldValue('urgency', $ticket); } else { $idurgency = "value_urgency" . mt_rand(); echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $ticket->fields["urgency"] . "'>"; echo Ticket::getUrgencyName($ticket->fields["urgency"]); } echo "</td>"; // Display validation state echo "<th>"; if (!$ID) { echo $tt->getBeginHiddenFieldText('_add_validation'); printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation')); echo $tt->getEndHiddenFieldText('_add_validation'); } else { echo $tt->getBeginHiddenFieldText('global_validation'); _e('Approval'); echo $tt->getEndHiddenFieldText('global_validation'); } echo "</th>"; echo "<td>"; if (!$ID) { echo $tt->getBeginHiddenFieldValue('_add_validation'); $validation_right = ''; if ($values['type'] == Ticket::INCIDENT_TYPE && Session::haveRight('create_incident_validation', 1)) { $validation_right = 'validate_incident'; } if ($values['type'] == Ticket::DEMAND_TYPE && Session::haveRight('create_request_validation', 1)) { $validation_right = 'validate_request'; } if (!empty($validation_right)) { User::dropdown(array('name' => "_add_validation", 'entity' => $ticket->fields['entities_id'], 'right' => $validation_right, 'value' => $values['_add_validation'])); } echo $tt->getEndHiddenFieldValue('_add_validation', $ticket); if ($tt->isPredefinedField('global_validation')) { echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>"; } } else { echo $tt->getBeginHiddenFieldValue('global_validation'); if ($canupdate) { TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $ticket->fields['global_validation'])); } else { echo TicketValidation::getStatus($ticket->fields['global_validation']); } echo $tt->getEndHiddenFieldValue('global_validation', $ticket); } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('impact'); printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact')); echo $tt->getEndHiddenFieldText('impact') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('impact'); if ($canupdate) { $idimpact = Ticket::dropdownImpact(array('value' => $ticket->fields["impact"])); } else { $idimpact = "value_impact" . mt_rand(); echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $ticket->fields["impact"] . "'>"; echo Ticket::getImpactName($ticket->fields["impact"]); } echo $tt->getEndHiddenFieldValue('impact', $ticket); echo "</td>"; echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('itemtype'); printf(__('%1$s%2$s'), __('Associated element'), $tt->getMandatoryMark('itemtype')); if ($ID && $canupdate) { echo " <img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n onClick=\"Ext.get('tickethardwareselection{$ID}').setDisplayed('block')\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'>"; } echo $tt->getEndHiddenFieldText('itemtype'); echo "</th>"; echo "<td rowspan='2'>"; echo $tt->getBeginHiddenFieldValue('itemtype'); // Select hardware on creation or if have update right if ($canupdate || !$ID || $canupdate_descr) { if ($ID) { if ($ticket->fields['itemtype'] && ($item = getItemForItemtype($ticket->fields['itemtype'])) && $ticket->fields["items_id"]) { if ($item->can($ticket->fields["items_id"], 'r')) { printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getLink(array('comments' => true))); } else { printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID()); } } } $dev_user_id = 0; $dev_itemtype = $ticket->fields["itemtype"]; $dev_items_id = $ticket->fields["items_id"]; if (!$ID) { $dev_user_id = $values['_users_id_requester']; $dev_itemtype = $values["itemtype"]; $dev_items_id = $values["items_id"]; } else { if (isset($ticket->users[CommonITILActor::REQUESTER]) && count($ticket->users[CommonITILActor::REQUESTER]) == 1) { foreach ($ticket->users[CommonITILActor::REQUESTER] as $user_id_single) { $dev_user_id = $user_id_single['users_id']; } } } if ($ID) { echo "<div id='tickethardwareselection{$ID}' style='display:none'>"; } if ($dev_user_id > 0) { Ticket::dropdownMyDevices($dev_user_id, $ticket->fields["entities_id"], $dev_itemtype, $dev_items_id); } Ticket::dropdownAllDevices("itemtype", $dev_itemtype, $dev_items_id, 1, $dev_user_id, $ticket->fields["entities_id"]); if ($ID) { echo "</div>"; } echo "<span id='item_ticket_selection_information'></span>"; } else { if ($ID && $ticket->fields['itemtype'] && ($item = getItemForItemtype($ticket->fields['itemtype']))) { $item->getFromDB($ticket->fields['items_id']); printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID()); } else { _e('General'); } } echo $tt->getEndHiddenFieldValue('itemtype', $ticket); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . sprintf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')) . "</th>"; echo "<td>"; $idajax = 'change_priority_' . mt_rand(); if ($canupdate && $canpriority && !$tt->isHiddenField('priority')) { $idpriority = Ticket::dropdownPriority(array('value' => $ticket->fields["priority"], 'withmajor' => true)); echo " <span id='{$idajax}' style='display:none'></span>"; } else { $idpriority = 0; echo "<span id='{$idajax}'>" . Ticket::getPriorityName($ticket->fields["priority"]) . "</span>"; } if ($canupdate || $canupdate_descr) { $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Need comment right to add a followup with the actiontime if (!$ID && Session::haveRight("global_add_followups", "1")) { echo "<th>" . $tt->getBeginHiddenFieldText('actiontime'); printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime')); echo $tt->getEndHiddenFieldText('actiontime') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('actiontime'); Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true)); echo $tt->getEndHiddenFieldValue('actiontime', $ticket); echo "</td>"; } else { echo "<th></th><td></td>"; } echo "<th>" . $tt->getBeginHiddenFieldText('locations_id'); printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id')); echo $tt->getEndHiddenFieldText('locations_id') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('locations_id'); if ($canupdate) { Location::dropdown(array('value' => $ticket->fields['locations_id'], 'entity' => $ticket->fields['entities_id'])); } else { echo Dropdown::getDropdownName('glpi_locations', $ticket->fields["locations_id"]); } echo $tt->getEndHiddenFieldValue('locations_id', $ticket); echo "</td></tr>"; echo "</table>"; if ($ID) { $values['canupdate'] = $canupdate; $ticket->showActorsPartForm($ID, $values); } $view_linked_tickets = $ID || $canupdate; echo "<table class='tab_cadre_fixe' id='mainformtable4'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name'); printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')); echo $tt->getEndHiddenFieldText('name') . "</th>"; echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>"; if (!$ID || $canupdate_descr) { echo $tt->getBeginHiddenFieldValue('name'); $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showName{$rand}() {\n"; echo "Ext.get('name{$rand}').setDisplayed('none');"; $params = array('maxlength' => 250, 'size' => 90, 'name' => 'name', 'data' => rawurlencode($ticket->fields["name"])); Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params); echo "}"; echo "</script>\n"; echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n"; if (empty($ticket->fields["name"])) { _e('Without title'); } else { echo $ticket->fields["name"]; } echo "</div>\n"; echo "<div id='viewname{$rand}'>\n"; echo "</div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showName{$rand}();\n </script>"; } echo $tt->getEndHiddenFieldValue('name', $ticket); } else { if (empty($ticket->fields["name"])) { _e('Without title'); } else { echo $ticket->fields["name"]; } } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content'); printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')); echo $tt->getEndHiddenFieldText('content') . "</th>"; echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>"; // * Added by plugin surveyticket $psTicketTemplate = new PluginSurveyticketTicketTemplate(); $psSurvey = new PluginSurveyticketSurvey(); $plugin_surveyticket_surveys_id = 0; $a_tickettemplates = current($psTicketTemplate->find("`tickettemplates_id`='" . $tt->fields['id'] . "'\n AND `type`='" . $values['type'] . "'\n AND `is_central`='1'")); if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) { $psSurvey = new PluginSurveyticketSurvey(); $psSurvey->getFromDB($a_tickettemplates['plugin_surveyticket_surveys_id']); if ($psSurvey->fields['is_active'] == 1) { $plugin_surveyticket_surveys_id = $a_tickettemplates['plugin_surveyticket_surveys_id']; $psSurvey = new PluginSurveyticketSurvey(); $psSurvey->startSurvey($plugin_surveyticket_surveys_id); } } else { // End of adding by plugin if (!$ID || $canupdate_descr) { // Admin =oui on autorise la modification de la description echo $tt->getBeginHiddenFieldValue('content'); $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showDesc{$rand}() {\n"; echo "Ext.get('desc{$rand}').setDisplayed('none');"; $params = array('rows' => 6, 'cols' => 90, 'name' => 'content', 'data' => rawurlencode($ticket->fields["content"])); Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params); echo "}"; echo "</script>\n"; echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n"; if (!empty($ticket->fields["content"])) { echo nl2br($ticket->fields["content"]); } else { _e('Empty description'); } echo "</div>\n"; echo "<div id='viewdesc{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>"; } echo $tt->getEndHiddenFieldValue('content', $ticket); } else { echo nl2br($ticket->fields["content"]); } // * Added by plugin surveyticket } // End of adding by plugin echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Permit to add doc when creating a ticket if (!$ID) { echo "<th width='{$colsize1}%'>" . sprintf(__('File (%s)'), Document::getMaxUploadSize()); echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt=\"" . __s('Help') . "\" onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000," . "height=800')\">"; echo " "; Ticket::showDocumentAddButton(); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo "<div id='uploadfiles'><input type='file' name='filename[]' size='20'></div></td>"; } else { echo "<th colspan='2'>"; $docnb = Document_Item::countForItem($ticket); echo "<a href=\"" . $ticket->getLinkURL() . "&forcetab=Document_Item\$1\">"; //TRANS: %d is the document number echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb); echo "</a></th>"; } if ($view_linked_tickets) { echo "<th width='{$colsize3}%'>" . _n('Linked ticket', 'Linked tickets', 2); $rand_linked_ticket = mt_rand(); if ($canupdate) { echo " "; echo "<img onClick=\"Ext.get('linkedticket{$rand_linked_ticket}').setDisplayed('block')\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } echo '</th>'; echo "<td width='{$colsize4}%'>"; if ($canupdate) { echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>"; Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : ''); printf(__('%1$s: %2$s'), __('Ticket'), __('ID')); echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n"; echo "<input type='text' name='_link[tickets_id_2]'\n value='" . (isset($values["_link"]) ? $values["_link"]['tickets_id_2'] : '') . "'\n size='10'>\n"; echo " "; echo "</div>"; if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) { echo "<script language='javascript'>Ext.get('linkedticket{$rand_linked_ticket}').\n setDisplayed('block');</script>"; } } Ticket_Ticket::displayLinkedTicketsTo($ID); echo "</td>"; } else { echo "<td></td>"; } echo "</tr>"; if ((!$ID || $canupdate || $canupdate_descr || Session::haveRight("assign_ticket", "1") || Session::haveRight("steal_ticket", "1")) && !$options['template_preview']) { echo "<tr class='tab_bg_1'>"; if ($ID) { if (Session::haveRight('delete_ticket', 1)) { echo "<td class='tab_bg_2 center' colspan='2'>"; if ($ticket->fields["is_deleted"] == 1) { echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'></td>"; } else { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'></td>"; } echo "<td class='tab_bg_2 center' colspan='2'>"; if ($ticket->fields["is_deleted"] == 1) { echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">"; } else { echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'></td>"; } } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>"; } echo "<input type='hidden' name='_read_date_mod' value='" . $ticket->getField('date_mod') . "'>"; } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; if ($tt->isField('id') && $tt->fields['id'] > 0) { echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>"; echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">"; } } } echo "</table>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</div>"; if (!$options['template_preview']) { Html::closeForm(); $ticket->addDivForTabs(); } return true; }
https://forge.indepnet.net/projects/projet ------------------------------------------------------------------------- LICENSE This file is part of Projet. Projet 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. Projet 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 Projet. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $AJAX_INCLUDE = 1; // Send UTF8 Headers header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); if (isset($_POST['duration']) && $_POST['duration'] == 0) { Html::showDateTimeFormItem($_POST['name'], $_POST['end'], -1, false, true, '', '', $_POST['global_begin'], $_POST['global_end']); }
Utilitaires 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. Utilitaires 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 utilitaires. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } if (isset($_POST["actionId"]) && !empty($_POST["actionId"])) { if ($_POST["actionId"] == PluginUtilitairesUtilitaire::DELETE_DELAY) { echo "<table><tr><td class='nopadding'>"; Html::showDateTimeFormItem("date", "", 1, false); echo "</td>"; } echo "<td><input type='hidden' name='choose[" . $_POST["action"] . "]' value='1'>"; echo " <input type='submit' name='action' class='submit' " . " value='" . _sx('button', 'Post') . "'></td>"; echo "</tr></table>"; }
static function prepareHtmlFields($fields, $items_id, $canedit = true, $show_table = true, $massiveaction = false) { if (empty($fields)) { return false; } //get object associated with this fields $tmp = $fields; $first_field = array_shift($tmp); $container_obj = new PluginFieldsContainer(); $container_obj->getFromDB($first_field['plugin_fields_containers_id']); $items_itemtype = ucfirst($container_obj->fields['itemtype']); $classname = "PluginFields" . $items_itemtype . preg_replace('/s$/', '', $container_obj->fields['name']); $obj = new $classname(); //find row for this object with the items_id $found_values = $obj->find("plugin_fields_containers_id = " . $first_field['plugin_fields_containers_id'] . " AND items_id = " . $items_id); $found_v = array_shift($found_values); // find profiles (to check if current profile can edit fields) $fprofile = new PluginFieldsProfile(); $found_p = $fprofile->find("`profiles_id` = '" . $_SESSION['glpiactiveprofile']['id'] . "'\n AND `plugin_fields_containers_id` = '" . $first_field['plugin_fields_containers_id'] . "'"); $first_found_p = array_shift($found_p); // test status for "CommonITILObject" objects if (is_subclass_of($items_itemtype, "CommonITILObject")) { $items_obj = new $items_itemtype(); $items_obj->getFromDB($items_id); if (in_array($items_obj->fields['status'], $items_obj->getClosedStatusArray()) || in_array($items_obj->fields['status'], $items_obj->getSolvedStatusArray()) || $first_found_p['right'] != CREATE) { $canedit = false; } } //show all fields $html = ""; $odd = 0; foreach ($fields as $field) { if ($field['type'] === 'header') { $html .= "<tr class='tab_bg_2'>"; $html .= "<th colspan='4'>" . $field['label'] . "</td>"; $html .= "</tr>"; $odd = 0; } else { //get value $value = ""; if (is_array($found_v)) { if ($field['type'] == "dropdown") { $value = $found_v["plugin_fields_" . $field['name'] . "dropdowns_id"]; } else { $value = $found_v[$field['name']]; } } if (isset($_SESSION['plugin']['fields']['values_sent'])) { if ($field['type'] == "dropdown") { $value = $_SESSION['plugin']['fields']['values_sent']["plugin_fields_" . $field['name'] . "dropdowns_id"]; } else { $value = $_SESSION['plugin']['fields']['values_sent'][$field['name']]; } } //get default value if (empty($value) && !empty($field['default_value'])) { $value = $field['default_value']; } //show field if ($show_table) { if ($odd % 2 == 0) { $html .= "<tr class='tab_bg_2'>"; } $required = $field['mandatory'] == 1 ? "<span class='red'>*</span>" : ''; if ($container_obj->fields['itemtype'] == 'Ticket' && $container_obj->fields['type'] == 'dom' && strpos($_SERVER['HTTP_REFERER'], ".injector.php") === false && strpos($_SERVER['HTTP_REFERER'], ".public.php") === false) { $html .= "<th width='13%'>" . $field['label'] . " : {$required}</th>"; } else { $html .= "<td>" . $field['label'] . " : {$required}</td>"; } $html .= "<td>"; } $readonly = $field['is_readonly']; switch ($field['type']) { case 'number': case 'text': $value = Html::cleanInputText($value); if ($canedit && !$readonly) { $html .= "<input type='text' name='" . $field['name'] . "' value=\"{$value}\" />"; } else { $html .= $value; } break; case 'textarea': if ($massiveaction) { continue; } if ($canedit && !$readonly) { $html .= "<textarea cols='45' rows='4' name='" . $field['name'] . "'>" . "{$value}</textarea>"; } else { $html .= nl2br($value); } break; case 'dropdown': if ($canedit && !$readonly) { //find entity on current object $obj = new $container_obj->fields['itemtype'](); $obj->getFromDB($items_id); ob_start(); if (strpos($field['name'], "dropdowns_id") !== false) { $dropdown_itemtype = getItemTypeForTable(getTableNameForForeignKeyField($field['name'])); } else { $dropdown_itemtype = PluginFieldsDropdown::getClassname($field['name']); } Dropdown::show($dropdown_itemtype, array('value' => $value, 'entity' => $obj->getEntityID())); $html .= ob_get_contents(); ob_end_clean(); } else { $dropdown_table = "glpi_plugin_fields_" . $field['name'] . "dropdowns"; $html .= Dropdown::getDropdownName($dropdown_table, $value); } break; case 'yesno': //in massive action, we must skip display for yesno (possible bug in framework) //otherwise double display of field if ($massiveaction) { continue; } if ($canedit && !$readonly) { ob_start(); Dropdown::showYesNo($field['name'], $value); $html .= ob_get_contents(); ob_end_clean(); } else { $html .= Dropdown::getYesNo($value); } break; case 'date': if ($massiveaction) { continue; } if ($canedit && !$readonly) { ob_start(); Html::showDateFormItem($field['name'], $value); $html .= ob_get_contents(); ob_end_clean(); } else { $html .= Html::convDate($value); } break; case 'datetime': if ($massiveaction) { continue; } if ($canedit && !$readonly) { ob_start(); Html::showDateTimeFormItem($field['name'], $value); $html .= ob_get_contents(); ob_end_clean(); } else { $html .= Html::convDateTime($value); } case 'dropdownuser': if ($massiveaction) { continue; } if ($canedit && !$readonly) { ob_start(); User::dropdown(array('name' => $field['name'], 'value' => $value, 'entity' => -1, 'right' => 'all', 'condition' => 'is_active=1 && is_deleted=0')); $html .= ob_get_contents(); ob_end_clean(); } else { $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } $html .= getUserName($value, $showuserlink); } } if ($show_table) { $html .= "</td>"; if ($odd % 2 == 1) { $html .= "</tr>"; } $odd++; } } } if ($show_table && $odd % 2 == 1) { $html .= "</tr>"; } unset($_SESSION['plugin']['fields']['values_sent']); return $html; }
function displayField($canedit, $name, $value, $template, $description = array()) { global $GO_BLACKLIST_FIELDS; $searchoption = PluginGenericobjectField::getOptionsWithGlobal($name, get_called_class()); if (!empty($searchoption) && !in_array($name, self::getFieldsToHide())) { $this->startColumn(); echo $searchoption['name']; if (isset($searchoption['autoname']) && $searchoption['autoname'] && $template) { echo "* "; } $this->endColumn(); $this->startColumn(); switch ($description['Type']) { case "int(11)": $fk_table = getTableNameForForeignKeyField($name); if ($fk_table != '') { $itemtype = getItemTypeForTable($fk_table); $dropdown = new $itemtype(); $parameters = array('name' => $name, 'value' => $value, 'comments' => true); if ($dropdown->isEntityAssign()) { $parameters["entity"] = $this->fields['entities_id']; } if ($dropdown->maybeRecursive()) { $parameters['entity_sons'] = true; } if (isset($searchoption['condition'])) { $parameters['condition'] = $searchoption['condition']; } Dropdown::show($itemtype, $parameters); } else { $min = $max = $step = 0; if (isset($searchoption['min'])) { $min = $searchoption['min']; } else { $min = 0; } if (isset($searchoption['max'])) { $max = $searchoption['max']; } else { $max = 100; } if (isset($searchoption['step'])) { $step = $searchoption['step']; } else { $step = 1; } Dropdown::showInteger($name, $value, $min, $max, $step); } break; case "tinyint(1)": Dropdown::showYesNo($name, $value); break; case "varchar(255)": if (isset($searchoption['autoname']) && $searchoption['autoname']) { $objectName = autoName($this->fields[$name], $name, $template === "newcomp", $this->getType(), $this->fields["entities_id"]); } else { $objectName = $this->fields[$name]; } Html::autocompletionTextField($this, $name, array('value' => $objectName)); break; case "longtext": case "text": echo "<textarea cols='40' rows='4' name='" . $name . "'>" . $value . "</textarea>"; break; case "date": Html::showDateFormItem($name, $value, false, true); break; case "datetime": Html::showDateTimeFormItem($name, $value, false, true); break; default: case "float": echo "<input type='text' name='{$name}' value='{$value}'>"; break; case 'decimal': echo "<input type='text' name='{$name}' value='" . Html::formatNumber($value) . "'>"; break; } $this->endColumn(); } }
/** * @param $options array **/ static function showDateRestrictionForm($options = array()) { echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'>"; $enabled = isset($options['enabled']) ? $options['enabled'] : false; if (!$enabled) { echo "<td colspan='4' class='center'>"; echo "<a href='#' onClick='activateRestriction()'>" . __('Enable filtering by date') . "</a>"; echo "</td></tr>"; } if ($enabled) { echo "<td>" . __('View updated users') . "</td>"; echo "<td>" . __('from') . "</td>"; echo "<td>"; $begin_date = isset($_SESSION['ldap_import']['begin_date']) ? $_SESSION['ldap_import']['begin_date'] : ''; Html::showDateTimeFormItem("begin_date", $begin_date, 1, true); echo "</td>"; echo "<td>" . __('to') . "</td>"; echo "<td>"; $end_date = isset($_SESSION['ldap_import']['end_date']) ? $_SESSION['ldap_import']['end_date'] : date('Y-m-d H:i:s', time() - DAY_TIMESTAMP); Html::showDateTimeFormItem("end_date", $end_date, 1, true); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td colspan='4' class='center'>"; echo "<a href='#' onClick='deactivateRestriction()'>" . __('Disable filtering by date') . "</a>"; echo "</td></tr>"; } echo "</table>"; }
/** 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; }
/** * Display actions possible in device * * @return nothing * **/ function showActions($items_id, $itemtype) { global $CFG_GLPI; // load all plugin and get method possible /* * Example : * * inventory * * snmpquery * * wakeonlan * * deploy => software * */ echo "<div align='center'>"; echo "<form method='post' name='' id='' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/taskjob.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='4'>"; echo __('Action on this device', 'fusioninventory'); echo " : </th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>"; echo __('Job', 'fusioninventory') . " :"; echo "</td>"; echo "<td align='center'>"; $a_methods = PluginFusioninventoryStaticmisc::getmethods(); $a_parseMethods = array(); $a_parseMethods[''] = "------"; foreach ($a_methods as $data) { $class = PluginFusioninventoryStaticmisc::getStaticmiscClass($data['directory']); if (is_callable(array($class, 'task_action_' . $data['method']))) { $a_itemtype = call_user_func(array($class, 'task_action_' . $data['method'])); if (in_array($itemtype, $a_itemtype)) { $a_parseMethods[$data['module'] . "||" . $data['method']] = $data['method']; } } } Dropdown::showFromArray('methodaction', $a_parseMethods); echo "</td>"; echo "<td align='center'>"; echo __('Scheduled date', 'fusioninventory') . " :"; echo "</td>"; echo "<td align='center'>"; Html::showDateTimeFormItem("datetime_start", date("Y-m-d H:i:s"), 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center' colspan='4'>"; echo "<input type='hidden' name='items_id' value='" . $items_id . "'/>"; echo "<input type='hidden' name='itemtype' value='" . $itemtype . "'/>"; echo "<input type='submit' name='itemaddaction' value=\"" . __('Add') . "\" class='submit' >"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; }
https://forge.indepnet.net/projects/resources ------------------------------------------------------------------------- LICENSE This file is part of Resources. Resources 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. Resources 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 Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $AJAX_INCLUDE = 1; // Send UTF8 Headers header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); if (isset($_POST['duration']) && $_POST['duration'] == 0) { Html::showDateTimeFormItem("plan[end]", $_POST['end'], -1, false, true, '', '', $_POST['global_begin'], $_POST['global_end']); }
/** * Print the waiting ticket form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * * @return Nothing (display) * */ function showForm($ID, $options = array()) { global $CFG_GLPI; // validation des droits if (!$this->canview()) { return false; } if ($ID > 0) { if (!($this->fields = self::getWaitingTicketFromDB($ID))) { $this->getEmpty(); } } else { // Create item $this->getEmpty(); } // If values are saved in session we retrieve it if (isset($_SESSION['glpi_plugin_moreticket_waiting'])) { foreach ($_SESSION['glpi_plugin_moreticket_waiting'] as $key => $value) { switch ($key) { case 'reason': $this->fields[$key] = stripslashes($value); break; default: $this->fields[$key] = $value; break; } } } unset($_SESSION['glpi_plugin_moreticket_waiting']); $config = new PluginMoreticketConfig(); echo "<div class='spaced' id='moreticket_waiting_ticket'>"; echo "</br>"; echo "<table class='moreticket_waiting_ticket' id='cl_menu'>"; echo "<tr><td>"; echo __('Reason', 'moreticket') . " : <span class='red'>*</span> "; Html::autocompletionTextField($this, "reason"); echo "</td></tr>"; echo "<tr><td>"; echo PluginMoreticketWaitingType::getTypeName(1); if ($config->mandatoryWaitingType() == true) { echo " : <span class='red'>*</span> "; } $opt = array('value' => $this->fields['plugin_moreticket_waitingtypes_id']); Dropdown::show('PluginMoreticketWaitingType', $opt); echo "</td></tr>"; echo "<tr><td>"; _e('Postponement date', 'moreticket'); if ($config->mandatoryReportDate() == true) { echo " : <span class='red'>*</span> "; } if ($this->fields['date_report'] == 'NULL') { $this->fields['date_report'] = date("Y-m-d H:i:s"); } Html::showDateTimeFormItem("date_report", $this->fields['date_report'], 1, false); echo "</td></tr>"; echo "</table>"; echo "</div>"; }
/** * Display for reservation * * @param $ID ID of the reservation (empty for create new) * @param $options array of possibles options: * - item reservation items ID for creation process * - date date for creation process **/ function showForm($ID, $options = array()) { global $CFG_GLPI; if (!Session::haveRight("reservation_helpdesk", "1")) { return false; } $resa = new self(); if (!empty($ID)) { if (!$resa->getFromDB($ID)) { return false; } if (!$resa->can($ID, "w")) { return false; } // Set item if not set if ((!isset($options['item']) || count($options['item']) == 0) && ($itemid = $resa->getField('reservationitems_id'))) { $options['item'][$itemid] = $itemid; } } else { $resa->getEmpty(); $resa->fields["begin"] = $options['date'] . " 12:00:00"; $resa->fields["end"] = $options['date'] . " 13:00:00"; } // No item : problem if (!isset($options['item']) || count($options['item']) == 0) { return false; } echo "<div class='center'><form method='post' name=form action='reservation.form.php'>"; if (!empty($ID)) { echo "<input type='hidden' name='id' value='{$ID}'>"; } echo "<table class='tab_cadre' width='700px'>"; echo "<tr><th colspan='2'>" . __('Reserve an item') . "</th></tr>\n"; // Add Hardware name $r = new ReservationItem(); echo "<tr class='tab_bg_1'><td>" . __('Item') . "</td>"; echo "<td>"; foreach ($options['item'] as $itemID) { $r->getFromDB($itemID); $type = $r->fields["itemtype"]; $name = NOT_AVAILABLE; $item = NULL; if ($item = getItemForItemtype($r->fields["itemtype"])) { $type = $item->getTypeName(); if ($item->getFromDB($r->fields["items_id"])) { $name = $item->getName(); } else { $item = NULL; } } echo "<span class='b'>" . sprintf(__('%1$s - %2$s'), $type, $name) . "</span><br>"; echo "<input type='hidden' name='items[{$itemID}]' value='{$itemID}'>"; } echo "</td></tr>\n"; if (!Session::haveRight("reservation_central", "w") || is_null($item) || !Session::haveAccessToEntity($item->fields["entities_id"])) { echo "<input type='hidden' name='users_id' value='" . Session::getLoginUserID() . "'>"; } else { echo "<tr class='tab_bg_2'><td>" . __('By') . "</td>"; echo "<td>"; if (empty($ID)) { User::dropdown(array('value' => Session::getLoginUserID(), 'entity' => $item->getEntityID(), 'right' => 'all')); } else { User::dropdown(array('value' => $resa->fields["users_id"], 'entity' => $item->getEntityID(), 'right' => 'all')); } echo "</td></tr>\n"; } echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>"; $rand_begin = Html::showDateTimeFormItem("resa[begin]", $resa->fields["begin"], -1, false); echo "</td></tr>\n"; $default_delay = floor((strtotime($resa->fields["end"]) - strtotime($resa->fields["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP; echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>"; $rand = Dropdown::showTimeStamp("resa[_duration]", array('min' => 0, 'max' => 24 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date'))); echo "<br><div id='date_end{$rand}'></div>"; $params = array('duration' => '__VALUE__', 'end' => $resa->fields["end"], 'name' => "resa[end]"); Ajax::updateItemOnSelectEvent("dropdown_resa[_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); } Alert::displayLastAlert('Reservation', $ID); echo "</td></tr>\n"; if (empty($ID)) { echo "<tr class='tab_bg_2'><td>" . __('Rehearsal') . "</td>"; echo "<td>"; echo "<select name='periodicity[type]' id='resaperiod{$rand}'>"; echo "<option value=''>" . _x('periodicity', 'None') . "</option>\n"; echo "<option value='day'>" . _x('periodicity', 'Daily') . "</option>\n"; echo "<option value='week'>" . _x('periodicity', 'Weekly') . "</option>\n"; echo "<option value='month'>" . _x('periodicity', 'Monthly') . "</option>\n"; echo "</select>"; $params = array('type' => '__VALUE__', 'end' => $resa->fields["end"]); Ajax::updateItemOnSelectEvent("resaperiod{$rand}", "resaperiodcontent{$rand}", $CFG_GLPI["root_doc"] . "/ajax/resaperiod.php", $params); echo "<br><div id='resaperiodcontent{$rand}'></div>"; // Dropdown::showInteger('periodicity_times', 1, 1, 60); echo "</td></tr>\n"; } echo "<tr class='tab_bg_2'><td>" . __('Comments') . "</td>"; echo "<td><textarea name='comment'rows='8' cols='30'>" . $resa->fields["comment"] . "</textarea>"; echo "</td></tr>\n"; if (empty($ID)) { echo "<tr class='tab_bg_2'>"; echo "<td colspan='2' class='top center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>\n"; } else { echo "<tr class='tab_bg_2'>"; echo "<td class='top center'>"; echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\"\n class='submit'>"; if ($resa->fields["group"] > 0) { echo "<br><input type='checkbox' name='_delete_group'> " . __s('Delete all rehearsals'); } echo "</td><td class='top center'>"; echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n class='submit'>"; echo "</td></tr>\n"; } echo "</table>"; Html::closeForm(); echo "</div>\n"; }
function showForm($ID, $options = array()) { global $CFG_GLPI; if (!$this->isNewID($ID)) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w'); } $this->showTabs($options); $this->showFormHeader($options); $fields = $this->getAdditionalFields(); $nb = count($fields); echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>"; echo "<td>"; /// TODO MoYo : Why add this field ? // echo "<input type='hidden' name='itemtype' value='".$this->getType()."'>"; if ($this instanceof CommonDevice) { // Awfull hack for CommonDevice where name is designation Html::autocompletionTextField($this, "designation"); } else { Html::autocompletionTextField($this, "name"); } echo "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>" . __('Comments') . "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>\n <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; foreach ($fields as $field) { if ($field['name'] == 'entities_id' && $ID == 0) { // No display for root entity echo "<tr class='tab_bg_1'><td colspan='2'> </td></tr>"; break; } echo "<tr class='tab_bg_1'><td>" . $field['label']; if (isset($field['comment']) && !empty($field['comment'])) { echo " "; Html::showToolTip($field['comment']); } echo "</td><td>"; if (!isset($field['type'])) { $field['type'] = ''; } switch ($field['type']) { case 'UserDropdown': $param = array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"]); if (isset($field['right'])) { $params['right'] = $field['right']; } User::dropdown($param); break; case 'dropdownValue': $params = array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID()); if (isset($field['condition'])) { $params['condition'] = $field['condition']; } Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), $params); break; case 'text': Html::autocompletionTextField($this, $field['name']); break; case 'textarea': echo "<textarea name='" . $field['name'] . "' cols='40' rows='3'>" . $this->fields[$field['name']] . "</textarea >"; break; case 'integer': Dropdown::showInteger($field['name'], $this->fields[$field['name']]); break; case 'timestamp': $param = array('value' => $this->fields[$field['name']]); if (isset($field['min'])) { $param['min'] = $field['min']; } if (isset($field['max'])) { $param['max'] = $field['max']; } if (isset($field['step'])) { $param['step'] = $field['step']; } Dropdown::showTimeStamp($field['name'], $param); break; case 'parent': if ($field['name'] == 'entities_id') { $restrict = -1; } else { $restrict = $this->getEntityID(); } Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array())); break; case 'icon': Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones"); if (!empty($this->fields[$field['name']])) { echo " <img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>"; } break; case 'bool': Dropdown::showYesNo($field['name'], $this->fields[$field['name']]); break; case 'date': Html::showDateFormItem($field['name'], $this->fields[$field['name']]); break; case 'datetime': Html::showDateTimeFormItem($field['name'], $this->fields[$field['name']]); break; case 'password': echo "<input type='password' name='password' value='' size='20' autocomplete='off'>"; break; default: $this->displaySpecificTypeField($ID, $field); break; } if (isset($field['unit'])) { echo " " . $field['unit']; } echo "</td></tr>\n"; } if (isset($this->fields['is_protected']) && $this->fields['is_protected']) { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return true; }