From 1080d9e2f6ef4f0ecc7e3c151a2fdeed441d4339 Mon Sep 17 00:00:00 2001 From: Jeramy Simpson Date: Thu, 26 Mar 2015 16:24:02 +1000 Subject: [PATCH] L5 Syntax Changes and Namespacing --- app/Http/Controllers/AccountController.php | 33 +++++++- .../Controllers/AccountGatewayController.php | 27 +++--- app/Http/Controllers/ClientController.php | 25 +++++- app/Http/Controllers/CreditController.php | 9 +- app/Http/Controllers/DashboardController.php | 9 +- app/Http/Controllers/InvoiceController.php | 9 +- app/Http/Controllers/PaymentController.php | 17 ++-- app/Http/Controllers/QuoteController.php | 6 +- app/Models/Client.php | 3 +- app/Models/Country.php | 2 + app/Models/Gateway.php | 3 +- resources/views/client.blade.php | 46 +++++------ resources/views/clients/edit.blade.php | 82 +++++++++---------- resources/views/clients/show.blade.php | 54 ++++++------ resources/views/header.blade.php | 12 +-- resources/views/list.blade.php | 24 +++--- 16 files changed, 224 insertions(+), 137 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 8c53a16b231b..86c43c5ab640 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -1,10 +1,27 @@ Account::with('users')->findOrFail(Auth::user()->account_id), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), @@ -115,6 +133,19 @@ class AccountController extends \BaseController 'languages' => Language::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id, ]; + */ + $data = [ + 'account' => Account::with('users')->findOrFail(Auth::user()->account_id), + 'countries' => Country::orderBy('name')->get(), + 'sizes' => Size::orderBy('id')->get(), + 'industries' => Industry::orderBy('name')->get(), + 'timezones' => Timezone::orderBy('location')->get(), + 'dateFormats' => DateFormat::get(), + 'datetimeFormats' => DatetimeFormat::get(), + 'currencies' => Currency::orderBy('name')->get(), + 'languages' => Language::orderBy('name')->get(), + 'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id, + ]; return View::make('accounts.details', $data); } elseif ($section == ACCOUNT_PAYMENTS) { diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index 92069f55c928..2cde2a4c7b57 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -1,24 +1,24 @@ join('gateways', 'gateways.id', '=', 'account_gateways.gateway_id') ->where('account_gateways.deleted_at', '=', null) - ->where('account_gateways.account_id', '=', \Auth::user()->account_id) + ->where('account_gateways.account_id', '=', Auth::user()->account_id) ->select('account_gateways.public_id', 'gateways.name', 'account_gateways.deleted_at'); return Datatable::query($query) @@ -95,8 +95,9 @@ class AccountGatewayController extends BaseController $selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0; $account = Auth::user()->account; - $recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE) - ->where('recommended', '=', '1') + // $recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE) + // ->where('recommended', '=', '1') + $recommendedGateways = Gateway::where('recommended', '=', '1') ->orderBy('sort_order') ->get(); $recommendedGatewayArray = array(); diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index fdbd3b475c63..e54328e71247 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -1,8 +1,18 @@ - Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), @@ -167,6 +178,16 @@ class ClientController extends \BaseController 'customLabel1' => Auth::user()->account->custom_client_label1, 'customLabel2' => Auth::user()->account->custom_client_label2, ]; + */ + return [ + 'sizes' => Size::orderBy('id')->get(), + 'paymentTerms' => PaymentTerm::orderBy('num_days')->get(['name', 'num_days']), + 'industries' => Industry::orderBy('name')->get(), + 'currencies' => Currency::orderBy('name')->get(), + 'countries' => Country::orderBy('name')->get(), + 'customLabel1' => Auth::user()->account->custom_client_label1, + 'customLabel2' => Auth::user()->account->custom_client_label2, + ]; } /** diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index efa83c7ca442..d4a3420cfe7b 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -1,8 +1,15 @@ = '.INVOICE_STATUS_SENT.' THEN 1 ELSE 0 END) invoices_sent, diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 919ec79a12d4..84da87b0f611 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -1,8 +1,11 @@ public_id); Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url); } - + + /* + This causes an error message. Commenting out. will return later. if (!empty(Input::get('pdfupload')) && strpos(Input::get('pdfupload'), 'data:application/pdf;base64,') === 0) { $this->storePDF(Input::get('pdfupload'), $invoice->id); } - + */ if ($action == 'clone') { return $this->cloneInvoice($publicId); } elseif ($action == 'convert') { diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 86036d11f87e..32922d2f88cf 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -1,11 +1,18 @@ belongsTo('PaymentLibrary', 'payment_library_id'); + return $this->belongsTo('\App\Models\PaymentLibrary', 'payment_library_id'); } public function getLogoUrl() diff --git a/resources/views/client.blade.php b/resources/views/client.blade.php index ef22259a0654..ebc46d293b64 100644 --- a/resources/views/client.blade.php +++ b/resources/views/client.blade.php @@ -2,44 +2,44 @@
- {{ Former::legend('Organization') }} - {{ Former::text('name') }} - {{ Former::text('id_number') }} - {{ Former::text('vat_number') }} - {{ Former::text('work_phone')->label('Phone') }} - {{ Former::textarea('notes') }} + {!! Former::legend('Organization') !!} + {!! Former::text('name') !!} + {!! Former::text('id_number') !!} + {!! Former::text('vat_number') !!} + {!! Former::text('work_phone')->label('Phone') !!} + {!! Former::textarea('notes') !!} - {{ Former::legend('Address') }} - {{ Former::text('address1')->label('Street') }} - {{ Former::text('address2')->label('Apt/Floor') }} - {{ Former::text('city') }} - {{ Former::text('state') }} - {{ Former::text('postal_code') }} - {{ Former::select('country_id')->addOption('','')->label('Country') - ->fromQuery($countries, 'name', 'id') }} + {!! Former::legend('Address') !!} + {!! Former::text('address1')->label('Street') !!} + {!! Former::text('address2')->label('Apt/Floor') !!} + {!! Former::text('city') !!} + {!! Former::text('state') !!} + {!! Former::text('postal_code') !!} + {!! Former::select('country_id')->addOption('','')->label('Country') + ->fromQuery($countries, 'name', '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'") }} - {{ 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'") !!} + {!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown'") !!}
- {{ link_to('#', 'Remove contact', array('data-bind'=>'click: $parent.removeContact')) }} + {!! link_to('#', 'Remove contact', array('data-bind'=>'click: $parent.removeContact')) !!} - {{ link_to('#', 'Add contact', array('onclick'=>'return addContact()')) }} + {!! link_to('#', 'Add contact', array('onclick'=>'return addContact()')) !!}
@@ -50,7 +50,7 @@
-{{ Former::hidden('data')->data_bind("value: ko.toJSON(model)") }} +{!! Former::hidden('data')->data_bind("value: ko.toJSON(model)") !!}
- {{ Button::lg_primary_submit_success(trans('texts.save'))->append_with_icon('floppy-disk') }} - {{ Button::lg_default_link('clients/' . ($client ? $client->public_id : ''), trans('texts.cancel'))->append_with_icon('remove-circle'); }} + {!! Button::primary(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!} + {!! Button::normal(trans('texts.cancel'))->large()->asLinkTo('clients/' . ($client ? $client->public_id : ''))->appendIcon(Icon::create('remove-circle')) !!}
- {{ Former::close() }} + {!! Former::close() !!}
@stop diff --git a/resources/views/clients/show.blade.php b/resources/views/clients/show.blade.php index c162d2939052..7e692a6bc552 100644 --- a/resources/views/clients/show.blade.php +++ b/resources/views/clients/show.blade.php @@ -4,10 +4,10 @@
- {{ Former::open('clients/bulk')->addClass('mainForm') }} + {!! Former::open('clients/bulk')->addClass('mainForm') !!}
- {{ Former::text('action') }} - {{ Former::text('id')->value($client->public_id) }} + {!! Former::text('action') !!} + {!! Former::text('id')->value($client->public_id) !!}
@if ($gatewayLink) @@ -26,11 +26,11 @@ [trans('texts.delete_client'), "javascript:onDeleteClick()"], ] ) - , ['id'=>'normalDropDown'])->split(); }} + , ['id'=>'normalDropDown'])->split() }} - {{ DropdownButton::primary(trans('texts.create_invoice'), Navigation::links($actionLinks), ['id'=>'primaryDropDown'])->split(); }} + {{ DropdownButton::primary(trans('texts.create_invoice'), Navigation::links($actionLinks), ['id'=>'primaryDropDown'])->split() }} @endif - {{ Former::close() }} + {!! Former::close() !!}
@@ -38,7 +38,7 @@

