forked from extern/egroupware
Add 'add' function to handle new add.php.
This commit is contained in:
parent
0c582297c4
commit
979d35be52
@ -74,6 +74,70 @@
|
||||
return $this;
|
||||
}
|
||||
|
||||
function add_entry() {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
|
||||
$sql = "INSERT INTO addressbook ("
|
||||
. "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone,"
|
||||
. "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2,"
|
||||
. "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company_id,ab_access,ab_url,"
|
||||
. "ab_owner) VALUES ("
|
||||
. " '" . addslashes($this->email)
|
||||
. "','" . addslashes($this->firstname)
|
||||
. "','" . addslashes($this->lastname)
|
||||
. "','" . addslashes($this->title)
|
||||
. "','" . addslashes($this->hphone)
|
||||
. "','" . addslashes($this->wphone)
|
||||
. "','" . addslashes($this->fax)
|
||||
. "','" . addslashes($this->pager)
|
||||
. "','" . addslashes($this->mphone)
|
||||
. "','" . addslashes($this->ophone)
|
||||
. "','" . addslashes($this->street)
|
||||
. "','" . addslashes($this->address2)
|
||||
. "','" . addslashes($this->city)
|
||||
. "','" . addslashes($this->state)
|
||||
. "','" . addslashes($this->zip)
|
||||
. "','" . addslashes($this->bday)
|
||||
. "','" . addslashes($this->notes)
|
||||
. "','" . addslashes($this->company_id)
|
||||
. "','" . addslashes($this->access)
|
||||
. "','" . addslashes($this->url)
|
||||
. "','" . $phpgw_info["user"]["account_id"]
|
||||
. "')";
|
||||
} else {
|
||||
$sql = "INSERT INTO addressbook ("
|
||||
. "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone,"
|
||||
. "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2,"
|
||||
. "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company,ab_access,ab_url,"
|
||||
. "ab_owner) VALUES ("
|
||||
. " '" . addslashes($this->email)
|
||||
. "','" . addslashes($this->firstname)
|
||||
. "','" . addslashes($this->lastname)
|
||||
. "','" . addslashes($this->title)
|
||||
. "','" . addslashes($this->hphone)
|
||||
. "','" . addslashes($this->wphone)
|
||||
. "','" . addslashes($this->fax)
|
||||
. "','" . addslashes($this->pager)
|
||||
. "','" . addslashes($this->mphone)
|
||||
. "','" . addslashes($this->ophone)
|
||||
. "','" . addslashes($this->street)
|
||||
. "','" . addslashes($this->address2)
|
||||
. "','" . addslashes($this->city)
|
||||
. "','" . addslashes($this->state)
|
||||
. "','" . addslashes($this->zip)
|
||||
. "','" . addslashes($this->bday)
|
||||
. "','" . addslashes($this->notes)
|
||||
. "','" . addslashes($this->company)
|
||||
. "','" . addslashes($this->access)
|
||||
. "','" . addslashes($this->url)
|
||||
. "','" . $phpgw_info["user"]["account_id"]
|
||||
. "')";
|
||||
}
|
||||
$phpgw->db->query($sql);
|
||||
return;
|
||||
}
|
||||
|
||||
function update_entry() {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
@ -85,7 +149,6 @@
|
||||
. "', ab_title='" . addslashes($this->title)
|
||||
. "', ab_hphone='" . addslashes($this->hphone)
|
||||
. "', ab_wphone='" . addslashes($this->wphone)
|
||||
. "', ab_company='" . addslashes($this->company)
|
||||
. "', ab_fax='" . addslashes($this->fax)
|
||||
. "', ab_pager='" . addslashes($this->pager)
|
||||
. "', ab_mphone='" . addslashes($this->mphone)
|
||||
|
@ -74,6 +74,70 @@
|
||||
return $this;
|
||||
}
|
||||
|
||||
function add_entry() {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
|
||||
$sql = "INSERT INTO addressbook ("
|
||||
. "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone,"
|
||||
. "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2,"
|
||||
. "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company_id,ab_access,ab_url,"
|
||||
. "ab_owner) VALUES ("
|
||||
. " '" . addslashes($this->email)
|
||||
. "','" . addslashes($this->firstname)
|
||||
. "','" . addslashes($this->lastname)
|
||||
. "','" . addslashes($this->title)
|
||||
. "','" . addslashes($this->hphone)
|
||||
. "','" . addslashes($this->wphone)
|
||||
. "','" . addslashes($this->fax)
|
||||
. "','" . addslashes($this->pager)
|
||||
. "','" . addslashes($this->mphone)
|
||||
. "','" . addslashes($this->ophone)
|
||||
. "','" . addslashes($this->street)
|
||||
. "','" . addslashes($this->address2)
|
||||
. "','" . addslashes($this->city)
|
||||
. "','" . addslashes($this->state)
|
||||
. "','" . addslashes($this->zip)
|
||||
. "','" . addslashes($this->bday)
|
||||
. "','" . addslashes($this->notes)
|
||||
. "','" . addslashes($this->company_id)
|
||||
. "','" . addslashes($this->access)
|
||||
. "','" . addslashes($this->url)
|
||||
. "','" . $phpgw_info["user"]["account_id"]
|
||||
. "')";
|
||||
} else {
|
||||
$sql = "INSERT INTO addressbook ("
|
||||
. "ab_email,ab_firstname,ab_lastname,ab_title,ab_hphone,ab_wphone,"
|
||||
. "ab_fax,ab_pager,ab_mphone,ab_ophone,ab_street,ab_address2,"
|
||||
. "ab_city,ab_state,ab_zip,ab_bday,ab_notes,ab_company,ab_access,ab_url,"
|
||||
. "ab_owner) VALUES ("
|
||||
. " '" . addslashes($this->email)
|
||||
. "','" . addslashes($this->firstname)
|
||||
. "','" . addslashes($this->lastname)
|
||||
. "','" . addslashes($this->title)
|
||||
. "','" . addslashes($this->hphone)
|
||||
. "','" . addslashes($this->wphone)
|
||||
. "','" . addslashes($this->fax)
|
||||
. "','" . addslashes($this->pager)
|
||||
. "','" . addslashes($this->mphone)
|
||||
. "','" . addslashes($this->ophone)
|
||||
. "','" . addslashes($this->street)
|
||||
. "','" . addslashes($this->address2)
|
||||
. "','" . addslashes($this->city)
|
||||
. "','" . addslashes($this->state)
|
||||
. "','" . addslashes($this->zip)
|
||||
. "','" . addslashes($this->bday)
|
||||
. "','" . addslashes($this->notes)
|
||||
. "','" . addslashes($this->company)
|
||||
. "','" . addslashes($this->access)
|
||||
. "','" . addslashes($this->url)
|
||||
. "','" . $phpgw_info["user"]["account_id"]
|
||||
. "')";
|
||||
}
|
||||
$phpgw->db->query($sql);
|
||||
return;
|
||||
}
|
||||
|
||||
function update_entry() {
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
@ -85,7 +149,6 @@
|
||||
. "', ab_title='" . addslashes($this->title)
|
||||
. "', ab_hphone='" . addslashes($this->hphone)
|
||||
. "', ab_wphone='" . addslashes($this->wphone)
|
||||
. "', ab_company='" . addslashes($this->company)
|
||||
. "', ab_fax='" . addslashes($this->fax)
|
||||
. "', ab_pager='" . addslashes($this->pager)
|
||||
. "', ab_mphone='" . addslashes($this->mphone)
|
||||
|
@ -35,7 +35,7 @@
|
||||
);
|
||||
|
||||
|
||||
function form($format,$action,$title,$fields) {
|
||||
function form($format,$action,$title,$fields) { // used for add/edit
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
$t = new Template($phpgw_info["server"]["app_tpl"]);
|
||||
@ -279,191 +279,4 @@
|
||||
$t->pparse("out","form");
|
||||
} //end form function
|
||||
|
||||
function NOlist_entries($start="",$sort="",$order="",$query="",$filter="") {
|
||||
global $phpgw,$phpgw_info;
|
||||
$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) {
|
||||
$searchreturn=lang("your search returned 1 match");
|
||||
} else {
|
||||
$searchreturn=lang("your search returned x matchs",$phpgw->db->f(0));
|
||||
}
|
||||
} else {
|
||||
$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"]) {
|
||||
$lang_showing=lang("showing x - x of x",($start + 1),($start + $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]),$phpgw->db->f(0));
|
||||
} else {
|
||||
$lang_showing=lang("showing x",$phpgw->db->f(0));
|
||||
}
|
||||
|
||||
$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($this)) {
|
||||
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) &&
|
||||
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) {
|
||||
$cols .= '<td height="21">';
|
||||
$cols .= '<font size="-1" face="Arial, Helvetica, sans-serif">';
|
||||
$cols .= $phpgw->nextmatchs->show_sort_order($sort,"ab_" . $column[0],$order,"index.php",lang($column[1]));
|
||||
$cols .= '</font></td>';
|
||||
$cols .= "\n";
|
||||
|
||||
// To be used when displaying the rows
|
||||
$columns_to_display[$column[0]] = True;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($query) && $query) {
|
||||
if (isset($phpgw_info["apps"]["timetrack"]["enabled"]) &&
|
||||
$phpgw_info["apps"]["timetrack"]["enabled"]) {
|
||||
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,a.ab_company_id,"
|
||||
. "a.ab_email,a.ab_wphone,c.company_name,a.ab_hphone,a.ab_fax,a.ab_mphone "
|
||||
. "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%') $ordermethod limit $limit",__LINE__,__FILE__);
|
||||
} else {
|
||||
$phpgw->db->query("SELECT * 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%') $ordermethod limit $limit",__LINE__,__FILE__);
|
||||
}
|
||||
} else {
|
||||
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
|
||||
$phpgw->db->query("SELECT a.ab_id,a.ab_owner,a.ab_firstname,a.ab_lastname,"
|
||||
. "a.ab_email,a.ab_wphone,c.company_name "
|
||||
. "from addressbook as a, customers as c where a.ab_company_id = c.company_id "
|
||||
. "AND $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
|
||||
} else {
|
||||
$phpgw->db->query("SELECT * from addressbook WHERE $filtermethod $ordermethod limit $limit",__LINE__,__FILE__);
|
||||
}
|
||||
} // else $query
|
||||
$rows="";
|
||||
while ($phpgw->db->next_record()) {
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
$rows .= '<tr bgcolor="#'.$tr_color . '">';
|
||||
|
||||
$ab_id = $phpgw->db->f("ab_id");
|
||||
|
||||
while ($column = each($columns_to_display)) {
|
||||
if ($column[0] == "company") {
|
||||
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
|
||||
$field = $phpgw->db->f("company_name");
|
||||
} else {
|
||||
$field = $phpgw->db->f("ab_company");
|
||||
}
|
||||
} else {
|
||||
$field = $phpgw->db->f("ab_" . $column[0]);
|
||||
}
|
||||
|
||||
$field = htmlentities($field);
|
||||
|
||||
// Some fields require special formating.
|
||||
if ($column[0] == "url") {
|
||||
if (! ereg("^http://",$field)) {
|
||||
$data = "http://" . $field;
|
||||
}
|
||||
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
|
||||
. '<a href="' . $field . '" target="_new">' . $field. '</a> </font></td>';
|
||||
} else if ($column[0] == "email") {
|
||||
if ($phpgw_info["user"]["apps"]["email"]) {
|
||||
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
|
||||
. '<a href="' . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/email/compose.php",
|
||||
"to=" . urlencode($field)) . '" target="_new">' . $field . '</a> </font></td>';
|
||||
} else {
|
||||
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
|
||||
. '<a href="mailto:' . $field . '">' . $field. '</a> </font></td>';
|
||||
}
|
||||
} else {
|
||||
$rows .= '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
|
||||
. $field . ' </font></td>';
|
||||
}
|
||||
#echo '</tr>';
|
||||
}
|
||||
reset($columns_to_display); // If we don't reset it, our inside while won't loop
|
||||
$rows .= '<td valign="top" width="3%">
|
||||
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
|
||||
<a href="'. $phpgw->link("view.php","ab_id=$ab_id&start=$start&order=$order&filter="
|
||||
. "$filter&query=$query&sort=$sort").'
|
||||
">'.lang("View").'</a>
|
||||
</font>
|
||||
</td>
|
||||
<td valign=top width=3%>
|
||||
<font face="'.$phpgw_info["theme"]["font"].'" size=2>
|
||||
<a href="'.$phpgw->link("vcardout.php","ab_id=$ab_id&start=$start&order=$order&filter="
|
||||
. "$filter&query=$query&sort=$sort").'
|
||||
">'.lang("vcard").'</a>
|
||||
</font>
|
||||
</td>
|
||||
<td valign="top" width="5%">
|
||||
<font face="'.$phpgw_info["theme"]["font"].'" size="2">
|
||||
'.$phpgw->common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")."&start=".$start."&sort=".$sort."&order=".$order).'
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
return array($cols,$rows,$searchreturn,$lang_showing,$search_filter);
|
||||
} //end list function
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user