Location: PHPKode > projects > O - OpenSource GroupWare > osgw/contacts/index.php
<?php
/**************************************************************************
   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.

   @Authors:	Ryan Thompson(hide@address.com)
***************************************************************************/

include("./data.php");
$service['add_header'] = TRUE;
include("../config.inc.php");

include($here. "/class.contacts.php");
$ct = new contacts;
echo $layout->page_header;
echo $layout->service_header($ct->msg('service_name'), $ct->nav_buttons());

if(isset($_POST['confirm_delete']))
{
	
	$delete = explode(":", $_POST['delete_values']);
	$ct->delete($delete);	
}
if(isset($_POST['delete_contacts']))
{
	
	echo $html->delete_confirm($O->create_link('/contacts/index.php'), 'ct', $_POST['delete']);
} else {


	echo "<p>";
	if($error->buffer)
	{
		echo $error->display();
	}

	echo $filters = $ct->get_filters();

	$link = $_SERVER['PHP_SELF'];

	if($_GET['filter'] == "All")
	{
		unset($_GET['filter']);
	}
	$sql = "SELECT o_contacts.*, o_countries.country FROM o_contacts 
		LEFT JOIN o_countries ON o_contacts.country=o_countries.c_id 
		WHERE o_contacts.user_id='". $user->user_id ."'";

		if(isset($_GET['filter']) & $_GET['filter'] != "All")
	{
		$filter = $_GET['filter'];
 		$sql .= " AND lastname LIKE '$filter%'";
		$link .= "?filter=". $_GET['filter'];
	} 

	$sql .= " ORDER BY lastname";

	$db->query($sql);
	
	if($db->num_rows > 0)
	{

		echo $buffer = $html->create_list(
		$replace_header = array("STYLE"=>'list_header',"FORM_LINK"=>$link),
		$O->dir ."/contacts/html/header.html");


		while($db->fetch_results())
		{
		
			$class = $html->list_class($class);
	
			echo $buffer = $html->create_list(
				$replace_header = array(
					"STYLE"=>$class,
					"CONTACT_ID" => $db->record['address_id'],
					"CONTACT"=>$O->create_link("/contacts/edit_contact.php?id=". $db->record['address_id'],
						$db->record['lastname']. ", ". $db->record['firstname'],$class),
					"CITY"=>$db->record['city'],
					"COUNTRY"=>$db->record['country'],
					"PHONE_NUMBER"=>$db->record['phone'],
					"EMAIL"=>"<a href=\"mailto:". $db->record['email'] ."\" class=\"$class\">". $db->record['email'] ."</a>"),
						$O->dir ."/contacts/html/list.html");
			
		}
	echo $buffer = $html->create_list(
		$replace_header = array(
		"DELETE_CONTACTS"=>$ct->msg('delete_contacts')),
		$O->dir ."/contacts/html/footer.html");

	} else {
		echo "<p>You have no contacts saved.</p>";
	}

}
	echo $layout->create_footer();
?>
Return current item: O - OpenSource GroupWare