/** * Show a dropdown list to select the number of datas to show */ static function selectorLimit() { Dropdown::showListLimit(); }
/** * Display the list_limit combo choice * * @param $action page would be posted when change the value (URL + param) (default '') * * ajax Pager will be displayed if empty * * @return nothing (print a combo) **/ static function printPagerForm($action = "") { if ($action) { echo "<form method='POST' action=\"{$action}\">"; echo "<span class='responsive_hidden'>" . __('Display (number of items)') . "</span> "; Dropdown::showListLimit("submit()"); } else { echo "<form method='POST' action =''>\n"; echo "<span class='responsive_hidden'>" . __('Display (number of items)') . "</span> "; Dropdown::showListLimit("reloadTab(\"glpilist_limit=\"+this.value)"); } Html::closeForm(); }
/** * @param $item * @param $action **/ function menu($item, $action) { global $DB, $PLUGIN_HOOKS; $type = $item->getType(); // $ID set if current object, not set from preference if (isset($item->fields['id'])) { $ID = $item->fields['id']; } else { $ID = 0; $item->getEmpty(); } if (!isset($PLUGIN_HOOKS['plugin_pdf'][$type]) || !class_exists($PLUGIN_HOOKS['plugin_pdf'][$type])) { return; } $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($item); $options = $itempdf->defineAllTabs(); $formid = "plugin_pdf_{$type}_" . mt_rand(); echo "<form name='" . $formid . "' id='" . $formid . "' action='{$action}' method='post' " . ($ID ? "target='_blank'" : "") . "><table class='tab_cadre_fixe'>"; $landscape = false; $values = array(); $sql = "SELECT `tabref`\n FROM `" . $this->getTable() . "`\n WHERE `users_ID` = '" . $_SESSION['glpiID'] . "'\n AND `itemtype` = '{$type}'"; foreach ($DB->request($sql) as $data) { if ($data["tabref"] == 'landscape') { $landscape = true; } else { $values[$data["tabref"]] = $data["tabref"]; } } // Always export, at least, main part. if (!count($values) && isset($options['_main_'])) { $values['_main_'] = 1; } echo "<tr><th colspan='6'>" . sprintf(__('%1$s: %2$s'), __('Choose the tables to print in pdf', 'pdf'), $item->getTypeName()); echo "</th></tr>"; $i = 0; foreach ($options as $num => $title) { if (!$i) { echo "<tr class='tab_bg_1'>"; } if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { $title = "{$title} ({$num})"; } $this->checkbox($num, $title, isset($values[$num]) ? true : false); if ($i == 4) { echo "</tr>"; $i = 0; } else { $i++; } } if ($i) { while ($i <= 4) { echo "<td width='20%'> </td>"; $i++; } echo "</tr>"; } echo "<tr class='tab_bg_2'><td colspan='2' class='left'>"; echo "<a onclick=\"if (markCheckboxes('" . $formid . "') ) return false;\" href='" . $_SERVER['PHP_SELF'] . "?select=all'>" . __('Check all') . "</a> / "; echo "<a onclick=\"if (unMarkCheckboxes('" . $formid . "') ) return false;\" href='" . $_SERVER['PHP_SELF'] . "?select=none'>" . __('Uncheck all') . "</a></td>"; echo "<td colspan='4' class='center'>"; echo "<input type='hidden' name='plugin_pdf_inventory_type' value='" . $type . "'>"; echo "<input type='hidden' name='indice' value='" . count($options) . "'>"; if ($ID) { printf(__('Display %d items', 'pdf'), Dropdown::showListLimit()); } echo "<select name='page'>\n"; echo "<option value='0'>" . __('Portrait', 'pdf') . "</option>\n"; // Portrait echo "<option value='1'" . ($landscape ? "selected='selected'" : '') . ">" . __('Landscape', 'pdf') . "</option>\n"; // Paysage echo "</select> \n"; if ($ID) { echo "<input type='hidden' name='itemID' value='" . $ID . "'>"; echo "<input type='submit' value='" . _sx('button', 'Print', 'pdf') . "' name='generate' class='submit'></td></tr>"; } else { echo "<input type='submit' value='" . _sx('button', 'Save') . "' name='plugin_pdf_user_preferences_save' class='submit'></td></tr>"; } echo "</table>"; Html::closeForm(); }