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