<?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 = $_POST['thick'];
	$colorb = $_POST['colorb'];
	if($meterko < 1){
		$meter=1;
	}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'];	
	}
	
	$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) VALUES('$name','$cid','$qty','$mythick','$branch','$meter','$mythick','$prod_desc','$colorko','$thick')")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) VALUES('$name','$cid','$qty','$mythick','$branch','$meter','$mythick','$prod_desc','$colorko','$thick')")or die(mysqli_error($con));
		}

	
		echo "<script>document.location='cash_transaction1.php?cid=$cid&cat=$cat'</script>";  

		

		
	
?>