309 $pdf->SetFont(
'',
'B', $fontsize - 1);
310 $pdf->SetFillColor(230, 230, 230);
311 $pdf->Cell($widths[0], 6, $outputlangs->transnoentities(
"Date"), 1, 0,
'C',
true);
312 $pdf->Cell($widths[1], 6, $outputlangs->transnoentities(
"Element"), 1, 0,
'L',
true);
313 $pdf->Cell($widths[2], 6, $outputlangs->transnoentities(
"Status"), 1, 0,
'L',
true);
314 $pdf->Cell($widths[3], 6, $outputlangs->transnoentities(
"Debit"), 1, 0,
'R',
true);
315 $pdf->Cell($widths[4], 6, $outputlangs->transnoentities(
"Credit"), 1, 0,
'R',
true);
316 $pdf->Cell($widths[5], 6, $outputlangs->transnoentities(
"Balance"), 1, 1,
'R',
true);
317 $pdf->SetFont(
'',
'', $fontsize - 1);
325if ($action ==
'exportpdf' && $socid > 0 && $permissiontoreadinvoice) {
327 $societe->fetch($socid);
329 $TData = recapFournGetData($db, $societe, $sortfield, $sortorder, $search_date_start, $search_date_end, $opening, $search_status, $search_late);
331 $outputlangs = $langs;
332 $pdfinit =
reportPdfInit($outputlangs, (
string) $societe->name, $outputlangs->transnoentities(
"SupplierPreview"));
333 $pdf = $pdfinit[
'pdf'];
334 $margin = $pdfinit[
'margin'];
335 $pageheight = $pdfinit[
'pageheight'];
336 $usablewidth = $pdfinit[
'usablewidth'];
337 $fontsize = $pdfinit[
'fontsize'];
339 $ratios = array(0.12, 0.30, 0.16, 0.14, 0.14, 0.14);
341 foreach ($ratios as $ratio) {
342 $widths[] = round($usablewidth * $ratio, 2);
348 $pdf->SetXY($margin, $posy);
349 $pdf->SetFont(
'',
'B', $fontsize + 3);
350 $pdf->Cell($usablewidth, 8, $outputlangs->convToOutputCharset($outputlangs->transnoentities(
"SupplierPreview")), 0, 1,
'L');
351 $supplierlabel = $societe->name . ($societe->code_fournisseur ?
' (' . $societe->code_fournisseur .
')' :
'');
352 $pdf->SetFont(
'',
'B', $fontsize);
353 $pdf->Cell($usablewidth, 5, $outputlangs->transnoentities(
"ThirdParty") .
': ' . $outputlangs->convToOutputCharset($supplierlabel), 0, 1,
'L');
354 $pdf->SetFont(
'',
'', $fontsize - 1);
355 $periodlabel =
reportPeriodLabel($outputlangs, $search_date_start, $search_date_end);
356 if ($periodlabel !==
'') {
357 $pdf->Cell($usablewidth, 5, $outputlangs->transnoentities(
"Period") .
': ' . $outputlangs->convToOutputCharset($periodlabel), 0, 1,
'L');
359 $pdf->Cell($usablewidth, 5, $outputlangs->transnoentities(
"Date") .
': ' .
dol_print_date(
dol_now(),
'dayhour',
'tzuser', $outputlangs), 0, 1,
'L');
368 $pdf->Cell($usablewidth, $rowheight, $outputlangs->transnoentities(
"NoInvoice"), 1, 1,
'L');
370 foreach ($TData as $data) {
371 if ($pdf->GetY() + $rowheight > $pageheight - $margin) {
375 if (!empty($data[
'isopening'])) {
376 $pdf->SetFont(
'',
'B', $fontsize - 1);
377 $pdf->Cell($widths[0], $rowheight,
dol_print_date($data[
'date'],
'day',
'tzserver', $outputlangs), 1, 0,
'C');
378 $pdf->Cell($widths[1] + $widths[2], $rowheight, $outputlangs->convToOutputCharset((
string) $data[
'ref']), 1, 0,
'L',
false,
'', 1);
379 $pdf->Cell($widths[3], $rowheight,
'', 1, 0,
'R');
380 $pdf->Cell($widths[4], $rowheight,
'', 1, 0,
'R');
381 $pdf->Cell($widths[5], $rowheight,
price(
price2num((
float) $data[
'balance'],
'MT'), 0, $outputlangs), 1, 1,
'R');
382 $pdf->SetFont(
'',
'', $fontsize - 1);
385 $amount = (float)
price2num($data[
'amount'],
'MT');
386 $debit = ($amount > 0) ? $amount : 0;
387 $credit = ($amount < 0) ? abs($amount) : 0;
388 $totalDebit += $debit;
389 $totalCredit += $credit;
391 $pdf->Cell($widths[0], $rowheight,
dol_print_date($data[
'date'],
'day',
'auto', $outputlangs), 1, 0,
'C');
392 $pdf->Cell($widths[1], $rowheight, $outputlangs->convToOutputCharset((
string) ($data[
'ref'] ??
'')), 1, 0,
'L',
false,
'', 1);
393 $pdf->Cell($widths[2], $rowheight, $outputlangs->convToOutputCharset((
string) ($data[
'statuslabel'] ??
'')), 1, 0,
'L',
false,
'', 1);
394 $pdf->Cell($widths[3], $rowheight, ($debit ?
price($debit, 0, $outputlangs) :
''), 1, 0,
'R');
395 $pdf->Cell($widths[4], $rowheight, ($credit ?
price($credit, 0, $outputlangs) :
''), 1, 0,
'R');
396 $pdf->Cell($widths[5], $rowheight,
price(
price2num((
float) $data[
'balance'],
'MT'), 0, $outputlangs), 1, 1,
'R');
399 if (!empty($TData)) {
400 if ($pdf->GetY() + $rowheight > $pageheight - $margin) {
403 $pdf->SetFont(
'',
'B', $fontsize - 1);
404 $pdf->Cell($widths[0] + $widths[1] + $widths[2], $rowheight, $outputlangs->transnoentities(
"Total"), 1, 0,
'L');
405 $pdf->Cell($widths[3], $rowheight,
price($totalDebit, 0, $outputlangs), 1, 0,
'R');
406 $pdf->Cell($widths[4], $rowheight,
price($totalCredit, 0, $outputlangs), 1, 0,
'R');
407 $pdf->Cell($widths[5], $rowheight,
price(
price2num($opening + $totalDebit - $totalCredit,
'MT'), 0, $outputlangs), 1, 1,
'R');
410 $filename =
reportFileName($outputlangs->transnoentitiesnoconv(
"SupplierPreview"), ((
string) $societe->name !==
'' ? (
string) $societe->name : (string) $societe->id),
'pdf');
411 $pdf->Output($filename,
'I');
418if ($action ==
'exportxlsx' && $socid > 0 && $permissiontoreadinvoice) {
419 if (!class_exists(
'ZipArchive')) {
420 $langs->load(
"errors");
421 setEventMessages($langs->trans(
'ErrorPHPNeedModule',
'zip'),
null,
'errors');
422 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?socid=' . ((
int) $socid) . ($dol_openinpopup ?
'&dol_openinpopup=' . urlencode($dol_openinpopup) :
''));
427 $societe->fetch($socid);
429 $TData = recapFournGetData($db, $societe, $sortfield, $sortorder, $search_date_start, $search_date_end, $opening, $search_status, $search_late);
431 $spreadsheet =
reportXlsxInit($langs, $langs->transnoentitiesnoconv(
"SupplierPreview") .
' - ' . $societe->name, (
string) $societe->name);
432 $sheet = $spreadsheet->getActiveSheet();
438 $row = $headrows + 2;
439 $sheet->setCellValue(
'A' . $row, $langs->transnoentitiesnoconv(
"SupplierPreview"));
440 $sheet->getStyle(
'A' . $row)->getFont()->setBold(
true)->setSize(14);
442 $supplierlabel = $societe->name . ($societe->code_fournisseur ?
' (' . $societe->code_fournisseur .
')' :
'');
443 $sheet->setCellValueExplicit(
'A' . $row, $langs->transnoentitiesnoconv(
"ThirdParty") .
': ' . $supplierlabel, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
444 $sheet->getStyle(
'A' . $row)->getFont()->setBold(
true);
447 if ($periodlabel !==
'') {
448 $sheet->setCellValueExplicit(
'A' . $row, $langs->transnoentitiesnoconv(
"Period") .
': ' . $periodlabel, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
451 $sheet->setCellValueExplicit(
'A' . $row, $langs->transnoentitiesnoconv(
"Date") .
': ' .
dol_print_date(
dol_now(),
'dayhour',
'tzuser', $langs), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
456 $headers = array(
'A' =>
"Date",
'B' =>
"Element",
'C' =>
"Status",
'D' =>
"Debit",
'E' =>
"Credit",
'F' =>
"Balance");
457 foreach ($headers as $colletter => $key) {
458 $sheet->setCellValue($colletter . $headrow, $langs->transnoentitiesnoconv($key));
460 $sheet->getStyle(
'A' . $headrow .
':F' . $headrow)->getFont()->setBold(
true);
461 $sheet->getStyle(
'D' . $headrow .
':F' . $headrow)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT);
462 $sheet->freezePane(
'A' . ($headrow + 1));
464 $firstrow = $headrow + 1;
467 foreach ($TData as $data) {
468 if (!empty($data[
'isopening'])) {
470 $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')));
471 $sheet->setCellValueExplicit(
'B' . $row, (
string) $data[
'ref'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
472 $sheet->setCellValue(
'F' . $row, (
float)
price2num((
float) $data[
'balance'],
'MT'));
473 $sheet->getStyle(
'A' . $row .
':F' . $row)->getFont()->setBold(
true);
477 $amount = (float)
price2num($data[
'amount'],
'MT');
478 if (!empty($data[
'date'])) {
479 $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')));
481 $sheet->setCellValueExplicit(
'B' . $row, (
string) ($data[
'ref'] ??
''), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
482 $sheet->setCellValueExplicit(
'C' . $row, (
string) ($data[
'statuslabel'] ??
''), \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
484 $sheet->setCellValue(
'D' . $row, $amount);
485 } elseif ($amount < 0) {
486 $sheet->setCellValue(
'E' . $row, abs($amount));
488 $sheet->setCellValue(
'F' . $row, (
float)
price2num((
float) $data[
'balance'],
'MT'));
492 if ($row > $firstrow) {
494 $sheet->setCellValue(
'C' . $row, $langs->transnoentitiesnoconv(
"Total"));
495 $sheet->setCellValue(
'D' . $row,
'=SUM(D' . $firstrow .
':D' . $last .
')');
496 $sheet->setCellValue(
'E' . $row,
'=SUM(E' . $firstrow .
':E' . $last .
')');
497 $sheet->setCellValue(
'F' . $row, ($openrow ?
'=F' . $openrow .
'+' :
'=') .
'D' . $row .
'-E' . $row);
498 $sheet->getStyle(
'A' . $row .
':F' . $row)->getFont()->setBold(
true);
501 $sheet->getStyle(
'A' . $firstrow .
':A' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD);
502 $sheet->getStyle(
'D' . $firstrow .
':F' . $row)->getNumberFormat()->setFormatCode(
'#,##0.00');
503 foreach (array(
'A' => 12,
'B' => 34,
'C' => 20,
'D' => 14,
'E' => 14,
'F' => 14) as $colletter => $colwidth) {
504 $sheet->getColumnDimension($colletter)->setWidth($colwidth);
508 $sheet->getPageSetup()->setFitToPage(
true);
509 $sheet->getPageSetup()->setFitToWidth(1);
510 $sheet->getPageSetup()->setFitToHeight(0);
512 $filename =
reportFileName($langs->transnoentitiesnoconv(
"SupplierPreview"), ((
string) $societe->name !==
'' ? (
string) $societe->name : (string) $societe->id),
'xlsx');
524$form =
new Form($db);
525$userstatic =
new User($db);
527llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-fourn page-recap-fourn');
531 $societe->fetch($socid);
536 if (empty($dol_openinpopup)) {
539 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), 0,
'company');
540 dol_banner_tab($societe,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
544 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
"fournisseur",
"facture",
"lire") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
"supplier_invoice",
"lire"))) {
546 $morehtmlright =
reportExportButtons(
'&socid=' . ((
int) $socid) .
'&sortfield=' . urlencode($sortfield) .
'&sortorder=' . urlencode($sortorder) . $dateparam . $filterparam,
'recapfourn');
547 $titrelist = $langs->trans(
"SupplierPreview");
548 if ($search_status ===
'unpaid' && $search_late ===
'late') {
549 $titrelist = $langs->trans(
"CurrentOutstandingBillLate");
550 } elseif ($search_status ===
'unpaid' && $search_late ===
'') {
551 $titrelist = $langs->trans(
"CurrentOutstandingBill");
558 $param .=
'&socid=' . $socid;
560 if ($dol_openinpopup) {
561 $param .=
'&dol_openinpopup=' . urlencode($dol_openinpopup);
563 $param .= $dateparam . $filterparam;
566 print
'<form method="GET" action="' .
dol_escape_htmltag($_SERVER[
"PHP_SELF"]) .
'" name="recapfournfilter">';
567 print
'<input type="hidden" name="socid" value="' . ((int) $socid) .
'">';
568 if ($dol_openinpopup) {
569 print
'<input type="hidden" name="dol_openinpopup" value="' .
dol_escape_htmltag($dol_openinpopup) .
'">';
571 print
'<input type="hidden" name="sortfield" value="' .
dol_escape_htmltag($sortfield) .
'">';
572 print
'<input type="hidden" name="sortorder" value="' .
dol_escape_htmltag($sortorder) .
'">';
573 print
'<div class="div-table-responsive-no-min">';
574 print
'<div class="inline-block valignmiddle nowrapfordate">';
575 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
577 print
'<div class="inline-block valignmiddle nowrapfordate">';
578 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
580 print
'<div class="inline-block valignmiddle marginleftonlyshort">' . $langs->trans(
'Status') .
' ';
581 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);
583 print
'<div class="inline-block valignmiddle marginleftonlyshort">' . $langs->trans(
'Late') .
' ';
584 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);
586 print
'<div class="inline-block valignmiddle">' . $form->showFilterButtons() .
'</div>';
590 print
'<table class="noborder tagtable liste centpercent">';
591 print
'<tr class="liste_titre">';
592 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
593 print
'<td>' . $langs->trans(
"Element") .
'</td>';
594 print
'<td>' . $langs->trans(
"Status") .
'</td>';
595 print
'<td class="right">' . $langs->trans(
"Debit") .
'</td>';
596 print
'<td class="right">' . $langs->trans(
"Credit") .
'</td>';
597 print
'<td class="right">' . $langs->trans(
"Balance") .
'</td>';
598 print
'<td class="right">' . $langs->trans(
"Author") .
'</td>';
602 $TData = recapFournGetData($db, $societe, $sortfield, $sortorder, $search_date_start, $search_date_end, $opening, $search_status, $search_late);
605 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">' . $langs->trans(
"NoInvoice") .
'</span></td></tr>';
611 foreach ($TData as $data) {
612 if (!empty($data[
'isopening'])) {
613 print
'<tr class="oddeven">';
614 print
'<td class="center">' .
dol_print_date($data[
'date'],
'day',
'tzserver') .
'</td>';
615 print
'<td colspan="2"><b>' .
dol_escape_htmltag((
string) $data[
'ref']) .
'</b></td>';
616 print
'<td></td><td></td>';
617 print
'<td class="right"><span class="amount"><b>' .
price($data[
'balance']) .
'</b></span></td>';
623 if (!empty($data[
'fk_facture'])) {
624 $html_class =
'facid-' . $data[
'fk_facture'];
625 } elseif (!empty($data[
'fk_paiement'])) {
626 $html_class =
'payid-' . $data[
'fk_paiement'];
629 print
'<tr class="oddeven ' . $html_class .
'">';
632 if (!empty($data[
'fk_facture'])) {
639 print
'<td>' . $data[
'link'] .
"</td>\n";
641 print
'<td class="left">' . $data[
'status'] .
'</td>';
643 print
'<td class="right">' . (($data[
'amount'] > 0) ?
price(abs($data[
'amount'])) :
'') .
"</td>\n";
645 $totalDebit += ($data[
'amount'] > 0) ? abs($data[
'amount']) : 0;
647 print
'<td class="right">' . (($data[
'amount'] > 0) ?
'' :
price(abs($data[
'amount']))) .
"</td>\n";
648 $totalCredit += ($data[
'amount'] > 0) ? 0 : abs($data[
'amount']);
651 print
'<td class="right"><span class="amount">' .
price($data[
'balance']) .
"</span></td>\n";
654 print
'<td class="nowrap right">';
655 print $data[
'author'];
661 print
'<tr class="liste_total">';
662 print
'<td colspan="3"> </td>';
663 print
'<td class="right">' .
price($totalDebit) .
'</td>';
664 print
'<td class="right">' .
price($totalCredit) .
'</td>';
665 print
'<td class="right">' .
price(
price2num($opening + $totalDebit - $totalCredit,
'MT')) .
'</td>';