Working on cleaning up the view addressbook section and added a new column called URL

This commit is contained in:
jengo 2000-11-01 12:32:36 +00:00
parent 512dd9c983
commit 58d7eb8f15
5 changed files with 228 additions and 198 deletions

View File

@ -26,58 +26,64 @@
} else if (! $submit && ! $add_email) {
form("","add.php","Add","","","");
} else {
if ($bday_month == "" && $bday_day == "" && $bday_year == "")
if ($bday_month == "" && $bday_day == "" && $bday_year == "") {
$bday = "";
else
} else {
$bday = "$bday_month/$bday_day/$bday_year";
}
$access = $phpgw->accounts->array_to_string($access,$n_groups);
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
if ($access != "private" && $access != "public") {
$access = $phpgw->accounts->array_to_string($access,$n_groups);
}
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$sql = "insert into addressbook (ab_owner,ab_access,ab_firstname,ab_lastname,ab_title,ab_email,"
. "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) values ('" . $phpgw_info["user"]["account_id"] . "','$access','"
. addslashes($firstname). "','"
. addslashes($lastname) . "','"
. addslashes($title) . "','"
. addslashes($email) . "','"
. addslashes($hphone) . "','"
. addslashes($wphone) . "','"
. addslashes($fax) . "','"
. addslashes($pager) . "','"
. addslashes($mphone) . "','"
. addslashes($ophone) . "','"
. addslashes($street) . "','"
. addslashes($address2) . "','"
. addslashes($city) . "','"
. addslashes($state) . "','"
. addslashes($zip) . "','"
. addslashes($bday) . "','"
. addslashes($notes) . "','"
. addslashes($company). "')";
. "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_url) values ('" . $phpgw_info["user"]["account_id"] . "','$access','"
. addslashes($firstname). "','"
. addslashes($lastname) . "','"
. addslashes($title) . "','"
. addslashes($email) . "','"
. addslashes($hphone) . "','"
. addslashes($wphone) . "','"
. addslashes($fax) . "','"
. addslashes($pager) . "','"
. addslashes($mphone) . "','"
. addslashes($ophone) . "','"
. addslashes($street) . "','"
. addslashes($address2) . "','"
. addslashes($city) . "','"
. addslashes($state) . "','"
. addslashes($zip) . "','"
. addslashes($bday) . "','"
. addslashes($notes) . "','"
. addslashes($company) . "','"
. addslashes($url) . "')";
} else {
$sql = "insert into addressbook (ab_owner,ab_access,ab_firstname,ab_lastname,ab_title,ab_email,"
. "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) values ('" . $phpgw_info["user"]["account_id"] . "','$access','"
. addslashes($firstname). "','"
. addslashes($lastname) . "','"
. addslashes($title) . "','"
. addslashes($email) . "','"
. addslashes($hphone) . "','"
. addslashes($wphone) . "','"
. addslashes($fax) . "','"
. addslashes($pager) . "','"
. addslashes($mphone) . "','"
. addslashes($ophone) . "','"
. addslashes($street) . "','"
. addslashes($address2) . "','"
. addslashes($city) . "','"
. addslashes($state) . "','"
. addslashes($zip) . "','"
. addslashes($bday) . "','"
. addslashes($notes) . "','"
. addslashes($company). "')";
. "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_url) values ('" . $phpgw_info["user"]["account_id"] . "','$access','"
. addslashes($firstname). "','"
. addslashes($lastname) . "','"
. addslashes($title) . "','"
. addslashes($email) . "','"
. addslashes($hphone) . "','"
. addslashes($wphone) . "','"
. addslashes($fax) . "','"
. addslashes($pager) . "','"
. addslashes($mphone) . "','"
. addslashes($ophone) . "','"
. addslashes($street) . "','"
. addslashes($address2) . "','"
. addslashes($city) . "','"
. addslashes($state) . "','"
. addslashes($zip) . "','"
. addslashes($bday) . "','"
. addslashes($notes) . "','"
. addslashes($company) . "','"
. addslashes($url) . "')";
}
$phpgw->db->query($sql);
@ -86,20 +92,20 @@
}
?>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="95%">
<TABLE border="0" cellPadding="0" cellSpacing="0" width="95%">
<TBODY>
<TR>
<TD>
<TABLE border=0 cellPadding=1 cellSpacing=1>
<TABLE border="0" cellPadding="1" cellSpacing="1">
<TBODY>
<TR>
<TD align=left>
<INPUT type=submit name=submit value="OK">
<TD align="left">
<INPUT type="submit" name="submit" value="<?php echo lang("OK"); ?>">
</TD>
<TD align=left>
<INPUT name=reset type=reset value="Clear">
<TD align="left">
<INPUT name="reset" type="reset" value="<?php echo lang("Clear"); ?>">
</TD>
<TD align=left>
<TD align="left">
<a href="<?php echo $phpgw->link($phpgw_info["server"]["webserver_url"] . "/addressbook/") . "\">" . lang("Cancel"); ?></a>
</TD>
</TR>

