<?php 
session_start();
$id=$_SESSION['id'];
//$branch=2;	

include('../dist/includes/dbcon.php');

	$cid = $_POST['cid'];
	$cat = $_POST['cat'];
	$name = $_POST['prod_name'];
	$qty = $_POST['qty'];
	$meterko = $_POST['meterko'];
	$thick = 0;
	
	$colorb = $_POST['colorb'];
	
	$varko="";
	$da=1;
	
	
	if($meterko < 1){
		$meter=1;
		$radio = "";
	}else{
		$radio = $_POST['radio'];
		if($radio == "Feet"){
			$meter=$meterko / 3.280839895;
		}else{
			$meter=$meterko;
		}	
	}
	
	$query33=mysqli_query($con,"select * from product where prod_id='$name'")or die(mysqli_error());
	$row33=mysqli_fetch_array($query33);
	
	if($cat == 1){
		$query2=mysqli_query($con,"select * from product where prod_id='$name'")or die(mysqli_error());
		$row2=mysqli_fetch_array($query2);
		$mythick=$row2['prod_price'];	
	}
	if($cat == 2){
	$query22=mysqli_query($con,"select * from product where prod_id='$name'")or die(mysqli_error());
		$row22=mysqli_fetch_array($query22);
		$mythick=$row22['prod_price1']?? null;	
	}
	if($cat == 3){
	$query23=mysqli_query($con,"select * from product where prod_id='$name'")or die(mysqli_error());
		$row23=mysqli_fetch_array($query23);
		$mythick=$row23['prod_price2'];	
	}
	$tara=$mythick * $da;
	$prod_desc=$row33['prod_desc'];
	$prod_color=$row33['prod_color'];
	$colorko=$colorb;
	$branch=$row33['branch_id'];
	
	$query1=mysqli_query($con,"select * from temp_trans where prod_id='$name' and cust_id='$cid'")or die(mysqli_error());
		$count=mysqli_num_rows($query1);
		$game=$qty * $mythick;
		$game1=$game * $meter;
		if ($count>0){
			mysqli_query($con,"INSERT INTO temp_trans(prod_id,cust_id,qty,price,branch_id,hh,ww,variation,color,thick,status) VALUES('$name','$cid','$qty','$tara','$branch','$meter','$tara','$prod_desc','$colorko','$radio','$prod_color')")or die(mysqli_error($con));
		}
		else{
			mysqli_query($con,"INSERT INTO temp_trans(prod_id,cust_id,qty,price,branch_id,hh,ww,variation,color,thick,status) VALUES('$name','$cid','$qty','$tara','$branch','$meter','$tara','$prod_desc','$colorko','$radio','$prod_color')")or die(mysqli_error($con));
		}
		echo "<script>document.location='cash_transaction1.php?cid=$cid&cat=$cat'</script>";  		
	
?>