예제 #1
0
/** Display an infocom report
 *
 * @param $itemtype item type
 * @param $begin begin date
 * @param $end end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
    global $DB, $valeurtot, $valeurnettetot, $valeurnettegraphtot, $valeurgraphtot, $LANG, $CFG_GLPI;
    $itemtable = getTableForItemType($itemtype);
    $query = "SELECT `glpi_infocoms`.*,\n                    `{$itemtable}`.`name` AS name,\n                    `{$itemtable}`.`ticket_tco`,\n                    `glpi_entities`.`completename` AS entname,\n                    `glpi_entities`.`id` AS entID\n             FROM `glpi_infocoms`\n             INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`\n                                         AND `glpi_infocoms`.`itemtype` = '{$itemtype}')\n             LEFT JOIN `glpi_entities` ON (`{$itemtable}`.`entities_id` = `glpi_entities`.`id`)\n             WHERE `{$itemtable}`.`is_template` = '0' " . getEntitiesRestrictRequest("AND", $itemtable);
    if (!empty($begin)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` >= '{$begin}'\n                       OR `glpi_infocoms`.`use_date` >= '{$begin}') ";
    }
    if (!empty($end)) {
        $query .= " AND (`glpi_infocoms`.`buy_date` <= '{$end}'\n                       OR `glpi_infocoms`.`use_date` <= '{$end}') ";
    }
    $query .= " ORDER BY entname ASC, `buy_date`, `use_date`";
    $display_entity = isMultiEntitiesMode();
    $result = $DB->query($query);
    if ($DB->numrows($result) > 0) {
        $item = new $itemtype();
        echo "<h2>" . $item->getTypeName() . "</h2>";
        echo "<table class='tab_cadre'><tr><th>" . $LANG['common'][16] . "</th>";
        if ($display_entity) {
            echo "<th>" . $LANG['entity'][0] . "</th>";
        }
        echo "<th>" . $LANG['financial'][21] . "</th><th>" . $LANG['financial'][92] . "</th>";
        echo "<th>" . $LANG['financial'][91] . "</th><th>" . $LANG['financial'][14] . "</th>";
        echo "<th>" . $LANG['financial'][76] . "</th><th>" . $LANG['financial'][80] . "</th></tr>";
        $valeursoustot = 0;
        $valeurnettesoustot = 0;
        $valeurnettegraph = array();
        $valeurgraph = array();
        while ($line = $DB->fetch_array($result)) {
            if (isset($line["is_global"]) && $line["is_global"]) {
                $line["value"] *= Computer_Item::countForItem($itemtype, $line["items_id"]);
            }
            if ($line["value"] > 0) {
                $valeursoustot += $line["value"];
            }
            $valeurnette = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "n");
            $tmp = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "all");
            if (is_array($tmp) && count($tmp) > 0) {
                foreach ($tmp["annee"] as $key => $val) {
                    if ($tmp["vcnetfin"][$key] > 0) {
                        if (!isset($valeurnettegraph[$val])) {
                            $valeurnettegraph[$val] = 0;
                        }
                        $valeurnettegraph[$val] += $tmp["vcnetdeb"][$key];
                    }
                }
            }
            if (!empty($line["buy_date"])) {
                $year = substr($line["buy_date"], 0, 4);
                if ($line["value"] > 0) {
                    if (!isset($valeurgraph[$year])) {
                        $valeurgraph[$year] = 0;
                    }
                    $valeurgraph[$year] += $line["value"];
                }
            }
            $valeurnettesoustot += str_replace(" ", "", $valeurnette);
            echo "<tr class='tab_bg_1'><td>" . $line["name"] . "</td>";
            if ($display_entity) {
                if ($line['entID'] == 0) {
                    echo "<td>" . $LANG['entity'][2] . "</td>";
                } else {
                    echo "<td>" . $line['entname'] . "</td>";
                }
            }
            echo "<td class='right'>" . formatNumber($line["value"]) . "</td><td class='right'>" . formatNumber($valeurnette) . "</td><td class='right'>" . Infocom::showTco($line["ticket_tco"], $line["value"]) . "</td><td>" . convDate($line["buy_date"]) . "</td><td>" . convDate($line["use_date"]) . "</td><td>" . getWarrantyExpir($line["buy_date"], $line["warranty_duration"]) . "</td></tr>";
        }
        $valeurtot += $valeursoustot;
        $valeurnettetot += $valeurnettesoustot;
        echo "<tr><td colspan='6' class='center'><h3>" . $LANG['common'][33] . "&nbsp;: " . $LANG['financial'][21] . "=" . formatNumber($valeursoustot) . " - " . $LANG['financial'][81] . "=" . formatNumber($valeurnettesoustot) . "</h3></td></tr>";
        if (count($valeurnettegraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurnettegraph);
            $valeurnettegraphdisplay = array_map('round', $valeurnettegraph);
            foreach ($valeurnettegraph as $key => $val) {
                if (!isset($valeurnettegraphtot[$key])) {
                    $valeurnettegraphtot[$key] = 0;
                }
                $valeurnettegraphtot[$key] += $valeurnettegraph[$key];
            }
            Stat::showGraph(array($LANG['financial'][81] => $valeurnettegraphdisplay), array('title' => $LANG['financial'][81], 'width' => 400));
            echo "</td></tr>";
        }
        if (count($valeurgraph) > 0) {
            echo "<tr><td colspan='5' class='center'>";
            ksort($valeurgraph);
            $valeurgraphdisplay = array_map('round', $valeurgraph);
            foreach ($valeurgraph as $key => $val) {
                if (!isset($valeurgraphtot[$key])) {
                    $valeurgraphtot[$key] = 0;
                }
                $valeurgraphtot[$key] += $valeurgraph[$key];
            }
            Stat::showGraph(array($LANG['financial'][21] => $valeurgraphdisplay), array('title' => $LANG['financial'][21], 'width' => 400));
            echo "</td></tr>";
        }
        echo "</table>";
        return true;
    }
    return false;
}
 /**
  * Print the search config form
  *
  * @param $target form target
  * @param $itemtype item type
  *
  * @return nothing
  **/
 function showFormGlobal($target, $itemtype)
 {
     global $CFG_GLPI, $LANG, $DB;
     $searchopt = Search::getOptions($itemtype);
     if (!is_array($searchopt)) {
         return false;
     }
     $IDuser = 0;
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $global_write = haveRight("search_config_global", "w");
     echo "<div class='center' id='tabsbody' >";
     // Defined items
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `itemtype` = '{$itemtype}'\n                      AND `users_id` = '{$IDuser}'\n                ORDER BY `rank`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     echo "<table class='tab_cadre_fixe'><tr><th colspan='4'>";
     echo $LANG['setup'][252] . "&nbsp;: </th></tr>\n";
     if ($global_write) {
         $already_added = self::getForTypeUser($itemtype, $IDuser);
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<form method='post' action='{$target}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
         echo "<select name='num'>";
         $first_group = true;
         $searchopt = Search::getCleanedOptions($itemtype);
         foreach ($searchopt as $key => $val) {
             if (!is_array($val)) {
                 if (!$first_group) {
                     echo "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 echo "<optgroup label=\"{$val}\">";
             } else {
                 if ($key != 1 && !in_array($key, $already_added)) {
                     echo "<option value='{$key}'>" . $val["name"] . "</option>";
                 }
             }
         }
         if (!$first_group) {
             echo "</optgroup>\n";
         }
         echo "</select><span class='small_space'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</span></form>";
         echo "</td></tr>";
     }
     // print first element
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' width='50%'>" . $searchopt[1]["name"];
     if ($global_write) {
         echo "</td><td colspan='3'>&nbsp;";
     }
     echo "</td></tr>";
     // print entity
     if (isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>";
         echo "<td colspan='3'>&nbsp;</td>";
         echo "</tr>";
     }
     $i = 0;
     if ($numrows) {
         while ($data = $DB->fetch_array($result)) {
             if ($data["num"] != 1 && isset($searchopt[$data["num"]])) {
                 echo "<tr class='tab_bg_2'><td class='center' width='50%'>";
                 echo $searchopt[$data["num"]]["name"];
                 echo "</td>";
                 if ($global_write) {
                     if ($i != 0) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='up' value=\"" . $LANG['buttons'][24] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up2.png' alt=\"" . $LANG['buttons'][24] . "\"  title=\"" . $LANG['buttons'][24] . "\">";
                         echo "</form>";
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     if ($i != $numrows - 1) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='down' value=\"" . $LANG['buttons'][25] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down2.png' alt=\"" . $LANG['buttons'][25] . "\" title=\"" . $LANG['buttons'][25] . "\">";
                         echo "</form>";
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     echo "<td class='center middle'>";
                     echo "<form method='post' action='{$target}'>";
                     echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                     echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                     echo "<input type='image' name='delete' value=\"" . $LANG['buttons'][6] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-delete2.png' alt=\"" . $LANG['buttons'][6] . "\" title=\"" . $LANG['buttons'][6] . "\">";
                     echo "</form>";
                     echo "</td>\n";
                 }
                 echo "</tr>";
                 $i++;
             }
         }
     }
     echo "</table>";
     echo "</div>";
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     PluginFusioninventoryAuth::checkRight("snmp_networking", "r");
     $CommonItem = new CommonItem();
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>";
     echo $LANG['plugin_fusioninventory']["menu"][4] . " ( " . $LANG['plugin_fusioninventory']["unknown"][3] . " ";
     $CommonItem->getFromDB(PLUGIN_FUSIONINVENTORY_SNMP_AGENTS, $this->fields["FK_agent"]);
     echo $CommonItem->getLink(1);
     echo ") :</th></tr>";
     $datestring = $LANG["common"][26] . ": ";
     $date = convDateTime($this->fields["date_mod"]);
     echo "<tr>";
     echo "<th align='center' width='450' colspan='2'>";
     echo $LANG["common"][2] . " " . $this->fields["ID"];
     echo "</th>";
     echo "<th align='center' colspan='2' width='50'>";
     echo $datestring . $date;
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='35'/>";
     echo "</td>";
     if (isMultiEntitiesMode()) {
         echo "<td align='center'>" . $LANG['entity'][0] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("Entity", array('name' => 'FK_entities', 'value' => $this->fields["FK_entities"]));
         echo "</td>";
         echo "</tr>";
         echo "</tr>";
     } else {
         echo "<td align='center'></td>";
         echo "</td>";
         echo "<td align='center'></td>";
         echo "</tr>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][0] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='dnsname' value='" . $this->fields["dnsname"] . "' size='35'/>";
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][18] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='contact' value='" . $this->fields["contact"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['common'][17] . " :</td>";
     echo "<td align='center'>";
     $type_list[] = COMPUTER_TYPE;
     $type_list[] = NETWORKING_TYPE;
     $type_list[] = PRINTER_TYPE;
     $type_list[] = PERIPHERAL_TYPE;
     $type_list[] = PHONE_TYPE;
     // GENERIC OBJECT : Search types in generic object
     $plugin = new Plugin();
     if ($plugin->isActivated('genericobject')) {
         if (TableExists("glpi_plugin_genericobject_types")) {
             $query = "SELECT * FROM `glpi_plugin_genericobject_types`\n                  WHERE `status`='1' ";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_array($result)) {
                     $type_list[] = $data['device_type'];
                 }
             }
         }
     }
     // END GENERIC OBJECT
     Device::dropdownTypes('type', $this->fields["type"], $type_list);
     echo "</td>";
     echo "<td align='center'>" . $LANG['setup'][89] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     Dropdown::show("Domain", array('name' => "domain", 'value' => $this->fields["domain"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['common'][15] . " :</td>";
     echo "<td align='center'>";
     Dropdown::show("Location", array('name' => "location", 'value' => $this->fields["location"]));
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][19] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='serial' value='" . $this->fields["serial"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][2] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("accepted", $this->fields["accepted"]);
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][20] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='otherserial' value='" . $this->fields["otherserial"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     if (!empty($this->fields["ifaddr"]) or !empty($this->fields["ifmac"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['networking'][14] . " :</td>";
         echo "<td align='center'>";
         echo "<input type='text' name='otherserial' value='" . $this->fields["ifaddr"] . "' size='35'/>";
         echo "</td>";
         echo "<td align='center'>" . $LANG['networking'][15] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         echo "<input type='text' name='otherserial' value='" . $this->fields["ifmac"] . "' size='35'/>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][3] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("snmp", $this->fields["snmp"]);
     echo "</td>";
     if ($this->fields["snmp"] == "1") {
         echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][4] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "FK_model_infos", 'value' => $this->fields["FK_model_infos"]));
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][3] . " :</td>";
         echo "<td align='center'>";
         Dropdown::show("PluginFusioninventorySnmpauth", array('name' => "FK_snmp_connection", 'value' => $this->fields["FK_snmp_connection"]));
         echo "</td>";
     }
     echo "<td align='center'>" . $LANG['common'][25] . " : </td>";
     echo "</td>";
     echo "<td align='middle'>";
     echo "<textarea  cols='50' rows='5' name='comments' >" . $this->fields["comments"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][4] . " :</td>";
     echo "<td align='center'>";
     echo Dropdown::getYesNo($this->fields["hub"]);
     echo "</td>";
     echo "<td align='center' colspan='2'></td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td class='tab_bg_2' align='center' colspan='4'>\n";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<input type='submit' name='import' value=\"" . $LANG['buttons'][37] . "\" class='submit'>";
     echo "</td>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
     echo "</td>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<div class='center'>";
     if (PluginFusioninventory::haveRight("unknowndevices", "w")) {
         if (!$this->fields["deleted"]) {
             echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][6] . "\" class='submit'>";
         } else {
             echo "<input type='submit' name='restore' value=\"" . $LANG['buttons'][21] . "\" class='submit'>";
             echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"" . $LANG['buttons'][22] . "\" class='submit'>";
         }
     }
     echo "</div>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "</table></form></div>";
 }
