<?php

include('config1.php');

$a = "";
$b = $_POST['product_name'];
$e = $_POST['purchase_qty'];
$f = $_POST['purchase_date'];
$g = $_POST['purchase_mfg_date'];
$h = $_POST['purchase_expr_date'];
$i = "purchase_doc1";
$j = "purchase_doc2";
$z = "purchase_doc3";


$sql = "INSERT INTO purchase (purchase_id,product_id,purchase_qty,purchase_date,purchase_mfg_date,purchase_expr_date,purchase_doc1,purchase_doc2,purchase_doc3) VALUES (:a,:b,:e,:f,:g,:h,:i,:j,:z)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':e'=>$e,':f'=>$f,':g'=>$g,':h'=>$h,':i'=>$i,':j'=>$j,':z'=>$z));


$sql_stock = "update product set product_size=product_size+$e where product_name='$b'";
$q_stock = $db->prepare($sql_stock);
$q_stock->execute(array(':b'=>$b,':e'=>$e));


header("location: add_purchase.php");
exit();


// query

?>