Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1010

Přidáno uživatelem Michal Kliment před více než 13 roky(ů)

Dalsi prace na filtrech - takrka dodelano...

Zobrazit rozdíly:

freenetis/branches/search_filters/media/css/style.css
}
.ui-autocomplete {
max-height: 100px;
text-align: left;
width: 222px;
max-height: 400px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
/* add padding to account for vertical scrollbar */
padding-right: 20px;
}
/* IE 6 doesn't support max-height
* we use height instead, but this forces the menu to always be this tall
*/
* html .ui-autocomplete {
height: 100px;
}
.select_button {
.select_button {
display: none;
}
.v {
position: relative;
top: -7px;
border-right-width: 0px;
}
.t, .o {
position: relative;
top: -7px;
}
.without_select_button {
border-right-width: 1px;
width: 222px;
}
.filter_div {
height: 27px;
}
.filter_div label.error {
display: none;
}
.delete_button {
border: 0px solid black;
margin-left: 7px;
margin-bottom: 5px;
cursor: pointer;
}
freenetis/branches/search_filters/application/i18n/cs_CZ/texts.php
'delete' => 'Smazat',
'delete selection' => 'Smazat výběr',
'delete selected messages' => 'Smazat vybrané zprávy',
'delete this filter' => 'Smazat tento filtr',
'delete this work' => 'Smazat tuto práci',
'delete whole device' => 'Smazat celé zařízení',
'delete wireless setting' => 'Smazat bezdrátové nastavení',
......
'no whitelist' => 'Žádný whitelist',
'nonactive' => 'Neaktivní',
'none' => 'žádný',
'nonei' => 'Žádné',
'non-member' => 'Nečlen',
'non-statutory member' => 'Člen bez statusu',
'norm' => 'Norma',
freenetis/branches/search_filters/application/helpers/server.php
{
return $_SERVER['REQUEST_URI'];
}
/**
* Returns query string of current url
*
* @author Michal Kliment
* @return string
*/
public static function query_string ()
{
return $_SERVER['QUERY_STRING'];
}
}
freenetis/branches/search_filters/application/models/member.php
$where = "WHERE $filter_sql";
return $this->db->query("
SELECT id, id AS member_id, registration, name, street, street_number, town, quarter, variable_symbol, aid, balance, redirect, GROUP_CONCAT(a_comment SEPARATOR ', \n\n') AS a_comment, a_comments_thread_id, type_name FROM
SELECT id, id AS member_id, registration, name, street, street_number, town, quarter, variable_symbol, aid, balance, redirect, GROUP_CONCAT(a_comment SEPARATOR ', \n\n') AS a_comment, a_comments_thread_id, type
FROM
(
SELECT
m.id, m.registration, m.name,
......
a.balance,
m.redirect, CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text) AS a_comment,
a.comments_thread_id AS a_comments_thread_id,
IFNULL(f.translated_term, e.value) AS type_name
FROM members m
m.type
FROM
(
SELECT m.id,
m.name,
m.variable_symbol,
m.redirect,
m.address_point_id,
IF(m.registration = 1, '".url_lang::lang('texts.Yes')."', '".url_lang::lang('texts.No')."') AS registration,
IFNULL(t.translated_term, e.value) AS type,
IF(mi.id IS NOT NULL, '".url_lang::lang('texts.Yes')."', '".url_lang::lang('texts.No')."') AS membership_interrupt
FROM members m
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN translations t ON e.value = t.original_term AND lang = '" . Config::get('lang') . "'
LEFT JOIN
(
SELECT mi.id, mi.member_id FROM membership_interrupts mi
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) mi ON mi.member_id = m.id
) AS m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
......
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN comments c ON ct.id = c.comments_thread_id
LEFT JOIN users u ON c.user_id = u.id
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN (SELECT * FROM translations WHERE lang = '".Config::get('lang')."') f ON e.value = f.original_term
$where
ORDER BY c.datetime DESC
) AS q
GROUP BY q.id
GROUP BY id
ORDER BY $order_by $order_by_direction
LIMIT $limit_from, $limit_results
");
......
* @param $filter_values
* @return unknown_type
*/
public function count_all_members($filter_values = array())
public function count_all_members($filter_sql = "")
{
// building of where clause
$where = array();
foreach($filter_values as $key => $value)
{
if (isset(self::$keys[$key]))
{
$column_name = (isset(self::$keys[$key]['column_name'])) ? self::$keys[$key]['column_name'] : $key;
$where = '';
if ($filter_sql != '')
$where = "WHERE $filter_sql";
// key is type of string
if (self::$keys[$key]['type'] == 'string')
{
$value = trim($value);
$items = explode(',',trim($value,','));
// split into array of conditions
$clauses = array();
foreach ($items as $item)
{
$item = trim($item);
if ($item!='')
$clauses[] = "$column_name LIKE '%".$item."%' COLLATE utf8_general_ci";
}
// convert array of conditions to one string condition
$where[] = '('.implode(' OR ', $clauses).')';
}
else if (self::$keys[$key]['type'] == 'number')
{
$value = trim($value);
// value is interval format
if (preg_match('/^([0-9]+)?-([0-9]+)?$/', $value, $matches))
{
// finding min and max of interval
$min = ($matches[1]!='')? $matches[1] : 0;
$max = (isset($matches[2]) && $matches[2]!='')? $matches[2] : 0;
if ($min && $max)
$where[] = "$column_name >= ".$min." AND $column_name <= ".$max;
else if ($min)
$where[] = "$column_name >= ".$min;
else
$where[] = "$column_name <= ".$max;
}
// value is one number
else
$where[] = "$column_name = ".(int)$value;
}
}
// special member types to filter
if ($key == 'type')
{
if ($value != 0)
{
$where[] = "m.type = $value";
}
else
// all without former members, default option
{
$enum_model = new Enum_type_Model();
$value = $enum_model->get_type_id('Former member');
$where[] = "m.type <> $value";
}
}
if ($key == 'redirect' && $value != self::$all)
{
if ($value == self::$all_redirected)
$where[] = "m.redirect > 0";
if ($value == self::$membership_interrupt)
$where[] = "m.redirect & 1 = 1";
if ($value == self::$debtors)
$where[] = "m.redirect & 2 = 2";
if ($value == self::$payment_notice)
$where[] = "m.redirect & 4 = 4";
if ($value == self::$optional_message)
$where[] = "m.redirect & 8 = 8";
}
}
// default filtering
if (count($filter_values) == 0)
{
$enum_model = new Enum_type_Model();
$value = $enum_model->get_type_id('Former member');
$where[] = "m.type <> $value";
}
$where = implode(" AND ",$where);
$where = ($where!='') ? 'WHERE '.$where : '';
return $this->db->query("SELECT COUNT(*) AS total
FROM members m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
$where
return $this->db->query("
SELECT COUNT(*) AS total
FROM
(
SELECT *
FROM
(
SELECT
m.id, m.registration, m.name,
s.street, ap.street_number, t.town, t.quarter,
m.variable_symbol, a.id AS aid,
a.balance,
m.redirect, CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text) AS a_comment,
a.comments_thread_id AS a_comments_thread_id,
m.type
FROM
(
SELECT m.id,
m.name,
m.variable_symbol,
m.redirect,
m.address_point_id,
IF(m.registration = 1, '".url_lang::lang('texts.Yes')."', '".url_lang::lang('texts.No')."') AS registration,
IFNULL(t.translated_term, e.value) AS type,
IF(mi.id IS NOT NULL, '".url_lang::lang('texts.Yes')."', '".url_lang::lang('texts.No')."') AS membership_interrupt,
IFNULL(r.name,'".url_lang::lang('texts.nonei')."') AS redirection
FROM members m
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN translations t ON e.value = t.original_term AND lang = '" . Config::get('lang') . "'
LEFT JOIN
(
SELECT mi.id, mi.member_id FROM membership_interrupts mi
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) mi ON mi.member_id = m.id
LEFT JOIN
(
SELECT '".url_lang::lang('texts.Membership interrupt')."' AS name, 1 AS redirect
UNION
SELECT '".url_lang::lang('texts.Debtor')."' AS name, 2 AS redirect
UNION
SELECT '".url_lang::lang('texts.Payment notice')."' AS name, 4 AS redirect
UNION
SELECT '".url_lang::lang('texts.Optional message')."' AS name, 8 AS redirect
) AS r ON m.redirect & r.redirect
) AS m
LEFT JOIN address_points ap ON m.address_point_id = ap.id
LEFT JOIN streets s ON ap.street_id = s.id
LEFT JOIN towns t ON ap.town_id = t.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN comments c ON ct.id = c.comments_thread_id
LEFT JOIN users u ON c.user_id = u.id
$where
ORDER BY c.datetime DESC
) AS q1
GROUP BY id
) AS q2
")->current()->total;
}
freenetis/branches/search_filters/application/controllers/members.php
*/
function show_all($limit_results = 100, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
{
// access rights
if (!$this->acl_check_view(get_class($this),'members'))
Controller::error(ACCESS);
$filter_form = new Filter_form('m');
$filter_form->add('id')->type('number');
$filter_form->add('name');
$filter_form->add('type')->type('string')->values(array('jowak', 'xien'));
$filter_form->add('variable_symbol');
$filter_form->add('name')->callback('json/member_name');
$filter_form->add('type')->type('select')->values(ORM::factory('enum_type')->get_values(Enum_type_Model::$member_type_id));
$filter_form->add('membership_interrupt')->type('select')->values(array(url_lang::lang('texts.Yes'), url_lang::lang('texts.No')));
$filter_form->add('balance')->table('a')->type('number');
$filter_form->add('redirect')->label(url_lang::lang('texts.Redirection'))->type('bit')->return('key')->values(array("~0" => url_lang::lang('texts.nonei'), 1 => url_lang::lang('texts.Membership interrupt'), 2 => url_lang::lang('texts.Debtor'), 4 => url_lang::lang('texts.Payment notice'), 8 => url_lang::lang('texts.Optional message')));
$filter_form->add('variable_symbol')->callback('json/variable_symbol');
$filter_form->add('comment');
$filter_form->add('balance')->table('a')->type('number');
$filter_form->add('town')->table('t');
$filter_form->add('street')->table('s');
$filter_form->add('registration')->type('select')->values(array(url_lang::lang('texts.Yes'), url_lang::lang('texts.No')));
$filter_form->add('organization_identifier');
$filter_form->add('town')->type('select')->table('t')->callback('json/town_name');
$filter_form->add('street')->type('select')->table('s')->callback('json/street_name');
$filter_form->add('street_number')->type('number')->table('ap');
// access rights
if (!$this->acl_check_view(get_class($this),'members'))
Controller::error(ACCESS);
// gets new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
// parameters control
$allowed_order_type = array('id', 'name', 'street', 'street_number', 'town', 'quarter', 'ZIP_code', 'qos_ceil', 'qos_rate', 'entrance_fee', 'debt_payment_rate', 'current_credit', 'entrance_date', 'comment', 'balance', 'type_name');
$allowed_order_type = array('id', 'registration', 'name', 'street','redirect', 'street_number', 'town', 'quarter', 'ZIP_code', 'qos_ceil', 'qos_rate', 'entrance_fee', 'debt_payment_rate', 'current_credit', 'entrance_date', 'comment', 'balance', 'type_name');
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'id';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
$order_by_direction = 'asc';
// types of members to filtering
$enum_types = new Enum_type_Model();
$types = $enum_types->get_values(Enum_type_Model::$member_type_id);
$types[0] = url_lang::lang('texts.All without former');
// types of redirection
$redir_types[Member_Model::$all] = url_lang::lang('texts.All');
$redir_types[Member_Model::$all_redirected] = url_lang::lang('texts.All redirected');
$redir_types[Member_Model::$membership_interrupt] = url_lang::lang('texts.Membership interrupt');
$redir_types[Member_Model::$debtors] = url_lang::lang('texts.Debtors');
$redir_types[Member_Model::$payment_notice] = url_lang::lang('texts.Payment notice');
$redir_types[Member_Model::$optional_message] = url_lang::lang('texts.Optional message');
// creates fields for filtering members
$filter=new Table_Form(url_lang::base()."members/show_all", "get", array(
new Table_Form_Item('text','name','Name'),
new Table_Form_Item('text','town','Town'),
"tr",
new Table_Form_Item('text','variable_symbol','Variable symbol'),
new Table_Form_Item('text','street','Street'),
"tr",
new Table_Form_Item('text','id','ID'),
new Table_Form_Item('select','redirect','Redirection', $redir_types),
"tr",
new Table_Form_Item('text','comment','Comment'),
new Table_Form_Item('select','type','Type', $types),
"tr",
new Table_Form_Item('text','street_number','Street number'),
"td",
new Table_Form_Item('submit','submit','Filter')
)
);
$arr_gets = array();
foreach ($this->input->get() as $key=>$value)
$arr_gets[] = $key.'='.$value;
$query_string = '?'.implode('&',$arr_gets);
$redir_types[Member_Model::$optional_message] = url_lang::lang('texts.Optional message');;
// load members
$model_members = new Member_Model();
$total_members = $model_members->count_all_members($filter->values());
$total_members = $model_members->count_all_members($filter_form->as_sql ());
if (($sql_offset = ($page - 1) * $limit_results) > $total_members)
$sql_offset = 0;
$query = $model_members->get_all_members($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_form->as_sql ());
......
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results,
'query_string' => $query_string,
'filter' => $filter_form
));
// grid buttons
......
}
// database columns - some are commented out because of lack of space
$grid->order_field('id')->label('ID');
$grid->order_field('registration')->label(url_lang::lang('texts.Reg'))->bool(array(url_lang::lang('texts.No'),url_lang::lang('texts.Yes')))->class('center');
$grid->order_callback_field('type_name')->label(url_lang::lang('texts.Type'))->callback('callback::member_type_name_field');
$grid->order_field('registration')->label(url_lang::lang('texts.Reg'))->class('center');
$grid->order_field('type')->label(url_lang::lang('texts.Type'));
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
$grid->order_field('street')->label(url_lang::lang('texts.Street'));
$grid->order_field('street_number')->label(url_lang::lang('texts.Street number'));
freenetis/branches/search_filters/application/controllers/json.php
$this->session->set('paths', $paths);
}
public function member_name ()
{
$term = $this->input->get('term');
$member_model = new Member_Model();
$members = $member_model->like('name', $term)->orderby('name')->find_all();
$arr_members = array();
foreach ($members as $member)
$arr_members[] = $member->name;
echo json_encode($arr_members);
}
public function variable_symbol ()
{
$term = $this->input->get('term');
$member_model = new Member_Model();
$members = $member_model->like('variable_symbol', $term)->orderby('variable_symbol')->find_all();
$arr_members = array();
foreach ($members as $member)
$arr_members[] = $member->variable_symbol;
echo json_encode($arr_members);
}
public function town_name ()
{
$term = $this->input->get('term');
$town_model = new Town_Model();
$towns = $town_model->like('town', $term)->orlike('quarter', $term)->orderby('town')->find_all();
$arr_towns = array();
foreach ($towns as $town)
$arr_towns[] = $town->town. (($town->quarter != '') ? ' - '.$town->quarter : '');
echo json_encode($arr_towns);
}
public function street_name ()
{
$term = $this->input->get('term');
$street_model = new Street_Model();
$streets = $street_model->like('street', $term)->orderby('street')->find_all();
$arr_streets = array();
foreach ($streets as $street)
$arr_streets[] = $street->street;
echo json_encode($arr_streets);
}
}
freenetis/branches/search_filters/application/libraries/Filter_form.php
10 => array(
'name' => '>=',
'sql' => ">= '{VALUE}'",
)
),
11 => array(
'name' => 'is',
'sql' => "& {VALUE} = 1",
),
12 => array(
'name' => 'is not',
'sql' => "& {VALUE} = 0",
)
);
protected $operation_types = array(
'string' => array(3,4,1,2),
'select' => array(3,4,1,2),
'text' => array(1,2,3,4),
'number' => array(5,6,7,8,9,10),
'bit' => array(11,12),
);
protected $minlengths = array(
'select' => 0,
'text' => 3,
'bit' => 0
);
public function __construct($table = '')
{
$this->table = $table;
$this->template = new View ($this->template);
$this->types = (count($types = Input::instance()->get('t'))) ? $types : array();
$this->operations = Input::instance()->get('o');
$this->values = Input::instance()->get('v');
$this->types = array();
$this->operations = array();
$this->values = array();
$types = Input::instance()->get('types');
$operations = Input::instance()->get('opers');
$values = Input::instance()->get('values');
$tables = Input::instance()->get('tables');
if (count($values))
{
foreach ($values as $i => $value)
{
$value = trim($value);
if ($value != '')
{
$this->values[] = $value;
$this->types[] = $types[$i];
$this->operations[] = $operations[$i];
$this->tables[] = $tables[$i];
}
}
}
}
public function autoload ()
{
foreach ($this->types as $i => $type)
{
$filter = new Filter($type, $this->tables[$i]);
$this->filters[$type] = $filter;
}
}
public function add ($name)
{
$filter = new Filter($name, $this->table);
......
$value_options = array();
$js_operation_values = array();
$js_types = array();
$callbacks = array();
$minlengths = array();
$withouts = array();
$tables = array();
foreach ($this->filters as $filter)
{
$types[$filter->name] = $filter->label;
......
$js_types[$filter->name] = $filter->type;
$value_options[$filter->name] = $filter->values;
if ($filter->callback != '')
$callbacks[$filter->name] = url_lang::base().$filter->callback;
if (isset($this->minlengths[$filter->type]))
{
$minlengths[$filter->name] = $this->minlengths[$filter->type];
$withouts[$filter->name] = ($this->minlengths[$filter->type]) ? 1 : 0;
}
else
$withouts[$filter->name] = 1;
$tables[$filter->name] = $filter->table;
}
$operations = array();
......
$this->template->js_operation_values = $js_operation_values;
$this->template->js_types = $js_types;
$this->template->value_options = $value_options;
$this->template->callbacks = $callbacks;
$this->template->minlengths = $minlengths;
$this->template->withouts = $withouts;
$this->template->tables = $tables;
$this->template->types = $this->types;
$this->template->operations = $this->operations;
......
$queries = array();
foreach ($this->types as $i => $type)
{
$filter = $this->filters[$type];
$value = trim($this->values[$i]);
if ($value != '')
{
$filter = $this->filters[$type];
$queries[] = "$filter->table.$filter->name ".str_replace("{VALUE}", mysql_real_escape_string($value), $this->opers[$this->operations[$i]]['sql']);
}
if ($filter->return == 'key' && array_search($value, $filter->values) !== FALSE)
$value = array_search($value, $filter->values);
$queries[] = "$filter->table.$filter->name ".str_replace("{VALUE}", mysql_real_escape_string($value), $this->opers[$this->operations[$i]]['sql']);
}
return implode (" AND ", $queries);
freenetis/branches/search_filters/application/libraries/Order_field.php
}
$this->return_link = url_lang::base().$pre_url.$new_order_by.'/'.$order_by_direction.'/';
$this->return_link .= ($this->use_paginator) ? $url_array[6+$url_array_ofset].'/'.$url_array[7+$url_array_ofset] : '';
if($query_string!='')
if(server::query_string() !='')
{
$this->return_link .= $query_string;
$this->return_link .= '?'.server::query_string();
}
}
}
freenetis/branches/search_filters/application/views/filter_form_template.php
<script>
$(document).ready(function(){
$("#filter_form").validate();
$("#filter_form").validate({
errorPlacement: function(error, element){}
});
function update_form ()
{
var i = 0;
$(".t").each(function (){
if (type_options[$(this).val()] != undefined)
{
......
{
$(this).next().append('<option value="'+type_options_orders[$(this).val()][key]+'"'+((type_options_orders[$(this).val()][key] == value) ? ' selected' : '')+'>'+type_options[$(this).val()][type_options_orders[$(this).val()][key]]+'</option>');
}
var values = value_options[$(this).val()];
if (type_values[i] == undefined)
type_values[i] = new Array();
if (type_values[i][$(this).val()] == undefined)
type_values[i][$(this).val()] = values[0];
$(this).next().next().val(type_values[i][$(this).val()]);
var without = withouts[$(this).val()];
$(this).next().next().attr ('class', 'v '+types[$(this).val()]);
if (without)
{
$(this).next().next().addClass('without_select_button');
$(this).next().next().next().hide();
}
else
$(this).next().next().next().show();
var values = value_options[$(this).val()];
$(this).next().next().autocomplete({
minLength: 0,
source: function (request, response){
var arr = new Array();
var x = 0;
for (var i=0;i<count(values);i++)
{
if (request.term == "" || (strpos(values[i], request.term) === 0 && values[i]!=request.term))
arr[x++] = values[i];
}
response(arr);
}
});
var callback = callbacks[$(this).val()];
var minlength = minlengths[$(this).val()];
if (values.length)
{
$(this).next().next().autocomplete({
minLength: minlength,
source: function (request, response){
var arr = new Array();
var x = 0;
for (var i=0;i<count(values);i++)
{
if (request.term == "" || (strpos(values[i], request.term) === 0 && values[i]!=request.term))
arr[x++] = values[i];
}
response(arr);
}
});
}
else if (callback != '')
{
$(this).next().next().autocomplete({
minLength: minlength,
source: callback
});
}
$(this).next().next().next().next().val(tables[$(this).val()]);
}
i++;
});
}
$( "<img src='<?php echo url::base() ?>media/images/select.png' class='select_button'>" )
.insertAfter(".v")
.click(function (){
$( ".select_button" ).click(function (){
$(this).prev().autocomplete( "search", "" );
$(this).prev().focus();
});
$(".v").change(function (){
var i =0;
$(".v").each(function (){
type_values[i][$(this).prev().prev().val()] = $(this).val()
i++;
});
});
$(".delete_button").click(function (){
$(this).parent().hide();
$(this).prev().prev().prev().val("");
$(this).remove();
if ($(".delete_button").length == 1)
$(".delete_button").hide();
});
var type_options = new Array();
var type_options_orders = new Array();
var value_options = new Array();
......
<?php endif ?>
<?php endforeach ?>
var callbacks = new Array();
<?php foreach ($callbacks as $name => $callback): ?>
callbacks['<?php echo $name ?>'] = '<?php echo $callback ?>';
<?php endforeach ?>
var minlengths = new Array();
<?php foreach ($minlengths as $name => $minlength): ?>
minlengths['<?php echo $name ?>'] = '<?php echo $minlength ?>';
<?php endforeach ?>
var withouts = new Array();
<?php foreach ($withouts as $name => $without): ?>
withouts['<?php echo $name ?>'] = <?php echo $without ?>;
<?php endforeach ?>
var types = new Array();
<?php foreach ($js_types as $name => $js_type): ?>
types['<?php echo $name ?>'] = '<?php echo $js_type ?>';
<?php endforeach ?>
type_values = {
<?php foreach ($types as $i => $type): ?>
<?php echo $i ?>: {
'<?php echo $type ?>': '<?php echo trim($values[$i]) ?>'
},
<?php endforeach ?>
}
var tables = {
<?php foreach ($tables as $name => $table):?>
'<?php echo $name ?>': ["<?php echo $table ?>"],
<?php endforeach; ?>
}
update_form();
$(".t").change(update_form);
if ($(".delete_button").length == 1)
$(".delete_button").hide();
});
</script>
<?php echo form::open(url::base(TRUE).url::current(TRUE), array('method' => 'get', 'id' => 'filter_form')) ?>
<?php echo form::open(url::base(TRUE).url::current(FALSE), array('method' => 'get', 'id' => 'filter_form')) ?>
<?php foreach ($types as $i => $type): ?>
<?php if (trim($values[$i]) != ''): ?>
<div style="height: 20px;">
<?php echo form::dropdown ('t['.$i.']', $type_values, $type, " class='t'") ?>
<?php echo form::dropdown ('o['.$i.']', $operation_values, $operations[$i], " class='o'") ?>
<?php echo form::input(array('name' => 'v['.$i.']', 'value' => trim($values[$i]), 'class' => 'v')) ?>
<div class="filter_div">
<?php echo form::dropdown ('types[]', $type_values, $type, " class='t'") ?>
<?php echo form::dropdown ('opers[]', $operation_values, $operations[$i], " class='o'") ?>
<?php echo form::input(array('name' => 'values[]', 'value' => trim($values[$i]), 'class' => 'v without_select_button')) ?>
<img src='<?php echo url::base() ?>media/images/select.png' class='select_button'>
<?php echo form::hidden('tables[]', $tables[$type]) ?>
<img src='<?php echo url::base() ?>media/images/icons/delete.png' class='delete_button' title="<?php echo url_lang::lang('texts.Delete this filter') ?>">
</div>
<br />
<?php endif ?>
<?php endforeach ?>
<?php echo form::dropdown ('t[]', $type_values, NULL, " class='t'") ?>
<?php echo form::dropdown ('o[]', $operation_values, NULL, " class='o'") ?>
<?php echo form::input(array('name' => 'v[]', 'class' => 'v')) ?>
<br />
<?php //echo form::button(array('type' => 'submit', 'class' => 'submit', 'value' => 'Filter')) ?>
<div class="filter_div">
<?php echo form::dropdown ('types[]', $type_values, NULL, " class='t'") ?>
<?php echo form::dropdown ('opers[]', $operation_values, NULL, " class='o'") ?>
<?php echo form::input(array('name' => 'values[]', 'class' => 'v without_select_button')) ?>
<img src='<?php echo url::base() ?>media/images/select.png' class='select_button'>
<?php echo form::hidden('tables[]', "") ?>
<img src='<?php echo url::base() ?>media/images/icons/delete.png' class='delete_button' title="<?php echo url_lang::lang('texts.Delete this filter') ?>">
</div>
<?php echo form::button(array('type' => 'submit', 'class' => 'submit', 'value' => url_lang::lang('texts.Filter'))) ?>
<?php echo form::close() ?>

Také k dispozici: Unified diff