noalyss Version-9
acc_ledger_history_purchase_detail.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22if (!defined('ALLOWED'))
23 die('Appel direct ne sont pas permis');
24
25/**
26 * @file
27 * @brief Display one purchase operation on one line , with the sum of VAT, ND...
28 */
29echo \HtmlInput::filter_table("tb_print_ledger", "0,1,2,3,4,5,6,7", 1);
30?>
31<TABLE class="result">
32 <tr>
33 <th><?php echo _("Pièce")?></th>
34 <th><?php echo _("Date")?></th>
35 <th><?php echo _("Paiement")?></th>
36 <th><?php echo _("Ref")?></th>
37 <th><?php echo _("Fournisseur")?></th>
38 <th><?php echo _("Description")?></th>
39 <th style="text-align:right">HTVA</th>
40 <th style="text-align:right">Privé</th>
41 <th style="text-align:right">DNA</th>
42
43
44<?php
45$col_tva="";
46
47 if ( $own->MY_TVA_USE=='Y')
48 {
49 echo '<th style="text-align:right">TVA ND</th>';
50 $a_Tva=$this->db->get_array("select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_id");
51 foreach($a_Tva as $line_tva)
52 {
53 $col_tva.='<th style="text-align:right">Tva '.$line_tva['tva_label'].'</th>';
54 }
55 }
56echo $col_tva;
57?>
58 <th style="text-align:right">TVAC</th>
59 <th><?php echo _("Opérations rapprochées")?></th>
60 </tr>
61<?php
62$i = 0;
63$tot['htva']=0;
64$tot['private_amount']=0;
65$tot['noded_amount']=0;
66$tot['tva_nd']=0;
67$tot['tvac']=0;
68$tot['tva']=array();
69bcscale(4);
70foreach ($this->data as $line) {
71 $i++;
72 /*
73 * Get date of reconcile operation
74 */
75 $ret_reconcile=$this->db->execute('reconcile_date',array($line['jr_id']));
76 $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" ';
77 echo "<tr $class>";
78
79 // Receipt number
80 echo "<TD>" . h($line['jr_pj_number']) . "</TD>";
81
82 // Date
83 echo "<TD>" . smaller_date($line['str_date']) . "</TD>";
84 echo "<TD>" . smaller_date($line['str_date_paid']) . "</TD>";
85
86 // Internal with detail
87 echo "<TD>" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "</TD>";
88
89 // find the tiers (normally in $Row !
90 $tiers =HtmlInput::history_card($line['qp_supplier'],h($line['name'].' '.$line['first_name'])."[{$line['qcode']}]");
91 echo td($tiers);
92 // Label
93 echo "<TD>" . h($line['jr_comment']) . "</TD>";
94
95 // Private expense
96 $private_amount=($line['private_amount']==0)?"":nbm(round($line['private_amount'],2),2);
97 $tot['private_amount']=bcadd($tot['private_amount'], floatval($line['private_amount']));
98
99 // No deductible
100 $noded_amount=($line['noded_amount']==0)?"":nbm(round($line['noded_amount'],2),2);
101 $tot['noded_amount']=bcadd($tot['noded_amount'],round(floatval($line['noded_amount'])),2);
102
103 // HTVA amount
104 echo "<TD class=\"num\">" . nbm(round($line['novat'],2),2) . "</TD>";
105 $tot['htva']=bcadd($tot['htva'], round(floatval($line['novat']),2));
106
107 echo "<TD class=\"num\">" .$private_amount . "</TD>";
108 echo "<TD class=\"num\">" . $noded_amount . "</TD>";
109
110 //--------------------------------------------------------------------------
111 // If VAT then display it
112 //--------------------------------------------------------------------------
113 if ($own->MY_TVA_USE == 'Y' )
114 {
115 $tva_dna=($line['noded_vat']==0)?"":nbm(round($line['noded_vat']),2);
116 $tot['tva_nd']=bcadd($tot['tva_nd'], round(floatval($line['noded_vat']),2));
117 echo "<TD class=\"num\">" . $tva_dna. "</TD>";
118 $a_tva_amount=array();
119
120 foreach ($line['detail_vat'] as $lineTVA)
121 {
122 foreach ($a_Tva as $idx=>$line_tva)
123 {
124
125 if ($line_tva['tva_id'] == $lineTVA['qp_vat_code'])
126 {
127 $a=$line_tva['tva_id'];
128 $a_tva_amount[$a]=$lineTVA['vat_amount'];
129 }
130 }
131 }
132 foreach ($a_Tva as $line_tva)
133 {
134 $a=$line_tva['tva_id'];
135 if ( isset($a_tva_amount[$a]) && $a_tva_amount[$a] != 0) {
136 echo '<td class="num">'.nbm(round($a_tva_amount[$a],2)).'</td>';
137 $tot['tva'][$a]=(isset($tot['tva'][$a]))?bcadd($tot['tva'][$a],round(floatval($a_tva_amount[$a]),2)):round(floatval($a_tva_amount[$a]),2);
138 }
139 else
140 printf("<td class=\"num\"></td>");
141 }
142 }
143
144 echo '<td class="num">'.nbm($line['tvac'],2).'</td>';
145 $tot['tvac']=bcadd($tot['tvac'], round($line['tvac'],2));
146 /*
147 * If reconcile print them
148 */
149 echo '<td>';
151 if ($max > 0) {
152 $sep="";
153 for ($e=0;$e<$max;$e++) {
155 $msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
156 echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
157 $sep=' ,';
158 }
159 }
160 echo '</td>';
161 echo "</tr>";
162}
163/**
164 * summary
165 */
166?>
167 <tr class="highlight">
168 <td>
169 <?php echo _('Totaux')?>
170 </td>
171 <td></td>
172 <td></td>
173 <td></td>
174 <td></td>
175 <td></td>
176 <td class="num"><?php echo nbm($tot['htva']); ?></td>
177 <td class="num"><?php echo nbm($tot['private_amount']) ?></td>
178 <td class="num"><?php echo nbm($tot['noded_amount'])?></td>
179 <?php if ($own->MY_TVA_USE == 'Y' ): ?>
180 <td><?php echo nbm($tot['tva_nd']) ?></td>
181 <?php foreach ($a_Tva as $line_tva) :
182 $a=$line_tva['tva_id'];
183 if ( isset($tot['tva'][$a])) :
184 ?>
185 <td class="num"><?php echo nbm($tot['tva'][$a])?></td>
186 <?php else : ?>
187 <td>
188
189 </td>
190 <?php endif; ?>
191 <?php endforeach;?>
192 <?php endif; ?>
193 <td class="num"><?php echo nbm($tot['tvac'])?></td>
194 <td></td>
195 </tr>
196
197
198</table>
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
smaller_date($p_date)
shrink the date, make a date shorter for the printing
Definition: ac_common.php:837
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
if(isset($tot['tva'][$a]))($tot['tva'][$a])?></td ><?php else endforeach
if(!headers_sent()) else
h( $row[ 'oa_description'])
$idx
$opd_description style
$class
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
static detail_op($p_jr_id, $p_mesg)
return a string containing the html code for calling the modifyOperation
static history_card($f_id, $p_mesg, $p_style="", $p_exercice="")
display a div with the history of the card
$all table
$SecUser db