Ejemplo n.º 1
0
 static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareLicense $license, $main = true, $cpt = true)
 {
     global $DB;
     $ID = $license->getField('id');
     $pdf->setColumnsSize(100);
     $entity = '';
     if (Session::isMultiEntitiesMode() && !$main) {
         $entity = ' (' . Html::clean(Dropdown::getDropdownName('glpi_entities', $license->fields['entities_id'])) . ')';
     }
     $pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>" . $entity));
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), Software::getTypeName(1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $license->fields['softwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Type') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $license->fields['softwarelicensetypes_id']))));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $license->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Serial number') . '</i></b>', $license->fields['serial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Purchase version') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_buy']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Inventory number') . '</i></b>', $license->fields['otherserial']));
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Version in use') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_use']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Expiration') . '</i></b>', Html::convDate($license->fields['expire'])));
     $col2 = '';
     if ($cpt) {
         $col2 = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Affected computers') . '</i></b>', Computer_SoftwareLicense::countForLicense($ID));
     }
     $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _x('quantity', 'Number') . '</i></b>', $license->fields['number'] > 0 ? $license->fields['number'] : __('Unlimited')), $col2);
     $pdf->setColumnsSize(100);
     PluginPdfCommon::mainLine($pdf, $license, 'comment');
     if ($main) {
         $pdf->displaySpace();
     }
 }
Ejemplo n.º 2
0
 /**
  * Print out list recent or popular kb/faq
  *
  * @param $type      type : recent / popular / not published
  *
  * @return nothing (display table)
  **/
 static function showRecentPopular($type)
 {
     global $DB, $CFG_GLPI;
     $faq = !Session::haveRight("knowbase", "r");
     if ($type == "recent") {
         $orderby = "ORDER BY `date` DESC";
         $title = __('Recent entries');
     } else {
         if ($type == 'lastupdate') {
             $orderby = "ORDER BY `date_mod` DESC";
             $title = __('Last updated entries');
         } else {
             $orderby = "ORDER BY `view` DESC";
             $title = __('Most popular questions');
         }
     }
     $faq_limit = "";
     // Force all joins for not published to verify no visibility set
     $join = self::addVisibilityJoins(true);
     if (Session::getLoginUserID()) {
         $faq_limit .= "WHERE " . self::addVisibilityRestrict();
     } else {
         // Anonymous access
         if (Session::isMultiEntitiesMode()) {
             $faq_limit .= " WHERE (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n                                   AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')";
         } else {
             $faq_limit .= " WHERE 1";
         }
     }
     // Only published
     $faq_limit .= " AND (`glpi_entities_knowbaseitems`.`entities_id` IS NOT NULL\n                           OR `glpi_knowbaseitems_profiles`.`profiles_id` IS NOT NULL\n                           OR `glpi_groups_knowbaseitems`.`groups_id` IS NOT NULL\n                           OR `glpi_knowbaseitems_users`.`users_id` IS NOT NULL)";
     if ($faq) {
         // FAQ
         $faq_limit .= " AND (`glpi_knowbaseitems`.`is_faq` = '1')";
     }
     $query = "SELECT DISTINCT `glpi_knowbaseitems`.*\n                FROM `glpi_knowbaseitems`\n                {$join}\n                {$faq_limit}\n                {$orderby}\n                LIMIT 10";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($number > 0) {
         echo "<table class='tab_cadrehov'>";
         echo "<tr><th>" . $title . "</th></tr>";
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tr class='tab_bg_2'><td class='left'>";
             echo "<a " . ($data['is_faq'] ? " class='pubfaq' " : " class='knowbase' ") . " href=\"" . $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\">" . Html::resume_text($data["name"], 80) . "</a></td></tr>";
         }
         echo "</table>";
     }
 }
Ejemplo n.º 3
0
 /**
  * Print the search config form
  *
  * @param $target    form target
  * @param $itemtype  item type
  *
  * @return nothing
  **/
 function showFormGlobal($target, $itemtype)
 {
     global $CFG_GLPI, $DB;
     $searchopt = Search::getOptions($itemtype);
     if (!is_array($searchopt)) {
         return false;
     }
     $IDuser = 0;
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     $global_write = Session::haveRight(self::$rightname, self::GENERAL);
     echo "<div class='center' id='tabsbody' >";
     // Defined items
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `itemtype` = '{$itemtype}'\n                      AND `users_id` = '{$IDuser}'\n                ORDER BY `rank`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     echo "<table class='tab_cadre_fixehov'><tr><th colspan='4'>";
     echo __('Select default items to show') . "</th></tr>\n";
     if ($global_write) {
         $already_added = self::getForTypeUser($itemtype, $IDuser);
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<form method='post' action='{$target}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
         $group = '';
         $values = array();
         $searchopt = Search::getCleanedOptions($itemtype);
         foreach ($searchopt as $key => $val) {
             if (!is_array($val)) {
                 $group = $val;
             } else {
                 if ($key != 1 && !in_array($key, $already_added) && (!isset($val['nodisplay']) || !$val['nodisplay'])) {
                     $values[$group][$key] = $val["name"];
                 }
             }
         }
         if ($values) {
             Dropdown::showFromArray('num', $values);
             echo "<span class='small_space'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</span>";
         }
         Html::closeForm();
         echo "</td></tr>";
     }
     // print first element
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' width='50%'>" . $searchopt[1]["name"];
     if ($global_write) {
         echo "</td><td colspan='3'>&nbsp;";
     }
     echo "</td></tr>";
     // print entity
     if (Session::isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>";
         echo "<td colspan='3'>&nbsp;</td>";
         echo "</tr>";
     }
     $i = 0;
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["num"] != 1 && isset($searchopt[$data["num"]])) {
                 echo "<tr class='tab_bg_2'><td class='center' width='50%'>";
                 echo $searchopt[$data["num"]]["name"];
                 echo "</td>";
                 if ($global_write) {
                     if ($i != 0) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='up' value=\"" . __s('Bring up') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up.png' alt=\"" . __s('Bring up') . "\"  title=\"" . __s('Bring up') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     if ($i != $numrows - 1) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='down' value=\"" . __s('Bring down') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down.png' alt=\"" . __s('Bring down') . "\" title=\"" . __s('Bring down') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     echo "<td class='center middle'>";
                     echo "<form method='post' action='{$target}'>";
                     echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                     echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                     echo "<input type='image' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png' alt=\"" . __s('Delete permanently') . "\" title=\"" . __s('Delete permanently') . "\"  class='pointer'>";
                     Html::closeForm();
                     echo "</td>\n";
                 }
                 echo "</tr>";
                 $i++;
             }
         }
     }
     echo "</table>";
     echo "</div>";
 }
Ejemplo n.º 4
0
 /**
  * Print the user form
  *
  * @param $ID        integer : Id of the user
  * @param $options   array
  *     - target form target
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean : user found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !Session::haveRight("user", "r")) {
         return false;
     }
     $this->initForm($ID, $options);
     if ($ID) {
         $caneditpassword = $this->currentUserHaveMoreRightThan($ID);
     } else {
         // can edit on creation form
         $caneditpassword = true;
     }
     $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Login') . "</td>";
     // si on est dans le cas d'un ajout , cet input ne doit plus etre hidden
     if ($this->fields["name"] == "") {
         echo "<td><input name='name' value=\"" . $this->fields["name"] . "\"></td>";
         // si on est dans le cas d'un modif on affiche la modif du login si ce n'est pas une auth externe
     } else {
         if (!empty($this->fields["password"]) || $this->fields["authtype"] == Auth::DB_GLPI) {
             echo "<td>";
             echo "<input name='name' value=\"" . $this->fields["name"] . "\">";
         } else {
             echo "<td class='b'>" . $this->fields["name"];
             echo "<input type='hidden' name='name' value=\"" . $this->fields["name"] . "\">";
         }
         echo "</td>";
     }
     //do some rights verification
     if (Session::haveRight("user", "w") && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<td>" . __('Password') . "</td>";
         echo "<td><input id='password' type='password' name='password' value='' size='20'\n                    autocomplete='off' onkeyup=\"return passwordCheck();\">";
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
     Html::autocompletionTextField($this, "realname");
     echo "</td>";
     //do some rights verification
     if (Session::haveRight("user", "w") && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<td>" . __('Password confirmation') . "</td>";
         echo "<td><input type='password' name='password2' value='' size='20' autocomplete='off'>";
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
     Html::autocompletionTextField($this, "firstname");
     echo "</td>";
     if (Session::haveRight("user", "w") && (!$extauth || empty($ID)) && $caneditpassword) {
         echo "<td>" . __('Password security policy') . "</td>";
         echo "<td>";
         Config::displayPasswordSecurityChecks();
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Email', 'Emails', 2);
     UserEmail::showAddEmailButton($this);
     echo "</td><td>";
     UserEmail::showForUser($this);
     echo "</td>";
     //Authentications information : auth method used and server used
     //don't display is creation of a new user'
     if (!empty($ID)) {
         if (Session::haveRight("user_authtype", "r")) {
             echo "<td>" . __('Authentication') . "</td><td>";
             echo Auth::getMethodName($this->fields["authtype"], $this->fields["auths_id"]);
             if (!empty($this->fields["date_sync"])) {
                 //TRANS: %s is the date of last sync
                 echo '<br>' . sprintf(__('Last synchronization on %s'), HTML::convDateTime($this->fields["date_sync"]));
             }
             if (!empty($this->fields["user_dn"])) {
                 //TRANS: %s is the user dn
                 echo '<br>' . sprintf(__('%1$s: %2$s'), __('User DN'), $this->fields["user_dn"]);
             }
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
     } else {
         echo "<td colspan='2'><input type='hidden' name='authtype' value='1'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone') . "</td><td>";
     Html::autocompletionTextField($this, "phone");
     echo "</td>";
     echo "<td>" . __('Active') . "</td><td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Mobile phone') . "</td><td>";
     Html::autocompletionTextField($this, "mobile");
     echo "</td>";
     echo "<td>" . __('Category') . "</td><td>";
     UserCategory::dropdown(array('value' => $this->fields["usercategories_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Phone 2') . "</td><td>";
     Html::autocompletionTextField($this, "phone2");
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='6' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Administrative number') . "</td><td>";
     Html::autocompletionTextField($this, "registration_number");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . _x('person', 'Title') . "&nbsp;:</td><td>";
     UserTitle::dropdown(array('value' => $this->fields["usertitles_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
     if (!empty($ID)) {
         $entities = Profile_User::getUserEntities($ID, true);
         if (count($entities) > 0) {
             Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $entities));
         } else {
             echo "&nbsp;";
         }
     } else {
         if (!Session::isMultiEntitiesMode()) {
             // Display all locations : only one entity
             Location::dropdown(array('value' => $this->fields["locations_id"]));
         } else {
             echo "&nbsp;";
         }
     }
     echo "</td></tr>";
     if (empty($ID)) {
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='2'>" . _n('Authorization', 'Authorizations', 1) . "</th>";
         echo "<td>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("_is_recursive", 0);
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Profile') . "</td><td>";
         Profile::dropdownUnder(array('name' => '_profiles_id', 'value' => Profile::getDefault()));
         echo "</td><td>" . __('Entity') . "</td><td>";
         Entity::dropdown(array('name' => '_entities_id', 'display_emptychoice' => false, 'entity' => $_SESSION['glpiactiveentities']));
         echo "</td></tr>";
     } else {
         if ($caneditpassword) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Default profile') . "</td><td>";
             $options[0] = Dropdown::EMPTY_VALUE;
             $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
             echo "</td><td>" . __('Default entity') . "</td><td>";
             $entities = Profile_User::getUserEntities($this->fields['id'], 1);
             Entity::dropdown(array('value' => $this->fields["entities_id"], 'entity' => $entities));
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         //TRANS: %s is the date
         printf(__('Last update on %s'), HTML::convDateTime($this->fields["date_mod"]));
         echo "<br>";
         printf(__('Last login on %s'), HTML::convDateTime($this->fields["last_login"]));
         echo "</td><td colspan='2'class='center'>";
         if ($ID > 0) {
             echo "<a target='_blank' href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?getvcard=1&amp;id={$ID}'>" . __('Vcard') . "</a>";
         }
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Ejemplo n.º 5
0
 static function showListSimple()
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight("reservation_helpdesk", "1")) {
         return false;
     }
     $ri = new self();
     $ok = false;
     $showentity = Session::isMultiEntitiesMode();
     // GET method passed to form creation
     echo "<div class='center'><form name='form' method='GET' action='reservation.form.php'>";
     echo "<table class='tab_cadre'>";
     echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n";
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $itemtable = getTableForItemType($itemtype);
         $query = "SELECT `glpi_reservationitems`.`id`,\n                          `glpi_reservationitems`.`comment`,\n                          `{$itemtable}`.`name` AS name,\n                          `{$itemtable}`.`entities_id` AS entities_id,\n                          `glpi_locations`.`completename` AS location,\n                          `glpi_reservationitems`.`items_id` AS items_id\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `{$itemtable}`\n                        ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n                            AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n                   LEFT JOIN `glpi_locations`\n                        ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n                   WHERE `glpi_reservationitems`.`is_active` = '1'\n                         AND `glpi_reservationitems`.`is_deleted` = '0'\n                         AND `{$itemtable}`.`is_deleted` = '0'" . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n                   ORDER BY `{$itemtable}`.`entities_id`,\n                            `{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             while ($row = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>";
                 $typename = $item->getTypeName();
                 if ($itemtype == 'Peripheral') {
                     $item->getFromDB($row['items_id']);
                     if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
                         $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
                     }
                 }
                 echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>" . sprintf(__('%1$s - %2$s'), $typename, $row["name"]) . "</a></td>";
                 echo "<td>" . $row["location"] . "</td>";
                 echo "<td>" . nl2br($row["comment"]) . "</td>";
                 if ($showentity) {
                     echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>";
                 }
                 echo "</tr>\n";
                 $ok = true;
             }
         }
     }
     if ($ok) {
         echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>";
         echo "<input type='submit' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>\n";
     }
     echo "</table>\n";
     echo "<input type='hidden' name='id' value=''>";
     echo "</form>";
     // No CSRF token needed
     echo "</div>\n";
 }
Ejemplo n.º 6
0
 /**
  * @see CommonDBTM::getSpecificMassiveActions()
  **/
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($isadmin) {
         $actions['add_contact_supplier'] = _x('button', 'Add a contact');
     }
     if (Session::haveRight('transfer', 'r') && Session::isMultiEntitiesMode() && $isadmin) {
         $actions['add_transfer_list'] = _x('button', 'Add to transfer list');
     }
     return $actions;
 }
Ejemplo n.º 7
0
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         if ($isadmin) {
             if (Session::haveRight('transfer', READ) && Session::isMultiEntitiesMode()) {
                 $actions['PluginTasklistsTask' . MassiveAction::CLASS_ACTION_SEPARATOR . 'transfer'] = __('Transfer');
             }
         }
     }
     return $actions;
 }
