Decode string from UTF-8 to specified charset
static public decodeFromUtf8 ( $string, $to_charset = "ISO-8859-1" ) : converted | ||
$string | string string to convert | |
$to_charset | string destination charset (default "ISO-8859-1") | |
Résultat | converted | string |
function decodeFromUtf8Array(&$arg) { if (is_array($arg)) { foreach (array_keys($arg) as $key) { decodeFromUtf8Array($arg[$key]); } } else { if (is_string($arg)) { $arg = Toolbox::decodeFromUtf8($arg); } } }
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(); }
/** * Print generic footer * * @param $type display type (0=HTML, 1=Sylk,2=PDF,3=CSV) * @param $title title of file : used for PDF (default '') * * @return string to display **/ static function showFooter($type, $title = "") { $out = ""; switch ($type) { case self::PDF_OUTPUT_LANDSCAPE: //pdf global $PDF_HEADER, $PDF_ARRAY; $pdf = new Cezpdf('a4', 'landscape'); $pdf->selectFont(GLPI_ROOT . "/lib/ezpdf/fonts/Helvetica.afm"); $nb = count($PDF_ARRAY); $tmptxt = sprintf(_n('%s item', '%s items', $nb), $nb); $pdf->ezStartPageNumbers(750, 10, 10, 'left', "GLPI PDF export - " . Html::convDate(date("Y-m-d")) . " - " . Toolbox::decodeFromUtf8($tmptxt, 'windows-1252') . " - {PAGENUM}/{TOTALPAGENUM}"); $options = array('fontSize' => 8, 'colGap' => 2, 'maxWidth' => 800, 'titleFontSize' => 8); $pdf->ezTable($PDF_ARRAY, $PDF_HEADER, Toolbox::decodeFromUtf8($title, 'windows-1252'), $options); $pdf->ezStream(); break; case self::PDF_OUTPUT_PORTRAIT: //pdf global $PDF_HEADER, $PDF_ARRAY; $pdf = new Cezpdf('a4', 'portrait'); $pdf->selectFont(GLPI_ROOT . "/lib/ezpdf/fonts/Helvetica.afm"); $nb = count($PDF_ARRAY); $tmptxt = sprintf(_n('%s item', '%s items', $nb), $nb); $pdf->ezStartPageNumbers(550, 10, 10, 'left', "GLPI PDF export - " . Html::convDate(date("Y-m-d")) . " - " . Toolbox::decodeFromUtf8($tmptxt, 'windows-1252') . " - {PAGENUM}/{TOTALPAGENUM}"); $options = array('fontSize' => 8, 'colGap' => 2, 'maxWidth' => 565, 'titleFontSize' => 8); $pdf->ezTable($PDF_ARRAY, $PDF_HEADER, Toolbox::decodeFromUtf8($title, 'windows-1252'), $options); $pdf->ezStream(); break; case self::SYLK_OUTPUT: //sylk global $SYLK_HEADER, $SYLK_ARRAY, $SYLK_SIZE; // largeurs des colonnes foreach ($SYLK_SIZE as $num => $val) { $out .= "F;W" . $num . " " . $num . " " . min(50, $val) . "\n"; } $out .= "\n"; // Header foreach ($SYLK_HEADER as $num => $val) { $out .= "F;SDM4;FG0C;" . ($num == 1 ? "Y1;" : "") . "X{$num}\n"; $out .= "C;N;K\"" . self::sylk_clean($val) . "\"\n"; $out .= "\n"; } // Datas foreach ($SYLK_ARRAY as $row => $tab) { foreach ($tab as $num => $val) { $out .= "F;P3;FG0L;" . ($num == 1 ? "Y" . $row . ";" : "") . "X{$num}\n"; $out .= "C;N;K\"" . self::sylk_clean($val) . "\"\n"; } } $out .= "E\n"; break; case self::CSV_OUTPUT: //csv break; default: $out = "</table></div>\n"; } return $out; }
function generatePdf($itemtype, $data, $saveas) { global $CFG_GLPI, $PDF, $DB; $ID = $data["id"]; //name if (!empty($data["name"])) { $name_item = Toolbox::decodeFromUtf8($data["name"]); } else { $name_item = ""; } //user if (!empty($data["users_id"])) { $user_item = Toolbox::decodeFromUtf8(Html::clean(getUserName($data["users_id"]))); } else { if (!empty($data["groups_id"])) { $user_item = Toolbox::decodeFromUtf8(Dropdown::getDropdownName("glpi_groups", $data["groups_id"])); } else { $user_item = ""; } } //fabricant if (!empty($data["manufacturers_id"])) { $fabricant_item = Toolbox::decodeFromUtf8(Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"])); } else { $fabricant_item = ""; } //serial if (!empty($data["serial"])) { $serial_item = Toolbox::decodeFromUtf8($data["serial"]); } else { $serial_item = ""; } $class = $itemtype . "Type"; $item = new $class(); $typefield = getForeignKeyFieldForTable(getTableForItemType($itemtype . "Type")); $item->getFromDB($data[$typefield]); if (!empty($typefield) && !empty($item->fields["name"])) { $type_item = Toolbox::decodeFromUtf8($item->fields["name"]); } else { $type_item = ""; } //infocoms $ic = new Infocom(); if ($ic->getfromDBforDevice($itemtype, $ID)) { //immobilizationsheets_item if (!empty($ic->fields["immo_number"])) { $immobilizationsheets_item = Toolbox::decodeFromUtf8($ic->fields["immo_number"]); } else { $immobilizationsheets_item = ""; } //buy_date if (!empty($ic->fields["buy_date"])) { $buy_date_item = Toolbox::decodeFromUtf8(Html::convdate($ic->fields["buy_date"])); } else { $buy_date_item = ""; } //use_date if (!empty($ic->fields["use_date"])) { $use_date_item = Toolbox::decodeFromUtf8(Html::convdate($ic->fields["use_date"])); } else { $use_date_item = ""; } //order_number if (!empty($ic->fields["order_number"])) { $order_number_item = Toolbox::decodeFromUtf8($ic->fields["order_number"]); } else { $order_number_item = ""; } //value_item if (!empty($ic->fields["value"])) { $value_item = Toolbox::decodeFromUtf8(Html::clean(Html::formatNumber($ic->fields["value"]))); } else { $value_item = ""; } //sink_time if (!empty($ic->fields["sink_time"])) { $sink_time_item = Toolbox::decodeFromUtf8(sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"])); } else { $sink_time_item = ""; } //sink_type if (!empty($ic->fields["sink_type"])) { $sink_type_item = Toolbox::decodeFromUtf8(Infocom::getAmortTypeName($ic->fields["sink_type"])); } else { $sink_type_item = ""; } } else { $immobilizationsheets_item = ""; $buy_date_item = ""; $use_date_item = ""; $order_number_item = ""; $value_item = ""; $sink_time_item = ""; $sink_type_item = ""; } //composants $devtypes = self::getDeviceTypes(); if ($itemtype == 'Computer') { $device2 = new $devtypes[2](); $query2 = "SELECT `deviceprocessors_id`\n FROM `" . getTableForItemType('items_' . $devtypes[2]) . "`\n WHERE `items_id` = '{$ID}'"; $result2 = $DB->query($query2); $number2 = $DB->numrows($result2); $device3 = new $devtypes[3](); $query3 = "SELECT SUM(`size`) AS total\n FROM `" . getTableForItemType('items_' . $devtypes[3]) . "`\n WHERE `items_id` = '{$ID}'"; $result3 = $DB->query($query3); $number3 = $DB->numrows($result3); $query3b = "SELECT `devicememories_id`\n FROM `" . getTableForItemType('items_' . $devtypes[3]) . "`\n WHERE `items_id` = '{$ID}'"; $result3b = $DB->query($query3b); $number3b = $DB->numrows($result3b); $device4 = new $devtypes[4](); $query4 = "SELECT `deviceharddrives_id`,`capacity`\n FROM `" . getTableForItemType('items_' . $devtypes[4]) . "`\n WHERE `items_id` = '{$ID}'"; $result4 = $DB->query($query4); $number4 = $DB->numrows($result4); $device5 = new $devtypes[6](); $query5 = "SELECT `devicedrives_id`\n FROM `" . getTableForItemType('items_' . $devtypes[6]) . "`\n WHERE `items_id` = '{$ID}'"; $result5 = $DB->query($query5); $number5 = $DB->numrows($result5); if ($number2 != 0) { while ($data2 = $DB->fetch_array($result2)) { //proc_item if (!empty($data2["deviceprocessors_id"])) { $query_proc = "SELECT `designation`\n FROM `glpi_deviceprocessors`\n WHERE `id` = '" . $data2["deviceprocessors_id"] . "'"; $result_proc = $DB->query($query_proc); $number_proc = $DB->numrows($result_proc); if ($number_proc != 0) { while ($data_proc = $DB->fetch_array($result_proc)) { $proc_item = Toolbox::decodeFromUtf8($data_proc["designation"]); } } } } } else { $proc_item = ""; } if ($number3 != 0) { while ($data3 = $DB->fetch_array($result3)) { //ram_item $ram_item = $data3["total"]; } } else { $ram_item = ""; } $ram_type_item = ""; if ($number3b != 0) { while ($data3b = $DB->fetch_array($result3b)) { //ram_type_item if (!empty($data3b["devicememories_id"])) { $query_ram = "SELECT `glpi_devicememorytypes`.`name`\n FROM `glpi_devicememories`,`glpi_devicememorytypes`\n WHERE `glpi_devicememories`.`id` = '" . $data3b["devicememories_id"] . "'\n AND `glpi_devicememorytypes`.`id` = `glpi_devicememories`.`devicememorytypes_id` "; $result_ram = $DB->query($query_ram); $number_ram = $DB->numrows($result_ram); if ($number_ram != 0) { while ($data_ram = $DB->fetch_array($result_ram)) { $ram_type_item = Toolbox::decodeFromUtf8($data_ram["name"]); } } else { $ram_type_item = ""; } } } } else { $ram_type_item = ""; } $hdd_item = ""; $hdd_designation_item = ""; $hdd_interface_item = ""; if ($number4 != 0) { while ($data4 = $DB->fetch_array($result4)) { //hdd_item $hdd_size_item = Toolbox::decodeFromUtf8($data4["capacity"]); if (!empty($data4["deviceharddrives_id"])) { $query_hdd = "SELECT `designation`\n FROM `glpi_deviceharddrives`\n WHERE `id` = '" . $data4["deviceharddrives_id"] . "'"; $result_hdd = $DB->query($query_hdd); $number_hdd = $DB->numrows($result_hdd); if ($number_hdd != 0) { while ($data_hdd = $DB->fetch_array($result_hdd)) { $hdd_designation_item = Toolbox::decodeFromUtf8($data_hdd["designation"]); } } else { $hdd_designation_item = ""; } $query_hdd1 = "SELECT `glpi_interfacetypes`.`name`\n FROM `glpi_deviceharddrives`,`glpi_interfacetypes`\n WHERE `glpi_deviceharddrives`.`id` = '" . $data4["deviceharddrives_id"] . "'\n AND `glpi_interfacetypes`.`id` = `glpi_deviceharddrives`.`interfacetypes_id` "; //replace interface by FK_interface 0.72.1 $result_hdd1 = $DB->query($query_hdd1); $number_hdd1 = $DB->numrows($result_hdd1); if ($number_hdd1 != 0) { while ($data_hdd1 = $DB->fetch_array($result_hdd1)) { $hdd_interface_item = Toolbox::decodeFromUtf8($data_hdd1["name"]); } } } else { $hdd_interface_item = ""; } $hdd_item .= $hdd_designation_item . " " . $hdd_interface_item . " (" . $hdd_size_item . " Mo)"; if ($number4 > 1) { $hdd_item .= " - "; } } } else { $hdd_item = ""; } $lecteur_item = ""; if ($number5 != 0) { while ($data5 = $DB->fetch_array($result5)) { //lecteur_item if (!empty($data5["items_id"])) { $query_lecteur = "SELECT `designation`\n FROM `glpi_devicedrives`\n WHERE `id` = '" . $data5["interfacetypes_id"] . "'"; $result_lecteur = $DB->query($query_lecteur); $number_lecteur = $DB->numrows($result_lecteur); if ($number_lecteur != 0) { while ($data_lecteur = $DB->fetch_array($result_lecteur)) { $lecteur_item .= Toolbox::decodeFromUtf8($data_lecteur["designation"]); if ($number5 > 1) { $lecteur_item .= " - "; } } } } } } else { $lecteur_item = ""; } //softwares $query6 = "SELECT `glpi_softwares`.`name`,`glpi_softwarelicenses`.`softwareversions_id_buy`,`glpi_softwarelicenses`.`serial`\n FROM `glpi_softwarelicenses`\n INNER JOIN `glpi_computers_softwarelicenses` ON (`glpi_softwarelicenses`.`id` = `glpi_computers_softwarelicenses`.`softwarelicenses_id` AND `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}') \n INNER JOIN `glpi_softwares` ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`) "; $result6 = $DB->query($query6); $number6 = $DB->numrows($result6); } //Affichage //$PDF->addJpegFromFile('../pics/immobilizationsheets.jpg',285,785,32,32); //title $PDF->ezSetDy(-20); $title = array(array('' => Toolbox::decodeFromUtf8(__('IDENTIFICATION IMMOBILIZATION SHEET', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'center')); $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $PDF->ezSetDy(-10); //partie 1 $PDF->ezSetDy(-20); $title1 = array(array('' => Toolbox::decodeFromUtf8(__('I - PART TO BE FILLED BY THE PERSON IN CHARGE FOR THE PURCHASES', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'left')); $PDF->ezTable($title1, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 10, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $title2 = array(array('' => Toolbox::decodeFromUtf8(__('(transfer the original to the administrator network so computer equipement, the assistant of management in the other cases)', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'left')); $PDF->ezTable($title2, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 8, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $PDF->ezSetDy(-10); //Date mise en service $PDF->ezText("<u>" . Toolbox::decodeFromUtf8(__('Startup date')) . "</u> : " . $buy_date_item, 8, array("justification" => "left")); $PDF->ezSetDy(-10); //ligne1 (entreprise / fournisseur) $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('MY ENTERPRISE', 'immobilizationsheets')), '1' => Toolbox::decodeFromUtf8(strtoupper(__('Supplier'))))); $cols1 = array('0' => array('width' => 265, 'justification' => 'center'), '1' => array('width' => 265, 'justification' => 'center')); $PDF->ezTable($data1, '', __('COMPUTER IDENTIFICATION', 'immobilizationsheets'), array('showHeadings' => 0, 'cols' => $cols1)); //ligne2 (4 / 9) $data2 = array(array('0' => Toolbox::decodeFromUtf8(__('Assignment number (si non informatique)', 'immobilizationsheets')), '1' => '', '2' => Toolbox::decodeFromUtf8(__('Brand')), '3' => $fabricant_item)); $cols2 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left')); $PDF->ezTable($data2, '', '', array('showHeadings' => 0, 'cols' => $cols2, 'fontSize' => 8)); //ligne3 (5 / 10) $data3 = array(array('0' => Toolbox::decodeFromUtf8(__('Invoice number')), '1' => $order_number_item, '2' => Toolbox::decodeFromUtf8(__('Type')), '3' => $type_item)); $cols3 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left')); $PDF->ezTable($data3, '', '', array('showHeadings' => 0, 'cols' => $cols3, 'fontSize' => 8)); //ligne4 (6 / 11) $data4 = array(array('0' => Toolbox::decodeFromUtf8(__('Value')), '1' => $value_item, '2' => Toolbox::decodeFromUtf8(__('Serial Number')), '3' => $serial_item)); $cols4 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left')); $PDF->ezTable($data4, '', '', array('showHeadings' => 0, 'cols' => $cols4, 'fontSize' => 8)); //ligne5 (7 / 12) $data5 = array(array('0' => Toolbox::decodeFromUtf8(__('Assignment (client / inv. …)', 'immobilizationsheets')), '1' => '', '2' => Toolbox::decodeFromUtf8(__('Permanent number', 'immobilizationsheets')), '3' => $immobilizationsheets_item)); $cols5 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left')); $PDF->ezTable($data5, '', '', array('showHeadings' => 0, 'cols' => $cols5, 'fontSize' => 8)); $PDF->ezSetDy(-10); //trigramme $data6 = array(array('0' => Toolbox::decodeFromUtf8(__('Trigram and visa of the person in charge', 'immobilizationsheets')), '1' => '')); $cols6 = array('0' => array('width' => 430, 'fontSize' => 8, 'justification' => 'right'), '1' => array('width' => 100, 'justification' => 'left')); $PDF->ezTable($data6, '', '', array('showHeadings' => 0, 'cols' => $cols6, 'xPos' => 'center', 'xOreintation' => 'right', 'fontSize' => 8)); //partie 2 $PDF->ezSetDy(-20); $title1 = array(array('' => Toolbox::decodeFromUtf8(__('II - PART TO BE FILLED BY THE NETWORK ADMINISTRATOR', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'left')); $PDF->ezTable($title1, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 10, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $title2 = array(array('' => Toolbox::decodeFromUtf8(__('(transfer to the assistant of management)', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'left')); $PDF->ezTable($title2, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 8, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $PDF->ezSetDy(-10); //ligne1 (name / user) $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('User name / sector', 'immobilizationsheets')), '1' => $user_item, '2' => Toolbox::decodeFromUtf8(__('Name')), '3' => $name_item)); $cols1 = array('0' => array('width' => 132.5, 'justification' => 'center'), '1' => array('width' => 132.5, 'justification' => 'center'), '2' => array('width' => 132.5, 'justification' => 'center'), '3' => array('width' => 132.5, 'justification' => 'center')); $PDF->ezTable($data1, '', __('PRINCIPAL ASSIGNMENT', 'immobilizationsheets'), array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1)); $PDF->ezSetDy(-10); if ($itemtype == 'Computer') { //title config mat?ielle $title = array(array('' => Toolbox::decodeFromUtf8(__('HARDWARE CONFIGURATION', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'center')); $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 1)); $PDF->ezSetDy(-10); //ligne1 (processeur / ram quantit?/ ram type) $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('Processor')), '1' => $proc_item, '2' => Toolbox::decodeFromUtf8(__('Memory')), '3' => Toolbox::decodeFromUtf8(__('Quantity', 'immobilizationsheets')), '4' => $ram_item, '5' => Toolbox::decodeFromUtf8(__('Type')), '6' => $ram_type_item)); $cols1 = array('0' => array('width' => 55, 'justification' => 'center'), '1' => array('width' => 200, 'justification' => 'left'), '2' => array('width' => 55, 'justification' => 'center'), '3' => array('width' => 55, 'justification' => 'center'), '4' => array('width' => 55, 'justification' => 'center'), '5' => array('width' => 55, 'justification' => 'center'), '6' => array('width' => 55, 'justification' => 'center')); $PDF->ezTable($data1, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1)); //ligne2 (Disque dur / Lecteur) $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('Hard drive')), '1' => $hdd_item, '2' => Toolbox::decodeFromUtf8(__('Drive')), '3' => $lecteur_item)); $cols1 = array('0' => array('width' => 55, 'justification' => 'center'), '1' => array('width' => 200, 'justification' => 'left'), '2' => array('width' => 55, 'justification' => 'center'), '3' => array('width' => 220, 'justification' => 'center')); $PDF->ezTable($data1, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1)); $PDF->ezSetDy(-10); //titre suppl?ent $PDF->ezText("<u>" . Toolbox::decodeFromUtf8(__('Additional cards or peripherals', 'immobilizationsheets')) . "</u> : ", 8, array("justification" => "left")); $PDF->ezSetDy(-10); if ($number6 > 0) { //title config logicielle $title = array(array('' => Toolbox::decodeFromUtf8(__('SOFTWARE CONFIGURATION', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'center')); $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 1)); $PDF->ezSetDy(-10); //titre logiciels $PDF->ezText("<u>" . Toolbox::decodeFromUtf8(__('Oem/Delivered software', 'immobilizationsheets')) . "</u> : ", 8, array("justification" => "left")); $PDF->ezSetDy(-10); //ligne1 (name / version / licence) $data0 = array(array('0' => Toolbox::decodeFromUtf8(__('Name')), '1' => Toolbox::decodeFromUtf8(__('Version')), '2' => Toolbox::decodeFromUtf8(__('License number')))); $cols1 = array('0' => array('width' => 240, 'justification' => 'left'), '1' => array('width' => 50, 'justification' => 'center'), '2' => array('width' => 240, 'justification' => 'center')); $PDF->ezTable($data0, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1)); while ($data6 = $DB->fetch_array($result6)) { $soft_name_item = $data6["name"]; $soft_version_item = Dropdown::getDropdownName("glpi_softwareversions", $data6["softwareversions_id_buy"]); $soft_license_item = $data6["serial"]; $data1 = array(array('0' => $soft_name_item, '1' => $soft_version_item, '2' => $soft_license_item)); $cols1 = array('0' => array('width' => 240, 'justification' => 'left'), '1' => array('width' => 50, 'justification' => 'center'), '2' => array('width' => 240, 'justification' => 'center')); $PDF->ezTable($data1, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1)); } $PDF->ezSetDy(-10); } } //trigramme $data6 = array(array('0' => Toolbox::decodeFromUtf8(__('Trigram and visa of the person in charge', 'immobilizationsheets')), '1' => '')); $cols6 = array('0' => array('width' => 430, 'fontSize' => 8, 'justification' => 'right'), '1' => array('width' => 100, 'justification' => 'left')); $PDF->ezTable($data6, '', '', array('showHeadings' => 0, 'cols' => $cols6, 'xPos' => 'center', 'xOreintation' => 'right', 'fontSize' => 8)); //partie 3 $PDF->ezSetDy(-20); $title1 = array(array('' => Toolbox::decodeFromUtf8(__('III - PART TO BE FILLED BY THE MANAGEMENT ASSISTANT', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'left')); $PDF->ezTable($title1, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 10, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $title2 = array(array('' => Toolbox::decodeFromUtf8(__('(for checking, visa and classification)', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'left')); $PDF->ezTable($title2, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 8, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8))); $PDF->ezSetDy(-20); //title $title = array(array('' => Toolbox::decodeFromUtf8(__('CALCULATION OF AMORTIZATION', 'immobilizationsheets')))); $cols = array('' => array('width' => 530, 'justification' => 'center')); $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 1)); $PDF->ezSetDy(-10); //Base d'amortissement $amort0 = array(array('0' => Toolbox::decodeFromUtf8(__('Base amortization', 'immobilizationsheets')), '1' => $sink_type_item)); $cols1 = array('0' => array('width' => 130, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 400, 'justification' => 'left')); $PDF->ezTable($amort0, '', '', array('showHeadings' => 0, 'cols' => $cols1, 'fontSize' => 8, 'showLines' => 0)); $PDF->ezSetDy(-10); //Duree d'amortissement $amort1 = array(array('0' => Toolbox::decodeFromUtf8(__('Amortization duration')), '1' => $sink_time_item)); $cols1 = array('0' => array('width' => 130, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 400, 'justification' => 'left')); $PDF->ezTable($amort1, '', '', array('showHeadings' => 0, 'cols' => $cols1, 'fontSize' => 8, 'showLines' => 0)); $PDF->ezSetDy(-10); //Date de debut d'amortissement $amort2 = array(array('0' => Toolbox::decodeFromUtf8(__('Date of beginning of amortization', 'immobilizationsheets')), '1' => $use_date_item)); $cols1 = array('0' => array('width' => 130, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 400, 'justification' => 'left')); $PDF->ezTable($amort2, '', '', array('showHeadings' => 0, 'cols' => $cols1, 'fontSize' => 8, 'showLines' => 0)); $PDF->ezSetDy(-10); //visa $amort1 = array(array('0' => Toolbox::decodeFromUtf8(__('VISA A.G.', 'immobilizationsheets')), '1' => "")); $cols6 = array('0' => array('width' => 430, 'fontSize' => 8, 'justification' => 'right'), '1' => array('width' => 100, 'justification' => 'left')); $PDF->ezTable($data6, '', '', array('showHeadings' => 0, 'cols' => $cols6, 'xPos' => 'center', 'xOreintation' => 'right', 'fontSize' => 8)); //end $PDF->addInfo('Author', Toolbox::decodeFromUtf8(Html::clean(getUserName(Session::getLoginUserID())))); $config = new PluginImmobilizationsheetsConfig(); if ($config->getFromDB(1)) { if ($saveas == 1) { if ($config->fields["use_backup"] == 1) { $path = GLPI_DOC_DIR . "/_uploads/"; $time_file = date("Y-m-d-H-i-s"); $filename = "immo_" . $time_file . "_" . $data["name"] . ".pdf"; $filepath = $path . $filename; $fp = fopen($filepath, 'wb'); fwrite($fp, $PDF->output()); fclose($fp); $doc = new document(); $input = array(); $input["entities_id"] = $data["entities_id"]; $input["name"] = addslashes(self::getTypeName(1) . " " . $data["name"] . " " . $time_file); $input["upload_file"] = $filename; $input["documentcategories_id"] = $config->fields["documentcategories_id"]; $input["type"] = "application/pdf"; $input["date_mod"] = date("Y-m-d H:i:s"); $input["users_id"] = Session::getLoginUserID(); $newdoc = $doc->add($input); $docitem = new Document_Item(); $docitem->add(array('documents_id' => $newdoc, 'itemtype' => $itemtype, 'items_id' => $ID, 'entities_id' => $input["entities_id"])); } } } }
/** * Fonction permettant de dessiner le pied de page du rapport. */ function Footer() { // Positionnement par rapport au bas de la page. $this->SetY(-$this->tail_bas_page); /* Numéro de page. */ $this->SetFont($this->pol_def, '', 9); $this->Cell(0, $this->tail_bas_page / 2, Toolbox::decodeFromUtf8("") . ' ' . $this->PageNo() . ' ' . Toolbox::decodeFromUtf8("") . ' ', 0, 0, 'C'); $this->Ln(10); /* Infos ODAXYS. */ $this->SetFont($this->pol_def, 'I', 9); $this->Cell(0, $this->tail_bas_page / 4, Toolbox::decodeFromUtf8(""), 0, 0, 'C'); $this->Ln(5); $this->Cell(0, $this->tail_bas_page / 4, Toolbox::decodeFromUtf8(""), 0, 0, 'C'); }
/** * Authentify a user by checking a specific mail server * * @param $auth identification object * @param $login user login * @param $password user password * @param $mail_method mail_method array to use * * @return identification object **/ static function mailAuth($auth, $login, $password, $mail_method) { if (isset($mail_method["connect_string"]) && !empty($mail_method["connect_string"])) { $auth->auth_succeded = $auth->connection_imap($mail_method["connect_string"], Toolbox::decodeFromUtf8($login), Toolbox::decodeFromUtf8($password)); if ($auth->auth_succeded) { $auth->extauth = 1; $auth->user_present = $auth->user->getFromDBbyName(addslashes($login)); $auth->user->getFromIMAP($mail_method, Toolbox::decodeFromUtf8($login)); //Update the authentication method for the current user $auth->user->fields["authtype"] = Auth::MAIL; $auth->user->fields["auths_id"] = $mail_method["id"]; } } return $auth; }
/** * Print generic normal Item Cell * * @param $type display type (0=HTML, 1=Sylk,2=PDF,3=CSV) * @param $value value to display * @param &$num column number * @param $row row number * @param $extraparam extra parameters for display (default '') * * @return string to display * */ static function showItem($type, $value, &$num, $row, $extraparam = '', $params = array()) { $out = ""; switch ($type) { case Search::PDF_OUTPUT_LANDSCAPE: //pdf //pdf case Search::PDF_OUTPUT_PORTRAIT: global $PDF_TABLE; $value = preg_replace('/' . Search::LBBR . '/', '<br>', $value); $value = preg_replace('/' . Search::LBHR . '/', '<hr>', $value); $PDF_TABLE .= "<td {$extraparam} valign='top'>"; $PDF_TABLE .= Html::weblink_extract(Html::clean($value)); $PDF_TABLE .= "</td>\n"; break; case Search::SYLK_OUTPUT: //sylk global $SYLK_ARRAY, $SYLK_HEADER, $SYLK_SIZE; $value = Html::weblink_extract($value); $value = preg_replace('/' . Search::LBBR . '/', '<br>', $value); $value = preg_replace('/' . Search::LBHR . '/', '<hr>', $value); $SYLK_ARRAY[$row][$num] = Search::sylk_clean($value); $SYLK_SIZE[$num] = max($SYLK_SIZE[$num], Toolbox::strlen($SYLK_ARRAY[$row][$num])); break; case Search::CSV_OUTPUT: //csv $value = preg_replace('/' . Search::LBBR . '/', '<br>', $value); $value = preg_replace('/' . Search::LBHR . '/', '<hr>', $value); $value = Html::weblink_extract($value); $quotes = ""; if ($params['quotes']) { $quotes = "\""; } switch ($params['encoding']) { case self::ANSI_ENCODING: $out = "{$quotes}" . Toolbox::decodeFromUtf8(Search::csv_clean($value), 'windows-1252') . "{$quotes}" . $_SESSION["glpicsv_delimiter"]; break; case self::UTF8_ENCODING: $out = "{$quotes}" . Search::csv_clean($value) . "{$quotes}" . $_SESSION["glpicsv_delimiter"]; break; } break; default: $out = "<td {$extraparam} valign='top'>"; if (!preg_match('/' . Search::LBHR . '/', $value)) { $values = preg_split('/' . Search::LBBR . '/i', $value); $line_delimiter = '<br>'; } else { $values = preg_split('/' . Search::LBHR . '/i', $value); $line_delimiter = '<hr>'; } $limitto = 20; if (count($values) > $limitto) { for ($i = 0; $i < $limitto; $i++) { $out .= $values[$i] . $line_delimiter; } // $rand=mt_rand(); $out .= "... "; $value = preg_replace('/' . Search::LBBR . '/', '<br>', $value); $value = preg_replace('/' . Search::LBHR . '/', '<hr>', $value); $out .= Html::showToolTip($value, array('display' => false, 'autoclose' => false)); } else { $value = preg_replace('/' . Search::LBBR . '/', '<br>', $value); $value = preg_replace('/' . Search::LBHR . '/', '<hr>', $value); $out .= $value; } $out .= "</td>\n"; } $num++; return $out; }
/** * Display a multi-line Box : 1 column only * * @param $name string display on the left, before text * @param $content string of text display on right (multi-line) * @param $minline integer for minimum box size (default 3) * @param $maxline interger for maximum box size (1 page = 80 lines) (default 100) **/ public function displayText($name, $content = '', $minline = 3, $maxline = 100) { // New page if less than $minline available if ($this->start_tab < 20 + 10 / $minline) { $this->newPage(); } // The Box Initial Size = $minline $gray = 0.95; $this->pdf->saveState(); $this->pdf->setColor($gray, $gray, $gray); $this->pdf->filledRectangle(25, $bottom = $this->start_tab - $minline * 10 + 5, $this->width - 50, $minline * 10 + 5); $this->pdf->restoreState(); // Title $name = Toolbox::decodeFromUtf8($name, "windows-1252"); $x = 30 + $this->pdf->getTextWidth(9, $name); $this->pdf->addText(27, $this->start_tab, 9, $name); $temp = str_replace("\r\n", "\n", $content); $lines = explode("\n", Toolbox::decodeFromUtf8($temp, "windows-1252")); $line = current($lines); // Content while ($line !== false && $maxline > 0) { // Need a new page ? if ($this->start_tab < 30) { $this->newPage(); $bottom = $this->start_tab + 10; } // Extent initial box if ($this->start_tab < $bottom) { $newbottom = $this->start_tab - 5; $this->pdf->saveState(); $this->pdf->setColor($gray, $gray, $gray); $this->pdf->filledRectangle(25, $newbottom, $this->width - 50, $bottom - $newbottom); $this->pdf->restoreState(); $bottom = $newbottom; } if (!empty($line)) { $line = $this->pdf->addTextWrap($x, $this->start_tab, $this->width - $x - 25, 9, $line); } if (empty($line)) { $line = next($lines); } $this->start_tab -= 10; $maxline--; } // Final position = behind the box $this->start_tab = $bottom - 15; }