예제 #4
0
 /**
  * Print the config form for restrictions
  *
  * @return Nothing (display)
  **/
 function showFormInventory()
 {
     global $DB, $LANG, $CFG_GLPI;
     if (!haveRight("config", "w")) {
         return false;
     }
     echo "<form name='form' action=\"" . getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     echo "<div class='center' id='tabsbody'>";
     echo "<input type='hidden' name='id' value='" . $CFG_GLPI["id"] . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . $LANG['Menu'][38] . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . $LANG['setup'][133] . "&nbsp;:</td><td>";
     Dropdown::showYesNo("use_ocs_mode", $CFG_GLPI["use_ocs_mode"]);
     echo "</td><td> " . $LANG['setup'][271] . "&nbsp;:</td>";
     echo "<td>";
     $this->dropdownGlobalManagement("monitors_management_restrict", $CFG_GLPI["monitors_management_restrict"]);
     echo "</td</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['setup'][8] . "&nbsp;:</td><td>";
     Dropdown::ShowYesNo('auto_create_infocoms', $CFG_GLPI["auto_create_infocoms"]);
     echo "</td></td><td> " . $LANG['setup'][272] . "&nbsp;:</td><td>";
     $this->dropdownGlobalManagement("peripherals_management_restrict", $CFG_GLPI["peripherals_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . $LANG['rulesengine'][86] . "&nbsp;:</td><td>";
     Dropdown::show('SoftwareCategory', array('value' => $CFG_GLPI["softwarecategories_id_ondelete"], 'name' => "softwarecategories_id_ondelete"));
     echo "</td><td> " . $LANG['setup'][273] . "&nbsp;:</td><td>";
     $this->dropdownGlobalManagement("phones_management_restrict", $CFG_GLPI["phones_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['setup'][221] . "&nbsp;:</td><td>";
     showDateFormItem("date_tax", $CFG_GLPI["date_tax"], false, true, '', '', false);
     echo "</td><td> " . $LANG['setup'][275] . "&nbsp;:</td><td>";
     $this->dropdownGlobalManagement("printers_management_restrict", $CFG_GLPI["printers_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['setup'][360] . "&nbsp;:</td><td>";
     $tab = array(0 => $LANG['common'][59], 1 => $LANG['entity'][8]);
     Dropdown::showFromArray('use_autoname_by_entity', $tab, array('value' => $CFG_GLPI["use_autoname_by_entity"]));
     echo "</td></td>";
     echo "<td colspan='2'>&nbsp;";
     echo "</td></tr>";
     echo "</table>";
     if (haveRight("transfer", "w") && isMultiEntitiesMode()) {
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . $LANG['setup'][290] . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . $LANG['setup'][291] . "&nbsp;:</td><td>";
         Dropdown::show('Transfer', array('value' => $CFG_GLPI["transfers_id_auto"], 'name' => "transfers_id_auto", 'emptylabel' => $LANG['setup'][292]));
         echo "</td></td></tr>";
         echo "</table>";
     }
     echo "<br><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='6'>" . $LANG['setup'][280] . " (" . $LANG['peripherals'][32] . ")</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . $LANG['common'][18] . "</th>";
     echo "<th>" . $LANG['common'][34] . "</th>";
     echo "<th>" . $LANG['common'][35] . "</th>";
     echo "<th>" . $LANG['common'][15] . "</th>";
     echo "<th>" . $LANG['state'][0] . "</th>";
     echo "</tr>";
     $fields = array("contact", "group", "location", "user");
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . $LANG['setup'][281] . "&nbsp;:</td>";
     $values[0] = $LANG['setup'][285];
     $values[1] = $LANG['setup'][283];
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoupdate";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoupdate_mode", $LANG['setup'][197], $CFG_GLPI["state_autoupdate_mode"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . $LANG['setup'][282] . "&nbsp;:</td>";
     $values[0] = $LANG['setup'][286];
     $values[1] = $LANG['setup'][284];
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoclean";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoclean_mode", $LANG['setup'][196], $CFG_GLPI["state_autoclean_mode"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='6' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['buttons'][2] . "\">";
     echo "</td></tr>";
     echo "</table></div>";
     echo "</form>";
 }
예제 #5
0
 /**
  *
  * Display a 2 columns Header 1 for ID, 1 for recursivity menu
  * Open the form is user can edit
  *
  * @param $options array
  *     - target for the Form
  *     - withtemplate : 1 for newtemplate, 2 for newobject from template
  *     - colspan for each column (default 2)
  *     - formoptions string (javascript p.e.)
  *     - canedit boolean edit mode of form ?
  *
  **/
 function showFormHeader($options = array())
 {
     global $LANG, $CFG_GLPI;
     $ID = $this->fields['id'];
     $params['target'] = $this->getFormURL();
     $params['colspan'] = 2;
     $params['withtemplate'] = '';
     $params['formoptions'] = '';
     $params['canedit'] = true;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     // Template case : clean entities data
     if ($params['withtemplate'] == 2 && $this->isEntityAssign()) {
         $this->fields['entities_id'] = $_SESSION['glpiactive_entity'];
         if ($this->maybeRecursive()) {
             $this->fields["is_recursive"] = 0;
         }
     }
     if ($this->can($ID, 'w')) {
         echo "<form name='form' method='post' action='" . $params['target'] . "' " . $params['formoptions'] . ">";
         //Should add an hidden entities_id field ?
         //If the table has an entities_id field
         if ($this->isField("entities_id")) {
             //The object type can be assigned to an entity
             if ($this->isEntityAssign()) {
                 // TODO CommonDBChild must not use current entity, but parent entity
                 if (isset($params['entities_id'])) {
                     $entity = $this->fields['entities_id'] = $params['entities_id'];
                 } else {
                     if ($this->isNewID($ID) || $params['withtemplate'] == 2) {
                         //It's a new object to be added
                         $entity = $_SESSION['glpiactive_entity'];
                     } else {
                         //It's an existing object to be displayed
                         $entity = $this->fields['entities_id'];
                     }
                 }
                 echo "<input type='hidden' name='entities_id' value='{$entity}'>";
                 // For Rules except ruleticket and slalevel
             } else {
                 if ($this->getType() != 'User') {
                     echo "<input type='hidden' name='entities_id' value='0'>";
                 }
             }
         }
         // No link on popup window
         if (isset($_GET['popup']) && $_GET['popup']) {
             echo "<input type='hidden' name='_no_message_link' value='1'>";
         }
     }
     echo "<div class='spaced' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='" . $params['colspan'] . "'>";
     if (!empty($params['withtemplate']) && $params['withtemplate'] == 2 && !$this->isNewID($ID)) {
         echo "<input type='hidden' name='template_name' value='" . $this->fields["template_name"] . "'>";
         echo $LANG['buttons'][8] . " - " . $LANG['common'][13] . "&nbsp;: " . $this->fields["template_name"];
     } else {
         if (!empty($params['withtemplate']) && $params['withtemplate'] == 1) {
             echo "<input type='hidden' name='is_template' value='1'>\n";
             echo $LANG['common'][6] . "&nbsp;: ";
             autocompletionTextField($this, "template_name", array('size' => 25));
         } else {
             if ($this->isNewID($ID)) {
                 echo $this->getTypeName() . " - " . $LANG['common'][87];
             } else {
                 echo $this->getTypeName() . " - " . $LANG['common'][2] . " {$ID}";
             }
         }
     }
     if (isset($this->fields["entities_id"]) && isMultiEntitiesMode() && $this->isEntityAssign()) {
         echo "&nbsp;(" . Dropdown::getDropdownName("glpi_entities", $this->fields["entities_id"]) . ")";
     }
     echo "</th><th colspan='" . $params['colspan'] . "'>";
     if (get_class($this) == 'Entity') {
         // is recursive but cannot be change
     } else {
         if ($this->maybeRecursive()) {
             if (isMultiEntitiesMode()) {
                 echo $LANG['entity'][9] . "&nbsp;:&nbsp;";
                 if ($params['canedit']) {
                     if (!$this->can($ID, 'recursive')) {
                         echo Dropdown::getYesNo($this->fields["is_recursive"]);
                         $comment = $LANG['common'][86];
                         // CommonDBChild : entity data is get or copy from parent
                     } else {
                         if ($this instanceof CommonDBChild) {
                             echo Dropdown::getYesNo($this->isRecursive());
                             $comment = $LANG['common'][91];
                         } else {
                             if (!$this->canUnrecurs()) {
                                 echo Dropdown::getYesNo($this->fields["is_recursive"]);
                                 $comment = $LANG['common'][84];
                             } else {
                                 Dropdown::showYesNo("is_recursive", $this->fields["is_recursive"]);
                                 $comment = $LANG['common'][85];
                             }
                         }
                     }
                     echo "&nbsp;";
                     showToolTip($comment);
                 } else {
                     echo Dropdown::getYesNo($this->fields["is_recursive"]);
                 }
             } else {
                 echo "<input type='hidden' name='is_recursive' value='0'>";
             }
         } else {
             echo "&nbsp;";
         }
     }
     echo "</th></tr>\n";
 }
예제 #6
0
 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;
 }
예제 #7
0
 /**
  * Print the user form
  *
  * @param $ID Integer : Id of the user
  * @param $options array
  *     - target form target
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean : user found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     // Affiche un formulaire User
     if ($ID != getLoginUserID() && !haveRight("user", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $caneditpassword = $this->currentUserHaveMoreRightThan($ID);
     $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][18] . "&nbsp;:</td>";
     // si on est dans le cas d'un ajout , cet input ne doit plus etre hidden
     if ($this->fields["name"] == "") {
         echo "<td><input name='name' value='" . $this->fields["name"] . "'></td>";
         // si on est dans le cas d'un modif on affiche la modif du login si ce n'est pas une auth externe
     } else {
         if (!empty($this->fields["password"]) || $this->fields["authtype"] == Auth::DB_GLPI) {
             echo "<td>";
             echo "<input name='name' value='" . $this->fields["name"] . "'>";
         } else {
             echo "<td class='b'>" . $this->fields["name"];
             echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         }
         echo "</td>";
     }
     //do some rights verification
     if (haveRight("user", "w")) {
         if ((!$extauth || empty($ID)) && $caneditpassword) {
             echo "<td>" . $LANG['setup'][19] . "&nbsp;:</td>";
             echo "<td><input type='password' name='password' value='' size='20' autocomplete='off'>";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'>&nbsp;</td></tr>";
         }
     } else {
         echo "<td colspan='2'>&nbsp;</td></tr>";
     }
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][48] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "realname");
     echo "</td>";
     //do some rights verification
     if (haveRight("user", "w")) {
         if ((!$extauth || empty($ID)) && $caneditpassword) {
             echo "<td>" . $LANG['setup'][20] . "&nbsp;:</td>";
             echo "<td><input type='password' name='password2' value='' size='20' autocomplete='off'>";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'>&nbsp;</td></tr>";
         }
     } else {
         echo "<td colspan='2'>&nbsp;</td></tr>";
     }
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][43] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "firstname");
     echo "</td>";
     //Authentications informations : auth method used and server used
     //don't display is creation of a new user'
     if (!empty($ID)) {
         if (haveRight("user_authtype", "r")) {
             echo "<td>" . $LANG['login'][10] . "&nbsp;:</td><td>";
             echo Auth::getMethodName($this->fields["authtype"], $this->fields["auths_id"]);
             if (!empty($this->fields["date_sync"])) {
                 echo '<br>' . $LANG['login'][29] . '&nbsp;: ' . convDateTime($this->fields["date_sync"]);
             }
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
     } else {
         echo "<td colspan='2'><input type='hidden' name='authtype' value='1'></td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][42] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "mobile");
     echo "</td>";
     echo "<td>" . $LANG['common'][60] . "&nbsp;:</td><td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][14] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "email", array('name' => "email_form"));
     if (!empty($ID) && !NotificationMail::isUserAddressValid($this->fields["email"])) {
         echo "<br><span class='red'>&nbsp;" . $LANG['mailing'][110] . "</span>";
     }
     echo "</td>";
     echo "<td>" . $LANG['users'][2] . "&nbsp;:</td><td>";
     Dropdown::show('UserCategory', array('value' => $this->fields["usercategories_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "phone");
     echo "</td>";
     echo "<td rowspan='5' class='middle'>" . $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td class='center middle' rowspan='5'>";
     echo "<textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['help'][35] . " 2&nbsp;:</td><td>";
     autocompletionTextField($this, "phone2");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['users'][17] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "registration_number");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['users'][1] . "&nbsp;:</td><td>";
     Dropdown::show('UserTitle', array('value' => $this->fields["usertitles_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][15] . "&nbsp;:</td><td>";
     if (!empty($ID)) {
         $entities = Profile_User::getUserEntities($ID, true);
         if (count($entities) > 0) {
             Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $entities));
         } else {
             echo "&nbsp;";
         }
     } else {
         if (!isMultiEntitiesMode()) {
             // Display all locations : only one entity
             Dropdown::show('Location', array('value' => $this->fields["locations_id"]));
         } else {
             echo "&nbsp;";
         }
     }
     echo "</td></tr>";
     //don't display is creation of a new user'
     if (!empty($ID)) {
         if ($caneditpassword) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . $LANG['profiles'][13] . "&nbsp;: </td><td>";
             $options[0] = DROPDOWN_EMPTY_VALUE;
             $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
             echo "<td>" . $LANG['profiles'][37] . "&nbsp;: </td><td>";
             $entities = Profile_User::getUserEntities($this->fields['id'], 1);
             Dropdown::show('Entity', array('value' => $this->fields["entities_id"], 'entity' => $entities));
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>" . $LANG['login'][24] . "&nbsp;: ";
         if (!empty($this->fields["date_mod"])) {
             echo convDateTime($this->fields["date_mod"]);
         }
         echo "<br>" . $LANG['login'][0] . "&nbsp;: ";
         if (!empty($this->fields["last_login"])) {
             echo convDateTime($this->fields["last_login"]);
         }
         echo "</td><td colspan='2'class='center'>";
         if ($ID > 0) {
             echo "<a target='_blank' href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?getvcard=1&amp;id={$ID}'>" . $LANG['common'][46] . "</a>";
         }
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     $this->showTabs($ID, "", $_SESSION['glpi_tab']);
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'><tr><th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["rangeip"][2];
     echo " :</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["rangeip"][0] . "</td>";
     echo "<td align='center'>";
     if (empty($this->fields["ifaddr_start"])) {
         $this->fields["ifaddr_start"] = "...";
     }
     $ipexploded = explode(".", $this->fields["ifaddr_start"]);
     $i = 0;
     foreach ($ipexploded as $ipnum) {
         if ($ipnum > 255) {
             $ipexploded[$i] = '';
         }
         $i++;
     }
     echo "<input type='text' value='" . $ipexploded[0] . "' name='ifaddr_start0' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[1] . "' name='ifaddr_start1' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[2] . "' name='ifaddr_start2' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[3] . "' name='ifaddr_start3' size='3' maxlength='3' >";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["rangeip"][1] . "</td>";
     echo "<td align='center'>";
     unset($ipexploded);
     if (empty($this->fields["ifaddr_end"])) {
         $this->fields["ifaddr_end"] = "...";
     }
     $ipexploded = explode(".", $this->fields["ifaddr_end"]);
     $i = 0;
     foreach ($ipexploded as $ipnum) {
         if ($ipnum > 255) {
             $ipexploded[$i] = '';
         }
         $i++;
     }
     echo "<input type='text' value='" . $ipexploded[0] . "' name='ifaddr_end0' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[1] . "' name='ifaddr_end1' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[2] . "' name='ifaddr_end2' size='3' maxlength='3' >.";
     echo "<input type='text' value='" . $ipexploded[3] . "' name='ifaddr_end3' size='3' maxlength='3' >";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["agents"][12] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventoryAgents", array('name' => "FK_fusioninventory_agents_discover", 'value' => $this->fields["FK_fusioninventory_agents_discover"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["agents"][13] . "</td>";
     echo "<td align='center'>";
     Dropdown::show("PluginFusioninventoryAgents", array('name' => "FK_fusioninventory_agents_query", 'value' => $this->fields["FK_fusioninventory_agents_query"], 'comments' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["discovery"][3] . "</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("discover", $this->fields["discover"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["rangeip"][3] . "</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("query", $this->fields["query"]);
     echo "</td>";
     echo "</tr>";
     if (isMultiEntitiesMode()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['entity'][0] . "</td>";
         echo "<td align='center'>";
         Dropdown::show('Entity', array('name' => 'FK_entities', 'value' => $this->fields["FK_entities"]));
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'><td align='center' colspan='3'>";
     if (PluginFusioninventory::haveRight("rangeip", "w")) {
         if ($ID == '') {
             echo "<div align='center'><input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit' >";
         } else {
             echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
             echo "<div align='center'><input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
             echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
         }
     }
     echo "</td></tr>";
     echo "</table></form></div>";
 }
예제 #9
0
 /**
  * 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";
     }
 }
예제 #10
0
 /**
  * Generic Function to add default columns to view
  *
  *@param $itemtype device type
  *
  *@return select string
  *
  **/
 static function addDefaultToView($itemtype)
 {
     global $CFG_GLPI;
     $toview = array();
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     // Add first element (name)
     array_push($toview, 1);
     // Add entity view :
     if (isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1)) {
         array_push($toview, 80);
     }
     return $toview;
 }
예제 #11
0
 static function showItems($target, $date1, $date2, $start)
 {
     global $DB, $CFG_GLPI, $LANG;
     $view_entities = isMultiEntitiesMode();
     if ($view_entities) {
         $entities = getAllDatasFromTable('glpi_entities');
     }
     $output_type = HTML_OUTPUT;
     if (isset($_GET["display_type"])) {
         $output_type = $_GET["display_type"];
     }
     if (empty($date2)) {
         $date2 = date("Y-m-d");
     }
     $date2 .= " 23:59:59";
     // 1 an par defaut
     if (empty($date1)) {
         $date1 = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1));
     }
     $date1 .= " 00:00:00";
     $query = "SELECT `itemtype`,\n                       `items_id`,\n                       COUNT(*) AS NB\n                FROM `glpi_tickets`\n                WHERE `date` <= '{$date2}'\n                      AND `date` >= '{$date1}' " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n                      AND `itemtype` <> ''\n                      AND `items_id` > 0\n                GROUP BY `itemtype`, `items_id`\n                ORDER BY NB DESC";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     if ($numrows > 0) {
         if ($output_type == HTML_OUTPUT) {
             printPager($start, $numrows, $target, "date1=" . $date1 . "&amp;date2=" . $date2 . "&amp;type=hardwares&amp;start={$start}", 'Stat');
             echo "<div class='center'>";
         }
         $end_display = $start + $_SESSION['glpilist_limit'];
         if (isset($_GET['export_all'])) {
             $end_display = $numrows;
         }
         echo Search::showHeader($output_type, $end_display - $start + 1, 2, 1);
         $header_num = 1;
         echo Search::showNewLine($output_type);
         echo Search::showHeaderItem($output_type, $LANG['document'][14], $header_num);
         if ($view_entities) {
             echo Search::showHeaderItem($output_type, $LANG['entity'][0], $header_num);
         }
         echo Search::showHeaderItem($output_type, $LANG['stats'][13], $header_num);
         echo Search::showEndLine($output_type);
         $DB->data_seek($result, $start);
         $i = $start;
         if (isset($_GET['export_all'])) {
             $start = 0;
         }
         for ($i = $start; $i < $numrows && $i < $end_display; $i++) {
             $item_num = 1;
             // Get data and increment loop variables
             $data = $DB->fetch_assoc($result);
             if (!class_exists($data["itemtype"])) {
                 continue;
             }
             $item = new $data["itemtype"]();
             if ($item->getFromDB($data["items_id"])) {
                 echo Search::showNewLine($output_type, $i % 2);
                 echo Search::showItem($output_type, $item->getTypeName() . " - " . $item->getLink(), $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : ""));
                 if ($view_entities) {
                     $ent = $item->getEntityID();
                     if ($ent == 0) {
                         $ent = $LANG['entity'][2];
                     } else {
                         $ent = $entities[$ent]['completename'];
                     }
                     echo Search::showItem($output_type, $ent, $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : ""));
                 }
                 echo Search::showItem($output_type, $data["NB"], $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : ""));
             }
         }
         echo Search::showFooter($output_type);
         if ($output_type == HTML_OUTPUT) {
             echo "</div>";
         }
     }
 }