Ejemplo n.º 8
0
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     $default_values = self::getDefaultValues();
     // Get default values from posted values on reload form
     // On get because of tabs
     // we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST)
     if (!isset($options['template_preview'])) {
         if (isset($_REQUEST)) {
             $values = Html::cleanPostForTextArea($_REQUEST);
         }
     }
     // Restore saved value or override with page parameter
     $saved = $this->restoreInput();
     foreach ($default_values as $name => $value) {
         if (!isset($values[$name])) {
             if (isset($saved[$name])) {
                 $values[$name] = $saved[$name];
             } else {
                 $values[$name] = $value;
             }
         }
     }
     if (isset($values['content'])) {
         // Clean new lines to be fix encoding
         $order = array('\\r', '\\n', "\\");
         $replace = array("", "", "");
         $values['content'] = str_replace($order, $replace, $values['content']);
     }
     if (isset($values['name'])) {
         $values['name'] = str_replace("\\", "", $values['name']);
     }
     if (!$ID) {
         // Override defaut values from projecttask if needed
         if (isset($options['_projecttasks_id'])) {
             $pt = new ProjectTask();
             if ($pt->getFromDB($options['_projecttasks_id'])) {
                 $values['name'] = $pt->getField('name');
                 $values['content'] = $pt->getField('name');
             }
         }
     }
     // Check category / type validity
     if ($values['itilcategories_id']) {
         $cat = new ITILCategory();
         if ($cat->getFromDB($values['itilcategories_id'])) {
             switch ($values['type']) {
                 case self::INCIDENT_TYPE:
                     if (!$cat->getField('is_incident')) {
                         $values['itilcategories_id'] = 0;
                     }
                     break;
                 case self::DEMAND_TYPE:
                     if (!$cat->getField('is_request')) {
                         $values['itilcategories_id'] = 0;
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     // Default check
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE, $values);
     }
     if (!$ID) {
         $this->userentities = array();
         if ($values["_users_id_requester"]) {
             //Get all the user's entities
             $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
             //For each user's entity, check if the technician which creates the ticket have access to it
             foreach ($all_entities as $tmp => $ID_entity) {
                 if (Session::haveAccessToEntity($ID_entity)) {
                     $this->userentities[] = $ID_entity;
                 }
             }
         }
         $this->countentitiesforuser = count($this->userentities);
         if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) {
             // If entity is not in the list of user's entities,
             // then use as default value the first value of the user's entites list
             $this->fields["entities_id"] = $this->userentities[0];
             // Pass to values
             $values['entities_id'] = $this->userentities[0];
         }
     }
     if ($values['type'] <= 0) {
         $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE);
     }
     if (!isset($options['template_preview'])) {
         $options['template_preview'] = 0;
     }
     // Load ticket template if available :
     if ($ID) {
         $tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']);
     } else {
         $tt = $this->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']);
     }
     // Predefined fields from template : reset them
     if (isset($values['_predefined_fields'])) {
         $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
     } else {
         $values['_predefined_fields'] = array();
     }
     // Store predefined fields to be able not to take into account on change template
     // Only manage predefined values on ticket creation
     $predefined_fields = array();
     if (!$ID) {
         if (isset($tt->predefined) && count($tt->predefined)) {
             foreach ($tt->predefined as $predeffield => $predefvalue) {
                 if (isset($default_values[$predeffield])) {
                     // Is always default value : not set
                     // Set if already predefined field
                     // Set if ticket template change
                     if (count($values['_predefined_fields']) == 0 && $values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID() || $predeffield == 'requesttypes_id' && empty($saved)) {
                         // Load template data
                         $values[$predeffield] = $predefvalue;
                         $this->fields[$predeffield] = $predefvalue;
                         $predefined_fields[$predeffield] = $predefvalue;
                     }
                 }
             }
             // All predefined override : add option to say predifined exists
             if (count($predefined_fields) == 0) {
                 $predefined_fields['_all_predefined_override'] = 1;
             }
         } else {
             // No template load : reset predefined values
             if (count($values['_predefined_fields'])) {
                 foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
                     if ($values[$predeffield] == $predefvalue) {
                         $values[$predeffield] = $default_values[$predeffield];
                     }
                 }
             }
         }
     }
     // Put ticket template on $values for actors
     $values['_tickettemplate'] = $tt;
     $canupdate = Session::haveRight(self::$rightname, UPDATE);
     $canpriority = Session::haveRight(self::$rightname, self::CHANGEPRIORITY);
     $canstatus = $canupdate;
     if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) {
         $canupdate = false;
         // No update for actors
         $values['_noupdate'] = true;
     }
     $showuserlink = 0;
     if (Session::haveRight('user', READ)) {
         $showuserlink = 1;
     }
     if ($options['template_preview']) {
         // Add all values to fields of tickets for template preview
         foreach ($values as $key => $val) {
             if (!isset($this->fields[$key])) {
                 $this->fields[$key] = $val;
             }
         }
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '29';
     $colsize3 = '13';
     $colsize4 = '45';
     $canupdate_descr = $canupdate || $this->fields['status'] == self::INCOMING && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0;
     if (!$options['template_preview']) {
         echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>";
         if (isset($options['_projecttasks_id'])) {
             echo "<input type='hidden' name='_projecttasks_id' value='" . $options['_projecttasks_id'] . "'>";
         }
     }
     echo "<div class='spaced' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe' id='mainformtable'>";
     // Optional line
     $ismultientities = Session::isMultiEntitiesMode();
     echo "<tr class='headerRow responsive_hidden'>";
     echo "<th colspan='4'>";
     if ($ID) {
         $text = sprintf(__('%1$s - %2$s'), $this->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID));
         if ($ismultientities) {
             $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']));
         }
         echo $text;
     } else {
         if ($ismultientities) {
             printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id']));
         } else {
             _e('New ticket');
         }
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date'));
     } else {
         _e('Opening date');
     }
     echo $tt->getEndHiddenFieldText('date');
     echo "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('date');
     $date = $this->fields["date"];
     if ($canupdate) {
         Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo Html::convDateTime($date);
     }
     echo $tt->getEndHiddenFieldValue('date', $this);
     echo "</td><td colspan='2'></td></tr>";
     // SLTs
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('time_to_own');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Time to own'), $tt->getMandatoryMark('time_to_own'));
     } else {
         _e('Time to own');
     }
     echo $tt->getEndHiddenFieldText('time_to_own');
     echo "</th>";
     echo "<td width='{$colsize2}%' class='nopadding'>";
     $slt = new SLT();
     $slt->showSltForTicket($this, SLT::TTO, $tt, $canupdate);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Time to resolve'), $tt->getMandatoryMark('due_date'));
     } else {
         _e('Time to resolve');
     }
     echo $tt->getEndHiddenFieldText('due_date');
     echo "</th>";
     echo "<td width='{$colsize4}%' class='nopadding'>";
     $slt->showSltForTicket($this, SLT::TTR, $tt, $canupdate);
     echo "</td>";
     echo "</tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('By') . "</th>";
         echo "<td width='{$colsize2}%'>";
         if ($canupdate) {
             User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         } else {
             echo getUserName($this->fields["users_id_recipient"], $showuserlink);
         }
         echo "</td>";
         echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>";
         echo "<td width='{$colsize4}%'>";
         if ($this->fields['users_id_lastupdater'] > 0) {
             //TRANS: %1$s is the update date, %2$s is the last updater name
             printf(__('%1$s by %2$s'), Html::convDateTime($this->fields["date_mod"]), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td>";
         echo "</tr>";
     }
     if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>";
         echo "<td width='{$colsize2}%'>";
         Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
         echo "</td>";
         if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
             echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>";
             echo "<td width='{$colsize4}%'>";
             Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     if ($ID) {
         echo "</table>";
         echo "<table  class='tab_cadre_fixe' id='mainformtable2'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Permit to set type when creating ticket without update right
     if ($canupdate || !$ID) {
         $opt = array('value' => $this->fields["type"]);
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'this.form.submit()';
         }
         $rand = self::dropdownType('type', $opt);
         if ($ID) {
             $params = array('type' => '__VALUE__', 'entity_restrict' => $this->fields['entities_id'], 'value' => $this->fields['itilcategories_id'], 'currenttype' => $this->fields['type']);
             Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params);
         }
     } else {
         echo self::getTicketTypeName($this->fields["type"]);
     }
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>";
     echo "<td width='{$colsize4}%'>";
     // Permit to set category when creating ticket without update right
     if ($canupdate || !$ID || $canupdate_descr) {
         $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"]);
         if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
             $opt['condition'] = "`is_helpdeskvisible`='1' AND ";
         } else {
             $opt['condition'] = '';
         }
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'this.form.submit()';
         }
         /// if category mandatory, no empty choice
         /// no empty choice is default value set on ticket creation, else yes
         if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $this->fields["itilcategories_id"] > 0) {
             $opt['display_emptychoice'] = false;
         }
         switch ($this->fields["type"]) {
             case self::INCIDENT_TYPE:
                 $opt['condition'] .= "`is_incident`='1'";
                 break;
             case self::DEMAND_TYPE:
                 $opt['condition'] .= "`is_request`='1'";
                 break;
             default:
                 break;
         }
         echo "<span id='show_category_by_type'>";
         ITILCategory::dropdown($opt);
         echo "</span>";
     } else {
         echo Dropdown::getDropdownName("glpi_itilcategories", $this->fields["itilcategories_id"]);
     }
     echo "</td>";
     echo "</tr>";
     if (!$ID) {
         echo "</table>";
         $this->showActorsPartForm($ID, $values);
         echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status');
     printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status'));
     echo $tt->getEndHiddenFieldText('status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('status');
     if ($canstatus) {
         self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
         TicketValidation::alertValidation($this, 'status');
     } else {
         echo self::getStatus($this->fields["status"]);
         if (in_array($this->fields["status"], $this->getClosedStatusArray()) && $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) {
             echo "&nbsp;<a class='vsubmit' href='" . $this->getLinkURL() . "&amp;forcetab=TicketFollowup\$1&amp;_openfollowup=1'>" . __('Reopen') . "</a>";
         }
     }
     echo $tt->getEndHiddenFieldValue('status', $this);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id');
     printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id'));
     echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>";
     echo "<td width='{$colsize4}%'>";
     echo $tt->getBeginHiddenFieldValue('requesttypes_id');
     if ($canupdate) {
         RequestType::dropdown(array('value' => $this->fields["requesttypes_id"], 'condition' => 'is_active = 1 AND is_ticketheader = 1'));
     } else {
         echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]);
         echo Html::hidden('requesttypes_id', array('value' => $this->fields["requesttypes_id"]));
     }
     echo $tt->getEndHiddenFieldValue('requesttypes_id', $this);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('urgency');
     printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency'));
     echo $tt->getEndHiddenFieldText('urgency') . "</th>";
     echo "<td>";
     if ($canupdate && $canpriority || !$ID || $canupdate_descr) {
         // Only change during creation OR when allowed to change priority OR when user is the creator
         echo $tt->getBeginHiddenFieldValue('urgency');
         $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
         echo $tt->getEndHiddenFieldValue('urgency', $this);
     } else {
         $idurgency = "value_urgency" . mt_rand();
         echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>";
         echo $tt->getBeginHiddenFieldValue('urgency');
         echo parent::getUrgencyName($this->fields["urgency"]);
         echo $tt->getEndHiddenFieldValue('urgency', $this);
     }
     echo "</td>";
     // Display validation state
     echo "<th>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldText('_add_validation');
         printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation'));
         echo $tt->getEndHiddenFieldText('_add_validation');
     } else {
         echo $tt->getBeginHiddenFieldText('global_validation');
         _e('Approval');
         echo $tt->getEndHiddenFieldText('global_validation');
     }
     echo "</th>";
     echo "<td>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldValue('_add_validation');
         $validation_right = '';
         if ($values['type'] == self::INCIDENT_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) {
             $validation_right = 'validate_incident';
         }
         if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) {
             $validation_right = 'validate_request';
         }
         if (!empty($validation_right)) {
             echo "<input type='hidden' name='_add_validation' value='" . $values['_add_validation'] . "'>";
             $params = array('name' => "users_id_validate", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'users_id_validate' => $values['users_id_validate']);
             TicketValidation::dropdownValidator($params);
         }
         echo $tt->getEndHiddenFieldValue('_add_validation', $this);
         if ($tt->isPredefinedField('global_validation')) {
             echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>";
         }
     } else {
         echo $tt->getBeginHiddenFieldValue('global_validation');
         if (Session::haveRightsOr('ticketvalidation', TicketValidation::getCreateRights()) && $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>" . $tt->getBeginHiddenFieldText('locations_id');
     printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
     echo $tt->getEndHiddenFieldText('locations_id') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('locations_id');
     if ($canupdate || !$ID) {
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $this->fields['entities_id']));
     } else {
         echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]);
     }
     echo $tt->getEndHiddenFieldValue('locations_id', $this);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('priority');
     printf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority'));
     echo $tt->getEndHiddenFieldText('priority') . "</th>";
     echo "<td>";
     $idajax = 'change_priority_' . mt_rand();
     if ($canpriority && !$tt->isHiddenField('priority')) {
         $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
         $idpriority = 'dropdown_priority' . $idpriority;
         echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     } else {
         $idpriority = 0;
         echo $tt->getBeginHiddenFieldValue('priority');
         echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>";
         echo $tt->getEndHiddenFieldValue('priority', $this);
     }
     if ($canupdate || $canupdate_descr) {
         $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority);
         Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     }
     echo "</td>";
     echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('items_id');
     printf(__('%1$s%2$s'), _n('Associated element', 'Associated elements', Session::getPluralNumber()), $tt->getMandatoryMark('items_id'));
     if ($ID && $canupdate) {
         echo "&nbsp;<a  href='" . $this->getFormURL() . "?id=" . $ID . "&amp;forcetab=Item_Ticket\$1'><img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n                      class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'></a>";
     }
     echo $tt->getEndHiddenFieldText('items_id');
     echo "</th>";
     if (!$ID) {
         echo "<td rowspan='2'>";
         echo $tt->getBeginHiddenFieldValue('items_id');
         $values['_canupdate'] = Session::haveRight('ticket', CREATE);
         if ($values['_canupdate']) {
             Item_Ticket::itemAddForm($this, $values);
         }
         echo $tt->getEndHiddenFieldValue('items_id', $this);
         echo "</td>";
     } else {
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('items_id');
         $values['_canupdate'] = $canupdate || $canupdate_descr;
         Item_Ticket::itemAddForm($this, $values);
         echo $tt->getEndHiddenFieldValue('items_id', $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     // Need comment right to add a followup with the actiontime
     if (!$ID && Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) {
         echo "<th>" . $tt->getBeginHiddenFieldText('actiontime');
         printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime'));
         echo $tt->getEndHiddenFieldText('actiontime') . "</th>";
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('actiontime');
         Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true));
         echo $tt->getEndHiddenFieldValue('actiontime', $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "</table>";
     if ($ID) {
         $this->showActorsPartForm($ID, $values);
     }
     $view_linked_tickets = $ID || $canupdate;
     echo "<table class='tab_cadre_fixe' id='mainformtable4'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name');
     printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name'));
     echo $tt->getEndHiddenFieldText('name') . "</th>";
     echo "<td colspan='3'>";
     if (!$ID || $canupdate_descr) {
         echo $tt->getBeginHiddenFieldValue('name');
         echo "<input type='text' style='width:98%' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">";
         echo $tt->getEndHiddenFieldValue('name', $this);
     } else {
         if (empty($this->fields["name"])) {
             _e('Without title');
         } else {
             echo $this->fields["name"];
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content');
     printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content'));
     if (!$ID || $canupdate_descr) {
         $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         Html::showTooltip(nl2br(Html::Clean($content)));
     }
     echo $tt->getEndHiddenFieldText('content') . "</th>";
     echo "<td colspan='3'>";
     if (!$ID || $canupdate_descr) {
         // Admin =oui on autorise la modification de la description
         echo $tt->getBeginHiddenFieldValue('content');
         $rand = mt_rand();
         $rand_text = mt_rand();
         $rows = 6;
         $content_id = "content{$rand}";
         if ($CFG_GLPI["use_rich_text"]) {
             $this->fields["content"] = $this->setRichTextContent($content_id, $this->fields["content"], $rand);
             $rows = 10;
         } else {
             $this->fields["content"] = $this->setSimpleTextContent($this->fields["content"]);
         }
         echo "<div id='content{$rand_text}'>";
         echo "<textarea id='{$content_id}' name='content' style='width:100%' rows='{$rows}'>" . $this->fields["content"] . "</textarea></div>";
         echo Html::scriptBlock("\$(document).ready(function() { \$('#{$content_id}').autogrow(); });");
         echo $tt->getEndHiddenFieldValue('content', $this);
     } else {
         $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         echo nl2br(Html::Clean($content));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     if ($view_linked_tickets) {
         echo "<th style='width:{$colsize1}%'>" . _n('Linked ticket', 'Linked tickets', Session::getPluralNumber());
         $rand_linked_ticket = mt_rand();
         if ($canupdate) {
             echo "&nbsp;";
             echo "<img onClick=\"" . Html::jsShow("linkedticket{$rand_linked_ticket}") . "\"\n                   title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                   class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo '</th>';
         echo "<td colspan='3'>";
         if ($canupdate) {
             echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>";
             echo "<table class='tab_format' width='100%'><tr><td width='30%'>";
             Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
             echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n";
             echo "</td><td width='70%'>";
             $linkparam = array('name' => '_link[tickets_id_2]', 'displaywith' => array('id'));
             if (isset($values["_link"])) {
                 $linkparam['value'] = $values["_link"]['tickets_id_2'];
             }
             Ticket::dropdown($linkparam);
             echo "</td></tr></table>";
             echo "</div>";
             if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) {
                 echo "<script language='javascript'>";
                 echo Html::jsShow("linkedticket{$rand_linked_ticket}");
                 echo "</script>";
             }
         }
         Ticket_Ticket::displayLinkedTicketsTo($ID);
         echo "</td>";
     }
     echo "</tr>";
     // View files added
     echo "<tr class='tab_bg_1'>";
     // Permit to add doc when creating a ticket
     echo "<th style='width:{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('_documents_id');
     $doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize());
     printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id'));
     // Do not show if hidden.
     if (!$tt->isHiddenField('_documents_id')) {
         DocumentType::showAvailableTypesLink();
     }
     echo $tt->getEndHiddenFieldText('_documents_id');
     echo "</th>";
     echo "<td colspan='3'>";
     // Do not set values
     echo $tt->getEndHiddenFieldValue('_documents_id');
     if ($tt->isPredefinedField('_documents_id')) {
         if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) {
             echo "<span class='b'>" . __('Default documents:') . '</span>';
             echo "<br>";
             $doc = new Document();
             foreach ($values['_documents_id'] as $key => $val) {
                 if ($doc->getFromDB($val)) {
                     echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>";
                     echo "- " . $doc->getNameID() . "<br>";
                 }
             }
         }
     }
     echo "<div id='fileupload_info'></div>";
     echo "</td>";
     echo "</tr>";
     if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) {
         echo "<tr class='tab_bg_1'>";
         if ($ID) {
             if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) {
                 echo "<td class='tab_bg_2 center' colspan='4'>";
                 if ($this->fields["is_deleted"] == 1) {
                     if (self::canPurge()) {
                         echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 } else {
                     if (self::canUpdate()) {
                         echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 }
                 if ($this->fields["is_deleted"] == 1) {
                     if (self::canPurge()) {
                         echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
                     }
                 } else {
                     if ($this->canDeleteItem()) {
                         echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>";
                     }
                 }
                 echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
                 echo "</td>";
             }
         } else {
             echo "<td class='tab_bg_2 center' colspan='4'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             if ($tt->isField('id') && $tt->fields['id'] > 0) {
                 echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
                 echo "<input type='hidden' name='_predefined_fields'\n                      value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
             }
         }
     }
     // File upload system
     $colspan = 3;
     if (!$CFG_GLPI['use_rich_text']) {
         $colspan = 4;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='{$colspan}'>";
     echo $tt->getBeginHiddenFieldValue('_documents_id');
     echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename'])));
     echo "</td>";
     if ($CFG_GLPI['use_rich_text']) {
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='{$colspan}'>";
         if (!isset($rand)) {
             $rand = mt_rand();
         }
         if ($canupdate_descr) {
             echo Html::initImagePasteSystem($content_id, $rand);
         }
         echo "</td>";
     }
     echo "</tr>";
     echo "</table>";
     echo "<input type='hidden' name='id' value='{$ID}'>";
     echo "</div>";
     if (!$options['template_preview']) {
         Html::closeForm();
     }
     return true;
 }
Ejemplo n.º 9
0
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($isadmin) {
         if (Session::haveRight('transfer', READ) && Session::isMultiEntitiesMode()) {
             $actions['PluginOrderOrder:transfert'] = __('Transfer');
         }
     }
     return $actions;
 }
Ejemplo n.º 10
0
 /**
  * @see Rule::getCriterias()
  **/
 function getCriterias()
 {
     static $criterias = array();
     if (count($criterias)) {
         return $criterias;
     }
     $criterias['mailcollector']['field'] = 'name';
     $criterias['mailcollector']['name'] = __('Mails receiver');
     $criterias['mailcollector']['table'] = 'glpi_mailcollectors';
     $criterias['mailcollector']['type'] = 'dropdown';
     $criterias['_users_id_requester']['field'] = 'name';
     $criterias['_users_id_requester']['name'] = __('Requester');
     $criterias['_users_id_requester']['table'] = 'glpi_users';
     $criterias['_users_id_requester']['type'] = 'dropdown';
     $criterias['subject']['name'] = __('Subject email header');
     $criterias['subject']['field'] = 'subject';
     $criterias['subject']['table'] = '';
     $criterias['subject']['type'] = 'text';
     $criterias['content']['name'] = __('Email body');
     $criterias['content']['table'] = '';
     $criterias['content']['type'] = 'text';
     $criterias['from']['name'] = __('From email header');
     $criterias['from']['table'] = '';
     $criterias['from']['type'] = 'text';
     $criterias['to']['name'] = __('To email header');
     $criterias['to']['table'] = '';
     $criterias['to']['type'] = 'text';
     $criterias['in_reply_to']['name'] = __('In-Reply-To email header');
     $criterias['in_reply_to']['table'] = '';
     $criterias['in_reply_to']['type'] = 'text';
     $criterias['x-priority']['name'] = __('X-Priority email header');
     $criterias['x-priority']['table'] = '';
     $criterias['x-priority']['type'] = 'text';
     $criterias['x-auto-response-suppress']['name'] = __('X-Auto-Response-Suppress email header');
     $criterias['x-auto-response-suppress']['table'] = '';
     $criterias['x-auto-response-suppress']['type'] = 'text';
     $criterias['auto-submitted']['name'] = __('Auto-Submitted email header');
     $criterias['auto-submitted']['table'] = '';
     $criterias['auto-submitted']['type'] = 'text';
     /// Renater spam matching : X-UCE-Status = Yes
     $criterias['x-uce-status']['name'] = __('X-UCE-Status email header');
     $criterias['x-uce-status']['table'] = '';
     $criterias['x-uce-status']['type'] = 'text';
     $criterias['received']['name'] = __('Received email header');
     $criterias['received']['table'] = '';
     $criterias['received']['type'] = 'text';
     $criterias['GROUPS']['table'] = 'glpi_groups';
     $criterias['GROUPS']['field'] = 'completename';
     $criterias['GROUPS']['name'] = sprintf(__('%1$s: %2$s'), __('User'), __('Group'));
     $criterias['GROUPS']['linkfield'] = '';
     $criterias['GROUPS']['type'] = 'dropdown';
     $criterias['GROUPS']['virtual'] = true;
     $criterias['GROUPS']['id'] = 'groups';
     $criterias['KNOWN_DOMAIN']['field'] = 'name';
     $criterias['KNOWN_DOMAIN']['name'] = __('Known mail domain');
     $criterias['KNOWN_DOMAIN']['table'] = 'glpi_entities';
     $criterias['KNOWN_DOMAIN']['type'] = 'yesno';
     $criterias['KNOWN_DOMAIN']['virtual'] = true;
     $criterias['KNOWN_DOMAIN']['id'] = 'entitydatas';
     $criterias['KNOWN_DOMAIN']['allow_condition'] = array(Rule::PATTERN_IS);
     $criterias['PROFILES']['field'] = 'name';
     $criterias['PROFILES']['name'] = __('User featuring the profile');
     $criterias['PROFILES']['table'] = 'glpi_profiles';
     $criterias['PROFILES']['type'] = 'dropdown';
     $criterias['PROFILES']['virtual'] = true;
     $criterias['PROFILES']['id'] = 'profiles';
     $criterias['PROFILES']['allow_condition'] = array(Rule::PATTERN_IS);
     if (Session::isMultiEntitiesMode()) {
         $criterias['UNIQUE_PROFILE']['field'] = 'name';
         $criterias['UNIQUE_PROFILE']['name'] = __('User featuring a single profile');
         $criterias['UNIQUE_PROFILE']['table'] = 'glpi_profiles';
         $criterias['UNIQUE_PROFILE']['type'] = 'dropdown';
         $criterias['UNIQUE_PROFILE']['virtual'] = true;
         $criterias['UNIQUE_PROFILE']['id'] = 'profiles';
         $criterias['UNIQUE_PROFILE']['allow_condition'] = array(Rule::PATTERN_IS);
     }
     $criterias['ONE_PROFILE']['field'] = 'name';
     $criterias['ONE_PROFILE']['name'] = __('User with a single profile');
     $criterias['ONE_PROFILE']['table'] = '';
     $criterias['ONE_PROFILE']['type'] = 'yesonly';
     $criterias['ONE_PROFILE']['virtual'] = true;
     $criterias['ONE_PROFILE']['id'] = 'profiles';
     $criterias['ONE_PROFILE']['allow_condition'] = array(Rule::PATTERN_IS);
     return $criterias;
 }
 /**
  * Print the config form for restrictions
  *
  * @return Nothing (display)
  **/
 function showFormInventory()
 {
     global $DB, $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Assets') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . __('Enable the financial and administrative information by default') . "</td>";
     echo "<td  width='20%'>";
     Dropdown::ShowYesNo('auto_create_infocoms', $CFG_GLPI["auto_create_infocoms"]);
     echo "</td><td width='20%'> " . __('Restrict monitor management') . "</td>";
     echo "<td width='30%'>";
     $this->dropdownGlobalManagement("monitors_management_restrict", $CFG_GLPI["monitors_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Software category deleted by the dictionary rules') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $CFG_GLPI["softwarecategories_id_ondelete"], 'name' => "softwarecategories_id_ondelete"));
     echo "</td><td> " . __('Restrict device management') . "</td><td>";
     $this->dropdownGlobalManagement("peripherals_management_restrict", $CFG_GLPI["peripherals_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Beginning of fiscal year') . "</td><td>";
     Html::showDateField("date_tax", array('value' => $CFG_GLPI["date_tax"], 'maybeempty' => false, 'canedit' => true, 'min' => '', 'max' => '', 'showyear' => false));
     echo "</td><td> " . __('Restrict phone management') . "</td><td>";
     $this->dropdownGlobalManagement("phones_management_restrict", $CFG_GLPI["phones_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Automatic fields (marked by *)') . "</td><td>";
     $tab = array(0 => __('Global'), 1 => __('By entity'));
     Dropdown::showFromArray('use_autoname_by_entity', $tab, array('value' => $CFG_GLPI["use_autoname_by_entity"]));
     echo "</td><td> " . __('Restrict printer management') . "</td><td>";
     $this->dropdownGlobalManagement("printers_management_restrict", $CFG_GLPI["printers_management_restrict"]);
     echo "</td></tr>";
     echo "</table>";
     if (Session::haveRightsOr("transfer", array(CREATE, UPDATE)) && Session::isMultiEntitiesMode()) {
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('Automatic transfer of computers') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Template for the automatic transfer of computers in another entity') . "</td><td>";
         Transfer::dropdown(array('value' => $CFG_GLPI["transfers_id_auto"], 'name' => "transfers_id_auto", 'emptylabel' => __('No automatic transfer')));
         echo "</td></tr>";
         echo "</table>";
     }
     echo "<br><table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='4'>" . __('Automatically update of the elements related to the computers');
     echo "</th><th colspan='2'>" . __('Unit management') . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . __('Alternate username') . "</th>";
     echo "<th>" . __('User') . "</th>";
     echo "<th>" . __('Group') . "</th>";
     echo "<th>" . __('Location') . "</th>";
     echo "<th>" . __('Status') . "</th>";
     echo "</tr>";
     $fields = array("contact", "user", "group", "location");
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When connecting or updating') . "</td>";
     $values[0] = __('Do not copy');
     $values[1] = __('Copy');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoupdate";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoupdate_mode", __('Copy computer status'), $CFG_GLPI["state_autoupdate_mode"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When disconnecting') . "</td>";
     $values[0] = __('Do not delete');
     $values[1] = __('Clear');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoclean";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoclean_mode", __('Clear status'), $CFG_GLPI["state_autoclean_mode"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' class='center'>";
         echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
         echo "</td></tr>";
     }
     echo "</table></div>";
     Html::closeForm();
 }
Ejemplo n.º 12
0
 static function displayBody($data)
 {
     global $CFG_GLPI;
     $computer = new computer();
     $computer->getFromDB($data["id"]);
     $body = "<tr class='tab_bg_2'><td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/computer.form.php?id=" . $computer->fields["id"] . "\">" . $computer->fields["name"];
     if ($_SESSION["glpiis_ids_visible"] == 1 || empty($computer->fields["name"])) {
         $body .= " (";
         $body .= $computer->fields["id"] . ")";
     }
     $body .= "</a></td>";
     if (Session::isMultiEntitiesMode()) {
         $body .= "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "</td>";
     }
     $body .= "<td>" . Dropdown::getDropdownName("glpi_operatingsystems", $computer->fields["operatingsystems_id"]) . "</td>";
     $body .= "<td>" . Dropdown::getDropdownName("glpi_states", $computer->fields["states_id"]) . "</td>";
     $body .= "<td>" . Dropdown::getDropdownName("glpi_locations", $computer->fields["locations_id"]) . "</td>";
     $body .= "<td>";
     if (!empty($computer->fields["users_id"])) {
         $body .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $computer->fields["users_id"] . "\">" . getUserName($computer->fields["users_id"]) . "</a>";
     }
     if (!empty($computer->fields["groups_id"])) {
         $body .= " - <a href=\"" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $computer->fields["groups_id"] . "\">";
     }
     $body .= Dropdown::getDropdownName("glpi_groups", $computer->fields["groups_id"]);
     if ($_SESSION["glpiis_ids_visible"] == 1) {
         $body .= " (";
         $body .= $computer->fields["groups_id"] . ")";
     }
     $body .= "</a>";
     if (!empty($computer->fields["contact"])) {
         $body .= " - " . $computer->fields["contact"];
     }
     $body .= " - </td>";
     $body .= "<td>" . Html::convdatetime($data["last_ocs_update"]) . "</td>";
     $body .= "<td>" . Html::convdatetime($data["last_update"]) . "</td>";
     $body .= "<td>" . Dropdown::getDropdownName("glpi_plugin_ocsinventoryng_ocsservers", $data["plugin_ocsinventoryng_ocsservers_id"]) . "</td>";
     $body .= "</tr>";
     return $body;
 }
Ejemplo n.º 13
0
 /**
  * @see CommonDBTM::getSpecificMassiveActions()
  **/
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if (ProblemTask::canCreate()) {
         $actions['add_task'] = __('Add a new task');
     }
     if (Session::haveRight("edit_all_problem", "1")) {
         $actions['add_actor'] = __('Add an actor');
     }
     if (Session::haveRight('transfer', 'r') && Session::isMultiEntitiesMode() && $isadmin) {
         $actions['add_transfer_list'] = _x('button', 'Add to transfer list');
     }
     return $actions;
 }
Ejemplo n.º 14
0
 /**
  * Print out list recent or popular kb/faq
  *
  * @param $type      type : recent / popular / not published
  *
  * @return nothing (display table)
  **/
 static function showRecentPopular($type)
 {
     global $DB, $CFG_GLPI;
     $faq = !Session::haveRight(self::$rightname, READ);
     if ($type == "recent") {
         $orderby = "ORDER BY `date` DESC";
         $title = __('Recent entries');
     } else {
         if ($type == 'lastupdate') {
             $orderby = "ORDER BY `date_mod` DESC";
             $title = __('Last updated entries');
         } else {
             $orderby = "ORDER BY `view` DESC";
             $title = __('Most popular questions');
         }
     }
     $faq_limit = "";
     $addselect = "";
     // Force all joins for not published to verify no visibility set
     $join = self::addVisibilityJoins(true);
     if (Session::getLoginUserID()) {
         $faq_limit .= "WHERE " . self::addVisibilityRestrict();
     } else {
         // Anonymous access
         if (Session::isMultiEntitiesMode()) {
             $faq_limit .= " WHERE (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n                                   AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')";
         } else {
             $faq_limit .= " WHERE 1";
         }
     }
     // Only published
     $faq_limit .= " AND (`glpi_entities_knowbaseitems`.`entities_id` IS NOT NULL\n                           OR `glpi_knowbaseitems_profiles`.`profiles_id` IS NOT NULL\n                           OR `glpi_groups_knowbaseitems`.`groups_id` IS NOT NULL\n                           OR `glpi_knowbaseitems_users`.`users_id` IS NOT NULL)";
     // Add visibility date
     $faq_limit .= " AND (`glpi_knowbaseitems`.`begin_date` IS NULL\n                           OR `glpi_knowbaseitems`.`begin_date` < NOW())\n                      AND (`glpi_knowbaseitems`.`end_date` IS NULL\n                           OR `glpi_knowbaseitems`.`end_date` > NOW()) ";
     if ($faq) {
         // FAQ
         $faq_limit .= " AND (`glpi_knowbaseitems`.`is_faq` = '1')";
     }
     if (KnowbaseItemTranslation::isKbTranslationActive()) {
         $join .= "LEFT JOIN `glpi_knowbaseitemtranslations`\n                     ON (`glpi_knowbaseitems`.`id` = `glpi_knowbaseitemtranslations`.`knowbaseitems_id`\n                           AND `glpi_knowbaseitemtranslations`.`language` = '" . $_SESSION['glpilanguage'] . "')";
         $addselect .= ", `glpi_knowbaseitemtranslations`.`name` AS transname,\n                          `glpi_knowbaseitemtranslations`.`answer` AS transanswer ";
     }
     $query = "SELECT DISTINCT `glpi_knowbaseitems`.* {$addselect}\n                FROM `glpi_knowbaseitems`\n                {$join}\n                {$faq_limit}\n                {$orderby}\n                LIMIT 10";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($number > 0) {
         echo "<table class='tab_cadrehov'>";
         echo "<tr class='noHover'><th>" . $title . "</th></tr>";
         while ($data = $DB->fetch_assoc($result)) {
             $name = $data['name'];
             if (isset($data['transname']) && !empty($data['transname'])) {
                 $name = $data['transname'];
             }
             echo "<tr class='tab_bg_2'><td class='left'>";
             echo "<a " . ($data['is_faq'] ? " class='pubfaq' title='" . __("This item is part of the FAQ") . "' " : " class='knowbase' ") . " href=\"" . $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\">" . Html::resume_text($name, 80) . "</a></td></tr>";
         }
         echo "</table>";
     }
 }
Ejemplo n.º 15
0
 /**
  * @see CommonDBTM::getSpecificMassiveActions()
  **/
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($isadmin && countElementsInTable("glpi_rules", "sub_type='RuleSoftwareCategory'") > 0) {
         $actions['compute_software_category'] = __('Recalculate the category');
     }
     if (Session::haveRight("rule_dictionnary_software", "w") && countElementsInTable("glpi_rules", "sub_type='RuleDictionnarySoftware'") > 0) {
         $actions['replay_dictionnary'] = __('Replay the dictionary rules');
     }
     if (Session::haveRight('transfer', 'r') && Session::isMultiEntitiesMode() && $isadmin) {
         $actions['add_transfer_list'] = _x('button', 'Add to transfer list');
     }
     return $actions;
 }
Ejemplo n.º 16
0
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         if ($isadmin) {
             if (Session::haveRight('transfer', 'r') && Session::isMultiEntitiesMode()) {
                 $actions['Transfert'] = __('Transfer');
             }
         }
     }
     return $actions;
 }
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if (Session::haveRight('transfer', READ) && Session::isMultiEntitiesMode() && $isadmin) {
         $actions['PluginRacksRack' . MassiveAction::CLASS_ACTION_SEPARATOR . 'transfer'] = __('Transfer');
     }
     return $actions;
 }
Ejemplo n.º 18
0
 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 "&nbsp;<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>&nbsp;";
                 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'>&nbsp;</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 "&nbsp;<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 "&nbsp;<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 "&nbsp;";
         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() . "&amp;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 "&nbsp;";
             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 "&nbsp;";
             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;
 }
Ejemplo n.º 19
0
 /**
  * Generic Function to add default columns to view
  *
  * @param $itemtype device type
  *
  * @return select string
  **/
 static function addDefaultToView($itemtype)
 {
     global $CFG_GLPI;
     $toview = array();
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     // Add first element (name)
     array_push($toview, 1);
     // Add entity view :
     if (Session::isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1)) {
         array_push($toview, 80);
     }
     return $toview;
 }
Ejemplo n.º 20
0
 /**
  * clone of function Ticket::showFormHelpdesk()
  */
 static function getHelpdesk($ID = 0, $ticket_template = false)
 {
     global $DB, $CFG_GLPI;
     // * Added by plugin survey ticket
     $ticket = new Ticket();
     // * End of adding
     if (!Session::haveRight("create_ticket", "1")) {
         return false;
     }
     if (!$ticket_template && (Session::haveRight('validate_incident', 1) || Session::haveRight('validate_request', 1))) {
         $opt = array();
         $opt['reset'] = 'reset';
         $opt['field'][0] = 55;
         // validation status
         $opt['searchtype'][0] = 'equals';
         $opt['contains'][0] = 'waiting';
         $opt['link'][0] = 'AND';
         $opt['field'][1] = 59;
         // validation aprobator
         $opt['searchtype'][1] = 'equals';
         $opt['contains'][1] = Session::getLoginUserID();
         $opt['link'][1] = 'AND';
         $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&amp;');
         if (TicketValidation::getNumberTicketsToValidate(Session::getLoginUserID()) > 0) {
             echo "<a href='{$url_validate}' title=\"" . __s('Ticket waiting for your approval') . "\"\n                   alt=\"" . __s('Ticket waiting for your approval') . "\">" . __('Tickets awaiting approval') . "</a><br><br>";
         }
     }
     $query = "SELECT `realname`, `firstname`, `name`\n                FROM `glpi_users`\n                WHERE `id` = '{$ID}'";
     $result = $DB->query($query);
     $email = UserEmail::getDefaultForUser($ID);
     // Set default values...
     $default_values = array('_users_id_requester_notif' => array('use_notification' => $email == "" ? 0 : 1), 'nodelegate' => 1, '_users_id_requester' => 0, 'name' => '', 'content' => '', 'itilcategories_id' => 0, 'locations_id' => 0, 'urgency' => 3, 'itemtype' => '', 'items_id' => 0, 'entities_id' => $_SESSION['glpiactive_entity'], 'plan' => array(), 'global_validation' => 'none', 'due_date' => 'NULL', 'slas_id' => 0, '_add_validation' => 0, 'type' => Entity::getUsedConfig('tickettype', $_SESSION['glpiactive_entity'], '', Ticket::INCIDENT_TYPE), '_right' => "id");
     // Get default values from posted values on reload form
     if (!$ticket_template) {
         if (isset($_POST)) {
             $values = $_POST;
         }
     }
     // Restore saved value or override with page parameter
     $saved = $ticket->restoreInput();
     foreach ($default_values as $name => $value) {
         if (!isset($values[$name])) {
             if (isset($saved[$name])) {
                 $values[$name] = $saved[$name];
             } else {
                 $values[$name] = $value;
             }
         }
     }
     if (!$ticket_template) {
         echo "<form method='post' name='helpdeskform' action='" . $CFG_GLPI["root_doc"] . "/front/tracking.injector.php' enctype='multipart/form-data'>";
     }
     $delegating = User::getDelegateGroupsForUser($values['entities_id']);
     if (count($delegating)) {
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('This ticket concerns me') . " ";
         $rand = Dropdown::showYesNo("nodelegate", $values['nodelegate']);
         $params = array('nodelegate' => '__VALUE__', 'rand' => $rand, 'right' => "delegate", '_users_id_requester' => $values['_users_id_requester'], '_users_id_requester_notif' => $values['_users_id_requester_notif'], 'use_notification' => $values['_users_id_requester_notif']['use_notification'], 'entity_restrict' => $_SESSION["glpiactive_entity"]);
         Ajax::UpdateItemOnSelectEvent("dropdown_nodelegate" . $rand, "show_result" . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownDelegationUsers.php", $params);
         if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
             echo "</th><th>" . __('Check your personnal information');
         }
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td colspan='2' class='center'>";
         echo "<div id='show_result{$rand}'>";
         $self = new Ticket();
         if ($values["_users_id_requester"] == 0) {
             $values['_users_id_requester'] = Session::getLoginUserID();
         } else {
             $values['_right'] = "delegate";
         }
         $self->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $values);
         echo "</div>";
         if ($CFG_GLPI['use_check_pref'] && $values['nodelegate']) {
             echo "</td><td class='center'>";
             User::showPersonalInformation(Session::getLoginUserID());
         }
         echo "</td></tr>";
         echo "</table></div>";
         echo "<input type='hidden' name='_users_id_recipient' value='" . Session::getLoginUserID() . "'>";
     } else {
         // User as requester
         $values['_users_id_requester'] = Session::getLoginUserID();
         if ($CFG_GLPI['use_check_pref']) {
             echo "<div class='center'><table class='tab_cadre_fixe'>";
             echo "<tr><th>" . __('Check your personnal information') . "</th></tr>";
             echo "<tr class='tab_bg_1'><td class='center'>";
             User::showPersonalInformation(Session::getLoginUserID());
             echo "</td></tr>";
             echo "</table></div>";
         }
     }
     echo "<input type='hidden' name='_from_helpdesk' value='1'>";
     echo "<input type='hidden' name='requesttypes_id' value='" . RequestType::getDefault('helpdesk') . "'>";
     // Load ticket template if available :
     $tt = $ticket->getTicketTemplateToUse($ticket_template, $values['type'], $values['itilcategories_id'], $_SESSION["glpiactive_entity"]);
     // Predefined fields from template : reset them
     if (isset($values['_predefined_fields'])) {
         $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
     } else {
         $values['_predefined_fields'] = array();
     }
     // Store predefined fields to be able not to take into account on change template
     $predefined_fields = array();
     if (isset($tt->predefined) && count($tt->predefined)) {
         foreach ($tt->predefined as $predeffield => $predefvalue) {
             if (isset($values[$predeffield]) && isset($default_values[$predeffield])) {
                 // Is always default value : not set
                 // Set if already predefined field
                 // Set if ticket template change
                 if ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) {
                     $values[$predeffield] = $predefvalue;
                     $predefined_fields[$predeffield] = $predefvalue;
                 }
             } else {
                 // Not defined options set as hidden field
                 echo "<input type='hidden' name='{$predeffield}' value='{$predefvalue}'>";
             }
         }
     } else {
         // No template load : reset predefined values
         if (count($values['_predefined_fields'])) {
             foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
                 if ($values[$predeffield] == $predefvalue) {
                     $values[$predeffield] = $default_values[$predeffield];
                 }
             }
         }
     }
     if ($CFG_GLPI['urgency_mask'] == 1 << 3 || $tt->isHiddenField('urgency')) {
         // Dont show dropdown if only 1 value enabled or field is hidden
         echo "<input type='hidden' name='urgency' value='" . $values['urgency'] . "'>";
     }
     // Display predefined fields if hidden
     if ($tt->isHiddenField('itemtype')) {
         echo "<input type='hidden' name='itemtype' value='" . $values['itemtype'] . "'>";
         echo "<input type='hidden' name='items_id' value='" . $values['items_id'] . "'>";
     }
     if ($tt->isHiddenField('locations_id')) {
         echo "<input type='hidden' name='locations_id' value='" . $values['locations_id'] . "'>";
     }
     echo "<input type='hidden' name='entities_id' value='" . $_SESSION["glpiactive_entity"] . "'>";
     echo "<div class='center'><table class='tab_cadre_fixe'>";
     echo "<tr><th>" . __('Describe the incident or request') . "</th><th>";
     if (Session::isMultiEntitiesMode()) {
         echo "(" . Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]) . ")";
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</td>";
     echo "<td>";
     Ticket::dropdownType('type', array('value' => $values['type'], 'on_change' => 'submit()'));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</td>";
     echo "<td>";
     $condition = "`is_helpdeskvisible`='1'";
     switch ($values['type']) {
         case Ticket::DEMAND_TYPE:
             $condition .= " AND `is_request`='1'";
             break;
         default:
             // Ticket::INCIDENT_TYPE :
             $condition .= " AND `is_incident`='1'";
     }
     $opt = array('value' => $values['itilcategories_id'], 'condition' => $condition, 'on_change' => 'submit()');
     if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
         $opt['display_emptychoice'] = false;
     }
     ITILCategory::dropdown($opt);
     echo "</td></tr>";
     if ($CFG_GLPI['urgency_mask'] != 1 << 3) {
         if (!$tt->isHiddenField('urgency')) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . sprintf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')) . "</td>";
             echo "<td>";
             Ticket::dropdownUrgency(array('value' => $values["urgency"]));
             echo "</td></tr>";
         }
     }
     if (empty($delegating) && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Inform me about the actions taken') . "</td>";
         echo "<td>";
         if ($values["_users_id_requester"] == 0) {
             $values['_users_id_requester'] = Session::getLoginUserID();
         }
         $_POST['value'] = $values['_users_id_requester'];
         $_POST['field'] = '_users_id_requester_notif';
         $_POST['use_notification'] = $values['_users_id_requester_notif']['use_notification'];
         include GLPI_ROOT . "/ajax/uemailUpdate.php";
         echo "</td></tr>";
     }
     if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) {
         if (!$tt->isHiddenField('itemtype')) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . sprintf(__('%1$s%2$s'), __('Hardware type'), $tt->getMandatoryMark('itemtype')) . "</td>";
             echo "<td>";
             Ticket::dropdownMyDevices($values['_users_id_requester'], $_SESSION["glpiactive_entity"], $values['itemtype'], $values['items_id']);
             Ticket::dropdownAllDevices("itemtype", $values['itemtype'], $values['items_id'], 0, $values['_users_id_requester'], $_SESSION["glpiactive_entity"]);
             echo "<span id='item_ticket_selection_information'></span>";
             echo "</td></tr>";
         }
     }
     if (!$tt->isHiddenField('locations_id')) {
         echo "<tr class='tab_bg_1'><td>";
         printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
         echo "</td><td>";
         Location::dropdown(array('value' => $values["locations_id"]));
         echo "</td></tr>";
     }
     if (!$tt->isHiddenField('name') || $tt->isPredefinedField('name')) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . sprintf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')) . "</td>";
         echo "<td><input type='text' maxlength='250' size='80' name='name'\n                    value=\"" . $values['name'] . "\"></td></tr>";
     }
     if (!$tt->isHiddenField('content') || $tt->isPredefinedField('content')) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . sprintf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')) . "</td>";
         // * Changed by plugin surveyticket
         // * Added by plugin surveyticket
         $psTicketTemplate = new PluginSurveyticketTicketTemplate();
         $psSurvey = new PluginSurveyticketSurvey();
         $plugin_surveyticket_surveys_id = 0;
         $a_tickettemplates = current($psTicketTemplate->find("`tickettemplates_id`='" . $tt->fields['id'] . "'\n                                                      AND `type`='" . $values['type'] . "'\n                                                      AND `is_helpdesk`='1'"));
         if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) {
             echo "<td>";
             $psSurvey = new PluginSurveyticketSurvey();
             $psSurvey->getFromDB($a_tickettemplates['plugin_surveyticket_surveys_id']);
             if ($psSurvey->fields['is_active'] == 1) {
                 $plugin_surveyticket_surveys_id = $a_tickettemplates['plugin_surveyticket_surveys_id'];
                 $psSurvey = new PluginSurveyticketSurvey();
                 $psSurvey->startSurvey($plugin_surveyticket_surveys_id);
             }
         } else {
             echo "<td><textarea name='content' cols='80' rows='14'>" . $values['content'] . "</textarea>";
         }
         // * End of change
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s (%2$s)'), __('File'), Document::getMaxUploadSize());
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt='" . __s('Help') . "' onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
     echo "&nbsp;";
     Ticket::showDocumentAddButton(60);
     echo "</td>";
     echo "<td><div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
     echo "</td></tr>";
     if (!$ticket_template) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         if ($tt->isField('id') && $tt->fields['id'] > 0) {
             echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
             echo "<input type='hidden' name='_predefined_fields'\n                   value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
         }
         echo "<input type='submit' name='add' value=\"" . __s('Submit message') . "\" class='submit'>";
         echo "</td></tr>";
     }
     echo "</table></div>";
     if (!$ticket_template) {
         Html::closeForm();
     }
 }
