
function media_pur_sublist_validation()
{
   var invoice_no = document.getElementById("invoice_no").value;
	if(invoice_no=='')
	{
		document.getElementById("invoice_no_media_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_media_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_media_valid_div").innerHTML="* This field is Required.";
		document.getElementById("particulars").focus();
		return false;
	}
	 var qty = document.getElementById("qty").value;
	if(qty=='')
	{
		document.getElementById("qty_media_valid_div").innerHTML="* This field is Required.";
		document.getElementById("qty").focus();
		return false;
	}
	 var mtr_roll = document.getElementById("mtr_roll").value;
	if(mtr_roll=='')
	{
		document.getElementById("mtr_roll_media_valid_div").innerHTML="* This field is Required.";
		document.getElementById("mtr_roll").focus();
		return false;
	}
}



function get_tot_mtr(qty,mtr_roll)
{
	 var hmtr=qty*mtr_roll;

document.getElementById("tot_mtr").value=hmtr;
}


function media_pur_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("invoice_no_media_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("supp_name_media_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("particulars_media_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("qty_media_valid_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("mtr_roll_media_valid_div").innerHTML="";
	}
	
}



function media_pur_sub(media_pur_no,media_date,entrydates,invoice_no,sup_name,particulars,batch_no,qty,mtr_roll,tot_mtr,edit_id,action)
{ //alert(batch_no);
	
if((invoice_no!='')&&(sup_name!='')&&(particulars!='')&&(batch_no!='')&&(qty!='')&&(mtr_roll!=''))
{
 jQuery.ajax({
		type: "POST",
		url: "consumable/media_purchase/media_pur_db.php",
		data: "media_pur_no="+media_pur_no+"&media_date="+media_date+"&entrydates="+entrydates+"&invoice_no="+invoice_no+"&sup_name="+sup_name+"&particulars="+particulars+"&batch_no="+batch_no+"&qty="+qty+"&mtr_roll="+mtr_roll+"&tot_mtr="+tot_mtr+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){ 
			jQuery("#media_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("qty").value='';
		document.getElementById("mtr_roll").value='';
		document.getElementById("tot_mtr").value='';
	
		document.getElementById('add').value='ADD';
		document.getElementById("entrydates").focus();	
 }
		});
}
else
{media_pur_sublist_validation();
}
}


function mediapurchase_sublist_edit(edit_id,media_pur_no)
{ 
	
  jQuery.ajax({
		type: "POST",
		url: "consumable/media_purchase/media_pur_sublist.php",
		data: "edit_id="+edit_id+"&media_pur_no="+media_pur_no,
		success: function(msg){
			jQuery("#media_pur_sub_list_div").html(msg);

 }
		});
}


function delete_sublist_media_pur(id, media_pur_no, particularss, batch_no) {
    if (confirm('Are You Sure! You Want To Delete?')) {
        jQuery.ajax({
            type: "POST",
            url: "consumable/media_purchase/media_pur_db.php",
            data: {
                id: id,
                media_pur_no: media_pur_no,
                particulars: particularss,
                batch_no: batch_no,
                action: "del_media_sublist"
            },
            success: function(msg) {
                jQuery("#media_pur_sub_list_div").html(msg);
                document.getElementById("entrydates").focus();
            }
        });
    }
}




function media_purchase(media_pur_no,media_date,total,edit_id,action)
{
	if(total!=0.00)
{
	if(confirm('Are You Sure! You Want To Confirm?'))
	{ 
   jQuery.ajax({
		type: "POST",
		url: "consumable/media_purchase/media_pur_db.php",
		data: "media_pur_no="+media_pur_no+"&media_date="+media_date+"&total="+total+"&main_edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#media_pur_list_div").html(msg);	
			if(edit_id!='')
			{
			window.location.href="main_fram.php?file=media_purchase";
			}
			else
			{
		window.location.reload(true);
		    }
 }
		});
}
}
else
{
	alert("Please fill the sublist");
	document.getElementById("entrydates").focus();	
}
}
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 edit_media_pur_main(edit_id,jobcard_no)
{
window.location.href="main_fram.php?file=media_purchase&edit_id=" + edit_id + "&jobcard_no=" + jobcard_no;
}
function del_media_pur_main(media_pur_no)
{
	//(jobcard_no);
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "consumable/media_purchase/media_pur_db.php",
		data: "media_pur_no="+media_pur_no+"&action=delete_media",
		success: function(msg){ //alert(msg);
			jQuery("#media_pur_list_div").html(msg);
		window.location.reload(true);
	}
	});
    }
}


