mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Delete PDF helper
This commit is contained in:
parent
73557bdc59
commit
d238d53b26
@ -33,10 +33,12 @@ class SetEmailDb
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($request->input('email') && config('ninja.db.multi_db_enabled')) {
|
if ($request->input('email') && config('ninja.db.multi_db_enabled')) {
|
||||||
nlog("trying to find db");
|
|
||||||
if (! MultiDB::userFindAndSetDb($request->input('email'))) {
|
|
||||||
|
if (! MultiDB::userFindAndSetDb($request->input('email')))
|
||||||
return response()->json($error, 400);
|
return response()->json($error, 400);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// else {
|
// else {
|
||||||
// return response()->json($error, 403);
|
// return response()->json($error, 403);
|
||||||
|
@ -92,6 +92,8 @@ class CreateEntityPdf implements ShouldQueue
|
|||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
Lang::replace(Ninja::transformTranslations($this->entity->client->getMergedSettings()));
|
Lang::replace(Ninja::transformTranslations($this->entity->client->getMergedSettings()));
|
||||||
|
|
||||||
|
$this->entity->service()->deletePdf();
|
||||||
|
|
||||||
if (config('ninja.phantomjs_pdf_generation')) {
|
if (config('ninja.phantomjs_pdf_generation')) {
|
||||||
return (new Phantom)->generate($this->invitation);
|
return (new Phantom)->generate($this->invitation);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ class UnlinkFile implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
// nlog("deleting");
|
||||||
|
// nlog($this->file_path);
|
||||||
Storage::disk($this->disk)->delete($this->file_path);
|
Storage::disk($this->disk)->delete($this->file_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,9 +187,10 @@ class MultiDB
|
|||||||
|
|
||||||
//multi-db active
|
//multi-db active
|
||||||
foreach (self::$dbs as $db) {
|
foreach (self::$dbs as $db) {
|
||||||
if (User::on($db)->where(['email' => $email])->get()->count() >= 1) { // if user already exists, validation will fail
|
|
||||||
|
if (User::on($db)->where(['email' => $email])->count() >= 1)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Credit;
|
namespace App\Services\Credit;
|
||||||
|
|
||||||
|
use App\Jobs\Util\UnlinkFile;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
@ -134,7 +135,14 @@ class CreditService
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deletePdf()
|
||||||
|
{
|
||||||
|
UnlinkFile::dispatchNow(config('filesystems.default'), $this->credit->client->credit_filepath() . $this->credit->number.'.pdf');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the credit.
|
* Saves the credit.
|
||||||
* @return Credit object
|
* @return Credit object
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Services\Quote;
|
namespace App\Services\Quote;
|
||||||
|
|
||||||
use App\Events\Quote\QuoteWasApproved;
|
use App\Events\Quote\QuoteWasApproved;
|
||||||
|
use App\Jobs\Util\UnlinkFile;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
use App\Repositories\QuoteRepository;
|
use App\Repositories\QuoteRepository;
|
||||||
@ -189,6 +190,13 @@ class QuoteService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deletePdf()
|
||||||
|
{
|
||||||
|
UnlinkFile::dispatchNow(config('filesystems.default'), $this->quote->client->quote_filepath() . $this->quote->number.'.pdf');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the quote.
|
* Saves the quote.
|
||||||
* @return Quote|null
|
* @return Quote|null
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Recurring;
|
namespace App\Services\Recurring;
|
||||||
|
|
||||||
|
use App\Jobs\Util\UnlinkFile;
|
||||||
use App\Models\RecurringInvoice;
|
use App\Models\RecurringInvoice;
|
||||||
use App\Services\Recurring\GetInvoicePdf;
|
use App\Services\Recurring\GetInvoicePdf;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@ -84,6 +85,13 @@ class RecurringService
|
|||||||
return (new GetInvoicePdf($this->recurring_entity, $contact))->run();
|
return (new GetInvoicePdf($this->recurring_entity, $contact))->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deletePdf()
|
||||||
|
{
|
||||||
|
UnlinkFile::dispatchNow(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath() . $this->recurring_entity->number.'.pdf');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
$this->recurring_entity->save();
|
$this->recurring_entity->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user