function ink_pur_sublist_validation()
{
   var invoice_no = document.getElementById("invoice_no").value;
	if(invoice_no=='')
	{
		document.getElementById("invoice_no_valid_div").innerHTML="* This field is Required.";
		document.getElementById("invoice_no").focus();
		return false;
	}
	 var sup_name = document.getElementById("sup_name").value;
	if(sup_name=='')
	{
		document.getElementById("supp_name_valid_div").innerHTML="* This field is Required.";
		document.getElementById("sup_name").focus();
		return false;
	}
	 var particulars = document.getElementById("particulars").value;
	if(particulars=='')
	{
		document.getElementById("particulars_valid_div").innerHTML="* This field is Required.";
		document.getElementById("particulars").focus();
		return false;
	}
	 var qty = document.getElementById("qty").value;
	if(qty=='')
	{
		document.getElementById("qty_valid_div").innerHTML="* This field is Required.";
		document.getElementById("qty").focus();
		return false;
	}
}

function mainlist_validation()
{	 
var total = document.getElementById("total").value;
	
	if((total=='')&&(total==0))
	{
		alert("Fill the sublist");
		document.getElementById("invoice_no").focus();
		return false;
	}
}

function ink_pur_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("invoice_no_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("supp_name_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("particulars_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("qty_valid_div").innerHTML="";
	}
}



function ink_pur_sub(ink_pur_no,ink_date,entrydates,invoice_no,sup_name,particulars,batch_no,uom,nos,qty,edit_id,action)
{ // alert(batch_no+','+uom+','+nos);
  console.log(batch_no+','+uom+','+nos);
	if((invoice_no!='')&&(sup_name!='')&&(particulars!='')&&(qty!=''))
	{
 jQuery.ajax({
		type: "POST",
		url: "consumable/ink_purchase/ink_pur_db.php",
		data: "ink_pur_no="+ink_pur_no+"&ink_date="+ink_date+"&entrydates="+entrydates+"&invoice_no="+invoice_no+"&sup_name="+sup_name+"&particulars="+particulars+"&batch_no="+batch_no+"&uom="+uom+"&nos="+nos+"&qty="+qty+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#ink_pur_sub_list_div").html(msg);
		document.getElementById("invoice_no").value = '';
                document.getElementById("sup_name").value = '';
                document.getElementById("particulars").value = '';
                document.getElementById("batch_no").value = '';
                document.getElementById("uom").value = '';
                document.getElementById("nos").value = '';
                document.getElementById("qty").value = '';
		
	
		document.getElementById('add').value='ADD';
		document.getElementById("entrydates").focus();	
 }
		});
	}
	else
	{
		ink_pur_sublist_validation();
	}
}


function inkpurchase_sublist_edit(edit_id,ink_pur_no)
{ 
  jQuery.ajax({
		type: "POST",
		url: "consumable/ink_purchase/ink_pur_sublist.php",
		data: "edit_id="+edit_id+"&ink_pur_no="+ink_pur_no,
		success: function(msg){jQuery("#ink_pur_sub_list_div").html(msg);

 }
		});
}


function delete_sublist_ink_pur(id,ink_pur_no,particulars,batch_no)
{
	//alert("id="+id+"&media_pur_no="+media_pur_no+"&action=del_media_sublist");
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
			type: "POST",
			url: "consumable/ink_purchase/ink_pur_db.php",
			data: {
				id: id,
				ink_pur_no: ink_pur_no,
				particulars: particulars,
				batch_no: batch_no,
				action: "del_media_sublist"
			},
			success: function(msg) {
				jQuery("#ink_pur_sub_list_div").html(msg);
				document.getElementById("entrydates").focus();
			}
		});
		
    }
}



function ink_purchase(ink_pur_no,ink_date,total,edit_id,action)
{ 
if((total!='')&&(total!=0))
{
	if(confirm('Are You Sure! You Want To Confirm?'))
	{ 
   jQuery.ajax({
		type: "POST",
		url: "consumable/ink_purchase/ink_pur_db.php",
		data: "ink_pur_no="+ink_pur_no+"&ink_date="+ink_date+"&total="+total+"&main_edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#ink_pur_list_div").html(msg);	
			if(edit_id!='')
			{
			window.location.href="main_fram.php?file=ink_purchase";
			}
			else
			{
		window.location.reload(true);
		    }
 }
		});
}
}
else
{
	mainlist_validation();
}
		
	
}


function check_farbic_f_emboss_or_not(in_jobcard_no_media) {
	getmediajobcard(in_jobcard_no_media);
	$.ajax({
		type: "POST",
		url: "consumable/media_entry/check_Fabric.php",
		data: "in_jobcard_no_media=" + in_jobcard_no_media,
		success: function (msg) {
			if (msg == 0){
				get_customer_medias(in_jobcard_no_media)
				get_created_by_media(in_jobcard_no_media)
				get_style_no_media(in_jobcard_no_media)
				get_customer_po_media(in_jobcard_no_media)
				get_style_name_media(in_jobcard_no_media)
				get_combo_media(in_jobcard_no_media)
				get_job_type_media(in_jobcard_no_media)
				get_fabric_types_media(in_jobcard_no_media)
				media_main_clear_validation(in_jobcard_no_media)
				
				get_particulars_media(in_jobcard_no_media)
				
			}
		}
	});
}





function get_customer_medias(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/customer_name.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#media_customer").html(msg);
	}
	});
}


function get_created_by_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/created_by.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#created_by_div").html(msg);
	}
	});
}

function get_style_no_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/style_no.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#style_no_div").html(msg);
	}
	});
}

function get_style_name_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/style_name.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#style_name_div").html(msg);
	}
	});
}

function get_customer_po_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/cust_po_no.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#customer_po_div").html(msg);
	}
	});
}


function get_combo_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/combo.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#combo_type_div").html(msg);
	}
	});
}


function get_job_type_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/job_type.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#job_types_div").html(msg);
	}
	});
}


function get_fabric_types_media(in_jobcard_no_media)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/media_entry/fabric_type.php",
		data: "in_jobcard_no_media="+in_jobcard_no_media,
		success: function(msg){jQuery("#fabric_type_div").html(msg);
	}
	});
}


function delete_ink_main_pur(ink_pur_no)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "consumable/ink_purchase/ink_pur_db.php",
		data: "ink_pur_no="+ink_pur_no+"&action=delete_media",
		success: function(msg){jQuery("#ink_pur_list_div").html(msg);
		window.location.reload(true);
	}
	});
    }
}



