2020-11-09 14:30:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
2022-04-27 13:20:41 +10:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-11-09 14:30:50 +01:00
|
|
|
*
|
2021-06-16 16:58:16 +10:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-11-09 14:30:50 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Services\Invoice;
|
|
|
|
|
|
|
|
|
|
use App\Models\ClientContact;
|
|
|
|
|
use App\Models\Design;
|
|
|
|
|
use App\Models\Invoice;
|
2022-12-29 02:22:48 +11:00
|
|
|
use App\Services\Pdf\PdfService;
|
2020-11-09 14:30:50 +01:00
|
|
|
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
|
|
|
|
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
2021-04-02 22:44:44 +11:00
|
|
|
use App\Utils\HostedPDF\NinjaPdf;
|
2020-11-09 14:30:50 +01:00
|
|
|
use App\Utils\HtmlEngine;
|
2021-04-02 22:44:44 +11:00
|
|
|
use App\Utils\PhantomJS\Phantom;
|
2020-11-09 14:30:50 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
|
use App\Utils\Traits\Pdf\PdfMaker;
|
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
|
|
|
|
|
|
class GenerateDeliveryNote
|
|
|
|
|
{
|
|
|
|
|
use MakesHash, PdfMaker;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \App\Models\Invoice
|
|
|
|
|
*/
|
|
|
|
|
private $invoice;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \App\Models\ClientContact
|
|
|
|
|
*/
|
|
|
|
|
private $contact;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var mixed
|
|
|
|
|
*/
|
|
|
|
|
private $disk;
|
|
|
|
|
|
|
|
|
|
public function __construct(Invoice $invoice, ClientContact $contact = null, $disk = null)
|
|
|
|
|
{
|
|
|
|
|
$this->invoice = $invoice;
|
|
|
|
|
|
|
|
|
|
$this->contact = $contact;
|
|
|
|
|
|
2021-07-07 21:39:49 +10:00
|
|
|
$this->disk = $disk ?? config('filesystems.default');
|
2020-11-09 14:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function run()
|
|
|
|
|
{
|
|
|
|
|
|
2021-06-12 21:50:01 +10:00
|
|
|
$invitation = $this->invoice->invitations->first();
|
2022-12-29 02:13:44 +11:00
|
|
|
|
2022-01-30 18:39:35 +11:00
|
|
|
$file_path = sprintf('%sdelivery_note.pdf', $this->invoice->client->invoice_filepath($invitation));
|
2020-11-09 14:30:50 +01:00
|
|
|
|
2022-12-29 02:22:48 +11:00
|
|
|
$pdf = (new PdfService($invitation, 'delivery_note'))->getPdf();
|
2020-12-17 15:44:01 +01:00
|
|
|
|
2022-10-24 08:42:38 +11:00
|
|
|
Storage::disk($this->disk)->put($file_path, $pdf);
|
2022-11-01 21:20:28 +11:00
|
|
|
|
2021-07-07 21:39:49 +10:00
|
|
|
return $file_path;
|
2022-12-29 02:22:48 +11:00
|
|
|
|
2020-11-09 14:30:50 +01:00
|
|
|
}
|
|
|
|
|
}
|