本文整理汇总了PHP中getEntitiesRestrictRequest函数的典型用法代码示例。如果您正苦于以下问题:PHP getEntitiesRestrictRequest函数的具体用法?PHP getEntitiesRestrictRequest怎么用?PHP getEntitiesRestrictRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getEntitiesRestrictRequest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getSqlSubRequest
function getSqlSubRequest($itemtype, $loc, $obj)
{
$table = getTableForItemType($itemtype);
$models_id = getForeignKeyFieldForTable(getTableForItemType($itemtype . 'Model'));
$types_id = getForeignKeyFieldForTable(getTableForItemType($itemtype . 'Type'));
$fields = array('name' => 'name', 'serial' => 'serial', 'otherserial' => 'otherserial', $models_id => 'models_id', $types_id => 'types_id');
$query_where = "SELECT '{$itemtype}' AS itemtype,\n `{$table}`.`id` AS items_id,\n `{$table}`.`locations_id`";
foreach ($fields as $field => $alias) {
if ($obj->isField($field)) {
$query_where .= ", `{$table}`.`{$field}` AS {$alias}";
} else {
$query_where .= ", '' AS {$alias}";
}
}
$query_where .= " FROM `{$table}` ";
if ($obj->isEntityAssign()) {
$query_where .= getEntitiesRestrictRequest('WHERE', "{$table}");
} else {
$query_where .= 'WHERE 1';
}
if ($obj->maybeTemplate()) {
$query_where .= " AND `is_template`='0'";
}
if ($obj->maybeDeleted()) {
$query_where .= " AND `is_deleted`='0'";
}
$query_where .= $loc->getSqlCriteriasRestriction();
return $query_where;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:29,代码来源:listequipmentbylocation.php
示例2: pdfForSoftware
static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $software, $infocom = false)
{
global $DB;
$sID = $software->getField('id');
$license = new SoftwareLicense();
$query = "SELECT `id`\n FROM `glpi_softwarelicenses`\n WHERE `softwares_id` = '" . $sID . "' " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true) . "\n ORDER BY `name`";
$pdf->setColumnsSize(100);
$pdf->displayTitle('<b>' . _n('License', 'Licenses', 2) . '</b>');
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
for ($tot = 0; $data = $DB->fetch_assoc($result);) {
if ($license->getFromDB($data['id'])) {
self::pdfMain($pdf, $license, false);
if ($infocom) {
PluginPdfInfocom::pdfForItem($pdf, $license);
}
}
}
} else {
$pdf->displayLine(__('No item found'));
}
} else {
$pdf->displayLine(__('No item found'));
}
$pdf->displaySpace();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:26,代码来源:softwarelicense.class.php
示例3: plugin_init_formcreator
/**
* Initialize all classes and generic variables of the plugin
*/
function plugin_init_formcreator()
{
global $PLUGIN_HOOKS;
// Set the plugin CSRF compliance (required since GLPI 0.84)
$PLUGIN_HOOKS['csrf_compliant']['formcreator'] = true;
$plugin = new Plugin();
if (isset($_SESSION['glpiID']) && $plugin->isInstalled('formcreator') && $plugin->isActivated('formcreator')) {
// Massive Action definition
$PLUGIN_HOOKS['use_massive_action']['formcreator'] = 1;
// If user have acces to one form or more, add link
$form_table = getTableForItemType('PluginFormcreatorForm');
$table_fp = getTableForItemType('PluginFormcreatorFormprofiles');
$where = getEntitiesRestrictRequest("", $form_table, "", "", true, false);
$query = "SELECT COUNT({$form_table}.id)\n FROM {$form_table}\n WHERE {$form_table}.`is_active` = 1\n AND {$form_table}.`is_deleted` = 0\n AND {$form_table}.`helpdesk_home` = 1\n AND ({$form_table}.`language` = '{$_SESSION['glpilanguage']}' OR {$form_table}.`language` = '')\n AND {$where}\n AND ({$form_table}.`access_rights` != " . PluginFormcreatorForm::ACCESS_RESTRICTED . " OR {$form_table}.`id` IN (\n SELECT plugin_formcreator_forms_id\n FROM {$table_fp}\n WHERE plugin_formcreator_profiles_id = " . (int) $_SESSION['glpiactiveprofile']['id'] . "))";
$result = $GLOBALS['DB']->query($query);
list($nb) = $GLOBALS['DB']->fetch_array($result);
if ($nb > 0) {
$PLUGIN_HOOKS['menu_toadd']['formcreator']['helpdesk'] = 'PluginFormcreatorFormlist';
}
if (strpos($_SERVER['REQUEST_URI'], "plugins/formcreator") !== false || strpos($_SERVER['REQUEST_URI'], "central.php") !== false || isset($_SESSION['glpiactiveprofile']) && $_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
// Add specific CSS
$PLUGIN_HOOKS['add_css']['formcreator'][] = "css/styles.css";
$PLUGIN_HOOKS['add_css']['formcreator'][] = 'lib/pqselect/pqselect.min.css';
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'lib/pqselect/pqselect.min.js';
// Add specific JavaScript
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/forms-validation.js.php';
$PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/scripts.js.php';
}
// Add a link in the main menu plugins for technician and admin panel
$PLUGIN_HOOKS['menu_entry']['formcreator'] = 'front/formlist.php';
// Config page
$plugin = new Plugin();
$links = array();
if (Session::haveRight('entity', UPDATE)) {
$PLUGIN_HOOKS['config_page']['formcreator'] = 'front/form.php';
$PLUGIN_HOOKS['menu_toadd']['formcreator']['admin'] = 'PluginFormcreatorForm';
$links['config'] = '/plugins/formcreator/front/form.php';
$links['add'] = '/plugins/formcreator/front/form.form.php';
}
$img = '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/pics/check.png"
title="' . __('Forms waiting for validation', 'formcreator') . '" alt="Waiting forms list" />';
$links[$img] = '/plugins/formcreator/front/formanswer.php';
// Set options for pages (title, links, buttons...)
$links['search'] = '/plugins/formcreator/front/formlist.php';
$PLUGIN_HOOKS['submenu_entry']['formcreator']['options'] = array('config' => array('title' => __('Setup'), 'page' => '/plugins/formcreator/front/form.php', 'links' => $links), 'options' => array('title' => _n('Form', 'Forms', 2, 'formcreator'), 'links' => $links));
// Load field class and all its method to manage fields
Plugin::registerClass('PluginFormcreatorFields');
// Notification
Plugin::registerClass('PluginFormcreatorFormanswer', array('notificationtemplates_types' => true));
if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE && isset($_SESSION['glpimenu'])) {
unset($_SESSION['glpimenu']);
}
}
}
开发者ID:jcr0ch4,项目名称:formcreator,代码行数:57,代码来源:setup.php
示例4: listTemplates
function listTemplates($itemtype, $target, $add = 0)
{
global $DB, $CFG_GLPI, $LANG;
if (!class_exists($itemtype)) {
return false;
}
$item = new $itemtype();
//Check is user have minimum right r
if (!$item->canView() && !$item->canCreate()) {
return false;
}
$query = "SELECT * FROM `" . $item->getTable() . "`\n WHERE `is_template` = '1' ";
if ($item->isEntityAssign()) {
$query .= getEntitiesRestrictRequest('AND', $item->getTable(), 'entities_id', $_SESSION['glpiactive_entity'], $item->maybeRecursive());
}
$query .= " ORDER by `template_name`";
if ($result = $DB->query($query)) {
echo "<div class='center'><table class='tab_cadre' width='50%'>";
if ($add) {
echo "<tr><th>" . $LANG['common'][7] . " - " . $item->getTypeName() . " :</th></tr>";
echo "<tr><td class='tab_bg_1 center'>";
echo "<a href=\"{$target}?id=-1&withtemplate=2\"> " . $LANG['common'][31] . " </a></td>";
echo "</tr>";
} else {
echo "<tr><th colspan='2'>" . $LANG['common'][14] . " - " . $item->getTypeName() . " :</th></tr>";
}
while ($data = $DB->fetch_array($result)) {
$templname = $data["template_name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["template_name"])) {
$templname .= "(" . $data["id"] . ")";
}
echo "<tr><td class='tab_bg_1 center'>";
if ($item->canCreate() && !$add) {
echo "<a href=\"{$target}?id=" . $data["id"] . "&withtemplate=1\">";
echo " {$templname} </a></td>";
echo "<td class='tab_bg_2 center b'>";
echo "<a href=\"{$target}?id=" . $data["id"] . "&purge=purge&withtemplate=1\">" . $LANG['buttons'][6] . "</a></td>";
} else {
echo "<a href=\"{$target}?id=" . $data["id"] . "&withtemplate=2\">";
echo " {$templname} </a></td>";
}
echo "</tr>";
}
if ($item->canCreate() && !$add) {
echo "<tr><td colspan='2' class='tab_bg_2 center b'>";
echo "<a href=\"{$target}?withtemplate=1\">" . $LANG['common'][9] . "</a>";
echo "</td></tr>";
}
echo "</table></div>\n";
}
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:51,代码来源:setup.function.php
示例5: displayTabContentForItem
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
$header = new self();
$found = $header->find('entities_id = ' . $_SESSION['glpiactive_entity']);
if (count($found) > 0) {
echo '<div class="tab_cadre_pager" style="padding: 2px; margin: 5px 0">
<h3 class="tab_bg_2" style="padding: 5px">
<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add_off.png" alt="+" align="absmiddle" />
' . __('Add an header', 'formcreator') . '<br /><br />
<em><i><img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/warning.png" alt="/!\\" align="absmiddle" height="16" />
' . __('An header already exists for this entity! You can have only one header per entity.', 'formcreator') . '</i></em>
</h3>
</div>';
} else {
$table = getTableForItemType('PluginFormcreatorHeader');
$where = getEntitiesRestrictRequest("", $table, "", "", true, false);
$found = $header->find($where);
if (count($found) > 0) {
echo '<div class="tab_cadre_pager" style="padding: 2px; margin: 5px 0">
<h3 class="tab_bg_2" style="padding: 5px">
<a href="' . Toolbox::getItemTypeFormURL(__CLASS__) . '" class="submit">
<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" />
' . __('Add an header', 'formcreator') . '
</a><br /><br />
<em><i><img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/warning.png" alt="/!\\" align="absmiddle" height="16" />
' . __('An header exists for a parent entity! Another header will overwrite the previous one.', 'formcreator') . '</i></em>
</h3>
</div>';
} else {
echo '<div class="tab_cadre_pager" style="padding: 2px; margin: 5px 0">
<h3 class="tab_bg_2" style="padding: 5px">
<a href="' . Toolbox::getItemTypeFormURL(__CLASS__) . '" class="submit">
<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" />
' . __('Add an header', 'formcreator') . '
</a>
</h3>
</div>';
}
}
$params['sort'] = !empty($_POST['sort']) ? (int) $_POST['sort'] : 0;
$params['order'] = !empty($_POST['order']) && in_array($_POST['order'], array('ASC', 'DESC')) ? $_POST['order'] : 'ASC';
$params['start'] = !empty($_POST['start']) ? (int) $_POST['start'] : 0;
Search::manageGetValues(__CLASS__);
//Search::showGenericSearch(__CLASS__, $_GET);
Search::showList(__CLASS__, $params);
}
开发者ID:jcr0ch4,项目名称:formcreator,代码行数:46,代码来源:header.class.php
示例6: getUserGroup
private static function getUserGroup($entity, $userid, $filter = '', $first = true)
{
global $DB;
$query = "SELECT glpi_groups.id\n FROM glpi_groups_users\n INNER JOIN glpi_groups ON (glpi_groups.id = glpi_groups_users.groups_id)\n WHERE glpi_groups_users.users_id='{$userid}'" . getEntitiesRestrictRequest(' AND ', 'glpi_groups', '', $entity, true, true);
if ($filter) {
$query .= "AND ({$filter})";
}
$query .= " ORDER BY glpi_groups_users.id";
$rep = array();
foreach ($DB->request($query) as $data) {
if ($first) {
return $data['id'];
}
$rep[] = $data['id'];
}
return $first ? 0 : array_pop($rep);
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:17,代码来源:user.class.php
示例7: getUserGroup
private static function getUserGroup($entity, $userid, $filter = '', $first = true)
{
global $DB;
$config = PluginBehaviorsConfig::getInstance();
$query = "SELECT glpi_groups.id\n FROM glpi_groups_users\n INNER JOIN glpi_groups ON (glpi_groups.id = glpi_groups_users.groups_id)\n WHERE glpi_groups_users.users_id = '" . $userid . "'" . getEntitiesRestrictRequest(' AND ', 'glpi_groups', '', $entity, true);
if ($filter) {
$query .= "AND (" . $filter . ")";
}
$rep = array();
foreach ($DB->request($query) as $data) {
if ($first) {
return $data['id'];
}
$rep[] = $data['id'];
}
return $first ? 0 : $rep;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:17,代码来源:user.class.php
示例8: showForItem
/**
* Show OcsLink of an item
*
* @param $item CommonDBTM object
*
* @return nothing
**/
static function showForItem(CommonDBTM $item)
{
global $DB, $LANG;
if (in_array($item->getType(), array('Computer'))) {
$items_id = $item->getField('id');
$query = "SELECT `glpi_ocslinks`.`tag` AS tag\n FROM `glpi_ocslinks`\n WHERE `glpi_ocslinks`.`computers_id` = '{$items_id}' " . getEntitiesRestrictRequest("AND", "glpi_ocslinks");
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$data = $DB->fetch_assoc($result);
$data = clean_cross_side_scripting_deep(addslashes_deep($data));
echo "<div class='center'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . $LANG['ocsng'][0] . "</th>";
echo "<tr class='tab_bg_2'>";
echo "<td class='center'>" . $LANG['ocsconfig'][39] . " : " . $data['tag'] . "</td></tr>";
}
}
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:25,代码来源:ocslink.class.php
示例9: countForItem
static function countForItem(CommonDBTM $item)
{
$restrict = "`glpi_documents_items`.`documents_id` = `glpi_documents`.`id`\n AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'";
if (getLoginUserID()) {
$restrict .= getEntitiesRestrictRequest(" AND ", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$restrict .= " AND `glpi_documents`.`entities_id` = '0' ";
}
$nb = countElementsInTable(array('glpi_documents_items', 'glpi_documents'), $restrict);
// Document case : search in both
if ($item->getType() == 'Document') {
$restrict = "`glpi_documents_items`.`items_id` = `glpi_documents`.`id`\n AND `glpi_documents_items`.`documents_id` = '" . $item->getField('id') . "'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'";
if (getLoginUserID()) {
$restrict .= getEntitiesRestrictRequest(" AND ", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$restrict .= " AND `glpi_documents`.`entities_id` = '0' ";
}
$nb += countElementsInTable(array('glpi_documents_items', 'glpi_documents'), $restrict);
}
return $nb;
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:23,代码来源:document_item.class.php
示例10: queryAccountsList
public static function queryAccountsList($values)
{
global $DB;
$ID = $values["id"];
$aeskey = $values["aeskey"];
$PluginAccountsHash = new PluginAccountsHash();
$PluginAccountsHash->getFromDB($ID);
$hash = $PluginAccountsHash->fields["hash"];
if ($PluginAccountsHash->isRecursive()) {
$entities = getSonsOf('glpi_entities', $PluginAccountsHash->getEntityID());
} else {
$entities = $PluginAccountsHash->getEntityID();
}
if ($aeskey) {
$query = "SELECT `glpi_plugin_accounts_accounts`.*,\n `glpi_plugin_accounts_accounttypes`.`name` AS type\n FROM `glpi_plugin_accounts_accounts`\n LEFT JOIN `glpi_plugin_accounts_accounttypes`\n ON (`glpi_plugin_accounts_accounts`.`plugin_accounts_accounttypes_id` = `glpi_plugin_accounts_accounttypes`.`id`)\n WHERE `is_deleted`= '0'";
$query .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_accounts_accounts", '', $entities, $PluginAccountsHash->maybeRecursive());
$query .= " ORDER BY `type`,`name`";
foreach ($DB->request($query) as $data) {
$accounts[] = $data;
}
$list = array();
if (!empty($accounts)) {
foreach ($accounts as $account) {
$ID = $account["id"];
$list[$ID]["id"] = $account["id"];
$list[$ID]["name"] = $account["name"];
if (Session::isMultiEntitiesMode()) {
$list[$ID]["entities_id"] = Dropdown::getDropdownName("glpi_entities", $account["entities_id"]);
}
$list[$ID]["type"] = $account["type"];
$list[$ID]["login"] = $account["login"];
$list[$ID]["password"] = $account["encrypted_password"];
}
}
}
return $list;
}
开发者ID:puchadesc,项目名称:accounts,代码行数:37,代码来源:report.class.php
示例11: showForSoftware
/**
* 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, READ)) {
return false;
}
$columns = array('name' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'number' => _x('quantity', 'Number'), '_affected' => __('Affected computers'), 'typename' => __('Type'), 'buyname' => __('Purchase version'), 'usename' => __('Version in use'), 'expire' => __('Expiration'));
if (!$software->isRecursive()) {
unset($columns['entity']);
}
if (isset($_GET["start"])) {
$start = $_GET["start"];
} else {
$start = 0;
}
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) {
$sort = "`" . $_GET["sort"] . "`";
} else {
$sort = "`entity` {$order}, `name`";
}
// Righ type is enough. Can add a License on a software we have Read access
$canedit = Software::canUpdate();
$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 ($canedit) {
echo "<div class='center firstbloc'>";
echo "<a class='vsubmit' href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . _x('button', 'Add a license') . "</a>";
echo "</div>";
}
$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)) {
// Display the pager
Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, $number);
if ($showmassiveactions) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $num_displayed, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('options' => array('glpi_softwareversions.name' => array('condition' => "`glpi_softwareversions`.`softwares_id`\n = {$softwares_id}"), 'glpi_softwarelicenses.name' => array('itemlink_as_string' => true))));
Html::showMassiveActions($massiveactionparams);
}
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
$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'>";
$header_begin = "<tr><th>";
$header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_end = '';
foreach ($columns as $key => $val) {
// Non order column
if ($key[0] == '_') {
$header_end .= "<th>{$val}</th>";
} else {
$header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>";
}
}
$header_end .= "</tr>\n";
echo $header_begin . $header_top . $header_end;
$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->canEdit($data['id'])) {
echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
} else {
echo "<td> </td>";
}
echo "<td><a href='softwarelicense.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a></td>";
if (isset($columns['entity'])) {
echo "<td>";
echo $data['entity'];
echo "</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;
$color = $data['is_valid'] ? 'green' : 'red';
echo "<td class='numeric {$color}'>" . $nb_assoc . "</td>";
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:softwarelicense.class.php
示例12: getTableForItemType
// Show categories wicth have at least one form user can access
$cat_table = getTableForItemType('PluginFormcreatorCategory');
$form_table = getTableForItemType('PluginFormcreatorForm');
$table_fp = getTableForItemType('PluginFormcreatorFormprofiles');
$where = getEntitiesRestrictRequest("", $form_table, "", "", true, false);
$query = "SELECT {$cat_table}.`name`, {$cat_table}.`id`\n FROM {$cat_table}\n WHERE 0 < (\n SELECT COUNT({$form_table}.id)\n FROM {$form_table}\n WHERE {$form_table}.`plugin_formcreator_categories_id` = {$cat_table}.`id`\n AND {$form_table}.`is_active` = 1\n AND {$form_table}.`is_deleted` = 0\n AND ({$form_table}.`language` = '{$_SESSION['glpilanguage']}' OR {$form_table}.`language` = '')\n AND {$where}\n AND ({$form_table}.`access_rights` != " . PluginFormcreatorForm::ACCESS_RESTRICTED . " OR {$form_table}.`id` IN (\n SELECT plugin_formcreator_forms_id\n FROM {$table_fp}\n WHERE plugin_formcreator_profiles_id = " . (int) $_SESSION['glpiactiveprofile']['id'] . "))\n )\n ORDER BY {$cat_table}.`name` ASC";
$result = $GLOBALS['DB']->query($query);
if (!empty($result)) {
echo '<table class="tab_cadrehov">';
echo '<tr class="noHover">';
echo '<th><a href="../plugins/formcreator/front/formlist.php">' . _n('Form', 'Forms', 2, 'formcreator') . '</a></th>';
echo '</tr>';
// For each categories, show the list of forms the user can fill
while ($category = $GLOBALS['DB']->fetch_array($result)) {
echo '<tr class="noHover"><th>' . $category['name'] . '</th></tr>';
$where = getEntitiesRestrictRequest("", $form_table, "", "", true, false);
$table_fp = getTableForItemType('PluginFormcreatorFormprofiles');
$query_forms = "SELECT {$form_table}.id, {$form_table}.name, {$form_table}.description\n FROM {$form_table}\n WHERE {$form_table}.`plugin_formcreator_categories_id` = {$category['id']}\n AND {$form_table}.`is_active` = 1\n AND {$form_table}.`is_deleted` = 0\n AND ({$form_table}.`language` = '{$_SESSION['glpilanguage']}' OR {$form_table}.`language` = '')\n AND {$where}\n AND (`access_rights` != " . PluginFormcreatorForm::ACCESS_RESTRICTED . " OR {$form_table}.`id` IN (\n SELECT plugin_formcreator_forms_id\n FROM {$table_fp}\n WHERE plugin_formcreator_profiles_id = " . (int) $_SESSION['glpiactiveprofile']['id'] . "))\n ORDER BY {$form_table}.name ASC";
$result_forms = $GLOBALS['DB']->query($query_forms);
$i = 0;
while ($form = $GLOBALS['DB']->fetch_array($result_forms)) {
$i++;
echo '<tr class="line' . $i % 2 . ' tab_bg_' . ($i % 2 + 1) . '">';
echo '<td>';
echo '<img src="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/pics/plus.png" alt="+" title=""
onclick="showDescription(' . $form['id'] . ', this)" align="absmiddle" style="cursor: pointer">';
echo ' ';
echo '<a href="' . $GLOBALS['CFG_GLPI']['root_doc'] . '/plugins/formcreator/front/showform.php?id=' . $form['id'] . '"
title="' . plugin_formcreator_encode($form['description']) . '">' . $form['name'] . '</a></td>';
echo '</tr>';
echo '<tr id="desc' . $form['id'] . '" class="line' . $i % 2 . ' form_description">';
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:homepage_forms.php
示例13: showListSimple
static function showListSimple()
{
global $DB, $CFG_GLPI;
if (!Session::haveRight(self::$rightname, self::RESERVEANITEM)) {
return false;
}
$ri = new self();
$ok = false;
$showentity = Session::isMultiEntitiesMode();
$values = array();
if (isset($_SESSION['glpi_saved']['ReservationItem'])) {
$_POST = $_SESSION['glpi_saved']['ReservationItem'];
}
if (isset($_POST['reserve'])) {
echo "<div id='viewresasearch' class='center'>";
Toolbox::manageBeginAndEndPlanDates($_POST['reserve']);
echo "<div id='nosearch' class='center firstbloc'>" . "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/reservationitem.php\">";
echo __('See all reservable items') . "</a></div>\n";
} else {
echo "<div id='makesearch' class='center firstbloc'>" . "<a class='pointer' onClick=\"javascript:showHideDiv('viewresasearch','','','');" . "showHideDiv('makesearch','','','')\">";
echo __('Find a free item in a specific period') . "</a></div>\n";
echo "<div id='viewresasearch' style=\"display:none;\" class='center'>";
$begin_time = time();
$begin_time -= $begin_time % HOUR_TIMESTAMP;
$_POST['reserve']["begin"] = date("Y-m-d H:i:s", $begin_time);
$_POST['reserve']["end"] = date("Y-m-d H:i:s", $begin_time + HOUR_TIMESTAMP);
$_POST['reservation_types'] = '';
}
echo "<form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
echo "<th colspan='3'>" . __('Find a free item in a specific period') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
Html::showDateTimeField("reserve[begin]", array('value' => $_POST['reserve']["begin"], 'maybeempty' => false));
echo "</td><td rowspan='3'>";
echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Search') . "\">";
echo "</td></tr>";
echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
$default_delay = floor((strtotime($_POST['reserve']["end"]) - strtotime($_POST['reserve']["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
$rand = Dropdown::showTimeStamp("reserve[_duration]", array('min' => 0, 'max' => 48 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
echo "<br><div id='date_end{$rand}'></div>";
$params = array('duration' => '__VALUE__', 'end' => $_POST['reserve']["end"], 'name' => "reserve[end]");
Ajax::updateItemOnSelectEvent("dropdown_reserve[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
echo "</td></tr>";
echo "<tr class='tab_bg_2'><td>" . __('Item type') . "</td><td>";
$sql = "SELECT DISTINCT(`itemtype`)\n FROM `glpi_reservationitems`\n WHERE `is_active` = 1" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']);
$result = $DB->query($sql);
while ($data = $DB->fetch_assoc($result)) {
$values[$data['itemtype']] = $data['itemtype']::getTypeName();
}
$query = "SELECT `glpi_peripheraltypes`.`name`, `glpi_peripheraltypes`.`id`\n FROM `glpi_peripheraltypes`\n LEFT JOIN `glpi_peripherals`\n ON `glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`\n LEFT JOIN `glpi_reservationitems`\n ON `glpi_reservationitems`.`items_id` = `glpi_peripherals`.`id`\n WHERE `itemtype` = 'Peripheral'\n AND `is_active` = 1\n AND `peripheraltypes_id`" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']) . "\n ORDER BY `glpi_peripheraltypes`.`name`";
foreach ($DB->request($query) as $ptype) {
$id = $ptype['id'];
$values["Peripheral#{$id}"] = $ptype['name'];
}
Dropdown::showFromArray("reservation_types", $values, array('value' => $_POST['reservation_types'], 'display_emptychoice' => true));
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
// GET method passed to form creation
echo "<div id='nosearch' class='center'>";
echo "<form name='form' method='GET' action='reservation.form.php'>";
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n";
foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
if (!($item = getItemForItemtype($itemtype))) {
continue;
}
$itemtable = getTableForItemType($itemtype);
$otherserial = "'' AS otherserial";
if ($item->isField('otherserial')) {
$otherserial = "`{$itemtable}`.`otherserial`";
}
$begin = $_POST['reserve']["begin"];
$end = $_POST['reserve']["end"];
$left = "";
$where = "";
if (isset($_POST['submit']) && isset($begin) && isset($end)) {
$left = "LEFT JOIN `glpi_reservations`\n ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n AND '" . $begin . "' < `glpi_reservations`.`end`\n AND '" . $end . "' > `glpi_reservations`.`begin`)";
$where = " AND `glpi_reservations`.`id` IS NULL ";
}
if (isset($_POST["reservation_types"]) && !empty($_POST["reservation_types"])) {
$tmp = explode('#', $_POST["reservation_types"]);
$where .= " AND `glpi_reservationitems`.`itemtype` = '" . $tmp[0] . "'";
if (isset($tmp[1]) && $tmp[0] == 'Peripheral' && $itemtype == 'Peripheral') {
$left .= " LEFT JOIN `glpi_peripheraltypes`\n ON (`glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`)";
$where .= " AND `{$itemtable}`.`peripheraltypes_id` = '" . $tmp[1] . "'";
}
}
$query = "SELECT `glpi_reservationitems`.`id`,\n `glpi_reservationitems`.`comment`,\n `{$itemtable}`.`name` AS name,\n `{$itemtable}`.`entities_id` AS entities_id,\n {$otherserial},\n `glpi_locations`.`id` AS location,\n `glpi_reservationitems`.`items_id` AS items_id\n FROM `glpi_reservationitems`\n INNER JOIN `{$itemtable}`\n ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n {$left}\n LEFT JOIN `glpi_locations`\n ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n WHERE `glpi_reservationitems`.`is_active` = '1'\n AND `glpi_reservationitems`.`is_deleted` = '0'\n AND `{$itemtable}`.`is_deleted` = '0'\n {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n ORDER BY `{$itemtable}`.`entities_id`,\n `{$itemtable}`.`name`";
if ($result = $DB->query($query)) {
while ($row = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_2'><td>";
echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>";
$typename = $item->getTypeName();
if ($itemtype == 'Peripheral') {
$item->getFromDB($row['items_id']);
if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
$typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
}
//.........这里部分代码省略.........
开发者ID:btry,项目名称:glpi,代码行数:101,代码来源:reservationitem.class.php
示例14: showItems
/**
* @param $target
* @param $date1
* @param $date2
* @param $start
**/
static function showItems($target, $date1, $date2, $start)
{
global $DB, $CFG_GLPI;
$view_entities = Session::isMultiEntitiesMode();
if ($view_entities) {
$entities = getAllDatasFromTable('glpi_entities');
}
$output_type = Search::HTML_OUTPUT;
if (isset($_GET["display_type"])) {
$output_type = $_GET["display_type"];
}
if (empty($date2)) {
$date2 = date("Y-m-d");
}
$date2 .= " 23:59:59";
// 1 an par defaut
if (empty($date1)) {
$date1 = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1));
}
$date1 .= " 00:00:00";
$query = "SELECT `glpi_items_tickets`.`itemtype`,\n `glpi_items_tickets`.`items_id`,\n COUNT(*) AS NB\n FROM `glpi_tickets`\n LEFT JOIN `glpi_items_tickets`\n ON (`glpi_tickets`.`id` = `glpi_items_tickets`.`tickets_id`)\n WHERE `date` <= '{$date2}'\n AND `glpi_tickets`.`date` >= '{$date1}' " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n AND `glpi_items_tickets`.`itemtype` <> ''\n AND `glpi_items_tickets`.`items_id` > 0\n GROUP BY `glpi_items_tickets`.`itemtype`, `glpi_items_tickets`.`items_id`\n ORDER BY NB DESC";
$result = $DB->query($query);
$numrows = $DB->numrows($result);
if ($numrows > 0) {
if ($output_type == Search::HTML_OUTPUT) {
Html::printPager($start, $numrows, $target, "date1=" . $date1 . "&date2=" . $date2 . "&type=hardwares&start={$start}", 'Stat');
echo "<div class='center'>";
}
$end_display = $start + $_SESSION['glpilist_limit'];
if (isset($_GET['export_all'])) {
$end_display = $numrows;
}
echo Search::showHeader($output_type, $end_display - $start + 1, 2, 1);
$header_num = 1;
echo Search::showNewLine($output_type);
echo Search::showHeaderItem($output_type, _n('Associated element', 'Associated elements', 2), $header_num);
if ($view_entities) {
echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
|
请发表评论