mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 22:54:25 +01:00
107 lines
2.7 KiB
PHP
107 lines
2.7 KiB
PHP
<?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\Jobs\Vendor;
|
|
|
|
use App\Exceptions\FilePermissionsFailure;
|
|
use App\Libraries\MultiDB;
|
|
use App\Models\Account;
|
|
use App\Models\Credit;
|
|
use App\Models\CreditInvitation;
|
|
use App\Models\Design;
|
|
use App\Models\Invoice;
|
|
use App\Models\InvoiceInvitation;
|
|
use App\Models\Quote;
|
|
use App\Models\QuoteInvitation;
|
|
use App\Models\RecurringInvoice;
|
|
use App\Models\RecurringInvoiceInvitation;
|
|
use App\Services\PdfMaker\Design as PdfDesignModel;
|
|
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
|
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
|
use App\Services\Pdf\PdfService;
|
|
use App\Utils\HostedPDF\NinjaPdf;
|
|
use App\Utils\HtmlEngine;
|
|
use App\Utils\Ninja;
|
|
use App\Utils\PhantomJS\Phantom;
|
|
use App\Utils\Traits\MakesHash;
|
|
use App\Utils\Traits\MakesInvoiceHtml;
|
|
use App\Utils\Traits\NumberFormatter;
|
|
use App\Utils\Traits\Pdf\PDF;
|
|
use App\Utils\Traits\Pdf\PageNumbering;
|
|
use App\Utils\Traits\Pdf\PdfMaker;
|
|
use App\Utils\VendorHtmlEngine;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Lang;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use setasign\Fpdi\PdfParser\StreamReader;
|
|
|
|
class CreatePurchaseOrderPdf implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public $entity;
|
|
|
|
private $disk;
|
|
|
|
public $invitation;
|
|
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @param $invitation
|
|
*/
|
|
public function __construct($invitation, $disk = null)
|
|
{
|
|
$this->invitation = $invitation;
|
|
|
|
$this->entity = $invitation->purchase_order;
|
|
|
|
$this->vendor = $invitation->contact->vendor;
|
|
|
|
$this->disk = $disk ?? config('filesystems.default');
|
|
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
|
|
MultiDB::setDb($this->invitation->company->db);
|
|
|
|
$file_path = $this->vendor->purchase_order_filepath($this->invitation);
|
|
|
|
$pdf = (new PdfService($this->invitation, 'purchase_order'))->getPdf();
|
|
|
|
if ($pdf) {
|
|
try {
|
|
Storage::disk($this->disk)->put($file_path, $pdf);
|
|
} catch (\Exception $e) {
|
|
throw new FilePermissionsFailure($e->getMessage());
|
|
}
|
|
}
|
|
|
|
return $pdf;
|
|
|
|
}
|
|
|
|
public function failed($e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
}
|