From 194eb9e28a3a558eda3a8265419218dd15810977 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 1 Apr 2015 18:44:55 +0300 Subject: [PATCH] Working on L5 --- app/Http/Controllers/ClientController.php | 15 ++-- app/Http/Controllers/CreditController.php | 3 + app/Models/Client.php | 94 ----------------------- app/Models/Contact.php | 23 ------ resources/views/client.blade.php | 2 +- resources/views/clients/edit.blade.php | 4 +- resources/views/clients/show.blade.php | 76 +++++++++++++++--- resources/views/credits/edit.blade.php | 22 +++--- resources/views/invoices/edit.blade.php | 2 +- resources/views/list.blade.php | 16 ++-- 10 files changed, 97 insertions(+), 160 deletions(-) diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index a8f523fca51c..34855b0a66ea 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -4,8 +4,13 @@ use Auth; use Utils; use View; use URL; +use Validator; +use Input; +use Session; +use Redirect; use App\Models\Client; +use App\Models\Contact; use App\Models\Invoice; use App\Models\Size; use App\Models\PaymentTerm; @@ -103,13 +108,13 @@ class ClientController extends BaseController Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT); $actionLinks = [ - [trans('texts.create_invoice'), URL::to('invoices/create/'.$client->public_id)], - [trans('texts.enter_payment'), URL::to('payments/create/'.$client->public_id)], - [trans('texts.enter_credit'), URL::to('credits/create/'.$client->public_id)], - ]; + ['label' => trans('texts.create_invoice'), 'url' => URL::to('invoices/create/'.$client->public_id)], + ['label' => trans('texts.enter_payment'), 'url' => URL::to('payments/create/'.$client->public_id)], + ['label' => trans('texts.enter_credit'), 'url' => URL::to('credits/create/'.$client->public_id)], + ]; if (Utils::isPro()) { - array_unshift($actionLinks, [trans('texts.create_quote'), URL::to('quotes/create/'.$client->public_id)]); + array_unshift($actionLinks, ['label' => trans('texts.create_quote'), 'url' => URL::to('quotes/create/'.$client->public_id)]); } $data = array( diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index d4a3420cfe7b..c895227772b5 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -6,6 +6,9 @@ use Redirect; use Session; use Utils; use View; +use Validator; + +use App\Models\Client; use App\Ninja\Repositories\CreditRepository; diff --git a/app/Models/Client.php b/app/Models/Client.php index c13e3c5befd8..76dea58a475c 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -94,100 +94,6 @@ class Client extends EntityModel return ENTITY_CLIENT; } - public function getAddress() - { - $str = ''; - - if ($this->address1) { - $str .= $this->address1.'
'; - } - if ($this->address2) { - $str .= $this->address2.'
'; - } - if ($this->city) { - $str .= $this->city.', '; - } - if ($this->state) { - $str .= $this->state.' '; - } - if ($this->postal_code) { - $str .= $this->postal_code; - } - if ($this->country) { - $str .= '
'.$this->country->name; - } - - if ($str) { - $str = '

'.$str.'

'; - } - - return $str; - } - - public function getPhone() - { - $str = ''; - - if ($this->work_phone) { - $str .= ''.Utils::formatPhoneNumber($this->work_phone); - } - - return $str; - } - - public function getVatNumber() - { - $str = ''; - - if ($this->vat_number) { - $str .= ''.trans('texts.vat_number').': '.$this->vat_number; - } - - return $str; - } - - public function getNotes() - { - $str = ''; - - if ($this->private_notes) { - $str .= ''.$this->private_notes.''; - } - - return $str; - } - - public function getIndustry() - { - $str = ''; - - if ($this->client_industry) { - $str .= $this->client_industry->name.' '; - } - - if ($this->client_size) { - $str .= $this->client_size->name; - } - - return $str; - } - - public function getCustomFields() - { - $str = ''; - $account = $this->account; - - if ($account->custom_client_label1 && $this->custom_value1) { - $str .= "{$account->custom_client_label1}: {$this->custom_value1}
"; - } - - if ($account->custom_client_label2 && $this->custom_value2) { - $str .= "{$account->custom_client_label2}: {$this->custom_value2}
"; - } - - return $str; - } - public function getWebsite() { if (!$this->website) { diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 69653d91171f..b789d2f3708a 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -55,27 +55,4 @@ class Contact extends EntityModel return ''; } } - - public function getDetails() - { - $str = ''; - - if ($this->first_name || $this->last_name) { - $str .= ''.$this->first_name.' '.$this->last_name.'
'; - } - - if ($this->email) { - $str .= ''.HTML::mailto($this->email, $this->email).'
'; - } - - if ($this->phone) { - $str .= ''.Utils::formatPhoneNumber($this->phone); - } - - if ($str) { - $str = '

'.$str.'

'; - } - - return $str; - } } diff --git a/resources/views/client.blade.php b/resources/views/client.blade.php index ebc46d293b64..499c8a30976f 100644 --- a/resources/views/client.blade.php +++ b/resources/views/client.blade.php @@ -73,7 +73,7 @@ function ContactsModel() { } @if ($client) - window.model = ko.mapping.fromJS({{ $client }}); + window.model = ko.mapping.fromJS({!! $client !!}); @else window.model = new ContactsModel(); addContact(); diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index 428c7708a324..997820d1726f 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -138,7 +138,7 @@ }); } - window.model = new ContactsModel({{ $client }}); + window.model = new ContactsModel({!! $client !!}); model.showContact = function(elem) { if (elem.nodeType === 1) $(elem).hide().slideDown() } model.hideContact = function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) } @@ -159,7 +159,7 @@
- {!! Button::primary(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!} + {!! Button::success(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')) !!}
diff --git a/resources/views/clients/show.blade.php b/resources/views/clients/show.blade.php index d411e3bde44e..534e401c6574 100644 --- a/resources/views/clients/show.blade.php +++ b/resources/views/clients/show.blade.php @@ -27,7 +27,9 @@ ] )->split() !!} - {!! DropdownButton::primary(trans('texts.create_invoice'), Navigation::links($actionLinks), ['id'=>'primaryDropDown'])->split() !!} + {!! DropdownButton::primary(trans('texts.create_invoice')) + ->withAttributes(['class'=>'primaryDropDown']) + ->withContents($actionLinks)->split() !!} @endif {!! Former::close() !!} @@ -46,22 +48,72 @@

{{ trans('texts.details') }}

@if ($client->id_number) -

{{ trans('texts.id_number').': '.$this->id_number }}

+

{{ trans('texts.id_number').': '.$client->id_number }}

@endif -

{{ $client->getVatNumber() }}

-

{{ $client->getAddress() }}

-

{{ $client->getCustomFields() }}

-

{{ $client->getPhone() }}

-

{{ $client->getNotes() }}

-

{{ $client->getIndustry() }}

-

{{ $client->getWebsite() }}

+ @if ($client->vat_number) +

{{ trans('texts.vat_number').': '.$client->vat_number }}

+ @endif + + @if ($client->address1) + {{ $client->address1 }}
+ @endif + @if ($client->address2) + {{ $client->address2 }}
+ @endif + @if ($client->city) + {{ $client->city }}, + @endif + @if ($client->state) + {{ $client->state }} + @endif + @if ($client->postal_code) + {{ $client->postal_code }} + @endif + @if ($client->country) +
{{ $client->country->name }} + @endif + + @if ($client->account->custom_client_label1 && $client->custom_value1) + {{ $client->account->custom_client_label1 . ': ' . $client->custom_value1 }}
+ @endif + @if ($client->account->custom_client_label2 && $client->custom_value2) + {{ $client->account->custom_client_label2 . ': ' . $client->custom_value2 }}
+ @endif + + @if ($client->work_phone) + {{ Utils::formatPhoneNumber($client->work_phone) }} + @endif + + @if ($client->private_notes) +

{{ $client->private_notes }}

+ @endif + + @if ($client->client_industry) + {{ $client->client_industry->name }}
+ @endif + @if ($client->client_size) + {{ $client->client_size->name }}
+ @endif + + @if ($client->website) +

{!! $client->getWebsite() !!}

+ @endif +

{{ $client->payment_terms ? trans('texts.payment_terms') . ": Net " . $client->payment_terms : '' }}

{{ trans('texts.contacts') }}

@foreach ($client->contacts as $contact) - {{ $contact->getDetails() }} + @if ($contact->first_name || $contact->last_name) + {{ $contact->first_name.' '.$contact->last_name }}
+ @endif + @if ($contact->email) + {!! HTML::mailto($contact->email, $contact->email) !!}
+ @endif + @if ($contact->phone) + {!! Utils::formatPhoneNumber($contact->phone) !!} + @endif @endforeach
@@ -204,10 +256,10 @@