<?php
include('config.php');
include('code.php');
$name=$_SESSION['admin_name'];
$bcode=$_SESSION['branchcode'];


if(isset($_GET['cash']))
$cash=$_GET['cash'];
$pos=$_GET['pos'];
$trans=$_GET['trans'];
if(isset($_GET['bcode']))
$bcode=$_GET['bcode'];
if(isset($_GET['customer']))
$customer=$_GET['customer'];
if(isset($_GET['mode']))
$mode=$_GET['mode'];
$date=date('Y-m-d');
$mon=date('m');
$yr=date('Y');
$teller=rand(0,7729);
$sql =$link->query("select * from cart where BranchCode='$bcode' and code='$code' and officer='$name'");
	while($reply = mysql_fetch_array($sql)){
			$code=$reply['code'];
			$name=$reply['name'];
			$name=$reply['name'];
			$quan=$reply['quantity'];
			$price=$reply['price'];
			$admin=$reply['officer'];
		$sql2 =$link->query("insert into invoice values('NULL', '$bcode','$teller','$date','$code','$name','$quan','$price',$mon,$yr,'$admin')");	
		}

	$sql3 =$link->query("insert into payment values('NULL', '$bcode','$date','$teller','$customer','$mode','$cash',$mon,$yr,'$admin')");
	$sql4 =$link->query("insert into payment values('NULL', '$bcode','$date','$teller','$customer','$mode','$pos',$mon,$yr,'$admin')");
	$sql5 =$link->query("insert into payment values('NULL', '$bcode','$date','$teller','$customer','$mode','$trans',$mon,$yr,'$admin')");
					if($mode=="Cash"){
					$sql4 =$link->query("insert into cashbook values('NULL', '$bcode','$date','$teller','$customer','$amnt','0','0','0',$mon,$yr,'$admin')");
					$sql7 =$link->query("insert into journal values('NULL', '$bcode','$date','100','Cash Account','0','$amnt',$mon,$yr,'$admin')");
					$sql8 =$link->query("insert into journal values('NULL', '$bcode','$date','101','Sales Account','$amnt','0',$mon,$yr,'$admin')");
					
					}else{
						$sql5 =$link->query("insert into cashbook values('NULL', '$bcode','$date','$teller','$customer','0','$amnt','0','0',$mon,$yr,'$admin')");
						$sql6 =$link->query("insert into bcashbook values('NULL', '$bcode','$date','$teller','$customer','$amnt','0','0',$mon,$yr,'$admin')");
						$sql9 =$link->query("insert into journal values('NULL', '$bcode','$date','100','Cash Account','0','$amnt',$mon,$yr,'$admin')");
						$sql10 =$link->query("insert into journal values('NULL', '$bcode','$date','101','Sales Account','$amnt','0',$mon,$yr,'$admin')");
						}

?>