mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Working on Invoice Designs (#3346)
This commit is contained in:
parent
69cc88e33f
commit
1edfee654f
@ -24,18 +24,18 @@ class Custom extends AbstractDesign
|
||||
|
||||
private $table_styles;
|
||||
|
||||
public function __construct(array $data)
|
||||
public function __construct($design)
|
||||
{
|
||||
|
||||
$this->header = $data['header'];
|
||||
$this->header = $design->header;
|
||||
|
||||
$this->body = $data['body'];
|
||||
$this->body = $design->body;
|
||||
|
||||
$this->table = $data['table'];
|
||||
$this->table = $design->table;
|
||||
|
||||
$this->footer = $data['footer'];
|
||||
$this->footer = $design->footer;
|
||||
|
||||
$this->table_styles = $data['table_styles'];
|
||||
$this->table_styles = $design->table_styles;
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Plain extends AbstractDesign
|
||||
$invoice_label
|
||||
</div>
|
||||
<div class="w-1/3 flex flex-col">
|
||||
$company_address
|
||||
$company_details
|
||||
</div>
|
||||
<div class="w-1/3 flex flex-col">
|
||||
<div class="h-14">$company_logo</div>
|
||||
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace App\Jobs\Invoice;
|
||||
|
||||
use App\Designs\Custom;
|
||||
use App\Designs\Designer;
|
||||
use App\Designs\Modern;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\Design;
|
||||
use App\Models\Invoice;
|
||||
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@ -25,9 +26,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
|
||||
@ -77,8 +76,17 @@ class CreateInvoicePdf implements ShouldQueue {
|
||||
//$file_path = $path . $this->invoice->number . '-' . $this->contact->contact_key .'.pdf';
|
||||
$file_path = $path . $this->invoice->number . '.pdf';
|
||||
|
||||
$modern = new Modern();
|
||||
$designer = new Designer($modern, $this->invoice->client->getSetting('invoice_variables'));
|
||||
$design = Design::find($this->invoice->client->getSetting('invoice_design_id'));
|
||||
|
||||
if($design->is_custom){
|
||||
$invoice_design = new Custom($design->design);
|
||||
}
|
||||
else{
|
||||
$class = 'App\Designs\\'.$design->name;
|
||||
$invoice_design = new $class();
|
||||
}
|
||||
|
||||
$designer = new Designer($invoice_design, $this->invoice->client->getSetting('invoice_variables'));
|
||||
|
||||
//get invoice design
|
||||
$html = $this->generateInvoiceHtml($designer->build($this->invoice)->getHtml(), $this->invoice, $this->contact);
|
||||
|
@ -17,6 +17,12 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class Design extends BaseModel
|
||||
{
|
||||
|
||||
protected $casts = [
|
||||
'design' => 'object',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
@ -95,6 +95,25 @@ trait MockAccountData
|
||||
'account_id' => $this->account->id,
|
||||
]);
|
||||
|
||||
$settings = CompanySettings::defaults();
|
||||
|
||||
$settings->name = 'The Best Company Name';
|
||||
$settings->company_logo = 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png';
|
||||
$settings->website = 'www.invoiceninja.com';
|
||||
$settings->address1 = 'Address 1';
|
||||
$settings->address2 = 'Address 2';
|
||||
$settings->city = 'City';
|
||||
$settings->state = 'State';
|
||||
$settings->postal_code = 'Postal Code';
|
||||
$settings->phone = '555-343-2323';
|
||||
$settings->email = 'user@example.com';
|
||||
$settings->country_id = '840';
|
||||
$settings->vat_number = 'vat number';
|
||||
$settings->id_number = 'id number';
|
||||
|
||||
$this->company->settings = $settings;
|
||||
$this->company->save();
|
||||
|
||||
$this->account->default_company_id = $this->company->id;
|
||||
$this->account->save();
|
||||
|
||||
@ -131,8 +150,14 @@ trait MockAccountData
|
||||
// 'settings' => json_encode(DefaultSettings::userSettings()),
|
||||
// ]);
|
||||
|
||||
$this->client = ClientFactory::create($this->company->id, $this->user->id);
|
||||
$this->client->save();
|
||||
// $this->client = ClientFactory::create($this->company->id, $this->user->id);
|
||||
// $this->client->save();
|
||||
|
||||
$this->client = factory(\App\Models\Client::class)->create([
|
||||
'user_id' => $this->user->id,
|
||||
'company_id' => $this->company->id,
|
||||
]);
|
||||
|
||||
|
||||
factory(\App\Models\ClientContact::class,1)->create([
|
||||
'user_id' => $this->user->id,
|
||||
@ -148,7 +173,6 @@ trait MockAccountData
|
||||
'company_id' => $this->company->id,
|
||||
'send_email' => true
|
||||
]);
|
||||
|
||||
|
||||
$gs = new GroupSetting;
|
||||
$gs->name = 'Test';
|
||||
|
Loading…
Reference in New Issue
Block a user