Exemplo n.º 1
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);
 }
Exemplo n.º 2
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();
     }
 }