function showprofileForm($target, $ID)
 {
     global $LANG, $CFG_GLPI;
     if (!haveRight("profile", "r")) {
         return false;
     }
     $onfocus = "";
     if ($ID) {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
         $onfocus = "onfocus=\"this.value=''\"";
     }
     if (empty($this->fields["interface"])) {
         $this->fields["interface"] = "fusioninventory";
     }
     if (empty($this->fields["name"])) {
         $this->fields["name"] = $LANG["common"][0];
     }
     echo "<form name='form' method='post' action=\"{$target}\">";
     echo "<div align='center'>";
     echo "<table class='tab_cadre'><tr>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<th>" . $LANG["common"][16] . ":</th>";
     echo "<th><input type='text' name='name' value=\"" . $this->fields["name"] . "\" {$onfocus}></th>";
     echo "<tr><th colspan='2' align='center'><strong>TEST " . $this->fields["name"] . "</strong></th></tr>";
     echo "<th>" . $LANG["profiles"][2] . ":</th>";
     echo "<th><select name='interface' id='profile_interface'>";
     echo "<option value='fusioninventory' " . ($this->fields["interface"] != "fusioninventory" ? "selected" : "") . ">" . $LANG['plugin_fusioninventory']["profile"][1] . "</option>";
     echo "</select></th>";
     echo "</tr></table>";
     echo "</div>";
     $params = array('interface' => '__VALUE__', 'ID' => $ID);
     ajaxUpdateItemOnSelectEvent("profile_interface", "profile_form", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/profiles.php", $params, false);
     ajaxUpdateItem("profile_form", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/profiles.php", $params, false, 'profile_interface');
     //$prof=new PluginFusioninventoryProfile;
     //	$prof->showfusioninventoryForm($_POST["ID"]);
     echo "<br>";
     echo "<div align='center' id='profile_form'>";
     echo "</div>";
     echo "</form>";
 }
Beispiel #2
0
 /** Display refresh button in the user page
  *
  * @param $ID ID of the user
  *
  * @return nothing
  */
 static function showSynchronizationForm($ID)
 {
     global $LANG, $DB, $CFG_GLPI;
     if (haveRight("user", "w")) {
         //Look it the user's auth method is LDAP
         $sql = "SELECT `authtype`, `auths_id`\n                 FROM `glpi_users`\n                 WHERE `id` = '{$ID}'";
         $result = $DB->query($sql);
         if ($DB->numrows($result) == 1) {
             $data = $DB->fetch_array($result);
             echo "<form method='post' action='" . getItemTypeFormURL('User') . "'>";
             echo "<div class='firstbloc'>";
             switch ($data["authtype"]) {
                 case self::LDAP:
                     //Look it the auth server still exists !
                     // <- Bad idea : id not exists unable to change anything
                     $sql = "SELECT `name`\n                          FROM `glpi_authldaps`\n                          WHERE `id` = '" . $data["auths_id"] . "'";
                     $result = $DB->query($sql);
                     if ($DB->numrows($result) > 0) {
                         echo "<table class='tab_cadre'><tr class='tab_bg_2'><td>";
                         echo "<input type='hidden' name='id' value='{$ID}'>";
                         echo "<input class=submit type='submit' name='force_ldap_resynch' value='" . $LANG['ocsng'][24] . "'>";
                         echo "</td></tr></table>";
                     }
                     break;
                 case self::DB_GLPI:
                 case self::MAIL:
                     break;
                 case self::CAS:
                 case self::EXTERNAL:
                 case self::X509:
                     if ($CFG_GLPI['authldaps_id_extra']) {
                         $sql = "SELECT `name`\n                             FROM `glpi_authldaps`\n                             WHERE `id` = '" . $CFG_GLPI['authldaps_id_extra'] . "'";
                         $result = $DB->query($sql);
                         if ($DB->numrows($result) > 0) {
                             echo "<table class='tab_cadre'><tr class='tab_bg_2'><td>";
                             echo "<input class=submit type='submit' name='force_ldap_resynch' value='" . $LANG['ocsng'][24] . "'>";
                             echo "</td></tr></table>";
                         }
                     }
                     break;
             }
             echo "</div>";
             echo "<div class='spaced'>";
             echo "<table class='tab_cadre'>";
             echo "<tr><th>" . $LANG['login'][30] . "&nbsp:&nbsp;</th></tr>";
             echo "<tr class='tab_bg_2'><td class='center'>";
             $rand = self::dropdown(array('name' => 'authtype'));
             $paramsmassaction = array('authtype' => '__VALUE__', 'name' => 'change_auth_method');
             ajaxUpdateItemOnSelectEvent("dropdown_authtype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAuthMethods.php", $paramsmassaction);
             echo "<input type='hidden' name='id' value='" . $ID . "'>";
             echo "<span id='show_massiveaction_field'></span>";
             echo "</td></tr></table>";
             echo "</div></form>";
         }
     }
 }
 static function dropdownService($ID, $options = array())
 {
     global $CFG_GLPI;
     $p = array();
     $p['name'] = 'networkports_id';
     $p['comments'] = 1;
     $p['entity'] = -1;
     $p['entity_sons'] = false;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     // Manage entity_sons
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     $rand = mt_rand();
     echo "<select name='itemtype[{$ID}]' id='itemtype{$rand}'>";
     echo "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option>";
     //      $a_types =array();
     echo "<option value='Computer'>" . Computer::getTypeName() . "</option>";
     echo "<option value='NetworkEquipment'>" . NetworkEquipment::getTypeName() . "</option>";
     echo "</select>";
     $params = array('itemtype' => '__VALUE__', 'entity_restrict' => $p['entity'], 'current' => $ID, 'comments' => $p['comments'], 'myname' => $p['name'], 'rand' => $rand);
     ajaxUpdateItemOnSelectEvent("itemtype{$rand}", "show_" . $p['name'] . "{$rand}", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownServiceHostType.php", $params);
     echo "<span id='show_" . $p['name'] . "{$rand}'><input type='hidden' name='services_id[]' value='0'/></span>\n";
     return $rand;
 }
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI, $LANG;
     $canupdate = haveRight('update_ticket', '1');
     $canpriority = haveRight('update_priority', '1');
     $showuserlink = 0;
     if (haveRight('user', 'r')) {
         $showuserlink = 1;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w', $options);
     }
     $this->showTabs($options);
     $canupdate_descr = $canupdate || $this->fields['status'] == 'new' && $this->isUser(self::REQUESTER, getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0;
     if (!$ID) {
         //Get all the user's entities
         $all_entities = Profile_User::getUserEntities($options["_users_id_requester"], true);
         $this->userentities = array();
         //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 (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];
         }
     }
     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'>";
     // Optional line
     $ismultientities = isMultiEntitiesMode();
     echo '<tr><th colspan="4">';
     if ($ID) {
         echo $this->getTypeName() . " - " . $LANG['common'][2] . " {$ID} ";
         if ($ismultientities) {
             echo "(" . Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']) . ")";
         }
     } else {
         if ($ismultientities) {
             echo $LANG['job'][46] . "&nbsp;:&nbsp;" . Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id']);
         } else {
             echo $LANG['job'][13];
         }
     }
     echo '</th></tr>';
     echo "<tr>";
     echo "<th class='left' colspan='2'>";
     echo "<table>";
     echo "<tr>";
     echo "<td><span class='tracking_small'>" . $LANG['joblist'][11] . "&nbsp;: </span></td>";
     echo "<td>";
     $date = $this->fields["date"];
     if (!$ID) {
         $date = date("Y-m-d H:i:s");
     }
     if ($canupdate) {
         showDateTimeFormItem("date", $date, 1, false);
     } else {
         echo convDateTime($date);
     }
     echo "</td></tr>";
     if ($ID) {
         echo "<tr><td><span class='tracking_small'>" . $LANG['common'][95] . " &nbsp;:</span></td><td>";
         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></tr>";
     }
     echo "</table>";
     echo "</th>";
     echo "<th class='left' colspan='2'>";
     echo "<table>";
     if ($ID) {
         echo "<tr><td><span class='tracking_small'>" . $LANG['common'][26] . "&nbsp;:</span></td>";
         echo "<td><span class='tracking_small'>" . convDateTime($this->fields["date_mod"]) . "\n";
         if ($this->fields['users_id_lastupdater'] > 0) {
             echo $LANG['common'][95] . "&nbsp;";
             echo getUserName($this->fields["users_id_lastupdater"], $showuserlink);
         }
         echo "</span>";
         echo "</td></tr>";
     }
     // SLA
     echo "<tr>";
     echo "<td><span class='tracking_small'>" . $LANG['sla'][5] . "&nbsp;: </span></td>";
     echo "<td>";
     if ($ID) {
         if ($this->fields["slas_id"] > 0) {
             echo "<span class='tracking_small'>&nbsp;";
             echo convDateTime($this->fields["due_date"]) . "</span>";
             echo "</td></tr><tr><td><span class='tracking_small'>" . $LANG['sla'][1] . "&nbsp;:</span></td>";
             echo "<td><span class='tracking_small'>";
             echo Dropdown::getDropdownName("glpi_slas", $this->fields["slas_id"]);
             $commentsla = "";
             $slalevel = new SlaLevel();
             if ($slalevel->getFromDB($this->fields['slalevels_id'])) {
                 $commentsla .= '<strong>' . $LANG['sla'][6] . "&nbsp;:&nbsp;</strong>" . $slalevel->getName() . '<br><br>';
             }
             $nextaction = new SlaLevel_Ticket();
             if ($nextaction->getFromDBForTicket($this->fields["id"])) {
                 $commentsla .= '<strong>' . $LANG['sla'][8] . "&nbsp;:&nbsp;</strong>" . convDateTime($nextaction->fields['date']) . '<br>';
                 if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) {
                     $commentsla .= '<strong>' . $LANG['sla'][6] . "&nbsp;:&nbsp;</strong>" . $slalevel->getName() . '<br>';
                 }
             }
             $slaoptions = array();
             if (haveRight('config', 'r')) {
             }
             $slaoptions['link'] = getItemTypeFormURL('SLA') . "?id=" . $this->fields["slas_id"];
             showToolTip($commentsla, $slaoptions);
             if ($canupdate) {
                 echo "&nbsp;<input type='submit' class='submit' name='sla_delete' value='" . $LANG['sla'][7] . "'>";
             }
             echo "</span>";
         } else {
             showDateTimeFormItem("due_date", $this->fields["due_date"], 1, false, $canupdate);
         }
     } else {
         // New Ticket
         if ($this->fields["due_date"] == 'NULL') {
             $this->fields["due_date"] = '';
         }
         showDateTimeFormItem("due_date", $this->fields["due_date"], 1, false, $canupdate);
         /*         echo $LANG['choice'][2]." ".$LANG['sla'][1]." : ";
                  Dropdown::show('Sla',array('entity' => $this->fields["entities_id"],
                                             'value' =>$this->fields["slas_id"]));*/
     }
     echo "</td></tr>";
     if ($ID) {
         switch ($this->fields["status"]) {
             case 'closed':
                 echo "<tr>";
                 echo "<td><span class='tracking_small'>" . $LANG['joblist'][12] . "&nbsp;: </span></td>";
                 echo "<td>";
                 showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false, $canupdate);
                 echo "</td></tr>";
                 break;
             case 'solved':
                 echo "<tr>";
                 echo "<td><span class='tracking_small'>" . $LANG['joblist'][14] . "&nbsp;: </span></td>";
                 echo "<td>";
                 showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false, $canupdate);
                 echo "</td></tr>";
                 break;
         }
     }
     echo "</table>";
     echo "</th></tr>";
     echo "</table>";
     if (!$ID) {
         $this->showActorsPartForm($ID, $options);
     }
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10%'>" . $LANG['joblist'][0] . "&nbsp;: </th>";
     echo "<td width='40%'>";
     if ($canupdate) {
         self::dropdownStatus("status", $this->fields["status"], 2);
         // Allowed status
     } else {
         echo self::getStatus($this->fields["status"]);
     }
     echo "</td>";
     echo "<th>" . $LANG['common'][17] . "&nbsp;: </th>";
     echo "<td >";
     // Permit to set type when creating ticket without update right
     if ($canupdate || !$ID) {
         self::dropdownType('type', $this->fields["type"]);
     } else {
         echo self::getTicketTypeName($this->fields["type"]);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $LANG['joblist'][29] . "&nbsp;: </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
         $idurgency = self::dropdownUrgency("urgency", $this->fields["urgency"]);
     } else {
         $idurgency = "value_urgency" . mt_rand();
         echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>";
         echo self::getUrgencyName($this->fields["urgency"]);
     }
     echo "</td>";
     echo "<th>" . $LANG['common'][36] . "&nbsp;: </th>";
     echo "<td >";
     // Permit to set category when creating ticket without update right
     if ($canupdate || !$ID || $canupdate_descr) {
         $opt = array('value' => $this->fields["ticketcategories_id"], 'entity' => $this->fields["entities_id"]);
         if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
             $opt['condition'] = '`is_helpdeskvisible`=1';
         }
         if ($ID && $CFG_GLPI["is_ticket_category_mandatory"]) {
             $opt['display_emptychoice'] = false;
         }
         Dropdown::show('TicketCategory', $opt);
     } else {
         echo Dropdown::getDropdownName("glpi_ticketcategories", $this->fields["ticketcategories_id"]);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $LANG['joblist'][30] . "&nbsp;: </th>";
     echo "<td>";
     if ($canupdate) {
         $idimpact = self::dropdownImpact("impact", $this->fields["impact"]);
     } else {
         echo self::getImpactName($this->fields["impact"]);
     }
     echo "</td>";
     echo "<th class='left' rowspan='2'>" . $LANG['document'][14] . "&nbsp;: </th>";
     echo "<td rowspan='2'>";
     // Select hardware on creation or if have update right
     if ($canupdate || !$ID || $canupdate_descr) {
         if ($ID) {
             if ($this->fields['itemtype'] && class_exists($this->fields['itemtype']) && $this->fields["items_id"]) {
                 $item = new $this->fields['itemtype']();
                 if ($item->can($this->fields["items_id"], 'r')) {
                     echo $item->getTypeName() . " - " . $item->getLink(true);
                 } else {
                     echo $item->getTypeName() . " " . $item->getNameID();
                 }
             }
         }
         $dev_user_id = 0;
         if (!$ID) {
             $dev_user_id = $options['_users_id_requester'];
         } else {
             if (isset($this->users[self::REQUESTER]) && count($this->users[self::REQUESTER]) == 1) {
                 foreach ($this->users[self::REQUESTER] as $user_id_single) {
                     $dev_user_id = $user_id_single['users_id'];
                 }
             }
         }
         if ($dev_user_id > 0) {
             self::dropdownMyDevices($dev_user_id, $this->fields["entities_id"], $this->fields["itemtype"], $this->fields["items_id"]);
         }
         self::dropdownAllDevices("itemtype", $this->fields["itemtype"], $this->fields["items_id"], 1, $this->fields["entities_id"]);
     } else {
         if ($ID && $this->fields['itemtype'] && class_exists($this->fields['itemtype'])) {
             $item = new $this->fields['itemtype']();
             $item->getFromDB($this->fields['items_id']);
             echo $item->getTypeName() . " - " . $item->getNameID();
         } else {
             echo $LANG['help'][30];
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th class='left'>" . $LANG['joblist'][2] . "&nbsp;: </th>";
     echo "<td>";
     if ($canupdate && $canpriority) {
         $idpriority = self::dropdownPriority("priority", $this->fields["priority"], false, true);
         $idajax = 'change_priority_' . mt_rand();
         echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     } else {
         $idajax = 'change_priority_' . mt_rand();
         $idpriority = 0;
         echo "<span id='{$idajax}'>" . self::getPriorityName($this->fields["priority"]) . "</span>";
     }
     if ($canupdate) {
         $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority);
         ajaxUpdateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th class='left'>" . $LANG['job'][44] . "&nbsp;: </th>";
     echo "<td>";
     if ($canupdate) {
         Dropdown::show('RequestType', array('value' => $this->fields["requesttypes_id"]));
     } else {
         echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]);
     }
     echo "</td>";
     // Display validation state
     echo "<th>";
     if (!$ID) {
         echo $LANG['validation'][26] . "&nbsp;:&nbsp;";
     } else {
         echo $LANG['validation'][0] . "&nbsp;:&nbsp;";
     }
     echo "</th>";
     echo "<td>";
     if (!$ID) {
         User::dropdown(array('name' => "_add_validation", 'entity' => $this->fields['entities_id'], 'right' => 'validate_ticket'));
     } else {
         if ($canupdate) {
             TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $this->fields['global_validation']));
         } else {
             echo TicketValidation::getStatus($this->fields['global_validation']);
         }
     }
     echo "</td></tr>";
     // Need comment right to add a followup with the actiontime
     if (!$ID && haveRight("global_add_followups", "1")) {
         echo "<tr class='tab_bg_1'>";
         echo "<th>" . $LANG['job'][20] . "&nbsp;: </th>";
         echo "<td class='left' colspan='3'>";
         Dropdown::showInteger('hour', $options['hour'], 0, 100);
         echo "&nbsp;" . $LANG['job'][21] . "&nbsp;&nbsp;";
         Dropdown::showInteger('minute', $options['minute'], 0, 59);
         echo "&nbsp;" . $LANG['job'][22] . "&nbsp;&nbsp;";
         echo "</td>";
         echo "</tr>";
     }
     echo '</table>';
     if ($ID) {
         $this->showActorsPartForm($ID, $options);
     }
     echo "<table  class='tab_cadre_fixe'>";
     $view_linked_tickets = $ID || $canupdate;
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10%'>" . $LANG['common'][57] . "&nbsp;:</th>";
     echo "<td width='50%'>";
     if (!$ID || $canupdate_descr) {
         $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' => 60, 'name' => 'name', 'data' => rawurlencode($this->fields["name"]));
         ajaxUpdateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params, false);
         echo "}";
         echo "</script>\n";
         echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n";
         if (empty($this->fields["name"])) {
             echo $LANG['reminder'][15];
         } 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>";
         }
     } else {
         if (empty($this->fields["name"])) {
             echo $LANG['reminder'][15];
         } else {
             echo $this->fields["name"];
         }
     }
     echo "</td>";
     // Permit to add doc when creating a ticket
     if (!$ID) {
         echo "<th>" . $LANG['document'][2] . " (" . Document::getMaxUploadSize() . ")&nbsp;:";
         echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt=\"" . $LANG['central'][7] . "\" onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
         echo "</th>";
         echo "<td>";
         echo "<input type='file' name='filename' value=\"\" size='25'></td>";
     } else {
         echo "<th colspan='2'>";
         echo $LANG['document'][20] . '&nbsp;: ' . Document_Item::countForItem($this);
         echo "</th>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10%'>" . $LANG['joblist'][6] . "&nbsp;:&nbsp;</th>";
     echo "<td width='50%'>";
     if (!$ID || $canupdate_descr) {
         // Admin =oui on autorise la modification de la description
         $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' => 60, 'name' => 'content', 'data' => rawurlencode($this->fields["content"]));
         ajaxUpdateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params, false);
         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 {
             echo $LANG['job'][33];
         }
         echo "</div>\n";
         echo "<div id='viewdesc{$rand}'></div>\n";
         if (!$ID) {
             echo "<script type='text/javascript' >\n\n            showDesc{$rand}();\n            </script>";
         }
     } else {
         echo nl2br($this->fields["content"]);
     }
     echo "</td>";
     if ($view_linked_tickets) {
         echo "<th width='10%'>";
         echo $LANG['job'][55];
         if ($canupdate) {
             $rand_linked_ticket = mt_rand();
             echo "&nbsp;&nbsp;<a class='tracking'\n                  onClick=\"Ext.get('linkedticket{$rand_linked_ticket}').setDisplayed('block')\">\n";
             echo $LANG['buttons'][8];
             echo "</a>\n";
         }
         echo '</th>';
         echo "<td>";
         Ticket_Ticket::displayLinkedTicketsTo($ID);
         if ($canupdate) {
             echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>";
             Ticket_Ticket::dropdownLinks('_link[link]');
             echo "&nbsp;" . $LANG['job'][38] . "&nbsp;" . $LANG['common'][2] . "&nbsp;:&nbsp;";
             echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n";
             echo "<input type='text' name='_link[tickets_id_2]' value='' size='10'>\n";
             echo "&nbsp;";
             echo "</div>";
         }
         echo "</td>";
     }
     echo "</tr>";
     if (!$ID || $canupdate || $canupdate_descr || haveRight("assign_ticket", "1") || haveRight("steal_ticket", "1")) {
         echo "<tr class='tab_bg_1'>";
         if ($ID) {
             if (haveRight('delete_ticket', 1)) {
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='submit' class='submit' name='update' value='" . $LANG['buttons'][7] . "'></td>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='submit' class='submit' name='delete' value='" . $LANG['buttons'][22] . "'" . addConfirmationOnAction($LANG['common'][50]) . ">";
             } else {
                 echo "<td class='tab_bg_2 center' colspan='4'>";
                 echo "<input type='submit' class='submit' name='update' value='" . $LANG['buttons'][7] . "'>";
             }
         } else {
             echo "<td class='tab_bg_2 center' colspan='2'>";
             echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
             echo "</td><td class='tab_bg_2 center' colspan='2'>";
             echo "<input type='button' value=\"" . $LANG['buttons'][16] . "\" class='submit'\n                   onclick=\"window.location='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'\">";
         }
         echo "</td></tr>";
     }
     echo "</table>";
     echo "<input type='hidden' name='id' value='{$ID}'>";
     echo "</div>";
     echo "</form>";
     $this->addDivForTabs();
     return true;
 }
