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

		
$obj  			= new Client();
$factory_obj   = new ClientFactories();
$branch_obj  	= new ClientBranches();
$objinfo  		= new AllTables();
//print_r($_GET);
		 $clientbranchid	= (int)($_GET['clientbranchid']);
	
	
	//get client factory address
	
$branchsql = "Select * from client_branches where clientbranchid=$clientbranchid";
					
				
	
		$brancharray	= $branch_obj -> getClientBranches('',$branchsql);
		$branchdata = count($brancharray);
		//print_r($brancharray);
		for($i=0;$i<$branchdata;$i++)
	{
		//print_r($brancharray);
		$branchaddress		= $brancharray[$i]['branchaddress'];		
		$branchaddressline2		= $brancharray[$i]['branchaddressline2'];
		$branchcity					= $brancharray[$i]['branchcity'];	
		$branchpincode				= $brancharray[$i]['branchpincode'];			
		$branchgstno				= $brancharray[$i]['branchgstno']; 				
		}
		
	if($_POST['SUBMIT'])
		{		
			
				
				$memberid 									= $_POST['txtmemberid'];
	 			//$clientbranchid 									= $_POST['txtclientbranchid'];
				$branclist['clientbranchid'] 			= $clientbranchid;
				$branclist['branchaddress'] 			= trim(sanitize($_POST['txtbranchadd_'.$i],SQL));
				$branclist['branchaddressline2'] 		= trim(sanitize($_POST['txtbranchadd2_'.$i],SQL));
				
				$branclist['branchcity'] 				= trim(sanitize($_POST['txtbranchcity_'.$i],SQL));
				$branclist['branchpincode'] 			= trim(sanitize($_POST['txtbranchpin_'.$i],SQL));
				
				$branclist['branchgstno'] 				= trim(sanitize($_POST['txtbranch_gstno_'.$i],SQL));
				$wherecondition ="clientbranchid =".$clientbranchid."";
				
				$edit_branch = $branch_obj -> EditClientBranches($branclist,$wherecondition);
				//die();
			 	require_once("edit-client.php");
		}	
		
				
		
		
		require_once("edit-client-branches1.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;
}   

	
	
?>
