本文整理汇总了PHP中Contract::canView方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract::canView方法的具体用法?PHP Contract::canView怎么用?PHP Contract::canView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contract
的用法示例。
在下文中一共展示了Contract::canView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
// can exists for template
if ($item->getType() == 'Contract' && Contract::canView()) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), countElementsInTable('glpi_contractcosts', "contracts_id = '" . $item->getID() . "'"));
}
return self::getTypeName(Session::getPluralNumber());
}
return '';
}
示例2: title
/**
* Show report title
**/
static function title()
{
global $PLUGIN_HOOKS, $CFG_GLPI;
// Report generation
// Default Report included
$report_list["default"]["name"] = __('Default report');
$report_list["default"]["file"] = "report.default.php";
if (Contract::canView()) {
// Rapport ajoute par GLPI V0.2
$report_list["Contrats"]["name"] = __('By contract');
$report_list["Contrats"]["file"] = "report.contract.php";
}
if (Infocom::canView()) {
$report_list["Par_annee"]["name"] = __('By year');
$report_list["Par_annee"]["file"] = "report.year.php";
$report_list["Infocoms"]["name"] = __('Hardware financial and administrative information');
$report_list["Infocoms"]["file"] = "report.infocom.php";
$report_list["Infocoms2"]["name"] = __('Other financial and administrative information (licenses, cartridges, consumables)');
$report_list["Infocoms2"]["file"] = "report.infocom.conso.php";
}
if (Session::haveRight("networking", READ)) {
$report_list["Rapport prises reseau"]["name"] = __('Network report');
$report_list["Rapport prises reseau"]["file"] = "report.networking.php";
}
if (Session::haveRight("reservation", READ)) {
$report_list["reservation"]["name"] = __('Loan');
$report_list["reservation"]["file"] = "report.reservation.php";
}
if (Computer::canView() || Monitor::canView() || Session::haveRight("networking", READ) || Peripheral::canView() || Printer::canView() || Phone::canView()) {
$report_list["state"]["name"] = _n('Status', 'Statuses', Session::getPluralNumber());
$report_list["state"]["file"] = "report.state.php";
}
//Affichage du tableau de presentation des stats
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Select the report you want to generate') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
$count = count($report_list);
$selected = -1;
$values = array($CFG_GLPI["root_doc"] . '/front/report.php' => Dropdown::EMPTY_VALUE);
while ($data = each($report_list)) {
$val = $data[0];
$name = $report_list["{$val}"]["name"];
$file = $report_list["{$val}"]["file"];
$key = $CFG_GLPI["root_doc"] . "/front/" . $file;
$values[$key] = $name;
if (stripos($_SERVER['REQUEST_URI'], $key) !== false) {
$selected = $key;
}
}
$names = array();
$optgroup = array();
if (isset($PLUGIN_HOOKS["reports"]) && is_array($PLUGIN_HOOKS["reports"])) {
foreach ($PLUGIN_HOOKS["reports"] as $plug => $pages) {
if (is_array($pages) && count($pages)) {
foreach ($pages as $page => $name) {
$names[$plug . '/' . $page] = array("name" => $name, "plug" => $plug);
$optgroup[$plug] = Plugin::getInfo($plug, 'name');
}
}
}
asort($names);
}
foreach ($optgroup as $opt => $title) {
$group = $title;
foreach ($names as $key => $val) {
if ($opt == $val["plug"]) {
$file = $CFG_GLPI["root_doc"] . "/plugins/" . $key;
$values[$group][$file] = $val["name"];
if (stripos($_SERVER['REQUEST_URI'], $file) !== false) {
$selected = $file;
}
}
}
}
Dropdown::showFromArray('statmenu', $values, array('on_change' => "window.location.href=this.options[this.selectedIndex].value", 'value' => $selected));
echo "</td>";
echo "</tr>";
echo "</table>";
}
示例3: showForSupplier
/**
* Print an HTML array with contracts associated to the enterprise
*
* @since version 0.84
*
* @param $supplier Supplier object
*
* @return Nothing (display)
**/
static function showForSupplier(Supplier $supplier)
{
global $DB, $CFG_GLPI;
$ID = $supplier->fields['id'];
if (!Contract::canView() || !$supplier->can($ID, READ)) {
return false;
}
$canedit = $supplier->can($ID, UPDATE);
$rand = mt_rand();
$query = "SELECT `glpi_contracts`.*,\n `glpi_contracts_suppliers`.`id` AS assocID,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_suppliers`, `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_contracts`.`entities_id`)\n WHERE `glpi_contracts_suppliers`.`suppliers_id` = '{$ID}'\n AND `glpi_contracts_suppliers`.`contracts_id`=`glpi_contracts`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_entities`.`completename`,\n `glpi_contracts`.`name`";
$result = $DB->query($query);
$contracts = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$contracts[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='suppliers_id' value='{$ID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
Contract::dropdown(array('used' => $used, 'entity' => $supplier->fields["entities_id"], 'entity_sons' => $supplier->fields["is_recursive"], 'nochecklimit' => true));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand, 'num_displayed' => $number);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . _x('phone', 'Number') . "</th>";
$header_end .= "<th>" . __('Contract type') . "</th>";
$header_end .= "<th>" . __('Start date') . "</th>";
$header_end .= "<th>" . __('Initial contract period') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
$used = array();
foreach ($contracts as $data) {
$cID = $data["id"];
$used[$cID] = $cID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
$name = $data["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
}
echo "<td class='center b'>\n <a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name . "</a>";
echo "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]);
echo "</td><td class='center'>" . $data["num"] . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_contracttypes", $data["contracttypes_id"]) . "</td>";
echo "<td class='center'>" . Html::convDate($data["begin_date"]) . "</td>";
echo "<td class='center'>";
sprintf(_n('%d month', '%d months', $data["duration"]), $data["duration"]);
if ($data["begin_date"] != '' && !empty($data["begin_date"])) {
echo " -> " . Infocom::getWarrantyExpir($data["begin_date"], $data["duration"], 0, true);
}
echo "</td>";
echo "</tr>";
}
if ($number) {
echo $header_begin . $header_bottom . $header_end;
}
//.........这里部分代码省略.........
示例4: showCentral
/**
* Show central contract resume
* HTML array
*
* @return Nothing (display)
**/
static function showCentral()
{
global $DB, $CFG_GLPI;
if (!Contract::canView()) {
return false;
}
// No recursive contract, not in local management
// contrats echus depuis moins de 30j
$query = "SELECT COUNT(*)\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`is_deleted`='0' " . getEntitiesRestrictRequest("AND", "glpi_contracts") . "\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n `glpi_contracts`.`duration` MONTH),CURDATE() )>-30\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n `glpi_contracts`.`duration` MONTH),CURDATE() )<'0'";
$result = $DB->query($query);
$contract0 = $DB->result($result, 0, 0);
// contrats echeance j-7
$query = "SELECT COUNT(*)\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`is_deleted`='0' " . getEntitiesRestrictRequest("AND", "glpi_contracts") . "\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n `glpi_contracts`.`duration` MONTH),CURDATE() )>'0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n `glpi_contracts`.`duration` MONTH),CURDATE() )<='7'";
$result = $DB->query($query);
$contract7 = $DB->result($result, 0, 0);
// contrats echeance j -30
$query = "SELECT COUNT(*)\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`is_deleted`='0' " . getEntitiesRestrictRequest("AND", "glpi_contracts") . "\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n `glpi_contracts`.`duration` MONTH),CURDATE() )>'7'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n `glpi_contracts`.`duration` MONTH),CURDATE() )<'30'";
$result = $DB->query($query);
$contract30 = $DB->result($result, 0, 0);
// contrats avec préavis echeance j-7
$query = "SELECT COUNT(*)\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`is_deleted`='0' " . getEntitiesRestrictRequest("AND", "glpi_contracts") . "\n AND `glpi_contracts`.`notice`<>'0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n (`glpi_contracts`.`duration`-`glpi_contracts`.`notice`)\n MONTH),CURDATE() )>'0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n (`glpi_contracts`.`duration`-`glpi_contracts`.`notice`)\n MONTH),CURDATE() )<='7'";
$result = $DB->query($query);
$contractpre7 = $DB->result($result, 0, 0);
// contrats avec préavis echeance j -30
$query = "SELECT COUNT(*)\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`is_deleted`='0'" . getEntitiesRestrictRequest("AND", "glpi_contracts") . "\n AND `glpi_contracts`.`notice`<>'0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n (`glpi_contracts`.`duration`-`glpi_contracts`.`notice`)\n MONTH),CURDATE() )>'7'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`, INTERVAL\n (`glpi_contracts`.`duration`-`glpi_contracts`.`notice`)\n MONTH),CURDATE() )<'30'";
$result = $DB->query($query);
$contractpre30 = $DB->result($result, 0, 0);
echo "<table class='tab_cadrehov'>";
echo "<tr class='noHover'><th colspan='2'>";
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.php?reset=reset\">" . self::getTypeName(1) . "</a></th></tr>";
echo "<tr class='tab_bg_2'>";
$options['reset'] = 'reset';
$options['sort'] = 12;
$options['order'] = 'DESC';
$options['start'] = 0;
$options['criteria'][0] = array('field' => 12, 'value' => '<0', 'searchtype' => 'contains');
$options['criteria'][1] = array('field' => 12, 'link' => 'AND', 'value' => '>-30', 'searchtype' => 'contains');
echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.php?" . Toolbox::append_params($options, '&') . "\">" . __('Contracts expired in the last 30 days') . "</a> </td>";
echo "<td class='numeric'>" . $contract0 . "</td></tr>";
echo "<tr class='tab_bg_2'>";
$options['criteria'][0]['value'] = 0;
$options['criteria'][1]['value'] = '<7';
echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.php?" . Toolbox::append_params($options, '&') . "\">" . __('Contracts expiring in less than 7 days') . "</a></td>";
echo "<td class='numeric'>" . $contract7 . "</td></tr>";
echo "<tr class='tab_bg_2'>";
$options['criteria'][0]['value'] = '>6';
$options['criteria'][1]['value'] = '<30';
echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.php?" . Toolbox::append_params($options, '&') . "\">" . __('Contracts expiring in less than 30 days') . "</a></td>";
echo "<td class='numeric'>" . $contract30 . "</td></tr>";
echo "<tr class='tab_bg_2'>";
$options['criteria'][0]['field'] = 13;
$options['criteria'][0]['value'] = '>0';
$options['criteria'][1]['field'] = 13;
$options['criteria'][1]['value'] = '<7';
echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.php?" . Toolbox::append_params($options, '&') . "\">" . __('Contracts where notice begins in less than 7 days') . "</a></td>";
echo "<td class='numeric'>" . $contractpre7 . "</td></tr>";
echo "<tr class='tab_bg_2'>";
$options['criteria'][0]['value'] = '>6';
$options['criteria'][1]['value'] = '<30';
echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.php?" . Toolbox::append_params($options, '&') . "\">" . __('Contracts where notice begins in less than 30 days') . "</a></td>";
echo "<td class='numeric'>" . $contractpre30 . "</td></tr>";
echo "</table>";
}
示例5: getItem
/**
* Return the instance fields of itemtype identified by id
*
* @param $itemtype string itemtype (class) of object
* @param $id integer identifier of object
* @param $params array with theses options :
* - 'expand_dropdowns': Show dropdown's names instead of id. default: false. Optionnal
* - 'get_hateoas': Show relation of current item in a links attribute. default: true. Optionnal
* - 'get_sha1': Get a sha1 signature instead of the full answer. default: false. Optionnal
* - 'with_components': Only for [Computer, NetworkEquipment, Peripheral, Phone, Printer], Optionnal.
* - 'with_disks': Only for Computer, retrieve the associated filesystems. Optionnal.
* - 'with_softwares': Only for Computer, retrieve the associated softwares installations. Optionnal.
* - 'with_connections': Only for Computer, retrieve the associated direct connections (like peripherals and printers) .Optionnal.
* - 'with_networkports':Retrieve all network connections and advanced network informations. Optionnal.
* - 'with_infocoms': Retrieve financial and administrative informations. Optionnal.
* - 'with_contracts': Retrieve associated contracts. Optionnal.
* - 'with_documents': Retrieve associated external documents. Optionnal.
* - 'with_tickets': Retrieve associated itil tickets. Optionnal.
* - 'with_problems': Retrieve associated itil problems. Optionnal.
* - 'with_changes': Retrieve associated itil changes. Optionnal.
* - 'with_notes': Retrieve Notes (if exists, not all itemtypes have notes). Optionnal.
* - 'with_logs': Retrieve historical. Optionnal.
*
* @return array fields of found object
**/
protected function getItem($itemtype, $id, $params = array())
{
global $CFG_GLPI, $DB;
$this->initEndpoint();
// default params
$default = array('expand_dropdowns' => false, 'get_hateoas' => true, 'get_sha1' => false, 'with_components' => false, 'with_disks' => false, 'with_softwares' => false, 'with_connections' => false, 'with_networkports' => false, 'with_infocoms' => false, 'with_contracts' => false, 'with_documents' => false, 'with_tickets' => false, 'with_problems' => false, 'with_changes' => false, 'with_notes' => false, 'with_logs' => false);
$params = array_merge($default, $params);
$item = new $itemtype();
if (!$item->getFromDB($id)) {
return $this->messageNotfoundError();
}
if (!$item->can($id, READ)) {
return $this->messageRightError();
}
$fields = $item->fields;
// avoid disclosure of critical fields
$item::unsetUndisclosedFields($fields);
// retrieve devices
if (isset($params['with_devices']) && $params['with_devices'] && in_array($itemtype, Item_Devices::getConcernedItems())) {
$all_devices = array();
foreach (Item_Devices::getItemAffinities($item->getType()) as $device_type) {
$found_devices = getAllDatasFromTable($device_type::getTable(), "`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "'\n AND `is_deleted` = '0'", true);
foreach ($found_devices as $devices_id => &$device) {
unset($device['items_id']);
unset($device['itemtype']);
unset($device['is_deleted']);
}
if (!empty($found_devices)) {
$all_devices[$device_type] = $found_devices;
}
}
$fields['_devices'] = $all_devices;
}
// retrieve computer disks
if (isset($params['with_disks']) && $params['with_disks'] && $itemtype == "Computer") {
// build query to retrive filesystems
$query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE `computers_id` = '{$id}'\n AND `is_deleted` = '0'";
$fields['_disks'] = array();
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
unset($data['computers_id']);
unset($data['is_deleted']);
$fields['_disks'][] = array('name' => $data);
}
}
}
// retrieve computer softwares
if (isset($params['with_softwares']) && $params['with_softwares'] && $itemtype == "Computer") {
$fields['_softwares'] = array();
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`id` AS softwares_id,\n `glpi_softwareversions`.`id` AS softwareversions_id,\n `glpi_computers_softwareversions`.`is_dynamic`,\n `glpi_softwareversions`.`states_id`,\n `glpi_softwares`.`is_valid`\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_softwares'][] = $data;
}
}
}
}
// retrieve item connections
if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
$fields['_connections'] = array();
foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
$connect_item = new $connect_type();
if ($connect_item->canView()) {
$query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n `glpi_computers_items`.`items_id` AS assoc_items_id,\n `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n " . getTableForItemType($connect_type) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($connect_type) . "`\n ON (`" . getTableForItemType($connect_type) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$id}'\n AND `itemtype` = '" . $connect_type . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_connections'][$connect_type][] = $data;
}
}
}
}
}
//.........这里部分代码省略.........
示例6: showForItem
/**
* Print an HTML array of contract associated to an object
*
* @since version 0.84
*
* @param $item CommonDBTM object wanted
* @param $withtemplate not used (to be deleted) (default '')
*
* @return Nothing (display)
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$itemtype = $item->getType();
$ID = $item->fields['id'];
if (!Contract::canView() || !$item->can($ID, READ)) {
return false;
}
$canedit = $item->can($ID, UPDATE);
$rand = mt_rand();
$query = "SELECT `glpi_contracts_items`.*\n FROM `glpi_contracts_items`,\n `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n AND `glpi_contracts_items`.`items_id` = '{$ID}'\n AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_contracts`.`name`";
$result = $DB->query($query);
$contracts = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$contracts[$data['id']] = $data;
$used[$data['contracts_id']] = $data['contracts_id'];
}
}
if ($canedit && $withtemplate != 2) {
echo "<div class='firstbloc'>";
echo "<form name='contractitem_form{$rand}' id='contractitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
echo "<tr class='tab_bg_1'><td>";
Contract::dropdown(array('entity' => $item->getEntityID(), 'used' => $used));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($withtemplate != 2) {
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number && $withtemplate != 2) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . _x('phone', 'Number') . "</th>";
$header_end .= "<th>" . __('Contract type') . "</th>";
$header_end .= "<th>" . __('Supplier') . "</th>";
$header_end .= "<th>" . __('Start date') . "</th>";
$header_end .= "<th>" . __('Initial contract period') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
if ($number > 0) {
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($contracts as $data) {
$cID = $data["contracts_id"];
Session::addToNavigateListItems(__CLASS__, $cID);
$contracts[] = $cID;
$assocID = $data["id"];
$con = new Contract();
$con->getFromDB($cID);
echo "<tr class='tab_bg_1" . ($con->fields["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate != 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
}
echo "<td class='center b'>";
$name = $con->fields["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($con->fields["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $con->fields["id"]);
}
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name;
echo "</a></td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"]) . "</td>";
echo "<td class='center'>" . $con->fields["num"] . "</td>";
echo "<td class='center'>";
//.........这里部分代码省略.........
示例7: showGlobalView
/**
* Show the central global view
**/
static function showGlobalView()
{
$showticket = Session::haveRight("ticket", Ticket::READALL);
$showproblem = Session::haveRight("problem", Problem::READALL);
echo "<table class='tab_cadre_central'><tr class='noHover'>";
echo "<td class='top' width='50%'>";
echo "<table class='central'>";
echo "<tr class='noHover'><td>";
if ($showticket) {
Ticket::showCentralCount();
}
if ($showproblem) {
Problem::showCentralCount();
}
if (Contract::canView()) {
Contract::showCentral();
}
echo "</td></tr>";
echo "</table></td>";
if (Session::haveRight("logs", READ)) {
echo "<td class='top' width='50%'>";
//Show last add events
Event::showForUser($_SESSION["glpiname"]);
echo "</td>";
}
echo "</tr></table>";
if ($_SESSION["glpishow_jobs_at_login"] && $showticket) {
echo "<br>";
Ticket::showCentralNewList();
}
}
示例8: getItem
/**
* Return the instance fields of itemtype identified by id
*
* @since version 9.1
*
* @param string $itemtype itemtype (class) of object
* @param integer $id identifier of object
* @param array $params array with theses options :
* - 'expand_dropdowns' : show dropdown's names instead of id. default: false. Optionnal
* - 'get_hateoas' : show relation of current item in a links attribute. default: true. Optionnal
* - 'with_components' : Only for [Computer, NetworkEquipment, Peripheral, Phone, Printer], Optionnal.
* - 'with_disks' : Only for Computer, retrieve the associated filesystems. Optionnal.
* - 'with_softwares' : Only for Computer, retrieve the associated softwares installations. Optionnal.
* - 'with_connections' : Only for Computer, retrieve the associated direct connections (like peripherals and printers) .Optionnal.
* - 'with_networkports' :Retrieve all network connections and advanced network informations. Optionnal.
* - 'with_infocoms' : Retrieve financial and administrative informations. Optionnal.
* - 'with_contracts' : Retrieve associated contracts. Optionnal.
* - 'with_documents' : Retrieve associated external documents. Optionnal.
* - 'with_tickets' : Retrieve associated itil tickets. Optionnal.
* - 'with_problems' : Retrieve associated itil problems. Optionnal.
* - 'with_changes' : Retrieve associated itil changes. Optionnal.
* - 'with_notes' : Retrieve Notes (if exists, not all itemtypes have notes). Optionnal.
* - 'with_logs' : Retrieve historical. Optionnal.
*
* @return array fields of found object
*/
protected function getItem($itemtype, $id, $params = array())
{
global $CFG_GLPI, $DB;
$this->initEndpoint();
// default params
$default = array('expand_dropdowns' => false, 'get_hateoas' => true, 'with_components' => false, 'with_disks' => false, 'with_softwares' => false, 'with_connections' => false, 'with_networkports' => false, 'with_infocoms' => false, 'with_contracts' => false, 'with_documents' => false, 'with_tickets' => false, 'with_problems' => false, 'with_changes' => false, 'with_notes' => false, 'with_logs' => false);
$params = array_merge($default, $params);
$item = new $itemtype();
if (!$item->getFromDB($id)) {
return $this->messageNotfoundError();
}
if (!$item->can($id, READ)) {
return $this->messageRightError();
}
$fields = $item->fields;
// retrieve devices
if (isset($params['with_devices']) && $params['with_devices'] && in_array($itemtype, Item_Devices::getConcernedItems())) {
$all_devices = array();
foreach (Item_Devices::getItemAffinities($item->getType()) as $device_type) {
$found_devices = getAllDatasFromTable($device_type::getTable(), "`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "'\n AND `is_deleted` = '0'", true);
foreach ($found_devices as $devices_id => &$device) {
unset($device['items_id']);
unset($device['itemtype']);
unset($device['is_deleted']);
}
if (!empty($found_devices)) {
$all_devices[$device_type] = $found_devices;
}
}
$fields['_devices'] = $all_devices;
}
// retrieve computer disks
if (isset($params['with_disks']) && $params['with_disks'] && $itemtype == "Computer") {
// build query to retrive filesystems
$query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE `computers_id` = '{$id}'\n AND `is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
unset($data['computers_id']);
unset($data['is_deleted']);
$fields['_disks'][] = array('name' => $data);
}
}
}
// retrieve computer softwares
if (isset($params['with_softwares']) && $params['with_softwares'] && $itemtype == "Computer") {
$fields['_softwares'] = array();
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`id` AS softwares_id,\n `glpi_softwareversions`.`id` AS softwareversions_id,\n `glpi_computers_softwareversions`.`is_dynamic`,\n `glpi_softwareversions`.`states_id`,\n `glpi_softwares`.`is_valid`\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_softwares'][] = $data;
}
}
}
}
// retrieve item connections
if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
$fields['_connections'] = array();
foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
$connect_item = new $connect_type();
if ($connect_item->canView()) {
$query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n `glpi_computers_items`.`items_id` AS assoc_items_id,\n `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n " . getTableForItemType($connect_type) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($connect_type) . "`\n ON (`" . getTableForItemType($connect_type) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$id}'\n AND `itemtype` = '" . $connect_type . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_connections'][$connect_type][] = $data;
}
}
}
}
}
// retrieve item networkports
if (isset($params['with_networkports']) && $params['with_networkports']) {
//.........这里部分代码省略.........