diff --git a/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl b/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl index ea72d4782..6d25b0a09 100644 --- a/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl @@ -26,6 +26,10 @@ {extends file="helpers/form/form.tpl"} {block name="label"} + {if $input.name == 'vat_number'} +
+ {/if} + {if $input.type == 'text_customer' && !isset($customer)} {else} @@ -90,4 +94,7 @@ {else} {$smarty.block.parent} {/if} + {if $input.name == 'vat_number'} +
+ {/if} {/block} diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 44d4a95f1..6ceeb3b3c 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1114,6 +1114,7 @@ abstract class PaymentModuleCore extends Module '{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile, '{delivery_other}' => $delivery->other, '{invoice_company}' => $invoice->company, + '{invoice_vat_number}' => $invoice->vat_number, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address2, diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index 296c9addc..db6f0c540 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -36,7 +36,7 @@ class AdminAddressesControllerCore extends AdminController { $this->bootstrap = true; $this->required_database = true; - $this->required_fields = array('company', 'address2', 'postcode', 'other', 'phone', 'phone_mobile', 'dni'); + $this->required_fields = array('company', 'address2', 'postcode', 'other', 'phone', 'phone_mobile', 'vat_number', 'dni'); $this->table = 'address'; $this->className = 'Address'; $this->lang = false; @@ -217,6 +217,13 @@ class AdminAddressesControllerCore extends AdminController 'col' => '4', 'hint' => $this->l('Invalid characters:').' <>;=#{}' ); + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('VAT number'), + 'col' => '2', + 'name' => 'vat_number', + 'required' => in_array('vat_number', $required_fields) + ); } elseif ($addr_field_item == 'lastname') { if (isset($customer) && !Tools::isSubmit('submit'.strtoupper($this->table)) && diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index e5dd8801c..20c9a2869 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -45,6 +45,7 @@ class AddressControllerCore extends FrontController { parent::setMedia(); $this->addJS(array( + _THEME_JS_DIR_.'tools/vatManagement.js', _THEME_JS_DIR_.'tools/statesManagement.js', _PS_JS_DIR_.'validate.js' )); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f787834b5..c07ec0d9c 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -669,6 +669,7 @@ class OrderOpcControllerCore extends ParentOrderController 'invoice_company' => Tools::htmlentitiesUTF8($address_invoice->company), 'invoice_lastname' => Tools::htmlentitiesUTF8($address_invoice->lastname), 'invoice_firstname' => Tools::htmlentitiesUTF8($address_invoice->firstname), + 'invoice_vat_number' => Tools::htmlentitiesUTF8($address_invoice->vat_number), 'invoice_dni' => Tools::htmlentitiesUTF8($address_invoice->dni), 'invoice_address' => $this->context->cart->id_address_invoice !== $this->context->cart->id_address_delivery, 'invoice_address1' => Tools::htmlentitiesUTF8($address_invoice->address1), diff --git a/themes/hotel-reservation-theme/address.tpl b/themes/hotel-reservation-theme/address.tpl index 44b8f74e0..57c00ef9c 100644 --- a/themes/hotel-reservation-theme/address.tpl +++ b/themes/hotel-reservation-theme/address.tpl @@ -54,6 +54,16 @@ {/if} + {if $field_name eq 'vat_number'} +
+
+
+ + +
+
+
+ {/if} {if $field_name eq 'dni'} {assign var="dniExist" value=true}
diff --git a/themes/hotel-reservation-theme/authentication.tpl b/themes/hotel-reservation-theme/authentication.tpl index 62f9df117..393e1f4c8 100644 --- a/themes/hotel-reservation-theme/authentication.tpl +++ b/themes/hotel-reservation-theme/authentication.tpl @@ -199,6 +199,13 @@
+ {elseif $field_name eq "vat_number"} + {elseif $field_name eq "dni"} {assign var='dniExist' value=true}
@@ -290,6 +297,13 @@
+ {elseif $field_name eq "vat_number"} + {elseif $field_name eq "dni"} {assign var=dniExist value=true}
@@ -544,6 +558,13 @@

{/if} + {elseif $field_name eq "vat_number"} + {elseif $field_name eq "firstname"}

diff --git a/themes/hotel-reservation-theme/js/tools/vatManagement.js b/themes/hotel-reservation-theme/js/tools/vatManagement.js new file mode 100644 index 000000000..eb2602058 --- /dev/null +++ b/themes/hotel-reservation-theme/js/tools/vatManagement.js @@ -0,0 +1,44 @@ +/* +* 2007-2017 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2017 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ +$(document).ready(function(){ + vat_number(); + + $(document).on('input', '#company, #company_invoice', function(){ + vat_number(); + }); +}); + +function vat_number() +{ + if ($('#company').length && ($('#company').val() != '')) + $('#vat_number, #vat_number_block').show(); + else + $('#vat_number, #vat_number_block').hide(); + + if ($('#company_invoice').length && ($('#company_invoice').val() != '')) + $('#vat_number_block_invoice').show(); + else + $('#vat_number_block_invoice').hide(); +} diff --git a/themes/hotel-reservation-theme/order-opc-edit-guest-info.tpl b/themes/hotel-reservation-theme/order-opc-edit-guest-info.tpl index ad1aacaf9..314f2e3ad 100644 --- a/themes/hotel-reservation-theme/order-opc-edit-guest-info.tpl +++ b/themes/hotel-reservation-theme/order-opc-edit-guest-info.tpl @@ -316,8 +316,5 @@ {if isset($countries)} {addJsDef countries=$countries} {/if} - {if isset($vatnumber_ajax_call) && $vatnumber_ajax_call} - {addJsDef vatnumber_ajax_call=$vatnumber_ajax_call} - {/if} {addJsDef PS_CUSTOMER_ADDRESS_CREATION=$PS_CUSTOMER_ADDRESS_CREATION|intval} {/strip}