noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
print_ledger_simple.php
Go to the documentation of this file.
00001 <?php
00002 //This file is part of NOALYSS and is under GPL 
00003 //see licence.txt
00004 ?><TABLE class="result">
00005     <tr>
00006         <th><?php echo _("Pièce")?></th>
00007         <th><?php echo _("Date")?></th>
00008         <th><?php echo _("Paiement")?></th>
00009         <th><?php echo _("Ref")?></th>
00010         <th><?php echo _("Client")."/"._("Fournisseur")?></th>
00011         <th><?php echo _("Description")?></th>
00012         <th style="text-align:right">HTVA</th>
00013         <th style="text-align:right">Privé</th>
00014         <th style="text-align:right">DNA</th>
00015         
00016         
00017 <?php
00018 $col_tva="";
00019 
00020  if ( $own->MY_TVA_USE=='Y')
00021         {
00022             echo '<th style="text-align:right">TVA ND</th>';
00023             $a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate");
00024             foreach($a_Tva as $line_tva)
00025             {
00026                 $col_tva.='<th style="text-align:right">Tva '.$line_tva['tva_label'].'</th>';
00027             }
00028         }
00029 echo $col_tva;      
00030 ?>
00031         <th style="text-align:right">TVAC</th>
00032         <th><?php echo _("Opérations rapprochées")?></th>
00033     </tr>
00034 <?php
00035 $i = 0;
00036 $cn->prepare('reconcile_date','select * from jrn where jr_id in (select jra_concerned from jrn_rapt where jr_id = $1 union all select jr_id from jrn_rapt where jra_concerned=$1)');
00037 $tot['htva']=0;
00038 $tot['dep_priv']=0;
00039 $tot['dna']=0;
00040 $tot['tva_nd']=0;
00041 $tot['tvac']=0;
00042 $tot['tva']=array();
00043 bcscale(2);
00044 foreach ($Row as $line) {
00045     $i++;
00046     /*
00047      * Get date of reconcile operation
00048      */
00049     $ret_reconcile=$cn->execute('reconcile_date',array($line['jr_id']));
00050    
00051     $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" ';
00052     echo "<tr $class>";
00053     echo "<TD>" . h($line['jr_pj_number']) . "</TD>";
00054     echo "<TD>" . smaller_date($line['date']) . "</TD>";
00055     echo "<TD>" . smaller_date($line['date_paid']) . "</TD>";
00056     echo "<TD>" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "</TD>";
00057     $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']);
00058     echo td($tiers);
00059     echo "<TD>" . h($line['comment']) . "</TD>";
00060     $dep_priv=($line['dep_priv']==0)?"":nbm($line['dep_priv']);
00061     $tot['dep_priv']=bcadd($tot['dep_priv'],  floatval($line['dep_priv']));
00062     $dna=($line['dna']==0)?"":nbm($line['dna']);
00063     $tot['dna']=bcadd($tot['dna'],floatval($line['dna']));
00064     echo "<TD class=\"num\">" . nbm($line['HTVA']) . "</TD>";
00065     $tot['htva']=bcadd($tot['htva'],  floatval($line['HTVA']));
00066     
00067     echo "<TD class=\"num\">" .$dep_priv . "</TD>";
00068     echo "<TD class=\"num\">" . $dna . "</TD>";
00069     if ($own->MY_TVA_USE == 'Y' )
00070     {
00071         $tva_dna=($line['tva_dna']==0)?"":nbm($line['tva_dna']);
00072         $tot['tva_nd']=bcadd($tot['tva_nd'],  floatval($line['tva_dna']));
00073         echo "<TD class=\"num\">" . $tva_dna. "</TD>";
00074         $a_tva_amount=array();
00075         foreach ($line['TVA'] as $lineTVA)
00076             {
00077                 foreach ($a_Tva as $idx=>$line_tva)
00078                 {
00079 
00080                     if ($line_tva['tva_id'] == $lineTVA[1][0])
00081                     {
00082                         $a=$line_tva['tva_id'];
00083                         $a_tva_amount[$a]=$lineTVA[1][2];
00084                     }
00085                 }
00086             }
00087         foreach ($a_Tva as $line_tva)
00088         {
00089             $a=$line_tva['tva_id'];
00090             if ( isset($a_tva_amount[$a])) {
00091                 echo '<td class="num">'.nb($a_tva_amount[$a]).'</td>';
00092                 $tot['tva'][$a]=(isset($tot['tva'][$a]))?bcadd($tot['tva'][$a],floatval($a_tva_amount[$a])):floatval($a_tva_amount[$a]);
00093             }
00094             else
00095                 printf("<td class=\"num\"></td>");
00096         }
00097     }
00098     echo '<td class="num">'.$line['TVAC'].'</td>';
00099     $tot['tvac']=bcadd($tot['tvac'], floatval($line['TVAC']));
00100     /*
00101      * If reconcile print them
00102      */
00103     echo '<td>';
00104     $max=Database::num_row($ret_reconcile);
00105     if ($max > 0) {
00106         $sep="";
00107         for ($e=0;$e<$max;$e++) {
00108             $row=Database::fetch_array($ret_reconcile, $e);
00109             echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
00110             $sep=' ,';
00111         }
00112     }
00113     echo '</td>';
00114     echo "</tr>";
00115 }
00116 /** 
00117  * summary
00118  */
00119 ?>
00120     <tr class="highlight">
00121         <td>
00122             <?php echo _('Totaux')?>
00123         </td>
00124         <td></td>
00125         <td></td>
00126         <td></td>
00127         <td></td>
00128         <td></td>
00129         <td class="num"><?php echo nbm($tot['htva']); ?></td>
00130         <td class="num"><?php echo nbm($tot['dep_priv']) ?></td>
00131         <td class="num"><?php echo nbm($tot['dna'])?></td>
00132         <?php if ($own->MY_TVA_USE == 'Y' ): ?>
00133             <td><?php echo nbm($tot['tva_nd']) ?></td>
00134             <?php  foreach ($a_Tva as $line_tva) :
00135                         $a=$line_tva['tva_id'];
00136                         if ( isset($tot['tva'][$a])) :
00137                     ?>
00138                         <td class="num"><?php echo nbm($tot['tva'][$a])?></td>
00139                     <?php else : ?>
00140                         <td>
00141 
00142                         </td>
00143                     <?php endif; ?>
00144                 <?php endforeach;?>
00145         <?php endif; ?>
00146         <td class="num"><?php echo nbm($tot['tvac'])?></td>
00147         <td></td>
00148     </tr>
00149         
00150         
00151 </table>
 All Data Structures Namespaces Files Functions Variables Enumerations