1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Merg PDFs

This commit is contained in:
David Bomba 2022-10-30 10:28:59 +11:00
parent e377861606
commit 9d09424e5e
2 changed files with 50 additions and 1 deletions

View File

@ -169,7 +169,7 @@ abstract class QueryFilters
public function clientFilter()
{
if (auth()->guard('contact')->user()) {
return $this->builder->whereClientId(auth()->guard('contact')->user()->client->id);
return $this->builder->where('client_id', auth()->guard('contact')->user()->client->id);
}
}
@ -179,6 +179,15 @@ abstract class QueryFilters
$created_at = date('Y-m-d H:i:s', $value);
if(is_string($created_at)){
$created_at = strtotime(str_replace("/","-",$created_at));
if(!$created_at)
return $this->builder;
}
return $this->builder->where('created_at', '>=', $created_at);
}

View File

@ -0,0 +1,40 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\PdfMaker;
use \setasign\Fpdi\Fpdi;
class PdfMerge
{
public function __construct(private array $file_paths) {}
public function run()
{
$pdf = new FPDI();
foreach ($this->file_paths as $file) {
$pageCount = $pdf->setSourceFile($file);
for ($i = 0; $i < $pageCount; $i++) {
$tpl = $pdf->importPage($i + 1, '/MediaBox');
$pdf->addPage();
$pdf->useTemplate($tpl);
}
}
return $pdf->Output('S');
}
}