showMassiveActionCheckBox() static public méthode

Show the massive action checkbox
static public showMassiveActionCheckBox ( $itemtype, $id, array $options = [] ) : show
$itemtype Massive action itemtype
$id ID of the item
$options array array
Résultat show checkbox
   /**
    * Show certificates associated to an item
    *
    * @since version 0.84
    *
    * @param $item            CommonDBTM object for which associated certificates must be displayed
    * @param $withtemplate    (default '')
   **/
   static function showForItem(CommonDBTM $item, $withtemplate='') {
      global $DB, $CFG_GLPI;

      $ID = $item->getField('id');

      if ($item->isNewID($ID)) {
         return false;
      }
      if (!Session::haveRight("plugin_certificates", READ)) {
         return false;
      }

      if (!$item->can($item->fields['id'], READ)) {
         return false;
      }

      if (empty($withtemplate)) {
         $withtemplate = 0;
      }

      $canedit       =  $item->canadditem('PluginCertificatesCertificate');
      $rand          = mt_rand();
      $is_recursive  = $item->isRecursive();

      $query = "SELECT `glpi_plugin_certificates_certificates_items`.`id` AS assocID,
                       `glpi_entities`.`id` AS entity,
                       `glpi_plugin_certificates_certificates`.`name` AS assocName,
                       `glpi_plugin_certificates_certificates`.*
                FROM `glpi_plugin_certificates_certificates_items`
                LEFT JOIN `glpi_plugin_certificates_certificates`
                 ON (`glpi_plugin_certificates_certificates_items`.`plugin_certificates_certificates_id`=`glpi_plugin_certificates_certificates`.`id`)
                LEFT JOIN `glpi_entities` ON (`glpi_plugin_certificates_certificates`.`entities_id`=`glpi_entities`.`id`)
                WHERE `glpi_plugin_certificates_certificates_items`.`items_id` = '$ID'
                      AND `glpi_plugin_certificates_certificates_items`.`itemtype` = '".$item->getType()."' ";

      $query .= getEntitiesRestrictRequest(" AND","glpi_plugin_certificates_certificates",'','',true);

      $query .= " ORDER BY `assocName`";

      $result = $DB->query($query);
      $number = $DB->numrows($result);
      $i      = 0;

      $certificates      = array();
      $certificate       = new PluginCertificatesCertificate();
      $used      = array();
      if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
            $certificates[$data['assocID']] = $data;
            $used[$data['id']] = $data['id'];
         }
      }

      if ($canedit && $withtemplate < 2) {
         // Restrict entity for knowbase
         $entities = "";
         $entity   = $_SESSION["glpiactive_entity"];

         if ($item->isEntityAssign()) {
            /// Case of personal items : entity = -1 : create on active entity (Reminder case))
            if ($item->getEntityID() >=0 ) {
               $entity = $item->getEntityID();
            }

            if ($item->isRecursive()) {
               $entities = getSonsOf('glpi_entities',$entity);
            } else {
               $entities = $entity;
            }
         }
         $limit = getEntitiesRestrictRequest(" AND ","glpi_plugin_certificates_certificates",'',$entities,true);
         $q = "SELECT COUNT(*)
               FROM `glpi_plugin_certificates_certificates`
               WHERE `is_deleted` = '0'
               $limit";

         $result = $DB->query($q);
         $nb     = $DB->result($result,0,0);

         echo "<div class='firstbloc'>";       
         
         
         if (Session::haveRight("plugin_certificates", READ)
             && ($nb > count($used))) {
            echo "<form name='certificate_form$rand' id='certificate_form$rand' method='post'
                   action='".Toolbox::getItemTypeFormURL('PluginCertificatesCertificate')."'>";
            echo "<table class='tab_cadre_fixe'>";
            echo "<tr class='tab_bg_1'>";
            echo "<td colspan='4' class='center'>";
            echo "<input type='hidden' name='entities_id' value='$entity'>";
            echo "<input type='hidden' name='is_recursive' value='$is_recursive'>";
            echo "<input type='hidden' name='itemtype' value='".$item->getType()."'>";
            echo "<input type='hidden' name='items_id' value='$ID'>";
            if ($item->getType() == 'Ticket') {
               echo "<input type='hidden' name='tickets_id' value='$ID'>";
            }

            PluginCertificatesCertificate::dropdown(array('entity' => $entities ,
                                                            'used'   => $used));
                                     
            echo "</td><td class='center' width='20%'>";
            echo "<input type='submit' name='additem' value=\"".
                     _sx('button', 'Associate a certificate', 'certificates')."\" class='submit'>";
            echo "</td>";
            echo "</tr>";
            echo "</table>";
            Html::closeForm();
         }

         echo "</div>";
      }

      echo "<div class='spaced'>";
      if ($canedit && $number && ($withtemplate < 2)) {
         Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
         $massiveactionparams = array('num_displayed'  => $number);
         Html::showMassiveActions($massiveactionparams);
      }
      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      if ($canedit && $number && ($withtemplate < 2)) {
         echo "<th width='10'>".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."</th>";
      }
      echo "<th>".__('Name')."</th>";
      if (Session::isMultiEntitiesMode()) {
         echo "<th>".__('Entity')."</th>";
      }
      echo "<th>".__('Type')."</th>";
      echo "<th>".__('DNS name', 'certificates')."</th>";
      echo "<th>".__('DNS suffix', 'certificates')."</th>";
      echo "<th>".__('Creation date')."</th>";
      echo "<th>".__('Expiration date')."</th>";
      echo "<th>".__('Status')."</th>";
      echo "</tr>";
      $used = array();

      if ($number) {

         Session::initNavigateListItems('PluginCertificatesCertificate',
                           //TRANS : %1$s is the itemtype name,
                           //        %2$s is the name of the item (used for headings of a list)
                                        sprintf(__('%1$s = %2$s'),
                                                $item->getTypeName(1), $item->getName()));

         
         foreach  ($certificates as $data) {
            $certificateID        = $data["id"];
            $link         = NOT_AVAILABLE;

            if ($certificate->getFromDB($certificateID)) {
               $link         = $certificate->getLink();
            }

            Session::addToNavigateListItems('PluginCertificatesCertificate', $certificateID);
            
            $used[$certificateID] = $certificateID;
            $assocID      = $data["assocID"];

            echo "<tr class='tab_bg_1".($data["is_deleted"]?"_2":"")."'>";
            if ($canedit && ($withtemplate < 2)) {
               echo "<td width='10'>";
               Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
               echo "</td>";
            }
            echo "<td class='center'>$link</td>";
            if (Session::isMultiEntitiesMode()) {
               echo "<td class='center'>".Dropdown::getDropdownName("glpi_entities", $data['entities_id']).
                    "</td>";
            }
            echo "<td class='center'>";
            echo Dropdown::getDropdownName("glpi_plugin_certificates_certificatetypes",
                                          $data["plugin_certificates_certificatetypes_id"]);
            echo "</td>";
            echo "<td class='center'>".$data["dns_name"]."</td>";
            echo "<td class='center'>".$data["dns_suffix"]."</td>";
            echo "<td class='center'>".Html::convdate($data["date_query"])."</td>";
            if ($data["date_expiration"] <= date('Y-m-d') 
                  && !empty($data["date_expiration"])) {
               echo "<td class='center'>";
               echo "<div class='deleted'>".Html::convdate($data["date_expiration"])."</div>";
               echo "</td>";
            } else if (empty($data["date_expiration"])) {
               echo "<td class='center'>".__('Does not expire', 'certificates')."</td>";
            } else {
               echo "<td class='center'>".Html::convdate($data["date_expiration"])."</td>";
            }
            echo "<td class='center'>";
            echo Dropdown::getDropdownName("glpi_plugin_certificates_certificatestates",
                                                $data["plugin_certificates_certificatestates_id"]);
            echo "</td>";
            echo "</tr>";
            $i++;
         }
      }


      echo "</table>";
      if ($canedit && $number && ($withtemplate < 2)) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
      }
      echo "</div>";
   }
 /**
  * Print the HTML array of suppliers for this contract
  *
  * @since version 0.84
  *
  * @param $contract Contract object
  *
  * @return Nothing (HTML display)
  **/
 static function showForContract(Contract $contract)
 {
     global $DB, $CFG_GLPI;
     $instID = $contract->fields['id'];
     if (!$contract->can($instID, 'r') || !Session::haveRight("contact_enterprise", "r")) {
         return false;
     }
     $canedit = $contract->can($instID, 'w');
     $rand = mt_rand();
     $query = "SELECT `glpi_contracts_suppliers`.`id`,\n                       `glpi_suppliers`.`id` AS entID,\n                       `glpi_suppliers`.`name` AS name,\n                       `glpi_suppliers`.`website` AS website,\n                       `glpi_suppliers`.`phonenumber` AS phone,\n                       `glpi_suppliers`.`suppliertypes_id` AS type,\n                       `glpi_entities`.`id` AS entity\n                FROM `glpi_contracts_suppliers`,\n                     `glpi_suppliers`\n                LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_suppliers`.`entities_id`)\n                WHERE `glpi_contracts_suppliers`.`contracts_id` = '{$instID}'\n                      AND `glpi_contracts_suppliers`.`suppliers_id`=`glpi_suppliers`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_suppliers", '', '', true) . "\n                ORDER BY `glpi_entities`.`completename`, `name`";
     $result = $DB->query($query);
     $suppliers = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $suppliers[$data['id']] = $data;
             $used[$data['entID']] = $data['entID'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a supplier') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         Supplier::dropdown(array('used' => $used, 'entity' => $contract->fields["entities_id"], 'entity_sons' => $contract->fields["is_recursive"]));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" 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);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Supplier') . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "<th>" . __('Third party type') . "</th>";
     echo "<th>" . __('Phone') . "</th>";
     echo "<th>" . __('Website') . "</th>";
     echo "</tr>";
     $used = array();
     foreach ($suppliers as $data) {
         $ID = $data['id'];
         $website = $data['website'];
         if (!empty($website)) {
             if (!preg_match("?https*://?", $website)) {
                 $website = "http://" . $website;
             }
             $website = "<a target=_blank href='{$website}'>" . $data['website'] . "</a>";
         }
         $entID = $data['entID'];
         $entity = $data['entity'];
         $used[$entID] = $entID;
         $entname = Dropdown::getDropdownName("glpi_suppliers", $entID);
         echo "<tr class='tab_bg_1'>";
         if ($canedit) {
             echo "<td>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
             echo "</td>";
         }
         echo "<td class='center'>";
         if ($_SESSION["glpiis_ids_visible"] || empty($entname)) {
             $entname = sprintf(__('%1$s (%2$s)'), $entname, $entID);
         }
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id={$entID}'>" . $entname;
         echo "</a></td>";
         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $entity) . "</td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName("glpi_suppliertypes", $data['type']) . "</td>";
         echo "<td class='center'>" . $data['phone'] . "</td>";
         echo "<td class='center'>" . $website . "</td>";
         echo "</tr>";
     }
     echo "</table>";
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Print the HTML array for Items linked to a problem
  *
  * @param $problem Problem object
  *
  * @return Nothing (display)
  **/
 static function showForProblem(Problem $problem)
 {
     global $DB, $CFG_GLPI;
     $instID = $problem->fields['id'];
     if (!$problem->can($instID, READ)) {
         return false;
     }
     $canedit = $problem->canEdit($instID);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_items_problems`\n                WHERE `glpi_items_problems`.`problems_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='problemitem_form{$rand}' id='problemitem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         $types = array();
         foreach ($problem->getAllTypesForHelpdesk() as $key => $val) {
             $types[] = $key;
         }
         Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $types, 'entity_restrict' => $problem->fields['is_recursive'] ? getSonsOf('glpi_entities', $problem->fields['entities_id']) : $problem->fields['entities_id']));
         echo "</td><td class='center' width='30%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "<input type='hidden' name='problems_id' value='{$instID}'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $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>" . __('Type') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Serial number') . "</th>";
     $header_end .= "<th>" . __('Inventory number') . "</th></tr>";
     echo $header_begin . $header_top . $header_end;
     $totalnb = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                             `glpi_items_problems`.`id` AS IDD,\n                             `glpi_entities`.`id` AS entity\n                      FROM `glpi_items_problems`,\n                           `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_items_problems`.`items_id`\n                              AND `glpi_items_problems`.`itemtype` = '{$itemtype}'\n                              AND `glpi_items_problems`.`problems_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                 $name = $data["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
                 }
                 $link = $itemtype::getFormURLWithID($data['id']);
                 $namelink = "<a href=\"" . $link . "\">" . $name . "</a>";
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td width='10'>";
                     Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
                     echo "</td>";
                 }
                 if ($prem) {
                     $typename = $item->getTypeName($nb);
                     echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>";
                 }
                 echo "<td class='center'>";
                 echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                 echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
                 echo ">" . $namelink . "</td>";
                 echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                 echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                 echo "</tr>";
             }
             $totalnb += $nb;
         }
     }
     if ($number) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /** Show LDAP groups to add or synchronise in an entity
  *
  * @param $target    target page for the form
  * @param $start     where to start the list
  * @param $sync      synchronise or add ? (default 0)
  * @param $filter    ldap filter to use (default '')
  * @param $filter2   second ldap filter to use (which case ?) (default '')
  * @param $entity    working entity
  * @param $order     display order (default DESC)
  *
  * @return  nothing
  **/
 static function showLdapGroups($target, $start, $sync = 0, $filter = '', $filter2 = '', $entity, $order = 'DESC')
 {
     echo "<br>";
     $limitexceeded = false;
     $ldap_groups = self::getAllGroups($_SESSION["ldap_server"], $filter, $filter2, $entity, $limitexceeded, $order);
     if (is_array($ldap_groups)) {
         $numrows = count($ldap_groups);
         $rand = mt_rand();
         $colspan = Session::isMultiEntitiesMode() ? 5 : 4;
         if ($numrows > 0) {
             self::displaySizeLimitWarning($limitexceeded);
             $parameters = '';
             Html::printPager($start, $numrows, $target, $parameters);
             // delete end
             array_splice($ldap_groups, $start + $_SESSION['glpilist_limit']);
             // delete begin
             if ($start > 0) {
                 array_splice($ldap_groups, 0, $start);
             }
             echo "<div class='center'>";
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => min($_SESSION['glpilist_limit'], count($ldap_groups)), 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'import_group' => _sx('button', 'Import')), 'extraparams' => array('massive_action_fields' => array('dn', 'ldap_import_type', 'ldap_import_entities', 'ldap_import_recursive')));
             Html::showMassiveActions($massiveactionparams);
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             echo "<th width='10'>";
             Html::showCheckbox(array('criterion' => array('tag_for_massive' => 'select_item')));
             echo "</th>";
             $header_num = 0;
             echo Search::showHeaderItem(Search::HTML_OUTPUT, __('Group'), $header_num, $target . "?order=" . ($order == "DESC" ? "ASC" : "DESC"), 1, $order);
             echo "<th>" . __('Group DN') . "</th>";
             echo "<th>" . __('Destination entity') . "</th>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<th>" . __('Child entities') . "</th>";
             }
             echo "</tr>";
             $dn_index = 0;
             foreach ($ldap_groups as $groupinfos) {
                 $group = $groupinfos["cn"];
                 $group_dn = $groupinfos["dn"];
                 $search_type = $groupinfos["search_type"];
                 echo "<tr class='tab_bg_2 center'>";
                 echo "<td>";
                 echo Html::hidden("dn[{$dn_index}]", array('value' => $group_dn, 'data-glpicore-ma-tags' => 'common'));
                 echo Html::hidden("ldap_import_type[{$dn_index}]", array('value' => $search_type, 'data-glpicore-ma-tags' => 'common'));
                 Html::showMassiveActionCheckBox(__CLASS__, $dn_index, array('massive_tags' => 'select_item'));
                 echo "</td>";
                 echo "<td>" . $group . "</td>";
                 echo "<td>" . $group_dn . "</td>";
                 echo "<td>";
                 Entity::dropdown(array('value' => $entity, 'name' => "ldap_import_entities[{$dn_index}]", 'specific_tags' => array('data-glpicore-ma-tags' => 'common')));
                 echo "</td>";
                 if (Session::isMultiEntitiesMode()) {
                     echo "<td>";
                     Html::showCheckbox(array('name' => "ldap_import_recursive[{$dn_index}]", 'specific_tags' => array('data-glpicore-ma-tags' => 'common')));
                     echo "</td>";
                 } else {
                     echo Html::hidden("ldap_import_recursive[{$dn_index}]", array('value' => 0, 'data-glpicore-ma-tags' => 'common'));
                 }
                 echo "</tr>\n";
                 $dn_index++;
             }
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
             echo "</div>";
             Html::printPager($start, $numrows, $target, $parameters);
         } else {
             echo "<div class='center b'>" . __('No group to be imported') . "</div>";
         }
     } else {
         echo "<div class='center b'>" . __('No group to be imported') . "</div>";
     }
 }
 /**
  * Show segments of a calendar
  *
  * @param $calendar Calendar object
  **/
 static function showForCalendar(Calendar $calendar)
 {
     global $DB, $CFG_GLPI;
     $ID = $calendar->getField('id');
     if (!$calendar->can($ID, READ)) {
         return false;
     }
     $canedit = $calendar->can($ID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT *\n                FROM `glpi_calendarsegments`\n                WHERE `calendars_id` = '{$ID}'\n                ORDER BY `day`, `begin`, `end`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n                action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a schedule') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>" . __('Day') . "</td><td>";
         echo "<input type='hidden' name='calendars_id' value='{$ID}'>";
         Dropdown::showFromArray('day', Toolbox::getDaysOfWeekArray());
         echo "</td><td class='center'>" . __('Start') . '</td><td>';
         Dropdown::showHours("begin", array('value' => date('H') . ":00"));
         echo "</td><td class='center'>" . __('End') . '</td><td>';
         Dropdown::showHours("end", array('value' => date('H') + 1 . ":00"));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Day') . "</th>";
     echo "<th>" . __('Start') . "</th>";
     echo "<th>" . __('End') . "</th>";
     echo "</tr>";
     $daysofweek = Toolbox::getDaysOfWeekArray();
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td>";
             echo $daysofweek[$data['day']];
             echo "</td>";
             echo "<td>" . $data["begin"] . "</td>";
             echo "<td>" . $data["end"] . "</td>";
         }
         echo "</tr>";
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Display list of packages to import
  */
 function listPackagesToImport()
 {
     $rand = mt_rand();
     echo "<div class='spaced'>";
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
     Html::showMassiveActions($massiveactionparams);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='5'>";
     echo __('Packages to import', 'fusioninventory');
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     echo "<th>";
     echo __('Name');
     echo "</th>";
     echo "<th>";
     echo __('uuid');
     echo "</th>";
     echo "<th>";
     echo __('Package to update');
     echo "</th>";
     echo "</tr>";
     foreach (glob(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/import/*.zip") as $file) {
         echo "<tr class='tab_bg_1'>";
         $file = str_replace(GLPI_PLUGIN_DOC_DIR . "/fusioninventory/files/import/", "", $file);
         $split = explode('.', $file);
         echo "<td>";
         Html::showMassiveActionCheckBox(__CLASS__, $file);
         echo "</td>";
         echo "<td>";
         echo $split[2];
         echo "</td>";
         echo "<td>";
         echo $split[0] . "." . $split[1];
         echo "</td>";
         echo "<td>";
         $a_packages = current($this->find("`uuid`='" . $split[0] . "." . $split[1] . "'", '', 1));
         if (count($a_packages) > 1) {
             $this->getFromDB($a_packages['id']);
             echo $this->getLink();
         }
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     $massiveactionparams['ontop'] = false;
     Html::showMassiveActions($massiveactionparams);
     echo "</div>";
 }
Exemple #7
0
 /**
  * Show the User having a profile, in allowed Entity
  *
  * @param $prof Profile object
  **/
 static function showForProfile(Profile $prof)
 {
     global $DB, $CFG_GLPI;
     $ID = $prof->fields['id'];
     $canedit = Session::haveRightsOr("user", array(CREATE, UPDATE, DELETE, PURGE));
     $rand = mt_rand();
     if (!$prof->can($ID, READ)) {
         return false;
     }
     $query = "SELECT `glpi_users`.*,\n                       `glpi_profiles_users`.`entities_id` AS entity,\n                       `glpi_profiles_users`.`id` AS linkID,\n                       `glpi_profiles_users`.`is_dynamic`,\n                       `glpi_profiles_users`.`is_recursive`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_entities`.`id`=`glpi_profiles_users`.`entities_id`)\n                LEFT JOIN `glpi_users`\n                     ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n                WHERE `glpi_profiles_users`.`profiles_id` = '{$ID}'\n                      AND `glpi_users`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_profiles_users", 'entities_id', $_SESSION['glpiactiveentities'], true) . "\n                ORDER BY `glpi_entities`.`completename`";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'><tr>";
     echo "<th>" . sprintf(__('%1$s: %2$s'), __('Profile'), $prof->fields["name"]) . "</th></tr>\n";
     echo "<tr><th colspan='2'>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive')) . "</th></tr>";
     echo "</table>\n";
     echo "<table class='tab_cadre_fixe'>";
     $i = 0;
     $nb_per_line = 3;
     $rand = mt_rand();
     // Just to avoid IDE warning
     $canedit_entity = false;
     if ($nb) {
         $temp = -1;
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["entity"] != $temp) {
                 while ($i % $nb_per_line != 0) {
                     if ($canedit_entity) {
                         echo "<td width='10'>&nbsp;</td>";
                     }
                     echo "<td class='tab_bg_1'>&nbsp;</td>\n";
                     $i++;
                 }
                 if ($i != 0) {
                     echo "</table>";
                     echo "</div>";
                     echo "</td></tr>\n";
                 }
                 // New entity
                 $i = 0;
                 $temp = $data["entity"];
                 $canedit_entity = $canedit && in_array($temp, $_SESSION['glpiactiveentities']);
                 $rand = mt_rand();
                 echo "<tr class='tab_bg_2'>";
                 echo "<td>";
                 echo "<a href=\"javascript:showHideDiv('entity{$temp}{$rand}','imgcat{$temp}', '" . $CFG_GLPI['root_doc'] . "/pics/folder.png','" . $CFG_GLPI['root_doc'] . "/pics/folder-open.png');\">";
                 echo "<img alt='' name='imgcat{$temp}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/folder.png\">&nbsp;";
                 echo "<span class='b'>" . Dropdown::getDropdownName('glpi_entities', $data["entity"]) . "</span>";
                 echo "</a>";
                 echo "</td></tr>\n";
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<div class='center' id='entity{$temp}{$rand}' style='display:none;'>\n";
                 echo Html::checkAllAsCheckbox("entity{$temp}{$rand}") . __('All');
                 echo "<table class='tab_cadre_fixe'>\n";
             }
             if ($i % $nb_per_line == 0) {
                 if ($i != 0) {
                     echo "</tr>\n";
                 }
                 echo "<tr class='tab_bg_1'>\n";
                 $i = 0;
             }
             if ($canedit_entity) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             $username = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
             if ($data["is_dynamic"] || $data["is_recursive"]) {
                 $username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
                 if ($data["is_dynamic"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, __('D'));
                 }
                 if ($data["is_dynamic"] && $data["is_recursive"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, ", ");
                 }
                 if ($data["is_recursive"]) {
                     $username = sprintf(__('%1$s%2$s'), $username, __('R'));
                 }
                 $username = sprintf(__('%1$s%2$s'), $username, ")</span>");
             }
             echo "<td class='tab_bg_1'>" . $username . "</td>\n";
             $i++;
         }
         if ($i % $nb_per_line != 0) {
             while ($i % $nb_per_line != 0) {
                 if ($canedit_entity) {
                     echo "<td width='10'>&nbsp;</td>";
                 }
                 echo "<td class='tab_bg_1'>&nbsp;</td>";
                 $i++;
             }
         }
         if ($i != 0) {
             echo "</table>";
             echo "</div>";
             echo "</td></tr>\n";
         }
     } else {
         echo "<tr class='tab_bg_2'><td class='tab_bg_1 center'>" . __('No user found') . "</td></tr>\n";
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>\n";
 }
 /**
  * Show problems for a change
  *
  * @param $change Change object
  **/
 static function showForChange(Change $change)
 {
     global $DB, $CFG_GLPI;
     $ID = $change->getField('id');
     if (!$change->can($ID, 'r')) {
         return false;
     }
     $canedit = $change->can($ID, 'w');
     $rand = mt_rand();
     $showentities = Session::isMultiEntitiesMode();
     $query = "SELECT DISTINCT `glpi_changes_problems`.`id` AS linkID,\n                                `glpi_problems`.*\n                FROM `glpi_changes_problems`\n                LEFT JOIN `glpi_problems`\n                     ON (`glpi_changes_problems`.`problems_id` = `glpi_problems`.`id`)\n                WHERE `glpi_changes_problems`.`changes_id` = '{$ID}'\n                ORDER BY `glpi_problems`.`name`";
     $result = $DB->query($query);
     $problems = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $problems[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a problem') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td>";
         echo "<input type='hidden' name='changes_id' value='{$ID}'>";
         Problem::dropdown(array('used' => $used, 'entity' => $change->getEntityID()));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr></table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . _n('Problem', 'Problems', 2) . "</th>";
     if ($showentities) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "</tr>";
     $used = array();
     if ($numrows) {
         Session::initNavigateListItems('Problem', sprintf(__('%1$s = %2$s'), Change::getTypeName(1), $change->fields["name"]));
         foreach ($problems as $data) {
             Session::addToNavigateListItems('Problem', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             echo "<td><a href='" . Toolbox::getItemTypeFormURL('Problem') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>";
             if ($showentities) {
                 echo "<td>" . Dropdown::getDropdownName('glpi_entities', $data["entities_id"]) . "</td>";
             }
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 public function showPluginFromItems($itemtype, $ID, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $item = new $itemtype();
     $canread = $item->can($ID, READ);
     $canedit = $item->can($ID, UPDATE);
     $table = $this->getTable();
     $rand = mt_rand();
     $PluginConnectionsConnection = new PluginConnectionsConnection();
     $entitiesRestrict = getEntitiesRestrictRequest(" AND ", "glpi_plugin_connections_connections", '', '', $PluginConnectionsConnection->maybeRecursive());
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='connection_form{$rand}' id='connection_form{$rand}' method='post'\n                action='" . $CFG_GLPI["root_doc"] . "/plugins/connections/front/connection.form.php'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         Dropdown::showSelectItemFromItemtypes(array('itemtypes' => array('PluginConnectionsConnection'), 'entity_restrict' => $item->fields['is_recursive'] ? getSonsOf('glpi_entities', $item->fields['entities_id']) : $item->fields['entities_id'], 'checkright' => true, 'items_id_name' => 'plugin_connections_connections_id'));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "<input type='hidden' name='items_id' value='{$ID}'>";
         echo "<input type='hidden' name='additem' value='true'>";
         echo "<input type='hidden' name='itemtype' value='NetworkEquipment'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     $query = "SELECT  t.`id` AS IDD, `glpi_plugin_connections_connections`.*\n                FROM `{$table}` t, `glpi_plugin_connections_connections`\n                LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_connections_connections`.`entities_id`)\n                WHERE t.`items_id` = '{$ID}'\n                AND t.`itemtype` = '{$itemtype}'\n                AND t.`plugin_connections_connections_id` = `glpi_plugin_connections_connections`.`id`\n                {$entitiesRestrict}\n                ORDER BY `glpi_plugin_connections_connections`.`name` ";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $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>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Type of Connections', 'connections') . "</th>";
     $header_end .= "<th>" . __('Rates', 'connections') . "</th>";
     $header_end .= "<th>" . __('Guaranteed Rates', 'connections') . "</th>";
     if ($number) {
         echo $header_begin . $header_top . $header_end;
     }
     while ($data = $DB->fetch_array($result)) {
         $name = $data["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
             $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
         }
         if ($_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
             $link = PluginConnectionsConnection::getFormURLWithID($data['id']);
             $namelink = "<a href=\"" . $link . "\">" . $name . "</a>";
         } else {
             $namelink = $name;
         }
         echo "<tr class='tab_bg_1'>";
         if ($canedit) {
             echo "<td width='10'>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
             echo "</td>";
         }
         echo "<td class='center'>";
         echo Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
         echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
         echo ">" . $namelink . "</td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName(getTableForItemType('PluginConnectionsConnectionType'), $data['plugin_connections_connectiontypes_id']) . "</td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName(getTableForItemType('PluginConnectionsConnectionRate'), $data['plugin_connections_connectionrates_id']) . "</td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName(getTableForItemType('PluginConnectionsGuaranteedConnectionRate'), $data['plugin_connections_guaranteedconnectionrates_id']) . "</td>";
         echo "</tr>";
     }
     if ($number) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show resource associated to an item
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object for which associated resource must be displayed
  * @param $withtemplate    (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!plugin_resources_haveRight('resources', 'r')) {
         return false;
     }
     if (!$item->can($item->fields['id'], 'r')) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $canedit = $item->canadditem('PluginResourcesResource');
     $rand = mt_rand();
     $is_recursive = $item->isRecursive();
     $query = "SELECT `glpi_plugin_resources_resources_items`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity,\n                       `glpi_plugin_resources_resources`.`name` AS assocName,\n                       `glpi_plugin_resources_resources`.*\n                FROM `glpi_plugin_resources_resources_items`\n                LEFT JOIN `glpi_plugin_resources_resources`\n                 ON (`glpi_plugin_resources_resources_items`.`plugin_resources_resources_id`=`glpi_plugin_resources_resources`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_resources_resources`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_resources_resources_items`.`items_id` = '{$ID}'\n                      AND `glpi_plugin_resources_resources_items`.`itemtype` = '" . $item->getType() . "' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_resources_resources", '', '', true);
     $query .= " ORDER BY `assocName`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $resources = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $resources[$data['assocID']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     $resource = new PluginResourcesResource();
     $more = true;
     if ($item->getType() == "User" && $number != 0) {
         $more = false;
     }
     if ($canedit && $withtemplate < 2 && $more) {
         // Restrict entity for knowbase
         $entities = "";
         $entity = $_SESSION["glpiactive_entity"];
         if ($item->isEntityAssign()) {
             /// Case of personal items : entity = -1 : create on active entity (Reminder case))
             if ($item->getEntityID() >= 0) {
                 $entity = $item->getEntityID();
             }
             if ($item->isRecursive()) {
                 $entities = getSonsOf('glpi_entities', $entity);
             } else {
                 $entities = $entity;
             }
         }
         $limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_resources_resources", '', $entities, true);
         $q = "SELECT COUNT(*)\n               FROM `glpi_plugin_resources_resources`\n               WHERE `is_deleted` = '0'\n               AND `is_template` = '0' ";
         if ($item->getType() != 'User') {
             $q .= " {$limit}";
         }
         $result = $DB->query($q);
         $nb = $DB->result($result, 0, 0);
         echo "<div class='firstbloc'>";
         if (plugin_resources_haveRight('resources', 'r') && $nb > count($used)) {
             echo "<form name='resource_form{$rand}' id='resource_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL('PluginResourcesResource') . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='4' class='center'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             if ($item->getType() == 'Ticket') {
                 echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
             }
             PluginResourcesResource::dropdown(array('entity' => $entities, 'used' => $used));
             echo "</td><td class='center' width='20%'>";
             echo "<input type='submit' name='additem' value=\"" . __s('Associate a resource', 'resources') . "\" class='submit'>";
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             Html::closeForm();
         }
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     echo "<tr>";
     if ($canedit && $number && $withtemplate < 2) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('First name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . __('Location') . "</th>";
     echo "<th>" . PluginResourcesContractType::getTypeName(1) . "</th>";
     echo "<th>" . PluginResourcesDepartment::getTypeName(1) . "</th>";
     echo "<th>" . __('Arrival date', 'resources') . "</th>";
     echo "<th>" . __('Departure date', 'resources') . "</th>";
     echo "</tr>";
     $used = array();
     $resourceID = 0;
     if ($number) {
         Session::initNavigateListItems('PluginResourcesResource', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($resources as $data) {
             $resourceID = $data["id"];
             $link = NOT_AVAILABLE;
             if ($resource->getFromDB($resourceID)) {
                 $link = $resource->getLink();
             }
             Session::addToNavigateListItems('PluginResourcesResource', $resourceID);
             $used[$resourceID] = $resourceID;
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$link}</td>";
             echo "<td class='center'>" . $data['firstname'] . "</td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             echo "<td class='center'>";
             echo Dropdown::getDropdownName("glpi_locations", $data["locations_id"]);
             echo "</td>";
             echo "<td class='center'>";
             echo Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"]);
             echo "</td>";
             echo "<td class='center'>";
             echo Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"]);
             echo "</td>";
             echo "<td class='center'>" . Html::convDate($data["date_begin"]) . "</td>";
             if ($data["date_end"] <= date('Y-m-d') && !empty($data["date_end"])) {
                 echo "<td class='center'>";
                 echo "<span class='plugin_resources_date_color'>";
                 echo Html::convDate($data["date_end"]);
                 echo "</span>";
                 echo "</td>";
             } else {
                 if (empty($data["date_end"])) {
                     echo "<td class='center'>" . __('Not defined', 'resources') . "</td>";
                 } else {
                     echo "<td class='center'>" . Html::convDate($data["date_end"]) . "</td>";
                 }
             }
             echo "</tr>";
             $i++;
         }
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate < 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
     if ($item->getType() == "User") {
         $PluginResourcesEmployee = new PluginResourcesEmployee();
         $PluginResourcesEmployee->showForm($resourceID, $ID, 0);
     }
 }
 /**
  * Show team for a project task
  *
  * @param $task   ProjectTask object
  *
  * @return boolean
  **/
 function showTeam(ProjectTask $task)
 {
     global $DB, $CFG_GLPI;
     /// TODO : permit to simple add member of project team ?
     $ID = $task->fields['id'];
     $canedit = $task->canEdit($ID);
     $rand = mt_rand();
     $nb = 0;
     $nb = $task->getTeamCount();
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='projecttaskteam_form{$rand}' id='projecttaskteam_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('ProjectTaskTeam') . "'>";
         echo "<input type='hidden' name='projecttasks_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a team member') . "</tr>";
         echo "<tr class='tab_bg_2'><td>";
         $params = array('itemtypes' => ProjectTeam::$available_types, 'entity_restrict' => $task->fields['is_recursive'] ? getSonsOf('glpi_entities', $task->fields['entities_id']) : $task->fields['entities_id']);
         $addrand = Dropdown::showSelectItemFromItemtypes($params);
         echo "</td>";
         echo "<td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
         //                     'specific_actions'
         //                         => array('delete' => _x('button', 'Delete permanently')) );
         //
         //          if ($this->fields['users_id'] != Session::getLoginUserID()) {
         //             $massiveactionparams['confirm']
         //                = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         //          }
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $nb) {
         $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>" . __('Type') . "</th>";
     $header_end .= "<th>" . _n('Member', 'Members', Session::getPluralNumber()) . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     foreach (ProjectTaskTeam::$available_types as $type) {
         if (isset($task->team[$type]) && count($task->team[$type])) {
             if ($item = getItemForItemtype($type)) {
                 foreach ($task->team[$type] as $data) {
                     $item->getFromDB($data['items_id']);
                     echo "<tr class='tab_bg_2'>";
                     if ($canedit) {
                         echo "<td>";
                         Html::showMassiveActionCheckBox('ProjectTaskTeam', $data["id"]);
                         echo "</td>";
                     }
                     echo "<td>" . $item->getTypeName(1) . "</td>";
                     echo "<td>" . $item->getLink() . "</td>";
                     echo "</tr>";
                 }
             }
         }
     }
     if ($nb) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
 /**
  * Show installed cartridges
  *
  * @since version 0.84 (before showInstalled)
  *
  * @param $printer            Printer object
  * @param $old       boolean  old cartridges or not ? (default 0)
  *
  * @return nothing (display)
  **/
 static function showForPrinter(Printer $printer, $old = 0)
 {
     global $DB, $CFG_GLPI;
     $instID = $printer->getField('id');
     if (!self::canView()) {
         return false;
     }
     $canedit = Session::haveRight("cartridge", UPDATE);
     $rand = mt_rand();
     $query = "SELECT `glpi_cartridgeitems`.`id` AS tID,\n                       `glpi_cartridgeitems`.`is_deleted`,\n                       `glpi_cartridgeitems`.`ref` AS ref,\n                       `glpi_cartridgeitems`.`name` AS type,\n                       `glpi_cartridges`.`id`,\n                       `glpi_cartridges`.`pages` AS pages,\n                       `glpi_cartridges`.`date_use` AS date_use,\n                       `glpi_cartridges`.`date_out` AS date_out,\n                       `glpi_cartridges`.`date_in` AS date_in,\n                       `glpi_cartridgeitemtypes`.`name` AS typename\n                FROM `glpi_cartridges`,\n                     `glpi_cartridgeitems`\n                LEFT JOIN `glpi_cartridgeitemtypes`\n                  on (`glpi_cartridgeitems`.`cartridgeitemtypes_id` = `glpi_cartridgeitemtypes`.`id`)\n                WHERE (`glpi_cartridges`.`date_out` IS " . ($old ? "NOT" : "") . " NULL\n                       AND `glpi_cartridges`.`printers_id` = '{$instID}'\n                       AND `glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`)\n                ORDER BY `glpi_cartridges`.`date_out` ASC,\n                         `glpi_cartridges`.`date_use` DESC,\n                         `glpi_cartridges`.`date_in`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     if ($canedit && !$old) {
         echo "<div class='firstbloc'>";
         echo "<form method='post' action=\"" . static::getFormURL() . "\">";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><td class='center tab_bg_2' width='50%'>";
         echo "<input type='hidden' name='printers_id' value='{$instID}'>\n";
         $installok = false;
         $cpt = '';
         if (CartridgeItem::dropdownForPrinter($printer)) {
             //TRANS : multiplier
             echo "</td><td>" . __('x') . "&nbsp;";
             Dropdown::showNumber("nbcart", array('value' => 1, 'min' => 1, 'max' => 5));
             $installok = true;
             echo "</td><td><input type='submit' name='install' value=\"" . _sx('button', 'Install') . "\"\n                         " . ($installok ? '' : 'disabled') . " class='submit'>";
         } else {
             _e('No cartridge available');
         }
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div id='viewcartridge{$rand}'></div>";
     $pages = $printer->fields['init_pages_counter'];
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         if (!$old) {
             $actions = array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'uninstall' => __('End of life'), __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'backtostock' => __('Back to stock'));
         } else {
             $actions = array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'updatepages' => __('Update printer counter'), 'purge' => _x('button', 'Delete permanently'));
         }
         $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => $actions, 'container' => 'mass' . __CLASS__ . $rand, 'rand' => $rand, 'extraparams' => array('maxpages' => $printer->fields['last_pages_counter']));
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='noHover'>";
     if ($old == 0) {
         echo "<th colspan='" . ($canedit ? '6' : '5') . "'>" . __('Used cartridges') . "</th>";
     } else {
         echo "<th colspan='" . ($canedit ? '9' : '8') . "'>" . __('Worn cartridges') . "</th>";
     }
     echo "</tr>";
     $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>" . __('ID') . "</th><th>" . _n('Cartridge model', 'Cartridge models', 1) . "</th>";
     $header_end .= "<th>" . _n('Cartridge type', 'Cartridge types', 1) . "</th>";
     $header_end .= "<th>" . __('Add date') . "</th>";
     $header_end .= "<th>" . __('Use date') . "</th>";
     if ($old != 0) {
         $header_end .= "<th>" . __('End date') . "</th>";
         $header_end .= "<th>" . __('Printer counter') . "</th>";
         $header_end .= "<th>" . __('Printed pages') . "</th>";
     }
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $stock_time = 0;
     $use_time = 0;
     $pages_printed = 0;
     $nb_pages_printed = 0;
     while ($data = $DB->fetch_assoc($result)) {
         $cart_id = $data["id"];
         $typename = $data["typename"];
         $date_in = Html::convDate($data["date_in"]);
         $date_use = Html::convDate($data["date_use"]);
         $date_out = Html::convDate($data["date_out"]);
         $viewitemjs = $canedit ? "style='cursor:pointer' onClick=\"viewEditCartridge" . $data['id'] . "{$rand}();\"" : '';
         echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
         if ($canedit) {
             echo "<td width='10'>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
             echo "</td>";
         }
         echo "<td class='center' {$viewitemjs}>";
         if ($canedit) {
             echo "\n<script type='text/javascript' >\n";
             echo "function viewEditCartridge" . $data["id"] . "{$rand}() {\n";
             $params = array('type' => __CLASS__, 'parenttype' => 'Printer', 'printers_id' => $printer->fields["id"], 'id' => $data["id"]);
             Ajax::updateItemJsCode("viewcartridge{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
             echo "};";
             echo "</script>\n";
         }
         echo $data["id"] . "</td>";
         echo "<td class='center' {$viewitemjs}>";
         echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/cartridgeitem.form.php?id=" . $data["tID"] . "\">";
         printf(__('%1$s - %2$s'), $data["type"], $data["ref"]);
         echo "</a></td>";
         echo "<td class='center' {$viewitemjs}>" . $typename . "</td>";
         echo "<td class='center' {$viewitemjs}>" . $date_in . "</td>";
         echo "<td class='center' {$viewitemjs}>" . $date_use . "</td>";
         $tmp_dbeg = explode("-", $data["date_in"]);
         $tmp_dend = explode("-", $data["date_use"]);
         $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
         $stock_time += $stock_time_tmp;
         if ($old != 0) {
             echo "<td class='center' {$viewitemjs}>" . $date_out;
             $tmp_dbeg = explode("-", $data["date_use"]);
             $tmp_dend = explode("-", $data["date_out"]);
             $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
             $use_time += $use_time_tmp;
             echo "</td><td class='numeric' {$viewitemjs}>" . $data['pages'] . "</td>";
             echo "<td class='numeric' {$viewitemjs}>";
             if ($pages < $data['pages']) {
                 $pages_printed += $data['pages'] - $pages;
                 $nb_pages_printed++;
                 $pp = $data['pages'] - $pages;
                 echo $pp;
                 $pages = $data['pages'];
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
         }
         echo "</tr>";
     }
     if ($old) {
         // Print average
         if ($number > 0) {
             if ($nb_pages_printed == 0) {
                 $nb_pages_printed = 1;
             }
             echo "<tr class='tab_bg_2'><td colspan='" . ($canedit ? "4" : '3') . "'>&nbsp;</td>";
             echo "<td class='center b'>" . __('Average time in stock') . "<br>";
             $time_stock = round($stock_time / $number / 60 / 60 / 24 / 30.5, 1);
             echo sprintf(_n('%d month', '%d months', $time_stock), $time_stock) . "</td>";
             echo "<td class='center b'>" . __('Average time in use') . "<br>";
             $time_use = round($use_time / $number / 60 / 60 / 24 / 30.5, 1);
             echo sprintf(_n('%d month', '%d months', $time_use), $time_use) . "</td>";
             echo "<td class='center b' colspan='2'>" . __('Average number of printed pages') . "<br>";
             echo round($pages_printed / $nb_pages_printed) . "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>\n\n";
 }
 function showForm(CommonDBTM $item, $options = array())
 {
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!$item->can($item->fields['id'], READ)) {
         return false;
     }
     $rand = mt_rand();
     $a_data = getAllDatasFromTable('glpi_plugin_fusioninventory_ipranges_configsecurities', "`plugin_fusioninventory_ipranges_id`='" . $item->getID() . "'", false, '`rank`');
     $a_used = array();
     foreach ($a_data as $data) {
         $a_used[] = $data['plugin_fusioninventory_configsecurities_id'];
     }
     echo "<div class='firstbloc'>";
     echo "<form name='iprange_configsecurity_form{$rand}' id='iprange_configsecurity_form{$rand}' method='post'\n             action='" . Toolbox::getItemTypeFormURL('PluginFusioninventoryIPRange_ConfigSecurity') . "' >";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='2'>" . __('Add a SNMP authentication') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>";
     Dropdown::show('PluginFusioninventoryConfigSecurity', array('used' => $a_used));
     echo "</td>";
     echo "<td>";
     echo Html::hidden('plugin_fusioninventory_ipranges_id', array('value' => $item->getID()));
     echo "<input type='submit' name='add' value=\"" . _sx('button', 'Associate') . "\" class='submit'>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
     // Display list of auth associated with IP range
     $rand = mt_rand();
     echo "<div class='spaced'>";
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
     Html::showMassiveActions($massiveactionparams);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'>";
     echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     echo "<th>";
     echo __('SNMP Authentication', 'fusioninventory');
     echo "</th>";
     echo "<th>";
     echo __('Version', 'fusioninventory');
     echo "</th>";
     echo "<th>";
     echo __('Rank');
     echo "</th>";
     echo "</tr>";
     $pfConfigSecurity = new PluginFusioninventoryConfigSecurity();
     foreach ($a_data as $data) {
         echo "<tr class='tab_bg_2'>";
         echo "<td>";
         Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
         echo "</td>";
         echo "<td>";
         $pfConfigSecurity->getFromDB($data['plugin_fusioninventory_configsecurities_id']);
         echo $pfConfigSecurity->getLink();
         echo "</td>";
         echo "<td>";
         echo $pfConfigSecurity->getSNMPVersion($pfConfigSecurity->fields['snmpversion']);
         echo "</td>";
         echo "<td>";
         echo $data['rank'];
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     $massiveactionparams['ontop'] = false;
     Html::showMassiveActions($massiveactionparams);
     echo "</div>";
 }
Exemple #14
0
 /**
  * Show bookmarks list
  *
  * @param $target       target to use for links
  * @param $is_private   show private of public bookmarks ? (default 1)
  *
  * @return nothing
  **/
 function showBookmarkList($target, $is_private = 1)
 {
     global $DB, $CFG_GLPI;
     if (!$is_private && !static::canView()) {
         return false;
     }
     $query = "SELECT `" . $this->getTable() . "`.*,\n                       `glpi_bookmarks_users`.`id` AS IS_DEFAULT\n                FROM `" . $this->getTable() . "`\n                LEFT JOIN `glpi_bookmarks_users`\n                  ON (`" . $this->getTable() . "`.`itemtype` = `glpi_bookmarks_users`.`itemtype`\n                      AND `" . $this->getTable() . "`.`id` = `glpi_bookmarks_users`.`bookmarks_id`\n                      AND `glpi_bookmarks_users`.`users_id` = '" . Session::getLoginUserID() . "')\n                WHERE ";
     if ($is_private) {
         $query .= "(`" . $this->getTable() . "`.`is_private`='1'\n                     AND `" . $this->getTable() . "`.`users_id`='" . Session::getLoginUserID() . "') ";
     } else {
         $query .= "(`" . $this->getTable() . "`.`is_private`='0' " . getEntitiesRestrictRequest("AND", $this->getTable(), "", "", true) . ")";
     }
     $query .= " ORDER BY `itemtype`, `name`";
     // get bookmarks
     $bookmarks = array();
     if ($result = $DB->query($query)) {
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $bookmarks[$data['id']] = $data;
             }
         }
     }
     $ordered_bookmarks = array();
     // get personal order
     if ($is_private) {
         $user = new User();
         $personalorderfield = 'privatebookmarkorder';
         if ($user->getFromDB(Session::getLoginUserID())) {
             $personalorder = importArrayFromDB($user->fields[$personalorderfield]);
         }
         if (!is_array($personalorder)) {
             $personalorder = array();
         }
         // Add bookmarks on personal order
         if (count($personalorder)) {
             foreach ($personalorder as $val) {
                 if (isset($bookmarks[$val])) {
                     $ordered_bookmarks[$val] = $bookmarks[$val];
                     unset($bookmarks[$val]);
                 }
             }
         }
     }
     // Add unsaved in order bookmarks
     if (count($bookmarks)) {
         foreach ($bookmarks as $key => $val) {
             $ordered_bookmarks[$key] = $val;
         }
     }
     if ($is_private) {
         // New bookmark : save order
         $store_bookmark = array_keys($ordered_bookmarks);
         $user->update(array('id' => Session::getLoginUserID(), $personalorderfield => exportArrayToDB($store_bookmark)));
     }
     $rand = mt_rand();
     $numrows = $DB->numrows($result);
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     echo "<div class='center' id='tabsbody' >";
     $maactions = array('purge' => _x('button', 'Delete permanently'));
     if ($is_private) {
         $maactions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'move_bookmark'] = __('Move');
     }
     $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand, 'width' => 600, 'extraparams' => array('is_private' => $is_private), 'height' => 200, 'specific_actions' => $maactions);
     // No massive action on bottom
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     echo "<th>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     echo "<th class='center' colspan='2'>" . _n('Bookmark', 'Bookmarks', Session::getPluralNumber()) . "</th>";
     echo "<th width='20px'>&nbsp;</th>";
     echo "<th>" . __('Default view') . "</th>";
     $colspan = 5;
     if ($is_private) {
         $colspan += 2;
         echo "<th colspan='2'>&nbsp;</th>";
     }
     echo "</tr>";
     if ($totalcount = count($ordered_bookmarks)) {
         $current_type = -1;
         $number = 0;
         $current_type_name = NOT_AVAILABLE;
         foreach ($ordered_bookmarks as $key => $this->fields) {
             $number++;
             if ($current_type != $this->fields['itemtype']) {
                 $current_type = $this->fields['itemtype'];
                 $current_type_name = NOT_AVAILABLE;
                 if ($current_type == "AllAssets") {
                     $current_type_name = __('Global');
                 } else {
                     if ($item = getItemForItemtype($current_type)) {
                         $current_type_name = $item->getTypeName(1);
                     }
                 }
             }
             $canedit = $this->canEdit($this->fields["id"]);
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10px'>";
             if ($canedit) {
                 Html::showMassiveActionCheckBox(__CLASS__, $this->fields["id"]);
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             echo "<td>{$current_type_name}</td>";
             echo "<td>";
             if ($canedit) {
                 echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=edit&amp;id=" . $this->fields["id"] . "\" alt='" . _sx('button', 'Update') . "'>" . $this->fields["name"] . "</a>";
             } else {
                 echo $this->fields["name"];
             }
             echo "</td>";
             echo "<td><a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=load&amp;id=" . $this->fields["id"] . "\" class='vsubmit'>" . __('Load') . "</a>";
             echo "</td>";
             echo "<td class='center'>";
             if ($this->fields['type'] == self::SEARCH) {
                 if (is_null($this->fields['IS_DEFAULT'])) {
                     echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=edit&amp;" . "mark_default=1&amp;id=" . $this->fields["id"] . "\" alt=\"" . __s('Not default search') . "\" itle=\"" . __s('Not default search') . "\">" . "<img src=\"" . $CFG_GLPI['root_doc'] . "/pics/bookmark_record.png\" class='pointer'></a>";
                 } else {
                     echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=edit&amp;" . "mark_default=0&amp;id=" . $this->fields["id"] . "\" alt=\"" . __s('Default search') . "\" title=\"" . __s('Default search') . "\">" . "<img src=\"" . $CFG_GLPI['root_doc'] . "/pics/bookmark_default.png\" class='pointer'></a>";
                 }
             }
             echo "</td>";
             if ($is_private) {
                 if ($number != 1) {
                     echo "<td>";
                     Html::showSimpleForm($this->getSearchURL(), array('action' => 'up'), '', array('id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_up.png");
                     echo "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($number != $totalcount) {
                     echo "<td>";
                     Html::showSimpleForm($this->getSearchURL(), array('action' => 'down'), '', array('id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_down.png");
                     echo "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
             }
             echo "</tr>";
             $first = false;
         }
         echo "</table></div>";
         if ($is_private || Session::haveRight('bookmark_public', PURGE)) {
             $massiveactionparams['ontop'] = false;
             $massiveactionparams['forcecreate'] = true;
             Html::showMassiveActions($massiveactionparams);
         }
     } else {
         echo "<tr class='tab_bg_1'><td colspan='{$colspan}'>";
         _e('You have not recorded any bookmarks yet');
         echo "</td></tr></table>";
     }
     Html::closeForm();
 }
 /**
  * @param $port   NetworkPort object
  **/
 static function showForNetworkPort(NetworkPort $port)
 {
     global $DB, $CFG_GLPI;
     $ID = $port->getID();
     if (!$port->can($ID, READ)) {
         return false;
     }
     $canedit = $port->canEdit($ID);
     $rand = mt_rand();
     $query = "SELECT `glpi_networkports_vlans`.id as assocID,\n                       `glpi_networkports_vlans`.tagged ,\n                       `glpi_vlans`.*\n                FROM `glpi_networkports_vlans`\n                LEFT JOIN `glpi_vlans`\n                        ON (`glpi_networkports_vlans`.`vlans_id` = `glpi_vlans`.`id`)\n                WHERE `networkports_id` = '{$ID}'";
     $result = $DB->query($query);
     $vlans = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($line = $DB->fetch_assoc($result)) {
             $used[$line["id"]] = $line["id"];
             $vlans[$line["assocID"]] = $line;
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>\n";
         echo "<form method='post' action='" . static::getFormURL() . "'>\n";
         echo "<table class='tab_cadre_fixe'>\n";
         echo "<tr><th colspan='4'>" . __('Associate a VLAN') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         echo "<input type='hidden' name='networkports_id' value='{$ID}'>";
         Vlan::dropdown(array('used' => $used));
         echo "</td>";
         echo "<td class='right'>" . __('Tagged') . "</td>";
         echo "<td class='left'><input type='checkbox' name='tagged' value='1'></td>";
         echo "<td><input type='submit' name='add' value='" . _sx('button', 'Associate') . "' class='submit'>";
         echo "</td></tr>\n";
         echo "</table>\n";
         Html::closeForm();
         echo "</div>\n";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $header_top .= "<th width='10'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
         $header_bottom .= "<th width='10'>";
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Tagged') . "</th>";
     $header_end .= "<th>" . __('ID TAG') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     foreach ($vlans as $data) {
         echo "<tr class='tab_bg_1'>";
         if ($canedit) {
             echo "<td>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
             echo "</td>";
         }
         $name = $data["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
             $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
         }
         echo "<td class='center b'>\n               <a href='" . $CFG_GLPI["root_doc"] . "/front/vlan.form.php?id=" . $data["id"] . "'>" . $name . "</a>";
         echo "</td>";
         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
         echo "</td><td class='center'>" . Dropdown::getYesNo($data["tagged"]) . "</td>";
         echo "<td class='numeric'>" . $data["tag"] . "</td>";
         echo "</tr>";
     }
     if ($number) {
         echo $header_begin . $header_top . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Exemple #16
0
 /**
  * Print the HTML array for SLTs linked to a SLA
  *
  * @param SLA $sla
  * @return boolean
  */
 static function showForSla(SLA $sla)
 {
     global $CFG_GLPI;
     $instID = $sla->fields['id'];
     $slt = new self();
     $calendar = new Calendar();
     if (!$sla->can($instID, READ)) {
         return false;
     }
     $canedit = $sla->canEdit($instID) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewslt{$instID}{$rand}'></div>\n";
         echo "<script type='text/javascript' >";
         echo "function viewAddSlt{$instID}{$rand}() {";
         $params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => -1);
         Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "}";
         echo "</script>";
         echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddSlt{$instID}{$rand}();'>";
         echo __('Add a new SLT') . "</a></div>\n";
     }
     // SLT list
     $sltList = $slt->find("`slas_id` = '" . $instID . "'");
     Session::initNavigateListItems('SLT', sprintf(__('%1$s = %2$s'), $sla::getTypeName(1), $sla->getName()));
     echo "<div class='spaced'>";
     if (count($sltList)) {
         if ($canedit) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         $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>";
         $header_end .= "<th>" . __('Type') . "</th>";
         $header_end .= "<th>" . __('Maximum time') . "</th>";
         $header_end .= "<th>" . __('Calendar') . "</th>";
         echo $header_begin . $header_top . $header_end;
         foreach ($sltList as $val) {
             $edit = $canedit ? "style='cursor:pointer' onClick=\"viewEditSlt" . $instID . $val["id"] . "{$rand}();\"" : '';
             echo "\n<script type='text/javascript' >\n";
             echo "function viewEditSlt" . $instID . $val["id"] . "{$rand}() {\n";
             $params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => $val["id"]);
             Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
             echo "};";
             echo "</script>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10' {$edit}>";
             if ($canedit) {
                 Html::showMassiveActionCheckBox($slt->getType(), $val['id']);
             }
             echo "</td>";
             $slt->getFromDB($val['id']);
             echo "<td {$edit}>" . $slt->getLink() . "</td>";
             echo "<td {$edit}>" . $slt->getSpecificValueToDisplay('type', $slt->fields['type']) . "</td>";
             echo "<td {$edit}>";
             echo $slt->getSpecificValueToDisplay('number_time', array('number_time' => $slt->fields['number_time'], 'definition_time' => $slt->fields['definition_time']));
             echo "</td>";
             if (!$sla->fields['calendars_id']) {
                 $link = __('24/7');
             } else {
                 if ($sla->fields['calendars_id'] == -1) {
                     $link = __('Calendar of the ticket');
                 } else {
                     if ($calendar->getFromDB($sla->fields['calendars_id'])) {
                         $link = $calendar->getLink();
                     }
                 }
             }
             echo "<td {$edit}>" . $link . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
     } else {
         echo __('No item to display');
     }
     echo "</div>";
 }
 /**
  * @param $template        NotificationTemplate object
  * @param $options   array
  **/
 function showSummary(NotificationTemplate $template, $options = array())
 {
     global $DB, $CFG_GLPI;
     $nID = $template->getField('id');
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<div class='center'>" . "<a class='vsubmit' href='" . Toolbox::getItemTypeFormURL('NotificationTemplateTranslation') . "?notificationtemplates_id=" . $nID . "'>" . __('Add a new translation') . "</a></div><br>";
     }
     echo "<div class='center' id='tabsbody'>";
     Session::initNavigateListItems('NotificationTemplateTranslation', sprintf(__('%1$s = %2$s'), NotificationTemplate::getTypeName(1), $template->getName()));
     if ($canedit) {
         $rand = mt_rand();
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     if ($canedit) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Language') . "</th></tr>";
     foreach ($DB->request('glpi_notificationtemplatetranslations', array('notificationtemplates_id' => $nID)) as $data) {
         if ($this->getFromDB($data['id'])) {
             Session::addToNavigateListItems('NotificationTemplateTranslation', $data['id']);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td class='center'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>";
             echo "<a href='" . Toolbox::getItemTypeFormURL('NotificationTemplateTranslation') . "?id=" . $data['id'] . "&amp;notificationtemplates_id=" . $nID . "'>";
             if ($data['language'] != '') {
                 echo $CFG_GLPI['languages'][$data['language']][0];
             } else {
                 _e('Default translation');
             }
             echo "</a></td></tr>";
         }
     }
     echo "</table>";
     if ($canedit) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show webapplications associated to an item
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object for which associated webapplications must be displayed
  * @param $withtemplate    (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!Session::haveRight("plugin_webapplications", READ)) {
         return false;
     }
     if (!$item->can($item->fields['id'], READ)) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $canedit = $item->canadditem('PluginWebapplicationsWebapplication');
     $rand = mt_rand();
     $is_recursive = $item->isRecursive();
     $query = "SELECT `glpi_plugin_webapplications_webapplications_items`.`id` AS assocID,\n                       `glpi_entities`.`id` AS entity,\n                       `glpi_plugin_webapplications_webapplications`.`name` AS assocName,\n                       `glpi_plugin_webapplications_webapplications`.*\n                FROM `glpi_plugin_webapplications_webapplications_items`\n                LEFT JOIN `glpi_plugin_webapplications_webapplications`\n                 ON (`glpi_plugin_webapplications_webapplications_items`.`plugin_webapplications_webapplications_id`=`glpi_plugin_webapplications_webapplications`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_webapplications_webapplications`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_webapplications_webapplications_items`.`items_id` = '{$ID}'\n                      AND `glpi_plugin_webapplications_webapplications_items`.`itemtype` = '" . $item->getType() . "' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_webapplications_webapplications", '', '', true);
     $query .= " ORDER BY `assocName`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $webs = array();
     $web = new PluginWebapplicationsWebapplication();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $webs[$data['assocID']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit && $withtemplate < 2) {
         // Restrict entity for knowbase
         $entities = "";
         $entity = $_SESSION["glpiactive_entity"];
         if ($item->isEntityAssign()) {
             /// Case of personal items : entity = -1 : create on active entity (Reminder case))
             if ($item->getEntityID() >= 0) {
                 $entity = $item->getEntityID();
             }
             if ($item->isRecursive()) {
                 $entities = getSonsOf('glpi_entities', $entity);
             } else {
                 $entities = $entity;
             }
         }
         $limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_webapplications_webapplications", '', $entities, true);
         $q = "SELECT COUNT(*)\n               FROM `glpi_plugin_webapplications_webapplications`\n               WHERE `is_deleted` = '0'\n               {$limit}";
         $result = $DB->query($q);
         $nb = $DB->result($result, 0, 0);
         echo "<div class='firstbloc'>";
         if (Session::haveRight("plugin_webapplications", READ) && $nb > count($used)) {
             echo "<form name='webapplication_form{$rand}' id='webapplication_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL('PluginWebapplicationsWebapplication') . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='4' class='center'>";
             echo "<input type='hidden' name='entities_id' value='{$entity}'>";
             echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             if ($item->getType() == 'Ticket') {
                 echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
             }
             PluginWebapplicationsWebapplication::dropdownWebapplication(array('entity' => $entities, 'used' => $used));
             echo "</td><td class='center' width='20%'>";
             echo "<input type='submit' name='additem' value=\"" . __s('Associate a web application', 'webapplications') . "\" class='submit'>";
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             Html::closeForm();
         }
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number && $withtemplate < 2) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . PluginWebapplicationsWebapplicationType::getTypeName(1) . "</th>";
     echo "<th>" . __('URL') . "</th>";
     echo "<th>" . __('Server') . "</th>";
     echo "<th>" . __('Language') . "</th>";
     echo "<th>" . __('Version') . "</th>";
     echo "<th>" . __('Comments') . "</th>";
     echo "</tr>";
     $used = array();
     if ($number) {
         Session::initNavigateListItems('PluginWebapplicationsWebapplication', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($webs as $data) {
             $webID = $data["id"];
             $link = NOT_AVAILABLE;
             if ($web->getFromDB($webID)) {
                 $link = $web->getLink();
             }
             Session::addToNavigateListItems('PluginWebapplicationsWebapplication', $webID);
             $used[$webID] = $webID;
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$link}</td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtypes", $data["plugin_webapplications_webapplicationtypes_id"]) . "</td>";
             $link = Toolbox::substr($data["address"], 0, 30) . "...";
             echo "<td class='center'>" . "<a href=\"" . str_replace("&", "&amp;", $data["address"]) . "\" target=\"_blank\">" . "<u>" . $link . "</u></a></td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationservertypes", $data["plugin_webapplications_webapplicationservertypes_id"]) . "</td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtechnics", $data["plugin_webapplications_webapplicationtechnics_id"]) . "</td>";
             echo "<td>" . $data["version"] . "</td>";
             echo "<td>" . $data["comment"] . "</td>";
             echo "</tr>";
             $i++;
         }
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate < 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Exemple #19
0
 /**
  * Show items for the group
  *
  * @param $tech   boolean  false search groups_id, true, search groups_id_tech
  **/
 function showItems($tech)
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $ID = $this->fields['id'];
     if ($tech) {
         $types = $CFG_GLPI['linkgroup_tech_types'];
         $field = 'groups_id_tech';
         $title = __('Managed items');
     } else {
         $types = $CFG_GLPI['linkgroup_types'];
         $field = 'groups_id';
         $title = __('Used items');
     }
     $tree = Session::getSavedOption(__CLASS__, 'tree', 0);
     $user = Session::getSavedOption(__CLASS__, 'user', 0);
     $type = Session::getSavedOption(__CLASS__, 'onlytype', '');
     if (!in_array($type, $types)) {
         $type = '';
     }
     echo "<div class='spaced'>";
     // Mini Search engine
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th colspan='3'>{$title}</tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo __('Type') . "&nbsp;";
     Dropdown::showItemType($types, array('value' => $type, 'name' => 'onlytype', 'plural' => true, 'on_change' => 'reloadTab("start=0&onlytype="+this.value)', 'checkright' => true));
     if ($this->haveChildren()) {
         echo "</td><td class='center'>" . __('Child groups') . "&nbsp;";
         Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
     } else {
         $tree = 0;
     }
     if ($this->getField('is_usergroup')) {
         echo "</td><td class='center'>" . User::getTypeName(Session::getPluralNumber()) . "&nbsp;";
         Dropdown::showYesNo('user', $user, -1, array('on_change' => 'reloadTab("start=0&user="******"</td></tr></table>";
     $datas = array();
     if ($type) {
         $types = array($type);
     }
     $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
     $nb = $this->getDataItems($types, $field, $tree, $user, $start, $datas);
     $nbcan = 0;
     if ($nb) {
         Html::printAjaxPager('', $start, $nb);
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         echo Html::hidden('field', array('value' => $field, 'data-glpicore-ma-tags' => 'common'));
         $massiveactionparams = array('num_displayed' => $nb, 'check_itemtype' => 'Group', 'check_items_id' => $ID, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('is_tech' => $tech, 'massive_action_fields' => array('field')), 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'changegroup' => __('Move')));
         Html::showMassiveActions($massiveactionparams);
         echo "<table class='tab_cadre_fixehov'>";
         $header_begin = "<tr><th width='10'>";
         $header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end = '</th>';
         $header_end .= "<th>" . __('Type') . "</th><th>" . __('Name') . "</th><th>" . __('Entity') . "</th>";
         if ($tree || $user) {
             $header_end .= "<th>" . sprintf(__('%1$s / %2$s'), self::getTypeName(1), User::getTypeName(1)) . "</th>";
         }
         $header_end .= "</tr>";
         echo $header_begin . $header_top . $header_end;
         $tuser = new User();
         $group = new Group();
         foreach ($datas as $data) {
             if (!($item = getItemForItemtype($data['itemtype']))) {
                 continue;
             }
             echo "<tr class='tab_bg_1'><td>";
             if ($item->canEdit($data['items_id'])) {
                 Html::showMassiveActionCheckBox($data['itemtype'], $data['items_id']);
             }
             echo "</td><td>" . $item->getTypeName(1);
             echo "</td><td>" . $item->getLink(array('comments' => true));
             echo "</td><td>" . Dropdown::getDropdownName("glpi_entities", $item->getEntityID());
             if ($tree || $user) {
                 echo "</td><td>";
                 if ($grp = $item->getField($field)) {
                     if ($group->getFromDB($grp)) {
                         echo $group->getLink(array('comments' => true));
                     }
                 } else {
                     if ($usr = $item->getField(str_replace('groups', 'users', $field))) {
                         if ($tuser->getFromDB($usr)) {
                             echo $tuser->getLink(array('comments' => true));
                         }
                     }
                 }
             }
             echo "</td></tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
     } else {
         echo "<p class='center b'>" . __('No item found') . "</p>";
     }
     if ($nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
     }
     Html::closeForm();
     if ($nb) {
         Html::printAjaxPager('', $start, $nb);
     }
     echo "</div>";
 }
Exemple #20
0
 /**
  * @param $item
  **/
 function showAndAddRuleForm($item)
 {
     $rand = mt_rand();
     $canedit = self::canUpdate();
     if ($canedit && $item->getType() == 'Entity') {
         $this->showNewRuleForm($item->getField('id'));
     }
     //Get all rules and actions
     $crit = array('field' => getForeignKeyFieldForTable($item->getTable()), 'value' => $item->getField('id'));
     $rules = $this->getRulesForCriteria($crit);
     $nb = count($rules);
     echo "<div class='spaced'>";
     if (!$nb) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th>" . __('No item found') . "</th>";
         echo "</tr>\n";
         echo "</table>\n";
     } else {
         if ($canedit) {
             Html::openMassiveActionsForm('mass' . get_called_class() . $rand);
             $massiveactionparams = array('num_displayed' => $nb, 'specific_actions' => array('update' => _x('button', 'Update'), 'purge' => _x('button', 'Delete permanently')));
             //     'extraparams'
             //           => array('rule_class_name' => $this->getRuleClassName()));
             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' . get_called_class() . $rand);
             $header_bottom .= Html::getCheckAllAsCheckbox('mass' . get_called_class() . $rand);
             $header_end .= "</th>";
         }
         $header_end .= "<th>" . $this->getTitle() . "</th>";
         $header_end .= "<th>" . __('Description') . "</th>";
         $header_end .= "<th>" . __('Active') . "</th>";
         $header_end .= "</tr>\n";
         echo $header_begin . $header_top . $header_end;
         Session::initNavigateListItems(get_class($this), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($rules as $rule) {
             Session::addToNavigateListItems(get_class($this), $rule->fields["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $rule->fields["id"]);
                 echo "</td>";
                 echo "<td><a href='" . Toolbox::getItemTypeFormURL(get_class($this)) . "?id=" . $rule->fields["id"] . "&amp;onglet=1'>" . $rule->fields["name"] . "</a></td>";
             } else {
                 echo "<td>" . $rule->fields["name"] . "</td>";
             }
             echo "<td>" . $rule->fields["description"] . "</td>";
             echo "<td>" . Dropdown::getYesNo($rule->fields["is_active"]) . "</td>";
             echo "</tr>\n";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>\n";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
     }
     echo "</div>";
 }
Exemple #21
0
 /**
  * Show visibility config for a rssfeed
  **/
 function showVisibility()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->fields['id'];
     $canedit = $this->canEdit($ID);
     $rand = mt_rand();
     $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='rssfeedvisibility_form{$rand}' id='rssfeedvisibility_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('RSSFeed') . "'>";
         echo "<input type='hidden' name='rssfeeds_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</tr>";
         echo "<tr class='tab_bg_1'><td class='tab_bg_2' width='100px'>";
         $types = array('Entity', 'Group', 'Profile', 'User');
         $addrand = Dropdown::showItemTypes('_type', $types);
         $params = array('type' => '__VALUE__', 'right' => 'rssfeed_public');
         Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params);
         echo "</td>";
         echo "<td><span id='visibility{$rand}'></span>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('delete' => _x('button', 'Delete permanently')));
         if ($this->fields['users_id'] != Session::getLoginUserID()) {
             $massiveactionparams['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         }
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $nb) {
         $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>" . __('Type') . "</th>";
     $header_end .= "<th>" . _n('Recipient', 'Recipients', Session::getPluralNumber()) . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     // Users
     if (count($this->users)) {
         foreach ($this->users as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('RSSFeed_User', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('User') . "</td>";
                 echo "<td>" . getUserName($data['users_id']) . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Groups
     if (count($this->groups)) {
         foreach ($this->groups as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Group_RSSFeed', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('Group') . "</td>";
                 $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1);
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $entname .= sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         //TRANS: R for Recursive
                         $entname .= sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Entity
     if (count($this->entities)) {
         foreach ($this->entities as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Entity_RSSFeed', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('Entity') . "</td>";
                 $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1);
                 $tooltip = Html::showToolTip($names["comment"], array('display' => false));
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip);
                 if ($data['is_recursive']) {
                     $entname .= sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Profiles
     if (count($this->profiles)) {
         foreach ($this->profiles as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Profile_RSSFeed', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>";
                 $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1);
                 $tooltip = Html::showToolTip($names["comment"], array('display' => false));
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip);
                 if ($data['entities_id'] >= 0) {
                     $entname .= sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $entname .= sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     if ($nb) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
 /**
  * Display all translated field for a dropdown
  *
  * @param $item a Dropdown item
  *
  * @return true;
  **/
 static function showTranslations(CommonDropdown $item)
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $canedit = $item->can($item->getID(), UPDATE);
     if ($canedit) {
         echo "<div id='viewtranslation" . $item->getType() . $item->getID() . "{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function addTranslation" . $item->getType() . $item->getID() . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => get_class($item), $item->getForeignKeyField() => $item->getID(), 'id' => -1);
         Ajax::updateItemJsCode("viewtranslation" . $item->getType() . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>\n";
         echo "<div class='center'>" . "<a class='vsubmit' href='javascript:addTranslation" . $item->getType() . $item->getID() . "{$rand}();'>" . __('Add a new translation') . "</a></div><br>";
     }
     $query = "SELECT *\n                FROM `" . getTableForItemType(__CLASS__) . "`\n                WHERE `itemtype` = '" . get_class($item) . "'\n                      AND `items_id` = '" . $item->getID() . "'\n                      AND `field` <> 'completename'\n                ORDER BY `language` ASC";
     $results = $DB->query($query);
     if ($DB->numrows($results)) {
         if ($canedit) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixehov'><tr class='tab_bg_2'>";
         echo "<th colspan='4'>" . __("List of translations") . "</th></tr><tr>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . __("Language") . "</th>";
         echo "<th>" . __("Field") . "</th>";
         echo "<th>" . __("Value") . "</th></tr>";
         while ($data = $DB->fetch_array($results)) {
             $onhover = '';
             if ($canedit) {
                 $onhover = "style='cursor:pointer'\n                           onClick=\"viewEditTranslation" . $data['itemtype'] . $data['id'] . "{$rand}();\"";
             }
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td class='center'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td {$onhover}>";
             if ($canedit) {
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditTranslation" . $data['itemtype'] . $data['id'] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'parenttype' => get_class($item), $item->getForeignKeyField() => $item->getID(), 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewtranslation" . $item->getType() . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
             echo Dropdown::getLanguageName($data['language']);
             echo "</td><td {$onhover}>";
             $searchOption = $item->getSearchOptionByField('field', $data['field']);
             echo $searchOption['name'] . "</td>";
             echo "<td {$onhover}>" . $data['value'] . "</td>";
             echo "</tr>";
         }
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
     } else {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
         echo "<th class='b'>" . __("No translation found") . "</th></tr></table>";
     }
     return true;
 }
 /**
  * Print the HTML array for device on link
  *
  * @param $link : Link
  *
  * @return Nothing (display)
  **/
 static function showForLink($link)
 {
     global $DB, $CFG_GLPI;
     $links_id = $link->getField('id');
     $canedit = $link->can($links_id, 'w');
     $rand = mt_rand();
     if (!Session::haveRight("link", "r") || !$link->can($links_id, 'r')) {
         return false;
     }
     $query = "SELECT *\n                FROM `glpi_links_itemtypes`\n                WHERE `links_id` = '{$links_id}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $types = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $types[$data['id']] = $data;
             $used[$data['itemtype']] = $data['itemtype'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item type') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='right'>";
         echo "<input type='hidden' name='links_id' value='{$links_id}'>";
         Dropdown::showItemTypes('itemtype', $CFG_GLPI["link_types"], array('used' => $used));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "</tr>";
     foreach ($types as $data) {
         $typename = NOT_AVAILABLE;
         if ($item = getItemForItemtype($data['itemtype'])) {
             $typename = $item->getTypeName(1);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$typename}</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Exemple #24
0
 function showScripts(PluginDatabasesDatabase $database)
 {
     global $DB, $CFG_GLPI;
     $instID = $database->fields['id'];
     if (!$database->can($instID, "r")) {
         return false;
     }
     $rand = mt_rand();
     $canedit = $database->can($instID, 'w');
     $query = "SELECT `glpi_plugin_databases_scripts`.`name` AS name,\n                        `glpi_plugin_databases_scripts`.`id`,\n                        `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`,\n                        `glpi_plugin_databases_scripts`.`path`,\n                        `glpi_plugin_databases_scripts`.`comment`,\n                        `glpi_plugin_databases_scripttypes`.`name` AS type\n               FROM `glpi_plugin_databases_scripts` ";
     $query .= " LEFT JOIN `glpi_plugin_databases_scripttypes`\n      ON (`glpi_plugin_databases_scripttypes`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_scripttypes_id`)";
     $query .= " LEFT JOIN `glpi_plugin_databases_databases`\n      ON (`glpi_plugin_databases_databases`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`)";
     $query .= " WHERE `glpi_plugin_databases_scripts`.`plugin_databases_databases_id` = '{$instID}'\n          ORDER BY `glpi_plugin_databases_scripts`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array();
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     if ($number != 0) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         if ($canedit && $number) {
             echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
         }
         echo "<th>" . __('Name') . "</th>";
         echo "<th>" . __('Type') . "</th>";
         echo "<th>" . __('Path', 'databases') . "</th>";
         echo "<th>" . __('Comments') . "</th>";
         echo "</tr>";
         Session::initNavigateListItems($this->getType(), PluginDatabasesDatabase::getTypeName(2) . " = " . $database->fields["name"]);
         $i = 0;
         $row_num = 1;
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems($this->getType(), $data['id']);
             $i++;
             $row_num++;
             echo "<tr class='tab_bg_1 center'>";
             echo "<td width='10'>";
             if ($canedit) {
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
             }
             echo "</td>";
             echo "<td class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/script.form.php?id=" . $data["id"] . "&amp;plugin_databases_databases_id=" . $data["plugin_databases_databases_id"] . "'>";
             echo $data["name"];
             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                 echo " (" . $data["id"] . ")";
             }
             echo "</a></td>";
             echo "<td class='center'>" . $data["type"] . "</td>";
             echo "<td class='left'>" . $data["path"] . "</td>";
             echo "<td class='center'>" . nl2br($data["comment"]) . "</td>";
             echo "</tr>";
         }
         echo "</table>";
     }
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * \brief Show aliases for an item from its form
  * Beware that the rendering can be different if readden from direct item form (ie : add new
  * NetworkAlias, remove, ...) or if readden from item of the item (for instance from the computer
  * form through NetworkPort::ShowForItem and NetworkName::ShowForItem).
  *
  * @param $item                     NetworkName object
  * @param $withtemplate   integer   withtemplate param (default 0)
  **/
 static function showForNetworkName(NetworkName $item, $withtemplate = 0)
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getID();
     if (!$item->can($ID, 'r')) {
         return false;
     }
     $canedit = $item->can($ID, 'w');
     $rand = mt_rand();
     $query = "SELECT *\n                FROM `glpi_networkaliases`\n                WHERE `networknames_id` = '{$ID}'";
     $result = $DB->query($query);
     $aliases = array();
     if ($number = $DB->numrows($result)) {
         while ($line = $DB->fetch_assoc($result)) {
             $aliases[$line["id"]] = $line;
         }
     }
     if ($canedit) {
         echo "\n<div class='firstbloc'>";
         echo "<script type='text/javascript' >\n";
         echo "function viewAddAlias{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'NetworkName', 'networknames_id' => $ID, 'id' => -1);
         Ajax::updateItemJsCode("viewnetworkalias{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>";
         echo "<a class='vsubmit' href='javascript:viewAddAlias{$rand}();'>";
         echo __('Add a network alias') . "</a>\n";
         echo "</div>\n";
     }
     echo "<div id='viewnetworkalias{$rand}'></div>";
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . _n('Internet domain', 'Internet domains', 1) . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "</tr>";
     $used = array();
     foreach ($aliases as $data) {
         $showviewjs = $canedit ? "style='cursor:pointer' onClick=\"viewEditAlias" . $data['id'] . "{$rand}();\"" : '';
         echo "<tr class='tab_bg_1'>";
         if ($canedit) {
             echo "<td>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
             echo "</td>";
         }
         $name = $data["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
             $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
         }
         echo "<td class='center b' {$showviewjs}>";
         if ($canedit) {
             echo "\n<script type='text/javascript' >\n";
             echo "function viewEditAlias" . $data["id"] . "{$rand}() {\n";
             $params = array('type' => __CLASS__, 'parenttype' => 'NetworkName', 'networknames_id' => $ID, 'id' => $data["id"]);
             Ajax::updateItemJsCode("viewnetworkalias{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
             echo "};";
             echo "</script>\n";
         }
         echo "<a href='" . static::getFormURL() . "?id=" . $data["id"] . "'>" . $name . "</a>";
         echo "</td>";
         echo "<td class='center' {$showviewjs}>" . Dropdown::getDropdownName("glpi_fqdns", $data["fqdns_id"]);
         echo "<td class='center' {$showviewjs}>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
         echo "</tr>";
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show users of a group
  *
  * @since version 0.83
  *
  * @param $group  Group object: the group
  **/
 static function showForGroup(Group $group)
 {
     global $DB, $CFG_GLPI;
     $ID = $group->getID();
     if (!User::canView() || !$group->can($ID, READ)) {
         return false;
     }
     // Have right to manage members
     $canedit = self::canUpdate();
     $rand = mt_rand();
     $user = new User();
     $crit = Session::getSavedOption(__CLASS__, 'criterion', '');
     $tree = Session::getSavedOption(__CLASS__, 'tree', 0);
     $used = array();
     $ids = array();
     // Retrieve member list
     $entityrestrict = self::getDataForGroup($group, $used, $ids, $crit, $tree);
     if ($canedit) {
         self::showAddUserForm($group, $ids, $entityrestrict, $crit);
     }
     // Mini Search engine
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th colspan='2'>" . User::getTypeName(Session::getPluralNumber()) . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo _n('Criterion', 'Criteria', 1) . "&nbsp;";
     $crits = array('' => Dropdown::EMPTY_VALUE, 'is_manager' => __('Manager'), 'is_userdelegate' => __('Delegatee'));
     Dropdown::showFromArray('crit', $crits, array('value' => $crit, 'on_change' => 'reloadTab("start=0&criterion="+this.value)'));
     if ($group->haveChildren()) {
         echo "</td><td class='center'>" . __('Child groups');
         Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
     } else {
         $tree = 0;
     }
     echo "</td></tr></table>";
     $number = count($used);
     $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
     if ($start >= $number) {
         $start = 0;
     }
     // Display results
     if ($number) {
         echo "<div class='spaced'>";
         Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number);
         Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName()));
         if ($canedit) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => min($number - $start, $_SESSION['glpilist_limit']), 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
         $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>" . User::getTypeName(1) . "</th>";
         if ($tree) {
             $header_end .= "<th>" . Group::getTypeName(1) . "</th>";
         }
         $header_end .= "<th>" . __('Dynamic') . "</th>";
         $header_end .= "<th>" . __('Manager') . "</th>";
         $header_end .= "<th>" . __('Delegatee') . "</th></tr>";
         echo $header_begin . $header_top . $header_end;
         $tmpgrp = new Group();
         for ($i = $start, $j = 0; $i < $number && $j < $_SESSION['glpilist_limit']; $i++, $j++) {
             $data = $used[$i];
             $user->getFromDB($data["id"]);
             Session::addToNavigateListItems('User', $data["id"]);
             echo "\n<tr class='tab_bg_" . ($user->isDeleted() ? '1_2' : '1') . "'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             echo "<td>" . $user->getLink();
             if ($tree) {
                 echo "</td><td>";
                 if ($tmpgrp->getFromDB($data['groups_id'])) {
                     echo $tmpgrp->getLink(array('comments' => true));
                 }
             }
             echo "</td><td class='center'>";
             if ($data['is_dynamic']) {
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Dynamic') . "\">";
             }
             echo "</td><td class='center'>";
             if ($data['is_manager']) {
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Manager') . "\">";
             }
             echo "</td><td class='center'>";
             if ($data['is_userdelegate']) {
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Delegatee') . "\">";
             }
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number);
         echo "</div>";
     } else {
         echo "<p class='center b'>" . __('No item found') . "</p>";
     }
 }
 /**
  * show defined display preferences for a user
  *
  * @param $users_id integer user ID
  **/
 static function showForUser($users_id)
 {
     global $DB;
     $url = Toolbox::getItemTypeFormURL(__CLASS__);
     $query = "SELECT `itemtype`,\n                       COUNT(*) AS nb\n                FROM `glpi_displaypreferences`\n                WHERE `users_id` = '{$users_id}'\n                GROUP BY `itemtype`";
     $req = $DB->request($query);
     if ($req->numrows() > 0) {
         $rand = mt_rand();
         echo "<div class='spaced'>";
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('width' => 400, 'height' => 200, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'delete_for_user' => _x('button', 'Delete permanently')), 'extraparams' => array('massive_action_fields' => array('users_id')));
         Html::showMassiveActions($massiveactionparams);
         echo Html::hidden('users_id', array('value' => $users_id, 'data-glpicore-ma-tags' => 'common'));
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
         echo "<th colspan='2'>" . __('Type') . "</th></tr>";
         foreach ($req as $data) {
             echo "<tr class='tab_bg_1'><td width='10'>";
             Html::showMassiveActionCheckBox(__CLASS__, $data["itemtype"]);
             echo "</td>";
             if ($item = getItemForItemtype($data["itemtype"])) {
                 $name = $item->getTypeName(1);
             } else {
                 $name = $data["itemtype"];
             }
             echo "<td>{$name}</td><td class='numeric'>" . $data['nb'] . "</td>";
             echo "</tr>";
         }
         echo "</table>";
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
         echo "</div>";
     } else {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>";
         echo "</table>";
     }
 }
 /**
  * Show holidays for a calendar
  *
  * @param $calendar Calendar object
  **/
 static function showForCalendar(Calendar $calendar)
 {
     global $DB, $CFG_GLPI;
     $ID = $calendar->getField('id');
     if (!$calendar->can($ID, 'r')) {
         return false;
     }
     $canedit = $calendar->can($ID, 'w');
     $rand = mt_rand();
     $query = "SELECT DISTINCT `glpi_calendars_holidays`.`id` AS linkID,\n                                `glpi_holidays`.*\n                FROM `glpi_calendars_holidays`\n                LEFT JOIN `glpi_holidays`\n                     ON (`glpi_calendars_holidays`.`holidays_id` = `glpi_holidays`.`id`)\n                WHERE `glpi_calendars_holidays`.`calendars_id` = '{$ID}'\n                ORDER BY `glpi_holidays`.`name`";
     $result = $DB->query($query);
     $holidays = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $holidays[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n                action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a close time') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='right'  colspan='4'>";
         echo "<input type='hidden' name='calendars_id' value='{$ID}'>";
         Holiday::dropdown(array('used' => $used, 'entity' => $calendar->fields["entities_id"]));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $paramsma = array('num_displayed' => $numrows);
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Start') . "</th>";
     echo "<th>" . __('End') . "</th>";
     echo "<th>" . __('Recurrent') . "</th>";
     echo "</tr>";
     $used = array();
     if ($numrows) {
         Session::initNavigateListItems('Holiday', sprintf(__('%1$s = %2$s'), Calendar::getTypeName(1), $calendar->fields["name"]));
         foreach ($holidays as $data) {
             Session::addToNavigateListItems('Holiday', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 echo "</td>";
             }
             echo "<td><a href='" . Toolbox::getItemTypeFormURL('Holiday') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>";
             echo "<td>" . Html::convDate($data["begin_date"]) . "</td>";
             echo "<td>" . Html::convDate($data["end_date"]) . "</td>";
             echo "<td>" . Dropdown::getYesNo($data["is_perpetual"]) . "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Show the printer types that are compatible with a cartridge type
  *
  * @param $item   CartridgeItem object
  *
  * @return nothing (display)
  **/
 static function showForCartridgeItem(CartridgeItem $item)
 {
     global $DB, $CFG_GLPI;
     $instID = $item->getField('id');
     if (!$item->can($instID, READ)) {
         return false;
     }
     $canedit = $item->canEdit($instID);
     $rand = mt_rand();
     $query = "SELECT `" . static::getTable() . "`.`id`,\n                       `glpi_printermodels`.`name` AS `type`,\n                       `glpi_printermodels`.`id` AS `pmid`\n                FROM `" . static::getTable() . "`,\n                     `glpi_printermodels`\n                WHERE `" . static::getTable() . "`.`printermodels_id` = `glpi_printermodels`.`id`\n                      AND `" . static::getTable() . "`.`cartridgeitems_id` = '{$instID}'\n                ORDER BY `glpi_printermodels`.`name`";
     $result = $DB->query($query);
     $i = 0;
     $used = array();
     $datas = array();
     if ($number = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $used[$data["pmid"]] = $data["pmid"];
             $datas[$data["id"]] = $data;
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='printermodel_form{$rand}' id='printermodel_form{$rand}' method='post'";
         echo " action='" . static::getFormURL() . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='6'>" . __('Add a compatible printer model') . "</th></tr>";
         echo "<tr><td class='tab_bg_2 center'>";
         echo "<input type='hidden' name='cartridgeitems_id' value='{$instID}'>";
         PrinterModel::dropdown(array('used' => $used));
         echo "</td><td class='tab_bg_2 center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     if ($number) {
         echo "<div class='spaced'>";
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => count($used), 'container' => 'mass' . __CLASS__ . $rand);
             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>" . __('Model') . "</th></tr>";
         echo $header_begin . $header_top . $header_end;
         foreach ($datas as $data) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>" . $data['type'] . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         echo "</div>";
     } else {
         echo "<p class='center b'>" . __('No item found') . "</p>";
     }
 }
 /**
  * Print the HTML array for Items linked to current contract
  *
  * @since version 0.84
  *
  * @param $contract   Contract object
  *
  * @return Nothing (display)
  **/
 static function showForContract(Contract $contract)
 {
     global $DB, $CFG_GLPI;
     $instID = $contract->fields['id'];
     if (!$contract->can($instID, READ)) {
         return false;
     }
     $canedit = $contract->can($instID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`contracts_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $data = array();
     $totalnb = 0;
     $used = array();
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                                 `glpi_contracts_items`.`id` AS IDD,\n                                 `glpi_entities`.`id` AS entity\n                          FROM `glpi_contracts_items`,\n                               `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_contracts_items`.`items_id`\n                              AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'\n                              AND `glpi_contracts_items`.`contracts_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             if ($nb > $_SESSION['glpilist_limit']) {
                 $opt = array('order' => 'ASC', 'is_deleted' => 0, 'reset' => 'reset', 'start' => 0, 'sort' => 80, 'criteria' => array(0 => array('value' => '$$$$' . $instID, 'searchtype' => 'contains', 'field' => 29)));
                 $url = $item::getSearchURL();
                 $url .= strpos($url, '?') ? '&' : '?';
                 $url .= Toolbox::append_params($opt);
                 $link = "<a href='{$url}'>" . __('Device list') . "</a>";
                 $data[$itemtype] = array('longlist' => true, 'name' => sprintf(__('%1$s: %2$s'), $item->getTypeName($nb), $nb), 'link' => $link);
             } else {
                 if ($nb > 0) {
                     $data[$itemtype] = array();
                     while ($objdata = $DB->fetch_assoc($result_linked)) {
                         $data[$itemtype][$objdata['id']] = $objdata;
                         $used[$itemtype][$objdata['id']] = $objdata['id'];
                     }
                 }
             }
             $totalnb += $nb;
         }
     }
     if ($canedit && ($contract->fields['max_links_allowed'] == 0 || $contract->fields['max_links_allowed'] > $totalnb)) {
         echo "<div class='firstbloc'>";
         echo "<form name='contract_form{$rand}' id='contract_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $CFG_GLPI["contract_types"], 'entity_restrict' => $contract->fields['is_recursive'] ? getSonsOf('glpi_entities', $contract->fields['entities_id']) : $contract->fields['entities_id'], 'checkright' => true, 'used' => $used));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $totalnb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $totalnb) {
         $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>" . __('Type') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Serial number') . "</th>";
     $header_end .= "<th>" . __('Inventory number') . "</th>";
     $header_end .= "<th>" . __('Status') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $totalnb = 0;
     foreach ($data as $itemtype => $datas) {
         if (isset($datas['longlist'])) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>&nbsp;</td>";
             }
             echo "<td class='center'>" . $datas['name'] . "</td>";
             echo "<td class='center' colspan='2'>" . $datas['link'] . "</td>";
             echo "<td class='center'>-</td><td class='center'>-</td></tr>";
         } else {
             $prem = true;
             $nb = count($datas);
             foreach ($datas as $id => $objdata) {
                 $name = $objdata["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     $name = sprintf(__('%1$s (%2$s)'), $name, $objdata["id"]);
                 }
                 $link = $itemtype::getFormURLWithID($objdata["id"]);
                 $name = "<a href=\"" . $link . "\">" . $name . "</a>";
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td width='10'>";
                     Html::showMassiveActionCheckBox(__CLASS__, $objdata["IDD"]);
                     echo "</td>";
                 }
                 if ($prem) {
                     $item = new $itemtype();
                     $typename = $item->getTypeName($nb);
                     echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>";
                     $prem = false;
                 }
                 echo "<td class='center'>";
                 echo Dropdown::getDropdownName("glpi_entities", $objdata['entity']) . "</td>";
                 echo "<td class='center" . (isset($objdata['is_deleted']) && $objdata['is_deleted'] ? " tab_bg_2_2'" : "'");
                 echo ">" . $name . "</td>";
                 echo "<td class='center'>" . (isset($objdata["serial"]) ? "" . $objdata["serial"] . "" : "-") . "</td>";
                 echo "<td class='center'>" . (isset($objdata["otherserial"]) ? "" . $objdata["otherserial"] . "" : "-") . "</td>";
                 echo "<td class='center'>";
                 if (isset($objdata["states_id"])) {
                     echo Dropdown::getDropdownName("glpi_states", $objdata['states_id']);
                 } else {
                     echo '&nbsp;';
                 }
                 echo "</td></tr>";
             }
         }
     }
     if ($number) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }