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>';
249$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
263report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
269print
'<div class="fichecenter"><div class="fichethirdleft">';
271print
load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code),
'',
'');
273print
'<table class="noborder centpercent">';
274print
'<tr class="liste_titre">';
275print
'<td>'.$langs->trans(
"Year").
"</td>";
277 print
'<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).
'</td>';
278 print
'<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).
'</td>';
281 print
'<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).
'</td><td></td>';
284 print
'<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).
'</td><td></td>';
286print
'<td class="right">'.$langs->trans(
"TotalToPay").
'</td>';
287print
"<td> </td>\n";
303while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) {
314 $x_coll =
tax_by_rate(($localTaxType == 1 ?
'localtax1' :
'localtax2'), $db, $y, 0, 0, 0, $modetax,
'sell', $m);
315 $x_paye =
tax_by_rate(($localTaxType == 1 ?
'localtax1' :
'localtax2'), $db, $y, 0, 0, 0, $modetax,
'buy', $m);
319 foreach (array_keys($x_coll) as $my_coll_rate) {
320 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
321 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
322 $x_both[$my_coll_rate][
'coll'][
'localtax1'] = $x_coll[$my_coll_rate][
'localtax1'];
323 $x_both[$my_coll_rate][
'coll'][
'localtax2'] = $x_coll[$my_coll_rate][
'localtax2'];
324 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
325 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
326 $x_both[$my_coll_rate][
'paye'][
'localtax1'] = 0;
327 $x_both[$my_coll_rate][
'paye'][
'localtax2'] = 0;
328 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
329 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
330 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
335 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
336 'id' =>$x_coll[$my_coll_rate][
'facid'][$id],
337 'descr' =>$x_coll[$my_coll_rate][
'descr'][$id],
338 'pid' =>$x_coll[$my_coll_rate][
'pid'][$id],
339 'pref' =>$x_coll[$my_coll_rate][
'pref'][$id],
340 'ptype' =>$x_coll[$my_coll_rate][
'ptype'][$id],
341 'payment_id'=>$x_coll[$my_coll_rate][
'payment_id'][$id],
342 'payment_amount'=>$x_coll[$my_coll_rate][
'payment_amount'][$id],
343 'ftotal_ttc'=>$x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
344 'dtotal_ttc'=>$x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
345 'dtype' =>$x_coll[$my_coll_rate][
'dtype'][$id],
346 'datef' =>$x_coll[$my_coll_rate][
'datef'][$id],
347 'datep' =>$x_coll[$my_coll_rate][
'datep'][$id],
349 'ddate_start'=>$x_coll[$my_coll_rate][
'ddate_start'][$id],
350 'ddate_end' =>$x_coll[$my_coll_rate][
'ddate_end'][$id],
352 'totalht' =>$x_coll[$my_coll_rate][
'totalht_list'][$id],
353 'vat' =>$x_coll[$my_coll_rate][
'vat_list'][$id],
354 'localtax1' =>$x_coll[$my_coll_rate][
'localtax1_list'][$id],
355 'localtax2' =>$x_coll[$my_coll_rate][
'localtax2_list'][$id],
362 foreach (array_keys($x_paye) as $my_paye_rate) {
363 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
364 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
365 $x_both[$my_paye_rate][
'paye'][
'localtax1'] = $x_paye[$my_paye_rate][
'localtax1'];
366 $x_both[$my_paye_rate][
'paye'][
'localtax2'] = $x_paye[$my_paye_rate][
'localtax2'];
367 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
368 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
369 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
370 $x_both[$my_paye_rate][
'coll'][
'localtax1'] = 0;
371 $x_both[$my_paye_rate][
'coll'][
'localtax2'] = 0;
373 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
374 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
376 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
378 if ($x_paye[$my_paye_rate][
'ptype'][$id] ==
'ExpenseReportPayment') {
383 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
384 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
385 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
386 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
387 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
388 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
389 'payment_id' =>$x_paye[$my_paye_rate][
'payment_id'][$id],
390 'payment_amount' =>$x_paye[$my_paye_rate][
'payment_amount'][$id],
391 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
392 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
393 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
394 'ddate_start' =>$x_paye[$my_paye_rate][
'ddate_start'][$id],
395 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
397 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
398 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
399 'localtax1' =>$x_paye[$my_paye_rate][
'localtax1_list'][$id],
400 'localtax2' =>$x_paye[$my_paye_rate][
'localtax2_list'][$id],
408 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
409 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
410 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
411 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
412 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
413 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
414 'payment_id'=>$x_paye[$my_paye_rate][
'payment_id'][$id],
415 'payment_amount'=>$x_paye[$my_paye_rate][
'payment_amount'][$id],
416 'ftotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
417 'dtotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
418 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
419 'datef' =>$x_paye[$my_paye_rate][
'datef'][$id],
420 'datep' =>$x_paye[$my_paye_rate][
'datep'][$id],
422 'ddate_start'=>$x_paye[$my_paye_rate][
'ddate_start'][$id],
423 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
425 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
426 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
427 'localtax1' =>$x_paye[$my_paye_rate][
'localtax1_list'][$id],
428 'localtax2' =>$x_paye[$my_paye_rate][
'localtax2_list'][$id],
437 $object = array(&$x_coll, &$x_paye, &$x_both);
438 $parameters[
"mode"] = $modetax;
439 $parameters[
"year"] = $y;
440 $parameters[
"month"] = $m;
441 $parameters[
"type"] =
'localtax'.$localTaxType;
444 $hookmanager->initHooks(array(
'externalbalance'));
445 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
448 print
'<tr class="oddeven">';
449 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>';
452 foreach (array_keys($x_coll) as $rate) {
453 $subtot_coll_total_ht = 0;
454 $subtot_coll_vat = 0;
456 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
458 $ratiopaymentinvoice = 1;
462 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
465 if (!empty($fields[
'ddate_start'])) {
468 if (!empty($fields[
'ddate_end'])) {
476 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
477 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
482 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
483 $temp_vat = $fields[
'localtax'.$localTaxType] * $ratiopaymentinvoice;
484 $subtot_coll_total_ht += $temp_ht;
485 $subtot_coll_vat += $temp_vat;
486 $x_coll_sum += $temp_vat;
489 print
'<td class="nowrap right">'.price(
price2num($x_coll_sum,
'MT')).
'</td>';
492 foreach (array_keys($x_paye) as $rate) {
493 $subtot_paye_total_ht = 0;
494 $subtot_paye_vat = 0;
496 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
498 $ratiopaymentinvoice = 1;
502 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
505 if (!empty($fields[
'ddate_start'])) {
508 if (!empty($fields[
'ddate_end'])) {
516 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
517 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
522 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
523 $temp_vat = $fields[
'localtax'.$localTaxType] * $ratiopaymentinvoice;
524 $subtot_paye_total_ht += $temp_ht;
525 $subtot_paye_vat += $temp_vat;
526 $x_paye_sum += $temp_vat;
529 print
'<td class="nowrap right">'.price(
price2num($x_paye_sum,
'MT')).
'</td>';
531 $subtotalcoll = $subtotalcoll + $x_coll_sum;
532 $subtotalpaid = $subtotalpaid + $x_paye_sum;
534 $diff = $x_coll_sum - $x_paye_sum;
535 $total = $total + $diff;
536 $subtotal =
price2num($subtotal + $diff,
'MT');
538 print
'<td class="nowrap right">'.price(
price2num($diff,
'MT')).
'</td>'.
"\n";
539 print
"<td> </td>\n";
545 print
'<tr class="liste_total">';
546 print
'<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).
'&year='.$y.
'">'.$langs->trans(
"SubTotal").
'</a>:</td>';
547 print
'<td class="nowrap right">'.price(
price2num($subtotalcoll,
'MT')).
'</td>';
548 print
'<td class="nowrap right">'.price(
price2num($subtotalpaid,
'MT')).
'</td>';
549 print
'<td class="nowrap right">'.price(
price2num($subtotal,
'MT')).
'</td>';
550 print
'<td> </td></tr>';