[*] BO : #PSFV-94 - changes to helpers
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9500 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -48,6 +48,21 @@ class AdminAddressesControllerCore extends AdminController
|
||||
|
||||
if (!Tools::getValue('realedit'))
|
||||
$this->deleted = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 80, 'filter_key' => 'a!firstname'),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!lastname'),
|
||||
'address1' => array('title' => $this->l('Address'), 'width' => 200),
|
||||
'postcode' => array('title' => $this->l('Postcode/ Zip Code'), 'align' => 'right', 'width' => 50),
|
||||
'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'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initList()
|
||||
{
|
||||
$this->_select = 'cl.`name` as country';
|
||||
$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.')';
|
||||
@@ -57,15 +72,11 @@ class AdminAddressesControllerCore extends AdminController
|
||||
foreach ($countries AS $country)
|
||||
$this->countriesArray[$country['id_country']] = $country['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 80, 'filter_key' => 'a!firstname'),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!lastname'),
|
||||
'address1' => array('title' => $this->l('Address'), 'width' => 200),
|
||||
'postcode' => array('title' => $this->l('Postcode/ Zip Code'), 'align' => 'right', 'width' => 50),
|
||||
'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'));
|
||||
parent::initList();
|
||||
}
|
||||
|
||||
public function initForm()
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Addresses'),
|
||||
@@ -125,7 +136,143 @@ class AdminAddressesControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
if (Validate::isLoadedObject($this->object))
|
||||
{
|
||||
$customer = new Customer($this->object->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
|
||||
));
|
||||
|
||||
// Order address fields depending on country format
|
||||
$addresses_fields = $this->processAddressFormat();
|
||||
$addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address
|
||||
|
||||
$temp_fields = array();
|
||||
|
||||
foreach($addresses_fields as $addr_field_item)
|
||||
{
|
||||
if ($addr_field_item == 'company')
|
||||
{
|
||||
$temp_fields[] = 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>'
|
||||
);
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('VAT number'),
|
||||
'name' => 'vat_number',
|
||||
'size' => 33,
|
||||
''
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'lastname')
|
||||
{
|
||||
$temp_fields[] = 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>'
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'firstname')
|
||||
{
|
||||
$temp_fields[] = 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>'
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'address1')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Address'),
|
||||
'name' => 'address1',
|
||||
'size' => 33,
|
||||
'required' => true,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'address2')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Address').' (2)',
|
||||
'name' => 'address2',
|
||||
'size' => 33,
|
||||
'required' => false,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'postcode')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Postcode/ Zip Code'),
|
||||
'name' => 'postcode',
|
||||
'size' => 33,
|
||||
'required' => false,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'city')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('City'),
|
||||
'name' => 'city',
|
||||
'size' => 33,
|
||||
'required' => true,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name')
|
||||
{
|
||||
$temp_fields[] = 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'
|
||||
)
|
||||
);
|
||||
$temp_fields[] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('State'),
|
||||
'name' => 'id_state',
|
||||
'required' => false,
|
||||
'options' => array(
|
||||
'id' => 'id_state',
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// merge address format with the rest of the form
|
||||
array_splice($this->fields_form['input'], 3, 0, $temp_fields);
|
||||
|
||||
parent::initForm();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -241,152 +388,4 @@ class AdminAddressesControllerCore extends AdminController
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if ($this->display == 'edit' || $this->display == 'add')
|
||||
{
|
||||
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
|
||||
));
|
||||
|
||||
// Order address fields depending on country format
|
||||
$addresses_fields = $this->processAddressFormat();
|
||||
$addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address
|
||||
|
||||
$temp_fields = array();
|
||||
|
||||
foreach($addresses_fields as $addr_field_item)
|
||||
{
|
||||
if ($addr_field_item == 'company')
|
||||
{
|
||||
$temp_fields[] = 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>'
|
||||
);
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('VAT number'),
|
||||
'name' => 'vat_number',
|
||||
'size' => 33,
|
||||
''
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'lastname')
|
||||
{
|
||||
$temp_fields[] = 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>'
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'firstname')
|
||||
{
|
||||
$temp_fields[] = 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>'
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'address1')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Address'),
|
||||
'name' => 'address1',
|
||||
'size' => 33,
|
||||
'required' => true,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'address2')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Address').' (2)',
|
||||
'name' => 'address2',
|
||||
'size' => 33,
|
||||
'required' => false,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'postcode')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Postcode/ Zip Code'),
|
||||
'name' => 'postcode',
|
||||
'size' => 33,
|
||||
'required' => false,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'city')
|
||||
{
|
||||
$temp_fields[] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('City'),
|
||||
'name' => 'city',
|
||||
'size' => 33,
|
||||
'required' => true,
|
||||
);
|
||||
}
|
||||
elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name')
|
||||
{
|
||||
$temp_fields[] = 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'
|
||||
)
|
||||
);
|
||||
$temp_fields[] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('State'),
|
||||
'name' => 'id_state',
|
||||
'required' => false,
|
||||
'options' => array(
|
||||
'id' => 'id_state',
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
// merge address format with the rest of the form
|
||||
array_splice($this->fields_form['input'], 3, 0, $temp_fields);
|
||||
}
|
||||
else
|
||||
$this->display = 'list';
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,13 @@ class AdminAliasesControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initForm()
|
||||
{
|
||||
$this->fields_value = array('alias' => $this->object->getAliases());
|
||||
|
||||
parent::initForm();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitAdd'.$this->table]))
|
||||
@@ -112,20 +119,6 @@ class AdminAliasesControllerCore extends AdminController
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
$this->fields_value = array('alias' => $obj->getAliases());
|
||||
|
||||
if ($this->display != 'edit' && $this->display != 'add')
|
||||
$this->display = 'list';
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,12 +36,13 @@ class AdminBackupControllerCore extends AdminController
|
||||
$this->className = 'Backup';
|
||||
parent::__construct();
|
||||
|
||||
$this->addRowAction('delete');
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('delete');
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$this->deleted = false;
|
||||
|
||||
$this->requiredDatabase = false;
|
||||
$this->identifier = 'filename';
|
||||
|
||||
$this->fieldsDisplay = array (
|
||||
'date' => array('title' => $this->l('Date'), 'type' => 'datetime', 'width' => 120, 'align' => 'right'),
|
||||
@@ -62,7 +63,6 @@ class AdminBackupControllerCore extends AdminController
|
||||
'submit' => array()
|
||||
),
|
||||
);
|
||||
$this->identifier = 'filename';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,6 @@ class AdminBackupControllerCore extends AdminController
|
||||
$this->display = 'list';
|
||||
$show_form = true;
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'current' => self::$currentIndex,
|
||||
'show_form' => $show_form,
|
||||
@@ -115,6 +114,7 @@ class AdminBackupControllerCore extends AdminController
|
||||
'how_to' => true,
|
||||
));
|
||||
}
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
@@ -154,7 +154,6 @@ class AdminBackupControllerCore extends AdminController
|
||||
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL)
|
||||
{
|
||||
|
||||
if (!Validate::isTableOrIdentifier($this->table))
|
||||
die('filter is corrupted');
|
||||
if (empty($orderBy))
|
||||
|
||||
@@ -43,20 +43,11 @@ class AdminContactsControllerCore extends AdminController
|
||||
'description' => array('title' => $this->l('Description'), 'width' => 150),
|
||||
);
|
||||
|
||||
$this->options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Contact options'),
|
||||
'fields' => array(
|
||||
'PS_CUSTOMER_SERVICE_FILE_UPLOAD' => array('title' => $this->l('Allow file upload'), 'desc' => $this->l('Allow customers to upload file using contact page'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array(
|
||||
'0' => array('value' => 0, 'name' => $this->l('No')),
|
||||
'1' => array('value' => 1, 'name' => $this->l('Yes'))
|
||||
)),
|
||||
'PS_CUSTOMER_SERVICE_SIGNATURE' => array('title' => $this->l('Pre-defined message'), 'desc' => $this->l('Please fill the message that appears by default when you answer a thread on the customer service page'), 'cast' => 'pSQL', 'type' => 'textareaLang', 'identifier' => 'value', 'cols' => 40, 'rows' => 8),
|
||||
),
|
||||
'submit' => array()
|
||||
),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initForm()
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Contacts'),
|
||||
@@ -120,16 +111,9 @@ class AdminContactsControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
parent::initForm();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if ($this->display != 'edit')
|
||||
$this->display = 'list';
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -274,13 +274,5 @@ class AdminCurrenciesControllerCore extends AdminController
|
||||
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
|
||||
Currency::refreshCurrencies();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if ($this->display != 'edit' && $this->display != 'add')
|
||||
$this->display = 'list';
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,18 +90,6 @@ class AdminEmailsControllerCore extends AdminController
|
||||
);
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$helper = new HelperOptions();
|
||||
$helper->id = $this->id;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->table = $this->table;
|
||||
$helper->token = $this->token;
|
||||
$this->content .= $helper->generateOptions($this->options);
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
|
||||
@@ -527,17 +527,7 @@ class AdminImagesController extends AdminController
|
||||
public function initContent()
|
||||
{
|
||||
if ($this->display != 'edit' && $this->display != 'add')
|
||||
$this->display = 'list';
|
||||
|
||||
parent::initContent();
|
||||
|
||||
if ($this->display == 'list')
|
||||
{
|
||||
$helper = new HelperOptions();
|
||||
$helper->id = $this->id;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$this->content .= $helper->generateOptions($this->options);
|
||||
|
||||
$this->initRegenerate();
|
||||
$this->initMoveImages();
|
||||
|
||||
@@ -549,5 +539,7 @@ class AdminImagesController extends AdminController
|
||||
|
||||
if ($this->display == 'edit')
|
||||
$this->warnings[] = $this->l('After modification, do not forget to regenerate thumbnails');
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user