// fix update view.tpl in AdminRequestSqlController
This commit is contained in:
@@ -24,47 +24,44 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*}
|
*}
|
||||||
|
|
||||||
{if isset($view['error'])}
|
{extends file="helper/view/view.tpl"}
|
||||||
<p>{l s ='This query has no result.'}</p>
|
|
||||||
{else}
|
|
||||||
<h2>{$view['name']}</h2>
|
|
||||||
<table cellpadding="0" cellspacing="0" class="table" id="viewRequestSql">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
{foreach $view['key'] AS $key}
|
|
||||||
<th align="center">{$key}</th>
|
|
||||||
{/foreach}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{foreach $view['results'] AS $result}
|
|
||||||
<tr>
|
|
||||||
{foreach $view['key'] AS $name}
|
|
||||||
{if isset($view['attributes'][$name])}
|
|
||||||
<td>{$view['attributes'][$name]}</td>
|
|
||||||
{else}
|
|
||||||
<td>{$result[$name]}</td>
|
|
||||||
{/if}
|
|
||||||
{/foreach}
|
|
||||||
</tr>
|
|
||||||
{/foreach}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
{block name="override_tpl"}
|
||||||
$(function(){
|
{if isset($view['error'])}
|
||||||
var width = $('#viewRequestSql').width();
|
<p>{l s ='This query has no result.'}</p>
|
||||||
if (width > 990){
|
{else}
|
||||||
$('#viewRequestSql').css('display','block').css('overflow-x', 'scroll');
|
<h2>{$view['name']}</h2>
|
||||||
}
|
<table cellpadding="0" cellspacing="0" class="table" id="viewRequestSql">
|
||||||
});
|
<thead>
|
||||||
</script>
|
<tr>
|
||||||
{/if}
|
{foreach $view['key'] AS $key}
|
||||||
|
<th align="center">{$key}</th>
|
||||||
<br /><br />
|
{/foreach}
|
||||||
|
</tr>
|
||||||
{if isset($back)}
|
</thead>
|
||||||
<a href="{$back}"><img src="../img/admin/arrow2.gif" />{l s='Back to list'}</a>
|
<tbody>
|
||||||
{/if}
|
{foreach $view['results'] AS $result}
|
||||||
<br />
|
<tr>
|
||||||
|
{foreach $view['key'] AS $name}
|
||||||
|
{if isset($view['attributes'][$name])}
|
||||||
|
<td>{$view['attributes'][$name]}</td>
|
||||||
|
{else}
|
||||||
|
<td>{$result[$name]}</td>
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
var width = $('#viewRequestSql').width();
|
||||||
|
if (width > 990){
|
||||||
|
$('#viewRequestSql').css('display','block').css('overflow-x', 'scroll');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{/if}
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
|||||||
@@ -35,16 +35,7 @@ class AdminRequestSqlControllerCore extends AdminController
|
|||||||
$this->export = true;
|
$this->export = true;
|
||||||
$this->requiredDatabase = true;
|
$this->requiredDatabase = true;
|
||||||
|
|
||||||
$this->addRowAction('view');
|
|
||||||
$this->addRowAction('edit');
|
|
||||||
$this->addRowAction('delete');
|
|
||||||
|
|
||||||
$this->context = Context::getContext();
|
$this->context = Context::getContext();
|
||||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')),
|
|
||||||
'export' => array('text' => $this->l('Export selected')));
|
|
||||||
|
|
||||||
if (!Tools::getValue('realedit'))
|
|
||||||
$this->deleted = false;
|
|
||||||
|
|
||||||
$this->fieldsDisplay = array(
|
$this->fieldsDisplay = array(
|
||||||
'id_request_sql' => array('title' => $this->l('ID'), 'width' => 25),
|
'id_request_sql' => array('title' => $this->l('ID'), 'width' => 25),
|
||||||
@@ -52,6 +43,41 @@ class AdminRequestSqlControllerCore extends AdminController
|
|||||||
'sql' => array('title' => $this->l('Request'), 'width' => 500)
|
'sql' => array('title' => $this->l('Request'), 'width' => 500)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initList()
|
||||||
|
{
|
||||||
|
$this->displayWarning($this->l('When saving the query, only the request type "SELECT" are allowed.'));
|
||||||
|
$this->displayInformation('
|
||||||
|
<strong>'.$this->l('How to create a new sql query?').'</strong>
|
||||||
|
<br />
|
||||||
|
<ul>
|
||||||
|
<li>'.$this->l('Click "Add new".').'<br /></li>
|
||||||
|
<li>'.$this->l('Fill in the fields and click "Save".').'</li>
|
||||||
|
<li>'.$this->l('You can then view the query results by clicking on the tab: ').' <img src="../img/admin/details.gif"></li>
|
||||||
|
<li>'.$this->l('You can then export the query results as a file. Csv file by clicking on the tab: ').' <img src="../img/admin/export.gif"></li>
|
||||||
|
</ul>
|
||||||
|
');
|
||||||
|
|
||||||
|
$this->addRowAction('view');
|
||||||
|
$this->addRowAction('edit');
|
||||||
|
$this->addRowAction('delete');
|
||||||
|
$this->bulk_actions = array(
|
||||||
|
'delete' => array(
|
||||||
|
'text' => $this->l('Delete selected'),
|
||||||
|
'confirm' => $this->l('Delete selected items?')
|
||||||
|
),
|
||||||
|
'export' => array(
|
||||||
|
'text' => $this->l('Export selected')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return parent::initList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initForm()
|
||||||
|
{
|
||||||
$this->fields_form = array(
|
$this->fields_form = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Request')
|
'title' => $this->l('Request')
|
||||||
@@ -79,32 +105,35 @@ class AdminRequestSqlControllerCore extends AdminController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
parent::__construct();
|
return parent::initForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function viewRequestSql()
|
public function initView()
|
||||||
{
|
{
|
||||||
if (!($obj = $this->loadObject(true)))
|
if (!($obj = $this->loadObject(true)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$content = array();
|
$view = array();
|
||||||
|
|
||||||
if ($results = Db::getInstance()->executeS($obj->sql))
|
if ($results = Db::getInstance()->executeS($obj->sql))
|
||||||
{
|
{
|
||||||
foreach (array_keys($results[0]) as $key)
|
foreach (array_keys($results[0]) as $key)
|
||||||
$tab_key[] = $key;
|
$tab_key[] = $key;
|
||||||
|
|
||||||
$content['name'] = $obj->name;
|
$view['name'] = $obj->name;
|
||||||
$content['key'] = $tab_key;
|
$view['key'] = $tab_key;
|
||||||
$content['results'] = $results;
|
$view['results'] = $results;
|
||||||
|
|
||||||
$request_sql = new RequestSql();
|
$request_sql = new RequestSql();
|
||||||
$content['attributes'] = $request_sql->attributes;
|
$view['attributes'] = $request_sql->attributes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$content['error'] = true;
|
$view['error'] = true;
|
||||||
|
|
||||||
return $content;
|
$this->tpl_view_vars = array(
|
||||||
|
'view' => $view
|
||||||
|
);
|
||||||
|
return parent::initView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _childValidation()
|
public function _childValidation()
|
||||||
@@ -120,47 +149,6 @@ class AdminRequestSqlControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initContent()
|
|
||||||
{
|
|
||||||
$this->displayWarning($this->l('When saving the query, only the request type "SELECT" are allowed.'));
|
|
||||||
$this->displayInformation('
|
|
||||||
<strong>'.$this->l('How to create a new sql query?').'</strong>
|
|
||||||
<br />
|
|
||||||
<ul>
|
|
||||||
<li>'.$this->l('Click "Add new".').'<br /></li>
|
|
||||||
<li>'.$this->l('Fill in the fields and click "Save".').'</li>
|
|
||||||
<li>'.$this->l('You can then view the query results by clicking on the tab: ').' <img src="../img/admin/details.gif"></li>
|
|
||||||
<li>'.$this->l('You can then export the query results as a file. Csv file by clicking on the tab: ').' <img src="../img/admin/export.gif"></li>
|
|
||||||
</ul>
|
|
||||||
');
|
|
||||||
|
|
||||||
$smarty = $this->context->smarty;
|
|
||||||
|
|
||||||
if ($this->display != 'edit' && $this->display != 'add' && $this->display != 'view')
|
|
||||||
$this->display = 'list';
|
|
||||||
|
|
||||||
switch ($this->display)
|
|
||||||
{
|
|
||||||
case 'edit':
|
|
||||||
$this->informations = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'view':
|
|
||||||
$this->warnings = false;
|
|
||||||
$this->informations = false;
|
|
||||||
|
|
||||||
if (Tools::getValue('back'))
|
|
||||||
$smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
|
|
||||||
else
|
|
||||||
$smarty->assign('back', Tools::safeOutput(self::$currentIndex.'&token='.$this->token));
|
|
||||||
|
|
||||||
$smarty->assign('view', $this->viewRequestSql());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::initContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function bulkexport($boxes)
|
public function bulkexport($boxes)
|
||||||
{
|
{
|
||||||
if (!$boxes || count($boxes) > 1)
|
if (!$boxes || count($boxes) > 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user