getDesigns() public static method

public static getDesigns ( ) : mixed
return mixed
 private static function getViewModel()
 {
     // Tax rate $options
     $account = Auth::user()->account;
     $rates = TaxRate::scope()->orderBy('name')->get();
     $options = [];
     $defaultTax = false;
     foreach ($rates as $rate) {
         $options[$rate->rate . ' ' . $rate->name] = $rate->name . ' ' . ($rate->rate + 0) . '%';
         // load default invoice tax
         if ($rate->id == $account->default_tax_rate_id) {
             $defaultTax = $rate;
         }
     }
     return ['entityType' => ENTITY_QUOTE, 'account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(['product_key', 'notes', 'cost', 'qty']), 'taxRateOptions' => $options, 'defaultTax' => $defaultTax, 'countries' => Cache::get('countries'), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Cache::get('currencies'), 'sizes' => Cache::get('sizes'), 'paymentTerms' => Cache::get('paymentTerms'), 'languages' => Cache::get('languages'), 'industries' => Cache::get('industries'), 'invoiceDesigns' => InvoiceDesign::getDesigns(), 'invoiceFonts' => Cache::get('fonts'), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'isRecurring' => false];
 }
 /**
  * @param $section
  * @return \Illuminate\Contracts\View\View
  */
 private function showInvoiceDesign($section)
 {
     $account = Auth::user()->account->load('country');
     $invoice = new stdClass();
     $client = new stdClass();
     $contact = new stdClass();
     $invoiceItem = new stdClass();
     $document = new stdClass();
     $client->name = 'Sample Client';
     $client->address1 = trans('texts.address1');
     $client->city = trans('texts.city');
     $client->state = trans('texts.state');
     $client->postal_code = trans('texts.postal_code');
     $client->work_phone = trans('texts.work_phone');
     $client->work_email = trans('texts.work_id');
     $invoice->invoice_number = '0000';
     $invoice->invoice_date = Utils::fromSqlDate(date('Y-m-d'));
     $invoice->account = json_decode($account->toJson());
     $invoice->amount = $invoice->balance = 100;
     $invoice->terms = trim($account->invoice_terms);
     $invoice->invoice_footer = trim($account->invoice_footer);
     $contact->first_name = 'Test';
     $contact->last_name = 'Contact';
     $contact->email = '*****@*****.**';
     $client->contacts = [$contact];
     $invoiceItem->cost = 100;
     $invoiceItem->qty = 1;
     $invoiceItem->notes = 'Notes';
     $invoiceItem->product_key = 'Item';
     $document->base64 = 'data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAyAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNBCUAAAAAABAAAAAAAAAAAAAAAAAAAAAA/+4AIUFkb2JlAGTAAAAAAQMAEAMDBgkAAAW8AAALrQAAEWf/2wCEAAgGBgYGBggGBggMCAcIDA4KCAgKDhANDQ4NDRARDA4NDQ4MEQ8SExQTEg8YGBoaGBgjIiIiIycnJycnJycnJycBCQgICQoJCwkJCw4LDQsOEQ4ODg4REw0NDg0NExgRDw8PDxEYFhcUFBQXFhoaGBgaGiEhICEhJycnJycnJycnJ//CABEIAGQAlgMBIgACEQEDEQH/xADtAAABBQEBAAAAAAAAAAAAAAAAAQIDBAUGBwEBAAMBAQEAAAAAAAAAAAAAAAIDBAUBBhAAAQQCAQMDBQEAAAAAAAAAAgABAwQRBRIQIBMwIQYxIiMUFUARAAIBAgMFAwgHBwUBAAAAAAECAwARIRIEMUFRYROhIkIgcYGRsdFSIzDBMpKyFAVA4WJyM0MkUPGiU3OTEgABAgQBCQYEBwAAAAAAAAABEQIAITESAyBBUWFxkaGxIhAwgdEyE8HxYnLw4UJSgiMUEwEAAgIBAwQCAwEBAAAAAAABABEhMVFBYXEQgZGhILEwwdHw8f/aAAwDAQACEQMRAAAA9ScqiDlGjgRUUcqSCOVfTEeETZI/TABQBHCxAiDmcvz1O3rM7i7HG29J1nGW6c/ZO4i1ry9ZZwJOzk2Gc11N8YVe6FsZKEQqwR8v0vnEpz4isza7FaovCjNThxulztSxiz6597PwkfQ99R6vxT0S7N2yuXJpQceKrkIq3L9kK/OuR9F8rpjCsmdZXLUN+H0Obp9Hp8azkdPd1q58T21bV6XK6dcjW2UP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wLAQBRotLMeIdlDn5FpRZUUm5R2ZJ7EpNZRMobAO5K5hOAUuBYHYG+8SddNHz0+EKEOCcKzlT1BZYb4uB90OpYUAVM2rcL3vCknNK+bjWGKs6bZa9oVhmRdpg/YWAAlUVJkcjdXD11Lgke0VcU2MbHfygaFKWEnTL5GJZzMyGuGMPMbSQlbPagPOZaKOHjusEyaLtXgeW3iK4+oDc4bNYnwcKiQaks/Caxh5wK7kdeZvb3LEJhAMqbKrhAqim522Qv5gPgqp9FxlL7mnZpXi3MxIMgDkG/ug65qHbsEF8zXvjwBFAU4jmwArRmKjV6XLdNd1TvoiF1X5vX/fMHBChWDvd+4paeJz4FDgzLjs70CdhHznQBjzv7Sxo8bd2NfcZmYNWs8RxQGYGe1+olGV9n7Z+0UPFyYwlYvmDNJctGQPGwnyQAWPv0haPhQ4abtsUxZfaFBalqvypK8pGizJpYO+aShBw+h2xgHf3CNeSAXzRnTRxS/szKo3P+IMAszsGE7iUiOwZy99tXZg3BCqz2L+qH0gU09RzxfaMDrstvwgKoDsPRrCLj7jcKSy6oH5pLZC0I+L/UPAvRNDQUa9oMU7aNedH3NWIKBWuO+m4lsAS60VfopKsCajNR6AT7l8D418EaQCisod0YIUK9U/PBh6loQegqKly/QfkBmNzMzM/i+jOk/9k=';
     $invoice->client = $client;
     $invoice->invoice_items = [$invoiceItem];
     //$invoice->documents = $account->hasFeature(FEATURE_DOCUMENTS) ? [$document] : [];
     $invoice->documents = [];
     $data['account'] = $account;
     $data['invoice'] = $invoice;
     $data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
     $data['title'] = trans('texts.invoice_design');
     $data['invoiceDesigns'] = InvoiceDesign::getDesigns();
     $data['invoiceFonts'] = Cache::get('fonts');
     $data['section'] = $section;
     $data['pageSizes'] = array_combine(InvoiceDesign::$pageSizes, InvoiceDesign::$pageSizes);
     $design = false;
     foreach ($data['invoiceDesigns'] as $item) {
         if ($item->id == $account->invoice_design_id) {
             $design = $item->javascript;
             break;
         }
     }
     if ($section == ACCOUNT_CUSTOMIZE_DESIGN) {
         $data['customDesign'] = $account->custom_design && !$design ? $account->custom_design : $design;
         // sample invoice to help determine variables
         $invoice = Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->with('client', 'account')->where('is_recurring', '=', false)->first();
         if ($invoice) {
             $invoice->hidePrivateFields();
             unset($invoice->account);
             unset($invoice->invoice_items);
             unset($invoice->client->contacts);
             $data['sampleInvoice'] = $invoice;
         }
     }
     return View::make("accounts.{$section}", $data);
 }
 private function showInvoiceDesign($section)
 {
     $account = Auth::user()->account->load('country');
     $invoice = new stdClass();
     $client = new stdClass();
     $contact = new stdClass();
     $invoiceItem = new stdClass();
     $client->name = 'Sample Client';
     $client->address1 = '';
     $client->city = '';
     $client->state = '';
     $client->postal_code = '';
     $client->work_phone = '';
     $client->work_email = '';
     $invoice->invoice_number = '0000';
     $invoice->invoice_date = Utils::fromSqlDate(date('Y-m-d'));
     $invoice->account = json_decode($account->toJson());
     $invoice->amount = $invoice->balance = 100;
     $invoice->terms = trim($account->invoice_terms);
     $invoice->invoice_footer = trim($account->invoice_footer);
     $contact->email = '*****@*****.**';
     $client->contacts = [$contact];
     $invoiceItem->cost = 100;
     $invoiceItem->qty = 1;
     $invoiceItem->notes = 'Notes';
     $invoiceItem->product_key = 'Item';
     $invoice->client = $client;
     $invoice->invoice_items = [$invoiceItem];
     $data['account'] = $account;
     $data['invoice'] = $invoice;
     $data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
     $data['title'] = trans('texts.invoice_design');
     $data['invoiceDesigns'] = InvoiceDesign::getDesigns();
     $data['section'] = $section;
     $design = false;
     foreach ($data['invoiceDesigns'] as $item) {
         if ($item->id == $account->invoice_design_id) {
             $design = $item->javascript;
             break;
         }
     }
     if ($section == ACCOUNT_CUSTOMIZE_DESIGN) {
         $data['customDesign'] = $account->custom_design && !$design ? $account->custom_design : $design;
     }
     return View::make("accounts.{$section}", $data);
 }
 public function invoiceHistory($publicId)
 {
     $invoice = Invoice::withTrashed()->scope($publicId)->firstOrFail();
     $invoice->load('user', 'invoice_items', 'account.country', 'client.contacts', 'client.country');
     $invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
     $invoice->due_date = Utils::fromSqlDate($invoice->due_date);
     $invoice->is_pro = Auth::user()->isPro();
     $invoice->is_quote = intval($invoice->is_quote);
     $activityTypeId = $invoice->is_quote ? ACTIVITY_TYPE_UPDATE_QUOTE : ACTIVITY_TYPE_UPDATE_INVOICE;
     $activities = Activity::scope(false, $invoice->account_id)->where('activity_type_id', '=', $activityTypeId)->where('invoice_id', '=', $invoice->id)->orderBy('id', 'desc')->get(['id', 'created_at', 'user_id', 'json_backup']);
     $versionsJson = [];
     $versionsSelect = [];
     $lastId = false;
     foreach ($activities as $activity) {
         $backup = json_decode($activity->json_backup);
         $backup->invoice_date = Utils::fromSqlDate($backup->invoice_date);
         $backup->due_date = Utils::fromSqlDate($backup->due_date);
         $backup->is_pro = Auth::user()->isPro();
         $backup->is_quote = isset($backup->is_quote) && intval($backup->is_quote);
         $backup->account = $invoice->account->toArray();
         $versionsJson[$activity->id] = $backup;
         $key = Utils::timestampToDateTimeString(strtotime($activity->created_at)) . ' - ' . $activity->user->getDisplayName();
         $versionsSelect[$lastId ? $lastId : 0] = $key;
         $lastId = $activity->id;
     }
     $versionsSelect[$lastId] = Utils::timestampToDateTimeString(strtotime($invoice->created_at)) . ' - ' . $invoice->user->getDisplayName();
     $data = ['invoice' => $invoice, 'versionsJson' => json_encode($versionsJson), 'versionsSelect' => $versionsSelect, 'invoiceDesigns' => InvoiceDesign::getDesigns()];
     return View::make('invoices.history', $data);
 }
 public function invoiceHistory(InvoiceRequest $request)
 {
     $invoice = $request->entity();
     $invoice->load('user', 'invoice_items', 'documents', 'expenses', 'expenses.documents', 'account.country', 'client.contacts', 'client.country');
     $invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
     $invoice->due_date = Utils::fromSqlDate($invoice->due_date);
     $invoice->features = ['customize_invoice_design' => Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN), 'remove_created_by' => Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY), 'invoice_settings' => Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS)];
     $invoice->invoice_type_id = intval($invoice->invoice_type_id);
     $activityTypeId = $invoice->isType(INVOICE_TYPE_QUOTE) ? ACTIVITY_TYPE_UPDATE_QUOTE : ACTIVITY_TYPE_UPDATE_INVOICE;
     $activities = Activity::scope(false, $invoice->account_id)->where('activity_type_id', '=', $activityTypeId)->where('invoice_id', '=', $invoice->id)->orderBy('id', 'desc')->get(['id', 'created_at', 'user_id', 'json_backup']);
     $versionsJson = [];
     $versionsSelect = [];
     $lastId = false;
     foreach ($activities as $activity) {
         if ($backup = json_decode($activity->json_backup)) {
             $backup->invoice_date = Utils::fromSqlDate($backup->invoice_date);
             $backup->due_date = Utils::fromSqlDate($backup->due_date);
             $backup->features = ['customize_invoice_design' => Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN), 'remove_created_by' => Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY), 'invoice_settings' => Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS)];
             $backup->invoice_type_id = isset($backup->invoice_type_id) && intval($backup->invoice_type_id) == INVOICE_TYPE_QUOTE;
             $backup->account = $invoice->account->toArray();
             $versionsJson[$activity->id] = $backup;
             $key = Utils::timestampToDateTimeString(strtotime($activity->created_at)) . ' - ' . $activity->user->getDisplayName();
             $versionsSelect[$lastId ? $lastId : 0] = $key;
             $lastId = $activity->id;
         } else {
             Utils::logError('Failed to parse invoice backup');
         }
     }
     if ($lastId) {
         $versionsSelect[$lastId] = Utils::timestampToDateTimeString(strtotime($invoice->created_at)) . ' - ' . $invoice->user->getDisplayName();
     }
     $data = ['invoice' => $invoice, 'versionsJson' => json_encode($versionsJson), 'versionsSelect' => $versionsSelect, 'invoiceDesigns' => InvoiceDesign::getDesigns(), 'invoiceFonts' => Cache::get('fonts')];
     return View::make('invoices.history', $data);
 }
 private static function getViewModel()
 {
     return ['entityType' => ENTITY_QUOTE, 'account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), 'countries' => Cache::get('countries'), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Cache::get('currencies'), 'sizes' => Cache::get('sizes'), 'paymentTerms' => Cache::get('paymentTerms'), 'languages' => Cache::get('languages'), 'industries' => Cache::get('industries'), 'invoiceDesigns' => InvoiceDesign::getDesigns(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'isRecurring' => false];
 }
 public function showSection($section = ACCOUNT_DETAILS, $subSection = false)
 {
     if ($section == ACCOUNT_DETAILS) {
         $primaryUser = Auth::user()->account->users()->orderBy('id')->first();
         $data = ['account' => Account::with('users')->findOrFail(Auth::user()->account_id), 'countries' => Cache::get('countries'), 'sizes' => Cache::get('sizes'), 'industries' => Cache::get('industries'), 'timezones' => Cache::get('timezones'), 'dateFormats' => Cache::get('dateFormats'), 'datetimeFormats' => Cache::get('datetimeFormats'), 'currencies' => Cache::get('currencies'), 'languages' => Cache::get('languages'), 'showUser' => Auth::user()->id === $primaryUser->id, 'title' => trans('texts.company_details'), 'primaryUser' => $primaryUser];
         return View::make('accounts.details', $data);
     } elseif ($section == ACCOUNT_PAYMENTS) {
         $account = Auth::user()->account;
         $account->load('account_gateways');
         $count = count($account->account_gateways);
         if ($count == 0) {
             return Redirect::to('gateways/create');
         } else {
             return View::make('accounts.payments', ['showAdd' => $count < 3, 'title' => trans('texts.online_payments')]);
         }
     } elseif ($section == ACCOUNT_NOTIFICATIONS) {
         $data = ['account' => Account::with('users')->findOrFail(Auth::user()->account_id), 'title' => trans('texts.notifications')];
         return View::make('accounts.notifications', $data);
     } elseif ($section == ACCOUNT_IMPORT_EXPORT) {
         return View::make('accounts.import_export', ['title' => trans('texts.import_export')]);
     } elseif ($section == ACCOUNT_ADVANCED_SETTINGS) {
         $account = Auth::user()->account->load('country');
         $data = ['account' => $account, 'feature' => $subSection, 'title' => trans('texts.invoice_settings')];
         if ($subSection == ACCOUNT_INVOICE_DESIGN || $subSection == ACCOUNT_CUSTOMIZE_DESIGN) {
             $invoice = new stdClass();
             $client = new stdClass();
             $contact = new stdClass();
             $invoiceItem = new stdClass();
             $client->name = 'Sample Client';
             $client->address1 = '';
             $client->city = '';
             $client->state = '';
             $client->postal_code = '';
             $client->work_phone = '';
             $client->work_email = '';
             $invoice->invoice_number = $account->getNextInvoiceNumber();
             $invoice->invoice_date = Utils::fromSqlDate(date('Y-m-d'));
             $invoice->account = json_decode($account->toJson());
             $invoice->amount = $invoice->balance = 100;
             $invoice->terms = trim($account->invoice_terms);
             $invoice->invoice_footer = trim($account->invoice_footer);
             $contact->email = '*****@*****.**';
             $client->contacts = [$contact];
             $invoiceItem->cost = 100;
             $invoiceItem->qty = 1;
             $invoiceItem->notes = 'Notes';
             $invoiceItem->product_key = 'Item';
             $invoice->client = $client;
             $invoice->invoice_items = [$invoiceItem];
             $data['account'] = $account;
             $data['invoice'] = $invoice;
             $data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
             $data['title'] = trans('texts.invoice_design');
             $data['invoiceDesigns'] = InvoiceDesign::getDesigns($subSection == ACCOUNT_CUSTOMIZE_DESIGN);
             $design = false;
             foreach ($data['invoiceDesigns'] as $item) {
                 if ($item->id == $account->invoice_design_id) {
                     $design = $item->javascript;
                     break;
                 }
             }
             if ($subSection == ACCOUNT_CUSTOMIZE_DESIGN) {
                 $data['customDesign'] = $account->custom_design && !$design ? $account->custom_design : $design;
             }
         } else {
             if ($subSection == ACCOUNT_EMAIL_TEMPLATES) {
                 $data['invoiceEmail'] = $account->getEmailTemplate(ENTITY_INVOICE);
                 $data['quoteEmail'] = $account->getEmailTemplate(ENTITY_QUOTE);
                 $data['paymentEmail'] = $account->getEmailTemplate(ENTITY_PAYMENT);
                 $data['emailFooter'] = $account->getEmailFooter();
                 $data['title'] = trans('texts.email_templates');
             } else {
                 if ($subSection == ACCOUNT_USER_MANAGEMENT) {
                     $data['title'] = trans('texts.users_and_tokens');
                 }
             }
         }
         return View::make("accounts.{$subSection}", $data);
     } elseif ($section == ACCOUNT_PRODUCTS) {
         $data = ['account' => Auth::user()->account, 'title' => trans('texts.product_library')];
         return View::make('accounts.products', $data);
     }
 }
 private function showInvoiceDesign($section)
 {
     $account = Auth::user()->account->load('country');
     $invoice = new stdClass();
     $client = new stdClass();
     $contact = new stdClass();
     $invoiceItem = new stdClass();
     $client->name = 'Sample Client';
     $client->address1 = trans('texts.address1');
     $client->city = trans('texts.city');
     $client->state = trans('texts.state');
     $client->postal_code = trans('texts.postal_code');
     $client->work_phone = trans('texts.work_phone');
     $client->work_email = trans('texts.work_id');
     $invoice->invoice_number = '0000';
     $invoice->invoice_date = Utils::fromSqlDate(date('Y-m-d'));
     $invoice->account = json_decode($account->toJson());
     $invoice->amount = $invoice->balance = 100;
     $invoice->terms = trim($account->invoice_terms);
     $invoice->invoice_footer = trim($account->invoice_footer);
     $contact->email = '*****@*****.**';
     $client->contacts = [$contact];
     $invoiceItem->cost = 100;
     $invoiceItem->qty = 1;
     $invoiceItem->notes = 'Notes';
     $invoiceItem->product_key = 'Item';
     $invoice->client = $client;
     $invoice->invoice_items = [$invoiceItem];
     $data['account'] = $account;
     $data['invoice'] = $invoice;
     $data['invoiceLabels'] = json_decode($account->invoice_labels) ?: [];
     $data['title'] = trans('texts.invoice_design');
     $data['invoiceDesigns'] = InvoiceDesign::getDesigns();
     $data['invoiceFonts'] = Cache::get('fonts');
     $data['section'] = $section;
     $design = false;
     foreach ($data['invoiceDesigns'] as $item) {
         if ($item->id == $account->invoice_design_id) {
             $design = $item->javascript;
             break;
         }
     }
     if ($section == ACCOUNT_CUSTOMIZE_DESIGN) {
         $data['customDesign'] = $account->custom_design && !$design ? $account->custom_design : $design;
         // sample invoice to help determine variables
         $invoice = Invoice::scope()->with('client', 'account')->where('is_quote', '=', false)->where('is_recurring', '=', false)->first();
         if ($invoice) {
             $invoice->hidePrivateFields();
             unset($invoice->account);
             unset($invoice->invoice_items);
             unset($invoice->client->contacts);
             $data['sampleInvoice'] = $invoice;
         }
     }
     return View::make("accounts.{$section}", $data);
 }