From d13629913e09269ae4845f98c66837cb311e5864 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 5 Dec 2017 17:38:41 +0200 Subject: [PATCH] Add copy shipping/billing address buttons --- resources/views/clients/edit.blade.php | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index c2e2202ed6b3..490847dce40e 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -306,6 +306,23 @@ $(function() { $('#country_id, #shipping_country_id').combobox(); + // show/hide copy buttons if address is set + $('#billing_address').change(function() { + $('#copyBillingDiv').toggle(isAddressSet()); + }); + $('#shipping_address').change(function() { + $('#copyShippingDiv').toggle(isAddressSet(true)); + }); + + // button handles to copy the address + $('#copyBillingDiv button').click(function() { + copyAddress(); + }); + $('#copyShippingDiv button').click(function() { + copyAddress(true); + }); + + // show/hide buttons based on loaded values if ({{ $client->hasAddress() ? 'true' : 'false' }}) { $('#copyBillingDiv').show(); } @@ -314,6 +331,49 @@ } }); + function copyAddress(shipping) { + var fields = [ + 'address1', + 'address2', + 'city', + 'state', + 'postal_code', + 'country_id', + ] + for (var i=0; i