/**
 * Show generic date search
 *
 * @param $element name of the html element
 * @param $value default value
 * @param $with_time display with time selection ?
 * @param $with_future display with future date selection ?
 *
 * @return rand value of dropdown
 **/
function showGenericDateTimeSearch($element, $value = '', $with_time = false, $with_future = false)
{
    global $LANG, $CFG_GLPI;
    $rand = mt_rand();
    // Validate value
    if ($value != 'NOW' && !preg_match("/\\d{4}-\\d{2}-\\d{2}.*/", $value) && !strstr($value, 'HOUR') && !strstr($value, 'DAY') && !strstr($value, 'WEEK') && !strstr($value, 'MONTH') && !strstr($value, 'YEAR')) {
        $value = "";
    }
    if (empty($value)) {
        $value = 'NOW';
    }
    $specific_value = date("Y-m-d H:i:s");
    if (preg_match("/\\d{4}-\\d{2}-\\d{2}.*/", $value)) {
        $specific_value = $value;
        $value = 0;
    }
    echo "<table><tr><td>";
    echo "<select id='genericdate{$element}{$rand}' name='_select_{$element}'>";
    $val = 'NOW';
    echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">" . $LANG['calendar'][16] . "</option>";
    echo "<option value='0' " . ($value === 0 ? 'selected' : '') . ">" . $LANG['calendar'][17] . "</option>";
    if ($with_time) {
        for ($i = 1; $i <= 24; $i++) {
            $val = '-' . $i . 'HOUR';
            echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
            echo "- {$i} " . $LANG['gmt'][1] . "</option>";
        }
    }
    for ($i = 1; $i <= 7; $i++) {
        $val = '-' . $i . 'DAY';
        echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
        echo "- {$i} " . $LANG['calendar'][12] . "</option>";
    }
    for ($i = 1; $i <= 10; $i++) {
        $val = '-' . $i . 'WEEK';
        echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
        echo "- {$i} " . $LANG['calendar'][13] . "</option>";
    }
    for ($i = 1; $i <= 12; $i++) {
        $val = '-' . $i . 'MONTH';
        echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
        echo "- {$i} " . $LANG['calendar'][14] . "</option>";
    }
    for ($i = 1; $i <= 10; $i++) {
        $val = '-' . $i . 'YEAR';
        echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
        echo "- {$i} " . $LANG['calendar'][15] . "</option>";
    }
    if ($with_future) {
        if ($with_time) {
            for ($i = 1; $i <= 24; $i++) {
                $val = $i . 'HOUR';
                echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
                echo "+ {$i} " . $LANG['gmt'][1] . "</option>";
            }
        }
        for ($i = 1; $i <= 7; $i++) {
            $val = $i . 'DAY';
            echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
            echo "+ {$i} " . $LANG['calendar'][12] . "</option>";
        }
        for ($i = 1; $i <= 10; $i++) {
            $val = $i . 'WEEK';
            echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
            echo "+ {$i} " . $LANG['calendar'][13] . "</option>";
        }
        for ($i = 1; $i <= 12; $i++) {
            $val = $i . 'MONTH';
            echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
            echo "+ {$i} " . $LANG['calendar'][14] . "</option>";
        }
        for ($i = 1; $i <= 10; $i++) {
            $val = $i . 'YEAR';
            echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">";
            echo "+ {$i} " . $LANG['calendar'][15] . "</option>";
        }
    }
    echo "</select>";
    echo "</td><td>";
    echo "<div id='displaygenericdate{$element}{$rand}'></div>";
    $params = array('value' => '__VALUE__', 'name' => $element, 'withtime' => $with_time, 'specificvalue' => $specific_value);
    ajaxUpdateItemOnSelectEvent("genericdate{$element}{$rand}", "displaygenericdate{$element}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/genericdate.php", $params, false);
    $params['value'] = $value;
    ajaxUpdateItem("displaygenericdate{$element}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/genericdate.php", $params);
    echo "</td></tr></table>";
    return $rand;
}
 function showForm($ID, $options = array())
 {
     global $LANG, $CFG_GLPI;
     if (!haveRight("notification", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='6' class='middle right'>" . $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td class='center middle' rowspan='6'><textarea cols='45' rows='9' name='comment' >" . $this->fields["comment"] . "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][60] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][17] . "&nbsp;:</td>";
     echo "<td>";
     if (haveRight('config', 'w') && $this->getEntityID() == 0) {
         $rand = Dropdown::dropdownTypes("itemtype", $this->fields['itemtype'], $CFG_GLPI["notificationtemplates_types"]);
     } else {
         $rand = Dropdown::dropdownTypes("itemtype", $this->fields['itemtype'], array_diff($CFG_GLPI["notificationtemplates_types"], array('Crontask', 'DBConnection')));
     }
     $params = array('itemtype' => '__VALUE__');
     ajaxUpdateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_events", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationEvent.php", $params);
     ajaxUpdateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_templates", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationTemplate.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][120] . "&nbsp;:</td>";
     echo "<td>";
     self::dropdownMode($this->fields['mode']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][119] . "&nbsp;:</td>";
     echo "<td><span id='show_events'>";
     NotificationEvent::dropdownEvents($this->fields['itemtype'], $this->fields['event']);
     echo "</span></td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][113] . "&nbsp;:</td>";
     echo "<td><span id='show_templates'>";
     NotificationTemplate::dropdownTemplates('notificationtemplates_id', $this->fields['itemtype'], $this->fields['notificationtemplates_id']);
     echo "</span></td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
}
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
checkLoginUser();
if (isset($_POST["sub_type"])) {
    $rule = new $_POST["sub_type"]();
    $criterias = $rule->getCriterias();
    if (count($criterias)) {
        // First include -> first of the predefined array
        if (!isset($_POST["criteria"])) {
            $_POST["criteria"] = key($criterias);
        }
        $type = "";
        if (isset($criterias[$_POST["criteria"]]['type'])) {
            $type = $criterias[$_POST["criteria"]]['type'];
        }
        if (isset($criterias[$_POST["criteria"]]['allow_condition'])) {
            $allow_condition = $criterias[$_POST["criteria"]]['allow_condition'];
        } else {
            $allow_condition = array();
        }
        $randcrit = RuleCriteria::dropdownConditions($_POST["sub_type"], array('criterion' => $_POST["criteria"], 'allow_conditions' => $allow_condition));
        echo "&nbsp;&nbsp;";
        echo "<span id='condition_span{$randcrit}'>\n";
        echo "</span>\n";
        $paramscriteria = array('condition' => '__VALUE__', 'criteria' => $_POST["criteria"], 'sub_type' => $_POST["sub_type"]);
        ajaxUpdateItemOnSelectEvent("dropdown_condition{$randcrit}", "condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria, false);
        ajaxUpdateItem("condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria, false, "dropdown_condition{$randcrit}");
    }
}
    function configureNodesLinks($weathermaps_id)
    {
        global $LANG, $DB, $CFG_GLPI;
        $networkPort = new NetworkPort();
        $pmWeathermapnode = new PluginMonitoringWeathermapnode();
        $this->getFromDB($weathermaps_id);
        echo "<table class='tab_cadre_fixe'>";
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][6];
        echo "</th>";
        echo "</tr>";
        $this->generateWeathermap($weathermaps_id, 1, 1);
        $map = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=weathermap-" . $weathermaps_id . ".png'/>";
        echo "<tr class='tab_bg_1'>";
        echo "<td valign='top' width='10'>";
        if ($this->fields['background'] == '') {
            echo '<script language="JavaScript" type="text/JavaScript">

         function FindPosition(oElement) {
            if(typeof( oElement.offsetParent ) != "undefined") {
               for(var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent) {
                  posX += oElement.offsetLeft;
                  posY += oElement.offsetTop;
               }
               return [ posX, posY ];
            } else {
               return [ oElement.x, oElement.y ];
            }
         }

         function GetCoordinates(e) {
            var PosX = 0;
            var PosY = 0;
            var ImgPos;
            ImgPos = FindPosition(myImg);
            if (!e) var e = window.event;
            if (e.pageX || e.pageY) {
               PosX = e.pageX;
               PosY = e.pageY;
            } else if (e.clientX || e.clientY) {
               PosX = e.clientX + document.body.scrollLeft
                 + document.documentElement.scrollLeft;
               PosY = e.clientY + document.body.scrollTop
                 + document.documentElement.scrollTop;
            }
            PosX = PosX - ImgPos[0];
            PosY = PosY - ImgPos[1];

            document.pointform.x.value = PosX;
            document.pointform.y.value = PosY;
         }

         var myImg = document.getElementById("myImgId");
         myImg.onmousedown = GetCoordinates;

         </script>';
            echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=weathermap-" . $weathermaps_id . ".png' id='myImgId' />";
        } else {
            echo '<div id="pointer_div" onclick="point_it(event)" style = "background-image:url(\'' . $this->fields['background'] . '\');">
            <img id="cross" style="position:relative;visibility:hidden;z-index:2;">
            ' . $map . '</div>';
            echo '<script language="JavaScript">
         function point_it(event){
            pos_x = event.offsetX?(event.offsetX):event.pageX;
            pos_y = event.offsetY?(event.offsetY):event.pageY;
            document.getElementById("cross").style.left = (pos_x-1) ;
            document.getElementById("cross").style.top = (pos_y-15) ;

            var topValue= 0;
            var leftValue= 0;
            var obj = document.getElementById("pointer_div");
            while(obj){
               leftValue+= obj.offsetLeft;
               topValue+= obj.offsetTop;
               obj= obj.offsetParent;
            }


            document.pointform.x.value = pos_x-leftValue;
            document.pointform.y.value = pos_y-topValue;

         }
         </script>';
        }
        echo "</td>";
        echo "<td valign='top'>";
        echo '<form name="pointform" method="post" action="' . $CFG_GLPI['root_doc'] . '/plugins/monitoring/front/weathermapnode.form.php">';
        echo "<table align='center'>";
        echo "<tr>";
        echo "<td>";
        echo "x :";
        echo "</td>";
        echo "<td>";
        echo '<input type="text" name="x" size="4" />';
        echo "</td>";
        echo "<td>";
        echo "y :";
        echo "</td>";
        echo "<td>";
        echo '<input type="text" name="y" size="4" />';
        echo "</td>";
        echo "</tr>";
        echo "</table>";
        echo "<input type='hidden' name='plugin_monitoring_weathermaps_id' value='" . $weathermaps_id . "' />";
        echo "<table class='tab_cadre'>";
        // * Add node
        echo "<tr>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][8];
        echo "</th>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo $LANG['plugin_monitoring']['weathermap'][7] . "&nbsp;:";
        echo "</td>";
        echo "<td>";
        Dropdown::showAllItems("items_id");
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo $LANG['common'][16] . "&nbsp;:";
        echo "</td>";
        echo "<td>";
        echo "<input type='text' name='name' value='' />";
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td align='center' colspan='2'>";
        echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
        echo "</td>";
        echo "</tr>";
        // * Change node position
        echo "<tr>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][9];
        echo "</th>";
        echo "</tr>";
        echo "<tr>";
        echo "<td colspan='2' align='center'>";
        $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n            WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n            ORDER BY `name`";
        $result = $DB->query($query);
        $elements = array();
        $elements[0] = DROPDOWN_EMPTY_VALUE;
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            $name = $data['name'];
            if ($name == '') {
                $name = $item->getName();
            }
            $elements[$data['id']] = $name;
        }
        $rand = Dropdown::showFromArray('id_update', $elements);
        $params = array('items_id' => '__VALUE__', 'rand' => $rand);
        ajaxUpdateItemOnSelectEvent("dropdown_id_update{$rand}", "show_updatenode{$rand}", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownWnode.php", $params, false);
        echo "<span id='show_updatenode{$rand}'></span>\n";
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td align='center' colspan='2'>";
        echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
        echo "</td>";
        echo "</tr>";
        // * Delete node
        echo "<tr>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][10];
        echo "</th>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo "</td>";
        echo "<td>";
        $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n            WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n            ORDER BY `name`";
        $result = $DB->query($query);
        $elements = array();
        $elements[0] = DROPDOWN_EMPTY_VALUE;
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            $name = $data['name'];
            if ($name == '') {
                $name = $item->getName();
            }
            $elements[$data['id']] = $name;
        }
        Dropdown::showFromArray('id', $elements);
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td align='center' colspan='2'>";
        echo "<input type='submit' name='purge' value=\"" . $LANG['buttons'][22] . "\" class='submit'>";
        echo "</td>";
        echo "</tr>";
        echo "</table>";
        echo "</form><br/>";
        echo '<form name="formlink" method="post" action="' . $CFG_GLPI['root_doc'] . '/plugins/monitoring/front/weathermaplink.form.php">';
        echo "<table class='tab_cadre'>";
        // *Add Link
        echo "<tr>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][11];
        echo "</th>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo $LANG['plugin_monitoring']['weathermap'][14] . "*&nbsp;:";
        echo "</td>";
        echo "<td>";
        $query = "SELECT `glpi_plugin_monitoring_weathermapnodes`.`id` as `id`,\n               `glpi_plugin_monitoring_weathermapnodes`.`name` as `name`,\n               `glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`, \n               `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id`,\n               `glpi_plugin_monitoring_services`.`id` as `services_id`,\n               `glpi_plugin_monitoring_components`.`name` as `components_name`,\n               `plugin_monitoring_commands_id`, `glpi_plugin_monitoring_components`.`arguments`,\n               `glpi_plugin_monitoring_services`.`networkports_id`\n            FROM `glpi_plugin_monitoring_weathermapnodes`\n            \n            LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n               ON (`glpi_plugin_monitoring_weathermapnodes`.`items_id`=`glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id`\n                  AND `glpi_plugin_monitoring_weathermapnodes`.`itemtype`=`glpi_plugin_monitoring_componentscatalogs_hosts`.`itemtype`)\n            \n            LEFT JOIN `glpi_plugin_monitoring_services` \n               ON `plugin_monitoring_componentscatalogs_hosts_id`= `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n\n            LEFT JOIN `glpi_plugin_monitoring_components` \n               ON `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id`\n            \n\n            WHERE `is_weathermap` = '1'\n               AND `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n            ORDER BY `itemtype`,`items_id`,`glpi_plugin_monitoring_components`.`name`";
        $elements = array();
        $elements[0] = DROPDOWN_EMPTY_VALUE;
        $elements2 = array();
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            $name = $data['name'];
            if ($name == '') {
                $name = $item->getName();
            }
            // Try to get device/node connected on this port
            $device_connected = '';
            if ($data['arguments'] != '') {
                $arguments = importArrayFromDB($data['arguments']);
                foreach ($arguments as $argument) {
                    if (!is_numeric($argument)) {
                        if (strstr($argument, "[[NETWORKPORTDESCR]]")) {
                            if (class_exists("PluginFusinvsnmpNetworkPort")) {
                                $pfNetworkPort = new PluginFusinvsnmpNetworkPort();
                                $pfNetworkPort->loadNetworkport($data['networkports_id']);
                                $argument = $pfNetworkPort->getValue("ifdescr");
                            }
                        } elseif (strstr($argument, "[[NETWORKPORTNUM]]")) {
                            $networkPort = new NetworkPort();
                            $networkPort->getFromDB($data['networkports_id']);
                            $argument = $pfNetworkPort->fields['logical_number'];
                        } elseif (strstr($argument, "[[NETWORKPORTNAME]]")) {
                            $networkPort = new NetworkPort();
                            $networkPort->getFromDB($data['networkports_id']);
                            $argument = $pfNetworkPort->fields['name'];
                        }
                        // Search networkport have this name or description
                        $a_ports = $networkPort->find("`itemtype`='" . $itemtype . "'\n                        AND `items_id`='" . $data['items_id'] . "'\n                        AND `name`='" . $argument . "'");
                        foreach ($a_ports as $pdata) {
                            if ($device_connected == '') {
                                $oppositeports_id = $networkPort->getContact($pdata['id']);
                                if ($oppositeports_id) {
                                    $networkPort->getFromDB($oppositeports_id);
                                    $a_nodes = $pmWeathermapnode->find("\n                                 `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n                                 AND `itemtype`='" . $networkPort->fields['itemtype'] . "'\n                                 AND `items_id`='" . $networkPort->fields['items_id'] . "'", "", 1);
                                    if (count($a_nodes) > 0) {
                                        $a_node = current($a_nodes);
                                        $device_connected = $pmWeathermapnode->getNodeName($a_node['id']);
                                    }
                                }
                            }
                        }
                        if ($device_connected == '' and class_exists("PluginFusinvsnmpNetworkPort")) {
                            $queryn = "SELECT `glpi_networkports`.`id` FROM `glpi_plugin_fusinvsnmp_networkports`\n                           \n                           LEFT JOIN `glpi_networkports`\n                              ON `glpi_networkports`.`id`=`networkports_id`\n                              \n                           WHERE `itemtype`='" . $itemtype . "'\n                           AND `items_id`='" . $data['items_id'] . "'\n                           AND `ifdescr`='" . $argument . "'";
                            $resultn = $DB->query($queryn);
                            while ($pdata = $DB->fetch_array($resultn)) {
                                if ($device_connected == '') {
                                    $oppositeports_id = $networkPort->getContact($pdata['id']);
                                    if ($oppositeports_id) {
                                        $networkPort->getFromDB($oppositeports_id);
                                        $a_nodes = $pmWeathermapnode->find("\n                                    `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n                                    AND `itemtype`='" . $networkPort->fields['itemtype'] . "'\n                                    AND `items_id`='" . $networkPort->fields['items_id'] . "'", "", 1);
                                        if (count($a_nodes) > 0) {
                                            $a_node = current($a_nodes);
                                            $queryl = "SELECT `plugin_monitoring_weathermapnodes_id_1`\n                                       FROM `glpi_plugin_monitoring_weathermaplinks`\n\n                                       LEFT JOIN `glpi_plugin_monitoring_weathermapnodes`\n                                          ON `glpi_plugin_monitoring_weathermapnodes`.`id` = `plugin_monitoring_weathermapnodes_id_1`\n\n                                       WHERE ((`plugin_monitoring_weathermapnodes_id_1`='" . $data['id'] . "'\n                                                   AND `plugin_monitoring_weathermapnodes_id_2`='" . $a_node['id'] . "')\n                                                OR (`plugin_monitoring_weathermapnodes_id_1`='" . $a_node['id'] . "'\n                                                   AND `plugin_monitoring_weathermapnodes_id_2`='" . $data['id'] . "'))\n                                          AND `plugin_monitoring_weathermaps_id` = '" . $weathermaps_id . "'";
                                            $resultl = $DB->query($queryl);
                                            if ($DB->numrows($resultl) == '0') {
                                                $device_connected = $pmWeathermapnode->getNodeName($a_node['id']);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if ($device_connected == '') {
                $networkPort->getFromDB($data['networkports_id']);
                $elements2[$data['id'] . "-" . $data['services_id']] = $name . " [" . $networkPort->fields['name'] . "] (" . $data['components_name'] . ")";
            } else {
                $networkPort->getFromDB($data['networkports_id']);
                $elements[$data['id'] . "-" . $data['services_id']] = $name . " [" . $networkPort->fields['name'] . "] (" . $data['components_name'] . ") > " . $device_connected;
            }
        }
        if (count($elements) > 1 and count($elements2) > 0) {
            $elements = array_merge($elements, array('0' => DROPDOWN_EMPTY_VALUE));
            $elements = array_merge($elements, $elements2);
        } else {
            $elements = array_merge($elements, $elements2);
        }
        Dropdown::showFromArray('linksource', $elements);
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo $LANG['plugin_monitoring']['weathermap'][15] . "&nbsp;:";
        echo "</td>";
        echo "<td>";
        echo "<div id='nodedestination'>";
        $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n            WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n            ORDER BY `name`";
        $result = $DB->query($query);
        $elements = array();
        $elements[0] = DROPDOWN_EMPTY_VALUE;
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            $name = $data['name'];
            if ($name == '') {
                $name = $item->getName();
            }
            $elements[$data['id']] = $name;
        }
        Dropdown::showFromArray('plugin_monitoring_weathermapnodes_id_2', $elements);
        echo "</div>";
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo $LANG['plugin_monitoring']['weathermap'][16] . "&nbsp;:";
        echo "</td>";
        echo "<td>";
        echo "<input type='text' name='bandwidth_in' value=''/>";
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo $LANG['plugin_monitoring']['weathermap'][17] . "&nbsp;:";
        echo "</td>";
        echo "<td>";
        echo "<input type='text' name='bandwidth_out' value=''/>";
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td align='center' colspan='2'>";
        echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
        echo "</td>";
        echo "</tr>";
        // * Edit link
        echo "<tr>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][12];
        echo "</th>";
        echo "</tr>";
        echo "<tr>";
        echo "<td colspan='2' align='center'>";
        $pmWeathermapnode = new PluginMonitoringWeathermapnode();
        $query = "SELECT `glpi_plugin_monitoring_weathermaplinks`.`id` as `id`,\n               `itemtype`, `items_id`, `name`, `plugin_monitoring_weathermapnodes_id_2`\n            FROM `glpi_plugin_monitoring_weathermaplinks`\n            \n            LEFT JOIN `glpi_plugin_monitoring_weathermapnodes`\n               ON `glpi_plugin_monitoring_weathermapnodes`.`id` = `plugin_monitoring_weathermapnodes_id_1`\n\n            WHERE `plugin_monitoring_weathermaps_id` = '" . $weathermaps_id . "'";
        $elements = array();
        $elements[0] = DROPDOWN_EMPTY_VALUE;
        $result = $DB->query($query);
        while ($data = $DB->fetch_array($result)) {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            $name1 = $data['name'];
            if ($name1 == '') {
                $name1 = $item->getName();
            }
            $pmWeathermapnode->getFromDB($data['plugin_monitoring_weathermapnodes_id_2']);
            $itemtype = $pmWeathermapnode->fields['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($pmWeathermapnode->fields['items_id']);
            $name2 = $pmWeathermapnode->fields['name'];
            if ($name2 == '') {
                $name2 = $item->getName();
            }
            $elements[$data['id']] = $name1 . " - " . $name2;
        }
        $rand = Dropdown::showFromArray('id_update', $elements);
        $params = array('items_id' => '__VALUE__', 'rand' => $rand);
        ajaxUpdateItemOnSelectEvent("dropdown_id_update{$rand}", "show_updatelink{$rand}", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownWlink.php", $params, false);
        echo "<span id='show_updatelink{$rand}'></span>\n";
        echo "</td>";
        echo "</tr>";
        // * Delete link
        echo "<tr>";
        echo "<th colspan='2'>";
        echo $LANG['plugin_monitoring']['weathermap'][13];
        echo "</th>";
        echo "</tr>";
        echo "<tr>";
        echo "<td>";
        echo "Link :";
        echo "</td>";
        echo "<td>";
        Dropdown::showFromArray('id', $elements);
        echo "</td>";
        echo "</tr>";
        echo "<tr>";
        echo "<td align='center' colspan='2'>";
        echo "<input type='submit' name='purge' value=\"" . $LANG['buttons'][22] . "\" class='submit'>";
        echo "</td>";
        echo "</tr>";
        echo "</table>";
        echo "</form>";
        echo "</td>";
        echo "</tr>";
    }
 /**
  * Make a select box for  connected port
  *
  * Parameters which could be used in options array :
  *    - name : string / name of the select (default is networkports_id)
  *    - comments : boolean / is the comments displayed near the dropdown (default true)
  *    - entity : integer or array / restrict to a defined entity or array of entities
  *                   (default -1 : no restriction)
  *    - entity_sons : boolean / if entity restrict specified auto select its sons
  *                   only available if entity is a single value not an array (default false)
  *
  * @param $ID ID of the current port to connect
  * @param $options possible options
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdownConnect($ID, $options = array())
 {
     global $LANG, $CFG_GLPI;
     $p['name'] = 'networkports_id';
     $p['comments'] = 1;
     $p['entity'] = -1;
     $p['entity_sons'] = false;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     // Manage entity_sons
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     $rand = mt_rand();
     echo "<select name='itemtype[{$ID}]' id='itemtype{$rand}'>";
     echo "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option>";
     foreach ($CFG_GLPI["networkport_types"] as $key => $itemtype) {
         if (class_exists($itemtype)) {
             $item = new $itemtype();
             echo "<option value='" . $itemtype . "'>" . $item->getTypeName() . "</option>";
         } else {
             unset($CFG_GLPI["networkport_types"][$key]);
         }
     }
     echo "</select>";
     $params = array('itemtype' => '__VALUE__', 'entity_restrict' => $p['entity'], 'current' => $ID, 'comments' => $p['comments'], 'myname' => $p['name']);
     ajaxUpdateItemOnSelectEvent("itemtype{$rand}", "show_" . $p['name'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownConnectPortDeviceType.php", $params);
     echo "<span id='show_" . $p['name'] . "{$rand}'>&nbsp;</span>\n";
     return $rand;
 }
 /**
  * Dropdown of actions for massive action
  *
  * @param $itemtype item type
  * @param $is_deleted massive action for deleted items ?
  * @param $extraparams array of extra parameters
  **/
 static function showForMassiveAction($itemtype, $is_deleted = 0, $extraparams = array())
 {
     global $LANG, $CFG_GLPI, $PLUGIN_HOOKS;
     /// TODO include in CommonDBTM defining only getAdditionalMassiveAction in sub classes
     /// for specific actions (return a array of action name and title)
     if (!class_exists($itemtype)) {
         return false;
     }
     if ($itemtype == 'NetworkPort') {
         echo "<select name='massiveaction' id='massiveaction'>";
         echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
         echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
         echo "<option value='assign_vlan'>" . $LANG['networking'][55] . "</option>";
         echo "<option value='unassign_vlan'>" . $LANG['networking'][58] . "</option>";
         // Interest of this massive action ?
         //          echo "<option value='move'>".$LANG['buttons'][20]."</option>";
         echo "</select>";
         $params = array('action' => '__VALUE__', 'itemtype' => $itemtype);
         ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionPorts.php", $params);
         echo "<span id='show_massiveaction'>&nbsp;</span>\n";
     } else {
         $item = new $itemtype();
         $infocom = new Infocom();
         $isadmin = $item->canUpdate();
         echo "<select name='massiveaction' id='massiveaction'>";
         echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
         if (!in_array($itemtype, $CFG_GLPI["massiveaction_noupdate_types"]) && ($isadmin && $itemtype != 'Ticket' || in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canUpdate() || $itemtype == 'Ticket' && haveRight('update_ticket', 1))) {
             echo "<option value='update'>" . $LANG['buttons'][14] . "</option>";
         }
         if (in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canCreate()) {
             echo "<option value='activate_infocoms'>" . $LANG['financial'][68] . "</option>";
         }
         if ($is_deleted && !in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"])) {
             if ($isadmin) {
                 echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>";
                 echo "<option value='restore'>" . $LANG['buttons'][21] . "</option>";
             }
         } else {
             // No delete for entities and tracking of not have right
             if (!in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"]) && ($isadmin && $itemtype != 'Ticket' || $itemtype == 'Ticket' && haveRight('delete_ticket', 1))) {
                 if ($item->maybeDeleted()) {
                     echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
                 } else {
                     echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>";
                 }
             }
             if ($isadmin && in_array($itemtype, array('Phone', 'Printer', 'Peripheral', 'Monitor'))) {
                 echo "<option value='connect'>" . $LANG['buttons'][9] . "</option>";
                 echo "<option value='disconnect'>" . $LANG['buttons'][10] . "</option>";
             }
             if (in_array($itemtype, $CFG_GLPI["document_types"])) {
                 $doc = new Document();
                 if ($doc->canView()) {
                     echo "<option value='add_document'>" . $LANG['document'][16] . "</option>";
                 }
             }
             if (in_array($itemtype, $CFG_GLPI["contract_types"])) {
                 $contract = new Contract();
                 if ($contract->canUpdate()) {
                     echo "<option value='add_contract'>" . $LANG['financial'][36] . "</option>";
                 }
             }
             if (haveRight('transfer', 'r') && isMultiEntitiesMode() && in_array($itemtype, array('CartridgeItem', 'Computer', 'ConsumableItem', 'Contact', 'Contract', 'Supplier', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer', 'Software', 'SoftwareLicense', 'Ticket', 'Document', 'Group', 'Link')) && $isadmin) {
                 echo "<option value='add_transfer_list'>" . $LANG['buttons'][48] . "</option>";
             }
             switch ($itemtype) {
                 case 'Software':
                     if ($isadmin && countElementsInTable("glpi_rules", "sub_type='RuleSoftwareCategory'") > 0) {
                         echo "<option value='compute_software_category'>" . $LANG['rulesengine'][38] . " " . $LANG['rulesengine'][40] . "</option>";
                     }
                     if (haveRight("rule_dictionnary_software", "w") && countElementsInTable("glpi_rules", "sub_type='RuleDictionnarySoftware'") > 0) {
                         echo "<option value='replay_dictionnary'>" . $LANG['rulesengine'][76] . "</option>";
                     }
                     break;
                 case 'Computer':
                     if ($isadmin) {
                         echo "<option value='connect_to_computer'>" . $LANG['buttons'][9] . "</option>";
                         echo "<option value='install'>" . $LANG['buttons'][4] . "</option>";
                         if ($CFG_GLPI['use_ocs_mode']) {
                             if (haveRight("ocsng", "w") || haveRight("sync_ocsng", "w")) {
                                 echo "<option value='force_ocsng_update'>" . $LANG['ocsng'][24] . "</option>";
                             }
                             echo "<option value='unlock_ocsng_field'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][16] . "</option>";
                             echo "<option value='unlock_ocsng_monitor'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][30] . "</option>";
                             echo "<option value='unlock_ocsng_peripheral'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][32] . "</option>";
                             echo "<option value='unlock_ocsng_printer'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][34] . "</option>";
                             echo "<option value='unlock_ocsng_software'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][52] . "</option>";
                             echo "<option value='unlock_ocsng_ip'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][50] . "</option>";
                             echo "<option value='unlock_ocsng_disk'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][55] . "</option>";
                         }
                     }
                     break;
                 case 'Supplier':
                     if ($isadmin) {
                         echo "<option value='add_contact'>" . $LANG['financial'][24] . "</option>";
                     }
                     break;
                 case 'Calendar':
                     echo "<option value='duplicate'>" . $LANG['buttons'][54] . "</option>";
                     break;
                 case 'Contact':
                     if ($isadmin) {
                         echo "<option value='add_enterprise'>" . $LANG['financial'][25] . "</option>";
                     }
                     break;
                 case 'User':
                     if ($isadmin) {
                         echo "<option value='add_group'>" . $LANG['setup'][604] . "</option>";
                         echo "<option value='add_userprofile'>" . $LANG['setup'][607] . "</option>";
                     }
                     if (haveRight("user_authtype", "w")) {
                         echo "<option value='change_authtype'>" . $LANG['login'][30] . "</option>";
                         echo "<option value='force_user_ldap_update'>" . $LANG['ocsng'][24] . "</option>";
                     }
                     break;
                 case 'Ticket':
                     $tmp = new TicketFollowup();
                     if ($tmp->canCreate()) {
                         echo "<option value='add_followup'>" . $LANG['job'][29] . "</option>";
                     }
                     $tmp = new TicketTask();
                     if ($tmp->canCreate()) {
                         echo "<option value='add_task'>" . $LANG['job'][30] . "</option>";
                     }
                     $tmp = new TicketValidation();
                     if ($tmp->canCreate()) {
                         echo "<option value='submit_validation'>" . $LANG['validation'][26] . "</option>";
                     }
                     if (haveRight("update_ticket", "1")) {
                         echo "<option value='add_actor'>" . $LANG['job'][27] . "</option>";
                         echo "<option value='link_ticket'>" . $LANG['job'][56] . "</option>";
                     }
                     break;
                 case 'CronTask':
                     echo "<option value='reset'>" . $LANG['buttons'][16] . " (" . $LANG['crontask'][40] . ")";
                     echo "</option>";
                     break;
                 case 'NotImportedEmail':
                     echo "<option value='delete_email'>" . $LANG['mailing'][133] . "</option>";
                     echo "<option value='import_email'>" . $LANG['buttons'][37] . "</option>";
                     break;
             }
             if ($item instanceof CommonTreeDropdown) {
                 if ($isadmin) {
                     echo "<option value='move_under'>" . $LANG['buttons'][20] . "</option>";
                 }
             }
             if ($itemtype != 'Entity' && $itemtype != 'Calendar' && $item instanceof CommonDropdown && $item->maybeRecursive()) {
                 if ($isadmin) {
                     echo "<option value='merge'>" . $LANG['buttons'][48] . " - " . $LANG['software'][48];
                     echo "</option>";
                 }
             }
             // Plugin Specific actions
             if (isset($PLUGIN_HOOKS['use_massive_action'])) {
                 foreach ($PLUGIN_HOOKS['use_massive_action'] as $plugin => $val) {
                     $actions = doOneHook($plugin, 'MassiveActions', $itemtype);
                     if (count($actions)) {
                         foreach ($actions as $key => $val) {
                             echo "<option value = '{$key}'>{$val}</option>";
                         }
                     }
                 }
             }
         }
         echo "</select>";
         $params = array('action' => '__VALUE__', 'is_deleted' => $is_deleted, 'itemtype' => $itemtype);
         if (count($extraparams)) {
             foreach ($extraparams as $key => $val) {
                 $params['extra_' . $key] = $val;
             }
         }
         ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveAction.php", $params);
         echo "<span id='show_massiveaction'>&nbsp;</span>\n";
     }
 }
 function selectCriterias()
 {
     global $DB, $CFG_GLPI;
     echo "<span id='span_fields' name='span_fields'>";
     if (!isset($this->fields['itemtype']) || !$this->fields['itemtype']) {
         echo "</span>";
         return;
     }
     if (!isset($this->fields['entities_id'])) {
         $this->fields['entities_id'] = $_SESSION['glpiactive_entity'];
     }
     $target = new $this->fields['itemtype']();
     $criteria = array();
     foreach ($DB->list_fields($target->getTable()) as $field) {
         $searchOption = $target->getSearchOptionByField('field', $field['Field']);
         if (empty($searchOption)) {
             if ($table = getTableNameForForeignKeyField($field['Field'])) {
                 $searchOption = $target->getSearchOptionByField('field', 'name', $table);
             }
         }
         if (!empty($searchOption) && !in_array($field['Type'], $target->getUnallowedFieldsForUnicity()) && !in_array($field['Field'], $target->getUnallowedFieldsForUnicity())) {
             $criteria[$field['Field']] = $searchOption['name'];
         }
     }
     $rand = Dropdown::showFromArray('field', $criteria, array('value' => $this->fields['field']));
     $params = array('itemtype' => $this->fields['itemtype'], 'id_field' => '__VALUE__', 'id' => $this->fields['id']);
     ajaxUpdateItemOnSelectEvent("dropdown_field{$rand}", "span_values", $CFG_GLPI["root_doc"] . "/ajax/dropdownValuesBlacklist.php", $params);
     echo "</span>";
 }
Beispiel #12
0
 /**
  * Display the dropdown of the actions for the rule
  *
  * @param $used already used actions
  *
  * @return the initial value (first non used)
  **/
 function dropdownActions($used = array())
 {
     global $CFG_GLPI;
     $actions = $this->getActions();
     // Complete used array with duplicate items
     // add duplicates of used items
     foreach ($used as $ID) {
         if (isset($actions[$ID]['duplicatewith'])) {
             $used[$actions[$ID]['duplicatewith']] = $actions[$ID]['duplicatewith'];
         }
     }
     // Parse for duplicates of already used items
     foreach ($actions as $ID => $act) {
         if (isset($actions[$ID]['duplicatewith']) && in_array($actions[$ID]['duplicatewith'], $used)) {
             $used[$ID] = $ID;
         }
     }
     $items = array();
     $value = '';
     foreach ($actions as $ID => $act) {
         $items[$ID] = $act['name'];
         if (empty($value) && !isset($used[$ID])) {
             $value = $ID;
         }
     }
     asort($items);
     $rand = Dropdown::showFromArray("field", $items, array('value' => $value, 'used' => $used));
     $params = array('field' => '__VALUE__', 'sub_type' => $this->getType());
     ajaxUpdateItemOnSelectEvent("dropdown_field{$rand}", "action_span", $CFG_GLPI["root_doc"] . "/ajax/ruleaction.php", $params, false);
     return $value;
 }
 /**
  * Print generic search form
  *
  * @param $itemtype type to display the form
  * @param $params parameters array may include field, contains, sort, is_deleted, link, link2,
  *                                             contains2, field2, type2
  *
  *@return nothing (displays)
  **/
 static function showGenericSearch($itemtype, $params)
 {
     global $LANG, $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = self::getCleanedOptions($itemtype);
     $target = getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $linked = self::getMetaItemtypeAvailable($itemtype);
     echo "<form name='searchform{$itemtype}' method='get' action=\"{$target}\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo "<table>";
     // Display normal search parameters
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         echo "<tr><td class='left' width='50%'>";
         // First line display add / delete images for normal and meta search items
         if ($i == 0) {
             echo "<input type='hidden' disabled id='add_search_count' name='add_search_count'\n                   value='1'>";
             echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;\n                   document.forms['searchform{$itemtype}'].submit();\">";
             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title=\"" . $LANG['search'][17] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
                 echo "<input type='hidden' disabled id='delete_search_count'\n                      name='delete_search_count' value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title=\"" . $LANG['search'][18] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             }
             if (is_array($linked) && count($linked) > 0) {
                 echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2'\n                      value='1'>";
                 echo "<a href='#' onClick=\"document.getElementById('add_search_count2').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title=\"" . $LANG['search'][19] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
                     echo "<input type='hidden' disabled id='delete_search_count2'\n                         name='delete_search_count2' value='1'>";
                     echo "<a href='#' onClick=\"document.getElementById('delete_search_count2').disabled=false;\n                         document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . $LANG['search'][20] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 }
             }
             $itemtable = getTableForItemType($itemtype);
             if ($item && $item->maybeDeleted()) {
                 echo "<input type='hidden' id='is_deleted' name='is_deleted' value='" . $p['is_deleted'] . "'>";
                 echo "<a href='#' onClick = \"toogle('is_deleted','','','');\n                      document.forms['searchform{$itemtype}'].submit();\">\n                      <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/showdeleted" . (!$p['is_deleted'] ? '_no' : '') . ".png\" name='img_deleted'  alt=\"" . (!$p['is_deleted'] ? $LANG['common'][3] : $LANG['common'][81]) . "\" title=\"" . (!$p['is_deleted'] ? $LANG['common'][3] : $LANG['common'][81]) . "\" ></a>";
                 // Dropdown::showYesNo("is_deleted",$p['is_deleted']);
                 echo '&nbsp;&nbsp;';
             }
         }
         // Display link item
         if ($i > 0) {
             echo "<select name='link[{$i}]'>";
             echo "<option value = 'AND' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>&nbsp;";
         }
         // display select box to define search item
         echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
         echo "<option value='view' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
             echo "selected";
         }
         echo ">" . $LANG['search'][11] . "</option>\n";
         reset($options);
         $first_group = true;
         $selected = 'view';
         $str_limit = 28;
         $nb_in_group = 0;
         $group = '';
         foreach ($options as $key => $val) {
             // print groups
             if (!is_array($val)) {
                 if (!$first_group) {
                     $group .= "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 if ($nb_in_group) {
                     echo $group;
                 }
                 $group = '';
                 $nb_in_group = 0;
                 $group .= "<optgroup label=\"" . utf8_substr($val, 0, $str_limit) . "\">";
             } else {
                 if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                     $nb_in_group++;
                     $group .= "<option title=\"" . cleanInputText($val["name"]) . "\" value='{$key}'";
                     if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                         $group .= "selected";
                         $selected = $key;
                     }
                     $group .= ">" . utf8_substr($val["name"], 0, $str_limit) . "</option>\n";
                 }
             }
         }
         if (!$first_group) {
             $group .= "</optgroup>\n";
         }
         if ($nb_in_group) {
             echo $group;
         }
         echo "<option value='all' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
             echo "selected";
         }
         echo ">" . $LANG['common'][66] . "</option>";
         echo "</select>\n";
         echo "</td><td class='left'>";
         echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
         $_POST['itemtype'] = $itemtype;
         $_POST['num'] = $i;
         $_POST['field'] = $selected;
         $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
         $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
         include GLPI_ROOT . "/ajax/searchoption.php";
         echo "</div>\n";
         $params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
         ajaxUpdateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false);
         echo "</td></tr>\n";
     }
     $metanames = array();
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             echo "<tr><td class='left' colspan='2'>";
             $rand = mt_rand();
             echo "<table width='100%'><tr class='left'><td width='35%'>";
             // Display link item (not for the first item)
             echo "<select name='link2[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>\n";
             echo "</select>&nbsp;";
             // Display select of the linked item type available
             echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
             echo "<option value=''>" . DROPDOWN_EMPTY_VALUE . "</option>";
             foreach ($linked as $key) {
                 if (!isset($metanames[$key])) {
                     $linkitem = new $key();
                     $metanames[$key] = $linkitem->getTypeName();
                 }
                 echo "<option value='{$key}'>" . utf8_substr($metanames[$key], 0, 20) . "</option>\n";
             }
             echo "</select>&nbsp;";
             echo "</td><td>";
             // Ajax script for display search met& item
             echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'>&nbsp;</span>\n";
             $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
             ajaxUpdateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
             if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
                 $params['itemtype'] = $p['itemtype2'][$i];
                 ajaxUpdateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
                 echo "<script type='text/javascript' >";
                 echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
                 echo "</script>\n";
             }
             echo "</td></tr></table>";
             echo "</td></tr>\n";
         }
     }
     echo "</table>\n";
     echo "</td>\n";
     echo "<td width='150px'>";
     echo "<table width='100%'>";
     // Display sort selection
     /*      echo "<tr><td colspan='2'>".$LANG['search'][4];
           echo "&nbsp;<select name='sort' size='1'>";
           reset($options);
           $first_group=true;
           foreach ($options as $key => $val) {
              if (!is_array($val)) {
                 if (!$first_group) {
                    echo "</optgroup>\n";
                 } else {
                    $first_group=false;
                 }
                 echo "<optgroup label=\"$val\">";
              } else {
                 echo "<option value='$key'";
                 if ($key == $p['sort']) {
                    echo " selected";
                 }
                 echo ">".utf8_substr($val["name"],0,20)."</option>\n";
              }
           }
           if (!$first_group) {
              echo "</optgroup>\n";
           }
           echo "</select> ";
           echo "</td></tr>\n";
     */
     // Display deleted selection
     echo "<tr>";
     // Display submit button
     echo "<td width='80' class='center'>";
     echo "<input type='submit' value=\"" . $LANG['buttons'][0] . "\" class='submit' >";
     echo "</td><td>";
     Bookmark::showSaveButton(BOOKMARK_SEARCH, $itemtype);
     echo "<a href='{$target}?reset=reset' >";
     echo "&nbsp;&nbsp;<img title=\"" . $LANG['buttons'][16] . "\" alt=\"" . $LANG['buttons'][16] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
     echo "</td></tr></table>\n";
     echo "</td></tr>";
     echo "</table>\n";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     echo "</form>";
 }
        echo $key . "--";
        if (!isPluginItemType($key) && !isset($val["nometa"])) {
            $newgroup .= "<option value='{$key}' title=\"" . cleanInputText($val["name"]) . "\"";
            if ($key == $_POST["field"]) {
                $newgroup .= "selected";
            }
            $newgroup .= ">" . utf8_substr($val["name"], 0, 20) . "</option>\n";
            $items_in_group++;
        }
    }
}
if (!empty($newgroup) && $items_in_group > 0) {
    echo $newgroup;
}
if (!$first_group) {
    echo "</optgroup>";
}
echo "</select>";
echo "</td><td class='left'>";
echo "<span id='Search2Span" . $_POST["itemtype"] . $_POST["num"] . "'>\n";
$_POST['itemtype'] = $_POST["itemtype"];
$_POST['num'] = $_POST["num"];
$_POST['field'] = $_POST["field"];
$_POST['searchtype'] = $_POST["searchtype2"];
$_POST['value'] = $_POST["value"];
$_POST['meta'] = 1;
include GLPI_ROOT . "/ajax/searchoption.php";
echo "</span>\n";
$params = array('field' => '__VALUE__', 'itemtype' => $_POST["itemtype"], 'num' => $_POST["num"], 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype2"], 'meta' => 1);
ajaxUpdateItemOnSelectEvent("Search2" . $_POST["itemtype"] . $_POST["num"], "Search2Span" . $_POST["itemtype"] . $_POST["num"], $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false);
echo '</td></tr></table>';
Beispiel #15
0
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "ruleaction.php")) {
    define('GLPI_ROOT', '..');
    include GLPI_ROOT . "/inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    header_nocache();
}
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
checkLoginUser();
// Non define case
if (isset($_POST["sub_type"]) && class_exists($_POST["sub_type"])) {
    if (!isset($_POST["field"])) {
        $_POST["field"] = key(Rule::getActionsByType($_POST["sub_type"]));
    }
    $randaction = RuleAction::dropdownActions($_POST["sub_type"], "action_type", $_POST["field"]);
    echo "&nbsp;&nbsp;";
    echo "<span id='action_type_span{$randaction}'>\n";
    echo "</span>\n";
    $paramsaction = array('action_type' => '__VALUE__', 'field' => $_POST["field"], 'sub_type' => $_POST["sub_type"]);
    ajaxUpdateItemOnSelectEvent("dropdown_action_type{$randaction}", "action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction, false);
    ajaxUpdateItem("action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction, false, "dropdown_action_type{$randaction}");
}
 /**
  * Make a select box for link document
  *
  * Parameters which could be used in options array :
  *    - name : string / name of the select (default is documents_id)
  *    - entity : integer or array / restrict to a defined entity or array of entities
  *                   (default -1 : no restriction)
  *    - used : array / Already used items ID: not to display in dropdown (default empty)
  *
  * @param $options possible options
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdown($options = array())
 {
     global $DB, $LANG, $CFG_GLPI;
     $p['name'] = 'documents_id';
     $p['entity'] = '';
     $p['used'] = array();
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $rand = mt_rand();
     $where = " WHERE `glpi_documents`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_documents", '', $p['entity'], true);
     if (count($p['used'])) {
         $where .= " AND `id` NOT IN ('0','" . implode("','", $p['used']) . "')";
     }
     $query = "SELECT *\n                FROM `glpi_documentcategories`\n                WHERE `id` IN (SELECT DISTINCT `documentcategories_id`\n                               FROM `glpi_documents`\n                             {$where})\n                ORDER BY `name`";
     $result = $DB->query($query);
     echo "<select name='_rubdoc' id='rubdoc{$rand}'>";
     echo "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option>";
     while ($data = $DB->fetch_assoc($result)) {
         echo "<option value='" . $data['id'] . "'>" . $data['name'] . "</option>";
     }
     echo "</select>";
     $params = array('rubdoc' => '__VALUE__', 'entity' => $p['entity'], 'rand' => $rand, 'myname' => $p['name'], 'used' => $p['used']);
     ajaxUpdateItemOnSelectEvent("rubdoc{$rand}", "show_" . $p['name'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownRubDocument.php", $params);
     echo "<span id='show_" . $p['name'] . "{$rand}'>";
     $_POST["entity"] = $p['entity'];
     $_POST["rubdoc"] = 0;
     $_POST["myname"] = $p['name'];
     $_POST["rand"] = $rand;
     $_POST["used"] = $p['used'];
     include GLPI_ROOT . "/ajax/dropdownRubDocument.php";
     echo "</span>\n";
     return $rand;
 }
 function showForm($p_target)
 {
     global $LANG, $DB, $LINK_ID_TABLE;
     $tableSelect = '';
     if (isset($_SESSION["glpi_plugin_fusioninventory_lockable_table"])) {
         $tableId = $_SESSION["glpi_plugin_fusioninventory_lockable_table"];
         if (isset($LINK_ID_TABLE[$tableId])) {
             $tableSelect = $LINK_ID_TABLE[$tableId];
         }
     }
     echo "<form method='post' name='setLockable_form' id='setLockable_form'\n                  action='" . $p_target . "'>";
     echo "<table class='tab_cadre_fixe' cellpadding='2'>";
     echo "<tr>";
     echo "<th colspan='4'>" . $LANG['plugin_fusioninventory']["functionalities"][70] . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][72] . " :</td>";
     echo "<td>" . $LANG['plugin_fusioninventory']["functionalities"][71] . " :</td>";
     echo "<td></td><td>" . $LANG['plugin_fusioninventory']['functionalities'][7] . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     $options = "";
     $query = "SHOW TABLES;";
     $elements = array(0 => '-----');
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             $elements[$data[0]] = $data[0];
         }
     }
     $idSelect = 'dropdown_tableSelect' . Dropdown::showFromArray('tableSelect', $elements, array('value' => $tableSelect));
     $elements = array();
     echo "</td><td class='right'>";
     echo "<span id='columnsSelect'>&nbsp;";
     if ($tableSelect != '') {
         PluginFusioninventoryLockable::getColumnSelect($tableSelect);
     }
     echo "</span>\n";
     $params = array('tableSelect' => '__VALUE__');
     ajaxUpdateItemOnSelectEvent($idSelect, 'columnsSelect', GLPI_ROOT . "/plugins/fusioninventory/ajax/lockable.columns.php", $params);
     ajaxUpdateItemOnSelectEvent($idSelect, 'columnsLockable', GLPI_ROOT . "/plugins/fusioninventory/ajax/lockable.lockables.php", $params);
     echo "</td><td class='center'>";
     if (PluginFusioninventory::haveRight("configuration", "w")) {
         echo "<input type='submit'  class=\"submit\" name='plugin_fusioninventory_lockable_add' value='" . $LANG["buttons"][8] . " >>'>";
         echo "<br /><br />";
         echo "<input type='submit'  class=\"submit\" name='plugin_fusioninventory_lockable_delete' value='<< " . $LANG["buttons"][6] . "'>";
     }
     echo "</td><td class='left'>";
     echo "<span id='columnsLockable'>&nbsp;";
     if ($tableSelect != '') {
         PluginFusioninventoryLockable::getLockableSelect($tableSelect);
     }
     echo "</span>\n";
     echo "</table></form>";
 }
        unset($tmp);
    }
    $randsearch = -1;
    $dropdownname = "searchtype{$addmeta}" . $_POST["itemtype"] . $_POST["num"];
    $searchopt = array();
    echo "<table><tr><td>";
    if (count($actions) > 0) {
        // get already get search options
        if (isset($actions['searchopt'])) {
            $searchopt = $actions['searchopt'];
            // No name for clean array whith quotes
            unset($searchopt['name']);
            unset($actions['searchopt']);
        }
        $randsearch = Dropdown::showFromArray("searchtype" . $addmeta . "[" . $_POST["num"] . "]", $actions, array('value' => $_POST["searchtype"]));
    }
    echo "</td><td>";
    echo "<span id='span{$dropdownname}'>\n";
    $_REQUEST['searchtype'] = $_POST["searchtype"];
    $_REQUEST['field'] = $_POST["field"];
    $_REQUEST['itemtype'] = $_POST["itemtype"];
    $_REQUEST['num'] = $_POST["num"];
    $_REQUEST['value'] = stripslashes($_POST['value']);
    $_REQUEST['meta'] = $_POST['meta'];
    $_REQUEST['searchopt'] = serialize($searchopt);
    include GLPI_ROOT . "/ajax/searchoptionvalue.php";
    echo "</span>\n";
    echo "</td></tr></table>";
    $paramsaction = array('searchtype' => '__VALUE__', 'field' => $_POST["field"], 'itemtype' => $_POST["itemtype"], 'num' => $_POST["num"], 'value' => rawurlencode(stripslashes($_POST['value'])), 'searchopt' => $searchopt, 'meta' => $_POST['meta']);
    ajaxUpdateItemOnSelectEvent("dropdown_searchtype" . $addmeta . "[" . $_POST["num"] . "]{$randsearch}", "span{$dropdownname}", $CFG_GLPI["root_doc"] . "/ajax/searchoptionvalue.php", $paramsaction, false);
}
 static function showHelpdeskOptions(Entity $entity)
 {
     global $LANG, $CFG_GLPI;
     $ID = $entity->getField('id');
     if (!$entity->can($ID, 'r') || !haveRight('entity_helpdesk', 'r')) {
         return false;
     }
     $canedit = haveRight('entity_helpdesk', 'w') && haveAccessToEntity($ID);
     // Get data
     $entdata = new EntityData();
     if (!$entdata->getFromDB($ID)) {
         $entdata->getEmpty();
     }
     echo "<div class='spaced'>";
     if ($canedit) {
         echo "<form method='post' name=form action='" . getItemTypeFormURL(__CLASS__) . "'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['buttons'][15] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $options = array('value' => $entdata->fields["calendars_id"], 'emptylabel' => $LANG['common'][102]);
     if ($ID == 0) {
         $options['emptylabel'] = $LANG['sla'][10];
     }
     Dropdown::show('Calendar', $options);
     if ($entdata->fields["calendars_id"] == 0) {
         $calendar = new Calendar();
         if ($calendar->getFromDB(self::getUsedConfig('calendars_id', $ID))) {
             echo " - " . $calendar->getLink();
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][28] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $toadd = array();
     if ($ID != 0) {
         $toadd = array(0 => $LANG['common'][102]);
     }
     Ticket::dropdownType('tickettype', $entdata->fields["tickettype"], $toadd);
     if ($entdata->fields["calendars_id"] == 0) {
         $calendar = new Calendar();
         if ($calendar->getFromDB(self::getUsedConfig('calendars_id', $ID))) {
             echo " - " . $calendar->getLink();
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td  colspan='2'>" . $LANG['setup'][52] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     $autoassign = array(-1 => $LANG['setup'][731], NO_AUTO_ASSIGN => $LANG['choice'][0], AUTO_ASSIGN_HARDWARE_CATEGORY => $LANG['setup'][51], AUTO_ASSIGN_CATEGORY_HARDWARE => $LANG['setup'][50]);
     Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entdata->fields["auto_assign_mode"]));
     echo "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['entity'][17] . "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][18] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     Dropdown::showInteger('autoclose_delay', $entdata->fields['autoclose_delay'], 0, 99, 1, array(-1 => $LANG['setup'][731], -10 => $LANG['setup'][307]));
     /*
           Alert::dropdownIntegerNever('autoclose_delay', $entdata->fields['autoclose_delay'],
                                       array('max'            => 99,
                                             'inherit_global' => 1,
                                             'never_value'    => -10,));
     */
     echo "&nbsp;" . $LANG['stats'][31] . "</td></tr>";
     echo "<tr><th colspan='4'>" . $LANG['entity'][19] . "</th></tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['entity'][19] . "&nbsp;:&nbsp;</td>";
     echo "<td colspan='2'>";
     /// no inquest case = rate 0
     $typeinquest = array(0 => $LANG['common'][102], 1 => $LANG['satisfaction'][9], 2 => $LANG['satisfaction'][10]);
     // No inherit from parent for root entity
     if ($entdata->fields['entities_id'] == 0) {
         unset($typeinquest[0]);
         if ($entdata->fields['inquest_config'] == 0) {
             $entdata->fields['inquest_config'] = 1;
         }
     }
     $rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entdata->fields['inquest_config']));
     echo "</td></tr>\n";
     // Do not display for root entity in inherit case
     if ($entdata->fields['inquest_config'] == 0 && $entdata->fields['entities_id'] != 0) {
         $inquestconfig = self::getUsedConfig('inquest_config', $entdata->fields['entities_id']);
         $inquestrate = self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_rate');
         echo "<tr><td colspan='4' class='green center'>" . $LANG['common'][102] . "&nbsp;:&nbsp;";
         if ($inquestrate == 0) {
             echo $LANG['crontask'][31];
         } else {
             echo $typeinquest[$inquestconfig];
             echo " - " . self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_delay');
             echo "&nbsp;" . $LANG['stats'][31] . " - ";
             echo $inquestrate . "%";
             if ($inquestconfig == 2) {
                 echo " - " . self::getUsedConfig('inquest_config', $entdata->fields['entities_id'], 'inquest_URL');
             }
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $_REQUEST = array('inquest_config' => $entdata->fields['inquest_config'], 'entities_id' => $ID);
     $params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
     echo "<div id='inquestconfig'>";
     include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
     echo "</div>\n";
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='entities_id' value='{$ID}'>";
         if ($entdata->fields["id"]) {
             echo "<input type='hidden' name='id' value='" . $entdata->fields["id"] . "'>";
             echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\"\n                   class='submit'>";
         } else {
             echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
         }
         echo "</td></tr>";
         echo "</table></form>";
     } else {
         echo "</table>";
     }
     echo "</div>";
     ajaxUpdateItemOnSelectEvent("dropdown_inquest_config{$rand}", "inquestconfig", $CFG_GLPI["root_doc"] . "/ajax/ticketsatisfaction.php", $params);
 }
 /**
  * Display a dropdown which contains all the available itemtypes
  *
  * @param ID the field unicity item id
  * @param value the selected value
  *
  * @return nothing
  **/
 function showItemtype($ID, $value = 0)
 {
     global $CFG_GLPI;
     //Criteria already added : only display the selected itemtype
     if ($ID > 0) {
         $item = new $this->fields['itemtype']();
         echo $item->getTypeName();
         echo "<input type='hidden' name='itemtype' value='" . $this->fields['itemtype'] . "'";
     } else {
         //Add criteria : display dropdown
         $options[0] = DROPDOWN_EMPTY_VALUE;
         foreach ($CFG_GLPI['unicity_types'] as $itemtype) {
             if (class_exists($itemtype)) {
                 $item = new $itemtype();
                 if ($item->can(-1, 'r')) {
                     $options[$itemtype] = $item->getTypeName($itemtype);
                 }
             }
         }
         asort($options);
         $rand = Dropdown::showFromArray('itemtype', $options);
         $params = array('itemtype' => '__VALUE__', 'id' => $ID);
         ajaxUpdateItemOnSelectEvent("dropdown_itemtype{$rand}", "span_fields", $CFG_GLPI["root_doc"] . "/ajax/dropdownUnicityFields.php", $params);
     }
 }
         }
     }
     if (!empty($newgroup) && $items_in_group > 0) {
         echo $newgroup;
     }
     if (!$first_group) {
         echo "</optgroup>";
     }
     echo "</select>";
     $paramsmassaction = array('id_field' => '__VALUE__', 'itemtype' => $_POST["itemtype"]);
     foreach ($_POST as $key => $val) {
         if (preg_match("/extra_/", $key, $regs)) {
             $paramsmassaction[$key] = $val;
         }
     }
     ajaxUpdateItemOnSelectEvent("massiveaction_field", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionField.php", $paramsmassaction);
     echo "<span id='show_massiveaction_field'>&nbsp;</span>\n";
     break;
 default:
     // Plugin specific actions
     $split = explode('_', $_POST["action"]);
     if ($split[0] == 'plugin' && isset($split[1])) {
         // Normalized name plugin_name_action
         // Allow hook from any plugin on any (core or plugin) type
         doOneHook($split[1], 'MassiveActionsDisplay', array('itemtype' => $_POST["itemtype"], 'action' => $_POST["action"]));
     } else {
         if ($plug = isPluginItemType($_POST["itemtype"])) {
             // non-normalized name
             // hook from the plugin defining the type
             doOneHook($plug['plugin'], 'MassiveActionsDisplay', $_POST["itemtype"], $_POST["action"]);
         }
  @comment   
  @copyright Copyright (c) 2011-2012 Plugin Monitoring for GLPI team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2011

  ------------------------------------------------------------------------
*/
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
// Make a select box
if (class_exists($_POST["itemtype"]) && isset($_POST["hosts"])) {
    $table = getTableForItemType($_POST["itemtype"]);
    $pmService = new PluginMonitoringService();
    $a_services = array();
    $a_services[] = DROPDOWN_EMPTY_VALUE;
    $query = "SELECT `" . getTableForItemType("PluginMonitoringService") . "`.*\n             FROM `" . getTableForItemType("PluginMonitoringService") . "`\n             LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts` \n                  ON `plugin_monitoring_componentscatalogs_hosts_id` \n                      = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n             WHERE `itemtype` = '" . $_POST["itemtype"] . "'\n                AND `items_id`='" . $_POST['hosts'] . "'\n             ORDER BY `" . getTableForItemType("PluginMonitoringService") . "`.`name`";
    $result = $DB->query($query);
    while ($data = $DB->fetch_array($result)) {
        $a_services[$data['id']] = $data['name'];
    }
    $rand = Dropdown::showFromArray("plugin_monitoring_services_id", $a_services);
    if ($_POST['selectgraph'] == '1') {
        $params = array('hosts' => '__VALUE__', 'rand' => $rand);
        ajaxUpdateItemOnSelectEvent("dropdown_plugin_monitoring_services_id" . $rand, "show_extrainfos{$rand}", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownDisplayviewExtrainfos.php", $params);
        echo "<span id='show_extrainfos{$rand}'></span>";
    }
}
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
checkLoginUser();
switch ($_POST['itemtype']) {
    case 'PluginMonitoringServicescatalog':
        Dropdown::show('PluginMonitoringServicescatalog', array('name' => 'items_id'));
        break;
    case 'PluginMonitoringComponentscatalog':
        Dropdown::show('PluginMonitoringComponentscatalog', array('name' => 'items_id'));
        break;
    case 'PluginMonitoringService':
        $rand = mt_rand();
        echo "<select name='itemtype' id='itemtype{$rand}'>";
        echo "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option>";
        //      $a_types =array();
        echo "<option value='Computer'>" . Computer::getTypeName() . "</option>";
        echo "<option value='NetworkEquipment'>" . NetworkEquipment::getTypeName() . "</option>";
        echo "</select>";
        $params = array('itemtype' => '__VALUE__', 'entity_restrict' => $_POST['a_entities'], 'selectgraph' => '1', 'rand' => $rand);
        ajaxUpdateItemOnSelectEvent("itemtype{$rand}", "show_itemtype{$rand}", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownServiceHostType.php", $params);
        echo "<span id='show_itemtype{$rand}'><input type='hidden' name='services_id[]' value='0'/></span>\n";
        break;
    case 'PluginMonitoringWeathermap':
        Dropdown::show('PluginMonitoringWeathermap', array('name' => 'items_id'));
        echo "&nbsp;&nbsp;&nbsp;" . $LANG['plugin_monitoring']['displayview'][5] . "&nbsp: " . Dropdown::showInteger("extra_infos", 100, 0, 100, 5);
        break;
    default:
        break;
}
// ----------------------------------------------------------------------
if (strpos($_SERVER['PHP_SELF'], "dropdownSelectSoftware.php")) {
    $AJAX_INCLUDE = 1;
    define('GLPI_ROOT', '..');
    include GLPI_ROOT . "/inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    header_nocache();
}
checkRight("software", "w");
// Make a select box
$rand = mt_rand();
$where = "";
if (strlen($_POST['searchText']) > 0 && $_POST['searchText'] != $CFG_GLPI["ajax_wildcard"]) {
    $where .= " AND `name` " . makeTextSearch($_POST['searchText']) . " ";
}
$where .= getEntitiesRestrictRequest(' AND', 'glpi_softwares', 'entities_id', $_POST["entity_restrict"], true);
$query = "SELECT DISTINCT `glpi_softwares`.`id`,\n                          `glpi_softwares`.`name`\n          FROM `glpi_softwares`\n          WHERE `glpi_softwares`.`is_deleted` = '0'\n                AND `glpi_softwares`.`is_template` = '0'\n                {$where}\n          ORDER BY `glpi_softwares`.`name`";
$result = $DB->query($query);
echo "<select name='softwares_id' id='item_type{$rand}'>\n";
echo "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option>\n";
if ($DB->numrows($result)) {
    while ($data = $DB->fetch_array($result)) {
        $softwares_id = $data["id"];
        $output = $data["name"];
        echo "<option value='{$softwares_id}' title=\"" . cleanInputText($output) . "\">" . utf8_substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
    }
}
echo "</select>\n";
$paramsselsoft = array('softwares_id' => '__VALUE__', 'myname' => $_POST["myname"]);
ajaxUpdateItemOnSelectEvent("item_type{$rand}", "show_" . $_POST["myname"] . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownInstallVersion.php", $paramsselsoft, false);
echo "<span id='show_" . $_POST["myname"] . "{$rand}'>&nbsp;</span>\n";
 function RemoteStateAgent($target, $ID, $type, $a_modules = array())
 {
     global $LANG, $CFG_GLPI;
     $ptcm = new PluginFusioninventoryConfigModules();
     $pfia = new PluginFusioninventoryAgents();
     if (!$ptcm->isActivated('remotehttpagent') and !PluginFusioninventory::haveRight("remotecontrol", "w")) {
         return;
     }
     if ($type == PLUGIN_FUSIONINVENTORY_SNMP_AGENTS) {
         $pfia->getFromDB($ID);
         $on_device = $ID;
     } else {
         if ($type == COMPUTER_TYPE) {
             $agentlist = $pfia->find("on_device='" . $ID . "'", "", "1");
             foreach ($agentlist as $data) {
                 $pfia->getFromDB($data['ID']);
                 $on_device = $pfia->fields['on_device'];
             }
         } else {
             if ($type == NETWORKING_TYPE or $type == PRINTER_TYPE) {
                 $on_device = $ID;
             }
         }
     }
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.state.php\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["agents"][14];
     echo " : </th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     $array_actions = array();
     $array_actions[""] = "------";
     switch ($type) {
         case NETWORKING_TYPE:
         case PRINTER_TYPE:
             if (isset($a_modules["INVENTORY"]) and $ptcm->getValue("snmp") == '1') {
                 $array_actions["INVENTORY"] = $LANG['plugin_fusioninventory']['config'][3];
             }
             break;
         case PLUGIN_FUSIONINVENTORY_SNMP_AGENTS:
         case COMPUTER_TYPE:
             if (isset($a_modules["INVENTORY"]) and $ptcm->getValue("inventoryocs") == '1' and isset($pfia->fields['module_inventory']) and $pfia->fields['module_inventory'] == '1' or isset($a_modules["INVENTORY"]) and $ptcm->getValue("snmp") == '1' and isset($pfia->fields['module_snmpquery']) and $pfia->fields['module_snmpquery'] == '1') {
                 $array_actions["INVENTORY"] = $LANG['plugin_fusioninventory']['config'][3];
             }
             if (isset($a_modules["WAKEONLAN"]) and $ptcm->getValue("wol") == '1') {
                 // Code for PLUGIN_FUSIONINVENTORY_SNMP_AGENTS if  ($pfia->fields['module_wakeonlan'] == '1')
                 // so :
                 if ($type == COMPUTER_TYPE) {
                     $array_actions["WAKEONLAN"] = $LANG['plugin_fusioninventory']['config'][6];
                 }
             }
             break;
     }
     //      if ((isset($a_modules["NETDISCOVERY"])) AND ($ptcm->getValue("netdiscovery") == '1') AND ($pfia->fields['module_netdiscovery'] == '1')) {
     //         $array_actions["NETDISCOVERY"] = $LANG['plugin_fusioninventory']['config'][4];
     //      }
     //      if ((isset($a_modules["SNMPQUERY"])) AND ($ptcm->getValue("snmp") == '1') AND ($pfia->fields['module_snmpquery'] == '1')) {
     //         $array_actions["SNMPQUERY"] = $LANG['plugin_fusioninventory']['config'][7];
     //      }
     $rand = Dropdown::showFromArray("agentaction", $array_actions);
     echo "</td>";
     echo "</tr>";
     if (!isset($on_device)) {
         $on_device = $ID;
     }
     $params = array('action' => '__VALUE__', 'on_device' => $on_device, 'device_type' => $type);
     ajaxUpdateItemOnSelectEvent("dropdown_agentaction{$rand}", "updateAgentState_{$rand}", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/agentsState.php", $params, false);
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     echo "<span id='updateAgentState_{$rand}'>\n";
     echo "&nbsp;";
     echo "</span>\n";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td align='center'>";
     echo "<input type='hidden' name='on_device' value='" . $ID . "'/>";
     echo "<input type='hidden' name='device_type' value='" . $type . "'/>";
     echo "<input type='submit' name='startagent' value=\"" . $LANG['plugin_fusioninventory']["task"][12] . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</form>";
     echo "</div>";
 }
 function addItem($displayviews_id)
 {
     global $DB, $CFG_GLPI, $LANG;
     $this->getEmpty();
     $pmDisplayview = new PluginMonitoringDisplayview();
     $pmDisplayview->getFromDB($displayviews_id);
     // Manage entity_sons
     $a_entities = array();
     if (!($pmDisplayview->fields['entities_id'] < 0)) {
         if ($pmDisplayview->fields['is_recursive'] == '0') {
             $a_entities[$pmDisplayview->fields['entities_id']] = $pmDisplayview->fields['entities_id'];
         } else {
             $a_entities = getSonsOf('glpi_entities', $pmDisplayview->fields['entities_id']);
         }
     }
     $options = array();
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo "<input type='hidden' name='plugin_monitoring_displayviews_id' value='" . $displayviews_id . "' />";
     echo $LANG['plugin_monitoring']['displayview'][3] . " :</td>";
     echo "<td>";
     $elements = array();
     $elements['NULL'] = DROPDOWN_EMPTY_VALUE;
     $elements['PluginMonitoringServicescatalog'] = $LANG['plugin_monitoring']['servicescatalog'][0];
     $elements['PluginMonitoringComponentscatalog'] = $LANG['plugin_monitoring']['componentscatalog'][0];
     $elements['PluginMonitoringService'] = $LANG['plugin_monitoring']['service'][0];
     $elements['PluginMonitoringWeathermap'] = $LANG['plugin_monitoring']['weathermap'][0];
     $rand = Dropdown::showFromArray('itemtype', $elements, array('value' => $this->fields['itemtype']));
     $params = array('itemtype' => '__VALUE__', 'displayviews_id' => $displayviews_id, 'myname' => "items_id", 'a_entities' => $a_entities);
     ajaxUpdateItemOnSelectEvent("dropdown_itemtype" . $rand, "items_id", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownDisplayviewItemtype.php", $params);
     echo "<span id='items_id'></span>";
     echo "<input type='hidden' name='x' value='1' />";
     echo "<input type='hidden' name='y' value='1' />";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Show the list of rules
  *
  * @param $target
  * @param $tab
  * @param $options
  *
  * @return nothing
  **/
 function showListRules($target, $tab = 0, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $p['inherited'] = true;
     $p['childrens'] = false;
     $p['active'] = false;
     foreach (array('inherited', 'childrens') as $param) {
         if (isset($options[$param]) && $this->isRuleRecursive()) {
             $p[$param] = $options[$param];
         }
     }
     $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']);
     // Do not know what it is ?
     $canedit = haveRight($this->right, "w") && !$display_entities;
     $nb = $this->getCollectionSize($p['inherited']);
     $p['start'] = isset($options["start"]) ? $options["start"] : 0;
     if ($p['start'] >= $nb) {
         $p['start'] = 0;
     }
     $p['limit'] = $_SESSION['glpilist_limit'];
     $this->getCollectionPart($p);
     printAjaxPager('', $p['start'], $nb);
     echo "<form name='ruleactions_form' id='ruleactions_form' method='post'action='" . $target . "'>";
     echo "\n<div class='spaced'>";
     echo "<table class='tab_cadre_fixehov'>";
     $colspan = 6;
     if ($display_entities) {
         $colspan++;
     }
     echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n";
     echo "<tr><th colspan='2'>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['joblist'][6] . "</th>";
     echo "<th>" . $LANG['common'][60] . "</th>";
     if ($display_entities) {
         echo "<th>" . $LANG['entity'][0] . "</th>\n";
     }
     if (!$display_entities) {
         echo "<th colspan='2'>&nbsp;</th>";
     }
     echo "</tr>\n";
     if (count($this->RuleList->list)) {
         $ruletype = $this->RuleList->list[0]->getType();
         initNavigateListItems($ruletype);
     }
     for ($i = $p['start'], $j = 0; isset($this->RuleList->list[$j]); $i++, $j++) {
         $this->RuleList->list[$j]->showMinimalForm($target, $i == 0, $i == $nb - 1, $display_entities);
         addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']);
     }
     echo "</table>\n";
     if ($canedit && $nb > 0) {
         openArrowMassive("ruleactions_form", true);
         echo "<select name='massiveaction' id='massiveaction'>";
         echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
         echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
         if ($this->orderby == "ranking") {
             echo "<option value='move_rule'>" . $LANG['buttons'][20] . "</option>";
         }
         echo "<option value='activate_rule'>" . $LANG['buttons'][41] . "</option>";
         echo "</select>\n";
         $params = array('action' => '__VALUE__', 'itemtype' => 'Rule', 'sub_type' => $this->getRuleClassName(), 'entity_restrict' => $this->entity);
         ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveAction.php", $params);
         echo "<span id='show_massiveaction'>&nbsp;</span>\n";
         if ($this->can_replay_rules) {
             echo "</td>";
             // close td of openArrowMassive
             echo "<td><input type='submit' name='replay_rule' value='" . $LANG['rulesengine'][76] . "' class='submit'></td>";
             echo "<td>";
             // open td for closeArrowMassive
         }
         closeArrowMassive();
     }
     echo "</div></form>";
     echo "<div class='spaced center'><span class='icon_consol'>";
     if ($plugin = isPluginItemType($this->getType())) {
         $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']);
     } else {
         $url = $CFG_GLPI["root_doc"];
     }
     echo "<a href='#' onClick=\"var w=window.open('" . $url . "/front/popup.php?popup=test_all_rules&amp;sub_type=" . $this->getRuleClassName() . "&amp' ,'glpipopup', 'height=400, width=1000, top=100, left=100, scrollbars=yes' );" . "w.focus();\">" . $LANG['rulesengine'][84] . "</a></span></div>";
     echo "<div class='spaced'>";
     $this->showAdditionalInformationsInForm($target);
     echo "</div>";
 }
/**
 * Javascript code for update an item (Javascript code only)
 *
 * @param $options array of options
*    - toupdate : array / Update a specific item on select change on dropdown
*                   (need value_fieldname, to_update, url (see ajaxUpdateItemOnSelectEvent for informations)
*                   and may have moreparams)
 *
 **/
function commonDropdownUpdateItem($options)
{
    if (isset($options["update_item"]) && (is_array($options["update_item"]) || strlen($options["update_item"]) > 0)) {
        if (!is_array($options["update_item"])) {
            $data = unserialize(stripslashes($options["update_item"]));
        } else {
            $data = $options["update_item"];
        }
        if (is_array($data) && count($data)) {
            $paramsupdate = array();
            if (isset($data['value_fieldname'])) {
                $paramsupdate = array($data['value_fieldname'] => '__VALUE__');
            }
            if (isset($data["moreparams"]) && is_array($data["moreparams"]) && count($data["moreparams"])) {
                foreach ($data["moreparams"] as $key => $val) {
                    $paramsupdate[$key] = $val;
                }
            }
            ajaxUpdateItemOnSelectEvent("dropdown_" . $options["myname"] . $options["rand"], $data['to_update'], $data['url'], $paramsupdate, false);
        }
    }
}
 function showTransferList()
 {
     global $LANG, $DB, $CFG_GLPI;
     if (isset($_SESSION['glpitransfer_list']) && count($_SESSION['glpitransfer_list'])) {
         echo "<div class='center b'>" . $LANG['transfer'][5] . "<br>" . $LANG['transfer'][6] . "</div>";
         echo "<table class='tab_cadre_fixe' >";
         echo '<tr><th>' . $LANG['transfer'][7] . '</th><th>' . $LANG['transfer'][8] . "&nbsp;:&nbsp;";
         $rand = Dropdown::show('Transfer', array('name' => 'id', 'comments' => false, 'toupdate' => array('value_fieldname' => 'id', 'to_update' => "transfer_form", 'url' => $CFG_GLPI["root_doc"] . "/ajax/transfers.php")));
         echo '</th></tr>';
         echo "<tr><td class='tab_bg_1 top'>";
         foreach ($_SESSION['glpitransfer_list'] as $itemtype => $tab) {
             if (count($tab)) {
                 $table = getTableForItemType($itemtype);
                 $query = "SELECT `{$table}`.`id`,\n                                 `{$table}`.`name`,\n                                 `glpi_entities`.`completename` AS locname,\n                                 `glpi_entities`.`id` AS entID\n                          FROM `{$table}`\n                          LEFT JOIN `glpi_entities`\n                               ON (`{$table}`.`entities_id` = `glpi_entities`.`id`)\n                          WHERE `{$table}`.`id` IN " . $this->createSearchConditionUsingArray($tab) . "\n                         ORDER BY locname, `{$table}`.`name`";
                 $entID = -1;
                 if (!class_exists($itemtype)) {
                     continue;
                 }
                 $item = new $itemtype();
                 if ($result = $DB->query($query)) {
                     if ($DB->numrows($result)) {
                         echo '<h3>' . $item->getTypeName() . '</h3>';
                         while ($data = $DB->fetch_assoc($result)) {
                             if ($entID != $data['entID']) {
                                 if ($entID != -1) {
                                     echo '<br>';
                                 }
                                 $entID = $data['entID'];
                                 if ($entID > 0) {
                                     echo '<strong>' . $data['locname'] . '</strong><br>';
                                 } else {
                                     echo '<strong>' . $LANG['entity'][2] . '</strong><br>';
                                 }
                             }
                             echo $data['name'] ? $data['name'] . "<br>" : "(" . $data['id'] . ")<br>";
                         }
                     }
                 }
             }
         }
         echo "</td><td class='tab_bg_2 top'>";
         if (countElementsInTable('glpi_transfers') == 0) {
             echo $LANG['search'][15];
         } else {
             $params = array('id' => '__VALUE__');
             ajaxUpdateItemOnSelectEvent("dropdown_ID{$rand}", "transfer_form", $CFG_GLPI["root_doc"] . "/ajax/transfers.php", $params, false);
         }
         echo "<div class='center' id='transfer_form'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/transfer.action.php?clear=1'>" . $LANG['transfer'][4] . "</a>";
         echo "</div>";
         echo '</td></tr>';
         echo '</table>';
     } else {
         echo $LANG['common'][24];
     }
 }
  @comment   
  @copyright Copyright (c) 2011-2012 Plugin Monitoring for GLPI team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2011

  ------------------------------------------------------------------------
*/
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
if (class_exists($_POST["itemtype"])) {
    $table = getTableForItemType($_POST["itemtype"]);
    $query = "SELECT `{$table}`.`name`, \n                    `" . $table . "`.`id`\n                        \n             FROM `" . getTableForItemType("PluginMonitoringService") . "`\n             LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts` \n                  ON `plugin_monitoring_componentscatalogs_hosts_id` \n                      = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n             LEFT JOIN `{$table}` ON `{$table}`.`id` = `items_id`          \n             WHERE `itemtype` = '" . $_POST["itemtype"] . "'\n             ORDER BY `{$table}`.`name`";
    $result = $DB->query($query);
    $a_hosts = array();
    $a_hosts[0] = DROPDOWN_EMPTY_VALUE;
    while ($data = $DB->fetch_array($result)) {
        $a_hosts[$data['id']] = $data['name'];
    }
    $rand = Dropdown::showFromArray("hosts", $a_hosts);
    $selectgraph = 0;
    if (isset($_POST['selectgraph'])) {
        $selectgraph = $_POST['selectgraph'];
    }
    $params = array('hosts' => '__VALUE__', 'entity_restrict' => $_POST["entity_restrict"], 'itemtype' => $_POST['itemtype'], 'selectgraph' => $selectgraph, 'rand' => $rand, 'myname' => "items");
    ajaxUpdateItemOnSelectEvent("dropdown_hosts" . $rand, "show_items{$rand}", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownServiceHost.php", $params);
    echo "<span id='show_items{$rand}'><input type='hidden' name='services_id[]' value='0'/></span>";
}