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+2,'   '.$libelle,0,'L',1, 1, '', '', true, 0, false, true, DOC_HEIGHT+2, 'M');
  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(mb_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.   // si non attaché au tableau de bord
  102.   if ($current_record['sdii_to_dashboard'] == 'N') {
  103.       $pdf->SetTextColorArray(getColor('DOC_ADVISE_COLOR'));
  104.       $pdf->SetFont(DOC_POLICE, '', SDI_TITLE_SIZE);
  105.       $out_attached_to_dashboard = ' (' . strtolower($lang['sdi']['not_attached_to_dashboard'].')');
  106.       $pdf->Write(DOC_HEIGHT, $out_attached_to_dashboard);
  107.       $pdf->SetFont(DOC_POLICE, SDI_TITLE_STYLE, SDI_TITLE_SIZE);
  108.       $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  109.   }
  110.   
  111.   $pdf->Ln(DOC_HEIGHT);
  112.   // thème d'appartenance
  113.   $out_theme = formatText('» ' . $lang['sdi']['theme'] . ' : ' . $current_record['theme_name'] . ' (' . $current_record['sdtheme_name'] . ')') . END_LINE;
  114.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  115.   $pdf->SetTextColorArray(getColor('SDI_TITLE_COLOR'));
  116.   $pdf->Write(DOC_HEIGHT, $out_theme);
  117.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  118.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  119.   // description
  120.   $out_desc = formatText(strip_tags($current_record['sdii_description'])) . END_LINE;
  121.   $pdf->Bookmark(mb_ucfirst($lang['sdi']['description']), 1, -1);
  122.   $pdf->MultiCell(0, DOC_HEIGHT, $out_desc, 0, 'L');
  123.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  124.   // objectif
  125.   $out_goal = formatText(empty_nc(strip_tags($current_record['sdii_goal']))) . END_LINE;
  126.   $out_goal_item = formatText(mb_ucfirst($lang['sdi']['goal']));
  127.   $pdf->Bookmark($out_goal_item, 1, -1);
  128.   FormatSdiItem($out_goal_item);
  129.   $pdf->MultiCell(0, DOC_HEIGHT, $out_goal, 0, 'L');
  130.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  131.   // conseil d'amélioration
  132.   $out_consulting = formatText(empty_nc(strip_tags($current_record['sdii_consulting']))) . END_LINE;
  133.   $out_consulting_item = formatText(mb_ucfirst($lang['sdi']['consulting']));
  134.   $pdf->Bookmark($out_consulting_item, 1, -1);
  135.   FormatSdiItem($out_consulting_item);
  136.   $pdf->MultiCell(0, DOC_HEIGHT, $out_consulting, 0, 'L');
  137.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  138.  
  139.   
  140.   // informations de mesure
  141.   $out_mesures_item = formatText(ucfirst($lang['sdi']['info_mesure']));
  142.   $out_mesures_behavior = ($current_record['sdii_threshold_relative'] == 'Y' ? $lang['sdi']['threshold_relative_Y']: $lang['sdi']['threshold_relative_N']);
  143.   $out_mesures_unit = formatText($lang['sdi']['unit']) . ' : ' . $current_record['sdii_unit'] . END_LINE;
  144.   $pdf->Bookmark($out_mesures_item, 1, -1);
  145.   FormatSdiItem($out_mesures_item);
  146.   // unitée de mesure
  147.   $pdf->SetFont(DOC_POLICE, EM_STYLE, MIN_SIZE);
  148.   $pdf->Write(DOC_HEIGHT, $out_mesures_unit . END_LINE);
  149.   // comportement
  150.   $pdf->Write(DOC_HEIGHT, $out_mesures_behavior . END_LINE);
  151.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  152.   // tableau de valeurs
  153.   DrawMesuresArray($current_record);
  154.   $pdf->SetFont(DOC_POLICE, EM_STYLE, MIN_SIZE);
  155.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  156. }
  157.  
  158. /**
  159.  * DrawMesuresArray()
  160.  * Dessine le tableau des valeurs IDD
  161.  *
  162.  * @param  $current_record 
  163.  * @return bool true
  164.  */
  165. function DrawMesuresArray($current_record)
  166. {
  167.   global $pdf;
  168.   global $lang;
  169.  
  170.   $tbl = '<style>
  171.     td {
  172.         text-align:center;
  173.     }
  174.     </style>
  175.   <table cellspacing="0" cellpadding="5" border="1" nobr="true">
  176.   <thead>
  177.       <tr>
  178.           <td>'.mb_ucfirst($lang['sdi']['max_value']).'</td>
  179.           <td>'.mb_ucfirst($lang['sdi']['min_value']).'</td>
  180.           <td>'.mb_ucfirst($lang['sdi']['initial_threshold_value']).'</td>
  181.           <td>'.mb_ucfirst($lang['sdi']['frequency']).'</td>
  182.       </tr>
  183.   </thead>
  184.       <tr>
  185.           <td>'.empty_nc($current_record['sdii_max_value']).'</td>
  186.           <td>'.empty_nc($current_record['sdii_min_value']).'</td>
  187.           <td>'.empty_nc($current_record['sdii_threshold_value']).'</td>
  188.           <td>'.$current_record['sdii_frequency'].'</td>
  189.       </tr>
  190.   </table>';
  191.   
  192.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, MIN_SIZE);
  193.   $pdf->writeHTML($tbl, true, false, false, false, '');
  194.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  195.  
  196.   return true;
  197. }
  198.  
  199. /**
  200.  * DisplayProviderInfo()
  201.  * Affiche les informations Fournisseurs d'un IDD
  202.  *
  203.  * @param  $current_record 
  204.  * @return bool true
  205.  */
  206. function DisplayProviderInfo($current_record)
  207. {
  208.   global $pdf;
  209.   global $lang;
  210.  
  211.   $out_name = formatText($current_record['sdip_name']);
  212.   if (!empty($current_record['sdip_service'])) $out_name .= ' - ' . formatText($current_record['sdip_service']);
  213.   if (!empty($current_record['sdip_incharge'])) $out_name .= ' - ' . formatText($current_record['sdip_incharge']) . ' (' . $lang['sdi']['p_incharge'] . ')';
  214.   $out_name .= END_LINE;
  215.   $out_adress = formatText(empty_nc(strip_tags($current_record['sdip_address'])));
  216.   $out_phone_fax = $lang['sdi']['p_phone'] . ' : ' . formatText(empty_nc($current_record['sdip_phone']));
  217.   $out_phone_fax .= ' - ' . $lang['sdi']['p_fax'] . ' : ' . formatText(empty_nc($current_record['sdip_fax'])) . END_LINE;
  218.   $out_email_item = $lang['sdi']['p_email'] . ' : ';
  219.   $out_email = formatText($current_record['sdip_email']);
  220.   $out_desc = formatText(empty_nc(strip_tags($current_record['sdip_description']))) . END_LINE;
  221.   $out_provider_item = formatText(ucfirst($lang['sdi']['p_title'])) ;
  222.  
  223.   $pdf->Bookmark($out_provider_item, 1, -1);
  224.   FormatSdiInfo($out_provider_item);
  225.  
  226.   $firstcell_width = 60;
  227.  
  228.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  229.   $pdf->MultiCell(0, DOC_HEIGHT, $out_name, 0, 'L');
  230.  
  231.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  232.   $pdf->MultiCell(0, DOC_HEIGHT, $out_adress, 0, 'L');
  233.  
  234.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  235.   $pdf->MultiCell(0, DOC_HEIGHT, $out_phone_fax, 0, 'L');
  236.  
  237.   $pdf->SetX($pdf->GetX() + $firstcell_width);
  238.   $pdf->Cell($pdf->GetStringWidth($out_email_item), DOC_HEIGHT, $out_email_item);
  239.   if (empty($out_email)) $pdf->Cell(0, DOC_HEIGHT, empty_nc($out_email));
  240.   else $pdf->Cell(0, DOC_HEIGHT, $out_email, 0, 0, 'L', 0, 'mailto:' . $out_email);
  241.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  242.  
  243.   return true;
  244. }
  245.  
  246. /**
  247.  * DisplayReglementationInfo()
  248.  * Affiche la réglementation d'un IDD
  249.  *
  250.  * @param  $current_record 
  251.  * @return bool true
  252.  */
  253. function DisplayReglementationInfo($current_record)
  254. {
  255.   global $pdf;
  256.   global $lang;
  257.  
  258.   $out_name = formatText(empty_nc($current_record['sdir_title'])) . END_LINE;
  259.   $out_body = formatText(empty_nc(strip_tags($current_record['sdir_body']))) . END_LINE;
  260.   $out_uri = formatText($current_record['sdir_mask_uri']);
  261.   $out_uri_href = $current_record['sdir_referer_uri'];
  262.  
  263.   $out_name_item = mb_ucfirst($lang['sdi']['r_title']) . ' : ';
  264.   $out_body_item = mb_ucfirst($lang['sdi']['r_body']) . ' : ';
  265.   $out_uri_item = mb_ucfirst($lang['sdi']['r_referer_uri']) . ' : ';
  266.  
  267.   $out_reglementation_item = formatText(ucfirst($lang['sdi']['add_step4'])) ;
  268.  
  269.   $pdf->Bookmark($out_reglementation_item, 1, -1);
  270.   FormatSdiInfo($out_reglementation_item);
  271.  
  272.   $firstcell_width = 60;
  273.   // nom de l'organisme fournisseur
  274.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  275.   $pdf->Cell($firstcell_width, DOC_HEIGHT, $out_name_item, 0, 0, 'R');
  276.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  277.   $pdf->MultiCell(0, DOC_HEIGHT, $out_name, 0, 'L');
  278.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  279.   // détail reglementation
  280.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  281.   $pdf->Cell($firstcell_width, DOC_HEIGHT, $out_body_item, 0, 0, 'R');
  282.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  283.   $pdf->MultiCell(0, DOC_HEIGHT, $out_body, 0, 'L');
  284.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  285.   // lien internet reglementation
  286.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  287.   $pdf->Cell($firstcell_width, DOC_HEIGHT, $out_uri_item, 0, 0, 'R');
  288.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  289.   if (!empty($out_uri_href)) {
  290.     if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, $out_uri, 0, 0, '', 0, $out_uri_href);
  291.     //if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, ' (', 0, 0);
  292.     //$pdf->Cell(0, DOC_HEIGHT, $out_uri, 0, 0, '', 0, $out_uri_href);
  293.     //if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, ')', 0, 0);
  294.   } else $pdf->Write(DOC_HEIGHT, empty_nc($out_uri));
  295.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  296.  
  297.   return true;
  298. }
  299.  
  300. /**
  301.  * DisplayEvaluationInfo()
  302.  * Affiche le tableau de critères d'évaluation
  303.  *
  304.  * @param int $current_record 
  305.  * @return bool true
  306.  */
  307. function DisplayEvaluationInfo($current_record)
  308. {
  309.   global $pdf;
  310.   global $lang;
  311.  
  312.   $out_eval_item = formatText(mb_ucfirst($lang['sdi']['e_title'])) ;
  313.  
  314.   $pdf->Bookmark($out_eval_item, 1, -1);
  315.   FormatSdiInfo($out_eval_item);
  316.   
  317.   
  318.   $tbl = '<style>
  319.             td {
  320.                 text-align:center;
  321.             }
  322.             </style>
  323.       <table cellspacing="0" cellpadding="5" border="1" nobr="true">
  324.       <thead>
  325.           <tr>
  326.               <td>'.mb_ucfirst($lang['sdi']['e_scale_compare']).'</td>
  327.               <td>'.mb_ucfirst($lang['sdi']['e_fiability']).'</td>
  328.               <td>'.mb_ucfirst($lang['sdi']['e_accessibility']).'</td>
  329.               <td>'.mb_ucfirst($lang['sdi']['e_lisibility']).'</td>
  330.               <td>'.mb_ucfirst($lang['sdi']['e_relevance']).'</td>
  331.               <td>'.mb_ucfirst($lang['sdi']['e_global_performance']).'</td>
  332.           </tr>
  333.       </thead>
  334.         <tr>
  335.             <td>'.$current_record['sdie_scale_compare'].'</td>
  336.             <td>'.$current_record['sdie_fiability'].'</td>
  337.             <td>'.$current_record['sdie_accessibility'].'</td>
  338.             <td>'.$current_record['sdie_lisibility'].'</td>
  339.             <td>'.$current_record['sdie_relevance'].'</td>
  340.             <td>'.$current_record['sdie_global_performance'].'</td>
  341.           </tr>
  342.       </table>';
  343.   
  344.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, MIN_SIZE);
  345.   $pdf->writeHTML($tbl, true, false, false, false, '');
  346.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  347.  
  348.   return true;
  349. }
  350.  
  351.  
  352. /**
  353.  * DisplayValues()
  354.  * Affiche les valeurs d'un IDD.
  355.  *
  356.  * @param int $sdi_id 
  357.  * @return bool true
  358.  ***/
  359. function DisplayValues($sdi_id)
  360. {
  361.   global $pdf;
  362.   global $lang;
  363.   global $report_settings;
  364.   global $scale_array;
  365.   global $sql_object;
  366.   global $scale_denomination_array;
  367.   
  368.   if(count($scale_array) == 0) return true;
  369.  
  370.   if ($report_settings['graphic_values'] === true && $report_settings['table_values'] === true) $mode = 'TWICE';
  371.   elseif ($report_settings['graphic_values'] === true || $report_settings['table_values'] === true) $mode = 'ONE';
  372.   else return false;
  373.  
  374.   $out_values_item = mb_ucfirst($lang['dashboard']['value']);
  375.   $pdf->Bookmark($out_values_item, 1, -1);
  376.   FormatSdiInfo($out_values_item);
  377.  
  378.   $scale_no_values = array(); // recipient no values
  379.   $scale_insuffisant_values = array(); // recipient insuffisant values graph
  380.   
  381.   
  382.   for($i = 0; $i < count($scale_array); $i++) {
  383.  
  384.       // we print chart if asked
  385.     if ($report_settings['graphic_values'] === true) {
  386.       if (DisplayGraphicValues($sdi_id, $scale_array[$i], GetStatus($report_settings['status']), $mode) === false) array_push($scale_insuffisant_values, $scale_array[$i]);
  387.     }
  388.  
  389.     // we print values if asked
  390.     if ($report_settings['table_values'] === true) {
  391.         if (DisplayTableValues($sdi_id, $scale_array[$i], GetStatus($report_settings['status']), $mode) === false) array_push($scale_no_values, $scale_array[$i]);
  392.     }
  393.     
  394.   }
  395.   DisplayNoValuesFor($scale_no_values, $lang['dashboard']['rap_no_values_for']);
  396.   DisplayNoValuesFor($scale_insuffisant_values, $lang['dashboard']['rap_insuffisant_values'], $mode, $scale_no_values);
  397.  
  398.   return true;
  399. }
  400.  
  401.  
  402. /**
  403.  * GetStatus()
  404.  * Formattage du statut pour requête SQL
  405.  *
  406.  * @param string $current_status 
  407.  * @return string $status
  408.  ***/
  409. function GetStatus($current_status)
  410. {
  411.   switch ($current_status) {
  412.     case 'ALL':
  413.       $status = 'SCA';
  414.       break;
  415.     case 'PUBLIC':
  416.       $status = 'SCP';
  417.       break;
  418.   }
  419.   return $status;
  420. }
  421.  
  422. /**
  423.  * DisplayNoValuesFor()
  424.  * Affiche les échelles ne contenant pas de valeurs ou insuffisamment
  425.  *
  426.  * @param array $array_scale 
  427.  * @param string $message 
  428.  * @param integer $mode 
  429.  * @param integer $array 
  430.  * @return bool true
  431.  ***/
  432. function DisplayNoValuesFor($array_scale, $message, $mode = -1, $array = -1)
  433. {
  434.   global $pdf;
  435.   global $lang;
  436.   global $scale_denomination_array;
  437.   $content = '';
  438.   $sep = '';
  439.   // si mode TWICE et deuxième tableau fourni. On le soustrait au premier.
  440.   if ($array != -1 && $mode == 'TWICE') $array_scale = array_values(array_diff($array_scale, $array));
  441.  
  442.   if (count($array_scale) == 0) return true;
  443.  
  444.   for($i = 0; $i < count($array_scale); $i++) {
  445.     $content .= $sep . $scale_denomination_array[$array_scale[$i]];
  446.     $sep = ', ';
  447.   }
  448.   if (empty($content)) return true;
  449.   $margin = 0;
  450.   $pdf->SetX($pdf->GetX() + $margin);
  451.   $pdf->SetFont(DOC_POLICE, EM_STYLE, DOC_SIZE);
  452.   $pdf->Cell(0, DOC_HEIGHT, $message, 0, 1, 'L');
  453.   $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  454.   $margin = 10;
  455.   $pdf->SetTextColorArray(getColor('DOC_ADVISE_COLOR'));
  456.   $pdf->SetX($pdf->GetX() + $margin);
  457.   $pdf->MultiCell(0, DOC_HEIGHT, $content, 0, 'L');
  458.   $pdf->SetY($pdf->GetY() + DOC_INTERVAL);
  459.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  460.  
  461.   return true;
  462. }
  463.  
  464. /**
  465.  * DisplayGraphicValues()
  466.  * Gènère et affiche les valeurs sous forme graphique
  467.  *
  468.  * @param int $sdi_id 
  469.  * @param int $current_scale 
  470.  * @param string $status 
  471.  * @param string $mode 
  472.  * @return bool true
  473.  ***/
  474. function DisplayGraphicValues($sdi_id, $current_scale, $status, $mode)
  475. {
  476.     global $pdf;
  477.     global $sql_object;
  478.     global $scale_denomination_array;
  479.     
  480.     include_once(override('../dashboard/graph.php'));
  481.  
  482.      $values = $sql_object->DBSelect(SQL_getAllValue($status, $current_scale, $sdi_id));
  483.     
  484. //     // renversement des valeurs pour affichage chronologique
  485. //     if(is_array($values)) $values = @array_reverse ($values, false);
  486.  
  487. //     $result_sdii = $sql_object->DBSelect(SQL_getInfoSdi($sdi_id));
  488.  
  489.     if (count($values) < 3)     return false;
  490.     
  491.     generateGraphic($sdi_id, $current_scale, $status, 'auto', false, '../tmp/report');
  492.     
  493.     // /////////////////////////////
  494.     // Affichage
  495.     
  496.     // définition du positionnement
  497.     $_y = $pdf->GetY() + 5;
  498.     $_x = 60;
  499.     
  500.     // Affichage du titre
  501.     $out_scale_item = $scale_denomination_array[$current_scale];
  502.     //$pdf->Bookmark($out_scale_item, 2, -1);
  503.     FormatSdiItem($out_scale_item);
  504.     $pdf->SetY($pdf->GetY() + DOC_INTERVAL * 2);
  505.     
  506.     // Affichage de l'image
  507.     $pdf->Image('../tmp/report/'.$sdi_id.'_'.$current_scale.'.png', $_x, $_y, GRAPH_WIDTH * 0.30, GRAPH_HEIGHT * 0.30);
  508.     
  509.     // on place le curseur en bas du graphique
  510.     $pdf->SetY($pdf->GetY() + (GRAPH_HEIGHT * 0.30));
  511.  
  512.     return true;
  513.     
  514. }
  515.  
  516. /**
  517.  * DisplayTableValues()
  518.  * Affiche un tableau de valeurs a une échelle donnée
  519.  *
  520.  * @param int $sdi_id 
  521.  * @param int $current_scale 
  522.  * @param string $status 
  523.  * @param string $mode 
  524.  * @return bool true
  525.  ***/
  526. function DisplayTableValues($sdi_id, $current_scale, $status, $mode)
  527. {
  528.     global $pdf;
  529.     global $lang;
  530.     global $sql_object;
  531.     global $scale_denomination_array;
  532.  
  533.     $values ='';
  534.  
  535.     // setting $default_threshold value
  536.     // By default initial value
  537.     $result_sdii = $sql_object -> DBSelect(SQL_getInfoSdi($sdi_id));
  538.     $default_threshold = $result_sdii[0]['sdii_threshold_value'];
  539.  
  540.     $sdi_values = $sql_object->DBSelect(SQL_getAllValue($status, $current_scale, $sdi_id));
  541.  
  542.     if (count($sdi_values) <= 1 && $sdi_values[0] == false) return false;
  543.  
  544.     // we prepare values for displaying
  545.     for($i = 0; $i < count($sdi_values); $i++) {
  546.  
  547.         $current_value = formatText($sdi_values[$i]['sdiv_value']);
  548.          
  549.         // if set, we get it from the table
  550.         if(!is_null($sdi_values[$i]['sdiv_threshold'])) {
  551.             $threshold = $sdi_values[$i]['sdiv_threshold'];
  552.         } else {
  553.             $threshold = $default_threshold;
  554.         }
  555.          
  556.         if ($sdi_values[$i]['sdiv_statut'] == 'D') $current_value .= ' *';
  557.         if (!empty($sdi_values[$i]['sdiv_comment'])) {
  558.             if($sdi_values[$i]['sdiv_comment_display']=='Y') {
  559.                 $comment_status = _t('dashboard', 'public');
  560.             } else {
  561.                 $comment_status = _t('dashboard', 'private');
  562.             }
  563.             
  564.             $comments = formatText(strip_tags($sdi_values[$i]['sdiv_comment'])) .' ('.$comment_status.')<br />';
  565.  
  566.         } else {
  567.             $comments = '';
  568.         }
  569.         
  570.         $current_date = formatText($sdi_values[$i]['date_p']);
  571.         $values .= '
  572.         <tr nobr="true">
  573.         <td class="center">'.$current_value.'</td>
  574.         <td class="center">'.$threshold.'</td>
  575.         <td class="center">'.$current_date.'</td>
  576.         <td class="comment">'.$comments.'</td>
  577.         </tr>';
  578.     }
  579.  
  580.  
  581.     $tbl = '<style>
  582.         table {}
  583.         td {
  584.             border-bottom:1px solid #000;
  585.         }
  586.     tr.header td {
  587.       font-weight:bold;
  588.       text-align:center;
  589.     }
  590.     
  591.     td.center {
  592.         text-align:center;
  593.     }
  594.     td.comment {
  595.     }
  596.     </style>
  597.     <table cellspacing="0" cellpadding="5">
  598.     <thead>
  599.     <tr class="header">
  600.     <td>'.mb_ucfirst($lang['dashboard']['name_pluriel']).'</td>
  601.     <td>'.mb_ucfirst($lang['dashboard']['threshold_value']).'</td>
  602.     <td>'.mb_ucfirst($lang['statut']['published_on']).'</td>
  603.     <td class="comment">'.mb_ucfirst($lang['sdi']['comment']).'</td>
  604.     </tr>
  605.     </thead>
  606.     '.$values.'
  607.     </table>';
  608.     
  609.     // Affichage des données
  610.     
  611.     // Affichage du titre seulement si affichage des valeurs en standalone
  612.     // ou si la génération des graphiques est infaisables car moins de 3 valeurs
  613.     if ($mode != 'TWICE' || (count($sdi_values) >= 1 && count($sdi_values) < 3)) {
  614.         $out_scale_item = $scale_denomination_array[$current_scale];
  615.         //$pdf->Bookmark($out_scale_item, 2, -1);
  616.         FormatSdiItem($out_scale_item);
  617.         $pdf->SetY($pdf->GetY() + DOC_INTERVAL * 2);
  618.     }
  619.     
  620.     $pdf->SetFont(DOC_POLICE, DOC_STYLE, ARRAY_DATA_SIZE );
  621.     // Affichage du tableau
  622.     $pdf->writeHTML($tbl, true, false, false, false, '');
  623.     // Affichage de l'astérisque - avertissement
  624.     $pdf->MultiCell(0, DOC_HEIGHT, '* ' . strtolower($lang['statut']['draftpdf']), 0, 'L', 0);
  625.     $pdf->SetFont(DOC_POLICE, DOC_STYLE, DOC_SIZE);
  626.     $pdf->Ln(DOC_INTERVAL * 2);
  627.         
  628.     return true;
  629. }
  630.  
  631. ?>

Documentation generated on Thu, 20 Mar 2014 16:49:20 +0100 by phpDocumentor 1.4.1