dolibarr 23.0.3
quadri_detail.php
1<?php
2/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
6 * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
29global $mysoc;
30
31// Load Dolibarr environment
32require '../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
45require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
46require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
47require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
48require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
49require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
50require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
51require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
52require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
53
54// Load translation files required by the page
55$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
56
57$local = GETPOSTINT('localTaxType');
58
59include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php';
71'
72@phan-var-force int $date_start
73@phan-var-force int $date_end
74@phan-var-force int $date_start_month
75@phan-var-force int $date_start_year
76@phan-var-force int $date_start_day
77@phan-var-force int $date_end_month
78@phan-var-force int $date_end_year
79@phan-var-force int $date_end_day
80@phan-var-force int $year_current
81';
82
83$min = price2num(GETPOST("min", "alpha"));
84if (empty($min)) {
85 $min = 0;
86}
87
88// Define modetax (0 or 1)
89// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
90//$modetax = $conf->global->TAX_MODE;
91$calc = getDolGlobalString('MAIN_INFO_LOCALTAX_CALC').$local;
92$modetax = getDolGlobalInt('TAX_MODE');
93if (GETPOSTISSET("modetax")) {
94 $modetax = GETPOSTINT("modetax");
95}
96if (empty($modetax)) {
97 $modetax = 0;
98}
99
100// Security check
101$socid = GETPOSTINT('socid');
102if ($user->socid) {
103 $socid = $user->socid;
104}
105$result = restrictedArea($user, 'tax', '', '', 'charges');
106
107if (empty($local)) {
108 accessforbidden('Parameter localTaxType is missing');
109}
110
111
112
113/*
114 * View
115 */
116
117$form = new Form($db);
118$company_static = new Societe($db);
119$invoice_customer = new Facture($db);
120$invoice_supplier = new FactureFournisseur($db);
121$expensereport = new ExpenseReport($db);
122$product_static = new Product($db);
123$payment_static = new Paiement($db);
124$paymentfourn_static = new PaiementFourn($db);
125$paymentexpensereport_static = new PaymentExpenseReport($db);
126
127$morequerystring = '';
128$listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday');
129foreach ($listofparams as $param) {
130 if (GETPOST($param) != '') {
131 $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOSTINT($param);
132 }
133}
134
135llxHeader('', $langs->trans("LocalTaxReport"), '', '', 0, 0, '', '', $morequerystring);
136
137$fsearch = '<!-- hidden fields for form -->';
138$fsearch .= '<input type="hidden" name="token" value="'.newToken().'">';
139$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
140$fsearch .= '<input type="hidden" name="localTaxType" value="'.$local.'">';
141
142$name = $langs->transcountry($local == 1 ? "LT1ReportByQuarters" : "LT2ReportByQuarters", $mysoc->country_code);
143$calcmode = '';
144if ($modetax == 0) {
145 $calcmode = $langs->trans('OptionVATDefault');
146}
147if ($modetax == 1) {
148 $calcmode = $langs->trans('OptionVATDebitOption');
149}
150if ($modetax == 2) {
151 $calcmode = $langs->trans('OptionPaymentForProductAndServices');
152}
153$calcmode .= ' <span class="opacitymedium">('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')</span>';
154// Set period
155$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
156
157$description = $fsearch;
158$builddate = dol_now();
159
160/*if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
161if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') $description.=$langs->trans("RulesVATInProducts");
162if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
163if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
164if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
165 $description.='<br>'.$langs->trans("DepositsAreNotIncluded");
166}
167if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
168 $description.='<br>'.$langs->trans("SupplierDepositsAreNotIncluded");
169}
170*/
171if (isModEnabled('accounting')) {
172 $description .= $langs->trans("ThisIsAnEstimatedValue");
173}
174
175// Customers invoices
176$elementcust = $langs->trans("CustomersInvoices");
177$productcust = $langs->trans("ProductOrService");
178$amountcust = $langs->trans("AmountHT");
179$vatcust = $langs->trans("VATReceived");
180$namecust = $langs->trans("Name");
181if ($mysoc->tva_assuj) {
182 $vatcust .= ' ('.$langs->trans("StatusToPay").')';
183}
184
185// Suppliers invoices
186$elementsup = $langs->trans("SuppliersInvoices");
187$productsup = $productcust;
188$amountsup = $amountcust;
189$vatsup = $langs->trans("VATPaid");
190$namesup = $namecust;
191if ($mysoc->tva_assuj) {
192 $vatsup .= ' ('.$langs->trans("ToGetBack").')';
193}
194
195$periodlink = '';
196$exportlink = '';
197
198report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
199
200if ($local == 1) {
201 $vatcust = $langs->transcountry("LT1", $mysoc->country_code);
202 $vatsup = $langs->transcountry("LT1", $mysoc->country_code);
203 $vatexpensereport = $langs->transcountry("LT1", $mysoc->country_code);
204} else {
205 $vatcust = $langs->transcountry("LT2", $mysoc->country_code);
206 $vatsup = $langs->transcountry("LT2", $mysoc->country_code);
207 $vatexpensereport = $langs->transcountry("LT2", $mysoc->country_code);
208}
209
210// VAT Received and paid
211print '<div class="div-table-responsive">';
212echo '<table class="noborder centpercent">';
213
214$y = $year_current;
215$total = 0;
216$i = 0;
217$columns = 4;
218
219// Load arrays of datas
220$x_coll = tax_by_rate('localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
221$x_paye = tax_by_rate('localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
222
223if (!is_array($x_coll) || !is_array($x_paye)) {
224 $langs->load("errors");
225 if ($x_coll == -1) {
226 print '<tr><td colspan="'.$columns.'">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
227 } elseif ($x_coll == -2) {
228 print '<tr><td colspan="'.$columns.'">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
229 } else {
230 print '<tr><td colspan="'.$columns.'">'.$langs->trans("Error").'</td></tr>';
231 }
232} else {
233 $x_both = array();
234
235 //now, from these two arrays, get another array with one rate per line
236 foreach (array_keys($x_coll) as $my_coll_rate) {
237 $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
238 $x_both[$my_coll_rate]['coll']['localtax'.$local] = $x_coll[$my_coll_rate]['localtax'.$local];
239 $x_both[$my_coll_rate]['paye']['totalht'] = 0;
240 $x_both[$my_coll_rate]['paye']['localtax'.$local] = 0;
241 $x_both[$my_coll_rate]['coll']['links'] = '';
242 $x_both[$my_coll_rate]['coll']['detail'] = array();
243 foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) {
244 $invoice_customer->id = $x_coll[$my_coll_rate]['facid'][$id];
245 $invoice_customer->ref = $x_coll[$my_coll_rate]['facnum'][$id];
246 $invoice_customer->type = $x_coll[$my_coll_rate]['type'][$id];
247 $company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
248 $x_both[$my_coll_rate]['coll']['detail'][] = array(
249 'id' => $x_coll[$my_coll_rate]['facid'][$id],
250 'descr' => $x_coll[$my_coll_rate]['descr'][$id],
251 'pid' => $x_coll[$my_coll_rate]['pid'][$id],
252 'pref' => $x_coll[$my_coll_rate]['pref'][$id],
253 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id],
254 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id],
255 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id],
256 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id],
257 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id],
258 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id],
259 'datef' => $x_coll[$my_coll_rate]['datef'][$id],
260 'datep' => $x_coll[$my_coll_rate]['datep'][$id],
261 'company_link' => $company_static->getNomUrl(1, '', 20),
262 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id],
263 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id],
264 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id],
265 'localtax1' => $x_coll[$my_coll_rate]['localtax1_list'][$id],
266 'localtax2' => $x_coll[$my_coll_rate]['localtax2_list'][$id],
267 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id],
268 'link' => $invoice_customer->getNomUrl(1, '', 12)
269 );
270 }
271 }
272 // tva paid
273 foreach (array_keys($x_paye) as $my_paye_rate) {
274 $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
275 $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
276 if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
277 $x_both[$my_paye_rate]['coll']['totalht'] = 0;
278 $x_both[$my_paye_rate]['coll']['vat'] = 0;
279 }
280 $x_both[$my_paye_rate]['paye']['links'] = '';
281 $x_both[$my_paye_rate]['paye']['detail'] = array();
282
283 foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) {
284 $invoice_supplier->id = $x_paye[$my_paye_rate]['facid'][$id];
285 $invoice_supplier->ref = $x_paye[$my_paye_rate]['facnum'][$id];
286 $invoice_supplier->type = $x_paye[$my_paye_rate]['type'][$id];
287 $x_both[$my_paye_rate]['paye']['detail'][] = array(
288 'id' => $x_paye[$my_paye_rate]['facid'][$id],
289 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
290 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
291 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
292 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
293 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
294 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
295 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
296 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
297 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
298 'datef' => $x_paye[$my_paye_rate]['datef'][$id],
299 'datep' => $x_paye[$my_paye_rate]['datep'][$id],
300 'company_link' => $company_static->getNomUrl(1, '', 20),
301 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
302 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
303 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
304 'localtax1' => $x_paye[$my_paye_rate]['localtax1_list'][$id],
305 'localtax2' => $x_paye[$my_paye_rate]['localtax2_list'][$id],
306 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
307 'link' => $invoice_supplier->getNomUrl(1, '', 12)
308 );
309 }
310 }
311 //now we have an array (x_both) indexed by rates for coll and paye
312
313 //print table headers for this quadri - incomes first
314
315 $x_coll_sum = 0;
316 $x_coll_ht = 0;
317 $x_paye_sum = 0;
318 $x_paye_ht = 0;
319
320 $span = $columns - 1;
321 if ($modetax != 2) {
322 $span += 1;
323 }
324 if ($modetax != 1) {
325 $span += 1;
326 }
327
328 // Customers invoices
329 print '<tr class="liste_titre">';
330 print '<td class="left">'.$elementcust.'</td>';
331 print '<td class="left">'.$productcust.'</td>';
332 if ($modetax != 2) {
333 print '<td class="right">'.$amountcust.'</td>';
334 }
335 if ($modetax != 1) {
336 print '<td class="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
337 }
338 print '<td class="right">'.$langs->trans("BI").'</td>';
339 print '<td class="right">'.$vatcust.'</td>';
340 print '</tr>';
341
342
343 $LT = 0;
344 $sameLT = false;
345 foreach (array_keys($x_coll) as $rate) {
346 $subtot_coll_total_ht = 0;
347 $subtot_coll_vat = 0;
348
349 if (is_array($x_both[$rate]['coll']['detail'])) {
350 // VAT Rate
351 if ($rate != 0) {
352 print "<tr>";
353 print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
354 print '</tr>'."\n";
355 }
356 foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
357 if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0)) {
358 // Define type
359 $type = ($fields['dtype'] ? $fields['dtype'] : $fields['ptype']);
360 // Try to enhance type detection using date_start and date_end for free lines where type was not saved.
361 if (!empty($fields['ddate_start'])) {
362 $type = 1;
363 }
364 if (!empty($fields['ddate_end'])) {
365 $type = 1;
366 }
367
368
369 print '<tr class="oddeven">';
370
371 // Ref
372 print '<td class="nowrap left">'.$fields['link'].'</td>';
373
374 // Description
375 print '<td class="left">';
376 if ($fields['pid']) {
377 $product_static->id = $fields['pid'];
378 $product_static->ref = $fields['pref'];
379 $product_static->type = $fields['ptype'];
380 print $product_static->getNomUrl(1);
381 if (dol_string_nohtmltag($fields['descr'])) {
382 print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
383 }
384 } else {
385 if ($type) {
386 $text = img_object($langs->trans('Service'), 'service');
387 } else {
388 $text = img_object($langs->trans('Product'), 'product');
389 }
390 if (preg_match('/^\‍((.*)\‍)$/', $fields['descr'], $reg)) {
391 if ($reg[1] == 'DEPOSIT') {
392 $fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
393 } elseif ($reg[1] == 'CREDIT_NOTE') {
394 $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
395 } else {
396 $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
397 }
398 }
399 print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
400
401 // Show range
402 print_date_range($fields['ddate_start'], $fields['ddate_end']);
403 }
404 print '</td>';
405
406 // Total HT
407 if ($modetax != 2) {
408 print '<td class="nowrap right">';
409 print price($fields['totalht']);
410 if (price2num($fields['ftotal_ttc'])) {
411 $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
412 }
413 print '</td>';
414 }
415
416 // Payment
417 $ratiopaymentinvoice = 1;
418 if ($modetax != 1) {
419 if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
420 $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
421 }
422 print '<td class="nowrap right">';
423 if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
424 $payment_static->id = $fields['payment_id'];
425 print $payment_static->getNomUrl(2);
426 }
427 if ($type == 0) {
428 print $langs->trans("NotUsedForGoods");
429 } else {
430 print price($fields['payment_amount']);
431 if (isset($fields['payment_amount'])) {
432 print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
433 }
434 }
435 print '</td>';
436 }
437
438 // Total collected
439 print '<td class="nowrap right">';
440 $temp_ht = $fields['totalht'];
441 if ($type == 1) {
442 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
443 }
444 print price(price2num($temp_ht, 'MT'));
445 print '</td>';
446
447 // Localtax
448 print '<td class="nowrap right">';
449 $temp_vat = $local == 1 ? $fields['localtax1'] : $fields['localtax2'];
450 print price(price2num($temp_vat, 'MT'));
451 //print price($fields['vat']);
452 print '</td>';
453 print '</tr>';
454
455 $subtot_coll_total_ht += $temp_ht;
456 $subtot_coll_vat += $temp_vat;
457 $x_coll_sum += $temp_vat;
458 }
459 }
460 }
461
462 // Total customers for this vat rate
463 print '<tr class="liste_total">';
464 print '<td></td>';
465 print '<td class="right">'.$langs->trans("Total").':</td>';
466 if ($modetax != 1) {
467 print '<td class="nowrap right">&nbsp;</td>';
468 print '<td class="right">&nbsp;</td>';
469 }
470 print '<td class="right"><span class="amount">'.price(price2num($subtot_coll_total_ht, 'MT')).'</span></td>';
471 print '<td class="nowrap right"><span class="amount">'.price(price2num($subtot_coll_vat, 'MT')).'</span></td>';
472 print '</tr>';
473 }
474
475 if (count($x_coll) == 0) { // Show a total line if nothing shown
476 print '<tr class="liste_total">';
477 print '<td>&nbsp;</td>';
478 print '<td class="right">'.$langs->trans("Total").':</td>';
479 if ($modetax == 0) {
480 print '<td class="nowrap right">&nbsp;</td>';
481 print '<td class="right">&nbsp;</td>';
482 }
483 print '<td class="right"><span class="amount">'.price(price2num(0, 'MT')).'</span></td>';
484 print '<td class="nowrap right"><span class="amount">'.price(price2num(0, 'MT')).'</span></td>';
485 print '</tr>';
486 }
487
488 // Blank line
489 print '<tr><td colspan="'.($span + 1).'">&nbsp;</td></tr>';
490 //print '</table>';
491 $diff = $x_coll_sum;
492
493 //echo '<table class="noborder centpercent">';
494 //print table headers for this quadri - expenses now
495 print '<tr class="liste_titre">';
496 print '<td class="left">'.$elementsup.'</td>';
497 print '<td class="left">'.$productsup.'</td>';
498 if ($modetax != 1) {
499 print '<td class="right">'.$amountsup.'</td>';
500 print '<td class="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
501 }
502 print '<td class="right">'.$langs->trans("BI").'</td>';
503 print '<td class="right">'.$vatsup.'</td>';
504 print '</tr>'."\n";
505
506 foreach (array_keys($x_paye) as $rate) {
507 $subtot_paye_total_ht = 0;
508 $subtot_paye_vat = 0;
509
510 if (is_array($x_both[$rate]['paye']['detail'])) {
511 if ($rate != 0) {
512 print "<tr>";
513 print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
514 print '</tr>'."\n";
515 }
516 foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) {
517 if (($local == 1 && $fields['localtax1'] != 0) || ($local == 2 && $fields['localtax2'] != 0)) {
518 // Define type
519 $type = ($fields['dtype'] ? $fields['dtype'] : $fields['ptype']);
520 // Try to enhance type detection using date_start and date_end for free lines where type was not saved.
521 if (!empty($fields['ddate_start'])) {
522 $type = 1;
523 }
524 if (!empty($fields['ddate_end'])) {
525 $type = 1;
526 }
527
528
529 print '<tr class="oddeven">';
530
531 // Ref
532 print '<td class="nowrap left">'.$fields['link'].'</td>';
533
534 // Description
535 print '<td class="left">';
536 if ($fields['pid']) {
537 $product_static->id = $fields['pid'];
538 $product_static->ref = $fields['pref'];
539 $product_static->type = $fields['ptype'];
540 print $product_static->getNomUrl(1);
541 if (dol_string_nohtmltag($fields['descr'])) {
542 print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
543 }
544 } else {
545 if ($type) {
546 $text = img_object($langs->trans('Service'), 'service');
547 } else {
548 $text = img_object($langs->trans('Product'), 'product');
549 }
550 print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
551
552 // Show range
553 print_date_range($fields['ddate_start'], $fields['ddate_end']);
554 }
555 print '</td>';
556
557 // Total HT
558 if ($modetax != 2) {
559 print '<td class="nowrap right">';
560 print price($fields['totalht']);
561 if (price2num($fields['ftotal_ttc'])) {
562 //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
563 $ratiolineinvoice = ((float) $fields['dtotal_ttc'] / (float) $fields['ftotal_ttc']);
564 //print ' ('.round($ratiolineinvoice*100,2).'%)';
565 }
566 print '</td>';
567 }
568
569 // Payment
570 $ratiopaymentinvoice = 1;
571 if ($modetax != 1) {
572 print '<td class="nowrap right">';
573 if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
574 $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']);
575 }
576 if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
577 $paymentfourn_static->id = $fields['payment_id'];
578 print $paymentfourn_static->getNomUrl(2);
579 }
580 if ($type == 0) {
581 print $langs->trans("NA");
582 } else {
583 print price(price2num($fields['payment_amount'], 'MT'));
584 if (isset($fields['payment_amount'])) {
585 print ' ('.round($ratiopaymentinvoice * 100, 2).'%)';
586 }
587 }
588 print '</td>';
589 }
590
591 // VAT paid
592 print '<td class="nowrap right">';
593 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
594 print price(price2num($temp_ht, 'MT'), 1);
595 print '</td>';
596
597 // Localtax
598 print '<td class="nowrap right">';
599 $temp_vat = ($local == 1 ? $fields['localtax1'] : $fields['localtax2']) * $ratiopaymentinvoice;
600 print price(price2num($temp_vat, 'MT'), 1);
601 //print price($fields['vat']);
602 print '</td>';
603 print '</tr>';
604
605 $subtot_paye_total_ht += $temp_ht;
606 $subtot_paye_vat += $temp_vat;
607 $x_paye_sum += $temp_vat;
608 }
609 }
610 }
611
612 // Total suppliers for this vat rate
613 print '<tr class="liste_total">';
614 print '<td>&nbsp;</td>';
615 print '<td class="right">'.$langs->trans("Total").':</td>';
616 if ($modetax != 1) {
617 print '<td class="nowrap right">&nbsp;</td>';
618 print '<td class="right">&nbsp;</td>';
619 }
620 print '<td class="right"><span class="amount">'.price(price2num($subtot_paye_total_ht, 'MT')).'</span></td>';
621 print '<td class="nowrap right"><span class="amount">'.price(price2num($subtot_paye_vat, 'MT')).'</span></td>';
622 print '</tr>';
623 }
624
625 if (count($x_paye) == 0) { // Show a total line if nothing shown
626 print '<tr class="liste_total">';
627 print '<td>&nbsp;</td>';
628 print '<td class="right">'.$langs->trans("Total").':</td>';
629 if ($modetax != 1) {
630 print '<td class="nowrap right">&nbsp;</td>';
631 print '<td class="right">&nbsp;</td>';
632 }
633 print '<td class="right"><span class="amount">'.price(price2num(0, 'MT')).'</span></td>';
634 print '<td class="nowrap right"><span class="amount">'.price(price2num(0, 'MT')).'</span></td>';
635 print '</tr>';
636 }
637
638 // Total to pay
639 $diff = $x_coll_sum - $x_paye_sum;
640 print '<tr class="liste_total">';
641 print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").'</td>';
642 print '<td class="liste_total nowrap right"><b>'.price(price2num($diff, 'MT'))."</b></td>\n";
643 print "</tr>\n";
644
645 $i++;
646}
647
648print '</table>';
649print '</div>';
650
651// End of page
652llxFooter();
653$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of expense report.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
global $mysoc
dol_now($mode='gmt')
Return date for now.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
Gets Tax to collect for the given year (and given quarter or month) The function gets the Tax in spli...
Definition tax.lib.php:669