<?php include 'inc_classes.php';
$product_id = $_POST['product_id'];
$employee_id=$_POST['employee_id'];
if($product_id)
{
    $select_details="select * from order_list_map where product_id='".$product_id."' and employee_id='".$employee_id."' order by order_list_map_id desc limit 0,1 ";
	$ptr_details=mysql_query($select_details);
	$data_products=mysql_fetch_array($ptr_details);
	
	$sel_prod_details="select quantity_in_consumable from product_user_map where product_id='".$product_id."' and user_id='".$employee_id."'";
	$ptr_prod_details=mysql_query($sel_prod_details);
	$data_prod_details=mysql_fetch_array($ptr_prod_details);
	
	$sel_prod_consumed="select SUM(consume_qty) as consume_qty from consumption_map where product_id='".$product_id."' and employee_id='".$employee_id."' and added_date >= '".$data_products['added_date']."' ";
	$ptr_prod_consumed=mysql_query($sel_prod_consumed);
	$data_prod_consumed=mysql_fetch_array($ptr_prod_consumed);
	
	$sel_batch="select s.enroll_id from course_batch_mapping c,student_course_batch_map s where'".date('Y-m-d')."' >=DATE(c.start_date) and '".date('Y-m-d')."'<=DATE(c.end_date) and c.c_b_id=s.c_b_id and c.staff_id='".$employee_id."' ";
	$ptr_batch=mysql_query($sel_batch);
	$total_student=mysql_num_rows($ptr_batch);
	
	$sel_invs="SELECT ip.inventory_id,i.vendor_id FROM inventory_product_map ip,inventory i where ip.product_id='".$product_id."' and ip.inventory_id=i.inventory_id order by ip.map_id desc limit 0,1 ";	 
	$query_invs=mysql_query($sel_invs);
	$data_invs=mysql_fetch_array($query_invs);
	if($data_invs['vendor_id'] > 0)
	{
		$vendor_ids=$data_invs['vendor_id'];
	}
	else
	{
		$sl_ven="select vendor_id from product_vendor_map where product_id='".$product_id."'";
		$ptr_ven=mysql_query($sl_ven);
		$data_vens=mysql_fetch_array($ptr_ven);
		
		$vendor_ids=$data_vens['vendor_id'];
	}
	echo $data_products['added_date']."#".$data_products['qty_from_qm']."#".$data_prod_details['quantity_in_consumable']."#".$data_prod_consumed['consume_qty']."#".$total_student."#".$vendor_ids;
}