From 3a6b27ff9e831786cc2b5984a93a9d358cf95404 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 5 Dec 2017 07:28:43 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20default=20tax=20rate=20u?= =?UTF-8?q?ntil=20tax=20rates=20have=20been=20created?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Client.php | 5 ++++- resources/lang/en/texts.php | 2 ++ resources/views/clients/edit.blade.php | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Models/Client.php b/app/Models/Client.php index 6e43816505e8..7d992d6c90fb 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -389,7 +389,7 @@ class Client extends EntityModel /** * @return bool */ - public function hasAddress() + public function hasAddress($shipping = false) { $fields = [ 'address1', @@ -401,6 +401,9 @@ class Client extends EntityModel ]; foreach ($fields as $field) { + if ($shipping) { + $field = 'shipping_' . $field; + } if ($this->$field) { return true; } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 105197d63c18..ea9582f1ce96 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2606,6 +2606,8 @@ $LANG = array( 'edit_times' => 'Edit Times', 'inclusive_taxes_help' => 'Include taxes in the cost', 'inclusive_taxes_warning' => 'Warning: existing invoices will need to be resaved', + 'copy_shipping' => 'Copy Shipping', + 'copy_billing' => 'Copy Billing', ); diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index 8bcf02696dad..c2e2202ed6b3 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -95,6 +95,14 @@ {!! Former::text('postal_code') !!} {!! Former::select('country_id')->addOption('','') ->fromQuery($countries, 'name', 'id') !!} + + +
{!! Former::text('shipping_address1')->label('address1') !!} @@ -104,6 +112,13 @@ {!! Former::text('shipping_postal_code')->label('postal_code') !!} {!! Former::select('shipping_country_id')->addOption('','') ->fromQuery($countries, 'name', 'id')->label('country_id') !!} + +
@@ -290,6 +305,13 @@ $(function() { $('#country_id, #shipping_country_id').combobox(); + + if ({{ $client->hasAddress() ? 'true' : 'false' }}) { + $('#copyBillingDiv').show(); + } + if ({{ $client->hasAddress(true) ? 'true' : 'false' }}) { + $('#copyShippingDiv').show(); + } }); function ContactModel(data) {