Add ability to select all/none or a specific category

This commit is contained in:
Miles Lott 2001-03-25 06:02:52 +00:00
parent 5c4dbe12cc
commit fb1aa7062b
3 changed files with 27 additions and 6 deletions

View File

@ -325,7 +325,7 @@
$isstd=0; $isstd=0;
if ($name && empty($value)) { if ($name && empty($value)) {
if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is empty (NULL)"; } if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is empty (NULL)"; }
$check_stock = $this->stock_contact_fields + array('id' => 'id', 'tid' => 'tid', 'lid' => 'lid', 'owner' => 'owner'); $check_stock = $this->stock_contact_fields + array('id' => 'id', 'tid' => 'tid', 'lid' => 'lid', 'owner' => 'owner', 'cat_id' => 'cat_id');
while (list($fname,$fvalue)=each($check_stock)) { while (list($fname,$fvalue)=each($check_stock)) {
if ($fvalue==$name) { if ($fvalue==$name) {
$filterlist .= $name.' is NULL,'; $filterlist .= $name.' is NULL,';

View File

@ -33,15 +33,23 @@
} }
} }
function cat_option($cat_id) { function cat_option($cat_id='') {
global $phpgw_info; global $phpgw_info;
// Get global and app-specific category listings // Setup all and none first
$cats_link = "<select name=\"cat_id\">"; $cats_link = "<select name=\"cat_id\">";
$cats_link .= "<option value =\"all\"";
if ($cat_id=="all") {
$cats_link .= " selected";
}
$cats_link .= ">".lang("all");
$cats_link .= "<option value =\"0\""; $cats_link .= "<option value =\"0\"";
if (!$cat_id) { if (!$cat_id) {
$cats_link .= " selected"; $cats_link .= " selected";
} }
$cats_link .= ">".lang("none"); $cats_link .= ">".lang("none");
// Get global and app-specific category listings
$cats = CreateObject('phpgwapi.categories'); $cats = CreateObject('phpgwapi.categories');
$cats->categories($phpgw_info['user']['account_id'],'phpgw'); $cats->categories($phpgw_info['user']['account_id'],'phpgw');

View File

@ -96,12 +96,25 @@
// Set filter to display entries where tid is blank, // Set filter to display entries where tid is blank,
// else they may be accounts, etc. // else they may be accounts, etc.
$savefilter = $filter; $savefilter = $filter;
if ($filter == "none") { if ($filter == "none") {
$filter = 'tid=,cat_id='.$cat_id; if ($cat_id == "all") {
$filter = 'tid=';
} else {
$filter = 'tid=,cat_id='.$cat_id;
}
} elseif($filter == "private") { } elseif($filter == "private") {
$filter = 'owner='.$phpgw_info["user"]["account_id"].',tid=,cat_id='.$cat_id; if ($cat_id == "all") {
$filter = 'owner='.$phpgw_info["user"]["account_id"].',tid=';
} else {
$filter = 'owner='.$phpgw_info["user"]["account_id"].',tid=,cat_id='.$cat_id;
}
} else { } else {
$filter .= ',tid=,cat_id='.$cat_id; if ($cat_id == "all") {
$filter .= ',tid=';
} else {
$filter .= ',tid=,cat_id='.$cat_id;
}
} }
// Check if prefs were set, if not, create some defaults // Check if prefs were set, if not, create some defaults