Location: PHPKode > projects > Mozart > Mozart-0.0.4/delcontact.php
<?
include("connect.inc");
include("reqlogin.inc");
include("userprefs.inc");
?>
<html>
<title>Mozart: Delete Contact</title>
<body bgcolor=<? echo $bgcolor ?> text=<? echo $txtcolor ?>>
<?
include("links.inc");
?>
The following has been selected for deletion:<br><br>
<?
$AddrPhoneSQL = "SELECT * FROM contact, address, phone WHERE contact_id=$id and contact_id = address.fk_contact_id AND contact_id = phone.fk_contact_id AND address_id = phone.fk_address_id"; 
$OtherPhoneSQL = "SELECT * FROM contact, phone WHERE contact_id=$id and contact_id = phone.fk_contact_id AND phone.fk_address_id = 0";
$AddrPhone = mysql_query($AddrPhoneSQL); 
$myrow = mysql_fetch_array($AddrPhone);

$typeid = $myrow["contact_type"];
$ContactTypeSQL = "SELECT type_name FROM types WHERE type_source = 'Contact' and type_id = '$typeid'";
$ContactType    = mysql_query($ContactTypeSQL);
$contactype     = mysql_fetch_array($ContactType);

printf("<i>%s %s %s</i><br>",
$myrow["first"], $myrow["middle"], $myrow["last"]); 
printf("<i>%s</i><br>", $contactype["type_name"]);
?>
<BR>
<?   
do {
  $typeid = $myrow["address_type"];
  $TypeSQL = "SELECT type_name FROM types WHERE type_source = 'Address' and type_id = '$typeid'";
  $Type    = mysql_query($TypeSQL);
  $type    = mysql_fetch_array($Type);

  printf("<b>%s</b>", $type["type_name"]);?><BR><?
  printf("%s", $myrow["street01"]);?><BR><?
  if ($myrow["street02"]) {
	printf("%s", $myrow["street02"]);?><BR><?
  }
  printf("%s, %s %s", $myrow["city"], $myrow["state"], $myrow["zip"]);
  ?><BR><?
  printf("%s", $myrow["number"]);
  ?><BR><BR><?
  }
  while ($myrow = mysql_fetch_array($AddrPhone));

?>
<b>Other</b><br>
<?
$OtherPhone = mysql_query($OtherPhoneSQL);
while ($myrow = mysql_fetch_array($OtherPhone)) {
  $typeid = $myrow["phone_type"];
  $TypeSQL = "SELECT type_name FROM types WHERE type_source = 'Phone' and type_id = '$typeid'";
  $Type    = mysql_query($TypeSQL);
  $type    = mysql_fetch_array($Type);
  printf("%s %s", $type["type_name"], $myrow["number"]);
  ?><BR><?
}
$NotesSQL = "SELECT information FROM notes WHERE type = 'Contact' AND fk_key = '$id'";
$Notes    = mysql_query($NotesSQL);
$notes    = mysql_fetch_array($Notes);
$note     = $notes["information"];
print("<br><b>Notes:</b> $note");
?>
<br><br>
This contact is associated with the following projects and events:<br><br>
<?
// get info from contxappt
$ContXApptSQL = "SELECT appt_id, information FROM appointment, contxappt WHERE appt_id = xappt_id AND xcont_id = '$id'"; 
$ContXAppt    = mysql_query($ContXApptSQL);
if ($contxappt = mysql_fetch_array($ContXAppt)) {
   print("Appointments affected:<br><br>");
   printf("<a href=\"updappt.php?id=%s\">%s</a>", $contxappt["appt_id"], $contxappt["information"]);
   while ($contxappt = mysql_fetch_array($ContXAppt)) {
      printf("<a href=\"updappt.php?id=%s\">%s</a>", $contxappt["appt_id"], $contxappt["information"]);
   }
}
// get info from contxproj
$ContXProjSQL = "SELECT proj_id, name FROM project, contxproj WHERE proj_id = xproj_id AND xcont_id = '$id'"; 
$ContXProj    = mysql_query($ContXProjSQL);
if ($contxproj = mysql_fetch_array($ContXProj)) {
   print("Projects affected:<br><br>");
   printf("<a href=\"projectdisplay.php?id=%s\">%s</a><br>", $contxproj["proj_id"], $contxproj["name"]);
   while ($contxproj = mysql_fetch_array($ContXProj)) {
      printf("<a href=\"projectdisplay.php?id=%s\">%s</a><br>", $contxproj["proj_id"], $contxproj["name"]);
   }
}
// get owner info from project
$ProjSQL = "SELECT proj_id, name FROM project WHERE owner = '$id'"; 
$Proj    = mysql_query($ProjSQL);
if ($proj = mysql_fetch_array($Proj)) {
   printf("<a href=\"projectdisplay.php?id=%s\">%s</a><br>", $proj["proj_id"], $proj["name"]);
   while ($proj = mysql_fetch_array($Proj)) {
      printf("<a href=\"projectdisplay.php?id=%s\">%s</a><br>", $proj["proj_id"], $proj["name"]);
   }
}
?>
<br><br>
Pressing Delete will <i>completely</i> remove this contact from the system.  Any projects or appointments listed could be orphaned as a result.<br><br>
<?
printf("<form action=\"deletecnt.php?id=%s\" method=\"post\">", $id);
?>
<input type="submit" value="Delete">
</form>
<?
include("links.inc");
?>
</body>
</html>
Return current item: Mozart