00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 include_once("class_acc_account_ledger.php");
00027 include_once("ac_common.php");
00028 require_once('class_database.php');
00029 include_once("class_impress.php");
00030 require_once("class_fiche.php");
00031 require_once ('header_print.php');
00032 require_once('class_dossier.php');
00033 require_once('class_pdf.php');
00034 $gDossier=dossier::id();
00035
00036 $cn=new Database($gDossier);
00037
00038 extract($_GET);
00039
00040 $ret="";
00041 $pdf= new PDF($cn);
00042 $pdf->setDossierInfo(" Periode : ".$_GET['from_periode']." - ".$_GET['to_periode']);
00043 $pdf->AliasNbPages();
00044 $pdf->AddPage();
00045 $pdf->SetAuthor('NOALYSS');
00046 $pdf->setTitle("Détail fiche",true);
00047
00048
00049 $Fiche=new Fiche($cn,$f_id);
00050
00051
00052 list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date($from_periode,$to_periode,$_GET['ople']);
00053
00054 if ( count($array) == 0 )
00055 {
00056 exit;
00057 }
00058 $size=array(13,25,20,60,12,20,20,20);
00059 $align=array('L','C','C','L','R','R','R','R');
00060
00061 $Libelle=sprintf("(%s) %s [ %s ]",$Fiche->id,$Fiche->getName(),$Fiche->get_quick_code());
00062 $pdf->SetFont('DejaVu','',10);
00063 $pdf->Cell(0,8,$Libelle,1,0,'C');
00064 $pdf->Ln();
00065
00066
00067 $pdf->SetFont('DejaVuCond','',8);
00068 $l=0;
00069 $pdf->Cell($size[$l],6,'Date',0,0,'L');
00070 $l++;
00071 $pdf->Cell($size[$l],6,'Ref',0,0,'C');
00072 $l++;
00073 $pdf->Cell($size[$l],6,'Journal',0,0,'C');
00074 $l++;
00075 $pdf->Cell($size[$l],6,'Libellé',0,0,'L');
00076 $l++;
00077 $pdf->Cell($size[$l],6,'Let',0,0,'R');
00078 $l++;
00079 $pdf->Cell($size[$l],6,'Debit',0,0,'R');
00080 $l++;
00081 $pdf->Cell($size[$l],6,'Credit',0,0,'R');
00082 $l++;
00083 $pdf->Cell($size[$l],6,'Prog',0,0,'R');
00084 $l++;
00085 $pdf->ln();
00086 $tot_deb=0;
00087 $tot_cred=0;
00088 $progress=0;
00089 for ($e=0;$e<count($array);$e++)
00090 {
00091 $l=0;
00092 $row=$array[$e];
00093 $progress+=$row['deb_montant']-$row['cred_montant'];
00094
00095
00096 $date=shrink_date($row['j_date_fmt']);
00097 $pdf->Cell($size[$l],6,$date,0,0,$align[$l]);
00098 $l++;
00099 if ( $row['jr_pj_number'] == '')
00100 $pdf->Cell($size[$l],6,"",0,0,$align[$l]);
00101 else
00102 $pdf->Cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
00103
00104 $l++;
00105 $pdf->Cell($size[$l],6,mb_substr($row['jrn_name'],0,14),0,0,$align[$l]);
00106 $l++;
00107 $pdf->LongLine($size[$l],6,($row['description'].'('.$row['jr_internal'].")"),0,$align[$l]);
00108
00109 $l++;
00110 $pdf->Cell($size[$l],6,(($row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,0,$align[$l]);
00111 $l++;
00112 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]);
00113 $l++;
00114 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]);
00115 $l++;
00116 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',abs($progress))),0,0,$align[$l]);
00117 $l++;
00118 $pdf->ln();
00119 $tot_deb+=$row['deb_montant'];
00120 $tot_cred+=$row['cred_montant'];
00121
00122
00123
00124 if ( isset($_GET['oper_detail']))
00125 {
00126 $detail=new Acc_Operation($cn);
00127 $detail->jr_id=$row['jr_id'];
00128 $a_detail=$detail->get_jrnx_detail();
00129 for ($f=0;$f<count($a_detail);$f++)
00130 {
00131 $l=0;
00132 $pdf->Cell($size[$l],6,'',0,0,$align[$l]);
00133 $l++;
00134 $pdf->Cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,'L');
00135 $l++;
00136 $pdf->Cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,'R');
00137 $l++;
00138 if ( $a_detail[$f]['j_qcode']=='')
00139 $lib=$a_detail[$f]['pcm_lib'];
00140 else
00141 {
00142 $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
00143 $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
00144 array(ATTR_DEF_NAME,$f_id));
00145 }
00146 $pdf->Cell($size[$l],6,$lib,0,0,$align[$l]);
00147 $l++;
00148 $pdf->Cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
00149 $l++;
00150
00151 $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
00152 $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
00153
00154 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
00155 $l++;
00156 $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
00157 $l++;
00158 $pdf->ln();
00159 }
00160 }
00161
00162 }
00163 $str_debit=sprintf("% 12.2f €",$tot_deb);
00164 $str_credit=sprintf("% 12.2f €",$tot_cred);
00165 $diff_solde=$tot_deb-$tot_cred;
00166 if ( $diff_solde < 0 )
00167 {
00168 $solde=" créditeur ";
00169 $diff_solde*=-1;
00170 }
00171 else
00172 {
00173 $solde=" débiteur ";
00174 }
00175 $str_diff_solde=sprintf("%12.2f €",$diff_solde);
00176
00177 $pdf->SetFont('DejaVu','B',8);
00178
00179 $pdf->Cell(160,5,'Débit',0,0,'R');
00180 $pdf->Cell(30,5,$str_debit,0,0,'R');
00181 $pdf->Ln();
00182 $pdf->Cell(160,5,'Crédit',0,0,'R');
00183 $pdf->Cell(30,5,$str_credit,0,0,'R');
00184 $pdf->Ln();
00185 $pdf->Cell(160,5,'Solde '.$solde,0,0,'R');
00186 $pdf->Cell(30,5,$str_diff_solde,0,0,'R');
00187 $pdf->Ln();
00188
00189 $fDate=date('dmy-Hi');
00190 $pdf->Output('fiche-'.$fDate.'.pdf','D');
00191
00192
00193 ?>