*
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info["flags"] = array("currentapp" => "addressbook", "enable_addressbook_class" => True,
"enable_nextmatchs_class" => True);
include("../header.inc.php");
//echo "
Time track = " . $phpgw_info["apps"]["timetrack"]["enabled"];
if (! $start)
$start = 0;
$t = new Template($phpgw_info["server"]["app_tpl"]);
$t->set_file(array( "addressbook_header" => "header.tpl",
"searchfilter" => "searchfilter.tpl",
"body" => "list.tpl",
"addressbook_footer" => "footer.tpl" ));
# $t->set_block("addressbook_header","searchfilter","body",
# "addressbook_footer","output");
$limit =$phpgw->nextmatchs->sql_limit($start);
if ($order)
$ordermethod = "order by $order $sort";
else
$ordermethod = "order by ab_lastname,ab_firstname,ab_email asc";
if (! $filter) {
$filter = "none";
}
if ($filter != "private") {
if ($filter != "none") {
$filtermethod = " ab_access like '%,$filter,%' ";
} else {
$filtermethod = " (ab_owner='" . $phpgw_info["user"]["account_id"] ."' OR ab_access='public' "
. $phpgw->accounts->sql_search("ab_access") . " ) ";
}
} else {
$filtermethod = " ab_owner='" . $phpgw_info["user"]["account_id"] . "' ";
}
if ($query) {
if ($phpgw_info["apps"]["timetrack"]["enabled"]){
$phpgw->db->query("SELECT count(*) "
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
. "AND $filtermethod AND (a.ab_lastname like '"
. "%$query%' OR a.ab_firstname like '%$query%' OR a.ab_email like '%$query%' OR "
. "a.ab_street like '%$query%' OR a.ab_city like '%$query%' OR a.ab_state "
. "like '%$query%' OR a.ab_zip like '%$query%' OR a.ab_notes like "
. "'%$query%' OR c.company_name like '%$query%' OR a.ab_url like '%$query%')",__LINE__,__FILE__);
// . "'%$query%' OR c.company_name like '%$query%')"
// . " $ordermethod limit $limit");
} else {
$phpgw->db->query("SELECT count(*) "
. "from addressbook "
. "WHERE $filtermethod AND (ab_lastname like '"
. "%$query%' OR ab_firstname like '%$query%' OR ab_email like '%$query%' OR "
. "ab_street like '%$query%' OR ab_city like '%$query%' OR ab_state "
. "like '%$query%' OR ab_zip like '%$query%' OR ab_notes like "
. "'%$query%' OR ab_company like '%$query%' OR ab_url like '%$query$%')",__LINE__,__FILE__);
// . "'%$query%' OR ab_company like '%$query%')"
// . " $ordermethod limit $limit");
}
$phpgw->db->next_record();
if ($phpgw->db->f(0) == 1)
$t->set_var(searchreturn,lang("your search returned 1 match"));
else
$t->set_var(searchreturn,lang("your search returned x matchs",$phpgw->db->f(0)));
} else {
$t->set_var(searchreturn,"");
$phpgw->db->query("select count(*) from addressbook where $filtermethod",__LINE__,__FILE__);
$phpgw->db->next_record();
}
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company_sortorder = "c.company_name";
} else {
$company_sortorder = "ab_company";
}
//$phpgw->db->next_record();
if ($phpgw->db->f(0) > $phpgw_info["user"]["preferences"]["common"]["maxmatchs"])
$t->set_var(lang_showing,lang("showing x - x of x",($start + 1),($start + $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]),$phpgw->db->f(0)));
else
$t->set_var(lang_showing,lang("showing x",$phpgw->db->f(0)));
$t->set_var("search_filter",$phpgw->nextmatchs->show_tpl("index.php",$start,$phpgw->db->f(0),"&order=$order&filter=$filter&sort=$sort&query=$query", "75%", $phpgw_info["theme"]["th_bg"]));
while ($column = each($abc)) {
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) &&
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
$cols .= '