// AdminAddresses now uses HelperForm
This commit is contained in:
1 parent
a8c8f30c07
commit
c5f301998b
4 files changed
+412
-100
No files matched your search
@@ -0,0 +1,182 @@
|
|||||||
|
{*
|
||||||
|
* 2007-2011 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 <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision$
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*}
|
||||||
|
|
||||||
|
{if $firstCall}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var vat_number = {$vat_number};
|
||||||
|
var module_dir = '{$module_dir}';
|
||||||
|
|
||||||
|
$(document).ready(function() {ldelim}
|
||||||
|
var id_language = {$defaultFormLanguage};
|
||||||
|
var languages = new Array();
|
||||||
|
{foreach $languages as $k => $language}
|
||||||
|
languages[{$k}] = {ldelim}
|
||||||
|
id_lang: {$language.id_lang},
|
||||||
|
iso_code: '{$language.iso_code}',
|
||||||
|
name: '{$language.name}'
|
||||||
|
{rdelim};
|
||||||
|
{/foreach}
|
||||||
|
displayFlags(languages, id_language, {$allowEmployeeFormLang});
|
||||||
|
|
||||||
|
{literal}
|
||||||
|
if ($('#id_country'))
|
||||||
|
{
|
||||||
|
ajaxStates();
|
||||||
|
$('#id_country').change(function() {
|
||||||
|
ajaxStates();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
{/literal}
|
||||||
|
{rdelim});
|
||||||
|
{if isset($script)}
|
||||||
|
{$script}
|
||||||
|
{/if}
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="../js/form.js"></script>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<form action="{$current}&submitAdd{$table}=1&token={$token}" method="post">
|
||||||
|
{if $form_id}
|
||||||
|
<input type="hidden" name="id_{$table}" value="{$form_id}" />
|
||||||
|
{/if}
|
||||||
|
<fieldset>
|
||||||
|
{foreach $fields as $key => $field}
|
||||||
|
{if $key == 'legend'}
|
||||||
|
<legend>
|
||||||
|
{if isset($field.image)}<img src="{$field.image}" alt="{$field.title}" />{/if}
|
||||||
|
{$field.title}
|
||||||
|
</legend>
|
||||||
|
{elseif $key == 'input'}
|
||||||
|
{foreach $field as $input}
|
||||||
|
{if $input.name == 'id_customer'}
|
||||||
|
{if isset($customer)}
|
||||||
|
<label>{$input.label}</label>
|
||||||
|
<div class="margin-form"><a style="display: block; padding-top: 4px;" href="?tab=AdminCustomers&id_customer={$customer->id}&viewcustomer&token={$tokenCustomer}">{$customer->lastname} {$customer->firstname} ({$customer->email})</a></div>
|
||||||
|
<input type="hidden" name="id_customer" value="{$customer->id}" />
|
||||||
|
<input type="hidden" name="email" value="{$customer->email}" />
|
||||||
|
{else}
|
||||||
|
<label>{l s='Customer e-mail'}</label>
|
||||||
|
<div class="margin-form">
|
||||||
|
<input type="text" size="33" name="email" value="{$fields_value[$input.name]}" style="text-transform: lowercase;" /> <sup>*</sup>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{else}
|
||||||
|
{if $input.name == 'vat_number'}
|
||||||
|
{if $vat == 'is_applicable'}
|
||||||
|
<div id="vat_area" style="display: visible">
|
||||||
|
{else if $vat == 'management'}
|
||||||
|
<div id="vat_area" style="display: hidden">
|
||||||
|
{else}
|
||||||
|
<div style="display: none;">
|
||||||
|
{/if}
|
||||||
|
{else if $input.name == 'id_state'}
|
||||||
|
<div id="contains_states" {if $contains_states}style="display:none;"{/if}>
|
||||||
|
{/if}
|
||||||
|
<label>{$input.label} </label>
|
||||||
|
<div class="margin-form">
|
||||||
|
{if $input.type == 'text'}
|
||||||
|
<input type="text"
|
||||||
|
name="{$input.name}"
|
||||||
|
id="{$input.name}"
|
||||||
|
value="{$fields_value[$input.name]}"
|
||||||
|
{if isset($input.size)}size="{$input.size}"{/if}
|
||||||
|
{if isset($input.class)}class="{$input.class}"{/if}
|
||||||
|
{if isset($input.readonly) && $input.readonly}readonly="readonly"{/if} />
|
||||||
|
{elseif $input.type == 'select'}
|
||||||
|
<select name="{$input.name}" id="{$input.name}" {if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
|
||||||
|
{if isset($input.options.optiongroup)}
|
||||||
|
{foreach $input.options.optiongroup.query AS $optiongroup}
|
||||||
|
<optgroup label="{$optiongroup[$input.options.optiongroup.label]}">
|
||||||
|
{foreach $optiongroup[$input.options.options.query] as $option}
|
||||||
|
<option value="{$option[$input.options.options.id]}"
|
||||||
|
{if $fields_value[$input.name] == $option[$input.options.options.id]}selected="selected"{/if}>{$option[$input.options.options.name]}</option>
|
||||||
|
{/foreach}
|
||||||
|
</optgroup>
|
||||||
|
{/foreach}
|
||||||
|
{else}
|
||||||
|
{foreach $input.options.query AS $option}
|
||||||
|
<option value="{$option[$input.options.id]}"
|
||||||
|
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}>{$option[$input.options.name]}</option>
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
|
{elseif $input.type == 'radio'}
|
||||||
|
{foreach $input.values as $value}
|
||||||
|
<input type="radio"
|
||||||
|
name="{$input.name}"
|
||||||
|
id="{$value.id}"
|
||||||
|
value="{$value.value}"
|
||||||
|
{if $fields_value[$input.name] == $value.value}checked="checked"{/if} />
|
||||||
|
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}"> {$value.label}</label>
|
||||||
|
{/foreach}
|
||||||
|
{elseif $input.type == 'textarea'}
|
||||||
|
<textarea name="{$input.name}" id="{$input.name}" cols="{$input.cols}" rows="{$input.rows}">{$fields_value[$input.name]}</textarea>
|
||||||
|
{elseif $input.type == 'checkbox'}
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
{if isset($input.required) && $input.required} <sup>*</sup>{/if}
|
||||||
|
{if isset($input.p)}
|
||||||
|
<p class="clear">
|
||||||
|
{if is_array($input.p)}
|
||||||
|
{foreach $input.p as $p}
|
||||||
|
{if is_array($p)}
|
||||||
|
<span id="{$p.id}">{$p.text}</span><br />
|
||||||
|
{else}
|
||||||
|
{$p}<br />
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
{else}
|
||||||
|
{$input.p}
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{if $input.name == 'id_state' || $input.name == 'vat_number'}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
{elseif $key == 'submit'}
|
||||||
|
<div class="margin-form">
|
||||||
|
<input type="submit" value="{$field.title}" name="submitAdd{$table}" {if isset($field.class)}class="{$field.class}"{/if} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
{if $requiredFields}
|
||||||
|
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||||
|
{/if}
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<br /><br />
|
||||||
|
{if $firstCall}
|
||||||
|
{if $back}
|
||||||
|
<a href="{$back}"><img src="../img/admin/arrow2.gif" />{l s='Back'}</a>
|
||||||
|
{else}
|
||||||
|
<a href="{$current}&token={$token}"><img src="../img/admin/arrow2.gif" />{l s='Back to list'}</a>
|
||||||
|
{/if}
|
||||||
|
<br />
|
||||||
|
{/if}
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
displayFlags(languages, id_language, {$allowEmployeeFormLang});
|
displayFlags(languages, id_language, {$allowEmployeeFormLang});
|
||||||
|
|
||||||
{literal}
|
{literal}
|
||||||
if ($('#id_country'))
|
if ($('#id_country') && $('#id_state'))
|
||||||
{
|
{
|
||||||
ajaxStates();
|
ajaxStates();
|
||||||
$('#id_country').change(function() {
|
$('#id_country').change(function() {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class HelperFormCore extends Helper
|
|||||||
'requiredFields' => $this->getFieldsRequired(),
|
'requiredFields' => $this->getFieldsRequired(),
|
||||||
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
|
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
|
||||||
'module_dir' => _MODULE_DIR_,
|
'module_dir' => _MODULE_DIR_,
|
||||||
'contains_states' => Country::containsStates($this->fields_value['id_country'])
|
'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
|
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
$this->deleted = true;
|
$this->deleted = true;
|
||||||
$this->_select = 'cl.`name` as country';
|
$this->_select = 'cl.`name` as country';
|
||||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON
|
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON
|
||||||
(cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')';
|
(cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||||
|
$this->_where = 'AND a.id_customer != 0';
|
||||||
|
|
||||||
$countries = Country::getCountries($this->context->language->id);
|
$countries = Country::getCountries($this->context->language->id);
|
||||||
foreach ($countries AS $country)
|
foreach ($countries AS $country)
|
||||||
@@ -64,46 +65,174 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
'city' => array('title' => $this->l('City'), 'width' => 150),
|
'city' => array('title' => $this->l('City'), 'width' => 150),
|
||||||
'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
|
'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
|
||||||
|
|
||||||
|
$this->fields_form = array(
|
||||||
|
'legend' => array(
|
||||||
|
'title' => $this->l('Addresses'),
|
||||||
|
'image' => '../img/admin/contact.gif'
|
||||||
|
),
|
||||||
|
'input' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Customer'),
|
||||||
|
'name' => 'id_customer',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Identification Number'),
|
||||||
|
'name' => 'dni',
|
||||||
|
'size' => 30,
|
||||||
|
'required' => false,
|
||||||
|
'p' => $this->l('DNI / NIF / NIE')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Alias'),
|
||||||
|
'name' => 'alias',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => true,
|
||||||
|
'p' => '<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('First name'),
|
||||||
|
'name' => 'firstname',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => true,
|
||||||
|
'p' => '<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span></span>'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Last name'),
|
||||||
|
'name' => 'lastname',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => true,
|
||||||
|
'p' => '<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span></span>'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Company'),
|
||||||
|
'name' => 'company',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => false,
|
||||||
|
'p' => '<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('VAT number'),
|
||||||
|
'name' => 'vat_number',
|
||||||
|
'size' => 33,
|
||||||
|
''
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Address'),
|
||||||
|
'name' => 'address1',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Address').' (2)',
|
||||||
|
'name' => 'address2',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Postcode/ Zip Code'),
|
||||||
|
'name' => 'postcode',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('City'),
|
||||||
|
'name' => 'city',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => $this->l('Country:'),
|
||||||
|
'name' => 'id_country',
|
||||||
|
'required' => false,
|
||||||
|
'options' => array(
|
||||||
|
'query' => Country::getCountries($this->context->language->id),
|
||||||
|
'id' => 'id_country',
|
||||||
|
'name' => 'name'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => $this->l('State'),
|
||||||
|
'name' => 'id_state',
|
||||||
|
'required' => false,
|
||||||
|
'options' => array(
|
||||||
|
'id' => 'id_state',
|
||||||
|
'name' => 'name'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Home phone'),
|
||||||
|
'name' => 'phone',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => $this->l('Mobile phone'),
|
||||||
|
'name' => 'phone_mobile',
|
||||||
|
'size' => 33,
|
||||||
|
'required' => false,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'textarea',
|
||||||
|
'label' => $this->l('Other'),
|
||||||
|
'name' => 'other',
|
||||||
|
'cols' => 36,
|
||||||
|
'rows' => 4,
|
||||||
|
'required' => false,
|
||||||
|
'p' => '<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'submit' => array(
|
||||||
|
'title' => $this->l(' Save '),
|
||||||
|
'class' => 'button'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
{
|
{
|
||||||
if (isset($_POST['submitAdd'.$this->table]))
|
if ($this->action == 'save')
|
||||||
{
|
{
|
||||||
// Transform e-mail in id_customer for parent processing
|
// Transform e-mail in id_customer for parent processing
|
||||||
if ($this->addressType == 'customer')
|
if (Validate::isEmail(Tools::getValue('email')))
|
||||||
{
|
{
|
||||||
if (Validate::isEmail(Tools::getValue('email')))
|
$customer = new Customer();
|
||||||
{
|
$customer->getByEmail(Tools::getValue('email'));
|
||||||
$customer = new Customer();
|
if (Validate::isLoadedObject($customer))
|
||||||
$customer->getByEmail(Tools::getValue('email'));
|
$_POST['id_customer'] = $customer->id;
|
||||||
if (Validate::isLoadedObject($customer))
|
else
|
||||||
$_POST['id_customer'] = $customer->id;
|
$this->_errors[] = Tools::displayError('This e-mail address is not registered.');
|
||||||
else
|
}
|
||||||
$this->_errors[] = Tools::displayError('This e-mail address is not registered.');
|
elseif ($id_customer = Tools::getValue('id_customer'))
|
||||||
}
|
{
|
||||||
elseif ($id_customer = Tools::getValue('id_customer'))
|
$customer = new Customer((int)($id_customer));
|
||||||
{
|
if (Validate::isLoadedObject($customer))
|
||||||
$customer = new Customer((int)($id_customer));
|
$_POST['id_customer'] = $customer->id;
|
||||||
if (Validate::isLoadedObject($customer))
|
|
||||||
$_POST['id_customer'] = $customer->id;
|
|
||||||
else
|
|
||||||
$this->_errors[] = Tools::displayError('Unknown customer');
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
$this->_errors[] = Tools::displayError('Unknown customer');
|
$this->_errors[] = Tools::displayError('Unknown customer');
|
||||||
if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) AND !Tools::getValue('dni'))
|
|
||||||
$this->_errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check manufacturer selected
|
|
||||||
if ($this->addressType == 'manufacturer')
|
|
||||||
{
|
|
||||||
$manufacturer = new Manufacturer((int)(Tools::getValue('id_manufacturer')));
|
|
||||||
if (!Validate::isLoadedObject($manufacturer))
|
|
||||||
$this->_errors[] = Tools::displayError('Manufacturer selected is not valid.');
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('Unknown customer');
|
||||||
|
if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) AND !Tools::getValue('dni'))
|
||||||
|
$this->_errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
||||||
|
|
||||||
/* If the selected country does not contain states */
|
/* If the selected country does not contain states */
|
||||||
$id_state = (int)(Tools::getValue('id_state'));
|
$id_state = (int)(Tools::getValue('id_state'));
|
||||||
@@ -150,7 +279,7 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
|
|
||||||
/* Reassignation of the order's new (invoice or delivery) address */
|
/* Reassignation of the order's new (invoice or delivery) address */
|
||||||
$address_type = ((int)(Tools::getValue('address_type')) == 2 ? 'invoice' : ((int)(Tools::getValue('address_type')) == 1 ? 'delivery' : ''));
|
$address_type = ((int)(Tools::getValue('address_type')) == 2 ? 'invoice' : ((int)(Tools::getValue('address_type')) == 1 ? 'delivery' : ''));
|
||||||
if (isset($_POST['submitAdd'.$this->table]) AND ($id_order = (int)(Tools::getValue('id_order'))) AND !sizeof($this->_errors) AND !empty($address_type))
|
if ($this->action == 'save' AND ($id_order = (int)(Tools::getValue('id_order'))) AND !sizeof($this->_errors) AND !empty($address_type))
|
||||||
{
|
{
|
||||||
if(!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET `id_address_'.$address_type.'` = '.Db::getInstance()->Insert_ID().' WHERE `id_order` = '.$id_order))
|
if(!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET `id_address_'.$address_type.'` = '.Db::getInstance()->Insert_ID().' WHERE `id_order` = '.$id_order))
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while linking this address to its order.');
|
$this->_errors[] = Tools::displayError('An error occurred while linking this address to its order.');
|
||||||
@@ -173,55 +302,38 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
'.(Tools::getValue('realedit') ? '<input type="hidden" name="realedit" value="1" />' : '').'
|
'.(Tools::getValue('realedit') ? '<input type="hidden" name="realedit" value="1" />' : '').'
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><img src="../img/admin/contact.gif" alt="" />'.$this->l('Addresses').'</legend>';
|
<legend><img src="../img/admin/contact.gif" alt="" />'.$this->l('Addresses').'</legend>';
|
||||||
switch ($this->addressType)
|
|
||||||
{
|
|
||||||
case 'manufacturer':
|
|
||||||
$content .= '<label>'.$this->l('Choose manufacturer').'</label>
|
|
||||||
<div class="margin-form">';
|
|
||||||
$manufacturers = Manufacturer::getManufacturers();
|
|
||||||
$content .= '<select name="id_manufacturer">';
|
|
||||||
if (!sizeof($manufacturers))
|
|
||||||
$content .= '<option value="0">'.$this->l('No manufacturer available').' </option>';
|
|
||||||
foreach ($manufacturers as $manufacturer)
|
|
||||||
$content .= '<option value="'.(int)($manufacturer['id_manufacturer']).'"'.($this->getFieldValue($obj, 'id_manufacturer') == $manufacturer['id_manufacturer'] ? ' selected="selected"' : '').'>'.$manufacturer['name'].' </option>';
|
|
||||||
$content .= '</select>';
|
|
||||||
$content .= '</div>';
|
|
||||||
$content .= '<input type="hidden" name="alias" value="manufacturer">';
|
|
||||||
break;
|
|
||||||
case 'customer':
|
|
||||||
default:
|
|
||||||
if ($obj->id)
|
|
||||||
{
|
|
||||||
$customer = new Customer($obj->id_customer);
|
|
||||||
$tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id);
|
|
||||||
$content .= '
|
|
||||||
<label>'.$this->l('Customer').'</label>
|
|
||||||
<div class="margin-form"><a style="display: block; padding-top: 4px;" href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.$tokenCustomer.'">'.$customer->lastname.' '.$customer->firstname.' ('.$customer->email.')</a></div>
|
|
||||||
<input type="hidden" name="id_customer" value="'.$customer->id.'" />
|
|
||||||
<input type="hidden" name="email" value="'.$customer->email.'" />';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$content .=
|
|
||||||
'<label>'.$this->l('Customer e-mail').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="text" size="33" name="email" value="'.htmlentities(Tools::getValue('email'), ENT_COMPAT, 'UTF-8').'" style="text-transform: lowercase;" /> <sup>*</sup>
|
|
||||||
</div>';
|
|
||||||
}
|
|
||||||
$content .= '
|
|
||||||
<label for="dni">'.$this->l('Identification Number').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="text" name="dni" id="dni" value="'.htmlentities($this->getFieldValue($obj, 'dni'), ENT_COMPAT, 'UTF-8').'" />
|
|
||||||
<p>'.$this->l('DNI / NIF / NIE').'</p>
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
$content .= '<label>'.$this->l('Alias').'</label>
|
if ($obj->id)
|
||||||
<div class="margin-form">
|
{
|
||||||
<input type="text" size="33" name="alias" value="'.htmlentities($this->getFieldValue($obj, 'alias'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
$customer = new Customer($obj->id_customer);
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
$tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id);
|
||||||
</div>';
|
$content .= '
|
||||||
break;
|
<label>'.$this->l('Customer').'</label>
|
||||||
|
<div class="margin-form"><a style="display: block; padding-top: 4px;" href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.$tokenCustomer.'">'.$customer->lastname.' '.$customer->firstname.' ('.$customer->email.')</a></div>
|
||||||
|
<input type="hidden" name="id_customer" value="'.$customer->id.'" />
|
||||||
|
<input type="hidden" name="email" value="'.$customer->email.'" />';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$content .=
|
||||||
|
'<label>'.$this->l('Customer e-mail').'</label>
|
||||||
|
<div class="margin-form">
|
||||||
|
<input type="text" size="33" name="email" value="'.htmlentities(Tools::getValue('email'), ENT_COMPAT, 'UTF-8').'" style="text-transform: lowercase;" /> <sup>*</sup>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
$content .= '
|
||||||
|
<label for="dni">'.$this->l('Identification Number').'</label>
|
||||||
|
<div class="margin-form">
|
||||||
|
<input type="text" name="dni" id="dni" value="'.htmlentities($this->getFieldValue($obj, 'dni'), ENT_COMPAT, 'UTF-8').'" />
|
||||||
|
<p>'.$this->l('DNI / NIF / NIE').'</p>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
$content .= '<label>'.$this->l('Alias').'</label>
|
||||||
|
<div class="margin-form">
|
||||||
|
<input type="text" size="33" name="alias" value="'.htmlentities($this->getFieldValue($obj, 'alias'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||||
|
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
|
||||||
$addresses_fields = $this->processAddressFormat();
|
$addresses_fields = $this->processAddressFormat();
|
||||||
$addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address
|
$addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address
|
||||||
@@ -230,27 +342,24 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if ($addr_field_item == 'company')
|
if ($addr_field_item == 'company')
|
||||||
{
|
{
|
||||||
if ($this->addressType != 'manufacturer')
|
$content .= '<label>'.$this->l('Company').'</label>
|
||||||
{
|
<div class="margin-form">
|
||||||
$content .= '<label>'.$this->l('Company').'</label>
|
<input type="text" size="33" name="company" value="'.htmlentities($this->getFieldValue($obj, 'company'), ENT_COMPAT, 'UTF-8').'" />
|
||||||
<div class="margin-form">
|
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||||
<input type="text" size="33" name="company" value="'.htmlentities($this->getFieldValue($obj, 'company'), ENT_COMPAT, 'UTF-8').'" />
|
</div>';
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
if ((Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
|
if ((Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
|
||||||
$content .= '<div id="vat_area" style="display: visible">';
|
$content .= '<div id="vat_area" style="display: visible">';
|
||||||
else if(Configuration::get('VATNUMBER_MANAGEMENT'))
|
else if(Configuration::get('VATNUMBER_MANAGEMENT'))
|
||||||
$content .= '<div id="vat_area" style="display: hidden">';
|
$content .= '<div id="vat_area" style="display: hidden">';
|
||||||
else
|
else
|
||||||
$content .='<div style="display: none;">';
|
$content .='<div style="display: none;">';
|
||||||
|
|
||||||
$content .= '<label>'.$this->l('VAT number').'</label>
|
$content .= '<label>'.$this->l('VAT number').'</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="text" size="33" name="vat_number" value="'.htmlentities($this->getFieldValue($obj, 'vat_number'), ENT_COMPAT, 'UTF-8').'" />
|
<input type="text" size="33" name="vat_number" value="'.htmlentities($this->getFieldValue($obj, 'vat_number'), ENT_COMPAT, 'UTF-8').'" />
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif ($addr_field_item == 'lastname')
|
elseif ($addr_field_item == 'lastname')
|
||||||
{
|
{
|
||||||
@@ -441,8 +550,29 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initContent()
|
public function initContent()
|
||||||
{
|
{
|
||||||
if ($this->display != 'edit')
|
if ($this->display != 'edit' && $this->display != 'add')
|
||||||
$this->display = 'list';
|
$this->display = 'list';
|
||||||
|
|
||||||
|
if (!($address = $this->loadObject(true)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Validate::isLoadedObject($address))
|
||||||
|
{
|
||||||
|
$customer = new Customer($address->id_customer);
|
||||||
|
$tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Configuration::get('VATNUMBER_MANAGEMENT'))
|
||||||
|
if (file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php') && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
|
||||||
|
$vat = 'is_applicable';
|
||||||
|
else
|
||||||
|
$vat = 'management';
|
||||||
|
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'vat' => isset($vat) ? $vat : null,
|
||||||
|
'customer' => isset($customer) ? $customer : null,
|
||||||
|
'tokenCustomer' => isset ($tokenCustomer) ? $tokenCustomer : null
|
||||||
|
));
|
||||||
parent::initContent();
|
parent::initContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user