dolibarr 21.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 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';
60'
61@phan-var-force int $date_start
62@phan-var-force int $date_end
63@phan-var-force string $date_start_month
64@phan-var-force string $date_start_year
65@phan-var-force string $date_start_day
66@phan-var-force string $date_end_month
67@phan-var-force string $date_end_year
68@phan-var-force string $date_end_day
69';
70
71// Define modetax (0 or 1)
72// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
73$modetax = getDolGlobalString('TAX_MODE');
74if (GETPOSTISSET("modetax")) {
75 $modetax = GETPOSTINT("modetax");
76}
77if (empty($modetax)) {
78 $modetax = 0;
79}
80
81// Security check
82$socid = GETPOSTINT('socid');
83if ($user->socid) {
84 $socid = $user->socid;
85}
86$result = restrictedArea($user, 'tax', '', 'tva', 'charges');
87
88
97function pt($db, $sql, $date)
98{
99 global $conf, $bc, $langs, $form;
100
101 $result = $db->query($sql);
102 if ($result) {
103 $num = $db->num_rows($result);
104 $i = 0;
105 $total = 0;
106 print '<table class="noborder centpercent">';
107
108 print '<tr class="liste_titre">';
109 print '<td class="nowrap">'.$date.'</td>';
110 print '<td class="right">'.$langs->trans("ClaimedForThisPeriod").'</td>';
111 print '<td class="right">'.$langs->trans("PaidDuringThisPeriod").$form->textwithpicto('', $langs->trans('PaidDuringThisPeriodDesc'), 1).'</td>';
112 print "</tr>\n";
113
114 $totalclaimed = 0;
115 $totalpaid = 0;
116 $amountclaimed = 0;
117 $amountpaid = 0;
118 $previousmonth = '';
119 $previousmode = '';
120 $mode = '';
121
122 while ($i < $num) {
123 $obj = $db->fetch_object($result);
124 $mode = $obj->mode;
125
126 //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
127 if ($obj->mode == 'claimed' && !empty($previousmode)) {
128 print '<tr class="oddeven">';
129 print '<td class="nowrap">'.$previousmonth."</td>\n";
130 print '<td class="nowrap right"><span class="amount">'.price($amountclaimed)."</span></td>\n";
131 print '<td class="nowrap right"><span class="amount">'.price($amountpaid)."</span></td>\n";
132 print "</tr>\n";
133
134 $amountclaimed = 0;
135 $amountpaid = 0;
136 }
137
138 if ($obj->mode == 'claimed') {
139 $amountclaimed = $obj->mm;
140 $totalclaimed += $amountclaimed;
141 }
142 if ($obj->mode == 'paid') {
143 $amountpaid = $obj->mm;
144 $totalpaid += $amountpaid;
145 }
146
147 if ($obj->mode == 'paid') {
148 print '<tr class="oddeven">';
149 print '<td class="nowrap">'.$obj->dm."</td>\n";
150 print '<td class="nowrap right"><span class="amount">'.price($amountclaimed)."</span></td>\n";
151 print '<td class="nowrap right"><span class="amount">'.price($amountpaid)."</span></td>\n";
152 print "</tr>\n";
153 $amountclaimed = 0;
154 $amountpaid = 0;
155 $previousmode = '';
156 $previousmonth = '';
157 } else {
158 $previousmode = $obj->mode;
159 $previousmonth = $obj->dm;
160 }
161
162 $i++;
163 }
164
165 if ($mode == 'claimed' && !empty($previousmode)) {
166 print '<tr class="oddeven">';
167 print '<td class="nowrap">'.$previousmonth."</td>\n";
168 print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
169 print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
170 print "</tr>\n";
171
172 $amountclaimed = 0;
173 $amountpaid = 0;
174 }
175
176 print '<tr class="liste_total">';
177 print '<td class="right">'.$langs->trans("Total").'</td>';
178 print '<td class="nowrap right">'.price($totalclaimed).'</td>';
179 print '<td class="nowrap right">'.price($totalpaid).'</td>';
180 print "</tr>";
181
182 print "</table>";
183
184 $db->free($result);
185 } else {
186 dol_print_error($db);
187 }
188}
189
190
191/*
192 * View
193 */
194
195$form = new Form($db);
196$company_static = new Societe($db);
197$tva = new Tva($db);
198
199$fsearch = '<!-- hidden fields for form -->';
200$fsearch .= '<input type="hidden" name="token" value="'.newToken().'">';
201$fsearch .= '<input type="hidden" name="modetax" value="'.$modetax.'">';
202
203$description = $fsearch;
204
205// Show report header
206$name = $langs->trans("VATReportByMonth");
207$calcmode = '';
208if ($modetax == 0) {
209 $calcmode = $langs->trans('OptionVATDefault');
210}
211if ($modetax == 1) {
212 $calcmode = $langs->trans('OptionVATDebitOption');
213}
214if ($modetax == 2) {
215 $calcmode = $langs->trans('OptionPaymentForProductAndServices');
216}
217$calcmode .= ' <span class="opacitymedium">('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')</span>';
218
219$description .= $langs->trans("VATSummary").'<br>';
220if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') {
221 $description .= $langs->trans("RulesVATDueProducts");
222}
223if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'payment') {
224 $description .= $langs->trans("RulesVATInProducts");
225}
226if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice') {
227 $description .= '<br>'.$langs->trans("RulesVATDueServices");
228}
229if (getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'payment') {
230 $description .= '<br>'.$langs->trans("RulesVATInServices");
231}
232if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
233 $description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
234}
235if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) {
236 $description .= $langs->trans("SupplierDepositsAreNotIncluded");
237}
238if (isModEnabled('accounting')) {
239 $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
240}
241
242$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
243
244$builddate = dol_now();
245
246
247llxHeader('', $name);
248
249//$textprevyear="<a href=\"index.php?year=" . ($year_current-1) . "\">".img_previous($langs->trans("Previous"), 'class="valignbottom"')."</a>";
250//$textnextyear=" <a href=\"index.php?year=" . ($year_current+1) . "\">".img_next($langs->trans("Next"), 'class="valignbottom"')."</a>";
251//print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'bill');
252
253$periodlink = '';
254$exportlink = '';
255
256report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
257//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode);
258
259
260print '<br>';
261
262if ($refresh === true) {
263 print '<div class="fichecenter"><div class="fichethirdleft">';
264
265 print load_fiche_titre($langs->trans("VATSummary"), '', '');
266
267 print '<table class="noborder centpercent">';
268 print '<tr class="liste_titre">';
269 print '<td width="30%">' . $langs->trans("Year") . '</td>';
270 print '<td class="right">' . $langs->trans("VATToPay") . '</td>';
271 print '<td class="right">' . $langs->trans("VATToCollect") . '</td>';
272 print '<td class="right">' . $langs->trans("Balance") . '</td>';
273 print '<td>&nbsp;</td>' . "\n";
274 print '</tr>' . "\n";
275
276 $tmp = dol_getdate($date_start);
277 $y = $tmp['year'];
278 $m = $tmp['mon'];
279 $tmp = dol_getdate($date_end);
280 $yend = $tmp['year'];
281 $mend = $tmp['mon'];
282 //var_dump($m);
283 $total = 0;
284 $subtotalcoll = 0;
285 $subtotalpaid = 0;
286 $subtotal = 0;
287 $i = 0;
288 $mcursor = 0;
289
290 while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $mcursor is to avoid too large loop
291 //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12);
292 if ($m == 13) {
293 $y++;
294 }
295 if ($m > 12) {
296 $m -= 12;
297 }
298 $mcursor++;
299
300 $x_coll = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m);
301 $x_paye = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m);
302
303 $x_both = array();
304 //now, from these two arrays, get another array with one rate per line
305 foreach (array_keys($x_coll) as $my_coll_rate) {
306 $x_both[$my_coll_rate] = array(
307 'coll' => array(),
308 'paye' => array(),
309 'detail' => array(),
310 'ptype' => array(),
311 );
312 $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
313 $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
314 $x_both[$my_coll_rate]['paye']['totalht'] = 0;
315 $x_both[$my_coll_rate]['paye']['vat'] = 0;
316 $x_both[$my_coll_rate]['coll']['links'] = '';
317 $x_both[$my_coll_rate]['coll']['detail'] = array();
318 foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) {
319 //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
320 //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
321 //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
322 //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
323 $x_both[$my_coll_rate]['coll']['detail'][] = array(
324 'id' => $x_coll[$my_coll_rate]['facid'][$id],
325 'descr' => $x_coll[$my_coll_rate]['descr'][$id],
326 'pid' => $x_coll[$my_coll_rate]['pid'][$id],
327 'pref' => $x_coll[$my_coll_rate]['pref'][$id],
328 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id],
329 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id],
330 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id],
331 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id],
332 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id],
333 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id],
334 'datef' => $x_coll[$my_coll_rate]['datef'][$id],
335 'datep' => $x_coll[$my_coll_rate]['datep'][$id],
336 //'company_link'=>$company_static->getNomUrl(1,'',20),
337 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id],
338 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id],
339 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id],
340 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id],
341 //'link' =>$invoice_customer->getNomUrl(1,'',12)
342 );
343 }
344 }
345
346 // tva paid
347 foreach (array_keys($x_paye) as $my_paye_rate) {
348 $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
349 $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
350 if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
351 $x_both[$my_paye_rate]['coll']['totalht'] = 0;
352 $x_both[$my_paye_rate]['coll']['vat'] = 0;
353 }
354 $x_both[$my_paye_rate]['paye']['links'] = '';
355 $x_both[$my_paye_rate]['paye']['detail'] = array();
356
357 foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) {
358 // ExpenseReport
359 if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') {
360 //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id];
361 //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id];
362 //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id];
363
364 $x_both[$my_paye_rate]['paye']['detail'][] = array(
365 'id' => $x_paye[$my_paye_rate]['facid'][$id],
366 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
367 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
368 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
369 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
370 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
371 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
372 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
373 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
374 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
375 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
376 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
377 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
378 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
379 //'link' =>$expensereport->getNomUrl(1)
380 );
381 } else {
382 //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
383 //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
384 //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
385 //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
386 $x_both[$my_paye_rate]['paye']['detail'][] = array(
387 'id' => $x_paye[$my_paye_rate]['facid'][$id],
388 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
389 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
390 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
391 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
392 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
393 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
394 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
395 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
396 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
397 'datef' => $x_paye[$my_paye_rate]['datef'][$id],
398 'datep' => $x_paye[$my_paye_rate]['datep'][$id],
399 //'company_link'=>$company_static->getNomUrl(1,'',20),
400 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
401 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
402 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
403 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
404 //'link' =>$invoice_supplier->getNomUrl(1,'',12)
405 );
406 }
407 }
408 }
409 //now we have an array (x_both) indexed by rates for coll and paye
410
411 $action = "tva";
412 $object = array(&$x_coll, &$x_paye, &$x_both);
413 $parameters["mode"] = $modetax;
414 $parameters["year"] = $y;
415 $parameters["month"] = $m;
416 $parameters["type"] = 'vat';
417
418 // Initialize a technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
419 $hookmanager->initHooks(array('externalbalance'));
420 $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
421
422
423 print '<tr class="oddeven">';
424 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>';
425
426 $x_coll_sum = 0;
427 foreach (array_keys($x_coll) as $rate) {
428 $subtot_coll_total_ht = 0;
429 $subtot_coll_vat = 0;
430
431 foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
432 // Payment
433 $ratiopaymentinvoice = 1;
434 if ($modetax != 1) {
435 // Define type
436 // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
437 $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
438 // Try to enhance type detection using date_start and date_end for free lines where type
439 // was not saved.
440 if (!empty($fields['ddate_start'])) {
441 $type = 1;
442 }
443 if (!empty($fields['ddate_end'])) {
444 $type = 1;
445 }
446
447 if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice')
448 || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) {
449 //print $langs->trans("NA");
450 } else {
451 if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
452 $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
453 }
454 }
455 }
456 //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
457 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
458 $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
459 $subtot_coll_total_ht += $temp_ht;
460 $subtot_coll_vat += $temp_vat;
461 $x_coll_sum += $temp_vat;
462 }
463 }
464 print '<td class="nowrap right"><span class="amount">' . price(price2num($x_coll_sum, 'MT')) . '</span></td>';
465
466 $x_paye_sum = 0;
467 foreach (array_keys($x_paye) as $rate) {
468 $subtot_paye_total_ht = 0;
469 $subtot_paye_vat = 0;
470
471 foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) {
472 // Payment
473 $ratiopaymentinvoice = 1;
474 if ($modetax != 1) {
475 // Define type
476 // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
477 $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
478 // Try to enhance type detection using date_start and date_end for free lines where type
479 // was not saved.
480 if (!empty($fields['ddate_start'])) {
481 $type = 1;
482 }
483 if (!empty($fields['ddate_end'])) {
484 $type = 1;
485 }
486
487 if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice')
488 || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) {
489 //print $langs->trans("NA");
490 } else {
491 if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
492 $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']);
493 }
494 }
495 }
496 //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
497 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
498 $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
499 $subtot_paye_total_ht += $temp_ht;
500 $subtot_paye_vat += $temp_vat;
501 $x_paye_sum += $temp_vat;
502 }
503 }
504 print '<td class="nowrap right"><span class="amount">' . price(price2num($x_paye_sum, 'MT')) . '</span></td>';
505
506 $subtotalcoll += $x_coll_sum;
507 $subtotalpaid += $x_paye_sum;
508
509 $diff = $x_coll_sum - $x_paye_sum;
510 $total += $diff;
511 $subtotal = price2num($subtotal + $diff, 'MT');
512
513 print '<td class="nowrap right"><span class="amount">' . price(price2num($diff, 'MT')) . '</span></td>' . "\n";
514 print "<td>&nbsp;</td>\n";
515 print "</tr>\n";
516
517 // Total
518 $i++;
519 $m++;
520 if ($i > 2) {
521 print '<tr class="liste_total">';
522 print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q=' . round($m / 3) . '&year=' . $y . '">' . $langs->trans("SubTotal") . '</a>:</td>';
523 print '<td class="nowrap right">' . price(price2num($subtotalcoll, 'MT')) . '</td>';
524 print '<td class="nowrap right">' . price(price2num($subtotalpaid, 'MT')) . '</td>';
525 print '<td class="nowrap right">' . price(price2num($subtotal, 'MT')) . '</td>';
526 print '<td>&nbsp;</td></tr>';
527 $i = 0;
528 $subtotalcoll = 0;
529 $subtotalpaid = 0;
530 $subtotal = 0;
531 }
532 }
533 print '<tr class="liste_total"><td class="right" colspan="3">' . $langs->trans("TotalToPay") . ':</td><td class="nowrap right">' . price(price2num($total, 'MT')) . '</td>';
534 print "<td>&nbsp;</td>\n";
535 print '</tr>';
536
537 print '</table>';
538
539
540 print '</div><div class="fichetwothirdright">';
541
542
543 /*
544 * Paid
545 */
546 print load_fiche_titre($langs->trans("VATPaid"), '', '');
547
548 $sql = '';
549
550 $sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode";
551 $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
552 $sql .= " WHERE tva.entity = " . $conf->entity;
553 $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
554 $sql .= " GROUP BY dm";
555
556 $sql .= " UNION ";
557
558 $sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode";
559 $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
560 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_vat as ptva ON (tva.rowid = ptva.fk_tva)";
561 $sql .= " WHERE tva.entity = " . $conf->entity;
562 $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
563 $sql .= " GROUP BY dm";
564
565 $sql .= " ORDER BY dm ASC, mode ASC";
566 //print $sql;
567
568 pt($db, $sql, $langs->trans("Month"));
569
570 print '</div>';
571}
572
573llxFooter();
574$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
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 - Taxe sur la valeur ajoutée)
Definition tva.class.php:38
llxFooter()
Footer empty.
Definition document.php:107
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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:707