noalyss Version-9
impress_gl_comptes.inc.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
21/*! \file
22 * \brief Print account (html or pdf)
23 * file included from user_impress
24 *
25 * some variable are already defined $cn, $g_user ...
26 *
27 */
28//-----------------------------------------------------
29// Show the jrn and date
30//-----------------------------------------------------
32//-----------------------------------------------------
33// Form
34//-----------------------------------------------------
35echo '<div class="content">';
36
37echo '<FORM action="?" METHOD="GET" onsubmit="waiting_box();return true;">';
38echo HtmlInput::hidden('ac',$http->request('ac'));
39echo HtmlInput::hidden('type','gl_comptes');
40echo dossier::hidden();
41echo '<TABLE><TR>';
42
45$a=$periode->get_limit($g_user->get_exercice());
46// $a is an array
47$first_day=$a[0]->first_day();
48$last_day=$a[1]->last_day();
49
50// filter on period
51$date_from=new IDate('from_periode');
52$date_to=new IDate('to_periode');
53$year=$g_user->get_exercice();
54$date_from->value=(isset($_REQUEST['from_periode'])&& isDate($_REQUEST['from_periode'])!=0)?$_REQUEST['from_periode']:$first_day;
55$date_to->value=(isset($_REQUEST['to_periode']) && isDate($_REQUEST['to_periode']) !=0 )?$_REQUEST['to_periode']:$last_day;
56echo td(_('Depuis').$date_from->input());
57echo td(_('Jusque ').$date_to->input());
58
59$letter=new ICheckbox('letter');
60$letter->selected=(isset($_REQUEST['letter']))?true:false;
61
62$from_poste=new IPoste('from_poste');
63$from_poste->value=$http->request('from_poste',"string",'');
64$from_poste->set_attribute('account','from_poste');
65
66$to_poste=new IPoste('to_poste');
67$to_poste->value=$http->request('to_poste',"string",'');
68$to_poste->set_attribute('account','to_poste');
69
70$solded=new ICheckbox('solded');
71$solded->selected=(isset($_REQUEST['solded']))?true:false;
72
73echo '<tr>';
74echo td(_('Depuis le poste')).td($from_poste->input());
75echo '</tr>';
76
77echo '<tr>';
78echo td(_("Jusqu'au poste")).td($to_poste->input());
79echo '</tr>';
80
81echo '<tr>';
82echo td(_('Uniquement les opérations non lettrées'));
83echo td($letter->input());
84echo '</tr>';
85
86echo '<tr>';
87echo td(_('Uniquement les comptes non soldés'));
88echo td($solded->input());
89echo '</tr>';
90
91
92//
93echo '</TABLE>';
94print HtmlInput::submit('bt_html',_('Visualisation'));
95
96echo '</FORM>';
97echo '<hr>';
98echo '</div>';
99
100//-----------------------------------------------------
101// If print is asked
102// First time in html
103// after in pdf or cvs
104//-----------------------------------------------------
105if ( isset( $_REQUEST['bt_html'] ) )
106{
107 if ( DEBUGNOALYSS > 1 ) \Noalyss\Dbg::timer_start();
108
109 echo '<div class="content">';
110 echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes");
111 echo '</div>';
112 try {
113 $from_periode=$http->request("from_periode","date");
114 $to_periode=$http->request("to_periode","date");
115
116 } catch (Exception $e) {
117 echo alert(_('Date malformée, désolée'));
118 return;
119 }
120
121
123
124 if ( sizeof($a_accounting) == 0 )
125 {
126 echo_warning(_("Aucune donnée"));
127 return;
128 }
129
130 echo '<div class="content">';
131
132
133 echo '<table class="result">';
134 $l=(isset($_REQUEST['letter']))?2:0;
135 $s=(isset($_REQUEST['solded']))?1:0;
136
137
138 foreach ($a_accounting as $accounting_id )
139 {
140 $acc_account_ledger=new Acc_Account_Ledger ($cn, $accounting_id['pcm_val']);
141
142 $acc_account_ledger->get_row_date( $from_periode, $to_periode,$l,$s);
143 if ( empty($acc_account_ledger->row))
144 {
145 continue;
146 }
147
148
149 echo '<tr >
150 <td colspan="8" style="width:auto">
151 <h2 class="">'. $accounting_id['pcm_val'].' '.h($accounting_id['pcm_lib']).'</h2>
152 </td>
153 </tr>';
154
155 echo '<tr>
156 <td>Date</td>
157 <td>R&eacute;f&eacute;rence</td>
158 <td>Libell&eacute;</td>
159 <td>Pi&egrave;ce</td>
160 <td>Type</td>
161 <td align="right">D&eacute;bit</td>
162 <td align="right">Cr&eacute;dit</td>
163 <td align="right">Solde</td>
164 <td align="right">Let.</td>
165 </tr>';
166
167 $solde = 0.0;
168 $solde_d = 0.0;
169 $solde_c = 0.0;
170 bcscale(2);
171 $i=0;
173
174 foreach ($acc_account_ledger->row as $detail)
175 {
176 /*
177 * separation per exercice
178 */
179 if ( $current_exercice == "") $current_exercice=$detail['p_exercice'];
180
181 if ( $current_exercice != $detail['p_exercice']) {
182 echo '<tr class="highlight">
183 <td>'.$current_exercice.'</td>
184 <td>'.''.'</td>
185 <td>'._("Total du compte").$accounting_id['pcm_val'].'</td>
186 <td>'.''.'</td>'.td("").
187 '<td align="right">'.($solde_d > 0 ? nbm( $solde_d) : '').'</td>
188 <td align="right">'.($solde_c > 0 ? nbm( $solde_c) : '').'</td>
189 <td align="right">'.nbm( abs($solde_c-$solde_d)).'</td>
190 <td>';
191 if ($solde_c > $solde_d ) echo _("Crédit");
192 if ($solde_c < $solde_d ) echo _("Débit");
193 if ($solde_c == $solde_d ) echo " ";
194
195 echo '</td>'.
196 '</tr>';
197 /*
198 * reset total and current_exercice
199 */
200 $current_exercice=$detail['p_exercice'];
201 $solde = 0.0;
202 $solde_d = 0.0;
203 $solde_c = 0.0;
204
205 }
206
207
208 if ($detail['cred_montant'] > 0)
209 {
210 $solde=bcsub($solde, $detail['cred_montant']);
211 $solde_c=bcadd($solde_c,$detail['cred_montant']);
212 }
213 if ($detail['deb_montant'] > 0)
214 {
215 $solde = bcadd($solde,$detail['deb_montant']);
216 $solde_d = bcadd($solde_d,$detail['deb_montant']);
217 }
218 $side="&nbsp;".$acc_account_ledger->get_amount_side($solde);
219 $letter="";
220 $html_let="";
221 if ($detail['letter'] > 0) {
222 $letter=strtoupper(base_convert($detail['letter'],10,36));
223 $html_let = HtmlInput::show_reconcile("", $letter);
224 }
225 $i++;
226 if (($i % 2 ) == 0) $class="odd"; else $class="even";
227 echo '<tr name="tr_'.$letter.'_" class="'.$class.'">
228 <td>'.$detail['j_date_fmt'].'</td>
229 <td>'.HtmlInput::detail_op($detail['jr_id'],$detail['jr_internal']).'</td>
230 <td>'.$detail['description'].'</td>
231 <td>'.$detail['jr_pj_number'].'</td>
232 <td>'.$detail['jr_optype'].'</td>
233 <td align="right">'.($detail['deb_montant'] > 0 ? nbm($detail['deb_montant']) : '').'</td>
234 <td align="right">'.($detail['cred_montant'] > 0 ? nbm($detail['cred_montant']) : '').'</td>
235 <td align="right">'.nbm(abs($solde)).$side.'</td>
236 <td style="text-align:right;color:red">'.$html_let.'</td>
237 </tr>';
238 }
239 echo '<tr class="highlight">
240 <td>'.$current_exercice.'</td>
241 <td>'.''.'</td>
242 <td>'.'<b>'.'Total du compte '.$accounting_id['pcm_val'].'</b>'.'</td>
243 <td>'.''.'</td>'.td("").
244 '<td align="right">'.'<b>'.($solde_d > 0 ? nbm( $solde_d) : '').'</b>'.'</td>
245 <td align="right">'.'<b>'.($solde_c > 0 ? nbm( $solde_c) : '').'</b>'.'</td>
246 <td align="right">'.'<b>'.nbm( abs($solde_c-$solde_d)).'</b>'.'</td>
247 <td>';
248 if ($solde_c > $solde_d ) echo "Crédit";
249 if ($solde_c < $solde_d ) echo "Débit";
250 if ($solde_c == $solde_d ) echo "=";
251
252 echo '</td>'.
253 '</tr>';
254 }
255 echo '</table>';
256 echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes");
257 echo "</div>";
258 if (DEBUGNOALYSS> 1) echo \Noalyss\Dbg::hidden_info("\$acc_account_ledger", $acc_account_ledger);
259 if ( DEBUGNOALYSS > 1 ) \Noalyss\Dbg::timer_show();
260 return;
261}
262?>
isDate($p_date)
Definition: ac_common.php:236
echo_warning($p_string)
warns
Definition: ac_common.php:589
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
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
h( $row[ 'oa_description'])
$_REQUEST['ac']
$class
Manage the account from the table jrn, jrnx or tmp_pcmn.
static get_used_accounting($from_date, $to_date, $from_accounting, $to_accounting)
static HtmlTableHeader($actiontarget="poste")
Display HTML Table Header (button)
static connect()
static detail_op($p_jr_id, $p_mesg)
return a string containing the html code for calling the modifyOperation
static hidden($p_name, $p_value, $p_id="")
static show_reconcile($p_div, $let, $span="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
show a button, for selecting a account and a input text for manually inserting an account the differe...
static timer_start()
start a timer
Definition: dbg.php:198
static timer_show()
stop the timer and show the elapsed time, it is used for optimising the code
Definition: dbg.php:208
For the periode tables parm_periode and jrn_periode.
$a_accounting
global $http
global $g_user
print
Type of printing.
$side