[*] BO #PSFV-94 : update of the displayform method by helperForm in AdminStoresController

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9401 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-10-17 16:37:21 +00:00
parent 651e2d72b9
commit 96844f2d92
6 changed files with 859 additions and 329 deletions
-324
View File
@@ -1,324 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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: 7310 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/../../classes/AdminTab.php');
class AdminStores extends AdminTab
{
/** @var array countries list */
private $countriesArray = array();
public function __construct()
{
$this->context = Context::getContext();
$this->table = 'store';
$this->className = 'Store';
$this->lang = false;
$this->edit = true;
$this->delete = true;
$this->fieldImageSettings = array('name' => 'image', 'dir' => 'st');
$this->_select = 'cl.`name` country, st.`name` state';
$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.')
LEFT JOIN `'._DB_PREFIX_.'state` st ON (st.`id_state` = a.`id_state`)';
$countries = Country::getCountries($this->context->language->id);
foreach ($countries AS $country)
$this->countriesArray[$country['id_country']] = $country['name'];
$this->fieldsDisplay = array(
'id_store' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'country' => array('title' => $this->l('Country'), 'width' => 100, 'filter_key' => 'cl!name'),
'state' => array('title' => $this->l('State'), 'width' => 100, 'filter_key' => 'st!name'),
'city' => array('title' => $this->l('City'), 'width' => 100),
'postcode' => array('title' => $this->l('Zip code'), 'width' => 50),
'name' => array('title' => $this->l('Name'), 'width' => 120, 'filter_key' => 'a!name'),
'phone' => array('title' => $this->l('Phone'), 'width' => 70),
'fax' => array('title' => $this->l('Fax'), 'width' => 70),
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
$this->optionsList = array(
'general' => array(
'title' => $this->l('Parameters'),
'fields' => array(
'PS_STORES_DISPLAY_FOOTER' => array('title' => $this->l('Display in the footer:'), 'desc' => $this->l('Display a link to the store locator in the footer'), 'cast' => 'intval', 'type' => 'bool'),
'PS_STORES_DISPLAY_SITEMAP' => array('title' => $this->l('Display in the sitemap page:'), 'desc' => $this->l('Display a link to the store locator in the sitemap page'), 'cast' => 'intval', 'type' => 'bool'),
'PS_STORES_SIMPLIFIED' => array('title' => $this->l('Show a simplified store locator:'), 'desc' => $this->l('No map, no search, only a store directory'), 'cast' => 'intval', 'type' => 'bool'),
'PS_STORES_CENTER_LAT' => array('title' => $this->l('Latitude by default:'), 'desc' => $this->l('Used for the position by default of the map'), 'cast' => 'floatval', 'type' => 'text', 'size' => '10'),
'PS_STORES_CENTER_LONG' => array('title' => $this->l('Longitude by default:'), 'desc' => $this->l('Used for the position by default of the map'), 'cast' => 'floatval', 'type' => 'text', 'size' => '10')
),
),
);
parent::__construct();
}
protected function postImage($id)
{
$ret = parent::postImage($id);
if (($id_store = (int)(Tools::getValue('id_store'))) AND isset($_FILES) AND sizeof($_FILES) AND file_exists(_PS_STORE_IMG_DIR_.$id_store.'.jpg'))
{
$imagesTypes = ImageType::getImagesTypes('stores');
foreach ($imagesTypes AS $k => $imageType)
imageResize(_PS_STORE_IMG_DIR_.$id_store.'.jpg', _PS_STORE_IMG_DIR_.$id_store.'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height']));
}
return $ret;
}
public function displayOptionsList()
{
parent::displayOptionsList();
echo '<br /><p><img src="../img/admin/asterisk.gif" class="middle" /> '.$this->l('You can also replace the icon representing your store in Google Maps. Go to the Preferences tab, and then the Appearance subtab.').'</p>';
}
public function postProcess()
{
if (isset($_POST['submitAdd'.$this->table]))
{
/* Cleaning fields */
foreach ($_POST as $kp => $vp)
$_POST[$kp] = trim($vp);
/* If the selected country does not contain states */
$id_state = (int)Tools::getValue('id_state');
if ($id_country = Tools::getValue('id_country') AND $country = new Country((int)($id_country)) AND !(int)($country->contains_states) AND $id_state)
$this->_errors[] = Tools::displayError('You have selected a state for a country that does not contain states.');
/* If the selected country contains states, then a state have to be selected */
if ((int)($country->contains_states) AND !$id_state)
$this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
$latitude = (float)Tools::getValue('latitude');
$longitude = (float)Tools::getValue('longitude');
if(empty($latitude) OR empty($longitude))
$this->_errors[] = Tools::displayError('Latitude and longitude are required.');
/* Check zip code */
if ($country->need_zip_code)
{
$zip_code_format = $country->zip_code_format;
if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
{
$zip_regexp = '/^'.$zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
if (!preg_match($zip_regexp, $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
}
elseif ($zip_code_format)
$this->_errors[] = Tools::displayError('Postcode required.');
elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
}
/* Store hours */
$_POST['hours'] = array();
for ($i = 1; $i < 8; $i++)
$_POST['hours'][] .= Tools::getValue('hours_'.(int)($i));
$_POST['hours'] = serialize($_POST['hours']);
}
if (!sizeof($this->_errors))
parent::postProcess();
}
public function displayForm($isMainTab = true)
{
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
echo '
<script type="text/javascript">
$(document).ready(function(){
ajaxStates ();
$(\'#id_country\').change(function() {
ajaxStates ();
});
function ajaxStates ()
{
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(),
success: function(html)
{
if (html == \'false\')
{
$(\'#contains_states\').fadeOut();
$(\'#id_state option[value=0]\').attr(\'selected\', \'selected\');
}
else
{
$(\'#id_state\').html(html);
$(\'#contains_states\').fadeIn();
$(\'#id_state option[value='.(int)$obj->id_state.']\').attr(\'selected\', \'selected\');
}
}
});
};
});
</script>
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset>
<legend><img src="../img/admin/home.gif" />'.$this->l('Stores').'</legend>
<div style="padding-right: 40px; border-right: 1px solid #E0D0B1; float: left;">
<label>'.$this->l('Name:').'</label>
<div class="margin-form">
<input type="text" size="33" name="name" value="'.htmlentities(Tools::getValue('name', $obj->name), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Allowed characters: letters, spaces and').' (-)<span class="hint-pointer">&nbsp;</span></span>
<p class="clear">'.$this->l('Store name, e.g. Citycentre Mall Store').'</p>
</div>
<label>'.$this->l('Address:').'</label>
<div class="margin-form">
<input type="text" size="33" name="address1" value="'.htmlentities($this->getFieldValue($obj, 'address1'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
</div>
<label>'.$this->l('Address').' (2):</label>
<div class="margin-form">
<input type="text" size="33" name="address2" value="'.htmlentities($this->getFieldValue($obj, 'address2'), ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('Postcode/ Zip Code:').'</label>
<div class="margin-form">
<input type="text" size="6" name="postcode" value="'.htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('City:').'</label>
<div class="margin-form">
<input type="text" size="33" name="city" value="'.htmlentities($this->getFieldValue($obj, 'city'), ENT_COMPAT, 'UTF-8').'" style="text-transform: uppercase;" /> <sup>*</sup>
</div>
<label>'.$this->l('Country:').'</label>
<div class="margin-form">
<select name="id_country" id="id_country"/>';
$selectedCountry = $this->getFieldValue($obj, 'id_country');
foreach ($this->countriesArray AS $id_country => $name)
echo ' <option value="'.$id_country.'"'.((!$selectedCountry AND Configuration::get('PS_COUNTRY_DEFAULT') == $id_country) ? ' selected="selected"' : ($selectedCountry == $id_country ? ' selected="selected"' : '')).'>'.$name.'</option>';
echo ' </select> <sup>*</sup>
</div>
<div id="contains_states">
<label>'.$this->l('State:').'</label>
<div class="margin-form">
<select name="id_state" id="id_state">
</select> <sup>*</sup>
</div>
</div>
<label>'.$this->l('Latitude / Longitude:').'</label>
<div class="margin-form">
<input type="text" size="11" maxlength="12" name="latitude" value="'.htmlentities($this->getFieldValue($obj, 'latitude'), ENT_COMPAT, 'UTF-8').'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> / <input type="text" size="11" maxlength="12" name="longitude" value="'.htmlentities($this->getFieldValue($obj, 'longitude'), ENT_COMPAT, 'UTF-8').'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />
<sup>*</sup>
<p class="clear">'.$this->l('Store coords, eg. 45.265469 / -47.226478').'</p>
</div>
<label>'.$this->l('Phone:').'</label>
<div class="margin-form">
<input type="text" size="33" name="phone" value="'.htmlentities($this->getFieldValue($obj, 'phone'), ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('Fax:').'</label>
<div class="margin-form">
<input type="text" size="33" name="fax" value="'.htmlentities($this->getFieldValue($obj, 'fax'), ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('E-mail address:').' </label>
<div class="margin-form">
<input type="text" size="33" name="email" value="'.htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('Note:').' </label>
<div class="margin-form">
<textarea name="note" style="width: 250px; height: 75px;">'.htmlentities($this->getFieldValue($obj, 'note'), ENT_COMPAT, 'UTF-8').'</textarea>
</div>
<label>'.$this->l('Status:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR Tools::getValue('active', $obj->active)) ? 'checked="checked" ' : '').'/>
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="active" id="active_off" value="0" '.((!Tools::getValue('active', $obj->active) AND $obj->id) ? 'checked="checked" ' : '').'/>
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p>'.$this->l('Display or not this store').'</p>
</div>
</div>
<div style="padding-left: 40px; float: left;">
<label style="text-align: left; width: inherit;">'.$this->l('Picture:').' </label>
<div class="margin-form" style="padding: 0; display: inline;">
<input type="file" name="image" />
<p class="clear">'.$this->l('Store window picture').'</p>';
echo $this->displayImage($obj->id, _PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminStores'.(int)(Tab::getIdFromClassName('AdminStores')).(int)$this->context->employee->id), true);
echo '</div>
<table cellpadding="2" cellspacing="2" style="padding: 10px; margin-top: 15px; border: 1px solid #BBB;">
<tr>
<th colspan="2">'.$this->l('Hours:').'</th>
</tr>
<tr>
<td>&nbsp;</td>
<td style="font-size: 0.85em;">'.$this->l('Sample: 10:00AM - 9:30PM').'</td>
</tr>';
$days = array();
$days[1] = $this->l('Monday');
$days[2] = $this->l('Tuesday');
$days[3] = $this->l('Wednesday');
$days[4] = $this->l('Thursday');
$days[5] = $this->l('Friday');
$days[6] = $this->l('Saturday');
$days[7] = $this->l('Sunday');
$hours = $this->getFieldValue($obj, 'hours');
if (!empty($hours))
$hoursUnserialized = unserialize($hours);
for ($i = 1; $i < 8; $i++)
echo '
<tr style="color: #7F7F7F; font-size: 0.85em;">
<td>'.$days[(int)($i)].'</td>
<td><input type="text" size="25" name="hours_'.(int)($i).'" value="'.(isset($hoursUnserialized) ? htmlentities($hoursUnserialized[$i - 1], ENT_COMPAT, 'UTF-8') : '').'" /><br /></td>
</tr>';
echo '
</table>
</div>
<div class="clear"></div>';
if (Shop::isMultiShopActivated())
{
echo '<label>'.$this->l('Shop association:').'</label><div class="margin-form">';
$this->displayAssoShop();
echo '</div>';
}
echo '
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset>
</form>';
}
}
+294
View File
@@ -0,0 +1,294 @@
{*
* 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: 8971 $
* @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}';
var id_language = {$defaultFormLanguage};
var languages = new Array();
$(document).ready(function() {ldelim}
{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});
{if isset($fields_value.id_state)}
if ($('#id_country') && $('#id_state'))
{ldelim}
ajaxStates({$fields_value.id_state});
$('#id_country').change(function() {ldelim}
ajaxStates();
{rdelim});
{rdelim}
{/if}
$('#latitude, #longitude').keyup(function() {ldelim}
$(this).val($(this).val().replace(/,/g, '.'));
{rdelim});
{rdelim});
</script>
<script type="text/javascript" src="../js/form.js"></script>
{/if}
<form action="{$current}&submitAdd{$table}=1&token={$token}" method="post" enctype="multipart/form-data">
{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>
<div style="padding-right: 40px; border-right: 1px solid #E0D0B1; float: left;">
{elseif $key == 'input'}
{foreach $field as $input}
{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'}
{if $input.name == 'latitude'}
<input type="text"
{if isset($input.size)}size="{$input.size}"{/if}
{if isset($input.maxlength)}size="{$input.maxlength}"{/if}
name="latitude"
id="latitude"
value="{$fields_value[$input.name]}" /> /
<input type="text"
{if isset($input.size)}size="{$input.size}"{/if}
{if isset($input.maxlength)}size="{$input.maxlength}"{/if}
name="longitude"
id="longitude"
value="{$fields_value['longitude']}" />
{else}
{if isset($input.lang) && isset($input.attributeLang)}
{foreach $languages as $language}
<div id="{$input.name}_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
<input type="text"
name="{$input.name}_{$language.id_lang}"
value="{$fields_value[$input.name][$language.id_lang]}"
{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} />
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
</div>
{/foreach}
{if count($languages) > 1}
<div class="displayed_flag">
<img src="../img/l/{$defaultFormLanguage}.jpg"
class="pointer"
id="language_current_{$input.name}"
onclick="toggleLanguageFlags(this);" />
</div>
<div id="languages_{$input.name}" class="language_flags">
{l s='Choose language:'}<br /><br />
{foreach $languages as $language}
<img src="../img/l/{$language.id_lang}.jpg"
class="pointer"
alt="{$language.name}"
title="{$language.name}"
onclick="changeLanguage('{$input.name}', '{$input.attributeLang}', {$language.id_lang}, '{$language.iso_code}');" />
{/foreach}
</div>
{/if}
{else}
<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} />
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
{/if}
{/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]|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</optgroup>
{/foreach}
{else}
{foreach $input.options.query AS $option}
{$fields_value[$input.name]|@p}
<option value="{$option[$input.options.id]}"
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}>{$option[$input.options.name]|escape:'htmlall':'UTF-8'}</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|escape:'htmlall':'UTF-8'}"
{if $fields_value[$input.name] == $value.value}checked="checked"{/if} />
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}">
{if isset($input.is_bool) && $input.is_bool == true}
{if $value.value == 1}
<img src="../img/admin/enabled.gif" alt="{$value.label}" title="{$value.label}" />
{else}
<img src="../img/admin/disabled.gif" alt="{$value.label}" title="{$value.label}" />
{/if}
{else}
{$value.label}
{/if}
</label>
{/foreach}
{elseif $input.type == 'textarea'}
{if isset($input.lang) && isset($input.attributeLang)}
{foreach $languages as $language}
<div id="{$input.name}_{$language.id_lang}" style="display:{if $language.id_lang == $defaultFormLanguage}block{else}none{/if}; float: left;">
<textarea cols="{$input.cols}" rows="{$input.rows}" name="{$input.name}_{$language.id_lang}">{$fields_value[$input.name][$language.id_lang]}</textarea>
</div>
{/foreach}
{if count($languages) > 1}
<div class="displayed_flag">
<img src="../img/l/{$defaultFormLanguage}.jpg"
class="pointer"
id="language_current_{$input.name}"
onclick="toggleLanguageFlags(this);" />
</div>
<div id="languages_{$input.name}" class="language_flags">
{l s='Choose language:'}<br /><br />
{foreach $languages as $language}
<img src="../img/l/{$language.id_lang}.jpg"
class="pointer"
alt="{$language.name}"
title="{$language.name}"
onclick="changeLanguage('{$input.name}', '{$input.attributeLang}', {$language.id_lang}, '{$language.iso_code}');" />
{/foreach}
</div>
{/if}
{else}
<textarea name="{$input.name}" id="{$input.name}" cols="{$input.cols}" rows="{$input.rows}">{$fields_value[$input.name]}</textarea>
{/if}
{elseif $input.type == 'checkbox'}
{elseif $input.type == 'file'}
<input type="file" name="{$input.name}" />
<img src="{$fields_value[$input.name]}" />
{/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 $input.name == 'active'}
</div>
{/if}
{/if}
{if isset($languages)}<div class="clear"></div>{/if}
</div>
{if $input.name == 'id_state'}
</div>
{/if}
{/foreach}
{elseif $key == 'rightCols'}
<div style="padding-left: 40px; float: left;">
{foreach $field as $input}
{if $input.type == 'file'}
<label style="text-align: left; width: inherit;">{$input.label} </label>
<div class="margin-form" style="padding: 0; display: inline;">
<input type="file" name="{$input.name}" />
<p class="clear">{$input.p}</p>
{if isset($fields_value.image) && $fields_value.image}
<div id="image" style="width:390px;">
{$fields_value.image}
<p align="center">{l s='File size'} {$fields_value.size}kb</p>
<a href="{$current}&id_store={$form_id}&token={$token}&deleteImage=1">
<img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'}
</a>
</div>
{/if}
</div>
{/if}
<table cellpadding="2" cellspacing="2" style="padding: 10px; margin-top: 15px; border: 1px solid #BBB;">
<tr>
<th colspan="2">{l s='Hours:'}</th>
</tr>
<tr>
<td>&nbsp;</td>
<td style="font-size: 0.85em;">{l s='Sample: 10:00AM - 9:30PM'}</td>
</tr>
{foreach $fields_value.days as $k => $value}
<tr style="color: #7F7F7F; font-size: 0.85em;">
<td>{$value}</td>
<td><input type="text" size="25" name="hours_{$k}" value="{if isset($fields_value.hours[$k-1])}{$fields_value.hours[$k-1]}{/if}" /><br /></td>
</tr>
{/foreach}
</table>
<div class="clear"></div>
{/foreach}
</div>
{elseif $key == 'submit'}
<div class="clear"></div>
<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}
@@ -0,0 +1,162 @@
{*
* 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: 9369 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<br />
<script type="text/javascript">
id_language = Number({$id_lang});
</script>
<form action="{$current}&submitOptions{$table}=1&token={$token}" method="post" enctype="multipart/form-data">
{foreach $optionsList AS $category => $categoryData}
{if isset($categoryData['top'])}{$categoryData['top']}{/if}
<fieldset {if isset($categoryData['class'])}class="{$categoryData['class']}"{/if}>
{* Options category title *}
<legend>
<img src="{$img_legend}"/>
{if isset($categoryData['title'])}{$categoryData['title']}{else}{l s='Options'}{/if}
</legend>
{* Category description *}
{if (isset($categoryData['description']) && $categoryData['description'])}
<p class="optionsDescription">{$categoryData['description']}</p>
{/if}
{foreach $categoryData['fields'] AS $key => $field}
<div style="clear: both; padding-top:15px;" id="conf_id_{$key}" {if $field['is_invisible']} class="isInvisible"{/if}>
{if $field['title']}
<label class="conf_title">
{if (isset($field['required']) && $field['required'])}
<sup>*</sup>
{/if}
{$field['title']}</label>
{/if}
<div class="margin-form">
{if $field['type'] == 'select'}
<select name="{$key}"{if isset($field['js'])} onchange="{$field['js']}"{/if} id="{$key}">
{foreach $field['list'] AS $k => $option}
<option value="{$option[$field['identifier']]}"{if $field['value'] == $option[$field['identifier']]} selected="selected"{/if}>{$option['name']}</option>
{/foreach}
</select>
{elseif $field['type'] == 'bool'}
<label class="t" for="{$key}_on"><img src="../img/admin/enabled.gif" alt="{l s='Yes'}" title="{l s='Yes'}" /></label>
<input type="radio" name="{$key}" id="{$key}_on" value="1" {if $field['value']} checked="checked"{/if}{if isset($field['js']['on'])} {$field['js']['on']}{/if}/>
<label class="t" for="{$key}_on"> {l s='Yes'}</label>
<label class="t" for="{$key}_off"><img src="../img/admin/disabled.gif" alt="{l s='No'}" title="{l s='No'}" style="margin-left: 10px;" /></label>
<input type="radio" name="{$key}" id="{$key}_off" value="0" {if !$field['value']} checked="checked"{/if}{if isset($field['js']['off'])} {$field['js']['off']}{/if}/>
<label class="t" for="{$key}_off"> {l s='No'}</label>
{elseif $field['type'] == 'radio'}
{foreach $field['choices'] AS $k => $v}
<input type="radio" name="{$key}" id="{$key}_{$k}" value="{$k}"{if $k == $field['value']} checked="checked"{/if}{if isset($field['js'][$k])} {$field['js'][$k]}{/if}/>
<label class="t" for="{$key}_{$k}"> {$v}</label><br />
{/foreach}
<br />
{*{elseif $field['type'] == 'checkbox'}
{foreach $field['choices'] AS $k => $v}
<input type="checkbox" name="{$key}" id="{$key}{$k}_on" value="{$k|intval}"{if $k == $field['value']} checked="checked"{/if}{if isset($field['js'][$k])} {$field['js'][$k]}{/if}/>
<label class="t" for="{$key}{$k}_on"> {$v}</label><br />
{/foreach}
<br />
*}
{elseif $field['type'] == 'text'}
<input type="{$field['type']}"{if isset($field['id'])} id="{$field['id']}"{/if} size="{if isset($field['size'])}{$field['size']|intval}{else}5{/if}" name="{$key}" value="{$field['value']|escape:'htmlall':'UTF-8'}" />
{if isset($field['next'])}&nbsp;{$field['next']|strval}{/if}
{elseif $field['type'] == 'password'}
<input type="{$field['type']}"{if isset($field['id'])} id="{$field['id']}"{/if} size="{if isset($field['size'])}{$field['size']|intval}{else}5{/if}" name="{$key}" value="" />
{if isset($field['next'])}&nbsp;{$field['next']|strval}{/if}
{elseif $field['type'] == 'textarea'}
<textarea name={$key} cols="{$field['cols']}" rows="{$field['rows']}">{$field['value']|escape:'htmlall':'UTF-8'}</textarea>
{elseif $field['type'] == 'file'}
{if isset($field['thumb']) && $field['thumb'] && $field['thumb']['pos'] == 'before'}
<img src="{$field['thumb']['file']}" alt="{$field['title']}" title="{$field['title']}" /><br />
{/if}
<input type="file" name="{$key}" />
{* {elseif $field['type'] == 'image'}
<table cellspacing="0" cellpadding="0">
<tr>
$i = 0;
foreach ($field['list'] as $theme)
{
<td class="center" style="width: 180px; padding:0px 20px 20px 0px;">
<input type="radio" name="{$key}" id="{$key}_{$theme['name']}_on" style="vertical-align: text-bottom;" value="{$theme['name']}"'.(_THEME_NAME_ == $theme['name'] ? 'checked="checked"' : '').' />';
echo '<label class="t" for="{$key}_'.$theme['name'].'_on"> '.Tools::strtolower($theme['name']).'</label>';
echo '<br />';
echo '<label class="t" for="{$key}_'.$theme['name'].'_on">';
echo '<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.Tools::strtolower($theme['name']).'">';
echo '</label>';
echo '</td>';
if (isset($field['max']) && ($i +1 ) % $field['max'] == 0)
echo '</tr><tr>';
$i++;
}
echo '</tr>';
echo '</table>';
*}
{elseif $field['type'] == 'textLang'}
{foreach $field['languages'] AS $id_lang => $value}
<div id="{$key}_{$id_lang}" style="margin-bottom:8px; display: {if $id_lang == $current_id_lang}'block'{else}'none'{/if}; float: left; vertical-align: top;">
<input type="text" size="{if isset($field['size'])}{$field['size']|intval}{else}5{/if}" name="{$key}_{$id_lang}" value="{$value}" />
</div>
{/foreach}
{$field['flags']}
{elseif $field['type'] == 'textareaLang'}
{foreach $field['languages'] AS $id_lang => $value}
<div id="{$key}_{$id_lang}" style="display: {if $id_lang == $current_id_lang}'block'{else}'none'{/if}; float: left;">';
<textarea rows="{$field['rows']}" cols="{$field['cols']|intval}" name="{$key}_{$id_lang}">{$value|replace:'\r\n':"\n"}</textarea>
</div>
{/foreach}
{$field['flags']}
<br style="clear:both">
{/if}
{if isset($field['method'])}$field['method']{/if}
{if ($field['multishop_default'])}
<div class="preference_default_multishop">
<label>
<input type="checkbox" name="configUseDefault['{$key}']" value="1" {if $field['is_disabled']} checked="checked"{/if} onclick="checkMultishopDefaultValue(this, '{$key}')" /> {l s='Use default value'}
</label>
</div>
{/if}
{if isset($field['desc'])}<p class="preference_description">{$field['desc']}</p>{/if}
{if $field['is_invisible']}<p class="multishop_warning">{l s='You can\'t change the value of this configuration field in this shop context'}</p>{/if}
</div></div>
{/foreach}
<div align="center" style="margin-top: 20px;">
<input type="submit" value="{l s=' Save '}" name="submit{$category|ucfirst}{$table}" class="button" />
</div>
{if $field['required']}
<div class="small"><sup>*</sup> {l s='Required field'}</div>
{/if}
</fieldset><br />
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if}
{/foreach}
</form><br />
<p>
<img src="../img/admin/asterisk.gif" class="middle" />
{l s='You can also replace the icon representing your store in Google Maps. Go to the Preferences tab, and then the Appearance subtab.'}
</p>
+5 -3
View File
@@ -971,6 +971,7 @@ class AdminControllerCore extends Controller
else if ($this->display == 'list')
{
$this->getList($this->context->language->id);
$helper = new HelperList();
// Check if list templates have been overriden
if (file_exists($this->context->smarty->template_dir.'/'.$this->tpl_folder.'list_header.tpl'))
@@ -1004,9 +1005,9 @@ class AdminControllerCore extends Controller
$helper->identifier = $this->identifier;
$helper->token = $this->token;
$helper->imageType = $this->imageType;
$helper->no_add = isset($this->no_add) ? $this->no_add : false;
$helper->_listSkipDelete = $this->_listSkipDelete;
$helper->colorOnBackground = $this->colorOnBackground;
$this->content .= $helper->generateList($this->_list, $this->fieldsDisplay);
}
else if ($this->display == 'options')
@@ -1194,6 +1195,7 @@ class AdminControllerCore extends Controller
if (isset($_GET['deleteImage']))
{
$this->action = 'delete_image';
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
if (Validate::isLoadedObject($object = $this->loadObject()))
if (($object->deleteImage()))
Tools::redirectAdmin(self::$currentIndex.'&add'.$this->table.'&'.$this->identifier.'='.Tools::getValue($this->identifier).'&conf=7&token='.$token);
@@ -1277,7 +1279,7 @@ class AdminControllerCore extends Controller
public function displayErrors()
{
// @TODO includesubtab
$this->includeSubTab('displayErrors');
$content = $this->includeSubTab('displayErrors');
return $content;
}
@@ -1337,7 +1339,7 @@ class AdminControllerCore extends Controller
$selectShop = ', shop.name as shop_name ';
$joinShop = ' LEFT JOIN '._DB_PREFIX_.$this->shopLinkType.' shop
ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType;
$whereShop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
$whereShop = $this->context->shop->sqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
}
$assos = Shop::getAssoTables();
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'shop')
+3 -2
View File
@@ -31,6 +31,7 @@
class HelperOptionsCore extends Helper
{
public $first_call = true;
public $required = false;
/**
* @var array of forms fields
@@ -51,10 +52,8 @@ class HelperOptionsCore extends Helper
public function generateOptions($option_list)
{
$tab = Tab::getTab($this->context->language->id, $this->id);
foreach ($option_list as $category => $category_data)
{
$required = false;
foreach ($category_data['fields'] as $key => $field)
{
// Field value
@@ -75,6 +74,8 @@ class HelperOptionsCore extends Helper
$option_list[$category]['fields'][$key]['is_disabled'] = $isDisabled;
$option_list[$category]['fields'][$key]['is_invisible'] = $isInvisible;
$option_list[$category]['fields'][$key]['required'] = isset($field['required']) ? $field['required'] : $this->required;
// Cast options values if specified
if ($field['type'] == 'select' && isset($field['cast']))
foreach ($field['list'] as $option_key => $option)
+395
View File
@@ -0,0 +1,395 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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: 8971 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminStoresControllerCore extends AdminController
{
public function __construct()
{
$this->table = 'store';
$this->className = 'Store';
$this->lang = false;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->requiredDatabase = true;
$this->context = Context::getContext();
if (!Tools::getValue('realedit'))
$this->deleted = false;
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fieldImageSettings = array(
'name' => 'image',
'dir' => 'st'
);
$this->_select = 'cl.`name` country, st.`name` state';
$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.')
LEFT JOIN `'._DB_PREFIX_.'state` st
ON (st.`id_state` = a.`id_state`)';
$this->fieldsDisplay = array(
'id_store' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'country' => array(
'title' => $this->l('Country'),
'width' => 100,
'filter_key' => 'cl!name'
),
'state' => array(
'title' => $this->l('State'),
'width' => 100,
'filter_key' => 'st!name'
),
'city' => array('title' => $this->l('City'), 'width' => 100),
'postcode' => array('title' => $this->l('Zip code'), 'width' => 50),
'name' => array('title' => $this->l('Name'), 'width' => 120, 'filter_key' => 'a!name'),
'phone' => array('title' => $this->l('Phone'), 'width' => 70),
'fax' => array('title' => $this->l('Fax'), 'width' => 70),
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Stores'),
'image' => '../img/admin/home.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name:'),
'name' => 'name',
'size' => 33,
'required' => false,
'hint' => $this->l('Allowed characters: letters, spaces and').' (-)',
'p' => $this->l('Store name, e.g. Citycentre Mall Store')
),
array(
'type' => 'text',
'label' => $this->l('Address:'),
'name' => 'address1',
'size' => 33,
'required' => true
),
array(
'type' => 'text',
'label' => $this->l('Address:'),
'name' => 'address2',
'size' => 33
),
array(
'type' => 'text',
'label' => $this->l('Postcode/ Zip Code:'),
'name' => 'postcode',
'size' => 6
),
array(
'type' => 'text',
'label' => $this->l('City:'),
'name' => 'city',
'size' => 33,
'class' => 'uppercase',
'required' => true
),
array(
'type' => 'select',
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => true,
'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' => true,
'options' => array(
'id' => 'id_state',
'name' => 'name'
)
),
array(
'type' => 'text',
'label' => $this->l('Latitude / Longitude:'),
'name' => 'latitude',
'required' => true,
'size' => 11,
'maxlength' => 12,
'p' => $this->l('Store coords, eg. 45.265469 / -47.226478')
),
array(
'type' => 'text',
'label' => $this->l('Phone:'),
'name' => 'phone',
'size' => 33
),
array(
'type' => 'text',
'label' => $this->l('Fax:'),
'name' => 'fax',
'size' => 33
),
array(
'type' => 'text',
'label' => $this->l('E-mail address:'),
'name' => 'email',
'size' => 33
),
array(
'type' => 'textarea',
'label' => $this->l('Note:'),
'name' => 'note',
'cols' => 42,
'rows' => 4
),
array(
'type' => 'radio',
'label' => $this->l('Status:'),
'name' => 'active',
'required' => false,
'class' => 't',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
'p' => $this->l('Display or not this store')
)
),
'rightCols' => array (
'input' => array(
'type' => 'file',
'label' => $this->l('Picture:'),
'name' => 'image',
'p' => $this->l('Store window picture')
)
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
$this->form_list = array(
'option_store_pref' => array(
'general' => array(
'title' => $this->l('Parameters'),
'fields' => array(
'PS_STORES_DISPLAY_FOOTER' => array(
'title' => $this->l('Display in the footer:'),
'desc' => $this->l('Display a link to the store locator in the footer'),
'cast' => 'intval',
'type' => 'bool'
),
'PS_STORES_DISPLAY_SITEMAP' => array(
'title' => $this->l('Display in the sitemap page:'),
'desc' => $this->l('Display a link to the store locator in the sitemap page'),
'cast' => 'intval',
'type' => 'bool'
),
'PS_STORES_SIMPLIFIED' => array(
'title' => $this->l('Show a simplified store locator:'),
'desc' => $this->l('No map, no search, only a store directory'),
'cast' => 'intval',
'type' => 'bool'
),
'PS_STORES_CENTER_LAT' => array(
'title' => $this->l('Latitude by default:'),
'desc' => $this->l('Used for the position by default of the map'),
'cast' => 'floatval',
'type' => 'text',
'size' => '10'
),
'PS_STORES_CENTER_LONG' => array(
'title' => $this->l('Longitude by default:'),
'desc' => $this->l('Used for the position by default of the map'),
'cast' => 'floatval',
'type' => 'text',
'size' => '10'
)
)
)
)
);
parent::__construct();
}
public function postProcess()
{
if (isset($_POST['submitAdd'.$this->table]))
{
/* Cleaning fields */
foreach ($_POST as $kp => $vp)
$_POST[$kp] = trim($vp);
/* If the selected country does not contain states */
$id_state = (int)Tools::getValue('id_state');
$id_country = (int)Tools::getValue('id_country');
$country = new Country((int)$id_country);
if ($id_country && $country && !(int)$country->contains_states && $id_state)
$this->_errors[] = Tools::displayError('You have selected a state for a country that does not contain states.');
/* If the selected country contains states, then a state have to be selected */
if ((int)$country->contains_states && !$id_state)
$this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
$latitude = (float)Tools::getValue('latitude');
$longitude = (float)Tools::getValue('longitude');
if (empty($latitude) || empty($longitude))
$this->_errors[] = Tools::displayError('Latitude and longitude are required.');
/* Check zip code */
if ($country->need_zip_code)
{
$zip_code_format = $country->zip_code_format;
if (($postcode = Tools::getValue('postcode')) && $zip_code_format)
{
$zip_regexp = '/^'.$zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
if (!preg_match($zip_regexp, $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.').'<br />'.Tools::displayError('Must be typed as follows:').' '.
str_replace(
'C',
$country->iso_code,
str_replace(
'N',
'0',
str_replace(
'L',
'A',
$zip_code_format
)
)
);
}
else if ($zip_code_format)
$this->_errors[] = Tools::displayError('Postcode required.');
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
}
/* Store hours */
$_POST['hours'] = array();
for ($i = 1; $i < 8; $i++)
$_POST['hours'][] .= Tools::getValue('hours_'.(int)$i);
$_POST['hours'] = serialize($_POST['hours']);
}
if (!count($this->_errors))
parent::postProcess();
}
public function initContent()
{
if (!($obj = $this->loadObject(true)))
return;
$image = cacheImage(_PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg', $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 350, $this->imageType, true);
$days = array();
$days[1] = $this->l('Monday');
$days[2] = $this->l('Tuesday');
$days[3] = $this->l('Wednesday');
$days[4] = $this->l('Thursday');
$days[5] = $this->l('Friday');
$days[6] = $this->l('Saturday');
$days[7] = $this->l('Sunday');
$hours = $this->getFieldValue($obj, 'hours');
if (!empty($hours))
$hours_unserialized = unserialize($hours);
$this->fields_value = array(
'latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'),
'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'),
'image' => $image ? $image : false,
'size' => $image ? filesize(_PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg') / 1000 : false,
'days' => $days,
'hours' => isset($hours_unserialized) ? $hours_unserialized : false
);
if ($this->display != 'edit' && $this->display != 'add')
$this->display = 'list';
parent::initContent();
if ($this->display == 'list')
{
$helper = new HelperOptions();
if (file_exists($this->context->smarty->template_dir.'/'.$this->tpl_folder.'options.tpl'))
$helper->tpl = $this->tpl_folder.'options.tpl';
$helper->id = $this->id;
$helper->currentIndex = self::$currentIndex;
$this->content .= $helper->generateOptions($this->form_list['option_store_pref']);
}
}
protected function postImage($id)
{
$ret = parent::postImage($id);
if (($id_store = (int)Tools::getValue('id_store')) && isset($_FILES) && count($_FILES) && file_exists(_PS_STORE_IMG_DIR_.$id_store.'.jpg'))
{
$images_types = ImageType::getImagesTypes('stores');
foreach ($images_types as $k => $image_type)
imageResize(_PS_STORE_IMG_DIR_.$id_store.'.jpg',
_PS_STORE_IMG_DIR_.$id_store.'-'.stripslashes($image_type['name']).'.jpg',
(int)$image_type['width'], (int)$image_type['height']
);
}
return $ret;
}
}