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(); }
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 pdfLdapForm(PluginPdfSimplePDF $pdf, Group $item) { if (Session::haveRight("config", "r") && AuthLdap::useAuthLdap()) { $pdf->setColumnsSize(100); $pdf->displayTitle(__('LDAP directory link')); $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('User attribute containing its groups') . '</b>', $item->getField('ldap_field'))); $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Attribute value') . '</b>', $item->getField('ldap_value'))); $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Group DN') . '</b>', $item->getField('ldap_group_dn'))); $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(); }
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 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(); }
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(); }
static function pdfSolution(PluginPdfSimplePDF $pdf, Ticket $job) { global $CFG_GLPI, $DB; $pdf->setColumnsSize(100); $pdf->displayTitle("<b>" . __('Solution') . "</b>"); if ($job->fields['solutiontypes_id'] || !empty($job->fields['solution'])) { if ($job->fields['solutiontypes_id']) { $title = Html::clean(Dropdown::getDropdownName('glpi_solutiontypes', $job->getField('solutiontypes_id'))); } else { $title = __('Solution'); } $sol = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($job->getField('solution'), ENT_QUOTES, "UTF-8"))); $pdf->displayText("<b><i>{$title}</i></b> : ", $sol); } else { $pdf->displayLine(__('None')); } $pdf->displaySpace(); }
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(); } }
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) { global $DB; $ID = $item->getField('id'); $type = $item->getType(); $info = new InfoCom(); $comp = new Computer(); $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . __('Direct connections') . '</b>'); $query = "SELECT *\n FROM `glpi_computers_items`\n WHERE `items_id` = '" . $ID . "'\n AND `itemtype` = '" . $type . "'"; if ($result = $DB->query($query)) { $resultnum = $DB->numrows($result); if ($resultnum > 0) { for ($j = 0; $j < $resultnum; $j++) { $tID = $DB->result($result, $j, "computers_id"); $connID = $DB->result($result, $j, "id"); $comp->getFromDB($tID); $info->getFromDBforDevice('Computer', $tID) || $info->getEmpty(); $line1 = $comp->fields['name'] ? $comp->fields['name'] : "(" . $comp->fields['id'] . ")"; if ($comp->fields['serial']) { $line1 = sprintf(__('%1$s - %2$s'), $line1, sprintf(__('%1$s: %2$s'), __('Serial number'), $comp->fields['serial'])); } $line1 = sprintf(__('%1$s - %2$s'), $line1, Html::clean(Dropdown::getDropdownName("glpi_states", $comp->fields['states_id']))); $line2 = ""; if ($comp->fields['otherserial']) { $line2 = sprintf(__('%1$s: %2$s'), __('Inventory number'), $item->getField("otherserial")); } if ($info->fields['immo_number']) { $line2 = sprintf(__('%1$s - %2$s'), $line2, sprintf(__('%1$s: %2$s'), __('Immobilization number'), $info->fields["immo_number"])); } if ($line2) { $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Computer') . '/b>', $line1 . "\n" . $line2), 2); } else { $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Computer') . '/b>', $line1), 1); } } // each device of current type } else { // No row $pdf->displayLine(__('Not connected.')); } // No row } // Result $pdf->displaySpace(); }
static function mainLine(PluginPdfSimplePDF $pdf, $item, $field) { $type = Toolbox::strtolower($item->getType()); switch ($field) { case 'name-status': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $item->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Status') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_states', $item->fields['states_id'])))); case 'location-type': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Location') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_locations', $item->fields['locations_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Type') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_' . $type . 'types', $item->fields[$type . 'types_id'])))); case 'tech-manufacturer': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Technician in charge of the hardware') . '</i></b>', getUserName($item->fields['users_id_tech'])), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Manufacturer') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_manufacturers', $item->fields['manufacturers_id'])))); case 'group-model': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Group in charge of the hardware') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_groups', $item->fields['groups_id_tech']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Model') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_' . $type . 'models', $item->fields[$type . 'models_id'])))); case 'contactnum-serial': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Alternate username number') . '</i></b>', $item->fields['contact_num']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Serial number') . '</i></b>', $item->fields['serial'])); case 'contact-otherserial': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Alternate username') . '</i></b>', $item->fields['contact']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Inventory number') . '</i></b>', $item->fields['otherserial'])); case 'user-management': return $pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('User') . '</i></b>', getUserName($item->fields['users_id'])), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Management type') . '</i></b>', $item->fields['is_global'] ? __('Global management') : __('Unit management'))); case 'comment': return $pdf->displayText('<b><i>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</i></b>', $item->fields['comment'])); default: return; } }