// JavaScript Document

/*************************************validation********************************/
function samp_jobcard_validation()
{
    var customer_name = document.getElementById("customer_name").value;
	if(customer_name=='')
	{
		document.getElementById("samp_customer_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("customer_name").focus();
		return false;
	}
	
	var designer = document.getElementById("designer").value;
	if(designer=='')
	{
		document.getElementById("designer_validation_div").innerHTML="* This field is Required.";
		document.getElementById("designer").focus();
		return false;
	}
	var designer_name = document.getElementById("designer_name").value;
	if(designer_name=='')
	{
		document.getElementById("designer_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("designer_name").focus();
		return false;
	}
	var color_profile = document.getElementById("color_profile").value;
	if(color_profile=='')
	{
		document.getElementById("color_profile_validation_div").innerHTML="* This field is Required.";
		document.getElementById("color_profile").focus();
		return false;
	}
	var net_amt = document.getElementById("net_amt").value;
	if(net_amt==0.00)
	{
	alert("Please Fill the sublist");
		document.getElementById("particulars").focus();
		return false;
	}
	
}

/*************************************validation********************************/
function sample_jobcard_sub_validation()
{
    var customer_name = document.getElementById("customer_name").value;
	if(customer_name=='')
	{
		document.getElementById("samp_customer_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("customer_name").focus();
		return false;
	}
	 var particulars = document.getElementById("particulars").value;
	if(particulars=='')
	{
		document.getElementById("sampbook_particulars_valid_div").innerHTML="* This field is Required.";
		document.getElementById("particulars").focus();
		return false;
	}
	var jobcard_width = document.getElementById("jobcard_width").value;
	if(jobcard_width=='')
	{
		document.getElementById("sampbook_width_valid_div").innerHTML="* This field is Required.";
		document.getElementById("jobcard_width").focus();
		return false;
	}
	var jobcard_height = document.getElementById("jobcard_height").value;
	if(jobcard_height=='')
	{
		document.getElementById("sampbook_height_valid_div").innerHTML="* This field is Required.";
		document.getElementById("jobcard_height").focus();
		return false;
	}
	var inch = document.getElementById("inch").value;
	if(inch=='')
	{
		document.getElementById("sampbook_inch_valid_div").innerHTML="* This field is Required.";
		document.getElementById("inch").focus();
		return false;
	}
	var qty = document.getElementById("qty").value;
	if(qty=='')
	{
		document.getElementById("sampbook_qty_valid_div").innerHTML="* This field is Required.";
		document.getElementById("qty").focus();
		return false;
	}
	
}
/*************************************validation********************************/


function samp_jobcard_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("samp_customer_name_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("designer_validation_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("designer_name_validation_div").innerHTML="";
	}
	if(str!='')
	{
		document.getElementById("color_profile_validation_div").innerHTML="";
	}
	
}
/************************************validation*********************************/

function sampjobcard_sub_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("samp_customer_name_validation_div").innerHTML="";
	}
	
	if(str!='')
	{
		document.getElementById("sampbook_particulars_valid_div").innerHTML="";
	}
		if(str!='')
	{
		document.getElementById("sampbook_width_valid_div").innerHTML="";
	}
		if(str!='')
	{
		document.getElementById("sampbook_height_valid_div").innerHTML="";
	}
		if(str!='')
	{
		document.getElementById("sampbook_inch_valid_div").innerHTML="";
	}
		if(str!='')
	{
		document.getElementById("sampbook_qty_valid_div").innerHTML="";
	}
	
}


/*************************************Main list add********************************/

function sample_jobcard(jobcard_no,entry_time,customer_name,designer,designer_name,color_profile,order_by,net_amt,edit_id,action)
{
 
		if((customer_name!='')&&(designer!='')&&(designer_name!='')&&(color_profile!='')&&(net_amt!=0.00))
 {if(confirm('Are You Sure! You Want To Conform The JobCard..?'))
	{
        jQuery.ajax({
		type: "POST",
		url: "jobcard/sample_jobcard/sample_jobcard_db.php",
		data: "jobcard_no="+jobcard_no+"&entry_time="+entry_time+"&customer_name="+customer_name+"&designer="+designer+"&designer_name="+designer_name+"&color_profile="+color_profile+"&order_by="+order_by+"&net_amt="+net_amt+"&main_edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#sample_jobcard_main_list_div").html(msg);	
		//alert(msg);
			if(edit_id!='')
			{
			window.location.href="main_fram.php?file=sample_jobcard";
			}
			else
			{
		window.location.reload(true);
		    } }
		});
 }}
