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();
 }
Example #2
0
 static function pdfDevice(PluginPdfSimplePDF $pdf, Computer $computer)
 {
     global $DB;
     $devtypes = Item_Devices::getDeviceTypes();
     $ID = $computer->getField('id');
     if (!$computer->can($ID, 'r')) {
         return false;
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . Toolbox::ucfirst(_n('Component', 'Components', 2)) . '</b>');
     $pdf->setColumnsSize(3, 14, 42, 41);
     foreach ($devtypes as $itemtype) {
         $devicetypes = new $itemtype();
         $specificities = $devicetypes->getSpecificities();
         $specif_fields = array_keys($specificities);
         $specif_text = implode(',', $specif_fields);
         if (!empty($specif_text)) {
             $specif_text = " ," . $specif_text . " ";
         }
         $associated_type = str_replace('Item_', '', $itemtype);
         $linktable = getTableForItemType($itemtype);
         $fk = getForeignKeyFieldForTable(getTableForItemType($associated_type));
         $query = "SELECT count(*) AS NB, `id`, `" . $fk . "`" . $specif_text . "\n                   FROM `" . $linktable . "`\n                   WHERE `items_id` = '" . $ID . "'\n                   AND `itemtype` = 'Computer'\n                   GROUP BY `" . $fk . "`" . $specif_text;
         $device = new $associated_type();
         foreach ($DB->request($query) as $data) {
             if ($device->getFromDB($data[$fk])) {
                 $spec = $device->getAdditionalFields();
                 $col4 = '';
                 if (count($spec)) {
                     $colspan = 60 / count($spec);
                     foreach ($spec as $i => $label) {
                         if (isset($device->fields[$label["name"]]) && !empty($device->fields[$label["name"]])) {
                             if ($label["type"] == "dropdownValue" && $device->fields[$label["name"]] != 0) {
                                 $table = getTableNameForForeignKeyField($label["name"]);
                                 $value = Dropdown::getDropdownName($table, $device->fields[$label["name"]]);
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', Html::clean($value) . " ");
                             } else {
                                 $value = $device->fields[$label["name"]];
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $value . " ");
                             }
                         } else {
                             if (isset($device->fields[$label["name"] . "_default"]) && !empty($device->fields[$label["name"] . "_default"])) {
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $device->fields[$label["name"] . "_default"] . " ");
                             }
                         }
                     }
                 }
                 $pdf->displayLine($data['NB'], $device->getTypeName(), $device->getName(), $col4);
             }
         }
     }
     $pdf->displaySpace();
 }
 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();
 }
 static function pdfForLicenseByComputer(PluginPdfSimplePDF $pdf, SoftwareLicense $license)
 {
     global $DB;
     $ID = $license->getField('id');
     $query_number = "SELECT COUNT(*) AS cpt\n                       FROM `glpi_computers_softwarelicenses`\n                       INNER JOIN `glpi_computers`\n                           ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n                       WHERE `glpi_computers_softwarelicenses`.`softwarelicenses_id` = '" . $ID . "'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                             AND `glpi_computers`.`is_deleted` = '0'\n                             AND `glpi_computers`.`is_template` = '0'";
     $number = 0;
     if ($result = $DB->query($query_number)) {
         $number = $DB->result($result, 0, 0);
     }
     $pdf->setColumnsSize(100);
     $pdf->setColumnsAlign('center');
     $title = '<b>' . __('Affected computers') . '</b>';
     if ($number) {
         if ($number > $_SESSION['glpilist_limit']) {
             $title = sprintf(__('%1$s: %2$s'), $title, $_SESSION['glpilist_limit'] . ' / ' . $number);
         } else {
             $title = sprintf(__('%1$s: %2$s'), $title, $number);
         }
         $pdf->displayTitle($title);
         $query = "SELECT `glpi_computers_softwarelicenses`.*,\n                          `glpi_computers`.`name` AS compname,\n                          `glpi_computers`.`id` AS cID,\n                          `glpi_computers`.`serial`,\n                          `glpi_computers`.`otherserial`,\n                          `glpi_users`.`name` AS username,\n                          `glpi_softwarelicenses`.`name` AS license,\n                          `glpi_softwarelicenses`.`id` AS vID,\n                          `glpi_softwarelicenses`.`name` AS vername,\n                          `glpi_entities`.`name` AS entity,\n                          `glpi_locations`.`completename` AS location,\n                          `glpi_states`.`name` AS state,\n                          `glpi_groups`.`name` AS groupe,\n                          `glpi_softwarelicenses`.`name` AS lname,\n                          `glpi_softwarelicenses`.`id` AS lID\n                   FROM `glpi_computers_softwarelicenses`\n                   INNER JOIN `glpi_softwarelicenses`\n                        ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                                = `glpi_softwarelicenses`.`id`)\n                   INNER JOIN `glpi_computers`\n                        ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n                   LEFT JOIN `glpi_entities`\n                        ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n                   LEFT JOIN `glpi_locations`\n                        ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n                   LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n                   LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n                   LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n                   WHERE (`glpi_softwarelicenses`.`id` = '" . $ID . "') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                         AND `glpi_computers`.`is_deleted` = '0'\n                         AND `glpi_computers`.`is_template` = '0'\n                   ORDER BY `entity`, `compname`\n                   LIMIT 0," . intval($_SESSION['glpilist_limit']);
         $result = $DB->query($query);
         $showEntity = $license->isRecursive();
         if ($showEntity) {
             $pdf->setColumnsSize(12, 12, 12, 12, 16, 12, 12, 12);
             $pdf->displayTitle('<b><i>' . __('Entity'), __('Name'), __('Serial number'), __('Inventory number'), __('Location'), __('Status'), __('Group'), __('User') . '</i></b>');
         } else {
             $pdf->setColumnsSize(14, 14, 14, 18, 14, 13, 13);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Serial number'), __('Inventory number'), __('Location'), __('Status'), __('Group'), __('User') . '</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']);
             }
             $entname = empty($data['entity']) ? __('Root entity') : $data['entity'];
             if ($showEntity) {
                 $pdf->displayLine($entname, $compname, $data['serial'], $data['otherserial'], $data['location'], $data['state'], $data['groupe'], $data['username']);
             } else {
                 $pdf->displayLine($compname, $data['serial'], $data['otherserial'], $data['location'], $data['state'], $data['groupe'], $data['username']);
             }
         }
     } else {
         $pdf->displayTitle(sprintf(__('%1$s: %2$s'), $title, __('No item found')));
     }
     $pdf->displaySpace();
 }
