checkAllAsCheckbox() static public method

Display "check All as" checkbox
static public checkAllAsCheckbox ( $container_id, $rand = '' ) : nothing
$container_id string html of the container of checkboxes link to this check all checkbox
$rand string rand value to use (default is auto generated) (default ''))
return nothing / display item
 function displayList($tasks_id)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     echo "<script type=\"text/javascript\">\nfunction edit_subtype(id,el) {\n\n   //remove all border to previous selected item (remove classes)\n//   Ext.select('#table_taskjob_'+ _rand +' tr').removeClass('selected');\n\n\n   var row = null;\n   if (el) {\n      // get parent row of the selected element\n      row = jQuery(el).parents('tr:first')\n   }\n\n   if (row) {\n      //add border to selected index (add class)\n      row.addClass('selected');\n//      params['index'] = row.index();\n      // change mode to edit\n//      params['mode'] = 'edit';\n      arg = 'taskjobs_id=' + id;\n   } else {\n      arg = 'tasks_id=' + id;\n   }\n\n   //scroll to edit form\n//   document.getElementById('th_title_taskjob_' + _rand).scrollIntoView();\n\n   //show and load form\n//   \$('taskjobs_block' + _rand).setDisplayed('block');\n   \$('#taskjobs_block').load('../ajax/taskjob_form.php?' + arg);\n}\n\n/*\n * Create a new subtype element.\n * This method just override *edit_subtype* with a null element.\n */\nfunction new_subtype(id) {\n   edit_subtype(id, null);\n}\n</script>";
     echo "<table class='tab_cadre_fixe' id='package_order_" . $tasks_id . "'>";
     echo "<tr>";
     echo "<th id='th_title_taskjob_{$rand}'>";
     //echo "<img src='".$CFG_GLPI["root_doc"]."/plugins/fusioninventory/pics/$subtype.png' />";
     echo "&nbsp;" . $this->getTypeName();
     echo "&nbsp;";
     echo "<img id='plus_taskjobs_block{$rand}'";
     echo " onclick=\"new_subtype({$tasks_id})\" ";
     echo " title='" . __('Add') . "' alt='" . __('Add') . "' ";
     echo " class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' /> ";
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<td style='vertical-align:top'>";
     /**
      * Display subtype form
      **/
     echo "<form name='additiontaskjob' method='post' " . " action='taskjob.form.php'>";
     echo "<input type='hidden' name='orders_id' value='{$tasks_id}' />";
     echo "<input type='hidden' name='itemtype' value='PluginFusioninventoryDeploy" . ucfirst('taskjob') . "' />";
     echo "<div id='taskjobs_block'></div>";
     Html::closeForm();
     $a_taskjobs = getAllDatasFromTable($this->getTable(), "`plugin_fusioninventory_tasks_id`='" . $tasks_id . "'", FALSE, '`ranking`');
     echo "<div id='drag_taskjob_taskjobs'>";
     echo "<table class='tab_cadrehov package_item_list' id='table_taskjob_{$rand}' style='width: 950px'>";
     $i = 0;
     foreach ($a_taskjobs as $data) {
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         echo "<td class='control'>";
         Html::showCheckbox(array('name' => 'taskjob_entries[]', 'value' => $i));
         echo "</td>";
         echo "<td>";
         echo "<a class='edit' " . "onclick=\"edit_subtype({$data['id']}, this)\">";
         echo $data['name'];
         echo "</a><br />";
         echo "<b>";
         echo __('Definition', 'fusioninventory');
         echo "</b>";
         echo "<ul class='retChecks'>";
         $a_definitions = importArrayFromDB($data['definition']);
         foreach ($a_definitions as $a_definition) {
             foreach ($a_definition as $itemtype => $items_id) {
                 echo "<li>";
                 $item = new $itemtype();
                 $item->getFromDB($items_id);
                 echo $item->getTypeName() . " > ";
                 echo $item->getLink();
                 echo "</li>";
             }
         }
         echo "</ul>";
         echo "<b>";
         echo __('Action', 'fusioninventory');
         echo "</b>";
         echo "<ul class='retChecks'>";
         $a_actions = importArrayFromDB($data['action']);
         foreach ($a_actions as $a_action) {
             foreach ($a_action as $itemtype => $items_id) {
                 echo "<li>";
                 $item = new $itemtype();
                 $item->getFromDB($items_id);
                 echo $item->getTypeName() . " > ";
                 echo $item->getLink();
                 echo "</li>";
             }
         }
         echo "</ul>";
         echo "</td>";
         echo "</td>";
         echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         echo "</tr>";
         $i++;
     }
     echo "<tr><th>";
     Html::checkAllAsCheckbox("taskjobsList{$rand}", mt_rand());
     echo "</th><th colspan='3' class='mark'></th></tr>";
     echo "</table>";
     echo "</div>";
     echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>";
     echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>";
     /**
      * Initialize drag and drop on subtype lists
      **/
     echo "<script type=\"text/javascript\">\n      redipsInit('taskjob', 'taskjob', {$tasks_id});\n</script>";
     echo "</table>";
 }
 /**
  * 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, 'r')) {
         return false;
     }
     $canedit = $item->can($instID, 'w');
     $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;
     function getForbiddenStandardMassiveAction()
     {
         $forbidden = parent::getForbiddenStandardMassiveAction();
         $forbidden[] = 'update';
         return $forbidden;
     }
     $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);
             $paramsma = array('num_displayed' => count($used));
             Html::showMassiveActions(__CLASS__, $paramsma);
         }
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . __('Model') . "</th></tr>";
         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 "</table>";
         if ($canedit) {
             $paramsma['ontop'] = false;
             Html::showMassiveActions(__CLASS__, $paramsma);
             Html::closeForm();
         }
         echo "</div>";
     } else {
         echo "<p class='center b'>" . __('No item found') . "</p>";
     }
 }
 static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']);
     $checks_types = self::getTypes();
     echo "<table class='tab_cadrehov package_item_list' id='table_check_{$rand}'>";
     $i = 0;
     foreach ($datas['jobs']['checks'] as $check) {
         //specific case for filesystem size
         if (is_numeric($check['value'])) {
             if ($check['type'] == "freespaceGreater") {
                 $check['value'] = $check['value'] * 1024 * 1024;
             }
             $check['value'] = PluginFusioninventoryDeployFile::processFilesize($check['value']);
         }
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='control'>";
             echo "<input type='checkbox' name='check_entries[]' value='{$i}' />";
             echo "</td>";
         }
         echo "<td>";
         echo "<a class='edit'" . "onclick=\"edit_subtype('check', {$order->fields['id']}, {$rand} ,this)\">" . $checks_types[$check['type']] . "</a><br />";
         echo $check['path'];
         if (!empty($check['value'])) {
             echo "&nbsp;&nbsp;&nbsp;<b>";
             if (strpos($check['type'], "Greater") !== FALSE) {
                 echo "&gt;";
             } else {
                 if (strpos($check['type'], "Lower") !== FALSE) {
                     echo "&lt;";
                 } else {
                     echo "=";
                 }
             }
             echo "</b>&nbsp;&nbsp;&nbsp;";
             echo $check['value'];
         }
         echo "</td>";
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         }
         echo "</tr>";
         $i++;
     }
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "<tr><th>";
         Html::checkAllAsCheckbox("checksList{$rand}", mt_rand());
         echo "</th><th colspan='3' class='mark'></th></tr>";
     }
     echo "</table>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt='' />";
         echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit' />";
     }
 }
 /**
  * Display category header for Computer_SoftwareVersion::showForComputer function
  *
  * @param $computers_ID             ID of the computer
  * @param $data                     data used to display
  * @param $rand                     random for unicity
  * @param $canedit         boolean
  *
  * @return new category ID
  **/
 private static function displayCategoryHeader($computers_ID, $data, $rand, $canedit)
 {
     global $CFG_GLPI;
     $display = "none";
     if (isset($data["softwarecategories_id"])) {
         $cat = $data["softwarecategories_id"];
         if ($cat) {
             // Categorized
             $catname = Dropdown::getDropdownName('glpi_softwarecategories', $cat);
             $display = $_SESSION["glpiis_categorized_soft_expanded"];
         } else {
             // Not categorized
             $catname = __('Uncategorized software');
             $display = $_SESSION["glpiis_not_categorized_soft_expanded"];
         }
     } else {
         // Not installed
         $cat = '';
         $catname = __('Affected licenses of not installed software');
         $display = true;
     }
     echo "<tr class='tab_bg_2'><td class='center' colspan='5'>";
     echo "<a href=\"javascript:showHideDiv('softcat{$cat}{$rand}','imgcat{$cat}','" . $CFG_GLPI['root_doc'] . "/pics/folder.png','" . $CFG_GLPI['root_doc'] . "/pics/folder-open.png');\">";
     echo "<img alt='' name='imgcat{$cat}' src='" . $CFG_GLPI['root_doc'] . "/pics/folder" . (!$display ? '' : "-open") . ".png'>&nbsp;<span class='b'>" . $catname . "</span>";
     echo "</a></td></tr>";
     echo "<tr class='tab_bg_2'><td colspan='5'>";
     echo "<div class='center' id='softcat{$cat}{$rand}' " . (!$display ? "style=\"display:none;\"" : '') . ">";
     echo "<table class='tab_cadre_fixe'><tr>";
     if ($canedit) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox("softcat{$cat}{$rand}");
         echo "</th>";
     }
     echo "<th>" . __('Name') . "</th><th>" . __('Status') . "</th>";
     echo "<th>" . __('Version') . "</th><th>" . __('License') . "</th>";
     if (isset($data['is_dynamic'])) {
         echo "<th>" . __('Automatic inventory') . "</th>";
     }
     echo "</tr>\n";
     return $cat;
 }
