[*] BO : #PSFV-94 - added AdminCurrencuesController
This commit is contained in:
@@ -1,247 +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: 7300 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php');
|
||||
|
||||
class AdminCurrencies extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'currency';
|
||||
$this->className = 'Currency';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_currency' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Currency'), 'width' => 100),
|
||||
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 35),
|
||||
'iso_code_num' => array('title' => $this->l('ISO code num'), 'align' => 'center', 'width' => 35),
|
||||
'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
|
||||
'conversion_rate' => array('title' => $this->l('Conversion rate'), 'float' => true, 'align' => 'center', 'width' => 50, 'search' => false),
|
||||
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
|
||||
);
|
||||
$this->_where = 'AND a.`deleted` = 0';
|
||||
|
||||
$this->optionsList = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Currencies options'),
|
||||
'fields' => array(
|
||||
'PS_CURRENCY_DEFAULT' => array(
|
||||
'title' => $this->l('Default currency:'),
|
||||
'desc' => $this->l('The default currency used in shop')
|
||||
.'<div class=warn"><img src="../img/admin/warn2.png" />'.$this->l('If you change default currency, you will have to manually edit every product price.').'</div>',
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'identifier' => 'id_currency',
|
||||
'list' => Currency::getCurrencies()
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||
$this->_errors[] = $this->l('You can\'t delete the default currency');
|
||||
elseif ($object->delete())
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=1'.'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif ((isset($_GET['status'.$this->table]) OR isset($_GET['status'])) AND Tools::getValue($this->identifier))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->active AND $object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||
$this->_errors[] = $this->l('You can\'t disable the default currency');
|
||||
elseif ($object->toggleStatus())
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
elseif (Tools::isSubmit('submitExchangesRates'))
|
||||
{
|
||||
if (!$this->_errors[] = Currency::refreshCurrencies())
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function updateOptionPsCurrencyDefault($value)
|
||||
{
|
||||
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
|
||||
Currency::refreshCurrencies();
|
||||
}
|
||||
|
||||
public function displayOptionsList()
|
||||
{
|
||||
parent::displayOptionsList();
|
||||
|
||||
$dir = explode(DIRECTORY_SEPARATOR, dirname(__FILE__));
|
||||
for ($i = 0; $i < 2; ++$i)
|
||||
$adminDir = array_pop($dir);
|
||||
|
||||
echo '<br /><br />
|
||||
<form action="'.self::$currentIndex.'&token='.$this->token.'" method="post">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/exchangesrate.gif" />'.$this->l('Currency rates').'</legend>
|
||||
<label>'.$this->l('Update currency rates').'</label>
|
||||
<div class="margin-form">
|
||||
<p>'.$this->l('Update your currencies exchanges rates with a real-time tool').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l('Update currency rates').'" name="submitExchangesRates" class="button" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
echo '<br /></br />
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/tab-tools.gif" />'.$this->l('Currency rates update').'</legend>
|
||||
<p>'.$this->l('Place this URL in crontab or call it manually daily').':<br />
|
||||
<b>'.Tools::getShopDomain(true, true). __PS_BASE_URI__.$adminDir.'/cron_currency_rates.php?secure_key='.md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME')).'</b></p>
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
echo '
|
||||
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/money.gif" />'.$this->l('Currencies').'</legend>
|
||||
<label>'.$this->l('Currency:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Only letters and the minus character are allowed').'<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('Will appear on Front Office, e.g., euro, dollar').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('ISO code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="iso_code" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint-pointer"> </span>
|
||||
<p class="clear">'.$this->l('ISO code, e.g., USD for dollar, EUR for euro').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('Numeric ISO code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="iso_code_num" value="'.htmlentities($this->getFieldValue($obj, 'iso_code_num'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint-pointer"> </span>
|
||||
<p class="clear">'.$this->l('Numeric ISO code, e.g., 840 for dollar, 978 for euro').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('Symbol:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="3" maxlength="8" name="sign" value="'.$this->getFieldValue($obj, 'sign').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Will appear on Front Office, e.g., €, $').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('Conversion rate:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="3" maxlength="11" name="conversion_rate" value="'.htmlentities($this->getFieldValue($obj, 'conversion_rate')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Conversion rate from one unit of your shop\'s default currency (for example, 1€) to this currency. For example, if the default currency is euros and this currency is dollars, type \'1.20\'').' 1€ = $1.20</p>
|
||||
</div>
|
||||
<label>'.$this->l('Formatting:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="format">';
|
||||
$currency_formats = array(
|
||||
1 => 'X0,000.00 ('.$this->l('as with dollars').')',
|
||||
2 => '0 000,00X ('.$this->l('as with euros').')',
|
||||
3 => 'X0.000,00',
|
||||
4 => '0,000.00X',
|
||||
);
|
||||
foreach ($currency_formats AS $nb => $desc)
|
||||
echo '<option value="'.$nb.'"'.($this->getFieldValue($obj, 'format') == $nb ? 'selected="selected"' : '').'>'.$desc.'</option>';
|
||||
echo '
|
||||
</select>
|
||||
<p class="clear">'.$this->l('Applies to all prices, e.g.,').' $1,240.15</p>
|
||||
</div>
|
||||
<label>'.$this->l('Decimals:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="decimals" id="decimals_on" value="1" '.($this->getFieldValue($obj, 'decimals') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="decimals_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" /></label>
|
||||
<input type="radio" name="decimals" id="decimals_off" value="0" '.(!$this->getFieldValue($obj, 'decimals') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="decimals_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" /></label>
|
||||
<p>'.$this->l('Display decimals on prices').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Blank:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="blank" id="blank_on" value="1" '.($this->getFieldValue($obj, 'blank') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="blank_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="blank" id="blank_off" value="0" '.(!$this->getFieldValue($obj, 'blank') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="blank_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Include a blank between sign and price, e.g.,').'<br />$1,240.15 -> $ 1,240.15</p>
|
||||
</div>
|
||||
<label>'.$this->l('Enable:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($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" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
</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>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +204,11 @@
|
||||
{elseif $input.type == 'file'}
|
||||
<input type="file" name="{$input.name}" />
|
||||
<img src="{$fields_value[$input.name]}" />
|
||||
{elseif $input.type == 'asso_shop' && isset($asso_shop) && $asso_shop}
|
||||
<label>{l s='Shop association:'}</label>
|
||||
<div class="margin-form">
|
||||
{$asso_shop}
|
||||
</div>
|
||||
{/if}
|
||||
{if isset($input.required) && $input.required} <sup>*</sup>{/if}
|
||||
{if isset($input.p)}
|
||||
|
||||
@@ -25,130 +25,139 @@
|
||||
*}
|
||||
<br />
|
||||
<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>
|
||||
{foreach $option_list 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="{$categoryData['image']}"/>
|
||||
{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}
|
||||
<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>
|
||||
{* Category info *}
|
||||
{if (isset($categoryData['info']) && $categoryData['info'])}
|
||||
<p>{$categoryData['info']}</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}
|
||||
</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 />
|
||||
<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'])} {$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'])} {$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'] == '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'])} {$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'])} {$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 />
|
||||
{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}
|
||||
<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}" />
|
||||
{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>
|
||||
{/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>
|
||||
{/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}
|
||||
{if isset($categoryData['submit'])}
|
||||
<div class="margin-form">
|
||||
<input type="submit"
|
||||
value="{if isset($categoryData['submit']['title'])}{$categoryData['submit']['title']}{else}{l s=' Save '}{/if}"
|
||||
name="{if isset($categoryData['submit']['name'])}$categoryData['submit']['name']{else}submit{$category|ucfirst}{$table}{/if}"
|
||||
class="{if isset($categoryData['submit']['class'])}{$categoryData['submit']['class']}{else}button{/if}"
|
||||
/>
|
||||
</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>
|
||||
{if $field['required']}
|
||||
<div class="small"><sup>*</sup> {l s='Required field'}</div>
|
||||
{/if}
|
||||
</fieldset><br />
|
||||
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if}
|
||||
{/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>
|
||||
|
||||
@@ -267,5 +267,108 @@ class HelperCore
|
||||
echo $output;
|
||||
}
|
||||
|
||||
protected function displayAssoShop($type = 'shop')
|
||||
{
|
||||
if (!Shop::isMultiShopActivated() || (!$this->id && $this->context->shop->getContextType() != Shop::CONTEXT_ALL))
|
||||
return;
|
||||
|
||||
if ($type != 'shop' && $type != 'group_shop')
|
||||
$type = 'shop';
|
||||
|
||||
$assos = array();
|
||||
$sql = 'SELECT id_'.$type.', `'.pSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$type.'`';
|
||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||
$assos[$row['id_'.$type]][] = $row[$this->identifier];
|
||||
|
||||
$html = <<<EOF
|
||||
<script type="text/javascript">
|
||||
$().ready(function()
|
||||
{
|
||||
// Click on "all shop"
|
||||
$('.input_all_shop').click(function()
|
||||
{
|
||||
var checked = $(this).attr('checked');
|
||||
$('.input_group_shop').attr('checked', checked);
|
||||
$('.input_shop').attr('checked', checked);
|
||||
});
|
||||
|
||||
// Click on a group shop
|
||||
$('.input_group_shop').click(function()
|
||||
{
|
||||
$('.input_shop[value='+$(this).val()+']').attr('checked', $(this).attr('checked'));
|
||||
check_all_shop();
|
||||
});
|
||||
|
||||
// Click on a shop
|
||||
$('.input_shop').click(function()
|
||||
{
|
||||
check_group_shop_status($(this).val());
|
||||
check_all_shop();
|
||||
});
|
||||
|
||||
// Initialize checkbox
|
||||
$('.input_shop').each(function(k, v)
|
||||
{
|
||||
check_group_shop_status($(v).val());
|
||||
check_all_shop();
|
||||
});
|
||||
});
|
||||
|
||||
function check_group_shop_status(id_group)
|
||||
{
|
||||
var groupChecked = true;
|
||||
$('.input_shop[value='+id_group+']').each(function(k, v)
|
||||
{
|
||||
if (!$(v).attr('checked'))
|
||||
groupChecked = false;
|
||||
});
|
||||
$('.input_group_shop[value='+id_group+']').attr('checked', groupChecked);
|
||||
}
|
||||
|
||||
function check_all_shop()
|
||||
{
|
||||
var allChecked = true;
|
||||
$('.input_group_shop').each(function(k, v)
|
||||
{
|
||||
if (!$(v).attr('checked'))
|
||||
allChecked = false;
|
||||
});
|
||||
$('.input_all_shop').attr('checked', allChecked);
|
||||
}
|
||||
</script>
|
||||
EOF;
|
||||
|
||||
$html .= '<div class="assoShop">';
|
||||
$html .= '<table class="table" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr><th>'.$this->l('Shop').'</th></tr>';
|
||||
$html .= '<tr'.(($type == 'group_shop') ? ' class="alt_row"' : '').'><td><label class="t"><input class="input_all_shop" type="checkbox" /> '.$this->l('All shops').'</label></td></tr>';
|
||||
foreach (Shop::getTree() as $groupID => $groupData)
|
||||
{
|
||||
$groupChecked = ($type == 'group_shop' && ((isset($assos[$groupID]) && in_array($this->id, $assos[$groupID])) || !$this->id));
|
||||
$html .= '<tr'.(($type == 'shop') ? ' class="alt_row"' : '').'>';
|
||||
$html .= '<td><img style="vertical-align: middle;" alt="" src="../img/admin/lv2_b.gif" /><label class="t"><input class="input_group_shop" type="checkbox" name="checkBoxGroupShopAsso_'.$this->table.'_'.$this->id.'_'.$groupID.'" value="'.$groupID.'" '.($groupChecked ? 'checked="checked"' : '').' /> '.$groupData['name'].'</label></td>';
|
||||
$html .= '</tr>';
|
||||
|
||||
if ($type == 'shop')
|
||||
{
|
||||
$total = count($groupData['shops']);
|
||||
$j = 0;
|
||||
foreach ($groupData['shops'] as $shopID => $shopData)
|
||||
{
|
||||
$checked = ((isset($assos[$shopID]) && in_array($this->id, $assos[$shopID])) || !$this->id);
|
||||
$html .= '<tr>';
|
||||
$html .= '<td><img style="vertical-align: middle;" alt="" src="../img/admin/lv3_'.(($j < $total - 1) ? 'b' : 'f').'.png" /><label class="child">';
|
||||
$html .= '<input class="input_shop" type="checkbox" value="'.$groupID.'" name="checkBoxShopAsso_'.$this->table.'_'.$this->id.'_'.$shopID.'" id="checkedBox_'.$shopID.'" '.($checked ? 'checked="checked"' : '').' /> ';
|
||||
$html .= $shopData['name'].'</label></td>';
|
||||
$html .= '</tr>';
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= '</table></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ class HelperFormCore extends Helper
|
||||
'requiredFields' => $this->getFieldsRequired(),
|
||||
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
|
||||
'module_dir' => _MODULE_DIR_,
|
||||
'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null
|
||||
'contains_states' => (isset($this->fields_value['id_country']) && isset($this->fields_value['id_state'])) ? Country::containsStates($this->fields_value['id_country']) : null,
|
||||
'asso_shop' => (isset($this->fields_form['asso_shop']) && $this->fields_form['asso_shop']) ? $this->displayAssoShop() : null,
|
||||
));
|
||||
|
||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
|
||||
|
||||
+22
-11
@@ -54,10 +54,16 @@ class HelperOptionsCore extends Helper
|
||||
$tab = Tab::getTab($this->context->language->id, $this->id);
|
||||
foreach ($option_list as $category => $category_data)
|
||||
{
|
||||
if (!isset($category_data['image']))
|
||||
$category_data['image'] = (!empty($tab['module']) && file_exists($_SERVER['DOCUMENT_ROOT']._MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.gif') ? _MODULE_DIR_.$tab['module'].'/' : '../img/t/').$tab['class_name'].'.gif';
|
||||
|
||||
if (!isset($category_data['fields']))
|
||||
$category_data['fields'] = array();
|
||||
|
||||
foreach ($category_data['fields'] as $key => $field)
|
||||
{
|
||||
// Field value
|
||||
$option_list[$category]['fields'][$key]['value'] = $this->getOptionValue($key, $field);
|
||||
// Set field value
|
||||
$field['value'] = $this->getOptionValue($key, $field);
|
||||
|
||||
// Check if var is invisible (can't edit it in current shop context), or disable (use default value for multishop)
|
||||
$isDisabled = $isInvisible = false;
|
||||
@@ -71,15 +77,15 @@ class HelperOptionsCore extends Helper
|
||||
else if (Context::shop() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
|
||||
$isDisabled = true;
|
||||
}
|
||||
$option_list[$category]['fields'][$key]['is_disabled'] = $isDisabled;
|
||||
$option_list[$category]['fields'][$key]['is_invisible'] = $isInvisible;
|
||||
$field['is_disabled'] = $isDisabled;
|
||||
$field['is_invisible'] = $isInvisible;
|
||||
|
||||
$option_list[$category]['fields'][$key]['required'] = isset($field['required']) ? $field['required'] : $this->required;
|
||||
$field['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)
|
||||
$option_list[$category]['fields'][$key]['list'][$option_key][$field['identifier']] = $field['cast']($option[$field['identifier']]);
|
||||
$field['list'][$option_key][$field['identifier']] = $field['cast']($option[$field['identifier']]);
|
||||
|
||||
// Fill values for all languages for all lang fields
|
||||
if (substr($field['type'], -4) == 'Lang')
|
||||
@@ -93,19 +99,24 @@ class HelperOptionsCore extends Helper
|
||||
$value = Tools::safeOutput(Tools::getValue($key.'_'.$language['id_lang'], Configuration::get($key, $language['id_lang'])));
|
||||
elseif ($field['type'] == 'textareaLang')
|
||||
$value = Configuration::get($key, $language['id_lang']);
|
||||
$option_list[$category]['fields'][$key]['languages'][$language['id_lang']] = $value;
|
||||
$field['languages'][$language['id_lang']] = $value;
|
||||
}
|
||||
$option_list[$category]['fields'][$key]['flags'] = $this->displayFlags($languages, $this->context->language->id, $key, $key, true);
|
||||
$field['flags'] = $this->displayFlags($languages, $this->context->language->id, $key, $key, true);
|
||||
}
|
||||
|
||||
// Multishop default value
|
||||
$option_list[$category]['fields'][$key]['multishop_default'] = (Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible);
|
||||
$field['multishop_default'] = (Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible);
|
||||
|
||||
// Assign the modifications back to parent array
|
||||
$category_data['fields'][$key] = $field;
|
||||
}
|
||||
// Assign the modifications back to parent array
|
||||
$option_list[$category] = $category_data;
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'img_legend' => (!empty($tab['module']) && file_exists($_SERVER['DOCUMENT_ROOT']._MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.gif') ? _MODULE_DIR_.$tab['module'].'/' : '../img/t/').$tab['class_name'].'.gif',
|
||||
'current' => $this->currentIndex,
|
||||
'optionsList' => $option_list,
|
||||
'option_list' => $option_list,
|
||||
'current_id_lang' => $this->context->language->id,
|
||||
));
|
||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
<?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: 7300 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php');
|
||||
|
||||
class AdminCurrenciesControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'currency';
|
||||
$this->className = 'Currency';
|
||||
$this->lang = false;
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_currency' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Currency'), 'width' => 100),
|
||||
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 35),
|
||||
'iso_code_num' => array('title' => $this->l('ISO code num'), 'align' => 'center', 'width' => 35),
|
||||
'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
|
||||
'conversion_rate' => array('title' => $this->l('Conversion rate'), 'float' => true, 'align' => 'center', 'width' => 50, 'search' => false),
|
||||
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
|
||||
);
|
||||
$this->_where = 'AND a.`deleted` = 0';
|
||||
|
||||
$this->options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Currencies options'),
|
||||
'fields' => array(
|
||||
'PS_CURRENCY_DEFAULT' => array(
|
||||
'title' => $this->l('Default currency:'),
|
||||
'desc' => $this->l('The default currency used in shop')
|
||||
.'<div class=warn"><img src="../img/admin/warn2.png" />'.$this->l('If you change default currency, you will have to manually edit every product price.').'</div>',
|
||||
'cast' => 'intval',
|
||||
'type' => 'select',
|
||||
'identifier' => 'id_currency',
|
||||
'list' => Currency::getCurrencies()
|
||||
),
|
||||
),
|
||||
),
|
||||
'change' => array(
|
||||
'title' => $this->l('Currency rates'),
|
||||
'image' => '../img/admin/exchangesrate.gif',
|
||||
'description' => $this->l('Update your currencies exchanges rates with a real-time tool'),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Update currency rates'),
|
||||
'class' => 'button',
|
||||
'name' => 'SubmitExchangesRates'
|
||||
),
|
||||
),
|
||||
'cron' => array(
|
||||
'title' => $this->l('Currency rates update'),
|
||||
'image' => '../img/admin/tab-tools.gif',
|
||||
'info' => $this->l('Place this URL in crontab or call it manually daily').':<br />
|
||||
<b>'.Tools::getShopDomain(true, true). __PS_BASE_URI__.basename(_PS_ADMIN_DIR_).'/cron_currency_rates.php?secure_key='.md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME')).'</b></p>',
|
||||
),
|
||||
);
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Currencies:'),
|
||||
'image' => '../img/admin/money.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Currency:'),
|
||||
'name' => 'name',
|
||||
'size' => 30,
|
||||
'maxlength' => 32,
|
||||
'required' => true,
|
||||
'hint' => $this->l('Only letters and the minus character are allowed'),
|
||||
'p' => $this->l('Will appear on Front Office, e.g., euro, dollar').'...',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('ISO code:'),
|
||||
'name' => 'iso_code',
|
||||
'size' => 30,
|
||||
'maxlength' => 32,
|
||||
'required' => true,
|
||||
'p' => $this->l('ISO code, e.g., USD for dollar, EUR for euro').'...',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Numeric ISO code:'),
|
||||
'name' => 'iso_code_num',
|
||||
'size' => 30,
|
||||
'maxlength' => 32,
|
||||
'required' => true,
|
||||
'p' => $this->l('Numeric ISO code, e.g., 840 for dollar, 978 for euro').'...',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Symbol:'),
|
||||
'name' => 'sign',
|
||||
'size' => 3,
|
||||
'maxlength' => 8,
|
||||
'required' => true,
|
||||
'p' => $this->l('Will appear on Front Office, e.g., €, $').'...',
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Conversion rate:'),
|
||||
'name' => 'conversion_rate',
|
||||
'size' => 3,
|
||||
'maxlength' => 11,
|
||||
'required' => true,
|
||||
'p' => $this->l('Conversion rate from one unit of your shop\'s default currency (for example, 1€) to this currency. For example, if the default currency is euros and this currency is dollars, type \'1.20\'').' 1€ = $1.20',
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Formatting:'),
|
||||
'name' => 'format',
|
||||
'size' => 3,
|
||||
'maxlength' => 11,
|
||||
'required' => true,
|
||||
'p' =>$this->l('Applies to all prices, e.g.,').' $1,240.15',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array('key' => 1, 'name' => 'X0,000.00 ('.$this->l('as with dollars').')'),
|
||||
array('key' => 2, 'name' => '0 000,00X ('.$this->l('as with euros').')'),
|
||||
array('key' => 3, 'name' => 'X0.000,00'),
|
||||
array('key' => 4, 'name' => '0,000.00X'),
|
||||
),
|
||||
'name' => 'name',
|
||||
'id' => 'key'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Decimals:'),
|
||||
'name' => 'decimals',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'p' => $this->l('Display decimals on prices'),
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'decimals_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'decimals_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Blank:'),
|
||||
'name' => 'blank',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'p' => $this->l('Include a blank between sign and price, e.g.,').'<br />$1,240.15 -> $ 1,240.15',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'blank_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'blank_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Enable:'),
|
||||
'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')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'asso_shop',
|
||||
'name' => ''
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
),
|
||||
'asso_shop' => Shop::isMultiShopActivated()
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if ($this->action == 'delete')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||
$this->_errors[] = $this->l('You can\'t delete the default currency');
|
||||
elseif ($object->delete())
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=1'.'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
elseif ($this->action == 'status')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->active AND $object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||
$this->_errors[] = $this->l('You can\'t disable the default currency');
|
||||
elseif ($object->toggleStatus())
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
elseif (Tools::isSubmit('submitExchangesRates'))
|
||||
{
|
||||
if (!$this->_errors[] = Currency::refreshCurrencies())
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function updateOptionPsCurrencyDefault($value)
|
||||
{
|
||||
Configuration::updateValue('PS_CURRENCY_DEFAULT', $value);
|
||||
Currency::refreshCurrencies();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ class AdminImagesController extends AdminController
|
||||
'PS_JPEG_QUALITY' => array('title' => $this->l('JPEG quality'), 'desc' => $this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
|
||||
'PS_PNG_QUALITY' => array('title' => $this->l('PNG quality'), 'desc' => $this->l('Ranges from 9 (worst quality, smallest file) to 0 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
|
||||
),
|
||||
'submit' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user