Example #5
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////Tasks///////////
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_tickettasks`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No task found.'));
     } else {
         $pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>"));
         $pdf->setColumnsSize(20, 20, 20, 20, 20);
         $pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $actiontime = Html::timestampToString($data['actiontime'], false);
             $planification = '';
             if (empty($data['begin'])) {
                 if (isset($data["state"])) {
                     $planification = Planning::getState($data["state"]) . "<br>";
                 }
                 $planification .= _e('None');
             } else {
                 if (isset($data["state"])) {
                     $planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"]));
                 }
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"]));
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s  %2$s'), __('By'), getUserName($data["users_id_tech"])));
             }
             if ($data['taskcategories_id']) {
                 $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             toolbox::logdebug("lib", $data);
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1));
         }
     }
     $pdf->displaySpace();
 }
 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $query = "SELECT `glpi_filesystems`.`name` AS fsname, `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 . "')";
     $result = $DB->query($query);
     $pdf->setColumnsSize(100);
     if ($DB->numrows($result) > 0) {
         $pdf->displayTitle("<b>" . _n('Volume', 'Volumes', 2) . "</b>");
         $pdf->setColumnsSize(22, 23, 22, 11, 11, 11);
         $pdf->displayTitle('<b>' . __('Name'), __('Partition'), _('Mount point'), __('Type'), __('Global size'), __('Free size') . '</b>');
         $pdf->setColumnsAlign('left', 'left', 'left', 'center', 'right', 'right');
         while ($data = $DB->fetch_assoc($result)) {
             $pdf->displayLine('<b>' . Toolbox::decodeFromUtf8(empty($data['name']) ? $data['ID'] : $data['name'], "windows-1252") . '</b>', $data['device'], $data['mountpoint'], Html::clean(Dropdown::getDropdownName('glpi_filesystems', $data["filesystems_id"])), sprintf(__('%s Mio'), Html::clean(Html::formatNumber($data['totalsize'], false, 0))), sprintf(__('%s Mio'), Html::clean(Html::formatNumber($data['freesize'], false, 0))));
         }
     } else {
         $pdf->displayTitle("<b>" . __('No volume found', 'pdf') . "</b>");
     }
     $pdf->displaySpace();
 }
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////followups///////////
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Ticket followup') . "</b>");
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_ticketfollowups`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->displayLine(__('No followup for this ticket.'));
     } else {
         while ($data = $DB->fetch_array($result)) {
             $pdf->setColumnsSize(44, 14, 42);
             $pdf->displayTitle("<b><i>" . __('Source of followup') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Requester') . "</i></b>");
             // Author
             if ($data['requesttypes_id']) {
                 $lib = Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::clean(getUserName($data["users_id"])));
             $pdf->displayText('<b><i>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</i></b>', $data["content"]));
         }
     }
     $pdf->displaySpace();
 }
Example #8
0
 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();
 }
Example #9
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     // Get the Full history for the item (really a good idea ?, should we limit this)
     $changes = Log::getHistoryData($item);
     $pdf->setColumnsSize(100);
     if (count($changes) > 0) {
         $pdf->displayTitle("<b>" . __('Historical') . "</b>");
         $pdf->setColumnsSize(14, 15, 20, 51);
         $pdf->displayTitle('<b><i>' . __('ID'), __('Date'), __('User'), __('Field'), _x('name', 'Update') . '</i></b>');
         foreach ($changes as $data) {
             if ($data['display_history']) {
                 $pdf->displayLine($data['id'], $data['date_mod'], $data['user_name'], $data['field'], Html::clean($data['change']));
             }
         }
         // Each log
     } else {
         $pdf->displayTitle("<b>" . __('No historical') . "</b>");
     }
     $pdf->displaySpace();
 }
Example #10
0
 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();
 }
Example #11
0
 static function exportAsPDF($models_id)
 {
     $logresults = self::prepareLogResults($models_id);
     $model = new self();
     $model->getFromDB($models_id);
     if (!empty($logresults)) {
         $pdf = new PluginPdfSimplePDF('a4', 'landscape');
         $pdf->setHeader(sprintf(__('%1$s (%2$s)'), __('File injection report', 'datainjection') . ' - <b>' . PluginDatainjectionSession::getParam('file_name') . '</b>', $model->getName()));
         $pdf->newPage();
         if (isset($logresults[PluginDatainjectionCommonInjectionLib::SUCCESS])) {
             $pdf->setColumnsSize(100);
             $pdf->displayTitle('<b>' . __('Array of successful injections', 'datainjection') . '</b>');
             $pdf->setColumnsSize(6, 54, 20, 20);
             $pdf->setColumnsAlign('center', 'center', 'center', 'center');
             $col0 = '<b>' . __('Line', 'datainjection') . '</b>';
             $col1 = '<b>' . __('Data Import', 'datainjection') . '</b>';
             $col2 = '<b>' . __('Injection type', 'datainjection') . '</b>';
             $col3 = '<b>' . __('Object Identifier', 'datainjection') . '</b>';
             $pdf->displayTitle($col0, $col1, $col2, $col3);
             $index = 0;
             foreach ($logresults[PluginDatainjectionCommonInjectionLib::SUCCESS] as $result) {
                 $pdf->displayLine($result['line'], $result['status_message'], $result['type'], $result['item']);
             }
         }
         if (isset($logresults[PluginDatainjectionCommonInjectionLib::FAILED])) {
             $pdf->setColumnsSize(100);
             $pdf->displayTitle('<b>' . __('Array of unsuccessful injections', 'datainjection') . '</b>');
             $pdf->setColumnsSize(6, 16, 38, 20, 20);
             $pdf->setColumnsAlign('center', 'center', 'center', 'center', 'center');
             $col0 = '<b>' . __('Line', 'datainjection') . '</b>';
             $col1 = '<b>' . __('Data check', 'datainjection') . '</b>';
             $col2 = '<b>' . __('Data Import', 'datainjection') . '</b>';
             $col3 = '<b>' . __('Injection type', 'datainjection') . '</b>';
             $col4 = '<b>' . __('Object Identifier', 'datainjection') . '</b>';
             $pdf->displayTitle($col0, $col1, $col2, $col3, $col4);
             $index = 0;
             foreach ($logresults[PluginDatainjectionCommonInjectionLib::FAILED] as $result) {
                 $pdf->setColumnsSize(6, 16, 38, 20, 20);
                 $pdf->setColumnsAlign('center', 'center', 'center', 'center', 'center');
                 $pdf->displayLine($result['line'], $result['check_sumnary'], $result['status_message'], $result['type'], $result['item']);
                 if ($result['check_message']) {
                     $pdf->displayText('<b>' . __('Data check', 'datainjection') . '</b> :', $result['check_message'], 1);
                 }
             }
         }
         $pdf->render();
     }
 }
Example #12
0
 static function pdfForGroup(PluginPdfSimplePDF $pdf, Group $group, $tree)
 {
     global $DB, $CFG_GLPI;
     $used = array();
     $ids = array();
     // Retrieve member list
     $entityrestrict = Group_User::getDataForGroup($group, $used, $ids, '', $tree);
     $title = "<b>" . sprintf(__('%1$s (%2$s)'), _n('User', 'Users', 2) . "</b>", __('D=Dynamic'));
     $number = count($used);
     if ($number > $_SESSION['glpilist_limit']) {
         $title = sprintf(__('%1$s (%2$s)'), $title, $_SESSION['glpilist_limit'] . "/" . $number);
     } else {
         $title = sprintf(__('%1$s (%2$s)'), $title, $number);
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle($title);
     if ($number) {
         $user = new User();
         $group = new Group();
         if ($tree) {
             $pdf->setColumnsSize(35, 45, 10, 10);
             $pdf->displayTitle(User::getTypeName(1), Group::getTypeName(1), __('Manager'), __('Delegatee'));
         } else {
             $pdf->setColumnsSize(60, 20, 20);
             $pdf->displayTitle(User::getTypeName(1), __('Manager'), __('Delegatee'));
         }
         for ($i = 0; $i < $number && $i < $_SESSION['glpilist_limit']; $i++) {
             $data = $used[$i];
             $name = Html::clean(getUserName($data["id"]));
             if ($data["is_dynamic"]) {
                 $name = sprintf(__('%1$s (%2$s)'), $name, '<b>' . __('D') . '</b>');
             }
             if ($tree) {
                 $group->getFromDB($data["groups_id"]);
                 $pdf->displayLine($name, $group->getName(), Dropdown::getYesNo($data['is_manager']), Dropdown::getYesNo($data['is_userdelegate']));
             } else {
                 $pdf->displayLine($name, Dropdown::getYesNo($data['is_manager']), Dropdown::getYesNo($data['is_userdelegate']));
             }
         }
     } else {
         $pdf->setColumnsAlign('center');
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
 /**
  * show for PDF the webapplications associated with a device
  *
  * @param $pdf
  * @param $item
  *
  **/
 static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item)
 {
     global $DB, $CFG_GLPI;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . _n('Associated web application', 'Associated web applications', 2, 'webapplications') . '</b>');
     $ID = $item->getField('id');
     $itemtype = get_Class($item);
     $canread = $item->can($ID, READ);
     $canedit = $item->can($ID, UPDATE);
     $web = new PluginWebapplicationsWebapplication();
     $query = "SELECT `glpi_plugin_webapplications_webapplications`.* " . " FROM `glpi_plugin_webapplications_webapplications_items`,`glpi_plugin_webapplications_webapplications` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_webapplications_webapplications`.`entities_id`) " . " WHERE `glpi_plugin_webapplications_webapplications_items`.`items_id` = '" . $ID . "' \n         AND `glpi_plugin_webapplications_webapplications_items`.`itemtype` = '" . $itemtype . "' \n         AND `glpi_plugin_webapplications_webapplications_items`.`plugin_webapplications_webapplications_id` = `glpi_plugin_webapplications_webapplications`.`id` " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_webapplications_webapplications", '', '', $web->maybeRecursive());
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         if (Session::isMultiEntitiesMode()) {
             $pdf->setColumnsSize(25, 25, 15, 15, 20);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Technician in charge of the hardware'), __('Group in charge of the hardware'), PluginWebapplicationsWebapplicationType::getTypeName(1) . '</i></b>');
         } else {
             $pdf->setColumnsSize(30, 30, 20, 20);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Technician in charge of the hardware'), __('Group in charge of the hardware'), PluginWebapplicationsWebapplicationType::getTypeName(1) . '</i></b>');
         }
         while ($data = $DB->fetch_array($result)) {
             $webapplicationsID = $data["id"];
             if (Session::isMultiEntitiesMode()) {
                 $pdf->setColumnsSize(25, 25, 15, 15, 20);
                 $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id'])), Html::clean(getUsername("glpi_users", $data["users_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtypes", $data["plugin_webapplications_webapplicationtypes_id"])));
             } else {
                 $pdf->setColumnsSize(50, 25, 25);
                 $pdf->displayLine($data["name"], Html::clean(getUsername("glpi_users", $data["users_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtypes", $data["plugin_webapplications_webapplicationtypes_id"])));
             }
         }
     }
 }
