mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Refactor for PDF code paths
This commit is contained in:
parent
4fe9e1cef4
commit
a669328a80
@ -1,184 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Events\Credit\CreditWasViewed;
|
||||
use App\Events\Invoice\InvoiceWasViewed;
|
||||
use App\Events\Misc\InvitationWasViewed;
|
||||
use App\Events\Quote\QuoteWasViewed;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* EntityViewController
|
||||
* @deprecated 5.7 ?
|
||||
*/
|
||||
class EntityViewController extends Controller
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
/**
|
||||
* Available options for viewing.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $entity_types = ['invoice', 'quote', 'credit', 'recurring_invoice'];
|
||||
|
||||
/**
|
||||
* Show the entity outside client portal.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* @param string $invitation_key
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function index(string $entity_type, string $invitation_key)
|
||||
{
|
||||
if (! in_array($entity_type, $this->entity_types)) {
|
||||
abort(404, 'Entity not found');
|
||||
}
|
||||
|
||||
$invitation_entity = sprintf('App\\Models\\%sInvitation', ucfirst($entity_type));
|
||||
|
||||
$key = $entity_type.'_id';
|
||||
|
||||
$invitation = $invitation_entity::where('key', $invitation_key)
|
||||
->with('contact.client')
|
||||
->firstOrFail();
|
||||
|
||||
$contact = $invitation->contact;
|
||||
$client = $contact->client;
|
||||
$entity = $invitation->{$entity_type};
|
||||
|
||||
if (is_null($contact->password) || empty($contact->password)) {
|
||||
return redirect("/client/password/reset?email={$contact->email}");
|
||||
}
|
||||
|
||||
if ((bool) $invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
|
||||
session()->flash("{$entity_type}_VIEW_{$entity->hashed_id}", true);
|
||||
}
|
||||
|
||||
if (! session("{$entity_type}_VIEW_{$entity->hashed_id}")) {
|
||||
return redirect()->route('client.entity_view.password', compact('entity_type', 'invitation_key'));
|
||||
}
|
||||
|
||||
return $this->render('view_entity.index', [
|
||||
'root' => 'themes',
|
||||
'entity' => $entity,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for entering password.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* @param string $invitation_key
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function password(string $entity_type, string $invitation_key)
|
||||
{
|
||||
return $this->render('view_entity.password', [
|
||||
'root' => 'themes',
|
||||
'entity_type' => $entity_type,
|
||||
]);
|
||||
}
|
||||
|
||||
/**`
|
||||
* Handle the password check.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* @param string $invitation_key
|
||||
*
|
||||
* @return Redirector|RedirectResponse|mixed
|
||||
*/
|
||||
public function handlePassword(string $entity_type, string $invitation_key)
|
||||
{
|
||||
if (! in_array($entity_type, $this->entity_types)) {
|
||||
abort(404, 'Entity not found');
|
||||
}
|
||||
|
||||
$invitation_entity = sprintf('App\\Models\\%sInvitation', ucfirst($entity_type));
|
||||
|
||||
$key = $entity_type.'_id';
|
||||
|
||||
$invitation = $invitation_entity::where('key', $invitation_key)->firstOrFail();
|
||||
|
||||
$contact = $invitation->contact;
|
||||
|
||||
$check = Hash::check(request()->password, $contact->password);
|
||||
|
||||
$entity_class = sprintf('App\\Models\\%s', ucfirst($entity_type));
|
||||
|
||||
$entity = $entity_class::findOrFail($invitation->{$key});
|
||||
|
||||
if ($check) {
|
||||
session()->flash("{$entity_type}_VIEW_{$entity->hashed_id}", true);
|
||||
|
||||
return redirect()->route('client.entity_view', compact('entity_type', 'invitation_key'));
|
||||
}
|
||||
|
||||
session()->flash('PASSWORD_FAILED', true);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function handlePasswordSet(Request $request)
|
||||
{
|
||||
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($request->entity_type)).'Invitation';
|
||||
$key = $request->entity_type.'_id';
|
||||
|
||||
$invitation = $entity_obj::where('key', $request->invitation_key)
|
||||
->whereHas($request->entity_type, function ($query) {
|
||||
$query->where('is_deleted', 0);
|
||||
})
|
||||
->with('contact.client')
|
||||
->firstOrFail();
|
||||
|
||||
$contact = $invitation->contact;
|
||||
$contact->password = Hash::make($request->password);
|
||||
$contact->save();
|
||||
|
||||
$request->session()->invalidate();
|
||||
auth()->guard('contact')->loginUsingId($contact->id, true);
|
||||
|
||||
if (! $invitation->viewed_date) {
|
||||
$invitation->markViewed();
|
||||
|
||||
if (! session()->get('is_silent')) {
|
||||
event(new InvitationWasViewed($invitation->{$request->entity_type}, $invitation, $invitation->{$request->entity_type}->company, Ninja::eventVars()));
|
||||
}
|
||||
|
||||
if (! session()->get('is_silent')) {
|
||||
$this->fireEntityViewedEvent($invitation, $request->entity_type);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('client.'.$request->entity_type.'.show', [$request->entity_type => $this->encodePrimaryKey($invitation->{$key})]);
|
||||
}
|
||||
|
||||
private function fireEntityViewedEvent($invitation, $entity_string)
|
||||
{
|
||||
switch ($entity_string) {
|
||||
case 'invoice':
|
||||
event(new InvoiceWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
break;
|
||||
case 'quote':
|
||||
event(new QuoteWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
break;
|
||||
case 'credit':
|
||||
event(new CreditWasViewed($invitation, $invitation->company, Ninja::eventVars()));
|
||||
break;
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ use App\Models\InvoiceInvitation;
|
||||
use App\Events\Quote\QuoteWasViewed;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Events\Credit\CreditWasViewed;
|
||||
use App\Events\Contact\ContactLoggedIn;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
@ -195,7 +196,7 @@ class InvitationController extends Controller
|
||||
|
||||
$file_name = $invitation->{$entity}->numberFormatter().'.pdf';
|
||||
|
||||
$file = (new CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
$file = (new CreateRawPdf($invitation))->handle();
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
@ -212,6 +213,41 @@ class InvitationController extends Controller
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function handlePasswordSet(Request $request)
|
||||
{
|
||||
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($request->entity_type)).'Invitation';
|
||||
$key = $request->entity_type.'_id';
|
||||
|
||||
$invitation = $entity_obj::where('key', $request->invitation_key)
|
||||
->whereHas($request->entity_type, function ($query) {
|
||||
$query->where('is_deleted', 0);
|
||||
})
|
||||
->with('contact.client')
|
||||
->firstOrFail();
|
||||
|
||||
$contact = $invitation->contact;
|
||||
$contact->password = Hash::make($request->password);
|
||||
$contact->save();
|
||||
|
||||
$request->session()->invalidate();
|
||||
auth()->guard('contact')->loginUsingId($contact->id, true);
|
||||
|
||||
if (! $invitation->viewed_date) {
|
||||
$invitation->markViewed();
|
||||
|
||||
if (! session()->get('is_silent')) {
|
||||
event(new InvitationWasViewed($invitation->{$request->entity_type}, $invitation, $invitation->{$request->entity_type}->company, Ninja::eventVars()));
|
||||
}
|
||||
|
||||
if (! session()->get('is_silent')) {
|
||||
$this->fireEntityViewedEvent($invitation, $request->entity_type);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('client.'.$request->entity_type.'.show', [$request->entity_type => $this->encodePrimaryKey($invitation->{$key})]);
|
||||
}
|
||||
|
||||
public function paymentRouter(string $contact_key, string $payment_id)
|
||||
{
|
||||
/** @var \App\Models\ClientContact $contact **/
|
||||
|
@ -107,7 +107,7 @@ class InvoiceController extends Controller
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
return response()->make($file, 200, $headers);
|
||||
|
@ -137,7 +137,7 @@ class QuoteController extends Controller
|
||||
|
||||
if ($quote_invitations->count() == 1) {
|
||||
$invitation = $quote_invitations->first();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo $file;
|
||||
}, $invitation->quote->numberFormatter().".pdf", ['Content-Type' => 'application/pdf']);
|
||||
@ -152,7 +152,7 @@ class QuoteController extends Controller
|
||||
$zipFile = new \PhpZip\ZipFile();
|
||||
try {
|
||||
foreach ($quote_invitations as $invitation) {
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
$zipFile->addFromString($invitation->quote->numberFormatter() . '.pdf', $file);
|
||||
}
|
||||
|
||||
|
@ -533,14 +533,14 @@ class CreditController extends BaseController
|
||||
}
|
||||
});
|
||||
|
||||
ZipCredits::dispatch($credits->pluck('id')->toArray(), $credits->first()->company, $user);
|
||||
ZipCredits::dispatch($credits->pluck('id')->toArray(), $user->company(), $user);
|
||||
|
||||
return response()->json(['message' => ctrans('texts.sent_message')], 200);
|
||||
}
|
||||
|
||||
if ($action == 'bulk_print' && $user->can('view', $credits->first())) {
|
||||
$paths = $credits->map(function ($credit) {
|
||||
return (new \App\Jobs\Entity\CreateRawPdf($credit->invitations->first(), $credit->company->db))->handle();
|
||||
return (new \App\Jobs\Entity\CreateRawPdf($credit->invitations->first()))->handle();
|
||||
});
|
||||
|
||||
$merge = (new PdfMerge($paths->toArray()))->run();
|
||||
@ -593,8 +593,8 @@ class CreditController extends BaseController
|
||||
$file = $credit->service()->getCreditPdf($credit->invitations->first());
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
echo $file;
|
||||
}, $credit->numberFormatter().'.pdf', ['Content-Type' => 'application/pdf']);
|
||||
break;
|
||||
case 'archive':
|
||||
$this->credit_repository->archive($credit);
|
||||
@ -710,8 +710,9 @@ class CreditController extends BaseController
|
||||
}
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), $headers);
|
||||
echo $file;
|
||||
}, $credit->numberFormatter().'.pdf', $headers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -528,7 +528,7 @@ class InvoiceController extends BaseController
|
||||
|
||||
if ($action == 'bulk_print' && $user->can('view', $invoices->first())) {
|
||||
$paths = $invoices->map(function ($invoice) {
|
||||
return (new \App\Jobs\Entity\CreateRawPdf($invoice->invitations->first(), $invoice->company->db))->handle();
|
||||
return (new \App\Jobs\Entity\CreateRawPdf($invoice->invitations->first()))->handle();
|
||||
});
|
||||
|
||||
$merge = (new PdfMerge($paths->toArray()))->run();
|
||||
@ -798,7 +798,7 @@ class InvoiceController extends BaseController
|
||||
|
||||
$file_name = $invoice->numberFormatter().'.pdf';
|
||||
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
|
@ -367,7 +367,6 @@ class PurchaseOrderController extends BaseController
|
||||
|
||||
$purchase_order = $purchase_order->service()
|
||||
->triggeredActions($request)
|
||||
// ->touchPdf()
|
||||
->save();
|
||||
|
||||
event(new PurchaseOrderWasUpdated($purchase_order, $purchase_order->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
@ -562,7 +562,7 @@ class QuoteController extends BaseController
|
||||
|
||||
if ($action == 'bulk_print' && $user->can('view', $quotes->first())) {
|
||||
$paths = $quotes->map(function ($quote) {
|
||||
return (new \App\Jobs\Entity\CreateRawPdf($quote->invitations->first(), $quote->company->db))->handle();
|
||||
return (new \App\Jobs\Entity\CreateRawPdf($quote->invitations->first()))->handle();
|
||||
});
|
||||
|
||||
$merge = (new PdfMerge($paths->toArray()))->run();
|
||||
@ -724,8 +724,8 @@ class QuoteController extends BaseController
|
||||
$file = $quote->service()->getQuotePdf();
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), ['Content-Type' => 'application/pdf']);
|
||||
echo $file;
|
||||
}, $quote->numberFormatter().".pdf", ['Content-Type' => 'application/pdf']);
|
||||
|
||||
case 'restore':
|
||||
$this->quote_repo->restore($quote);
|
||||
@ -828,17 +828,18 @@ class QuoteController extends BaseController
|
||||
|
||||
App::setLocale($invitation->contact->preferredLocale());
|
||||
|
||||
$file = $quote->service()->getQuotePdf($contact);
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
if (request()->input('inline') == 'true') {
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
}
|
||||
|
||||
$file = $quote->service()->getQuotePdf($contact);
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file), $headers);
|
||||
echo $file;
|
||||
}, $quote->numberFormatter().".pdf", $headers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -580,7 +580,7 @@ class RecurringInvoiceController extends BaseController
|
||||
|
||||
$file_name = $invoice->numberFormatter().'.pdf';
|
||||
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
|
@ -98,7 +98,7 @@ class PdfSlot extends Component
|
||||
if($this->entity instanceof \App\Models\PurchaseOrder)
|
||||
$file = (new CreatePurchaseOrderPdf($this->invitation, $this->invitation->company->db))->rawPdf();
|
||||
else
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation, $this->invitation->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation))->handle();
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
|
@ -55,7 +55,7 @@ class ZipCredits implements ShouldQueue
|
||||
|
||||
try {
|
||||
foreach ($invitations as $invitation) {
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $this->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
$zipFile->addFromString($invitation->credit->numberFormatter() . '.pdf', $file);
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,9 @@ use App\Services\PdfMaker\Design as PdfDesignModel;
|
||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
||||
|
||||
class CreateRawPdf implements ShouldQueue
|
||||
class CreateRawPdf
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash, PageNumbering;
|
||||
use NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash, PageNumbering;
|
||||
|
||||
public Invoice | Credit | Quote | RecurringInvoice $entity;
|
||||
|
||||
@ -59,13 +59,10 @@ class CreateRawPdf implements ShouldQueue
|
||||
public $entity_string = '';
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param $invitation
|
||||
*/
|
||||
public function __construct($invitation, $db)
|
||||
public function __construct($invitation)
|
||||
{
|
||||
MultiDB::setDb($db);
|
||||
|
||||
$this->invitation = $invitation;
|
||||
|
||||
@ -99,8 +96,6 @@ class CreateRawPdf implements ShouldQueue
|
||||
$pdf = $ps->boot()->getPdf();
|
||||
nlog("pdf timer = ". $ps->execution_time);
|
||||
|
||||
|
||||
|
||||
/* Forget the singleton*/
|
||||
App::forgetInstance('translator');
|
||||
|
||||
|
@ -60,7 +60,7 @@ class ZipQuotes implements ShouldQueue
|
||||
try {
|
||||
|
||||
foreach ($invitations as $invitation) {
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation, $this->company->db))->handle();
|
||||
$file = (new \App\Jobs\Entity\CreateRawPdf($invitation))->handle();
|
||||
$zipFile->addFromString($invitation->quote->numberFormatter() . '.pdf', $file);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class CreditEmailEngine extends BaseEmailEngine
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->credit->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
|
||||
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
|
||||
$pdf = ((new CreateRawPdf($this->invitation))->handle());
|
||||
|
||||
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->credit->numberFormatter().'.pdf']]);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
->setTextBody($text_body);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
|
||||
$pdf = ((new CreateRawPdf($this->invitation))->handle());
|
||||
|
||||
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->invoice->numberFormatter().'.pdf']]);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
||||
|
||||
if(!$template_in_use)
|
||||
{
|
||||
$pdf = ((new CreateRawPdf($invoice->invitations->first(), $invoice->company->db))->handle());
|
||||
$pdf = ((new CreateRawPdf($invoice->invitations->first()))->handle());
|
||||
$file_name = $invoice->numberFormatter().'.pdf';
|
||||
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class QuoteEmailEngine extends BaseEmailEngine
|
||||
->setTextBody($text_body);
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
$pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle());
|
||||
$pdf = ((new CreateRawPdf($this->invitation))->handle());
|
||||
|
||||
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->quote->numberFormatter().'.pdf']]);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class BaseModel extends Model
|
||||
if($this instanceof \App\Models\PurchaseOrder)
|
||||
return "data:application/pdf;base64,".base64_encode((new CreatePurchaseOrderPdf($invitation, $invitation->company->db))->rawPdf());
|
||||
|
||||
return "data:application/pdf;base64,".base64_encode((new CreateRawPdf($invitation, $invitation->company->db))->handle());
|
||||
return "data:application/pdf;base64,".base64_encode((new CreateRawPdf($invitation))->handle());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Traits\MakesReminders;
|
||||
use App\Services\Credit\CreditService;
|
||||
use App\Services\Ledger\LedgerService;
|
||||
@ -26,8 +26,6 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
use App\Models\Presenters\CreditPresenter;
|
||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
/**
|
||||
* App\Models\Credit
|
||||
@ -360,6 +358,7 @@ class Credit extends BaseModel
|
||||
$this->saveQuietly();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
@ -380,7 +379,7 @@ class Credit extends BaseModel
|
||||
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
} elseif (Ninja::isHosted() && $portal) {
|
||||
$file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
// $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
@ -402,7 +401,7 @@ class Credit extends BaseModel
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
$file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
// $file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Traits\Inviteable;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -155,12 +155,13 @@ class CreditInvitation extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path()
|
||||
{
|
||||
$storage_path = Storage::url($this->credit->client->quote_filepath($this).$this->credit->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->credit->client->credit_filepath($this).$this->credit->numberFormatter().'.pdf')) {
|
||||
(new CreateEntityPdf($this))->handle();
|
||||
// (new CreateEntityPdf($this))->handle();
|
||||
}
|
||||
|
||||
return $storage_path;
|
||||
|
@ -14,9 +14,8 @@ namespace App\Models;
|
||||
use App\Utils\Ninja;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Traits\MakesReminders;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use App\Services\Ledger\LedgerService;
|
||||
@ -26,12 +25,10 @@ use App\Utils\Traits\MakesInvoiceValues;
|
||||
use App\Events\Invoice\InvoiceWasEmailed;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
use App\Models\Presenters\EntityPresenter;
|
||||
use App\Models\Presenters\InvoicePresenter;
|
||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
use App\Utils\Traits\Invoice\ActionsInvoice;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Events\Invoice\InvoiceReminderWasEmailed;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
/**
|
||||
* App\Models\Invoice
|
||||
@ -529,6 +526,7 @@ class Invoice extends BaseModel
|
||||
return $invoice_calc->build();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
|
||||
@ -559,7 +557,7 @@ class Invoice extends BaseModel
|
||||
if (Ninja::isHosted() && $portal && $file_exists) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
} elseif (Ninja::isHosted()) {
|
||||
$file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
// $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
@ -584,7 +582,7 @@ class Invoice extends BaseModel
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
$file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
// $file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
@ -12,11 +12,10 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\Invoice\InvoiceWasUpdated;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Inviteable;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -158,13 +157,14 @@ class InvoiceInvitation extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path(): string
|
||||
{
|
||||
$storage_path = Storage::url($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf')) {
|
||||
event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
(new CreateEntityPdf($this))->handle();
|
||||
// (new CreateEntityPdf($this))->handle();
|
||||
}
|
||||
|
||||
return $storage_path;
|
||||
|
@ -281,6 +281,7 @@ class PurchaseOrder extends BaseModel
|
||||
});
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
|
@ -13,7 +13,7 @@ namespace App\Models;
|
||||
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\Presenters\QuotePresenter;
|
||||
use App\Services\Quote\QuoteService;
|
||||
use App\Utils\Ninja;
|
||||
@ -314,6 +314,7 @@ class Quote extends BaseModel
|
||||
return new QuoteService($this);
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
@ -334,7 +335,7 @@ class Quote extends BaseModel
|
||||
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
} elseif (Ninja::isHosted() && $portal) {
|
||||
$file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
// $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
|
||||
@ -354,7 +355,7 @@ class Quote extends BaseModel
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
$file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
// $file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
@ -11,10 +11,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Traits\Inviteable;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -141,12 +139,14 @@ class QuoteInvitation extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
|
||||
public function pdf_file_path()
|
||||
{
|
||||
$storage_path = Storage::url($this->quote->client->quote_filepath($this).$this->quote->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->quote->client->quote_filepath($this).$this->quote->numberFormatter().'.pdf')) {
|
||||
(new CreateEntityPdf($this))->handle();
|
||||
// (new CreateEntityPdf($this))->handle();
|
||||
}
|
||||
|
||||
return $storage_path;
|
||||
|
@ -15,10 +15,9 @@ use App\Utils\Ninja;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Jobs\Util\UnlinkFile;
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Repositories\CreditRepository;
|
||||
use App\Repositories\PaymentRepository;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -180,32 +179,6 @@ class CreditService
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes we need to refresh the
|
||||
* PDF when it is updated etc.
|
||||
* @return self
|
||||
*/
|
||||
public function touchPdf($force = false)
|
||||
{
|
||||
try {
|
||||
if ($force) {
|
||||
$this->credit->invitations->each(function ($invitation) {
|
||||
(new CreateEntityPdf($invitation))->handle();
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->credit->invitations->each(function ($invitation) {
|
||||
CreateEntityPdf::dispatch($invitation);
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
nlog('failed creating invoices in Touch PDF');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fillDefaults()
|
||||
{
|
||||
$settings = $this->credit->client->getMergedSettings();
|
||||
|
@ -11,38 +11,20 @@
|
||||
|
||||
namespace App\Services\Credit;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Services\AbstractService;
|
||||
|
||||
class GetCreditPdf extends AbstractService
|
||||
{
|
||||
public $credit;
|
||||
|
||||
public $contact;
|
||||
|
||||
public $invitation;
|
||||
|
||||
public function __construct($invitation)
|
||||
public function __construct(public CreditInvitation $invitation)
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
$this->credit = $invitation->credit;
|
||||
$this->contact = $invitation->contact;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
if (! $this->contact) {
|
||||
$this->contact = $this->credit->client->primary_contact()->first() ?: $this->credit->client->contacts()->first();
|
||||
}
|
||||
|
||||
$path = $this->credit->client->credit_filepath($this->invitation);
|
||||
return (new CreateRawPdf($this->invitation))->handle();
|
||||
|
||||
$file_path = $path.$this->credit->numberFormatter().'.pdf';
|
||||
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file_path = (new CreateEntityPdf($this->invitation))->handle();
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ use App\Utils\Traits\MakesHash;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\DataMapper\EmailTemplateDefaults;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use App\Jobs\Vendor\CreatePurchaseOrderPdf;
|
||||
@ -308,7 +307,7 @@ class EmailDefaults
|
||||
($this->email->email_object->entity instanceof Invoice ||
|
||||
$this->email->email_object->entity instanceof Quote ||
|
||||
$this->email->email_object->entity instanceof Credit)) {
|
||||
$pdf = ((new CreateRawPdf($this->email->email_object->invitation, $this->email->company->db))->handle());
|
||||
$pdf = ((new CreateRawPdf($this->email->email_object->invitation))->handle());
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,10 @@
|
||||
|
||||
namespace App\Services\Invoice;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Jobs\Invoice\CreateEInvoice;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\ClientContact;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Services\AbstractService;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class GetInvoicePdf extends AbstractService
|
||||
{
|
||||
@ -36,19 +34,7 @@ class GetInvoicePdf extends AbstractService
|
||||
$invitation = $this->invoice->invitations->first();
|
||||
}
|
||||
|
||||
$path = $this->invoice->client->invoice_filepath($invitation);
|
||||
return (new CreateRawPdf($invitation))->handle();
|
||||
|
||||
$file_path = $path.$this->invoice->numberFormatter().'.pdf';
|
||||
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file = Storage::disk($disk)->exists($file_path);
|
||||
|
||||
if (! $file) {
|
||||
$file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
}
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace App\Services\Invoice;
|
||||
|
||||
use App\Events\Invoice\InvoiceWasArchived;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Jobs\Inventory\AdjustProductInventory;
|
||||
use App\Jobs\Invoice\CreateEInvoice;
|
||||
@ -20,7 +19,6 @@ use App\Libraries\Currency\Conversion\CurrencyApi;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Task;
|
||||
use App\Utils\Ninja;
|
||||
@ -192,7 +190,7 @@ class InvoiceService
|
||||
{
|
||||
$invitation = $contact ? $this->invoice->invitations()->where('contact_id', $contact->id)->first() : $this->invoice->invitations()->first();
|
||||
|
||||
return (new CreateRawPdf($invitation, $invitation->company->db))->handle();
|
||||
return (new CreateRawPdf($invitation))->handle();
|
||||
}
|
||||
|
||||
public function getInvoiceDeliveryNote(Invoice $invoice, \App\Models\ClientContact $contact = null)
|
||||
@ -486,39 +484,6 @@ class InvoiceService
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes we need to refresh the
|
||||
* PDF when it is updated etc.
|
||||
* @return InvoiceService
|
||||
*/
|
||||
public function touchPdf($force = false)
|
||||
{
|
||||
try {
|
||||
if ($force) {
|
||||
$this->invoice->invitations->each(function ($invitation) {
|
||||
(new CreateEntityPdf($invitation))->handle();
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
$this->invoice->invitations->each(function ($invitation) {
|
||||
CreateEntityPdf::dispatch($invitation);
|
||||
|
||||
if ($invitation->invoice->client->getSetting('enable_e_invoice') && $invitation instanceof InvoiceInvitation) {
|
||||
CreateEInvoice::dispatch($invitation->invoice);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} catch (\Exception $e) {
|
||||
nlog('failed creating invoices in Touch PDF');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*When a reminder is sent we want to touch the dates they were sent*/
|
||||
public function touchReminder(string $reminder_template)
|
||||
{
|
||||
|
@ -98,27 +98,6 @@ class PurchaseOrderService
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function touchPdf($force = false)
|
||||
{
|
||||
try {
|
||||
if ($force) {
|
||||
$this->purchase_order->invitations->each(function ($invitation) {
|
||||
(new CreatePurchaseOrderPdf($invitation))->handle();
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->purchase_order->invitations->each(function ($invitation) {
|
||||
CreatePurchaseOrderPdf::dispatch($invitation);
|
||||
});
|
||||
} catch(\Exception $e) {
|
||||
nlog("failed creating purchase orders in Touch PDF");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function add_to_inventory()
|
||||
{
|
||||
if ($this->purchase_order->status_id >= PurchaseOrder::STATUS_RECEIVED) {
|
||||
|
@ -11,18 +11,15 @@
|
||||
|
||||
namespace App\Services\Quote;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Quote;
|
||||
use App\Models\ClientContact;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Services\AbstractService;
|
||||
|
||||
class GetQuotePdf extends AbstractService
|
||||
{
|
||||
public function __construct(public Quote $quote, public ?ClientContact $contact = null)
|
||||
{
|
||||
$this->quote = $quote;
|
||||
|
||||
$this->contact = $contact;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -37,16 +34,7 @@ class GetQuotePdf extends AbstractService
|
||||
$invitation = $this->quote->invitations->first();
|
||||
}
|
||||
|
||||
$path = $this->quote->client->quote_filepath($invitation);
|
||||
return (new CreateRawPdf($invitation))->handle();
|
||||
|
||||
$file_path = $path . $this->quote->numberFormatter() . '.pdf';
|
||||
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
|
||||
$file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ use App\Models\Quote;
|
||||
use App\Models\Project;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Exceptions\QuoteConversion;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Repositories\QuoteRepository;
|
||||
use App\Events\Quote\QuoteWasApproved;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -133,32 +132,7 @@ class QuoteService
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes we need to refresh the
|
||||
* PDF when it is updated etc.
|
||||
*
|
||||
* @return QuoteService
|
||||
*/
|
||||
public function touchPdf($force = false)
|
||||
{
|
||||
try {
|
||||
if ($force) {
|
||||
$this->quote->invitations->each(function ($invitation) {
|
||||
(new CreateEntityPdf($invitation))->handle();
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->quote->invitations->each(function ($invitation) {
|
||||
CreateEntityPdf::dispatch($invitation);
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
nlog('failed creating invoices in Touch PDF');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function approveWithNoCoversion($contact = null) :self
|
||||
{
|
||||
|
@ -11,22 +11,15 @@
|
||||
|
||||
namespace App\Services\Recurring;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\ClientContact;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Services\AbstractService;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class GetInvoicePdf extends AbstractService
|
||||
{
|
||||
public $entity;
|
||||
|
||||
public $contact;
|
||||
|
||||
public function __construct($entity, ClientContact $contact = null)
|
||||
public function __construct(public $entity, public ClientContact $contact = null)
|
||||
{
|
||||
$this->entity = $entity;
|
||||
|
||||
$this->contact = $contact;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -37,18 +30,11 @@ class GetInvoicePdf extends AbstractService
|
||||
|
||||
$invitation = $this->entity->invitations->where('client_contact_id', $this->contact->id)->first();
|
||||
|
||||
$path = $this->entity->client->recurring_invoice_filepath($invitation);
|
||||
|
||||
$file_path = $path.$this->entity->hashed_id.'.pdf';
|
||||
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file = Storage::disk($disk)->exists($file_path);
|
||||
|
||||
if (! $file) {
|
||||
$file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
if (! $invitation) {
|
||||
$invitation = $this->entity->invitations->first();
|
||||
}
|
||||
|
||||
return $file_path;
|
||||
return (new CreateRawPdf($invitation))->handle();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
@extends('portal.ninja2020.layout.clean')
|
||||
|
||||
@push('head')
|
||||
<meta name="pdf-url" content="{{ asset($entity->pdf_file_path(null, 'url',true)) }}">
|
||||
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
|
||||
<script src="{{ asset('vendor/alpinejs@2.8.2/alpine.js') }}" defer></script>
|
||||
@endpush
|
||||
|
||||
@section('body')
|
||||
<div class="container mx-auto my-10">
|
||||
<div class="flex items-center justify-between">
|
||||
<section class="flex items-center">
|
||||
<button class="input-label" id="previous-page-button">
|
||||
<svg class="w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
<button class="input-label" id="next-page-button">
|
||||
<svg class="w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
</button>
|
||||
</section>
|
||||
<div class="flex items-center">
|
||||
@if($entity instanceof App\Models\Invoice)
|
||||
<button class="button button-primary bg-blue-600">{{ ctrans('texts.pay_now') }}</button>
|
||||
@elseif($$entity instanceof App\Models\Quote)
|
||||
<button class="button button-primary bg-blue-600">{{ ctrans('texts.approve') }}</button>
|
||||
@endif
|
||||
<button class="button button-primary bg-blue-600 ml-2">{{ ctrans('texts.download') }}</button>
|
||||
<div x-data="{ open: false }" @keydown.escape="open = false" @click.away="open = false" class="relative inline-block text-left ml-2">
|
||||
<div>
|
||||
<button @click="open = !open" class="flex items-center text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600">
|
||||
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg">
|
||||
<div class="rounded-md bg-white ring-1 ring-black ring-opacity-5">
|
||||
<div class="py-1">
|
||||
<a target="_blank" href="{{ asset($entity->pdf_file_path(null, 'url',true)) }}" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center">
|
||||
<canvas id="pdf-placeholder" class="shadow-lg border rounded-lg bg-white mt-4 p-4"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('footer')
|
||||
@vite('resources/js/clients/shared/pdf.js')
|
||||
@endsection
|
@ -31,10 +31,7 @@ Route::post('client/password/email', [ContactForgotPasswordController::class, 's
|
||||
Route::get('client/password/reset/{token}', [ContactResetPasswordController::class, 'showResetForm'])->name('client.password.reset')->middleware(['domain_db', 'contact_account','locale', 'throttle:portal']);
|
||||
Route::post('client/password/reset', [ContactResetPasswordController::class, 'reset'])->name('client.password.update')->middleware(['domain_db', 'contact_account','locale', 'throttle:portal']);
|
||||
|
||||
Route::get('view/{entity_type}/{invitation_key}', [App\Http\Controllers\ClientPortal\EntityViewController::class, 'index'])->name('client.entity_view');
|
||||
Route::get('view/{entity_type}/{invitation_key}/password', [App\Http\Controllers\ClientPortal\EntityViewController::class ,'password'])->name('client.entity_view.password');
|
||||
Route::post('view/{entity_type}/{invitation_key}/password', [App\Http\Controllers\ClientPortal\EntityViewController::class, 'handlePassword']);
|
||||
Route::post('set_password', [App\Http\Controllers\ClientPortal\EntityViewController::class, 'handlePasswordSet'])->name('client.set_password')->middleware('domain_db');
|
||||
Route::post('set_password', [App\Http\Controllers\ClientPortal\InvitationController::class, 'handlePasswordSet'])->name('client.set_password')->middleware('domain_db');
|
||||
|
||||
Route::get('tmp_pdf/{hash}', [App\Http\Controllers\ClientPortal\TempRouteController::class, 'index'])->name('tmp_pdf');
|
||||
|
||||
|
@ -11,10 +11,8 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -41,24 +39,4 @@ class PdfCreatorTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
// public function testCreditPdfCreated()
|
||||
// {
|
||||
// $credit_path = (new CreateEntityPdf($this->credit->invitations->first()))->handle();
|
||||
|
||||
// $this->assertTrue(Storage::exists($credit_path));
|
||||
// }
|
||||
|
||||
public function testInvoicePdfCreated()
|
||||
{
|
||||
$invoice_path = (new CreateEntityPdf($this->invoice->invitations->first()))->handle();
|
||||
|
||||
$this->assertTrue(Storage::exists($invoice_path));
|
||||
}
|
||||
|
||||
public function testQuotePdfCreated()
|
||||
{
|
||||
$quote_path = (new CreateEntityPdf($this->quote->invitations->first()))->handle();
|
||||
|
||||
$this->assertTrue(Storage::exists($quote_path));
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ use App\Models\Payment;
|
||||
use App\Utils\HtmlEngine;
|
||||
use Tests\MockAccountData;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Services\PdfMaker\PdfMaker;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Services\Template\TemplateService;
|
||||
use App\Services\PdfMaker\Design as PdfDesignModel;
|
||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||
@ -607,7 +607,7 @@ class TemplateTest extends TestCase
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$pdf = (new CreateEntityPdf($i))->handle();
|
||||
$pdf = (new CreateRawPdf($i))->handle();
|
||||
|
||||
$end = microtime(true);
|
||||
|
||||
@ -621,7 +621,7 @@ class TemplateTest extends TestCase
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
$pdf = (new CreateEntityPdf($this->invoice->invitations->first()))->handle();
|
||||
$pdf = (new CreateRawPdf($this->invoice->invitations->first()))->handle();
|
||||
|
||||
$end = microtime(true);
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
namespace Tests\Integration;
|
||||
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
@ -34,8 +33,6 @@ class InvoiceUploadTest extends TestCase
|
||||
|
||||
public function testInvoiceUploadWorks()
|
||||
{
|
||||
CreateEntityPdf::dispatchSync($this->invoice->invitations->first());
|
||||
|
||||
$this->assertNotNull($this->invoice->service()->getInvoicePdf($this->invoice->client->primary_contact()->first()));
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,8 @@
|
||||
|
||||
use Tests\TestCase;
|
||||
use Tests\MockAccountData;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Jobs\Invoice\CreateEInvoice;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use horstoeko\zugferd\ZugferdDocumentReader;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
@ -66,7 +65,7 @@ class EInvoiceTest extends TestCase
|
||||
*/
|
||||
public function checkEmbededPDFFile()
|
||||
{
|
||||
$pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle();
|
||||
$pdf = (new CreateRawPdf($this->invoice->invitations()->first()))->handle();
|
||||
$document = ZugferdDocumentReader::readAndGuessFromContent($pdf);
|
||||
$document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
|
||||
$this->assertEquals($this->invoice->number, $documentno);
|
||||
|
Loading…
x
Reference in New Issue
Block a user