<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
include ("opendb.php");
$dt=date("Y-m-d");
$pcode=$_REQUEST['itemcd'];
	$pname=$_REQUEST['itemname'];
	$grp=$_REQUEST['grp'];
	$subgp=$_REQUEST['subgrp'];
	$bunit=$_REQUEST['bunit'];
	$rebtbl=$_REQUEST['rebtbl'];
	$rbtvl=$_REQUEST['rbtvl'];
	$reduction=$_REQUEST['reduction'];
	$prate=$_REQUEST['prate'];
	$srate=$_REQUEST['srate'];
	$opening=$_REQUEST['opening'];
	$location=$_REQUEST['location'];
	

$sql1="INSERT INTO partmaster(partcode,partname,gname,subgroup,activevl,unit,rbtbl,rbtvl,reduction) VALUES ('$pcode','$pname','$grp','$subgp','Y','$bunit','$rebtbl','$rbtvl','$reduction')";
			mysqli_query($db,$sql1) or die('Insert Err:'.mysqli_error($db));
			$sql2="insert into spareprmast(partcode,effectfrom,effectto,ndpcost,lstprice,brcode) values('$pcode','$dt','2099-12-31','$prate','$srate','$brcode')";
			
			mysqli_query($db,$sql2) or die('Insert Err1:'.mysqli_error($db));
			if($opening>0)
				{				

					mysqli_query($db,"insert into sparestock(itemcode,itemname,opstk,curstk,brcode,location,item_grp,item_subgrp,item_unit,item_active) values('$pcode','$pname','$opening','$opening','$brcode','$location','$grp','$subgp','Y','$bunit') ");
				}
?>
<div id="adnw_panel" class="itemalist" style="display:none;position: absolute;">
  <table  border='1' class='conf_tbl' style="border_collpase:collapse;background-color:white;  " width='100%'>
  
 	  <tr><th colspan=2>Added Item  <?echo $pcode;?>     <input type="button" value='x' id='close' onclick='updclose_div();'/></th></tr>

      
  </table>


</div>






