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