function ink_entry_sublist_validation()
{
   var shift_time = document.getElementById("shift_time").value;
	if(shift_time=='')
	{
		document.getElementById("shift_time_validation_inkent_div").innerHTML="* This field is Required.";
		document.getElementById("shift_time").focus();
		return false;
	}
	 var machine_no = document.getElementById("machine_no").value;
	if(machine_no=='')
	{
		document.getElementById("machine_no_validation_inkent_div").innerHTML="* This field is Required.";
		document.getElementById("machine_no").focus();
		return false;
	}
	 var operator_name = document.getElementById("operator_name").value;
	if(operator_name=='')
	{
		document.getElementById("operator_name_validation_inkent_div").innerHTML="* This field is Required.";
		document.getElementById("operator_name").focus();
		return false;
	}
	 var prod_size = document.getElementById("prod_size").value;
	if(prod_size=='')
	{
		document.getElementById("prod_size_validation_inkent_div").innerHTML="* This field is Required.";
		document.getElementById("prod_size").focus();
		return false;
	}
	
}
function ink_entry_clear_sub_validation(str)
{
	if(str!='')
	{
		document.getElementById("shift_time_validation_inkent_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("machine_no_validation_inkent_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("operator_name_validation_inkent_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("prod_size_validation_inkent_div").innerHTML="";
	}
	// if(str!='')
	// {
	// 	document.getElementById("tota_validation_inkent_div").innerHTML="";
	// }
}
function get_total_ink_roll(roll_name) {
     
    var batch_no = $("#batch_no").val();
   // alert(batch_no);
    jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/tot_qty_hid_ink.php",
		data: "roll_name="+roll_name+"&batch_no="+batch_no,
		success: function(msg){ 
		    //alert(msg);
		    jQuery("#tot_qty_hid_ink").val(msg); 
	    }
	});

	jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/tot_qty_hid_ink1.php",
		data: "roll_name="+roll_name+"&batch_no="+batch_no,
		success: function(msg){ 
		    //alert(msg);
		    jQuery("#tot_qty_hid_ink1").val(msg); 
	    }
	});

}

function ink_entry_sublist(ink_entry_no,ink_date,shift_time,machine_no,operator_name,prod_size,batch_no,total_req,tot_qty_hid_ink,tot_qty_hid_ink1,edit_id,action)
{	
	//  alert(tot_qty_hid_ink);
	//  alert(tot_qty_hid_ink1);

	 var totl=tot_qty_hid_ink - tot_qty_hid_ink1;
	//  alert(totl);
	// alert(total_req);
	var t1 = parseFloat(tot_qty_hid_ink1);
	var t2 = parseFloat(total_req);
    var total_meeter_run = t1+t2;
	
// alert(total_meeter_run);
// exit();

if((shift_time!='')&&(machine_no!='')&&(operator_name!='')&&(prod_size!=''))
{
	if(parseFloat(total_meeter_run)<=parseFloat(tot_qty_hid_ink)){
	// &&(parseFloat(total_qty)<=parseFloat(balance))&&(total_qty!=0)

jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/ink_entry_db.php",
		data: "ink_entry_no="+ink_entry_no+"&ink_date="+ink_date+"&shift_time="+shift_time+"&machine_no="+machine_no+"&operator_name="+operator_name+"&prod_size="+prod_size+"&batch_no="+batch_no+"&total_req="+total_req+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#ink_sub_list_div").html(msg);
        document.getElementById("shift_time").value='';
		document.getElementById("machine_no").value='';
		document.getElementById("operator_name").value='';
		document.getElementById("prod_size").value='';
		document.getElementById("batch_no").value='';
		document.getElementById("total_req").value='';
		document.getElementById('add').value='ADD';
		document.getElementById("shift_time").focus();	
 }
		});



	}
	else{
		alert("Total Req should less then Batch No Qty is "+totl);
	// document.getElementById("media_paln_qty_validation_div").innerHTML="";
	}

}
	
else
{
	ink_entry_sublist_validation();
}


}


function inkent_sublist_edit(edit_id,ink_entry_no)
{
	
  jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/ink_sublist.php",
		data: "edit_id="+edit_id+"&ink_entry_no="+ink_entry_no,
		success: function(msg){jQuery("#ink_sub_list_div").html(msg);

 }
		});
}



function del_ink_sub(id,ink_entry_no)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/ink_entry_db.php",
		data: "id="+id+"&ink_entry_no="+ink_entry_no+"&action=del_ink_sublist",
		success: function(msg){jQuery("#ink_sub_list_div").html(msg);
	}
	});
    }
}


function ink_main_list(ink_entry_no,ink_date,tot_prod,tot_bal,edit_id,action)
{ 

	if(tot_prod!=0.00)
	{
		if(confirm('Are You Sure! You Want To Confirm?'))
	{ 
   jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/ink_entry_db.php",
		data: "ink_entry_no="+ink_entry_no+"&ink_date="+ink_date+"&tot_prod="+tot_prod+"&tot_bal="+tot_bal+"&main_edit_id="+edit_id+"&action="+action,
		success: function(msg){
		    alert(msg);
		  //console.log(msg);
		   // jQuery("#ink_main_div").html(msg);	
			if(edit_id!='')
			{
			window.location.href="main_fram.php?file=ink_entry";
			}
			else
			{
		window.location.reload(true);
		    }
 }
		});
	}
}
else
{alert("Please fill the sublist");
document.getElementById("shift_time").focus();	
}
}


function delete_ink_main(ink_entry_no)
{
	
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/ink_entry_db.php",
		data: "ink_entry_no="+ink_entry_no+"&action=del_main",
		success: function(msg){jQuery("#ink_main_div").html(msg);
		//window.location.reload(true);
	
	}
	});
    }
}
function get_tot_qty(particular)
{
  jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/qty.php",
		data: "particular="+particular,
		success: function(msg){
		    jQuery("#total_qty").val(msg);
		    jQuery("#balance").val(msg);
		   // document.getElementById("total_qty").value = msg; 
           // document.getElementById("balance").value = msg;
		   // jQuery("#ink_entry_qty_div").html(msg);

 }
		});
}
function get_batchno(particular)
{ 
  jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/batch_no.php",
		data: "particular="+particular,
		success: function(msg){
		  //  jQuery("#total_qty").val(msg);
		  //  jQuery("#balance").val(msg);
		   // document.getElementById("total_qty").value = msg; 
           // document.getElementById("balance").value = msg;
		    jQuery("#ink_entry_batchno_div").html(msg);

 }
		});
}
function get_batchno_detail(batchno)
{ 
	// alert(batchno);
  jQuery.ajax({
		type: "POST",
		url: "consumable/ink_entry/batchno_details.php",
		data: "batchno="+batchno,
		success: function(msg){
		    var data = JSON.parse(msg); 
           // document.getElementById("total_req").value = data.total_req; 
           // document.getElementById("nos").value = data.nos;
		    // jQuery("#total_req").val(data.total_req);
		    // jQuery("#nos").val(data.nos);
		   // document.getElementById("total_qty").value = msg; 
           // document.getElementById("balance").value = msg;
		  //  jQuery("#ink_entry_batchno_div").html(msg);

 }
		});
}