linea21-utils
[ class tree: linea21-utils ] [ index: linea21-utils ] [ all elements ]

Source for file pdf.report.inc.php

Documentation is available at pdf.report.inc.php

  1. <?php
  2. /**
  3.  * @package linea21.utils
  4.  * @subpackage report_sdi
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Define, compose and generate a SDI (Sustainable Development Indicators) PDF report
  10.  */
  11.  
  12. /**
  13.  * DisplayOneSdi()
  14.  * Affiche un IDD + infos satellites
  15.  *
  16.  * @param int $pointer 
  17.  * @return bool true
  18.  */
  19. function DisplayOneSdi($pointer)
  20. {
  21.   global $sdi;
  22.   global $pdf;
  23.   global $report_settings;
  24.  
  25.   $pdf->AddPage();
  26.   // lien interne si actif
  27.   if ($report_settings['summary'] === true) $pdf->SetLink($pointer+1);
  28.   DisplayGeneralsInfo($sdi[$pointer]);
  29.   DisplayValues($sdi[$pointer]['sdii_id']);
  30.   if ($report_settings['display_provider'] === true) DisplayProviderInfo($sdi[$pointer]);
  31.   if ($report_settings['display_reglementation'] === true) DisplayReglementationInfo($sdi[$pointer]);
  32.   if ($report_settings['display_evaluation'] === true) DisplayEvaluationInfo($sdi[$pointer]);
  33.  
  34.   return true;
  35. }
  36.  
  37.  
  38. function FormatSdiItem($libelle)
  39. {
  40.   global $pdf;
  41.   
  42.   $libelle="        ".$libelle;
  43.   $pdf->SetFont(DOC_POLICE, SDI_ITEM_STYLE, SDI_ITEM_SIZE);
  44.   $pdf->SetTextColorArray(getColor('SDI_ITEM_COLOR'));
  45.   $pdf->MultiCell(0,DOC_HEIGHT,$libelle,0,'L',0);
  46.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  47.   $pdf->SetFont(DOC_POLICE,DOC_STYLE,DOC_SIZE);
  48. }
  49.  
  50. function FormatSdiInfo($libelle)
  51. {
  52.   global $pdf;
  53.   
  54.   $pdf->SetFillColorArray(getColor('BCKG_INFO'));
  55.   $pdf->SetFont(DOC_POLICE, SDI_INFO_STYLE, SDI_INFO_SIZE);
  56.   $pdf->SetTextColorArray(getColor('SDI_INFO_COLOR'));
  57.   $pdf->MultiCell(0,DOC_HEIGHT+1,$libelle,0,'L',1);
  58.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  59.   $pdf->SetFont(DOC_POLICE,DOC_STYLE,DOC_SIZE);
  60.   $pdf->Ln(DOC_INTERVAL);
  61. }
  62.  
  63. // Saut de paragraphe
  64. function ParagraphBreak()
  65. {
  66.   global $pdf;
  67.   
  68.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  69.   $pdf->SetFont(DOC_POLICE,DOC_STYLE,DOC_SIZE);
  70.   $pdf->Ln(PARAGRAPH_BREAK);
  71. }
  72.  
  73. /**
  74.  * DisplayGeneralsInfo()
  75.  * Affiche les infos générales d'un IDD
  76.  *
  77.  * @param int $current_record 
  78.  * @return bool true
  79.  */
  80. function DisplayGeneralsInfo($current_record)
  81. {
  82.   global $pdf;
  83.   global $lang;
  84.   global $report_settings;
  85.  
  86.   // titre d'un indicateur
  87.   $out_title = formatText($current_record['sdii_name']);
  88.   $pdf->SetTextColorArray(getColor('SDI_TITLE_COLOR'));
  89.   $pdf->SetFont(DOC_POLICE, SDI_TITLE_STYLE, SDI_TITLE_SIZE);
  90.   $pdf->Bookmark(ucfirst(strtolower($out_title)));
  91.   $pdf->Write(DOC_HEIGHT, $out_title);
  92.   // si non publié
  93.   if ($current_record['sdii_statut'] == 'D') {
  94.     $pdf->SetTextColorArray(getColor('DOC_ADVISE_COLOR'));
  95.     $pdf->SetFont(DOC_POLICE, '', SDI_TITLE_SIZE);
  96.     $out_status = ' :: ' . strtolower($lang['statut']['draftpdf']);
  97.     $pdf->Write(DOC_HEIGHT, $out_status);
  98.     $pdf->SetFont(DOC_POLICE, SDI_TITLE_STYLE, SDI_TITLE_SIZE);
  99.     $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  100.   }
  101.   $pdf->Ln(DOC_HEIGHT);
  102.   // thème d'appartenance
  103.   $out_theme = formatText('» ' . $lang['sdi']['theme'] . ' : ' . $current_record['theme_name'] . ' (' . $current_record['sdtheme_name'] . ')') . END_LINE;
  104.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  105.   $pdf->SetTextColorArray(getColor('SDI_TITLE_COLOR'));
  106.   $pdf->Write(DOC_HEIGHT, $out_theme);
  107.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  108.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  109.   // description
  110.   $out_desc = formatText(strip_tags($current_record['sdii_description'])) . END_LINE;
  111.   $pdf->Bookmark(ucfirst($lang['sdi']['description']), 1, -1);
  112.   $pdf->MultiCell(0, DOC_HEIGHT, $out_desc, 0, 'L');
  113.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  114.   // objectif
  115.   $out_goal = formatText(empty_nc(strip_tags($current_record['sdii_goal']))) . END_LINE;
  116.   $out_goal_item = formatText(ucfirst($lang['sdi']['goal']));
  117.   $pdf->Bookmark($out_goal_item, 1, -1);
  118.   FormatSdiItem($out_goal_item);
  119.   $pdf->MultiCell(0, DOC_HEIGHT, $out_goal, 0, 'L');
  120.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  121.   // conseil d'amélioration
  122.   $out_consulting = formatText(empty_nc(strip_tags($current_record['sdii_consulting']))) . END_LINE;
  123.   $out_consulting_item = formatText(ucfirst($lang['sdi']['consulting']));
  124.   $pdf->Bookmark($out_consulting_item, 1, -1);
  125.   FormatSdiItem($out_consulting_item);
  126.   $pdf->MultiCell(0, DOC_HEIGHT, $out_consulting, 0, 'L');
  127.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  128.   // informations de mesure
  129.   $out_mesures_item = formatText(ucfirst($lang['sdi']['info_mesure']));
  130.   $out_mesures_behavior = ($current_record['sdii_threshold_relative'] == 'Y' ? $lang['sdi']['threshold_relative_Y']: $lang['sdi']['threshold_relative_N']);
  131.   $out_mesures_unit = formatText($lang['sdi']['unit']) . ' : ' . $current_record['sdii_unit'] . END_LINE;
  132.   $pdf->Bookmark($out_mesures_item, 1, -1);
  133.   FormatSdiItem($out_mesures_item);
  134.   // unitée de mesure
  135.   $pdf->SetFont(DOC_POLICE, EM_STYLE, MIN_SIZE);
  136.   $pdf->Write(DOC_HEIGHT, $out_mesures_unit . END_LINE);
  137.   // comportement
  138.   $pdf->Write(DOC_HEIGHT, $out_mesures_behavior . END_LINE);
  139.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  140.   // tableau de valeurs
  141.   DrawMesuresArray($current_record);
  142.   $pdf->SetFont(DOC_POLICE, EM_STYLE, MIN_SIZE);
  143.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  144. }
  145.  
  146. /**
  147.  * DrawMesuresArray()
  148.  * Dessine le tableau des valeurs IDD
  149.  *
  150.  * @param  $current_record 
  151.  * @return bool true
  152.  */
  153. function DrawMesuresArray($current_record)
  154. {
  155.   global $pdf;
  156.   global $lang;
  157.  
  158.   $tbl = '
  159.   <table cellspacing="0" cellpadding="5" border="1">
  160.   <thead>
  161.       <tr>
  162.           <td>'.$lang['sdi']['max_value'].'</td>
  163.           <td>'.$lang['sdi']['min_value'].'</td>
  164.           <td>'.$lang['sdi']['threshold_value'].'</td>
  165.           <td>'.$lang['sdi']['frequency'].'</td>
  166.       </tr>
  167.   </thead>
  168.       <tr>
  169.           <td>'.$current_record['sdii_max_value'].'</td>
  170.           <td>'.$current_record['sdii_min_value'].'</td>
  171.           <td>'.$current_record['sdii_threshold_value'].'</td>
  172.           <td>'.$current_record['sdii_frequency'].'</td>
  173.       </tr>
  174.   </table>';
  175.   
  176.   $pdf->writeHTML($tbl, true, false, false, false, '');
  177.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  178.  
  179.   return true;
  180. }
  181.  
  182. /**
  183.  * DisplayProviderInfo()
  184.  * Affiche les informations Fournisseurs d'un IDD
  185.  *
  186.  * @param  $current_record 
  187.  * @return bool true
  188.  */
  189. function DisplayProviderInfo($current_record)
  190. {
  191.   global $pdf;
  192.   global $lang;
  193.  
  194.   $out_name = formatText($current_record['sdip_name']);
  195.   if (!empty($current_record['sdip_service'])) $out_name .= ' - ' . formatText($current_record['sdip_service']);
  196.   if (!empty($current_record['sdip_incharge'])) $out_name .= ' - ' . formatText($current_record['sdip_incharge']) . ' (' . $lang['sdi']['p_incharge'] . ')';
  197.   $out_name .= END_LINE;
  198.   $out_adress = formatText(empty_nc(strip_tags($current_record['sdip_address'])));
  199.   $out_phone_fax = $lang['sdi']['p_phone'] . ' : ' . formatText(empty_nc($current_record['sdip_phone']));
  200.   $out_phone_fax .= ' - ' . $lang['sdi']['p_fax'] . ' : ' . formatText(empty_nc($current_record['sdip_fax'])) . END_LINE;
  201.   $out_email_item = $lang['sdi']['p_email'] . ' : ';
  202.   $out_email = formatText($current_record['sdip_email']);
  203.   $out_desc = formatText(empty_nc(strip_tags($current_record['sdip_description']))) . END_LINE;
  204.   $out_provider_item = formatText(ucfirst($lang['sdi']['p_title'])) ;
  205.  
  206.   $pdf->Bookmark($out_provider_item, 1, -1);
  207.   FormatSdiInfo($out_provider_item);
  208.  
  209.   $firstcell_width = 60;
  210.  
  211.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  212.   $pdf->MultiCell(0, DOC_HEIGHT, $out_name, 0, 'L');
  213.  
  214.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  215.   $pdf->MultiCell(0, DOC_HEIGHT, $out_adress, 0, 'L');
  216.  
  217.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  218.   $pdf->MultiCell(0, DOC_HEIGHT, $out_phone_fax, 0, 'L');
  219.  
  220.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  221.   $pdf->Cell($pdf->GetStringWidth($out_email_item), DOC_HEIGHT, $out_email_item);
  222.   if (empty($out_email)) $pdf->Cell(0, DOC_HEIGHT, empty_nc($out_email));
  223.   else $pdf->Cell(0, DOC_HEIGHT, $out_email, 0, 0, 'L', 0, 'mailto:' . $out_email);
  224.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  225.  
  226.   return true;
  227. }
  228.  
  229. /**
  230.  * DisplayReglementationInfo()
  231.  * Affiche la réglementation d'un IDD
  232.  *
  233.  * @param  $current_record 
  234.  * @return bool true
  235.  */
  236. function DisplayReglementationInfo($current_record)
  237. {
  238.   global $pdf;
  239.   global $lang;
  240.  
  241.   $out_name = formatText(empty_nc($current_record['sdir_title'])) . END_LINE;
  242.   $out_body = formatText(empty_nc(strip_tags($current_record['sdir_body']))) . END_LINE;
  243.   $out_uri = formatText($current_record['sdir_mask_uri']);
  244.   $out_uri_href = $current_record['sdir_referer_uri'];
  245.  
  246.   $out_name_item = $lang['sdi']['r_title'] . ' : ';
  247.   $out_body_item = $lang['sdi']['r_body'] . ' : ';
  248.   $out_uri_item = $lang['sdi']['r_referer_uri'] . ' : ';
  249.  
  250.   $out_reglementation_item = formatText(ucfirst($lang['sdi']['add_step4'])) ;
  251.  
  252.   $pdf->Bookmark($out_reglementation_item, 1, -1);
  253.   FormatSdiInfo($out_reglementation_item);
  254.  
  255.   $firstcell_width = 60;
  256.   // nom de l'organisme fournisseur
  257.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  258.   $pdf->Cell($firstcell_width, DOC_HEIGHT, $out_name_item, 0, 0, 'R');
  259.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  260.   $pdf->MultiCell(0, DOC_HEIGHT, $out_name, 0, 'L');
  261.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  262.   // détail reglementation
  263.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  264.   $pdf->Cell($firstcell_width, DOC_HEIGHT, $out_body_item, 0, 0, 'R');
  265.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  266.   $pdf->MultiCell(0, DOC_HEIGHT, $out_body, 0, 'L');
  267.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  268.   // lien internet reglementation
  269.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  270.   $pdf->Cell($firstcell_width, DOC_HEIGHT, $out_uri_item, 0, 0, 'R');
  271.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  272.   if (!empty($out_uri_href)) {
  273.     if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, $out_uri, 0, 0, '', 0, $out_uri_href);
  274.     //if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, ' (', 0, 0);
  275.     //$pdf->Cell(0, DOC_HEIGHT, $out_uri, 0, 0, '', 0, $out_uri_href);
  276.     //if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, ')', 0, 0);
  277.   } else $pdf->Write(DOC_HEIGHT, empty_nc($out_uri));
  278.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  279.  
  280.   return true;
  281. }
  282.  
  283. /**
  284.  * DisplayEvaluationInfo()
  285.  * Affiche le tableau de critères d'évaluation
  286.  *
  287.  * @param int $current_record 
  288.  * @return bool true
  289.  */
  290. function DisplayEvaluationInfo($current_record)
  291. {
  292.   global $pdf;
  293.   global $lang;
  294.  
  295.   $out_eval_item = formatText(ucfirst($lang['sdi']['e_title'])) ;
  296.  
  297.   $pdf->Bookmark($out_eval_item, 1, -1);
  298.   FormatSdiInfo($out_eval_item);
  299.   
  300.   
  301.   $tbl = '
  302.       <table cellspacing="0" cellpadding="5" border="1">
  303.       <thead>
  304.           <tr>
  305.               <td>'.$lang['sdi']['e_scale_compare'].'</td>
  306.               <td>'.$lang['sdi']['e_fiability'].'</td>
  307.               <td>'.$lang['sdi']['e_accessibility'].'</td>
  308.               <td>'.$lang['sdi']['e_lisibility'].'</td>
  309.               <td>'.$lang['sdi']['e_relevance'].'</td>
  310.               <td>'.$lang['sdi']['e_global_performance'].'</td>
  311.           </tr>
  312.       </thead>
  313.         <tr>
  314.             <td>'.$current_record['sdie_scale_compare'].'</td>
  315.             <td>'.$current_record['sdie_fiability'].'</td>
  316.             <td>'.$current_record['sdie_accessibility'].'</td>
  317.             <td>'.$current_record['sdie_lisibility'].'</td>
  318.             <td>'.$current_record['sdie_relevance'].'</td>
  319.             <td>'.$current_record['sdie_global_performance'].'</td>
  320.           </tr>
  321.       </table>';
  322.   
  323.   $pdf->writeHTML($tbl, true, false, false, false, '');
  324.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  325.  
  326.   return true;
  327. }
  328.  
  329. /**
  330.  * DisplayValues()
  331.  * Affiche les valeurs d'un IDD.
  332.  *
  333.  * @param int $sdi_id 
  334.  * @return bool true
  335.  ***/
  336. function DisplayValues($sdi_id)
  337. {
  338.   global $pdf;
  339.   global $lang;
  340.   global $report_settings;
  341.   global $scale_array;
  342.   global $sql_object;
  343.  
  344.   if ($report_settings['graphic_values'] === true && $report_settings['table_values'] === true) $mode = 'TWICE';
  345.   elseif ($report_settings['graphic_values'] === true || $report_settings['table_values'] === true) $mode = 'ONE';
  346.   else return false;
  347.  
  348.   $out_values_item = ucfirst($lang['dashboard']['value']);
  349.   $pdf->Bookmark($out_values_item, 1, -1);
  350.   FormatSdiInfo($out_values_item);
  351.  
  352.   $scale_no_values = array(); // recipient no values
  353.   $scale_insuffisant_values = array(); // recipient insuffisant values graph
  354.   for($i = 0; $i < count($scale_array); $i++) {
  355.     if ($report_settings['graphic_values'] === true) {
  356.       if (DisplayGraphicValues($sdi_id, $scale_array[$i], GetStatus($report_settings['status']), $mode) === false) array_push($scale_insuffisant_values, $scale_array[$i]);
  357.     }
  358.  
  359.     if ($report_settings['table_values'] === true) {
  360.       if (DisplayTableValues($sdi_id, $scale_array[$i], GetStatus($report_settings['status']), $mode) === false) array_push($scale_no_values, $scale_array[$i]);
  361.     }
  362.   }
  363.   DisplayNoValuesFor($scale_no_values, $lang['dashboard']['rap_no_values_for']);
  364.   DisplayNoValuesFor($scale_insuffisant_values, $lang['dashboard']['rap_insuffisant_values'], $mode, $scale_no_values);
  365.  
  366.   return true;
  367. }
  368.  
  369. /**
  370.  * GetStatus()
  371.  * Formattage du statut pour requête SQL
  372.  *
  373.  * @param string $current_status 
  374.  * @return string $status
  375.  ***/
  376. function GetStatus($current_status)
  377. {
  378.   switch ($current_status) {
  379.     case 'ALL':
  380.       $status = 'SCA';
  381.       break;
  382.     case 'PUBLIC':
  383.       $status = 'SCP';
  384.       break;
  385.   }
  386.   return $status;
  387. }
  388.  
  389. /**
  390.  * DisplayNoValuesFor()
  391.  * Affiche les échelles ne contenant pas de valeurs ou insuffisamment
  392.  *
  393.  * @param array $array_scale 
  394.  * @param string $message 
  395.  * @param integer $mode 
  396.  * @param integer $array 
  397.  * @return bool true
  398.  ***/
  399. function DisplayNoValuesFor($array_scale, $message, $mode = -1, $array = -1)
  400. {
  401.   global $pdf;
  402.   global $lang;
  403.   global $scale_denomination_array;
  404.   $content = '';
  405.   $sep = '';
  406.   // si mode TWICE et deuxième tableau fourni. On le soustrait au premier.
  407.   if ($array != -1 && $mode == 'TWICE') $array_scale = array_values(array_diff($array_scale, $array));
  408.  
  409.   if (count($array_scale) == 0) return true;
  410.  
  411.   for($i = 0; $i < count($array_scale); $i++) {
  412.     $content .= $sep . $scale_denomination_array[$array_scale[$i]];
  413.     $sep = ', ';
  414.   }
  415.   if (empty($content)) return true;
  416.   $margin = 0;
  417.   $pdf->SetX($pdf->GetX() + $margin);
  418.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  419.   $pdf->Cell(0, DOC_HEIGHT, $message, 0, 1, 'L');
  420.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  421.   $margin = 10;
  422.   $pdf->SetTextColorArray(getColor('DOC_ADVISE_COLOR'));
  423.   $pdf->SetX($pdf->GetX() + $margin);
  424.   $pdf->MultiCell(0, DOC_HEIGHT, $content, 0, 'L');
  425.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  426.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  427.  
  428.   return true;
  429. }
  430.  
  431. /**
  432.  * DisplayGraphicValues()
  433.  * Gènère et affiche les valeurs sous forme graphique
  434.  *
  435.  * @param int $sdi_id 
  436.  * @param int $current_scale 
  437.  * @param string $status 
  438.  * @param string $mode 
  439.  * @return bool true
  440.  ***/
  441. function DisplayGraphicValues($sdi_id, $current_scale, $status, $mode)
  442. {
  443.   global $pdf;
  444.   global $sql_object;
  445.   global $scale_denomination_array;
  446.  
  447.   $values = $sql_object->DBSelect(SQL_getAllValue($status, $current_scale, $sdi_id));
  448.   // renversement des valeurs pour affichage chronologique
  449.   if(is_array($values)) $values = @array_reverse ($values, false);
  450.  
  451.   $result_sdii = $sql_object->DBSelect(SQL_getInfoSdi($sdi_id));
  452.  
  453.   if (count($values) < 3) return false;
  454.   // on checke si le graph tient sur la page sinon Saut de page
  455.   // $pdf->CheckPageBreak((GRAPH_HEIGHT * 0.36) + DOC_INTERVAL);
  456.   // Affichage du titre seulement si $values>= 3
  457.   $out_scale_item = $scale_denomination_array[$current_scale];
  458.   //$pdf->Bookmark($out_scale_item, 2, -1);
  459.   FormatSdiItem($out_scale_item);
  460.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  461.  
  462.   // stockage de l'ordonnée initiale
  463.   $_y = $pdf->GetY();
  464.  
  465.   // positionnement en fonction du mode.
  466.  
  467.   if ($mode == 'TWICE') $_x = 104;
  468.   else $_x = 50;
  469.  
  470.   require_once "../class/system/artichow/BarPlot.class.php";
  471.   require_once "../class/system/artichow/LinePlot.class.php";
  472.  
  473.   $unit = $result_sdii[0]['sdii_unit'];
  474.  
  475.   for ($i = 0; $i < count($values); $i++) {
  476.     $ydata[$i] = $values[$i]['sdiv_value'];
  477.     $ydata2[$i] = $result_sdii[0]['sdii_threshold_value'];
  478.     list($day, $month, $year)=explode('-', $values[$i]['date_p']);
  479.     $months[$i] = $day . '-' .$month. '-'. substr($year, 2, 2);
  480.   }
  481.  
  482.   // Create the graph.
  483.   $graph = new Graph(GRAPH_WIDTH, GRAPH_HEIGHT);
  484.   if(function_exists('imageantialias')) {
  485.     $graph->setAntiAliasing(TRUE);
  486.   }
  487.   $graph->border->SetColor(new Color(133, 133, 133, 50));
  488.  
  489.   $group = new PlotGroup;
  490.   $group->setSpace(5, 5, 5, 0);
  491.   $group->setBackgroundColor(
  492.   new Color(244, 244, 244)
  493.   );
  494.   $group->grid->hideVertical();
  495.   $group->grid->SetColor(new Color(0, 0, 0, 80));
  496.   $group->grid->setType(LINE_DOTTED );
  497.   $group->setPadding(40, 15, 20, 50);
  498.  
  499.   $bplot = new BarPlot($ydata);
  500.   //$bplot->setSpace(4, 4, 4, 0);
  501.   //$bplot->setPadding(15, 15, 5, 50);
  502.   $bplot->SetBarGradient(
  503.   new LinearGradient(
  504.   new Color(207, 228, 252, 0),
  505.   new Color(146, 174, 206, 0),
  506.   90
  507.   )
  508.   );
  509.  
  510.   $group->axis->left->title->set($unit);
  511.   $group->axis->left->title->setFont(new Tuffy(10));
  512.   $group->axis->left->title->move(-4, 0);
  513.   $group->axis->left->setTitleAlignment(LABEL_TOP);
  514.  
  515.   $bplot->label->border->SetColor(new Color(20, 20, 20, 20));
  516.   $bplot->label->setPadding(3, 1, 1, 0);
  517.   $bplot->barBorder->SetColor(new Color(161, 182, 206, 0));
  518.  
  519.   $group->axis->bottom->setLabelText($months);
  520.   $group->axis->bottom->label->setAngle(55);
  521.   $group->axis->bottom->label->setFont(new Tuffy(7));
  522.  
  523.   $group->add($bplot);
  524.  
  525.  
  526.   $plot = new LinePlot($ydata2, LINEPLOT_MIDDLE);
  527.   $plot->setFillColor(new Color(254, 148, 64, 50));
  528.   $plot->SetColor(new Color(254, 148, 64, 0));
  529.   $plot->mark->setType(MARK_SQUARE);
  530.   $plot->mark->setSize(5);
  531.   $plot->mark->setFill(new Color(246, 149, 55, 20));
  532.   $plot->mark->border->show();
  533.   $plot->mark->border->SetColor(new Color(254, 148, 64, 0));
  534.  
  535.   $group->add($plot);
  536.   $graph->add($group);
  537.   if(!file_exists('tmp')) mkdir('tmp');
  538.   $graph->draw('tmp/'.$sdi_id.'_'.$current_scale.'.png');
  539.   // /////////////////////////////
  540.   // Affichage
  541.   $pdf->Image('tmp/'.$sdi_id.'_'.$current_scale.'.png', $_x, $_y, 0, 0);
  542.   // conversion px -> mm + replacement en ordonnée
  543.   if ($mode == 'TWICE') $pdf->SetY($_y);
  544.   else $pdf->SetY($_y + (GRAPH_HEIGHT * 0.36)); //$pdf->SetY($_y + (GRAPH_HEIGHT * 0.36) + DOC_INTERVAL);
  545.   return true;
  546. }
  547.  
  548. /**
  549.  * DisplayTableValues()
  550.  * Affiche un tableau de valeurs a une échelle donnée
  551.  *
  552.  * @param int $sdi_id 
  553.  * @param int $current_scale 
  554.  * @param string $status 
  555.  * @param string $mode 
  556.  * @return bool true
  557.  ***/
  558. function DisplayTableValues($sdi_id, $current_scale, $status, $mode)
  559. {
  560.   global $pdf;
  561.   global $lang;
  562.   global $sql_object;
  563.   global $scale_denomination_array;
  564.   
  565.   $values ='';
  566.   $comments='';
  567.   $j = 1;
  568.  
  569.   $_y = $pdf->GetY();
  570.   $sdi_values = $sql_object->DBSelect(SQL_getAllValue($status, $current_scale, $sdi_id));
  571.   
  572.   if (count($sdi_values) <= 1 && $sdi_values[0] == false) return false;
  573.   
  574.   // we prepare values for displaying
  575.   for($i = 0; $i < count($sdi_values); $i++) {
  576.     
  577.       $current_value = formatText($sdi_values[$i]['sdiv_value']);
  578.       if ($sdi_values[$i]['sdiv_statut'] == 'D') $current_value .= ' *';
  579.       if (!empty($sdi_values[$i]['sdiv_comment'])) {
  580.         if($sdi_values[$i]['sdiv_comment_display']=='Y') {
  581.           $comment_status = _t('dashboard', 'public');
  582.         } else {
  583.           $comment_status = _t('dashboard', 'private');
  584.         }
  585.         $bullet = ' <sup>['.$j.']</sup>';
  586.         $current_value .= $bullet;
  587.         $comments .= $bullet. ' '.formatText(strip_tags($sdi_values[$i]['sdiv_comment'])) .' ('.$comment_status.')<br />';
  588.         $j++;
  589.       }
  590.       $current_date = formatText($sdi_values[$i]['date_p']);
  591.       $values .= '
  592.             <tr>
  593.                 <td>'.$current_value.'</td>
  594.                 <td>'.$current_date.'</td>
  595.             </tr>';
  596.   }
  597.  
  598.   
  599.  
  600.   if ($mode != 'TWICE' || (count($sdi_values) >= 1 && count($sdi_values) < 3)) {
  601.     // Affichage du titre seulement si affichage des valeurs en standalone
  602.     $out_scale_item = $scale_denomination_array[$current_scale];
  603.     //$pdf->Bookmark($out_scale_item, 2, -1);
  604.     FormatSdiItem($out_scale_item);
  605.     $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  606.   }
  607.  
  608.   $pdf->Ln(DOC_INTERVAL);
  609.   if ($mode == 'TWICE') $_margin = 20;
  610.   else $_margin = 60;
  611.  
  612.   $pdf->SetX($_margin);
  613.  
  614.   
  615.   $tbl = '
  616.     <table cellspacing="0" cellpadding="5" border="1" style="width:40%">
  617.     <thead>
  618.         <tr>
  619.             <td>'.$lang['dashboard']['name_pluriel'].'</td>
  620.             <td>'.$lang['statut']['published_on'].'</td>
  621.         </tr>
  622.     </thead>
  623.     '.$values.'
  624.     </table>';
  625.   
  626.   $pdf->writeHTML($tbl, true, false, false, false, '');
  627.   
  628.   $pdf->SetX($_margin);
  629.   $pdf->SetFont(DOC_POLICE, EM_STYLE, MIN_SIZE);
  630.   $pdf->MultiCell(0, DOC_HEIGHT, '* ' . strtolower($lang['statut']['draftpdf']), 0, 'L', 0);
  631.   $pdf->SetX($_margin);
  632.   if(!empty($comments))  $pdf->writeHTMLCell(0, DOC_HEIGHT, $pdf->GetX(), $pdf->GetY(), $comments, 0, 1);
  633.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  634.   $pdf->Ln(DOC_INTERVAL * 2);
  635.   // conversion px -> mm + replacement en ordonnées
  636.   if ($mode == 'TWICE' && count($sdi_values) >= 3 && $pdf->GetY() < ($_y + (GRAPH_HEIGHT * 0.36))) $pdf->SetY($_y + (GRAPH_HEIGHT * 0.36) + DOC_INTERVAL);
  637.  
  638.   return true;
  639. }
  640.  
  641. ?>

Documentation generated on Thu, 03 May 2012 15:06:57 +0200 by phpDocumentor 1.4.1