Ejemplo n.º 21
0
 function getSpecificMassiveActions($checkitem = NULL)
 {
     $isadmin = static::canUpdate();
     $actions = parent::getSpecificMassiveActions($checkitem);
     if ($isadmin) {
         $actions['Install'] = __('Associate');
         $actions['Desinstall'] = __('Dissociate');
         $actions['Duplicate'] = __('Duplicate', 'resources');
         if (Session::haveRight('transfer', 'r') && Session::isMultiEntitiesMode()) {
             $actions['Transfert'] = __('Transfer');
         }
     }
     return $actions;
 }
Ejemplo n.º 22
0
                $first = true;
                foreach ($_POST["annee"] as $key2 => $val2) {
                    if (!$first) {
                        $query[$val] .= " OR ";
                    } else {
                        $first = false;
                    }
                    $query[$val] .= " YEAR(`glpi_infocoms`.`buy_date`) = '{$val2}'\n                                OR YEAR(`glpi_contracts`.`begin_date`) = '{$val2}'";
                }
                $query[$val] .= ")";
            }
            $query[$val] .= " ORDER BY entname ASC, itemdeleted DESC, itemname ASC";
        }
    }
}
$display_entity = Session::isMultiEntitiesMode();
if (isset($query) && count($query)) {
    foreach ($query as $key => $val) {
        $result = $DB->query($val);
        if ($result && $DB->numrows($result)) {
            $item = new $key();
            echo "<span class='b'>" . $item->getTypeName(1) . "</span>";
            echo "<table class='tab_cadre_report'>";
            echo "<tr><th>" . __('Name') . "</th>";
            echo "<th>" . __('Deleted') . "</th>";
            if ($display_entity) {
                echo "<th>" . __('Entity') . "</th>";
            }
            echo "<th>" . __('Location') . "</th>";
            echo "<th>" . __('Date of purchase') . "</th>";
            echo "<th>" . __('Warranty expiration date') . "</th>";
Ejemplo n.º 23
0
 /**
  * Print the form used to select profile if several are available
  *
  * @param $target target of the form
  *
  * @return nothing
  **/
 static function showProfileSelecter($target)
 {
     global $CFG_GLPI;
     if (count($_SESSION["glpiprofiles"]) > 1) {
         echo '<li class="profile-selector"><form name="form" method="post" action="' . $target . '">';
         $values = array();
         foreach ($_SESSION["glpiprofiles"] as $key => $val) {
             $values[$key] = $val['name'];
         }
         Dropdown::showFromArray('newprofile', $values, array('value' => $_SESSION["glpiactiveprofile"]["id"], 'width' => '150px', 'on_change' => 'submit()'));
         Html::closeForm();
         echo '</li>';
     }
     if (Session::isMultiEntitiesMode()) {
         echo "<li class='profile-selector'>";
         Ajax::createModalWindow('entity_window', $CFG_GLPI['root_doc'] . "/ajax/entitytree.php", array('title' => __('Select the desired entity'), 'extraparams' => array('target' => $target)));
         echo "<a onclick='entity_window.dialog(\"open\");' href='#modal_entity_content' title=\"" . addslashes($_SESSION["glpiactive_entity_name"]) . "\" class='entity_select' id='global_entity_select'>" . $_SESSION["glpiactive_entity_shortname"] . "</a>";
         echo "</li>";
     }
 }
Ejemplo n.º 24
0
 /**
  * @param $authldap  AuthLDAP object
  **/
 static function showUserImportForm(AuthLDAP $authldap)
 {
     global $DB;
     //Get data related to entity (directory and ldap filter)
     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
     echo "<div class='center'>";
     echo "<form method='post' action='" . $_SERVER['PHP_SELF'] . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4' class='middle'><div class='relative'>";
     echo "<span>" . ($_SESSION['ldap_import']['mode'] ? __('Synchronizing already imported users') : __('Import new users'));
     // Expert interface allow user to override configuration.
     // If not coming from the ticket form, then give expert/simple link
     if ((Config::canUpdate() || Entity::canUpdate()) && !isset($_SESSION['ldap_import']['no_expert_mode'])) {
         echo "</span>&nbsp;<span class='floatright'><a href='" . $_SERVER['PHP_SELF'] . "?action=" . $_SESSION['ldap_import']['action'] . "&amp;mode=" . $_SESSION['ldap_import']['mode'];
         if ($_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE) {
             echo "&amp;interface=" . self::EXPERT_INTERFACE . "'>" . __('Expert mode') . "</a>";
         } else {
             echo "&amp;interface=" . self::SIMPLE_INTERFACE . "'>" . __('Simple mode') . "</a>";
         }
     } else {
         $_SESSION['ldap_import']['interface'] = self::SIMPLE_INTERFACE;
     }
     echo "</span></div>";
     echo "</th></tr>";
     switch ($_SESSION['ldap_import']['interface']) {
         case self::EXPERT_INTERFACE:
             //If more than one directory configured
             //Display dropdown ldap servers
             if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
                 if (self::getNumberOfServers() > 1) {
                     echo "<tr class='tab_bg_2'><td>" . __('LDAP directory choice') . "</td>";
                     echo "<td colspan='3'>";
                     self::dropdown(array('name' => 'authldaps_id', 'value' => $_SESSION['ldap_import']['authldaps_id'], 'condition' => "`is_active` = '1'", 'display_emptychoice' => false));
                     echo "&nbsp;<input class='submit' type='submit' name='change_directory'\n                        value=\"" . _sx('button', 'To change') . "\">";
                     echo "</td></tr>";
                 }
                 echo "<tr class='tab_bg_2'><td>" . __('BaseDN') . "</td><td colspan='3'>";
                 echo "<input type='text' class='form-control' name='basedn' value=\"" . $_SESSION['ldap_import']['basedn'] . "\" size='90' " . (!$_SESSION['ldap_import']['basedn'] ? "disabled" : "") . ">";
                 echo "</td></tr>";
                 echo "<tr class='tab_bg_2'><td>" . __('Search filter for users') . "</td><td colspan='3'>";
                 echo "<input type='text' class='form-control' name='ldap_filter' value=\"" . $_SESSION['ldap_import']['ldap_filter'] . "\" size='90'>";
                 echo "</td></tr>";
             }
             break;
             //case self::SIMPLE_INTERFACE :
         //case self::SIMPLE_INTERFACE :
         default:
             //If multi-entity mode and more than one entity visible
             //else no need to select entity
             if (Session::isMultiEntitiesMode() && count($_SESSION['glpiactiveentities']) > 1) {
                 echo "<tr class='tab_bg_2'><td>" . __('Select the desired entity') . "</td>" . "<td colspan='3'>";
                 Entity::dropdown(array('value' => $_SESSION['ldap_import']['entities_id'], 'entity' => $_SESSION['glpiactiveentities'], 'on_change' => 'submit()'));
                 echo "</td></tr>";
             } else {
                 //Only one entity is active, store it
                 echo "<tr><td><input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'></td></tr>";
             }
             if (isset($_SESSION['ldap_import']['begin_date']) && !empty($_SESSION['ldap_import']['begin_date']) || isset($_SESSION['ldap_import']['end_date']) && !empty($_SESSION['ldap_import']['end_date'])) {
                 $enabled = 1;
             } else {
                 $enabled = 0;
             }
             Dropdown::showAdvanceDateRestrictionSwitch($enabled);
             echo "<table class='tab_cadre_fixe'>";
             if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
                 $field_counter = 0;
                 $fields = array('login_field' => __('Login'), 'email1_field' => __('Email'), 'email2_field' => sprintf(__('%1$s %2$s'), _n('Email', 'Emails', 1), '2'), 'email3_field' => sprintf(__('%1$s %2$s'), _n('Email', 'Emails', 1), '3'), 'email4_field' => sprintf(__('%1$s %2$s'), _n('Email', 'Emails', 1), '4'), 'realname_field' => __('Surname'), 'firstname_field' => __('First name'), 'phone_field' => __('Phone'), 'phone2_field' => __('Phone 2'), 'mobile_field' => __('Mobile phone'), 'title_field' => _x('person', 'Title'), 'category_field' => __('Category'), 'picture_field' => __('Picture'));
                 $available_fields = array();
                 foreach ($fields as $field => $label) {
                     if (isset($authldap->fields[$field]) && $authldap->fields[$field] != '') {
                         $available_fields[$field] = $label;
                     }
                 }
                 echo "<tr><th colspan='4'>" . __('Search criteria for users') . "</th></tr>";
                 foreach ($available_fields as $field => $label) {
                     if ($field_counter == 0) {
                         echo "<tr class='tab_bg_1'>";
                     }
                     echo "<td>{$label}</td><td>";
                     $field_counter++;
                     echo "<input type='text' class='form-control' name='criterias[{$field}]' value='" . (isset($_SESSION['ldap_import']['criterias'][$field]) ? $_SESSION['ldap_import']['criterias'][$field] : '') . "'>";
                     echo "</td>";
                     if ($field_counter == 2) {
                         echo "</tr>";
                         $field_counter = 0;
                     }
                 }
                 if ($field_counter > 0) {
                     while ($field_counter < 2) {
                         echo "<td colspan='2'></td>";
                         $field_counter++;
                     }
                     $field_counter = 0;
                     echo "</tr>";
                 }
             }
             break;
     }
     if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
         if ($_SESSION['ldap_import']['authldaps_id']) {
             echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
             echo "<input class='submit' type='submit' name='search' value=\"" . _sx('button', 'Search') . "\">";
             echo "</td></tr>";
         } else {
             echo "<tr class='tab_bg_2'><" . "td colspan='4' class='center'>" . __('No directory selected') . "</td></tr>";
         }
     } else {
         echo "<tr class='tab_bg_2'><td colspan='4' class='center'>" . __('No directory associated to entity: impossible search') . "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Ejemplo n.º 25
0
 function getSearchOptions()
 {
     $tab = array();
     $tab['common'] = __('Characteristics');
     $tab[1]['table'] = $this->getTable();
     $tab[1]['field'] = 'name';
     $tab[1]['name'] = __('Name');
     $tab[1]['datatype'] = 'itemlink';
     $tab[1]['massiveaction'] = false;
     $tab[19]['table'] = $this->getTable();
     $tab[19]['field'] = 'date_mod';
     $tab[19]['name'] = __('Last update');
     $tab[19]['datatype'] = 'datetime';
     $tab[19]['massiveaction'] = false;
     $tab[121]['table'] = $this->getTable();
     $tab[121]['field'] = 'date_creation';
     $tab[121]['name'] = __('Creation date');
     $tab[121]['datatype'] = 'datetime';
     $tab[121]['massiveaction'] = false;
     $tab[2]['table'] = $this->getTable();
     $tab[2]['field'] = 'interface';
     $tab[2]['name'] = __("Profile's interface");
     $tab[2]['massiveaction'] = false;
     $tab[2]['datatype'] = 'specific';
     $tab[2]['searchtype'] = array('equals', 'notequals');
     $tab[3]['table'] = $this->getTable();
     $tab[3]['field'] = 'is_default';
     $tab[3]['name'] = __('Default profile');
     $tab[3]['datatype'] = 'bool';
     $tab[3]['massiveaction'] = false;
     $tab[118]['table'] = $this->getTable();
     $tab[118]['field'] = 'create_ticket_on_login';
     $tab[118]['name'] = __('Ticket creation form on login');
     $tab[118]['datatype'] = 'bool';
     $tab[16]['table'] = $this->getTable();
     $tab[16]['field'] = 'comment';
     $tab[16]['name'] = __('Comments');
     $tab[16]['datatype'] = 'text';
     // add objectlock search options
     $tab += ObjectLock::getSearchOptionsToAdd(get_class($this));
     $tab['inventory'] = __('Assets');
     $tab[20]['table'] = 'glpi_profilerights';
     $tab[20]['field'] = 'rights';
     $tab[20]['name'] = _n('Computer', 'Computers', Session::getPluralNumber());
     $tab[20]['datatype'] = 'right';
     $tab[20]['rightclass'] = 'Computer';
     $tab[20]['rightname'] = 'computer';
     $tab[20]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'computer'");
     $tab[21]['table'] = 'glpi_profilerights';
     $tab[21]['field'] = 'rights';
     $tab[21]['name'] = _n('Monitor', 'Monitors', Session::getPluralNumber());
     $tab[21]['datatype'] = 'right';
     $tab[21]['rightclass'] = 'Monitor';
     $tab[21]['rightname'] = 'monitor';
     $tab[21]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'monitor'");
     $tab[22]['table'] = 'glpi_profilerights';
     $tab[22]['field'] = 'rights';
     $tab[22]['name'] = _n('Software', 'Software', Session::getPluralNumber());
     $tab[22]['datatype'] = 'right';
     $tab[22]['rightclass'] = 'Software';
     $tab[22]['rightname'] = 'software';
     $tab[22]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'software'");
     $tab[23]['table'] = 'glpi_profilerights';
     $tab[23]['field'] = 'rights';
     $tab[23]['name'] = _n('Network', 'Networks', Session::getPluralNumber());
     $tab[23]['datatype'] = 'right';
     $tab[23]['rightclass'] = 'Network';
     $tab[23]['rightname'] = 'networking';
     $tab[23]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'networking'");
     $tab[24]['table'] = 'glpi_profilerights';
     $tab[24]['field'] = 'rights';
     $tab[24]['name'] = _n('Printer', 'Printers', Session::getPluralNumber());
     $tab[24]['datatype'] = 'right';
     $tab[24]['rightclass'] = 'Printer';
     $tab[24]['rightname'] = 'printer';
     $tab[24]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'printer'");
     $tab[25]['table'] = 'glpi_profilerights';
     $tab[25]['field'] = 'rights';
     $tab[25]['name'] = _n('Device', 'Devices', Session::getPluralNumber());
     $tab[25]['datatype'] = 'right';
     $tab[25]['rightclass'] = 'Peripheral';
     $tab[25]['rightname'] = 'peripheral';
     $tab[25]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'peripheral'");
     $tab[26]['table'] = 'glpi_profilerights';
     $tab[26]['field'] = 'rights';
     $tab[26]['name'] = _n('Cartridge', 'Cartridges', Session::getPluralNumber());
     $tab[26]['datatype'] = 'right';
     $tab[26]['rightclass'] = 'Cartridge';
     $tab[26]['rightname'] = 'cartridge';
     $tab[26]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'cartridge'");
     $tab[27]['table'] = 'glpi_profilerights';
     $tab[27]['field'] = 'rights';
     $tab[27]['name'] = _n('Consumable', 'Consumables', Session::getPluralNumber());
     $tab[27]['datatype'] = 'right';
     $tab[27]['rightclass'] = 'Consumable';
     $tab[27]['rightname'] = 'consumable';
     $tab[27]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'consumable'");
     $tab[28]['table'] = 'glpi_profilerights';
     $tab[28]['field'] = 'rights';
     $tab[28]['name'] = _n('Phone', 'Phones', Session::getPluralNumber());
     $tab[28]['datatype'] = 'right';
     $tab[28]['rightclass'] = 'Phone';
     $tab[28]['rightname'] = 'phone';
     $tab[28]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'phone'");
     $tab[129]['table'] = 'glpi_profilerights';
     $tab[129]['field'] = 'rights';
     $tab[129]['name'] = __('Internet');
     $tab[129]['datatype'] = 'right';
     $tab[129]['rightclass'] = 'NetworkName';
     $tab[129]['rightname'] = 'internet';
     $tab[129]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'internet'");
     $tab['management'] = __('Management');
     $tab[30]['table'] = 'glpi_profilerights';
     $tab[30]['field'] = 'rights';
     $tab[30]['name'] = __('Contact') . " / " . __('Supplier');
     $tab[30]['datatype'] = 'right';
     $tab[30]['rightclass'] = 'Contact';
     $tab[30]['rightname'] = 'contact_entreprise';
     $tab[30]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'contact_enterprise'");
     $tab[31]['table'] = 'glpi_profilerights';
     $tab[31]['field'] = 'rights';
     $tab[31]['name'] = _n('Document', 'Documents', Session::getPluralNumber());
     $tab[31]['datatype'] = 'right';
     $tab[31]['rightclass'] = 'Document';
     $tab[31]['rightname'] = 'document';
     $tab[31]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'document'");
     $tab[32]['table'] = 'glpi_profilerights';
     $tab[32]['field'] = 'rights';
     $tab[32]['name'] = _n('Contract', 'Contracts', Session::getPluralNumber());
     $tab[32]['datatype'] = 'right';
     $tab[32]['rightclass'] = 'Contract';
     $tab[32]['rightname'] = 'contract';
     $tab[32]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'contract'");
     $tab[33]['table'] = 'glpi_profilerights';
     $tab[33]['field'] = 'rights';
     $tab[33]['name'] = __('Financial and administratives information');
     $tab[33]['datatype'] = 'right';
     $tab[33]['rightclass'] = 'Infocom';
     $tab[33]['rightname'] = 'infocom';
     $tab[33]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'infocom'");
     $tab[101]['table'] = 'glpi_profilerights';
     $tab[101]['field'] = 'rights';
     $tab[101]['name'] = __('Budget');
     $tab[101]['datatype'] = 'right';
     $tab[101]['rightclass'] = 'Budget';
     $tab[101]['rightname'] = 'budget';
     $tab[101]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'budget'");
     $tab['tools'] = __('Tools');
     $tab[34]['table'] = 'glpi_profilerights';
     $tab[34]['field'] = 'rights';
     $tab[34]['name'] = __('Knowledge base');
     $tab[34]['datatype'] = 'right';
     $tab[34]['rightclass'] = 'KnowbaseItem';
     $tab[34]['rightname'] = 'knowbase';
     $tab[34]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'knowbase'");
     $tab[36]['table'] = 'glpi_profilerights';
     $tab[36]['field'] = 'rights';
     $tab[36]['name'] = _n('Reservation', 'Reservations', Session::getPluralNumber());
     $tab[36]['datatype'] = 'right';
     $tab[36]['rightclass'] = 'ReservationItem';
     $tab[36]['rightname'] = 'reservation';
     $tab[36]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'reservation'");
     $tab[38]['table'] = 'glpi_profilerights';
     $tab[38]['field'] = 'rights';
     $tab[38]['name'] = _n('Report', 'Reports', Session::getPluralNumber());
     $tab[38]['datatype'] = 'right';
     $tab[38]['rightclass'] = 'Report';
     $tab[38]['rightname'] = 'reports';
     $tab[38]['nowrite'] = true;
     $tab[38]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'reports'");
     $tab['config'] = __('Setup');
     $tab[42]['table'] = 'glpi_profilerights';
     $tab[42]['field'] = 'rights';
     $tab[42]['name'] = _n('Dropdown', 'Dropdowns', Session::getPluralNumber());
     $tab[42]['datatype'] = 'right';
     $tab[42]['rightclass'] = 'DropdownTranslation';
     $tab[42]['rightname'] = 'dropdown';
     $tab[42]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'dropdown'");
     $tab[44]['table'] = 'glpi_profilerights';
     $tab[44]['field'] = 'rights';
     $tab[44]['name'] = _n('Component', 'Components', Session::getPluralNumber());
     $tab[44]['datatype'] = 'right';
     $tab[44]['rightclass'] = 'Item_Devices';
     $tab[44]['rightname'] = 'device';
     $tab[44]['noread'] = true;
     $tab[44]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'device'");
     $tab[106]['table'] = 'glpi_profilerights';
     $tab[106]['field'] = 'rights';
     $tab[106]['name'] = _n('Notification', 'Notifications', Session::getPluralNumber());
     $tab[106]['datatype'] = 'right';
     $tab[106]['rightclass'] = 'Notification';
     $tab[106]['rightname'] = 'notification';
     $tab[106]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'notification'");
     $tab[45]['table'] = 'glpi_profilerights';
     $tab[45]['field'] = 'rights';
     $tab[45]['name'] = __('Document type');
     $tab[45]['datatype'] = 'right';
     $tab[45]['rightclass'] = 'DocumentType';
     $tab[45]['rightname'] = 'typedoc';
     $tab[45]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'typedoc'");
     $tab[46]['table'] = 'glpi_profilerights';
     $tab[46]['field'] = 'rights';
     $tab[46]['name'] = _n('External link', 'External links', Session::getPluralNumber());
     $tab[46]['datatype'] = 'right';
     $tab[46]['rightclass'] = 'Link';
     $tab[46]['rightname'] = 'link';
     $tab[46]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'link'");
     $tab[47]['table'] = 'glpi_profilerights';
     $tab[47]['field'] = 'rights';
     $tab[47]['name'] = __('General setup');
     $tab[47]['datatype'] = 'right';
     $tab[47]['rightclass'] = 'Config';
     $tab[47]['rightname'] = 'config';
     $tab[47]['noread'] = true;
     $tab[47]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'config'");
     $tab[52]['table'] = 'glpi_profilerights';
     $tab[52]['field'] = 'rights';
     $tab[52]['name'] = __('Search result user display');
     $tab[52]['datatype'] = 'right';
     $tab[52]['rightclass'] = 'DisplayPreference';
     $tab[52]['rightname'] = 'search_config';
     $tab[52]['noread'] = true;
     $tab[52]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'search_config'");
     $tab[107]['table'] = 'glpi_profilerights';
     $tab[107]['field'] = 'rights';
     $tab[107]['name'] = _n('Calendar', 'Calendars', Session::getPluralNumber());
     $tab[107]['datatype'] = 'right';
     $tab[107]['rightclass'] = 'Calendar';
     $tab[107]['rightname'] = 'calendar';
     $tab[107]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'calendar'");
     $tab['admin'] = __('Administration');
     $tab[48]['table'] = 'glpi_profilerights';
     $tab[48]['field'] = 'rights';
     $tab[48]['name'] = __('Business rules for tickets');
     $tab[48]['datatype'] = 'right';
     $tab[48]['rightclass'] = 'RuleTicket';
     $tab[48]['rightname'] = 'rule_ticket';
     $tab[48]['nowrite'] = true;
     $tab[48]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_ticket'");
     $tab[105]['table'] = 'glpi_profilerights';
     $tab[105]['field'] = 'rights';
     $tab[105]['name'] = __('Rules for assigning a ticket created through a mails receiver');
     $tab[105]['datatype'] = 'right';
     $tab[105]['rightclass'] = 'RuleMailCollector';
     $tab[105]['rightname'] = 'rule_mailcollector';
     $tab[105]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_mailcollector'");
     $tab[49]['table'] = 'glpi_profilerights';
     $tab[49]['field'] = 'rights';
     $tab[49]['name'] = __('Rules for assigning a computer to an entity');
     $tab[49]['datatype'] = 'right';
     $tab[49]['rightclass'] = 'RuleImportComputer';
     $tab[49]['rightname'] = 'rule_import';
     $tab[49]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_import'");
     $tab[50]['table'] = 'glpi_profilerights';
     $tab[50]['field'] = 'rights';
     $tab[50]['name'] = __('Authorizations assignment rules');
     $tab[50]['datatype'] = 'right';
     $tab[50]['rightclass'] = 'Rule';
     $tab[50]['rightname'] = 'rule_ldap';
     $tab[50]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_ldap'");
     $tab[51]['table'] = 'glpi_profilerights';
     $tab[51]['field'] = 'rights';
     $tab[51]['name'] = __('Rules for assigning a category to a software');
     $tab[51]['datatype'] = 'right';
     $tab[51]['rightclass'] = 'RuleSoftwareCategory';
     $tab[51]['rightname'] = 'rule_softwarecategories';
     $tab[51]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_softwarecategories'");
     $tab[90]['table'] = 'glpi_profilerights';
     $tab[90]['field'] = 'rights';
     $tab[90]['name'] = __('Software dictionary');
     $tab[90]['datatype'] = 'right';
     $tab[90]['rightclass'] = 'RuleDictionnarySoftware';
     $tab[90]['rightname'] = 'rule_dictionnary_software';
     $tab[90]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_dictionnary_software'");
     $tab[91]['table'] = 'glpi_profilerights';
     $tab[91]['field'] = 'rights';
     $tab[91]['name'] = __('Dropdowns dictionary');
     $tab[91]['datatype'] = 'right';
     $tab[91]['rightclass'] = 'RuleDictionnaryDropdown';
     $tab[91]['rightname'] = 'rule_dictionnary_dropdown';
     $tab[91]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rule_dictionnary_dropdown'");
     $tab[55]['table'] = 'glpi_profilerights';
     $tab[55]['field'] = 'rights';
     $tab[55]['name'] = self::getTypeName(Session::getPluralNumber());
     $tab[55]['datatype'] = 'right';
     $tab[55]['rightclass'] = 'Profile';
     $tab[55]['rightname'] = 'profile';
     $tab[55]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'profile'");
     $tab[56]['table'] = 'glpi_profilerights';
     $tab[56]['field'] = 'rights';
     $tab[56]['name'] = _n('User', 'Users', Session::getPluralNumber());
     $tab[56]['datatype'] = 'right';
     $tab[56]['rightclass'] = 'User';
     $tab[56]['rightname'] = 'user';
     $tab[56]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'user'");
     $tab[58]['table'] = 'glpi_profilerights';
     $tab[58]['field'] = 'rights';
     $tab[58]['name'] = _n('Group', 'Groups', Session::getPluralNumber());
     $tab[58]['datatype'] = 'right';
     $tab[58]['rightclass'] = 'Group';
     $tab[58]['rightname'] = 'group';
     $tab[58]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'group'");
     $tab[59]['table'] = 'glpi_profilerights';
     $tab[59]['field'] = 'rights';
     $tab[59]['name'] = _n('Entity', 'Entities', Session::getPluralNumber());
     $tab[59]['datatype'] = 'right';
     $tab[59]['rightclass'] = 'Entity';
     $tab[59]['rightname'] = 'entity';
     $tab[59]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'entity'");
     $tab[60]['table'] = 'glpi_profilerights';
     $tab[60]['field'] = 'rights';
     $tab[60]['name'] = __('Transfer');
     $tab[60]['datatype'] = 'right';
     $tab[60]['rightclass'] = 'Transfer';
     $tab[60]['rightname'] = 'transfer';
     $tab[60]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'transfer'");
     $tab[61]['table'] = 'glpi_profilerights';
     $tab[61]['field'] = 'rights';
     $tab[61]['name'] = _n('Log', 'Logs', Session::getPluralNumber());
     $tab[61]['datatype'] = 'right';
     $tab[61]['rightclass'] = 'Log';
     $tab[61]['rightname'] = 'logs';
     $tab[61]['nowrite'] = true;
     $tab[61]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'logs'");
     $tab[62]['table'] = 'glpi_profilerights';
     $tab[62]['field'] = 'rights';
     $tab[62]['name'] = __('Maintenance');
     $tab[62]['datatype'] = 'right';
     $tab[62]['rightclass'] = 'Backup';
     $tab[62]['rightname'] = 'backup';
     $tab[62]['noread'] = true;
     $tab[62]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'backup'");
     $tab['ticket'] = __('Assistance');
     $tab[102]['table'] = 'glpi_profilerights';
     $tab[102]['field'] = 'rights';
     $tab[102]['name'] = __('Create a ticket');
     $tab[102]['datatype'] = 'right';
     $tab[102]['rightclass'] = 'Ticket';
     $tab[102]['rightname'] = 'ticket';
     $tab[102]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'ticket'");
     $tab[108]['table'] = 'glpi_tickettemplates';
     $tab[108]['field'] = 'name';
     $tab[108]['name'] = __('Default ticket template');
     $tab[108]['datatype'] = 'dropdown';
     if (Session::isMultiEntitiesMode()) {
         $tab[108]['condition'] = '`entities_id` = 0 AND `is_recursive`';
     } else {
         $tab[108]['condition'] = '`entities_id` = 0';
     }
     $tab[103]['table'] = 'glpi_profilerights';
     $tab[103]['field'] = 'rights';
     $tab[103]['name'] = _n('Ticket template', 'Ticket templates', Session::getPluralNumber());
     $tab[103]['datatype'] = 'right';
     $tab[103]['rightclass'] = 'TicketTemplate';
     $tab[103]['rightname'] = 'tickettemplate';
     $tab[103]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'tickettemplate'");
     $tab[79]['table'] = 'glpi_profilerights';
     $tab[79]['field'] = 'rights';
     $tab[79]['name'] = __('Planning');
     $tab[79]['datatype'] = 'right';
     $tab[79]['rightclass'] = 'Planning';
     $tab[79]['rightname'] = 'planning';
     $tab[79]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'planning'");
     $tab[85]['table'] = 'glpi_profilerights';
     $tab[85]['field'] = 'rights';
     $tab[85]['name'] = __('Statistics');
     $tab[85]['datatype'] = 'right';
     $tab[85]['rightclass'] = 'Stat';
     $tab[85]['rightname'] = 'statistic';
     $tab[85]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'statistic'");
     $tab[119]['table'] = 'glpi_profilerights';
     $tab[119]['field'] = 'rights';
     $tab[119]['name'] = _n('Ticket cost', 'Ticket costs', Session::getPluralNumber());
     $tab[119]['datatype'] = 'right';
     $tab[119]['rightclass'] = 'TicketCost';
     $tab[119]['rightname'] = 'ticketcost';
     $tab[119]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'ticketcost'");
     $tab[86]['table'] = $this->getTable();
     $tab[86]['field'] = 'helpdesk_hardware';
     $tab[86]['name'] = __('Link with items for the creation of tickets');
     $tab[86]['massiveaction'] = false;
     $tab[86]['datatype'] = 'specific';
     $tab[87]['table'] = $this->getTable();
     $tab[87]['field'] = 'helpdesk_item_type';
     $tab[87]['name'] = __('Associable items to a ticket');
     $tab[87]['massiveaction'] = false;
     $tab[87]['datatype'] = 'specific';
     $tab[89]['table'] = 'glpi_profilerights';
     $tab[89]['field'] = 'rights';
     $tab[89]['name'] = __('See hardware of my groups');
     $tab[89]['datatype'] = 'bool';
     $tab[89]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'show_group_hardware'");
     $tab[100]['table'] = $this->getTable();
     $tab[100]['field'] = 'ticket_status';
     $tab[100]['name'] = __('Life cycle of tickets');
     $tab[100]['nosearch'] = true;
     $tab[100]['datatype'] = 'text';
     $tab[100]['massiveaction'] = false;
     $tab[110]['table'] = $this->getTable();
     $tab[110]['field'] = 'problem_status';
     $tab[110]['name'] = __('Life cycle of problems');
     $tab[110]['nosearch'] = true;
     $tab[110]['datatype'] = 'text';
     $tab[110]['massiveaction'] = false;
     $tab[112]['table'] = 'glpi_profilerights';
     $tab[112]['field'] = 'rights';
     $tab[112]['name'] = _n('Problem', 'Problems', Session::getPluralNumber());
     $tab[112]['datatype'] = 'right';
     $tab[112]['rightclass'] = 'Problem';
     $tab[112]['rightname'] = 'problem';
     $tab[112]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'problem'");
     $tab[111]['table'] = $this->getTable();
     $tab[111]['field'] = 'change_status';
     $tab[111]['name'] = __('Life cycle of changes');
     $tab[111]['nosearch'] = true;
     $tab[111]['datatype'] = 'text';
     $tab[111]['massiveaction'] = false;
     $tab[115]['table'] = 'glpi_profilerights';
     $tab[115]['field'] = 'rights';
     $tab[115]['name'] = _n('Change', 'Changes', Session::getPluralNumber());
     $tab[115]['datatype'] = 'right';
     $tab[115]['rightclass'] = 'Change';
     $tab[115]['rightname'] = 'change';
     $tab[115]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'change'");
     $tab['other'] = __('Other');
     $tab[4]['table'] = 'glpi_profilerights';
     $tab[4]['field'] = 'rights';
     $tab[4]['name'] = __('Update password');
     $tab[4]['datatype'] = 'bool';
     $tab[4]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'password_update'");
     $tab[63]['table'] = 'glpi_profilerights';
     $tab[63]['field'] = 'rights';
     $tab[63]['name'] = _n('Public reminder', 'Public reminders', Session::getPluralNumber());
     $tab[63]['datatype'] = 'right';
     $tab[63]['rightclass'] = 'Reminder';
     $tab[63]['rightname'] = 'reminder_public';
     $tab[63]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'reminder_public'");
     $tab[64]['table'] = 'glpi_profilerights';
     $tab[64]['field'] = 'rights';
     $tab[64]['name'] = _n('Public bookmark', 'Public bookmarks', Session::getPluralNumber());
     $tab[64]['datatype'] = 'right';
     $tab[64]['rightclass'] = 'Bookmark';
     $tab[64]['rightname'] = 'bookmark_public';
     $tab[64]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'bookmark_public'");
     $tab[120]['table'] = 'glpi_profilerights';
     $tab[120]['field'] = 'rights';
     $tab[120]['name'] = _n('Public RSS feed', 'Public RSS feeds', Session::getPluralNumber());
     $tab[120]['datatype'] = 'right';
     $tab[120]['rightclass'] = 'RSSFeed';
     $tab[120]['rightname'] = 'rssfeed_public';
     $tab[120]['joinparams'] = array('jointype' => 'child', 'condition' => "AND `NEWTABLE`.`name`= 'rssfeed_public'");
     return $tab;
 }
Ejemplo n.º 26
0
 function isTransferable()
 {
     return Session::isMultiEntitiesMode();
 }
 /**
  * @param $target
  * @param $date1
  * @param $date2
  * @param $start
  **/
 static function showItems($target, $date1, $date2, $start)
 {
     global $DB, $CFG_GLPI;
     $view_entities = Session::isMultiEntitiesMode();
     if ($view_entities) {
         $entities = getAllDatasFromTable('glpi_entities');
     }
     $output_type = Search::HTML_OUTPUT;
     if (isset($_GET["display_type"])) {
         $output_type = $_GET["display_type"];
     }
     if (empty($date2)) {
         $date2 = date("Y-m-d");
     }
     $date2 .= " 23:59:59";
     // 1 an par defaut
     if (empty($date1)) {
         $date1 = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1));
     }
     $date1 .= " 00:00:00";
     $query = "SELECT `glpi_items_tickets`.`itemtype`,\n                       `glpi_items_tickets`.`items_id`,\n                       COUNT(*) AS NB\n                FROM `glpi_tickets`\n                LEFT JOIN `glpi_items_tickets`\n                   ON (`glpi_tickets`.`id` = `glpi_items_tickets`.`tickets_id`)\n                WHERE `date` <= '{$date2}'\n                      AND `glpi_tickets`.`date` >= '{$date1}' " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n                      AND `glpi_items_tickets`.`itemtype` <> ''\n                      AND `glpi_items_tickets`.`items_id` > 0\n                GROUP BY `glpi_items_tickets`.`itemtype`, `glpi_items_tickets`.`items_id`\n                ORDER BY NB DESC";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     if ($numrows > 0) {
         if ($output_type == Search::HTML_OUTPUT) {
             Html::printPager($start, $numrows, $target, "date1=" . $date1 . "&amp;date2=" . $date2 . "&amp;type=hardwares&amp;start={$start}", 'Stat');
             echo "<div class='center'>";
         }
         $end_display = $start + $_SESSION['glpilist_limit'];
         if (isset($_GET['export_all'])) {
             $end_display = $numrows;
         }
         echo Search::showHeader($output_type, $end_display - $start + 1, 2, 1);
         $header_num = 1;
         echo Search::showNewLine($output_type);
         echo Search::showHeaderItem($output_type, _n('Associated element', 'Associated elements', 2), $header_num);
         if ($view_entities) {
             echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
         }
         echo Search::showHeaderItem($output_type, __('Number of tickets'), $header_num);
         echo Search::showEndLine($output_type);
         $DB->data_seek($result, $start);
         $i = $start;
         if (isset($_GET['export_all'])) {
             $start = 0;
         }
         for ($i = $start; $i < $numrows && $i < $end_display; $i++) {
             $item_num = 1;
             // Get data and increment loop variables
             $data = $DB->fetch_assoc($result);
             if (!($item = getItemForItemtype($data["itemtype"]))) {
                 continue;
             }
             if ($item->getFromDB($data["items_id"])) {
                 echo Search::showNewLine($output_type, $i % 2);
                 echo Search::showItem($output_type, sprintf(__('%1$s - %2$s'), $item->getTypeName(), $item->getLink()), $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : ""));
                 if ($view_entities) {
                     $ent = $item->getEntityID();
                     $ent = $entities[$ent]['completename'];
                     echo Search::showItem($output_type, $ent, $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : ""));
                 }
                 echo Search::showItem($output_type, $data["NB"], $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : ""));
             }
         }
         echo Search::showFooter($output_type);
         if ($output_type == Search::HTML_OUTPUT) {
             echo "</div>";
         }
     }
 }
