From 1cc88c1a769c1af55892b4fb4938f6368f3a3ffe Mon Sep 17 00:00:00 2001 From: Jeramy Simpson Date: Fri, 27 Mar 2015 15:02:19 +1000 Subject: [PATCH] L5 Syntax Changes --- app/Http/Controllers/QuoteController.php | 28 ++++ app/Models/InvoiceDesign.php | 2 + resources/views/invoices/edit.blade.php | 162 +++++++++++------------ resources/views/invoices/view.blade.php | 6 +- 4 files changed, 114 insertions(+), 84 deletions(-) diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index ee56fa2b91..620f50fe12 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -5,6 +5,17 @@ use Input; use Redirect; use Utils; use View; + +use App\Models\Account; +use App\Models\Client; +use App\Models\Country; +use App\Models\Currency; +use App\Models\Industry; +use App\Models\InvoiceDesign; +use App\Models\PaymentTerm; +use App\Models\Product; +use App\Models\Size; +use App\Models\TaxRate; use App\Ninja\Mailers\ContactMailer as Mailer; use App\Ninja\Repositories\InvoiceRepository; use App\Ninja\Repositories\ClientRepository; @@ -128,6 +139,7 @@ class QuoteController extends BaseController private static function getViewModel() { + /* return [ 'entityType' => ENTITY_QUOTE, 'account' => Auth::user()->account, @@ -143,6 +155,22 @@ class QuoteController extends BaseController ->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels() ]; +*/ + // TODO: Add Remember Cache + return [ + 'entityType' => ENTITY_QUOTE, + 'account' => Auth::user()->account, + 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), + 'countries' => Country::orderBy('name')->get(), + 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), + 'taxRates' => TaxRate::scope()->orderBy('name')->get(), + 'currencies' => Currency::orderBy('name')->get(), + 'sizes' => Size::orderBy('id')->get(), + 'paymentTerms' => PaymentTerm::orderBy('num_days')->get(['name', 'num_days']), + 'industries' => Industry::orderBy('name')->get(), + 'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(), + 'invoiceLabels' => Auth::user()->account->getInvoiceLabels() + ]; } public function bulk() diff --git a/app/Models/InvoiceDesign.php b/app/Models/InvoiceDesign.php index 5779f32952..9604a3451c 100644 --- a/app/Models/InvoiceDesign.php +++ b/app/Models/InvoiceDesign.php @@ -1,5 +1,7 @@ @endif - {{ Former::open($url)->method($method)->addClass('warn-on-exit')->rules(array( + {!! Former::open($url)->method($method)->addClass('warn-on-exit')->rules(array( 'client' => 'required', 'email' => 'required', 'product_key' => 'max:20' - )) }} + )) !!} @@ -38,7 +38,7 @@
@endif - {{ Former::select('client')->addOption('', '')->data_bind("dropdown: client")->addGroupClass('client_select closer-row') }} + {!! Former::select('client')->addOption('', '')->data_bind("dropdown: client")->addGroupClass('client_select closer-row') !!}
@@ -64,27 +64,27 @@
- {{ Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->label(trans("texts.{$entityType}_date")) - ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') }} - {{ Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'") - ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') }} + {!! Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->label(trans("texts.{$entityType}_date")) + ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') !!} + {!! Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'") + ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') !!}
@if ($entityType == ENTITY_INVOICE)
- {{ Former::select('frequency_id')->options($frequencies)->data_bind("value: frequency_id") }} - {{ Former::text('start_date')->data_bind("datePicker: start_date, valueUpdate: 'afterkeydown'") - ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') }} - {{ Former::text('end_date')->data_bind("datePicker: end_date, valueUpdate: 'afterkeydown'") - ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') }} + {!! Former::select('frequency_id')->options($frequencies)->data_bind("value: frequency_id") !!} + {!! Former::text('start_date')->data_bind("datePicker: start_date, valueUpdate: 'afterkeydown'") + ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') !!} + {!! Former::text('end_date')->data_bind("datePicker: end_date, valueUpdate: 'afterkeydown'") + ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('') !!}
@if ($invoice && $invoice->recurring_invoice_id)
- Created by a {{ link_to('/invoices/'.$invoice->recurring_invoice_id, 'recurring invoice') }} + Created by a {!! link_to('/invoices/'.$invoice->recurring_invoice_id, 'recurring invoice') !!}
@else
- {{ Former::checkbox('recurring')->onclick('setEmailEnabled()')->text(trans('texts.enable').'    '.trans('texts.learn_more').'')->data_bind("checked: is_recurring") - ->inlineHelp($invoice && $invoice->last_sent_date ? 'Last invoice sent ' . Utils::dateToString($invoice->last_sent_date) : '') }} + {!! Former::checkbox('recurring')->onclick('setEmailEnabled()')->text(trans('texts.enable').'    '.trans('texts.learn_more').'')->data_bind("checked: is_recurring") + ->inlineHelp($invoice && $invoice->last_sent_date ? 'Last invoice sent ' . Utils::dateToString($invoice->last_sent_date) : '') !!}
@endif @endif @@ -92,13 +92,13 @@
- {{ Former::text('invoice_number')->label(trans("texts.{$entityType}_number_short"))->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") }} - {{ Former::text('po_number')->label(trans('texts.po_number_short'))->data_bind("value: po_number, valueUpdate: 'afterkeydown'") }} - {{ Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'") + {!! Former::text('invoice_number')->label(trans("texts.{$entityType}_number_short"))->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('po_number')->label(trans('texts.po_number_short'))->data_bind("value: po_number, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'") ->addGroupClass('discount-group')->type('number')->min('0')->step('any')->append( Former::select('is_amount_discount')->addOption(trans('texts.discount_percent'), '0') ->addOption(trans('texts.discount_amount'), '1')->data_bind("value: is_amount_discount")->raw() - ) }} + ) !!} {{-- Former::select('currency_id')->addOption('', '')->fromQuery($currencies, 'name', 'id')->data_bind("value: currency_id") --}}
@@ -113,7 +113,7 @@

 

