fixed paging and searching.. still problems

This commit is contained in:
skeeter 2001-01-25 17:56:25 +00:00
parent 39334f25ec
commit de2aa31d33
3 changed files with 48 additions and 32 deletions

View File

@ -109,6 +109,9 @@
$s_users = 0;
}
if(!isset($query)) {
$query = "";
}
if(!isset($maxm)) {
$maxm = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
@ -134,6 +137,18 @@
$p->set_var('bg_color',$phpgw_info["theme"]["th_bg"]);
$p->set_var('submit_lang',lang('submit'));
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
. ' <input type="hidden" name="start" value="'.$start.'">'."\n"
. ' <input type="hidden" name="query" value="'.$query.'">'."\n";
$p->set_var('common_hidden_vars_form',$common_hidden_vars);
if(isset($query_result) && $query_result)
$common_hidden_vars .= "<input type=\"hidden\" name=\"query_result\" value=\"".$query_result."\">\n";
$p->set_var('common_hidden_vars',$common_hidden_vars);
$p->set_var(array('read_lang' => lang('Read'),
'add_lang' => lang('Add'),
'edit_lang' => lang('Edit'),
@ -144,6 +159,13 @@
$p->parse('row','row_colspan',True);
while(list(,$group) = each($groups)) {
$go = True;
if($query) {
if(!strpos(' '.$group[1].' ',$query)) {
$go = False;
}
}
if($go) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
display_row($tr_color,'g_',$group[0],$group[1]);
$s_groups++;
@ -152,13 +174,14 @@
if($total == $maxm) break;
}
}
}
if($total <> $maxm) {
if(!is_object($db)) {
$db = $phpgw->db;
}
$db->query("select account_id from accounts ORDER BY account_lastname, account_firstname, account_lid LIMIT ".$phpgw->nextmatchs->sql_limit(intval($s_users)),__LINE__,__FILE__);
$db->query("select account_id, account_firstname, account_lastname, account_lid from accounts ORDER BY account_lastname, account_firstname, account_lid ".$db->limit(intval($s_users),$maxm),__LINE__,__FILE__);
$users = $db->num_rows();
if($total <> $maxm) {
if($users) {
@ -166,6 +189,14 @@
$p->parse('row','row_colspan',True);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
while($db->next_record()) {
$go = True;
if($query) {
$name = ' '.$db->f("account_firstname").' '.$db->f("account_lastname").' '.$db->f("account_lid").' ';
if(!strpos($name,$query)) {
$go = False;
}
}
if($go) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$id = $db->f("account_id");
display_row($tr_color,'u_',$id,$phpgw->common->grab_owner_name($id));
@ -177,28 +208,15 @@
}
}
}
}
$extra_parms = "&s_users=".$s_users."&s_groups=".$s_groups."&maxm=".$maxm."&totalentries=".$totalentries."&total=".($start + $total);
$p->set_var("nml",$phpgw->nextmatchs->left("",$start,$totalentries,$extra_parms));
$p->set_var("nmr",$phpgw->nextmatchs->right("",$start,$totalentries,$extra_parms));
$start += $total;
$common_hidden_vars = ' <input type="hidden" name="s_groups" value="'.$s_groups.'">'."\n"
. ' <input type="hidden" name="s_users" value="'.$s_users.'">'."\n"
. ' <input type="hidden" name="maxm" value="'.$maxm.'">'."\n"
. ' <input type="hidden" name="totalentries" value="'.$totalentries.'">'."\n"
. ' <input type="hidden" name="start" value="'.$start.'">'."\n";
$p->set_var('common_hidden_vars_form',$common_hidden_vars);
if(isset($query_result) && $query_result)
$common_hidden_vars .= "<input type=\"hidden\" name=\"query_result\" value=\"".$query_result."\">\n";
$p->set_var('common_hidden_vars',$common_hidden_vars);
$p->set_var("search_value",(isset($query) && $query?$query:""));
$p->set_var("search",lang("search"));
$p->set_var("next",lang("next"));
$p->set_var('processed',urlencode(serialize($processed)));
$p->pparse('out','preferences');

View File

@ -5,11 +5,10 @@
{nml}
<td width="40%">
<div align="center">
<form method="GET" action="{action_url}">
<form method="POST" action="{action_url}">
{common_hidden_vars}
<input type="text" name="query" value="{search_value}">
<input type="submit" name="search" value="{search}">
<input type="submit" name="next" value="{next}">
</form>
</div>
</td>

View File

@ -5,11 +5,10 @@
{nml}
<td width="40%">
<div align="center">
<form method="GET" action="{action_url}">
<form method="POST" action="{action_url}">
{common_hidden_vars}
<input type="text" name="query" value="{search_value}">
<input type="submit" name="search" value="{search}">
<input type="submit" name="next" value="{next}">
</form>
</div>
</td>