Example #14
0
 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();
 }
 static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $item)
 {
     global $DB;
     $sID = $item->getField('id');
     $query = "SELECT `glpi_softwareversions`.*,\n                       `glpi_states`.`name` AS sname,\n                       `glpi_operatingsystems`.`name` AS osname\n                FROM `glpi_softwareversions`\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_operatingsystems`\n                     ON (`glpi_operatingsystems`.`id` = `glpi_softwareversions`.`operatingsystems_id`)\n                WHERE (`softwares_id` = '" . $sID . "')\n                ORDER BY `name`";
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . SoftwareVersion::getTypeName(2) . '</b>');
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result) > 0) {
             $pdf->setColumnsSize(13, 13, 30, 14, 30);
             $pdf->displayTitle('<b><i>' . SoftwareVersion::getTypeName(2) . '</i></b>', '<b><i>' . __('Status') . '</i></b>', '<b><i>' . __('Operating system') . '</i></b>', '<b><i>' . _n('Installation', 'Installations', 2) . '</i></b>', '<b><i>' . __('Comments') . '</i></b>');
             $pdf->setColumnsAlign('left', 'left', 'left', 'right', 'left');
             for ($tot = $nb = 0; $data = $DB->fetch_assoc($result); $tot += $nb) {
                 $nb = Computer_SoftwareVersion::countForVersion($data['id']);
                 $pdf->displayLine(empty($data['name']) ? "(" . $data['id'] . ")" : $data['name'], $data['sname'], $data['osname'], $nb, str_replace(array("\r", "\n"), " ", $data['comment']));
             }
             $pdf->setColumnsAlign('left', 'right', 'left', 'right', 'left');
             $pdf->displayTitle('', '', "<b>" . sprintf(__('%1$s: %2$s'), __('Total') . "</b>", ''), $tot, '');
         } else {
             $pdf->displayLine(__('No item found'));
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
 /**
  * Show for PDF an projet - Hierarchy
  * 
  * @param $pdf object for the output
  * @param $ID of the projet
  */
 static function pdfHierarchyForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli, $parents = 0)
 {
     global $DB, $CFG_GLPI;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_projet_haveRight("projet", "r")) {
         return false;
     }
     $pdf->setColumnsSize(100);
     if ($parents) {
         $pdf->displayTitle('<b>' . __('Parent project', 'projet') . '</b>');
     } else {
         $pdf->displayTitle('<b>' . _n('Child project', 'Child projects', 2, 'projet') . '</b>');
     }
     $first = false;
     $query = "SELECT `" . $appli->gettable() . "`.*  ";
     if ($parents != 0) {
         $parent = "plugin_projet_projets_id_1";
         $child = "plugin_projet_projets_id_2";
     } else {
         $parent = "plugin_projet_projets_id_2";
         $child = "plugin_projet_projets_id_1";
     }
     $query .= " FROM `glpi_plugin_projet_projets`";
     $query .= " LEFT JOIN `glpi_plugin_projet_projets_projets` \n                  ON (`glpi_plugin_projet_projets_projets`.`{$child}` = `glpi_plugin_projet_projets`.`id`)";
     $query .= " WHERE `glpi_plugin_projet_projets_projets`.`{$parent}` = '{$ID}' ";
     if ($appli->maybeTemplate()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $query .= $LINK . "`" . $appli->getTable() . "`.`is_template` = '0' ";
     }
     // Add is_deleted if item have it
     if ($appli->maybeDeleted()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $query .= $LINK . "`" . $appli->getTable() . "`.`is_deleted` = '0' ";
     }
     $LINK = " AND ";
     $query .= getEntitiesRestrictRequest(" AND ", $appli->gettable(), '', '', $appli->maybeRecursive());
     $query .= " ORDER BY `" . $appli->gettable() . "`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         if (Session::isMultiEntitiesMode()) {
             $pdf->setColumnsSize(17, 17, 17, 17, 16, 16);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Progress'), _n('State', 'States', 1), __('Start date'), __('End date') . '</i></b>');
         } else {
             $pdf->setColumnsSize(20, 17, 17, 17, 17);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Progress'), _n('State', 'States', 1), __('Start date'), __('End date') . '</i></b>');
         }
         while ($data = $DB->fetch_array($result)) {
             $items_id_display = "";
             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                 $items_id_display = " (" . $data["id"] . ")";
             }
             $name = $data["name"] . $items_id_display;
             $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id']));
             if (Session::isMultiEntitiesMode()) {
                 $pdf->setColumnsSize(17, 17, 17, 17, 16, 16);
                 $pdf->displayLine($name, $entity, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $data['plugin_projet_projetstates_id'])), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"]));
             } else {
                 $pdf->setColumnsSize(20, 17, 17, 17, 17);
                 $pdf->displayLine($name, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $data['plugin_projet_projetstates_id'])), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"]));
             }
         }
     }
     $pdf->displaySpace();
 }
Example #17
0
 /**
  * @param $pdf                PluginPdfSimplePDF object
  * @param $p                  Printer object
  * @param $old
  **/
 static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old = false)
 {
     global $DB, $CFG_GLPI;
     $instID = $p->getField('id');
     if (!Session::haveRight("cartridge", "r")) {
         return false;
     }
     $dateout = "IS NULL ";
     if ($old) {
         $dateout = " IS NOT NULL ";
     }
     $query = "SELECT `glpi_cartridgeitems`.`id` AS tid,\n                       `glpi_cartridgeitems`.`ref`,\n                       `glpi_cartridgeitems`.`name`,\n                       `glpi_cartridges`.`id`,\n                       `glpi_cartridges`.`pages`,\n                       `glpi_cartridges`.`date_use`,\n                       `glpi_cartridges`.`date_out`,\n                       `glpi_cartridges`.`date_in`\n                FROM `glpi_cartridges`, `glpi_cartridgeitems`\n                WHERE `glpi_cartridges`.`date_out` " . $dateout . "\n                      AND `glpi_cartridges`.`printers_id` = '" . $instID . "'\n                      AND `glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`\n                ORDER BY `glpi_cartridges`.`date_out` ASC,\n                         `glpi_cartridges`.`date_use` DESC,\n                         `glpi_cartridges`.`date_in`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $pages = $p->fields['init_pages_counter'];
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . ($old ? __('Worn cartridges') : __('Used cartridges')) . "</b>");
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         $pdf->setColumnsSize(25, 13, 12, 12, 12, 26);
         $pdf->displayTitle('<b><i>' . __('Cartridge type'), __('State'), __('Add date'), __('Use date'), __('End date'), __('Printer counter') . '</b></i>');
         $stock_time = 0;
         $use_time = 0;
         $pages_printed = 0;
         $nb_pages_printed = 0;
         while ($data = $DB->fetch_array($result)) {
             $date_in = Html::convDate($data["date_in"]);
             $date_use = Html::convDate($data["date_use"]);
             $date_out = Html::convDate($data["date_out"]);
             $col1 = sprintf(__('%1$s - %2$s'), $data["name"], $data["ref"]);
             $col2 = Cartridge::getStatus($data["date_use"], $data["date_out"]);
             $col6 = '';
             $tmp_dbeg = explode("-", $data["date_in"]);
             $tmp_dend = explode("-", $data["date_use"]);
             $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
             $stock_time += $stock_time_tmp;
             if ($old) {
                 $tmp_dbeg = explode("-", $data["date_use"]);
                 $tmp_dend = explode("-", $data["date_out"]);
                 $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
                 $use_time += $use_time_tmp;
                 $col6 = $data['pages'];
                 if ($pages < $data['pages']) {
                     $pages_printed += $data['pages'] - $pages;
                     $nb_pages_printed++;
                     $col6 = sprintf(__('%1$s (%2$s)'), $col6, __('%d printed pages'), $data['pages'] - $pages);
                     $pages = $data['pages'];
                 }
             }
             $pdf->displayLine($col1, $col2, $date_in, $date_use, $date_out, $col6);
         }
         // Each cartridge
     }
     if ($old) {
         if ($number > 0) {
             if ($nb_pages_printed == 0) {
                 $nb_pages_printed = 1;
             }
             $nbstock = round($stock_time / $number / 60 / 60 / 24 / 30.5, 1);
             $nbuse = round($use_time / $number / 60 / 60 / 24 / 30.5, 1);
             $pdf->setColumnsSize(33, 33, 34);
             $pdf->displayTitle("<b><i>" . sprintf(__('%1$s: %2$s'), __('Average time in stock') . "</i></b>", _n('%d month', '%d months', $nbstock), $nbstock), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Average time in use') . "</i></b>", _n('%d month', '%d months', $nbuse), $nbuse), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Average number of printed pages') . "</i></b>", round($pages_printed / $nb_pages_printed)));
         }
         $pdf->displaySpace();
     }
 }
