<?php
ob_start();
include("../connect.php");
$response = array();
if(isset($_POST['product_id']) && isset($_POST['category_id']) && isset($_POST['product_name']) && isset($_POST['hsn_code']) && isset($_POST['mrp']) && isset($_POST['product_price']) && isset($_POST['mAh_compatible']) && isset($_POST['warranty']) &&  isset($_POST['warranty_description']))
{
	$product_id=$_POST['product_id'];
	$category_id=$_POST['category_id'];
	$product_name=$_POST['product_name'];
	$hsn_code=$_POST['hsn_code'];
	$mrp=$_POST['mrp'];
	$product_price=$_POST['product_price'];
	$mAh_compatible=$_POST['mAh_compatible'];
	$warranty=$_POST['warranty'];
	$warranty_description=$_POST['warranty_description'];

	date_default_timezone_set('Asia/Calcutta');
	$tb_updatedatetime=date("Y-m-d H:i:s");
	
	$res="SELECT * FROM tbl_master_product WHERE product_id='$product_id'";
	$query=mysqli_query($con,$res);
	$row=mysqli_fetch_assoc($query);
	if(mysqli_num_rows($query)>0){
		
		$product_id=$_POST['product_id'];
		$category_id=$_POST['category_id'];
		$product_name=$_POST['product_name'];
		$hsn_code=$_POST['hsn_code'];
		$mrp=$_POST['mrp'];
		$product_price=$_POST['product_price'];
		$mAh_compatible=$_POST['mAh_compatible'];
		$warranty=$_POST['warranty'];
		$warranty_description=$_POST['warranty_description'];	
			
		$sql="update tbl_master_product set
					product_id='$product_id',
					category_id='$category_id',
					product_name='$product_name',
					hsn_code='$hsn_code',
					mrp='$mrp',
					product_price='$product_price',
					mAh_compatible='$mAh_compatible',
					warranty='$warranty',
					warranty_description='$warranty_description',
					tb_updatedatetime='$tb_updatedatetime'
					where product_id='$product_id'";
		$query2=mysqli_query($con,$sql);
		
		if($query2){
			$response['success']=1;
			$response['details']="Product Detail Updated Successfully!";
		}
		else{
			$response['success']=0;
			$response['details']="Product Detail Not Updated!";
		}
	}
}
else{
	$response['success']=0;
	$response['details']="Required fields missing";
}
echo json_encode($response);