{{ $client->getDisplayName() }}

@if ($client->last_login > 0)

- {{ trans('texts.last_logged_in') }} {{ Utils::timestampToDateTimeString(strtotime($client->last_login)); }} + {{ trans('texts.last_logged_in') }} {{ Utils::timestampToDateTimeString(strtotime($client->last_login)) }}

@endif @@ -69,16 +69,16 @@ - + - + @if ($credit > 0) - + @endif
{{ trans('texts.paid_to_date') }}{{ Utils::formatMoney($client->paid_to_date, $client->currency_id); }}{{ Utils::formatMoney($client->paid_to_date, $client->currency_id) }}
{{ trans('texts.balance') }}{{ Utils::formatMoney($client->balance, $client->currency_id); }}{{ Utils::formatMoney($client->balance, $client->currency_id) }}
{{ trans('texts.credit') }}{{ Utils::formatMoney($credit, $client->currency_id); }}{{ Utils::formatMoney($credit, $client->currency_id) }}
@@ -90,20 +90,20 @@

 

- {{ Datatable::table() + {!! Datatable::table() ->addColumn( trans('texts.date'), trans('texts.message'), @@ -113,14 +113,14 @@ ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('aaSorting', [['0', 'desc']]) - ->render('datatable') }} + ->render('datatable') !!}
@if (Utils::isPro())
- {{ Datatable::table() + {!! Datatable::table() ->addColumn( trans('texts.quote_number'), trans('texts.quote_date'), @@ -131,7 +131,7 @@ ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('aaSorting', [['0', 'desc']]) - ->render('datatable') }} + ->render('datatable') !!}
@endif @@ -139,7 +139,7 @@
@if ($hasRecurringInvoices) - {{ Datatable::table() + {!! Datatable::table() ->addColumn( trans('texts.frequency_id'), trans('texts.start_date'), @@ -149,10 +149,10 @@ ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('aaSorting', [['0', 'asc']]) - ->render('datatable') }} + ->render('datatable') !!} @endif - {{ Datatable::table() + {!! Datatable::table() ->addColumn( trans('texts.invoice_number'), trans('texts.invoice_date'), @@ -164,12 +164,12 @@ ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('aaSorting', [['0', 'asc']]) - ->render('datatable') }} + ->render('datatable') !!}
- {{ Datatable::table() + {!! Datatable::table() ->addColumn( trans('texts.invoice'), trans('texts.transaction_reference'), @@ -180,12 +180,12 @@ ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('aaSorting', [['0', 'asc']]) - ->render('datatable') }} + ->render('datatable') !!}
- {{ Datatable::table() + {!! Datatable::table() ->addColumn( trans('texts.credit_amount'), trans('texts.credit_balance'), @@ -195,7 +195,7 @@ ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('aaSorting', [['0', 'asc']]) - ->render('datatable') }} + ->render('datatable') !!}
diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 7122379eb340..6884e4ae320d 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -89,15 +89,15 @@
diff --git a/resources/views/list.blade.php b/resources/views/list.blade.php index 4cc501c55d16..6fc4a7b0c471 100644 --- a/resources/views/list.blade.php +++ b/resources/views/list.blade.php @@ -2,21 +2,21 @@ @section('content') - {{ Former::open($entityType . 's/bulk')->addClass('listForm') }} + {!! Former::open($entityType . 's/bulk')->addClass('listForm') !!}
- {{ Former::text('action') }} - {{ Former::text('statusId') }} - {{ Former::text('id') }} + {!! Former::text('action') !!} + {!! Former::text('statusId') !!} + {!! Former::text('id') !!}
- {{ DropdownButton::normal(trans('texts.archive'), + {!! DropdownButton::normal(trans('texts.archive'), Navigation::links( array( array(trans('texts.archive_'.$entityType), "javascript:submitForm('archive')"), array(trans('texts.delete_'.$entityType), "javascript:submitForm('delete')"), ) ) - , array('id'=>'archive'))->split(); }} + , array('id'=>'archive'))->split() !!}