// fix bug statsforecast and added toolbar in AdminDbController
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10411 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{*
|
{*
|
||||||
* 2007-2011 PrestaShop
|
* 2007-2011 PrestaShop
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* NOTICE OF LICENSE
|
||||||
*
|
*
|
||||||
@@ -19,17 +19,14 @@
|
|||||||
*
|
*
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
* @version Release: $Revision$
|
* @version Release: $Revision: 8971 $
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
{extends file="helper/form/form.tpl"}
|
||||||
|
|
||||||
<br />
|
{block name="label"}
|
||||||
{$content}
|
{if $input.type == 'table'}
|
||||||
<br />
|
|
||||||
<fieldset class="width2">
|
|
||||||
<legend>{l s='MySQL Engine'}</legend>
|
|
||||||
<form name="updateEngine" action="{$update_url}" method="post">
|
|
||||||
<table cellspacing="0" cellpadding="0" class="table width2 clear">
|
<table cellspacing="0" cellpadding="0" class="table width2 clear">
|
||||||
<tr>
|
<tr>
|
||||||
<th><input type="checkbox" onclick="checkDelBoxes(this.form, 'tablesBox[]', this.checked)" class="noborder" name="checkme"></th>
|
<th><input type="checkbox" onclick="checkDelBoxes(this.form, 'tablesBox[]', this.checked)" class="noborder" name="checkme"></th>
|
||||||
@@ -41,15 +38,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</table>
|
</table>
|
||||||
<br />
|
{/if}
|
||||||
<label for="dbEngine">{l s='Change Engine to'}</label>
|
{if isset($input.label)}
|
||||||
<div class="margin-form">
|
<label>{$input.label} </label>
|
||||||
<select name="engineType">
|
{/if}
|
||||||
{foreach $engines AS $engine}
|
{/block}
|
||||||
<option value="{$engine}">{$engine}</option>
|
|
||||||
{/foreach}
|
|
||||||
</select>
|
|
||||||
<input style="margin-left:15px;" class="button" type="submit" value="Submit" name="submitEngine" />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</fieldset>
|
|
||||||
@@ -38,29 +38,136 @@ class AdminDbControllerCore extends AdminController
|
|||||||
'database' => array(
|
'database' => array(
|
||||||
'title' => $this->l('Database'),
|
'title' => $this->l('Database'),
|
||||||
'icon' => 'database_gear',
|
'icon' => 'database_gear',
|
||||||
'class' => 'width2',
|
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'db_server' => array('title' => $this->l('Server:'), 'desc' => $this->l('IP or server name; \'localhost\' will work in most cases'), 'size' => 30, 'type' => 'text', 'required' => true, 'defaultValue' => _DB_SERVER_, 'visibility' => Shop::CONTEXT_ALL),
|
'db_server' => array(
|
||||||
'db_name' => array('title' => $this->l('Database:'), 'desc' => $this->l('Database name (e.g., \'prestashop\')'), 'size' => 30, 'type' => 'text', 'required' => true, 'defaultValue' => _DB_NAME_, 'visibility' => Shop::CONTEXT_ALL),
|
'title' => $this->l('Server:'),
|
||||||
'db_prefix' => array('title' => $this->l('Prefix:'), 'size' => 30, 'type' => 'text', 'defaultValue' => _DB_PREFIX_, 'visibility' => Shop::CONTEXT_ALL),
|
'desc' => $this->l('IP or server name; \'localhost\' will work in most cases'),
|
||||||
'db_user' => array('title' => $this->l('User:'), 'size' => 30, 'type' => 'text', 'required' => true, 'defaultValue' => _DB_USER_, 'visibility' => Shop::CONTEXT_ALL),
|
'size' => 30,
|
||||||
'db_passwd' => array('title' => $this->l('Password:'), 'size' => 30, 'type' => 'password', 'desc' => $this->l('Leave blank if no change'), 'defaultValue' => _DB_PASSWD_, 'visibility' => Shop::CONTEXT_ALL),
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'defaultValue' => _DB_SERVER_,
|
||||||
|
'visibility' => Shop::CONTEXT_ALL
|
||||||
|
),
|
||||||
|
'db_name' => array(
|
||||||
|
'title' => $this->l('Database:'),
|
||||||
|
'desc' => $this->l('Database name (e.g., \'prestashop\')'),
|
||||||
|
'size' => 30,
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'defaultValue' => _DB_NAME_,
|
||||||
|
'visibility' => Shop::CONTEXT_ALL
|
||||||
|
),
|
||||||
|
'db_prefix' => array(
|
||||||
|
'title' => $this->l('Prefix:'),
|
||||||
|
'size' => 30,
|
||||||
|
'type' => 'text',
|
||||||
|
'defaultValue' => _DB_PREFIX_,
|
||||||
|
'visibility' => Shop::CONTEXT_ALL
|
||||||
|
),
|
||||||
|
'db_user' => array(
|
||||||
|
'title' => $this->l('User:'),
|
||||||
|
'size' => 30,
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'defaultValue' => _DB_USER_,
|
||||||
|
'visibility' => Shop::CONTEXT_ALL
|
||||||
|
),
|
||||||
|
'db_passwd' => array(
|
||||||
|
'title' => $this->l('Password:'),
|
||||||
|
'size' => 30,
|
||||||
|
'type' => 'password',
|
||||||
|
'desc' => $this->l('Leave blank if no change'),
|
||||||
|
'defaultValue' => _DB_PASSWD_,
|
||||||
|
'visibility' => Shop::CONTEXT_ALL
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'submit' => array()
|
'submit' => array()
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->fieldsDisplay = array (
|
$this->fieldsDisplay = array (
|
||||||
'table' => array('title' => $this->l('Table'), 'type' => 'string', 'width' => 120),
|
'table' => array(
|
||||||
'table_engine' => array('title' => $this->l('Table Engine'), 'type' => 'string', 'width' => 120),
|
'title' => $this->l('Table'),
|
||||||
|
'type' => 'string',
|
||||||
|
'width' => 120
|
||||||
|
),
|
||||||
|
'table_engine' => array(
|
||||||
|
'title' => $this->l('Table Engine'),
|
||||||
|
'type' => 'string',
|
||||||
|
'width' => 120
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initContent()
|
public function initContent()
|
||||||
{
|
{
|
||||||
$this->warnings[] = $this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction. For all issues, check the config/settings.inc.php file.');
|
$this->warnings[] = $this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction.
|
||||||
|
For all issues, check the config/settings.inc.php file.');
|
||||||
|
|
||||||
$this->content .= $this->initToolbar();
|
$this->display = 'options';
|
||||||
|
$this->initToolbar();
|
||||||
|
$this->content .= $this->initOptions();
|
||||||
|
$this->content .= $this->initForm();
|
||||||
|
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'content' => $this->content,
|
||||||
|
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initForm()
|
||||||
|
{
|
||||||
|
$engines = array();
|
||||||
|
$tab_engines = $this->getEngines();
|
||||||
|
foreach ($tab_engines as $key => $engine)
|
||||||
|
$engines[]['name'] = $engine;
|
||||||
|
|
||||||
|
$this->fields_form = array(
|
||||||
|
'legend' => array(
|
||||||
|
'title' => $this->l('MySQL Engine'),
|
||||||
|
'image' => '../img/admin/AdminBackup.gif'
|
||||||
|
),
|
||||||
|
'input' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'table',
|
||||||
|
'name' => 'table'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => $this->l('Change Engine to'),
|
||||||
|
'name' => 'engineType',
|
||||||
|
'options' => array(
|
||||||
|
'query' => $engines,
|
||||||
|
'id' => 'name',
|
||||||
|
'name' => 'name'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'submit' => array(
|
||||||
|
'title' => $this->l(' Save '),
|
||||||
|
'class' => 'button'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$table_status = $this->getTablesStatus();
|
||||||
|
foreach ($table_status as $key => $table)
|
||||||
|
if (!preg_match('#^'._DB_PREFIX_.'.*#Ui', $table['Name']))
|
||||||
|
unset($table_status[$key]);
|
||||||
|
|
||||||
|
$this->tpl_form_vars = array('table_status' => $table_status);
|
||||||
|
|
||||||
|
$this->show_toolbar = false;
|
||||||
|
|
||||||
|
return parent::initForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function initContent()
|
||||||
|
{
|
||||||
|
$this->warnings[] = $this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction.
|
||||||
|
For all issues, check the config/settings.inc.php file.');
|
||||||
|
|
||||||
|
$this->initToolbar();
|
||||||
$this->content .= $this->initOptions();
|
$this->content .= $this->initOptions();
|
||||||
|
|
||||||
$table_status = $this->getTablesStatus();
|
$table_status = $this->getTablesStatus();
|
||||||
@@ -74,8 +181,8 @@ class AdminDbControllerCore extends AdminController
|
|||||||
'engines' => $this->getEngines(),
|
'engines' => $this->getEngines(),
|
||||||
'content' => $this->content,
|
'content' => $this->content,
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
{
|
{
|
||||||
@@ -88,12 +195,12 @@ class AdminDbControllerCore extends AdminController
|
|||||||
|
|
||||||
if ($this->action == 'update_options')
|
if ($this->action == 'update_options')
|
||||||
{
|
{
|
||||||
foreach ($this->options['database']['fields'] AS $field => $values)
|
foreach ($this->options['database']['fields'] as $field => $values)
|
||||||
if (isset($values['required']) AND $values['required'])
|
if (isset($values['required']) && $values['required'])
|
||||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
|
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required.');
|
||||||
|
|
||||||
if (!sizeof($this->_errors))
|
if (!count($this->_errors))
|
||||||
{
|
{
|
||||||
/* Datas are not saved in database but in config/settings.inc.php */
|
/* Datas are not saved in database but in config/settings.inc.php */
|
||||||
$settings = array();
|
$settings = array();
|
||||||
@@ -109,7 +216,7 @@ class AdminDbControllerCore extends AdminController
|
|||||||
true
|
true
|
||||||
) == 0)
|
) == 0)
|
||||||
{
|
{
|
||||||
rewriteSettingsFile(NULL, NULL, $settings);
|
rewriteSettingsFile(null, null, $settings);
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&conf=6'.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -120,7 +227,7 @@ class AdminDbControllerCore extends AdminController
|
|||||||
// Change engine
|
// Change engine
|
||||||
if ($this->action == 'save')
|
if ($this->action == 'save')
|
||||||
{
|
{
|
||||||
if (!isset($_POST['tablesBox']) OR !sizeof($_POST['tablesBox']))
|
if (!isset($_POST['tablesBox']) || !count($_POST['tablesBox']))
|
||||||
$this->_errors[] = Tools::displayError('You did not select any tables');
|
$this->_errors[] = Tools::displayError('You did not select any tables');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -128,39 +235,36 @@ class AdminDbControllerCore extends AdminController
|
|||||||
$tables_status = $this->getTablesStatus();
|
$tables_status = $this->getTablesStatus();
|
||||||
$tables_engine = array();
|
$tables_engine = array();
|
||||||
|
|
||||||
foreach ($tables_status AS $table)
|
foreach ($tables_status as $table)
|
||||||
$tables_engine[$table['Name']] = $table['Engine'];
|
$tables_engine[$table['Name']] = $table['Engine'];
|
||||||
|
|
||||||
$engineType = pSQL(Tools::getValue('engineType'));
|
$engine_type = pSQL(Tools::getValue('engineType'));
|
||||||
|
|
||||||
/* Datas are not saved in database but in config/settings.inc.php */
|
/* Datas are not saved in database but in config/settings.inc.php */
|
||||||
$settings = array('_MYSQL_ENGINE_' => $engineType);
|
$settings = array('_MYSQL_ENGINE_' => $engine_type);
|
||||||
rewriteSettingsFile(NULL, NULL, $settings);
|
rewriteSettingsFile(null, null, $settings);
|
||||||
|
|
||||||
foreach ($_POST['tablesBox'] AS $table)
|
foreach ($_POST['tablesBox'] as $table)
|
||||||
{
|
{
|
||||||
if ($engineType == $tables_engine[$table])
|
if ($engine_type == $tables_engine[$table])
|
||||||
$this->_errors[] = $table.' '.$this->l('is already in').' '.$engineType;
|
$this->_errors[] = $table.' '.$this->l('is already in').' '.$engine_type;
|
||||||
else
|
else
|
||||||
if (!Db::getInstance()->execute('ALTER TABLE `'.bqSQL($table).'` ENGINE=`'.bqSQL($engineType).'`'))
|
if (!Db::getInstance()->execute('ALTER TABLE `'.bqSQL($table).'` ENGINE=`'.bqSQL($engine_type).'`'))
|
||||||
$this->_errors[] = $this->l('Can\'t change engine for').' '.$table;
|
$this->_errors[] = $this->l('Can\'t change engine for').' '.$table;
|
||||||
else
|
|
||||||
echo '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Engine change of').' '.$table.' '.$this->l('to').' '.$engineType.'</div>';
|
|
||||||
}
|
}
|
||||||
|
if (!count($this->_errors))
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=4'.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEngines()
|
public function getEngines()
|
||||||
{
|
{
|
||||||
$engines = Db::getInstance()->executeS('SHOW ENGINES');
|
$engines = Db::getInstance()->executeS('SHOW ENGINES');
|
||||||
$allowed_engines = array();
|
$allowed_engines = array();
|
||||||
foreach ($engines AS $engine)
|
foreach ($engines as $engine)
|
||||||
{
|
if (in_array($engine['Engine'], array('InnoDB', 'MyISAM')) && in_array($engine['Support'], array('DEFAULT', 'YES')))
|
||||||
if (in_array($engine['Engine'], array('InnoDB', 'MyISAM')) AND in_array($engine['Support'], array('DEFAULT', 'YES')))
|
|
||||||
$allowed_engines[] = $engine['Engine'];
|
$allowed_engines[] = $engine['Engine'];
|
||||||
}
|
|
||||||
return $allowed_engines;
|
return $allowed_engines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class StatsForecast extends Module
|
|||||||
$intervalAvg = $interval2 / 7;
|
$intervalAvg = $interval2 / 7;
|
||||||
|
|
||||||
$dataTable = array();
|
$dataTable = array();
|
||||||
if ($cookie->stats_granularity == 10)
|
if ($this->context->cookie->stats_granularity == 10)
|
||||||
for ($i = $from; $i <= $to2; $i = strtotime('+1 day', $i))
|
for ($i = $from; $i <= $to2; $i = strtotime('+1 day', $i))
|
||||||
$dataTable[date('Y-m-d', $i)] = array('fix_date' => date('Y-m-d', $i), 'countOrders' => 0, 'countProducts' => 0, 'totalProducts' => 0);
|
$dataTable[date('Y-m-d', $i)] = array('fix_date' => date('Y-m-d', $i), 'countOrders' => 0, 'countProducts' => 0, 'totalProducts' => 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user