Example #18
0
 static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item)
 {
     global $DB;
     $ID = $item->getField('id');
     if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) {
         return false;
     }
     $knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id');
     $fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id));
     $question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8")));
     $answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8")));
     $pdf->setColumnsSize(100);
     if (Toolbox::strlen($fullcategoryname) > 0) {
         $pdf->displayTitle('<b>' . __('Category name') . '</b>');
         $pdf->displayLine($fullcategoryname);
     }
     if (Toolbox::strlen($question) > 0) {
         $pdf->displayTitle('<b>' . __('Subject') . '</b>');
         $pdf->displayText('', $question, 5);
     } else {
         $pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>');
     }
     if (Toolbox::strlen($answer) > 0) {
         $pdf->displayTitle('<b>' . __('Content') . '</b>');
         $pdf->displayText('', $answer, 5);
     } else {
         $pdf->displayTitle('<b>' . __('No answer found') . '</b>');
     }
     $pdf->setColumnsSize(50, 15, 15, 10, 10);
     $pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2));
     $pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]);
     $pdf->displaySpace();
 }
 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
 {
     global $DB;
     $ID = $comp->getField('id');
     // From Computer_SoftwareVersion::showForComputer();
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version\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_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$ID}'\n                ORDER BY `softwarecategories_id`, `softname`, `version`";
     $output = array();
     $software_category = new SoftwareCategory();
     $software_version = new SoftwareVersion();
     foreach ($DB->request($query) as $softwareversion) {
         $output[] = $softwareversion;
     }
     $installed = array();
     if (count($output)) {
         $pdf->setColumnsSize(100);
         $pdf->displayTitle('<b>' . _n('Installed software', 'Installed software', 2, 'pdf') . '</b>');
         $cat = -1;
         foreach ($output as $soft) {
             if ($soft["softwarecategories_id"] != $cat) {
                 $cat = $soft["softwarecategories_id"];
                 if ($cat && $software_category->getFromDB($cat)) {
                     $catname = $software_category->getName();
                 } else {
                     $catname = __('Uncategorized software');
                 }
                 $pdf->setColumnsSize(100);
                 $pdf->displayTitle('<b>' . $catname . '</b>');
                 $pdf->setColumnsSize(50, 13, 13, 24);
                 $pdf->displayTitle('<b>' . __('Name'), __('Status'), __('Version'), __('License') . '</b>');
             }
             // From Computer_SoftwareVersion::displaySoftsByCategory()
             $verid = $soft['verid'];
             $query = "SELECT `glpi_softwarelicenses`.*,\n                             `glpi_softwarelicensetypes`.`name` AS type\n                      FROM `glpi_computers_softwarelicenses`\n                      INNER JOIN `glpi_softwarelicenses`\n                           ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                                    = `glpi_softwarelicenses`.`id`)\n                      LEFT JOIN `glpi_softwarelicensetypes`\n                           ON (`glpi_softwarelicenses`.`softwarelicensetypes_id`\n                                    =`glpi_softwarelicensetypes`.`id`)\n                      WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}'\n                            AND (`glpi_softwarelicenses`.`softwareversions_id_use` = '{$verid}'\n                                 OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                                     AND `glpi_softwarelicenses`.`softwareversions_id_buy` = '{$verid}'))";
             $lic = '';
             foreach ($DB->request($query) as $licdata) {
                 $installed[] = $licdata['id'];
                 $lic .= (empty($lic) ? '' : ', ') . '<b>' . $licdata['name'] . '</b> ' . $licdata['serial'];
                 if (!empty($licdata['type'])) {
                     $lic = sprintf(__('%1$s (%2$s)'), $lic, $licdata['type']);
                 }
             }
             $pdf->displayLine($soft['softname'], $soft['state'], $soft['version'], $lic);
         }
         // Each version
     } else {
         $pdf->displayTitle('<b>' . __('No installed software', 'pdf') . '</b>');
     }
     // Affected licenses NOT installed
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_states`.`name` AS state\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_computers_softwarelicenses`\n                      ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n                              = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_softwares`\n                      ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                LEFT JOIN `glpi_softwareversions`\n                      ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n                              = `glpi_softwareversions`.`id`\n                           OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                               AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n                                       = `glpi_softwareversions`.`id`))\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}' ";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($req->numrows()) {
         $pdf->setColumnsSize(100);
         $pdf->displayTitle('<b>' . __('Affected licenses of not installed software') . '</b>');
         $pdf->setColumnsSize(50, 13, 13, 24);
         $pdf->displayTitle('<b>' . __('Name'), __('Status'), __('Version'), __('License') . '</b>');
         $lic = '';
         foreach ($req as $data) {
             $lic .= '<b>' . $data['name'] . '</b> ' . $data['serial'];
             if (!empty($data['softwarelicensetypes_id'])) {
                 $lic = sprintf(__('%1$s (%2$s)'), $lic, Html::Clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $data['softwarelicensetypes_id'])));
             }
             $pdf->displayLine($data['softname'], $data['state'], $data['version'], $lic);
         }
     }
     $pdf->displaySpace();
 }
Example #20
0
 /**
  * Show for PDF an resources : employee informations
  * 
  * @param $pdf object for the output
  * @param $appli PluginResourcesResource Class
  */
 static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli)
 {
     global $DB;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_resources_haveRight("resources", "r")) {
         return false;
     }
     $query = "SELECT * \n               FROM `glpi_plugin_resources_employees` \n               WHERE `plugin_resources_resources_id` = '{$ID}'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . self::getTypeName(1) . '</b>');
     $pdf->setColumnsSize(33, 33, 34);
     $pdf->displayTitle('<b><i>' . PluginResourcesEmployer::getTypeName(1), PluginResourcesClient::getTypeName(1) . '</i></b>');
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         for ($i = 0; $i < $number; $i++) {
             $employer = $DB->result($result, $i, "plugin_resources_employers_id");
             $client = $DB->result($result, $i, "plugin_resources_clients_id");
             $pdf->displayLine(Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_employers", $employer)), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_clients", $client)));
         }
     }
     $pdf->displaySpace();
 }
 static function pdfForAppliance(PluginPdfSimplePDF $pdf, PluginAppliancesAppliance $appli)
 {
     global $DB, $CFG_GLPI;
     $instID = $appli->fields['id'];
     if (!$appli->can($instID, "r")) {
         return false;
     }
     if (!plugin_appliances_haveRight("appliance", "r")) {
         return false;
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('Associated items', 'behaviors') . '</b>');
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_plugin_appliances_appliances_items`\n                WHERE `plugin_appliances_appliances_id` = '" . $instID . "'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (Session::isMultiEntitiesMode()) {
         $pdf->setColumnsSize(12, 27, 25, 18, 18);
         $pdf->displayTitle('<b><i>' . __('Type'), __('Name'), __('Entity'), __('Serial number'), __('Inventory number') . '</i></b>');
     } else {
         $pdf->setColumnsSize(25, 31, 22, 22);
         $pdf->displayTitle('<b><i>' . __('Type'), __('Name'), __('Serial number'), __('Inventory number') . '</i></b>');
     }
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         for ($i = 0; $i < $number; $i++) {
             $type = $DB->result($result, $i, "itemtype");
             if (!($item = getItemForItemtype($type))) {
                 continue;
             }
             if ($item->canView()) {
                 $column = "name";
                 if ($type == 'Ticket') {
                     $column = "id";
                 }
                 if ($type == 'KnowbaseItem') {
                     $column = "question";
                 }
                 $query = "SELECT `" . $item->getTable() . "`.*,\n                                `glpi_plugin_appliances_appliances_items`.`id` AS IDD,\n                                `glpi_entities`.`id` AS entity\n                         FROM `glpi_plugin_appliances_appliances_items`, `" . $item->getTable() . "`\n                         LEFT JOIN `glpi_entities`\n                              ON (`glpi_entities`.`id` = `" . $item->getTable() . "`.`entities_id`)\n                         WHERE `" . $item->getTable() . "`.`id`\n                                    = `glpi_plugin_appliances_appliances_items`.`items_id`\n                               AND `glpi_plugin_appliances_appliances_items`.`itemtype` = '" . $type . "'\n                               AND `glpi_plugin_appliances_appliances_items`.`plugin_appliances_appliances_id`\n                                    = '" . $instID . "' " . getEntitiesRestrictRequest(" AND ", $item->getTable());
                 if ($item->maybeTemplate()) {
                     $query .= " AND `" . $item->getTable() . "`.`is_template` = '0'";
                 }
                 $query .= " ORDER BY `glpi_entities`.`completename`, `" . $item->getTable() . "`.{$column}";
                 if ($result_linked = $DB->query($query)) {
                     if ($DB->numrows($result_linked)) {
                         while ($data = $DB->fetch_assoc($result_linked)) {
                             if (!$item->getFromDB($data["id"])) {
                                 continue;
                             }
                             if ($type == 'Ticket') {
                                 $data["name"] = sprintf(__('%1$s %2$s'), __('Ticket'), $data["id"]);
                             }
                             if ($type == 'KnowbaseItem') {
                                 $data["name"] = $data["question"];
                             }
                             $name = $data["name"];
                             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                                 $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
                             }
                             if (Session::isMultiEntitiesMode()) {
                                 $pdf->setColumnsSize(12, 27, 25, 18, 18);
                                 $pdf->displayLine($item->getTypeName(), $name, Dropdown::getDropdownName("glpi_entities", $data['entities_id']), isset($data["serial"]) ? $data["serial"] : "-", isset($data["otherserial"]) ? $data["otherserial"] : "-");
                             } else {
                                 $pdf->setColumnsSize(25, 31, 22, 22);
                                 $pdf->displayTitle($item->getTypeName(), $name, isset($data["serial"]) ? $data["serial"] : "-", isset($data["otherserial"]) ? $data["otherserial"] : "-");
                             }
                             PluginAppliancesRelation::showList_PDF($pdf, $appli->fields["relationtype"], $data["IDD"]);
                             PluginAppliancesOptvalue_Item::showList_PDF($pdf, $data["id"], $instID);
                         }
                         // Each device
                     }
                     // numrows device
                 }
             }
             // type right
         }
         // each type
     }
     // numrows type
     $pdf->displaySpace();
 }
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
 {
     $survey = new TicketSatisfaction();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Satisfaction survey') . "</b>");
     if (!$survey->getFromDB($ticket->getID())) {
         $pdf->displayLine(__('No generated survey'));
     } else {
         if ($survey->getField('type') == 2) {
             $url = Entity::generateLinkSatisfaction($ticket);
             $pdf->displayLine(sprintf(__('%1$s (%2$s)'), __('External survey'), $url));
         } else {
             if ($survey->getField('date_answered')) {
                 $sat = $survey->getField('satisfaction');
                 $tabsat = array(0 => __('None'), 1 => __('1 star', 'pdf'), 2 => __('2 stars', 'pdf'), 3 => __('3 stars', 'pdf'), 4 => __('4 stars', 'pdf'), 5 => __('5 stars', 'pdf'));
                 if (isset($tabsat[$sat])) {
                     $sat = $tabsat[$sat] . "  ({$sat}/5)";
                 }
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Response date to the satisfaction survey') . '</b>', Html::convDateTime($survey->getField('date_answered'))));
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Satisfaction with the resolution of the ticket') . '</b>', $sat));
                 $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</b>', $survey->getField('comment')));
             } else {
                 // No answer
                 $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Creation date of the satisfaction survey'), Html::convDateTime($survey->getField('date_begin'))));
                 $pdf->displayLine(__('No answer', 'pdf'));
             }
         }
     }
     $pdf->displaySpace();
 }