- {{ Former::hidden('data')->data_bind("value: ko.mapping.toJSON(model)") }} + {!! Former::hidden('data')->data_bind("value: ko.mapping.toJSON(model)") !!}
@@ -135,8 +135,8 @@
- {{ Former::text('product_key')->useDatalist($products->toArray(), 'product_key')->onkeyup('onItemChange()') - ->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') }} + {!! Former::text('product_key')->useDatalist($products->toArray(), 'product_key')->onkeyup('onItemChange()') + ->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') !!} @@ -175,20 +175,20 @@
- {{ Former::textarea('public_notes')->data_bind("value: wrapped_notes, valueUpdate: 'afterkeydown'") - ->label(null)->style('resize: none; min-width: 450px;')->rows(3) }} + {!! Former::textarea('public_notes')->data_bind("value: wrapped_notes, valueUpdate: 'afterkeydown'") + ->label(null)->style('resize: none; min-width: 450px;')->rows(3) !!}
- {{ Former::textarea('terms')->data_bind("value:wrapped_terms, placeholder: default_terms, valueUpdate: 'afterkeydown'") + {!! Former::textarea('terms')->data_bind("value:wrapped_terms, placeholder: default_terms, valueUpdate: 'afterkeydown'") ->label(false)->style('resize: none; min-width: 450px')->rows(3) ->help('') }} + '.trans('texts.save_as_default_terms').'') !!}
@@ -278,24 +278,24 @@
- {{ Former::populateField('entityType', $entityType) }} - {{ Former::text('entityType') }} - {{ Former::text('action') }} + {!! Former::populateField('entityType', $entityType) !!} + {!! Former::text('entityType') !!} + {!! Former::text('action') !!} @if ($invoice && $invoice->id) - {{ Former::populateField('id', $invoice->public_id) }} - {{ Former::text('id') }} + {!! Former::populateField('id', $invoice->public_id) !!} + {!! Former::text('id') !!} @endif
@if (!Utils::isPro() || InvoiceDesign::count() == COUNT_FREE_DESIGNS) - {{ Former::select('invoice_design_id')->style('display:inline;width:150px')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') }} + {!! Former::select('invoice_design_id')->style('display:inline;width:150px')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') !!} @else - {{ Former::select('invoice_design_id')->style('display:inline;width:150px')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") }} + {!! Former::select('invoice_design_id')->style('display:inline;width:150px')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") !!} @endif - {{ Button::primary(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()'))->append_with_icon('download-alt'); }} + {!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!} @if (!$invoice || (!$invoice->trashed() && !$invoice->client->trashed())) @if ($invoice && $invoice->id) @@ -334,18 +334,18 @@
@else - {{ Button::success(trans("texts.save_{$entityType}"), array('id' => 'saveButton', 'onclick' => 'onSaveClick()')) }} + {!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()')) !!} @endif @if (!$invoice || ($invoice && !$invoice->is_recurring)) - {{ Button::normal(trans("texts.email_{$entityType}"), array('id' => 'email_button', 'onclick' => 'onEmailClick()'))->append_with_icon('send'); }} + {!! Button::normal(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'email_button', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!} @endif @if ($invoice && $invoice->id && $entityType == ENTITY_INVOICE && !$invoice->is_recurring) - {{ Button::primary(trans('texts.enter_payment'), array('onclick' => 'onPaymentClick()'))->append_with_icon('usd'); }} + {!! Button::primary(trans('texts.enter_payment'))->withAttributes(array('onclick' => 'onPaymentClick()'))->appendIcon(Icon::create('usd')) !!} @endif @elseif ($invoice && $invoice->trashed() && !$invoice->is_deleted == '1') - {{ Button::success(trans('texts.restore'), ['onclick' => 'submitAction("restore")'])->append_with_icon('cloud-download') }} + {!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitAction("restore")'])->appendIcon(Icon:create('cloud-download')) !!} @endif @@ -371,70 +371,70 @@
- {{ Former::legend('organization') }} - {{ Former::text('name')->data_bind("value: name, valueUpdate: 'afterkeydown', attr { placeholder: name.placeholder }") }} - {{ Former::text('id_number')->data_bind("value: id_number, valueUpdate: 'afterkeydown'") }} - {{ Former::text('vat_number')->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") }} + {!! Former::legend('organization') !!} + {!! Former::text('name')->data_bind("value: name, valueUpdate: 'afterkeydown', attr { placeholder: name.placeholder }") !!} + {!! Former::text('id_number')->data_bind("value: id_number, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('vat_number')->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") !!} - {{ Former::text('website')->data_bind("value: website, valueUpdate: 'afterkeydown'") }} - {{ Former::text('work_phone')->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") }} + {!! Former::text('website')->data_bind("value: website, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('work_phone')->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") !!} @if (Auth::user()->isPro()) @if ($account->custom_client_label1) - {{ Former::text('custom_value1')->label($account->custom_client_label1) - ->data_bind("value: custom_value1, valueUpdate: 'afterkeydown'") }} + {!! Former::text('custom_value1')->label($account->custom_client_label1) + ->data_bind("value: custom_value1, valueUpdate: 'afterkeydown'") !!} @endif @if ($account->custom_client_label2) - {{ Former::text('custom_value2')->label($account->custom_client_label2) - ->data_bind("value: custom_value2, valueUpdate: 'afterkeydown'") }} + {!! Former::text('custom_value2')->label($account->custom_client_label2) + ->data_bind("value: custom_value2, valueUpdate: 'afterkeydown'") !!} @endif @endif - {{ Former::legend('address') }} - {{ Former::text('address1')->data_bind("value: address1, valueUpdate: 'afterkeydown'") }} - {{ Former::text('address2')->data_bind("value: address2, valueUpdate: 'afterkeydown'") }} - {{ Former::text('city')->data_bind("value: city, valueUpdate: 'afterkeydown'") }} - {{ Former::text('state')->data_bind("value: state, valueUpdate: 'afterkeydown'") }} - {{ Former::text('postal_code')->data_bind("value: postal_code, valueUpdate: 'afterkeydown'") }} - {{ Former::select('country_id')->addOption('','')->addGroupClass('country_select') - ->fromQuery($countries, 'name', 'id')->data_bind("dropdown: country_id") }} + {!! Former::legend('address') !!} + {!! Former::text('address1')->data_bind("value: address1, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('address2')->data_bind("value: address2, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('city')->data_bind("value: city, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('state')->data_bind("value: state, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('postal_code')->data_bind("value: postal_code, valueUpdate: 'afterkeydown'") !!} + {!! Former::select('country_id')->addOption('','')->addGroupClass('country_select') + ->fromQuery($countries, 'name', 'id')->data_bind("dropdown: country_id") !!}
- {{ Former::legend('contacts') }} + {!! Former::legend('contacts') !!}
- {{ Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown'") }} - {{ Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown'") }} - {{ Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown'") }} - {{ Former::text('email')->data_bind('value: email, valueUpdate: \'afterkeydown\', attr: {id:\'email\'+$index()}') }} - {{ Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown'") }} + {!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown'") !!} + {!! Former::text('email')->data_bind('value: email, valueUpdate: \'afterkeydown\', attr: {id:\'email\'+$index()}') !!} + {!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown'") !!}
- {{ link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) }} + {!! link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) !!} - {{ link_to('#', trans('texts.add_contact').' +', array('data-bind'=>'click: $parent.addContact')) }} + {!! link_to('#', trans('texts.add_contact').' +', array('data-bind'=>'click: $parent.addContact')) !!}
- {{ Former::legend('additional_info') }} - {{ Former::select('payment_terms')->addOption('','0')->data_bind('value: payment_terms') - ->fromQuery($paymentTerms, 'name', 'num_days') }} - {{ Former::select('currency_id')->addOption('','')->data_bind('value: currency_id') - ->fromQuery($currencies, 'name', 'id') }} - {{ Former::select('size_id')->addOption('','')->data_bind('value: size_id') - ->fromQuery($sizes, 'name', 'id') }} - {{ Former::select('industry_id')->addOption('','')->data_bind('value: industry_id') - ->fromQuery($industries, 'name', 'id') }} - {{ Former::textarea('private_notes')->data_bind('value: private_notes') }} + {!! Former::legend('additional_info') !!} + {!! Former::select('payment_terms')->addOption('','0')->data_bind('value: payment_terms') + ->fromQuery($paymentTerms, 'name', 'num_days') !!} + {!! Former::select('currency_id')->addOption('','')->data_bind('value: currency_id') + ->fromQuery($currencies, 'name', 'id') !!} + {!! Former::select('size_id')->addOption('','')->data_bind('value: size_id') + ->fromQuery($sizes, 'name', 'id') !!} + {!! Former::select('industry_id')->addOption('','')->data_bind('value: industry_id') + ->fromQuery($industries, 'name', 'id') !!} + {!! Former::textarea('private_notes')->data_bind('value: private_notes') !!}
@@ -486,10 +486,10 @@
  - {{ Former::checkbox('invoice_taxes')->text(trans('texts.enable_invoice_tax')) - ->label(trans('texts.settings'))->data_bind('checked: $root.invoice_taxes, enable: $root.tax_rates().length > 1') }} - {{ Former::checkbox('invoice_item_taxes')->text(trans('texts.enable_line_item_tax')) - ->label(' ')->data_bind('checked: $root.invoice_item_taxes, enable: $root.tax_rates().length > 1') }} + {!! Former::checkbox('invoice_taxes')->text(trans('texts.enable_invoice_tax')) + ->label(trans('texts.settings'))->data_bind('checked: $root.invoice_taxes, enable: $root.tax_rates().length > 1') !!} + {!! Former::checkbox('invoice_item_taxes')->text(trans('texts.enable_line_item_tax')) + ->label(' ')->data_bind('checked: $root.invoice_item_taxes, enable: $root.tax_rates().length > 1') !!}
@@ -524,7 +524,7 @@
- {{ Former::close() }} + {!! Former::close() !!}
diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php index 6f53dba4a4..1cff9e6468 100644 --- a/resources/views/invoices/view.blade.php +++ b/resources/views/invoices/view.blade.php @@ -22,12 +22,12 @@

 

@if ($invoice->is_quote) - {{ Button::normal(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}   + {!! Button::normal(trans('texts.download_pdf')->withAttributes(array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) !!}   @if (!$isConverted) - {{ Button::success_link(URL::to('approve/' . $invitation->invitation_key), trans('texts.approve'), array('class' => 'btn-lg')) }} + {!! Button::success(trans('texts.approve'))->asLinkTo(URL::to('approve/' . $invitation->invitation_key))->withAttributes(array('class' => 'btn-lg')) !!} @endif @elseif ($invoice->client->account->isGatewayConfigured() && !$invoice->isPaid() && !$invoice->is_recurring) - {{ Button::normal(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}   + {!! Button::normal(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) !!}   @if ($hasToken) {{ DropdownButton::success_lg(trans('texts.pay_now'), [ ['url' => URL::to("payment/{$invitation->invitation_key}?use_token=true&use_paypal=false"), 'label' => trans('texts.use_card_on_file')],