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'=== trueDisplayProviderInfo($sdi[$pointer]);
  31.   if ($report_settings['display_reglementation'=== trueDisplayReglementationInfo($sdi[$pointer]);
  32.   if ($report_settings['display_evaluation'=== trueDisplayEvaluationInfo($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_POLICESDI_ITEM_STYLESDI_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_POLICESDI_INFO_STYLESDI_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_POLICESDI_TITLE_STYLESDI_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_POLICESDI_TITLE_STYLESDI_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_POLICESDI_TITLE_STYLESDI_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_POLICEDOC_STYLEDOC_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(ucfirst($lang['sdi']['description'])1-1);
  122.   $pdf->MultiCell(0DOC_HEIGHT$out_desc0'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(ucfirst($lang['sdi']['goal']));
  127.   $pdf->Bookmark($out_goal_item1-1);
  128.   FormatSdiItem($out_goal_item);
  129.   $pdf->MultiCell(0DOC_HEIGHT$out_goal0'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(ucfirst($lang['sdi']['consulting']));
  134.   $pdf->Bookmark($out_consulting_item1-1);
  135.   FormatSdiItem($out_consulting_item);
  136.   $pdf->MultiCell(0DOC_HEIGHT$out_consulting0'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_item1-1);
  145.   FormatSdiItem($out_mesures_item);
  146.   // unitée de mesure
  147.   $pdf->SetFont(DOC_POLICEEM_STYLEMIN_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_POLICEDOC_STYLEDOC_SIZE);
  152.   // tableau de valeurs
  153.   DrawMesuresArray($current_record);
  154.   $pdf->SetFont(DOC_POLICEEM_STYLEMIN_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 '
  171.   <table cellspacing="0" cellpadding="5" border="1">
  172.   <thead>
  173.       <tr>
  174.           <td>'.$lang['sdi']['max_value'].'</td>
  175.           <td>'.$lang['sdi']['min_value'].'</td>
  176.           <td>'.$lang['sdi']['initial_threshold_value'].'</td>
  177.           <td>'.$lang['sdi']['frequency'].'</td>
  178.       </tr>
  179.   </thead>
  180.       <tr>
  181.           <td>'.empty_nc($current_record['sdii_max_value']).'</td>
  182.           <td>'.empty_nc($current_record['sdii_min_value']).'</td>
  183.           <td>'.empty_nc($current_record['sdii_threshold_value']).'</td>
  184.           <td>'.$current_record['sdii_frequency'].'</td>
  185.       </tr>
  186.   </table>';
  187.   
  188.   $pdf->writeHTML($tbltruefalsefalsefalse'');
  189.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  190.  
  191.   return true;
  192. }
  193.  
  194. /**
  195.  * DisplayProviderInfo()
  196.  * Affiche les informations Fournisseurs d'un IDD
  197.  *
  198.  * @param  $current_record 
  199.  * @return bool true
  200.  */
  201. function DisplayProviderInfo($current_record)
  202. {
  203.   global $pdf;
  204.   global $lang;
  205.  
  206.   $out_name formatText($current_record['sdip_name']);
  207.   if (!empty($current_record['sdip_service'])) $out_name .= ' - ' formatText($current_record['sdip_service']);
  208.   if (!empty($current_record['sdip_incharge'])) $out_name .= ' - ' formatText($current_record['sdip_incharge']' (' $lang['sdi']['p_incharge'')';
  209.   $out_name .= END_LINE;
  210.   $out_adress formatText(empty_nc(strip_tags($current_record['sdip_address'])));
  211.   $out_phone_fax $lang['sdi']['p_phone'' : ' formatText(empty_nc($current_record['sdip_phone']));
  212.   $out_phone_fax .= ' - ' $lang['sdi']['p_fax'' : ' formatText(empty_nc($current_record['sdip_fax'])) END_LINE;
  213.   $out_email_item $lang['sdi']['p_email'' : ';
  214.   $out_email formatText($current_record['sdip_email']);
  215.   $out_desc formatText(empty_nc(strip_tags($current_record['sdip_description']))) END_LINE;
  216.   $out_provider_item formatText(ucfirst($lang['sdi']['p_title'])) ;
  217.  
  218.   $pdf->Bookmark($out_provider_item1-1);
  219.   FormatSdiInfo($out_provider_item);
  220.  
  221.   $firstcell_width 60;
  222.  
  223.   $pdf->SetX($pdf->GetX($firstcell_width);
  224.   $pdf->MultiCell(0DOC_HEIGHT$out_name0'L');
  225.  
  226.   $pdf->SetX($pdf->GetX($firstcell_width);
  227.   $pdf->MultiCell(0DOC_HEIGHT$out_adress0'L');
  228.  
  229.   $pdf->SetX($pdf->GetX($firstcell_width);
  230.   $pdf->MultiCell(0DOC_HEIGHT$out_phone_fax0'L');
  231.  
  232.   $pdf->SetX($pdf->GetX($firstcell_width);
  233.   $pdf->Cell($pdf->GetStringWidth($out_email_item)DOC_HEIGHT$out_email_item);
  234.   if (empty($out_email)) $pdf->Cell(0DOC_HEIGHTempty_nc($out_email));
  235.   else $pdf->Cell(0DOC_HEIGHT$out_email00'L'0'mailto:' $out_email);
  236.   $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  237.  
  238.   return true;
  239. }
  240.  
  241. /**
  242.  * DisplayReglementationInfo()
  243.  * Affiche la réglementation d'un IDD
  244.  *
  245.  * @param  $current_record 
  246.  * @return bool true
  247.  */
  248. function DisplayReglementationInfo($current_record)
  249. {
  250.   global $pdf;
  251.   global $lang;
  252.  
  253.   $out_name formatText(empty_nc($current_record['sdir_title'])) END_LINE;
  254.   $out_body formatText(empty_nc(strip_tags($current_record['sdir_body']))) END_LINE;
  255.   $out_uri formatText($current_record['sdir_mask_uri']);
  256.   $out_uri_href $current_record['sdir_referer_uri'];
  257.  
  258.   $out_name_item $lang['sdi']['r_title'' : ';
  259.   $out_body_item $lang['sdi']['r_body'' : ';
  260.   $out_uri_item $lang['sdi']['r_referer_uri'' : ';
  261.  
  262.   $out_reglementation_item formatText(ucfirst($lang['sdi']['add_step4'])) ;
  263.  
  264.   $pdf->Bookmark($out_reglementation_item1-1);
  265.   FormatSdiInfo($out_reglementation_item);
  266.  
  267.   $firstcell_width 60;
  268.   // nom de l'organisme fournisseur
  269.   $pdf->SetFont(DOC_POLICEEM_STYLEDOC_SIZE);
  270.   $pdf->Cell($firstcell_widthDOC_HEIGHT$out_name_item00'R');
  271.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  272.   $pdf->MultiCell(0DOC_HEIGHT$out_name0'L');
  273.   $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  274.   // détail reglementation
  275.   $pdf->SetFont(DOC_POLICEEM_STYLEDOC_SIZE);
  276.   $pdf->Cell($firstcell_widthDOC_HEIGHT$out_body_item00'R');
  277.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  278.   $pdf->MultiCell(0DOC_HEIGHT$out_body0'L');
  279.   $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  280.   // lien internet reglementation
  281.   $pdf->SetFont(DOC_POLICEEM_STYLEDOC_SIZE);
  282.   $pdf->Cell($firstcell_widthDOC_HEIGHT$out_uri_item00'R');
  283.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  284.   if (!empty($out_uri_href)) {
  285.     if (!empty($out_uri)) $pdf->Cell(0DOC_HEIGHT$out_uri00''0$out_uri_href);
  286.     //if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, ' (', 0, 0);
  287.     //$pdf->Cell(0, DOC_HEIGHT, $out_uri, 0, 0, '', 0, $out_uri_href);
  288.     //if (!empty($out_uri)) $pdf->Cell(0, DOC_HEIGHT, ')', 0, 0);
  289.   else $pdf->Write(DOC_HEIGHTempty_nc($out_uri));
  290.   $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  291.  
  292.   return true;
  293. }
  294.  
  295. /**
  296.  * DisplayEvaluationInfo()
  297.  * Affiche le tableau de critères d'évaluation
  298.  *
  299.  * @param int $current_record 
  300.  * @return bool true
  301.  */
  302. function DisplayEvaluationInfo($current_record)
  303. {
  304.   global $pdf;
  305.   global $lang;
  306.  
  307.   $out_eval_item formatText(ucfirst($lang['sdi']['e_title'])) ;
  308.  
  309.   $pdf->Bookmark($out_eval_item1-1);
  310.   FormatSdiInfo($out_eval_item);
  311.   
  312.   
  313.   $tbl '
  314.       <table cellspacing="0" cellpadding="5" border="1">
  315.       <thead>
  316.           <tr>
  317.               <td>'.$lang['sdi']['e_scale_compare'].'</td>
  318.               <td>'.$lang['sdi']['e_fiability'].'</td>
  319.               <td>'.$lang['sdi']['e_accessibility'].'</td>
  320.               <td>'.$lang['sdi']['e_lisibility'].'</td>
  321.               <td>'.$lang['sdi']['e_relevance'].'</td>
  322.               <td>'.$lang['sdi']['e_global_performance'].'</td>
  323.           </tr>
  324.       </thead>
  325.         <tr>
  326.             <td>'.$current_record['sdie_scale_compare'].'</td>
  327.             <td>'.$current_record['sdie_fiability'].'</td>
  328.             <td>'.$current_record['sdie_accessibility'].'</td>
  329.             <td>'.$current_record['sdie_lisibility'].'</td>
  330.             <td>'.$current_record['sdie_relevance'].'</td>
  331.             <td>'.$current_record['sdie_global_performance'].'</td>
  332.           </tr>
  333.       </table>';
  334.   
  335.   $pdf->writeHTML($tbltruefalsefalsefalse'');
  336.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  337.  
  338.   return true;
  339. }
  340.  
  341. /**
  342.  * DisplayValues()
  343.  * Affiche les valeurs d'un IDD.
  344.  *
  345.  * @param int $sdi_id 
  346.  * @return bool true
  347.  ***/
  348. function DisplayValues($sdi_id)
  349. {
  350.   global $pdf;
  351.   global $lang;
  352.   global $report_settings;
  353.   global $scale_array;
  354.   global $sql_object;
  355.  
  356.   if ($report_settings['graphic_values'=== true && $report_settings['table_values'=== true$mode 'TWICE';
  357.   elseif ($report_settings['graphic_values'=== true || $report_settings['table_values'=== true$mode 'ONE';
  358.   else return false;
  359.  
  360.   $out_values_item ucfirst($lang['dashboard']['value']);
  361.   $pdf->Bookmark($out_values_item1-1);
  362.   FormatSdiInfo($out_values_item);
  363.  
  364.   $scale_no_values array()// recipient no values
  365.   $scale_insuffisant_values array()// recipient insuffisant values graph
  366.   for($i 0$i count($scale_array)$i++{
  367.     if ($report_settings['graphic_values'=== true{
  368.       if (DisplayGraphicValues($sdi_id$scale_array[$i]GetStatus($report_settings['status'])$mode=== falsearray_push($scale_insuffisant_values$scale_array[$i]);
  369.     }
  370.  
  371.     if ($report_settings['table_values'=== true{
  372.       if (DisplayTableValues($sdi_id$scale_array[$i]GetStatus($report_settings['status'])$mode=== falsearray_push($scale_no_values$scale_array[$i]);
  373.     }
  374.   }
  375.   DisplayNoValuesFor($scale_no_values$lang['dashboard']['rap_no_values_for']);
  376.   DisplayNoValuesFor($scale_insuffisant_values$lang['dashboard']['rap_insuffisant_values']$mode$scale_no_values);
  377.  
  378.   return true;
  379. }
  380.  
  381. /**
  382.  * GetStatus()
  383.  * Formattage du statut pour requête SQL
  384.  *
  385.  * @param string $current_status 
  386.  * @return string $status
  387.  ***/
  388. function GetStatus($current_status)
  389. {
  390.   switch ($current_status{
  391.     case 'ALL':
  392.       $status 'SCA';
  393.       break;
  394.     case 'PUBLIC':
  395.       $status 'SCP';
  396.       break;
  397.   }
  398.   return $status;
  399. }
  400.  
  401. /**
  402.  * DisplayNoValuesFor()
  403.  * Affiche les échelles ne contenant pas de valeurs ou insuffisamment
  404.  *
  405.  * @param array $array_scale 
  406.  * @param string $message 
  407.  * @param integer $mode 
  408.  * @param integer $array 
  409.  * @return bool true
  410.  ***/
  411. function DisplayNoValuesFor($array_scale$message$mode = -1$array = -1)
  412. {
  413.   global $pdf;
  414.   global $lang;
  415.   global $scale_denomination_array;
  416.   $content '';
  417.   $sep '';
  418.   // si mode TWICE et deuxième tableau fourni. On le soustrait au premier.
  419.   if ($array != -&& $mode == 'TWICE'$array_scale array_values(array_diff($array_scale$array));
  420.  
  421.   if (count($array_scale== 0return true;
  422.  
  423.   for($i 0$i count($array_scale)$i++{
  424.     $content .= $sep $scale_denomination_array[$array_scale[$i]];
  425.     $sep ', ';
  426.   }
  427.   if (empty($content)) return true;
  428.   $margin 0;
  429.   $pdf->SetX($pdf->GetX($margin);
  430.   $pdf->SetFont(DOC_POLICEEM_STYLEDOC_SIZE);
  431.   $pdf->Cell(0DOC_HEIGHT$message01'L');
  432.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  433.   $margin 10;
  434.   $pdf->SetTextColorArray(getColor('DOC_ADVISE_COLOR'));
  435.   $pdf->SetX($pdf->GetX($margin);
  436.   $pdf->MultiCell(0DOC_HEIGHT$content0'L');
  437.   $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  438.   $pdf->SetTextColorArray(getColor('DOC_COLOR'));
  439.  
  440.   return true;
  441. }
  442.  
  443. /**
  444.  * DisplayGraphicValues()
  445.  * Gènère et affiche les valeurs sous forme graphique
  446.  *
  447.  * @param int $sdi_id 
  448.  * @param int $current_scale 
  449.  * @param string $status 
  450.  * @param string $mode 
  451.  * @return bool true
  452.  ***/
  453. function DisplayGraphicValues($sdi_id$current_scale$status$mode)
  454. {
  455.   global $pdf;
  456.   global $sql_object;
  457.   global $scale_denomination_array;
  458.  
  459.   $values $sql_object->DBSelect(SQL_getAllValue($status$current_scale$sdi_id));
  460.   // renversement des valeurs pour affichage chronologique
  461.   if(is_array($values)) $values @array_reverse ($valuesfalse);
  462.  
  463.   $result_sdii $sql_object->DBSelect(SQL_getInfoSdi($sdi_id));
  464.  
  465.   if (count($values3return false;
  466.   // on checke si le graph tient sur la page sinon Saut de page
  467.   // $pdf->CheckPageBreak((GRAPH_HEIGHT * 0.36) + DOC_INTERVAL);
  468.   // Affichage du titre seulement si $values>= 3
  469.   $out_scale_item $scale_denomination_array[$current_scale];
  470.   //$pdf->Bookmark($out_scale_item, 2, -1);
  471.   FormatSdiItem($out_scale_item);
  472.   $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  473.  
  474.   // stockage de l'ordonnée initiale
  475.   $_y $pdf->GetY();
  476.  
  477.   // positionnement en fonction du mode.
  478.  
  479.   if ($mode == 'TWICE'$_x 104;
  480.   else $_x 50;
  481.  
  482.   /* pChart library inclusions */
  483.     include_once("../class/system/pChart/class/pData.class.php");
  484.     include_once("../class/system/pChart/class/pDraw.class.php");
  485.     include_once("../class/system/pChart/class/pImage.class.php");
  486.  
  487.   $unit $result_sdii[0]['sdii_unit'];
  488.   $full_title=formatText($result_sdii[0]['sdii_name']);
  489.   $title=cutText($full_title500);
  490.  
  491.   $is_null_threshold true// is the threshold null or not? to know if we display it
  492.   for ($i 0$i count($values)$i++{
  493.     $ydata[$i$values[$i]['sdiv_value'];
  494.     
  495.     // setting $threshold_value
  496.     // By default initial value
  497.     $ydata2[$i]=$result_sdii[0]['sdii_threshold_value'];
  498.     // if set, we get it from the table
  499.     if(!is_null($values[$i]['sdiv_threshold'])) {
  500.         $ydata2[$i]=$values[$i]['sdiv_threshold'];
  501.     }
  502.     // if at least one numeric value is there test is false
  503.     if(is_numeric($ydata2[$i])) $is_null_threshold false;
  504.     
  505.     list($day$month$year)=explode('-'$values[$i]['date_p']);
  506.     $months[$i$day '-' .$month'-'substr($year22);
  507.   }
  508.   
  509.   /* Create and populate the pData object */
  510.   $MyData new pData();
  511.   //  $MyData->loadPalette("../class/system/pChart/palettes/blind.color",TRUE);
  512.   $MyData->setAxisName(0,$unit);
  513.   $MyData->addPoints($ydata,$full_title);
  514.   $MyData->addPoints($ydata2,"thresholds");
  515.   $MyData->addPoints($months,"Dates");
  516.   $MyData->setSerieDescription($full_title,$unit);
  517.   $MyData->setAbscissa("Dates");
  518.   
  519.   $thresholdsSettings array("R"=>254,"G"=>148,"B"=>64);
  520.   $MyData->setPalette("thresholds",$thresholdsSettings);
  521.   $valuesSettings array("R"=>207,"G"=>228,"B"=>252);
  522.   $MyData->setPalette("$full_title",$valuesSettings);
  523.   
  524.   /* Create the pChart object */
  525.   $myPicture new pImage(GRAPH_WIDTH,GRAPH_HEIGHT,$MyData);
  526.  
  527.   /* Turn of Antialiasing */
  528.     $myPicture->Antialias TRUE;
  529.     
  530.     /* Add a border to the picture */
  531.     // $myPicture->drawRectangle(0,0,499,349,array("R"=>180,"G"=>180,"B"=>180));
  532.     
  533.     /* Set the default font */
  534.     $myPicture->setFontProperties(array("FontName"=>"../class/system/pChart/fonts/verdana.ttf","FontSize"=>7,"R"=>80,"G"=>80,"B"=>80));
  535.     
  536.     /* Define the chart area */
  537.     $myPicture->setGraphArea(50,20,GRAPH_WIDTH-20,GRAPH_HEIGHT-50);
  538.     
  539.     
  540.     /* Draw the scale */
  541.     $scaleSettings array(
  542.             // grid settings
  543.             "GridR"=>160,"GridG"=>160,"GridB"=>160,"GridTicks"=>1"DrawSubTicks"=>TRUE,
  544.             // axis settings
  545.             "AxisR"=>80,"AxisG"=>80,"AxisB"=>80,
  546.             "CycleBackground"=>TRUE'LabelRotation'=>50,
  547.             "DrawArrows"=>FALSE);
  548.     
  549.     $myPicture->drawScale($scaleSettings);
  550.     
  551.     
  552.     /* Write the chart legend */
  553.     //$myPicture->drawLegend(50,5,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
  554.     
  555.     
  556.     /* Draw the chart */
  557.     $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10))/* Turn on shadow computing */
  558.     $settings array(
  559.             "InnerBorderR"=>80"InnerBorderG"=>80"InnerBorderB"=>80,
  560.             "BorderR"=>80"BorderG"=>80"BorderB"=>80,
  561.             // color and gradient settings
  562.             "DisplayColor"=>DISPLAY_MANUAL,
  563.             "Gradient"=>TRUE,"GradientStartR"=>207,"GradientStartG"=>228,"GradientStartB"=>252,
  564.             "GradientEndR"=>146"GradientEndG"=>174"GradientEndB"=>206,"GradientAlpha"=>100,
  565.             // label settings
  566.             "DisplayValues"=>FALSE"DisplayPos"=>LABEL_POS_OUTSIDE,"DisplayR"=>115,"DisplayG"=>115,"DisplayB"=>115,"DisplayOrientation"=>ORIENTATION_AUTO,
  567.             "DisplayShadow"=>FALSE,
  568.             "Draw0Line"=>FALSE,
  569.             //"Rounded"=>TRUE, // not working with gradient
  570.             "Surrounding"=>-30,
  571.             "InnerSurrounding"=>0);
  572.     
  573.     $MyData->setSerieDrawable($full_title,TRUE);
  574.     $MyData->setSerieDrawable("thresholds",FALSE);
  575.     $myPicture->drawBarChart($settings);
  576.     
  577.     /* Draw the line and plot chart */
  578.     $myPicture->setShadow(FALSE)/* Turn off shadow computing */
  579.     // if at least one threshold is there we display the serie on graph
  580.     if(!$is_null_threshold{
  581.         $MyData->setSerieDrawable("thresholds",TRUE);
  582.     }
  583.     $MyData->setSerieDrawable($full_title,FALSE);
  584.     $myPicture->drawSplineChart();
  585.     $myPicture->drawPlotChart();
  586.     
  587.     /* Render the picture */
  588.     if(!file_exists('../tmp/report')) mkdir('../tmp/report');
  589.  
  590.     $myPicture->render('../tmp/report/'.$sdi_id.'_'.$current_scale.'.png');
  591.     
  592.     /**
  593.  
  594.   $group = new PlotGroup;
  595.   $group->setSpace(5, 5, 5, 0);
  596.   $group->setBackgroundColor(
  597.   new Color(244, 244, 244)
  598.   );
  599.   $group->grid->hideVertical();
  600.   $group->grid->SetColor(new Color(0, 0, 0, 80));
  601.   $group->grid->setType(LINE_DOTTED );
  602.   $group->setPadding(40, 15, 20, 50);
  603.  
  604.   $bplot = new BarPlot($ydata);
  605.   //$bplot->setSpace(4, 4, 4, 0);
  606.   //$bplot->setPadding(15, 15, 5, 50);
  607.   $bplot->SetBarGradient(
  608.   new LinearGradient(
  609.   new Color(207, 228, 252, 0),
  610.   new Color(146, 174, 206, 0),
  611.   90
  612.   )
  613.   );
  614.  
  615.   $group->axis->left->title->set($unit);
  616.   $group->axis->left->title->setFont(new Tuffy(10));
  617.   $group->axis->left->title->move(-4, 0);
  618.   $group->axis->left->setTitleAlignment(LABEL_TOP);
  619.  
  620.   $bplot->label->border->SetColor(new Color(20, 20, 20, 20));
  621.   $bplot->label->setPadding(3, 1, 1, 0);
  622.   $bplot->barBorder->SetColor(new Color(161, 182, 206, 0));
  623.  
  624.   $group->axis->bottom->setLabelText($months);
  625.   $group->axis->bottom->label->setAngle(55);
  626.   $group->axis->bottom->label->setFont(new Tuffy(7));
  627.  
  628.   $group->add($bplot);
  629.  
  630.  
  631.   $plot = new LinePlot($ydata2, LINEPLOT_MIDDLE);
  632.   $plot->setFillColor(new Color(254, 148, 64, 50));
  633.   $plot->SetColor(new Color(254, 148, 64, 0));
  634.   $plot->mark->setType(MARK_SQUARE);
  635.   $plot->mark->setSize(5);
  636.   $plot->mark->setFill(new Color(246, 149, 55, 20));
  637.   $plot->mark->border->show();
  638.   $plot->mark->border->SetColor(new Color(254, 148, 64, 0));
  639.  
  640.   $group->add($plot);
  641.   $graph->add($group);
  642.   if(!file_exists('tmp')) mkdir('tmp');
  643.   $graph->draw('tmp/'.$sdi_id.'_'.$current_scale.'.png');
  644.   */
  645.     
  646.   // /////////////////////////////
  647.   // Affichage
  648.   $pdf->Image('../tmp/report/'.$sdi_id.'_'.$current_scale.'.png'$_x$_y00);
  649.   // conversion px -> mm + replacement en ordonnée
  650.   if ($mode == 'TWICE'$pdf->SetY($_y);
  651.   else $pdf->SetY($_y (GRAPH_HEIGHT 0.36))//$pdf->SetY($_y + (GRAPH_HEIGHT * 0.36) + DOC_INTERVAL);
  652.   return true;
  653. }
  654.  
  655. /**
  656.  * DisplayTableValues()
  657.  * Affiche un tableau de valeurs a une échelle donnée
  658.  *
  659.  * @param int $sdi_id 
  660.  * @param int $current_scale 
  661.  * @param string $status 
  662.  * @param string $mode 
  663.  * @return bool true
  664.  ***/
  665. function DisplayTableValues($sdi_id$current_scale$status$mode)
  666. {
  667.   global $pdf;
  668.   global $lang;
  669.   global $sql_object;
  670.   global $scale_denomination_array;
  671.   
  672.   $values ='';
  673.   $comments='';
  674.   $j 1;
  675.  
  676.   $_y $pdf->GetY();
  677.   
  678.   
  679.   // setting $default_threshold value
  680.   // By default initial value
  681.   $result_sdii $sql_object -> DBSelect(SQL_getInfoSdi($sdi_id));
  682.   $default_threshold $result_sdii[0]['sdii_threshold_value'];
  683.   
  684.   $sdi_values $sql_object->DBSelect(SQL_getAllValue($status$current_scale$sdi_id));
  685.   
  686.   if (count($sdi_values<= && $sdi_values[0== falsereturn false;
  687.   
  688.   // we prepare values for displaying
  689.   for($i 0$i count($sdi_values)$i++{
  690.     
  691.       $current_value formatText($sdi_values[$i]['sdiv_value']);
  692.       
  693.       // if set, we get it from the table
  694.       if(!is_null($sdi_values[$i]['sdiv_threshold'])) {
  695.           $threshold $sdi_values[$i]['sdiv_threshold'];
  696.       else {
  697.           $threshold $default_threshold;
  698.       }
  699.       
  700.       if ($sdi_values[$i]['sdiv_statut'== 'D'$current_value .= ' *';
  701.       if (!empty($sdi_values[$i]['sdiv_comment'])) {
  702.         if($sdi_values[$i]['sdiv_comment_display']=='Y'{
  703.           $comment_status _t('dashboard''public');
  704.         else {
  705.           $comment_status _t('dashboard''private');
  706.         }
  707.         $bullet ' <sup>['.$j.']</sup>';
  708.         $current_value .= $bullet;
  709.         $comments .= $bullet' '.formatText(strip_tags($sdi_values[$i]['sdiv_comment'])) .' ('.$comment_status.')<br />';
  710.         $j++;
  711.       }
  712.       $current_date formatText($sdi_values[$i]['date_p']);
  713.       $values .= '
  714.             <tr>
  715.                 <td>'.$current_value.'</td>
  716.                 <td>'.$threshold.'</td>
  717.                 <td>'.$current_date.'</td>
  718.             </tr>';
  719.   }
  720.  
  721.   
  722.  
  723.   if ($mode != 'TWICE' || (count($sdi_values>= && count($sdi_values3)) {
  724.     // Affichage du titre seulement si affichage des valeurs en standalone
  725.     $out_scale_item $scale_denomination_array[$current_scale];
  726.     //$pdf->Bookmark($out_scale_item, 2, -1);
  727.     FormatSdiItem($out_scale_item);
  728.     $pdf->SetY($pdf->GetY(DOC_INTERVAL);
  729.   }
  730.  
  731.   $pdf->Ln(DOC_INTERVAL);
  732.   if ($mode == 'TWICE'$_margin 20;
  733.   else $_margin 60;
  734.  
  735.   $pdf->SetX($_margin);
  736.  
  737.   
  738.   $tbl '
  739.     <table cellspacing="0" cellpadding="5" border="1" style="width:40%">
  740.     <thead>
  741.         <tr>
  742.             <td>'.$lang['dashboard']['name_pluriel'].'</td>
  743.             <td>'.$lang['dashboard']['threshold_value'].'</td>
  744.             <td>'.$lang['statut']['published_on'].'</td>
  745.         </tr>
  746.     </thead>
  747.     '.$values.'
  748.     </table>';
  749.   
  750.   $pdf->writeHTML($tbltruefalsefalsefalse'');
  751.   
  752.   $pdf->SetX($_margin);
  753.   $pdf->SetFont(DOC_POLICEEM_STYLEMIN_SIZE);
  754.   $pdf->MultiCell(0DOC_HEIGHT'* ' strtolower($lang['statut']['draftpdf'])0'L'0);
  755.   $pdf->SetX($_margin);
  756.   if(!empty($comments))  $pdf->writeHTMLCell(0DOC_HEIGHT$pdf->GetX()$pdf->GetY()$comments01);
  757.   $pdf->SetFont(DOC_POLICEDOC_STYLEDOC_SIZE);
  758.   $pdf->Ln(DOC_INTERVAL 2);
  759.   // conversion px -> mm + replacement en ordonnées
  760.   if ($mode == 'TWICE' && count($sdi_values>= && $pdf->GetY(($_y (GRAPH_HEIGHT 0.36))) $pdf->SetY($_y (GRAPH_HEIGHT 0.36DOC_INTERVAL);
  761.  
  762.   return true;
  763. }
  764.  
  765. ?>

Documentation generated on Mon, 08 Apr 2013 18:16:06 +0200 by phpDocumentor 1.4.1