Example #23
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $type = get_class($item);
     $query = "SELECT `glpi_networkports`.`id`\n                FROM `glpi_networkports`\n                WHERE `items_id` = '" . $ID . "'\n                      AND `itemtype` = '" . $type . "'\n                ORDER BY `name`, `logical_number`";
     $pdf->setColumnsSize(100);
     if ($result = $DB->query($query)) {
         $nb_connect = $DB->numrows($result);
         if (!$nb_connect) {
             $pdf->displayTitle('<b>0 ' . __('No network port found') . '</b>');
         } else {
             $pdf->displayTitle('<b>' . sprintf(__('%1$s: %2$d'), _n('Network port', 'Network ports', $nb_connect), $nb_connect . "</b>"));
             while ($devid = $DB->fetch_row($result)) {
                 $netport = new NetworkPort();
                 $netport->getfromDB(current($devid));
                 $instantiation_type = $netport->fields["instantiation_type"];
                 $instname = call_user_func(array($instantiation_type, 'getTypeName'));
                 $pdf->displayTitle('<b>' . $instname . '</b>');
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), '#</b>', $netport->fields["logical_number"]));
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Name') . '</b>', $netport->fields["name"]));
                 $contact = new NetworkPort();
                 $netport2 = new NetworkPort();
                 $add = __('Not connected.');
                 if ($cid = $contact->getContact($netport->fields["id"])) {
                     if ($netport2->getFromDB($cid) && ($device2 = getItemForItemtype($netport2->fields["itemtype"]))) {
                         if ($device2->getFromDB($netport2->fields["items_id"])) {
                             $add = $netport2->getName() . ' ' . __('on') . ' ' . $device2->getName() . ' (' . $device2->getTypeName() . ')';
                         }
                     }
                 }
                 if ($instantiation_type == 'NetworkPortEthernet') {
                     $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Connected to') . '</b>', $add));
                     $netportethernet = new NetworkPortEthernet();
                     $speed = $type = '';
                     if ($netportethernet->getFromDB($netport->fields['id'])) {
                         $speed = NetworkPortEthernet::getPortSpeed($netportethernet->fields['speed']);
                         $type = NetworkPortEthernet::getPortTypeName($netportethernet->fields['type']);
                     }
                     $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Ethernet port speed') . '</b>', $speed));
                     $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Ethernet port type') . '</b>', $type));
                     $netpoint = new Netpoint();
                     $outlet = '';
                     if ($netpoint->getFromDB($netportethernet->fields['netpoints_id'])) {
                         $outlet = $netpoint->fields['name'];
                     }
                     $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Network outlet') . '</b>', $outlet));
                 }
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('MAC') . '</b>', $netport->fields["mac"]));
                 $sqlip = "LEFT JOIN `glpi_networknames`\n                           ON (`glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`\n                               AND `glpi_ipaddresses`.`entities_id`\n                                    = '" . $_SESSION['glpiactive_entity'] . "')\n                         WHERE `glpi_networknames`.`items_id` = '" . $netport->fields["id"] . "'";
                 $ipname = '';
                 $ip = new IPAddress();
                 if ($ip->getFromDBByQuery($sqlip)) {
                     $ipname = $ip->fields['name'];
                     $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('ip') . '</b>', $ipname));
                     $sql = "SELECT `glpi_ipaddresses_ipnetworks`.`ipnetworks_id`\n                      FROM `glpi_ipaddresses_ipnetworks`\n                      LEFT JOIN `glpi_ipnetworks`\n                           ON (`glpi_ipaddresses_ipnetworks`.`ipnetworks_id` = `glpi_ipnetworks`.`id`)\n                      WHERE `glpi_ipaddresses_ipnetworks`.`ipaddresses_id` = '" . $ip->getID() . "'";
                     $res = $DB->query($sql);
                     if ($res) {
                         while ($row = $DB->fetch_assoc($res)) {
                             $ipnetwork = new IPNetwork();
                             if ($ipnetwork->getFromDB($row['ipnetworks_id'])) {
                                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('IP network') . '</b>', $ipnetwork->fields['address']));
                                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Subnet mask') . '</b>', $ipnetwork->fields['netmask']));
                                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Gateway') . '</b>', $ipnetwork->fields['gateway']));
                             }
                         }
                     }
                 }
             }
             // each port
         }
         // Found
     }
     // Query
     $pdf->displaySpace();
 }
