/********************************** Validation *******************************************************/
function consumable_validation()
{
	
    var item_name = document.getElementById("item_name").value;
	if(item_name=='')
	{
		document.getElementById("consumable_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("item_name").focus();
		return false;
	}
	
	 var particulars = document.getElementById("particulars").value;
	if(particulars=='')
	{
		//alert();
		document.getElementById("consumable_particulas_validation_div").innerHTML="* This field is Required.";
		document.getElementById("particulars").focus();
		return false;
	}
	
	
	
}

function consumable_validation_clear(str)
{
	if(str!='')
	{
		document.getElementById("consumable_name_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("consumable_particulas_validation_div").innerHTML="";
	}
	
	
	
	
}

/********************************** Mainlist Add *******************************************************/
function consumable_mainlist_add(item_name,particulars,description,status_type,edit_id,action)
{  
  //alert(item_name);
if((item_name!='')&&(particulars!=''))
 {
    jQuery.ajax({
		type: "POST",
		url: "consumable_entry_db.php",
		data: "item_name="+item_name+"&particulars="+particulars+"&description="+description+"&status_type="+status_type+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#consumable_list_div").html(msg);	
		alert(msg);
		window.close();
		window.opener.location.reload(true);
 }
		});
 }
else
{
    consumable_validation();
}
}

/********************************** Mainlist Delete *******************************************************/
function consumable_delete(id)
{
	
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "consumable_creation/consumable_entry_db.php",
		data: "id="+id+"&action=delete",
		success: function(msg){jQuery("#consumable_list_div").html(msg);
		
				window.opener.location.reload(true);

	}
	});
    }
}