예제 #12
0
// Original Author of file: Walid Nouh
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
commonHeader($LANG['common'][12], $_SERVER['PHP_SELF'], "admin", "rule", -1);
echo "<table class='tab_cadre'>";
echo "<tr><th>" . $LANG['rulesengine'][24] . "</th></tr>";
foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
    $rulecollection = new $rulecollectionclass();
    if ($rulecollection->canList()) {
        if ($plug = isPluginItemType($rulecollectionclass)) {
            $function = 'plugin_version_' . strtolower($plug['plugin']);
            $plugname = $function();
            $title = $plugname['name'] . ' - ';
        } else {
            $title = '';
        }
        $title .= $rulecollection->getTitle();
        echo "<tr class='tab_bg_1'><td class='center b'>";
        echo "<a href='" . getItemTypeSearchURL($rulecollection->getRuleClassName()) . "'>";
        echo $title . "</a></td></tr>";
    }
}
if (haveRight("transfer", "r") && isMultiEntitiesMode()) {
    echo "<tr class='tab_bg_1'><td class='center b'>";
    echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/transfer.php'>" . $LANG['transfer'][1] . "</a>";
    echo "</td></tr>";
}
echo "</table>";
commonFooter();
 /**
  * Show KB categories
  *
  * @param $options : $_GET
  * @param $faq display on faq ?
  *
  * @return nothing (display the form)
  **/
 static function showFirstLevel($options, $faq = 0)
 {
     global $DB, $LANG, $CFG_GLPI;
     // Default values of parameters
     $params["knowbaseitemcategories_id"] = "0";
     $params["target"] = $_SERVER['PHP_SELF'];
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $faq_limit = '';
     if ($faq) {
         if (!$CFG_GLPI["use_public_faq"] && !haveRight("faq", "r")) {
             return false;
         }
         if (getLoginUserID()) {
             $faq_limit = getEntitiesRestrictRequest("AND", "glpi_knowbaseitemcategories", "", "", true);
         } else {
             // Anonymous access
             if (isMultiEntitiesMode()) {
                 $faq_limit = " AND (`glpi_knowbaseitemcategories`.`entities_id` = '0'\n                                   AND `glpi_knowbaseitemcategories`.`is_recursive` = '1')";
             }
         }
         // Get All FAQ categories
         if (!isset($_SESSION['glpi_faqcategories'])) {
             $_SESSION['glpi_faqcategories'] = '(0)';
             $tmp = array();
             $query = "SELECT DISTINCT `glpi_knowbaseitems`.`knowbaseitemcategories_id`\n                      FROM `glpi_knowbaseitems`\n                      LEFT JOIN `glpi_knowbaseitemcategories`\n                           ON (`glpi_knowbaseitemcategories`.`id`\n                                 = `glpi_knowbaseitems`.`knowbaseitemcategories_id`)\n                      WHERE `glpi_knowbaseitems`.`is_faq` = '1'\n                            {$faq_limit}";
             if ($result = $DB->query($query)) {
                 if ($DB->numrows($result)) {
                     while ($data = $DB->fetch_array($result)) {
                         if (!in_array($data['knowbaseitemcategories_id'], $tmp)) {
                             $tmp[] = $data['knowbaseitemcategories_id'];
                             $tmp = array_merge($tmp, getAncestorsOf('glpi_knowbaseitemcategories', $data['knowbaseitemcategories_id']));
                         }
                     }
                 }
                 if (count($tmp)) {
                     $_SESSION['glpi_faqcategories'] = "('" . implode("','", $tmp) . "')";
                 }
             }
         }
         $query = "SELECT DISTINCT `glpi_knowbaseitemcategories`.*\n                   FROM `glpi_knowbaseitemcategories`\n                   WHERE `id` IN " . $_SESSION['glpi_faqcategories'] . "\n                         AND (`glpi_knowbaseitemcategories`.`knowbaseitemcategories_id`\n                                 = '" . $params["knowbaseitemcategories_id"] . "')\n                         {$faq_limit}\n                   ORDER BY `name` ASC";
     } else {
         if (!haveRight("knowbase", "r")) {
             return false;
         }
         $faq_limit = getEntitiesRestrictRequest("AND", "glpi_knowbaseitemcategories", "entities_id", $_SESSION['glpiactiveentities'], true);
         $query = "SELECT *\n                   FROM `glpi_knowbaseitemcategories`\n                   WHERE `glpi_knowbaseitemcategories`.`knowbaseitemcategories_id`\n                              = '" . $params["knowbaseitemcategories_id"] . "'\n                         {$faq_limit}\n                   ORDER BY `name` ASC";
     }
     // Show category
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_central'>";
         echo "<tr><td colspan='3'><a href='" . $params['target'] . "'>";
         echo "<img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/folder-open.png' class='bottom'></a>";
         // Display Category
         if ($params["knowbaseitemcategories_id"] != 0) {
             $tmpID = $params["knowbaseitemcategories_id"];
             $todisplay = "";
             while ($tmpID != 0) {
                 $query2 = "SELECT *\n                          FROM `glpi_knowbaseitemcategories`\n                          WHERE `id` = '{$tmpID}'\n                                {$faq_limit}";
                 $result2 = $DB->query($query2);
                 if ($DB->numrows($result2) == 1) {
                     $data = $DB->fetch_assoc($result2);
                     $tmpID = $data["knowbaseitemcategories_id"];
                     $todisplay = "<a href='" . $params['target'] . "?knowbaseitemcategories_id=" . $data["id"] . "'>" . $data["name"] . "</a>" . (empty($todisplay) ? "" : " > ") . $todisplay;
                 } else {
                     $tmpID = 0;
                 }
             }
             echo " > " . $todisplay;
         }
         if ($DB->numrows($result) > 0) {
             $i = 0;
             while ($row = $DB->fetch_array($result)) {
                 // on affiche les résultats sur trois colonnes
                 if ($i % 3 == 0) {
                     echo "<tr>";
                 }
                 $ID = $row["id"];
                 echo "<td class='tdkb_result'>";
                 echo "<img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/folder.png' hspace='5'>";
                 echo "<strong><a href='" . $params['target'] . "?knowbaseitemcategories_id=" . $row["id"] . "'>" . $row["name"] . "</a></strong>";
                 echo "<div class='kb_resume'>" . resume_text($row['comment'], 60) . "</div>";
                 if ($i % 3 == 2) {
                     echo "</tr>";
                 }
                 $i++;
             }
         }
         echo "<tr><td colspan='3'>&nbsp;</td></tr></table><br>";
     }
 }
예제 #14
0
 /**
  * Print out list recent or popular kb/faq
  *
  * @param $target where to go on action
  * @param $type type : recent / popular
  * @param $faq display only faq
  *
  * @return nothing (display table)
  **/
 static function showRecentPopular($target, $type, $faq = 0)
 {
     global $DB, $LANG;
     if ($type == "recent") {
         $orderby = "ORDER BY `date` DESC";
         $title = $LANG['knowbase'][29];
     } else {
         $orderby = "ORDER BY `view` DESC";
         $title = $LANG['knowbase'][30];
     }
     $faq_limit = "";
     if (getLoginUserID()) {
         $faq_limit .= getEntitiesRestrictRequest(" WHERE ", "glpi_knowbaseitems", "", "", true);
     } else {
         // Anonymous access
         if (isMultiEntitiesMode()) {
             $faq_limit .= " WHERE (`glpi_knowbaseitems`.`entities_id` = '0'\n                                   AND `glpi_knowbaseitems`.`is_recursive` = '1')";
         } else {
             $faq_limit .= " WHERE 1";
         }
     }
     if ($faq) {
         // FAQ
         $faq_limit .= " AND (`glpi_knowbaseitems`.`is_faq` = '1')";
     }
     $query = "SELECT *\n                FROM `glpi_knowbaseitems`\n                {$faq_limit}\n                {$orderby}\n                LIMIT 10";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($number > 0) {
         echo "<table class='tab_cadrehov'>";
         echo "<tr><th>" . $title . "</th></tr>";
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_2'><td class='left'>";
             echo "<a " . ($data['is_faq'] ? " class='pubfaq' " : " class='knowbase' ") . " href=\"" . $target . "?id=" . $data["id"] . "\">" . resume_text($data["question"], 80) . "</a></td></tr>";
         }
         echo "</table>";
     }
 }
