noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
impress_rapport.inc.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /*! \file
00020  * \brief print first the report in html and propose to print it in pdf
00021  *        file included by user_impress
00022  *
00023  * some variable are already defined ($cn, $g_user ...)
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 require_once("class_ihidden.php");
00027 require_once("class_iselect.php");
00028 require_once("class_idate.php");
00029 require_once("class_acc_report.php");
00030 require_once('class_exercice.php');
00031 global $g_user;
00032 //-----------------------------------------------------
00033 // If print is asked
00034 // First time in html
00035 // after in pdf or cvs
00036 //-----------------------------------------------------
00037 if ( isset( $_GET['bt_html'] ) )
00038 {
00039     $Form=new Acc_Report($cn,$_GET['form_id']);
00040     $Form->get_name();
00041     // step asked ?
00042     //--
00043     $type_periode=HtmlInput::default_value_get("type_periode", -1);
00044     if ( $type_periode == 1 )
00045         $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $type_periode);
00046 
00047     if ($type_periode == 0   && $_GET['p_step'] == 0)
00048         $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $type_periode);
00049 
00050 
00051     if ($type_periode  == 0  && $_GET['p_step'] == 1 )
00052     {
00053         // step are asked
00054         //--
00055         for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step'])
00056         {
00057 
00058             $periode=getPeriodeName($cn,$e);
00059             if ( $periode == null ) continue;
00060             $array[]=$Form->get_row($e,$e,$_GET['type_periode']);
00061             $periode_name[]=$periode;
00062         }
00063     }
00064 
00065 
00066 
00067     $rep="";
00068 
00069     $hid=new IHidden();
00070     echo '<div class="content">';
00071     if ( $_GET['type_periode'] == 0)
00072     {
00073         $t=($_GET['from_periode']==$_GET['to_periode'])?"":" -> ".getPeriodeName($cn,$_GET['to_periode'],'p_end');
00074         echo '<h2 class="info">'.$Form->id." ".$Form->name.
00075         " - ".getPeriodeName($cn,$_GET['from_periode'],'p_start').
00076         " ".$t.
00077         '</h2>';
00078     }
00079     else
00080     {
00081         echo '<h2 class="info">'.$Form->id." ".$Form->name.
00082         ' Date :'.
00083         $_GET['from_date'].
00084         " au ".
00085         $_GET['to_date'].
00086         '</h2>';
00087     }
00088     echo '<table >';
00089     echo '<TR>';
00090     echo '<TD><form method="GET" ACTION="?">'.
00091     dossier::hidden().
00092     HtmlInput::submit('bt_other',"Autre Rapport").
00093     $hid->input("type","rapport").$hid->input("ac",$_GET['ac'])."</form></TD>";
00094 
00095     echo '<TD><form method="GET" ACTION="export.php">'.
00096     HtmlInput::submit('bt_pdf',"Export PDF").
00097       HtmlInput::hidden('act','PDF:report').
00098     dossier::hidden().
00099     $hid->input("type","rapport").
00100     $hid->input("ac",$_GET['ac']).
00101     $hid->input("form_id",$Form->id);
00102     if ( isset($_GET['from_periode'])) echo $hid->input("from_periode",$_GET['from_periode']);
00103     if ( isset($_GET['to_periode'])) echo $hid->input("to_periode",$_GET['to_periode']);
00104     if (isset($_GET['p_step'])) echo $hid->input("p_step",$_GET['p_step']);
00105     if ( isset($_GET['from_date'])) echo $hid->input("from_date",$_GET['from_date']);
00106     if ( isset($_GET['to_date'])) echo $hid->input("to_date",$_GET['to_date']);
00107     echo $hid->input("type_periode",$_GET['type_periode']);
00108 
00109 
00110 
00111 
00112     echo "</form></TD>";
00113     echo '<TD><form method="GET" ACTION="export.php">'.
00114       HtmlInput::hidden('act','CSV:report').
00115     HtmlInput::submit('bt_csv',"Export CSV").
00116     dossier::hidden().
00117     $hid->input("type","form").
00118     $hid->input("ac",$_GET['ac']).
00119     $hid->input("form_id",$Form->id);
00120     if ( isset($_GET['from_periode'])) echo $hid->input("from_periode",$_GET['from_periode']);
00121     if ( isset($_GET['to_periode'])) echo $hid->input("to_periode",$_GET['to_periode']);
00122     if (isset($_GET['p_step'])) echo $hid->input("p_step",$_GET['p_step']);
00123     if ( isset($_GET['from_date'])) echo $hid->input("from_date",$_GET['from_date']);
00124     if ( isset($_GET['to_date'])) echo $hid->input("to_date",$_GET['to_date']);
00125     echo        $hid->input("type_periode",$_GET['type_periode']);
00126 
00127 
00128     echo "</form></TD>";
00129 
00130     echo "</TR>";
00131 
00132     echo "</table>";
00133     if ( count($Form->row ) == 0 )
00134         exit;
00135     if ( $_GET['type_periode']== 0 )
00136     {
00137         if ( $_GET['p_step'] == 0)
00138         { // check the step
00139             // show tables
00140             ShowReportResult($Form->row);
00141         }
00142         else
00143         {
00144             $a=0;
00145             foreach ( $array as $e)
00146             {
00147                 echo '<h2 class="info">Periode : '.$periode_name[$a]."</h2>";
00148                 $a++;
00149                 ShowReportResult($e);
00150             }
00151         }
00152     }
00153     else
00154     {
00155         ShowReportResult($Form->row);
00156     }
00157     echo "</div>";
00158     exit;
00159 }
00160 
00161 //-----------------------------------------------------
00162 // Show the jrn and date
00163 //-----------------------------------------------------
00164 require_once('class_database.php');
00165 $ret=$cn->make_array("select fr_id,fr_label
00166                      from formdef
00167                      order by fr_label");
00168 if ( sizeof($ret) == 0 )
00169 {
00170     echo "Aucun Rapport";
00171     return;
00172 }
00173 //-----------------------------------------------------
00174 // Form
00175 //-----------------------------------------------------
00176 echo '<div class="content">';
00177 $exercice=(isset($_GET['exercice']))?$_GET['exercice']:$g_user->get_exercice();
00178 
00179 /*
00180  * Let you change the exercice
00181  */
00182 echo '<fieldset><legend>'._('Choississez un autre exercice').'</legend>';;
00183 echo '<form method="GET">';
00184 echo 'Choississez un autre exercice :';
00185 $ex=new Exercice($cn);
00186 $wex=$ex->select('exercice',$exercice,' onchange="submit(this)"');
00187 echo $wex->input();
00188 echo dossier::hidden();
00189 echo HtmlInput::get_to_hidden(array('ac','type'));
00190 echo '</form>';
00191 echo '</fieldset>';
00192 
00193 
00194 echo '<FORM METHOD="GET">';
00195 $hidden=new IHidden();
00196 echo $hidden->input("ac",$_GET['ac']);
00197 echo $hidden->input("type","rapport");
00198 echo    dossier::hidden();
00199 
00200 echo '<TABLE><TR>';
00201 $w=new ISelect();
00202 $w->table=1;
00203 print td("Choississez le rapport");
00204 print $w->input("form_id",$ret);
00205 print '</TR>';
00206 //-- calendrier ou periode comptable
00207 $aCal=array(
00208           array('value'=>0,'label'=>'P&eacute;riode comptable'),
00209           array('value'=>1,'label'=>'Calendrier')
00210       );
00211 
00212 $w->javascript=' onchange=enable_type_periode();';
00213 $w->id='type_periode';
00214 echo '<tr>';
00215 print td('Type de date : ');
00216 echo $w->input('type_periode',$aCal);
00217 echo '</Tr>';
00218 $w->javascript='';
00219 print '<TR>';
00220 // filter on the current year
00221 $filter_year=" where p_exercice='".sql_string($exercice)."'";
00222 $periode_start_select=new ISelect();
00223 $periode_start_select->table=1;
00224 $periode_end_select=new ISelect();
00225 $periode_end_select->table=1;
00226 $periode_start=$cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
00227 print td("P&eacute;riode comptable : Depuis");
00228 echo $periode_start_select->input('from_periode',$periode_start);
00229 print td(" jusqu'à ");
00230 $periode_end=$cn->make_array("select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode  $filter_year order by p_start,p_end");
00231 print $periode_end_select->input('to_periode',$periode_end);
00232 print "</TR>";
00233 echo '<tr>';
00234 //--- by date
00235 $date_from=new IDate('from_date');
00236 $date_from->id='from_date';
00237 $date_to=new IDate('to_date');
00238 $date_to->id='to_date';
00239 
00240 echo td("Calendrier depuis :");
00241 echo td($date_from->input('from_date'));
00242 echo td("jusque");
00243 echo td($date_to->input('to_date'));
00244 echo '</tr>';
00245 
00246 $aStep=array(
00247            array('value'=>0,'label'=>'Pas d\'étape'),
00248            array('value'=>1,'label'=>'1 mois')
00249        );
00250 echo '<tr>';
00251 echo td('Par étape de');
00252 $w->id='p_step';
00253 echo $w->input('p_step',$aStep);
00254 echo '</TR>';
00255 
00256 echo '</TABLE>';
00257 echo '<span class="notice"> Attention : vous ne pouvez pas utiliser les &eacute;tapes avec les dates calendriers.</span>';
00258 echo '<br>';
00259 echo '<span class="notice"> Les clauses FROM sont ignorés avec les dates calendriers</span>';
00260 echo '<br>';
00261 print HtmlInput::submit('bt_html','Visualisation');
00262 
00263 echo '</FORM>';
00264 echo '<script>enable_type_periode()</script>';
00265 echo '</div>';
00266 //-----------------------------------------------------
00267 // Function
00268 //-----------------------------------------------------
00269 function ShowReportResult($p_array)
00270 {
00271 
00272     echo '<TABLE class="result">';
00273     echo "<TR>".
00274     "<TH> Description </TH>".
00275     "<TH> montant </TH>".
00276     "</TR>";
00277     $i=0;
00278     foreach ( $p_array as $op )
00279     {
00280         $i++;
00281         $class= ( $i % 2 == 0 )?' class="odd"':' class="even"';
00282 
00283         echo "<TR $class>".
00284         "<TD>".h($op['desc'])."</TD>".
00285         "<TD align=\"right\">".nbm($op['montant'])."</TD>".
00286         "</TR>";
00287     }
00288     echo "</table>";
00289 
00290 }
00291 
00292 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations