<?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 Company();
$factory_obj   = new Factories();
$branch_obj  	= new Branches();
$objinfo  		= new AllTables();
//print_r($_GET);
		 $memberbranchid	= (int)($_GET['memberbranchid']);
	
	
	//get client factory address
	$branch_obj			=	new Branches();
$branchsql = "Select * from member_branches where memberbranchid=$memberbranchid";
					
				
	
		$brancharray	= $branch_obj -> getBranches('',$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'])
		{		
			
				$branclist['memberbranchid'] 			= $memberbranchid;
				$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 ="memberbranchid =$memberbranchid";
				$edit_branch = $branch_obj -> EditBranches($branclist,$wherecondition);
			 	require_once("edit-company.php");
		}	
		
				
		
		
		require_once("edit-mycompany-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;
}   

	
	
?>
