32require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
55$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
57include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
70@phan-var-force int $date_start
71@phan-var-force int $date_end
72@phan-var-force int $date_start_month
73@phan-var-force int $date_start_year
74@phan-var-force int $date_start_day
75@phan-var-force int $date_end_month
76@phan-var-force int $date_end_year
77@phan-var-force int $date_end_day
78@phan-var-force int $year_current
89if (GETPOSTISSET(
"modetax")) {
99 $socid = $user->socid;
120$morequerystring =
'';
121$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
122foreach ($listofparams as $param) {
124 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
128$special_report = (
GETPOSTINT(
'extra_report') == 1);
130llxHeader(
'', $langs->trans(
"VATReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
132$fsearch =
'<!-- hidden fields for form -->';
133$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
134$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
135$fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
136$fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" class="width75 right">';
139$name = $langs->trans(
"VATReportByThirdParties");
142 $calcmode = $langs->trans(
'OptionVATDefault');
145 $calcmode = $langs->trans(
'OptionVATDebitOption');
148 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
150$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
152$period = $form->selectDate(
$date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
158 $description = $langs->trans(
"RulesVATDueProducts");
161 $description .= $langs->trans(
"RulesVATInProducts");
164 $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
167 $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
170 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
173 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
176 $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
180$description .= ($description ?
'<br>' :
'').$fsearch;
182 $description .=
'<br>';
183 $description .=
'<input type="radio" name="extra_report" value="0" '.($special_report ?
'' :
'checked="checked"').
'> ';
184 $description .= $langs->trans(
'SimpleReport');
185 $description .=
'</input>';
186 $description .=
'<br>';
187 $description .=
'<input type="radio" name="extra_report" value="1" '.($special_report ?
'checked="checked"' :
'').
'> ';
188 $description .= $langs->trans(
'AddExtraReport');
189 $description .=
'</input>';
190 $description .=
'<br>';
193$elementcust = $langs->trans(
"CustomersInvoices");
194$productcust = $langs->trans(
"Description");
195$namerate = $langs->trans(
"VATRate");
196$amountcust = $langs->trans(
"AmountHT");
198 $vatcust =
' ('.$langs->trans(
"StatusToPay").
')';
200$elementsup = $langs->trans(
"SuppliersInvoices");
201$productsup = $langs->trans(
"Description");
202$amountsup = $langs->trans(
"AmountHT");
204 $vatsup =
' ('.$langs->trans(
"ToGetBack").
')';
209report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
211$vatcust = $langs->trans(
"VATReceived");
212$vatsup = $langs->trans(
"VATPaid");
216print
'<div class="div-table-responsive">';
217print
'<table class="noborder centpercent">';
232if (!is_array($x_coll) || !is_array($x_paye)) {
233 $langs->load(
"errors");
235 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
236 } elseif ($x_coll == -2) {
237 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
239 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
244 foreach (array_keys($x_coll) as $my_coll_thirdpartyid) {
245 $x_both[$my_coll_thirdpartyid] = array(
249 $x_both[$my_coll_thirdpartyid][
'coll'][
'totalht'] = $x_coll[$my_coll_thirdpartyid][
'totalht'];
250 $x_both[$my_coll_thirdpartyid][
'coll'][
'vat'] = $x_coll[$my_coll_thirdpartyid][
'vat'];
251 $x_both[$my_coll_thirdpartyid][
'paye'][
'totalht'] = 0;
252 $x_both[$my_coll_thirdpartyid][
'paye'][
'vat'] = 0;
253 $x_both[$my_coll_thirdpartyid][
'coll'][
'links'] =
'';
254 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'] = array();
255 foreach ($x_coll[$my_coll_thirdpartyid][
'facid'] as
$id => $dummy) {
256 $invoice_customer->id = $x_coll[$my_coll_thirdpartyid][
'facid'][
$id];
257 $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid][
'facnum'][
$id];
258 $invoice_customer->type = $x_coll[$my_coll_thirdpartyid][
'type'][
$id];
261 $company_static->id = $x_coll[$my_coll_thirdpartyid][
'company_id'][
$id];
262 $company_static->name = $x_coll[$my_coll_thirdpartyid][
'company_name'][
$id];
263 $company_static->name_alias = $x_coll[$my_coll_thirdpartyid][
'company_alias'][
$id];
264 $company_static->email = $x_coll[$my_coll_thirdpartyid][
'company_email'][
$id];
265 $company_static->tva_intra = isset($x_coll[$my_coll_thirdpartyid][
'tva_intra'][
$id]) ? $x_coll[$my_coll_thirdpartyid][
'tva_intra'][
$id] :
'0';
266 $company_static->client = $x_coll[$my_coll_thirdpartyid][
'company_client'][
$id];
267 $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_fournisseur'][
$id];
268 $company_static->status = $x_coll[$my_coll_thirdpartyid][
'company_status'][
$id];
269 $company_static->code_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_code'][
$id];
270 $company_static->code_compta_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_accounting_code'][
$id];
271 $company_static->code_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_code'][
$id];
272 $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_accounting_code'][
$id];
274 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'][] = array(
275 'id' => $x_coll[$my_coll_thirdpartyid][
'facid'][
$id],
276 'descr' => $x_coll[$my_coll_thirdpartyid][
'descr'][
$id],
278 'pid' => $x_coll[$my_coll_thirdpartyid][
'pid'][
$id],
279 'pref' => isset($x_coll[$my_coll_thirdpartyid][
'pref'][
$id]) ? $x_coll[$my_coll_thirdpartyid][
'pref'][
$id] :
'',
280 'ptype' => $x_coll[$my_coll_thirdpartyid][
'ptype'][
$id],
281 'pstatus' => isset($x_paye[$my_coll_thirdpartyid][
'pstatus'][
$id]) ? $x_paye[$my_coll_thirdpartyid][
'pstatus'][
$id] :
'',
282 'pstatusbuy' => isset($x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][
$id]) ? $x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][
$id] :
'',
284 'payment_id' => $x_coll[$my_coll_thirdpartyid][
'payment_id'][
$id],
285 'payment_ref' => isset($x_coll[$my_coll_thirdpartyid][
'payment_ref'][
$id]) ? $x_coll[$my_coll_thirdpartyid][
'payment_ref'][
$id] :
'',
286 'payment_amount' => $x_coll[$my_coll_thirdpartyid][
'payment_amount'][
$id],
287 'ftotal_ttc' => $x_coll[$my_coll_thirdpartyid][
'ftotal_ttc'][
$id],
288 'dtotal_ttc' => $x_coll[$my_coll_thirdpartyid][
'dtotal_ttc'][
$id],
289 'dtype' => $x_coll[$my_coll_thirdpartyid][
'dtype'][
$id],
290 'drate' => $x_coll[$my_coll_thirdpartyid][
'drate'][
$id],
291 'datef' => $x_coll[$my_coll_thirdpartyid][
'datef'][
$id],
292 'datep' => $x_coll[$my_coll_thirdpartyid][
'datep'][
$id],
294 'company_link' => $company_static->getNomUrl(1,
'', 20),
296 'ddate_start' => $x_coll[$my_coll_thirdpartyid][
'ddate_start'][
$id],
297 'ddate_end' => $x_coll[$my_coll_thirdpartyid][
'ddate_end'][
$id],
298 'totalht' => $x_coll[$my_coll_thirdpartyid][
'totalht_list'][
$id],
299 'vat' => $x_coll[$my_coll_thirdpartyid][
'vat_list'][
$id],
300 'link' => $invoice_customer->getNomUrl(1,
'', 12)
305 foreach (array_keys($x_paye) as $my_paye_thirdpartyid) {
306 $x_both[$my_paye_thirdpartyid][
'paye'][
'totalht'] = $x_paye[$my_paye_thirdpartyid][
'totalht'];
307 $x_both[$my_paye_thirdpartyid][
'paye'][
'vat'] = $x_paye[$my_paye_thirdpartyid][
'vat'];
308 if (!isset($x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'])) {
309 $x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'] = 0;
310 $x_both[$my_paye_thirdpartyid][
'coll'][
'vat'] = 0;
312 $x_both[$my_paye_thirdpartyid][
'paye'][
'links'] =
'';
313 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'] = array();
315 foreach ($x_paye[$my_paye_thirdpartyid][
'facid'] as
$id => $dummy) {
317 if ($x_paye[$my_paye_thirdpartyid][
'ptype'][
$id] ==
'ExpenseReportPayment') {
318 $expensereport->id = $x_paye[$my_paye_thirdpartyid][
'facid'][
$id];
319 $expensereport->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][
$id];
320 $expensereport->type = $x_paye[$my_paye_thirdpartyid][
'type'][
$id];
322 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
323 'id' => $x_paye[$my_paye_thirdpartyid][
'facid'][
$id],
324 'descr' => $x_paye[$my_paye_thirdpartyid][
'descr'][
$id],
326 'pid' => $x_paye[$my_paye_thirdpartyid][
'pid'][
$id],
327 'pref' => $x_paye[$my_paye_thirdpartyid][
'pref'][
$id],
328 'ptype' => $x_paye[$my_paye_thirdpartyid][
'ptype'][
$id],
329 'pstatus' => $x_paye[$my_paye_thirdpartyid][
'pstatus'][
$id],
330 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][
$id],
332 'payment_id' => $x_paye[$my_paye_thirdpartyid][
'payment_id'][
$id],
333 'payment_ref' => $x_paye[$my_paye_thirdpartyid][
'payment_ref'][
$id],
334 'payment_amount' => $x_paye[$my_paye_thirdpartyid][
'payment_amount'][
$id],
335 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][
$id]),
336 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][
$id]),
337 'dtype' => $x_paye[$my_paye_thirdpartyid][
'dtype'][
$id],
338 'drate' => $x_paye[$my_paye_thirdpartyid][
'drate'][
$id],
339 'ddate_start' => $x_paye[$my_paye_thirdpartyid][
'ddate_start'][
$id],
340 'ddate_end' => $x_paye[$my_paye_thirdpartyid][
'ddate_end'][
$id],
341 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][
$id]),
342 'vat' => $x_paye[$my_paye_thirdpartyid][
'vat_list'][
$id],
343 'link' => $expensereport->getNomUrl(1)
346 $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid][
'facid'][
$id];
347 $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][
$id];
348 $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid][
'type'][
$id];
351 $company_static->id = $x_paye[$my_paye_thirdpartyid][
'company_id'][
$id];
352 $company_static->name = $x_paye[$my_paye_thirdpartyid][
'company_name'][
$id];
353 $company_static->name_alias = $x_paye[$my_paye_thirdpartyid][
'company_alias'][
$id];
354 $company_static->email = $x_paye[$my_paye_thirdpartyid][
'company_email'][
$id];
355 $company_static->tva_intra = $x_paye[$my_paye_thirdpartyid][
'tva_intra'][
$id];
356 $company_static->client = $x_paye[$my_paye_thirdpartyid][
'company_client'][
$id];
357 $company_static->fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_fournisseur'][
$id];
358 $company_static->status = $x_paye[$my_paye_thirdpartyid][
'company_status'][
$id];
359 $company_static->code_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_code'][
$id];
360 $company_static->code_compta_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_accounting_code'][
$id];
361 $company_static->code_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_code'][
$id];
362 $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_accounting_code'][
$id];
364 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
365 'id' => $x_paye[$my_paye_thirdpartyid][
'facid'][
$id],
366 'descr' => $x_paye[$my_paye_thirdpartyid][
'descr'][
$id],
368 'pid' => $x_paye[$my_paye_thirdpartyid][
'pid'][
$id],
369 'pref' => $x_paye[$my_paye_thirdpartyid][
'pref'][
$id],
370 'ptype' => $x_paye[$my_paye_thirdpartyid][
'ptype'][
$id],
371 'pstatus' => (
int) $x_paye[$my_paye_thirdpartyid][
'pstatus'][
$id],
372 'pstatusbuy' => (
int) $x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][
$id],
374 'payment_id' => $x_paye[$my_paye_thirdpartyid][
'payment_id'][
$id],
375 'payment_ref' => $x_paye[$my_paye_thirdpartyid][
'payment_ref'][
$id],
376 'payment_amount' => $x_paye[$my_paye_thirdpartyid][
'payment_amount'][
$id],
377 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][
$id]),
378 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][
$id]),
379 'dtype' => $x_paye[$my_paye_thirdpartyid][
'dtype'][
$id],
380 'drate' => $x_paye[$my_paye_thirdpartyid][
'drate'][
$id],
381 'datef' => $x_paye[$my_paye_thirdpartyid][
'datef'][
$id],
382 'datep' => $x_paye[$my_paye_thirdpartyid][
'datep'][
$id],
384 'company_link' => $company_static->getNomUrl(1,
'', 20),
386 'ddate_start' => $x_paye[$my_paye_thirdpartyid][
'ddate_start'][
$id],
387 'ddate_end' => $x_paye[$my_paye_thirdpartyid][
'ddate_end'][
$id],
388 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][
$id]),
389 'vat' => $x_paye[$my_paye_thirdpartyid][
'vat_list'][
$id],
390 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
407 print
'<tr class="liste_titre">';
408 print
'<td class="left">'.$elementcust.
'</td>';
409 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
411 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
415 print
'<td class="right"></td>';
416 print
'<td class="left">'.$productcust.
'</td>';
418 print
'<td class="right">'.$amountcust.
'</td>';
419 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
421 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
422 print
'<td class="right">'.$vatcust.
'</td>';
425 $action =
"tvadetail";
426 $parameters = array();
427 $parameters[
"mode"] = $modetax;
429 $parameters[
"end"] = $date_end;
430 $parameters[
"type"] =
'vat';
432 $object = array(&$x_coll, &$x_paye, &$x_both);
434 $hookmanager->initHooks(array(
'externalbalance'));
435 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters,
$object, $action);
437 foreach (array_keys($x_coll) as $thirdparty_id) {
438 $subtot_coll_total_ht = 0;
439 $subtot_coll_vat = 0;
441 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'coll'][
'totalht'] > $min)) {
442 if (is_array($x_both[$thirdparty_id][
'coll'][
'detail'])) {
445 print
'<td class="tax_rate" colspan="2">';
446 if (is_numeric($thirdparty_id)) {
447 $company_static->fetch($thirdparty_id);
448 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
450 $tmpid = (int) preg_replace(
'/userid_/',
'', $thirdparty_id);
451 $user_static->fetch($tmpid);
452 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
454 print
'</td><td colspan="'.$span.
'"></td>';
457 foreach ($x_both[$thirdparty_id][
'coll'][
'detail'] as $index => $fields) {
459 usort($x_both[$thirdparty_id][
'coll'][
'detail'],
'cmp_fields_date');
463 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
465 if (!empty($fields[
'ddate_start'])) {
468 if (!empty($fields[
'ddate_end'])) {
472 print
'<tr class="oddeven">';
475 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
478 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
482 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
488 print
'<td class="right">'.$fields[
'drate'].
'</td>';
491 print
'<td class="left">';
492 if ($fields[
'pid']) {
493 $product_static->id = $fields[
'pid'];
494 $product_static->ref = $fields[
'pref'];
495 $product_static->type = $fields[
'dtype'];
496 $product_static->status = (int) $fields[
'pstatus'];
497 $product_static->status_buy = (int) $fields[
'pstatusbuy'];
499 print $product_static->getNomUrl(1);
505 $text =
img_object($langs->trans(
'Service'),
'service');
507 $text =
img_object($langs->trans(
'Product'),
'product');
509 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
510 if ($reg[1] ==
'DEPOSIT') {
511 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
512 } elseif ($reg[1] ==
'CREDIT_NOTE') {
513 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
515 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
527 print
'<td class="nowrap right"><span class="amount">';
528 print
price($fields[
'totalht']);
531 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
534 print
'</span></td>';
538 $ratiopaymentinvoice = 1;
540 print
'<td class="nowrap right">';
542 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
543 $payment_static->id = $fields[
'payment_id'];
544 $payment_static->ref = $fields[
'payment_ref'];
545 print $payment_static->getNomUrl(2,
'',
'', 0).
' ';
549 print $langs->trans(
"NA");
551 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
552 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
554 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
555 if (isset($fields[
'payment_amount'])) {
556 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
563 print
'<td class="nowrap right"><span class="amount">';
564 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
566 print
'</span></td>';
569 print
'<td class="nowrap right"><span class="amount">';
570 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
573 print
'</span></td>';
576 $subtot_coll_total_ht += $temp_ht;
577 $subtot_coll_vat += $temp_vat;
578 $x_coll_sum += $temp_vat;
583 print
'<tr class="liste_total">';
584 print
'<td colspan="4"></td>';
585 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
587 print
'<td class="nowrap right"> </td>';
588 print
'<td class="right"> </td>';
590 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
591 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
596 if (count($x_coll) == 0) {
597 print
'<tr class="liste_total">';
598 print
'<td colspan="4"></td>';
599 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
601 print
'<td class="nowrap right"> </td>';
602 print
'<td class="right"> </td>';
604 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
605 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
610 print
'<tr><td colspan="'.($span + 1).
'"> </td></tr>';
613 print
'<tr class="liste_titre liste_titre_topborder">';
614 print
'<td class="left">'.$elementsup.
'</td>';
615 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
617 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
621 print
'<td class="left"></td>';
622 print
'<td class="left">'.$productsup.
'</td>';
624 print
'<td class="right">'.$amountsup.
'</td>';
625 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
627 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
628 print
'<td class="right">'.$vatsup.
'</td>';
631 foreach (array_keys($x_paye) as $thirdparty_id) {
632 $subtot_paye_total_ht = 0;
633 $subtot_paye_vat = 0;
635 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'paye'][
'totalht'] > $min)) {
636 if (is_array($x_both[$thirdparty_id][
'paye'][
'detail'])) {
638 print
'<td class="tax_rate">';
639 if (is_numeric($thirdparty_id)) {
640 $company_static->fetch($thirdparty_id);
641 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
643 $tmpid = (int) preg_replace(
'/userid_/',
'', $thirdparty_id);
644 $user_static->fetch($tmpid);
645 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
647 print
'<td colspan="'.($span + 1).
'"></td>';
650 foreach ($x_both[$thirdparty_id][
'paye'][
'detail'] as $index => $fields) {
652 usort($x_both[$thirdparty_id][
'paye'][
'detail'],
'cmp_fields_date');
656 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
658 if (!empty($fields[
'ddate_start'])) {
661 if (!empty($fields[
'ddate_end'])) {
666 print
'<tr class="oddeven">';
669 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
672 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
676 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
682 print
'<td class="tdoverflowmax150">';
683 print $fields[
'company_link'];
687 print
'<td class="left">';
688 if ($fields[
'pid']) {
689 $product_static->id = $fields[
'pid'];
690 $product_static->ref = $fields[
'pref'];
691 $product_static->type = $fields[
'dtype'];
692 print $product_static->getNomUrl(1);
698 $text =
img_object($langs->trans(
'Service'),
'service');
700 $text =
img_object($langs->trans(
'Product'),
'product');
703 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
704 if ($reg[1] ==
'DEPOSIT') {
705 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
706 } elseif ($reg[1] ==
'CREDIT_NOTE') {
707 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
709 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
721 print
'<td class="nowrap right"><span class="amount">';
722 print
price($fields[
'totalht']);
725 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
728 print
'</span></td>';
732 $ratiopaymentinvoice = 1;
734 print
'<td class="nowrap right">';
735 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
736 $paymentfourn_static->id = $fields[
'payment_id'];
737 $paymentfourn_static->ref = $fields[
'payment_ref'];
738 print $paymentfourn_static->getNomUrl(2,
'',
'', 0);
743 print $langs->trans(
"NA");
745 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
746 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
748 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
749 if (isset($fields[
'payment_amount'])) {
750 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
757 print
'<td class="nowrap right"><span class="amount">';
758 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
760 print
'</span></td>';
763 print
'<td class="nowrap right"><span class="amount">';
764 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
767 print
'</span></td>';
770 $subtot_paye_total_ht += $temp_ht;
771 $subtot_paye_vat += $temp_vat;
772 $x_paye_sum += $temp_vat;
776 print
'<tr class="liste_total">';
777 print
'<td colspan="4"></td>';
778 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
780 print
'<td class="nowrap right"> </td>';
781 print
'<td class="right"> </td>';
783 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
784 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
789 if (count($x_paye) == 0) {
790 print
'<tr class="liste_total">';
791 print
'<td colspan="4"></td>';
792 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
794 print
'<td class="nowrap right"> </td>';
795 print
'<td class="right"> </td>';
797 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
798 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
803 print
'<tr><td colspan="'.($span + 2).
'"></td></tr>';
805 $diff = $x_coll_sum - $x_paye_sum;
806 print
'<tr class="liste_total">';
807 print
'<td class="liste_total" colspan="'.($span + 1).
'">'.$langs->trans(
"TotalToPay").
'</td>';
808 print
'<td class="liste_total nowrap right"><b>'.price(
price2num($diff,
'MT')).
"</b></td>\n";
831 if ($a[
'datep'] != $b[
'datep']) {
832 return $a[
'datep'] <=> $b[
'datep'];
835 return $a[
'datef'] <=> $b[
'datef'];
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of expense report.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0)
Look for collectable VAT clients in the chosen year (and month)
cmp_fields_date(&$a, &$b)
Helper compare function to sort lines by payment date first.