mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 23:44:35 -04:00
fixes for design preview
This commit is contained in:
parent
c7701b71d6
commit
0bff698bc4
@ -214,9 +214,9 @@ class PreviewController extends BaseController
|
|||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->has('client_id')) {
|
if($request->has('client_id') && strlen($request->client_id) > 4) {
|
||||||
$client = Client::withTrashed()->find($this->decodePrimaryKey($request->client_id));
|
$client = Client::withTrashed()->find($this->decodePrimaryKey($request->client_id));
|
||||||
if($request->settings_type == 'client'){
|
if($request->settings_type == 'client' && $client ){
|
||||||
$client->settings = $request->settings;
|
$client->settings = $request->settings;
|
||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ class PreviewController extends BaseController
|
|||||||
if($request->has('terms') && !$request->filled('terms') && $request->input('entity') == 'recurring_invoice')
|
if($request->has('terms') && !$request->filled('terms') && $request->input('entity') == 'recurring_invoice')
|
||||||
$request->merge(['terms' => $company->settings->invoice_terms]);
|
$request->merge(['terms' => $company->settings->invoice_terms]);
|
||||||
|
|
||||||
$entity_obj = $repo->save($request->all(), $entity_obj);
|
// $entity_obj = $repo->save($request->all(), $entity_obj);
|
||||||
|
|
||||||
if (! $request->has('entity_id')) {
|
if (! $request->has('entity_id')) {
|
||||||
$entity_obj->service()->fillDefaults()->save();
|
$entity_obj->service()->fillDefaults()->save();
|
||||||
@ -311,28 +311,36 @@ class PreviewController extends BaseController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if phantom js...... inject here..
|
//if phantom js...... inject here..et
|
||||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||||
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
|
$pdf = (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
|
||||||
|
|
||||||
|
$headers = ['Content-Type' => 'application/pdf'];
|
||||||
|
|
||||||
|
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'){
|
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
|
||||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||||
|
|
||||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
$headers = ['Content-Type' => 'application/pdf'];
|
||||||
|
|
||||||
|
if(request()->input('inline') == 'true')
|
||||||
|
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||||
|
|
||||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
return response()->streamDownload(function () use($pdf) {
|
||||||
|
echo $pdf;
|
||||||
|
}, "preview.pdf", $headers);
|
||||||
|
|
||||||
if ($numbered_pdf) {
|
|
||||||
$pdf = $numbered_pdf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pdf;
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
|
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
|
||||||
|
|
||||||
$response = Response::make($file_path, 200);
|
$response = Response::make($file_path, 200);
|
||||||
$response->header('Content-Type', 'application/pdf');
|
$response->header('Content-Type', 'application/pdf');
|
||||||
|
|
||||||
|
@ -22,15 +22,7 @@ class UnlinkFile implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected $file_path;
|
public function __construct(protected string $disk = '', protected ?string $file_path = ''){}
|
||||||
|
|
||||||
protected $disk;
|
|
||||||
|
|
||||||
public function __construct(string $disk, string $file_path)
|
|
||||||
{
|
|
||||||
$this->file_path = $file_path;
|
|
||||||
$this->disk = $disk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
@ -40,9 +32,12 @@ class UnlinkFile implements ShouldQueue
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
/* Do not delete files if we are on the sync queue*/
|
/* 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)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Storage::disk($this->disk)->delete($this->file_path);
|
Storage::disk($this->disk)->delete($this->file_path);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ class BaseRepository
|
|||||||
protected function alternativeSave($data, $model)
|
protected function alternativeSave($data, $model)
|
||||||
{ //$start = microtime(true);
|
{ //$start = microtime(true);
|
||||||
//forces the client_id if it doesn't exist
|
//forces the client_id if it doesn't exist
|
||||||
if(array_key_exists('client_id', $data))
|
if(array_key_exists('client_id', $data) && !empty($data['client_id']))
|
||||||
$model->client_id = $data['client_id'];
|
$model->client_id = $data['client_id'];
|
||||||
|
|
||||||
$client = Client::with('group_settings')->where('id', $model->client_id)->withTrashed()->firstOrFail();
|
$client = Client::with('group_settings')->where('id', $model->client_id)->withTrashed()->firstOrFail();
|
||||||
@ -176,7 +176,7 @@ class BaseRepository
|
|||||||
|
|
||||||
if (isset($tmp_data['client_contacts']))
|
if (isset($tmp_data['client_contacts']))
|
||||||
unset($tmp_data['client_contacts']);
|
unset($tmp_data['client_contacts']);
|
||||||
|
nlog($tmp_data);
|
||||||
$model->fill($tmp_data);
|
$model->fill($tmp_data);
|
||||||
|
|
||||||
$model->custom_surcharge_tax1 = $client->company->custom_surcharge_taxes1;
|
$model->custom_surcharge_tax1 = $client->company->custom_surcharge_taxes1;
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.company-logo {
|
.company-logo {
|
||||||
max-width: 65%;
|
/* max-width: 65%;*/
|
||||||
/* max-width: $company_logo_size;*/
|
max-width: $company_logo_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#company-details {
|
#company-details {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user