dolibarr 21.0.0-alpha
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 += $amountclaimed;
123 }
124 if ($obj->mode == 'paid') {
125 $amountpaid = $obj->mm;
126 $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] = array(
289 'coll' => array(),
290 'paye' => array(),
291 'detail' => array(),
292 'ptype' => array(),
293 );
294 $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
295 $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
296 $x_both[$my_coll_rate]['paye']['totalht'] = 0;
297 $x_both[$my_coll_rate]['paye']['vat'] = 0;
298 $x_both[$my_coll_rate]['coll']['links'] = '';
299 $x_both[$my_coll_rate]['coll']['detail'] = array();
300 foreach ($x_coll[$my_coll_rate]['facid'] as $id => $dummy) {
301 //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
302 //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
303 //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
304 //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
305 $x_both[$my_coll_rate]['coll']['detail'][] = array(
306 'id' => $x_coll[$my_coll_rate]['facid'][$id],
307 'descr' => $x_coll[$my_coll_rate]['descr'][$id],
308 'pid' => $x_coll[$my_coll_rate]['pid'][$id],
309 'pref' => $x_coll[$my_coll_rate]['pref'][$id],
310 'ptype' => $x_coll[$my_coll_rate]['ptype'][$id],
311 'payment_id' => $x_coll[$my_coll_rate]['payment_id'][$id],
312 'payment_amount' => $x_coll[$my_coll_rate]['payment_amount'][$id],
313 'ftotal_ttc' => $x_coll[$my_coll_rate]['ftotal_ttc'][$id],
314 'dtotal_ttc' => $x_coll[$my_coll_rate]['dtotal_ttc'][$id],
315 'dtype' => $x_coll[$my_coll_rate]['dtype'][$id],
316 'datef' => $x_coll[$my_coll_rate]['datef'][$id],
317 'datep' => $x_coll[$my_coll_rate]['datep'][$id],
318 //'company_link'=>$company_static->getNomUrl(1,'',20),
319 'ddate_start' => $x_coll[$my_coll_rate]['ddate_start'][$id],
320 'ddate_end' => $x_coll[$my_coll_rate]['ddate_end'][$id],
321 'totalht' => $x_coll[$my_coll_rate]['totalht_list'][$id],
322 'vat' => $x_coll[$my_coll_rate]['vat_list'][$id],
323 //'link' =>$invoice_customer->getNomUrl(1,'',12)
324 );
325 }
326 }
327
328 // tva paid
329 foreach (array_keys($x_paye) as $my_paye_rate) {
330 $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
331 $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
332 if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
333 $x_both[$my_paye_rate]['coll']['totalht'] = 0;
334 $x_both[$my_paye_rate]['coll']['vat'] = 0;
335 }
336 $x_both[$my_paye_rate]['paye']['links'] = '';
337 $x_both[$my_paye_rate]['paye']['detail'] = array();
338
339 foreach ($x_paye[$my_paye_rate]['facid'] as $id => $dummy) {
340 // ExpenseReport
341 if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') {
342 //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id];
343 //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id];
344 //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id];
345
346 $x_both[$my_paye_rate]['paye']['detail'][] = array(
347 'id' => $x_paye[$my_paye_rate]['facid'][$id],
348 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
349 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
350 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
351 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
352 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
353 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
354 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
355 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
356 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
357 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
358 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
359 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
360 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
361 //'link' =>$expensereport->getNomUrl(1)
362 );
363 } else {
364 //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
365 //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
366 //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
367 //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
368 $x_both[$my_paye_rate]['paye']['detail'][] = array(
369 'id' => $x_paye[$my_paye_rate]['facid'][$id],
370 'descr' => $x_paye[$my_paye_rate]['descr'][$id],
371 'pid' => $x_paye[$my_paye_rate]['pid'][$id],
372 'pref' => $x_paye[$my_paye_rate]['pref'][$id],
373 'ptype' => $x_paye[$my_paye_rate]['ptype'][$id],
374 'payment_id' => $x_paye[$my_paye_rate]['payment_id'][$id],
375 'payment_amount' => $x_paye[$my_paye_rate]['payment_amount'][$id],
376 'ftotal_ttc' => price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
377 'dtotal_ttc' => price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
378 'dtype' => $x_paye[$my_paye_rate]['dtype'][$id],
379 'datef' => $x_paye[$my_paye_rate]['datef'][$id],
380 'datep' => $x_paye[$my_paye_rate]['datep'][$id],
381 //'company_link'=>$company_static->getNomUrl(1,'',20),
382 'ddate_start' => $x_paye[$my_paye_rate]['ddate_start'][$id],
383 'ddate_end' => $x_paye[$my_paye_rate]['ddate_end'][$id],
384 'totalht' => price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
385 'vat' => $x_paye[$my_paye_rate]['vat_list'][$id],
386 //'link' =>$invoice_supplier->getNomUrl(1,'',12)
387 );
388 }
389 }
390 }
391 //now we have an array (x_both) indexed by rates for coll and paye
392
393 $action = "tva";
394 $object = array(&$x_coll, &$x_paye, &$x_both);
395 $parameters["mode"] = $modetax;
396 $parameters["year"] = $y;
397 $parameters["month"] = $m;
398 $parameters["type"] = 'vat';
399
400 // Initialize a technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
401 $hookmanager->initHooks(array('externalbalance'));
402 $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
403
404
405 print '<tr class="oddeven">';
406 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>';
407
408 $x_coll_sum = 0;
409 foreach (array_keys($x_coll) as $rate) {
410 $subtot_coll_total_ht = 0;
411 $subtot_coll_vat = 0;
412
413 foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
414 // Payment
415 $ratiopaymentinvoice = 1;
416 if ($modetax != 1) {
417 // Define type
418 // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
419 $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
420 // Try to enhance type detection using date_start and date_end for free lines where type
421 // was not saved.
422 if (!empty($fields['ddate_start'])) {
423 $type = 1;
424 }
425 if (!empty($fields['ddate_end'])) {
426 $type = 1;
427 }
428
429 if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice')
430 || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) {
431 //print $langs->trans("NA");
432 } else {
433 if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
434 $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
435 }
436 }
437 }
438 //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
439 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
440 $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
441 $subtot_coll_total_ht += $temp_ht;
442 $subtot_coll_vat += $temp_vat;
443 $x_coll_sum += $temp_vat;
444 }
445 }
446 print '<td class="nowrap right"><span class="amount">' . price(price2num($x_coll_sum, 'MT')) . '</span></td>';
447
448 $x_paye_sum = 0;
449 foreach (array_keys($x_paye) as $rate) {
450 $subtot_paye_total_ht = 0;
451 $subtot_paye_vat = 0;
452
453 foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) {
454 // Payment
455 $ratiopaymentinvoice = 1;
456 if ($modetax != 1) {
457 // Define type
458 // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
459 $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
460 // Try to enhance type detection using date_start and date_end for free lines where type
461 // was not saved.
462 if (!empty($fields['ddate_start'])) {
463 $type = 1;
464 }
465 if (!empty($fields['ddate_end'])) {
466 $type = 1;
467 }
468
469 if (($type == 0 && getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice')
470 || ($type == 1 && getDolGlobalString('TAX_MODE_SELL_SERVICE') == 'invoice')) {
471 //print $langs->trans("NA");
472 } else {
473 if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
474 $ratiopaymentinvoice = ($fields['payment_amount'] / (float) $fields['ftotal_ttc']);
475 }
476 }
477 }
478 //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
479 $temp_ht = (float) $fields['totalht'] * $ratiopaymentinvoice;
480 $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
481 $subtot_paye_total_ht += $temp_ht;
482 $subtot_paye_vat += $temp_vat;
483 $x_paye_sum += $temp_vat;
484 }
485 }
486 print '<td class="nowrap right"><span class="amount">' . price(price2num($x_paye_sum, 'MT')) . '</span></td>';
487
488 $subtotalcoll += $x_coll_sum;
489 $subtotalpaid += $x_paye_sum;
490
491 $diff = $x_coll_sum - $x_paye_sum;
492 $total += $diff;
493 $subtotal = price2num($subtotal + $diff, 'MT');
494
495 print '<td class="nowrap right"><span class="amount">' . price(price2num($diff, 'MT')) . '</span></td>' . "\n";
496 print "<td>&nbsp;</td>\n";
497 print "</tr>\n";
498
499 // Total
500 $i++;
501 $m++;
502 if ($i > 2) {
503 print '<tr class="liste_total">';
504 print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q=' . round($m / 3) . '&year=' . $y . '">' . $langs->trans("SubTotal") . '</a>:</td>';
505 print '<td class="nowrap right">' . price(price2num($subtotalcoll, 'MT')) . '</td>';
506 print '<td class="nowrap right">' . price(price2num($subtotalpaid, 'MT')) . '</td>';
507 print '<td class="nowrap right">' . price(price2num($subtotal, 'MT')) . '</td>';
508 print '<td>&nbsp;</td></tr>';
509 $i = 0;
510 $subtotalcoll = 0;
511 $subtotalpaid = 0;
512 $subtotal = 0;
513 }
514 }
515 print '<tr class="liste_total"><td class="right" colspan="3">' . $langs->trans("TotalToPay") . ':</td><td class="nowrap right">' . price(price2num($total, 'MT')) . '</td>';
516 print "<td>&nbsp;</td>\n";
517 print '</tr>';
518
519 print '</table>';
520
521
522 print '</div><div class="fichetwothirdright">';
523
524
525 /*
526 * Paid
527 */
528 print load_fiche_titre($langs->trans("VATPaid"), '', '');
529
530 $sql = '';
531
532 $sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode";
533 $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
534 $sql .= " WHERE tva.entity = " . $conf->entity;
535 $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
536 $sql .= " GROUP BY dm";
537
538 $sql .= " UNION ";
539
540 $sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode";
541 $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
542 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_vat as ptva ON (tva.rowid = ptva.fk_tva)";
543 $sql .= " WHERE tva.entity = " . $conf->entity;
544 $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
545 $sql .= " GROUP BY dm";
546
547 $sql .= " ORDER BY dm ASC, mode ASC";
548 //print $sql;
549
550 pt($db, $sql, $langs->trans("Month"));
551
552 print '</div>';
553}
554
555llxFooter();
556$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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.
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