107function pt($db, $sql, $date)
109 global $conf, $bc, $langs;
111 $result = $db->query($sql);
113 $num = $db->num_rows($result);
116 print
'<table class="noborder centpercent">';
118 print
'<tr class="liste_titre">';
119 print
'<td class="nowrap">'.$date.
'</td>';
120 print
'<td class="right">'.$langs->trans(
"ClaimedForThisPeriod").
'</td>';
121 print
'<td class="right">'.$langs->trans(
"PaidDuringThisPeriod").
'</td>';
133 $obj = $db->fetch_object($result);
137 if ($obj->mode ==
'claimed' && !empty($previousmode)) {
138 print
'<tr class="oddeven">';
139 print
'<td class="nowrap">'.$previousmonth.
"</td>\n";
140 print
'<td class="nowrap right">'.price($amountclaimed).
"</td>\n";
141 print
'<td class="nowrap right">'.price($amountpaid).
"</td>\n";
148 if ($obj->mode ==
'claimed') {
149 $amountclaimed = $obj->mm;
150 $totalclaimed = $totalclaimed + $amountclaimed;
152 if ($obj->mode ==
'paid') {
153 $amountpaid = $obj->mm;
154 $totalpaid = $totalpaid + $amountpaid;
157 if ($obj->mode ==
'paid') {
158 print
'<tr class="oddeven">';
159 print
'<td class="nowrap">'.$obj->dm.
"</td>\n";
160 print
'<td class="nowrap right">'.price($amountclaimed).
"</td>\n";
161 print
'<td class="nowrap right">'.price($amountpaid).
"</td>\n";
168 $previousmode = $obj->mode;
169 $previousmonth = $obj->dm;
175 if ($mode ==
'claimed' && !empty($previousmode)) {
176 print
'<tr class="oddeven">';
177 print
'<td class="nowrap">'.$previousmonth.
"</td>\n";
178 print
'<td class="nowrap right">'.price($amountclaimed).
"</td>\n";
179 print
'<td class="nowrap right">'.price($amountpaid).
"</td>\n";
186 print
'<tr class="liste_total">';
187 print
'<td class="right">'.$langs->trans(
"Total").
'</td>';
188 print
'<td class="nowrap right">'.price($totalclaimed).
'</td>';
189 print
'<td class="nowrap right">'.price($totalpaid).
'</td>';
199if (empty($localTaxType)) {
216$form =
new Form($db);
217$company_static =
new Societe($db);
220if ($localTaxType == 1) {
222 $LTSummary =
'LT1Summary';
224 $LTCustomer =
'LT1Customer';
225 $LTSupplier =
'LT1Supplier';
229 $LTSummary =
'LT2Summary';
231 $LTCustomer =
'LT2Customer';
232 $LTSupplier =
'LT2Supplier';
236$fsearch =
'<!-- hidden fields for form -->';
237$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
238$fsearch .=
'<input type="hidden" name="localTaxType" value="'.$localTaxType.
'">';
239$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
241$description = $fsearch;
244$name = $langs->transcountry($localTaxType == 1 ?
"LT1ReportByMonth" :
"LT2ReportByMonth", $mysoc->country_code);
245$description .= $langs->trans($LT);
246$calcmode = $langs->trans(
"LTReportBuildWithOptionDefinedInModule").
' ';
247$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
251$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
265report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
271print
'<div class="fichecenter"><div class="fichethirdleft">';
273print
load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code),
'',
'');
275print
'<table class="noborder centpercent">';
276print
'<tr class="liste_titre">';
277print
'<td>'.$langs->trans(
"Year").
"</td>";
279 print
'<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).
'</td>';
280 print
'<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).
'</td>';
283 print
'<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).
'</td><td></td>';
286 print
'<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).
'</td><td></td>';
288print
'<td class="right">'.$langs->trans(
"TotalToPay").
'</td>';
289print
"<td> </td>\n";
305while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) {
316 $x_coll =
tax_by_rate(($localTaxType == 1 ?
'localtax1' :
'localtax2'), $db, $y, 0, 0, 0, $modetax,
'sell', $m);
317 $x_paye =
tax_by_rate(($localTaxType == 1 ?
'localtax1' :
'localtax2'), $db, $y, 0, 0, 0, $modetax,
'buy', $m);
321 foreach (array_keys($x_coll) as $my_coll_rate) {
322 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
323 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
324 $x_both[$my_coll_rate][
'coll'][
'localtax1'] = $x_coll[$my_coll_rate][
'localtax1'];
325 $x_both[$my_coll_rate][
'coll'][
'localtax2'] = $x_coll[$my_coll_rate][
'localtax2'];
326 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
327 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
328 $x_both[$my_coll_rate][
'paye'][
'localtax1'] = 0;
329 $x_both[$my_coll_rate][
'paye'][
'localtax2'] = 0;
330 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
331 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
332 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
337 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
338 'id' =>$x_coll[$my_coll_rate][
'facid'][$id],
339 'descr' =>$x_coll[$my_coll_rate][
'descr'][$id],
340 'pid' =>$x_coll[$my_coll_rate][
'pid'][$id],
341 'pref' =>$x_coll[$my_coll_rate][
'pref'][$id],
342 'ptype' =>$x_coll[$my_coll_rate][
'ptype'][$id],
343 'payment_id'=>$x_coll[$my_coll_rate][
'payment_id'][$id],
344 'payment_amount'=>$x_coll[$my_coll_rate][
'payment_amount'][$id],
345 'ftotal_ttc'=>$x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
346 'dtotal_ttc'=>$x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
347 'dtype' =>$x_coll[$my_coll_rate][
'dtype'][$id],
348 'datef' =>$x_coll[$my_coll_rate][
'datef'][$id],
349 'datep' =>$x_coll[$my_coll_rate][
'datep'][$id],
351 'ddate_start'=>$x_coll[$my_coll_rate][
'ddate_start'][$id],
352 'ddate_end' =>$x_coll[$my_coll_rate][
'ddate_end'][$id],
354 'totalht' =>$x_coll[$my_coll_rate][
'totalht_list'][$id],
355 'vat' =>$x_coll[$my_coll_rate][
'vat_list'][$id],
356 'localtax1' =>$x_coll[$my_coll_rate][
'localtax1_list'][$id],
357 'localtax2' =>$x_coll[$my_coll_rate][
'localtax2_list'][$id],
364 foreach (array_keys($x_paye) as $my_paye_rate) {
365 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
366 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
367 $x_both[$my_paye_rate][
'paye'][
'localtax1'] = $x_paye[$my_paye_rate][
'localtax1'];
368 $x_both[$my_paye_rate][
'paye'][
'localtax2'] = $x_paye[$my_paye_rate][
'localtax2'];
369 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
370 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
371 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
372 $x_both[$my_paye_rate][
'coll'][
'localtax1'] = 0;
373 $x_both[$my_paye_rate][
'coll'][
'localtax2'] = 0;
375 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
376 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
378 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
380 if ($x_paye[$my_paye_rate][
'ptype'][$id] ==
'ExpenseReportPayment') {
385 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
386 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
387 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
388 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
389 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
390 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
391 'payment_id' =>$x_paye[$my_paye_rate][
'payment_id'][$id],
392 'payment_amount' =>$x_paye[$my_paye_rate][
'payment_amount'][$id],
393 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
394 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
395 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
396 'ddate_start' =>$x_paye[$my_paye_rate][
'ddate_start'][$id],
397 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
399 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
400 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
401 'localtax1' =>$x_paye[$my_paye_rate][
'localtax1_list'][$id],
402 'localtax2' =>$x_paye[$my_paye_rate][
'localtax2_list'][$id],
410 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
411 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
412 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
413 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
414 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
415 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
416 'payment_id'=>$x_paye[$my_paye_rate][
'payment_id'][$id],
417 'payment_amount'=>$x_paye[$my_paye_rate][
'payment_amount'][$id],
418 'ftotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
419 'dtotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
420 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
421 'datef' =>$x_paye[$my_paye_rate][
'datef'][$id],
422 'datep' =>$x_paye[$my_paye_rate][
'datep'][$id],
424 'ddate_start'=>$x_paye[$my_paye_rate][
'ddate_start'][$id],
425 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
427 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
428 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
429 'localtax1' =>$x_paye[$my_paye_rate][
'localtax1_list'][$id],
430 'localtax2' =>$x_paye[$my_paye_rate][
'localtax2_list'][$id],
439 $object = array(&$x_coll, &$x_paye, &$x_both);
440 $parameters[
"mode"] = $modetax;
441 $parameters[
"year"] = $y;
442 $parameters[
"month"] = $m;
443 $parameters[
"type"] =
'localtax'.$localTaxType;
446 $hookmanager->initHooks(array(
'externalbalance'));
447 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
450 print
'<tr class="oddeven">';
451 print
'<td class="nowrap"><a href="'.DOL_URL_ROOT.
'/compta/localtax/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>';
454 foreach (array_keys($x_coll) as $rate) {
455 $subtot_coll_total_ht = 0;
456 $subtot_coll_vat = 0;
458 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
460 $ratiopaymentinvoice = 1;
464 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
467 if (!empty($fields[
'ddate_start'])) {
470 if (!empty($fields[
'ddate_end'])) {
478 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
479 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
484 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
485 $temp_vat = $fields[
'localtax'.$localTaxType] * $ratiopaymentinvoice;
486 $subtot_coll_total_ht += $temp_ht;
487 $subtot_coll_vat += $temp_vat;
488 $x_coll_sum += $temp_vat;
491 print
'<td class="nowrap right">'.price(
price2num($x_coll_sum,
'MT')).
'</td>';
494 foreach (array_keys($x_paye) as $rate) {
495 $subtot_paye_total_ht = 0;
496 $subtot_paye_vat = 0;
498 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
500 $ratiopaymentinvoice = 1;
504 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
507 if (!empty($fields[
'ddate_start'])) {
510 if (!empty($fields[
'ddate_end'])) {
518 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
519 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
524 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
525 $temp_vat = $fields[
'localtax'.$localTaxType] * $ratiopaymentinvoice;
526 $subtot_paye_total_ht += $temp_ht;
527 $subtot_paye_vat += $temp_vat;
528 $x_paye_sum += $temp_vat;
531 print
'<td class="nowrap right">'.price(
price2num($x_paye_sum,
'MT')).
'</td>';
533 $subtotalcoll = $subtotalcoll + $x_coll_sum;
534 $subtotalpaid = $subtotalpaid + $x_paye_sum;
536 $diff = $x_coll_sum - $x_paye_sum;
537 $total = $total + $diff;
538 $subtotal =
price2num($subtotal + $diff,
'MT');
540 print
'<td class="nowrap right">'.price(
price2num($diff,
'MT')).
'</td>'.
"\n";
541 print
"<td> </td>\n";
547 print
'<tr class="liste_total">';
548 print
'<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).
'&year='.$y.
'">'.$langs->trans(
"SubTotal").
'</a>:</td>';
549 print
'<td class="nowrap right">'.price(
price2num($subtotalcoll,
'MT')).
'</td>';
550 print
'<td class="nowrap right">'.price(
price2num($subtotalpaid,
'MT')).
'</td>';
551 print
'<td class="nowrap right">'.price(
price2num($subtotal,
'MT')).
'</td>';
552 print
'<td> </td></tr>';