public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { echo '<table class="tab_cadre_fixe">'; echo '<tr>'; echo '<th colspan="3">' . _n('Destinations', 'Destinations', 2, 'formcreator') . '</th>'; echo '</tr>'; $target_class = new PluginFormcreatorTarget(); $found_targets = $target_class->find('plugin_formcreator_forms_id = ' . $item->getID()); $target_number = count($found_targets); $token = Session::getNewCSRFToken(); $i = 0; foreach ($found_targets as $target) { $i++; echo '<tr class="line' . $i % 2 . '">'; echo '<td onclick="document.location=\'../front/targetticket.form.php?id=' . $target['items_id'] . '\'" style="cursor: pointer">'; echo $target['name']; echo '</td>'; echo '<td align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/pencil.png" alt="*" title="' . __('Edit') . '" onclick="document.location=\'../front/targetticket.form.php?id=' . $target['items_id'] . '\'" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '<td align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/delete.png" alt="*" title="' . __('Delete', 'formcreator') . '" onclick="deleteTarget(' . $item->getID() . ', \'' . $token . '\', ' . $target['id'] . ', \'' . addslashes($target['name']) . '\')" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '</tr>'; } // Display add target link... echo '<tr class="line' . ($i + 1) % 2 . '" id="add_target_row">'; echo '<td colspan="3">'; echo '<a href="javascript:addTarget(' . $item->getID() . ', \'' . $token . '\');"> <img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a destination', 'formcreator') . ' </a>'; echo '</td>'; echo '</tr>'; // OR display add target form echo '<tr class="line' . ($i + 1) % 2 . '" id="add_target_form" style="display: none;">'; echo '<td colspan="3" id="add_target_form_td"></td>'; echo '</tr>'; echo "</table>"; }
" }, }).done(function(response){ jQuery("#dropdown_default_value_field").html(response); }); } function change_LDAP(ldap) { var ldap_directory = ldap.value; jQuery.ajax({ url: "<?php echo $GLOBALS['CFG_GLPI']['root_doc']; ?> /plugins/formcreator/ajax/ldap_filter.php", type: "POST", data: { value: ldap_directory, _glpi_csrf_token: "<?php Session::getNewCSRFToken(); ?> " }, }).done(function(response){ document.getElementById('ldap_filter').value = response; }); } </script> <?php Html::closeForm();
/** * Display a list of all form sections and questions * * @param CommonGLPI $item Instance of a CommonGLPI Item (The Form Item) * @param integer $tabnum Number of the current tab * @param integer $withtemplate * * @see CommonDBTM::displayTabContentForItem * * @return null Nothing, just display the list */ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { echo '<table class="tab_cadre_fixe">'; // Get sections $section = new PluginFormcreatorSection(); $found_sections = $section->find('plugin_formcreator_forms_id = ' . $item->getId(), '`order`'); $section_number = count($found_sections); $tab_sections = array(); $tab_questions = array(); $token = Session::getNewCSRFToken(); foreach ($found_sections as $section) { $tab_sections[] = $section['id']; echo '<tr id="section_row_' . $section['id'] . '">'; echo '<th>' . $section['name'] . '</th>'; echo '<th align="center" width="32"> </th>'; echo '<th align="center" width="32">'; if ($section['order'] != 1) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/up2.png" alt="*" title="' . __('Edit') . '" onclick="moveSection(\'' . $token . '\', ' . $section['id'] . ', \'up\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</th>'; echo '<th align="center" width="32">'; if ($section['order'] != $section_number) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/down2.png" alt="*" title="' . __('Edit') . '" onclick="moveSection(\'' . $token . '\', ' . $section['id'] . ', \'down\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</th>'; echo '<th align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/pencil.png" alt="*" title="' . __('Edit') . '" onclick="editSection(' . $item->getId() . ', \'' . $token . '\', ' . $section['id'] . ')" align="absmiddle" style="cursor: pointer" /> '; echo '</th>'; echo '<th align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/delete.png" alt="*" title="' . __('Delete', 'formcreator') . '" onclick="deleteSection(' . $item->getId() . ', \'' . $token . '\', ' . $section['id'] . ', \'' . addslashes($section['name']) . '\')" align="absmiddle" style="cursor: pointer" /> '; echo '</th>'; echo '</tr>'; // Get questions $question = new PluginFormcreatorQuestion(); $found_questions = $question->find('plugin_formcreator_sections_id = ' . $section['id'], '`order`'); $question_number = count($found_questions); $i = 0; foreach ($found_questions as $question) { $i++; $tab_questions[] = $question['id']; echo '<tr class="line' . $i % 2 . '" id="question_row_' . $question['id'] . '">'; echo '<td onclick="editQuestion(' . $item->getId() . ', \'' . $token . '\', ' . $question['id'] . ', ' . $section['id'] . ')" style="cursor: pointer">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/ui-' . $question['fieldtype'] . '-field.png" alt="" title="" /> '; echo $question['name']; echo '</td>'; echo '<td align="center">'; $question_type = $question['fieldtype'] . 'Field'; $question_types = PluginFormcreatorFields::getTypes(); $classname = $question['fieldtype'] . 'Field'; $fields = $classname::getPrefs(); // avoid quote js error $question['name'] = htmlspecialchars_decode($question['name'], ENT_QUOTES); if ($fields['required'] == 0) { echo ' '; } elseif ($question['required']) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/required.png" alt="*" title="' . __('Required', 'formcreator') . '" onclick="setRequired(\'' . $token . '\', ' . $question['id'] . ', 0)" align="absmiddle" style="cursor: pointer" /> '; } else { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/not-required.png" alt="*" title="' . __('Required', 'formcreator') . '" onclick="setRequired(\'' . $token . '\', ' . $question['id'] . ', 1)" align="absmiddle" style="cursor: pointer" /> '; } echo '</td>'; echo '<td align="center">'; if ($question['order'] != 1) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/up.png" alt="*" title="' . __('Edit') . '" onclick="moveQuestion(\'' . $token . '\', ' . $question['id'] . ', \'up\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</td>'; echo '<td align="center">'; if ($question['order'] != $question_number) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/down.png" alt="*" title="' . __('Edit') . '" onclick="moveQuestion(\'' . $token . '\', ' . $question['id'] . ', \'down\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</td>'; echo '<td align="center">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/pencil.png" alt="*" title="' . __('Edit') . '" onclick="editQuestion(' . $item->getId() . ', \'' . $token . '\', ' . $question['id'] . ', ' . $section['id'] . ')" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '<td align="center">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/delete.png" alt="*" title="' . __('Delete', 'formcreator') . '" onclick="deleteQuestion(' . $item->getId() . ', \'' . $token . '\', ' . $question['id'] . ', \'' . addslashes($question['name']) . '\')" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '</tr>'; } echo '<tr class="line' . ($i + 1) % 2 . '">'; echo '<td colspan="6" id="add_question_td_' . $section['id'] . '" class="add_question_tds">'; echo '<a href="javascript:addQuestion(' . $item->getId() . ', \'' . $token . '\', ' . $section['id'] . ');"> <img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a question', 'formcreator') . ' </a>'; echo '</td>'; echo '</tr>'; } echo '<tr class="line1">'; echo '<th colspan="6" id="add_section_th">'; echo '<a href="javascript:addSection(' . $item->getId() . ', \'' . $token . '\');"> <img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a section', 'formcreator') . ' </a>'; echo '</th>'; echo '</tr>'; echo "</table>"; $js_tab_sections = ""; $js_tab_questions = ""; $js_line_questions = ""; foreach ($tab_sections as $key) { $js_tab_sections .= "tab_sections[{$key}] = document.getElementById('section_row_{$key}').innerHTML;" . PHP_EOL; $js_tab_questions .= "tab_questions[{$key}] = document.getElementById('add_question_td_{$key}').innerHTML;" . PHP_EOL; } foreach ($tab_questions as $key) { $js_line_questions .= "line_questions[{$key}] = document.getElementById('question_row_{$key}').innerHTML;" . PHP_EOL; } }
/** * Show SLT for ticket * * @param $ticket Ticket item * @param $type * @param $tt * @param $canupdate **/ function showSltForTicket(Ticket $ticket, $type, $tt, $canupdate) { global $CFG_GLPI; list($dateField, $sltField) = self::getSltFieldNames($type); echo "<table width='100%'>"; echo "<tr class='tab_bg_1'>"; if (!isset($ticket->fields[$dateField]) || $ticket->fields[$dateField] == 'NULL') { $ticket->fields[$dateField] = ''; } if ($ticket->fields['id']) { if ($this->getSltDataForTicket($ticket->fields['id'], $type)) { echo "<td>"; echo Html::convDateTime($ticket->fields[$dateField]); echo "</td>"; echo "<th>" . __('SLT') . "</th>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_slts', $ticket->fields[$sltField]) . " "; $commentsla = ""; $slalevel = new SlaLevel(); $nextaction = new SlaLevel_Ticket(); if ($nextaction->getFromDBForTicket($ticket->fields["id"], $type)) { $commentsla .= '<span class="b spaced">' . sprintf(__('Next escalation: %s'), Html::convDateTime($nextaction->fields['date'])) . '</span><br>'; 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('sla', READ)) { $slaoptions['link'] = Toolbox::getItemTypeFormURL('SLT') . "?id=" . $this->fields["id"]; } Html::showToolTip($commentsla, $slaoptions); if ($canupdate) { $fields = array('slt_delete' => 'slt_delete', 'id' => $ticket->getID(), 'type' => $type, '_glpi_csrf_token' => Session::getNewCSRFToken(), '_glpi_simple_form' => 1); $JS = " function delete_date{$type}(){\n if (nativeConfirm('" . addslashes(__('Also delete date ?')) . "')) {\n submitGetLink('" . $ticket->getFormURL() . "',\n " . json_encode(array_merge($fields, array('delete_date' => 1))) . ");\n } else {\n submitGetLink('" . $ticket->getFormURL() . "',\n " . json_encode(array_merge($fields, array('delete_date' => 0))) . ");\n }\n }"; echo Html::scriptBlock($JS); echo "<a class='pointer' onclick='delete_date{$type}();return false;'>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/delete.png' title='" . _x('button', 'Delete permanently') . "' " . "alt='" . _x('button', 'Delete permanently') . "' class='pointer'>"; echo "</a>"; } echo "</td>"; } else { echo "<td width='200px'>"; echo $tt->getBeginHiddenFieldValue($dateField); if ($canupdate) { Html::showDateTimeField($dateField, array('value' => $ticket->fields[$dateField], 'timestep' => 1, 'maybeempty' => true)); } else { echo Html::convDateTime($ticket->fields[$dateField]); } echo $tt->getEndHiddenFieldValue($dateField, $ticket); echo "</td>"; $slt_data = $this->getSltData("`type` = '{$type}'\n AND `entities_id` = '" . $ticket->fields['entities_id'] . "'"); if ($canupdate && !empty($slt_data)) { echo "<td>"; echo $tt->getBeginHiddenFieldText($sltField); echo "<span id='slt_action{$type}'>"; echo "<a " . Html::addConfirmationOnAction(array(__('The assignment of a SLT to a ticket causes the recalculation of the date.'), __("Escalations defined in the SLT will be triggered under this new date.")), "cleanhide('slt_action{$type}');cleandisplay('slt_choice{$type}');") . "><img src='" . $CFG_GLPI['root_doc'] . "/pics/clock.png' title='" . __('SLT') . "' alt='" . __('SLT') . "' class='pointer'></a>"; echo "</span>"; echo "<div id='slt_choice{$type}' style='display:none'>"; echo "<span class='b'>" . __('SLT') . "</span> "; Slt::dropdown(array('name' => $sltField, 'entity' => $ticket->fields["entities_id"], 'condition' => "`type` = '" . $type . "'")); echo "</div>"; echo $tt->getEndHiddenFieldText($sltField); echo "</td>"; } } } else { // New Ticket echo "<td>"; echo $tt->getBeginHiddenFieldValue($dateField); Html::showDateTimeField($dateField, array('value' => $ticket->fields[$dateField], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo $tt->getEndHiddenFieldValue($dateField, $ticket); echo "</td>"; $slt_data = $this->getSltData("`type` = '{$type}'\n AND `entities_id` = '" . $ticket->fields['entities_id'] . "'"); if ($canupdate && !empty($slt_data)) { echo "<th>" . $tt->getBeginHiddenFieldText($sltField); printf(__('%1$s%2$s'), __('SLT'), $tt->getMandatoryMark($sltField)); echo $tt->getEndHiddenFieldText('slas_id') . "</th>"; echo "<td class='nopadding'>" . $tt->getBeginHiddenFieldValue($sltField); Slt::dropdown(array('name' => $sltField, 'entity' => $ticket->fields["entities_id"], 'value' => isset($ticket->fields[$sltField]) ? $ticket->fields[$sltField] : 0, 'condition' => "`type` = '" . $type . "'")); echo $tt->getEndHiddenFieldValue($sltField, $ticket); echo "</td>"; } } echo "</tr>"; echo "</table>"; }
static function showOutputFormat() { global $CFG_GLPI; $values['-' . Search::PDF_OUTPUT_LANDSCAPE] = __('All pages in landscape PDF'); $values['-' . Search::PDF_OUTPUT_PORTRAIT] = __('All pages in portrait PDF'); $values['-' . Search::SYLK_OUTPUT] = __('All pages in SLK'); $values['-' . Search::CSV_OUTPUT] = __('All pages in CSV'); Dropdown::showFromArray('display_type', $values); if (GLPI_USE_CSRF_CHECK) { echo "<input type='hidden' id='report_csrf' name='_glpi_csrf_token' value='" . Session::getNewCSRFToken() . "'>"; } echo "<input type='image' name='export' class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/export.png'\n title=\"" . _sx('button', 'Export') . "\" value=\"" . _sx('button', 'Export') . "\">"; }
function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; $default_values = self::getDefaultValues(); // Get default values from posted values on reload form // On get because of tabs // we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST) if (!isset($options['template_preview'])) { if (isset($_REQUEST)) { $values = Html::cleanPostForTextArea($_REQUEST); } } // Restore saved value or override with page parameter $saved = $this->restoreInput(); foreach ($default_values as $name => $value) { if (!isset($values[$name])) { if (isset($saved[$name])) { $values[$name] = $saved[$name]; } else { $values[$name] = $value; } } } if (isset($values['content'])) { // Clean new lines to be fix encoding $order = array('\\r', '\\n', "\\"); $replace = array("", "", ""); $values['content'] = str_replace($order, $replace, $values['content']); } if (isset($values['name'])) { $values['name'] = str_replace("\\", "", $values['name']); } if (!$ID) { // Override defaut values from projecttask if needed if (isset($options['_projecttasks_id'])) { $pt = new ProjectTask(); if ($pt->getFromDB($options['_projecttasks_id'])) { $values['name'] = $pt->getField('name'); $values['content'] = $pt->getField('name'); } } } // Check category / type validity if ($values['itilcategories_id']) { $cat = new ITILCategory(); if ($cat->getFromDB($values['itilcategories_id'])) { switch ($values['type']) { case self::INCIDENT_TYPE: if (!$cat->getField('is_incident')) { $values['itilcategories_id'] = 0; } break; case self::DEMAND_TYPE: if (!$cat->getField('is_request')) { $values['itilcategories_id'] = 0; } break; default: break; } } } // Default check if ($ID > 0) { $this->check($ID, READ); } else { // Create item $this->check(-1, CREATE, $values); } if (!$ID) { $this->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)) { $this->userentities[] = $ID_entity; } } } $this->countentitiesforuser = count($this->userentities); if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->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 $this->fields["entities_id"] = $this->userentities[0]; // Pass to values $values['entities_id'] = $this->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 : if ($ID) { $tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']); } else { $tt = $this->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 (count($values['_predefined_fields']) == 0 && $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() || $predeffield == 'requesttypes_id' && empty($saved)) { // Load template data $values[$predeffield] = $predefvalue; $this->fields[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } } // All predefined override : add option to say predifined exists if (count($predefined_fields) == 0) { $predefined_fields['_all_predefined_override'] = 1; } } 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(self::$rightname, UPDATE); $canpriority = Session::haveRight(self::$rightname, self::CHANGEPRIORITY); $canstatus = $canupdate; if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) { $canupdate = false; // No update for actors $values['_noupdate'] = true; } $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } if ($options['template_preview']) { // Add all values to fields of tickets for template preview foreach ($values as $key => $val) { if (!isset($this->fields[$key])) { $this->fields[$key] = $val; } } } // In percent $colsize1 = '13'; $colsize2 = '29'; $colsize3 = '13'; $colsize4 = '45'; $canupdate_descr = $canupdate || $this->fields['status'] == self::INCOMING && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->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'>"; if (isset($options['_projecttasks_id'])) { echo "<input type='hidden' name='_projecttasks_id' value='" . $options['_projecttasks_id'] . "'>"; } } echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe' id='mainformtable'>"; // Optional line $ismultientities = Session::isMultiEntitiesMode(); echo "<tr class='headerRow responsive_hidden'>"; echo "<th colspan='4'>"; if ($ID) { $text = sprintf(__('%1$s - %2$s'), $this->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID)); if ($ismultientities) { $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id'])); } echo $text; } else { if ($ismultientities) { printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $this->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 = $this->fields["date"]; if ($canupdate) { Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false)); } else { echo Html::convDateTime($date); } echo $tt->getEndHiddenFieldValue('date', $this); 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 ($this->fields["slas_id"] > 0) { echo "<table width='100%'><tr><td class='nopadding'>"; echo Html::convDateTime($this->fields["due_date"]); echo "</td><td class='b'>" . __('SLA') . "</td>"; echo "<td class='nopadding'>"; echo Dropdown::getDropdownName("glpi_slas", $this->fields["slas_id"]); $commentsla = ""; $slalevel = new SlaLevel(); if ($slalevel->getFromDB($this->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($this->fields["id"])) { $commentsla .= '<span class="b spaced">' . sprintf(__('Next escalation: %s'), Html::convDateTime($nextaction->fields['date'])) . '</span><br>'; 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('sla', READ)) { $slaoptions['link'] = Toolbox::getItemTypeFormURL('SLA') . "?id=" . $this->fields["slas_id"]; } Html::showToolTip($commentsla, $slaoptions); if ($canupdate) { echo " "; $fields = array('sla_delete' => 'sla_delete', 'id' => $this->getID(), '_glpi_csrf_token' => Session::getNewCSRFToken(), '_glpi_simple_form' => 1); $JS = " function delete_due_date(){\n if (confirm('" . addslashes(__('Delete due date too?')) . "')) {\n submitGetLink('" . $this->getFormURL() . "',\n " . json_encode(array_merge($fields, array('delete_due_date' => 1))) . ");\n } else {\n submitGetLink('" . $this->getFormURL() . "',\n " . json_encode(array_merge($fields, array('delete_due_date' => 0))) . ");\n }\n }"; echo Html::scriptBlock($JS); echo "<a class='vsubmit' onclick='delete_due_date();'>" . _x('button', 'Delete permanently') . "</a>"; } echo "</td>"; echo "</tr></table>"; } else { echo "<table width='100%'><tr><td class='nopadding'>"; echo $tt->getBeginHiddenFieldValue('due_date'); if ($canupdate) { Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1, 'maybeempty' => true)); } else { echo Html::convDateTime($this->fields["due_date"]); } echo $tt->getEndHiddenFieldValue('due_date', $this); 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 "<div id='sla_choice' style='display:none'>"; echo "<span class='b'>" . __('SLA') . "</span> "; Sla::dropdown(array('entity' => $this->fields["entities_id"], 'value' => $this->fields["slas_id"])); echo "</div>"; echo $tt->getEndHiddenFieldText('slas_id'); echo "</td>"; } echo "</tr></table>"; } } else { // New Ticket echo "<table width='100%'><tr><td width='40%' class='nopadding'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo $tt->getEndHiddenFieldValue('due_date', $this); 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' => $this->fields["entities_id"], 'value' => $this->fields["slas_id"])); echo $tt->getEndHiddenFieldValue('slas_id', $this); 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' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); } else { echo getUserName($this->fields["users_id_recipient"], $showuserlink); } echo "</td>"; echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>"; echo "<td width='{$colsize4}%'>"; if ($this->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($this->fields["date_mod"]), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td>"; echo "</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 width='{$colsize1}%'>" . __('Resolution date') . "</th>"; echo "<td width='{$colsize2}%'>"; Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>"; echo "<td width='{$colsize4}%'>"; Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $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' => $this->fields["type"]); /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'this.form.submit()'; } $rand = self::dropdownType('type', $opt); if ($ID) { $params = array('type' => '__VALUE__', 'entity_restrict' => $this->fields['entities_id'], 'value' => $this->fields['itilcategories_id'], 'currenttype' => $this->fields['type']); Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params); } } else { echo self::getTicketTypeName($this->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' => $this->fields["itilcategories_id"], 'entity' => $this->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'] = 'this.form.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") && $this->fields["itilcategories_id"] > 0) { $opt['display_emptychoice'] = false; } switch ($this->fields["type"]) { case self::INCIDENT_TYPE: $opt['condition'] .= "`is_incident`='1'"; break; case self::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", $this->fields["itilcategories_id"]); } echo "</td>"; echo "</tr>"; if (!$ID) { echo "</table>"; $this->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) { self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); TicketValidation::alertValidation($this, 'status'); } else { echo self::getStatus($this->fields["status"]); if (in_array($this->fields["status"], $this->getClosedStatusArray()) && $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) { echo " <a class='vsubmit' href='" . $this->getLinkURL() . "&forcetab=TicketFollowup\$1&_openfollowup=1'>" . __('Reopen') . "</a>"; } } echo $tt->getEndHiddenFieldValue('status', $this); 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' => $this->fields["requesttypes_id"])); } else { echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]); } echo $tt->getEndHiddenFieldValue('requesttypes_id', $this); 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 = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo $tt->getEndHiddenFieldValue('urgency', $this); } else { $idurgency = "value_urgency" . mt_rand(); echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>"; echo $tt->getBeginHiddenFieldValue('urgency'); echo parent::getUrgencyName($this->fields["urgency"]); echo $tt->getEndHiddenFieldValue('urgency', $this); } 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'] == self::INCIDENT_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) { $validation_right = 'validate_incident'; } if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) { $validation_right = 'validate_request'; } if (!empty($validation_right)) { echo "<input type='hidden' name='_add_validation' value='" . $values['_add_validation'] . "'>"; $params = array('name' => "users_id_validate", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'users_id_validate' => $values['users_id_validate']); TicketValidation::dropdownValidator($params); } echo $tt->getEndHiddenFieldValue('_add_validation', $this); if ($tt->isPredefinedField('global_validation')) { echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>"; } } else { echo $tt->getBeginHiddenFieldValue('global_validation'); if (Session::haveRightsOr('ticketvalidation', TicketValidation::getCreateRights())) { TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $this->fields['global_validation'])); } else { echo TicketValidation::getStatus($this->fields['global_validation']); } echo $tt->getEndHiddenFieldValue('global_validation', $this); } 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 = self::dropdownImpact(array('value' => $this->fields["impact"])); } else { $idimpact = "value_impact" . mt_rand(); echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $this->fields["impact"] . "'>"; echo parent::getImpactName($this->fields["impact"]); } echo $tt->getEndHiddenFieldValue('impact', $this); echo "</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 || !$ID) { Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $this->fields['entities_id'])); } else { echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]); } echo $tt->getEndHiddenFieldValue('locations_id', $this); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('priority'); printf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')); echo $tt->getEndHiddenFieldText('priority') . "</th>"; echo "<td>"; $idajax = 'change_priority_' . mt_rand(); if ($canupdate && $canpriority && !$tt->isHiddenField('priority')) { $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idpriority = 'dropdown_priority' . $idpriority; echo " <span id='{$idajax}' style='display:none'></span>"; } else { $idpriority = 0; echo $tt->getBeginHiddenFieldValue('priority'); echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>"; echo $tt->getEndHiddenFieldValue('priority', $this); } if ($canupdate || $canupdate_descr) { $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); } echo "</td>"; echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('itemtype'); printf(__('%1$s%2$s'), _n('Associated element', 'Associated elements', Session::getPluralNumber()), $tt->getMandatoryMark('itemtype')); if ($ID && $canupdate) { echo " <a href='" . $this->getFormURL() . "?id=" . $ID . "&forcetab=Item_Ticket\$1'><img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'></a>"; } echo $tt->getEndHiddenFieldText('itemtype'); echo "</th>"; echo "<td rowspan='2'>"; if (!$ID) { echo $tt->getBeginHiddenFieldValue('itemtype'); // Select hardware on creation or if have update right if ($canupdate || $canupdate_descr) { $dev_user_id = $values['_users_id_requester']; $dev_itemtype = $values["itemtype"]; $dev_items_id = $values["items_id"]; if ($dev_user_id > 0) { Item_Ticket::dropdownMyDevices($dev_user_id, $this->fields["entities_id"], $dev_itemtype, $dev_items_id); } Item_Ticket::dropdownAllDevices("itemtype", $dev_itemtype, $dev_items_id, 1, $dev_user_id, $this->fields["entities_id"]); echo "<span id='item_ticket_selection_information'></span>"; } echo $tt->getEndHiddenFieldValue('itemtype', $this); } else { // display associated elements $item_tickets = getAllDatasFromTable(getTableForItemType('Item_Ticket'), "`tickets_id`='" . $ID . "'"); $i = 0; foreach ($item_tickets as $itdata) { if ($i >= 5) { echo "<i><a href='" . $this->getFormURL() . "?id=" . $ID . "&forcetab=Item_Ticket\$1'>" . __('Display all items') . " (" . count($item_tickets) . ")</a></i>"; break; } $item = new $itdata['itemtype'](); $item->getFromDB($itdata['items_id']); echo $item->getTypeName(1) . ": " . $item->getLink(array('comments' => true)) . "<br/>"; $i++; } } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Need comment right to add a followup with the actiontime if (!$ID && Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) { 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', $this); echo "</td>"; } echo "</tr>"; echo "</table>"; if ($ID) { $this->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'); echo "<input type='text' size='90' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">"; echo $tt->getEndHiddenFieldValue('name', $this); } else { if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->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')); if (!$ID || $canupdate_descr) { $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); Html::showTooltip(nl2br(Html::Clean($content))); } echo $tt->getEndHiddenFieldText('content') . "</th>"; echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>"; if (!$ID || $canupdate_descr) { // Admin =oui on autorise la modification de la description echo $tt->getBeginHiddenFieldValue('content'); $rand = mt_rand(); $rand_text = mt_rand(); $cols = 90; $rows = 6; $content_id = "content{$rand}"; if ($CFG_GLPI["use_rich_text"]) { $this->fields["content"] = $this->setRichTextContent($content_id, $this->fields["content"], $rand); $cols = 100; $rows = 10; } else { $this->fields["content"] = $this->setSimpleTextContent($this->fields["content"]); } echo "<div id='content{$rand_text}'>"; echo "<textarea id='{$content_id}' name='content' cols='{$cols}' rows='{$rows}'>" . $this->fields["content"] . "</textarea></div>"; echo Html::scriptBlock("\$(document).ready(function() { \$('#{$content_id}').autogrow(); });"); echo $tt->getEndHiddenFieldValue('content', $this); } else { $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); echo nl2br(Html::Clean($content)); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; if ($view_linked_tickets) { echo "<th width='{$colsize1}%'>" . _n('Linked ticket', 'Linked tickets', Session::getPluralNumber()); $rand_linked_ticket = mt_rand(); if ($canupdate) { echo " "; echo "<img onClick=\"" . Html::jsShow("linkedticket{$rand_linked_ticket}") . "\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } echo '</th>'; echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>"; if ($canupdate) { echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>"; echo "<table class='tab_format' width='100%'><tr><td width='30%'>"; Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : ''); echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n"; echo "</td><td width='70%'>"; $linkparam = array('name' => '_link[tickets_id_2]', 'displaywith' => array('id')); if (isset($values["_link"])) { $linkparam['value'] = $values["_link"]['tickets_id_2']; } Ticket::dropdown($linkparam); echo "</td></tr></table>"; echo "</div>"; if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) { echo "<script language='javascript'>"; echo Html::jsShow("linkedticket{$rand_linked_ticket}"); echo "</script>"; } } Ticket_Ticket::displayLinkedTicketsTo($ID); echo "</td>"; } echo "</tr>"; // View files added echo "<tr class='tab_bg_1'>"; // Permit to add doc when creating a ticket echo "<th width='{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('_documents_id'); $doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize()); printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id')); // Do not show if hidden. if (!$tt->isHiddenField('_documents_id')) { DocumentType::showAvailableTypesLink(); } echo $tt->getEndHiddenFieldText('_documents_id'); echo "</th>"; echo "<td colspan='3' width='" . (100 - $colsize1) . "%' >"; // Do not set values echo $tt->getEndHiddenFieldValue('_documents_id'); if ($tt->isPredefinedField('_documents_id')) { if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) { echo "<span class='b'>" . __('Default documents:') . '</span>'; echo "<br>"; $doc = new Document(); foreach ($values['_documents_id'] as $key => $val) { if ($doc->getFromDB($val)) { echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>"; echo "- " . $doc->getNameID() . "<br>"; } } } } echo "<div id='fileupload_info'></div>"; echo "</td>"; echo "</tr>"; if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) { echo "<tr class='tab_bg_1'>"; if ($ID) { if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) { echo "<td class='tab_bg_2 center' colspan='4'>"; if ($this->fields["is_deleted"] == 1) { if (self::canPurge()) { echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'> "; } } else { if (self::canUpdate()) { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'> "; } } if ($this->fields["is_deleted"] == 1) { if (self::canPurge()) { echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">"; } } else { if (self::canDelete()) { echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>"; } } echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>"; echo "</td>"; } } 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) . "\">"; } } } // File upload system $colspan = 3; if (!$CFG_GLPI['use_rich_text']) { $colspan = 4; } echo "<tr class='tab_bg_1'>"; echo "<td colspan='{$colspan}'>"; echo $tt->getBeginHiddenFieldValue('_documents_id'); echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename']))); echo "</td>"; if ($CFG_GLPI['use_rich_text']) { echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='{$colspan}'>"; if (!isset($rand)) { $rand = mt_rand(); } if ($canupdate_descr) { echo Html::initImagePasteSystem($content_id, $rand); } echo "</td>"; } echo "</tr>"; echo "</table>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</div>"; if (!$options['template_preview']) { Html::closeForm(); } return true; }
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { echo '<table class="tab_cadre_fixe">'; echo '<tr>'; echo '<th colspan="3">' . _n('Destinations', 'Destinations', 2, 'formcreator') . '</th>'; echo '</tr>'; $target_class = new PluginFormcreatorTarget(); $founded_targets = $target_class->find('plugin_formcreator_forms_id = ' . $item->getID()); $target_number = count($founded_targets); $i = 0; foreach ($founded_targets as $target) { $i++; echo '<tr class="line' . $i % 2 . '">'; echo '<td onclick="document.location=\'../front/targetticket.form.php?id=' . $target['items_id'] . '\'" style="cursor: pointer">'; echo $target['name']; echo '</td>'; echo '<td align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/pencil.png" alt="*" title="' . __('Edit') . '" onclick="document.location=\'../front/targetticket.form.php?id=' . $target['items_id'] . '\'" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '<td align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/delete.png" alt="*" title="' . __('Delete', 'formcreator') . '" onclick="deleteTarget(' . $target['id'] . ', \'' . addslashes($target['name']) . '\')" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '</tr>'; } // Display add target link... echo '<tr class="line' . ($i + 1) % 2 . '" id="add_target_row">'; echo '<td colspan="3">'; echo '<a href="javascript:addTarget(' . $item->fields['id'] . ');"> <img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a destination', 'formcreator') . ' </a>'; echo '</td>'; echo '</tr>'; // OR display add target form echo '<tr class="line' . ($i + 1) % 2 . '" id="add_target_form" style="display: none;">'; echo '<td colspan="3" id="add_target_form_td"></td>'; echo '</tr>'; echo "</table>"; echo '<script type="text/javascript"> function addTarget(form) { document.getElementById("add_target_form").style.display = "table-row"; document.getElementById("add_target_row").style.display = "none"; Ext.get("add_target_form_td").load({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/ajax/target.php", scripts: true, params: "form_id=" + ' . $item->getId() . ' }); } function cancelAddTarget() { document.getElementById("add_target_row").style.display = "table-row"; document.getElementById("add_target_form").style.display = "none"; } function deleteTarget(target_id, target_name) { if(confirm("' . __('Are you sure you want to delete this destination:', 'formcreator') . ' " + target_name)) { Ext.Ajax.request({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/target.form.php", success: reloadTab, params: { delete: 1, id: target_id, plugin_formcreator_forms_id: ' . $item->getId() . ', _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" } }); } } </script>'; }
/** * Display the Form end-user form to be filled * * @param CommonGLPI $item Instance of the Form to be displayed * * @return Null Nothing, just display the form */ public function displayUserForm(CommonGLPI $item) { if (isset($_SESSION['formcreator']['datas'])) { $datas = $_SESSION['formcreator']['datas']; unset($_SESSION['formcreator']['datas']); } else { $datas = null; } echo '<form name="formcreator_form' . $item->getID() . '" method="post" role="form" enctype="multipart/form-data" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/form.form.php" class="formcreator_form form_horizontal">'; echo '<h1 class="form-title">' . $item->fields['name'] . '</h1>'; // Form Header if (!empty($item->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($item->fields['content']); echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . $item->getID(), '`order` ASC'); foreach ($find_sections as $section_line) { echo '<div class="form_section">'; echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { PluginFormcreatorFields::showField($question_line, $datas); } echo '</div>'; } // Display submit button echo '<div class="center">'; echo '<input type="submit" name="submit_formcreator" class="submit_button" value="' . __('Send') . '" />'; echo '</div>'; echo '<input type="hidden" name="formcreator_form" value="' . $item->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</form>'; }
/** * Display the Form end-user form to be filled * * @param CommonGLPI $item Instance of the Form to be displayed * * @return Null Nothing, just display the form */ public function displayUserForm(CommonGLPI $item) { if (isset($_SESSION['formcreator']['datas'])) { $datas = $_SESSION['formcreator']['datas']; unset($_SESSION['formcreator']['datas']); } else { $datas = null; } echo '<form name="formcreator_form' . $item->getID() . '" method="post" role="form" enctype="multipart/form-data" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/form.form.php" class="formcreator_form form_horizontal" onsubmit="return validateForm(this);">'; echo '<h1 class="form-title">' . $item->fields['name'] . '</h1>'; // Form Header if (!empty($item->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($item->fields['content']); echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $questions = array(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . $item->getID(), '`order` ASC'); echo '<div class="form_section">'; foreach ($find_sections as $section_line) { echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { if (isset($datas[$question_line['id']])) { // multiple choice question are saved as JSON and needs to be decoded $answer = in_array($question_line['fieldtype'], array('checkboxes', 'multiselect')) ? json_decode($datas[$question_line['id']]) : $datas[$question_line['id']]; } else { $answer = null; } PluginFormcreatorFields::showField($question_line, $answer); } } echo '<script type="text/javascript">formcreatorShowFields();</script>'; // Show validator selector if ($item->fields['validation_required']) { $validators = array(); $tab_users = array(); $subquery = 'SELECT u.`id` FROM `glpi_users` u LEFT JOIN `glpi_plugin_formcreator_formvalidators` fv ON fv.`users_id` = u.`id` WHERE fv.`forms_id` = "' . $this->getID() . '"'; $result = $GLOBALS['DB']->query($subquery); if ($GLOBALS['DB']->numrows($result) == 0) { $subentities = getSonsOf('glpi_entities', $this->fields["entities_id"]); $subentities = implode(',', $subentities); $query = "SELECT u.`id`\n FROM `glpi_users` u\n INNER JOIN `glpi_profiles_users` pu ON u.`id` = pu.`users_id`\n INNER JOIN `glpi_profiles` p ON p.`id` = pu.`profiles_id`\n INNER JOIN `glpi_profilerights` pr ON p.`id` = pr.`profiles_id`\n WHERE pr.`name` = 'ticketvalidation'\n AND (pr.`rights` & " . TicketValidation::VALIDATEREQUEST . " = " . TicketValidation::VALIDATEREQUEST . "\n OR pr.`rights` & " . TicketValidation::VALIDATEINCIDENT . " = " . TicketValidation::VALIDATEINCIDENT . ")\n AND (pu.`entities_id` = {$this->fields["entities_id"]}\n OR (pu.`is_recursive` = 1 AND pu.entities_id IN ({$subentities})))\n GROUP BY u.`id`\n ORDER BY u.`name`"; $result = $GLOBALS['DB']->query($query); } echo '<div class="form-group required liste line' . (count($questions) + 1) % 2 . '" id="form-validator">'; echo '<label>' . __('Choose a validator', 'formcreator') . ' <span class="red">*</span></label>'; echo '<select name="formcreator_validator" id="formcreator_validator" class="required">'; echo '<option value="">---</option>'; while ($user = $GLOBALS['DB']->fetch_assoc($result)) { $userItem = new User(); $userItem->getFromDB($user['id']); echo '<option value="' . $user['id'] . '">' . $userItem->getname() . '</option>'; } echo '</select>'; echo '<script type="text/javascript" src="../scripts/combobox.js.php"></script>'; echo '</div>'; } echo '</div>'; // Display submit button echo '<div class="center">'; echo '<input type="submit" name="submit_formcreator" class="submit_button" value="' . __('Send') . '" />'; echo '</div>'; echo '<input type="hidden" name="formcreator_form" value="' . $item->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</form>'; }
/** * @static function drawCanvas : permet de dessiner le canvas avec les éléments récupérés en paramètre * @param $items * @param $params */ public static function drawCanvas($items, $params) { global $CFG_GLPI; $nodes = array(); //tests sur les droits $eventless = false; if (!Session::haveRight('plugin_positions', UPDATE) || isset($params['menuoff']) && $params['menuoff'] == 1) { $eventless = true; } //image de fond $input = array(); $input['id'] = "Fond"; $input['shape'] = 'image'; $input['eventless'] = true; $input['width'] = $params['largeur']; $input['height'] = $params['hauteur']; $input['imagePath'] = $CFG_GLPI['url_base'] . '/plugins/positions/front/map.send.php?docid=' . $params['docid']; $input['color'] = 'black'; $input['testEvent'] = $eventless; $input['x'] = 250; $input['y'] = 250; $input['hideLabel'] = true; $nodes['nodes'][] = $input; $highlight = array(); //création des noeuds foreach ($items as $node) { $node['imagePath'] = $node['img']; $node['x'] = $node['x_coordinates'] + 1; $node['y'] = $node['y_coordinates'] + 1; if (empty($node['hideTooltip'])) { unset($node['hideTooltip']); } if (empty($node['hideLabel'])) { unset($node['hideLabel']); } $node['testEvent'] = $eventless; $node['shape'] = 'image'; $nodes['nodes'][] = $node; } if (isset($node['id']) == $params['id'] && isset($node['id']) != '') { $highlight[] = $params['id']; } //configuration du canvas $canvas_config = array('graphType' => 'Network', 'backgroundGradient2Color' => 'white', 'backgroundGradient1Color' => 'white', 'gradient' => false, 'networkFreezeOnLoad' => true, 'nodeFontColor' => 'rgb(29,34,43)', 'imageDir' => $CFG_GLPI['url_base'] . "/plugins/positions/lib/canvas/images/", 'calculateLayout' => false, 'disableConfigurator' => true, 'showCode' => false, 'nodeFontSize' => 6, 'fontName' => 'Verdana', 'resizable' => false); //Création du canvas et des évènements echo "<script>\n Ext.onReady(function(){\n Ext.QuickTips.init();\n var panel = new Ext.canvasXpress({\n renderTo: 'Carte',\n languages : " . json_encode(self::getJsLanguages()) . " ,\n frame: false,\n id: 'graph',\n width: 1300,\n height: 550,\n highlightArray: " . json_encode($highlight) . ",\n showExampleData: false,\n imgDir: '../lib/canvas/images/',\n data: " . json_encode($nodes) . ",\n _glpi_csrf_token: " . json_encode(Session::getNewCSRFToken()) . ",\n options:" . json_encode($canvas_config) . ",\n events:{\n dblclick : function(obj){\n if (navigator.appName == 'Microsoft Internet Explorer')\n {\n var ua = navigator.userAgent;\n var re = new RegExp(\"MSIE ([0-9]{1,}[\\.0-9]{0,})\");\n if (re.exec(ua) != null){\n rv = parseFloat( RegExp.\$1 );\n }\n if ( rv == 9.0 ){\n var n = obj.nodes[0];\n var win = new Ext.Window({\n id:n.id,\n title:'Informations - '+n.name,\n width:'600px',\n height:'800px',\n modal:false,\n layout:'fit',\n resizable:false,\n autoLoad: function(n){\n url: 'showinfos.php?items_id='+n.items_id+'&id='+n.id+'&name='+n.name+\n '&img='+n.imagePath+'&itemtype='+n.itemtype}\n\n });\n win.show();\n if( n.itemtype =='Location'){\n win.hide();\n }\n }\n else{\n alert('Download Internet Explorer v9.0');\n }\n }\n },\n click: function(obj) {\n var n = obj.nodes[0];\n var win = new Ext.Window({\n id:n.id,\n title:'Informations - '+n.name,\n width:'600px',\n height:'800px',\n modal:false,\n layout:'fit',\n resizable:false,\n autoLoad: {\n url: 'showinfos.php?items_id='+n.items_id+'&id='+n.id+'&name='+n.name+\n '&img='+n.imagePath+'&itemtype='+n.itemtype}\n });\n win.show();\n if( n.itemtype =='Location'){\n win.hide();\n }\n }\n }\n });\n });\n </script>"; echo "<div id='Carte'></div>"; }
function getWidgetContentForItem($widgetId) { global $CFG_GLPI, $DB; if (empty($this->form)) { $this->init(); } switch ($widgetId) { case $this->getType() . "1": $plugin = new Plugin(); if ($plugin->isActivated("tasklists")) { $widget = new PluginMydashboardDatatable(); $headers = array(__('Name'), __('Priority'), _n('Context', 'Contexts', 1, 'tasklists'), __('User'), __('Percent done'), __('Due date'), __('Action')); $query = "SELECT `glpi_plugin_tasklists_tasks`.*,`glpi_plugin_tasklists_tasktypes`.`completename` as 'type' \n FROM `glpi_plugin_tasklists_tasks`\n LEFT JOIN `glpi_plugin_tasklists_tasktypes` ON (`glpi_plugin_tasklists_tasks`.`plugin_tasklists_tasktypes_id` = `glpi_plugin_tasklists_tasktypes`.`id`) \n WHERE NOT `glpi_plugin_tasklists_tasks`.`is_deleted`\n AND `glpi_plugin_tasklists_tasks`.`state` < 2 "; $query .= getEntitiesRestrictRequest('AND', 'glpi_plugin_tasklists_tasks'); $query .= "ORDER BY `glpi_plugin_tasklists_tasks`.`priority`DESC "; $tasks = array(); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { while ($data = $DB->fetch_array($result)) { //$groups = Group_User::getGroupUsers($data['groups_id']); $groupusers = Group_User::getGroupUsers($data['groups_id']); $groups = array(); foreach ($groupusers as $groupuser) { $groups[] = $groupuser["id"]; } if ($data['visibility'] == 1 && $data['users_id'] == Session::getLoginUserID() || $data['visibility'] == 2 && ($data['users_id'] == Session::getLoginUserID() || in_array(Session::getLoginUserID(), $groups)) || $data['visibility'] == 3) { $ID = $data['id']; $rand = mt_rand(); $url = Toolbox::getItemTypeFormURL("PluginTasklistsTask") . "?id=" . $data['id']; $tasks[$data['id']][0] = "<a id='task" . $data["id"] . $rand . "' target='_blank' href='{$url}'>" . $data['name'] . "</a>"; $tasks[$data['id']][0] .= Html::showToolTip($data['comment'], array('applyto' => 'task' . $data["id"] . $rand, 'display' => false)); $bgcolor = $_SESSION["glpipriority_" . $data['priority']]; $tasks[$data['id']][1] = "<div class='center' style='background-color:{$bgcolor};'>" . CommonITILObject::getPriorityName($data['priority']) . "</div>"; $tasks[$data['id']][2] = $data['type']; $tasks[$data['id']][3] = getUserName($data['users_id']); $tasks[$data['id']][4] = Dropdown::getValueWithUnit($data['percent_done'], "%"); $due_date = $data['due_date']; $display = Html::convDate($data['due_date']); if ($due_date <= date('Y-m-d') && !empty($due_date)) { $display = "<div class='deleted'>" . Html::convDate($data['due_date']) . "</div>"; } $tasks[$data['id']][5] = $display; $tasks[$data['id']][6] = "<div align='center'>"; if (Session::haveRight("plugin_tasklists", UPDATE)) { $tasks[$data['id']][6] .= "<a class='pointer' onclick=\" submitGetLink('" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/front/task.form.php', {'done': 'done', 'id': '" . $data['id'] . "', '_glpi_csrf_token': '" . Session::getNewCSRFToken() . "', '_glpi_simple_form': '1'});\"><img src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/ok.png' title='" . __('Mark as done', 'tasklists') . "'></a>"; } if (Session::haveRight("plugin_tasklists", UPDATENOTE)) { $link = " <a href=\"javascript:" . Html::jsGetElementbyID('comment' . $rand) . ".dialog('open');\">"; $link .= "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/plus.png' title='" . __('Add comment', 'tasklists') . "'>"; $link .= "</a>"; $link .= Ajax::createIframeModalWindow('comment' . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/comment.form.php?id=" . $ID, array('title' => __('Add comment', 'tasklists'), 'reloadonclose' => false, 'width' => 1100, 'display' => false, 'height' => 300)); $tasks[$data['id']][6] .= $link; } $tasks[$data['id']][6] .= "</div>"; } } } } $widget->setTabDatas($tasks); $widget->setTabNames($headers); $widget->setOption("bSort", false); $widget->toggleWidgetRefresh(); $link = "<div align='right'><a class='vsubmit' href=\"javascript:" . Html::jsGetElementbyID('task') . ".dialog('open');\">"; $link .= __('Add task', 'tasklists'); $link .= "</a></div>"; $link .= Ajax::createIframeModalWindow('task', $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/task.form.php", array('title' => __('Add task', 'tasklists'), 'reloadonclose' => false, 'width' => 1180, 'display' => false, 'height' => 600)); $widget->appendWidgetHtmlContent($link); $widget->setWidgetTitle(__("Tasks list", 'tasklists')); return $widget; } else { $widget = new PluginMydashboardDatatable(); $widget->setWidgetTitle(__("Tasks list", 'tasklists')); return $widget; } break; } }
public function showForm($ID, $options = array()) { if (!isset($ID) || !$this->getFromDB($ID)) { Html::displayNotFoundError(); } $options = array('canedit' => false); $this->initForm($ID, $options); $this->showFormHeader($options); $form = new PluginFormcreatorForm(); $form->getFromDB($this->fields['plugin_formcreator_forms_id']); $canEdit = $this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']; if ($form->fields['validation_required'] == 1 && $_SESSION['glpiID'] == $this->fields['validator_id']) { $canValidate = true; } elseif ($form->fields['validation_required'] == 2) { // Get validator users from group $query = "SELECT u.`id`\n FROM `glpi_users` u\n INNER JOIN `glpi_groups_users` gu ON gu.`users_id` = u.`id`\n INNER JOIN `glpi_profiles_users` pu ON u.`id` = pu.`users_id`\n INNER JOIN `glpi_profiles` p ON p.`id` = pu.`profiles_id`\n INNER JOIN `glpi_profilerights` pr ON p.`id` = pr.`profiles_id`\n WHERE pr.`name` = 'ticketvalidation'\n AND (\n pr.`rights` & " . TicketValidation::VALIDATEREQUEST . " = " . TicketValidation::VALIDATEREQUEST . "\n OR pr.`rights` & " . TicketValidation::VALIDATEINCIDENT . " = " . TicketValidation::VALIDATEINCIDENT . ")\n AND gu.`groups_id` = " . $this->fields['validator_id'] . "\n AND u.`id` = " . (int) $_SESSION['glpiID']; $result = $GLOBALS['DB']->query($query); if ($GLOBALS['DB']->numrows($result) == 1) { $canValidate = true; } else { $canValidate = false; } } else { $canValidate = false; } echo '<tr><td colspan="4" class="formcreator_form form_horizontal">'; // Form Header if (!empty($form->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($form->fields['content']); echo '</div>'; } if ($this->fields['status'] == 'refused') { echo '<div class="refused_header">'; echo '<div>' . nl2br($this->fields['comment']) . '</div>'; echo '</div>'; } elseif ($this->fields['status'] == 'accepted') { echo '<div class="accepted_header">'; echo '<div>'; if (!empty($this->fields['comment'])) { echo nl2br($this->fields['comment']); } elseif ($form->fields['validation_required']) { echo __('Form accepted by validator.', 'formcreator'); } else { echo __('Form successfully saved.', 'formcreator'); } echo '</div>'; echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $questions = array(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . (int) $form->getID(), '`order` ASC'); echo '<div class="form_section">'; foreach ($find_sections as $section_line) { echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . (int) $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { $answer = new PluginFormcreatorAnswer(); $found = $answer->find("plugin_formcreator_formanwers_id = " . (int) $this->getID() . "\n AND plugin_formcreator_question_id = " . (int) $question_line['id']); $found = array_shift($found); // if (in_array($question_line['fieldtype'], array('checkboxes', 'multiselect'))) { // $found['answer'] = json_decode($found['answer']); // } if ($canEdit || $question_line['fieldtype'] != "description" && $question_line['fieldtype'] != "hidden") { PluginFormcreatorFields::showField($question_line, $found['answer'], $canEdit); } } } echo '<script type="text/javascript">formcreatorShowFields();</script>'; // Display submit button if ($this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']) { echo '<div class="form-group line' . (count($questions) + 1) % 2 . '">'; echo '<div class="center">'; echo '<input type="submit" name="save_formanswer" class="submit_button" value="' . __('Save') . '" />'; echo '</div>'; echo '</div>'; // Display validation form } elseif ($this->fields['status'] == 'waiting' && $canValidate) { if (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST)) { echo '<div class="form-group required line' . (count($questions) + 1) % 2 . '">'; echo '<label for="comment">' . __('Comment', 'formcreator') . ' <span class="red">*</span></label>'; echo '<textarea class="form-control" rows="5" name="comment" id="comment">' . $this->fields['comment'] . '</textarea>'; echo '<div class="help-block">' . __('Required if refused', 'formcreator') . '</div>'; echo '</div>'; echo '<div class="form-group line' . count($questions) % 2 . '">'; echo '<div class="center" style="float: left; width: 50%;">'; echo '<input type="submit" name="refuse_formanswer" class="submit_button" value="' . __('Refuse', 'formcreator') . '" onclick="return checkComment(this);" />'; echo '</div>'; echo '<div class="center">'; echo '<input type="submit" name="accept_formanswer" class="submit_button" value="' . __('Accept', 'formcreator') . '" />'; echo '</div>'; echo '</div>'; } } echo '<input type="hidden" name="formcreator_form" value="' . $form->getID() . '">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</div>'; // echo '</form>'; echo '<script type="text/javascript"> function checkComment(field) { if (document.getElementById("comment").value == "") { alert("' . __('Refused comment is required!', 'formcreator') . '"); return false; } } </script>'; echo '</td></tr>'; $this->showFormButtons($options); return true; }
/** * Display the Form end-user form to be filled * * @param CommonGLPI $item Instance of the Form to be displayed * * @return Null Nothing, just display the form */ public function displayUserForm(CommonGLPI $item) { if (isset($_SESSION['formcreator']['datas'])) { $datas = $_SESSION['formcreator']['datas']; unset($_SESSION['formcreator']['datas']); } else { $datas = null; } echo '<form name="formcreator_form' . $item->getID() . '" method="post" role="form" enctype="multipart/form-data" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/form.form.php" class="formcreator_form form_horizontal" onsubmit="return validateForm(this);">'; echo '<h1 class="form-title">' . $item->fields['name'] . '</h1>'; // Form Header if (!empty($item->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($item->fields['content']); echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $questions = array(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . (int) $item->getID(), '`order` ASC'); echo '<div class="form_section">'; foreach ($find_sections as $section_line) { echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . (int) $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { if (isset($datas[$question_line['id']])) { // multiple choice question are saved as JSON and needs to be decoded $answer = in_array($question_line['fieldtype'], array('checkboxes', 'multiselect')) ? json_decode($datas[$question_line['id']]) : $datas[$question_line['id']]; } else { $answer = null; } PluginFormcreatorFields::showField($question_line, $answer); } } echo '<script type="text/javascript">formcreatorShowFields();</script>'; // Show validator selector if ($item->fields['validation_required'] > 0) { $validators = array(0 => Dropdown::EMPTY_VALUE); // Groups if ($item->fields['validation_required'] == 2) { $query = 'SELECT g.`id`, g.`completename` FROM `glpi_groups` g LEFT JOIN `glpi_plugin_formcreator_formvalidators` fv ON fv.`users_id` = g.`id` WHERE fv.`forms_id` = ' . (int) $this->getID(); Toolbox::logDebug($query); $result = $GLOBALS['DB']->query($query); while ($validator = $GLOBALS['DB']->fetch_assoc($result)) { $validators[$validator['id']] = $validator['completename']; } // Users } else { $query = 'SELECT u.`id`, u.`name`, u.`realname`, u.`firstname` FROM `glpi_users` u LEFT JOIN `glpi_plugin_formcreator_formvalidators` fv ON fv.`users_id` = u.`id` WHERE fv.`forms_id` = ' . (int) $this->getID(); $result = $GLOBALS['DB']->query($query); while ($validator = $GLOBALS['DB']->fetch_assoc($result)) { $validators[$validator['id']] = formatUserName($validator['id'], $validator['name'], $validator['realname'], $validator['firstname']); } } echo '<div class="form-group required liste line' . (count($questions) + 1) % 2 . '" id="form-validator">'; echo '<label>' . __('Choose a validator', 'formcreator') . ' <span class="red">*</span></label>'; Dropdown::showFromArray('formcreator_validator', $validators); echo '</div>'; } echo '</div>'; // Display submit button echo '<div class="center">'; echo '<input type="submit" name="submit_formcreator" class="submit_button" value="' . __('Send') . '" />'; echo '</div>'; echo '<input type="hidden" name="formcreator_form" value="' . $item->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</form>'; }
/** * Create a close form part including CSRF token * * @param $display boolean Display or return string (default true) * * @since version 0.83. * * @return String **/ static function closeForm($display = true) { global $CFG_GLPI; $out = "\n"; if (GLPI_USE_CSRF_CHECK) { $out .= Html::hidden('_glpi_csrf_token', array('value' => Session::getNewCSRFToken())) . "\n"; } if (isset($CFG_GLPI['checkbox-zero-on-empty']) && $CFG_GLPI['checkbox-zero-on-empty']) { $js = " \$('form').submit(function() {\n \$('input[type=\"checkbox\"][data-glpicore-cb-zero-on-empty=\"1\"]:not(:checked)').each(function(index){\n // If the checkbox is not validated, we add a hidden field with '0' as value\n if (\$(this).attr('name')) {\n \$('<input>').attr({\n type: 'hidden',\n name: \$(this).attr('name'),\n value: '0'\n }).insertAfter(\$(this));\n }\n });\n });"; $out .= Html::scriptBlock($js) . "\n"; unset($CFG_GLPI['checkbox-zero-on-empty']); } $out .= "</form>\n"; if ($display) { echo $out; return true; } return $out; }
/** * Create a close form part including CSRF token * * @param $display boolean Display or return string (default true) * * @since version 0.83. * * @return String **/ static function closeForm($display = true) { $out = ''; if (GLPI_USE_CSRF_CHECK) { $out .= "<input type='hidden' name='_glpi_csrf_token' value='" . Session::getNewCSRFToken() . "'>"; } $out .= "</form>\n"; if ($display) { echo $out; return true; } return $out; }
public function showForm($datas) { if (!isset($datas['id']) || !$this->getFromDB($datas['id'])) { Html::displayNotFoundError(); } $form = new PluginFormcreatorForm(); $form->getFromDB($this->fields['plugin_formcreator_forms_id']); echo '<form name="formcreator_form' . $form->getID() . '" method="post" role="form" enctype="multipart/form-data" action="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/formanswer.form.php" class="formcreator_form form_horizontal">'; echo '<h1 class="form-title">' . $form->fields['name'] . '</h1>'; // Form Header if (!empty($form->fields['content'])) { echo '<div class="form_header">'; echo html_entity_decode($form->fields['content']); echo '</div>'; } if ($this->fields['status'] == 'refused') { echo '<div class="refused_header">'; echo '<div>' . nl2br($this->fields['comment']) . '</div>'; echo '</div>'; } elseif ($this->fields['status'] == 'accepted') { echo '<div class="accepted_header">'; echo '<div>'; if (!empty($this->fields['comment'])) { echo nl2br($this->fields['comment']); } elseif ($form->fields['validation_required']) { echo __('Form accepted by validator.', 'formcreator'); } else { echo __('Form successfully saved.', 'formcreator'); } echo '</div>'; echo '</div>'; } // Get and display sections of the form $question = new PluginFormcreatorQuestion(); $questions = array(); $section_class = new PluginFormcreatorSection(); $find_sections = $section_class->find('plugin_formcreator_forms_id = ' . $form->getID(), '`order` ASC'); echo '<div class="form_section">'; foreach ($find_sections as $section_line) { echo '<h2>' . $section_line['name'] . '</h2>'; // Display all fields of the section $questions = $question->find('plugin_formcreator_sections_id = ' . $section_line['id'], '`order` ASC'); foreach ($questions as $question_line) { $answer = new PluginFormcreatorAnswer(); $found = $answer->find('plugin_formcreator_formanwers_id = "' . $this->getID() . '" AND plugin_formcreator_question_id = "' . $question_line['id'] . '"'); $found = array_shift($found); // if (in_array($question_line['fieldtype'], array('checkboxes', 'multiselect'))) { // $found['answer'] = json_decode($found['answer']); // } $canEdit = $this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']; if ($canEdit || $question_line['fieldtype'] != "description" && $question_line['fieldtype'] != "hidden") { PluginFormcreatorFields::showField($question_line, $found['answer'], $canEdit); } } } echo '<script type="text/javascript">formcreatorShowFields();</script>'; // Display submit button if ($this->fields['status'] == 'refused' && $_SESSION['glpiID'] == $this->fields['requester_id']) { echo '<div class="form-group line' . (count($questions) + 1) % 2 . '">'; echo '<div class="center">'; echo '<input type="submit" name="save_formanswer" class="submit_button" value="' . __('Save') . '" />'; echo '</div>'; echo '</div>'; // Display validation form } elseif ($this->fields['status'] == 'waiting' && $_SESSION['glpiID'] == $this->fields['validator_id']) { if (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST)) { echo '<div class="form-group required line' . (count($questions) + 1) % 2 . '">'; echo '<label for="comment">' . __('Comment', 'formcreator') . ' <span class="red">*</span></label>'; echo '<textarea class="form-control" rows="5" name="comment" id="comment">' . $this->fields['comment'] . '</textarea>'; echo '<div class="help-block">' . __('Required if refused', 'formcreator') . '</div>'; echo '</div>'; echo '<div class="form-group line' . count($questions) % 2 . '">'; echo '<div class="center" style="float: left; width: 50%;">'; echo '<input type="submit" name="refuse_formanswer" class="submit_button" value="' . __('Refuse', 'formcreator') . '" onclick="return checkComment(this);" />'; echo '</div>'; echo '<div class="center">'; echo '<input type="submit" name="accept_formanswer" class="submit_button" value="' . __('Accept', 'formcreator') . '" />'; echo '</div>'; echo '</div>'; } } echo '<input type="hidden" name="formcreator_form" value="' . $form->getID() . '">'; echo '<input type="hidden" name="id" value="' . $this->getID() . '">'; echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">'; echo '</div>'; echo '</form>'; echo '<script type="text/javascript"> function checkComment(field) { if (document.getElementById("comment").value == "") { alert("' . __('Refused comment is required!', 'formcreator') . '"); return false; } } </script>'; }
/** * Display a list of all form sections and questions * * @param CommonGLPI $item Instance of a CommonGLPI Item (The Form Item) * @param integer $tabnum Number of the current tab * @param integer $withtemplate * * @see CommonDBTM::displayTabContentForItem * * @return null Nothing, just display the list */ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { echo '<table class="tab_cadre_fixe">'; // Get sections $section = new PluginFormcreatorSection(); $founded_sections = $section->find('plugin_formcreator_forms_id = ' . $item->getId(), '`order`'); $section_number = count($founded_sections); $tab_sections = array(); $tab_questions = array(); foreach ($founded_sections as $section) { $tab_sections[] = $section['id']; echo '<tr id="section_row_' . $section['id'] . '">'; echo '<th>' . $section['name'] . '</th>'; echo '<th align="center" width="32"> </th>'; echo '<th align="center" width="32">'; if ($section['order'] != 1) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/up2.png" alt="*" title="' . __('Edit') . '" onclick="moveSection(' . $section['id'] . ', \'up\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</th>'; echo '<th align="center" width="32">'; if ($section['order'] != $section_number) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/down2.png" alt="*" title="' . __('Edit') . '" onclick="moveSection(' . $section['id'] . ', \'down\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</th>'; echo '<th align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/pencil.png" alt="*" title="' . __('Edit') . '" onclick="editSection(' . $section['id'] . ')" align="absmiddle" style="cursor: pointer" /> '; echo '</th>'; echo '<th align="center" width="32">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/delete.png" alt="*" title="' . __('Delete', 'formcreator') . '" onclick="deleteSection(' . $section['id'] . ', \'' . addslashes($section['name']) . '\')" align="absmiddle" style="cursor: pointer" /> '; echo '</th>'; echo '</tr>'; // Get questions $question = new PluginFormcreatorQuestion(); $founded_questions = $question->find('plugin_formcreator_sections_id = ' . $section['id'], '`order`'); $question_number = count($founded_questions); $i = 0; foreach ($founded_questions as $question) { $i++; $tab_questions[] = $question['id']; echo '<tr class="line' . $i % 2 . '" id="question_row_' . $question['id'] . '">'; echo '<td onclick="editQuestion(' . $question['id'] . ', ' . $section['id'] . ')" style="cursor: pointer">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/ui-' . $question['fieldtype'] . '-field.png" alt="" title="" /> '; echo $question['name']; echo '</td>'; echo '<td align="center">'; $question_type = $question['fieldtype'] . 'Field'; $question_types = PluginFormcreatorFields::getTypes(); $classname = $question['fieldtype'] . 'Field'; $fields = $classname::getPrefs(); if ($fields['required'] == 0) { echo ' '; } elseif ($question['required']) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/required.png" alt="*" title="' . __('Required', 'formcreator') . '" onclick="setRequired(' . $question['id'] . ', 0)" align="absmiddle" style="cursor: pointer" /> '; } else { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/not-required.png" alt="*" title="' . __('Required', 'formcreator') . '" onclick="setRequired(' . $question['id'] . ', 1)" align="absmiddle" style="cursor: pointer" /> '; } echo '</td>'; echo '<td align="center">'; if ($question['order'] != 1) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/up.png" alt="*" title="' . __('Edit') . '" onclick="moveQuestion(' . $question['id'] . ', \'up\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</td>'; echo '<td align="center">'; if ($question['order'] != $question_number) { echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/down.png" alt="*" title="' . __('Edit') . '" onclick="moveQuestion(' . $question['id'] . ', \'down\');" align="absmiddle" style="cursor: pointer" /> '; } else { echo ' '; } echo '</td>'; echo '<td align="center">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/pencil.png" alt="*" title="' . __('Edit') . '" onclick="editQuestion(' . $question['id'] . ', ' . $section['id'] . ')" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '<td align="center">'; echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/delete.png" alt="*" title="' . __('Delete', 'formcreator') . '" onclick="deleteQuestion(' . $question['id'] . ', \'' . addslashes($question['name']) . '\')" align="absmiddle" style="cursor: pointer" /> '; echo '</td>'; echo '</tr>'; } echo '<tr class="line' . ($i + 1) % 2 . '">'; echo '<td colspan="6" id="add_question_td_' . $section['id'] . '" class="add_question_tds">'; echo '<a href="javascript:addQuestion(' . $section['id'] . ');"> <img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a question', 'formcreator') . ' </a>'; echo '</td>'; echo '</tr>'; } echo '<tr class="line1">'; echo '<th colspan="6" id="add_section_th">'; echo '<a href="javascript:addSection();" class="submit"> <img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a section', 'formcreator') . ' </a>'; echo '</th>'; echo '</tr>'; echo "</table>"; $js_tab_sections = ""; $js_tab_questions = ""; $js_line_questions = ""; foreach ($tab_sections as $key) { $js_tab_sections .= "tab_sections[{$key}] = document.getElementById('section_row_{$key}').innerHTML;" . PHP_EOL; $js_tab_questions .= "tab_questions[{$key}] = document.getElementById('add_question_td_{$key}').innerHTML;" . PHP_EOL; } foreach ($tab_questions as $key) { $js_line_questions .= "line_questions[{$key}] = document.getElementById('question_row_{$key}').innerHTML;" . PHP_EOL; } echo '<script type="text/javascript"> var modalWindow = new Ext.Window({ layout: "fit", width: "964", height: "600", closeAction: "hide", modal: "true", autoScroll: true, y: 500 }); // === QUESTIONS === var tab_questions = []; ' . $js_tab_questions . ' var line_questions = []; ' . $js_line_questions . ' function addQuestion(section) { modalWindow.show(); modalWindow.load({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/ajax/question.php", params: { section_id: section, form_id: ' . $item->getId() . ', _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" }, timeout: 30, scripts: true }); } function editQuestion(question, section) { modalWindow.show(); modalWindow.load({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/ajax/question.php", params: { question_id: question, section_id: section, form_id: ' . $item->getId() . ', _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" }, timeout: 30, scripts: true }); } function setRequired(question_id, value) { Ext.Ajax.request({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/question.form.php", success: reloadTab, params: { set_required: 1, id: question_id, value: value, _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" } }); } function moveQuestion(question_id, way) { Ext.Ajax.request({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/question.form.php", success: reloadTab, params: { move: 1, id: question_id, way: way, _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" } }); } function deleteQuestion(question_id, question_name) { if(confirm("' . __('Are you sure you want to delete this question:', 'formcreator') . ' " + question_name)) { Ext.Ajax.request({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/question.form.php", success: reloadTab, params: { delete: 1, id: question_id, plugin_formcreator_forms_id: ' . $item->getId() . ', _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" } }); } } // === SECTIONS === var add_section_link = document.getElementById("add_section_th").innerHTML; var tab_sections = []; ' . $js_tab_sections . ' function addSection() { Ext.get("add_section_th").load({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/ajax/section.php", scripts: true, params: "form_id=' . $item->getId() . '" }); } function editSection(section) { document.getElementById("section_row_" + section).innerHTML = "<th colspan=\\"6\\"></th>"; Ext.get("section_row_" + section + "").child("th").load({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/ajax/section.php", scripts: true, params: "section_id=" + section + "&form_id=' . $item->getId() . '" }); } function deleteSection(section_id, section_name) { if(confirm("' . __('Are you sure you want to delete this section:', 'formcreator') . ' " + section_name)) { Ext.Ajax.request({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/section.form.php", success: reloadTab, params: { delete: 1, id: section_id, plugin_formcreator_forms_id: ' . $item->getId() . ', _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" } }); } } function moveSection(section_id, way) { Ext.Ajax.request({ url: "' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/section.form.php", success: reloadTab, params: { move: 1, id: section_id, way: way, _glpi_csrf_token: "' . Session::getNewCSRFToken() . '" } }); } function resetAll() { document.getElementById("add_section_th").innerHTML = add_section_link; for (section_id in tab_sections) { if(parseInt(section_id)) { document.getElementById("section_row_" + section_id).innerHTML = tab_sections[section_id]; document.getElementById("add_question_td_" + section_id).innerHTML = tab_questions[section_id]; } } for (question_id in line_questions) { if(parseInt(question_id)) { document.getElementById("question_row_" + question_id).innerHTML = line_questions[question_id]; } } } </script>'; }