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

		

$factory_obj   = new  ClientFactories();


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

	$sql="Select * from client_factories where clientfactoryid=$clientfactoryid";
			 $factorylist		=	$factory_obj->getClientFactories('',$sql);

		
		//print_r($factorydata);
		$factorydata = count($factorylist);
		//print_r($factorylist);
		for($i=0;$i<$factorydata;$i++)
	{
		$factoryaddress 		= $factorylist[$i]['factoryaddress'];
		$factoryaddressline2 = $factorylist[$i]['factoryaddressline2'];
		$factorycity 			= $factorylist[$i]['factorycity'];
		$factorypincode 		= $factorylist[$i]['factorypincode'];
		$factorygstno 			= $factorylist[$i]['factorygstno'];
		}
		
	if($_POST['SUBMIT'])
		{
			
			 	
				
				$factarray['clientfactoryid'] 				= $clientfactoryid;
				
				$factarray['factoryaddress'] 					= trim(sanitize($_POST['txtfactadd_'.$i],SQL));
				$factarray['factoryaddressline2'] 			= trim(sanitize($_POST['txtfactadd2_'.$i],SQL));
			
				$factarray['factorycity'] 						= trim(sanitize($_POST['txtfactcity_'.$i],SQL));
				$factarray['factorypincode'] 					= trim(sanitize($_POST['txtfactpin_'.$i],SQL));
				
				//$factarray['factorystate'] 					= $_POST['txtfactstate_'.$i];
				//$factarray['factorytelno'] 					= trim(sanitize($_POST['txtfacttel_'.$i],SQL));
				//$factarray['factoryfaxno'] 					= trim(sanitize($_POST['txtfactfax_'.$i],SQL));
				//$factarray['factoryemail'] 					= trim(sanitize($_POST['txtfactemail_'.$i],SQL));
				$factarray['factorygstno'] 					= trim(sanitize($_POST['txtfactgstno_'.$i],SQL));
				//print_r($factarray);
				$wherefactory = "clientfactoryid = ".$clientfactoryid."";
			
				$addfactory     = $factory_obj ->EditClientFactories($factarray,$wherefactory);
				require_once("edit-client.php");
			
		}
		
				
		
		
		require_once("edit-client-factories1.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;
}   

	
	
?>
