// Update list generation
This commit is contained in:
@@ -28,8 +28,7 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('.filter').keypress(function(event){
|
||||
//alert('submitFilterButton_{$table}');
|
||||
//formSubmit(event, 'submitFilterButton{$table}')
|
||||
formSubmit(event, 'submitFilterButton{$table}')
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@@ -44,7 +43,9 @@
|
||||
<script type="text/javascript" src="../js/admin-dnd.js"></script>
|
||||
{/if}
|
||||
|
||||
|
||||
{if $add_button}
|
||||
<br /><a href="{$currentIndex}&add{$table}&token={$token}"><img src="../img/admin/add.gif" border="0" />{l s='Add new'}</a><br /><br />
|
||||
{/if}
|
||||
<a name="{$table}"> </a>
|
||||
<form method="post" action="{$action}" class="form">
|
||||
<input type="hidden" id="submitFilter{$table}" name="submitFilter{$table}" value="0"/>
|
||||
@@ -80,9 +81,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<table
|
||||
{*(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' )*}
|
||||
class="table"
|
||||
{*(array_key_exists($this->identifier,$this->identifiersDnd) AND ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'"*}
|
||||
{if $table_id} id={$table_id}{/if}
|
||||
class="table {if $table_dnd}tableDnd{/if}"
|
||||
cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr class="nodrag nodrop">
|
||||
@@ -138,10 +138,8 @@
|
||||
<option value="0" {if $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option>
|
||||
</select>
|
||||
{elseif $params.type == 'date' || $params.type == 'datetime'}
|
||||
{*
|
||||
{l s='From'} <input type="text" id="'.$nameId.'_0" name="'.$name.'[0]" value="'.(isset($value[0]) ? $value[0] : '').'"'.$width.' '.$keyPress.' /><br />
|
||||
{l s='To'} <input type="text" id="'.$nameId.'_1" name="'.$name.'[1]" value="'.(isset($value[1]) ? $value[1] : '').'"'.$width.' '.$keyPress.' />
|
||||
*}
|
||||
{l s='From'} <input type="text" class="filter" id="{$name_id}_0" name="{$name}[0]" value="{if isset($value.0)}$value.0{/if}"{if isset($params.width)} style="width:{$params.width}px"{/if}/><br />
|
||||
{l s='To'} <input type="text" class="filter" id="{$name_id}_1" name="{$name}[1]" value="{if isset($value.1)}$value.1{/if}"{if isset($params.width)} style="width:{$params.width}px"{/if}/>
|
||||
{elseif $params.type == 'select'}
|
||||
{if isset($params.filter_key)}
|
||||
<select onchange="$('#submitFilter{$table}').focus();$('#submitFilter{$table}').click();" name="{$table}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
|
||||
|
||||
+20
-14
@@ -84,6 +84,7 @@ class AdminControllerCore extends Controller
|
||||
protected $colorOnBackground;
|
||||
/** @string Action to perform : 'edit', 'view', 'add', ... */
|
||||
protected $action;
|
||||
protected $display;
|
||||
protected $_includeContainer = true;
|
||||
|
||||
public function __construct()
|
||||
@@ -496,6 +497,7 @@ class AdminControllerCore extends Controller
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$token);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -821,7 +823,7 @@ class AdminControllerCore extends Controller
|
||||
$this->content = $this->displayErrors();
|
||||
else
|
||||
{
|
||||
if ($this->action == 'edit' && $this->id_entity)
|
||||
if ($this->display == 'edit')
|
||||
{
|
||||
$this->content .= $this->displayForm();
|
||||
if ($this->tabAccess['view']){
|
||||
@@ -833,7 +835,7 @@ class AdminControllerCore extends Controller
|
||||
// move to form.tpl
|
||||
$this->content .= '<br /><br /><a href="'.((Tools::getValue('back')) ? Tools::getValue('back') : self::$currentIndex.'&token='.$this->token).'"><img src="../img/admin/arrow2.gif" /> '.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'</a><br />';
|
||||
}
|
||||
elseif ($this->action == 'list')
|
||||
elseif ($this->display == 'list')
|
||||
{
|
||||
$this->getList($this->context->language->id);
|
||||
|
||||
@@ -851,7 +853,6 @@ class AdminControllerCore extends Controller
|
||||
$this->content .= $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -993,7 +994,6 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
elseif (strncmp($key, $this->table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
|
||||
$this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
|
||||
|
||||
if (isset($_GET) AND !empty($_GET) AND isset($this->table))
|
||||
foreach ($_GET AS $key => $value)
|
||||
if (is_array($this->table))
|
||||
@@ -1047,7 +1047,23 @@ class AdminControllerCore extends Controller
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif (Tools::getValue('submitAdd'.$this->table))
|
||||
{
|
||||
$this->action = 'save';
|
||||
$this->display = 'edit';
|
||||
//$this->id_entity = (int)$_GET['id_'.$this->table];
|
||||
}
|
||||
elseif (isset($_GET['add'.$this->table]))
|
||||
{
|
||||
$this->action = 'new';
|
||||
$this->display = 'edit';
|
||||
}
|
||||
elseif (isset($_GET['update'.$this->table]) && isset($_GET['id_'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee')))
|
||||
$this->display = 'edit';
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
/* Cancel all filters for this tab */
|
||||
elseif (isset($_POST['submitReset'.$this->table]))
|
||||
$this->action = 'reset_filters';
|
||||
@@ -1059,16 +1075,6 @@ class AdminControllerCore extends Controller
|
||||
$this->action = 'update_filters';
|
||||
elseif(Tools::isSubmit('submitFields') AND $this->requiredDatabase AND $this->tabAccess['add'] === '1' AND $this->tabAccess['delete'] === '1')
|
||||
$this->action = 'update_fields';
|
||||
elseif (isset($_GET['update'.$this->table]) && isset($_GET['id_'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee')))
|
||||
{
|
||||
$this->action = 'edit';
|
||||
$this->id_entity = (int)$_GET['id_'.$this->table];
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+46
-2
@@ -35,6 +35,12 @@ class HelperCore
|
||||
'Home', 'selected', 'selecteds', 'Collapse All', 'Expand All', 'Check All', 'Uncheck All'
|
||||
);
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $trads values of translations keys
|
||||
@@ -63,7 +69,7 @@ class HelperCore
|
||||
{
|
||||
if (!$use_radio)
|
||||
$input_name = $input_name.'[]';
|
||||
|
||||
|
||||
$html = '
|
||||
<script src="../js/jquery/treeview/jquery.treeview.js" type="text/javascript"></script>
|
||||
<script src="../js/jquery/treeview/jquery.treeview.async.js" type="text/javascript"></script>
|
||||
@@ -159,7 +165,7 @@ class HelperCore
|
||||
$select_html .= '<option value="">'.$select_options['empty'].'</option>';
|
||||
|
||||
if (isset($select_options['selected']) && !is_array($select_options['selected']))
|
||||
$select_options['selected'] = array($select_options['selected']);
|
||||
$select_options['selected'] = array($select_options['selected']);
|
||||
// render options fields
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
@@ -196,5 +202,43 @@ class HelperCore
|
||||
|
||||
return rtrim($html, ' ');
|
||||
}
|
||||
|
||||
function bindDatepicker($id, $time)
|
||||
{
|
||||
if ($time)
|
||||
echo '
|
||||
var dateObj = new Date();
|
||||
var hours = dateObj.getHours();
|
||||
var mins = dateObj.getMinutes();
|
||||
var secs = dateObj.getSeconds();
|
||||
if (hours < 10) { hours = "0" + hours; }
|
||||
if (mins < 10) { mins = "0" + mins; }
|
||||
if (secs < 10) { secs = "0" + secs; }
|
||||
var time = " "+hours+":"+mins+":"+secs;';
|
||||
|
||||
echo '
|
||||
$(function() {
|
||||
$("#'.$id.'").datepicker({
|
||||
prevText:"",
|
||||
nextText:"",
|
||||
dateFormat:"yy-mm-dd"'.($time ? '+time' : '').'});
|
||||
});';
|
||||
}
|
||||
|
||||
// id can be a identifier or an array of identifiers
|
||||
function includeDatepicker($id, $time = false)
|
||||
{
|
||||
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/jquery-ui-1.8.10.custom.min.js"></script>';
|
||||
$iso = Db::getInstance()->getValue('SELECT iso_code FROM '._DB_PREFIX_.'lang WHERE `id_lang` = '.(int)Context::getContext()->language->id);
|
||||
if ($iso != 'en')
|
||||
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/datepicker/ui/i18n/ui.datepicker-'.$iso.'.js"></script>';
|
||||
echo '<script type="text/javascript">';
|
||||
if (is_array($id))
|
||||
foreach ($id as $id2)
|
||||
bindDatepicker($id2, $time);
|
||||
else
|
||||
bindDatepicker($id, $time);
|
||||
echo '</script>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-10
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class HelperList
|
||||
class HelperListCore extends Helper
|
||||
{
|
||||
/** @var array Cache for query results */
|
||||
protected $_list = array();
|
||||
@@ -67,11 +67,6 @@ class HelperList
|
||||
|
||||
protected $identifiersDnd = array('id_product' => 'id_product', 'id_category' => 'id_category_to_move','id_cms_category' => 'id_cms_category_to_move', 'id_cms' => 'id_cms', 'id_attribute' => 'id_attribute');
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an html list given the data to fill it up
|
||||
*
|
||||
@@ -340,6 +335,12 @@ class HelperList
|
||||
// Check if object can be modified, deleted or detailed
|
||||
$has_actions = ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn')) ? true : false;
|
||||
|
||||
if (array_key_exists($this->identifier,$this->identifiersDnd) && (int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1)))
|
||||
$table_id = substr($this->identifier,3,strlen($this->identifier));
|
||||
|
||||
if (array_key_exists($this->identifier,$this->identifiersDnd) && ($this->_orderBy != 'position' && $this->_orderWay != 'DESC'))
|
||||
$table_dnd = true;
|
||||
|
||||
foreach ($this->fieldsDisplay as $key => $params)
|
||||
{
|
||||
if (!isset($params['type']))
|
||||
@@ -357,9 +358,9 @@ class HelperList
|
||||
$value = unserialize($value);
|
||||
if (!Validate::isCleanHtml($value[0]) OR !Validate::isCleanHtml($value[1]))
|
||||
$value = '';
|
||||
//$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
|
||||
//$nameId = str_replace('!', '__', $name);
|
||||
//includeDatepicker(array($nameId.'_0', $nameId.'_1'));
|
||||
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
|
||||
$name_id = str_replace('!', '__', $name);
|
||||
$this->includeDatepicker(array($name_id.'_0', $name_id.'_1'));
|
||||
break;
|
||||
case 'select':
|
||||
foreach ($params['select'] AS $option_value => $option_display)
|
||||
@@ -397,7 +398,11 @@ class HelperList
|
||||
'id_cat' => $id_cat,
|
||||
'shop_link_type' => $this->shopLinkType,
|
||||
'has_actions' => $has_actions,
|
||||
|
||||
'add_button' => $this->edit AND (!isset($this->noAdd) OR !$this->noAdd),
|
||||
'table_id' => isset($table_id) ? $table_id : null,
|
||||
'table_dnd' => isset($table_dnd) ? $table_dnd : null,
|
||||
'name' => isset($name) ? $name : null,
|
||||
'name_id' => isset($name_id) ? $name_id : null,
|
||||
));
|
||||
|
||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/list_header.tpl');
|
||||
|
||||
@@ -157,9 +157,6 @@ class AdminAddressesControllerCore extends AdminController
|
||||
else
|
||||
Tools::redirectAdmin(Tools::getValue('back').'&conf=4');
|
||||
}
|
||||
|
||||
if (!isset($this->action))
|
||||
$this->action = 'list';
|
||||
}
|
||||
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL)
|
||||
@@ -506,21 +503,12 @@ class AdminAddressesControllerCore extends AdminController
|
||||
return $out;
|
||||
}
|
||||
|
||||
/*public function initContent()
|
||||
public function initContent()
|
||||
{
|
||||
$this->getList($this->context->language->id);
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->edit = $this->edit;
|
||||
$helper->delete = $this->delete;
|
||||
$helper::$currentIndex = self::$currentIndex;
|
||||
$helper->table = $this->table;
|
||||
$helper->shopLink = $this->shopLink;
|
||||
$helper->shopLinkType = $this->shopLinkType;
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->token = $this->token;
|
||||
$this->context->smarty->assign(array('list' => $helper->generateList($this->_list, $this->fieldsDisplay)));
|
||||
}*/
|
||||
if ($this->display != 'edit')
|
||||
$this->display = 'list';
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user