Revize 1016
Přidáno uživatelem Michal Kliment před více než 13 roky(ů)
freenetis/branches/search_filters/media/css/style.css | ||
---|---|---|
margin-left: 7px;
|
||
margin-bottom: 5px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.ui-autocomplete-loading {
|
||
background: white url('../images/ui-anim_basic_16x16.gif') right center no-repeat;
|
||
}
|
freenetis/branches/search_filters/application/models/user.php | ||
---|---|---|
* @param numeric $member_id
|
||
* @return Mysql_Result object
|
||
*/
|
||
public function get_all_users($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $filter_values = array(), $member_id=NULL)
|
||
public function get_all_users($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $filter_sql='', $member_id=NULL)
|
||
{
|
||
$where = '';
|
||
if(count($filter_values)>0) $where .= 'WHERE ';
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if ($key!='submit')
|
||
{
|
||
if ($where!='WHERE ')
|
||
$where .= ' AND ';
|
||
$where .= $this->arr_sql[$key].' LIKE \'%'.trim($value).'%\' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
if ($member_id)
|
||
{
|
||
if($where=='') $where = 'WHERE u.member_id = '.$member_id;
|
||
else $where .= ' AND u.member_id = '.$member_id;
|
||
}
|
||
|
||
if ($filter_sql != '')
|
||
$where .= 'WHERE '.$filter_sql;
|
||
|
||
return $this->db->query('
|
||
SELECT u.id, u.name, u.surname, u.login, u.member_id, m.name AS member_name
|
||
FROM users u
|
||
LEFT JOIN members m on m.id = u.member_id
|
||
LEFT JOIN users_contacts uc ON u.id = uc.user_id
|
||
LEFT JOIN contacts c ON uc.contact_id = c.id AND c.type = (SELECT id FROM enum_types WHERE value = \'E-mail\')
|
||
'.$where.'
|
||
GROUP BY u.id
|
||
ORDER BY '.$this->arr_sql[$order_by].' '.$order_by_direction.'
|
||
SELECT * FROM
|
||
(
|
||
SELECT u.*, m.name AS member, c.value AS email FROM users u
|
||
JOIN members m ON u.member_id = m.id
|
||
LEFT JOIN users_contacts uc ON u.id = uc.user_id
|
||
LEFT JOIN contacts c ON uc.contact_id = c.id AND c.type = 21
|
||
) AS u
|
||
ORDER BY '.$order_by.' '.$order_by_direction.'
|
||
LIMIT '.$limit_from.','.$limit_results
|
||
);
|
||
}
|
freenetis/branches/search_filters/application/models/member.php | ||
---|---|---|
WHERE account_attribute_id = ? AND member_id = ?
|
||
", array($account_attribute_id, $this->id))->current();
|
||
}
|
||
|
||
public function get_all_as_array()
|
||
{
|
||
$members = $this->orderby('name')->find_all();
|
||
|
||
$arr_members = array();
|
||
foreach ($members as $member)
|
||
$arr_members[$member->id] = $member->name;
|
||
|
||
return $arr_members;
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/branches/search_filters/application/controllers/users.php | ||
---|---|---|
|
||
if (!$this->acl_check_view(get_class($this), 'users'))
|
||
Controller::error(ACCESS);
|
||
|
||
$filter_form = new Filter_form('u');
|
||
$filter_form->add('id')->type('number');
|
||
$filter_form->add('name')->callback('json/user_name');
|
||
$filter_form->add('surname')->callback('json/user_surname');
|
||
$filter_form->add('login')->label(url_lang::lang('texts.Login name'))->callback('json/user_login');
|
||
$filter_form->add('member')->type('select')->callback('json/member_name');
|
||
$filter_form->add('email')->callback('json/user_email');
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page'))) $limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
... | ... | |
"tr",
|
||
new Table_Form_Item('text','email', 'E-mail'), "td",
|
||
new Table_Form_Item('submit','submit','Filter')
|
||
|
||
)
|
||
);
|
||
|
||
... | ... | |
if (($sql_offset = ($page - 1) * $limit_results) > $total_users)
|
||
$sql_offset = 0;
|
||
|
||
$query = $model_users->get_all_users($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter->values());
|
||
$query = $model_users->get_all_users($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $filter_form->as_sql());
|
||
|
||
$arr_gets = array();
|
||
foreach ($this->input->get() as $key=>$value) $arr_gets[] = $key.'='.$value;
|
||
... | ... | |
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'query_string' => $query_string,
|
||
'filter' => $filter->view
|
||
'filter' => $filter_form
|
||
));
|
||
|
||
//$grid->add_new_button(url_lang::base().'users/add', url_lang::lang('texts.Add new user'));
|
freenetis/branches/search_filters/application/controllers/members.php | ||
---|---|---|
$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('redirect')->label(url_lang::lang('texts.Redirection'))->type('bit')->return('key')->values(array("~16" => 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('registration')->type('select')->values(array(url_lang::lang('texts.Yes'), url_lang::lang('texts.No')));
|
freenetis/branches/search_filters/application/controllers/json.php | ||
---|---|---|
|
||
echo json_encode($arr_streets);
|
||
}
|
||
|
||
public function user_name ()
|
||
{
|
||
$term = $this->input->get('term');
|
||
|
||
$user_model = new User_Model();
|
||
|
||
$users = $user_model->like('name', $term)->groupby('name')->orderby('name')->find_all();
|
||
|
||
$arr_users = array();
|
||
foreach ($users as $member)
|
||
$arr_users[] = $member->name;
|
||
|
||
echo json_encode($arr_users);
|
||
}
|
||
|
||
public function user_surname ()
|
||
{
|
||
$term = $this->input->get('term');
|
||
|
||
$user_model = new User_Model();
|
||
|
||
$users = $user_model->like('surname', $term)->groupby('surname')->orderby('surname')->find_all();
|
||
|
||
$arr_users = array();
|
||
foreach ($users as $member)
|
||
$arr_users[] = $member->surname;
|
||
|
||
echo json_encode($arr_users);
|
||
}
|
||
|
||
public function user_login ()
|
||
{
|
||
$term = $this->input->get('term');
|
||
|
||
$user_model = new User_Model();
|
||
|
||
$users = $user_model->like('login', $term)->groupby('login')->orderby('login')->find_all();
|
||
|
||
$arr_users = array();
|
||
foreach ($users as $member)
|
||
$arr_users[] = $member->login;
|
||
|
||
echo json_encode($arr_users);
|
||
}
|
||
|
||
public function user_email ()
|
||
{
|
||
$term = $this->input->get('term');
|
||
|
||
$contact_model = new Contact_Model();
|
||
|
||
$contacts = $contact_model->where('type', Contact_Model::TYPE_EMAIL)->like('value', $term)->groupby('value')->orderby('value')->find_all();
|
||
|
||
$arr_contacts = array();
|
||
foreach ($contacts as $member)
|
||
$arr_contacts[] = $member->value;
|
||
|
||
echo json_encode($arr_contacts);
|
||
}
|
||
}
|
freenetis/branches/search_filters/system/libraries/drivers/Database.php | ||
---|---|---|
$match = '%'.str_replace('%', '\\%', $match).'%';
|
||
}
|
||
|
||
return $prefix.' '.$this->escape_column($field).' LIKE \''.$match . '\'';
|
||
return $prefix.' '.$this->escape_column($field).' LIKE \''.$match . '\' COLLATE utf8_general_ci';
|
||
}
|
||
|
||
/**
|
||
... | ... | |
$match = '%'.$match.'%';
|
||
}
|
||
|
||
return $prefix.' '.$this->escape_column($field).' NOT LIKE \''.$match.'\'';
|
||
return $prefix.' '.$this->escape_column($field).' NOT LIKE \''.$match.'\' COLLATE utf8_general_ci';
|
||
}
|
||
|
||
/**
|
Také k dispozici: Unified diff
Filtry u vypisu vsech uzivatelu.