00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 include_once("class_widget.php");
00026
00027
00028
00029
00030
00031 if ( isset( $_POST['bt_html'] ) ) {
00032 include("class_jrn.php");
00033 $p_cent=( isset ( $_POST['cent']) )?'on':'off';
00034
00035 $d=var_export($_POST,true);
00036 echo_debug('impress_jrn.php',__LINE__,$d);
00037 $Jrn=new jrn($cn,$_POST['jrn_id']);
00038 $Jrn->GetName();
00039 if ( $_POST['p_simple']==0 )
00040 {
00041 $Jrn->GetRow( $_POST['from_periode'],
00042 $_POST['to_periode'],
00043 $p_cent);
00044 }
00045 else
00046 {
00047 $Row=$Jrn->GetRowSimple($_POST['from_periode'],
00048 $_POST['to_periode'],
00049 $p_cent);
00050
00051 }
00052 $rep="";
00053 $submit=new widget();
00054 $hid=new widget("hidden");
00055 echo '<div class="u_content">';
00056 echo '<h2 class="info">'.$Jrn->name.'</h2>';
00057 echo "<table>";
00058 echo '<TR>';
00059 echo '<TD><form method="GET" ACTION="user_impress.php">'.
00060 $submit->Submit('bt_other',"Autre journal").
00061 $hid->IOValue("type","jrn")."</form></TD>";
00062
00063 echo '<TD><form method="GET" ACTION="jrn_pdf.php">'.
00064 $submit->Submit('bt_pdf',"Export PDF").
00065 $hid->IOValue("type","jrn").
00066 $hid->IOValue("central",$p_cent).
00067 $hid->IOValue("jrn_id",$Jrn->id).
00068 $hid->IOValue("from_periode",$_POST['from_periode']).
00069 $hid->IOValue("to_periode",$_POST['to_periode']);
00070 echo $hid->IOValue("p_simple",$_POST['p_simple']);
00071
00072 echo "</form></TD>";
00073 echo '<TD><form method="GET" ACTION="jrn_csv.php">'.
00074 $submit->Submit('bt_csv',"Export CSV").
00075 $hid->IOValue("type","jrn").
00076 $hid->IOValue("central",$p_cent).
00077 $hid->IOValue("jrn_id",$Jrn->id).
00078 $hid->IOValue("from_periode",$_POST['from_periode']).
00079 $hid->IOValue("to_periode",$_POST['to_periode']);
00080 echo $hid->IOValue("p_simple",$_POST['p_simple']);
00081 echo "</form></TD>";
00082
00083 echo "</TR>";
00084
00085 echo "</table>";
00086 if ( count($Jrn->row ) == 0
00087 && $Row==null)
00088 exit;
00089
00090 echo '<TABLE class="result">';
00091
00092 if ( $_POST['p_simple'] == 0 ) {
00093
00094
00095 foreach ( $Jrn->row as $op ) {
00096 echo "<TR>";
00097
00098 if ( $p_cent == 'on') {
00099 echo "<TD>".$op['j_id']."</TD>";
00100 }
00101 echo "<TD>".$op['internal']."</TD>".
00102 "<TD>".$op['j_date']."</TD>".
00103 "<TD>".$op['poste']."</TD>".
00104 "<TD>".$op['description']."</TD>".
00105 "<TD>".$op['deb_montant']."</TD>".
00106 "<TD>".$op['cred_montant']."</TD>".
00107 "</TR>";
00108 }
00109 }
00110 else
00111 {
00112 include_once("jrn.php");
00113
00114
00115
00116 echo "<TR>".
00117 "<th> operation </td>".
00118 "<th>Date</th>".
00119 "<th> commentaire </th>".
00120 "<th>internal</th>".
00121
00122 "<th> montant</th>".
00123 "</TR>";
00124
00125 foreach ($Row as $line)
00126 {
00127 echo "<tr>";
00128 echo "<TD>".$line['num']."</TD>";
00129 echo "<TD>".$line['date']."</TD>";
00130 echo "<TD>".$line['comment']."</TD>";
00131 echo "<TD>".$line['jr_internal']."</TD>";
00132
00133
00134
00135
00136 if ( $line['jrn_def_type'] == 'FIN' ) {
00137 $positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
00138 " where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
00139 " and j_debit='f'");
00140
00141 echo "<TD align=\"right\">";
00142 echo ( $positive != 0 )?"<font color=\"red\"> - ".sprintf("%8.2f",$line['montant'])."</font>":sprintf("%8.2f",$line['montant']);
00143 echo "</TD>";
00144 }
00145 else
00146 {
00147 echo "<TD align=\"right\">".sprintf("% 8.2f",$line['montant'])."</TD>";
00148 }
00149
00150 echo "</tr>";
00151 }
00152
00153 }
00154 echo "</table>";
00155
00156 echo "</div>";
00157 exit;
00158 }
00159
00160
00161
00162
00163 include_once("postgres.php");
00164
00165 if ( $User->Admin() ==0) {
00166 $ret=make_array($cn,"select jrn_def_id,jrn_def_name
00167 from jrn_def join jrn_type on jrn_def_type=jrn_type_id
00168 join user_sec_jrn on uj_jrn_id=jrn_def_id
00169 where
00170 uj_login='$User->id'
00171 and uj_priv !='X'
00172 ");
00173 } else {
00174 $ret=make_array($cn,"select jrn_def_id,jrn_def_name
00175 from jrn_def join jrn_type on jrn_def_type=jrn_type_id");
00176
00177 }
00178
00179
00180 $NoPriv=CountSql($cn,"select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
00181 jrn_deb_max_line,jrn_cred_max_line
00182 from jrn_def join jrn_type on jrn_def_type=jrn_type_id
00183 join user_sec_jrn on uj_jrn_id=jrn_def_id
00184 where
00185 uj_login='$User->id'
00186 and uj_priv ='X'
00187 ");
00188
00189 if ( $NoPriv == 0 ) {
00190 $a=count($ret);
00191 $all=array('value'=>0,'label'=>'Grand Livre');
00192 $ret[$a]=$all;
00193 }
00194 if ( count($ret) < 1 )
00195 NoAccess();
00196
00197
00198
00199 echo '<div class="u_content">';
00200 echo '<FORM ACTION="?type=jrn" METHOD="POST">';
00201 echo '<TABLE width="90%" align="center"><TR>';
00202 $w=new widget("select");
00203 $w->table=1;
00204 $w->label="Choississez le journal";
00205 print $w->IOValue("jrn_id",$ret);
00206 print '</TR>';
00207 print '<TR>';
00208
00209 $filter_year=" where p_exercice='".$User->getExercice()."'";
00210
00211 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00212 $w->label="Depuis";
00213 print $w->IOValue('from_periode',$periode_start);
00214 $w->label=" jusqu'à ";
00215 $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00216 print $w->IOValue('to_periode',$periode_end);
00217 print "</TR><TR>";
00218 $centralise=new widget("checkbox");
00219 $centralise->label="Depuis les journaux centralisés";
00220 $centralise->table=1;
00221 print $centralise->IOValue('cent');
00222 $a=array(
00223 array('value'=>0,'label'=>'Detaillé'),
00224 array('value'=>1,'label'=>'Simple')
00225 );
00226 $w->selected=1;
00227 echo $w->IOValue('p_simple',$a,'Style d\'impression');
00228 print "</TR>";
00229 echo '</TABLE>';
00230 print $w->Submit('bt_html','Impression');
00231
00232 echo '</FORM>';
00233 echo '</div>';
00234 ?>