當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Computer::getField方法代碼示例

本文整理匯總了PHP中Computer::getField方法的典型用法代碼示例。如果您正苦於以下問題:PHP Computer::getField方法的具體用法?PHP Computer::getField怎麽用?PHP Computer::getField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Computer的用法示例。


在下文中一共展示了Computer::getField方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: pdfDevice

 static function pdfDevice(PluginPdfSimplePDF $pdf, Computer $computer)
 {
     global $DB;
     $devtypes = Item_Devices::getDeviceTypes();
     $ID = $computer->getField('id');
     if (!$computer->can($ID, 'r')) {
         return false;
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . Toolbox::ucfirst(_n('Component', 'Components', 2)) . '</b>');
     $pdf->setColumnsSize(3, 14, 42, 41);
     foreach ($devtypes as $itemtype) {
         $devicetypes = new $itemtype();
         $specificities = $devicetypes->getSpecificities();
         $specif_fields = array_keys($specificities);
         $specif_text = implode(',', $specif_fields);
         if (!empty($specif_text)) {
             $specif_text = " ," . $specif_text . " ";
         }
         $associated_type = str_replace('Item_', '', $itemtype);
         $linktable = getTableForItemType($itemtype);
         $fk = getForeignKeyFieldForTable(getTableForItemType($associated_type));
         $query = "SELECT count(*) AS NB, `id`, `" . $fk . "`" . $specif_text . "\n                   FROM `" . $linktable . "`\n                   WHERE `items_id` = '" . $ID . "'\n                   AND `itemtype` = 'Computer'\n                   GROUP BY `" . $fk . "`" . $specif_text;
         $device = new $associated_type();
         foreach ($DB->request($query) as $data) {
             if ($device->getFromDB($data[$fk])) {
                 $spec = $device->getAdditionalFields();
                 $col4 = '';
                 if (count($spec)) {
                     $colspan = 60 / count($spec);
                     foreach ($spec as $i => $label) {
                         if (isset($device->fields[$label["name"]]) && !empty($device->fields[$label["name"]])) {
                             if ($label["type"] == "dropdownValue" && $device->fields[$label["name"]] != 0) {
                                 $table = getTableNameForForeignKeyField($label["name"]);
                                 $value = Dropdown::getDropdownName($table, $device->fields[$label["name"]]);
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', Html::clean($value) . " ");
                             } else {
                                 $value = $device->fields[$label["name"]];
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $value . " ");
                             }
                         } else {
                             if (isset($device->fields[$label["name"] . "_default"]) && !empty($device->fields[$label["name"] . "_default"])) {
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $device->fields[$label["name"] . "_default"] . " ");
                             }
                         }
                     }
                 }
                 $pdf->displayLine($data['NB'], $device->getTypeName(), $device->getName(), $col4);
             }
         }
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:53,代碼來源:computer.class.php

