本文整理汇总了PHP中CommonDBTM::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getField方法的具体用法?PHP CommonDBTM::getField怎么用?PHP CommonDBTM::getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::getField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB, $CFG_GLPIG;
if (!Session::haveRight("contract", "r")) {
return false;
}
$type = $item->getType();
$ID = $item->getField('id');
$con = new Contract();
$query = "SELECT *\n FROM `glpi_contracts_items`\n WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = $j = 0;
$pdf->setColumnsSize(100);
if ($number > 0) {
$pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
$pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
$pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
$i++;
while ($j < $number) {
$cID = $DB->result($result, $j, "contracts_id");
$assocID = $DB->result($result, $j, "id");
if ($con->getFromDB($cID)) {
$pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
}
$j++;
}
} else {
$pdf->displayTitle("<b>" . __('No item found') . "</b>");
}
$pdf->displaySpace();
}
示例2: countForItem
/**
* @param CommonDBTM $item
**/
static function countForItem(CommonDBTM $item)
{
global $DB;
$query = "SELECT COUNT(*) AS cpt FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n LEFT JOIN `glpi_plugin_monitoring_services`\n ON `glpi_plugin_monitoring_services`.`plugin_monitoring_componentscatalogs_hosts_id` =\n `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n WHERE `itemtype` = '" . $item->getType() . "'\n AND `items_id` ='" . $item->getField('id') . "'\n AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL";
$result = $DB->query($query);
$ligne = $DB->fetch_assoc($result);
return $ligne['cpt'];
}
示例3: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB;
$ID = $item->getField('id');
$type = $item->getType();
$crit = $type == 'Software' ? 'softwares_id' : 'id';
if ($type == 'Software') {
$crit = 'softwares_id';
// Software ID
$innerjoin = "INNER JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)";
$where = "WHERE `glpi_softwareversions`.`softwares_id` = '" . $ID . "'";
} else {
$crit = 'id';
//SoftwareVersion ID
$innerjoin = '';
$where = "WHERE `glpi_computers_softwareversions`.`softwareversions_id` = '" . $ID . "'";
}
$query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_computers_softwareversions`\n {$innerjoin}\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)\n {$where}" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'";
$total = 0;
if ($result = $DB->query($query_number)) {
$total = $DB->result($result, 0, 0);
}
$query = "SELECT DISTINCT `glpi_computers_softwareversions`.*,\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_softwareversions`.`name` AS version,\n `glpi_softwareversions`.`id` AS vID,\n `glpi_softwareversions`.`softwares_id` AS sID,\n `glpi_softwareversions`.`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 FROM `glpi_computers_softwareversions`\n INNER JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwareversions`.`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_softwareversions`.`{$crit}` = '{$ID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'\n ORDER BY version, compname\n LIMIT 0," . intval($_SESSION['glpilist_limit']);
$pdf->setColumnsSize(100);
if (($result = $DB->query($query)) && ($number = $DB->numrows($result)) > 0) {
if ($number == $total) {
$pdf->displayTitle('<b>' . sprintf(__('%1$s: %2$s'), _n('Installation', 'Installations', 2), $number) . "</b>");
} else {
$pdf->displayTitle('<b>' . sprintf(__('%1$s: %2$s'), _n('Installation', 'Installations', 2), $number / $total) . "</b>");
}
$pdf->setColumnsSize(12, 16, 15, 15, 22, 20);
$pdf->displayTitle('<b><i>' . _n('Version', 'Versions', 2), __('Name'), __('Serial number'), __('Inventory number'), __('Location'), _n('License', 'Licenses', 2) . '</i></b>');
while ($data = $DB->fetch_assoc($result)) {
$compname = $data['compname'];
if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
$compname = sprintf(__('%1$s (%2$s)'), $compname, $data['cID']);
}
$lics = Computer_SoftwareLicense::GetLicenseForInstallation($data['cID'], $data['vID']);
$tmp = array();
if (count($lics)) {
foreach ($lics as $lic) {
$licname = $lic['name'];
if (!empty($lic['type'])) {
$licname = sprintf(__('%1$s (%2$s)'), $licname, $lic['type']);
}
$tmp[] = $licname;
}
}
$pdf->displayLine($data['version'], $compname, $data['serial'], $data['otherserial'], $data['location'], implode(', ', $tmp));
}
} else {
$pdf->displayTitle('<b>' . _n('Installation', 'Installations', 2) . '</b>');
$pdf->displayLine(__('No item found'));
}
$pdf->displaySpace();
}
示例4: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB;
$ID = $item->getField('id');
$type = get_class($item);
if (!Session::haveRight("link", "r")) {
return false;
}
$query = "SELECT `glpi_links`.`id` AS ID, `glpi_links`.`link`, `glpi_links`.`name`,\n `glpi_links`.`data`\n FROM `glpi_links`\n INNER JOIN `glpi_links_itemtypes`\n ON `glpi_links`.`id` = `glpi_links_itemtypes`.`links_id`\n WHERE `glpi_links_itemtypes`.`itemtype` = '" . $type . "'\n ORDER BY `glpi_links`.`name`";
$result = $DB->query($query);
$pdf->setColumnsSize(100);
if ($DB->numrows($result) > 0) {
$pdf->displayTitle('<b>' . __('External Links') . '</b>');
while ($data = $DB->fetch_assoc($result)) {
$name = $data["name"];
if (empty($name)) {
$name = $data["link"];
}
$link = $data["link"];
$file = trim($data["data"]);
if (empty($file)) {
$links = Link::generateLinkContents($data['link'], $item, $name);
$i = 1;
foreach ($links as $key => $link) {
$url = $link;
$pdf->displayLine(sprintf(__('%1$s: %2$s'), "<b>{$name} #{$i}</b>", $link));
$i++;
$i++;
}
} else {
// Generated File
$files = Link::generateLinkContents($data['link'], $item);
$links = Link::generateLinkContents($data['data'], $item);
$i = 1;
foreach ($links as $key => $data) {
if (isset($files[$key])) {
// a different name for each file, ex name = foo-[IP].txt
$file = $files[$key];
} else {
// same name for all files, ex name = foo.txt
$file = reset($files);
}
$pdf->displayText(sprintf(__('%1$s: %2$s'), "<b>{$name} #{$i} - {$file}</b>", trim($data), 1, 10));
$i++;
}
}
}
// Each link
} else {
$pdf->displayTitle('<b>' . __('No link defined') . '</b>');
}
$pdf->displaySpace();
}
示例5: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
$type = get_class($item);
if (!Session::haveRight("reservation_central", "r")) {
return;
}
$user = new User();
$ri = new ReservationItem();
$pdf->setColumnsSize(100);
if ($ri->getFromDBbyItem($type, $ID)) {
$now = $_SESSION["glpi_currenttime"];
$query = "SELECT *\n FROM `glpi_reservationitems`\n INNER JOIN `glpi_reservations`\n ON (`glpi_reservations`.`reservationitems_id` = `glpi_reservationitems`.`id`)\n WHERE `end` > '" . $now . "'\n AND `glpi_reservationitems`.`items_id` = '{$ID}'\n ORDER BY `begin`";
$result = $DB->query($query);
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Current and future reservations') . "</b>");
if (!$DB->numrows($result)) {
$pdf->displayLine("<b>" . __('No reservation') . "</b>");
} else {
$pdf->setColumnsSize(14, 14, 26, 46);
$pdf->displayTitle('<i>' . __('Start date'), __('End date'), __('By'), __('Comments') . '</i>');
while ($data = $DB->fetch_assoc($result)) {
if ($user->getFromDB($data["users_id"])) {
$name = formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]);
} else {
$name = "(" . $data["users_id"] . ")";
}
$pdf->displayLine(Html::convDateTime($data["begin"]), Html::convDateTime($data["end"]), $name, str_replace(array("\r", "\n"), " ", $data["comment"]));
}
}
$query = "SELECT *\n FROM `glpi_reservationitems`\n INNER JOIN `glpi_reservations`\n ON (`glpi_reservations`.`reservationitems_id` = `glpi_reservationitems`.`id`)\n WHERE `end` <= '" . $now . "'\n AND `glpi_reservationitems`.`items_id` = '{$ID}'\n ORDER BY `begin`\n DESC";
$result = $DB->query($query);
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Past reservations') . "</b>");
if (!$DB->numrows($result)) {
$pdf->displayLine("<b>" . __('No reservation') . "</b>");
} else {
$pdf->setColumnsSize(14, 14, 26, 46);
$pdf->displayTitle('<i>' . __('Start date'), __('End date'), __('By'), __('Comments') . '</i>');
while ($data = $DB->fetch_assoc($result)) {
if ($user->getFromDB($data["users_id"])) {
$name = formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]);
} else {
$name = "(" . $data["users_id"] . ")";
}
$pdf->displayLine(Html::convDateTime($data["begin"]), Html::convDateTime($data["end"]), $name, str_replace(array("\r", "\n"), " ", $data["comment"]));
}
}
}
$pdf->displaySpace();
}
示例6: 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;
}
示例7: 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>";
}
}
}
示例8: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $CFG_GLPI;
$ID = $item->getField('id');
if (!Session::haveRight("infocom", "r")) {
return false;
}
$ic = new Infocom();
$pdf->setColumnsSize(100);
if ($ic->getFromDBforDevice(get_class($item), $ID)) {
$pdf->displayTitle("<b>" . __('Financial and administrative information') . "</b>");
$pdf->setColumnsSize(50, 50);
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Supplier') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Budget') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_budgets", $ic->fields["budgets_id"]))));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Order number') . "</i></b>", $ic->fields["order_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Order date') . "</i></b>", Html::convDate($ic->fields["order_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Immobilization number') . "</i></b>", $ic->fields["immo_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Date of purchase') . "</i></b>", Html::convDate($ic->fields["buy_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Invoice number') . "</i></b>", $ic->fields["bill"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery date') . "</i></b>", Html::convDate($ic->fields["delivery_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery form') . "</i></b>", $ic->fields["delivery_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Startup date') . "</i></b>", Html::convDate($ic->fields["use_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), _('Date of last physical inventory') . "</i></b>", Html::convDate($ic->fields["inventory_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty extension value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["warranty_value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization duration') . "</i></b>", sprintf(__('%1$s (%2$s)'), sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]), Infocom::getAmortTypeName($ic->fields["sink_type"]))));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Account net value') . "</i></b>", Infocom::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $CFG_GLPI['date_tax'], "n")), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization coefficient') . "</i></b>", $ic->fields["sink_coeff"]));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('TCO (value + tracking cost)') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Monthly TCO') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]))));
PluginPdfCommon::mainLine($pdf, $ic, 'comment');
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Warranty information') . "</b>");
$pdf->setColumnsSize(50, 50);
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Start date of warranty') . "</i></b>", Html::convDate($ic->fields["warranty_date"])), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty duration') . "</i></b>", sprintf(__('%1$s - %2$s'), sprintf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]), sprintf(__('Valid to %s'), Infocom::getWarrantyExpir($ic->fields["buy_date"], $ic->fields["warranty_duration"])))));
$col1 = "<b><i>" . __('Alarms on financial and administrative information') . "</i></b>";
if ($ic->fields["alert"] == 0) {
$col1 = sprintf(__('%1$s: %2$s'), $col1, __('No'));
} else {
if ($ic->fields["alert"] == 4) {
$col1 = sprintf(__('%1$s: %2$s'), $col1, __('Warranty expiration date'));
}
}
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty information') . "</i></b>", $ic->fields["warranty_info"]), $col1);
} else {
$pdf->displayTitle("<b>" . __('No financial information', 'pdf') . "</b>");
}
$pdf->displaySpace();
}
示例9: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB;
$ID = $item->getField('id');
$type = get_class($item);
if (!Session::haveRight("document", "r")) {
return false;
}
$query = "SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`documents_id` = `glpi_documents`.`id`)\n WHERE `glpi_documents_items`.`items_id` = '" . $ID . "'\n AND `glpi_documents_items`.`itemtype` = '" . $type . "'";
$result = $DB->query($query);
$number = $DB->numrows($result);
$pdf->setColumnsSize(100);
if (!$number) {
$pdf->displayTitle('<b>' . __('No associated documents', 'pdf') . '</b>');
} else {
$pdf->displayTitle('<b>' . __('Associated documents', 'pdf') . '</b>');
$pdf->setColumnsSize(32, 15, 21, 19, 13);
$pdf->displayTitle('<b>' . __('Name'), __('File'), __('Web link'), __('Heading'), _('MIME type') . '</b>');
while ($data = $DB->fetch_assoc($result)) {
$pdf->displayLine($data["name"], basename($data["filename"]), $data["link"], Html::clean(Dropdown::getDropdownName("glpi_documentcategories", $data["documentcategories_id"])), $data["mime"]);
}
}
$pdf->displaySpace();
}
示例10: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tree = false)
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
$type = $item->getType();
if (!Session::haveRight("show_all_ticket", "1")) {
return;
}
switch ($item->getType()) {
case 'User':
$restrict = "(`glpi_tickets_users`.`users_id` = '" . $item->getID() . "'\n AND `glpi_tickets_users`.`type` = " . CommonITILActor::REQUESTER . ")";
$order = '`glpi_tickets`.`date_mod` DESC';
break;
case 'SLA':
$restrict = "(`slas_id` = '" . $item->getID() . "')";
$order = '`glpi_tickets`.`due_date` DESC';
break;
case 'Supplier':
$restrict = "(`glpi_suppliers_tickets`.`suppliers_id` = '" . $item->getID() . "'\n AND `glpi_suppliers_tickets`.`type` = " . CommonITILActor::ASSIGN . ")";
$order = '`glpi_tickets`.`date_mod` DESC';
break;
case 'Group':
if ($tree) {
$restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")";
} else {
$restrict = "='" . $item->getID() . "'";
}
$restrict = "(`glpi_groups_tickets`.`groups_id` {$restrict}\n AND `glpi_groups_tickets`.`type` = " . CommonITILActor::REQUESTER . ")";
$order = '`glpi_tickets`.`date_mod` DESC';
break;
default:
$restrict = "(`items_id` = '" . $item->getID() . "' AND `itemtype` = '{$type}')";
$order = '`glpi_tickets`.`date_mod` DESC';
}
$query = "SELECT " . Ticket::getCommonSelect() . "\n FROM glpi_tickets " . Ticket::getCommonLeftJoin() . "\n WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n ORDER BY {$order}\n LIMIT " . intval($_SESSION['glpilist_limit']);
$result = $DB->query($query);
$number = $DB->numrows($result);
$pdf->setColumnsSize(100);
if (!$number) {
$pdf->displayTitle('<b>' . __('Last tickets') . '</b>');
} else {
$pdf->displayTitle("<b>" . sprintf(__('Last %d ticket') . "</b>", $number));
$job = new Ticket();
while ($data = $DB->fetch_assoc($result)) {
if (!$job->getFromDB($data["id"])) {
continue;
}
$pdf->setColumnsAlign('center');
$col = '<b><i>ID ' . $job->fields["id"] . '</i></b>, ' . sprintf(__('%1$s: %2$s'), __('Status'), Ticket::getStatus($job->fields["status"]));
if (count($_SESSION["glpiactiveentities"]) > 1) {
if ($job->fields['entities_id'] == 0) {
$col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity'));
} else {
$col = sprintf(__('%1$s (%2$s)'), $col, Dropdown::getDropdownName("glpi_entities", $job->fields['entities_id']));
}
}
$pdf->displayLine($col);
$pdf->setColumnsAlign('left');
$col = '<b><i>' . sprintf(__('Opened on %s') . '</i></b>', Html::convDateTime($job->fields['date']));
if ($job->fields['begin_waiting_date']) {
$col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('Put on hold on %s') . '</i></b>', Html::convDateTime($job->fields['begin_waiting_date'])));
}
if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) {
$col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('Solved on %s') . '</i></b>', Html::convDateTime($job->fields['solvedate'])));
}
if (in_array($job->fields["status"], $job->getClosedStatusArray())) {
$col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('Closed on %s') . '</i></b>', Html::convDateTime($job->fields['closedate'])));
}
if ($job->fields['due_date']) {
$col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', __('Due date'), Html::convDateTime($job->fields['due_date'])));
}
$pdf->displayLine($col);
$col = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Priority') . '</i></b>', Ticket::getPriorityName($job->fields["priority"]));
if ($job->fields["itilcategories_id"]) {
$col = sprintf(__('%1$s - %2$s'), $col, '<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', __('Category'), Dropdown::getDropdownName('glpi_itilcategories', $job->fields["itilcategories_id"])));
}
$pdf->displayLine($col);
$col = '';
$users = $job->getUsers(CommonITILActor::REQUESTER);
if (count($users)) {
foreach ($users as $d) {
if (empty($col)) {
$col = getUserName($d['users_id']);
} else {
$col = sprintf(__('%1$s, %2$s'), $col, getUserName($d['users_id']));
}
}
}
$grps = $job->getGroups(CommonITILActor::REQUESTER);
if (count($grps)) {
if (empty($col)) {
$col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' </i></b>');
} else {
$col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' </i></b>');
}
$first = true;
foreach ($grps as $d) {
if ($first) {
$col = sprintf(__('%1$s %2$s'), $col, Dropdown::getDropdownName("glpi_groups", $d['groups_id']));
} else {
//.........这里部分代码省略.........
示例11: cleanForItem
/**
* Hook called After an item is uninstall or purge
*/
static function cleanForItem(CommonDBTM $item)
{
$temp = new self();
$temp->deleteByCriteria(array('itemtype' => $item->getType(), 'items_id' => $item->getField('id')));
}
示例12: processMassiveActionsForOneItemtype
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'Generate':
$pbQRcode = new PluginBarcodeQRcode();
$rand = mt_rand();
$number = 0;
$codes = array();
if ($ma->POST['eliminate'] > 0) {
for ($nb = 0; $nb < $ma->POST['eliminate']; $nb++) {
$codes[] = '';
}
}
if ($ma->POST['type'] == 'QRcode') {
foreach ($ids as $key) {
$filename = $pbQRcode->generateQRcode($item->getType(), $key, $rand, $number, $ma->POST);
if ($filename) {
$codes[] = $filename;
$number++;
}
}
} else {
foreach ($ids as $key) {
$item->getFromDB($key);
if ($item->isField('otherserial')) {
$codes[] = $item->getField('otherserial');
}
}
}
if (count($codes) > 0) {
$params['codes'] = $codes;
$params['type'] = $ma->POST['type'];
$params['size'] = $ma->POST['size'];
$params['border'] = $ma->POST['border'];
$params['orientation'] = $ma->POST['orientation'];
$barcode = new PluginBarcodeBarcode();
$file = $barcode->printPDF($params);
$filePath = explode('/', $file);
$filename = $filePath[count($filePath) - 1];
$msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>";
Session::addMessageAfterRedirect($msg);
$pbQRcode->cleanQRcodefiles($rand, $number);
}
$ma->itemDone($item->getType(), 0, MassiveAction::ACTION_OK);
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例13: showForItem
/**
* Show rack associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated rack must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID) || !self::canView() || !$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginRacksRack');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$itemtype = $item->getType() . "Model";
$query = "SELECT `glpi_plugin_racks_racks_items`.`id` AS assocID,\n `glpi_plugin_racks_racks_items`.`faces_id`,\n `glpi_plugin_racks_racks_items`.`position`,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_racks_racks`.`name` AS assocName,\n `glpi_plugin_racks_racks`.*\n FROM `glpi_plugin_racks_racks_items`\n LEFT JOIN `glpi_plugin_racks_racks`\n ON (`glpi_plugin_racks_racks_items`.`plugin_racks_racks_id`=`glpi_plugin_racks_racks`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_racks_racks`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_racks_racks_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_racks_racks_items`.`itemtype` = '" . $itemtype . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_racks_racks", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$racks = array();
$rack = new PluginRacksRack();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$racks[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Disposition', 'racks') . "</th>";
echo "<th>" . __('Position', 'racks') . "</th>";
echo "<th>" . __('Location') . "</th>";
echo "<th>" . __('Place', 'racks') . "</th>";
echo "<th>" . __('Manufacturer') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginRacksRack', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($racks as $data) {
$rackID = $data["id"];
$link = NOT_AVAILABLE;
if ($rack->getFromDB($rackID)) {
$link = $rack->getLink();
}
Session::addToNavigateListItems('PluginRacksRack', $rackID);
$used[$rackID] = $rackID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
if ($data["faces_id"] == PluginRacksRack::FRONT_FACE) {
$faces_id = __('Front', 'racks');
} else {
$faces_id = _x('Rack enclosure', 'Back', 'racks');
}
echo "<td class='center'>" . $faces_id . "</td>";
echo "<td class='center'>" . $data["position"] . "</td>";
echo "<td>" . Dropdown::getDropdownName("glpi_locations", $data["locations_id"]) . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_racks_roomlocations", $data["plugin_racks_roomlocations_id"], 0) . "</td>";
echo "<td>" . Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]) . "</td>";
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
//.........这里部分代码省略.........
示例14: generateLinkContents
/**
* Generate link
*
* @param $link string original string content
* @param $item CommonDBTM object: item used to make replacements
*
* @return array of link contents (may have several when item have several IP / MAC cases)
**/
static function generateLinkContents($link, CommonDBTM $item)
{
global $DB;
if (strstr($link, "[ID]")) {
$link = str_replace("[ID]", $item->fields['id'], $link);
}
if (strstr($link, "[LOGIN]") && isset($_SESSION["glpiname"])) {
$link = str_replace("[LOGIN]", $_SESSION["glpiname"], $link);
}
if (strstr($link, "[NAME]")) {
$link = str_replace("[NAME]", $item->getName(), $link);
}
if (strstr($link, "[SERIAL]") && $item->isField('serial')) {
$link = str_replace("[SERIAL]", $item->getField('serial'), $link);
}
if (strstr($link, "[OTHERSERIAL]") && $item->isField('otherserial')) {
$link = str_replace("[OTHERSERIAL]", $item->getField('otherserial'), $link);
}
if (strstr($link, "[LOCATIONID]") && $item->isField('locations_id')) {
$link = str_replace("[LOCATIONID]", $item->getField('locations_id'), $link);
}
if (strstr($link, "[LOCATION]") && $item->isField('locations_id')) {
$link = str_replace("[LOCATION]", Dropdown::getDropdownName("glpi_locations", $item->getField('locations_id')), $link);
}
if (strstr($link, "[NETWORK]") && $item->isField('networks_id')) {
$link = str_replace("[NETWORK]", Dropdown::getDropdownName("glpi_networks", $item->getField('networks_id')), $link);
}
if (strstr($link, "[DOMAIN]") && $item->isField('domains_id')) {
$link = str_replace("[DOMAIN]", Dropdown::getDropdownName("glpi_domains", $item->getField('domains_id')), $link);
}
if (strstr($link, "[USER]") && $item->isField('users_id')) {
$link = str_replace("[USER]", Dropdown::getDropdownName("glpi_users", $item->getField('users_id')), $link);
}
if (strstr($link, "[GROUP]") && $item->isField('groups_id')) {
$link = str_replace("[GROUP]", Dropdown::getDropdownName("glpi_groups", $item->getField('groups_id')), $link);
}
if (strstr($link, "[REALNAME]") && $item->isField('realname')) {
$link = str_replace("[REALNAME]", $item->getField('realname'), $link);
}
if (strstr($link, "[FIRSTNAME]") && $item->isField('firstname')) {
$link = str_replace("[FIRSTNAME]", $item->getField('firstname'), $link);
}
$replace_IP = strstr($link, "[IP]");
$replace_MAC = strstr($link, "[MAC]");
if (!$replace_IP && !$replace_MAC) {
return array($link);
}
// Return several links id several IP / MAC
$ipmac = array();
if (get_class($item) == 'NetworkEquipment') {
if ($replace_IP) {
$query2 = "SELECT `glpi_ipaddresses`.`id`,\n `glpi_ipaddresses`.`name` AS ip\n FROM `glpi_networknames`, `glpi_ipaddresses`\n WHERE `glpi_networknames`.`items_id` = '" . $item->getID() . "'\n AND `glpi_networknames`.`itemtype` = 'NetworkEquipment'\n AND `glpi_ipaddresses`.`itemtype` = 'NetworkName'\n AND `glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`";
foreach ($DB->request($query2) as $data2) {
$ipmac['ip' . $data2['id']]['ip'] = $data2["ip"];
$ipmac['ip' . $data2['id']]['mac'] = $item->getField('mac');
}
}
if ($replace_MAC) {
// If there is no entry, then, we must at least define the mac of the item ...
if (count($ipmac) == 0) {
$ipmac['mac0']['ip'] = '';
$ipmac['mac0']['mac'] = $item->getField('mac');
}
}
}
if ($replace_IP) {
$query2 = "SELECT `glpi_ipaddresses`.`id`,\n `glpi_networkports`.`mac`,\n `glpi_ipaddresses`.`name` AS ip\n FROM `glpi_networkports`, `glpi_networknames`, `glpi_ipaddresses`\n WHERE `glpi_networkports`.`items_id` = '" . $item->getID() . "'\n AND `glpi_networkports`.`itemtype` = '" . $item->getType() . "'\n AND `glpi_networknames`.`itemtype` = 'NetworkPort'\n AND `glpi_networknames`.`items_id` = `glpi_networkports`.`id`\n AND `glpi_ipaddresses`.`itemtype` = 'NetworkName'\n AND `glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`";
foreach ($DB->request($query2) as $data2) {
$ipmac['ip' . $data2['id']]['ip'] = $data2["ip"];
$ipmac['ip' . $data2['id']]['mac'] = $data2["mac"];
}
}
if ($replace_MAC) {
$left = '';
$where = '';
if ($replace_IP) {
$left = " LEFT JOIN `glpi_networknames`\n ON (`glpi_networknames`.`items_id` = `glpi_networkports`.`id`\n AND `glpi_networknames`.`itemtype` = 'NetworkPort')";
$where = " AND `glpi_networknames`.`id` IS NULL";
}
$query2 = "SELECT `glpi_networkports`.`id`,\n `glpi_networkports`.`mac`\n FROM `glpi_networkports`\n {$left}\n WHERE `glpi_networkports`.`items_id` = '" . $item->getID() . "'\n AND `glpi_networkports`.`itemtype` = '" . $item->getType() . "'\n {$where}\n GROUP BY `glpi_networkports`.`mac`";
foreach ($DB->request($query2) as $data2) {
$ipmac['mac' . $data2['id']]['ip'] = '';
$ipmac['mac' . $data2['id']]['mac'] = $data2["mac"];
}
}
$links = array();
if (count($ipmac) > 0) {
foreach ($ipmac as $key => $val) {
$tmplink = $link;
$disp = 1;
if (strstr($link, "[IP]")) {
if (empty($val['ip'])) {
//.........这里部分代码省略.........
示例15: showForItem
/**
* Show documents associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated documents must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if ($item->getType() != 'Ticket' && $item->getType() != 'KnowbaseItem' && $item->getType() != 'Reminder' && !Document::canView()) {
return false;
}
$params = array();
$params['rand'] = mt_rand();
self::showAddFormForItem($item, $withtemplate, $params);
self::showListForItem($item, $withtemplate, $params);
}