dolibarr 24.0.0-beta
index.php
Go to the documentation of this file.
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-2018 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
7 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
9 * Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
10 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
31require '../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
48
49$now = dol_now();
50
51$refresh = GETPOSTISSET('submit') ? true : false;
52$year_current = GETPOSTISSET('year') ? GETPOSTINT('year') : dol_print_date($now, '%Y', 'tzserver');
53$year_start = $year_current;
54$month_current = GETPOSTISSET('month') ? GETPOSTINT('month') : dol_print_date($now, '%m', 'tzserver');
55$month_start = $month_current;
56
57$refresh = true;
58
59include DOL_DOCUMENT_ROOT.'/compta/tva/initdatesforvat.inc.php';
73'
74@phan-var-force int $date_start
75@phan-var-force int $date_end
76@phan-var-force string $date_start_month
77@phan-var-force string $date_start_year
78@phan-var-force string $date_start_day
79@phan-var-force string $date_end_month
80@phan-var-force string $date_end_year
81@phan-var-force string $date_end_day
82';
83
84// Define modetax (0 or 1)
85// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
86$modetax = getDolGlobalString('TAX_MODE');
87if (GETPOSTISSET("modetax")) {
88 $modetax = GETPOSTINT("modetax");
89}
90if (empty($modetax)) {
91 $modetax = 0;
92}
93
94// Security check
95$socid = GETPOSTINT('socid');
96if ($user->socid) {
97 $socid = $user->socid;
98}
99$result = restrictedArea($user, 'tax', '', 'tva', 'charges');
100
101
110function pt($db, $sql, $date)
111{
112 global $conf, $bc, $langs, $form;
113
114 $result = $db->query($sql);
115 if ($result) {
116 $num = $db->num_rows($result);
117 $i = 0;
118 $total = 0;
119 print '<table class="noborder centpercent">';
120
121 print '<tr class="liste_titre">';
122 print '<td class="nowrap">'.$date.'</td>';
123 print '<td class="right">'.$langs->trans("ClaimedForThisPeriod").'</td>';
124 print '<td class="right">'.$langs->trans("PaidDuringThisPeriod").$form->textwithpicto('', $langs->trans('PaidDuringThisPeriodDesc'), 1).'</td>';
125 print "</tr>\n";
126
127 $totalclaimed = 0;
128 $totalpaid = 0;
129 $amountclaimed = 0;
130 $amountpaid = 0;
131 $previousmonth = '';
132 $previousmode = '';
133 $mode = '';
134
135 while ($i < $num) {
136 $obj = $db->fetch_object($result);
137 $mode = $obj->mode;
138
139 //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
140 if ($obj->mode == 'claimed' && !empty($previousmode)) {
141 print '<tr class="oddeven">';
142 print '<td class="nowrap">'.$previousmonth."</td>\n";
143 print '<td class="nowrap right"><span class="amount">'.price($amountclaimed)."</span></td>\n";
144 print '<td class="nowrap right"><span class="amount">'.price($amountpaid)."</span></td>\n";
145 print "</tr>\n";
146
147 $amountclaimed = 0;
148 $amountpaid = 0;
149 }
150
151 if ($obj->mode == 'claimed') {
152 $amountclaimed = $obj->mm;
153 $totalclaimed += $amountclaimed;
154 }
155 if ($obj->mode == 'paid') {
156 $amountpaid = $obj->mm;
157 $totalpaid += $amountpaid;
158 }
159
160 if ($obj->mode == 'paid') {
161 print '<tr class="oddeven">';
162 print '<td class="nowrap">'.$obj->dm."</td>\n";
163 print '<td class="nowrap right"><span class="amount">'.price($amountclaimed)."</span></td>\n";
164 print '<td class="nowrap right"><span class="amount">'.price($amountpaid)."</span></td>\n";
165 print "</tr>\n";
166 $amountclaimed = 0;
167 $amountpaid = 0;
168 $previousmode = '';
169 $previousmonth = '';
170 } else {
171 $previousmode = $obj->mode;
172 $previousmonth = $obj->dm;
173 }
174
175 $i++;
176 }
177
178 if ($mode == 'claimed' && !empty($previousmode)) {
179 print '<tr class="oddeven">';
180 print '<td class="nowrap">'.$previousmonth."</td>\n";
181 print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
182 print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
183 print "</tr>\n";
184
185 $amountclaimed = 0;
186 $amountpaid = 0;
187 }
188
189 print '<tr class="liste_total">';
190 print '<td class="right">'.$langs->trans("Total").'</td>';
191 print '<td class="nowrap right">'.price($totalclaimed).'</td>';
192 print '<td class="nowrap right">'.price($totalpaid).'</td>';
193 print "</tr>";
194
195 print "</table>";
196
197 $db->free($result);
198 } else {
200 }
201}
202
203
204/*
205 * View
206 */
207
208$form = new Form($db);
209$company_static = new Societe($db);
210$tva = new Tva($db);
211
212$fsearch = '<!-- hidden fields for form -->';
213$fsearch .= '<input type="hidden" name="token" value="'.newToken().'">';
214$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
215
216$description = $fsearch;
217
218// Show report header
219$name = $langs->trans("VATReportByMonth");
220$calcmode = '';
221if ($modetax == 0) {
222 $calcmode = $langs->trans('OptionVATDefault');
223}
224if ($modetax == 1) {
225 $calcmode = $langs->trans('OptionVATDebitOption');
226}
227if ($modetax == 2) {
228 $calcmode = $langs->trans('OptionPaymentForProductAndServices');
229}
230$calcmode .= ' <span class="opacitymedium">('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')</span>';
231
232$description .= $langs->trans("VATSummary").'<br>';
233if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') {
234 $description .= $langs->trans("RulesVATDueProducts");
235}
236if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') {
237 $description .= $langs->trans("RulesVATInProducts");
238}
239if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') {
240 $description .= '<br>'.$langs->trans("RulesVATDueServices");
241}
242if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') {
243 $description .= '<br>'.$langs->trans("RulesVATInServices");
244}
245if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
246 $description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
247}
248if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
249 $description .= $langs->trans("SupplierDepositsAreNotIncluded");
250}
251if (isModEnabled('accounting')) {
252 $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
253}
254
255$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
256
257$builddate = dol_now();
258
259
260llxHeader('', $name);
261
262//$textprevyear="<a href=\"index.php?year=" . ($year_current-1) . "\">".img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a>";
263//$textnextyear=" <a href=\"index.php?year=" . ($year_current+1) . "\">".img_next($langs->trans("Next"), 'class="valignbottom"')."</a>";
264//print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'bill');
265
266$periodlink = '';
267$exportlink = '';
268
269report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
270//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode);
271
272
273print '<br>';
274
275if ($refresh === true) {
276 print '<div class="fichecenter"><div class="fichethirdleft">';
277
278 print load_fiche_titre($langs->trans("VATSummary"), '', '');
279
280 print '<table class="noborder centpercent">';
281 print '<tr class="liste_titre">';
282 print '<td width="30%">' . $langs->trans("Year") . '</td>';
283 print '<td class="right">' . $langs->trans("VATToPay") . '</td>';
284 print '<td class="right">' . $langs->trans("VATToCollect") . '</td>';
285 print '<td class="right">' . $langs->trans("Balance") . '</td>';
286 print '<td>&nbsp;</td>' . "\n";
287 print '</tr>' . "\n";
288
289 $tmp = dol_getdate($date_start);
290 $y = $tmp['year'];
291 $m = $tmp['mon'];
292 $tmp = dol_getdate($date_end);
293 $yend = $tmp['year'];
294 $mend = $tmp['mon'];
295 //var_dump($m);
296 $total = 0;
297 $subtotalcoll = 0;
298 $subtotalpaid = 0;
299 $subtotal = 0;
300 $i = 0;
301 $mcursor = 0;
302
303 while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $mcursor is to avoid too large loop
304 //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12);
305 if ($m == 13) {
306 $y++;
307 }
308 if ($m > 12) {
309 $m -= 12;
310 }
311 $mcursor++;
312
313 $x_coll = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m);
314 $x_paye = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m);
315
316 $x_both = array();
317 //now, from these two arrays, get another array with one rate per line
318 foreach (array_keys($x_coll) as $my_coll_rate) {
319 $x_both[$my_coll_rate] = array(
320 'coll' => array(),
321 'paye' => array(),
322 'detail' => array(),
323 'ptype' => array(),
324 );
325 $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
326 $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
327 $x_both[$my_coll_rate]['paye']['totalht'] = 0;
328 $x_both[$my_coll_rate]['paye']['vat'] = 0;
329 $x_both[$my_coll_rate]['coll']['links'] = '';
330 $x_both[$my_coll_rate]['coll']['detail'] = array();
331 foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) {
332 //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
333 //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
334 //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
335 //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
336 $x_both[$my_coll_rate]['coll']['detail'][] = array(
337 'id' => $x_coll[$my_coll_rate]['facid'][$id],
338 'descr' => $x_coll[$my_coll_rate]['descr'][$id],
339 'pid' => $x_coll[$my_coll_rate]['pid'][$id],
340 'pref' => $x_coll[$my_coll_rate]['pref'][$id],
341 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id],
342 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id],
343 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id],
344 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id],
345 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id],
346 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id],
347 'datef' => $x_coll[$my_coll_rate]['datef'][$id],
348 'datep' => $x_coll[$my_coll_rate]['datep'][$id],
349 //'company_link'=>$company_static->getNomUrl(1,'',20),
350 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id],
351 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id],
352 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id],
353 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id],
354 //'link' =>$invoice_customer->getNomUrl(1,'',12)
355 );
356 }
357 }
358
359 // tva paid
360 foreach (array_keys($x_paye) as $my_paye_rate) {
361 $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
362 $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
363 if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
364 $x_both[$my_paye_rate]['coll']['totalht'] = 0;
365 $x_both[$my_paye_rate]['coll']['vat'] = 0;
366 }
367 $x_both[$my_paye_rate]['paye']['links'] = '';
368 $x_both[$my_paye_rate]['paye']['detail'] = array();
369
370 foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) {
371 // ExpenseReport
372 if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') {
373 //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id];
374 //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id];
375 //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id];
376
377 $x_both[$my_paye_rate]['paye']['detail'][] = array(
378 'id' => $x_paye[$my_paye_rate]['facid'][$id],
379 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
380 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
381 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
382 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
383 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
384 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
385 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
386 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
387 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
388 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
389 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
390 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
391 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
392 //'link' =>$expensereport->getNomUrl(1)
393 );
394 } else {
395 //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
396 //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
397 //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
398 //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
399 $x_both[$my_paye_rate]['paye']['detail'][] = array(
400 'id' => $x_paye[$my_paye_rate]['facid'][$id],
401 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
402 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
403 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
404 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
405 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
406 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
407 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
408 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
409 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
410 'datef' => $x_paye[$my_paye_rate]['datef'][$id],
411 'datep' => $x_paye[$my_paye_rate]['datep'][$id],
412 //'company_link'=>$company_static->getNomUrl(1,'',20),
413 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
414 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
415 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
416 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
417 //'link' =>$invoice_supplier->getNomUrl(1,'',12)
418 );
419 }
420 }
421 }
422 //now we have an array (x_both) indexed by rates for coll and paye
423
424 $action = "tva";
425 $object = array(&$x_coll, &$x_paye, &$x_both);
426 $parameters = array();
427 $parameters["mode"] = $modetax;
428 $parameters["year"] = $y;
429 $parameters["month"] = $m;
430 $parameters["type"] = 'vat';
431
432 // Initialize a technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
433 $hookmanager->initHooks(array('externalbalance'));
434 $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
435
436
437 print '<tr class="oddeven">';
438 print '<td class="nowrap"><a href="' . DOL_URL_ROOT . '/compta/tva/quadri_detail.php?leftmenu=tax_vat&month=' . $m . '&year=' . $y . '">' . dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y") . '</a></td>';
439
440 $x_coll_sum = 0;
441 foreach (array_keys($x_coll) as $rate) {
442 $subtot_coll_total_ht = 0;
443 $subtot_coll_vat = 0;
444
445 foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
446 // Payment
447 $ratiopaymentinvoice = 1;
448 if ($modetax != 1) {
449 // Define type
450 // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
451 $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
452 // Try to enhance type detection using date_start and date_end for free lines where type was not saved.
453 if (!empty($fields['ddate_start'])) {
454 $type = 1;
455 }
456 if (!empty($fields['ddate_end'])) {
457 $type = 1;
458 }
459
460 if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice')
461 || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) {
462 //print $langs->trans("NA");
463 } else {
464 if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
465 $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
466 }
467 }
468 }
469 //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
470 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
471 $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
472 $subtot_coll_total_ht += $temp_ht;
473 $subtot_coll_vat += $temp_vat;
474 $x_coll_sum += $temp_vat;
475 }
476 }
477 print '<td class="nowrap right"><span class="amount">' . price(price2num($x_coll_sum, 'MT')) . '</span></td>';
478
479 $x_paye_sum = 0;
480 foreach (array_keys($x_paye) as $rate) {
481 $subtot_paye_total_ht = 0;
482 $subtot_paye_vat = 0;
483
484 foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) {
485 // Payment
486 $ratiopaymentinvoice = 1;
487 if ($modetax != 1) {
488 // Define type
489 // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
490 $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
491 // Try to enhance type detection using date_start and date_end for free lines where type was not saved.
492 if (!empty($fields['ddate_start'])) {
493 $type = 1;
494 }
495 if (!empty($fields['ddate_end'])) {
496 $type = 1;
497 }
498
499 if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice')
500 || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) {
501 //print $langs->trans("NA");
502 } else {
503 if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
504 $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']);
505 }
506 }
507 }
508 //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
509 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
510 $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
511 $subtot_paye_total_ht += $temp_ht;
512 $subtot_paye_vat += $temp_vat;
513 $x_paye_sum += $temp_vat;
514 }
515 }
516 print '<td class="nowrap right"><span class="amount">' . price(price2num($x_paye_sum, 'MT')) . '</span></td>';
517
518 $subtotalcoll += $x_coll_sum;
519 $subtotalpaid += $x_paye_sum;
520
521 $diff = $x_coll_sum - $x_paye_sum;
522 $total += $diff;
523 $subtotal = price2num($subtotal + $diff, 'MT');
524
525 print '<td class="nowrap right"><span class="amount">' . price(price2num($diff, 'MT')) . '</span></td>' . "\n";
526 print "<td>&nbsp;</td>\n";
527 print "</tr>\n";
528
529 // Total
530 $i++;
531 $m++;
532 if ($i > 2) {
533 print '<tr class="liste_total">';
534 print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q=' . round($m / 3) . '&year=' . $y . '">' . $langs->trans("SubTotal") . '</a>:</td>';
535 print '<td class="nowrap right">' . price(price2num($subtotalcoll, 'MT')) . '</td>';
536 print '<td class="nowrap right">' . price(price2num($subtotalpaid, 'MT')) . '</td>';
537 print '<td class="nowrap right">' . price(price2num($subtotal, 'MT')) . '</td>';
538 print '<td>&nbsp;</td></tr>';
539 $i = 0;
540 $subtotalcoll = 0;
541 $subtotalpaid = 0;
542 $subtotal = 0;
543 }
544 }
545 print '<tr class="liste_total"><td class="right" colspan="3">' . $langs->trans("TotalToPay") . ':</td><td class="nowrap right">' . price(price2num($total, 'MT')) . '</td>';
546 print "<td>&nbsp;</td>\n";
547 print '</tr>';
548
549 print '</table>';
550
551
552 print '</div><div class="fichetwothirdright">';
553
554
555 /*
556 * Paid
557 */
558 print load_fiche_titre($langs->trans("VATPaid"), '', '');
559
560 $sql = '';
561
562 $sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode";
563 $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
564 $sql .= " WHERE tva.entity = " . $conf->entity;
565 $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
566 $sql .= " GROUP BY dm";
567
568 $sql .= " UNION ";
569
570 $sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode";
571 $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
572 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_vat as ptva ON (tva.rowid = ptva.fk_tva)";
573 $sql .= " WHERE tva.entity = " . $conf->entity;
574 $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
575 $sql .= " GROUP BY dm";
576
577 $sql .= " ORDER BY dm ASC, mode ASC";
578 //print $sql;
579
580 pt($db, $sql, $langs->trans("Month"));
581
582 print '</div>';
583}
584
585llxFooter();
586$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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 generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage VAT - Value-added tax (also known in French as TVA)
Definition tva.class.php:39
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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.
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