View File

@ -27,31 +27,33 @@
if (! $submit) {
$phpgw->db->query("SELECT * FROM addressbook WHERE ab_owner='"
. $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id");
. $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id");
$phpgw->db->next_record();
$fields = array('ab_id' => $phpgw->db->f("ab_id"),
'owner' => $phpgw->db->f("ab_owner"),
'access' => $phpgw->db->f("ab_access"),
'firstname' => $phpgw->db->f("ab_firstname"),
'lastname' => $phpgw->db->f("ab_lastname"),
'title' => $phpgw->db->f("ab_title"),
'email' => $phpgw->db->f("ab_email"),
'hphone' => $phpgw->db->f("ab_hphone"),
'wphone' => $phpgw->db->f("ab_wphone"),
'fax' => $phpgw->db->f("ab_fax"),
'pager' => $phpgw->db->f("ab_pager"),
'mphone' => $phpgw->db->f("ab_mphone"),
'ophone' => $phpgw->db->f("ab_ophone"),
'street' => $phpgw->db->f("ab_street"),
'address2' => $phpgw->db->f("ab_address2"),
'city' => $phpgw->db->f("ab_city"),
'state' => $phpgw->db->f("ab_state"),
'zip' => $phpgw->db->f("ab_zip"),
'bday' => $phpgw->db->f("ab_bday"),
'company' => $phpgw->db->f("ab_company"),
'company_id' => $phpgw->db->f("ab_company_id"),
'notes' => $phpgw->db->f("ab_notes")
$fields = array('ab_id' => $phpgw->db->f("ab_id"),
'owner' => $phpgw->db->f("ab_owner"),
'access' => $phpgw->db->f("ab_access"),
'firstname' => $phpgw->db->f("ab_firstname"),
'lastname' => $phpgw->db->f("ab_lastname"),
'title' => $phpgw->db->f("ab_title"),
'email' => $phpgw->db->f("ab_email"),
'hphone' => $phpgw->db->f("ab_hphone"),
'wphone' => $phpgw->db->f("ab_wphone"),
'fax' => $phpgw->db->f("ab_fax"),
'pager' => $phpgw->db->f("ab_pager"),
'mphone' => $phpgw->db->f("ab_mphone"),
'ophone' => $phpgw->db->f("ab_ophone"),
'street' => $phpgw->db->f("ab_street"),
'address2' => $phpgw->db->f("ab_address2"),
'city' => $phpgw->db->f("ab_city"),
'state' => $phpgw->db->f("ab_state"),
'zip' => $phpgw->db->f("ab_zip"),
'bday' => $phpgw->db->f("ab_bday"),
'company' => $phpgw->db->f("ab_company"),
'company_id' => $phpgw->db->f("ab_company_id"),
'notes' => $phpgw->db->f("ab_notes")
,
'url' => $phpgw->db->f("ab_url")
);
form("","edit.php","Edit",$fields);
@ -64,45 +66,47 @@
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$sql = "UPDATE addressbook set ab_email='" . addslashes($email)
. "', ab_firstname='". addslashes($firstname)
. "', ab_lastname='" . addslashes($lastname)
. "', ab_title='" . addslashes($title)
. "', ab_hphone='" . addslashes($hphone)
. "', ab_wphone='" . addslashes($wphone)
. "', ab_fax='" . addslashes($fax)
. "', ab_pager='" . addslashes($pager)
. "', ab_mphone='" . addslashes($mphone)
. "', ab_ophone='" . addslashes($ophone)
. "', ab_street='" . addslashes($street)
. "', ab_address2='" . addslashes($address2)
. "', ab_city='" . addslashes($city)
. "', ab_state='" . addslashes($state)
. "', ab_zip='" . addslashes($zip)
. "', ab_bday='" . addslashes($bday)
. "', ab_notes='" . addslashes($notes)
. "', ab_company_id='" . addslashes($company)
. "', ab_access='" . addslashes($access)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id";
. "', ab_firstname='" . addslashes($firstname)
. "', ab_lastname='" . addslashes($lastname)
. "', ab_title='" . addslashes($title)
. "', ab_hphone='" . addslashes($hphone)
. "', ab_wphone='" . addslashes($wphone)
. "', ab_fax='" . addslashes($fax)
. "', ab_pager='" . addslashes($pager)
. "', ab_mphone='" . addslashes($mphone)
. "', ab_ophone='" . addslashes($ophone)
. "', ab_street='" . addslashes($street)
. "', ab_address2='" . addslashes($address2)
. "', ab_city='" . addslashes($city)
. "', ab_state='" . addslashes($state)
. "', ab_zip='" . addslashes($zip)
. "', ab_bday='" . addslashes($bday)
. "', ab_notes='" . addslashes($notes)
. "', ab_company_id='" . addslashes($company)
. "', ab_access='" . addslashes($access)
. "', ab_url='" . addslashes($url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id";
} else {
$sql = "UPDATE addressbook set ab_email='" . addslashes($email)
. "', ab_firstname='". addslashes($firstname)
. "', ab_lastname='" . addslashes($lastname)
. "', ab_title='" . addslashes($title)
. "', ab_hphone='" . addslashes($hphone)
. "', ab_wphone='" . addslashes($wphone)
. "', ab_fax='" . addslashes($fax)
. "', ab_pager='" . addslashes($pager)
. "', ab_mphone='" . addslashes($mphone)
. "', ab_ophone='" . addslashes($ophone)
. "', ab_street='" . addslashes($street)
. "', ab_title='" . addslashes($title)
. "', ab_hphone='" . addslashes($hphone)
. "', ab_wphone='" . addslashes($wphone)
. "', ab_fax='" . addslashes($fax)
. "', ab_pager='" . addslashes($pager)
. "', ab_mphone='" . addslashes($mphone)
. "', ab_ophone='" . addslashes($ophone)
. "', ab_street='" . addslashes($street)
. "', ab_address2='" . addslashes($address2)
. "', ab_city='" . addslashes($city)
. "', ab_state='" . addslashes($state)
. "', ab_zip='" . addslashes($zip)
. "', ab_bday='" . addslashes($bday)
. "', ab_notes='" . addslashes($notes)
. "', ab_company='" . addslashes($company)
. "', ab_access='" . addslashes($access)
. "', ab_city='" . addslashes($city)
. "', ab_state='" . addslashes($state)
. "', ab_zip='" . addslashes($zip)
. "', ab_bday='" . addslashes($bday)
. "', ab_notes='" . addslashes($notes)
. "', ab_company='" . addslashes($company)
. "', ab_access='" . addslashes($access)
. "', ab_url='" . addslashes($url)
. "' WHERE ab_owner='" . $phpgw_info["user"]["account_id"] . "' AND ab_id=$ab_id";
}
@ -120,16 +124,16 @@
<input type="hidden" name="filter" value="<? echo $filter; ?>">
<input type="hidden" name="start" value="<? echo $start; ?>">
<TABLE border=0 cellPadding=1 cellSpacing=1 width="95%">
<TABLE border="0" cellPadding="1" cellSpacing="1" width="95%">
<TBODY>
<tr>
<TD align=left width=7%>
<TD align="left" width="7%">
<input type="submit" name="submit" value="<?php echo lang("Submit"); ?>">
</TD>
<TD align=left width=7%>
<TD align="left" width="7%">
<a href="<?php echo $phpgw->link("view.php","ab_id=$ab_id") . "\">" . lang("Cancel"); ?></a>
</TD>
<TD align=right>
<TD align="right">
<a href="<?php echo $phpgw->link("delete.php","ab_id=$ab_id") . "\">" . lang("Delete"); ?></a>
</TD>
</TR>

View File

@ -32,8 +32,7 @@
function form($format,$action,$title,$fields)
{
global $phpgw;
global $phpgw_info;
global $phpgw, $phpgw_info;
$email = $fields["email"];
$firstname = $fields["firstname"];
@ -56,6 +55,7 @@
$ab_company = $fields["company"];
$company_id = $fields["company_id"];
$company_name = $fields["company_name"];
$url = $fields["url"];
if ($format != "view") {
$email = "<input name=\"email\" value=\"$email\">";
@ -73,6 +73,8 @@
$city = "<input name=\"city\" value=\"$city\">";
$state = "<input name=\"state\" value=\"$state\">";
$zip = "<input name=\"zip\" value=\"$zip\">";
$url = "<input name=\"url\" value=\"$url\">";
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$company = '<select name="company">';
$phpgw->db->query("select company_id,company_name from customers order by company_name");
@ -186,13 +188,25 @@
</tr>
<tr>
<td><font color="#000000" face="" size="-1"><?php echo lang("Company Name"); ?>:</font></td>
<td>
<font size="-1">
<?php echo $company; ?>
</font></td>
<font color="#000000" face="" size="-1"><?php echo lang("Company Name"); ?>:</font>
</td>
<td>
<font size="-1">
<?php echo $company; ?>
</font>
</td>
<td>
<font color="#000000" face="" size="-1"><?php echo lang("URL"); ?>:</font>
</td>
<td>
<font size="-1">
<?php echo $url; ?>
</font>
</td>
<td><font size="-1"></font></td>
</tr>
<tr>
<td><font color="#000000" face="" size="-1"><?php echo lang("Home Phone"); ?>:</font></td>
<td>
@ -317,7 +331,7 @@
. ":</font></td><td colspan=\"3\"><select name=\"n_groups[]\" "
. "multiple size=\"5\">";
$user_groups = $phpgw->accounts->read_group_names($fields["owner"]);
$user_groups = $phpgw->accounts->read_group_names($fields["ab_owner"]);
for ($i=0;$i<count($user_groups);$i++) {
echo "<option value=\"" . $user_groups[$i][0] . "\"";
if (ereg(",".$user_groups[$i][0].",",$access))

View File

@ -163,6 +163,8 @@
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
echo '<tr bgcolor="#' . $tr_color . '">';
$ab_id = $phpgw->db->f("ab_id");
while ($column = each($columns_to_display)) {
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
if ($column[0] == "company") {
@ -174,46 +176,43 @@
$field = $phpgw->db->f("ab_" . $column[0]);
}
if (! $field) {
$field = "&nbsp;";
} else {
$field = htmlentities($field);
}
$field = htmlentities($field);
// Some fields require special formating.
if ($column[0] == "url") {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="' . $field . '" target="_top">' . $field. '</a></font></td>';
. '<a href="' . $field . '" target="_new">' . $field. '</a>&nbsp;</font></td>';
} else if ($column[0] == "email") {
if ($phpgw_info["user"]["apps"]["email"]) {
echo '<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="_top">' . $field . '</a></font></td>';
"to=" . urlencode($field)) . '" target="_top">' . $field . '</a>&nbsp;</font></td>';
} else {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. '<a href="mailto:' . $field . '" target="_top">' . $field. '</a></font></td>';
. '<a href="mailto:' . $field . '" target="_top">' . $field. '</a>&nbsp;</font></td>';
}
} else {
echo '<td valign="top"><font face="' . $phpgw_info["theme"]["font"] . '" size="2">'
. $field . '</font></td>';
. $field . '&nbsp;</font></td>';
}
}
reset($columns_to_display); // If we don't reset it, our inside while won't loop
?>
<td valign=top width=3%>
<font face=Arial, Helvetica, sans-serif size=2>
<a href="<?php echo $phpgw->link("view.php","ab_id=$ab_id&start=$start&order=$order&filter="
<td valign="top" width="3%">
<font face="<?php echo $phpgw_info["theme"]["font"]; ?>" size="2">
<a href="<?php echo $phpgw->link("view.php","ab_id=$ab_id&start=$start&order=$order&filter="
. "$filter&query=$query&sort=$sort");
?>"> <?php echo lang("View"); ?> </a>
</font>
</td>
<td valign=top width=5%>
<font face=Arial, Helvetica, sans-serif size=2>
<?php echo $phpgw->common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")); ?>
</font>
</td>
</tr>
<?php
</font>
</td>
<td valign="top" width="5%">
<font face="<?php echo $phpgw_info["theme"]["font"]; ?>" size="2">
<?php echo $phpgw->common->check_owner($phpgw->db->f("ab_owner"),"edit.php",lang("edit"),"ab_id=" . $phpgw->db->f("ab_id")); ?>
</font>
</td>
</tr>
<?php
}
?>

View File

@ -24,71 +24,78 @@
}
if ($filter != "private")
{
$filtermethod = " or ab_access='public' " . $phpgw->accounts->sql_search("ab_access");
}
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT * FROM addressbook as a, customers as c WHERE a.ab_company_id = c.company_id "
. "AND ab_id=$ab_id AND (ab_owner='"
. $phpgw_info["user"]["account_id"] . "' $filtermethod)");
if ($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT * FROM addressbook as a, customers as c WHERE a.ab_company_id = c.company_id "
. "AND ab_id=$ab_id AND (ab_owner='"
. $phpgw_info["user"]["account_id"] . "' $filtermethod)");
} else {
$phpgw->db->query("SELECT * FROM addressbook "
. "WHERE ab_id=$ab_id AND (ab_owner='"
$phpgw->db->query("SELECT * FROM addressbook WHERE ab_id=$ab_id AND (ab_owner='"
. $phpgw_info["user"]["account_id"] . "' $filtermethod)");
}
$phpgw->db->next_record();
$fields = array('ab_id' => $phpgw->db->f("ab_id"),
'owner' => $phpgw->db->f("ab_owner"),
'access' => $phpgw->db->f("ab_access"),
'firstname' => $phpgw->db->f("ab_firstname"),
'lastname' => $phpgw->db->f("ab_lastname"),
'title' => $phpgw->db->f("ab_title"),
'email' => $phpgw->db->f("ab_email"),
'hphone' => $phpgw->db->f("ab_hphone"),
'wphone' => $phpgw->db->f("ab_wphone"),
'fax' => $phpgw->db->f("ab_fax"),
'pager' => $phpgw->db->f("ab_pager"),
'mphone' => $phpgw->db->f("ab_mphone"),
'ophone' => $phpgw->db->f("ab_ophone"),
'street' => $phpgw->db->f("ab_street"),
'address2' => $phpgw->db->f("ab_address2"),
'city' => $phpgw->db->f("ab_city"),
'state' => $phpgw->db->f("ab_state"),
'zip' => $phpgw->db->f("ab_zip"),
'bday' => $phpgw->db->f("ab_bday"),
'company' => $phpgw->db->f("ab_company"),
'company_id' => $phpgw->db->f("ab_company_id"),
'company_name' => $phpgw->db->f("company_name"),
'notes' => $phpgw->db->f("ab_notes")
);
echo "<p>&nbsp;<b>" . lang("Address book - view") . "</b><hr><p>";
$owner = $phpgw->db->f("ab_owner");
$ab_id = $phpgw->db->f("ab_id");
form("view","","View",$fields);
$i = 0;
while ($column = each($abc)) {
if ($phpgw->db->f("ab_" . $column[0])) {
$columns_to_display[$i]["field_name"] = $column[1];
$columns_to_display[$i]["field_value"] = $phpgw->db->f("ab_" . $column[0]);
$i++;
}
}
echo '<table border="0" cellspacing="2" cellpadding="2" width="80%" align="center">';
for ($i=0;$i<200;) { // The $i<200 is only used for a brake
if (! $columns_to_display[$i]["field_name"]) break;
$columns_html .= "<tr><td><b>" . lang($columns_to_display[$i]["field_name"]) . "</b>:</td>"
. "<td>" . $columns_to_display[$i]["field_value"] . "</td>";
$i++;
if (! $columns_to_display[$i]["field_name"]) break;
$columns_html .= "<td><b>" . lang($columns_to_display[$i]["field_name"]) . "</b>:</td>"
. "<td>" . $columns_to_display[$i]["field_value"];
$i++;
$columns_html .= "</td></tr>";
}
$owner = $phpgw->db->f("ab_owner");
$access = $phpgw->db->f("ab_access");
echo $columns_html . '<tr><td colspan="4">&nbsp;</td></tr>';
echo "<tr><td><b>" . lang("Record owner") . "</b></td><td>"
. $phpgw->common->grab_owner_name($phpgw->db->f("ab_owner")) . "</td><td><b>"
. lang("Record Access") . "</b></td><td>";
if ($access != "private" && $access != "public") {
echo lang("Group access") . $phpgw->accounts->convert_string_to_names_access($access);
} else {
echo $access;
}
echo "</td></tr></table>";
?>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="95%">
<TBODY>
<TR>
<TD>
<TABLE border=0 cellPadding=1 cellSpacing=1>
<TBODY>
<TR>
<TD align=left>
<?php
echo $phpgw->common->check_owner($ab_id,$owner,"Edit");
?>
</TD>
<TD align=left>
<a href="<?php echo $phpgw->link("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort"); ?>">Done</a>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<TABLE border="0" cellpadding="1" cellspacing="1">
<TR>
<TD align="left">
<?php
echo $phpgw->common->check_owner($owner,"edit.php","Edit");
?>
</TD>
<TD align="left">
<a href="<?php echo $phpgw->link("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort"); ?>">Done</a>
</TD>
</TR>
</TABLE>
<?php
$phpgw->common->phpgw_footer();
?>