示例#5
0
 /**
  * @param $item
  **/
 function showAndAddRuleForm($item)
 {
     $rand = mt_rand();
     $canedit = Session::haveRight(static::$right, "w");
     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);
             $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('update' => _x('button', 'Update'), 'purge' => _x('button', 'Delete permanently')));
             Html::showMassiveActions(get_called_class(), $paramsma);
         }
         echo "<table class='tab_cadre_fixehov'><tr>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . get_called_class() . $rand);
             echo "</th>";
         }
         echo "<th>" . $this->getTitle() . "</th>";
         echo "<th>" . __('Description') . "</th>";
         echo "<th>" . __('Active') . "</th>";
         echo "</tr>\n";
         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 "</table>\n";
         if ($canedit) {
             $paramsma['ontop'] = false;
             Html::showMassiveActions(get_called_class(), $paramsma);
             Html::closeForm();
         }
     }
     echo "</div>";
 }
示例#6
0
 /**
  * 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>";
     }
 }
示例#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";
 }
 /**
  * @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>";
 }
示例#9
0
 /**
  * Print the HTML array of the Netpoint associated to a Location
  *
  * @param $item Location
  *
  * @return Nothing (display)
  **/
 static function showForLocation($item)
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     $netpoint = new self();
     $item->check($ID, READ);
     $canedit = $item->canEdit($ID);
     if (isset($_GET["start"])) {
         $start = intval($_GET["start"]);
     } else {
         $start = 0;
     }
     $number = countElementsInTable('glpi_netpoints', "`locations_id`='{$ID}'");
     if ($canedit) {
         echo "<div class='first-bloc'>";
         // Minimal form for quick input.
         echo "<form action='" . $netpoint->getFormURL() . "' method='post'>";
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'>";
         echo "<td class='b'>" . _n('Network outlet', 'Network outlets', 1) . "</td>";
         echo "<td>" . __('Name') . "</td><td>";
         Html::autocompletionTextField($item, "name", array('value' => ''));
         echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>";
         echo "<input type='hidden' name='locations_id' value='{$ID}'></td>";
         echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table>\n";
         Html::closeForm();
         // Minimal form for massive input.
         echo "<form action='" . $netpoint->getFormURL() . "' method='post'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'>";
         echo "<td class='b'>" . _n('Network outlet', 'Network outlets', Session::getPluralNumber()) . "</td>";
         echo "<td>" . __('Name') . "</td><td>";
         echo "<input type='text' maxlength='100' size='10' name='_before'>&nbsp;";
         Dropdown::showNumber('_from', array('value' => 0, 'min' => 0, 'max' => 400));
         echo "&nbsp;-->&nbsp;";
         Dropdown::showNumber('_to', array('value' => 0, 'min' => 0, 'max' => 400));
         echo "&nbsp;<input type='text' maxlength='100' size='10' name='_after'><br>";
         echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>";
         echo "<input type='hidden' name='locations_id' value='{$ID}'>";
         echo "<input type='hidden' name='_method' value='AddMulti'></td>";
         echo "<td><input type='submit' name='execute' value=\"" . _sx('button', 'Add') . "\"\n                    class='submit'>";
         echo "</td></tr>\n";
         echo "</table>\n";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . self::getTypeName(1) . "</th>";
         echo "<th>" . __('No item found') . "</th></tr>";
         echo "</table>\n";
     } else {
         Html::printAjaxPager(sprintf(__('Network outlets for %s'), $item->getTreeLink()), $start, $number);
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $_SESSION['glpilist_limit'], 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixe'><tr>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . __('Name') . "</th>";
         // Name
         echo "<th>" . __('Comments') . "</th>";
         // Comment
         echo "</tr>\n";
         $crit = array('locations_id' => $ID, 'ORDER' => 'name', 'START' => $start, 'LIMIT' => $_SESSION['glpilist_limit']);
         Session::initNavigateListItems('Netpoint', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($DB->request('glpi_netpoints', $crit) as $data) {
             Session::addToNavigateListItems('Netpoint', $data["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
             }
             echo "<td><a href='" . $netpoint->getFormURL();
             echo '?id=' . $data['id'] . "'>" . $data['name'] . "</a></td>";
             echo "<td>" . $data['comment'] . "</td>";
             echo "</tr>\n";
         }
         echo "</table>\n";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         Html::printAjaxPager(sprintf(__('Network outlets for %s'), $item->getTreeLink()), $start, $number);
     }
     echo "</div>\n";
 }
示例#10
0
 /**
  * Print out the consumables of a defined type
  *
  * @param $consitem           ConsumableItem object
  * @param $show_old  boolean  show old consumables or not. (default 0)
  *
  * @return Nothing (displays)
  **/
 static function showForConsumableItem(ConsumableItem $consitem, $show_old = 0)
 {
     global $DB, $CFG_GLPI;
     $tID = $consitem->getField('id');
     if (!$consitem->can($tID, 'r')) {
         return false;
     }
     $canedit = $consitem->can($tID, 'w');
     $rand = mt_rand();
     $where = "";
     if (!$show_old) {
         // NEW
         $where = " AND `date_out` IS NULL\n                  ORDER BY `date_in`, `id`";
     } else {
         //OLD
         $where = " AND `date_out` IS NOT NULL\n                  ORDER BY `date_out` DESC,\n                           `date_in`,\n                           `id`";
     }
     $query = "SELECT `glpi_consumables`.*\n                FROM `glpi_consumables`\n                WHERE `consumableitems_id` = '{$tID}'\n                      {$where}";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $actions = array('delete' => _x('button', 'Delete permanently'), 'activate_infocoms' => __('Enable the financial and administrative information'));
         if ($show_old) {
             $actions['restore'] = __('Back to stock');
         } else {
             $actions['give'] = _x('button', 'Give');
         }
         $paramsma = array('num_displayed' => $number, 'specific_actions' => $actions, 'extraparams' => array('entities_id' => $consitem->getEntityID()));
         Html::showMassiveActions(__CLASS__, $paramsma);
         echo "<input type='hidden' name='consumableitems_id' value='{$tID}'>\n";
     }
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     if (!$show_old) {
         echo "<tr><th colspan=" . ($canedit ? '5' : '4') . ">";
         echo self::getCount($tID, -1);
         echo "</th></tr>";
     } else {
         // Old
         echo "<tr><th colspan='" . ($canedit ? '7' : '6') . "'>" . __('Used consumables') . "</th></tr>";
     }
     if ($number) {
         $i = 0;
         echo "<tr>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . __('ID') . "</th>";
         echo "<th>" . _x('item', 'State') . "</th>";
         echo "<th>" . __('Add date') . "</th>";
         if ($show_old) {
             echo "<th>" . __('Use date') . "</th>";
             echo "<th>" . __('Given to') . "</th>";
         }
         echo "<th width='200px'>" . __('Financial and administrative information') . "</th>";
         echo "</tr>";
     }
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         while ($data = $DB->fetch_assoc($result)) {
             $date_in = Html::convDate($data["date_in"]);
             $date_out = Html::convDate($data["date_out"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>" . $data["id"] . "</td>";
             echo "<td class='center'>" . self::getStatus($data["id"]) . "</td>";
             echo "<td class='center'>" . $date_in . "</td>";
             if ($show_old) {
                 echo "<td class='center'>" . $date_out . "</td>";
                 echo "<td class='center'>";
                 if ($item = getItemForItemtype($data['itemtype'])) {
                     if ($item->getFromDB($data['items_id'])) {
                         echo $item->getLink();
                     }
                 }
                 echo "</td>";
             }
             echo "<td class='center'>";
             Infocom::showDisplayLink('Consumable', $data["id"], 1);
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
示例#11
0
 /**
  * Show Licenses of a software
  *
  * @param $software Software object
  *
  * @return nothing
  **/
 static function showForSoftware(Software $software)
 {
     global $DB, $CFG_GLPI;
     $softwares_id = $software->getField('id');
     $license = new self();
     $computer = new Computer();
     if (!$software->can($softwares_id, "r")) {
         return false;
     }
     if (isset($_POST["start"])) {
         $start = $_POST["start"];
     } else {
         $start = 0;
     }
     if (isset($_POST["order"]) && $_POST["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     if (isset($_POST["sort"]) && !empty($_POST["sort"])) {
         $sort = "`" . $_POST["sort"] . "`";
     } else {
         $sort = "`entity` {$order}, `name`";
     }
     // Righ type is enough. Can add a License on a software we have Read access
     $canedit = Session::haveRight("software", "w");
     $showmassiveactions = $canedit;
     // Total Number of events
     $number = countElementsInTable("glpi_softwarelicenses", "glpi_softwarelicenses.softwares_id = {$softwares_id} " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true));
     echo "<div class='spaced'>";
     Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $software->getName()));
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No item found') . "</th></tr>\n";
         if ($canedit) {
             echo "<tr class='tab_bg_2'><td class='center'>";
             echo "<a class='vsubmit' href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . _sx('button', 'Add a license') . "</a>";
             echo "</td></tr>\n";
         }
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     Html::printAjaxPager(self::getTypeName(2), $start, $number);
     $rand = mt_rand();
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `buyvers`.`name` AS buyname,\n                       `usevers`.`name` AS usename,\n                       `glpi_entities`.`completename` AS entity,\n                       `glpi_softwarelicensetypes`.`name` AS typename\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_softwareversions` AS buyvers\n                     ON (`buyvers`.`id` = `glpi_softwarelicenses`.`softwareversions_id_buy`)\n                LEFT JOIN `glpi_softwareversions` AS usevers\n                     ON (`usevers`.`id` = `glpi_softwarelicenses`.`softwareversions_id_use`)\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_entities`.`id` = `glpi_softwarelicenses`.`entities_id`)\n                LEFT JOIN `glpi_softwarelicensetypes`\n                     ON (`glpi_softwarelicensetypes`.`id`\n                          = `glpi_softwarelicenses`.`softwarelicensetypes_id`)\n                WHERE (`glpi_softwarelicenses`.`softwares_id` = '{$softwares_id}') " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true) . "\n                ORDER BY {$sort} {$order}\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     if ($result = $DB->query($query)) {
         if ($num_displayed = $DB->numrows($result)) {
             if ($showmassiveactions) {
                 Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
                 $massiveactionparams = array('num_displayed' => $num_displayed, 'extraparams' => array('options' => array('condition' => "`glpi_softwareversions`.`softwares_id` = {$softwares_id}")));
                 Html::showMassiveActions(__CLASS__, $massiveactionparams);
             }
             $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
             echo "<table class='tab_cadre_fixehov'><tr>";
             echo "<th>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
             echo "<th>" . ($sort == "`name`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=name&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Name') . "</a></th>";
             if ($software->isRecursive()) {
                 // Ereg to search entity in string for match default order
                 echo "<th>" . (strstr($sort, "entity") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=entity&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Entity') . "</a></th>";
             }
             echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Serial number') . "</a></th>";
             echo "<th>" . ($sort == "`number`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=number&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . _x('quantity', 'Number') . "</a></th>";
             echo "<th>" . __('Affected computers') . "</th>";
             echo "<th>" . ($sort == "`typename`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=typename&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Type') . "</a></th>";
             echo "<th>" . ($sort == "`buyname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=buyname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Purchase version') . "</a></th>";
             echo "<th>" . ($sort == "`usename`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=usename&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Version in use') . "</a></th>";
             echo "<th>" . ($sort == "`expire`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=expire&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Expiration') . "</a></th>";
             echo "</tr>\n";
             $tot_assoc = 0;
             for ($tot = 0; $data = $DB->fetch_assoc($result);) {
                 Session::addToNavigateListItems('SoftwareLicense', $data['id']);
                 $expired = true;
                 if (is_null($data['expire']) || $data['expire'] > date('Y-m-d')) {
                     $expired = false;
                 }
                 echo "<tr class='tab_bg_2" . ($expired ? '_2' : '') . "'>";
                 if ($license->can($data['id'], "w")) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 echo "<td><a href='softwarelicense.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a></td>";
                 if ($software->isRecursive()) {
                     echo "<td>" . $data['entity'] . "</td>";
                 }
                 echo "<td>" . $data['serial'] . "</td>";
                 echo "<td class='numeric'>" . ($data['number'] > 0 ? $data['number'] : __('Unlimited')) . "</td>";
                 $nb_assoc = Computer_SoftwareLicense::countForLicense($data['id']);
                 $tot_assoc += $nb_assoc;
                 echo "<td class='numeric'>" . $nb_assoc . "</td>";
                 echo "<td>" . $data['typename'] . "</td>";
                 echo "<td>" . $data['buyname'] . "</td>";
                 echo "<td>" . $data['usename'] . "</td>";
                 echo "<td class='center'>" . Html::convDate($data['expire']) . "</td>";
                 echo "</tr>";
                 if ($data['number'] < 0) {
                     // One illimited license, total is illimited
                     $tot = -1;
                 } else {
                     if ($tot >= 0) {
                         // Expire license not count
                         if (!$expired) {
                             // Not illimited, add the current number
                             $tot += $data['number'];
                         }
                     }
                 }
             }
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='" . ($software->isRecursive() ? 4 : 3) . "' class='right b'>" . __('Total') . "</td>";
             echo "<td class='numeric'>" . ($tot > 0 ? $tot . "" : __('Unlimited')) . "</td>";
             echo "<td class='numeric'>" . $tot_assoc . "</td>";
             echo "<td colspan='4' class='center'>";
             if ($canedit) {
                 echo "<a class='vsubmit' href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . _sx('button', 'Add a license') . "</a>";
             }
             echo "</td></tr>";
             echo "</table>\n";
             if ($showmassiveactions) {
                 $massiveactionparams['ontop'] = false;
                 Html::showMassiveActions(__CLASS__, $massiveactionparams);
                 Html::closeForm();
             }
         } else {
             _e('No item found');
         }
     }
     Html::printAjaxPager(self::getTypeName(2), $start, $number);
     echo "</div>";
 }
示例#12
0
 /**
  * Show softwares candidates to be merged with the current
  *
  * @return nothing
  **/
 function showMergeCandidates()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->getField('id');
     $this->check($ID, "w");
     $rand = mt_rand();
     echo "<div class='center'>";
     $sql = "SELECT `glpi_softwares`.`id`,\n                     `glpi_softwares`.`name`,\n                     `glpi_entities`.`completename` AS entity\n              FROM `glpi_softwares`\n              LEFT JOIN `glpi_entities` ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)\n              WHERE (`glpi_softwares`.`id` != '{$ID}'\n                     AND `glpi_softwares`.`name` = '" . addslashes($this->fields["name"]) . "'\n                     AND `glpi_softwares`.`is_deleted` = '0'\n                     AND `glpi_softwares`.`is_template` = '0' " . getEntitiesRestrictRequest('AND', 'glpi_softwares', 'entities_id', getSonsOf("glpi_entities", $this->fields["entities_id"]), false) . ")\n              ORDER BY `entity`";
     $req = $DB->request($sql);
     if ($nb = $req->numrows()) {
         $link = Toolbox::getItemTypeFormURL('Software');
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('mergesoftware' => __('Merge')));
         Html::showMassiveActions(__CLASS__, $paramsma);
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th width='10'>";
         echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
         echo "<th>" . __('Name') . "</th>";
         echo "<th>" . __('Entity') . "</th>";
         echo "<th>" . _n('Installation', 'Installations', 2) . "</th>";
         echo "<th>" . _n('License', 'Licenses', 2) . "</th></tr>";
         foreach ($req as $data) {
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
             echo "<td><a href='" . $link . "?id=" . $data["id"] . "'>" . $data["name"] . "</a></td>";
             echo "<td>" . $data["entity"] . "</td>";
             echo "<td class='right'>" . Computer_SoftwareVersion::countForSoftware($data["id"]) . "</td>";
             echo "<td class='right'>" . SoftwareLicense::countForSoftware($data["id"]) . "</td></tr>\n";
         }
         echo "</table>\n";
         echo "<input type='hidden' name='id' value='{$ID}'>";
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     } else {
         _e('No item found');
     }
     echo "</div>";
 }
示例#13
0
 /**
  * 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>";
 }
 /**
  * Show the list of rules
  *
  * @param $target
  * @param $options   array
  *
  * @return nothing
  **/
 function showListRules($target, $options = array())
 {
     global $CFG_GLPI;
     $p['inherited'] = 1;
     $p['childrens'] = 0;
     $p['active'] = false;
     $p['condition'] = 0;
     $rand = mt_rand();
     foreach (array('inherited', 'childrens', 'condition') as $param) {
         if (isset($options[$param]) && $this->isRuleRecursive()) {
             $p[$param] = $options[$param];
         }
     }
     $rule = $this->getRuleClass();
     $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']);
     // Do not know what it is ?
     $canedit = self::canUpdate() && !$display_entities;
     $use_conditions = false;
     if ($rule->useConditions()) {
         // First get saved option
         $p['condition'] = Session::getSavedOption($this->getType(), 'condition', 0);
         if ($p['condition'] == 0) {
             $p['condition'] = $this->getDefaultRuleConditionForList();
         }
         $use_conditions = true;
         // Mini Search engine
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><td class='center' width='50%'>";
         echo __('Rules used for') . "</td><td>";
         $rule->dropdownConditions(array('value' => $p['condition'], 'on_change' => 'reloadTab("start=0&inherited=' . $p['inherited'] . '&childrens=' . $p['childrens'] . '&condition="+this.value)'));
         echo "</td></tr></table>";
     }
     $nb = $this->getCollectionSize($p['inherited'], $p['condition']);
     $p['start'] = isset($options["start"]) ? $options["start"] : 0;
     if ($p['start'] >= $nb) {
         $p['start'] = 0;
     }
     $p['limit'] = $_SESSION['glpilist_limit'];
     $this->getCollectionPart($p);
     Html::printAjaxPager('', $p['start'], $nb);
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     echo "\n<div class='spaced'>";
     if ($canedit && $nb) {
         $massiveactionparams = array('num_displayed' => min($p['limit'], $nb), 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('entity' => $this->entity, 'condition' => $p['condition'], 'rule_class_name' => $this->getRuleClassName()));
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
     $colspan = 6;
     if ($display_entities) {
         $colspan++;
     }
     if ($use_conditions) {
         $colspan++;
     }
     echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n";
     echo "<tr>";
     echo "<th>";
     if ($canedit) {
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
     }
     echo "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Description') . "</th>";
     if ($use_conditions) {
         echo "<th>" . __('Use rule for') . "</th>";
     }
     echo "<th>" . __('Active') . "</th>";
     if ($display_entities) {
         echo "<th>" . __('Entity') . "</th>\n";
     }
     if (!$display_entities) {
         echo "<th colspan='2'>&nbsp;</th>";
     }
     echo "</tr>\n";
     if (count($this->RuleList->list)) {
         $ruletype = $this->RuleList->list[0]->getType();
         Session::initNavigateListItems($ruletype);
     }
     for ($i = $p['start'], $j = 0; isset($this->RuleList->list[$j]); $i++, $j++) {
         $this->RuleList->list[$j]->showMinimalForm($target, $i == 0, $i == $nb - 1, $display_entities, $p['condition']);
         Session::addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']);
     }
     if ($nb) {
         echo "<tr>";
         echo "<th>";
         if ($canedit) {
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         }
         echo "</th>";
         echo "<th>" . __('Name') . "</th>";
         echo "<th>" . __('Description') . "</th>";
         if ($use_conditions) {
             echo "<th>" . __('Use rule for') . "</th>";
         }
         echo "<th>" . __('Active') . "</th>";
         if ($display_entities) {
             echo "<th>" . __('Entity') . "</th>\n";
         }
         if (!$display_entities) {
             echo "<th colspan='2'>&nbsp;</th>";
         }
         echo "</tr>\n";
     }
     echo "</table>\n";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
     }
     echo "</div>";
     Html::closeForm();
     Html::printAjaxPager('', $p['start'], $nb);
     echo "<div class='spaced center'>";
     if ($plugin = isPluginItemType($this->getType())) {
         $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']);
     } else {
         $url = $CFG_GLPI["root_doc"];
     }
     echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID('allruletest' . $rand) . ".dialog('open');\">" . __('Test rules engine') . "</a>";
     Ajax::createIframeModalWindow('allruletest' . $rand, $url . "/front/rulesengine.test.php?" . "sub_type=" . $this->getRuleClassName() . "&condition=" . $p['condition'], array('title' => __('Test rules engine')));
     echo "</div>";
     if ($this->can_replay_rules) {
         echo "<div class='spaced center'>";
         echo "<a class='vsubmit' href='" . $rule->getSearchURL() . "?replay_rule=replay_rule'>" . __s('Replay the dictionary rules') . "</a>";
         echo "</div>";
     }
     echo "<div class='spaced'>";
     $this->showAdditionalInformationsInForm($target);
     echo "</div>";
 }
 /**
  * Display all translations for a label
  *
  * @param CommonDBTM $item Item instance
  *
  * @return void
  **/
 static function showTranslations(CommonDBTM $item)
 {
     global $DB, $CFG_GLPI;
     $canedit = $item->can($item->getID(), UPDATE);
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewtranslation" . $item->getID() . "{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function addTranslation" . $item->getID() . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'itemtype' => $item::getType(), 'items_id' => $item->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/plugins/fields/ajax/viewtranslations.php", $params);
         echo "};";
         echo "</script>\n";
         echo "<div class='center'>" . "<a class='vsubmit' href='javascript:addTranslation" . $item->getID() . "{$rand}();'>" . __('Add a new translation') . "</a></div><br>";
     }
     $obj = new self();
     $found = $obj->find("`plugin_fields_itemtype` = '{$item::getType()}' AND\n           `plugin_fields_items_id`='{$item->getID()}'", "`language` ASC");
     if (count($found) > 0) {
         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>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . __("Language", "fields") . "</th>";
         echo "<th>" . __("Label", "fields") . "</th>";
         foreach ($found as $data) {
             echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer'\n                     onClick=\"viewEditTranslation" . $data['id'] . "{$rand}();\"" : '') . ">";
             if ($canedit) {
                 echo "<td class='center'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td>";
             if ($canedit) {
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditTranslation" . $data["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'itemtype' => $item::getType(), 'items_id' => $item->getID(), 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/plugins/fields/ajax/viewtranslations.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
             echo Dropdown::getLanguageName($data['language']);
             echo "</td><td>";
             echo $data['label'];
             echo "</td></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;
 }
示例#16
0
 /**
  * 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 (!Session::haveRight("user", "r") || !$group->can($ID, 'r')) {
         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(2) . "</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($_POST['start']) ? intval($_POST['start']) : 0;
     if ($start >= $number) {
         $start = 0;
     }
     // Display results
     if ($number) {
         echo "<div class='spaced'>";
         Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(2), __('D=Dynamic')), $start, $number);
         Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName()));
         if ($canedit) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $paramsma = array('num_displayed' => min($number - $start, $_SESSION['glpilist_limit']));
             Html::showMassiveActions(__CLASS__, $paramsma);
         }
         echo "<table class='tab_cadre_fixehov'><tr>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . User::getTypeName(1) . "</th>";
         if ($tree) {
             echo "<th>" . Group::getTypeName(1) . "</th>";
         }
         echo "<th>" . __('Dynamic') . "</th>";
         echo "<th>" . __('Manager') . "</th>";
         echo "<th>" . __('Delegatee') . "</th></tr>";
         $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'/>";
             }
             echo "</td><td class='center'>";
             if ($data['is_manager']) {
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14'/>";
             }
             echo "</td><td class='center'>";
             if ($data['is_userdelegate']) {
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14'/>";
             }
             echo "</tr>";
         }
         echo "</table>";
         if ($canedit) {
             $paramsma['ontop'] = false;
             Html::showMassiveActions(__CLASS__, $paramsma);
             Html::closeForm();
         }
         Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(2), __('D=Dynamic')), $start, $number);
         echo "</div>";
     } else {
         echo "<p class='center b'>" . __('No item found') . "</p>";
     }
 }
 /**
  * Display all translated field for an KnowbaseItem
  *
  * @param $item a KnowbaseItem item
  *
  * @return true;
  **/
 static function showTranslations(KnowbaseItem $item)
 {
     global $DB, $CFG_GLPI;
     $canedit = $item->can($item->getID(), UPDATE);
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewtranslation" . $item->getID() . "{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function addTranslation" . $item->getID() . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => get_class($item), 'knowbaseitems_id' => $item->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewtranslation" . $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->getID() . "{$rand}();'>" . __('Add a new translation') . "</a></div><br>";
     }
     $obj = new self();
     $found = $obj->find("`knowbaseitems_id`='" . $item->getID() . "'", "`language` ASC");
     if (count($found) > 0) {
         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>";
         if ($canedit) {
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . __("Language") . "</th>";
         echo "<th>" . __("Subject") . "</th>";
         foreach ($found as $data) {
             echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer'\n                     onClick=\"viewEditTranslation" . $data['id'] . "{$rand}();\"" : '') . ">";
             if ($canedit) {
                 echo "<td class='center'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td>";
             if ($canedit) {
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditTranslation" . $data["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'parenttype' => get_class($item), 'knowbaseitems_id' => $item->getID(), 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
             echo Dropdown::getLanguageName($data['language']);
             echo "</td><td>";
             echo $data["name"];
             if (isset($data['answer']) && !empty($data['answer'])) {
                 echo "&nbsp;";
                 Html::showToolTip(Toolbox::unclean_html_cross_side_scripting_deep($data['answer']));
             }
             echo "</td></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;
 }
 /**
  * Show computers linked to a License
  *
  * @param $license SoftwareLicense object
  *
  * @return nothing
  **/
 static function showForLicense(SoftwareLicense $license)
 {
     global $DB, $CFG_GLPI;
     $searchID = $license->getField('id');
     if (!Session::haveRight("software", "r") || !$searchID) {
         return false;
     }
     $canedit = Session::haveRight("software", "w");
     $canshowcomputer = Session::haveRight("computer", "r");
     if (isset($_POST["start"])) {
         $start = $_POST["start"];
     } else {
         $start = 0;
     }
     if (isset($_POST["order"]) && $_POST["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     if (isset($_POST["sort"]) && !empty($_POST["sort"])) {
         // manage several param like location,compname : order first
         $tmp = explode(",", $_POST["sort"]);
         $sort = "`" . implode("` {$order},`", $tmp) . "`";
     } else {
         $sort = "`entity` {$order}, `compname`";
     }
     //SoftwareLicense ID
     $query_number = "SELECT COUNT(*) AS cpt\n                       FROM `glpi_computers_softwarelicenses`\n                       INNER JOIN `glpi_computers`\n                           ON (`glpi_computers_softwarelicenses`.`computers_id`\n                                 = `glpi_computers`.`id`)\n                       WHERE `glpi_computers_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                             AND `glpi_computers`.`is_deleted` = '0'\n                             AND `glpi_computers`.`is_template` = '0'\n                             AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'";
     $number = 0;
     if ($result = $DB->query($query_number)) {
         $number = $DB->result($result, 0, 0);
     }
     echo "<div class='center'>";
     if ($canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'>";
         echo "<td>";
         Computer::dropdown(array('entity' => $license->fields['entities_id'], 'entity_sons' => $license->fields['is_recursive']));
         echo "</td>";
         echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     }
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No item found') . "</th></tr>";
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     Html::printAjaxPager(__('Affected computers'), $start, $number);
     $query = "SELECT `glpi_computers_softwarelicenses`.*,\n                       `glpi_computers`.`name` AS compname,\n                       `glpi_computers`.`id` AS cID,\n                       `glpi_computers`.`serial`,\n                       `glpi_computers`.`otherserial`,\n                       `glpi_users`.`name` AS username,\n                       `glpi_users`.`id` AS userid,\n                       `glpi_users`.`realname` AS userrealname,\n                       `glpi_users`.`firstname` AS userfirstname,\n                       `glpi_softwarelicenses`.`name` AS license,\n                       `glpi_softwarelicenses`.`id` AS vID,\n                       `glpi_softwarelicenses`.`name` AS vername,\n                       `glpi_entities`.`completename` AS entity,\n                       `glpi_locations`.`completename` AS location,\n                       `glpi_states`.`name` AS state,\n                       `glpi_groups`.`name` AS groupe,\n                       `glpi_softwarelicenses`.`name` AS lname,\n                       `glpi_softwarelicenses`.`id` AS lID\n                FROM `glpi_computers_softwarelicenses`\n                INNER JOIN `glpi_softwarelicenses`\n                     ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                          = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_computers`\n                     ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n                LEFT JOIN `glpi_locations`\n                     ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n                LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n                LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n                WHERE (`glpi_softwarelicenses`.`id` = '{$searchID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                       AND `glpi_computers`.`is_deleted` = '0'\n                       AND `glpi_computers`.`is_template` = '0'\n                       AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'\n                ORDER BY {$sort} {$order}\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $rand = mt_rand();
     if ($result = $DB->query($query)) {
         if ($data = $DB->fetch_assoc($result)) {
             if ($canedit) {
                 $rand = mt_rand();
                 Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
                 $paramsma = array('num_displayed' => $_SESSION['glpilist_limit'], 'specific_actions' => array('move_license' => _x('button', 'Move'), 'delete' => _x('button', 'Delete permanently')));
                 // Options to update license
                 $paramsma['extraparams']['options']['move']['used'] = array($searchID);
                 $paramsma['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
                 Html::showMassiveActions(__CLASS__, $paramsma);
             }
             $soft = new Software();
             $soft->getFromDB($license->fields['softwares_id']);
             $showEntity = $license->isRecursive();
             $linkUser = Session::haveRight('user', 'r');
             $text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
             $text = sprintf(__('%1$s - %2$s'), $text, $data["vername"]);
             Session::initNavigateListItems('Computer', $text);
             $sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt='' title=''>";
             echo "<table class='tab_cadre_fixehov'><tr>";
             if ($canedit) {
                 echo "<th width='10'>";
                 Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
                 echo "</th>";
             }
             echo "<th>" . ($sort == "`compname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Name') . "</a></th>";
             if ($showEntity) {
                 echo "<th>" . (strstr($sort, "entity") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=entity,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Entity') . "</a></th>";
             }
             echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Serial number') . "</a></th>";
             echo "<th>" . ($sort == "`otherserial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=otherserial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Inventory number') . "</a></th>";
             echo "<th>" . (strstr($sort, "`location`") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=location,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Location') . "</a></th>";
             echo "<th>" . (strstr($sort, "state") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=state,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Status') . "</a></th>";
             echo "<th>" . (strstr($sort, "groupe") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=groupe,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Group') . "</a></th>";
             echo "<th>" . (strstr($sort, "username") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=username,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('User') . "</a></th>";
             echo "</tr>\n";
             do {
                 Session::addToNavigateListItems('Computer', $data["cID"]);
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 $compname = $data['compname'];
                 if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
                     $compname = sprintf(__('%1$s (%2$s)'), $compname, $data['cID']);
                 }
                 if ($canshowcomputer) {
                     echo "<td><a href='computer.form.php?id=" . $data['cID'] . "'>{$compname}</a></td>";
                 } else {
                     echo "<td>" . $compname . "</td>";
                 }
                 if ($showEntity) {
                     echo "<td>" . $data['entity'] . "</td>";
                 }
                 echo "<td>" . $data['serial'] . "</td>";
                 echo "<td>" . $data['otherserial'] . "</td>";
                 echo "<td>" . $data['location'] . "</td>";
                 echo "<td>" . $data['state'] . "</td>";
                 echo "<td>" . $data['groupe'] . "</td>";
                 echo "<td>" . formatUserName($data['userid'], $data['username'], $data['userrealname'], $data['userfirstname'], $linkUser) . "</td>";
                 echo "</tr>\n";
             } while ($data = $DB->fetch_assoc($result));
             echo "</table>\n";
             if ($canedit) {
                 $paramsma['ontop'] = false;
                 Html::showMassiveActions(__CLASS__, $paramsma);
                 Html::closeForm();
             }
         } else {
             // Not found
             _e('No item found');
         }
     }
     // Query
     Html::printAjaxPager(__('Affected computers'), $start, $number);
     echo "</div>\n";
 }
 static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']);
     echo "<table class='tab_cadrehov package_item_list' id='table_action_{$rand}'>";
     $i = 0;
     foreach ($datas['jobs']['actions'] as $action) {
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='control'>";
             Html::showCheckbox(array('name' => 'action_entries[]'));
             echo "</td>";
         }
         $keys = array_keys($action);
         $action_type = array_shift($keys);
         echo "<td>";
         echo "<a class='edit' " . "onclick=\"edit_subtype('action', {$order->fields['id']}, {$rand}, this)\">";
         echo PluginFusioninventoryDeployAction::getType($action_type);
         echo "</a><br />";
         foreach ($action[$action_type] as $key => $value) {
             if (is_array($value)) {
                 if ($key === "list") {
                     foreach ($value as $list) {
                         echo $list;
                         echo " ";
                     }
                 }
             } else {
                 echo "<b>";
                 if ($key == 'exec') {
                     echo __('Command to execute', 'fusioninventory');
                 } else {
                     echo $key;
                 }
                 echo "</b>";
                 if ($key === "exec") {
                     echo "<pre style='border-left:solid lightgrey 3px;margin-left: 5px;" . "padding-left:2px'>{$value}</pre>";
                 } else {
                     echo " {$value} ";
                 }
             }
         }
         if (isset($action[$action_type]['retChecks'])) {
             echo "<br><b>" . __("return codes saved for this command", 'fusioninventory') . "</b> : <ul class='retChecks'>";
             foreach ($action[$action_type]['retChecks'] as $retCheck) {
                 echo "<li>";
                 $retchecks_entries = self::retchecks_entries();
                 echo $retchecks_entries[$retCheck['type']] . " " . array_shift($retCheck['values']);
                 echo "</li>";
             }
             echo "</ul>";
         }
         echo "</td>";
         echo "</td>";
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         }
         echo "</tr>";
         $i++;
     }
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "<tr><th>";
         Html::checkAllAsCheckbox("actionsList{$rand}", mt_rand());
         echo "</th><th colspan='3' class='mark'></th></tr>";
     }
     echo "</table>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>";
         echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>";
     }
 }
示例#20
0
 /**
  * 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 (!Session::haveRight("cartridge", "r")) {
         return false;
     }
     $canedit = Session::haveRight("cartridge", "w");
     $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                FROM `glpi_cartridges`,\n                     `glpi_cartridgeitems`\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;
         if (CartridgeItem::dropdownForPrinter($printer)) {
             $installok = true;
         } else {
             _e('No cartridge available');
         }
         echo "</td><td><input type='submit' name='install' value=\"" . _sx('button', 'Install') . "\"\n                         " . ($installok ? '' : 'disabled') . " class='submit'>";
         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('uninstall' => __('End of life'));
         } else {
             $actions = array('updatepages' => __('Update printer counter'), 'delete' => _x('button', 'Delete permanently'));
         }
         $paramsma = array('num_displayed' => $number, 'specific_actions' => $actions, 'rand' => $rand, 'extraparams' => array('maxpages' => $printer->fields['last_pages_counter']));
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     echo "<table class='tab_cadre_fixehov'>";
     if ($old == 0) {
         echo "<tr><th colspan='" . ($canedit ? '5' : '4') . "'>" . __('Used cartridges') . "</th></tr>";
     } else {
         echo "<tr><th colspan='" . ($canedit ? '8' : '7') . "'>" . __('Worn cartridges') . "</th></tr>";
     }
     echo "<tr>";
     if ($canedit) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('ID') . "</th><th>" . _n('Cartridge model', 'Cartridge models', 1) . "</th>";
     echo "<th>" . __('Add date') . "</th>";
     echo "<th>" . __('Use date') . "</th>";
     if ($old != 0) {
         echo "<th>" . __('End date') . "</th>";
         echo "<th>" . __('Printer counter') . "</th>";
         echo "<th>" . __('Printed pages') . "</th>";
     }
     echo "</tr>";
     $stock_time = 0;
     $use_time = 0;
     $pages_printed = 0;
     $nb_pages_printed = 0;
     while ($data = $DB->fetch_assoc($result)) {
         $cart_id = $data["id"];
         $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}>" . $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) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>\n\n";
 }
示例#21
0
 /** Show LDAP users to add or synchronise
  *
  * @return  nothing
  **/
 static function showLdapUsers()
 {
     global $CFG_GLPI;
     $values['order'] = 'DESC';
     $values['start'] = 0;
     foreach ($_SESSION['ldap_import'] as $option => $value) {
         $values[$option] = $value;
     }
     $rand = mt_rand();
     $results = array();
     $limitexceeded = false;
     $ldap_users = self::getAllUsers($values, $results, $limitexceeded);
     if (is_array($ldap_users)) {
         $numrows = count($ldap_users);
         if ($numrows > 0) {
             self::displaySizeLimitWarning($limitexceeded);
             Html::printPager($values['start'], $numrows, $_SERVER['PHP_SELF'], '');
             // delete end
             array_splice($ldap_users, $values['start'] + $_SESSION['glpilist_limit']);
             // delete begin
             if ($values['start'] > 0) {
                 array_splice($ldap_users, 0, $values['start']);
             }
             $form_action = '';
             $textbutton = '';
             if ($_SESSION['ldap_import']['mode']) {
                 $textbutton = _x('button', 'Synchronize');
                 $form_action = __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'sync';
             } else {
                 $textbutton = _x('button', 'Import');
                 $form_action = __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'import';
             }
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => min(count($ldap_users), $_SESSION['glpilist_limit']), 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array($form_action => $textbutton));
             Html::showMassiveActions($massiveactionparams);
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
             $num = 0;
             echo Search::showHeaderItem(Search::HTML_OUTPUT, _n('User', 'Users', Session::getPluralNumber()), $num, $_SERVER['PHP_SELF'] . "?order=" . ($values['order'] == "DESC" ? "ASC" : "DESC"));
             echo "<th>" . __('Last update in the LDAP directory') . "</th>";
             if ($_SESSION['ldap_import']['mode']) {
                 echo "<th>" . __('Last update in GLPI') . "</th>";
             }
             echo "</tr>";
             foreach ($ldap_users as $userinfos) {
                 $link = $user = $userinfos["user"];
                 if (isset($userinfos['id']) && User::canView()) {
                     $link = "<a href='" . Toolbox::getItemTypeFormURL('User') . '?id=' . $userinfos['id'] . "'>{$user}</a>";
                 }
                 if (isset($userinfos["timestamp"])) {
                     $stamp = $userinfos["timestamp"];
                 } else {
                     $stamp = '';
                 }
                 if (isset($userinfos["date_sync"])) {
                     $date_sync = $userinfos["date_sync"];
                 } else {
                     $date_sync = '';
                 }
                 echo "<tr class='tab_bg_2 center'>";
                 //Need to use " instead of ' because it doesn't work with names with ' inside !
                 echo "<td>";
                 echo Html::getMassiveActionCheckBox(__CLASS__, $user);
                 //echo "<input type='checkbox' name=\"item[" . $user . "]\" value='1'>";
                 echo "</td>";
                 echo "<td>" . $link . "</td>";
                 if ($stamp != '') {
                     echo "<td>" . Html::convDateTime(date("Y-m-d H:i:s", $stamp)) . "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($_SESSION['ldap_import']['mode']) {
                     if ($date_sync != '') {
                         echo "<td>" . Html::convDateTime($date_sync) . "</td>";
                     } else {
                         echo "<td>&nbsp;</td>";
                     }
                 }
                 echo "</tr>";
             }
             echo "<tr>";
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
             $num = 0;
             echo Search::showHeaderItem(Search::HTML_OUTPUT, _n('User', 'Users', Session::getPluralNumber()), $num, $_SERVER['PHP_SELF'] . "?order=" . ($values['order'] == "DESC" ? "ASC" : "DESC"));
             echo "<th>" . __('Last update in the LDAP directory') . "</th>";
             if ($_SESSION['ldap_import']['mode']) {
                 echo "<th>" . __('Last update in GLPI') . "</th>";
             }
             echo "</tr>";
             echo "</table>";
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
             Html::printPager($values['start'], $numrows, $_SERVER['PHP_SELF'], '');
         } else {
             echo "<div class='center b'>" . ($_SESSION['ldap_import']['mode'] ? __('No user to be synchronized') : __('No user to be imported')) . "</div>";
         }
     } else {
         echo "<div class='center b'>" . ($_SESSION['ldap_import']['mode'] ? __('No user to be synchronized') : __('No user to be imported')) . "</div>";
     }
 }
 /**
  * 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;
 }
示例#23
0
 /**
  * Show visibility config for a reminder
  **/
 function showVisibility()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->fields['id'];
     $canedit = Session::haveRight('reminder_public', 'w');
     echo "<div class='center'>";
     $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='remindervisibility_form{$rand}' id='remindervisibility_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('Reminder') . "'>";
         echo "<input type='hidden' name='reminders_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_2'><td width='100px'>";
         $types = array('Entity', 'Group', 'Profile', 'User');
         $addrand = Dropdown::showItemTypes('_type', $types);
         $params = array('type' => '__VALUE__', 'right' => 'reminder_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);
         $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('deletevisibility' => _x('button', 'Delete permanently')));
         if ($this->fields['users_id'] != Session::getLoginUserID()) {
             $paramsma['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         }
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $nb) {
         echo "<th width='10'>";
         echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . _n('Recipient', 'Recipients', 2) . "</th>";
     echo "</tr>";
     // Users
     if (count($this->users)) {
         foreach ($this->users as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Reminder_User][" . $data["id"] . "]'\n                          value='1' >";
                     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_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Group_Reminder][" . $data["id"] . "]'\n                         value='1'>";
                     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
                         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_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Entity_Reminder][" . $data["id"] . "]'\n                          value='1'>";
                     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_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Profile_Reminder][" . $data["id"] . "]'\n                         value='1'>";
                     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"], $entname);
                 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>";
             }
         }
     }
     echo "</table>";
     if ($canedit && $nb) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
示例#24
0
 /**
  * Display form to unlock fields and links
  *
  * @param CommonDBTM $item the source item
  **/
 static function showForItem(CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getID();
     $itemtype = $item->getType();
     $header = false;
     //If user doesn't have write right on the item, lock form must not be displayed
     if (!$item->canCreate()) {
         return false;
     }
     echo "<div width='50%'>";
     echo "<form method='post' id='lock_form'\n             name='lock_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<input type='hidden' name='id' value='{$ID}'>\n";
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2''>" . __('Locked items') . "</th></tr>";
     //Use a hook to allow external inventory tools to manage per field lock
     $results = Plugin::doHookFunction('display_locked_fields', array('item' => $item, 'header' => $header));
     $header |= $results['header'];
     //Special locks for computers only
     if ($itemtype == 'Computer') {
         //Locks for items recorded in glpi_computers_items table
         $types = array('Monitor', 'Peripheral', 'Printer');
         foreach ($types as $type) {
             $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID, 'itemtype' => $type);
             $params['FIELDS'] = array('id', 'items_id');
             $first = true;
             foreach ($DB->request('glpi_computers_items', $params) as $line) {
                 $tmp = new $type();
                 $tmp->getFromDB($line['items_id']);
                 $header = true;
                 if ($first) {
                     echo "<tr><th colspan='2'>" . $type::getTypeName(Session::getPluralNumber()) . "</th></tr>\n";
                     $first = false;
                 }
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='Computer_Item[" . $line['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>" . $tmp->getName() . "</td>";
                 echo "</tr>\n";
             }
         }
         $types = array('ComputerDisk', 'ComputerVirtualMachine');
         foreach ($types as $type) {
             $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
             $params['FIELDS'] = array('id', 'name');
             $first = true;
             foreach ($DB->request(getTableForItemType($type), $params) as $line) {
                 $header = true;
                 if ($first) {
                     echo "<tr><th colspan='2'>" . $type::getTypeName(Session::getPluralNumber()) . "</th></tr>\n";
                     $first = false;
                 }
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='" . $type . "[" . $line['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>" . $line['name'] . "</td>";
                 echo "</tr>\n";
             }
         }
         //Software versions
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwareversions` AS csv\n                    LEFT JOIN `glpi_softwareversions` AS sv\n                       ON (`csv`.`softwareversions_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . Software::getTypeName(Session::getPluralNumber()) . "</th></tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareVersion[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
         //Software licenses
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwarelicenses` AS csv\n                    LEFT JOIN `glpi_softwarelicenses` AS sv\n                       ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(Session::getPluralNumber()) . "</th>" . "</tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
     }
     $first = true;
     $item = new NetworkPort();
     $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
     $params['FIELDS'] = array('id');
     foreach ($DB->request('glpi_networkports', $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . NetworkPort::getTypeName(Session::getPluralNumber()) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='NetworkPort[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $first = true;
     $item = new NetworkName();
     $params = array('`glpi_networknames`.`is_dynamic`' => 1, '`glpi_networknames`.`is_deleted`' => 1, '`glpi_networknames`.`itemtype`' => 'NetworkPort', '`glpi_networknames`.`items_id`' => '`glpi_networkports`.`id`', '`glpi_networkports`.`items_id`' => $ID, '`glpi_networkports`.`itemtype`' => $itemtype);
     $params['FIELDS'] = array('glpi_networknames' => 'id');
     foreach ($DB->request(array('glpi_networknames', 'glpi_networkports'), $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . NetworkName::getTypeName(Session::getPluralNumber()) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='NetworkName[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $first = true;
     $item = new IPAddress();
     $params = array('`glpi_ipaddresses`.`is_dynamic`' => 1, '`glpi_ipaddresses`.`is_deleted`' => 1, '`glpi_ipaddresses`.`itemtype`' => 'Networkname', '`glpi_ipaddresses`.`items_id`' => '`glpi_networknames`.`id`', '`glpi_networknames`.`itemtype`' => 'NetworkPort', '`glpi_networknames`.`items_id`' => '`glpi_networkports`.`id`', '`glpi_networkports`.`items_id`' => $ID, '`glpi_networkports`.`itemtype`' => $itemtype);
     $params['FIELDS'] = array('glpi_ipaddresses' => 'id');
     foreach ($DB->request(array('glpi_ipaddresses', 'glpi_networknames', 'glpi_networkports'), $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . IPAddress::getTypeName(Session::getPluralNumber()) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='IPAddress[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $types = Item_Devices::getDeviceTypes();
     $nb = 0;
     foreach ($types as $old => $type) {
         $nb += countElementsInTable(getTableForItemType($type), "`items_id`='{$ID}'\n                                         AND `itemtype`='{$itemtype}'\n                                         AND `is_dynamic`='1'\n                                         AND `is_deleted`='1'");
     }
     if ($nb) {
         $header = true;
         echo "<tr><th colspan='2'>" . _n('Component', 'Components', Session::getPluralNumber()) . "</th></tr>\n";
         foreach ($types as $old => $type) {
             $associated_type = str_replace('Item_', '', $type);
             $associated_table = getTableForItemType($associated_type);
             $fk = getForeignKeyFieldForTable($associated_table);
             $query = "SELECT `i`.`id`,\n                             `t`.`designation` AS `name`\n                      FROM `" . getTableForItemType($type) . "` AS i\n                      LEFT JOIN `{$associated_table}` AS t\n                         ON (`t`.`id` = `i`.`{$fk}`)\n                      WHERE `itemtype` = '{$itemtype}'\n                            AND `items_id` = '{$ID}'\n                            AND `is_dynamic` = '1'\n                            AND `is_deleted` = '1'";
             foreach ($DB->request($query) as $data) {
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='" . $type . "[" . $data['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>";
                 printf(__('%1$s: %2$s'), $associated_type::getTypeName(), $data['name']);
                 echo "</td></tr>\n";
             }
         }
     }
     if ($header) {
         echo "<tr><th>";
         Html::checkAllAsCheckbox('lock_form');
         echo "</th><th>&nbsp</th></tr>\n";
         echo "</table>";
         Html::openArrowMassives('lock_form', true);
         Html::closeArrowMassives(array('unlock' => _sx('button', 'Unlock')));
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>" . __('No locked item') . "</td></tr>";
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>\n";
 }
 static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']);
     $o_file = new self();
     // compute short shas to find the corresponding entries in database
     $short_shas = array();
     foreach ($datas['jobs']['associatedFiles'] as $sha512) {
         $short_shas[] = "'" . substr($sha512, 0, 6) . "'";
     }
     // find corresponding file entries
     $files = $o_file->find("shortsha512 IN (" . implode(",", $short_shas) . ")");
     // do a quick mapping between database id and short shas
     $files_mapping = array();
     foreach ($files as $f) {
         $files_mapping[$f['shortsha512']] = $f['id'];
     }
     echo "<table class='tab_cadrehov package_item_list' id='table_file_{$rand}'>";
     $i = 0;
     foreach ($datas['jobs']['associatedFiles'] as $sha512) {
         $short_sha = substr($sha512, 0, 6);
         $fileregistry_error = 0;
         // check if the files is registered in database
         if (!array_key_exists($short_sha, $files_mapping)) {
             $fileregistry_error |= self::REGISTRY_NO_DB_ENTRY;
         }
         if (!$o_file->checkPresenceManifest($sha512)) {
             $fileregistry_error |= self::REGISTRY_NO_MANIFEST;
         }
         // get database entries
         if (!$fileregistry_error) {
             $file_id = $files_mapping[$short_sha];
             // get file's name
             $file_name = $files[$file_id]['name'];
             // get file's size
             $file_size = $files[$file_id]['filesize'];
             //mimetype icon
             if (isset($files[$file_id]['mimetype'])) {
                 $file_mimetype = str_replace('/', '__', $files[$file_id]['mimetype']);
             } else {
                 $file_mimetype = NULL;
             }
         } else {
             // get file's name from what has been saved in json
             $file_name = $datas['associatedFiles'][$sha512]['name'];
             $file_size = NULL;
             $file_mimetype = NULL;
         }
         $file_uncompress = $datas['associatedFiles'][$sha512]['uncompress'];
         $file_p2p = $datas['associatedFiles'][$sha512]['p2p'];
         $file_p2p_retention_duration = $datas['associatedFiles'][$sha512]['p2p-retention-duration'];
         // start new line
         $pics_path = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/";
         echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2);
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='control'>";
             Html::showCheckbox(array('name' => 'file_entries[]', 'value' => 0));
             echo "</td>";
         }
         echo "<td class='filename'>";
         if (!empty($file_mimetype) && file_exists(GLPI_ROOT . "/plugins/fusioninventory/pics/ext/extensions/{$file_mimetype}.png")) {
             echo "<img src='" . $pics_path . "ext/extensions/{$file_mimetype}.png' />";
         } else {
             echo "<img src='" . $pics_path . "ext/extensions/documents.png' />";
         }
         //filename
         echo "&nbsp;" . "<a class='edit' " . "  onclick=\"edit_subtype(" . "   'file', {$order->fields['id']}, {$rand}, this " . "  )\"" . ">{$file_name}</a>";
         //p2p icon
         if (isset($file_p2p) && $file_p2p != 0) {
             echo "<a title='" . __('p2p', 'fusioninventory') . ", " . __("retention", 'fusioninventory') . " : " . $file_p2p_retention_duration . " " . __("days", 'fusioninventory') . "' class='more'>";
             echo "<img src='" . $pics_path . "p2p.png' />";
             echo "<sup>" . $file_p2p_retention_duration . "</sup>";
             echo "</a>";
         }
         //uncompress icon
         if (isset($file_uncompress) && $file_uncompress != 0) {
             echo "<a title='" . __('uncompress', 'fusioninventory') . "' class='more'><img src='" . $pics_path . "uncompress.png' /></a>";
         }
         //sha fingerprint
         $sha_status = "good";
         if ($fileregistry_error != 0) {
             $sha_status = "bad";
         }
         echo "<div class='fingerprint'>";
         echo "<div class='fingerprint_" . $sha_status . "'>" . $sha512;
         if ($fileregistry_error & self::REGISTRY_NO_DB_ENTRY) {
             echo "<div class='fingerprint_badmsg'>" . __("This file is not correctly registered in database.") . "<br/>" . __("You can fix it by uploading or selecting the good one.");
             echo "</div>";
         }
         if ($fileregistry_error & self::REGISTRY_NO_MANIFEST) {
             echo "<div class='fingerprint_badmsg'>" . __("This file doesn't have any manifest file associated.") . "<br/>" . __("You must upload the file.");
             echo "</div>";
         }
         echo "</div>";
         echo "</div>";
         //filesize
         if (!$fileregistry_error) {
             echo "<div class='size'>";
             echo __('Size') . ": " . self::processFilesize($file_size);
             echo "</div>";
         }
         echo "</td>";
         if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
             echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>";
         }
         $i++;
     }
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "<tr><th>";
         Html::checkAllAsCheckbox("filesList{$rand}", mt_rand());
         echo "</th><th colspan='3' class='mark'></th></tr>";
     }
     echo "</table>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         echo "&nbsp;&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>";
         echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>";
     }
 }
 /**
  * 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>";
 }
示例#27
0
 /**
  * Show the list of rules
  *
  * @param $target
  * @param $options   array
  *
  * @return nothing
  **/
 function showListRules($target, $options = array())
 {
     global $CFG_GLPI;
     $p['inherited'] = true;
     $p['childrens'] = false;
     $p['active'] = false;
     $rand = mt_rand();
     foreach (array('inherited', 'childrens') as $param) {
         if (isset($options[$param]) && $this->isRuleRecursive()) {
             $p[$param] = $options[$param];
         }
     }
     $rule = $this->getRuleClass();
     $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']);
     // Do not know what it is ?
     $canedit = Session::haveRight(static::$right, "w") && !$display_entities;
     $nb = $this->getCollectionSize($p['inherited']);
     $p['start'] = isset($options["start"]) ? $options["start"] : 0;
     if ($p['start'] >= $nb) {
         $p['start'] = 0;
     }
     $p['limit'] = $_SESSION['glpilist_limit'];
     $this->getCollectionPart($p);
     Html::printAjaxPager('', $p['start'], $nb);
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     echo "\n<div class='spaced'>";
     if ($canedit && $nb) {
         $massiveactionparams = array('num_displayed' => min($p['limit'], $nb), 'extraparams' => array('entity_restrict' => $this->entity));
         Html::showMassiveActions($this->getRuleClassName(), $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $colspan = 6;
     if ($display_entities) {
         $colspan++;
     }
     echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n";
     echo "<tr>";
     echo "<th>";
     if ($canedit) {
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
     }
     echo "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Description') . "</th>";
     echo "<th>" . __('Active') . "</th>";
     if ($display_entities) {
         echo "<th>" . __('Entity') . "</th>\n";
     }
     if (!$display_entities) {
         echo "<th colspan='2'>&nbsp;</th>";
     }
     echo "</tr>\n";
     if (count($this->RuleList->list)) {
         $ruletype = $this->RuleList->list[0]->getType();
         Session::initNavigateListItems($ruletype);
     }
     for ($i = $p['start'], $j = 0; isset($this->RuleList->list[$j]); $i++, $j++) {
         $this->RuleList->list[$j]->showMinimalForm($target, $i == 0, $i == $nb - 1, $display_entities);
         Session::addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']);
     }
     if ($nb) {
         echo "<tr>";
         echo "<th>";
         if ($canedit) {
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         }
         echo "</th>";
         echo "<th>" . __('Name') . "</th>";
         echo "<th>" . __('Description') . "</th>";
         echo "<th>" . __('Active') . "</th>";
         if ($display_entities) {
             echo "<th>" . __('Entity') . "</th>\n";
         }
         if (!$display_entities) {
             echo "<th colspan='2'>&nbsp;</th>";
         }
         echo "</tr>\n";
     }
     echo "</table>\n";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($this->getRuleClassName(), $massiveactionparams);
     }
     echo "</div>";
     Html::closeForm();
     Html::printAjaxPager('', $p['start'], $nb);
     echo "<div class='spaced center'>";
     if ($plugin = isPluginItemType($this->getType())) {
         $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']);
     } else {
         $url = $CFG_GLPI["root_doc"];
     }
     echo "<a class='vsubmit' href='#' onClick=\"var w=window.open('" . $url . "/front/popup.php?popup=test_all_rules&amp;sub_type=" . $this->getRuleClassName() . "&amp' ,'glpipopup', 'height=400, width=1000, top=100, left=100, scrollbars=yes' );" . "w.focus();\">" . __('Test rules engine') . "</a></div>";
     if ($this->can_replay_rules) {
         echo "<div class='spaced center'>";
         echo "<a class='vsubmit' href='" . $rule->getSearchURL() . "?replay_rule=replay_rule'>" . __s('Replay the dictionary rules') . "</a>";
         echo "</div>";
     }
     echo "<div class='spaced'>";
     $this->showAdditionalInformationsInForm($target);
     echo "</div>";
 }
示例#28
-1
 /** 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);
             $paramsma = array('num_displayed' => min($_SESSION['glpilist_limit'], count($ldap_groups)), 'specific_actions' => array('import_group' => _sx('button', 'Import')));
             Html::showMassiveActions(__CLASS__, $paramsma);
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             echo "<th width='10'>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             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>";
             foreach ($ldap_groups as $groupinfos) {
                 $group = $groupinfos["cn"];
                 $group_dn = $groupinfos["dn"];
                 $search_type = $groupinfos["search_type"];
                 echo "<tr class='tab_bg_2 center'>";
                 //Need to use " instead of ' because it doesn't work with names with ' inside !
                 echo "<td><input type='checkbox' name=\"item[" . $group_dn . "]\"></td>";
                 echo "<td>" . $group . "</td>";
                 echo "<td>" . $group_dn . "</td>";
                 echo "<td>";
                 Entity::dropdown(array('value' => $entity, 'name' => "ldap_import_entities[" . $group_dn . "]=" . $entity));
                 echo "</td>";
                 if (Session::isMultiEntitiesMode()) {
                     echo "<td>";
                     Dropdown::showYesNo("ldap_import_recursive[" . $group_dn . "]", 0);
                 } else {
                     echo "<td><input type='hidden' name=\"ldap_import_recursive[" . $group_dn . "]\"\n                             value='0'>";
                 }
                 echo "<input type='hidden' name=\"ldap_import_type[" . $group_dn . "]\" value=\"" . $search_type . "\"></td></tr>";
             }
             $paramsma['ontop'] = false;
             Html::showMassiveActions(__CLASS__, $paramsma);
             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>";
     }
 }