示例2: pdfForComputer

 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
 {
     global $DB;
     $ID = $item->getField('id');
     // From ComputerVirtualMachine::showForComputer()
     $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}'");
     $pdf->setColumnsSize(100);
     if (count($virtualmachines)) {
         $pdf->displayTitle("<b>" . __('List of virtual machines') . "</b>");
         $pdf->setColumnsSize(20, 8, 8, 8, 25, 8, 8, 15);
         $pdf->setColumnsAlign('left', 'center', 'center', 'center', 'left', 'right', 'right', 'left');
         $typ = explode(' ', __('Virtualization system'));
         $sys = explode(' ', __('Virtualization model'));
         $sta = explode(' ', __('State of the virtual machine'));
         $pdf->displayTitle(__('Name'), $typ[0], $sys[0], $sta[0], __('UUID'), __('CPU'), __('Mio'), __('Machine'));
         foreach ($virtualmachines as $virtualmachine) {
             $name = '';
             if ($link_computer = ComputerVirtualMachine::findVirtualMachine($virtualmachine)) {
                 $computer = new Computer();
                 if ($computer->getFromDB($link_computer)) {
                     $name = $computer->getName();
                 }
             }
             $pdf->displayLine($virtualmachine['name'], Html::clean(Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id'])), Html::clean(Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id'])), Html::clean(Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id'])), $virtualmachine['uuid'], $virtualmachine['vcpu'], Html::clean(Html::formatNumber($virtualmachine['ram'], false, 0)), $name);
         }
     } else {
         $pdf->displayTitle("<b>" . __('No virtual machine associated with the computer') . "</b>");
     }
     // From ComputerVirtualMachine::showForVirtualMachine()
     if ($item->fields['uuid']) {
         $where = "`uuid`" . ComputerVirtualMachine::getUUIDRestrictRequest($item->fields['uuid']);
         $hosts = getAllDatasFromTable('glpi_computervirtualmachines', $where);
         if (count($hosts)) {
             $pdf->setColumnsSize(100);
             $pdf->displayTitle("<b>" . __('List of host machines') . "</b>");
             $pdf->setColumnsSize(26, 37, 37);
             $pdf->displayTitle(__('Name'), __('Operating system'), __('Entity'));
             $computer = new Computer();
             foreach ($hosts as $host) {
                 if ($computer->getFromDB($host['computers_id'])) {
                     $pdf->displayLine($computer->getName(), Html::clean(Dropdown::getDropdownName('glpi_operatingsystems', $computer->getField('operatingsystems_id'))), Html::clean(Dropdown::getDropdownName('glpi_entities', $computer->getEntityID())));
                 }
             }
         }
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:47,代碼來源:computervirtualmachine.class.php

示例3: pdfForComputer

 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $query = "SELECT `glpi_filesystems`.`name` AS fsname, `glpi_computerdisks`.*\n                FROM `glpi_computerdisks`\n                LEFT JOIN `glpi_filesystems`\n                  ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n                WHERE (`computers_id` = '" . $ID . "')";
     $result = $DB->query($query);
     $pdf->setColumnsSize(100);
     if ($DB->numrows($result) > 0) {
         $pdf->displayTitle("<b>" . _n('Volume', 'Volumes', 2) . "</b>");
         $pdf->setColumnsSize(22, 23, 22, 11, 11, 11);
         $pdf->displayTitle('<b>' . __('Name'), __('Partition'), _('Mount point'), __('Type'), __('Global size'), __('Free size') . '</b>');
         $pdf->setColumnsAlign('left', 'left', 'left', 'center', 'right', 'right');
         while ($data = $DB->fetch_assoc($result)) {
             $pdf->displayLine('<b>' . Toolbox::decodeFromUtf8(empty($data['name']) ? $data['ID'] : $data['name'], "windows-1252") . '</b>', $data['device'], $data['mountpoint'], Html::clean(Dropdown::getDropdownName('glpi_filesystems', $data["filesystems_id"])), sprintf(__('%s Mio'), Html::clean(Html::formatNumber($data['totalsize'], false, 0))), sprintf(__('%s Mio'), Html::clean(Html::formatNumber($data['freesize'], false, 0))));
         }
     } else {
         $pdf->displayTitle("<b>" . __('No volume found', 'pdf') . "</b>");
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:20,代碼來源:computerdisk.class.php

示例4: pdfForComputer

 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
 {
     global $DB;
     $ID = $comp->getField('id');
     // From Computer_SoftwareVersion::showForComputer();
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version\n                FROM `glpi_computers_softwareversions`\n                LEFT JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$ID}'\n                ORDER BY `softwarecategories_id`, `softname`, `version`";
     $output = array();
     $software_category = new SoftwareCategory();
     $software_version = new SoftwareVersion();
     foreach ($DB->request($query) as $softwareversion) {
         $output[] = $softwareversion;
     }
     $installed = array();
     if (count($output)) {
         $pdf->setColumnsSize(100);
         $pdf->displayTitle('<b>' . _n('Installed software', 'Installed software', 2, 'pdf') . '</b>');
         $cat = -1;
         foreach ($output as $soft) {
             if ($soft["softwarecategories_id"] != $cat) {
                 $cat = $soft["softwarecategories_id"];
                 if ($cat && $software_category->getFromDB($cat)) {
                     $catname = $software_category->getName();
                 } else {
                     $catname = __('Uncategorized software');
                 }
                 $pdf->setColumnsSize(100);
                 $pdf->displayTitle('<b>' . $catname . '</b>');
                 $pdf->setColumnsSize(50, 13, 13, 24);
                 $pdf->displayTitle('<b>' . __('Name'), __('Status'), __('Version'), __('License') . '</b>');
             }
             // From Computer_SoftwareVersion::displaySoftsByCategory()
             $verid = $soft['verid'];
             $query = "SELECT `glpi_softwarelicenses`.*,\n                             `glpi_softwarelicensetypes`.`name` AS type\n                      FROM `glpi_computers_softwarelicenses`\n                      INNER JOIN `glpi_softwarelicenses`\n                           ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                                    = `glpi_softwarelicenses`.`id`)\n                      LEFT JOIN `glpi_softwarelicensetypes`\n                           ON (`glpi_softwarelicenses`.`softwarelicensetypes_id`\n                                    =`glpi_softwarelicensetypes`.`id`)\n                      WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}'\n                            AND (`glpi_softwarelicenses`.`softwareversions_id_use` = '{$verid}'\n                                 OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                                     AND `glpi_softwarelicenses`.`softwareversions_id_buy` = '{$verid}'))";
             $lic = '';
             foreach ($DB->request($query) as $licdata) {
                 $installed[] = $licdata['id'];
                 $lic .= (empty($lic) ? '' : ', ') . '<b>' . $licdata['name'] . '</b> ' . $licdata['serial'];
                 if (!empty($licdata['type'])) {
                     $lic = sprintf(__('%1$s (%2$s)'), $lic, $licdata['type']);
                 }
             }
             $pdf->displayLine($soft['softname'], $soft['state'], $soft['version'], $lic);
         }
         // Each version
     } else {
         $pdf->displayTitle('<b>' . __('No installed software', 'pdf') . '</b>');
     }
     // Affected licenses NOT installed
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_states`.`name` AS state\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_computers_softwarelicenses`\n                      ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n                              = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_softwares`\n                      ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                LEFT JOIN `glpi_softwareversions`\n                      ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n                              = `glpi_softwareversions`.`id`\n                           OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                               AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n                                       = `glpi_softwareversions`.`id`))\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}' ";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($req->numrows()) {
         $pdf->setColumnsSize(100);
         $pdf->displayTitle('<b>' . __('Affected licenses of not installed software') . '</b>');
         $pdf->setColumnsSize(50, 13, 13, 24);
         $pdf->displayTitle('<b>' . __('Name'), __('Status'), __('Version'), __('License') . '</b>');
         $lic = '';
         foreach ($req as $data) {
             $lic .= '<b>' . $data['name'] . '</b> ' . $data['serial'];
             if (!empty($data['softwarelicensetypes_id'])) {
                 $lic = sprintf(__('%1$s (%2$s)'), $lic, Html::Clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $data['softwarelicensetypes_id'])));
             }
             $pdf->displayLine($data['softname'], $data['state'], $data['version'], $lic);
         }
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:69,代碼來源:computer_softwareversion.class.php

示例5: showForComputer

 /**
  * Show software installed on a computer
  *
  * @param $comp Computer object
  * @param $withtemplate template case of the view process
  *
  * @return nothing
  **/
 static function showForComputer(Computer $comp, $withtemplate = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     if (!haveRight("software", "r")) {
         return false;
     }
     $computers_id = $comp->getField('id');
     $rand = mt_rand();
     $canedit = haveRight("software", "w");
     $entities_id = $comp->fields["entities_id"];
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version\n                FROM `glpi_computers_softwareversions`\n                LEFT JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$computers_id}'\n                ORDER BY `softwarecategories_id`, `softname`, `version`";
     $result = $DB->query($query);
     $i = 0;
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<tr class='tab_bg_1'><td class='center' colspan='3'>";
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php'>";
         echo $LANG['Menu'][4] . "&nbsp;:&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownSoftwareToInstall("softwareversions_id", $entities_id);
         echo "<input type='submit' name='install' value=\"" . $LANG['buttons'][4] . "\" class='submit'>";
         echo "</form>";
         echo "</td>";
         echo "<td class='cneter' clospan='2'>";
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo $LANG['software'][11] . "&nbsp;:&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownLicenseToInstall("softwarelicenses_id", $entities_id);
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</form>";
         echo "</td></tr>\n";
     }
     echo "<tr><th colspan='5'>";
     if ($DB->numrows($result) == 1) {
         echo $LANG['software'][16];
     } else {
         echo $LANG['software'][17];
     }
     echo "</th></tr>";
     $cat = -1;
     initNavigateListItems('Software', $LANG['help'][25] . " = " . (empty($comp->fields["name"]) ? "(" . $comp->fields["id"] . ")" : $comp->fields["name"]));
     initNavigateListItems('SoftwareLicense', $LANG['help'][25] . " = " . (empty($comp->fields["name"]) ? "(" . $comp->fields["id"] . ")" : $comp->fields["name"]));
     $installed = array();
     if ($DB->numrows($result)) {
         while ($data = $DB->fetch_array($result)) {
             if ($data["softwarecategories_id"] != $cat) {
                 self::displayCategoryFooter($cat, $rand, $canedit);
                 $cat = self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
             }
             $licids = self::displaySoftsByCategory($data, $computers_id, $withtemplate, $canedit);
             addToNavigateListItems('Software', $data["softwares_id"]);
             foreach ($licids as $licid) {
                 addToNavigateListItems('SoftwareLicense', $licid);
                 $installed[] = $licid;
             }
         }
         self::displayCategoryFooter($cat, $rand, $canedit);
     }
     // Affected licenses NOT installed
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_states`.`name` AS state\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_computers_softwarelicenses`\n                      ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n                              = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_softwares`\n                      ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                LEFT JOIN `glpi_softwareversions`\n                      ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n                              = `glpi_softwareversions`.`id`\n                           OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                               AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n                                       = `glpi_softwareversions`.`id`))\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$computers_id}' ";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($req->numrows()) {
         $cat = true;
         foreach ($req as $data) {
             if ($cat) {
                 self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
                 $cat = false;
             }
             self::displaySoftsByLicense($data, $computers_id, $withtemplate, $canedit);
             addToNavigateListItems('SoftwareLicense', $data["id"]);
         }
         self::displayCategoryFooter(NULL, $rand, $canedit);
     }
     echo "</table></div>\n";
 }
開發者ID:ryukansent,項目名稱:Thesis-SideB,代碼行數:86,代碼來源:computer_softwareversion.class.php

示例6: getLastOcsUpdate

 $result = $DBread->query($Sql);
 for ($prev = -1, $i = 0; $data = $DBread->fetch_array($result); $i++) {
     if ($prev != $data["entity"]) {
         $prev = $data["entity"];
         echo "<tr class='tab_bg_4'><td class='center' colspan='{$colspan}'>" . Dropdown::getDropdownName("glpi_entities", $prev) . "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'>";
     if ($canedit) {
         echo "<td><input type='checkbox' name='item[" . $data["AID"] . "]' value='1'></td>";
     }
     echo "<td class='b'>" . $data["AID"] . "</td>";
     if ($comp->getFromDB($data["AID"])) {
         echo "<td>";
         echo $comp->getLink(true);
         echo "</td><td>";
         echo Dropdown::getDropdownName("glpi_manufacturers", $comp->getField('manufacturers_id'));
         echo "</td><td>";
         echo Dropdown::getDropdownName("glpi_computermodels", $comp->getField('computermodels_id'));
         echo "</td><td>" . $comp->getField('serial');
         echo "</td><td>" . $comp->getField('otherserial') . "</td>";
     } else {
         echo "<td colspan='5'>" . $data["Aname"] . "</td>";
     }
     if ($col) {
         echo "<td>" . $data["Aaddr"] . "</td>";
     }
     echo "<td>" . getLastOcsUpdate($data['AID']) . "</td>";
     if ($canedit) {
         echo "<td><input type='checkbox' name='item[" . $data["BID"] . "]' value='1'></td>";
     }
     echo "<td class='b blue'>" . $data["BID"] . "</td>";
開發者ID:geldarr,項目名稱:hack-space,代碼行數:31,代碼來源:doublons.php

示例7: purgeComputer

 /**
  * if Computer deleted
  *
  * @param $comp   Computer object
  **/
 static function purgeComputer(Computer $comp)
 {
     $link = new self();
     $link->deleteByCriteria(array('computers_id' => $comp->getField("id")));
     $reg = new PluginOcsinventoryngRegistryKey();
     $reg->deleteByCriteria(array('computers_id' => $comp->getField("id")));
 }
開發者ID:JULIO8,項目名稱:respaldo_glpi,代碼行數:12,代碼來源:ocslink.class.php

示例8: update0782to080


//.........這裏部分代碼省略.........
    }
    if (!isIndex("glpi_computers_softwareversions", "unicity")) {
        // clean datas
        $query = "SELECT `computers_id`,\n                       `softwareversions_id`,\n                       COUNT(*) AS CPT\n               FROM `glpi_computers_softwareversions`\n               GROUP BY `computers_id`, `softwareversions_id`\n               HAVING CPT > 1";
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result)) {
                while ($data = $DB->fetch_assoc($result)) {
                    $query2 = "SELECT `id`\n                          FROM `glpi_computers_softwareversions`\n                          WHERE `computers_id` = '" . $data['computers_id'] . "'\n                                AND `softwareversions_id` = '" . $data['softwareversions_id'] . "'\n                          LIMIT 1";
                    if ($result2 = $DB->query($query2)) {
                        if ($DB->numrows($result2)) {
                            $keep_id = $DB->result($result2, 0, 0);
                            $query3 = "DELETE\n                                FROM `glpi_computers_softwareversions`\n                                WHERE `computers_id` = '" . $data['computers_id'] . "'\n                                      AND `softwareversions_id` = '" . $data['softwareversions_id'] . "'\n                                      AND `id` <> {$keep_id}";
                            $DB->queryOrDie($query3, "0.80 clean glpi_computers_softwareversions");
                        }
                    }
                }
            }
        }
        $migration->addKey("glpi_computers_softwareversions", array('computers_id', 'softwareversions_id'), 'unicity', "UNIQUE");
    }
    $migration->dropKey("glpi_computers_softwareversions", "computers_id");
    // For real count : copy template and deleted information
    $migration->addField("glpi_computers_softwareversions", "is_deleted", "tinyint(1) NOT NULL DEFAULT 0");
    // Gain de temps pour les beta-testeurs
    if ($migration->addField("glpi_computers_softwareversions", "is_template", "tinyint(1) NOT NULL DEFAULT 0")) {
        $migration->migrationOneTable('glpi_computers_softwareversions');
        // Update datas
        $query = "SELECT DISTINCT `computers_id`\n                FROM `glpi_computers_softwareversions`";
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result)) {
                while ($data = $DB->fetch_assoc($result)) {
                    $comp = new Computer();
                    if ($comp->getFromDB($data['computers_id'])) {
                        $query = "UPDATE `glpi_computers_softwareversions`\n                            SET `is_template` = '" . $comp->getField('is_template') . "',\n                                `is_deleted` = '" . $comp->getField('is_deleted') . "'\n                            WHERE `computers_id` = '" . $data['computers_id'] . "';";
                        $DB->query($query);
                    }
                }
            }
        }
    }
    if (!TableExists("glpi_computers_softwarelicenses")) {
        $query = "CREATE TABLE `glpi_computers_softwarelicenses` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `computers_id` int(11) NOT NULL default '0',\n                  `softwarelicenses_id` int(11) NOT NULL default '0',\n                  PRIMARY KEY  (`id`),\n                  KEY `computers_id` (`computers_id`),\n                  KEY `softwarelicenses_id` (`softwarelicenses_id`),\n                  UNIQUE `unicity` ( `computers_id` , `softwarelicenses_id` )\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_computers_softwarelicenses");
    }
    if (FieldExists("glpi_softwarelicenses", "computers_id", false)) {
        $query = "SELECT *\n                FROM `glpi_softwarelicenses`\n                WHERE `computers_id` > 0\n                      AND `computers_id` IS NOT NULL";
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result)) {
                while ($data = $DB->fetch_assoc($result)) {
                    $query = "INSERT INTO `glpi_computers_softwarelicenses`\n                                (`computers_id`, `softwarelicenses_id`)\n                         VALUES ('" . $data['computers_id'] . "','" . $data['id'] . "')";
                    $DB->queryOrDie($query, "0.80 migrate data to computers_softwarelicenses table");
                }
            }
        }
        $migration->dropField("glpi_softwarelicenses", "computers_id");
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'Common'));
    // Updating schema
    $migration->addField("glpi_softwarelicenses", "date_mod", "DATETIME NULL");
    $migration->addKey("glpi_softwarelicenses", "date_mod");
    $migration->renameTable("glpi_cartridges_printermodels", "glpi_cartridgeitems_printermodels");
    $migration->addField("glpi_monitors", "have_hdmi", "tinyint(1) NOT NULL DEFAULT 0 AFTER `have_pivot`");
    $migration->addField("glpi_monitors", "have_displayport", "tinyint(1) NOT NULL DEFAULT 0 AFTER `have_hdmi`");
    $migration->dropField("glpi_configs", "dbreplicate_email");
    $migration->addField("glpi_configs", "auto_create_infocoms", "tinyint(1) NOT NULL DEFAULT 0");
    $migration->addField("glpi_configs", "csv_delimiter", "CHAR( 1 ) NOT NULL AFTER `number_format`", array('update' => "';'"));
