Ejemplo n.º 1
0
 public function removeInfoComRelatedToOrder($itemtype, $items_id)
 {
     $infocom = new InfoCom();
     $infocom->getFromDBforDevice($itemtype, $items_id);
     $input["id"] = $infocom->fields["id"];
     $input["order_number"] = "";
     $input["delivery_number"] = "";
     $input["budgets_id"] = 0;
     $input["suppliers_id"] = 0;
     $input["bill"] = "";
     $input["value"] = 0;
     $input["order_date"] = NULL;
     $input["delivery_date"] = NULL;
     $infocom->update($input);
 }
 /**
  * Return Infocom for an object
  *
  * @param $protocol           the commonication protocol used
  * @param $params    array
  *
  * @return a hasdtable, fields of glpi_infocoms
  **/
 static function methodgetItemInfocoms($params, $protocol)
 {
     if (isset($params['help'])) {
         $params = array('itemtype' => 'string, mandatory', 'id' => 'integer, mandatory', 'id2name' => 'bool,optional', 'help' => 'bool,optional');
     }
     $check = self::checkStandardParameters($params, $protocol);
     if (!$check == 1) {
         exit;
     }
     if (!Session::haveRight("infocom", READ)) {
         return array();
     }
     $infocom = new InfoCom();
     $item = new $params['itemtype']();
     $item->getTypeName();
     if (!$infocom->getFromDBforDevice($params['itemtype'], $params['id']) || !$item->can($params['id'], READ)) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
     }
     $resp = $infocom->fields;
     $resp['warranty_expiration'] = Infocom::getWarrantyExpir($infocom->fields['buy_date'], $infocom->fields['warranty_duration']);
     if ($id2name) {
         // TODO : more dropdown value
         $resp['suppliers_name'] = Html::clean(Dropdown::getDropdownName('glpi_suppliers', $infocom->fields['suppliers_id']));
         $resp['budgets_names'] = Html::ml_clean(Dropdown::getDropdownName('glpi_budgets', $infocom->fields['budgets_id']));
     }
     return $resp;
 }
Ejemplo n.º 3
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $type = $item->getType();
     $info = new InfoCom();
     $comp = new Computer();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('Direct connections') . '</b>');
     $query = "SELECT *\n                FROM `glpi_computers_items`\n                WHERE `items_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, "computers_id");
                 $connID = $DB->result($result, $j, "id");
                 $comp->getFromDB($tID);
                 $info->getFromDBforDevice('Computer', $tID) || $info->getEmpty();
                 $line1 = $comp->fields['name'] ? $comp->fields['name'] : "(" . $comp->fields['id'] . ")";
                 if ($comp->fields['serial']) {
                     $line1 = sprintf(__('%1$s - %2$s'), $line1, sprintf(__('%1$s: %2$s'), __('Serial number'), $comp->fields['serial']));
                 }
                 $line1 = sprintf(__('%1$s - %2$s'), $line1, Html::clean(Dropdown::getDropdownName("glpi_states", $comp->fields['states_id'])));
                 $line2 = "";
                 if ($comp->fields['otherserial']) {
                     $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'), __('Computer') . '/b>', $line1 . "\n" . $line2), 2);
                 } else {
                     $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Computer') . '/b>', $line1), 1);
                 }
             }
             // each device   of current type
         } else {
             // No row
             $pdf->displayLine(__('Not connected.'));
         }
         // No row
     }
     // Result
     $pdf->displaySpace();
 }