Example #24
0
 static function pdfForAppliance(PluginPdfSimplePDF $pdf, PluginAppliancesAppliance $appli)
 {
     global $DB;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('User fields', 'appliances') . '</b>');
     $query_app = "SELECT `champ`, `ddefault`\n                    FROM `glpi_plugin_appliances_optvalues`\n                    WHERE `plugin_appliances_appliances_id` = '" . $appli->getID() . "'\n                    ORDER BY `vvalues`";
     $result_app = $DB->query($query_app);
     $opts = array();
     while ($data = $DB->fetch_array($result_app)) {
         $opts[] = '<b>' . $data["champ"] . '</b>' . ($data["ddefault"] ? '=' . $data["ddefault"] : '');
     }
     if (count($opts)) {
         $pdf->displayLine(implode(',  ', $opts));
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
Example #25
0
 static function pdfChildren(PluginPdfSimplePDF $pdf, CommonTreeDropdown $item)
 {
     global $DB;
     $ID = $item->getID();
     $fields = $item->getAdditionalFields();
     $nb = count($fields);
     $entity_assign = $item->isEntityAssign();
     $fk = $item->getForeignKeyField();
     $crit = array($fk => $item->getID(), 'ORDER' => 'name');
     $pdf->setColumnsSize(100);
     $pdf->displayTitle(sprintf(__('Sons of %s'), '<b>' . $item->getNameID() . '</b>'));
     if ($item->haveChildren()) {
         if ($entity_assign) {
             if ($fk == 'entities_id') {
                 $crit['id'] = $_SESSION['glpiactiveentities'];
                 $crit['id'] += $_SESSION['glpiparententities'];
             } else {
                 $crit['entities_id'] = $_SESSION['glpiactiveentities'];
             }
             $pdf->setColumnsSize(30, 30, 40);
             $pdf->displayTitle(__('Name'), __('Entity'), __('Comments'));
         } else {
             $pdf->setColumnsSize(45, 55);
             $pdf->displayTitle(__('Name'), __('Comments'));
         }
         foreach ($DB->request($item->getTable(), $crit) as $data) {
             if ($entity_assign) {
                 $pdf->displayLine($data['name'], Html::clean(Dropdown::getDropdownName("glpi_entities", $data["entities_id"])), $data['comment']);
             } else {
                 $pdf->displayLine($data['name'], $data['comment']);
             }
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
 /**
  * Show for PDF an resources - asociated devices
  * 
  * @param $pdf object for the output
  * @param $ID of the resources
  */
 static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli)
 {
     global $DB, $CFG_GLPI;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_resources_haveRight("resources", "r")) {
         return false;
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . _n('Associated item', 'Associated items', 2) . '</b>');
     $query = "SELECT DISTINCT `itemtype` \n               FROM `glpi_plugin_resources_resources_items` \n               WHERE `plugin_resources_resources_id` = '{$ID}' \n               ORDER BY `itemtype` ";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (Session::isMultiEntitiesMode()) {
         $pdf->setColumnsSize(12, 27, 25, 18, 18);
         $pdf->displayTitle('<b><i>' . __('Type'), __('Name'), __('Entity'), __('Serial Number'), __('Inventory number') . '</i></b>');
     } else {
         $pdf->setColumnsSize(25, 31, 22, 22);
         $pdf->displayTitle('<b><i>' . __('Type'), __('Name'), __('Serial Number'), __('Inventory number') . '</i></b>');
     }
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         for ($i = 0; $i < $number; $i++) {
             $type = $DB->result($result, $i, "itemtype");
             if (!($item = getItemForItemtype($type))) {
                 continue;
             }
             if ($item->canView()) {
                 $column = "name";
                 $table = getTableForItemType($type);
                 $items = new $type();
                 $query = "SELECT `" . $table . "`.*, `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_resources_resources_items`, `" . $table . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $table . "`.`entities_id`) " . " WHERE `" . $table . "`.`id` = `glpi_plugin_resources_resources_items`.`items_id` \n                  AND `glpi_plugin_resources_resources_items`.`itemtype` = '{$type}' \n                  AND `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id` = '{$ID}' ";
                 if ($type != 'User') {
                     $query .= getEntitiesRestrictRequest(" AND ", $table, '', '', $items->maybeRecursive());
                 }
                 if ($items->maybeTemplate()) {
                     $query .= " AND `" . $table . "`.`is_template` = '0'";
                 }
                 $query .= " ORDER BY `glpi_entities`.`completename`, `" . $table . "`.`{$column}`";
                 if ($result_linked = $DB->query($query)) {
                     if ($DB->numrows($result_linked)) {
                         while ($data = $DB->fetch_assoc($result_linked)) {
                             if (!$items->getFromDB($data["id"])) {
                                 continue;
                             }
                             $items_id_display = "";
                             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                                 $items_id_display = " (" . $data["id"] . ")";
                             }
                             if ($type == 'User') {
                                 $name = Html::clean(getUserName($data["id"])) . $items_id_display;
                             } else {
                                 $name = $data["name"] . $items_id_display;
                             }
                             if ($type != 'User') {
                                 $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entity']));
                             } else {
                                 $entity = "-";
                             }
                             if (Session::isMultiEntitiesMode()) {
                                 $pdf->setColumnsSize(12, 27, 25, 18, 18);
                                 $pdf->displayLine($items->getTypeName(), $name, $entity, isset($data["serial"]) ? "" . $data["serial"] . "" : "-", isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-");
                             } else {
                                 $pdf->setColumnsSize(25, 31, 22, 22);
                                 $pdf->displayTitle($items->getTypeName(), $name, isset($data["serial"]) ? "" . $data["serial"] . "" : "-", isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-");
                             }
                         }
                         // Each device
                     }
                 }
                 // numrows device
             }
             // type right
         }
         // each type
     }
     // numrows type
 }
Example #27
0
 static function pdfStat(PluginPdfSimplePDF $pdf, Ticket $job)
 {
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . _n('Date', 'Dates', 2) . "</b>");
     $pdf->setColumnsSize(50, 50);
     $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Opening date'), Html::convDateTime($job->fields['date'])));
     $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Due date'), Html::convDateTime($job->fields['due_date'])));
     if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) {
         $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Solution date'), Html::convDateTime($job->fields['solvedate'])));
     }
     if (in_array($job->fields["status"], $job->getClosedStatusArray())) {
         $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Closing date'), Html::convDateTime($job->fields['closedate'])));
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . _n('Time', 'Times', 2) . "</b>");
     $pdf->setColumnsSize(50, 50);
     if ($job->fields['takeintoaccount_delay_stat'] > 0) {
         $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Take into account'), Html::clean(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], 0))));
     }
     if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) {
         if ($job->fields['solve_delay_stat'] > 0) {
             $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Solution'), Html::clean(Html::timestampToString($job->fields['solve_delay_stat'], 0))));
         }
     }
     if (in_array($job->fields["status"], $job->getClosedStatusArray())) {
         if ($job->fields['close_delay_stat'] > 0) {
             $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Closing'), Html::clean(Html::timestampToString($job->fields['close_delay_stat'], 0))));
         }
     }
     if ($job->fields['waiting_duration'] > 0) {
         $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Pending'), Html::clean(Html::timestampToString($job->fields['waiting_duration'], 0))));
     }
     $pdf->displaySpace();
 }
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
 {
     global $CFG_GLPI, $DB;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Approvals for the ticket') . "</b>");
     if (!Session::haveRight('validate_request', 1) && !Session::haveRight('validate_incident', 1) && !Session::haveRight('create_incident_validation', 1) && !Session::haveRight('create_request_validation', 1)) {
         return false;
     }
     $ID = $ticket->getField('id');
     $query = "SELECT *\n                FROM `glpi_ticketvalidations`\n                WHERE `tickets_id` = '" . $ticket->getField('id') . "'\n                ORDER BY submission_date DESC";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($number) {
         $pdf->setColumnsSize(20, 19, 21, 19, 21);
         $pdf->displayTitle(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Approval date'), __('Approver'));
         while ($row = $DB->fetch_assoc($result)) {
             $pdf->setColumnsSize(20, 19, 21, 19, 21);
             $pdf->displayLine(TicketValidation::getStatus($row['status']), Html::convDateTime($row["submission_date"]), getUserName($row["users_id"]), Html::convDateTime($row["validation_date"]), getUserName($row["users_id_validate"]));
             $tmp = trim($row["comment_submission"]);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Request comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
             if ($row["validation_date"]) {
                 $tmp = trim($row["comment_validation"]);
                 $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Approval comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
             }
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
Example #29
0
 /**
  * Show for PDF an resources : tasks informations
  * 
  * @param $pdf object for the output
  * @param $ID of the resources
  */
 static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli)
 {
     global $DB;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_resources_haveRight("resources", "r")) {
         return false;
     }
     $query = "SELECT * \n               FROM `glpi_plugin_resources_tasks` \n               WHERE `plugin_resources_resources_id` = '{$ID}'\n               AND `is_deleted` ='0'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . self::getTypeName(2) . '</b>');
         $pdf->setColumnsSize(14, 14, 14, 14, 16, 14, 14);
         $pdf->displayTitle('<b><i>' . __('Name'), __('Type'), __('Comments'), __('Duration'), __('Planning'), __('Resource manager', 'resources'), __('Group') . '</i></b>');
         $i++;
         while ($j < $number) {
             $tID = $DB->result($result, $j, "id");
             $actiontime_ID = $DB->result($result, $j, "actiontime");
             $actiontime = '';
             $units = Toolbox::getTimestampTimeUnits($actiontime_ID);
             $hour = $units['hour'];
             $minute = $units['minute'];
             if ($hour) {
                 $actiontime = $hour . __('Hour', 'Hours', 2);
             }
             if ($minute || !$hour) {
                 $actiontime .= $minute . __('Minute', 'Minutes', 2);
             }
             $restrict = " `plugin_resources_tasks_id` = '" . $tID . "' ";
             $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
             if (!empty($plans)) {
                 foreach ($plans as $plan) {
                     $planification = Html::convDateTime($plan["begin"]) . "&nbsp;->&nbsp;" . Html::convDateTime($plan["end"]);
                 }
             } else {
                 $planification = __('None');
             }
             $users_id = $DB->result($result, $j, "users_id");
             $managers = Html::clean(getUserName($users_id));
             $name = $DB->result($result, $j, "name");
             $task_type = $DB->result($result, $j, "plugin_resources_tasktypes_id");
             $comment = $DB->result($result, $j, "comment");
             $groups_id = $DB->result($result, $j, "groups_id");
             $pdf->displayLine(Html::clean($name), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_tasktypes", $task_type)), $comment, $actiontime, Html::clean($planification), $managers, Html::clean(Dropdown::getDropdownName("glpi_groups", $groups_id)));
             $j++;
         }
     } else {
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
Example #30
0
 /**
  * Show for PDF an projet
  * 
  * @param $pdf object for the output
  * @param $ID of the projet
  */
 static function pdfGanttForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli)
 {
     global $CFG_GLPI, $gtitle, $gdata, $gconst, $gdate_begin, $gdate_end;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_projet_haveRight("projet", "r")) {
         return false;
     }
     //nom
     $gantt_p_name = $appli->fields["name"];
     //type de gantt
     $int = hexdec(PluginProjetProjetState::getStatusColor($appli->fields["plugin_projet_projetstates_id"]));
     $gantt_p_bgcolor = array(0xff & $int >> 0x10, 0xff & $int >> 0x8, 0xff & $int);
     $gantt_p_date_begin = date("Y-m-d");
     $gantt_p_date_end = date("Y-m-d");
     if (!empty($appli->fields["date_begin"])) {
         $gantt_p_date_begin = $appli->fields["date_begin"];
     }
     if (!empty($appli->fields["date_end"])) {
         $gantt_p_date_end = $appli->fields["date_end"];
     }
     $gdata[] = array("type" => 'group', "projet" => $ID, "name" => $gantt_p_name, "date_begin" => $gantt_p_date_begin, "date_end" => $gantt_p_date_end, "advance" => $appli->fields["advance"], "bg_color" => $gantt_p_bgcolor);
     PluginProjetTask::showTaskTreeGantt(array('plugin_projet_projets_id' => $ID));
     if (!empty($gdate_begin) && !empty($gdate_end)) {
         $gtitle = $gtitle . "<DateBeg> / <DateEnd>";
         $gdate_begin = date("Y", $gdate_begin) . "-" . date("m", $gdate_begin) . "-" . date("d", $gdate_begin);
         $gdate_end = date("Y", $gdate_end) . "-" . date("m", $gdate_end) . "-" . date("d", $gdate_end);
     }
     $ImgName = self::writeGantt($gtitle, $gdata, $gconst, $gdate_begin, $gdate_end);
     $image = GLPI_PLUGIN_DOC_DIR . "/projet/" . $ImgName;
     $pdf->newPage();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('Gantt', 'projet') . '</b>');
     $size = GetImageSize($image);
     $src_w = $size[0];
     $src_h = $size[1];
     $pdf->addPngFromFile($image, $src_w / 2, $src_h / 2);
     $pdf->displaySpace();
     unlink($image);
 }