Ejemplo n.º 28
0
 /**
  * Show tabs
  *
  * @param $options array of parameters to add to URLs and ajax
  *     - withtemplate is a template view ?
  *
  * @return Nothing ()
  **/
 function showNavigationHeader($options = array())
 {
     global $CFG_GLPI;
     // for objects not in table like central
     if (isset($this->fields['id'])) {
         $ID = $this->fields['id'];
     } else {
         if (isset($options['id'])) {
             $ID = $options['id'];
         } else {
             $ID = 0;
         }
     }
     $target = $_SERVER['PHP_SELF'];
     $extraparamhtml = "";
     $extraparam = "";
     $withtemplate = "";
     if (is_array($options) && count($options)) {
         $cleanoptions = $options;
         if (isset($options['withtemplate'])) {
             $withtemplate = $options['withtemplate'];
             unset($cleanoptions['withtemplate']);
         }
         foreach ($cleanoptions as $key => $val) {
             // Do not include id options
             if ($key[0] == '_' || $key == 'id') {
                 unset($cleanoptions[$key]);
             }
         }
         $extraparamhtml = "&amp;" . Toolbox::append_params($cleanoptions, '&amp;');
         $extraparam = "&" . Toolbox::append_params($cleanoptions);
     }
     if (empty($withtemplate) && !$this->isNewID($ID) && $this->getType() && $this->displaylist) {
         $glpilistitems =& $_SESSION['glpilistitems'][$this->getType()];
         $glpilisttitle =& $_SESSION['glpilisttitle'][$this->getType()];
         $glpilisturl =& $_SESSION['glpilisturl'][$this->getType()];
         if (empty($glpilisturl)) {
             $glpilisturl = $this->getSearchURL();
         }
         //          echo "<div id='menu_navigate'>";
         $next = $prev = $first = $last = -1;
         $current = false;
         if (is_array($glpilistitems)) {
             $current = array_search($ID, $glpilistitems);
             if ($current !== false) {
                 if (isset($glpilistitems[$current + 1])) {
                     $next = $glpilistitems[$current + 1];
                 }
                 if (isset($glpilistitems[$current - 1])) {
                     $prev = $glpilistitems[$current - 1];
                 }
                 $first = $glpilistitems[0];
                 if ($first == $ID) {
                     $first = -1;
                 }
                 $last = $glpilistitems[count($glpilistitems) - 1];
                 if ($last == $ID) {
                     $last = -1;
                 }
             }
         }
         $cleantarget = HTML::cleanParametersURL($target);
         echo "<div class='navigationheader'><table class='tab_cadre_pager'>";
         echo "<tr class='tab_bg_2'>";
         if ($first >= 0) {
             echo "<td class='left' width='16px'><a href='{$cleantarget}?id={$first}{$extraparamhtml}'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('First') . "\" title=\"" . __s('First') . "\" class='pointer'></a></td>";
         } else {
             echo "<td class='left' width='16px'><img src='" . $CFG_GLPI["root_doc"] . "/pics/first_off.png' alt=\"" . __s('First') . "\" title=\"" . __s('First') . "\"></td>";
         }
         if ($prev >= 0) {
             echo "<td class='left' width='16px'><a href='{$cleantarget}?id={$prev}{$extraparamhtml}' id='previouspage'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\" class='pointer'></a></td>";
             $js = '$("body").keydown(function(e) {
                    if ($("input, textarea").is(":focus") === false) {
                       if(e.keyCode == 37 && e.ctrlKey) {
                         window.location = $("#previouspage").attr("href");
                       }
                    }
               });';
             echo Html::scriptBlock($js);
         } else {
             echo "<td class='left' width='16px'><img src='" . $CFG_GLPI["root_doc"] . "/pics/left_off.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\"></td>";
         }
         echo "<td width='200px'><a href=\"" . $glpilisturl . "\">";
         if ($glpilisttitle) {
             echo $glpilisttitle;
         } else {
             _e('List');
         }
         echo "</a></td>";
         $name = $this->getTypeName(1);
         if (isset($this->fields['id']) && $this instanceof CommonDBTM) {
             $name = sprintf(__('%1$s - %2$s'), $name, sprintf(__('%1$s - ID %2$d'), $this->getName(), $this->fields['id']));
         }
         if (isset($this->fields["entities_id"]) && Session::isMultiEntitiesMode() && $this->isEntityAssign()) {
             $entname = Dropdown::getDropdownName("glpi_entities", $this->fields["entities_id"]);
             if ($this->isRecursive()) {
                 $entname = sprintf(__('%1$s + %2$s'), $entname, __('Child entities'));
             }
             $name = sprintf(__('%1$s (%2$s)'), $name, $entname);
         }
         echo "<td class='b big'>";
         if (!self::isLayoutWithMain() || self::isLayoutExcludedPage()) {
             echo $name;
         }
         echo "</td>";
         if ($current !== false) {
             echo "<td width='40px'>" . ($current + 1) . "/" . count($glpilistitems) . "</td>";
         }
         if ($next >= 0) {
             echo "<td class='right' width='16px'><a href='{$cleantarget}?id={$next}{$extraparamhtml}' id='nextpage'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\" class='pointer'></a></td>";
             $js = '$("body").keydown(function(e) {
                    if ($("input, textarea").is(":focus") === false) {
                       if(e.keyCode == 39 && e.ctrlKey) {
                         window.location = $("#nextpage").attr("href");
                       }
                    }
               });';
             echo Html::scriptBlock($js);
         } else {
             echo "<td class='right' width='16px'><img src='" . $CFG_GLPI["root_doc"] . "/pics/right_off.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\"></td>";
         }
         if ($last >= 0) {
             echo "<td class='right' width='16px'><a href='{$cleantarget}?id={$last}{$extraparamhtml}'>" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/last.png\" alt=\"" . __s('Last') . "\" title=\"" . __s('Last') . "\" class='pointer'></a></td>";
         } else {
             echo "<td class='right' width='16px'><img src='" . $CFG_GLPI["root_doc"] . "/pics/last_off.png' alt=\"" . __s('Last') . "\" title=\"" . __s('Last') . "\"></td>";
         }
         //          echo "</ul></div>";
         // End pager
         echo "</tr></table></div>";
         //          echo "<div class='sep'></div>";
     }
 }
