function showAddTitle($form) { global $LANG, $CFG_GLPI; echo "<div id='viewaddtitle'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewAddTitle () {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'PluginFormcreatorForm', 'plugin_formcreator_forms_id' => $form->fields['id'], 'id' => -1); Ajax::updateItemJsCode("viewaddtitle", $CFG_GLPI["root_doc"] . "/plugins/formcreator/ajax/viewaddobject.php", $params); echo "};"; echo "</script>\n"; echo "<div class='center'>" . "<a href='javascript:viewAddTitle();'>"; echo $LANG['plugin_formcreator']["title"][0] . "</a></div><br/>\n"; self::getListTitle($form->fields['id']); }
function showAddSection($form) { global $LANG, $CFG_GLPI; $target = new PluginFormcreatorTarget(); $listTarget = $target->find("plugin_formcreator_forms_id = '" . $form->fields['id'] . "'"); if (!empty($listTarget)) { echo "<div id='viewaddsection'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewAddSection () {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'PluginFormcreatorForm', 'plugin_formcreator_forms_id' => $form->fields['id'], 'id' => -1); Ajax::updateItemJsCode("viewaddsection", $CFG_GLPI["root_doc"] . "/plugins/formcreator/ajax/viewaddobject.php", $params); echo "};"; echo "</script>\n"; echo "<div class='center'>" . "<a href='javascript:viewAddSection();'>"; echo $LANG['plugin_formcreator']["section"][0] . "</a></div><br/>\n"; self::getListSection($form->fields['id']); } else { echo "<div class='center'>"; echo $LANG['plugin_formcreator']['section'][2]; echo "</div>"; } }
/** * Display all translated field for an KnowbaseItem * * @param $item a KnowbaseItem item * * @return true; **/ static function showTranslations(KnowbaseItem $item) { global $DB, $CFG_GLPI; $canedit = $item->can($item->getID(), UPDATE); $rand = mt_rand(); if ($canedit) { echo "<div id='viewtranslation" . $item->getID() . "{$rand}'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function addTranslation" . $item->getID() . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => get_class($item), 'knowbaseitems_id' => $item->fields['id'], 'id' => -1); Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo "<div class='center'>" . "<a class='vsubmit' href='javascript:addTranslation" . $item->getID() . "{$rand}();'>" . __('Add a new translation') . "</a></div><br>"; } $obj = new self(); $found = $obj->find("`knowbaseitems_id`='" . $item->getID() . "'", "`language` ASC"); if (count($found) > 0) { if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<div class='center'>"; echo "<table class='tab_cadre_fixehov'><tr class='tab_bg_2'>"; echo "<th colspan='4'>" . __("List of translations") . "</th></tr>"; if ($canedit) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __("Language") . "</th>"; echo "<th>" . __("Subject") . "</th>"; foreach ($found as $data) { echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer'\n onClick=\"viewEditTranslation" . $data['id'] . "{$rand}();\"" : '') . ">"; if ($canedit) { echo "<td class='center'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditTranslation" . $data["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => get_class($item), 'knowbaseitems_id' => $item->getID(), 'id' => $data["id"]); Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo Dropdown::getLanguageName($data['language']); echo "</td><td>"; echo $data["name"]; if (isset($data['answer']) && !empty($data['answer'])) { echo " "; Html::showToolTip(Toolbox::unclean_html_cross_side_scripting_deep($data['answer'])); } echo "</td></tr>"; } echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } else { echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>"; echo "<th class='b'>" . __("No translation found") . "</th></tr></table>"; } return true; }
/** * Print the contract costs * * @param $contract Contract object * @param $withtemplate boolean Template or basic item (default '') * * @return Nothing (call to classes members) **/ static function showForContract(Contract $contract, $withtemplate = '') { global $DB, $CFG_GLPI; $ID = $contract->fields['id']; if (!$contract->getFromDB($ID) || !$contract->can($ID, READ)) { return false; } $canedit = $contract->can($ID, UPDATE); echo "<div class='center'>"; $query = "SELECT *\n FROM `glpi_contractcosts`\n WHERE `contracts_id` = '{$ID}'\n ORDER BY `begin_date`"; $rand = mt_rand(); if ($canedit) { echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewAddCost" . $ID . "_{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $ID, 'id' => -1); Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>"; echo __('Add a new cost') . "</a></div>\n"; } if ($result = $DB->query($query)) { echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='5'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>"; if ($DB->numrows($result)) { echo "<tr><th>" . __('Name') . "</th>"; echo "<th>" . __('Begin date') . "</th>"; echo "<th>" . __('End date') . "</th>"; echo "<th>" . __('Budget') . "</th>"; echo "<th>" . __('Cost') . "</th>"; echo "</tr>"; Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Contract::getTypeName(1), $contract->getName())); $total = 0; while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data['contracts_id'] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">"; $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name']; echo "<td>"; printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false))); if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditCost" . $data['contracts_id'] . "_" . $data["id"] . "_{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $data["contracts_id"], 'id' => $data["id"]); Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo "</td>"; echo "<td>" . Html::convDate($data['begin_date']) . "</td>"; echo "<td>" . Html::convDate($data['end_date']) . "</td>"; echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>"; echo "<td class='numeric'>" . Html::formatNumber($data['cost']) . "</td>"; $total += $data['cost']; echo "</tr>"; Session::addToNavigateListItems(__CLASS__, $data['id']); } echo "<tr class='b noHover'><td colspan='3'> </td>"; echo "<td class='right'>" . __('Total cost') . '</td>'; echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>'; } else { echo "<tr><th colspan='5'>" . __('No item found') . "</th></tr>"; } echo "</table>"; } echo "</div><br>"; }
/** * show actor part in ITIL object form * * @param $ID integer ITIL object ID * @param $options array options for default values ($options of showForm) * * @return nothing display **/ function showActorsPartForm($ID, array $options) { global $CFG_GLPI; $showuserlink = 0; if (User::canView()) { $showuserlink = 1; } $options['_default_use_notification'] = 1; if (isset($options['entities_id'])) { $options['_default_use_notification'] = Entity::getUsedConfig('is_notif_enable_default', $options['entities_id'], '', 1); } // check is_hidden fields foreach (array('_users_id_requester', '_groups_id_requester', '_users_id_observer', '_groups_id_observer', '_users_id_assign', '_groups_id_assign', '_suppliers_id_assign') as $f) { $is_hidden[$f] = false; if (isset($options['_tickettemplate']) && $options['_tickettemplate']->isHiddenField($f)) { $is_hidden[$f] = true; } } $can_admin = $this->canAdminActors(); $can_assign = $this->canAssign(); $can_assigntome = $this->canAssignToMe(); if (isset($options['_noupdate']) && !$options['_noupdate']) { $can_admin = false; $can_assign = false; $can_assigntome = false; } // Manage actors : requester and assign echo "<table class='tab_cadre_fixe' id='mainformtable5'>"; echo "<tr class='tab_bg_1'>"; echo "<th rowspan='2' width='13%'>" . __('Actor') . "</th>"; echo "<th width='29%'>"; if (!$is_hidden['_users_id_requester'] || !$is_hidden['_groups_id_requester']) { _e('Requester'); } $rand_requester = -1; $candeleterequester = false; if ($ID && $can_admin && (!$is_hidden['_users_id_requester'] || !$is_hidden['_groups_id_requester'])) { $rand_requester = mt_rand(); echo " "; echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n onClick=\"" . Html::jsShow("itilactor{$rand_requester}") . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; $candeleterequester = true; } echo "</th>"; echo "<th width='29%'>"; if (!$is_hidden['_users_id_observer'] || !$is_hidden['_groups_id_observer']) { _e('Watcher'); } $rand_observer = -1; $candeleteobserver = false; if ($ID && $can_admin && (!$is_hidden['_users_id_observer'] || !$is_hidden['_groups_id_observer'])) { $rand_observer = mt_rand(); echo " "; echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n onClick=\"" . Html::jsShow("itilactor{$rand_observer}") . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; $candeleteobserver = true; } else { if ($ID > 0 && !in_array($this->fields['status'], $this->getClosedStatusArray()) && !$is_hidden['_users_id_observer'] && !$this->isUser(CommonITILActor::OBSERVER, Session::getLoginUserID()) && !$this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())) { echo " "; Html::showSimpleForm($this->getFormURL(), 'addme_observer', __('Associate myself'), array($this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/addme.png"); } } echo "</th>"; echo "<th width='29%'>"; if (!$is_hidden['_users_id_assign'] || !$is_hidden['_groups_id_assign'] || !$is_hidden['_suppliers_id_assign']) { _e('Assigned to'); } $rand_assign = -1; $candeleteassign = false; if ($ID && ($can_assign || $can_assigntome) && (!$is_hidden['_users_id_assign'] || !$is_hidden['_groups_id_assign'] || !$is_hidden['_suppliers_id_assign']) && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { $rand_assign = mt_rand(); echo " "; echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n onClick=\"" . Html::jsShow("itilactor{$rand_assign}") . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } if ($ID && $can_assigntome && !in_array($this->fields['status'], $this->getClosedStatusArray()) && !$is_hidden['_users_id_assign'] && !$this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { Html::showSimpleForm($this->getFormURL(), 'addme_assign', __('Associate myself'), array($this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/addme.png"); } if ($ID && $can_assign) { $candeleteassign = true; } echo "</th></tr>"; echo "<tr class='tab_bg_1 top'>"; echo "<td>"; if ($rand_requester >= 0) { $this->showActorAddForm(CommonITILActor::REQUESTER, $rand_requester, $this->fields['entities_id'], $is_hidden); } // Requester if (!$ID) { $reqdisplay = false; if ($can_admin && !$is_hidden['_users_id_requester']) { $this->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $options); $reqdisplay = true; } else { $delegating = User::getDelegateGroupsForUser($options['entities_id']); if (count($delegating) && !$is_hidden['_users_id_requester']) { //$this->getDefaultActor(CommonITILActor::REQUESTER); $options['_right'] = "delegate"; $this->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $options); $reqdisplay = true; } else { // predefined value if (isset($options["_users_id_requester"]) && $options["_users_id_requester"]) { echo self::getActorIcon('user', CommonITILActor::REQUESTER) . " "; echo Dropdown::getDropdownName("glpi_users", $options["_users_id_requester"]); echo "<input type='hidden' name='_users_id_requester' value=\"" . $options["_users_id_requester"] . "\">"; echo '<br>'; $reqdisplay = true; } } } //If user have access to more than one entity, then display a combobox : Ticket case if ($this->userentity_oncreate && isset($this->countentitiesforuser) && $this->countentitiesforuser > 1) { echo "<br>"; $rand = Entity::dropdown(array('value' => $this->fields["entities_id"], 'entity' => $this->userentities, 'on_change' => 'this.form.submit()')); } else { echo "<input type='hidden' name='entities_id' value='" . $this->fields["entities_id"] . "'>"; } if ($reqdisplay) { echo '<hr>'; } } else { if (!$is_hidden['_users_id_requester']) { $this->showUsersAssociated(CommonITILActor::REQUESTER, $candeleterequester, $options); } } // Requester Group if (!$ID) { if ($can_admin && !$is_hidden['_groups_id_requester']) { echo self::getActorIcon('group', CommonITILActor::REQUESTER); /// For ticket templates : mandatories if (isset($options['_tickettemplate'])) { echo $options['_tickettemplate']->getMandatoryMark('_groups_id_requester'); } echo " "; Group::dropdown(array('name' => '_groups_id_requester', 'value' => $options["_groups_id_requester"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_requester`')); } else { // predefined value if (isset($options["_groups_id_requester"]) && $options["_groups_id_requester"]) { echo self::getActorIcon('group', CommonITILActor::REQUESTER) . " "; echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_requester"]); echo "<input type='hidden' name='_groups_id_requester' value=\"" . $options["_groups_id_requester"] . "\">"; echo '<br>'; } } } else { if (!$is_hidden['_groups_id_requester']) { $this->showGroupsAssociated(CommonITILActor::REQUESTER, $candeleterequester, $options); } } echo "</td>"; echo "<td>"; if ($rand_observer >= 0) { $this->showActorAddForm(CommonITILActor::OBSERVER, $rand_observer, $this->fields['entities_id'], $is_hidden); } // Observer if (!$ID) { if ($can_admin && !$is_hidden['_users_id_observer']) { $this->showActorAddFormOnCreate(CommonITILActor::OBSERVER, $options); echo '<hr>'; } else { // predefined value if (isset($options["_users_id_observer"]) && $options["_users_id_observer"]) { echo self::getActorIcon('user', CommonITILActor::OBSERVER) . " "; echo Dropdown::getDropdownName("glpi_users", $options["_users_id_observer"]); echo "<input type='hidden' name='_users_id_observer' value=\"" . $options["_users_id_observer"] . "\">"; echo '<hr>'; } } } else { if (!$is_hidden['_users_id_observer']) { $this->showUsersAssociated(CommonITILActor::OBSERVER, $candeleteobserver, $options); } } // Observer Group if (!$ID) { if ($can_admin && !$is_hidden['_groups_id_observer']) { echo self::getActorIcon('group', CommonITILActor::OBSERVER); /// For ticket templates : mandatories if (isset($options['_tickettemplate'])) { echo $options['_tickettemplate']->getMandatoryMark('_groups_id_observer'); } echo " "; Group::dropdown(array('name' => '_groups_id_observer', 'value' => $options["_groups_id_observer"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_requester`')); } else { // predefined value if (isset($options["_groups_id_observer"]) && $options["_groups_id_observer"]) { echo self::getActorIcon('group', CommonITILActor::OBSERVER) . " "; echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_observer"]); echo "<input type='hidden' name='_groups_id_observer' value=\"" . $options["_groups_id_observer"] . "\">"; echo '<br>'; } } } else { if (!$is_hidden['_groups_id_observer']) { $this->showGroupsAssociated(CommonITILActor::OBSERVER, $candeleteobserver, $options); } } echo "</td>"; echo "<td>"; if ($rand_assign >= 0) { $this->showActorAddForm(CommonITILActor::ASSIGN, $rand_assign, $this->fields['entities_id'], $is_hidden, $this->canAssign(), $this->canAssign()); } // Assign User if (!$ID) { if ($can_assign && !$is_hidden['_users_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { $this->showActorAddFormOnCreate(CommonITILActor::ASSIGN, $options); echo '<hr>'; } else { if ($can_assigntome && !$is_hidden['_users_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { echo self::getActorIcon('user', CommonITILActor::ASSIGN) . " "; User::dropdown(array('name' => '_users_id_assign', 'value' => $options["_users_id_assign"], 'entity' => $this->fields["entities_id"], 'ldap_import' => true)); echo '<hr>'; } else { // predefined value if (isset($options["_users_id_assign"]) && $options["_users_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { echo self::getActorIcon('user', CommonITILActor::ASSIGN) . " "; echo Dropdown::getDropdownName("glpi_users", $options["_users_id_assign"]); echo "<input type='hidden' name='_users_id_assign' value=\"" . $options["_users_id_assign"] . "\">"; echo '<hr>'; } } } } else { if (!$is_hidden['_users_id_assign']) { $this->showUsersAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options); } } // Assign Groups if (!$ID) { if ($can_assign && !$is_hidden['_groups_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { echo self::getActorIcon('group', CommonITILActor::ASSIGN); /// For ticket templates : mandatories if (isset($options['_tickettemplate'])) { echo $options['_tickettemplate']->getMandatoryMark('_groups_id_assign'); } echo " "; $rand = mt_rand(); $params = array('name' => '_groups_id_assign', 'value' => $options["_groups_id_assign"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_assign`', 'rand' => $rand); if ($this->getType() == 'Ticket') { $params['toupdate'] = array('value_fieldname' => 'value', 'to_update' => "countgroupassign_{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/ticketassigninformation.php", 'moreparams' => array('groups_id_assign' => '__VALUE__')); } Group::dropdown($params); echo "<span id='countgroupassign_{$rand}'>"; echo "</span>"; echo "<script type='text/javascript'>"; Ajax::updateItemJsCode("countgroupassign_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/ticketassigninformation.php", array('groups_id_assign' => '__VALUE__'), "dropdown__groups_id_assign{$rand}"); echo "</script>"; echo '<hr>'; } else { // predefined value if (isset($options["_groups_id_assign"]) && $options["_groups_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { echo self::getActorIcon('group', CommonITILActor::ASSIGN) . " "; echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_assign"]); echo "<input type='hidden' name='_groups_id_assign' value=\"" . $options["_groups_id_assign"] . "\">"; echo '<hr>'; } } } else { if (!$is_hidden['_groups_id_assign']) { $this->showGroupsAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options); } } // Assign Suppliers if (!$ID) { if ($can_assign && !$is_hidden['_suppliers_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { $this->showSupplierAddFormOnCreate($options); } else { // predefined value if (isset($options["_suppliers_id_assign"]) && $options["_suppliers_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) { echo self::getActorIcon('supplier', CommonITILActor::ASSIGN) . " "; echo Dropdown::getDropdownName("glpi_suppliers", $options["_suppliers_id_assign"]); echo "<input type='hidden' name='_suppliers_id_assign' value=\"" . $options["_suppliers_id_assign"] . "\">"; echo '<hr>'; } } } else { if (!$is_hidden['_suppliers_id_assign']) { $this->showSuppliersAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options); } } echo "</td>"; echo "</tr>"; echo "</table>"; }
/** * @since version 0.90 * * @param $rand **/ function showTimelineForm($rand) { global $CFG_GLPI; //check global rights if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) { return false; } // javascript function for add and edit items echo "<script type='text/javascript' >\n"; echo "function viewAddSubitem" . $this->fields['id'] . "{$rand}(itemtype) {\n"; $params = array('action' => 'viewsubitem', 'type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => -1); if (isset($_GET['load_kb_sol'])) { $params['load_kb_sol'] = $_GET['load_kb_sol']; } $out = Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline.php", $params, "", false); echo str_replace("\"itemtype\"", "itemtype", $out); echo "\$('#approbation_form{$rand}').remove()"; echo "};"; echo "\n\n function change_task_state(tasks_id, target) {\n \$.post('" . $CFG_GLPI["root_doc"] . "/ajax/timeline.php',\n {'action': 'change_task_state',\n 'tasks_id': tasks_id,\n 'tickets_id': " . $this->fields['id'] . "\n })\n .done(function(new_state) {\n \$(target).removeClass('state_1 state_2')\n .addClass('state_'+new_state);\n });\n }\n\n function viewEditSubitem" . $this->fields['id'] . "{$rand}(e, itemtype, items_id, o, domid) {\n domid = (typeof domid === 'undefined')\n ? 'viewitem" . $this->fields['id'] . $rand . "'\n : domid;\n var target = e.target || window.event.srcElement;\n if (target.nodeName == 'a') return;\n if (target.className == 'read_more_button') return;\n \$('#'+domid).addClass('edited');\n \$('#'+domid+' .displayed_content').hide();\n \$('#'+domid+' .cancel_edit_item_content').show()\n .click(function() {\n \$(this).hide();\n \$('#'+domid).removeClass('edited');\n \$('#'+domid+' .edit_item_content').empty().hide();\n \$('#'+domid+' .displayed_content').show();\n });\n \$('#'+domid+' .edit_item_content').show()\n .load('" . $CFG_GLPI["root_doc"] . "/ajax/timeline.php',\n {'action' : 'viewsubitem',\n 'type' : itemtype,\n 'parenttype': 'Ticket',\n 'tickets_id': " . $this->fields['id'] . ",\n 'id' : items_id\n });\n\n\n };"; if (isset($_GET['load_kb_sol'])) { echo "viewAddSubitem" . $this->fields['id'] . "{$rand}('Solution');"; } echo "</script>\n"; //check sub-items rights $tmp = array('tickets_id' => $this->getID()); $fup = new TicketFollowup(); $ttask = new TicketTask(); $doc = new Document(); $canadd_fup = $fup->can(-1, CREATE, $tmp); $canadd_task = $ttask->can(-1, CREATE, $tmp); $canadd_document = $doc->can(-1, CREATE, $tmp) && $this->canAddItem('Document'); $canadd_solution = Ticket::canUpdate() && $this->canSolve(); if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) { return false; } //show choices echo "<h2>" . _sx('button', 'Add') . " : </h2>"; echo "<div class='timeline_form'>"; echo "<ul class='timeline_choices'>"; if ($canadd_fup) { echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>"; } if ($canadd_task) { echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>"; } if ($canadd_document) { echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>"; } if ($canadd_solution) { echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>"; } echo "</ul>"; // timeline_choices echo "<div class='clear'> </div>"; echo "</div>"; //end timeline_form echo "<div class='ajax_box' id='viewitem" . $this->fields['id'] . "{$rand}'></div>\n"; }
/** * Print the reminder form * * @param $ID integer Id of the item to print * @param $options array of possible options: * - target filename : where to go when done. **/ function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); // Show Reminder or blank form $onfocus = ""; if (!$ID > 0) { // Create item : do getempty before check right to set default values $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\""; } $canedit = $this->can($ID, 'w'); if ($canedit) { Html::initEditorSystem('text'); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_2'><td>" . __('Title') . "</td>"; echo "<td>"; if ($canedit) { Html::autocompletionTextField($this, "name", array('size' => 80, 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus)); } else { echo $this->fields['name']; } echo "</td>\n"; echo "<td>" . __('By') . "</td>"; echo "<td>"; echo getUserName($this->fields["users_id"]); if (!$ID) { echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n"; } echo "</td></tr>\n"; echo "<tr class='tab_bg_2'>"; echo "<td>" . _x('reminder', 'Visibility') . "</td>"; echo "<td>"; echo '<table><tr><td>'; echo __('Begin') . '</td><td>'; Html::showDateTimeFormItem("begin_view_date", $this->fields["begin_view_date"], 1, true, $canedit); echo '</td><td>' . __('End') . '</td><td>'; Html::showDateTimeFormItem("end_view_date", $this->fields["end_view_date"], 1, true, $canedit); echo '</td></tr></table>'; echo "</td>"; echo "<td>" . __('Status') . "</td>"; echo "<td>"; if ($canedit) { Planning::dropdownState("state", $this->fields["state"]); } else { echo Planning::getState($this->fields["state"]); } echo "</td>\n"; echo "</tr>\n"; echo "<tr class='tab_bg_2'><td >" . __('Calendar') . "</td>"; echo "<td class='center'>"; if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function showPlan() {\n"; echo "Ext.get('plan').setDisplayed('none');"; $params = array('form' => 'remind', 'users_id' => $this->fields["users_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); if ($ID && $this->fields["is_planned"]) { $params['begin'] = $this->fields["begin"]; $params['end'] = $this->fields["end"]; } Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; } if (!$ID || !$this->fields["is_planned"]) { if (Session::haveRight("show_planning", "1") || Session::haveRight("show_group_planning", "1") || Session::haveRight("show_all_planning", "1")) { echo "<div id='plan' onClick='showPlan()'>\n"; echo "<a href='#' class='vsubmit'>" . __('Add to schedule') . "</a>"; } } else { if ($canedit) { echo "<div id='plan' onClick='showPlan()'>\n"; echo "<span class='showplan'>"; } //TRANS: %1$s is the begin date, %2$s is the end date printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if ($canedit) { echo "</span>"; } } if ($canedit) { echo "</div>\n"; echo "<div id='viewplan'>\n</div>\n"; } echo "</td>"; if ($ID && $this->fields["is_planned"] && PlanningRecall::isAvailable()) { echo "<td>" . _x('Planning', 'Reminder') . "</td>"; echo "<td>"; if ($canedit) { PlanningRecall::dropdown(array('itemtype' => 'Reminder', 'items_id' => $ID)); } else { // No edit right : use specific Planning Recall Form PlanningRecall::specificForm(array('itemtype' => 'Reminder', 'items_id' => $ID)); } echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "</tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Description') . "</td>" . "<td colspan='3'>"; if ($canedit) { echo "<textarea cols='115' rows='15' name='text'>" . $this->fields["text"] . "</textarea>"; } else { echo "<div id='kbanswer'>"; echo Toolbox::unclean_html_cross_side_scripting_deep($this->fields["text"]); echo "</div>"; } echo "</td></tr>\n"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; $default_values = self::getDefaultValues(); // Get default values from posted values on reload form if (!isset($options['template_preview'])) { if (isset($_POST)) { $values = Html::cleanPostForTextArea($_POST); } } // 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; } } } // Default check if ($ID > 0) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w', $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 : $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 ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) { // Load template data $values[$predeffield] = $predefvalue; $this->fields[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } } } else { // No template load : reset predefined values if (count($values['_predefined_fields'])) { foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) { if ($values[$predeffield] == $predefvalue) { $values[$predeffield] = $default_values[$predeffield]; } } } } } // Put ticket template on $values for actors $values['_tickettemplate'] = $tt; $canupdate = Session::haveRight('update_ticket', '1'); $canpriority = Session::haveRight('update_priority', '1'); $canstatus = $canupdate; if (in_array($this->fields['status'], $this->getClosedStatusArray())) { $canupdate = false; } $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } if (!$options['template_preview']) { $this->showTabs($options); } else { // 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'>"; } echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe' id='mainformtable'>"; // Optional line $ismultientities = Session::isMultiEntitiesMode(); echo "<tr class='headerRow'>"; echo "<th colspan='4'>"; if ($ID) { $text = sprintf(__('%1$s - %2$s'), $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::showDateTimeFormItem("date", $date, 1, 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>'; if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) { $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span>'; } } $slaoptions = array(); if (Session::haveRight('config', 'r')) { $slaoptions['link'] = Toolbox::getItemTypeFormURL('SLA') . "?id=" . $this->fields["slas_id"]; } Html::showToolTip($commentsla, $slaoptions); if ($canupdate) { echo " <input type='submit' class='submit' name='sla_delete' value='" . _sx('button', 'Delete permanently') . "'>"; } echo "</td>"; echo "</tr></table>"; } else { echo "<table><tr><td class='nopadding'>"; echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true, $canupdate); 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 "<span 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 "</span>"; echo $tt->getEndHiddenFieldText('slas_id'); echo "</td>"; } echo "</tr></table>"; } } else { // New Ticket echo "<table><tr><td class='nopadding'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, false, $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::showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false, $canupdate); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>"; echo "<td width='{$colsize4}%'>"; Html::showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false, $canupdate); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } if ($ID) { echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>"; echo "<td width='{$colsize2}%'>"; // Permit to set type when creating ticket without update right if ($canupdate || !$ID) { $opt = array('value' => $this->fields["type"]); /// Auto submit to load template if (!$ID) { $opt['on_change'] = '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'] = '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')); } else { echo self::getStatus($this->fields["status"]); } 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 parent::getUrgencyName($this->fields["urgency"]); } echo "</td>"; // Display validation state echo "<th>"; if (!$ID) { echo $tt->getBeginHiddenFieldText('_add_validation'); printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation')); echo $tt->getEndHiddenFieldText('_add_validation'); } else { echo $tt->getBeginHiddenFieldText('global_validation'); _e('Approval'); echo $tt->getEndHiddenFieldText('global_validation'); } echo "</th>"; echo "<td>"; if (!$ID) { echo $tt->getBeginHiddenFieldValue('_add_validation'); $validation_right = ''; if ($values['type'] == self::INCIDENT_TYPE && Session::haveRight('create_incident_validation', 1)) { $validation_right = 'validate_incident'; } if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('create_request_validation', 1)) { $validation_right = 'validate_request'; } if (!empty($validation_right)) { User::dropdown(array('name' => "_add_validation", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'value' => $values['_add_validation'])); } 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 ($canupdate) { 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 rowspan='2'>" . $tt->getBeginHiddenFieldText('itemtype'); printf(__('%1$s%2$s'), __('Associated element'), $tt->getMandatoryMark('itemtype')); if ($ID && $canupdate) { echo " <img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n onClick=\"Ext.get('tickethardwareselection{$ID}').setDisplayed('block')\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'>"; } echo $tt->getEndHiddenFieldText('itemtype'); echo "</th>"; echo "<td rowspan='2'>"; echo $tt->getBeginHiddenFieldValue('itemtype'); // Select hardware on creation or if have update right if ($canupdate || !$ID || $canupdate_descr) { if ($ID) { if ($this->fields['itemtype'] && ($item = getItemForItemtype($this->fields['itemtype'])) && $this->fields["items_id"]) { if ($item->can($this->fields["items_id"], 'r')) { printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getLink(array('comments' => true))); } else { printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID()); } } } $dev_user_id = 0; $dev_itemtype = $this->fields["itemtype"]; $dev_items_id = $this->fields["items_id"]; if (!$ID) { $dev_user_id = $values['_users_id_requester']; $dev_itemtype = $values["itemtype"]; $dev_items_id = $values["items_id"]; } else { if (isset($this->users[CommonITILActor::REQUESTER]) && count($this->users[CommonITILActor::REQUESTER]) == 1) { foreach ($this->users[CommonITILActor::REQUESTER] as $user_id_single) { $dev_user_id = $user_id_single['users_id']; } } } if ($ID) { echo "<div id='tickethardwareselection{$ID}' style='display:none'>"; } if ($dev_user_id > 0) { self::dropdownMyDevices($dev_user_id, $this->fields["entities_id"], $dev_itemtype, $dev_items_id); } self::dropdownAllDevices("itemtype", $dev_itemtype, $dev_items_id, 1, $dev_user_id, $this->fields["entities_id"]); if ($ID) { echo "</div>"; } echo "<span id='item_ticket_selection_information'></span>"; } else { if ($ID && $this->fields['itemtype'] && ($item = getItemForItemtype($this->fields['itemtype']))) { $item->getFromDB($this->fields['items_id']); printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID()); } else { _e('General'); } } echo $tt->getEndHiddenFieldValue('itemtype', $this); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . sprintf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')) . "</th>"; echo "<td>"; $idajax = 'change_priority_' . mt_rand(); if ($canupdate && $canpriority && !$tt->isHiddenField('priority')) { $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); echo " <span id='{$idajax}' style='display:none'></span>"; } else { $idpriority = 0; echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>"; } if ($canupdate || $canupdate_descr) { $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Need comment right to add a followup with the actiontime if (!$ID && Session::haveRight("global_add_followups", "1")) { echo "<th>" . $tt->getBeginHiddenFieldText('actiontime'); printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime')); echo $tt->getEndHiddenFieldText('actiontime') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('actiontime'); Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true)); echo $tt->getEndHiddenFieldValue('actiontime', $this); echo "</td>"; } else { echo "<th></th><td></td>"; } echo "<th>" . $tt->getBeginHiddenFieldText('locations_id'); printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id')); echo $tt->getEndHiddenFieldText('locations_id') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('locations_id'); if ($canupdate) { Location::dropdown(array('value' => $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></tr>"; echo "</table>"; if ($ID) { $values['canupdate'] = $canupdate; $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'); $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showName{$rand}() {\n"; echo "Ext.get('name{$rand}').setDisplayed('none');"; $params = array('maxlength' => 250, 'size' => 90, 'name' => 'name', 'data' => rawurlencode($this->fields["name"])); Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params); echo "}"; echo "</script>\n"; echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n"; if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->fields["name"]; } echo "</div>\n"; echo "<div id='viewname{$rand}'>\n"; echo "</div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showName{$rand}();\n </script>"; } 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')); 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(); echo "<script type='text/javascript' >\n"; echo "function showDesc{$rand}() {\n"; echo "Ext.get('desc{$rand}').setDisplayed('none');"; $params = array('rows' => 6, 'cols' => 90, 'name' => 'content', 'data' => rawurlencode($this->fields["content"])); Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params); echo "}"; echo "</script>\n"; echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n"; if (!empty($this->fields["content"])) { echo nl2br($this->fields["content"]); } else { _e('Empty description'); } echo "</div>\n"; echo "<div id='viewdesc{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>"; } echo $tt->getEndHiddenFieldValue('content', $this); } else { echo nl2br($this->fields["content"]); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Permit to add doc when creating a ticket if (!$ID) { echo "<th width='{$colsize1}%'>" . sprintf(__('File (%s)'), Document::getMaxUploadSize()); echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt=\"" . __s('Help') . "\" onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000," . "height=800')\">"; echo " "; self::showDocumentAddButton(); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo "<div id='uploadfiles'><input type='file' name='filename[]' size='20'></div></td>"; } else { echo "<th colspan='2'>"; $docnb = Document_Item::countForItem($this); echo "<a href=\"" . $this->getLinkURL() . "&forcetab=Document_Item\$1\">"; //TRANS: %d is the document number echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb); echo "</a></th>"; } if ($view_linked_tickets) { echo "<th width='{$colsize3}%'>" . _n('Linked ticket', 'Linked tickets', 2); $rand_linked_ticket = mt_rand(); if ($canupdate) { echo " "; echo "<img onClick=\"Ext.get('linkedticket{$rand_linked_ticket}').setDisplayed('block')\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } echo '</th>'; echo "<td width='{$colsize4}%'>"; if ($canupdate) { echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>"; Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : ''); printf(__('%1$s: %2$s'), __('Ticket'), __('ID')); echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n"; echo "<input type='text' name='_link[tickets_id_2]'\n value='" . (isset($values["_link"]) ? $values["_link"]['tickets_id_2'] : '') . "'\n size='10'>\n"; echo " "; echo "</div>"; if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) { echo "<script language='javascript'>Ext.get('linkedticket{$rand_linked_ticket}').\n setDisplayed('block');</script>"; } } Ticket_Ticket::displayLinkedTicketsTo($ID); echo "</td>"; } else { echo "<td></td>"; } echo "</tr>"; if ((!$ID || $canupdate || $canupdate_descr || Session::haveRight("assign_ticket", "1") || Session::haveRight("steal_ticket", "1")) && !$options['template_preview']) { echo "<tr class='tab_bg_1'>"; if ($ID) { if (Session::haveRight('delete_ticket', 1)) { echo "<td class='tab_bg_2 center' colspan='2'>"; if ($this->fields["is_deleted"] == 1) { echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'></td>"; } else { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'></td>"; } echo "<td class='tab_bg_2 center' colspan='2'>"; if ($this->fields["is_deleted"] == 1) { echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">"; } else { echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'></td>"; } } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>"; } echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>"; } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; if ($tt->isField('id') && $tt->fields['id'] > 0) { echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>"; echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">"; } } } echo "</table>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</div>"; if (!$options['template_preview']) { Html::closeForm(); $this->addDivForTabs(); } return true; }
/** * @since version 0.90 * * @param $rand **/ function showTimelineForm($rand) { global $CFG_GLPI; //check global rights if (!Session::haveRight("ticket", Ticket::READMY) && !Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE))) { return false; } // javascript function for add and edit items echo "<script type='text/javascript' >\n"; echo "function viewAddSubitem" . $this->fields['id'] . "{$rand}(itemtype) {\n"; $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => -1); if (isset($_GET['load_kb_sol'])) { $params['load_kb_sol'] = $_GET['load_kb_sol']; } $out = Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline_viewsubitem.php", $params, "", false); echo str_replace("\"itemtype\"", "itemtype", $out); echo "\$('#approbation_form{$rand}').remove()"; echo "};"; $out = "function viewEditSubitem" . $this->fields['id'] . "{$rand}(e, itemtype, items_id, o) {\n\n var target = e.target || window.event.srcElement;\n if (target.nodeName == 'a') return;\n if (target.className == 'read_more_button') return;"; $params = array('type' => 'itemtype', 'parenttype' => 'Ticket', 'tickets_id' => $this->fields['id'], 'id' => 'items_id'); $out .= Ajax::updateItemJsCode("viewitem" . $this->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/timeline_viewsubitem.php", $params, "", false); $out = str_replace("\"itemtype\"", "itemtype", $out); $out = str_replace("\"items_id\"", "items_id", $out); echo $out; //scroll to edit form echo "\$('body').scrollTop(0);"; echo "\$('.ui-tabs-panel').scrollTop(0);"; // add a mark to currently edited element echo "var found_active = \$('.talk_active');\n i = found_active.length;\n while(i--) {\n var classes = found_active[i].className.replace( /(?:^|\\s)talk_active(?!\\S)/ , '' );\n found_active[i].className = classes;\n }\n o.className = o.className + ' talk_active';\n\n \$('#approbation_form{$rand}').remove();\n };"; if (isset($_GET['load_kb_sol'])) { echo "viewAddSubitem" . $this->fields['id'] . "{$rand}('Solution');"; } echo "</script>\n"; //check sub-items rights $tmp = array('tickets_id' => $this->getID()); $fup = new TicketFollowup(); $ttask = new TicketTask(); $doc = new Document(); $canadd_fup = $fup->can(-1, CREATE, $tmp); $canadd_task = $ttask->can(-1, CREATE, $tmp); $canadd_document = $doc->can(-1, CREATE, $tmp) && $this->canAddItem('Document'); $canadd_solution = Ticket::canUpdate() && $this->canSolve(); if (!$canadd_fup && !$canadd_task && !$canadd_document && !$canadd_solution) { return false; } //show choices echo "<h2>" . _sx('button', 'Add') . " : </h2>"; echo "<div class='timeline_form'>"; echo "<ul class='timeline_choices'>"; if ($canadd_fup) { echo "<li class='followup' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketFollowup\");'>" . __("Followup") . "</li>"; } if ($canadd_task) { echo "<li class='task' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"TicketTask\");'>" . __("Task") . "</li>"; } if ($canadd_document) { echo "<li class='document' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Document_Item\");'>" . __("Document") . "</li>"; } if ($canadd_solution) { echo "<li class='solution' onclick='" . "javascript:viewAddSubitem" . $this->fields['id'] . "{$rand}(\"Solution\");'>" . __("Solution") . "</li>"; } echo "</ul>"; // timeline_choices echo "<div class='clear'> </div>"; echo "</div>"; //end timeline_form echo "<div class='ajax_box' id='viewitem" . $this->fields['id'] . "{$rand}'></div>\n"; }
/** * Print the item costs * * @param $item CommonITILObject object or Project * @param $withtemplate boolean Template or basic item (default '') * * @return total cost **/ static function showForObject($item, $withtemplate = '') { global $DB, $CFG_GLPI; $forproject = false; if (Toolbox::is_a($item, 'Project')) { $forproject = true; } $ID = $item->fields['id']; if (!$item->getFromDB($ID) || !$item->canViewItem() || !static::canView()) { return false; } $canedit = false; if (!$forproject) { $canedit = $item->canUpdateItem(); } echo "<div class='center'>"; $condition = "= '{$ID}'"; if ($forproject) { $condition = " IN ('" . implode("','", ProjectTask::getAllTicketsForProject($ID)) . "')"; } $query = "SELECT *\n FROM `" . static::getTable() . "`\n WHERE `" . static::$items_id . "` {$condition}\n ORDER BY `begin_date`"; $rand = mt_rand(); if ($canedit) { echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewAddCost" . $ID . "_{$rand}() {\n"; $params = array('type' => static::getType(), 'parenttype' => static::$itemtype, static::$items_id => $ID, 'id' => -1); Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; if (static::canCreate()) { echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>"; echo __('Add a new cost') . "</a></div>\n"; } } $total = 0; $total_time = 0; $total_costtime = 0; $total_fixed = 0; $total_material = 0; if ($result = $DB->query($query)) { echo "<table class='tab_cadre_fixehov'>"; echo "<tr class='noHover'>"; if ($forproject) { echo "<th colspan='10'>" . _n('Ticket cost', 'Ticket costs', $DB->numrows($result)) . "</th>"; } else { echo "<th colspan='7'>" . self::getTypeName($DB->numrows($result)) . "</th>"; echo "<th>" . __('Item duration') . "</th>"; echo "<th>" . CommonITILObject::getActionTime($item->fields['actiontime']) . "</th>"; } echo "</tr>"; if ($DB->numrows($result)) { echo "<tr>"; if ($forproject) { echo "<th>" . __('Ticket') . "</th>"; $ticket = new Ticket(); } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Begin date') . "</th>"; echo "<th>" . __('End date') . "</th>"; echo "<th>" . __('Budget') . "</th>"; echo "<th>" . __('Duration') . "</th>"; echo "<th>" . __('Time cost') . "</th>"; echo "<th>" . __('Fixed cost') . "</th>"; echo "<th>" . __('Material cost') . "</th>"; echo "<th>" . __('Total cost') . "</th>"; echo "</tr>"; Session::initNavigateListItems(static::getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data[static::$items_id] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">"; $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name']; if ($forproject) { $ticket->getFromDB($data['tickets_id']); echo "<td>" . $ticket->getLink() . "</td>"; } echo "<td>"; printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false))); if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditCost" . $data[static::$items_id] . "_" . $data["id"] . "_{$rand}() {\n"; $params = array('type' => static::getType(), 'parenttype' => static::$itemtype, static::$items_id => $data[static::$items_id], 'id' => $data["id"]); Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo "</td>"; echo "<td>" . Html::convDate($data['begin_date']) . "</td>"; echo "<td>" . Html::convDate($data['end_date']) . "</td>"; echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>"; echo "<td>" . CommonITILObject::getActionTime($data['actiontime']) . "</td>"; $total_time += $data['actiontime']; echo "<td class='numeric'>" . Html::formatNumber($data['cost_time']) . "</td>"; $total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP; echo "<td class='numeric'>" . Html::formatNumber($data['cost_fixed']) . "</td>"; $total_fixed += $data['cost_fixed']; echo "<td class='numeric'>" . Html::formatNumber($data['cost_material']) . "</td>"; $total_material += $data['cost_material']; $cost = self::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']); echo "<td class='numeric'>" . Html::formatNumber($cost) . "</td>"; $total += $cost; echo "</tr>"; Session::addToNavigateListItems(static::getType(), $data['id']); } $colspan = 4; if ($forproject) { $colspan++; } echo "<tr class='b noHover'><td colspan='{$colspan}' class='right'>" . __('Total') . '</td>'; echo "<td>" . CommonITILObject::getActionTime($total_time) . "</td>"; echo "<td class='numeric'>" . Html::formatNumber($total_costtime) . "</td>"; echo "<td class='numeric'>" . Html::formatNumber($total_fixed) . '</td>'; echo "<td class='numeric'>" . Html::formatNumber($total_material) . '</td>'; echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>'; } else { echo "<tr><th colspan='9'>" . __('No item found') . "</th></tr>"; } echo "</table>"; } echo "</div><br>"; return $total; }
function showSummary($container) { global $DB, $CFG_GLPI; $cID = $container->fields['id']; // Display existing Fields $tmp = array('plugin_fields_containers_id' => $cID); $canadd = $this->can(-1, CREATE, $tmp); $query = "SELECT `id`, `label`\n FROM `" . $this->getTable() . "`\n WHERE `plugin_fields_containers_id` = '{$cID}'\n ORDER BY `ranking` ASC"; $result = $DB->query($query); $rand = mt_rand(); echo "<div id='viewField" . $cID . "{$rand}'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewAddField" . $cID . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'PluginFieldsContainer', 'plugin_fields_containers_id' => $cID, 'id' => -1); Ajax::updateItemJsCode("viewField" . $cID . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo "<div class='center'>" . "<a href='javascript:viewAddField" . $container->fields['id'] . "{$rand}();'>"; echo __("Add a new field", "fields") . "</a></div><br>\n"; if ($DB->numrows($result) == 0) { echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>"; echo "<th class='b'>" . __("No field for this bloc", "fields") . "</th></tr></table>"; } else { echo '<div id="drag">'; echo '<input type="hidden" name="_plugin_fields_containers_id" id="plugin_fields_containers_id" value="' . $cID . '" />'; echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; echo "<th>" . __("Label") . "</th>"; echo "<th>" . __("Type") . "</th>"; echo "<th>" . __("Default values") . "</th>"; echo "<th>" . __("Mandatory field") . "</th>"; echo "<th>" . __("Active") . "</th>"; echo "<th>" . __("Read only", "fields") . "</th>"; echo "<th width='16'> </th>"; echo "</tr>\n"; $fields_type = self::getTypes(); while ($data = $DB->fetch_array($result)) { if ($this->getFromDB($data['id'])) { echo "<tr class='tab_bg_2' style='cursor:pointer' onClick=\"viewEditField{$cID}" . $this->fields['id'] . "{$rand}();\">"; echo "<td>"; echo "\n<script type='text/javascript' >\n"; echo "function viewEditField" . $cID . $this->fields["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'PluginFieldsContainer', 'plugin_fields_containers_id' => $cID, 'id' => $this->fields["id"]); Ajax::updateItemJsCode("viewField" . $cID . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo $this->fields['label'] . "</td>"; echo "<td>" . $fields_type[$this->fields['type']] . "</td>"; echo "<td>" . $this->fields['default_value'] . "</td>"; echo "<td align='center'>" . Dropdown::getYesNo($this->fields["mandatory"]) . "</td>"; echo "<td align='center'>"; echo $this->fields['is_active'] == 1 ? __('Yes') : '<b class="red">' . __('No') . '</b>'; echo "</td>"; echo "<td>"; echo Dropdown::getYesNo($this->fields["is_readonly"]); echo "</td>"; echo '<td class="rowhandler control center">'; echo '<div class="drag row" style="cursor:move;border:none !important;">'; echo '<img src="../pics/drag.png" alt="#" title="Déplacer" width="16" height="16" />'; echo '</div>'; echo '</td>'; echo "</tr>\n"; } } } echo '</table>'; echo '</div>'; echo Html::scriptBlock('redipsInit()'); }
public function showFormDetail($plugin_order_orders_id) { global $CFG_GLPI, $DB; $order = new PluginOrderOrder(); $reference = new PluginOrderReference(); $reception = new PluginOrderReception(); $result_ref = $this->queryDetail($plugin_order_orders_id); $numref = $DB->numrows($result_ref); $rand = mt_rand(); $canedit = $order->can($plugin_order_orders_id, UPDATE) && $order->canUpdateOrder(); Session::initNavigateListItems($this->getType(), __("Order", "order") . " = " . $order->getName()); while ($data_ref = $DB->fetch_array($result_ref)) { $global_rand = mt_rand(); echo "<div class='center'>"; echo "<form method='post' name='order_updatedetail_form{$rand}' " . "id='order_updatedetail_form{$rand}' " . "action='" . Toolbox::getItemTypeFormURL('PluginOrderOrder') . "'>"; echo "<input type='hidden' name='plugin_order_orders_id'\n value='" . $plugin_order_orders_id . "'>"; echo "<input type='hidden' name='plugin_order_order_items_id'\n value='" . $data_ref['IDD'] . "'>"; echo "<table class='tab_cadre_fixe'>"; if (!$numref) { echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>"; } else { $refID = $data_ref["id"]; $price_taxfree = $data_ref["price_taxfree"]; $discount = $data_ref["discount"]; $rand = mt_rand(); echo "<tr><th><ul><li>"; echo "<a href=\"javascript:showHideDiv('detail{$rand}','detail_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">"; echo "<img alt='' name='detail_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">"; echo "</a>"; echo "</li></ul></th>"; echo "<th>" . __("Quantity", "order") . "</th>"; echo "<th>" . __("Equipment", "order") . "</th>"; echo "<th>" . __("Manufacturer") . "</th>"; echo "<th>" . __("Reference") . "</th>"; echo "<th>" . __("Type") . "</th>"; echo "<th>" . __("Model") . "</th>"; echo "<th>" . __("Unit price tax free", "order") . "</th>"; echo "<th>" . __("Discount (%)", "order") . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1 center'>"; echo "<td><div id='viewaccept{$rand}' style='display:none;'>"; echo "<p><input type='submit' onclick=\"return confirm('" . __("Do you really want to update this item ?", "order") . "');\" name='update_item' value=\"" . _sx("button", "Update") . "\" class='submit'></p>"; echo "<br /><p><input type='button' onclick=\"hideForm{$rand}();\" value=\"" . _sx("button", "Cancel") . "\" class='submit'></p>"; echo "</div></td>"; if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function hideForm{$rand}() {\n"; echo "\$('#quantity{$rand}').show();"; echo "\$('#pricetaxfree{$rand}').show();"; echo "\$('#discount{$rand}').show();"; echo "\$('#viewquantity{$rand} input').remove();"; echo "\$('#viewpricetaxfree{$rand} input').remove();"; echo "\$('#viewdiscount{$rand} input').remove();"; echo "\$('#viewaccept{$rand}').hide();"; echo "}\n"; echo "</script>\n"; } /* quantity */ $quantity = $this->getTotalQuantityByRefAndDiscount($plugin_order_orders_id, $refID, $price_taxfree, $discount); if ($canedit) { echo "<td align='center'>"; echo "<script type='text/javascript' >\n"; echo "function showQuantity{$rand}() {\n"; echo "\$('#quantity{$rand}').hide();"; echo "\$('#viewaccept{$rand}').show();"; $params = array('maxlength' => 15, 'size' => 8, 'name' => 'quantity', 'class' => 'quantity', 'force_integer' => true, 'data' => rawurlencode($quantity)); Ajax::updateItemJsCode("viewquantity{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false); echo "}"; echo "</script>\n"; echo "<div id='quantity{$rand}' class='center' onClick='showQuantity{$rand}()'>\n"; echo $quantity; echo "</div>\n"; echo "<div id='viewquantity{$rand}'>\n"; echo "</div>\n"; echo "</td>"; } else { echo "<td align='center'>" . $quantity . "</td>"; } /* type */ $item = new $data_ref["itemtype"](); echo "<td align='center'>" . $item->getTypeName() . "</td>"; /* manufacturer */ echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>"; /* reference */ echo "<td align='center'>"; echo "<input type='hidden' name='old_plugin_order_references_id'\n value='" . $refID . "'>"; echo $reference->getReceptionReferenceLink($data_ref); echo "</td>"; /* type */ echo "<td align='center'>"; if (file_exists(GLPI_ROOT . "/inc/" . strtolower($data_ref["itemtype"]) . "type.class.php")) { echo Dropdown::getDropdownName(getTableForItemType($data_ref["itemtype"] . "Type"), $data_ref["types_id"]); } echo "</td>"; /* modele */ echo "<td align='center'>"; if (file_exists(GLPI_ROOT . "/inc/" . strtolower($data_ref["itemtype"]) . "model.class.php")) { echo Dropdown::getDropdownName(getTableForItemType($data_ref["itemtype"] . "Model"), $data_ref["models_id"]); } echo "</td>"; if ($canedit) { echo "<td align='center'>"; echo "<input type='hidden' name='old_price_taxfree' value='" . $price_taxfree . "'>"; echo "<script type='text/javascript' >\n"; echo "function showPricetaxfree{$rand}() {\n"; echo "\$('#pricetaxfree{$rand}').hide();"; echo "\$('#viewaccept{$rand}').show();"; $params = array('maxlength' => 15, 'size' => 8, 'name' => 'price_taxfree', 'class' => 'decimal', 'data' => rawurlencode($price_taxfree)); Ajax::updateItemJsCode("viewpricetaxfree{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false); echo "}"; echo "</script>\n"; echo "<div id='pricetaxfree{$rand}' class='center' onClick='showPricetaxfree{$rand}()'>\n"; echo Html::formatNumber($price_taxfree); echo "</div>\n"; echo "<div id='viewpricetaxfree{$rand}'>\n"; echo "</div>\n"; echo "</td>"; } else { echo "<td align='center'>" . Html::formatNumber($price_taxfree) . "</td>"; } /* reduction */ if ($canedit) { echo "<td align='center'>"; echo "<input type='hidden' name='old_discount' value='" . $discount . "'>"; echo "<script type='text/javascript' >\n"; echo "function showDiscount{$rand}() {\n"; echo "\$('#discount{$rand}').hide();"; echo "\$('#viewaccept{$rand}').show();"; $params = array('maxlength' => 15, 'size' => 8, 'name' => 'discount', 'class' => 'smalldecimal', 'data' => rawurlencode($discount)); Ajax::updateItemJsCode("viewdiscount{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false); echo "}"; echo "</script>\n"; echo "<div id='discount{$rand}' class='center' onClick='showDiscount{$rand}()'>\n"; echo Html::formatNumber($discount); echo "</div>\n"; echo "<div id='viewdiscount{$rand}'>\n"; echo "</div>\n"; echo "</td>"; } else { echo "<td align='center'>" . Html::formatNumber($discount) . "</td>"; } echo "</tr></table>"; Html::closeForm(); echo "<div class='center' id='detail{$rand}' style='display:none'>"; echo "<form method='post' name='order_detail_form{$rand}' id='order_detail_form{$rand}' " . "action=\"" . Toolbox::getItemTypeFormURL('PluginOrderOrder') . "\">"; if ($canedit) { echo "<div class='center'>"; echo "<table width='950px' class='tab_glpi'>"; echo "<tr><td><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/arrow-left-top.png\" alt=''>"; echo "</td><td class='center'>"; echo "<a onclick= \"if ( markCheckboxes('order_detail_form{$rand}') ) return false;\" href='#'>" . __("Check all") . "</a></td>"; echo "<td>/</td><td class='center'>"; echo "<a onclick= \"if ( unMarkCheckboxes('order_detail_form{$rand}') ) " . " return false;\" href='#'>" . __("Uncheck all") . "</a>"; echo "</td><td align='left'>"; echo "<input type='submit' onclick=\"return confirm('" . __("Do you really want to delete these details ? Delivered items will not be linked to order !", "order") . "')\" name='delete_item' value=\"" . __("Delete permanently") . "\" class='submit'>"; echo "</td>"; // Edit buttons echo "<td align='left' width='80%'>"; echo "<div id='detail_viewaccept{$global_rand}' style='display:none;'>"; echo " <input type='submit' onclick=\"return confirm('" . __("Do you really want to update this item ?", "order") . "');\" name='update_detail_item'\n value=\"" . _sx("button", "Update") . "\" class='submit'> "; echo " <input type='button' onclick=\"detail_hideForm{$global_rand}();\"\n value=\"" . _sx("button", "Cancel") . "\" class='submit'>"; echo "</div>"; echo "</td>"; echo "</table>"; echo "</div>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit) { echo "<th></th>"; } if ($data_ref["itemtype"] != 'SoftwareLicense') { echo "<th>" . __("ID") . "</th>"; } echo "<th>" . __("Reference") . "</th>"; echo "<th>" . __("Unit price tax free", "order") . "</th>"; echo "<th>" . __("VAT", "order") . "</th>"; echo "<th>" . __("Discount (%)", "order") . "</th>"; echo "<th>" . __("Discounted price tax free", "order") . "</th>"; echo "<th>" . __("Price ATI", "order") . "</th>"; echo "<th>" . __("Status") . "</th></tr>"; $query = "SELECT `" . $this->getTable() . "`.`id` AS IDD, `glpi_plugin_order_references`.`id`,\n `glpi_plugin_order_references`.`name`,\n `" . $this->getTable() . "`.`comment`,\n `" . $this->getTable() . "`.`price_taxfree`,\n `" . $this->getTable() . "`.`price_discounted`,\n `" . $this->getTable() . "`.`discount`,\n `" . $this->getTable() . "`.`plugin_order_ordertaxes_id`,\n `" . $this->getTable() . "`.`price_ati`\n FROM `" . $this->getTable() . "`, `glpi_plugin_order_references`\n WHERE `" . $this->getTable() . "`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n AND `" . $this->getTable() . "`.`plugin_order_references_id` = '" . $refID . "'\n AND `" . $this->getTable() . "`.`price_taxfree` LIKE '" . $price_taxfree . "'\n AND `" . $this->getTable() . "`.`discount` LIKE '" . $discount . "'\n AND `" . $this->getTable() . "`.`plugin_order_orders_id` = '{$plugin_order_orders_id}'"; if ($data_ref["itemtype"] == 'SoftwareLicense') { $query .= " GROUP BY `glpi_plugin_order_references`.`name` "; } $query .= " ORDER BY `glpi_plugin_order_references`.`name` "; $result = $DB->query($query); $num = $DB->numrows($result); // Initialize for detail_hideForm javascript function $hideForm = ""; while ($data = $DB->fetch_array($result)) { $rand_line = mt_rand(); Session::addToNavigateListItems($this->getType(), $data['IDD']); // Compute for detail_hideForm javascript function $hideForm .= "\$('#detail_pricetaxfree{$rand_line}').show();\n"; $hideForm .= "\$('#detail_viewpricetaxfree{$rand_line} input').remove();\n"; $hideForm .= "\$('#detail_discount{$rand_line}').show();\n"; $hideForm .= "\$('#detail_viewdiscount{$rand_line} input').remove();\n"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}>"; echo "<input type='hidden' name='plugin_order_orders_id' value='" . $plugin_order_orders_id . "'>"; echo "</td>"; } if ($data_ref["itemtype"] != 'SoftwareLicense') { echo "<td align='center'><a href='" . Toolbox::getItemTypeFormURL('PluginOrderOrder_Item') . "?id=" . $data['IDD'] . "'>" . $data['IDD'] . "</a>"; echo " "; Html::showToolTip($data['comment']); } /* reference */ echo "<td align='center'>"; echo "<input type='hidden' name='detail_old_plugin_order_references_id[" . $data["IDD"] . "]'\n value='" . $data["id"] . "'>"; echo $reference->getReceptionReferenceLink($data); echo "</td>"; if ($canedit) { echo "<td align='center'>"; echo "<input type='hidden' name='detail_old_price_taxfree[" . $data["IDD"] . "]'\n value='" . $data["price_taxfree"] . "'>"; echo "<script type='text/javascript' >\n"; echo "function showDetailPricetaxfree{$rand_line}() {\n"; echo "\$('#detail_pricetaxfree{$rand_line}').hide();"; echo "\$('#detail_viewaccept{$global_rand}').show();"; $params = array('maxlength' => 15, 'size' => 8, 'name' => 'detail_price_taxfree[' . $data["IDD"] . ']', 'class' => 'decimal', 'data' => rawurlencode($data["price_taxfree"])); Ajax::updateItemJsCode("detail_viewpricetaxfree{$rand_line}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false); echo "}"; echo "</script>\n"; echo "<div id='detail_pricetaxfree{$rand_line}' class='center'\n onClick='showDetailPricetaxfree{$rand_line}()'>\n"; echo Html::formatNumber($data["price_taxfree"]); echo "</div>\n"; echo "<div id='detail_viewpricetaxfree{$rand_line}'>\n"; echo "</div>\n"; echo "</td>"; } else { echo "<td align='center'>" . Html::formatNumber($data["price_taxfree"]) . "</td>"; } /* taxe */ echo "<td align='center'>"; echo Dropdown::getDropdownName(getTableForItemType("PluginOrderOrderTax"), $data["plugin_order_ordertaxes_id"]); echo "</td>"; /* reduction */ if ($canedit) { echo "<td align='center'>"; echo "<input type='hidden' name='detail_old_discount[" . $data["IDD"] . "]'\n value='" . $data["discount"] . "'>"; echo "<script type='text/javascript' >\n"; echo "function showDetailDiscount{$rand_line}() {\n"; echo "\$('#detail_discount{$rand_line}').hide();"; echo "\$('#detail_viewaccept{$global_rand}').show();"; $params = array('maxlength' => 15, 'size' => 8, 'name' => 'detail_discount[' . $data["IDD"] . ']', 'class' => 'smalldecimal', 'data' => rawurlencode($data["discount"])); Ajax::updateItemJsCode("detail_viewdiscount{$rand_line}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false); echo "}"; echo "</script>\n"; echo "<div id='detail_discount{$rand_line}' class='center'\n onClick='showDetailDiscount{$rand_line}()'>\n"; echo Html::formatNumber($data["discount"]); echo "</div>\n"; echo "<div id='detail_viewdiscount{$rand_line}'>\n"; echo "</div>\n"; echo "</td>"; } else { echo "<td align='center'>" . Html::formatNumber($data["discount"]) . "</td>"; } /* price with reduction */ echo "<td align='center'>" . Html::formatNumber($data["price_discounted"]) . "</td>"; /* price ati */ echo "<td align='center'>" . Html::formatNumber($data["price_ati"]) . "</td>"; /* status */ echo "<td align='center'>" . $reception->getReceptionStatus($data["IDD"]) . "</td></tr>"; } echo "</table>"; if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function detail_hideForm{$global_rand}() {\n"; echo $hideForm; echo "\$('#detail_viewaccept{$global_rand}').hide();"; echo "}\n"; echo "</script>\n"; } if ($canedit) { echo "<div class='center'>"; echo "<table width='950px' class='tab_glpi'>"; echo "<tr><td><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png\" alt=''>"; echo "</td><td class='center'>"; echo "<a onclick= \"if ( markCheckboxes('order_detail_form{$rand}') ) return false;\" href='#'>" . __("Check all") . "</a></td>"; echo "<td>/</td><td class='center'>"; echo "<a onclick= \"if ( unMarkCheckboxes('order_detail_form{$rand}') ) " . " return false;\" href='#'>" . __("Uncheck all") . "</a>"; echo "</td><td align='left'>"; echo "<input type='submit' onclick=\"return confirm('" . __("Do you really want to delete these details ? Delivered items will not be linked to order !", "order") . "')\" name='delete_item' value=\"" . __("Delete permanently") . "\" class='submit'>"; echo "</td>"; // Edit buttons echo "<td align='left' width='80%'>"; echo "<div id='detail_viewaccept{$global_rand}' style='display:none;'>"; echo " <input type='submit' onclick=\"return confirm('" . __("Do you really want to update this item ?", "order") . "');\" name='update_detail_item'\n value=\"" . _sx("button", "Update") . "\" class='submit'> "; echo " <input type='button' onclick=\"detail_hideForm{$global_rand}();\"\n value=\"" . _sx("button", "Cancel") . "\" class='submit'>"; echo "</div>"; echo "</td>"; echo "</table>"; echo "</div>"; } Html::closeForm(); echo "</div>"; } echo "<br>"; } }
/** * Toggle view in LDAP user import/synchro between no restriction and date restriction * * @param $enabled (default 0) **/ static function showAdvanceDateRestrictionSwitch($enabled = 0) { global $CFG_GLPI; $rand = mt_rand(); $url = $CFG_GLPI["root_doc"] . "/ajax/ldapdaterestriction.php"; echo "<script type='text/javascript' >\n"; echo "function activateRestriction() {\n"; $params = array('enabled' => 1); Ajax::updateItemJsCode('date_restriction', $url, $params); echo "};"; echo "function deactivateRestriction() {\n"; $params = array('enabled' => 0); Ajax::updateItemJsCode('date_restriction', $url, $params); echo "};"; echo "</script>"; echo "</table>"; echo "<span id='date_restriction'>"; $_POST['enabled'] = $enabled; include GLPI_ROOT . "/ajax/ldapdaterestriction.php"; echo "</span>\n"; return $rand; }
/** * Make a select box for Tracking All Devices * * @param $myname select name * @param $itemtype preselected value.for item type * @param $items_id preselected value for item ID (default 0) * @param $admin is an admin access ? (default 0) * @param $users_id user ID used to display my devices (default 0 * @param $entity_restrict Restrict to a defined entity (default -1) * @param $options array of possible options: * - tickets_id : ID of the ticket * - used : ID of the requester user * - multiple : allow multiple choice * - rand : random number * * @return nothing (print out an HTML select box) **/ static function dropdownAllDevices($myname, $itemtype, $items_id = 0, $admin = 0, $users_id = 0, $entity_restrict = -1, $options = array()) { global $CFG_GLPI, $DB; $params = array('tickets_id' => 0, 'used' => array(), 'multiple' => 0, 'rand' => mt_rand()); foreach ($options as $key => $val) { $params[$key] = $val; } $rand = $params['rand']; if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] == 0) { echo "<input type='hidden' name='{$myname}' value=''>"; echo "<input type='hidden' name='items_id' value='0'>"; } else { echo "<div id='tracking_all_devices{$rand}'>"; if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, Ticket::HELPDESK_ALL_HARDWARE)) { // Display a message if view my hardware if ($users_id && $_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, Ticket::HELPDESK_MY_HARDWARE)) { echo __('Or complete search') . " "; } $types = Ticket::getAllTypesForHelpdesk(); $emptylabel = __('General'); if ($params['tickets_id'] > 0) { $emptylabel = Dropdown::EMPTY_VALUE; } Dropdown::showItemTypes($myname, array_keys($types), array('emptylabel' => $emptylabel, 'value' => $itemtype, 'rand' => $rand, 'display_emptychoice' => true)); $found_type = isset($types[$itemtype]); $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $entity_restrict, 'admin' => $admin, 'used' => $params['used'], 'multiple' => $params['multiple'], 'rand' => $rand, 'myname' => "add_items_id"); Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "results_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownTrackingDeviceType.php", $p); echo "<span id='results_{$myname}{$rand}'>\n"; // Display default value if itemtype is displayed if ($found_type && $itemtype) { if (($item = getItemForItemtype($itemtype)) && $items_id) { if ($item->getFromDB($items_id)) { Dropdown::showFromArray('items_id', array($items_id => $item->getName()), array('value' => $items_id)); } } else { $p['itemtype'] = $itemtype; echo "<script type='text/javascript' >\n"; Ajax::updateItemJsCode("results_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownTrackingDeviceType.php", $p); echo '</script>'; } } echo "</span>\n"; } echo "</div>"; } return $rand; }
/** * Print the reminder form * * @param $ID integer Id of the item to print * @param $options array of possible options: * - target filename : where to go when done. * - from_planning_ajax : set to disable planning form part **/ function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); $rand = mt_rand(); // Show Reminder or blank form $onfocus = ""; if (!$ID > 0) { // Create item : do getempty before check right to set default values $onfocus = "onfocus=\"if (this.value=='" . $this->fields['name'] . "') this.value='';\""; } $canedit = $this->can($ID, UPDATE); $this->showFormHeader($options); echo "<tr class='tab_bg_2'><td>" . __('Title') . "</td>"; echo "<td>"; if (!$ID) { echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n"; } if ($canedit) { Html::autocompletionTextField($this, "name", array('size' => '80', 'entity' => -1, 'user' => $this->fields["users_id"], 'option' => $onfocus)); } else { echo $this->fields['name']; } if (isset($options['from_planning_edit_ajax']) && $options['from_planning_edit_ajax']) { echo Html::hidden('from_planning_edit_ajax'); } echo "</td>"; echo "</tr>"; if (!isset($options['from_planning_ajax'])) { echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Visibility') . "</td>"; echo "<td>"; echo '<table><tr><td>'; echo __('Begin') . '</td><td>'; Html::showDateTimeField("begin_view_date", array('value' => $this->fields["begin_view_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo '</td><td>' . __('End') . '</td><td>'; Html::showDateTimeField("end_view_date", array('value' => $this->fields["end_view_date"], 'timestep' => 1, 'maybeempty' => true, 'canedit' => $canedit)); echo '</td></tr></table>'; echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Status') . "</td>"; echo "<td>"; if ($canedit) { Planning::dropdownState("state", $this->fields["state"]); } else { echo Planning::getState($this->fields["state"]); } echo "</td>\n"; echo "</tr>\n"; echo "<tr class='tab_bg_2'><td >" . __('Calendar') . "</td>"; echo "<td>"; if (isset($options['from_planning_ajax']) && $options['from_planning_ajax']) { echo Html::hidden('plan[begin]', array('value' => $options['begin'])); echo Html::hidden('plan[end]', array('value' => $options['end'])); printf(__('From %1$s to %2$s'), Html::convDateTime($options["begin"]), Html::convDateTime($options["end"])); echo "</td>"; } else { if ($canedit) { echo "<script type='text/javascript' >\n"; echo "function showPlan{$rand}() {\n"; echo Html::jsHide("plan{$rand}"); $params = array('action' => 'add_event_classic_form', 'form' => 'remind', 'users_id' => $this->fields["users_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); if ($ID && $this->fields["is_planned"]) { $params['begin'] = $this->fields["begin"]; $params['end'] = $this->fields["end"]; } Ajax::updateItemJsCode("viewplan{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; } if (!$ID || !$this->fields["is_planned"]) { if (Session::haveRightsOr("planning", array(Planning::READMY, Planning::READGROUP, Planning::READALL))) { echo "<div id='plan{$rand}' onClick='showPlan{$rand}()'>\n"; echo "<a href='#' class='vsubmit'>" . __('Add to schedule') . "</a>"; } } else { if ($canedit) { echo "<div id='plan{$rand}' onClick='showPlan{$rand}()'>\n"; echo "<span class='showplan'>"; } //TRANS: %1$s is the begin date, %2$s is the end date printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if ($canedit) { echo "</span>"; } } if ($canedit) { echo "</div>\n"; echo "<div id='viewplan{$rand}'>\n</div>\n"; } echo "</td>"; if ($ID && $this->fields["is_planned"] && PlanningRecall::isAvailable()) { echo "<td>" . _x('Planning', 'Reminder') . "</td>"; echo "<td>"; if ($canedit) { PlanningRecall::dropdown(array('itemtype' => 'Reminder', 'items_id' => $ID)); } else { // No edit right : use specific Planning Recall Form PlanningRecall::specificForm(array('itemtype' => 'Reminder', 'items_id' => $ID)); } echo "</td>"; } else { echo "<td colspan='2'></td>"; } } echo "</tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Description') . "</td>" . "<td colspan='3'>"; if ($canedit) { $rand = mt_rand(); echo "<textarea rows='15' name='text' id='text{$rand}'>" . $this->fields["text"] . "</textarea>"; Html::initEditorSystem('text' . $rand); } else { echo "<div id='kbanswer'>"; echo Toolbox::unclean_html_cross_side_scripting_deep($this->fields["text"]); echo "</div>"; } echo "</td></tr>\n"; $this->showFormButtons($options); return true; }
public function showOrderReception($orders_id) { global $DB, $CFG_GLPI; $order_order = new PluginOrderOrder(); $order_item = new PluginOrderOrder_Item(); $reference = new PluginOrderReference(); $order_order->getFromDB($orders_id); Session::initNavigateListItems($this->getType(), __("Order", "order") . " = " . $order_order->fields["name"]); $canedit = self::canCreate() && !$order_order->canUpdateOrder() && !$order_order->isCanceled(); $result_ref = $order_item->queryDetail($orders_id); $numref = $DB->numrows($result_ref); while ($data_ref = $DB->fetch_array($result_ref)) { echo "<div class='center'><table class='tab_cadre_fixe'>"; if (!$numref) { echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>"; } else { $references_id = $data_ref["id"]; $typeRef = $data_ref["itemtype"]; $price_taxfree = $data_ref["price_taxfree"]; $discount = $data_ref["discount"]; $item = new $typeRef(); $rand = mt_rand(); echo "<tr><th><ul><li>"; echo "<a href=\"javascript:showHideDiv('reception{$rand}','reception_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">"; echo "<img alt='' name='reception_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">"; echo "</a>"; echo "</li></ul></th>"; echo "<th>" . __("Type") . "</th>"; echo "<th>" . __("Manufacturer") . "</th>"; echo "<th>" . __("Product reference", "order") . "</th>"; echo "<th>" . __("Delivered items", "order") . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1 center'>"; echo "<td></td>"; echo "<td align='center'>" . $item->getTypeName() . "</td>"; echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>"; echo "<td>" . $reference->getReceptionReferenceLink($data_ref) . "</td>"; $total = $order_item->getTotalQuantityByRefAndDiscount($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]); echo "<td>" . $order_item->getDeliveredQuantity($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]) . " / " . $total . "</td>"; echo "</tr></table>"; echo "<div class='center' id='reception{$rand}' style='display:none'>"; echo "<form method='post' name='order_reception_form{$rand}' id='order_reception_form{$rand}'" . " action=\"" . Toolbox::getItemTypeFormURL("PluginOrderReception") . "\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='15'></th>"; if ($typeRef != 'SoftwareLicense') { echo "<th>" . __("ID") . "</th>"; } echo "<th>" . __("Reference") . "</th>"; echo "<th>" . __("Status") . "</th>"; echo "<th>" . __("Delivery date") . "</th>"; echo "<th>" . __("Delivery form") . "</th>"; echo "<th>" . __("Delivery status", "order") . "</th>"; echo "</tr>"; $query = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD,\n `glpi_plugin_order_references`.`id` AS id,\n `glpi_plugin_order_references`.`templates_id`,\n `glpi_plugin_order_orders_items`.`states_id`,\n `glpi_plugin_order_orders_items`.`comment`,\n `glpi_plugin_order_orders_items`.`plugin_order_deliverystates_id`,\n `glpi_plugin_order_orders_items`.`delivery_date`,\n `glpi_plugin_order_orders_items`.`delivery_number`,\n `glpi_plugin_order_references`.`name`,\n `glpi_plugin_order_references`.`itemtype`,\n `glpi_plugin_order_orders_items`.`items_id`\n FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references`\n WHERE `plugin_order_orders_id` = '{$orders_id}'\n AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = '" . $references_id . "'\n AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n AND `glpi_plugin_order_orders_items`.`discount` LIKE '" . $discount . "'\n AND `glpi_plugin_order_orders_items`.`price_taxfree` LIKE '" . $price_taxfree . "' "; if ($typeRef == 'SoftwareLicense') { $query .= " GROUP BY `glpi_plugin_order_references`.`name` "; } $query .= " ORDER BY `glpi_plugin_order_references`.`name` "; $result = $DB->query($query); $num = $DB->numrows($result); while ($data = $DB->fetch_array($result)) { $random = mt_rand(); $detailID = $data["IDD"]; Session::addToNavigateListItems($this->getType(), $detailID); echo "<tr class='tab_bg_2'>"; $status = 1; if ($typeRef != 'SoftwareLicense') { $status = $this->checkThisItemStatus($detailID, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED); } if ($order_order->canDeliver() && $status) { echo "<td width='15' align='left'>"; $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<input type='checkbox' name='item[" . $detailID . "]' value='1' {$sel}>"; echo "</td>"; } else { echo "<td width='15' align='left'></td>"; } if ($typeRef != 'SoftwareLicense') { echo "<td align='center'>" . $data["IDD"] . " "; Html::showTooltip($data['comment']); echo "</td>"; } echo "<td align='center'>" . $reference->getReceptionReferenceLink($data) . "</td>"; echo "<td align='center'>"; $link = Toolbox::getItemTypeFormURL($this->getType()); if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) { echo "<a href=\"" . $link . "?id=" . $data["IDD"] . "\">"; } echo $this->getReceptionStatus($detailID); if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) { echo "</a>"; } echo "</td>"; echo "<td align='center'>" . Html::convDate($data["delivery_date"]) . "</td>"; echo "<td align='center'>" . $data["delivery_number"] . "</td>"; echo "<td align='center'>" . Dropdown::getDropdownName("glpi_plugin_order_deliverystates", $data["plugin_order_deliverystates_id"]) . "</td>"; echo "<input type='hidden' name='id[{$detailID}]' value='{$detailID}'>"; echo "<input type='hidden' name='name[{$detailID}]' value='" . $data["name"] . "'>"; echo "<input type='hidden' name='plugin_order_references_id[{$detailID}]' value='" . $data["id"] . "'>"; echo "<input type='hidden' name='itemtype[{$detailID}]' value='" . $data["itemtype"] . "'>"; echo "<input type='hidden' name='templates_id[{$detailID}]' value='" . $data["templates_id"] . "'>"; echo "<input type='hidden' name='states_id[{$detailID}]' value='" . $data["states_id"] . "'>"; } echo "</table>"; if ($order_order->canDeliver() && $this->checkItemStatus($orders_id, $references_id, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED)) { Html::openArrowMassives("order_reception_form{$rand}", true); echo "<input type='hidden' name='plugin_order_orders_id' value='{$orders_id}'>"; $this->dropdownReceptionActions($typeRef, $references_id, $orders_id); Html::closeArrowMassives(array()); $rand = mt_rand(); if ($typeRef != 'SoftwareLicense') { echo "<div id='massreception" . $orders_id . $rand . "'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewmassreception" . $orders_id . "{$rand}(){\n"; $params = array('plugin_order_orders_id' => $orders_id, 'plugin_order_references_id' => $references_id); Ajax::updateItemJsCode("massreception" . $orders_id . $rand, $CFG_GLPI["root_doc"] . "/plugins/order/ajax/massreception.php", $params, false); echo "};"; echo "</script>\n"; echo "<p><a href='javascript:viewmassreception" . $orders_id . "{$rand}();'>"; echo __("Take item delivery (bulk)", "order") . "</a></p><br>\n"; } } Html::closeForm(); echo "</div>"; } echo "<br>"; } }
/** * @param $ID * @param $options array **/ function showForm($ID, $options = array()) { global $CFG_GLPI, $DB; if (!static::canView()) { return false; } // In percent $colsize1 = '13'; $colsize2 = '37'; // Set default options if (!$ID) { $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'name' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'itilcategories_id' => 0); foreach ($values as $key => $val) { if (!isset($options[$key])) { $options[$key] = $val; } } if (isset($options['tickets_id'])) { $ticket = new Ticket(); if ($ticket->getFromDB($options['tickets_id'])) { $options['content'] = $ticket->getField('content'); $options['name'] = $ticket->getField('name'); $options['impact'] = $ticket->getField('impact'); $options['urgency'] = $ticket->getField('urgency'); $options['priority'] = $ticket->getField('priority'); $options['itilcategories_id'] = $ticket->getField('itilcategories_id'); } } } $this->initForm($ID, $options); $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>"; echo "<td class='left' width='{$colsize2}%'>"; if (isset($options['tickets_id'])) { echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>"; } $date = $this->fields["date"]; if (!$ID) { $date = date("Y-m-d H:i:s"); } Html::showDateTimeFormItem("date", $date, 1, false); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>"; echo "<td width='{$colsize2}%' class='left'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true); echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>"; User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); echo "</td>"; echo "<th>" . __('Last update') . "</th>"; echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n"; if ($this->fields['users_id_lastupdater'] > 0) { printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td></tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Date of solving') . "</th>"; echo "<td>"; Html::showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th>" . __('Closing date') . "</th>"; echo "<td>"; Html::showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Status') . "</th>"; echo "<td width='{$colsize2}%'>"; self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>"; echo "<td width='{$colsize2}%'>"; // Only change during creation OR when allowed to change priority OR when user is the creator $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Category') . "</th>"; echo "<td >"; $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_problem`='1'"); ITILCategory::dropdown($opt); echo "</td>"; echo "<th>" . __('Impact') . "</th>"; echo "<td>"; $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Total duration') . "</th>"; echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>"; echo "<th class='left'>" . __('Priority') . "</th>"; echo "<td>"; $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idajax = 'change_priority_' . mt_rand(); echo " <span id='{$idajax}' style='display:none'></span>"; $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); echo "</td>"; echo "</tr>"; echo "</table>"; $this->showActorsPartForm($ID, $options); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Title') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showName{$rand}() {\n"; echo "Ext.get('name{$rand}').setDisplayed('none');"; $params = array('maxlength' => 250, 'size' => 110, 'name' => 'name', 'data' => rawurlencode($this->fields["name"])); Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params); echo "}"; echo "</script>\n"; echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n"; if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->fields["name"]; } echo "</div>\n"; echo "<div id='viewname{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showName{$rand}();\n </script>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Description') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showDesc{$rand}() {\n"; echo "Ext.get('desc{$rand}').setDisplayed('none');"; $params = array('rows' => 6, 'cols' => 110, 'name' => 'content', 'data' => rawurlencode($this->fields["content"])); Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params); echo "}"; echo "</script>\n"; echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n"; if (!empty($this->fields["content"])) { echo nl2br($this->fields["content"]); } else { _e('Empty description'); } echo "</div>\n"; echo "<div id='viewdesc{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>"; } echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th colspan='2' width='" . ($colsize1 + $colsize2) . "%'>"; $docnb = Document_Item::countForItem($this); echo "<a href=\"" . $this->getLinkURL() . "&forcetab=Document_Item\$1\">"; //TRANS: %d is the document number echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb); echo "</a></th>"; echo "<td colspan='2'></td>"; echo "</tr>"; } $options['colspan'] = 2; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
/** * Show installed cartridges * * @since version 0.84 (before showInstalled) * * @param $printer Printer object * @param $old boolean old cartridges or not ? (default 0) * * @return nothing (display) **/ static function showForPrinter(Printer $printer, $old = 0) { global $DB, $CFG_GLPI; $instID = $printer->getField('id'); if (!self::canView()) { return false; } $canedit = Session::haveRight("cartridge", UPDATE); $rand = mt_rand(); $query = "SELECT `glpi_cartridgeitems`.`id` AS tID,\n `glpi_cartridgeitems`.`is_deleted`,\n `glpi_cartridgeitems`.`ref` AS ref,\n `glpi_cartridgeitems`.`name` AS type,\n `glpi_cartridges`.`id`,\n `glpi_cartridges`.`pages` AS pages,\n `glpi_cartridges`.`date_use` AS date_use,\n `glpi_cartridges`.`date_out` AS date_out,\n `glpi_cartridges`.`date_in` AS date_in,\n `glpi_cartridgeitemtypes`.`name` AS typename\n FROM `glpi_cartridges`,\n `glpi_cartridgeitems`\n LEFT JOIN `glpi_cartridgeitemtypes`\n on (`glpi_cartridgeitems`.`cartridgeitemtypes_id` = `glpi_cartridgeitemtypes`.`id`)\n WHERE (`glpi_cartridges`.`date_out` IS " . ($old ? "NOT" : "") . " NULL\n AND `glpi_cartridges`.`printers_id` = '{$instID}'\n AND `glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`)\n ORDER BY `glpi_cartridges`.`date_out` ASC,\n `glpi_cartridges`.`date_use` DESC,\n `glpi_cartridges`.`date_in`"; $result = $DB->query($query); $number = $DB->numrows($result); $i = 0; if ($canedit && !$old) { echo "<div class='firstbloc'>"; echo "<form method='post' action=\"" . static::getFormURL() . "\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><td class='center tab_bg_2' width='50%'>"; echo "<input type='hidden' name='printers_id' value='{$instID}'>\n"; $installok = false; $cpt = ''; if (CartridgeItem::dropdownForPrinter($printer)) { //TRANS : multiplier echo "</td><td>" . __('x') . " "; Dropdown::showNumber("nbcart", array('value' => 1, 'min' => 1, 'max' => 5)); $installok = true; echo "</td><td><input type='submit' name='install' value=\"" . _sx('button', 'Install') . "\"\n " . ($installok ? '' : 'disabled') . " class='submit'>"; } else { _e('No cartridge available'); } echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div id='viewcartridge{$rand}'></div>"; $pages = $printer->fields['init_pages_counter']; echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); if (!$old) { $actions = array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'uninstall' => __('End of life'), __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'backtostock' => __('Back to stock')); } else { $actions = array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'updatepages' => __('Update printer counter'), 'purge' => _x('button', 'Delete permanently')); } $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => $actions, 'container' => 'mass' . __CLASS__ . $rand, 'rand' => $rand, 'extraparams' => array('maxpages' => $printer->fields['last_pages_counter'])); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr class='noHover'>"; if ($old == 0) { echo "<th colspan='" . ($canedit ? '6' : '5') . "'>" . __('Used cartridges') . "</th>"; } else { echo "<th colspan='" . ($canedit ? '9' : '8') . "'>" . __('Worn cartridges') . "</th>"; } echo "</tr>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . __('ID') . "</th><th>" . _n('Cartridge model', 'Cartridge models', 1) . "</th>"; $header_end .= "<th>" . _n('Cartridge type', 'Cartridge types', 1) . "</th>"; $header_end .= "<th>" . __('Add date') . "</th>"; $header_end .= "<th>" . __('Use date') . "</th>"; if ($old != 0) { $header_end .= "<th>" . __('End date') . "</th>"; $header_end .= "<th>" . __('Printer counter') . "</th>"; $header_end .= "<th>" . __('Printed pages') . "</th>"; } $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; $stock_time = 0; $use_time = 0; $pages_printed = 0; $nb_pages_printed = 0; while ($data = $DB->fetch_assoc($result)) { $cart_id = $data["id"]; $typename = $data["typename"]; $date_in = Html::convDate($data["date_in"]); $date_use = Html::convDate($data["date_use"]); $date_out = Html::convDate($data["date_out"]); $viewitemjs = $canedit ? "style='cursor:pointer' onClick=\"viewEditCartridge" . $data['id'] . "{$rand}();\"" : ''; echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center' {$viewitemjs}>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditCartridge" . $data["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Printer', 'printers_id' => $printer->fields["id"], 'id' => $data["id"]); Ajax::updateItemJsCode("viewcartridge{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo $data["id"] . "</td>"; echo "<td class='center' {$viewitemjs}>"; echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/cartridgeitem.form.php?id=" . $data["tID"] . "\">"; printf(__('%1$s - %2$s'), $data["type"], $data["ref"]); echo "</a></td>"; echo "<td class='center' {$viewitemjs}>" . $typename . "</td>"; echo "<td class='center' {$viewitemjs}>" . $date_in . "</td>"; echo "<td class='center' {$viewitemjs}>" . $date_use . "</td>"; $tmp_dbeg = explode("-", $data["date_in"]); $tmp_dend = explode("-", $data["date_use"]); $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]); $stock_time += $stock_time_tmp; if ($old != 0) { echo "<td class='center' {$viewitemjs}>" . $date_out; $tmp_dbeg = explode("-", $data["date_use"]); $tmp_dend = explode("-", $data["date_out"]); $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]); $use_time += $use_time_tmp; echo "</td><td class='numeric' {$viewitemjs}>" . $data['pages'] . "</td>"; echo "<td class='numeric' {$viewitemjs}>"; if ($pages < $data['pages']) { $pages_printed += $data['pages'] - $pages; $nb_pages_printed++; $pp = $data['pages'] - $pages; echo $pp; $pages = $data['pages']; } else { echo " "; } echo "</td>"; } echo "</tr>"; } if ($old) { // Print average if ($number > 0) { if ($nb_pages_printed == 0) { $nb_pages_printed = 1; } echo "<tr class='tab_bg_2'><td colspan='" . ($canedit ? "4" : '3') . "'> </td>"; echo "<td class='center b'>" . __('Average time in stock') . "<br>"; $time_stock = round($stock_time / $number / 60 / 60 / 24 / 30.5, 1); echo sprintf(_n('%d month', '%d months', $time_stock), $time_stock) . "</td>"; echo "<td class='center b'>" . __('Average time in use') . "<br>"; $time_use = round($use_time / $number / 60 / 60 / 24 / 30.5, 1); echo sprintf(_n('%d month', '%d months', $time_use), $time_use) . "</td>"; echo "<td class='center b' colspan='2'>" . __('Average number of printed pages') . "<br>"; echo round($pages_printed / $nb_pages_printed) . "</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>\n\n"; }
static function updateItemOnEventJsCode($toobserve, $toupdate, $url, $parameters = array(), $events = array("change"), $minsize = -1, $forceloadfor = array()) { if (is_array($toobserve)) { $zones = $toobserve; } else { $zones = array($toobserve); } foreach ($zones as $zone) { foreach ($events as $event) { echo "\n Ext.get('{$zone}').on(\n '{$event}',\n function() {"; $condition = ''; if ($minsize >= 0) { $condition = " Ext.get('{$zone}').getValue().length >= {$minsize} "; } if (count($forceloadfor)) { foreach ($forceloadfor as $value) { if (!empty($condition)) { $condition .= " || "; } $condition .= "Ext.get('{$zone}').getValue() == '{$value}'"; } } if (!empty($condition)) { echo "if ({$condition}) {"; } Ajax::updateItemJsCode($toupdate, $url, $parameters, $zone); if (!empty($condition)) { echo "}"; } echo "});\n"; } } }
/** * Print the HTML array for SLTs linked to a SLA * * @param SLA $sla * @return boolean */ static function showForSla(SLA $sla) { global $CFG_GLPI; $instID = $sla->fields['id']; $slt = new self(); $calendar = new Calendar(); if (!$sla->can($instID, READ)) { return false; } $canedit = $sla->canEdit($instID) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central"; $rand = mt_rand(); if ($canedit) { echo "<div id='viewslt{$instID}{$rand}'></div>\n"; echo "<script type='text/javascript' >"; echo "function viewAddSlt{$instID}{$rand}() {"; $params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => -1); Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "}"; echo "</script>"; echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddSlt{$instID}{$rand}();'>"; echo __('Add a new SLT') . "</a></div>\n"; } // SLT list $sltList = $slt->find("`slas_id` = '" . $instID . "'"); Session::initNavigateListItems('SLT', sprintf(__('%1$s = %2$s'), $sla::getTypeName(1), $sla->getName())); echo "<div class='spaced'>"; if (count($sltList)) { if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_top .= "</th>"; $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= "</th>"; } $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __('Type') . "</th>"; $header_end .= "<th>" . __('Maximum time') . "</th>"; $header_end .= "<th>" . __('Calendar') . "</th>"; echo $header_begin . $header_top . $header_end; foreach ($sltList as $val) { $edit = $canedit ? "style='cursor:pointer' onClick=\"viewEditSlt" . $instID . $val["id"] . "{$rand}();\"" : ''; echo "\n<script type='text/javascript' >\n"; echo "function viewEditSlt" . $instID . $val["id"] . "{$rand}() {\n"; $params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => $val["id"]); Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo "<tr class='tab_bg_1'>"; echo "<td width='10' {$edit}>"; if ($canedit) { Html::showMassiveActionCheckBox($slt->getType(), $val['id']); } echo "</td>"; $slt->getFromDB($val['id']); echo "<td {$edit}>" . $slt->getLink() . "</td>"; echo "<td {$edit}>" . $slt->getSpecificValueToDisplay('type', $slt->fields['type']) . "</td>"; echo "<td {$edit}>"; echo $slt->getSpecificValueToDisplay('number_time', array('number_time' => $slt->fields['number_time'], 'definition_time' => $slt->fields['definition_time'])); echo "</td>"; if (!$sla->fields['calendars_id']) { $link = __('24/7'); } else { if ($sla->fields['calendars_id'] == -1) { $link = __('Calendar of the ticket'); } else { if ($calendar->getFromDB($sla->fields['calendars_id'])) { $link = $calendar->getLink(); } } } echo "<td {$edit}>" . $link . "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } else { echo __('No item to display'); } echo "</div>"; }
/** form for rule action * * @since version 0.85 * * @param $ID integer : Id of the action * @param $options array of possible options: * - rule Object : the rule **/ function showForm($ID, $options = array()) { global $CFG_GLPI; // Yllen: you always have parent for action $rule = $options['parent']; if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[static::$items_id] = $rule->getField('id'); //force itemtype of parent static::$itemtype = get_class($rule); $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1 center'>"; echo "<td>" . _n('Action', 'Actions', 1) . "</td><td colspan='3'>"; echo "<input type='hidden' name='" . $rule->getRuleIdField() . "' value='" . $this->fields[static::$items_id] . "'>"; $used = $this->getAlreadyUsedForRuleID($this->fields[static::$items_id], $rule->getType()); // On edit : unset selected value if ($ID && isset($used[$this->fields['field']])) { unset($used[$this->fields['field']]); } $rand = $rule->dropdownActions(array('value' => $this->fields['field'], 'used' => $used)); $params = array('field' => '__VALUE__', 'sub_type' => $rule->getType(), 'ruleactions_id' => $this->getID(), $rule->getRuleIdField() => $this->fields[static::$items_id]); Ajax::updateItemOnSelectEvent("dropdown_field{$rand}", "action_span", $CFG_GLPI["root_doc"] . "/ajax/ruleaction.php", $params); if (isset($this->fields['field']) && !empty($this->fields['field'])) { $params['field'] = $this->fields['field']; $params['action_type'] = $this->fields['action_type']; $params['value'] = $this->fields['value']; echo "<script type='text/javascript' >\n"; Ajax::updateItemJsCode("action_span", $CFG_GLPI["root_doc"] . "/ajax/ruleaction.php", $params); echo '</script>'; } echo "</td></tr>"; echo "<tr><td colspan='4'><span id='action_span'>\n"; echo "</span></td>\n"; echo "</tr>\n"; $this->showFormButtons($options); }
/** * Show the minimal form for the criteria rule * * @param $fields datas used to display the criteria * @param $canedit can edit the criterias rule ? * @param $rand random value of the form **/ function showMinimalCriteriaForm($fields, $canedit, $rand) { global $CFG_GLPI; $edit = $canedit ? "style='cursor:pointer' onClick=\"viewEditCriteria" . $fields[$this->rules_id_field] . $fields["id"] . "{$rand}();\"" : ''; echo "<tr class='tab_bg_1' >"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox($this->rulecriteriaclass, $fields["id"]); echo "\n<script type='text/javascript' >\n"; echo "function viewEditCriteria" . $fields[$this->rules_id_field] . $fields["id"] . "{$rand}() {\n"; $params = array('type' => 'RuleCriteria', 'parenttype' => $this->getType(), $this->rules_id_field => $fields[$this->rules_id_field], 'id' => $fields["id"]); Ajax::updateItemJsCode("viewcriteria" . $fields[$this->rules_id_field] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo "</td>"; } echo $this->getMinimalCriteriaText($fields, $edit); echo "</tr>\n"; }
public function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showFormHeader($options); echo '<table class="tab_cadre_fixe">'; echo "<tr class='line0 tab_bg_2'><td><label for='name'>" . __('Name') . " <span class='red'>*</span></label></td>"; echo "<td>"; echo '<input type="text" id="name" name="name" value="' . $this->fields['name'] . '" size="40" required>'; echo "</td>"; echo "</tr>"; echo "<tr class='line1 tab_bg_2'><td><label for='comment'>" . __('Description') . "</label></td>"; echo "<td>"; echo "<textarea name='comment' id ='comment' cols='45' rows='2'>" . $this->fields['comment'] . "</textarea>"; echo "</td>"; echo "</tr>"; echo "<tr class='line1 tab_bg_2'><td><label>" . __('HTML color', 'tag') . "</label></td>"; echo "<td>"; //Note : create some bugs Html::showColorField('color', array('value' => $this->fields['color'])); echo "</td>"; echo "</tr>"; echo "<tr class='line0 tab_bg_2'>"; echo "<td colspan='2'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='line1 tab_bg_2'>"; echo "<th>" . _n('Associated item type', 'Associated item types', 2) . "</th>"; echo "</tr>"; echo "<tr class='line1 tab_bg_2'>"; echo "<td class='center'>"; echo _n('Tag type', 'Tag types', 1, 'tag') . " "; $values = array(0 => Dropdown::EMPTY_VALUE); $menus = Html::getMenuInfos(); foreach ($menus as $key => $value) { if ($key != 'plugins' && $key != 'preference') { $values[$key] = $menus[$key]['title']; } } $rand = Dropdown::showFromArray("type_menu", $values, array('value' => $this->fields['type_menu'], 'width' => '50%', 'on_change' => 'pluginTagSubType();')); echo "<div id='plugin_tag_itemtype'></div><br>"; $JS = 'function pluginTagSubType(){'; $JS .= Ajax::updateItemJsCode('plugin_tag_itemtype', $CFG_GLPI['root_doc'] . "/plugins/tag/ajax/tag.php", array('action' => 'add_subtypes', 'type_menu' => '__VALUE__', 'rand' => $rand), "dropdown_type_menu{$rand}", false); $JS .= '}'; $JS .= 'pluginTagSubType();'; echo Html::scriptBlock($JS); // Sub type choice $itemtypes = array(); $selected = array(); if (!empty($this->fields['type_menu'])) { foreach (json_decode($this->fields['type_menu'], true) as $itemtype) { $item = getItemForItemtype($itemtype); $itemtypes[$itemtype] = $item->getTypeName(); $selected[] = $itemtype; } } Dropdown::showFromArray("subtypes", $itemtypes, array('values' => $selected, 'multiple' => true, 'rand' => $rand, 'width' => '100%')); echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
/** * Display all translated field for a dropdown * * @param $item a Dropdown item * * @return true; **/ static function showTranslations(CommonDropdown $item) { global $DB, $CFG_GLPI; $rand = mt_rand(); $canedit = $item->can($item->getID(), UPDATE); if ($canedit) { echo "<div id='viewtranslation" . $item->getType() . $item->getID() . "{$rand}'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function addTranslation" . $item->getType() . $item->getID() . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => get_class($item), $item->getForeignKeyField() => $item->getID(), 'id' => -1); Ajax::updateItemJsCode("viewtranslation" . $item->getType() . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; echo "<div class='center'>" . "<a class='vsubmit' href='javascript:addTranslation" . $item->getType() . $item->getID() . "{$rand}();'>" . __('Add a new translation') . "</a></div><br>"; } $query = "SELECT *\n FROM `" . getTableForItemType(__CLASS__) . "`\n WHERE `itemtype` = '" . get_class($item) . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `field` <> 'completename'\n ORDER BY `language` ASC"; $results = $DB->query($query); if ($DB->numrows($results)) { if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<div class='center'>"; echo "<table class='tab_cadre_fixehov'><tr class='tab_bg_2'>"; echo "<th colspan='4'>" . __("List of translations") . "</th></tr><tr>"; if ($canedit) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __("Language") . "</th>"; echo "<th>" . __("Field") . "</th>"; echo "<th>" . __("Value") . "</th></tr>"; while ($data = $DB->fetch_array($results)) { $onhover = ''; if ($canedit) { $onhover = "style='cursor:pointer'\n onClick=\"viewEditTranslation" . $data['itemtype'] . $data['id'] . "{$rand}();\""; } echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td class='center'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td {$onhover}>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditTranslation" . $data['itemtype'] . $data['id'] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => get_class($item), $item->getForeignKeyField() => $item->getID(), 'id' => $data["id"]); Ajax::updateItemJsCode("viewtranslation" . $item->getType() . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo Dropdown::getLanguageName($data['language']); echo "</td><td {$onhover}>"; $searchOption = $item->getSearchOptionByField('field', $data['field']); echo $searchOption['name'] . "</td>"; echo "<td {$onhover}>" . $data['value'] . "</td>"; echo "</tr>"; } echo "</table>"; if ($canedit) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } } else { echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>"; echo "<th class='b'>" . __("No translation found") . "</th></tr></table>"; } return true; }
/** * Print the validation list into ticket * * @param $ticket class **/ function showSummary($ticket) { global $DB, $CFG_GLPI; if (!Session::haveRight('validate_request', 1) && !Session::haveRight('validate_incident', 1) && !Session::haveRight('create_incident_validation', 1) && !Session::haveRight('create_request_validation', 1)) { return false; } $tID = $ticket->fields['id']; $tmp = array('tickets_id' => $tID); $canadd = $this->can(-1, 'w', $tmp); $rand = mt_rand(); echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n"; if ($canadd) { echo "<script type='text/javascript' >\n"; echo "function viewAddValidation" . $tID . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $tID, 'id' => -1); Ajax::updateItemJsCode("viewfollowup" . $tID . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; if ($ticket->fields["status"] != CommonITILObject::SOLVED && $ticket->fields["status"] != CommonITILObject::CLOSED) { echo "<div class='center'>"; echo "<a class='vsubmit' href='javascript:viewAddValidation" . $tID . "{$rand}();'>"; echo __('Send an approval request') . "</a></div><br>\n"; } } $query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `tickets_id` = '" . $ticket->getField('id') . "'"; if (!$canadd) { $query .= " AND `users_id_validate` = '" . Session::getLoginUserID() . "' "; } $query .= " ORDER BY submission_date DESC"; $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { $colonnes = array(__('State'), sprintf(__('%1$s: %2$s'), __('Request'), __('Date')), __('Approval requester'), sprintf(__('%1$s: %2$s'), __('Request'), __('Comments')), __('Approval date'), __('Approver'), sprintf(__('%1$s: %2$s'), __('Approval'), __('Comments'))); $nb_colonnes = count($colonnes); echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='" . $nb_colonnes . "'>" . __('Approvals for the ticket') . "</th></tr>"; echo "<tr>"; foreach ($colonnes as $colonne) { echo "<th>" . $colonne . "</th>"; } echo "</tr>"; Session::initNavigateListItems('TicketValidation', sprintf(__('%1$s = %2$s'), $ticket->getTypeName(1), $ticket->fields["name"])); while ($row = $DB->fetch_assoc($result)) { $canedit = $this->can($row["id"], 'w'); Session::addToNavigateListItems('TicketValidation', $row["id"]); $bgcolor = $this->getStatusColor($row['status']); $status = $this->getStatus($row['status']); echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditValidation" . $ticket->fields['id'] . $row["id"] . "{$rand}();\"" : '') . " id='viewfollowup" . $this->fields['tickets_id'] . $row["id"] . "{$rand}'>"; echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditValidation" . $ticket->fields['id'] . $row["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $this->fields["tickets_id"], 'id' => $row["id"]); Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo "<div style='background-color:" . $bgcolor . ";'>" . $status . "</div></td>"; echo "<td>" . Html::convDateTime($row["submission_date"]) . "</td>"; echo "<td>" . getUserName($row["users_id"]) . "</td>"; echo "<td>" . $row["comment_submission"] . "</td>"; echo "<td>" . Html::convDateTime($row["validation_date"]) . "</td>"; echo "<td>" . getUserName($row["users_id_validate"]) . "</td>"; echo "<td>" . $row["comment_validation"] . "</td>"; echo "</tr>"; } echo "</table>"; } else { echo "<div class='center b'>" . __('No item found') . "</div>"; } }
/** form for rule criteria * * @since version 0.85 * * @param $ID integer Id of the criteria * @param $options array of possible options: * - rule Object : the rule **/ function showForm($ID, $options = array()) { global $CFG_GLPI; // Yllen: you always have parent for criteria $rule = $options['parent']; if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[static::$items_id] = $rule->getField('id'); //force itemtype of parent static::$itemtype = get_class($rule); $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . _n('Criterion', 'Criteria', 1) . "</td><td colspan='3'>"; echo "<input type='hidden' name='" . $rule->getRuleIdField() . "' value='" . $this->fields[$rule->getRuleIdField()] . "'>"; $rand = $rule->dropdownCriteria(array('value' => $this->fields['criteria'])); $params = array('criteria' => '__VALUE__', 'rand' => $rand, 'sub_type' => $rule->getType()); Ajax::updateItemOnSelectEvent("dropdown_criteria{$rand}", "criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params); if (isset($this->fields['criteria']) && !empty($this->fields['criteria'])) { $params['criteria'] = $this->fields['criteria']; $params['condition'] = $this->fields['condition']; $params['pattern'] = $this->fields['pattern']; echo "<script type='text/javascript' >\n"; Ajax::updateItemJsCode("criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params); echo '</script>'; } if ($rule->specific_parameters) { $itemtype = get_class($rule) . 'Parameter'; echo "<img alt='' title=\"" . __s('Add a criterion') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('addcriterion' . $rand) . ".dialog('open');\">"; Ajax::createIframeModalWindow('addcriterion' . $rand, Toolbox::getItemTypeFormURL($itemtype), array('reloadonclose' => true)); } echo "</td></tr>"; echo "<tr><td colspan='4'><span id='criteria_span'>\n"; echo "</span></td></tr>\n"; $this->showFormButtons($options); }
/** * Show the current ticketfollowup summary * * @param $ticket Ticket object **/ function showSummary($ticket) { global $DB, $CFG_GLPI; if (!Session::haveRightsOr(self::$rightname, array(self::SEEPUBLIC, self::SEEPRIVATE))) { return false; } $tID = $ticket->fields['id']; // Display existing Followups $showprivate = Session::haveRight(self::$rightname, self::SEEPRIVATE); $caneditall = Session::haveRight(self::$rightname, self::UPDATEALL); $tmp = array('tickets_id' => $tID); $canadd = $this->can(-1, CREATE, $tmp); $showuserlink = 0; if (User::canView()) { $showuserlink = 1; } $techs = $ticket->getAllUsers(CommonITILActor::ASSIGN); $reopen_case = false; if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray()) && $ticket->isAllowedStatus($ticket->fields['status'], Ticket::INCOMING)) { $reopen_case = true; } $tech = Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']); $RESTRICT = ""; if (!$showprivate) { $RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') "; } $query = "SELECT `glpi_ticketfollowups`.*, `glpi_users`.`picture`\n FROM `glpi_ticketfollowups`\n LEFT JOIN `glpi_users` ON (`glpi_ticketfollowups`.`users_id` = `glpi_users`.`id`)\n WHERE `tickets_id` = '{$tID}'\n {$RESTRICT}\n ORDER BY `date` DESC"; $result = $DB->query($query); $rand = mt_rand(); if ($caneditall || $canadd) { echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n"; } if ($canadd) { echo "<script type='text/javascript' >\n"; echo "function viewAddFollowup" . $ticket->fields['id'] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'id' => -1); Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo Html::jsHide('addbutton' . $ticket->fields['id'] . "{$rand}"); echo "};"; echo "</script>\n"; // Not closed ticket or closed if (!in_array($ticket->fields["status"], array_merge($ticket->getSolvedStatusArray(), $ticket->getClosedStatusArray())) || $reopen_case) { if (isset($_GET['_openfollowup']) && $_GET['_openfollowup']) { echo Html::scriptBlock("viewAddFollowup" . $ticket->fields['id'] . "{$rand}()"); } else { echo "<div id='addbutton" . $ticket->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddFollowup" . $ticket->fields['id'] . "{$rand}();'>"; if ($reopen_case) { _e('Reopen the ticket'); } else { _e('Add a new followup'); } echo "</a></div>\n"; } } } if ($DB->numrows($result) == 0) { echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>"; echo "<th class='b'>" . __('No followup for this ticket.') . "</th></tr></table>"; } else { $today = strtotime('today'); $lastmonday = strtotime('last monday'); $lastlastmonday = strtotime('last monday', strtotime('last monday')); // Case of monday if ($today - $lastmonday == 7 * DAY_TIMESTAMP) { $lastlastmonday = $lastmonday; $lastmonday = $today; } $steps = array(0 => array('end' => $today, 'name' => __('Today')), 1 => array('end' => $lastmonday, 'name' => __('This week')), 2 => array('end' => $lastlastmonday, 'name' => __('Last week')), 3 => array('end' => strtotime('midnight first day of'), 'name' => __('This month')), 4 => array('end' => strtotime('midnight first day of last month'), 'name' => __('Last month')), 5 => array('end' => 0, 'name' => __('Before the last month'))); $currentpos = -1; while ($data = $DB->fetch_assoc($result)) { $this->getFromDB($data['id']); $candelete = $this->canPurge() && $this->canPurgeItem(); $canedit = $this->canUpdate() && $this->canUpdateItem(); $time = strtotime($data['date']); if (!isset($steps[$currentpos]) || $steps[$currentpos]['end'] > $time) { $currentpos++; while ($steps[$currentpos]['end'] > $time && isset($steps[$currentpos + 1])) { $currentpos++; } if (isset($steps[$currentpos])) { echo "<h3>" . $steps[$currentpos]['name'] . "</h3>"; } } $id = 'followup' . $data['id'] . $rand; $color = 'byuser'; if (isset($techs[$data['users_id']])) { $color = 'bytech'; } $classtoadd = ''; if ($canedit) { $classtoadd = " pointer"; } echo "<div class='boxnote {$color}' id='view{$id}'"; echo ">"; echo "<div class='boxnoteleft'>"; echo "<img class='user_picture_verysmall' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($data['picture']) . "'>"; echo "</div>"; // boxnoteleft echo "<div class='boxnotecontent'"; echo ">"; echo "<div class='boxnotefloatleft'>"; $username = NOT_AVAILABLE; if ($data['users_id']) { $username = getUserName($data['users_id'], $showuserlink); } $name = sprintf(__('Create by %1$s on %2$s'), $username, Html::convDateTime($data['date'])); if ($data['requesttypes_id']) { $name = sprintf(__('%1$s - %2$s'), $name, Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id'])); } if ($showprivate && $data["is_private"]) { $name = sprintf(__('%1$s - %2$s'), $name, __('Private')); } echo $name; echo "</div>"; // floatright echo "<div class='boxnotetext {$classtoadd}'"; if ($canedit) { echo " onClick=\"viewEditFollowup" . $ticket->fields['id'] . $data['id'] . "{$rand}(); " . Html::jsHide("view{$id}") . " " . Html::jsShow("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}") . "\" "; } echo ">"; $content = nl2br($data['content']); if (empty($content)) { $content = NOT_AVAILABLE; } echo $content . '</div>'; // boxnotetext echo "</div>"; // boxnotecontent echo "<div class='boxnoteright'>"; if ($candelete) { Html::showSimpleForm(Toolbox::getItemTypeFormURL('TicketFollowup'), array('purge' => 'purge'), _x('button', 'Delete permanently'), array('id' => $data['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png", '', __('Confirm the final deletion?')); } echo "</div>"; // boxnoteright echo "</div>"; // boxnote if ($canedit) { echo "<div id='viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}' class='starthidden'></div>\n"; echo "\n<script type='text/javascript' >\n"; echo "function viewEditFollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $data["tickets_id"], 'id' => $data["id"]); Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } } } }
/** * Show the current task sumnary * * @param $item CommonITILObject **/ function showSummary(CommonITILObject $item) { global $DB, $CFG_GLPI; if (!static::canView()) { return false; } $tID = $item->fields['id']; // Display existing Followups $showprivate = $this->canViewPrivates(); $caneditall = $this->canEditAll(); $tmp = array($item->getForeignKeyField() => $tID); $canadd = $this->can(-1, CREATE, $tmp); $canpurge = $this->canPurgeItem(); $canview = $this->canViewItem(); $RESTRICT = ""; if ($this->maybePrivate() && !$showprivate) { $RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "'\n OR `users_id_tech` ='" . Session::getLoginUserID() . "'\n OR `groups_id_tech` IN ('" . implode("','", $_SESSION["glpigroups"]) . "')) "; } $query = "SELECT `id`, `date`\n FROM `" . $this->getTable() . "`\n WHERE `" . $item->getForeignKeyField() . "` = '{$tID}'\n {$RESTRICT}\n ORDER BY `date` DESC"; $result = $DB->query($query); $rand = mt_rand(); if ($caneditall || $canadd || $canpurge) { echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n"; } if ($canadd) { echo "<script type='text/javascript' >\n"; echo "function viewAddTask" . $item->fields['id'] . "{$rand}() {\n"; $params = array('type' => $this->getType(), 'parenttype' => $item->getType(), $item->getForeignKeyField() => $item->fields['id'], 'id' => -1); Ajax::updateItemJsCode("viewfollowup" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo Html::jsHide('addbutton' . $item->fields['id'] . "{$rand}"); echo "};"; echo "</script>\n"; if (!in_array($item->fields["status"], array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray()))) { echo "<div id='addbutton" . $item->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddTask" . $item->fields['id'] . "{$rand}();'>"; echo __('Add a new task') . "</a></div>\n"; } } if ($DB->numrows($result) == 0) { echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'><th>" . __('No task found.'); echo "</th></tr></table>"; } else { echo "<table class='tab_cadre_fixehov'>"; $header = "<tr><th> </th><th>" . __('Type') . "</th><th>" . __('Date') . "</th>"; $header .= "<th>" . __('Description') . "</th><th>" . __('Duration') . "</th>"; $header .= "<th>" . __('Writer') . "</th>"; if ($this->maybePrivate() && $showprivate) { $header .= "<th>" . __('Private') . "</th>"; } $header .= "<th>" . __('Planning') . "</th></tr>\n"; echo $header; while ($data = $DB->fetch_assoc($result)) { if ($this->getFromDB($data['id'])) { $options = array('parent' => $item, 'rand' => $rand, 'showprivate' => $showprivate); Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options)); $this->showInObjectSumnary($item, $rand, $showprivate); Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options)); } } echo $header; echo "</table>"; } }
/** * \brief Show aliases for an item from its form * Beware that the rendering can be different if readden from direct item form (ie : add new * NetworkAlias, remove, ...) or if readden from item of the item (for instance from the computer * form through NetworkPort::ShowForItem and NetworkName::ShowForItem). * * @param $item NetworkName object * @param $withtemplate integer withtemplate param (default 0) **/ static function showForNetworkName(NetworkName $item, $withtemplate = 0) { global $DB, $CFG_GLPI; $ID = $item->getID(); if (!$item->can($ID, 'r')) { return false; } $canedit = $item->can($ID, 'w'); $rand = mt_rand(); $query = "SELECT *\n FROM `glpi_networkaliases`\n WHERE `networknames_id` = '{$ID}'"; $result = $DB->query($query); $aliases = array(); if ($number = $DB->numrows($result)) { while ($line = $DB->fetch_assoc($result)) { $aliases[$line["id"]] = $line; } } if ($canedit) { echo "\n<div class='firstbloc'>"; echo "<script type='text/javascript' >\n"; echo "function viewAddAlias{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'NetworkName', 'networknames_id' => $ID, 'id' => -1); Ajax::updateItemJsCode("viewnetworkalias{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>"; echo "<a class='vsubmit' href='javascript:viewAddAlias{$rand}();'>"; echo __('Add a network alias') . "</a>\n"; echo "</div>\n"; } echo "<div id='viewnetworkalias{$rand}'></div>"; echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $number) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . _n('Internet domain', 'Internet domains', 1) . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "</tr>"; $used = array(); foreach ($aliases as $data) { $showviewjs = $canedit ? "style='cursor:pointer' onClick=\"viewEditAlias" . $data['id'] . "{$rand}();\"" : ''; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } echo "<td class='center b' {$showviewjs}>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditAlias" . $data["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'NetworkName', 'networknames_id' => $ID, 'id' => $data["id"]); Ajax::updateItemJsCode("viewnetworkalias{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo "<a href='" . static::getFormURL() . "?id=" . $data["id"] . "'>" . $name . "</a>"; echo "</td>"; echo "<td class='center' {$showviewjs}>" . Dropdown::getDropdownName("glpi_fqdns", $data["fqdns_id"]); echo "<td class='center' {$showviewjs}>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo "</tr>"; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions(__CLASS__, $massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Print the validation list into item * * @param $item class **/ function showSummary($item) { global $DB, $CFG_GLPI; if (!Session::haveRightsOr(static::$rightname, array_merge(static::getCreateRights(), static::getValidateRights(), static::getPurgeRights()))) { return false; } $tID = $item->fields['id']; $tmp = array(static::$items_id => $tID); $canadd = $this->can(-1, CREATE, $tmp); $rand = mt_rand(); if ($canadd) { echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(static::$itemtype) . "'>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='3'>" . self::getTypeName(Session::getPluralNumber()) . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Global approval status') . "</td>"; echo "<td colspan='2'>"; if (Session::haveRightsOr(static::$rightname, TicketValidation::getCreateRights())) { self::dropdownStatus("global_validation", array('value' => $item->fields["global_validation"])); } else { echo TicketValidation::getStatus($item->fields["global_validation"]); } echo "</td></tr>"; echo "<tr>"; echo "<th colspan='2'>" . _x('item', 'State') . "</th>"; echo "<th colspan='2'>"; echo self::getValidationStats($tID); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Minimum validation required') . "</td>"; if ($canadd) { echo "<td>"; echo $item->getValueToSelect('validation_percent', 'validation_percent', $item->fields["validation_percent"]); echo "</td>"; echo "<td><input type='submit' name='update' class='submit' value='" . _sx('button', 'Save') . "'>"; if (!empty($tID)) { echo "<input type='hidden' name='id' value='{$tID}'>"; } echo "</td>"; } else { echo "<td colspan='2'>"; echo Dropdown::getValueWithUnit($item->fields["validation_percent"], "%"); echo "</td>"; } echo "</tr>"; echo "</table>"; if ($canadd) { Html::closeForm(); } echo "<div id='viewvalidation" . $tID . "{$rand}'></div>\n"; if ($canadd) { echo "<script type='text/javascript' >\n"; echo "function viewAddValidation" . $tID . "{$rand}() {\n"; $params = array('type' => $this->getType(), 'parenttype' => static::$itemtype, static::$items_id => $tID, 'id' => -1); Ajax::updateItemJsCode("viewvalidation" . $tID . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; if (!in_array($item->fields['status'], array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray()))) { echo "<div class='center'>"; echo "<a class='vsubmit' href='javascript:viewAddValidation" . $tID . "{$rand}();'>"; echo __('Send an approval request') . "</a></div><br>\n"; } } $query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `" . static::$items_id . "` = '" . $item->getField('id') . "'"; if (!$canadd) { $query .= " AND `users_id_validate` = '" . Session::getLoginUserID() . "'"; } $query .= " ORDER BY submission_date DESC"; $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { $colonnes = array(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Request comments'), __('Approval status'), __('Approver'), __('Approval comments')); $nb_colonnes = count($colonnes); echo "<table class='tab_cadre_fixehov'>"; echo "<tr class='noHover'><th colspan='" . $nb_colonnes . "'>" . __('Approvals for the ticket') . "</th></tr>"; $header = "<tr>"; foreach ($colonnes as $colonne) { $header .= "<th>" . $colonne . "</th>"; } $header .= "</tr>"; echo $header; Session::initNavigateListItems($this->getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->fields["name"])); while ($row = $DB->fetch_assoc($result)) { $canedit = $this->canEdit($row["id"]); Session::addToNavigateListItems($this->getType(), $row["id"]); $bgcolor = self::getStatusColor($row['status']); $status = self::getStatus($row['status']); echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditValidation" . $item->fields['id'] . $row["id"] . "{$rand}();\"" : '') . " id='viewvalidation" . $this->fields[static::$items_id] . $row["id"] . "{$rand}'>"; echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditValidation" . $item->fields['id'] . $row["id"] . "{$rand}() {\n"; $params = array('type' => $this->getType(), 'parenttype' => static::$itemtype, static::$items_id => $this->fields[static::$items_id], 'id' => $row["id"]); Ajax::updateItemJsCode("viewvalidation" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo "<div style='background-color:" . $bgcolor . ";'>" . $status . "</div></td>"; echo "<td>" . Html::convDateTime($row["submission_date"]) . "</td>"; echo "<td>" . getUserName($row["users_id"]) . "</td>"; echo "<td>" . $row["comment_submission"] . "</td>"; echo "<td>" . Html::convDateTime($row["validation_date"]) . "</td>"; echo "<td>" . getUserName($row["users_id_validate"]) . "</td>"; echo "<td>" . $row["comment_validation"] . "</td>"; echo "</tr>"; } echo $header; echo "</table>"; } else { echo "<div class='center b'>" . __('No item found') . "</div>"; } }