/** * clone of function Ticket::showFormHelpdesk() */ static function getHelpdesk($ID = 0, $ticket_template = false) { global $DB, $CFG_GLPI; // * Added by plugin survey ticket $ticket = new Ticket(); // * End of adding if (!Session::haveRight("create_ticket", "1")) { return false; } if (!$ticket_template && (Session::haveRight('validate_incident', 1) || Session::haveRight('validate_request', 1))) { $opt = array(); $opt['reset'] = 'reset'; $opt['field'][0] = 55; // validation status $opt['searchtype'][0] = 'equals'; $opt['contains'][0] = 'waiting'; $opt['link'][0] = 'AND'; $opt['field'][1] = 59; // validation aprobator $opt['searchtype'][1] = 'equals'; $opt['contains'][1] = Session::getLoginUserID(); $opt['link'][1] = 'AND'; $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&'); if (TicketValidation::getNumberTicketsToValidate(Session::getLoginUserID()) > 0) { echo "<a href='{$url_validate}' title=\"" . __s('Ticket waiting for your approval') . "\"\n alt=\"" . __s('Ticket waiting for your approval') . "\">" . __('Tickets awaiting approval') . "</a><br><br>"; } } $query = "SELECT `realname`, `firstname`, `name`\n FROM `glpi_users`\n WHERE `id` = '{$ID}'"; $result = $DB->query($query); $email = UserEmail::getDefaultForUser($ID); // Set default values... $default_values = array('_users_id_requester_notif' => array('use_notification' => $email == "" ? 0 : 1), 'nodelegate' => 1, '_users_id_requester' => 0, 'name' => '', 'content' => '', 'itilcategories_id' => 0, 'locations_id' => 0, 'urgency' => 3, 'itemtype' => '', 'items_id' => 0, 'entities_id' => $_SESSION['glpiactive_entity'], 'plan' => array(), 'global_validation' => 'none', 'due_date' => 'NULL', 'slas_id' => 0, '_add_validation' => 0, 'type' => Entity::getUsedConfig('tickettype', $_SESSION['glpiactive_entity'], '', Ticket::INCIDENT_TYPE), '_right' => "id"); // Get default values from posted values on reload form if (!$ticket_template) { 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; } } } if (!$ticket_template) { echo "<form method='post' name='helpdeskform' action='" . $CFG_GLPI["root_doc"] . "/front/tracking.injector.php' enctype='multipart/form-data'>"; } $delegating = User::getDelegateGroupsForUser($values['entities_id']); if (count($delegating)) { echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . __('This ticket concerns me') . " "; $rand = Dropdown::showYesNo("nodelegate", $values['nodelegate']); $params = array('nodelegate' => '__VALUE__', 'rand' => $rand, 'right' => "delegate", '_users_id_requester' => $values['_users_id_requester'], '_users_id_requester_notif' => $values['_users_id_requester_notif'], 'use_notification' => $values['_users_id_requester_notif']['use_notification'], 'entity_restrict' => $_SESSION["glpiactive_entity"]); Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate" . $rand, "show_result" . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownDelegationUsers.php", $params); if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) { echo "</th><th>" . __('Check your personnal information'); } echo "</th></tr>"; echo "<tr class='tab_bg_1'><td colspan='2' class='center'>"; echo "<div id='show_result{$rand}'>"; $self = new Ticket(); if ($values["_users_id_requester"] == 0) { $values['_users_id_requester'] = Session::getLoginUserID(); } else { $values['_right'] = "delegate"; } $self->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $values); echo "</div>"; if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) { echo "</td><td class='center'>"; User::showPersonalInformation(Session::getLoginUserID()); } echo "</td></tr>"; echo "</table></div>"; echo "<input type='hidden' name='_users_id_recipient' value='" . Session::getLoginUserID() . "'>"; } else { // User as requester $values['_users_id_requester'] = Session::getLoginUserID(); if ($CFG_GLPI['use_check_pref']) { echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Check your personnal information') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; User::showPersonalInformation(Session::getLoginUserID()); echo "</td></tr>"; echo "</table></div>"; } } echo "<input type='hidden' name='_from_helpdesk' value='1'>"; echo "<input type='hidden' name='requesttypes_id' value='" . RequestType::getDefault('helpdesk') . "'>"; // Load ticket template if available : $tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'], $values['itilcategories_id'], $_SESSION["glpiactive_entity"]); // 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 $predefined_fields = array(); if (isset($tt->predefined) && count($tt->predefined)) { foreach ($tt->predefined as $predeffield => $predefvalue) { if (isset($values[$predeffield]) && 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()) { $values[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } else { // Not defined options set as hidden field echo "<input type='hidden' name='{$predeffield}' value='{$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]; } } } } if ($CFG_GLPI['urgency_mask'] == 1 << 3 || $tt->isHiddenField('urgency')) { // Dont show dropdown if only 1 value enabled or field is hidden echo "<input type='hidden' name='urgency' value='" . $values['urgency'] . "'>"; } // Display predefined fields if hidden if ($tt->isHiddenField('itemtype')) { echo "<input type='hidden' name='itemtype' value='" . $values['itemtype'] . "'>"; echo "<input type='hidden' name='items_id' value='" . $values['items_id'] . "'>"; } if ($tt->isHiddenField('locations_id')) { echo "<input type='hidden' name='locations_id' value='" . $values['locations_id'] . "'>"; } echo "<input type='hidden' name='entities_id' value='" . $_SESSION["glpiactive_entity"] . "'>"; echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Describe the incident or request') . "</th><th>"; if (Session::isMultiEntitiesMode()) { echo "(" . Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]) . ")"; } echo "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</td>"; echo "<td>"; Ticket::dropdownType('type', array('value' => $values['type'], 'on_change' => 'submit()')); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</td>"; echo "<td>"; $condition = "`is_helpdeskvisible`='1'"; switch ($values['type']) { case Ticket::DEMAND_TYPE: $condition .= " AND `is_request`='1'"; break; default: // Ticket::INCIDENT_TYPE : $condition .= " AND `is_incident`='1'"; } $opt = array('value' => $values['itilcategories_id'], 'condition' => $condition, 'on_change' => 'submit()'); if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) { $opt['display_emptychoice'] = false; } ITILCategory::dropdown($opt); echo "</td></tr>"; if ($CFG_GLPI['urgency_mask'] != 1 << 3) { if (!$tt->isHiddenField('urgency')) { echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')) . "</td>"; echo "<td>"; Ticket::dropdownUrgency(array('value' => $values["urgency"])); echo "</td></tr>"; } } if (empty($delegating) && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Inform me about the actions taken') . "</td>"; echo "<td>"; if ($values["_users_id_requester"] == 0) { $values['_users_id_requester'] = Session::getLoginUserID(); } $_POST['value'] = $values['_users_id_requester']; $_POST['field'] = '_users_id_requester_notif'; $_POST['use_notification'] = $values['_users_id_requester_notif']['use_notification']; include GLPI_ROOT . "/ajax/uemailUpdate.php"; echo "</td></tr>"; } if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) { if (!$tt->isHiddenField('itemtype')) { echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s%2$s'), __('Hardware type'), $tt->getMandatoryMark('itemtype')) . "</td>"; echo "<td>"; Ticket::dropdownMyDevices($values['_users_id_requester'], $_SESSION["glpiactive_entity"], $values['itemtype'], $values['items_id']); Ticket::dropdownAllDevices("itemtype", $values['itemtype'], $values['items_id'], 0, $values['_users_id_requester'], $_SESSION["glpiactive_entity"]); echo "<span id='item_ticket_selection_information'></span>"; echo "</td></tr>"; } } if (!$tt->isHiddenField('locations_id')) { echo "<tr class='tab_bg_1'><td>"; printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id')); echo "</td><td>"; Location::dropdown(array('value' => $values["locations_id"])); echo "</td></tr>"; } if (!$tt->isHiddenField('name') || $tt->isPredefinedField('name')) { echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')) . "</td>"; echo "<td><input type='text' maxlength='250' size='80' name='name'\n value=\"" . $values['name'] . "\"></td></tr>"; } if (!$tt->isHiddenField('content') || $tt->isPredefinedField('content')) { echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')) . "</td>"; // * Changed by plugin surveyticket // * 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_helpdesk`='1'")); if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) { echo "<td>"; $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 { echo "<td><textarea name='content' cols='80' rows='14'>" . $values['content'] . "</textarea>"; } // * End of change echo "</td></tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . sprintf(__('%1$s (%2$s)'), __('File'), 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(60); echo "</td>"; echo "<td><div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>"; echo "</td></tr>"; if (!$ticket_template) { echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' class='center'>"; 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 "<input type='submit' name='add' value=\"" . __s('Submit message') . "\" class='submit'>"; echo "</td></tr>"; } echo "</table></div>"; if (!$ticket_template) { Html::closeForm(); } }
/** * Display item used to select a pattern for a criteria * * @param $name criteria name * @param $ID the given criteria * @param $condition condition used * @param $value the pattern (default '') * @param $test Is to test rule ? (false by default) **/ function displayCriteriaSelectPattern($name, $ID, $condition, $value = "", $test = false) { $crit = $this->getCriteria($ID); $display = false; $tested = false; if (isset($crit['type']) && ($test || in_array($condition, array(self::PATTERN_IS, self::PATTERN_IS_NOT, self::PATTERN_NOT_UNDER, self::PATTERN_UNDER)))) { switch ($crit['type']) { case "yesonly": Dropdown::showYesNo($name, $crit['table'], 0); $display = true; break; case "yesno": Dropdown::showYesNo($name, $crit['table']); $display = true; break; case "dropdown": $param = array('name' => $name, 'value' => $value); if (isset($crit['condition'])) { $param['condition'] = $crit['condition']; } Dropdown::show(getItemTypeForTable($crit['table']), $param); $display = true; break; case "dropdown_users": User::dropdown(array('value' => $value, 'name' => $name, 'right' => 'all')); $display = true; break; case "dropdown_tracking_itemtype": Dropdown::showItemTypes($name, array_keys(Ticket::getAllTypesForHelpdesk())); $display = true; break; case "dropdown_urgency": Ticket::dropdownUrgency(array('name' => $name, 'value' => $value)); $display = true; break; case "dropdown_impact": Ticket::dropdownImpact(array('name' => $name, 'value' => $value)); $display = true; break; case "dropdown_priority": Ticket::dropdownPriority(array('name' => $name, 'value' => $value)); $display = true; break; case "dropdown_status": Ticket::dropdownStatus(array('name' => $name, 'value' => $value)); $display = true; break; case "dropdown_tickettype": Ticket::dropdownType($name, array('value' => $value)); $display = true; break; } $tested = true; } //Not a standard condition if (!$tested) { $display = $this->displayAdditionalRuleCondition($condition, $crit, $name, $value, $test); } if ($condition == self::PATTERN_EXISTS || $condition == self::PATTERN_DOES_NOT_EXISTS) { echo "<input type='hidden' name='{$name}' value='1'>"; $display = true; } if (!$display && ($rc = getItemForItemtype($this->rulecriteriaclass))) { Html::autocompletionTextField($rc, "pattern", array('name' => $name, 'value' => $value, 'size' => 70)); } }
/** * Print the helpdesk * * @param $ID int : ID of the user who want to display the Helpdesk * @param $from_helpdesk int : is display from the helpdesk.php ? * * @return nothing (print the helpdesk) **/ function printHelpDesk($ID, $from_helpdesk) { global $DB, $CFG_GLPI, $LANG; if (!haveRight("create_ticket", "1")) { return false; } if (haveRight('validate_ticket', 1)) { $opt = array(); $opt['reset'] = 'reset'; $opt['field'][0] = 55; // validation status $opt['searchtype'][0] = 'equals'; $opt['contains'][0] = 'waiting'; $opt['link'][0] = 'AND'; $opt['field'][1] = 59; // validation aprobator $opt['searchtype'][1] = 'equals'; $opt['contains'][1] = getLoginUserID(); $opt['link'][1] = 'AND'; $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($opt, '&'); if (TicketValidation::getNumberTicketsToValidate(getLoginUserID()) > 0) { echo "<a href='{$url_validate}' title=\"" . $LANG['validation'][15] . "\"\n alt=\"" . $LANG['validation'][15] . "\">" . $LANG['validation'][33] . "</a><br><br>"; } } $query = "SELECT `email`, `realname`, `firstname`, `name`\n FROM `glpi_users`\n WHERE `id` = '{$ID}'"; $result = $DB->query($query); $email = $DB->result($result, 0, "email"); // Get saved data from a back system $use_email_notification = 1; if ($email == "") { $use_email_notification = 0; } $itemtype = 0; $items_id = ""; $content = ""; $title = ""; $ticketcategories_id = 0; $urgency = 3; $type = 0; if (isset($_SESSION["helpdeskSaved"]['_users_id_requester_notif']) && isset($_SESSION["helpdeskSaved"]['_users_id_requester_notif']['use_notification'])) { $use_email_notification = stripslashes($_SESSION["helpdeskSaved"]['_users_id_requester_notif']['use_notification']); } if (isset($_SESSION["helpdeskSaved"]["email"])) { $email = stripslashes($_SESSION["helpdeskSaved"]["user_email"]); } if (isset($_SESSION["helpdeskSaved"]["itemtype"])) { $itemtype = stripslashes($_SESSION["helpdeskSaved"]["itemtype"]); } if (isset($_SESSION["helpdeskSaved"]["items_id"])) { $items_id = stripslashes($_SESSION["helpdeskSaved"]["items_id"]); } if (isset($_SESSION["helpdeskSaved"]["content"])) { $content = cleanPostForTextArea($_SESSION["helpdeskSaved"]["content"]); } if (isset($_SESSION["helpdeskSaved"]["name"])) { $title = stripslashes($_SESSION["helpdeskSaved"]["name"]); } if (isset($_SESSION["helpdeskSaved"]["ticketcategories_id"])) { $ticketcategories_id = stripslashes($_SESSION["helpdeskSaved"]["ticketcategories_id"]); } if (isset($_SESSION["helpdeskSaved"]["type"])) { $type = stripslashes($_SESSION["helpdeskSaved"]["type"]); } if (isset($_SESSION["helpdeskSaved"]["urgency"])) { $urgency = stripslashes($_SESSION["helpdeskSaved"]["urgency"]); } unset($_SESSION["helpdeskSaved"]); echo "<form method='post' name='helpdeskform' action='" . $CFG_GLPI["root_doc"] . "/front/tracking.injector.php' enctype='multipart/form-data'>"; echo "<input type='hidden' name='_from_helpdesk' value='{$from_helpdesk}'>"; echo "<input type='hidden' name='requesttypes_id' value='" . RequestType::getDefault('helpdesk') . "'>"; if ($CFG_GLPI['urgency_mask'] == 1 << 3) { // Dont show dropdown if only 1 value enabled echo "<input type='hidden' name='urgency' value='3'>"; } echo "<input type='hidden' name='entities_id' value='" . $_SESSION["glpiactive_entity"] . "'>"; echo "<div class='center'><table class='tab_cadre'>"; echo "<tr><th colspan='2'>" . $LANG['job'][11] . " : "; if (isMultiEntitiesMode()) { echo " (" . Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]) . ")"; } echo "</th></tr>"; if ($CFG_GLPI['urgency_mask'] != 1 << 3) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['joblist'][29] . " : </td>"; echo "<td>"; Ticket::dropdownUrgency("urgency", $urgency); echo "</td></tr>"; } if (NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][8] . " : </td>"; echo "<td>"; $_REQUEST['value'] = getLoginUserID(); $_REQUEST['field'] = '_users_id_requester_notif'; $_REQUEST['use_notification'] = $use_email_notification; include GLPI_ROOT . "/ajax/uemailUpdate.php"; echo "</td></tr>"; } if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][24] . " : </td>"; echo "<td>"; Ticket::dropdownMyDevices(getLoginUserID(), $_SESSION["glpiactive_entity"]); Ticket::dropdownAllDevices("itemtype", $itemtype, $items_id, 0, $_SESSION["glpiactive_entity"]); echo "</td></tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][17] . " : </td><td>"; Ticket::dropdownType('type', $type); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][36] . " : </td><td>"; Dropdown::show('TicketCategory', array('value' => $ticketcategories_id, 'condition' => '`is_helpdeskvisible`=1')); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][57] . " : </td>"; echo "<td><input type='text' maxlength='250' size='50' name='name' value='{$title}'></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'><textarea name='content' cols='78' rows='14'>{$content}</textarea>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['document'][2] . " (" . Document::getMaxUploadSize() . ") : "; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt='" . $LANG['central'][7] . "' onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">"; echo "</td>"; echo "<td><input type='file' name='filename' value='' size='25'></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' class='center'>"; echo "<input type='submit' value=\"" . $LANG['help'][14] . "\" class='submit'>"; echo "</td></tr>"; echo "</table></div></form>"; }
public function showEquals($searchopt, $value, $edit = true) { $inputname = $searchopt['linkfield']; switch ($searchopt['table'] . "." . $searchopt['linkfield']) { case "glpi_tickets.status": if ($edit) { Ticket::dropdownStatus($inputname, $value, 1); } else { echo Ticket::getStatus($value); } break; case "glpi_tickets.priority": if ($edit) { Ticket::dropdownPriority($inputname, $value, true, true); } else { echo Ticket::getPriorityName(trim($value)); } break; case "glpi_tickets.impact": if ($edit) { Ticket::dropdownImpact($inputname, $value, true); } else { echo Ticket::getImpactName($value); } break; case "glpi_tickets.urgency": if ($edit) { Ticket::dropdownUrgency($inputname, $value, true); } else { echo Ticket::getUrgencyName($value); } break; case "glpi_tickets.global_validation": if ($edit) { TicketValidation::dropdownStatus($inputname, array('value' => $value, 'all' => 1)); } else { TicketValidation::getStatus($value); } break; case "glpi_users.name": if ($edit) { User::dropdown(array('name' => $inputname, 'value' => $value, 'comments' => false, 'all' => -1, 'right' => 'all')); } else { echo getUserName($value); } break; case "glpi_ticketvalidations.status": if ($edit) { TicketValidation::dropdownStatus($inputname, array('value' => $value, 'all' => 1)); } else { echo TicketValidation::getStatus($value); } break; } }
/** * @param $options array **/ function displayActionSelectPattern($options = array()) { $display = false; $param['value'] = ''; if (isset($options['value'])) { $param['value'] = $options['value']; } switch ($options["action_type"]) { //If a regex value is used, then always display an autocompletiontextfield case "regex_result": case "append_regex_result": Html::autocompletionTextField($this, "value", $param); break; case 'fromuser': case 'fromitem': Dropdown::showYesNo("value", $param['value'], 0); $display = true; break; default: $actions = Rule::getActionsByType($options["sub_type"]); if (isset($actions[$options["field"]]['type'])) { switch ($actions[$options["field"]]['type']) { case "dropdown": $table = $actions[$options["field"]]['table']; $param['name'] = "value"; if (isset($actions[$options["field"]]['condition'])) { $param['condition'] = $actions[$options["field"]]['condition']; } Dropdown::show(getItemTypeForTable($table), $param); $display = true; break; case "dropdown_tickettype": Ticket::dropdownType('value', $param); $display = true; break; case "dropdown_assign": $param['name'] = 'value'; $param['right'] = 'own_ticket'; User::dropdown($param); $display = true; break; case "dropdown_users": $param['name'] = 'value'; $param['right'] = 'all'; User::dropdown($param); $display = true; break; case "dropdown_urgency": $param['name'] = 'value'; Ticket::dropdownUrgency($param); $display = true; break; case "dropdown_impact": $param['name'] = 'value'; Ticket::dropdownImpact($param); $display = true; break; case "dropdown_priority": if ($_POST["action_type"] != 'compute') { $param['name'] = 'value'; Ticket::dropdownPriority($param); } $display = true; break; case "dropdown_status": $param['name'] = 'value'; Ticket::dropdownStatus($param); $display = true; break; case "yesonly": Dropdown::showYesNo("value", $param['value'], 0); $display = true; break; case "yesno": Dropdown::showYesNo("value", $param['value']); $display = true; break; case "dropdown_management": $param['name'] = 'value'; $param['management_restrict'] = 2; $param['withtemplate'] = false; Dropdown::showGlobalSwitch(0, $param); $display = true; break; case "dropdown_users_validate": $used = array(); if ($item = getItemForItemtype($options["sub_type"])) { $rule_data = getAllDatasFromTable('glpi_ruleactions', "`action_type` = 'add_validation'\n AND `field` = 'users_id_validate'\n AND `" . $item->getRuleIdField() . "`\n = '" . $options[$item->getRuleIdField()] . "'"); foreach ($rule_data as $data) { $used[] = $data['value']; } } $param['name'] = 'value'; $param['right'] = array('validate_incident', 'validate_request'); $param['used'] = $used; User::dropdown($param); $display = true; break; case "dropdown_groups_validate": $used = array(); if ($item = getItemForItemtype($options["sub_type"])) { $rule_data = getAllDatasFromTable('glpi_ruleactions', "`action_type` = 'add_validation'\n AND `field` = 'groups_id_validate'\n AND `" . $item->getRuleIdField() . "`\n = '" . $options[$item->getRuleIdField()] . "'"); foreach ($rule_data as $data) { $used[] = $data['value']; } } $condition = "(SELECT count(`users_id`)\n FROM `glpi_groups_users`\n WHERE `groups_id` = `glpi_groups`.`id`)"; $param['name'] = 'value'; $param['condition'] = $condition; $param['right'] = array('validate_incident', 'validate_request'); $param['used'] = $used; Group::dropdown($param); $display = true; break; case "dropdown_validation_percent": $ticket = new Ticket(); echo $ticket->getValueToSelect('validation_percent', 'value', $param['value']); $display = true; break; default: if ($rule = getItemForItemtype($options["sub_type"])) { $display = $rule->displayAdditionalRuleAction($actions[$options["field"]], $param['value']); } break; } } if (!$display) { Html::autocompletionTextField($this, "value", $param); } } }
// Specific cases switch ($searchopt['table'] . "." . $searchopt['field']) { case "glpi_tickets.status": Ticket::dropdownStatus($inputname, $_REQUEST['value'], 1); $display = true; break; case "glpi_tickets.priority": Ticket::dropdownPriority($inputname, $_REQUEST['value'], true, true); $display = true; break; case "glpi_tickets.impact": Ticket::dropdownImpact($inputname, $_REQUEST['value'], true); $display = true; break; case "glpi_tickets.urgency": Ticket::dropdownUrgency($inputname, $_REQUEST['value'], true); $display = true; break; case "glpi_tickets.global_validation": TicketValidation::dropdownStatus($inputname, array('value' => $_REQUEST['value'], 'all' => 1)); $display = true; break; case "glpi_users.name": User::dropdown(array('name' => $inputname, 'value' => $_REQUEST['value'], 'comments' => false, 'all' => -1, 'right' => 'all')); $display = true; break; case "glpi_ticketvalidations.status": TicketValidation::dropdownStatus($inputname, array('value' => $_REQUEST['value'], 'all' => 1)); $display = true; break; }
/** * @param $options array **/ function displayActionSelectPattern($options = array()) { $display = false; switch ($_POST["action_type"]) { //If a regex value is used, then always display an autocompletiontextfield case "regex_result": case "append_regex_result": Html::autocompletionTextField($this, "value"); break; case 'fromuser': case 'fromitem': Dropdown::showYesNo("value", 0, 0); $display = true; break; default: $actions = Rule::getActionsByType($options["sub_type"]); if (isset($actions[$options["field"]]['type'])) { switch ($actions[$options["field"]]['type']) { case "dropdown": $table = $actions[$options["field"]]['table']; $param = array('name' => "value"); if (isset($actions[$options["field"]]['condition'])) { $param['condition'] = $actions[$options["field"]]['condition']; } Dropdown::show(getItemTypeForTable($table), $param); $display = true; break; case "dropdown_tickettype": Ticket::dropdownType('value'); $display = true; break; case "dropdown_assign": User::dropdown(array('name' => 'value', 'right' => 'own_ticket')); $display = true; break; case "dropdown_users": User::dropdown(array('name' => 'value', 'right' => 'all')); $display = true; break; case "dropdown_urgency": Ticket::dropdownUrgency(array('name' => 'value')); $display = true; break; case "dropdown_impact": Ticket::dropdownImpact(array('name' => 'value')); $display = true; break; case "dropdown_priority": if ($_POST["action_type"] != 'compute') { Ticket::dropdownPriority(array('name' => 'value')); } $display = true; break; case "dropdown_status": Ticket::dropdownStatus(array('name' => "value")); $display = true; break; case "yesonly": Dropdown::showYesNo("value", 0, 0); $display = true; break; case "yesno": Dropdown::showYesNo("value"); $display = true; break; case "dropdown_management": Dropdown::showGlobalSwitch(0, array('name' => 'value', 'management_restrict' => 2, 'withtemplate' => false)); $display = true; break; case "dropdown_users_validate": User::dropdown(array('name' => "value", 'right' => array('validate_incident', 'validate_request'))); $display = true; break; default: if ($rule = getItemForItemtype($options["sub_type"])) { $display = $rule->displayAdditionalRuleAction($actions[$options["field"]]); } break; } } if (!$display) { Html::autocompletionTextField($this, "value"); } } }
public static function show($ID, $from_helpdesk) { global $LANG, $CFG_GLPI, $DB; //$logged = $_SESSION['glpiID']; if (!isset($_REQUEST['session'])) { $IDO = Session::getLoginUserID(); } else { $IDO = $_REQUEST['session']; } $logged = $ID; /* echo $logged."logged2 "; echo Session::getLoginUserID()."session "; */ if (isset($_REQUEST['id'])) { $ID = $_REQUEST['id']; $_SESSION["glpiID"] = $_REQUEST['id']; $query = "SELECT `profiles_id` AS id\nFROM `glpi_profiles_users`\nWHERE `users_id` = " . $IDO . "\nORDER BY `glpi_profiles_users`.`profiles_id` DESC"; $result = $DB->query($query); $cont = $DB->numrows($result); $profile = $DB->fetch_assoc($result); } else { $ID = $_SESSION['glpiID']; $_SESSION['glpiID'] = $_SESSION['glpiID']; $query = "SELECT `profiles_id` AS id\nFROM `glpi_profiles_users`\nWHERE `users_id` = " . $IDO . "\nORDER BY `glpi_profiles_users`.`profiles_id` DESC"; $result = $DB->query($query); $cont = $DB->numrows($result); $profile = $DB->fetch_assoc($result); } /* echo $ID."id "; echo $_SESSION['glpiID']."glpiid "; echo $_SESSION['logged']."logged "; echo $logged."logged2 "; */ if (!Session::haveRight("ticket", CREATE)) { return false; } if (Session::haveRight('validate_ticket', 1)) { // if (Session::haveRightsOr('ticketvalidation', array(TicketValidation::VALIDATEREQUEST, TicketValidation::VALIDATEINCIDENT))) { $opt = array(); $opt['reset'] = 'reset'; $opt['field'][0] = 55; // validation status $opt['searchtype'][0] = 'equals'; $opt['contains'][0] = 'waiting'; $opt['link'][0] = 'AND'; $opt['field'][1] = 59; // validation aprobator $opt['searchtype'][1] = 'equals'; $opt['contains'][1] = Session::getLoginUserID(); //$opt['contains'][1] = $ID; $opt['link'][1] = 'AND'; $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&'); if (TicketValidation::getNumberTicketsToValidate(Session::getLoginUserID()) > 0) { //if (TicketValidation::getNumberTicketsToValidate( $ID >0) { echo "<a href='{$url_validate}' title=\"" . $LANG['validation'][15] . "\"\n alt=\"" . $LANG['validation'][15] . "\">" . $LANG['validation'][33] . "</a><br><br>"; } } // Stevenes Donato //email user $query = "SELECT gu.id, ge.email, gu.`firstname`, gu.`realname`, gu.`name`\n FROM `glpi_users` gu, glpi_useremails ge\n WHERE gu.`id` = '{$ID}'\n\t\t\t\t\t AND ge.users_id = gu.id "; $result = $DB->query($query); $email = $DB->result($result, 0, "email"); $user_name = $DB->result($result, 0, "firstname") . " "; $user_sname = $DB->result($result, 0, "realname"); //categories $query_cat = "SELECT id, completename\n\t\t\t\t\t\t\tFROM `glpi_itilcategories` \n\t\t\t\t\t\t\tWHERE `is_helpdeskvisible` = 1"; $result_cat = $DB->query($query_cat); $itilcategories_id = $DB->fetch_assoc($result_cat); $sql_user = "******"; $result_user = $DB->query($sql_user); $user = $DB->fetch_assoc($result_user); // Get saved data from a back system $use_email_notification = 1; if ($email == "") { $use_email_notification = 0; } $itemtype = 0; $items_id = ""; $content = ""; $title = ""; //$itilcategories_id = 0; $urgency = 3; if (isset($_SESSION["helpdeskSaved"]["use_email_notification"])) { $use_email_notification = stripslashes($_SESSION["helpdeskSaved"]["use_email_notification"]); } if (isset($_SESSION["helpdeskSaved"]["email"])) { $email = stripslashes($_SESSION["helpdeskSaved"]["user_email"]); } if (isset($_SESSION["helpdeskSaved"]["itemtype"])) { $itemtype = stripslashes($_SESSION["helpdeskSaved"]["itemtype"]); } if (isset($_SESSION["helpdeskSaved"]["items_id"])) { $items_id = stripslashes($_SESSION["helpdeskSaved"]["items_id"]); } if (isset($_SESSION["helpdeskSaved"]["content"])) { $content = cleanPostForTextArea($_SESSION["helpdeskSaved"]["content"]); } if (isset($_SESSION["helpdeskSaved"]["name"])) { $title = stripslashes($_SESSION["helpdeskSaved"]["name"]); } if (isset($_SESSION["helpdeskSaved"]["itilcategories_id"])) { //$itilcategories_id = stripslashes($_SESSION["helpdeskSaved"]["itilcategories_id"]); $itilcategories_id = $_SESSION["helpdeskSaved"]["itilcategories_id"]; } if (isset($_SESSION["helpdeskSaved"]["urgency"])) { $urgency = stripslashes($_SESSION["helpdeskSaved"]["urgency"]); } unset($_SESSION["helpdeskSaved"]); echo "<form method='post' name=\"helpdeskform\" action=\"" . $CFG_GLPI["root_doc"] . "/plugins/mobile/front/tracking.injector.php?ido=" . $IDO . "\" enctype=\"multipart/form-data\">"; echo "<input type='hidden' name='_from_helpdesk' value='{$from_helpdesk}'>"; if ($CFG_GLPI['urgency_mask'] == 1 << 3) { // Dont show dropdown if only 1 value enabled echo "<input type='hidden' name='urgency' value='3'>"; } echo "<input type='hidden' name='entities_id' value='" . $_SESSION["glpiactive_entity"] . "'>"; echo "<div class='force_left input_right'><table class='tab_cadre'>"; echo "<tr><th colspan='1'>" . $LANG['job'][11] . " : </th></tr>"; echo "<tr><th colspan='1'>"; if (Session::isMultiEntitiesMode()) { echo " (" . Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]) . ")"; } echo "</th></tr>"; //Requerente if ($cont != "1" && $profile != "1") { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['job'][4] . " : </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td >"; // Dropdown::show('ITILCategories', array('value' => $user,'condition'=>'is_deleted=0')); //Dropdown::showFromArray("user_id", $user); echo "\n\n<script>\nfunction getComboA(sel) {\n var id = sel.options[sel.selectedIndex].value; \n //var name = sel.options[sel.selectedIndex].id;\n //document.getElementById('user').innerHTML = id;\n window.location.assign('" . $CFG_GLPI['root_doc'] . "/plugins/mobile/front/helpdesk.php?id='+id+'&session=" . $IDO . "'); \n}\n</script> "; echo "<select id='sel_user' onchange='getComboA(this)'>"; echo '<option value=" "> -- Selecione -- </option>'; while ($user = $DB->fetch_array($result_user)) { echo "<option value=" . $user['id'] . " id= \"" . $user['name'] . " " . $user['sname'] . " \">" . $user['name'] . " " . $user['sname'] . "</option>"; } echo "</select>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['job'][4] . " : </td></tr>"; echo "<tr class='center tab_bg_1'>"; echo "<td >" . $user_name . $user_sname . "</td></tr>"; echo "<input type='hidden' name='logged' value='" . $logged . "'>"; } if ($CFG_GLPI['urgency_mask'] != 1 << 3) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['joblist'][29] . " : </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; //Ticket::dropdownUrgency("urgency",$urgency); Ticket::dropdownUrgency(array('value' => $values["urgency"])); echo "</td></tr>"; } if (NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][8] . " :</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td >"; Dropdown::showYesNo('use_email_notification', $use_email_notification); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['plugin_mobile']["email"] . " :</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td ><input type='text' id='user_email' name='user_email' value=\"{$email}\" size='40' onchange=\"use_email_notification.value='1'\">"; echo "</td></tr>"; } if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][24] . " : </td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td >"; Item_Ticket::dropdownMyDevices(Session::getLoginUserID(), $_SESSION["glpiactive_entity"]); //Ticket::dropdownMyDevices($ID,$_SESSION["glpiactive_entity"]); echo "</td></tr>"; } //Stevenes Donato echo "<tr class='tab_bg_1'>"; echo "<td class='force_left'>" . $LANG['common'][36] . " :</td></tr>"; echo "<tr class='tab_bg_1'><td>"; //Dropdown::show('TicketCategory', array('value' => $itilcategories_id,'condition'=>'`is_helpdeskvisible`=1')); //Dropdown::show('ITILCategory', array('value' => $itilcategories_id,'condition'=>'`is_helpdeskvisible`=1')); //Dropdown::getDropdownName("glpi_itilcategories", $this->fields["itilcategories_id"]); //Dropdown::showFromArray("completename", $itilcategories_id); echo "<script>\n\t\tfunction getCat(sel) {\n\t\t //var x = document.getElementById('sel_cat').value;\n\t\t var cat = sel.options[sel.selectedIndex].value; \n\t\t //document.getElementById('demo').innerHTML = 'Categoria: ' + cat;\n\t\t //document.getElementById('demo').innerHTML = '<input type=\\'text\\' name=\\'itilcategories_id\\' value=\\' +cat+ \\'/>';\n\t\t document.getElementById('categoria').value = cat;\t\t \n\t\t}\n\t\t</script>"; echo "<select id='sel_cat' onchange='getCat(this)'>"; echo '<option value=" "> -- ' . $LANG['dropdown'][35] . '-- </option>'; while ($cat = $DB->fetch_array($result_cat)) { echo "<option value=" . $cat['id'] . " id= \"" . $cat['completename'] . " \">" . $cat['completename'] . " </option>"; } echo "</select>" . "\n"; echo "</td></tr>"; echo "<tr><td>"; //echo '<label for="itilcategories_id" id="demo"></label>'; //echo "<span id='demo'></span>"; echo "<input id='categoria' type='hidden' name='itilcategories_id' value='' />"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][57] . " :</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td ><input type='text' maxlength='250' size='50' name='name' value=\"{$title}\" required ></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['joblist'][6] . " :</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='1'><textarea name='content' cols='78' rows='14' required >{$content}</textarea>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['document'][2] . " (" . Document::getMaxUploadSize() . ") :"; /* * we hide the picture (aide.png) to prevent the form openning in other window, * outside the mobile plugin layout. echo "<img src=\"".$CFG_GLPI["root_doc"]."/pics/aide.png\" class='pointer' alt=\"". $LANG['central'][7]."\" onclick=\"window.open('".$CFG_GLPI["root_doc"]. "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">"; */ echo "<input type='hidden' name='ido' value='" . $IDO . "'>"; ?> <script> function getID() { var ido = document.getElementById('ido').value; document.getElementById('session').innerHTML = "$_SESSION['logged']="+ido; //window.location.assign('".$CFG_GLPI['root_doc']."/plugins/mobile/front/helpdesk.php?id='+id+'&session=".$IDO."'); } </script> <div id="session" style="display:none;"></div> <?php echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td><input type='file' class='ui-input-text ui-body-null ui-corner-all ui-shadow-inset ui-body-c' name='filename' value=\"\" size='25'></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='1' class='center'>"; echo "<input type='submit' value=\"" . $LANG['help'][14] . "\" class='submit' >"; echo "</td></tr>"; echo "</table></div>"; //</form>"; Html::closeForm(); }
Contract::dropdownAlert($search["linkfield"], 0); break; case "glpi_tickets.status": Ticket::dropdownStatus($search["linkfield"]); break; case "glpi_tickets.type": Ticket::dropdownType($search["linkfield"]); break; case "glpi_tickets.priority": Ticket::dropdownPriority($search["linkfield"]); break; case "glpi_tickets.impact": Ticket::dropdownImpact($search["linkfield"]); break; case "glpi_tickets.urgency": Ticket::dropdownUrgency($search["linkfield"]); break; case "glpi_tickets.global_validation": TicketValidation::dropdownStatus($search["linkfield"]); break; default: // Specific plugin Type case $plugdisplay = false; if ($plug = isPluginItemType($_POST["itemtype"])) { $plugdisplay = doOneHook($plug['plugin'], 'MassiveActionsFieldsDisplay', array('itemtype' => $_POST["itemtype"], 'options' => $search)); } $already_display = false; if (isset($search['datatype'])) { switch ($search['datatype']) { case "date": showDateFormItem($search["field"]);
function showFormEdit($params, $options = array()) { global $LANG, $CFG_GLPI; if ($params['id'] > 0) { $this->check($params['id'], 'r'); } else { // Create item $this->check(-1, 'w'); } echo "<form method='POST' \n action='" . $CFG_GLPI["root_doc"] . "/plugins/formcreator/front/target.form.php'>"; echo "<input type='hidden' name='plugin_formcreator_forms_id' \n value='" . $this->fields['plugin_formcreator_forms_id'] . "' />"; echo "<input type='hidden' name='id' \n value='" . $this->fields['id'] . "' />"; echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe fix_tab_height'>"; echo "<tr>"; echo "<th colspan='2'>" . $LANG['plugin_formcreator']["target"][5] . "</th>"; echo "<th colspan='2'>" . $LANG['plugin_formcreator']["target"][3] . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['plugin_formcreator']["target"][4] . " :</td>"; echo '<td><input type="text" name="name" value="' . $this->fields['name'] . '" size="54"/></td>'; echo "</td>"; echo "<td>" . __('Category') . " :</td>"; echo "<td>"; Dropdown::show('ITILCategory', array('value' => $this->fields["itilcategories_id"])); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td rowspan='3'>"; echo __('Description') . " :"; echo "</td><td rowspan='3'>"; echo "<textarea name='content' cols='65' rows='12'>" . $this->fields['content'] . "</textarea>"; echo "</td>"; echo "<td>" . __('Type') . " :</td>"; echo "<td>"; echo '<select name="type">'; if ($this->fields['type'] == 2) { echo '<option value="2">' . __('Request') . '</option>'; echo '<option value="1">' . __('Incident') . '</option>'; } else { echo '<option value="2">' . __('Request') . '</option>'; echo '<option value="1" SELECTED>' . __('Incident') . '</option>'; } echo '</select>'; echo "</td>"; echo "</tr><tr>"; echo "<td>" . __('Urgency') . " :</td>"; echo "<td>"; Ticket::dropdownUrgency(array("urgency", $this->fields["urgency"])); echo "</td>"; echo "</tr><tr>"; echo "<td rownspan='2'>" . __('Priority') . " :</td>"; echo "<td>"; CommonITILObject::dropdownPriority(array("priority", $this->fields["priority"])); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='center' colspan='2'>"; echo "<input class='submit' type='submit' value='" . __('Update') . "' name='update'>"; echo "</td>"; echo "<td class='center' colspan='2'>"; echo "<input class='submit' type='submit' value='" . __('Purge') . "' name='delete'>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; Html::closeForm(); self::popupContent($this->fields['plugin_formcreator_forms_id']); }