contract_item.class.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  * @version $Id: contract_item.class.php 21364 2013-07-19 15:38:35Z yllen $
00004  -------------------------------------------------------------------------
00005  GLPI - Gestionnaire Libre de Parc Informatique
00006  Copyright (C) 2003-2013 by the INDEPNET Development Team.
00007 
00008  http://indepnet.net/   http://glpi-project.org
00009  -------------------------------------------------------------------------
00010 
00011  LICENSE
00012 
00013  This file is part of GLPI.
00014 
00015  GLPI is free software; you can redistribute it and/or modify
00016  it under the terms of the GNU General Public License as published by
00017  the Free Software Foundation; either version 2 of the License, or
00018  (at your option) any later version.
00019 
00020  GLPI is distributed in the hope that it will be useful,
00021  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  GNU General Public License for more details.
00024 
00025  You should have received a copy of the GNU General Public License
00026  along with GLPI. If not, see <http://www.gnu.org/licenses/>.
00027  --------------------------------------------------------------------------
00028  */
00029 
00030 /** @file
00031 * @brief
00032 */
00033 
00034 if (!defined('GLPI_ROOT')) {
00035    die("Sorry. You can't access directly to this file");
00036 }
00037 
00038 // Relation between Contracts and Items
00039 class Contract_Item extends CommonDBRelation{
00040 
00041    // From CommonDBRelation
00042    static public $itemtype_1 = 'Contract';
00043    static public $items_id_1 = 'contracts_id';
00044 
00045    static public $itemtype_2 = 'itemtype';
00046    static public $items_id_2 = 'items_id';
00047 
00048 
00049 
00050    /**
00051     * @since version 0.84
00052    **/
00053    function getForbiddenStandardMassiveAction() {
00054 
00055       $forbidden   = parent::getForbiddenStandardMassiveAction();
00056       $forbidden[] = 'update';
00057       return $forbidden;
00058    }
00059 
00060 
00061    /**
00062     * Don't create a Contract_Item on contract that is alreay max used
00063     * Was previously done (until 0.83.*) by Contract_Item::can()
00064     *
00065     * @see CommonDBRelation::canCreateItem()
00066     *
00067     * @since version 0.84
00068    **/
00069    function canCreateItem() {
00070 
00071       // Try to load the contract
00072       $contract = $this->getConnexityItem(static::$itemtype_1, static::$items_id_1);
00073       if ($contract === false) {
00074          return false;
00075       }
00076       if (($contract->fields['max_links_allowed'] > 0)
00077           && (countElementsInTable($this->getTable(),
00078                                    "`contracts_id`='".$this->input['contracts_id']."'")
00079                 >= $contract->fields['max_links_allowed'])) {
00080          return false;
00081       }
00082 
00083       return parent::canCreateItem();
00084    }
00085 
00086 
00087    static function getTypeName($nb=0) {
00088       return _n('Link Contract/Item','Links Contract/Item',$nb);
00089    }
00090 
00091    static function getSpecificValueToDisplay($field, $values, array $options=array()) {
00092 
00093       if (!is_array($values)) {
00094          $values = array($field => $values);
00095       }
00096       switch ($field) {
00097          case 'items_id':
00098             if (isset($values['itemtype'])) {
00099                if (isset($options['comments']) && $options['comments']) {
00100                   $tmp = Dropdown::getDropdownName(getTableForItemtype($values['itemtype']),
00101                                                    $values[$field], 1);
00102                   return sprintf(__('%1$s %2$s'), $tmp['name'],
00103                                  Html::showToolTip($tmp['comment'], array('display' => false)));
00104 
00105                }
00106                return Dropdown::getDropdownName(getTableForItemtype($values['itemtype']),
00107                                                 $values[$field]);
00108             }
00109             break;
00110       }
00111       return parent::getSpecificValueToDisplay($field, $values, $options);
00112    }
00113 
00114 
00115    /**
00116     * @since version 0.84
00117     *
00118     * @param $field
00119     * @param $name               (default '')
00120     * @param $values             (default '')
00121     * @param $options      array
00122    **/
00123    static function getSpecificValueToSelect($field, $name='', $values='', array $options=array()) {
00124 
00125       if (!is_array($values)) {
00126          $values = array($field => $values);
00127       }
00128       $options['display'] = false;
00129       switch ($field) {
00130          case 'items_id' :
00131             if (isset($values['itemtype']) && !empty($values['itemtype'])) {
00132                $options['name']  = $name;
00133                $options['value'] = $values[$field];
00134                return Dropdown::show($values['itemtype'], $options);
00135             }
00136             break;
00137       }
00138       return parent::getSpecificValueToSelect($field, $name, $values, $options);
00139    }
00140 
00141 
00142    function getSearchOptions() {
00143 
00144       $tab                        = array();
00145 
00146       $tab[2]['table']            = $this->getTable();
00147       $tab[2]['field']            = 'id';
00148       $tab[2]['name']             = __('ID');
00149       $tab[2]['massiveaction']    = false;
00150       $tab[2]['datatype']         = 'number';
00151 
00152       $tab[3]['table']            = $this->getTable();
00153       $tab[3]['field']            = 'items_id';
00154       $tab[3]['name']             = __('Associated item ID');
00155       $tab[3]['massiveaction']    = false;
00156       $tab[3]['datatype']         = 'specific';
00157       $tab[3]['additionalfields'] = array('itemtype');
00158 
00159       $tab[4]['table']            = $this->getTable();
00160       $tab[4]['field']            = 'itemtype';
00161       $tab[4]['name']             = __('Type');
00162       $tab[4]['massiveaction']    = false;
00163       $tab[4]['datatype']         = 'itemtypename';
00164       $tab[4]['itemtype_list']    = 'contract_types';
00165 
00166       return $tab;
00167    }
00168 
00169 
00170    /**
00171     * @param $item    CommonDBTM object
00172    **/
00173    static function countForItem(CommonDBTM $item) {
00174 
00175       return countElementsInTable('glpi_contracts_items',
00176                                   "`itemtype` = '".$item->getType()."'
00177                                    AND `items_id` ='".$item->getField('id')."'");
00178    }
00179 
00180 
00181    /**
00182     * @param $item   Contract object
00183    **/
00184    static function countForContract(Contract $item) {
00185 
00186       $restrict = "`glpi_contracts_items`.`contracts_id` = '".$item->getField('id')."'";
00187 
00188       return countElementsInTable(array('glpi_contracts_items'), $restrict);
00189    }
00190 
00191 
00192    /**
00193     * @since version 0.84
00194     *
00195     * @param $contract_id   contract ID
00196     * @param $entities_id   entity ID
00197     *
00198     * @return array of items linked to contracts
00199    **/
00200    static function getItemsForContract($contract_id, $entities_id) {
00201       global $DB;
00202 
00203       $items = array();
00204 
00205       $query = "SELECT DISTINCT `itemtype`
00206                 FROM `glpi_contracts_items`
00207                 WHERE `glpi_contracts_items`.`contracts_id` = '$contract_id'
00208                 ORDER BY `itemtype`";
00209 
00210       $result = $DB->query($query);
00211       $number = $DB->numrows($result);
00212 
00213       $data    = array();
00214       $totalnb = 0;
00215       for ($i=0 ; $i<$number ; $i++) {
00216          $itemtype = $DB->result($result, $i, "itemtype");
00217          if (!($item = getItemForItemtype($itemtype))) {
00218             continue;
00219          }
00220          $itemtable = getTableForItemType($itemtype);
00221          $query     = "SELECT `$itemtable`.*,
00222                               `glpi_contracts_items`.`id` AS IDD,
00223                               `glpi_entities`.`id` AS entity
00224                         FROM `glpi_contracts_items`,
00225                               `$itemtable`";
00226          if ($itemtype != 'Entity') {
00227             $query .= " LEFT JOIN `glpi_entities`
00228                               ON (`$itemtable`.`entities_id`=`glpi_entities`.`id`) ";
00229          }
00230          $query .= " WHERE `$itemtable`.`id` = `glpi_contracts_items`.`items_id`
00231                            AND `glpi_contracts_items`.`itemtype` = '$itemtype'
00232                            AND `glpi_contracts_items`.`contracts_id` = '$contract_id'";
00233 
00234          if ($item->maybeTemplate()) {
00235             $query .= " AND `$itemtable`.`is_template` = '0'";
00236          }
00237          $query .= getEntitiesRestrictRequest(" AND",$itemtable, '', $entities_id,
00238                                                 $item->maybeRecursive())."
00239                      ORDER BY `glpi_entities`.`completename`, `$itemtable`.`name`";
00240 
00241          $result_linked = $DB->query($query);
00242          $nb            = $DB->numrows($result_linked);
00243 
00244          while ($objdata = $DB->fetch_assoc($result_linked)) {
00245             $items[$itemtype][$objdata['id']] = $objdata;
00246          }
00247       }
00248       return $items;
00249    }
00250 
00251 
00252    /**
00253     * @see CommonGLPI::getTabNameForItem()
00254    **/
00255    function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
00256       global $CFG_GLPI;
00257 
00258       // Can exists on template
00259       if (Session::haveRight("contract","r")) {
00260          switch ($item->getType()) {
00261             case 'Contract' :
00262                if ($_SESSION['glpishow_count_on_tabs']) {
00263                   return self::createTabEntry(_n('Item', 'Items', 2), self::countForContract($item));
00264                }
00265                return _n('Item', 'Items', 2);
00266 
00267             default :
00268                if ($_SESSION['glpishow_count_on_tabs']
00269                    && in_array($item->getType(), $CFG_GLPI["contract_types"])) {
00270                   return self::createTabEntry(Contract::getTypeName(2), self::countForItem($item));
00271                }
00272                return _n('Contract', 'Contracts', 2);
00273 
00274          }
00275       }
00276       return '';
00277    }
00278 
00279 
00280    /**
00281     * @param $item         CommonGLPI object
00282     * @param $tabnum       (default 1)
00283     * @param $withtemplate (default 0)
00284    **/
00285    static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
00286       global $CFG_GLPI;
00287 
00288       switch ($item->getType()) {
00289          case 'Contract' :
00290             self::showForContract($item);
00291 
00292          default :
00293             if (in_array($item->getType(), $CFG_GLPI["contract_types"])) {
00294                self::showForItem($item, $withtemplate);
00295             }
00296       }
00297       return true;
00298    }
00299 
00300 
00301    /**
00302     * Duplicate contracts from an item template to its clone
00303     *
00304     * @since version 0.84
00305     *
00306     * @param $itemtype     itemtype of the item
00307     * @param $oldid        ID of the item to clone
00308     * @param $newid        ID of the item cloned
00309     * @param $newitemtype  itemtype of the new item (= $itemtype if empty) (default '')
00310    **/
00311    static function cloneItem($itemtype, $oldid, $newid, $newitemtype='') {
00312       global $DB;
00313 
00314       if (empty($newitemtype)) {
00315          $newitemtype = $itemtype;
00316       }
00317 
00318       $query  = "SELECT `contracts_id`
00319                  FROM `glpi_contracts_items`
00320                  WHERE `items_id` = '$oldid'
00321                         AND `itemtype` = '$itemtype';";
00322 
00323       foreach ($DB->request($query) as $data) {
00324          $contractitem = new self();
00325          $contractitem->add(array('contracts_id' => $data["contracts_id"],
00326                                   'itemtype'     => $newitemtype,
00327                                   'items_id'     => $newid));
00328       }
00329    }
00330 
00331 
00332    /**
00333     * Print an HTML array of contract associated to an object
00334     *
00335     * @since version 0.84
00336     *
00337     * @param $item            CommonDBTM object wanted
00338     * @param $withtemplate    not used (to be deleted) (default '')
00339     *
00340     * @return Nothing (display)
00341    **/
00342    static function showForItem(CommonDBTM $item, $withtemplate='') {
00343       global $DB, $CFG_GLPI;
00344 
00345       $itemtype = $item->getType();
00346       $ID       = $item->fields['id'];
00347 
00348       if (!Session::haveRight("contract","r") || !$item->can($ID,"r")) {
00349          return false;
00350       }
00351 
00352       $canedit = $item->can($ID,"w");
00353       $rand = mt_rand();
00354 
00355       $query = "SELECT `glpi_contracts_items`.*
00356                 FROM `glpi_contracts_items`,
00357                      `glpi_contracts`
00358                 LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)
00359                 WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`
00360                       AND `glpi_contracts_items`.`items_id` = '$ID'
00361                       AND `glpi_contracts_items`.`itemtype` = '$itemtype'".
00362                       getEntitiesRestrictRequest(" AND","glpi_contracts",'','',true)."
00363                 ORDER BY `glpi_contracts`.`name`";
00364 
00365       $result = $DB->query($query);
00366 
00367       $contracts = array();
00368       $used      = array();
00369       if ($number = $DB->numrows($result)) {
00370          while ($data = $DB->fetch_assoc($result)) {
00371             $contracts[$data['id']] = $data;
00372             $used[$data['id']]      = $data['id'];
00373          }
00374       }
00375 
00376       if ($canedit && ($withtemplate != 2)) {
00377          echo "<div class='firstbloc'>";
00378          echo "<form name='contractitem_form$rand' id='contractitem_form$rand' method='post'
00379                 action='".Toolbox::getItemTypeFormURL(__CLASS__)."'>";
00380          echo "<input type='hidden' name='items_id' value='$ID'>";
00381          echo "<input type='hidden' name='itemtype' value='$itemtype'>";
00382 
00383          echo "<table class='tab_cadre_fixe'>";
00384          echo "<tr class='tab_bg_2'><th colspan='2'>".__('Add a contract')."</th></tr>";
00385 
00386          echo "<tr class='tab_bg_1'><td class='right'>";
00387          Contract::dropdown(array('entity' => $item->getEntityID(),
00388                                   'used'   => $used));
00389 
00390          echo "</td><td class='center'>";
00391          echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>";
00392          echo "</td></tr>";
00393          echo "</table>";
00394          Html::closeForm();
00395          echo "</div>";
00396       }
00397 
00398       echo "<div class='spaced'>";
00399       if ($withtemplate != 2) {
00400          if ($canedit && $number) {
00401             Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
00402             $massiveactionparams = array('num_displayed' => $number);
00403             Html::showMassiveActions(__CLASS__, $massiveactionparams);
00404          }
00405       }
00406       echo "<table class='tab_cadre_fixe'>";
00407 
00408       echo "<tr>";
00409       if ($canedit && $number && ($withtemplate != 2)) {
00410          echo "<th width='10'>".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."</th>";
00411       }
00412 
00413       echo "<th>".__('Name')."</th>";
00414       echo "<th>".__('Entity')."</th>";
00415       echo "<th>"._x('phone', 'Number')."</th>";
00416       echo "<th>".__('Contract type')."</th>";
00417       echo "<th>".__('Supplier')."</th>";
00418       echo "<th>".__('Start date')."</th>";
00419       echo "<th>".__('Initial contract period')."</th>";
00420       echo "</tr>";
00421 
00422       if ($number > 0) {
00423          Session::initNavigateListItems(__CLASS__,
00424                               //TRANS : %1$s is the itemtype name,
00425                               //         %2$s is the name of the item (used for headings of a list)
00426                                         sprintf(__('%1$s = %2$s'),
00427                                                 $item->getTypeName(1), $item->getName()));
00428          foreach ($contracts as $data) {
00429             $cID         = $data["contracts_id"];
00430             Session::addToNavigateListItems(__CLASS__,$cID);
00431             $contracts[] = $cID;
00432             $assocID     = $data["id"];
00433             $con         = new Contract();
00434             $con->getFromDB($cID);
00435             echo "<tr class='tab_bg_1".($con->fields["is_deleted"]?"_2":"")."'>";
00436             if ($canedit && ($withtemplate != 2)) {
00437                echo "<td width='10'>";
00438                Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
00439                echo "</td>";
00440             }
00441             echo "<td class='center b'>";
00442             $name = $con->fields["name"];
00443             if ($_SESSION["glpiis_ids_visible"]
00444                 || empty($con->fields["name"])) {
00445                $name = sprintf(__('%1$s (%2$s)'), $name, $con->fields["id"]);
00446             }
00447             echo "<a href='".$CFG_GLPI["root_doc"]."/front/contract.form.php?id=$cID'>".$name;
00448             echo "</a></td>";
00449             echo "<td class='center'>";
00450             echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"])."</td>";
00451             echo "<td class='center'>".$con->fields["num"]."</td>";
00452             echo "<td class='center'>";
00453             echo Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"]).
00454                "</td>";
00455             echo "<td class='center'>".$con->getSuppliersNames()."</td>";
00456             echo "<td class='center'>".Html::convDate($con->fields["begin_date"])."</td>";
00457 
00458             echo "<td class='center'>".sprintf(__('%1$s %2$s'), $con->fields["duration"],
00459                                                _n('month', 'months', $con->fields["duration"]));
00460             if (($con->fields["begin_date"] != '')
00461                 && !empty($con->fields["begin_date"])) {
00462                echo " -> ".Infocom::getWarrantyExpir($con->fields["begin_date"],
00463                                                      $con->fields["duration"], 0, true);
00464             }
00465             echo "</td>";
00466             echo "</tr>";
00467          }
00468       }
00469 
00470       echo "</table>";
00471       if ($canedit && $number && ($withtemplate != 2)) {
00472          $paramsma['ontop'] = false;
00473          Html::showMassiveActions(__CLASS__, $paramsma);
00474          Html::closeForm();
00475       }
00476       echo "</div>";
00477    }
00478 
00479 
00480    /**
00481     * Print the HTML array for Items linked to current contract
00482     *
00483     * @since version 0.84
00484     *
00485     * @param $contract   Contract object
00486     *
00487     * @return Nothing (display)
00488    **/
00489    static function showForContract(Contract $contract) {
00490       global $DB, $CFG_GLPI;
00491 
00492       $instID = $contract->fields['id'];
00493 
00494       if (!$contract->can($instID,'r')) {
00495          return false;
00496       }
00497       $canedit = $contract->can($instID,'w');
00498       $rand    = mt_rand();
00499 
00500       $query = "SELECT DISTINCT `itemtype`
00501                 FROM `glpi_contracts_items`
00502                 WHERE `glpi_contracts_items`.`contracts_id` = '$instID'
00503                 ORDER BY `itemtype`";
00504 
00505       $result = $DB->query($query);
00506       $number = $DB->numrows($result);
00507 
00508       $data = array();
00509       $totalnb = 0;
00510       for ($i=0 ; $i<$number ; $i++) {
00511          $itemtype = $DB->result($result, $i, "itemtype");
00512          if (!($item = getItemForItemtype($itemtype))) {
00513             continue;
00514          }
00515          if ($item->canView()) {
00516             $itemtable = getTableForItemType($itemtype);
00517             $query     = "SELECT `$itemtable`.*,
00518                                  `glpi_contracts_items`.`id` AS IDD,
00519                                  `glpi_entities`.`id` AS entity
00520                           FROM `glpi_contracts_items`,
00521                                `$itemtable`";
00522             if ($itemtype != 'Entity') {
00523                $query .= " LEFT JOIN `glpi_entities`
00524                                  ON (`$itemtable`.`entities_id`=`glpi_entities`.`id`) ";
00525             }
00526             $query .= " WHERE `$itemtable`.`id` = `glpi_contracts_items`.`items_id`
00527                               AND `glpi_contracts_items`.`itemtype` = '$itemtype'
00528                               AND `glpi_contracts_items`.`contracts_id` = '$instID'";
00529 
00530             if ($item->maybeTemplate()) {
00531                $query .= " AND `$itemtable`.`is_template` = '0'";
00532             }
00533             $query .= getEntitiesRestrictRequest(" AND",$itemtable, '', '',
00534                                                  $item->maybeRecursive())."
00535                       ORDER BY `glpi_entities`.`completename`, `$itemtable`.`name`";
00536 
00537             $result_linked = $DB->query($query);
00538             $nb            = $DB->numrows($result_linked);
00539 
00540             if ($nb > $_SESSION['glpilist_limit']) {
00541                $link = "<a href='". Toolbox::getItemTypeSearchURL($itemtype) . "?" .
00542                          rawurlencode("contains[0]") . "=" . rawurlencode('$$$$'.$instID) . "&amp;" .
00543                          rawurlencode("field[0]") . "=29&amp;sort=80&amp;order=ASC&amp;is_deleted=0".
00544                          "&amp;start=0". "'>" . __('Device list')."</a>";
00545 
00546                $data[$itemtype] = array('longlist' => true,
00547                                         'name'     => sprintf(__('%1$s: %2$s'),
00548                                                               $item->getTypeName($nb), $nb),
00549                                         'link'     => $link);
00550             } else if ($nb > 0) {
00551                for ($prem=true ; $objdata=$DB->fetch_assoc($result_linked) ; $prem=false) {
00552                   $data[$itemtype][$objdata['id']] = $objdata;
00553                }
00554             }
00555             $totalnb += $nb;
00556          }
00557       }
00558 
00559       if ($canedit
00560           && (($contract->fields['max_links_allowed'] == 0)
00561               || ($contract->fields['max_links_allowed'] > $totalnb))) {
00562          echo "<div class='firstbloc'>";
00563          echo "<form name='contract_form$rand' id='contract_form$rand' method='post'
00564                 action='".Toolbox::getItemTypeFormURL(__CLASS__)."'>";
00565 
00566          echo "<table class='tab_cadre_fixe'>";
00567          echo "<tr class='tab_bg_2'><th colspan='2'>".__('Add an item')."</th></tr>";
00568 
00569          echo "<tr class='tab_bg_1'><td class='right'>";
00570          Dropdown::showAllItems("items_id", 0, 0,
00571                                 ($contract->fields['is_recursive']?-1:$contract->fields['entities_id']),
00572                                 $CFG_GLPI["contract_types"], false, true);
00573          echo "</td><td class='center'>";
00574          echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>";
00575          echo "<input type='hidden' name='contracts_id' value='$instID'>";
00576          echo "</td></tr>";
00577          echo "</table>";
00578          Html::closeForm();
00579          echo "</div>";
00580       }
00581 
00582       echo "<div class='spaced'>";
00583       if ($canedit && $totalnb) {
00584          Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
00585          $massiveactionparams = array();
00586          Html::showMassiveActions(__CLASS__, $massiveactionparams);
00587       }
00588       echo "<table class='tab_cadre_fixe'>";
00589        echo "<tr>";
00590 
00591       if ($canedit && $totalnb) {
00592          echo "<th width='10'>".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."</th>";
00593       }
00594       echo "<th>".__('Type')."</th>";
00595       echo "<th>".__('Entity')."</th>";
00596       echo "<th>".__('Name')."</th>";
00597       echo "<th>".__('Serial number')."</th>";
00598       echo "<th>".__('Inventory number')."</th>";
00599       echo "<th>".__('Status')."</th>";
00600       echo "</tr>";
00601 
00602       $totalnb = 0;
00603       foreach ($data as $itemtype => $datas) {
00604 
00605          if (isset($datas['longlist'])) {
00606             echo "<tr class='tab_bg_1'>";
00607             if ($canedit) {
00608                echo "<td>&nbsp;</td>";
00609             }
00610             echo "<td class='center'>".$datas['name']."</td>";
00611             echo "<td class='center' colspan='2'>".$datas['link']."</td>";
00612             echo "<td class='center'>-</td><td class='center'>-</td></tr>";
00613 
00614          } else {
00615             $prem = true;
00616             $nb   = count($datas);
00617             foreach ($datas as $id => $objdata) {
00618                $name = $objdata["name"];
00619                if ($_SESSION["glpiis_ids_visible"]
00620                    || empty($data["name"])) {
00621                   $name = sprintf(__('%1$s (%2$s)'), $name, $objdata["id"]);
00622                }
00623                $link = Toolbox::getItemTypeFormURL($itemtype);
00624                $name = "<a href=\"".$link."?id=".$objdata["id"]."\">".$name."</a>";
00625 
00626                echo "<tr class='tab_bg_1'>";
00627                if ($canedit) {
00628                   echo "<td width='10'>";
00629                   Html::showMassiveActionCheckBox(__CLASS__, $objdata["IDD"]);
00630                   echo "</td>";
00631                }
00632                if ($prem) {
00633                   $item     = new $itemtype();
00634                   $typename = $item->getTypeName($nb);
00635                   echo "<td class='center top' rowspan='$nb'>".
00636                          ($nb  >1 ? sprintf(__('%1$s: %2$s'), $typename, $nb): $typename)."</td>";
00637                   $prem = false;
00638                }
00639                echo "<td class='center'>";
00640                echo Dropdown::getDropdownName("glpi_entities",$objdata['entity'])."</td>";
00641                echo "<td class='center".
00642                       (isset($objdata['is_deleted']) && $objdata['is_deleted'] ? " tab_bg_2_2'" : "'");
00643                echo ">".$name."</td>";
00644                echo"<td class='center'>".
00645                       (isset($objdata["serial"])? "".$objdata["serial"]."" :"-")."</td>";
00646                echo "<td class='center'>".
00647                       (isset($objdata["otherserial"])? "".$objdata["otherserial"]."" :"-")."</td>";
00648                echo "<td class='center'>";
00649                if (isset($objdata["states_id"])) {
00650                   echo Dropdown::getDropdownName("glpi_states", $objdata['states_id']);
00651                } else {
00652                   echo '&nbsp;';
00653                }
00654                echo "</td></tr>";
00655 
00656             }
00657          }
00658       }
00659       echo "<tr class='tab_bg_2'>";
00660       echo "<td class='center' colspan='2'>".
00661             ($totalnb > 0 ? sprintf(__('%1$s = %2$s'), __('Total'), $totalnb) : "&nbsp;");
00662       echo "</td><td colspan='5'>&nbsp;</td></tr> ";
00663 
00664       echo "</table>";
00665       if ($canedit && $number) {
00666          $paramsma['ontop'] = false;
00667          Html::showMassiveActions(__CLASS__, $paramsma);
00668          Html::closeForm();
00669       }
00670       echo "</div>";
00671    }
00672 
00673 }
00674 ?>