開發者ID:paisdelconocimiento,項目名稱:glpi-smartcities,代碼行數:67,代碼來源:update_0782_080.php

示例9: showForComputer

 /**
  * Show software installed on a computer
  *
  * @param $comp            Computer object
  * @param $withtemplate    template case of the view process (default '')
  *
  * @return nothing
  **/
 static function showForComputer(Computer $comp, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     if (!Software::canView()) {
         return false;
     }
     $computers_id = $comp->getField('id');
     $rand = mt_rand();
     $canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE));
     $entities_id = $comp->fields["entities_id"];
     $crit = Session::getSavedOption(__CLASS__, 'criterion', -1);
     $where = '';
     if ($crit > -1) {
         $where = " AND `glpi_softwares`.`softwarecategories_id` = {$crit}";
     }
     $add_dynamic = '';
     if (Plugin::haveImport()) {
         $add_dynamic = "`glpi_computers_softwareversions`.`is_dynamic`,";
     }
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       {$add_dynamic}\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_softwares`.`is_valid` AS softvalid\n                FROM `glpi_computers_softwareversions`\n                LEFT JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$computers_id}'\n                      AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n                      {$where}\n                ORDER BY `softname`, `version`";
     $result = $DB->query($query);
     $i = 0;
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php'>";
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><td class='center'>";
         echo _n('Software', 'Software', Session::getPluralNumber()) . "&nbsp;&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownSoftwareToInstall("softwareversions_id", $entities_id);
         echo "</td><td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Install') . "\"\n                class='submit'>";
         echo "</td>";
         echo "</tr>\n";
         echo "</table></div>\n";
         Html::closeForm();
     }
     echo "<div class='spaced'>";
     $cat = -1;
     Session::initNavigateListItems('Software', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
     Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
     // Mini Search engine
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th colspan='2'>" . Software::getTypeName(Session::getPluralNumber()) . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo __('Category') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $crit, 'toadd' => array('-1' => __('All categories')), 'emptylabel' => __('Uncategorized software'), 'on_change' => 'reloadTab("start=0&criterion="+this.value)'));
     echo "</td></tr></table></div>";
     $number = $DB->numrows($result);
     $start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0;
     if ($start >= $number) {
         $start = 0;
     }
     $installed = array();
     if ($number) {
         echo "<div class='spaced'>";
         Html::printAjaxPager('', $start, $number);
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         $header_begin = "<tr>";
         $header_top = '';
         $header_bottom = '';
         $header_end = '';
         if ($canedit) {
             $header_begin .= "<th width='10'>";
             $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_end .= "</th>";
         }
         $header_end .= "<th>" . __('Name') . "</th><th>" . __('Status') . "</th>";
         $header_end .= "<th>" . __('Version') . "</th><th>" . __('License') . "</th>";
         if (Plugin::haveImport()) {
             $header_end .= "<th>" . __('Automatic inventory') . "</th>";
         }
         $header_end .= "<th>" . SoftwareCategory::getTypeName(1) . "</th>";
         $header_end .= "<th>" . __('Valid license') . "</th>";
         $header_end .= "</tr>\n";
         echo $header_begin . $header_top . $header_end;
         for ($row = 0; $data = $DB->fetch_assoc($result); $row++) {
             if ($row >= $start && $row < $start + $_SESSION['glpilist_limit']) {
                 $licids = self::softsByCategory($data, $computers_id, $withtemplate, $canedit, true);
             } else {
                 $licids = self::softsByCategory($data, $computers_id, $withtemplate, $canedit, false);
             }
             Session::addToNavigateListItems('Software', $data["softwares_id"]);
             foreach ($licids as $licid) {
                 Session::addToNavigateListItems('SoftwareLicense', $licid);
                 $installed[] = $licid;
//.........這裏部分代碼省略.........
開發者ID:JULIO8,項目名稱:respaldo_glpi,代碼行數:101,代碼來源:computer_softwareversion.class.php

示例10: purgeComputer

 /**
  * if Computer purged
  *
  * @param $comp   Computer object
  **/
 static function purgeComputer(Computer $comp)
 {
     $snmp = new self();
     $snmp->deleteByCriteria(array('items_id' => $comp->getField("id"), 'itemtype' => $comp->getType()));
     $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink();
     $ipdiscover->deleteByCriteria(array('items_id' => $comp->getField("id"), 'itemtype' => $comp->getType()));
 }
開發者ID:pluginsGLPI,項目名稱:ocsinventoryng,代碼行數:12,代碼來源:snmpocslink.class.php

示例11: getMacAddr

 /**
  * get the Mac Addresses for a computer
  *
  * @param $comp object
  *
  * @return array of Mac Addresses
  **/
 static function getMacAddr(Computer $comp)
 {
     global $DB;
     $query = "SELECT DISTINCT `specificity`\n                FROM `glpi_computers_devicenetworkcards`\n                WHERE `computers_id`='" . $comp->getField('id') . "'";
     $mac = array();
     foreach ($DB->request($query) as $data) {
         $mac[] = $data['specificity'];
     }
     return $mac;
 }
開發者ID:ryukansent,項目名稱:Thesis-SideB,代碼行數:17,代碼來源:computer_device.class.php

示例12: showForItem

 /**
  * Prints a direct connection to a computer
  *
  * @param $item                     CommonDBTM object: the Monitor/Phone/Peripheral/Printer
  * @param $withtemplate    integer  withtemplate param (default '')
  *
  * @return nothing (print out a table)
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     // Prints a direct connection to a computer
     global $DB;
     $comp = new Computer();
     $ID = $item->getField('id');
     if (!$item->can($ID, READ)) {
         return false;
     }
     $canedit = $item->canEdit($ID);
     $rand = mt_rand();
     // Is global connection ?
     $global = $item->getField('is_global');
     $used = array();
     $compids = array();
     $crit = array('FIELDS' => array('id', 'computers_id', 'is_dynamic'), 'itemtype' => $item->getType(), 'items_id' => $ID, 'is_deleted' => 0);
     foreach ($DB->request('glpi_computers_items', $crit) as $data) {
         $compids[$data['id']] = $data['computers_id'];
         $dynamic[$data['id']] = $data['is_dynamic'];
         $used['Computer'][] = $data['computers_id'];
     }
     $number = count($compids);
     if ($canedit && ($global || !$number)) {
         echo "<div class='firstbloc'>";
         echo "<form name='computeritem_form{$rand}' id='computeritem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Connect a computer') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         echo "<input type='hidden' name='items_id' value='{$ID}'>";
         echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
         if ($item->isRecursive()) {
             self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
         } else {
             self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
         }
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Connect') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Disconnect')), 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     if ($number > 0) {
         $header_begin = "<tr>";
         $header_top = '';
         $header_bottom = '';
         $header_end = '';
         if ($canedit) {
             $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_top .= "</th>";
             $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_bottom .= "</th>";
         }
         $header_end .= "<th>" . __('Name') . "</th>";
         if (Plugin::haveImport()) {
             $header_end .= "<th>" . __('Automatic inventory') . "</th>";
         }
         $header_end .= "<th>" . __('Entity') . "</th>";
         $header_end .= "<th>" . __('Serial number') . "</th>";
         $header_end .= "<th>" . __('Inventory number') . "</th>";
         $header_end .= "</tr>";
         echo $header_begin . $header_top . $header_end;
         foreach ($compids as $key => $compid) {
             $comp->getFromDB($compid);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $key);
                 echo "</td>";
             }
             echo "<td " . ($comp->getField('is_deleted') ? "class='tab_bg_2_2'" : "") . ">" . $comp->getLink() . "</td>";
             if (Plugin::haveImport()) {
                 echo "<td>" . Dropdown::getYesNo($dynamic[$key]) . "</td>";
             }
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $comp->getField('entities_id'));
             echo "</td>";
             echo "<td class='center'>" . $comp->getField('serial') . "</td>";
             echo "<td class='center'>" . $comp->getField('otherserial') . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
     } else {
         echo "<tr><td class='tab_bg_1 b'><i>" . __('Not connected') . "</i>";
         echo "</td></tr>";
     }
//.........這裏部分代碼省略.........
開發者ID:stweil,項目名稱:glpi,代碼行數:101,代碼來源:computer_item.class.php

示例13: showForItem

 /**
  * Prints a direct connection to a computer
  *
  * @param $item the Monitor/Phone/Peripheral/Printer
  *
  * @return nothing (print out a table)
  */
 static function showForItem(CommonDBTM $item)
 {
     // Prints a direct connection to a computer
     global $DB, $LANG;
     $comp = new Computer();
     $target = $comp->getFormURL();
     $ID = $item->getField('id');
     if (!$item->can($ID, "r")) {
         return false;
     }
     $canedit = $item->can($ID, "w");
     // Is global connection ?
     $global = $item->getField('is_global');
     $used = array();
     $compids = array();
     $crit = array('FIELDS' => array('id', 'computers_id'), 'itemtype' => $item->getType(), 'items_id' => $ID);
     foreach ($DB->request('glpi_computers_items', $crit) as $data) {
         $compids[$data['id']] = $data['computers_id'];
     }
     echo "<div class='spaced'><table width='50%' class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>";
     if (count($compids) == 0) {
         echo $LANG['connect'][4];
     } else {
         if (count($compids) == 1) {
             echo $LANG['connect'][3] . "&nbsp;:&nbsp;" . count($compids);
         } else {
             echo $LANG['connect'][2] . "&nbsp;:&nbsp;" . count($compids);
         }
     }
     echo "</th></tr>";
     if (count($compids) > 0) {
         foreach ($compids as $key => $compid) {
             $comp->getFromDB($compid);
             echo "<tr><td class='b tab_bg_1" . ($comp->getField('is_deleted') ? "_2" : "") . "'>";
             echo $LANG['help'][25] . "&nbsp;:&nbsp;" . $comp->getLink() . "</td>";
             echo "<td class='tab_bg_2" . ($comp->getField('is_deleted') ? "_2" : "") . " center b'>";
             if ($canedit) {
                 echo "<a href=\"{$target}?disconnect=1&amp;computers_id={$compid}&amp;id={$key}\">" . $LANG['buttons'][10] . "</a>";
             } else {
                 echo "&nbsp;";
             }
             $used[] = $compid;
         }
     } else {
         echo "<tr><td class='tab_bg_1 b'>" . $LANG['help'][25] . "&nbsp;:&nbsp;";
         echo "<i>" . $LANG['connect'][1] . "</i></td>";
         echo "<td class='tab_bg_2' class='center'>";
         if ($canedit) {
             echo "<form method='post' action=\"{$target}\">";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             if ($item->isRecursive()) {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
             } else {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
             }
             echo "<input type='submit' name='connect' value=\"" . $LANG['buttons'][9] . "\"\n                   class='submit'>";
             echo "</form>";
         } else {
             echo "&nbsp;";
         }
     }
     if ($global && count($compids) > 0) {
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_1'>&nbsp;</td>";
         echo "<td class='tab_bg_2' class='center'>";
         if ($canedit) {
             echo "<form method='post' action=\"{$target}\">";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             if ($item->isRecursive()) {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
             } else {
                 self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
             }
             echo "<input type='submit' name='connect' value=\"" . $LANG['buttons'][9] . "\"\n                   class='submit'>";
             echo "</form>";
         } else {
             echo "&nbsp;";
         }
     }
     echo "</td></tr>";
     echo "</table></div>";
 }
開發者ID:ryukansent,項目名稱:Thesis-SideB,代碼行數:92,代碼來源:computer_item.class.php

示例14: pdfForComputer

 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
 {
     global $DB;
     $ID = $comp->getField('id');
     $items = array('Printer' => _n('Printer', 'Printers', 2), 'Monitor' => _n('Monitor', 'Monitors', 2), 'Peripheral' => _n('Device', 'Devices', 2), 'Phone' => _n('Phone', 'Phones', 2));
     $info = new InfoCom();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('Direct connections') . '</b>');
     foreach ($items as $type => $title) {
         if (!($item = getItemForItemtype($type))) {
             continue;
         }
         if (!$item->canView()) {
             continue;
         }
         $query = "SELECT *\n                   FROM `glpi_computers_items`\n                   WHERE `computers_id` = '" . $ID . "'\n                         AND `itemtype` = '" . $type . "'";
         if ($result = $DB->query($query)) {
             $resultnum = $DB->numrows($result);
             if ($resultnum > 0) {
                 for ($j = 0; $j < $resultnum; $j++) {
                     $tID = $DB->result($result, $j, "items_id");
                     $connID = $DB->result($result, $j, "id");
                     $item->getFromDB($tID);
                     $info->getFromDBforDevice($type, $tID) || $info->getEmpty();
                     $line1 = $item->getName();
                     if ($item->getField("serial") != null) {
                         $line1 = sprintf(__('%1$s - %2$s'), $line1, sprintf(__('%1$s: %2$s'), __('Serial number'), $item->getField("serial")));
                     }
                     $line1 = sprintf(__('%1$s - %2$s'), $line1, Html::clean(Dropdown::getDropdownName("glpi_states", $item->getField('states_id'))));
                     $line2 = "";
                     if ($item->getField("otherserial") != null) {
                         $line2 = sprintf(__('%1$s: %2$s'), __('Inventory number'), $item->getField("otherserial"));
                     }
                     if ($info->fields["immo_number"]) {
                         $line2 = sprintf(__('%1$s - %2$s'), $line2, sprintf(__('%1$s: %2$s'), __('Immobilization number'), $info->fields["immo_number"]));
                     }
                     if ($line2) {
                         $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), $item->getTypeName() . '</b>', $line1 . "\n" . $line2), 2);
                     } else {
                         $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), $item->getTypeName() . '</b>', $line1), 1);
                     }
                 }
                 // each device   of current type
             } else {
                 // No row
                 switch ($type) {
                     case 'Printer':
                         $pdf->displayLine(sprintf(__('No printer', 'pdf')));
                         break;
                     case 'Monitor':
                         $pdf->displayLine(sprintf(__('No monitor', 'pdf')));
                         break;
                     case 'Peripheral':
                         $pdf->displayLine(sprintf(__('No peripheral', 'pdf')));
                         break;
                     case 'Phone':
                         $pdf->displayLine(sprintf(__('No phone', 'pdf')));
                         break;
                 }
             }
             // No row
         }
         // Result
     }
     // each type
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:67,代碼來源:computer_item.class.php

示例15: showForComputer

 /**
  * Show software installed on a computer
  *
  * @param $comp            Computer object
  * @param $withtemplate    template case of the view process (default '')
  *
  * @return nothing
  **/
 static function showForComputer(Computer $comp, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight("software", "r")) {
         return false;
     }
     $computers_id = $comp->getField('id');
     $rand = mt_rand();
     $canedit = Session::haveRight("software", "w");
     $entities_id = $comp->fields["entities_id"];
     $add_dynamic = '';
     if (Plugin::haveImport()) {
         $add_dynamic = "`glpi_computers_softwareversions`.`is_dynamic`,";
     }
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       {$add_dynamic}\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version\n                FROM `glpi_computers_softwareversions`\n                LEFT JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$computers_id}'\n                      AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n                ORDER BY `softwarecategories_id`, `softname`, `version`";
     $result = $DB->query($query);
     $i = 0;
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php'>";
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><td class='center'>";
         echo _n('Software', 'Software', 2) . "&nbsp;&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownSoftwareToInstall("softwareversions_id", $entities_id);
         echo "</td><td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Install') . "\"\n                class='submit'>";
         echo "</td>";
         echo "</tr>\n";
         echo "</table></div>\n";
         Html::closeForm();
     }
     echo "<div class='spaced'>";
     $cat = -1;
     Session::initNavigateListItems('Software', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
     Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
     $installed = array();
     if ($number = $DB->numrows($result)) {
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $paramsma = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
             Html::showMassiveActions(__CLASS__, $paramsma);
         }
         echo "<table class='tab_cadre_fixe'>";
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["softwarecategories_id"] != $cat) {
                 self::displayCategoryFooter($cat, $rand, $canedit);
                 $cat = self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
             }
             $licids = self::displaySoftsByCategory($data, $computers_id, $withtemplate, $canedit);
             Session::addToNavigateListItems('Software', $data["softwares_id"]);
             foreach ($licids as $licid) {
                 Session::addToNavigateListItems('SoftwareLicense', $licid);
                 $installed[] = $licid;
             }
         }
         self::displayCategoryFooter($cat, $rand, $canedit);
         echo "</table>";
         if ($canedit) {
             $paramsma['ontop'] = false;
             Html::showMassiveActions(__CLASS__, $paramsma);
             Html::closeForm();
         }
     }
     echo "</div>\n";
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>";
         echo _n('License', 'Licenses', 2) . "&nbsp;&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownLicenseToInstall("softwarelicenses_id", $entities_id);
         echo "</td><td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table></div>\n";
         Html::closeForm();
     }
     echo "<div class='spaced'>";
     // Affected licenses NOT installed
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `glpi_computers_softwarelicenses`.`id` AS linkID,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_states`.`name` AS state\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_computers_softwarelicenses`\n                      ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n                              = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_softwares`\n                      ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                LEFT JOIN `glpi_softwareversions`\n                      ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n                              = `glpi_softwareversions`.`id`\n                           OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                               AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n                                       = `glpi_softwareversions`.`id`))\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$computers_id}'\n                      AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($number = $req->numrows()) {
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('massSoftwareLicense' . $rand);
             $actions = array('install' => _x('button', 'Install'));
             if (SoftwareLicense::canUpdate()) {
//.........這裏部分代碼省略.........
開發者ID:gaforeror,項目名稱:glpi,代碼行數:101,代碼來源:computer_softwareversion.class.php


注:本文中的Computer::getField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。