else
{
   samp_jobcard_validation();
}
	
}

/******************************* Branch Sublist**********************************************/
function sample_jobcard_sub_list(jobcard_no,entry_time,customer_name,particulars,width,height,inch,qty,total,edit_id,action)
{

if((particulars!='')&&(width!='')&&(inch!='')&&(qty!=''))
 {
        jQuery.ajax({
		type: "POST",
		url: "jobcard/sample_jobcard/sample_jobcard_db.php",
		data: "jobcard_no="+jobcard_no+"&entry_time="+entry_time+"&customer_name="+customer_name+"&particulars="+particulars+"&jobcard_width="+width+"&jobcard_height="+height+"&inch="+inch+"&qty="+qty+"&total="+total+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#sample_jobcard_sublist_div").html(msg);	
		document.getElementById('particulars').value="";
		document.getElementById('jobcard_width').value="";
		document.getElementById('jobcard_height').value="";
		document.getElementById('inch').value="";
		document.getElementById('qty').value="";
		document.getElementById('total').value="";
	
          document.getElementById('add').value="ADD";
         document.getElementById('particulars').focus();

		//alert(msg);
		//window.close();
		//window.opener.location.reload(true);
		
 }
		});
 }
else
{
  sample_jobcard_sub_validation();
}
}

/***********************************delete************************************/
function edit_jobcard_sub_sample(edit_id,jobcard_no)
{
	
		jQuery.ajax({
		type: "POST",
		url: "jobcard/sample_jobcard/sample_jobcard_sublist.php",
		data: "edit_id="+edit_id+"&jobcard_no="+jobcard_no,
		success: function(msg){jQuery("#sample_jobcard_sublist_div").html(msg);
	}
	});

}
/********************************************************************************************/
function get_jobcard_amt(jobcard_width,jobcard_height,rate)
{
if(jobcard_width=='')
{
var jobcard_width=0;
}
if(jobcard_height=='')
{
var jobcard_height=0;
}
if(rate=='')
{
var rate=0;
}
var amt=(jobcard_width)*(jobcard_height)*(rate);
document.getElementById('amount').value=amt.toFixed(2);
}

function get_total_inch_value(width,height)
{var total_inches=width*height;
document.getElementById('inch').value=total_inches.toFixed(2);

	
}

function get_total_inch(inch,qty)
{ 
var total_val=inch*qty;
document.getElementById('total').value=total_val.toFixed(2);
	
}
function get_total(overal_tot,tax)
{
	if(overal_tot=='')
{
var overal_tot=0;
}
	if(tax=='')
{
var tax=0;
}
var tax_amt=(overal_tot/100)*tax;
var tot_tax_amt2=tax_amt.toFixed(2);
document.getElementById('tax_amt').value=tot_tax_amt2;
var tot_tax_amt=parseFloat(overal_tot)+parseFloat(tax_amt);
var tot_tax_amt1=tot_tax_amt.toFixed(2);
document.getElementById('net_amt').value=tot_tax_amt1;
}
/******************************************************************************************/
function get_jobcard_tot(conformed_amt,qty)
{
if(conformed_amt=='')
{	
var	conformed_amt=0;
}
if(qty=='')
{	
var	qty=0;
}
var value_amt=parseFloat(conformed_amt)*parseFloat(qty);
document.getElementById('values').value=value_amt;

}
/**********************************************************************************************/
function get_fabric_type(jobtype)
{
	if(jobtype=='sticker')
	{
		            document.getElementById('fabric_type_div').style.display='none'; 
					document.getElementById('fabric_type_div1').style.display='none';
	}
	if(jobtype=='production')
	{
		            document.getElementById('fabric_type_div').style.display='block'; 
					document.getElementById('fabric_type_div1').style.display='block';

	}
	
	}
/***********************************Delete Branch Sublist************************************/
function del_jobcard_sub_sample(job_id,jobcard_no)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/sample_jobcard/sample_jobcard_db.php",
		data: "job_id="+job_id+"&jobcard_no="+jobcard_no+"&action=delete_job_sub",
		success: function(msg){jQuery("#sample_jobcard_sublist_div").html(msg);
	}
	});
    }
}

function del_job_main_sample(job_id,jobcard_no)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/sample_jobcard/sample_jobcard_db.php",
		data: "job_id="+job_id+"&jobcard_no="+jobcard_no+"&action=delete_job_main",
		success: function(msg){jQuery("#sample_jobcard_main_list_div").html(msg);
		window.location.reload(true);
	}
	});
    }
}

