1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/app/Models/InvoiceDesign.php

98 lines
2.1 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Models;
2015-03-16 22:45:25 +01:00
2015-04-20 16:47:14 +02:00
use Auth;
2015-07-28 09:00:00 +02:00
use Cache;
2017-01-30 20:40:43 +01:00
use Eloquent;
2015-03-27 06:02:19 +01:00
/**
2017-01-30 20:40:43 +01:00
* Class InvoiceDesign.
*/
2015-03-16 22:45:25 +01:00
class InvoiceDesign extends Eloquent
{
/**
* @var bool
*/
2015-03-16 22:45:25 +01:00
public $timestamps = false;
2015-04-20 16:47:14 +02:00
2016-09-02 16:53:16 +02:00
public static $pageSizes = [
'A0',
'A1',
'A2',
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'A9',
'A10',
'B0',
'B1',
'B2',
'B3',
'B4',
'B5',
'B6',
'B7',
'B8',
'B9',
'B10',
'C0',
'C1',
'C2',
'C3',
'C4',
'C5',
'C6',
'C7',
'C8',
'C9',
'C10',
'RA0',
'RA1',
'RA2',
'RA3',
'RA4',
'SRA0',
'SRA1',
'SRA2',
'SRA3',
'SRA4',
'Executive',
'Folio',
'Legal',
'Letter',
'Tabloid',
];
/**
* @return mixed
*/
public static function getDesigns()
2015-04-20 16:47:14 +02:00
{
2015-07-21 20:51:56 +02:00
$account = Auth::user()->account;
2015-07-28 09:00:00 +02:00
$designs = Cache::get('invoiceDesigns');
2015-04-20 16:47:14 +02:00
2015-07-21 20:51:56 +02:00
foreach ($designs as $design) {
2015-07-28 09:00:00 +02:00
if ($design->id > Auth::user()->maxInvoiceDesignId()) {
$designs->pull($design->id);
2015-04-20 16:47:14 +02:00
}
2016-09-02 16:53:16 +02:00
$design->javascript = $design->pdfmake;
2015-07-28 09:00:00 +02:00
$design->pdfmake = null;
2017-06-01 18:13:13 +02:00
if (in_array($design->id, [CUSTOM_DESIGN1, CUSTOM_DESIGN2, CUSTOM_DESIGN3])) {
if ($javascript = $account->getCustomDesign($design->id)) {
$design->javascript = $javascript;
2015-07-21 20:51:56 +02:00
} else {
2017-06-01 18:13:13 +02:00
$designs->forget($design->id - 1);
2015-07-21 20:51:56 +02:00
}
}
2015-04-13 11:23:43 +02:00
}
2016-09-02 16:53:16 +02:00
2015-04-20 16:47:14 +02:00
return $designs;
2015-04-13 11:23:43 +02:00
}
2016-09-02 16:53:16 +02:00
}