353 $pdf->SetFont(
'',
'B', $fontsize - 1);
354 $pdf->SetFillColor(230, 230, 230);
355 $pdf->Cell($widths[0], 6, $outputlangs->transnoentities(
"Date"), 1, 0,
'C',
true);
356 $pdf->Cell($widths[1], 6, $outputlangs->transnoentities(
"Element"), 1, 0,
'L',
true);
357 $pdf->Cell($widths[2], 6, $outputlangs->transnoentities(
"Status"), 1, 0,
'L',
true);
358 $pdf->Cell($widths[3], 6, $outputlangs->transnoentities(
"Debit"), 1, 0,
'R',
true);
359 $pdf->Cell($widths[4], 6, $outputlangs->transnoentities(
"Credit"), 1, 0,
'R',
true);
360 $pdf->Cell($widths[5], 6, $outputlangs->transnoentities(
"Balance"), 1, 1,
'R',
true);
361 $pdf->SetFont(
'',
'', $fontsize - 1);
369$parameters = array(
'socid' => $id);
370$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
372 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
375if (empty($reshook) && in_array($action, array(
'exportpdf',
'exportxlsx')) && !$permissiontoreadinvoice) {
379if (empty($reshook) && $action ==
'exportpdf' && $id > 0 && $permissiontoreadinvoice) {
382 $TData = recapComptaGetData($db, $object, $hookmanager, $id, $sortfield, $sortorder, $errors, $search_date_start, $search_date_end, $opening, $search_status, $search_late);
383 foreach ($errors as $err) {
384 dol_syslog(
'recap-compta.php exportpdf '.$err, LOG_WARNING);
387 $outputlangs = $langs;
388 $pdfinit =
reportPdfInit($outputlangs, (
string)
$object->name, $outputlangs->transnoentities(
"CustomerPreview"));
389 $pdf = $pdfinit[
'pdf'];
390 $margin = $pdfinit[
'margin'];
391 $pageheight = $pdfinit[
'pageheight'];
392 $usablewidth = $pdfinit[
'usablewidth'];
393 $fontsize = $pdfinit[
'fontsize'];
395 $ratios = array(0.12, 0.30, 0.16, 0.14, 0.14, 0.14);
397 foreach ($ratios as $ratio) {
398 $widths[] = round($usablewidth * $ratio, 2);
404 $pdf->SetXY($margin, $posy);
405 $pdf->SetFont(
'',
'B', $fontsize + 3);
406 $pdf->Cell($usablewidth, 8, $outputlangs->convToOutputCharset($outputlangs->transnoentities(
"CustomerPreview")), 0, 1,
'L');
407 $customerlabel =
$object->name.($object->code_client ?
' ('.$object->code_client.
')' :
'');
408 $pdf->SetFont(
'',
'B', $fontsize);
409 $pdf->Cell($usablewidth, 5, $outputlangs->transnoentities(
"ThirdParty").
': '.$outputlangs->convToOutputCharset($customerlabel), 0, 1,
'L');
410 $pdf->SetFont(
'',
'', $fontsize - 1);
411 $periodlabel =
reportPeriodLabel($outputlangs, $search_date_start, $search_date_end);
412 if ($periodlabel !==
'') {
413 $pdf->Cell($usablewidth, 5, $outputlangs->transnoentities(
"Period").
': '.$outputlangs->convToOutputCharset($periodlabel), 0, 1,
'L');
415 $pdf->Cell($usablewidth, 5, $outputlangs->transnoentities(
"Date").
': '.
dol_print_date(
dol_now(),
'dayhour',
'tzuser', $outputlangs), 0, 1,
'L');
424 $pdf->Cell($usablewidth, $rowheight, $outputlangs->transnoentities(
"NoInvoice"), 1, 1,
'L');
426 foreach ($TData as $data) {
427 if ($pdf->GetY() + $rowheight > $pageheight - $margin) {
431 if (!empty($data[
'isopening'])) {
432 $pdf->SetFont(
'',
'B', $fontsize - 1);
433 $pdf->Cell($widths[0], $rowheight,
dol_print_date($data[
'date'],
'day',
'tzserver', $outputlangs), 1, 0,
'C');
434 $pdf->Cell($widths[1] + $widths[2], $rowheight, $outputlangs->convToOutputCharset((
string) $data[
'ref']), 1, 0,
'L',
false,
'', 1);
435 $pdf->Cell($widths[3], $rowheight,
'', 1, 0,
'R');
436 $pdf->Cell($widths[4], $rowheight,
'', 1, 0,
'R');
437 $pdf->Cell($widths[5], $rowheight,
price(
price2num((
float) $data[
'balance'],
'MT'), 0, $outputlangs), 1, 1,
'R');
438 $pdf->SetFont(
'',
'', $fontsize - 1);
441 $amount = (float)
price2num($data[
'amount'],
'MT');
442 $debit = ($amount > 0) ? $amount : 0;
443 $credit = ($amount < 0) ? abs($amount) : 0;
444 $totalDebit += $debit;
445 $totalCredit += $credit;
447 $pdf->Cell($widths[0], $rowheight,
dol_print_date($data[
'date'],
'day',
'auto', $outputlangs), 1, 0,
'C');
448 $pdf->Cell($widths[1], $rowheight, $outputlangs->convToOutputCharset((
string) ($data[
'ref'] ??
'')), 1, 0,
'L',
false,
'', 1);
449 $pdf->Cell($widths[2], $rowheight, $outputlangs->convToOutputCharset((
string) ($data[
'statuslabel'] ??
'')), 1, 0,
'L',
false,
'', 1);
450 $pdf->Cell($widths[3], $rowheight, ($debit ?
price($debit, 0, $outputlangs) :
''), 1, 0,
'R');
451 $pdf->Cell($widths[4], $rowheight, ($credit ?
price($credit, 0, $outputlangs) :
''), 1, 0,
'R');
452 $pdf->Cell($widths[5], $rowheight,
price(
price2num((
float) $data[
'balance'],
'MT'), 0, $outputlangs), 1, 1,
'R');
455 if (!empty($TData)) {
456 if ($pdf->GetY() + $rowheight > $pageheight - $margin) {
459 $pdf->SetFont(
'',
'B', $fontsize - 1);
460 $pdf->Cell($widths[0] + $widths[1] + $widths[2], $rowheight, $outputlangs->transnoentities(
"Total"), 1, 0,
'L');
461 $pdf->Cell($widths[3], $rowheight,
price($totalDebit, 0, $outputlangs), 1, 0,
'R');
462 $pdf->Cell($widths[4], $rowheight,
price($totalCredit, 0, $outputlangs), 1, 0,
'R');
463 $pdf->Cell($widths[5], $rowheight,
price(
price2num($opening + $totalDebit - $totalCredit,
'MT'), 0, $outputlangs), 1, 1,
'R');
466 $filename =
reportFileName($outputlangs->transnoentitiesnoconv(
"CustomerPreview"), ((
string)
$object->name !==
'' ? (
string)
$object->name : (string)
$object->id),
'pdf');
467 $pdf->Output($filename,
'I');
474if (empty($reshook) && $action ==
'exportxlsx' && $id > 0 && $permissiontoreadinvoice) {
475 if (!class_exists(
'ZipArchive')) {
476 $langs->load(
"errors");
477 setEventMessages($langs->trans(
'ErrorPHPNeedModule',
'zip'),
null,
'errors');
478 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?socid='.((
int) $id).($dol_openinpopup ?
'&dol_openinpopup='.urlencode($dol_openinpopup) :
''));
484 $TData = recapComptaGetData($db, $object, $hookmanager, $id, $sortfield, $sortorder, $errors, $search_date_start, $search_date_end, $opening, $search_status, $search_late);
485 foreach ($errors as $err) {
486 dol_syslog(
'recap-compta.php exportxlsx '.$err, LOG_WARNING);
490 $sheet = $spreadsheet->getActiveSheet();
496 $row = $headrows + 2;
497 $sheet->setCellValue(
'A'.$row, $langs->transnoentitiesnoconv(
"CustomerPreview"));
498 $sheet->getStyle(
'A'.$row)->getFont()->setBold(
true)->setSize(14);
500 $customerlabel =
$object->name.($object->code_client ?
' ('.$object->code_client.
')' :
'');
501 $sheet->setCellValueExplicit(
'A'.$row, $langs->transnoentitiesnoconv(
"ThirdParty").
': '.$customerlabel, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
502 $sheet->getStyle(
'A'.$row)->getFont()->setBold(
true);
505 if ($periodlabel !==
'') {
506 $sheet->setCellValueExplicit(
'A'.$row, $langs->transnoentitiesnoconv(
"Period").
': '.$periodlabel, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
509 $sheet->setCellValueExplicit(
'A'.$row, $langs->transnoentitiesnoconv(
"Date").
': '.
dol_print_date(
dol_now(),
'dayhour',
'tzuser', $langs), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
514 $headers = array(
'A' =>
"Date",
'B' =>
"Element",
'C' =>
"Status",
'D' =>
"Debit",
'E' =>
"Credit",
'F' =>
"Balance");
515 foreach ($headers as $colletter => $key) {
516 $sheet->setCellValue($colletter.$headrow, $langs->transnoentitiesnoconv($key));
518 $sheet->getStyle(
'A'.$headrow.
':F'.$headrow)->getFont()->setBold(
true);
519 $sheet->getStyle(
'D'.$headrow.
':F'.$headrow)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT);
520 $sheet->freezePane(
'A'.($headrow + 1));
522 $firstrow = $headrow + 1;
525 foreach ($TData as $data) {
526 if (!empty($data[
'isopening'])) {
528 $sheet->setCellValue(
'A'.$row, \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel((
int)
dol_print_date($data[
'date'],
'%Y'), (
int)
dol_print_date($data[
'date'],
'%m'), (
int)
dol_print_date($data[
'date'],
'%d')));
529 $sheet->setCellValueExplicit(
'B'.$row, (
string) $data[
'ref'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
530 $sheet->setCellValue(
'F'.$row, (
float)
price2num((
float) $data[
'balance'],
'MT'));
531 $sheet->getStyle(
'A'.$row.
':F'.$row)->getFont()->setBold(
true);
535 $amount = (float)
price2num($data[
'amount'],
'MT');
536 if (!empty($data[
'date'])) {
537 $sheet->setCellValue(
'A'.$row, \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel((
int)
dol_print_date($data[
'date'],
'%Y'), (
int)
dol_print_date($data[
'date'],
'%m'), (
int)
dol_print_date($data[
'date'],
'%d')));
539 $sheet->setCellValueExplicit(
'B'.$row, (
string) ($data[
'ref'] ??
''), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
540 $sheet->setCellValueExplicit(
'C'.$row, (
string) ($data[
'statuslabel'] ??
''), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
542 $sheet->setCellValue(
'D'.$row, $amount);
543 } elseif ($amount < 0) {
544 $sheet->setCellValue(
'E'.$row, abs($amount));
546 $sheet->setCellValue(
'F'.$row, (
float)
price2num((
float) $data[
'balance'],
'MT'));
550 if ($row > $firstrow) {
552 $sheet->setCellValue(
'C'.$row, $langs->transnoentitiesnoconv(
"Total"));
553 $sheet->setCellValue(
'D'.$row,
'=SUM(D'.$firstrow.
':D'.$last.
')');
554 $sheet->setCellValue(
'E'.$row,
'=SUM(E'.$firstrow.
':E'.$last.
')');
555 $sheet->setCellValue(
'F'.$row, ($openrow ?
'=F'.$openrow.
'+' :
'=').
'D'.$row.
'-E'.$row);
556 $sheet->getStyle(
'A'.$row.
':F'.$row)->getFont()->setBold(
true);
559 $sheet->getStyle(
'A'.$firstrow.
':A'.$row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD);
560 $sheet->getStyle(
'D'.$firstrow.
':F'.$row)->getNumberFormat()->setFormatCode(
'#,##0.00');
561 foreach (array(
'A' => 12,
'B' => 34,
'C' => 20,
'D' => 14,
'E' => 14,
'F' => 14) as $colletter => $colwidth) {
562 $sheet->getColumnDimension($colletter)->setWidth($colwidth);
566 $sheet->getPageSetup()->setFitToPage(
true);
567 $sheet->getPageSetup()->setFitToWidth(1);
568 $sheet->getPageSetup()->setFitToHeight(0);
582$form =
new Form($db);
584$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Summary");
586 $title =
$object->name.
' - '.$langs->trans(
"Summary");
588$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
595 $param .=
'&socid='.$id;
597 if ($dol_openinpopup) {
598 $param .=
'&dol_openinpopup='.urlencode($dol_openinpopup);
600 $param .= $dateparam.$filterparam;
602 if (empty($dol_openinpopup)) {
605 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), 0,
'company');
606 dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom',
'',
'', 0,
'',
'', 1);
610 if ($permissiontoreadinvoice) {
612 $morehtmlright =
reportExportButtons(
'&socid='.((
int) $id).
'&sortfield='.urlencode($sortfield).
'&sortorder='.urlencode($sortorder).$dateparam.$filterparam,
'recapcompta');
613 $titrelist = $langs->trans(
"CustomerPreview");
614 if ($search_status ===
'unpaid' && $search_late ===
'late') {
615 $titrelist = $langs->trans(
"CurrentOutstandingBillLate");
616 } elseif ($search_status ===
'unpaid' && $search_late ===
'') {
617 $titrelist = $langs->trans(
"CurrentOutstandingBill");
622 print
'<form method="GET" action="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'" name="recapcomptafilter">';
623 print
'<input type="hidden" name="socid" value="'.((int) $id).
'">';
624 if ($dol_openinpopup) {
625 print
'<input type="hidden" name="dol_openinpopup" value="'.dol_escape_htmltag($dol_openinpopup).
'">';
627 print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
628 print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
629 print
'<div class="div-table-responsive-no-min">';
630 print
'<div class="inline-block valignmiddle nowrapfordate">';
631 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
633 print
'<div class="inline-block valignmiddle nowrapfordate">';
634 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
636 print
'<div class="inline-block valignmiddle marginleftonlyshort">'.$langs->trans(
'Status').
' ';
637 print $form->selectarray(
'search_status', array(
'unpaid' => $langs->trans(
'Unpaid'),
'paid' => $langs->trans(
'Paid')), $search_status, $langs->trans(
'All'), 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 0);
639 print
'<div class="inline-block valignmiddle marginleftonlyshort">'.$langs->trans(
'Late').
' ';
640 print $form->selectarray(
'search_late', array(
'late' => $langs->trans(
'Late'),
'notlate' => $langs->trans(
'NotLate')), $search_late, $langs->trans(
'All'), 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 0);
642 print
'<div class="inline-block valignmiddle">'.$form->showFilterButtons().
'</div>';
646 print
'<table class="noborder tagtable liste centpercent">';
647 print
'<tr class="liste_titre">';
648 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
649 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
651 print
'<td>'.$langs->trans(
"Element").
'</td>';
652 print
'<td>'.$langs->trans(
"Status").
'</td>';
653 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
654 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
655 print
'<td class="right">'.$langs->trans(
"Balance").
'</td>';
656 print
'<td class="right">'.$langs->trans(
"Author").
'</td>';
661 $TData = recapComptaGetData($db, $object, $hookmanager, $id, $sortfield, $sortorder, $errors, $search_date_start, $search_date_end, $opening, $search_status, $search_late);
662 foreach ($errors as $err) {
663 print
'<tr class="oddeven"><td colspan="7"><span class="error">'.dol_escape_htmltag($err).
'</span></td></tr>';
667 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</span></td></tr>';
673 foreach ($TData as $data) {
674 if (!empty($data[
'isopening'])) {
675 print
'<tr class="oddeven">';
676 print
'<td class="center">'.dol_print_date($data[
'date'],
'day',
'tzserver').
'</td>';
677 print
'<td colspan="2"><b>'.dol_escape_htmltag((
string) $data[
'ref']).
'</b></td>';
678 print
'<td></td><td></td>';
679 print
'<td class="right"><span class="amount"><b>'.price($data[
'balance']).
'</b></span></td>';
685 if (!empty($data[
'fk_facture'])) {
686 $html_class =
'facid-'.$data[
'fk_facture'];
687 } elseif (!empty($data[
'fk_paiement'])) {
688 $html_class =
'payid-'.$data[
'fk_paiement'];
691 print
'<tr class="oddeven '.$html_class.
'">';
694 if (!empty($data[
'fk_facture'])) {
697 print
'<td class="center" title="'.dol_escape_htmltag($datedetail).
'">';
701 print
'<td>'.$data[
'link'].
"</td>\n";
703 print
'<td class="left">'.$data[
'status'].
'</td>';
705 $amount = (float)
price2num($data[
'amount'],
'MT');
706 print
'<td class="right">'.(($amount > 0) ?
price($amount) :
'').
"</td>\n";
707 $totalDebit += ($amount > 0) ? $amount : 0;
709 print
'<td class="right">'.(($amount < 0) ?
price(abs($amount)) :
'').
"</td>\n";
710 $totalCredit += ($amount < 0) ? abs($amount) : 0;
713 print
'<td class="right"><span class="amount">'.price($data[
'balance']).
"</span></td>\n";
716 print
'<td class="nowrap right">';
717 print $data[
'author'];
723 print
'<tr class="liste_total">';
724 print
'<td colspan="3"> </td>';
725 print
'<td class="right">'.price($totalDebit).
'</td>';
726 print
'<td class="right">'.price($totalCredit).
'</td>';
727 print
'<td class="right">'.price(
price2num($opening + $totalDebit - $totalCredit,
'MT')).
'</td>';