// JavaScript Document
/********************************** Validation *******************************************************/
function challan_validation()
{
    var job_no = document.getElementById("job_no").value;
	if(job_no=='')
	{
		document.getElementById("delivery_challan_validation_div").innerHTML="* This field is Required.";
		document.getElementById("job_no").focus();
		return false;
	}
}

function challan_clear_validation(str)
{
	if(str!='')
	{
		document.getElementById("delivery_challan_validation_div").innerHTML="";
	}
}
/*************************main list********************************************/
function return_add(return_no,date_time,job_no,created_by,customer_name,style_no,style_name,combo,cust_po_no,job_type,fabric_type,remarks,overal_qty,edit_id,action)
{ 
if((job_no!=''))
 {
  jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_form_db.php",
		data: "return_no="+return_no+"&date_time="+date_time+"&job_no="+job_no+"&created_by="+created_by+"&customer_name="+customer_name+"&style_no="+style_no+"&style_name="+style_name+"&combo="+combo+"&cust_po_no="+cust_po_no+"&job_type="+job_type+"&fabric_type="+fabric_type+"&remarks="+remarks+"&overal_qty="+overal_qty+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#return_main_add").html(msg);
		  window.location.reload(true);
		 
	 if(edit_id!='')
		 { 
		     window.location.reload(true);
			 window.location.href="main_fram.php?file=return_form";
		 }
  	    
 }
		});
}
else
{
    challan_validation();
}

}


/**************************** Delivery Sublist***********************************************/
function return_sublist_add(return_no,date_time,job_no,customer_name,job_type,fabric_type,return_dates,deliv_particular,roll_width,kg_height,inward_qty,tot_qty,overal_qty,edit_id,action)
{ 
if(edit_id!='')
{		
var tot_qty=document.getElementById("tot_qty44").value;
}

var in_qty=Number(inward_qty)+Number(overal_qty);

if(((in_qty<tot_qty)||(in_qty==tot_qty))&&(in_qty!=0))
 {
  jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_form_db.php",
		data: "return_no="+return_no+"&date_time="+date_time+"&job_no="+job_no+"&customer_name="+customer_name+"&job_type="+job_type+"&fabric_type="+fabric_type+"&return_dates="+return_dates+"&deliv_particular="+deliv_particular+"&roll_width="+roll_width+"&kg_height="+kg_height+"&inward_qty="+inward_qty+"&tot_qty="+tot_qty+"&edit_id="+edit_id+"&action="+action,
		success: function(msg){jQuery("#return_sublist_div").html(msg);
		//document.getElementById("delivery_dates").value='';
		document.getElementById("roll_width").value='';
		document.getElementById("kg_height").value='';
		document.getElementById("inward_qty").value='';
		document.getElementById('add').value='ADD';
		document.getElementById("job_no").focus();
		document.getElementById("return_dates").focus();
 }
		});
 }
 else
 {
	 alert("Check The Quantity");
 }
}

/************************* SUB EDIT********************************/
function edit_sublist_return(edit_id,job_no,particulars)
{ 
  jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_sublist.php",
		data: "edit_id="+edit_id+"&job_no="+job_no+"&particulars="+particulars,
		success: function(msg){jQuery("#return_sublist_div").html(msg);
		//document.getElementById("job_no").focus();
		//document.getElementById("delivery_dates").focus();

 }
		});
}
/**************************** get_jobcard_details ************************************************/
function get_jobcard_details2(job_no)
{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/customer_name.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_cust_name").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/style_no.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_style_no_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/created_by.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_created_by_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/style_name.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_style_name_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/cust_po_no.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_customer_po_div").html(msg);
	}
	});
	
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/combo.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_combo_type_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/job_type.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_job_types_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/fabric_type.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#return_fabric_type_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/inward_particulars.php",
		data: "job_no="+job_no,
		success: function(msg){jQuery("#ret_particulars_div").html(msg);
	}
	});
	
}

/***************************** Get Sublist details ***********************************************************/
function get_sub_details1(job_no,deliv_particulars)
{
	
		jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_roll_width.php",
		data: "job_no="+job_no+"&deliv_particulars="+deliv_particulars,
		success: function(msg){jQuery("#return_roll_width_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_kg_height.php",
		data: "job_no="+job_no+"&deliv_particulars="+deliv_particulars,
		success: function(msg){jQuery("#return_kg_height_div").html(msg);
	}
	});
	
	jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_qty.php",
		data: "job_no="+job_no+"&deliv_particulars="+deliv_particulars,
		success: function(msg){jQuery("#return_qty_div").html(msg);
	}
	});
}
/******************************************** SUB DELETE*****************************************************************/
function delete_sublist_return(id,job_no)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_form_db.php",
		data: "id="+id+"&job_no="+job_no+"&action=del_return_sublist",
		success: function(msg){jQuery("#return_sublist_div").html(msg);
		document.getElementById("job_no").focus();
		document.getElementById("return_dates").focus();
	}
	});
    }
}
/******************************main list delte*******************************************/
function return_delete(id,job_no,return_no)
{
	if(confirm('Are You Sure! You Want To Delete?'))
	{
		jQuery.ajax({
		type: "POST",
		url: "jobcard/return_form/return_form_db.php",
		data: "id="+id+"&job_no="+job_no+"&return_no="+return_no+"&action=delete_return_main",
		success: function(msg){jQuery("#return_main_add").html(msg);
		window.location.reload(true);
	}
	});
    }
}