예제 #15
0
 static function showUserImportForm(AuthLDAP $authldap)
 {
     global $DB, $LANG;
     //Get data related to entity (directory and ldap filter)
     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
     echo "<div class='center'>";
     echo "<form method='post' action='" . $_SERVER['PHP_SELF'] . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4' class='middle'><div class='relative'>";
     echo "<span>" . ($_SESSION['ldap_import']['mode'] ? $LANG['ldap'][1] : $LANG['ldap'][2]);
     // Expert interface allow user to override configuration.
     // If not coming from the ticket form, then give expert/simple link
     if ((haveRight('config', 'w') || haveRight('entity', 'w')) && !isset($_SESSION['ldap_import']['no_expert_mode'])) {
         echo "</span>&nbsp;<span class='ldap_right'>" . $LANG['common'][65] . "&nbsp;: ";
         echo "<a href='" . $_SERVER['PHP_SELF'] . "?action=" . $_SESSION['ldap_import']['action'] . "&amp;mode=" . $_SESSION['ldap_import']['mode'] . "&amp;interface=" . ($_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE ? self::EXPERT_INTERFACE : self::SIMPLE_INTERFACE) . "'>" . ($_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE ? $LANG['ldap'][39] : $LANG['ldap'][40]) . "</a>";
     } else {
         $_SESSION['ldap_import']['interface'] = self::SIMPLE_INTERFACE;
     }
     echo "</span></div>";
     echo "</th></tr>";
     switch ($_SESSION['ldap_import']['interface']) {
         case self::EXPERT_INTERFACE:
             //If more than one directory configured
             //Display dropdown ldap servers
             if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
                 if (self::getNumberOfServers() > 1) {
                     echo "<tr class='tab_bg_2'><td>" . $LANG['ldap'][4] . "</td><td colspan='3'>";
                     Dropdown::show('AuthLdap', array('name' => 'authldaps_id', 'value' => $_SESSION['ldap_import']['authldaps_id'], 'condition' => "`is_active` = '1'", 'display_emptychoice' => false));
                     echo "&nbsp;<input class='submit' type='submit' name='change_directory'\n                        value=\"" . $LANG['ldap'][41] . "\">";
                     echo "</td></tr>";
                 }
                 echo "<tr class='tab_bg_2'><td>Basedn</td><td colspan='3'>";
                 echo "<input type='text' name='basedn' value=\"" . $_SESSION['ldap_import']['basedn'] . "\" size='90' " . (!$_SESSION['ldap_import']['basedn'] ? "disabled" : "") . ">";
                 echo "</td></tr>";
                 echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][263] . "</td><td colspan='3'>";
                 echo "<input type='text' name='ldap_filter' value=\"" . $_SESSION['ldap_import']['ldap_filter'] . "\" size='90'>";
                 echo "</td></tr>";
             }
             break;
             //case self::SIMPLE_INTERFACE :
         //case self::SIMPLE_INTERFACE :
         default:
             //If multi-entity mode and more than one entity visible
             //else no need to select entity
             if (isMultiEntitiesMode() && count($_SESSION['glpiactiveentities']) > 1) {
                 echo "<tr class='tab_bg_2'><td>" . $LANG['entity'][10] . "</td><td colspan='3'>";
                 Dropdown::show('Entity', array('value' => $_SESSION['ldap_import']['entities_id'], 'entity' => $_SESSION['glpiactiveentities'], 'auto_submit' => 1));
                 echo "</td></tr>";
             } else {
                 //Only one entity is active, store it
                 echo "<tr><td><input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'></td></tr>";
             }
             if (isset($_SESSION['ldap_import']['days']) && $_SESSION['ldap_import']['days']) {
                 $enabled = 1;
             } else {
                 $enabled = 0;
             }
             Dropdown::showAdvanceDateRestrictionSwitch($enabled);
             echo "<table class='tab_cadre_fixe'>";
             if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
                 $field_counter = 0;
                 $fields = array('login_field' => $LANG['login'][6], 'email_field' => $LANG['setup'][14], 'realname_field' => $LANG['common'][48], 'firstname_field' => $LANG['common'][43], 'phone_field' => $LANG['help'][35], 'phone2_field' => $LANG['help'][35] . " 2", 'mobile_field' => $LANG['common'][42], 'title_field' => $LANG['users'][1], 'category_field' => $LANG['users'][2]);
                 $available_fields = array();
                 foreach ($fields as $field => $label) {
                     if (isset($authldap->fields[$field]) && $authldap->fields[$field] != '') {
                         $available_fields[$field] = $label;
                     }
                 }
                 echo "<tr><th colspan='4'>" . $LANG['ldap'][38] . "</th></tr>";
                 foreach ($available_fields as $field => $label) {
                     if ($field_counter == 0) {
                         echo "<tr class='tab_bg_1'>";
                     }
                     echo "<td>{$label}</td><td>";
                     $field_counter++;
                     echo "<input type='text' name='criterias[{$field}]' value='" . (isset($_SESSION['ldap_import']['criterias'][$field]) ? $_SESSION['ldap_import']['criterias'][$field] : '') . "'>";
                     echo "</td>";
                     if ($field_counter == 2) {
                         echo "</tr>";
                         $field_counter = 0;
                     }
                 }
                 if ($field_counter > 0) {
                     while ($field_counter < 2) {
                         echo "<td colspan='2'></td>";
                         $field_counter++;
                     }
                     $field_counter = 0;
                     echo "</tr>";
                 }
             }
             break;
     }
     if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
         if ($_SESSION['ldap_import']['authldaps_id']) {
             echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
             echo "<input class='submit' type='submit' name='search' value=\"" . $LANG['buttons'][0] . "\">";
             echo "</td></tr>";
         } else {
             echo "<tr class='tab_bg_2'><td colspan='4' class='center'>" . $LANG['ldap'][42] . "</td></tr>";
         }
     } else {
         echo "<tr class='tab_bg_2'><td colspan='4' class='center'>" . $LANG['ldap'][36] . "</td></tr>";
     }
     echo "</table></form></div>";
 }
 static function showListSimple()
 {
     global $DB, $LANG, $CFG_GLPI;
     if (!haveRight("reservation_helpdesk", "1")) {
         return false;
     }
     $ri = new ReservationItem();
     $ok = false;
     $showentity = isMultiEntitiesMode();
     echo "<div class='center'><form name='form' method='get' action='reservation.form.php'>";
     echo "<table class='tab_cadre'>";
     echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . $LANG['reservation'][1] . "</th></tr>\n";
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         $itemtable = getTableForItemType($itemtype);
         $query = "SELECT `glpi_reservationitems`.`id`,\n                          `glpi_reservationitems`.`comment`,\n                          `{$itemtable}`.`name` AS name,\n                          `{$itemtable}`.`entities_id` AS entities_id,\n                          `glpi_locations`.`completename` AS location,\n                          `glpi_reservationitems`.`items_id` AS items_id\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `{$itemtable}`\n                        ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n                            AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n                   LEFT JOIN `glpi_locations`\n                        ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n                   WHERE `glpi_reservationitems`.`is_active` = '1'\n                         AND `{$itemtable}`.`is_deleted` = '0'" . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n                   ORDER BY `{$itemtable}`.`entities_id`,\n                            `{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             while ($row = $DB->fetch_array($result)) {
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'></td>";
                 $typename = $item->getTypeName();
                 if ($itemtype == 'Peripheral') {
                     $item->getFromDB($row['items_id']);
                     if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
                         $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
                     }
                 }
                 echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>{$typename} - " . $row["name"] . "</a></td>";
                 echo "<td>" . $row["location"] . "</td>";
                 echo "<td>" . nl2br($row["comment"]) . "</td>";
                 if ($showentity) {
                     echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>";
                 }
                 echo "</tr>\n";
                 $ok = true;
             }
         }
     }
     if ($ok) {
         echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>";
         echo "<input type='submit' value=\"" . $LANG['buttons'][8] . "\" class='submit'></td></tr>\n";
     }
     echo "</table>\n";
     echo "<input type='hidden' name='id' value=''>";
     echo "</form></div>\n";
 }
예제 #17
0
/**
 * Print the form used to select profile if several are available
 *
 * @param $target target of the form
 *
 * @return nothing
 **/
function showProfileSelecter($target)
{
    global $CFG_GLPI, $LANG;
    if (count($_SESSION["glpiprofiles"]) > 1) {
        echo '<li><form name="form" method="post" action="' . $target . '">';
        echo '<select name="newprofile" onChange="submit()">';
        foreach ($_SESSION["glpiprofiles"] as $key => $val) {
            echo '<option value="' . $key . '" ' . ($_SESSION["glpiactiveprofile"]["id"] == $key ? 'selected' : '') . '>' . $val['name'] . '</option>';
        }
        echo '</select></form></li>';
    }
    if (isMultiEntitiesMode()) {
        echo "<li>";
        echo "<script type='text/javascript'>";
        echo "cleanhide('modal_entity_content');";
        echo "var entity_window=new Ext.Window({\n         layout:'fit',\n         width:800,\n         height:400,\n         closeAction:'hide',\n         modal: true,\n         autoScroll: true,\n         title: \"" . $LANG['entity'][10] . "\",\n         autoLoad: '" . $CFG_GLPI['root_doc'] . "/ajax/entitytree.php?target={$target}'\n      });";
        echo "</script>";
        echo "<a onclick='entity_window.show();' href='#modal_entity_content' title=\"" . $_SESSION["glpiactive_entity_name"] . "\" class='entity_select' id='global_entity_select'>" . $_SESSION["glpiactive_entity_shortname"] . "</a>";
        echo "</li>";
    }
}
 function getCriterias()
 {
     global $LANG;
     $criterias = array();
     $criterias['mailcollector']['field'] = 'name';
     $criterias['mailcollector']['name'] = $LANG['mailgate'][0];
     $criterias['mailcollector']['table'] = 'glpi_mailcollectors';
     $criterias['mailcollector']['type'] = 'dropdown';
     $criterias['_users_id_requester']['field'] = 'name';
     $criterias['_users_id_requester']['name'] = $LANG['common'][34] . ' : ' . $LANG['common'][16];
     $criterias['_users_id_requester']['table'] = 'glpi_users';
     $criterias['_users_id_requester']['type'] = 'dropdown';
     $criterias['subject']['name'] = $LANG['mailing'][118] . ' : ' . $LANG['common'][90];
     $criterias['subject']['field'] = 'subject';
     $criterias['subject']['table'] = '';
     $criterias['subject']['type'] = 'text';
     $criterias['content']['name'] = $LANG['mailing'][118] . ' : ' . $LANG['mailing'][114];
     $criterias['content']['table'] = '';
     $criterias['content']['type'] = 'text';
     $criterias['from']['name'] = $LANG['mailing'][132] . ' : from';
     $criterias['from']['table'] = '';
     $criterias['from']['type'] = 'text';
     $criterias['to']['name'] = $LANG['mailing'][132] . ' : to';
     $criterias['to']['table'] = '';
     $criterias['to']['type'] = 'text';
     $criterias['in_reply_to']['name'] = $LANG['mailing'][132] . ' : in_reply_to';
     $criterias['in_reply_to']['table'] = '';
     $criterias['in_reply_to']['type'] = 'text';
     $criterias['x-priority']['name'] = $LANG['mailing'][132] . ' : X-Priority';
     $criterias['x-priority']['table'] = '';
     $criterias['x-priority']['type'] = 'text';
     $criterias['x-auto-response-suppress']['name'] = $LANG['mailing'][132] . ' : X-Auto-Response-Suppress';
     $criterias['x-auto-response-suppress']['table'] = '';
     $criterias['x-auto-response-suppress']['type'] = 'text';
     $criterias['auto-submitted']['name'] = $LANG['mailing'][132] . ' : Auto-Submitted';
     $criterias['auto-submitted']['table'] = '';
     $criterias['auto-submitted']['type'] = 'text';
     /// Renater spam matching : X-UCE-Status = Yes
     $criterias['x-uce-status']['name'] = $LANG['mailing'][132] . ' : X-UCE-Status';
     $criterias['x-uce-status']['table'] = '';
     $criterias['x-uce-status']['type'] = 'text';
     $criterias['received']['name'] = $LANG['mailing'][132] . ' : Received';
     $criterias['received']['table'] = '';
     $criterias['received']['type'] = 'text';
     $criterias['GROUPS']['table'] = 'glpi_groups';
     $criterias['GROUPS']['field'] = 'name';
     $criterias['GROUPS']['name'] = $LANG['common'][34] . ' : ' . $LANG['common'][35];
     $criterias['GROUPS']['linkfield'] = '';
     $criterias['GROUPS']['type'] = 'dropdown';
     $criterias['GROUPS']['virtual'] = true;
     $criterias['GROUPS']['id'] = 'groups';
     $criterias['KNOWN_DOMAIN']['field'] = 'name';
     $criterias['KNOWN_DOMAIN']['name'] = $LANG['rulesengine'][148];
     $criterias['KNOWN_DOMAIN']['table'] = 'glpi_entitydatas';
     $criterias['KNOWN_DOMAIN']['type'] = 'yesno';
     $criterias['KNOWN_DOMAIN']['virtual'] = true;
     $criterias['KNOWN_DOMAIN']['id'] = 'entitydatas';
     $criterias['KNOWN_DOMAIN']['allow_condition'] = array(Rule::PATTERN_IS);
     $criterias['PROFILES']['field'] = 'name';
     $criterias['PROFILES']['name'] = $LANG['rulesengine'][146];
     $criterias['PROFILES']['table'] = 'glpi_profiles';
     $criterias['PROFILES']['type'] = 'dropdown';
     $criterias['PROFILES']['virtual'] = true;
     $criterias['PROFILES']['id'] = 'profiles';
     $criterias['PROFILES']['allow_condition'] = array(Rule::PATTERN_IS);
     if (isMultiEntitiesMode()) {
         $criterias['UNIQUE_PROFILE']['field'] = 'name';
         $criterias['UNIQUE_PROFILE']['name'] = $LANG['rulesengine'][147];
         $criterias['UNIQUE_PROFILE']['table'] = 'glpi_profiles';
         $criterias['UNIQUE_PROFILE']['type'] = 'dropdown';
         $criterias['UNIQUE_PROFILE']['virtual'] = true;
         $criterias['UNIQUE_PROFILE']['id'] = 'profiles';
         $criterias['UNIQUE_PROFILE']['allow_condition'] = array(Rule::PATTERN_IS);
     }
     $criterias['ONE_PROFILE']['field'] = 'name';
     $criterias['ONE_PROFILE']['name'] = $LANG['rulesengine'][145];
     $criterias['ONE_PROFILE']['table'] = '';
     $criterias['ONE_PROFILE']['type'] = 'yesonly';
     $criterias['ONE_PROFILE']['virtual'] = true;
     $criterias['ONE_PROFILE']['id'] = 'profiles';
     $criterias['ONE_PROFILE']['allow_condition'] = array(Rule::PATTERN_IS);
     return $criterias;
 }
                $first = true;
                foreach ($_POST["annee"] as $key2 => $val2) {
                    if (!$first) {
                        $query[$val] .= " OR ";
                    } else {
                        $first = false;
                    }
                    $query[$val] .= " YEAR(`glpi_infocoms`.`buy_date`) = '{$val2}'\n                                OR YEAR(`glpi_contracts`.`begin_date`) = '{$val2}'";
                }
                $query[$val] .= ")";
            }
            $query[$val] .= " ORDER BY entname ASC, itemdeleted DESC, itemname ASC";
        }
    }
}
$display_entity = isMultiEntitiesMode();
if (isset($query) && count($query)) {
    foreach ($query as $key => $val) {
        $result = $DB->query($val);
        if ($result && $DB->numrows($result)) {
            $item = new $key();
            echo "<strong>" . $item->getTypeName() . "</strong>";
            echo "<table class='tab_cadre_report'>";
            echo "<tr><th>" . $LANG['common'][16] . "</th>";
            echo "<th>" . $LANG['common'][28] . "</th>";
            if ($display_entity) {
                echo "<th>" . $LANG['entity'][0] . "</th>";
            }
            echo "<th>" . $LANG['common'][15] . "</th>";
            echo "<th>" . $LANG['financial'][14] . "</th>";
            echo "<th>" . $LANG['financial'][80] . "</th>";
예제 #20
0
 /**
  * Display a list of computers to add or to link
  *
  * @param ocsservers_id the ID of the ocs server
  * @param advanced display detail about the computer import or not (target entity, matched rules, etc.)
  * @param check indicates if checkboxes are checked or not
  * @param start display a list of computers starting at row X
  * @param entity a list of entities in which computers can be added or linked
  * @param tolinked false for an import, true for a link
  *
  * @return nothing
  **/
 static function showComputersToAdd($ocsservers_id, $advanced, $check, $start, $entity = 0, $tolinked = false)
 {
     global $DB, $DBocs, $LANG, $CFG_GLPI;
     if (!haveRight("ocsng", "w")) {
         return false;
     }
     $target = $CFG_GLPI['root_doc'] . '/front/ocsng.import.php';
     if ($tolinked) {
         $target = $CFG_GLPI['root_doc'] . '/front/ocsng.link.php';
     }
     $cfg_ocs = self::getConfig($ocsservers_id);
     $WHERE = self::getTagLimit($cfg_ocs);
     $query_ocs = "SELECT `hardware`.*,\n                           `accountinfo`.`TAG` AS TAG,\n                           `bios`.`SSN` AS SERIAL\n                    FROM `hardware`\n                    INNER JOIN `accountinfo` ON (`hardware`.`id` = `accountinfo`.`HARDWARE_ID`)\n                    INNER JOIN `bios` ON (`hardware`.`id` = `bios`.`HARDWARE_ID`)" . (!empty($WHERE) ? "WHERE {$WHERE}" : "") . "\n                    ORDER BY `hardware`.`NAME`";
     $result_ocs = $DBocs->query($query_ocs);
     // Existing OCS - GLPI link
     $query_glpi = "SELECT *\n                     FROM `glpi_ocslinks`\n                     WHERE `ocsservers_id` = '{$ocsservers_id}'";
     $result_glpi = $DB->query($query_glpi);
     if ($DBocs->numrows($result_ocs) > 0) {
         // Get all hardware from OCS DB
         $hardware = array();
         while ($data = $DBocs->fetch_array($result_ocs)) {
             $data = clean_cross_side_scripting_deep(addslashes_deep($data));
             $hardware[$data["ID"]]["date"] = $data["LASTDATE"];
             $hardware[$data["ID"]]["name"] = $data["NAME"];
             $hardware[$data["ID"]]["TAG"] = $data["TAG"];
             $hardware[$data["ID"]]["id"] = $data["ID"];
             $hardware[$data["ID"]]["serial"] = $data["SERIAL"];
             $query_network = "SELECT *\n                              FROM `networks`\n                              WHERE `HARDWARE_ID` = '" . $data["ID"] . "'";
             //Get network informations for this computer
             //Ignore informations that contains "??"
             foreach ($DBocs->request($query_network) as $network) {
                 if (isset($network['IPADDRESS']) && $network['IPADDRESS'] != '??') {
                     $hardware[$data["ID"]]['IPADDRESS'][] = $network['IPADDRESS'];
                 }
                 if (isset($network['IPSUBNET']) && $network['IPSUBNET'] != '??') {
                     $hardware[$data["ID"]]['IPSUBNET'][] = $network['IPSUBNET'];
                 }
                 if (isset($network['MACADDRESS']) && $network['MACADDR'] != '??') {
                     $hardware[$data["ID"]]['MACADDRESS'][] = $network['MACADDR'];
                 }
             }
         }
         // Get all links between glpi and OCS
         $already_linked = array();
         if ($DB->numrows($result_glpi) > 0) {
             while ($data = $DBocs->fetch_array($result_glpi)) {
                 $already_linked[$data["ocsid"]] = $data["last_update"];
             }
         }
         // Clean $hardware from already linked element
         if (count($already_linked) > 0) {
             foreach ($already_linked as $ID => $date) {
                 if (isset($hardware[$ID]) && isset($already_linked[$ID])) {
                     unset($hardware[$ID]);
                 }
             }
         }
         if ($tolinked && count($hardware)) {
             echo "<div class='center'><strong>" . $LANG['ocsng'][22] . "</strong></div>";
         }
         echo "<div class='center'>";
         if (($numrows = count($hardware)) > 0) {
             $parameters = "check={$check}";
             printPager($start, $numrows, $target, $parameters);
             // delete end
             array_splice($hardware, $start + $_SESSION['glpilist_limit']);
             // delete begin
             if ($start > 0) {
                 array_splice($hardware, 0, $start);
             }
             //Show preview form only in import and in multi-entity mode
             if (!$tolinked && isMultiEntitiesMode()) {
                 echo "<div class='firstbloc'>";
                 echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode'\n                      action='{$target}'>\n";
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . $LANG['ocsng'][41] . "</th></tr>\n";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 if ($advanced) {
                     $status = "false";
                 } else {
                     $status = "true";
                 }
                 echo "<a href='" . $target . "?change_import_mode=" . $status . "'>";
                 if ($advanced) {
                     echo $LANG['ocsng'][38];
                 } else {
                     echo $LANG['ocsng'][37];
                 }
                 echo "</a></td></tr>";
                 echo "<tr class='tab_bg_1'><td class='center b'>" . $LANG['ocsconfig'][18] . "<br>";
                 echo "</tr></table></form></div>";
             }
             echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>";
             if (!$tolinked) {
                 echo "<a href='" . $target . "?check=all&amp;start={$start}' onclick= " . "\"if ( markCheckboxes('ocsng_form') ) return false;\">" . $LANG['buttons'][18] . "</a>&nbsp;/&nbsp;<a href='" . $target . "?check=none&amp;start=" . "{$start}' onclick= \"if ( unMarkCheckboxes('ocsng_form') ) return false;\">" . $LANG['buttons'][19] . "</a>\n";
             }
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'><td colspan='" . ($advanced ? 8 : 5) . "' class='center'>";
             echo "<input class='submit' type='submit' name='import_ok' value=\"" . $LANG['buttons'][37] . "\">";
             echo "</td></tr>\n";
             echo "<tr><th>" . $LANG['ocsng'][5] . "</th>\n<th>" . $LANG['common'][19] . "</th>\n";
             echo "<th>" . $LANG['common'][27] . "</th>\n<th>TAG</th>\n";
             if ($advanced && !$tolinked) {
                 echo "<th>" . $LANG['ocsng'][40] . "</th>\n";
                 echo "<th>" . $LANG['ocsng'][36] . "</th>\n";
                 echo "<th>" . $LANG['ocsng'][39] . "</th>\n";
             }
             echo "<th>&nbsp;</th></tr>\n";
             $rule = new RuleOcsCollection($ocsservers_id);
             foreach ($hardware as $ID => $tab) {
                 $comp = new Computer();
                 $comp->fields["id"] = $tab["id"];
                 $data = array();
                 if ($advanced && !$tolinked) {
                     $data = $rule->processAllRules(array(), array(), $tab["id"]);
                 }
                 echo "<tr class='tab_bg_2'><td>" . $tab["name"] . "</td>\n";
                 echo "<td>" . $tab["serial"] . "</td>\n";
                 echo "<td>" . convDateTime($tab["date"]) . "</td>\n";
                 echo "<td>" . $tab["TAG"] . "</td>\n";
                 if ($advanced && !$tolinked) {
                     if (!isset($data['entities_id']) || $data['entities_id'] == -1) {
                         echo "<td class='center'><img src=\"" . GLPI_ROOT . "/pics/redbutton.png\"></td>\n";
                         $data['entities_id'] = -1;
                     } else {
                         echo "<td class='center'>";
                         //echo "<td class='center'><img src=\"".GLPI_ROOT. "/pics/greenbutton.png\">";
                         //echo "&nbsp;";
                         $tmprule = new RuleOcs();
                         if ($tmprule->can($data['_ruleid'], 'r')) {
                             echo "<a href='" . $tmprule->getLinkURL() . "'>" . $tmprule->getName() . "</a>";
                         } else {
                             echo $tmprule->getName();
                         }
                         echo "</td>\n";
                     }
                     echo "<td>";
                     Dropdown::show('Entity', array('name' => "toimport_entities[" . $tab["id"] . "]\n                                                      =" . $data['entities_id'], 'value' => $data['entities_id'], 'comments' => 0));
                     echo "</td>\n";
                     echo "<td>";
                     if (!isset($data['locations_id'])) {
                         $data['locations_id'] = 0;
                     }
                     Dropdown::show('Location', array('name' => "toimport_locations[" . $tab["id"] . "]\n                                                      =" . $data['locations_id'], 'value' => $data['locations_id'], 'comments' => 0));
                     echo "</td>\n";
                 }
                 echo "<td>";
                 if (!$tolinked) {
                     echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . ">";
                 } else {
                     $rulelink = new RuleImportComputerCollection();
                     $rulelink_results = array();
                     $params = array('entities_id' => $entity, 'ocsservers_id' => $ocsservers_id);
                     $rulelink_results = $rulelink->processAllRules($tab, array(), $params);
                     //Look for the computer using automatic link criterias as defined in OCSNG configuration
                     $options = array('name' => "tolink[" . $tab["id"] . "]");
                     $show_dropdown = true;
                     //If the computer is not explicitly refused by a rule
                     if (!isset($rulelink_results['action']) || $rulelink_results['action'] != self::LINK_RESULT_NO_IMPORT) {
                         if (!empty($rulelink_results['found_computers'])) {
                             $options['value'] = $rulelink_results['found_computers'][0];
                             $options['entity'] = $entity;
                         }
                         Dropdown::show('Computer', $options);
                     } else {
                         echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'>";
                     }
                 }
                 echo "</td></tr>\n";
             }
             echo "<tr class='tab_bg_1'><td colspan='" . ($advanced ? 8 : 5) . "' class='center'>";
             echo "<input class='submit' type='submit' name='import_ok' value=\"" . $LANG['buttons'][37] . "\">\n";
             echo "<input type=hidden name='ocsservers_id' value='{$ocsservers_id}'>";
             echo "</td></tr>";
             echo "</table></form>\n";
             if (!$tolinked) {
                 echo "<a href='" . $target . "?check=all&amp;start={$start}' onclick=" . "\"if ( markCheckboxes('ocsng_form') ) return false;\">" . $LANG['buttons'][18] . "</a>&nbsp;/&nbsp;" . "<a href='" . $target . "?check=none&amp;start=" . "{$start}' onclick=\"if (unMarkCheckboxes('ocsng_form')) return false;\">" . $LANG['buttons'][19] . "</a>\n";
             }
             printPager($start, $numrows, $target, $parameters);
         } else {
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . $LANG['ocsng'][2] . "</th></tr>\n";
             echo "<tr class='tab_bg_1'><td class='center b'>" . $LANG['ocsng'][9] . "</td></tr>\n";
             echo "</table>";
         }
         echo "</div>";
     } else {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . $LANG['ocsng'][2] . "</th></tr>\n";
         echo "<tr class='tab_bg_1'><td class='center b'>" . $LANG['ocsng'][9] . "</td></tr>\n";
         echo "</table></div>";
     }
 }