mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
php-cs-fixer
This commit is contained in:
parent
9972bce7d7
commit
cfdaa1517c
@ -195,7 +195,6 @@ class PreviewController extends BaseController
|
||||
$response->header('Content-Type', 'application/pdf');
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function oldDesign(DesignPreviewRequest $request)
|
||||
@ -244,7 +243,6 @@ class PreviewController extends BaseController
|
||||
$client->settings = $request->settings;
|
||||
$client->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($request->has('group_id')) {
|
||||
@ -340,13 +338,13 @@ class PreviewController extends BaseController
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
if(request()->input('inline') == 'true')
|
||||
if (request()->input('inline') == 'true') {
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
}
|
||||
|
||||
return response()->streamDownload(function () use ($pdf) {
|
||||
echo $pdf;
|
||||
}, "preview.pdf", $headers);
|
||||
|
||||
}
|
||||
|
||||
if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') {
|
||||
@ -354,13 +352,13 @@ class PreviewController extends BaseController
|
||||
|
||||
$headers = ['Content-Type' => 'application/pdf'];
|
||||
|
||||
if(request()->input('inline') == 'true')
|
||||
if (request()->input('inline') == 'true') {
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
}
|
||||
|
||||
return response()->streamDownload(function () use ($pdf) {
|
||||
echo $pdf;
|
||||
}, "preview.pdf", $headers);
|
||||
|
||||
}
|
||||
|
||||
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
|
||||
@ -372,8 +370,9 @@ class PreviewController extends BaseController
|
||||
|
||||
public function live(PreviewInvoiceRequest $request)
|
||||
{
|
||||
if(Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co']))
|
||||
if (Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co'])) {
|
||||
return response()->json(['message' => 'This server cannot handle this request.'], 400);
|
||||
}
|
||||
|
||||
|
||||
$company = auth()->user()->company();
|
||||
|
@ -208,9 +208,7 @@ class SetupController extends Controller
|
||||
public function checkPdf(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
return response(['url' => ''], 200);
|
||||
|
||||
} catch (Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
namespace App\Http\Requests\TaskScheduler;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Http\ValidationRules\Scheduler\ValidClientIds;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateSchedulerRequest extends Request
|
||||
{
|
||||
|
@ -26,8 +26,9 @@ class ValidCompanyQuantity implements Rule
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
if(config('ninja.testvars.travis'))
|
||||
if (config('ninja.testvars.travis')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Ninja::isSelfHost()) {
|
||||
return auth()->user()->company()->account->companies->count() < 10;
|
||||
|
@ -611,8 +611,9 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
public function failed($exception = null)
|
||||
{
|
||||
if($exception)
|
||||
if ($exception) {
|
||||
nlog($exception->getMessage());
|
||||
}
|
||||
|
||||
config(['queue.failed.driver' => null]);
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ class UnlinkFile implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function __construct(protected string $disk = '', protected ?string $file_path = ''){}
|
||||
public function __construct(protected string $disk = '', protected ?string $file_path = '')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
@ -32,12 +34,14 @@ class UnlinkFile implements ShouldQueue
|
||||
public function handle()
|
||||
{
|
||||
/* Do not delete files if we are on the sync queue*/
|
||||
if (config('queue.default') == 'sync')
|
||||
if (config('queue.default') == 'sync') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!$this->file_path)
|
||||
if (!$this->file_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk($this->disk)->delete($this->file_path);
|
||||
}
|
||||
|
@ -11,16 +11,16 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Jobs\Util\WebhookHandler;
|
||||
use App\Models\Traits\Excludable;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\UserSessionAttributes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class BaseModel
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Models\Traits\Excludable;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;
|
||||
|
||||
|
@ -245,8 +245,9 @@ class Design extends BaseDesign
|
||||
{
|
||||
$elements = [];
|
||||
|
||||
if(!$this->client)
|
||||
if (!$this->client) {
|
||||
return $elements;
|
||||
}
|
||||
|
||||
$elements = [
|
||||
['element' => 'p', 'content' => ctrans('texts.shipping_address'), 'properties' => ['data-ref' => 'shipping_address-label', 'style' => 'font-weight: bold; text-transform: uppercase']],
|
||||
@ -266,7 +267,6 @@ class Design extends BaseDesign
|
||||
// }
|
||||
|
||||
return $elements;
|
||||
|
||||
}
|
||||
|
||||
public function clientDetails(): array
|
||||
@ -309,10 +309,7 @@ class Design extends BaseDesign
|
||||
|
||||
public function entityDetailsx(): array
|
||||
{
|
||||
|
||||
|
||||
if ($this->type === 'statement') {
|
||||
|
||||
$s_date = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()) . " - " . $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale());
|
||||
|
||||
return [
|
||||
@ -324,7 +321,6 @@ class Design extends BaseDesign
|
||||
['element' => 'span', 'content' => Number::formatMoney($this->invoices->sum('balance'), $this->client)]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$variables = $this->context['pdf_variables']['invoice_details'];
|
||||
@ -342,9 +338,7 @@ class Design extends BaseDesign
|
||||
}
|
||||
|
||||
if ($this->vendor) {
|
||||
|
||||
$variables = $this->context['pdf_variables']['purchase_order_details'];
|
||||
|
||||
}
|
||||
|
||||
$elements = [];
|
||||
@ -377,7 +371,6 @@ class Design extends BaseDesign
|
||||
}
|
||||
|
||||
return $elements;
|
||||
|
||||
}
|
||||
|
||||
public function entityDetails(): array
|
||||
|
@ -11,27 +11,26 @@
|
||||
|
||||
namespace App\Services\Preview;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Client;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
use App\Utils\HtmlEngine;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Jobs\Util\PreviewPdf;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\VendorContact;
|
||||
use App\Utils\PhantomJS\Phantom;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Services\PdfMaker\Design;
|
||||
use App\Utils\HostedPDF\NinjaPdf;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\PdfMaker\PdfMaker;
|
||||
use App\Factory\GroupSettingFactory;
|
||||
use App\Jobs\Util\PreviewPdf;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\Design as DesignModel;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\User;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\VendorContact;
|
||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||
use App\Services\PdfMaker\PdfMaker;
|
||||
use App\Utils\HostedPDF\NinjaPdf;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\PhantomJS\Phantom;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\Pdf\PageNumbering;
|
||||
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StubBuilder
|
||||
{
|
||||
@ -56,7 +55,9 @@ class StubBuilder
|
||||
|
||||
public array $settings;
|
||||
|
||||
public function __construct(public Company $company, public User $user){}
|
||||
public function __construct(public Company $company, public User $user)
|
||||
{
|
||||
}
|
||||
|
||||
public function setEntityType($entity_type)
|
||||
{
|
||||
@ -67,26 +68,26 @@ class StubBuilder
|
||||
|
||||
public function build(): self
|
||||
{
|
||||
|
||||
try {
|
||||
DB::connection($this->company->db)->beginTransaction();
|
||||
|
||||
$this
|
||||
->createRecipient()
|
||||
DB::connection(config('database.default'))->transaction(function () {
|
||||
$this->createRecipient()
|
||||
->initializeSettings()
|
||||
->createEntity()
|
||||
->linkRelations()
|
||||
->buildHtml();
|
||||
});
|
||||
} catch (\Throwable $throwable) {
|
||||
nlog("DB ERROR " . $throwable->getMessage());
|
||||
|
||||
DB::connection($this->company->db)->rollBack();
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
} catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
// return $e->getMessage();
|
||||
|
||||
DB::connection($this->company->db)->rollBack();
|
||||
|
||||
if (DB::connection(config('database.default'))->transactionLevel() > 0) {
|
||||
DB::connection(config('database.default'))->rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -94,7 +95,6 @@ class StubBuilder
|
||||
|
||||
public function getPdf(): mixed
|
||||
{
|
||||
|
||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||
return (new Phantom)->convertHtmlToPdf($this->html);
|
||||
}
|
||||
@ -112,12 +112,10 @@ class StubBuilder
|
||||
}
|
||||
|
||||
return (new PreviewPdf($this->html, $this->company))->handle();
|
||||
|
||||
}
|
||||
|
||||
private function initializeSettings(): self
|
||||
{
|
||||
|
||||
$this->dynamic_settings_type = 'company';
|
||||
|
||||
match ($this->dynamic_settings_type) {
|
||||
@ -175,7 +173,6 @@ class StubBuilder
|
||||
|
||||
private function buildHtml(): self
|
||||
{
|
||||
|
||||
$html = new HtmlEngine($this->invitation);
|
||||
|
||||
$design_string = "{$this->entity_type}_design_id";
|
||||
@ -216,7 +213,6 @@ class StubBuilder
|
||||
|
||||
private function createRecipient(): self
|
||||
{
|
||||
|
||||
match ($this->entity_type) {
|
||||
'invoice' => $this->createClient(),
|
||||
'quote' => $this->createClient(),
|
||||
@ -225,7 +221,6 @@ class StubBuilder
|
||||
};
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
private function createClient(): self
|
||||
|
Loading…
x
Reference in New Issue
Block a user