Ejemplo n.º 29
0
 static function showListSimple()
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight(self::$rightname, self::RESERVEANITEM)) {
         return false;
     }
     $ri = new self();
     $ok = false;
     $showentity = Session::isMultiEntitiesMode();
     $values = array();
     if (isset($_SESSION['glpi_saved']['ReservationItem'])) {
         $_POST = $_SESSION['glpi_saved']['ReservationItem'];
     }
     if (isset($_POST['reserve'])) {
         echo "<div id='viewresasearch'  class='center'>";
         Toolbox::manageBeginAndEndPlanDates($_POST['reserve']);
         echo "<div id='nosearch' class='center firstbloc'>" . "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/reservationitem.php\">";
         echo __('See all reservable items') . "</a></div>\n";
     } else {
         echo "<div id='makesearch' class='center firstbloc'>" . "<a class='pointer' onClick=\"javascript:showHideDiv('viewresasearch','','','');" . "showHideDiv('makesearch','','','')\">";
         echo __('Find a free item in a specific period') . "</a></div>\n";
         echo "<div id='viewresasearch' style=\"display:none;\" class='center'>";
         $begin_time = time();
         $begin_time -= $begin_time % HOUR_TIMESTAMP;
         $_POST['reserve']["begin"] = date("Y-m-d H:i:s", $begin_time);
         $_POST['reserve']["end"] = date("Y-m-d H:i:s", $begin_time + HOUR_TIMESTAMP);
         $_POST['reservation_types'] = '';
     }
     echo "<form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
     echo "<th colspan='3'>" . __('Find a free item in a specific period') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     Html::showDateTimeField("reserve[begin]", array('value' => $_POST['reserve']["begin"], 'maybeempty' => false));
     echo "</td><td rowspan='3'>";
     echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
     $default_delay = floor((strtotime($_POST['reserve']["end"]) - strtotime($_POST['reserve']["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
     $rand = Dropdown::showTimeStamp("reserve[_duration]", array('min' => 0, 'max' => 48 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $params = array('duration' => '__VALUE__', 'end' => $_POST['reserve']["end"], 'name' => "reserve[end]");
     Ajax::updateItemOnSelectEvent("dropdown_reserve[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Item type') . "</td><td>";
     $sql = "SELECT DISTINCT(`itemtype`)\n              FROM `glpi_reservationitems`\n              WHERE `is_active` = 1" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']);
     $result = $DB->query($sql);
     while ($data = $DB->fetch_assoc($result)) {
         $values[$data['itemtype']] = $data['itemtype']::getTypeName();
     }
     $query = "SELECT `glpi_peripheraltypes`.`name`, `glpi_peripheraltypes`.`id`\n                FROM `glpi_peripheraltypes`\n                LEFT JOIN `glpi_peripherals`\n                  ON `glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`\n                LEFT JOIN `glpi_reservationitems`\n                  ON `glpi_reservationitems`.`items_id` = `glpi_peripherals`.`id`\n                WHERE `itemtype` = 'Peripheral'\n                      AND `is_active` = 1\n                      AND `peripheraltypes_id`" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']) . "\n                ORDER BY `glpi_peripheraltypes`.`name`";
     foreach ($DB->request($query) as $ptype) {
         $id = $ptype['id'];
         $values["Peripheral#{$id}"] = $ptype['name'];
     }
     Dropdown::showFromArray("reservation_types", $values, array('value' => $_POST['reservation_types'], 'display_emptychoice' => true));
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
     // GET method passed to form creation
     echo "<div id='nosearch' class='center'>";
     echo "<form name='form' method='GET' action='reservation.form.php'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n";
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $itemtable = getTableForItemType($itemtype);
         $otherserial = "'' AS otherserial";
         if ($item->isField('otherserial')) {
             $otherserial = "`{$itemtable}`.`otherserial`";
         }
         $begin = $_POST['reserve']["begin"];
         $end = $_POST['reserve']["end"];
         $left = "";
         $where = "";
         if (isset($_POST['submit']) && isset($begin) && isset($end)) {
             $left = "LEFT JOIN `glpi_reservations`\n                        ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n                            AND '" . $begin . "' < `glpi_reservations`.`end`\n                            AND '" . $end . "' > `glpi_reservations`.`begin`)";
             $where = " AND `glpi_reservations`.`id` IS NULL ";
         }
         if (isset($_POST["reservation_types"]) && !empty($_POST["reservation_types"])) {
             $tmp = explode('#', $_POST["reservation_types"]);
             $where .= " AND `glpi_reservationitems`.`itemtype` = '" . $tmp[0] . "'";
             if (isset($tmp[1]) && $tmp[0] == 'Peripheral' && $itemtype == 'Peripheral') {
                 $left .= " LEFT JOIN `glpi_peripheraltypes`\n                              ON (`glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`)";
                 $where .= " AND `{$itemtable}`.`peripheraltypes_id` = '" . $tmp[1] . "'";
             }
         }
         $query = "SELECT `glpi_reservationitems`.`id`,\n                          `glpi_reservationitems`.`comment`,\n                          `{$itemtable}`.`name` AS name,\n                          `{$itemtable}`.`entities_id` AS entities_id,\n                          {$otherserial},\n                          `glpi_locations`.`id` AS location,\n                          `glpi_reservationitems`.`items_id` AS items_id\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `{$itemtable}`\n                        ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n                            AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n                   {$left}\n                   LEFT JOIN `glpi_locations`\n                        ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n                   WHERE `glpi_reservationitems`.`is_active` = '1'\n                         AND `glpi_reservationitems`.`is_deleted` = '0'\n                         AND `{$itemtable}`.`is_deleted` = '0'\n                         {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n                   ORDER BY `{$itemtable}`.`entities_id`,\n                            `{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             while ($row = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>";
                 $typename = $item->getTypeName();
                 if ($itemtype == 'Peripheral') {
                     $item->getFromDB($row['items_id']);
                     if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
                         $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
                     }
                 }
                 echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>" . sprintf(__('%1$s - %2$s'), $typename, $row["name"]) . "</a></td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_locations", $row["location"]) . "</td>";
                 echo "<td>" . nl2br($row["comment"]) . "</td>";
                 if ($showentity) {
                     echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>";
                 }
                 echo "</tr>\n";
                 $ok = true;
             }
         }
     }
     if ($ok) {
         echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>";
         if (isset($_POST['reserve'])) {
             echo Html::hidden('begin', array('value' => $_POST['reserve']["begin"]));
             echo Html::hidden('end', array('value' => $_POST['reserve']["end"]));
         }
         echo "<input type='submit' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>\n";
     }
     echo "</table>\n";
     echo "<input type='hidden' name='id' value=''>";
     echo "</form>";
     // No CSRF token needed
     echo "</div>\n";
 }
Ejemplo n.º 30
0
 /**
  *  @see CommonGLPI::getMenuContent()
  *
  *  @since version 0.85
  **/
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     if (Session::haveRight("rule_ldap", READ) || Session::haveRight("rule_ocs", READ) || Session::haveRight("entity_rule_ticket", READ) || Session::haveRight("rule_softwarecategories", READ) || Session::haveRight("rule_mailcollector", READ)) {
         $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['rule']['page'] = static::getSearchURL(false);
         foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
             $rulecollection = new $rulecollectionclass();
             if ($rulecollection->canList()) {
                 $ruleclassname = $rulecollection->getRuleClassName();
                 $menu['rule']['options'][$rulecollection->menu_option]['title'] = $rulecollection->getRuleClass()->getTitle();
                 $menu['rule']['options'][$rulecollection->menu_option]['page'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                 $menu['rule']['options'][$rulecollection->menu_option]['links']['search'] = Toolbox::getItemTypeSearchURL($ruleclassname, false);
                 if ($rulecollection->canCreate()) {
                     $menu['rule']['options'][$rulecollection->menu_option]['links']['add'] = Toolbox::getItemTypeFormURL($ruleclassname, false);
                 }
             }
         }
     }
     if (Transfer::canView() && Session::isMultiEntitiesMode()) {
         $menu['rule']['title'] = static::getTypeName(Session::getPluralNumber());
         $menu['rule']['page'] = static::getSearchURL(false);
         $menu['rule']['options']['transfer']['title'] = __('Transfer');
         $menu['rule']['options']['transfer']['page'] = "/front/transfer.php";
         $menu['rule']['options']['transfer']['links']['search'] = "/front/transfer.php";
         if (Session::haveRightsOr("transfer", array(CREATE, UPDATE))) {
             $menu['rule']['options']['transfer']['links']['summary'] = "/front/transfer.action.php";
             $menu['rule']['options']['transfer']['links']['add'] = "/front/transfer.form.php";
         }
     }
     if (Session::haveRight("rule_dictionnary_dropdown", READ) || Session::haveRight("rule_dictionnary_software", READ) || Session::haveRight("rule_dictionnary_printer", READ)) {
         $menu['dictionnary']['title'] = _n('Dictionary', 'Dictionaries', Session::getPluralNumber());
         $menu['dictionnary']['shortcut'] = '';
         $menu['dictionnary']['page'] = '/front/dictionnary.php';
         $menu['dictionnary']['options']['manufacturers']['title'] = _n('Manufacturer', 'Manufacturers', Session::getPluralNumber());
         $menu['dictionnary']['options']['manufacturers']['page'] = '/front/ruledictionnarymanufacturer.php';
         $menu['dictionnary']['options']['manufacturers']['links']['search'] = '/front/ruledictionnarymanufacturer.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['manufacturers']['links']['add'] = '/front/ruledictionnarymanufacturer.form.php';
         }
         $menu['dictionnary']['options']['software']['title'] = _n('Software', 'Software', Session::getPluralNumber());
         $menu['dictionnary']['options']['software']['page'] = '/front/ruledictionnarysoftware.php';
         $menu['dictionnary']['options']['software']['links']['search'] = '/front/ruledictionnarysoftware.php';
         if (RuleDictionnarySoftware::canCreate()) {
             $menu['dictionnary']['options']['software']['links']['add'] = '/front/ruledictionnarysoftware.form.php';
         }
         $menu['dictionnary']['options']['model.computer']['title'] = _n('Computer model', 'Computer models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.computer']['page'] = '/front/ruledictionnarycomputermodel.php';
         $menu['dictionnary']['options']['model.computer']['links']['search'] = '/front/ruledictionnarycomputermodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.computer']['links']['add'] = '/front/ruledictionnarycomputermodel.form.php';
         }
         $menu['dictionnary']['options']['model.monitor']['title'] = _n('Monitor model', 'Monitor models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.monitor']['page'] = '/front/ruledictionnarymonitormodel.php';
         $menu['dictionnary']['options']['model.monitor']['links']['search'] = '/front/ruledictionnarymonitormodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.monitor']['links']['add'] = '/front/ruledictionnarymonitormodel.form.php';
         }
         $menu['dictionnary']['options']['model.printer']['title'] = _n('Printer model', 'Printer models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.printer']['page'] = '/front/ruledictionnaryprintermodel.php';
         $menu['dictionnary']['options']['model.printer']['links']['search'] = '/front/ruledictionnaryprintermodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.printer']['links']['add'] = '/front/ruledictionnaryprintermodel.form.php';
         }
         $menu['dictionnary']['options']['model.peripheral']['title'] = _n('Peripheral model', 'Peripheral models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.peripheral']['page'] = '/front/ruledictionnaryperipheralmodel.php';
         $menu['dictionnary']['options']['model.peripheral']['links']['search'] = '/front/ruledictionnaryperipheralmodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.peripheral']['links']['add'] = '/front/ruledictionnaryperipheralmodel.form.php';
         }
         $menu['dictionnary']['options']['model.networking']['title'] = _n('Networking equipment model', 'Networking equipment models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.networking']['page'] = '/front/ruledictionnarynetworkequipmentmodel.php';
         $menu['dictionnary']['options']['model.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmentmodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmentmodel.form.php';
         }
         $menu['dictionnary']['options']['model.phone']['title'] = _n('Phone model', 'Phone models', Session::getPluralNumber());
         $menu['dictionnary']['options']['model.phone']['page'] = '/front/ruledictionnaryphonemodel.php';
         $menu['dictionnary']['options']['model.phone']['links']['search'] = '/front/ruledictionnaryphonemodel.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['model.phone']['links']['add'] = '/front/ruledictionnaryphonemodel.form.php';
         }
         $menu['dictionnary']['options']['type.computer']['title'] = _n('Computer type', 'Computer types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.computer']['page'] = '/front/ruledictionnarycomputertype.php';
         $menu['dictionnary']['options']['type.computer']['links']['search'] = '/front/ruledictionnarycomputertype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.computer']['links']['add'] = '/front/ruledictionnarycomputertype.form.php';
         }
         $menu['dictionnary']['options']['type.monitor']['title'] = _n('Monitor type', 'Monitors types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.monitor']['page'] = '/front/ruledictionnarymonitortype.php';
         $menu['dictionnary']['options']['type.monitor']['links']['search'] = '/front/ruledictionnarymonitortype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.monitor']['links']['add'] = '/front/ruledictionnarymonitortype.form.php';
         }
         $menu['dictionnary']['options']['type.printer']['title'] = _n('Printer type', 'Printer types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.printer']['page'] = '/front/ruledictionnaryprintertype.php';
         $menu['dictionnary']['options']['type.printer']['links']['search'] = '/front/ruledictionnaryprintertype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.printer']['links']['add'] = '/front/ruledictionnaryprintertype.form.php';
         }
         $menu['dictionnary']['options']['type.peripheral']['title'] = _n('Peripheral type', 'Peripheral types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.peripheral']['page'] = '/front/ruledictionnaryperipheraltype.php';
         $menu['dictionnary']['options']['type.peripheral']['links']['search'] = '/front/ruledictionnaryperipheraltype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.peripheral']['links']['add'] = '/front/ruledictionnaryperipheraltype.form.php';
         }
         $menu['dictionnary']['options']['type.networking']['title'] = _n('Networking equipment type', 'Networking equipment types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.networking']['page'] = '/front/ruledictionnarynetworkequipmenttype.php';
         $menu['dictionnary']['options']['type.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmenttype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmenttype.form.php';
         }
         $menu['dictionnary']['options']['type.phone']['title'] = _n('Phone type', 'Phone types', Session::getPluralNumber());
         $menu['dictionnary']['options']['type.phone']['page'] = '/front/ruledictionnaryphonetype.php';
         $menu['dictionnary']['options']['type.phone']['links']['search'] = '/front/ruledictionnaryphonetype.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['type.phone']['links']['add'] = '/front/ruledictionnaryphonetype.form.php';
         }
         $menu['dictionnary']['options']['os']['title'] = __('Operating system');
         $menu['dictionnary']['options']['os']['page'] = '/front/ruledictionnaryoperatingsystem.php';
         $menu['dictionnary']['options']['os']['links']['search'] = '/front/ruledictionnaryoperatingsystem.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os']['links']['add'] = '/front/ruledictionnaryoperatingsystem.form.php';
         }
         $menu['dictionnary']['options']['os_sp']['title'] = __('Service pack');
         $menu['dictionnary']['options']['os_sp']['page'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
         $menu['dictionnary']['options']['os_sp']['links']['search'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os_sp']['links']['add'] = '/front/ruledictionnaryoperatingsystemservicepack.form.php';
         }
         $menu['dictionnary']['options']['os_version']['title'] = __('Version of the operating system');
         $menu['dictionnary']['options']['os_version']['page'] = '/front/ruledictionnaryoperatingsystemversion.php';
         $menu['dictionnary']['options']['os_version']['links']['search'] = '/front/ruledictionnaryoperatingsystemversion.php';
         if (RuleDictionnaryDropdown::canCreate()) {
             $menu['dictionnary']['options']['os_version']['links']['add'] = '/front/ruledictionnaryoperatingsystemversion.form.php';
         }
         $menu['dictionnary']['options']['printer']['title'] = _n('Printer', 'Printers', Session::getPluralNumber());
         $menu['dictionnary']['options']['printer']['page'] = '/front/ruledictionnaryprinter.php';
         $menu['dictionnary']['options']['printer']['links']['search'] = '/front/ruledictionnaryprinter.php';
         if (RuleDictionnaryPrinter::canCreate()) {
             $menu['dictionnary']['options']['printer']['links']['add'] = '/front/ruledictionnaryprinter.form.php';
         }
     }
     if (count($menu)) {
         $menu['is_multi_entries'] = true;
         return $menu;
     }
     return false;
 }