<?php
require_once("../include/config.php");
require_once("../include/startup.php");
	
if($G_memberid > 0)
{
		require_once("header1.html");
		require_once("leftnav.html");

		

$Contact_obj   = new  ClientContacts();


//print_r($_GET);
		 $clientcontactid 	= (int)($_GET['clientcontactid']);
	
	

	$sql="Select * from client_contacts where clientcontactid=$clientcontactid";
			 $contactlist		=	$Contact_obj->getClientContacts('',$sql);

		
		//print_r($factorydata);
		$contactdata = count($contactlist);
		//print_r($contactlist);
		for($i=0;$i<$contactdata;$i++)
	{
		$contact_parson_name 		= $contactlist[$i]['contact_parson_name1'];
		$contact_telno = $contactlist[$i]['contact_telno'];
		$contactfaxno 			= $contactlist[$i]['contactfaxno'];
		$contactmob 		= $contactlist[$i]['contactmob'];
		$contactemail 			= $contactlist[$i]['contactemail'];
		$contactwebaddress 			= $contactlist[$i]['contactwebaddress'];
		$clientcontactids 			= $contactlist[$i]['clientcontactid'];
		}
		
	if($_POST['SUBMIT'])
		{
			
			 	//echo"<pre>";
			 	//print_r($_POST);
			 	//die();
				
				$contactarray['clientcontactid'] 				= $clientcontactid;
				
				$contactarray['contact_parson_name1'] 					= sanitize($_POST['txtclientname_'.$i],SQL);
				$contactarray['contact_telno'] 			= trim(sanitize($_POST['txthead_TelNo_'.$i],SQL));
			
				$contactarray['contactfaxno'] 						= trim(sanitize($_POST['head_FaxNo_'.$i],SQL));
				//$contactarray['factorypincode'] 					= trim(sanitize($_POST['txtfactpin_'.$i],SQL));
				
				//$contactarray['factorystate'] 					= $_POST['txtfactstate_'.$i];
				//$contactarray['factorytelno'] 					= trim(sanitize($_POST['txtfacttel_'.$i],SQL));
				//$contactarray['factoryfaxno'] 					= trim(sanitize($_POST['txtfactfax_'.$i],SQL));
				//$contactarray['factoryemail'] 					= trim(sanitize($_POST['txtfactemail_'.$i],SQL));
				$contactarray['contactmob'] 					= trim(sanitize($_POST['head_mobNo_'.$i],SQL));
				$contactarray['contactemail'] 					= trim(sanitize($_POST['head_Email_'.$i],SQL));
				$contactarray['contactwebaddress'] 					= trim(sanitize($_POST['txtWebsite_'.$i],SQL));
				//$contactarray['contactmob'] 					= trim(sanitize($_POST['txtfactgstno_'.$i],SQL));
				//print_r($contactarray);
				$wherecontact = "clientcontactid = ".$clientcontactid."";
			
				$addcontact     = $Contact_obj ->EditClientContacts($contactarray,$wherecontact);
				require_once("edit-client.php");
			
		}
		
				
		
		
		require_once("edit-client-contacts1.html");
		require_once("footer1.html");


}
else if (!headers_sent($filename, $linenum)) 
{
				$redirect_url = DOC_ROOT."login.php";
				header("Location: $redirect_url");
    				exit;
					// You would most likely trigger an error here.
}
else 
{
				echo "Headers already sent in $filename on line $linenum\n" .
          			"Cannot redirect, for now please click this <a ";
    				exit;
}   

	
	
?>
