Fixes for designs and pdf_variables (#3425)

This commit is contained in:
David Bomba 2020-03-05 18:50:50 +11:00 committed by GitHub
parent 7acc6ee300
commit ab4ec76830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 5 deletions

View File

@ -125,14 +125,44 @@ class PreviewController extends BaseController
private function blankEntity()
{
$client = factory(\App\Models\Client::class)->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
]);
return response()->json(['message' => 'Blank Entity not implemented.'], 200);
$contact = factory(\App\Models\ClientContact::class)->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'client_id' => $client->id,
'is_primary' => 1,
'send_email' => true,
]);
$invoice = factory(\App\Models\Invoice::class)->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'client_id' => $client->id,
]);
$invoice->setRelation('client', $client);
$invoice->load('client');
$invoice_design = new Custom((object)request()->input('body'));
$designer = new Designer($invoice, $invoice_design, $invoice->client->getSetting('pdf_variables'), lcfirst(request()->has('entity')));
$html = $this->generateInvoiceHtml($designer->build()->getHtml(), $invoice);
$file_path = PreviewPdf::dispatchNow($html, auth()->user()->company());
$invoice->forceDelete();
$contact->forceDelete();
$client->forceDelete();
return response()->download($file_path)->deleteFileAfterSend(true);
// $invoice_design = new Custom((object)request()->input('body'));
// $file_path = PreviewPdf::dispatchNow(request()->input('body'), auth()->user()->company());
// return response()->download($file_path)->deleteFileAfterSend(true);
}

View File

@ -74,6 +74,9 @@ trait CompanySettingsSaver
$settings = (object)$settings;
$casts = CompanySettings::$casts;
if(property_exists($settings, 'pdf_variables'))
unset($settings->pdf_variables);
ksort($casts);
foreach ($casts as $key => $value) {

View File

@ -45,7 +45,6 @@ class DesignSeeder extends Seeder
$design_object->include = $invoice_design->include();
$design_object->header = $invoice_design->header();
$design_object->body = $invoice_design->body();
$design_object->table_styles = $invoice_design->table_styles();
$design_object->product_table = $invoice_design->product_table();
$design_object->task_table = $invoice_design->task_table();
$design_object->footer = $invoice_design->footer();