noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ledger_detail_ach.php
Go to the documentation of this file.
1<?php
2//This file is part of NOALYSS and is under GPL
3//see licence.txt
4
5/**
6 * @var $str_anc String HTML contains the detail of analytic
7 * @var $g_user Noalyss_User inherited , it is the connected user
8 * @var $div (string) current DIV ID prefix (det<x> where <x> is a number
9 */
12
13//@var $dossier_id (int) folder id
14$dossier_id=Dossier::id();
15
16//@var $jr_id (int) jrn.jr_id
17//@var $obj (Acc_Operation) current operation detail
18
19?><?php require_once NOALYSS_TEMPLATE.'/ledger_detail_top.php'; ?>
20<div class="content">
21 <?php
23 ?>
24
25 <?php if ($access == 'W') : ?>
26 <form class="print" onsubmit="return op_save(this);">
27 <?php endif; ?>
28
29 <?php echo HtmlInput::hidden('whatdiv', $div) . HtmlInput::hidden('jr_id', $jr_id) . dossier::hidden(); ?>
30 <table style="width:100%">
31 <tr><td>
32 <table>
33 <td></td>
34 <?php
35 $date = new IDate('p_date');
36 $date->value = format_date($obj->det->jr_date);
37 if ( $g_parameter->MY_STRICT=='Y' || $g_user->check_action(UPDDATE)==0) {
38 $date->setReadOnly(true);
39 }
40 echo td(_('Date')) . td($date->input());
41 ?>
42 <tr>
43 <td></td>
44 <?php
45 $date_ech = new IDate('p_ech');
46 $date_ech->value = format_date($obj->det->jr_ech);
47 echo td(_('Echeance')) . td($date_ech->input());
48 ?>
49 </tr>
50 <tr>
51 <td></td>
52 <td>
53 <?php echo _("Date paiement")?>
54 </td>
55 <td>
56 <?php
57 $date_paid = new IDate('p_date_paid');
58 $date_paid->value = format_date($obj->det->jr_date_paid);
59 echo $date_paid->input();
60 ?>
61 </td>
62 </tr>
63
64 <tr><td>
65 <?php
66 $bk = new Fiche($cn, $obj->det->array[0]['qp_supplier']);
67 echo td(_('Fournisseur'));
68
69 $view_card_detail = HtmlInput::card_detail($bk->get_quick_code(), h($bk->getName()), ' class="line" ');
71 ?>
72 </td>
73 </tr>
74 <tr>
75 <td>
76 <?php
77 $itext = new IText('npj');
78 if ($owner->MY_PJ_SUGGEST=='A' || $g_user->check_action(UPDRECEIPT)==0)
79 $itext->setReadOnly(true);
80 $itext->value = strip_tags($obj->det->jr_pj_number);
81 echo td(_('Pièce')) . td($itext->input());
82 ?>
83 </td>
84 <tr>
85 <td>
86 <?php
87 $itext = new IText('lib');
88 $itext->value = strip_tags($obj->det->jr_comment??"");
89 $itext->size = 40;
90 echo td(_('Libellé')) . td($itext->input(), ' colspan="2" ');
91 ?>
92 </td>
93 </tr>
94 <tr>
95 <td></td>
96 <td>Payé</td>
97 <td>
98 <?php
99 $ipaid = new ICheckBox("ipaid", 'paid');
100 $ipaid->selected = ($obj->det->jr_rapt == 'paid');
101 echo $ipaid->input();
102 ?>
103 </td>
104 </tr>
105
106 </table>
107 </td>
108 <td style="width:50%;height:100%;vertical-align:top;text-align: center">
109 <table style="width:99%;height:8rem;vertical-align:top;">
110 <tr style="height: 5%">
111 <td style="text-align:center;vertical-align: top">
112 <?php
113 $inote = new ITextarea('jrn_note');
114 $inote->set_enrichText("minimal");
115 $inote->id="jrn_note{$div}";
116 $inote->style=' class="itextarea" style="width:90%;height:100%;"';
117 $inote->value = $obj->det->note_html;
118 $inote->heigh=200;
119 echo $inote->input();
120
121 ?>
122 </td>
123 </tr>
124 <tr>
125 <td>
126 <div id="operation_tag_td<?=$div?>">
127 <?php
128 /******************************************************************************************************************
129 * Tags on operation
130 *****************************************************************************************************************/
132 $tag_operation->set_jrn_id($obj->det->jr_id);
133 $tag_operation->tag_cell($div);
134 ?>
135
136
137 </div>
138 <?php
139 // Button add tags
140 if ( $access=='W') { echo Tag_Operation::button_search($obj->det->jr_id,$div);}
141 ?>
142 </td>
143 </tr>
144 </table>
145 </td>
146 </tr>
147
148 </table>
149 <table class="result" style="margin-left:4px">
150 <?php
151 bcscale(2);
154 echo th(_('Quick Code'));
155 echo th(_('Description'));
156
157 echo th(_('Prix/Un.'), 'style="text-align:right"');
158 echo th(_('Quantité'), 'style="text-align:right"');
159 if ($owner->MY_TVA_USE == 'Y')
160 {
161 echo th(_('Taux TVA'), 'style="text-align:right"');
162 } else
163 {
164 echo th('');
165 }
166 echo th(_('Non ded'), 'style="text-align:right"');
167
168 if ($owner->MY_TVA_USE == 'Y')
169 {
170 echo th(_('HTVA'), 'style="text-align:right"');
171 echo th(_('TVA ND'), 'style="text-align:right"');
172 echo th(_('TVA'), 'style="text-align:right"');
173 echo th(_('TVAC'), 'style="text-align:right"');
174 } else
175 echo th(_('Total'), 'style="text-align:right"');
176 if ( $obj->det->currency_id != 0 ) {
177 $currency=$obj->db->get_value("select cr_code_iso from currency where id=$1",
178 [$obj->det->currency_id]);
179 echo th($currency, 'style="text-align:right"');
180 }
181 if ($owner->MY_ANALYTIC != 'nu' )
182 {
183 $anc = new Anc_Plan($cn);
184 $a_anc = $anc->get_list(' order by pa_id ');
185 $x = count($a_anc);
186 /* set the width of the col */
187 /* add hidden variables pa[] to hold the value of pa_id */
188 $str_anc.='<tr>'.
189 '<th>'.
190 _('Code').
191 '</th>'.
192 '<th>'.
193 _('Poste').
194 '</th>'.
195 '<th>'.
196 _('Montant').
197 '</th>'.
198 '<th colspan="' . $x . '">'
199 . _('Compt. Analytique') .Anc_Plan::hidden($a_anc).
200 '</th>'.
201 '</tr>';
202
203 }
204 echo '</tr>';
206 for ($e = 0; $e < count($obj->det->array); $e++)
207 {
208 $row = '';
209 $q = $obj->det->array[$e];
210 $fiche = new Fiche($cn, $q['qp_fiche']);
211 $qcode=$fiche->get_attribute(ATTR_DEF_QUICKCODE);
212 $view_card_detail = HtmlInput::card_detail($qcode, "", ' class="line" ');
214 $sym_tva = '';
215
216 if ($owner->MY_TVA_USE == 'Y' && $q['qp_vat_code'] != '')
217 {
218 /* retrieve TVA symbol */
219 $tva = Acc_Tva::build($cn, $q['qp_vat_code']);
220 $tva->load();
221 $sym_tva = h($tva->get_parameter('label'));
222 $x=($g_user->get_vat_code_preference()==1)?$tva->get_parameter('tva_code'):$tva->get_parameter('id');
223 $sym_tva .= sprintf('[%s]',$x);
224 }
225 if ($owner->MY_UPDLAB == 'Y')
226 {
227 $l_lib = ($q['j_text'] == '') ? $fiche->get_attribute(ATTR_DEF_NAME) : $q['j_text'];
228 $hidden = HtmlInput::hidden("j_id[]", $q['j_id']);
229 $input = new IText("e_march" . $q['j_id'] . "_label", $l_lib);
230 $input->css_size = "100%";
231 } else
232 {
233 $input = new ISpan("e_march" . $q['j_id'] . "_label");
234 $hidden = HtmlInput::hidden("j_id[]", $q['j_id']);
235 $input->value = $fiche->get_attribute(ATTR_DEF_NAME);
236 }
237 $row.=td($input->input() . $hidden);
238 $pu = $q['qp_unit'];
239 $row.=td(nbm($pu,4), 'class="num"');
240 $row.=td(nbm($q['qp_quantite'],4), 'class="num"');
241 $row.=td($sym_tva, 'style="text-align:center"');
242
243 $no_ded = bcadd($q['qp_dep_priv'], $q['qp_nd_amount']);
244 $row.=td(nbm($no_ded), ' style="text-align:right"');
245 $htva = $q['qp_price'];
246
247
248 $row.=td(nbm($htva), 'class="num"');
249 $tva_rounded=round($q['qp_vat'],2);
250 $tvac = bcadd($htva, $tva_rounded);
251 $tvac = bcadd($tvac, $q['qp_nd_tva']);
252 $tvac = bcadd($tvac, $q['qp_nd_tva_recup']);
253 $tvac = bcsub ($tvac,$q['qp_vat_sided']);
254 if ($owner->MY_TVA_USE == 'Y')
255 {
256 $tva_amount_nd = bcadd($q['qp_nd_tva_recup'], $q['qp_nd_tva']);
257 $class = "";
258 if ($q['qp_vat_sided'] <> 0)
259 {
260 $class = ' style="text-decoration:line-through"';
261 }
262 $row.=td(nbm($tva_amount_nd), 'class="num" ' . $class);
263 $row.=td(nbm($tva_rounded), 'class="num" ' . $class);
264 $row.=td(nbm($tvac), 'class="num"');
265 }
266 $total_tvac=bcadd($total_tvac,$tvac);
267 $total_htva=bcadd($htva,$total_htva);
268 /* Analytic accountancy */
269 if ($owner->MY_ANALYTIC != "nu" /*&& $div == 'popup'*/ )
270 {
271 $poste = $fiche->get_attribute(ATTR_DEF_ACCOUNT);
272 if ( $g_parameter->match_analytic($poste))
273 {
274 $anc_op = new Anc_Operation($cn);
275 $anc_op->j_id = $q['j_id'];
276 $anc_op->in_div=$div;
277 $side=($q['j_debit'] == 'f')?'C':'D';
278
279 echo HtmlInput::hidden('opanc[]', $anc_op->j_id);
280 /* compute total price */
281 bcscale(2);
282 $str_anc.='<tr>';
285 $str_anc.=td(nbm($htva)." {$side}");
286 $str_anc.=$anc_op->display_table(1, $htva, $div);
287
288 $str_anc.='</tr>';
289 /* check there is no other row for this one like TVA_ND */
290 /**
291 * @var $anl_extra array of rows from operation_analytique concerning the current record
292 *
293 */
294 $anl_extra=$cn->get_array('select distinct j1.f_id,
295 o1.j_id j_id_anx,
296 j1.j_poste,
297 j1.j_debit,
298 j1.j_montant
299 from operation_analytique o1
300 join jrnx j1 on (o1.j_id=j1.j_id)
301 where oa_jrnx_id_source = $1',
302 [$q['j_id']]);
303 if (count($anl_extra) > 0)
304 {
305 foreach ($anl_extra as $item_anl_extra) {
306
307 $anc_op = new Anc_Operation($cn);
308 $anc_op->j_id =$item_anl_extra['j_id_anx'];
309 $anc_op->in_div=uniqid();
310 $side=($item_anl_extra['j_debit'] == 'f')?'C':'D';
311 $n="";
312 if ( $item_anl_extra['f_id'] != "") {
313 $n=$cn->get_value('select ad_value from fiche_detail
314 where
315 f_id =$1
316 and ad_id=$2'
317 ,[$item_anl_extra['f_id'],ATTR_DEF_QUICKCODE]);
318 }
319
320 /* compute total price */
321 bcscale(2);
322 $str_anc.='<tr>';
323 $str_anc.=td($n);
324 $str_anc.=td($item_anl_extra['j_poste']);
325
326 $str_anc.=td(nbm($item_anl_extra['j_montant'])." {$side}");
327 $str_anc.=$anc_op->display_table(0, $htva, $anc_op->in_div);
328
329 $str_anc.='</tr>';
330 }
331
332 }
333 }
334 }
335 $class=($e%2==0)?' class="even"':'class="odd"';
336 /*
337 * Display Currency in a column, if invoice not recorded in EUR
338 */
339 if ( $obj->det->currency_id != 0 ) {
340 $value=$obj->db->get_value("select oc_amount+oc_vat_amount from operation_currency where j_id=$1",[$q['j_id']]);
341 $row.=td(nbm($value,4),' class="num"');
343
344 }
345 echo tr($row,$class);
346 }
347
348 if ($owner->MY_TVA_USE == 'Y')
349 $row = td(_('Total'), ' style="font-style:italic;text-align:right;font-weight: bolder;width:auto" colspan="6"');
350 else
351 $row = td(_('Total'), ' style="font-style:italic;text-align:right;font-weight: bolder;width:auto" colspan="6"');
352 /**
353 * display additional tax if any + currency
354 */
358
360 if ($owner->MY_TVA_USE == 'N') {
362 }
363 $row.=td(nbm($total_htva), 'class="num" style="font-style:italic;font-weight: bolder;"');
364 if ($owner->MY_TVA_USE == 'Y')
365 $row.=td("") . td("").td(nbm($total_tvac), 'class="num" style="font-style:italic;font-weight: bolder;"');
366 /**
367 * display additional tax if any + currency
368 */
369
370
371 //Display total in currency
372 if ( $obj->det->currency_id != "" && $obj->det->currency_id > 0)
373 {
374 $currency=new Acc_Currency($obj->db, $obj->det->currency_id);
375 $row.= td(nbm($sum_charge_euro,4),' class="num" style="font-style:italic;font-weight: bolder;"');
376 }
377 echo tr($row);
378
379 ?>
380 </table>
381<?php
382
383
384/*
385 * Info about currency if not in euro
386 */
387 // Add a row with currency and amount
388 if ( $obj->det->currency_id != "" && $obj->det->currency_id > 0)
389 {
390 $currency=new Acc_Currency($obj->db, $obj->det->currency_id);
391 $four_space="&nbsp;"."&nbsp;"."&nbsp;"."&nbsp;";
392
393 echo $currency->get_code(),$four_space;
394 echo _("Taux utilisé"),"&nbsp;", nbm($obj->det->currency_rate,4),$four_space;
395 echo _("Taux Réf"), "&nbsp;",nbm($obj->det->currency_rate_ref,4).$four_space;
396 echo _("Montant en devise"), "&nbsp;",nbm($sum_charge_euro,4).$four_space;
397 }
398?>
399
400
401
402<?php
403require_once NOALYSS_TEMPLATE.'/ledger_detail_bottom.php';
404?>
405</div>
format_date($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
th($p_string, $p_extra='', $raw='')
Definition ac_common.php:58
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.
global $g_parameter
global $g_user
if no group available , then stop
$dossier_id
catch(Exception $e) $obj
h( $row[ 'oa_description'])
if($ledger=="") $access
$jr_id
$opd_description style
_("actif, passif,charge,...")
$class
Display the Plugin and for each profile were it is installed or not.
display currency , convert to euro , and save them if used.
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
static display_row($p_jrn_id, &$sum_euro, &$sum_currency, $decalage=0)
display the additional_tax in the ledger_detail for Sales and Purchase
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
Concerns the Analytic plan (table plan_analytique)
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
static hidden($p_name, $p_value, $p_id="")
Html Input.
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Html Input.
Html Input Text member :
Manage the TEXTAREA html element.
Class to manage the company parameter (address, name...)
concerns the tags linked to an accountancy writing
static button_search($p_jr, $p_div)
Show a button to select tag for Search.
$all table
$n
Definition compute.php:54
const ATTR_DEF_NAME
Definition constant.php:223
const ATTR_DEF_QUICKCODE
Definition constant.php:244
const ATTR_DEF_ACCOUNT
Definition constant.php:222
const UPDDATE
const UPDRECEIPT
$sum_add_tax
display additional tax if any + currency
$tag_operation
Tags on operation.
$view_card_detail
$side