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();
 }
 /**
  * Print the version form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $computers_id = -1;
     if (isset($options['computers_id'])) {
         $computers_id = $options['computers_id'];
     }
     if (!haveRight("computer", "w")) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, 'r');
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $comp->getFromDB($computers_id);
         // Create item
         $input = array('entities_id' => $comp->getEntityID());
         $this->check(-1, 'w', $input);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if ($ID > 0) {
         $computers_id = $this->fields["computers_id"];
     } else {
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['help'][25] . "&nbsp;:</td>";
     echo "<td colspan='3'>" . $comp->getLink() . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td><td>" . $LANG['computers'][62] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('VirtualMachineType', array('value' => $this->fields['virtualmachinetypes_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][60] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('VirtualMachineSystem', array('value' => $this->fields['virtualmachinesystems_id']));
     echo "</td><td>" . $LANG['computers'][63] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('VirtualMachineState', array('value' => $this->fields['virtualmachinestates_id']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][58] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "uuid");
     echo "</td>";
     echo "<td>" . $LANG['computers'][61] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "vcpu");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][24] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "ram");
     echo "</td>";
     echo "<td>" . $LANG['computers'][64] . "&nbsp;:</td>";
     echo "<td>";
     if ($link_computer = self::findVirtualMachine($this->fields)) {
         $computer = new Computer();
         if ($computer->can($link_computer, 'r')) {
             $url = "<a href='computer.form.php?id=" . $link_computer . "'>";
             $url .= $computer->fields["name"] . "</a>";
             $tooltip = $LANG['common'][16] . "&nbsp;: " . $computer->fields['name'];
             $tooltip .= "<br>" . $LANG['common'][19] . "&nbsp;: ";
             $tooltip .= "<br>" . $computer->fields['serial'];
             $tooltip .= "<br>" . $computer->fields['comment'];
             $url .= "&nbsp; " . showToolTip($tooltip, array('display' => false));
         } else {
             $url = $this->fields['name'];
         }
         echo $url;
     }
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Exemplo n.º 3
0
 /**
  * @param $ocsid
  * @param $ocsservers_id
  * @param $action
  * @param $threadid
  * @param $threads_id
  **/
 function logProcessedComputer($ocsid, $ocsservers_id, $action, $threadid, $threads_id)
 {
     $input["ocsid"] = $ocsid;
     if (isset($action["rule_matched"])) {
         $input["rules_id"] = json_encode($action['rule_matched']);
     } else {
         $input["rules_id"] = "";
     }
     $input["threadid"] = $threadid;
     $input["plugin_ocsinventoryng_threads_id"] = $threads_id;
     $input["plugin_ocsinventoryng_ocsservers_id"] = $ocsservers_id;
     $input["action"] = $action['status'];
     if (isset($action["entities_id"])) {
         $input["entities_id"] = $action['entities_id'];
     } else {
         $input['entities_id'] = 0;
     }
     if (isset($action['computers_id'])) {
         $comp = new Computer();
         if ($comp->getFromDB($action['computers_id'])) {
             $input['computers_id'] = $comp->getID();
             $input['entities_id'] = $comp->getEntityID();
         }
     }
     $input["process_time"] = date("Y-m-d H:i:s");
     $this->add($input);
 }
 /**
  * Print the version form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - computers_id ID of the computer for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $computers_id = -1;
     if (isset($options['computers_id'])) {
         $computers_id = $options['computers_id'];
     }
     if (!haveRight("computer", "w")) {
         return false;
     }
     $comp = new Computer();
     if ($ID > 0) {
         $this->check($ID, 'r');
         $comp->getFromDB($this->fields['computers_id']);
     } else {
         $comp->getFromDB($computers_id);
         // Create item
         $input = array('entities_id' => $comp->getEntityID());
         $this->check(-1, 'w', $input);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if ($ID > 0) {
         $computers_id = $this->fields["computers_id"];
     } else {
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['help'][25] . "&nbsp;:</td>";
     echo "<td colspan='3'>" . $comp->getLink() . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td><td>" . $LANG['computers'][6] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "device");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][5] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "mountpoint");
     echo "</td><td>" . $LANG['computers'][4] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('FileSystem', array('value' => $this->fields["filesystems_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][3] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "totalsize");
     echo "&nbsp;" . $LANG['common'][82] . "</td>";
     echo "<td>" . $LANG['computers'][2] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "freesize");
     echo "&nbsp;" . $LANG['common'][82] . "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }