<?php 
   include('cocoon_config.php');
   date_default_timezone_set('Asia/Calcutta');
   
   function getFieldvalue_cake($table, $condition, $val, $field)
   {
     	global $link1;
		$sql = mysqli_query($link1, "select " . $field . " from " . $table . " where " . $condition . " ='" . $val . "'");
     	$r = mysqli_fetch_array($sql);
     	return ($r[$field]);
   }
   ?>
<script>
   /* function addBatch(obj,id)
   {
   
      var data1=id.split("_");
   
      var thisRow = $(obj).closest( 'tr' )[0];
      $( thisRow ).clone().insertAfter( thisRow ).find( 'input:text' );
      
      var qty=$(obj).closest('tr').find('input[id=qtyasperbill_'+data1[1]+']').val();
    
      var pen=$(obj).closest('tr').find('input[id=pending_'+data1[1]+']').val();
     
     
      var countqty=countPendingQty();
      //alert(pen);
      if(countqty>parseFloat(pen))
      {
         
          $(obj).closest('tr').find('input[id=qtyasperbill_'+data1[1]+']').val(0);
          qty=0;
           //var countqty=countPendingQty();
      }
   
   
      var shortDirect=document.getElementById('shortDirect').value;
      //alert(qty+" "+shortDirect);
      if(qty=="")
          qty=0;
      if(shortDirect=="")
          shortDirect=0;
      var total=parseFloat(qty)+parseFloat(shortDirect);
      document.getElementById('shortDirect').value=total.toFixed();
       var secqty=$(obj).closest('tr').find('input[id=reciveqty2_'+data1[1]+']').val();
      var shortDirect1=document.getElementById('short1Direct').value;
   
       if(secqty=="")
          secqty=0;
      if(shortDirect1=="")
          shortDirect1=0;
      var total1=parseFloat(secqty)+parseFloat(shortDirect1);
   
      document.getElementById('short1Direct').value=parseFloat(total1.toFixed(2));
      var i=parseInt(data1[1]+1);
      $(obj).closest('tr').find('input[id=mfg_'+data1[1]+']').attr('id','mfg_'+i);
      $(obj).closest('tr').find('input[id=expiry_'+data1[1]+']').attr('id','expiry_'+i);
      $('.datepicker').removeClass('hasDatepicker').datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true, changeYear: true,yearRange: '-80:+20'});
   
   
   
   } */
   
   
   function addBatch(obj, id) {
   
   	var data1 = id.split("_");
   
   	var thisRow = $(obj).closest('tr')[0];
   	$(thisRow).clone().insertBefore(thisRow).find('input:text');
   
   	var qty = $(obj).closest('tr').find('input[id=qtyasperbill_' + data1[1] + ']').val();
   	var pen = $(obj).closest('tr').find('input[id=pending_' + data1[1] + ']').val();   
   
   	/* -------------- Code for add button to remove duplicacy of po Quantity Starts here-------------------------------------------------------  */
   	$(obj).closest('tr').find('input[id=add_' + data1[1] + ']').hide();
   	$(obj).closest('tr').find('input[id=poqty_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('td:eq(1)').html('');
   	$(obj).closest('tr').find('td:eq(2)').html('');
   	$(obj).closest('tr').find('td:eq(3)').html('');
   	$(obj).closest('tr').find('td:eq(3)').html('<input type="hidden" value="" id="poqty_1" name="poqty[]">');
   	$(obj).closest('tr').find('input[id=poqty_1]').attr("id", 'poqty_' + data1[1]);
   	$(obj).closest('tr').find('td:eq(4)').html('');   
   	$(obj).closest('tr').find('input[id=pending_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=batchNo_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=mfg_' + data1[1] + ']').val('').addClass("datepicker");
   	$(obj).closest('tr').find('input[id=expiry_' + data1[1] + ']').val('').addClass("datepicker");
   	$(obj).closest('tr').find('input[id=qtyasperbill_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=reciveqty_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=reciveqty2_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=minSign_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=shortaccessid_' + data1[1] + ']').val('');
   	$(obj).closest('tr').find('input[id=mrprate_' + data1[1] + ']').val('');
   
   	/* -------------- Code for add button to remove duplicacy of po Quantity Ends here -------------------------------------------------------  */
   	var countqty = countPendingQty();
   	if (countqty > parseFloat(pen)) {
   		$(obj).closest('tr').find('input[id=qtyasperbill_' + data1[1] + ']').val(0);
   		qty = 0;
   		//var countqty=countPendingQty();
   	}
   	var shortDirect = document.getElementById('shortDirect').value;
   	if (qty == "")
   		qty = 0;
   	if (shortDirect == "")
   		shortDirect = 0;
   	var total = parseFloat(qty) + parseFloat(shortDirect);
   	document.getElementById('shortDirect').value = total.toFixed();
   	var secqty = $(obj).closest('tr').find('input[id=reciveqty2_' + data1[1] + ']').val();
   	var shortDirect1 = document.getElementById('short1Direct').value;   
   	if (secqty == "")
   		secqty = 0;
   	if (shortDirect1 == "")
   		shortDirect1 = 0;
   	var total1 = parseFloat(secqty) + parseFloat(shortDirect1);
   	document.getElementById('short1Direct').value = parseFloat(total1.toFixed(2));
   	var i = parseInt(data1[1] + 1);
   	$(obj).closest('tr').find('input[id=mfg_' + data1[1] + ']').attr('id', 'mfg_' + i);
   	$(obj).closest('tr').find('input[id=expiry_' + data1[1] + ']').attr('id', 'expiry_' + i);
   	$('.datepicker').removeClass('hasDatepicker').datepicker({
   		dateFormat: 'dd/mm/yy',
   		changeMonth: true,
   		changeYear: true,
   		yearRange: '-80:+20'
   	});
   }
   
   
   function calTotalQtyDirect(val, idd, obj) {
   	id1 = idd.split("_");
   	id = id1[1];
   	//alert(id);
   	var totalamt1 = 0;
   	if (id == undefined) {
   		//var qtyRec = document.getElementById("reciveqty").value;
   		var qtyRec = $(obj).closest('tr').find('input[id=reciveqty]').val();
   		var qtyFr  = $(obj).closest('tr').find('input[id=rfreeqty]').val();
   qtyFr      = (isNaN(qtyFr) || qtyFr=='')?0:qtyFr;   
   		// var qtyBill = document.getElementById("qtyasperbill").value;
   		var qtyBill = $(obj).closest('tr').find('input[id=qtyasperbill]').val();
   		var qtyFree = $(obj).closest('tr').find('input[id=freeqty]').val();
   qtyFree = (isNaN(qtyFree) || qtyFree=='')?0:qtyFree;
   
   		if (qtyRec == '') {
   			qtyRec = 0;
   		}
   		var confac = $(obj).closest('tr').find('input[id=convfac]').val();
   		if (confac == '') confac = 0;
   		var secondaryqty = parseFloat(qtyRec) * parseFloat(confac);
   		$(obj).closest('tr').find('input[id=reciveqty2]').val(secondaryqty.toFixed(2));
   		if (parseFloat(qtyBill) > parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyBill) - parseFloat(qtyRec);
   			$(obj).closest('tr').find('input[id=shortaccessid]').val(diff.toFixed(2));
   			//document.getElementById('minSign_'+id).style.display="block";
   			$(obj).closest('tr').find('input[id=minSign]').val('-');
   		}
   if (parseFloat(qtyFr) > parseFloat(qtyFree)) {
   			alert("Receive free Quantity cannot be greater than assigned free Quantity");
   $(obj).closest('tr').find('input[id=rfreeqty]').val(0);
   return false;
   		}
   		if (parseFloat(qtyBill) <= parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyRec) - parseFloat(qtyBill);
   			$(obj).closest('tr').find('input[id=shortaccessid]').val(diff.toFixed(2));
   			$(obj).closest('tr').find('input[id=minSign]').val('+');
   		}
   		var firstRow = $(obj).closest('tr').find('input[id=qtyasperbill]').val();
   		if (firstRow == '') {
   			firstRow = 0;
   		}
   		var firstRow1 = $(obj).closest('tr').find('input[id=reciveqty]').val();
   		if (firstRow1 == '') {
   			firstRow1 = 0;
   		}
   		var totalamt = 0;
   		calculateBillQty('shortDirect');
   		calculateRecQty('short1Direct');
   	} else {
   		//var qtyRec = document.getElementById("reciveqty").value;
   		var qtyRec = $(obj).closest('tr').find('input[id=reciveqty_' + id + "]").val();
   		var qtyFr = $(obj).closest('tr').find('input[id=rfreeqty_' + id + "]").val();
   qtyFr = (isNaN(qtyFr) || qtyFr=='')?0:qtyFr; 		
   		// var qtyBill = document.getElementById("qtyasperbill").value;
   		var qtyBill = $(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").val();
   		var qtyFree = $(obj).closest('tr').find('input[id=freeqty_' + id + "]").val();
     qtyFree = (isNaN(qtyFree) || qtyFree=='')?0:qtyFree;
   		
   if (parseFloat(qtyRec)  > parseFloat(qtyBill)) {
   			alert("Receive Quantity cannot be greater than Bill Quantity");
   			$(obj).closest('tr').find('input[id=reciveqty_' + id + "]").val('0');
   			//return false;
   		}
   
   if (parseFloat(qtyFr) > parseFloat(qtyFree)) {
   			alert("Receive free Quantity cannot be greater than assigned free Quantity");
   $(obj).closest('tr').find('input[id=rfreeqty_' + id + "]").val(0);
   return false;
   		}
   		if (qtyRec == '') {
   			qtyRec = 0;
   		}
   		var confac = $(obj).closest('tr').find('input[id=convfac_' + id + "]").val();
   		if (confac == '') confac = 0;
   		var secondaryqty = parseFloat(qtyRec) * parseFloat(confac);
   		$(obj).closest('tr').find('input[id=reciveqty2_' + id + "]").val(secondaryqty.toFixed(2));
   
   		if (parseFloat(qtyBill) > parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyBill) - parseFloat(qtyRec);
   			$(obj).closest('tr').find('input[id=shortaccessid_' + id + "]").val(diff.toFixed(2));
   			//document.getElementById('minSign_'+id).style.display="block";
   			$(obj).closest('tr').find('input[id=minSign_' + id + "]").val('-');
   
   		}
   		if (parseFloat(qtyBill) <= parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyRec) - parseFloat(qtyBill);
   			$(obj).closest('tr').find('input[id=shortaccessid_' + id + "]").val(diff.toFixed(2));
   			$(obj).closest('tr').find('input[id=minSign_' + id + "]").val('+');
   		}
   
   		var firstRow = $(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").val();
   		if (firstRow == '') {
   			firstRow = 0;
   		}
   		var firstRow1 = $(obj).closest('tr').find('input[id=reciveqty_' + id + "]").val();
   		if (firstRow1 == '') {
   			firstRow1 = 0;
   		}
   		var totalamt = 0;
   		//var countcharges =$(obj).closest('tr').find('input[id=hiditemcount_'+id+"]").val();
   		calculateBillQty('shortDirect');
   		calculateRecQty('short1Direct');
   	}
   calculateAmt();
   }
   
   function countPendingQty() {
   	var total = 0;
   
   	jQuery('input[id^=qtyasperbill_]').each(function() {
   		var amount = parseFloat(jQuery(this).val());
   		total += parseFloat(amount);
   	});
   	return total;
   }
   
   function calTotalQty1Direct(val, idd, obj) {
   	id1 = idd.split("_");
   	id = id1[1];
   	var totalamt1 = 0;
   	if (id == undefined) {
   		var count = countPendingQty();
   		var pendings = document.getElementById('pending').value;
   		/* if(count>pendings)
   		     {
   		        alert("Bill qty cannot greater then pending qty");
   		        return false;
   
   		     }*/
   		//var qtyRec = document.getElementById("reciveqty").value;
   		var qtyRec = $(obj).closest('tr').find('input[id=reciveqty]').val();
   		// var qtyBill = document.getElementById("qtyasperbill").value;
   		var qtyBill = $(obj).closest('tr').find('input[id=qtyasperbill]').val();
   		if (qtyRec == '') {
   			qtyRec = 0;
   		}
   		var confac = $(obj).closest('tr').find('input[id=convfac]').val();
   
   		if (confac == '') confac = 0;
   		var secondaryqty = parseFloat(qtyRec) * parseFloat(confac);
   		$(obj).closest('tr').find('input[id=reciveqty2]').val(secondaryqty.toFixed(2));
   
   		if (parseFloat(qtyBill) > parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyBill) - parseFloat(qtyRec);
   			$(obj).closest('tr').find('input[id=shortaccessid]').val(diff.toFixed(2));
   			//document.getElementById('minSign_'+id).style.display="block";
   			$(obj).closest('tr').find('input[id=minSign]').val('-');
   
   		}
   		if (parseFloat(qtyBill) <= parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyRec) - parseFloat(qtyBill);
   			$(obj).closest('tr').find('input[id=shortaccessid]').val(diff.toFixed(2));
   			$(obj).closest('tr').find('input[id=minSign]').val('+');
   
   		}
   
   		var firstRow = $(obj).closest('tr').find('input[id=qtyasperbill]').val();
   		if (firstRow == '') {
   			firstRow = 0;
   		}
   		var firstRow1 = $(obj).closest('tr').find('input[id=reciveqty]').val();
   
   
   		if (firstRow1 == '') {
   			firstRow1 = 0;
   		}
   		var totalamt = 0;
   		calculateBillQty('shortDirect');
   		calculateRecQty('short1Direct');
   
   
   
   
   		var poqty = parseInt($(obj).closest('tr').find('input[id=poqty').val());
   		var freeqty = parseInt($(obj).closest('tr').find('input[id=freeqty').val());
   		//var totqty=parseFloat(poqty)+parseFloat(freeqty);
   		poqty = parseFloat(poqty) + parseFloat(freeqty);
   		if (freeqty == '') {
   			freeqty = 0;
   		}
   		if (totqty == '') {
   			totqty = 0;
   		}
   
   		var tolerance = $(obj).closest('tr').find('input[id=tolerances').val()
   		if (tolerance == '') {
   			tolerance = 0;
   		}
   		if (poqty == '') {
   			poqty = 0;
   		}
   		str1 = parseInt(val);
   		if (str1 == '') {
   			str1 = 0;
   		}
   		if (tolerance == '') {
   			if (parseInt(poqty) < parseInt(str1)) {
   				alert('Bill Quantity Cannot Be Greater Than poqty Quantity1');
   				$(obj).closest('tr').find('input[id=qtyasperbill').focus();
   				$(obj).closest('tr').find('input[id=qtyasperbill').val('');
   				return false;
   			}
   		} else {
   			var p1 = (tolerance * poqty) / 100;
   			var p2 = parseFloat(poqty) + parseFloat(p1);
   			if (parseInt(p2) < parseInt(str1)) {
   				alert('Bill Quantity Cannot Be Greater Than PO quantity2');
   				$(obj).closest('tr').find('input[id=qtyasperbill').focus();
   				$(obj).closest('tr').find('input[id=qtyasperbill').val('');
   				return false;
   			}
   		}
   	} else {
   		var count = countPendingQty();
   		var pendings = document.getElementById('pending_' + id).value;
   		/*if(count>pendings)
   		 {
   		    alert("Bill qty cannot greater then pending qty");
   		    var qtyBill=$(obj).closest('tr').find('input[id=qtyasperbill_'+id+"]").val(0);
   		    var count=countPendingQty();
   		    document.getElementById('shortDirect').value=count.toFixed(2);
   		    return false;
   
   		 }*/
   
   		//var qtyRec = document.getElementById("reciveqty").value;
   		var qtyRec = $(obj).closest('tr').find('input[id=reciveqty_' + id + "]").val();
   
   		// var qtyBill = document.getElementById("qtyasperbill").value;
   		var qtyBill = $(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").val();
   
   		if (qtyRec == '') {
   			qtyRec = 0;
   		}
   		var confac = $(obj).closest('tr').find('input[id=convfac_' + id + "]").val();
   
   		if (confac == '') confac = 0;
   
   		var secondaryqty = parseFloat(qtyRec) * parseFloat(confac);
   		$(obj).closest('tr').find('input[id=reciveqty2_' + id + "]").val(secondaryqty.toFixed(2));
   
   		if (parseFloat(qtyBill) > parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyBill) - parseFloat(qtyRec);
   			$(obj).closest('tr').find('input[id=shortaccessid_' + id + "]").val(diff.toFixed(2));
   			//document.getElementById('minSign_'+id).style.display="block";
   			$(obj).closest('tr').find('input[id=minSign_' + id + "]").val('-');
   
   		}
   		if (parseFloat(qtyBill) <= parseFloat(qtyRec)) {
   			var diff = parseFloat(qtyRec) - parseFloat(qtyBill);
   			$(obj).closest('tr').find('input[id=shortaccessid_' + id + "]").val(diff.toFixed(2));
   			$(obj).closest('tr').find('input[id=minSign_' + id + "]").val('+');
   
   		}
   
   		var firstRow = $(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").val();
   		if (firstRow == '') {
   			firstRow = 0;
   		}
   		var firstRow1 = $(obj).closest('tr').find('input[id=reciveqty_' + id + "]").val();
   
   
   		if (firstRow1 == '') {
   			firstRow1 = 0;
   		}
   		var totalamt = 0;
   		//var countcharges =$(obj).closest('tr').find('input[id=hiditemcount_'+id+"]").val();
   		calculateBillQty('shortDirect');
   		calculateRecQty('short1Direct');
   		var po_qty = document.getElementById("poqty_" + id).value;
   
   		var sumOfArea = 0;
   
   		$('#tableDataProduction').find('input[type="text"][class="sum_bill_quantity_' + id + '"]').each(function() {
   			if ($(this).val() != '')
   				sumOfArea = sumOfArea + parseFloat($(this).val());
   			else
   				sumOfArea = sumOfArea;
   		});
   
   		var poqty = parseInt($(obj).closest('tr').find('input[id=poqty_' + id + "]").val());
   		var tolerance123 = $(obj).closest('tr').find('input[id=tolerances_' + id + "]").val();
   		var calculate_expected1 = (parseFloat(tolerance123) * parseFloat(poqty)) / 100;
   		var calculate_expected = parseFloat(poqty) + parseFloat(calculate_expected1);   
   		if (parseFloat(sumOfArea) > parseFloat(calculate_expected)) {
   			alert("Bill Quantity cannot be greater than PO Quantity");
   			//document.getElementById("qtyasperbill_"+id).value='';
   			//   document.getElementById("qtyasperbill_1").value='';
   			$('input.sum_bill_quantity_' + id).val('');
   			// $('#discount_amt').val('');
   			// $(this).val('0');
   
   		}
   
   		var tolerance = $(obj).closest('tr').find('input[id=tolerances_' + id + "]").val();
   		var freeqty = $(obj).closest('tr').find('input[id=freeqty_' + id + "]").val();
   
   		if (tolerance == '') {
   			tolerance = 0;
   		}
   		if (poqty == '') {
   			poqty = 0;
   		}
   		if (freeqty == '') {
   			freeqty = 0;
   		}
   		poqty = parseFloat(poqty) + parseFloat(freeqty);
   		str1 = parseInt(val);
   		if (str1 == '') {
   			str1 = 0;
   		}
   		// alert(poqty+"   "+str1);
   		if (tolerance == '') {
   			if (parseInt(poqty) < parseInt(str1)) {
   				alert('Bill Quantity Cannot Be Greater Than PO quantity');
   				$(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").focus();
   				$(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").val('');
   				return false;
   			}
   		} else {
   			var p1 = (tolerance * poqty) / 100;
   			var p2 = parseFloat(poqty) + parseFloat(p1);
   			if (parseInt(p2) < parseInt(str1)) {
   				alert('Bill Quantity Cannot Be Greater Than poqty Quantity');
   				$(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").focus();
   				$(obj).closest('tr').find('input[id=qtyasperbill_' + id + "]").val('');
   				return false;
   			}
   		}
   
   	}
   }
   
   function calculateBillQty(id) {
   
   	var total = 0;
   
   	jQuery('input[id^=qtyasperbill]').each(function() {
   		var amount = parseFloat(jQuery(this).val());
   		if (!isNaN(amount))
   			total += parseFloat(amount);
   	});
   	document.getElementById(id).value = total.toFixed(2);
   }
   
   function calculateRecQty(id) {
   	// alert(id);
   	var total = 0;
   
   	jQuery('input[id^=reciveqty_]').each(function() {
   		var amount = parseFloat(jQuery(this).val());
   		if (!isNaN(amount))
   			total += parseFloat(amount);
   	});
   	document.getElementById(id).value = total.toFixed(2);
   }
   
   function GetPODetails(str) {
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   
   			document.getElementById("inprno").innerHTML = data[0];
   			document.getElementById("alldatadetails").innerHTML = data[1];
   			document.getElementById("GtT6").innerHTML = data[2];
   			$('.datepicker').removeClass('hasDatepicker').datepicker({
   				dateFormat: 'dd/mm/yy',
   				changeMonth: true,
   				changeYear: true,
   				yearRange: '-80:+20'
   			});
   
   		}
   	}
   	var rec = document.getElementById("receiviedagaist").value;
   	xmlhttp.open("GET", "ajax_getpodetails1.php?POID=" + str + "&recAgainst=" + rec, true);
   	xmlhttp.send();
   }
   
   function isNumberKey(evt) {
   	var charCode = (evt.which) ? evt.which : event.keyCode;
   	if (charCode != 46 && charCode > 31 &&
   		(charCode < 48 || charCode > 57))
   		return false;
   
   	return true;
   }
   
   function checkItemdelete() {
   	var check = 0;
   	jQuery('input[id^=itemid_]').each(function() {
   		check += 1;
   	});
   	return check;
   }
   
   function deleteItems() {
   	var x = checkItemdelete();
   
   	if (checkItemdelete() == 1) {
   		alert("You cannot delete all the items");
   		return false;
   	}
   
   	$("input[name='rec[]']:checked").each(function(i) {
   		var rec_id = this.id;
   		var val = document.getElementById(rec_id).value;
   		var x = rec_id.split('_');
   		var val1 = $(this).closest('tr').find('input[id=qtyasperbill_' + x[1] + ']').val();
   
   		var shortDirect = document.getElementById('shortDirect').value;
   		var total = parseFloat(shortDirect) - parseFloat(val1);
   		document.getElementById('shortDirect').value = total.toFixed(2);
   
   
   		var val2 = $(this).closest('tr').find('input[id=reciveqty2_' + x[1] + ']').val();
   
   		var short1Direct = document.getElementById('short1Direct').value;
   		var total1 = parseFloat(short1Direct) - parseFloat(val2);
   
   		document.getElementById('short1Direct').value = total1.toFixed(2);
   
   
   		$(this).closest('tr').remove();
   		alert("Item has been deleted successfully");
   
   	});
   }
   
   function GetPODetails1(str) {
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText;
   			//document.getElementById("inprno").innerHTML=data[0];
   			document.getElementById("alldatadetails").innerHTML = data;
   			//document.getElementById("GtT6").innerHTML=data[2];
   		}
   	}
   	var rec = document.getElementById("receiviedagaist").value;
   	xmlhttp.open("GET", "ajax_getpodetails1.php?POID=" + str + "&recAgainst=" + rec, true);
   	xmlhttp.send();
   }
   
   function calcAmt(str, i) {
   	var totalamt = 0;
   	var qty = document.getElementById("poqty_" + i).value;
   	if (qty == '') {
   		qty = 0;
   	}
   	var finalaAmt = parseFloat(qty) * parseFloat(str);
   
   	document.getElementById("totalValue_" + i).value = finalaAmt.toFixed(2);
   	document.getElementById("basic_Amt_" + i).value = finalaAmt.toFixed(2);
   
   
   	var countcharges = document.getElementById("count3").value;
   	for (var j = 1; j < countcharges; j++) {
   		var qtyBill1 = document.getElementById("basic_Amt_" + j).value;
   // var qtyBill1 = document.getElementById("mrprate_" + j).value;
   		
   if (qtyBill1 == '') {
   			qtyBill1 = 0;
   		}
   		var totalamt = parseFloat(totalamt) + parseFloat(qtyBill1);
   
   	}
   
   	document.getElementById("total_item_amount").value = totalamt.toFixed(2);
   }
   
   function calculateTotalPriceNew(id, i) {
   
   	var totalamt = 0;
   	Quantity = document.getElementById("poqty_" + i).value;
   	Rate = document.getElementById("Rate_" + i).value;
   	disct = document.getElementById("Discount_" + i).value;
   	perAmount = document.getElementById("PerAmo_" + i).value;
   	var Total = parseFloat(Quantity * Rate);
   	var totalamt = 0;
   	document.getElementById("totalValue_" + i).value = Total.toFixed(2);
   	if (disct != "") {
   		if (perAmount == 'Amount') {
   			var finalAmount = parseFloat(Quantity * Rate) - parseFloat(disct);
   			document.getElementById("basic_Amt_" + i).value = finalAmount.toFixed(2);
   			document.getElementById("perc_" + i).value = parseFloat(disct).toFixed(2);
   		} else {
   			var finalAmount = parseFloat(Quantity * Rate) - parseFloat((Quantity * Rate) * disct / 100);
   			document.getElementById("basic_Amt_" + i).value = finalAmount.toFixed(2);
   			document.getElementById("perc_" + i).value = parseFloat((Quantity * Rate) * disct / 100).toFixed(2);
   		}
   	} else {
   		document.getElementById("basic_Amt_" + i).value = Total.toFixed(2);
   	}
   
   
   
   	var c = document.getElementById("count3").value;
   	for (var l = 1; l < c; l++) {
   		if (document.getElementById("basic_Amt_" + l) != null) {
   			if (document.getElementById("basic_Amt_" + l).value != '')
   				var totalamt = parseFloat(totalamt) + parseFloat(document.getElementById("basic_Amt_" + l).value);
   		}
   	}
   
   	document.getElementById("total_item_amount").value = totalamt.toFixed(2);
   }
   
   function calculate_bill_quantity() {
   
   	var count = document.getElementById("count3").value;
   	// alert(count);
   	for (var i = 0; i < count; i++) {
   		var po_qty = document.getElementById("poqty_" + i).value;
   		alert(po_qty);
   		var sumOfArea = 0;
   
   		$('#tableDataProduction').find('input[type="text"][class="sum_bill_quantity_"+i]').each(function() {
   			if ($(this).val() != '')
   				sumOfArea = sumOfArea + parseFloat($(this).val());
   			else
   				sumOfArea = sumOfArea;
   		});
   	}
   	alert(sumOfArea);
   
   	// document.getElementById("funding_amt").value=sumOfArea.toFixed(2);
   
   }
   
   function checkitemdate(str) {
   
   	var id = str.id.split("_");
   	var val = str.value.split("/");
   	var req_date1 = document.getElementById("mfg_" + id[1]).value.split("/");
   	var val1 = val[2] + "-" + val[1] + "-" + val[0];
   	var req_date = req_date1[2] + "-" + req_date1[1] + "-" + req_date1[0];
   	if (Date.parse(val1) < Date.parse(req_date) || req_date == "undefined-undefined-") {
   		if (id[1] == undefined) {
   			alert("Material Required Date must be greater or equal to Requisition Date");
   			document.getElementById(id[0]).value = "";
   			var exp = document.getElementById(id[0]).focus();
   			alert(exp.innerHTML);
   		} else {
   			alert("Expiry Date must be greater  than Manufacturing Date");
   			document.getElementById(id[0] + "_" + id[1]).value = "";
   			var ex = document.getElementById(id[0] + "_" + id[1]).focus();
   			alert(ex.innerHTML);
   		}
   	}
   }
   
   function checkfuturedate(dt) {
   
   	var d = new Date();
   	var day = d.getDate();
   	if (day < 9 && day > 0) {
   		day = "0" + day;
   	}
   	var mon = d.getMonth();
   	var month = mon + 1;
   	var year = d.getFullYear();
   	var dateformat = year + "-" + month + "-" + day;
   	var get = dt.split("/");
   	var get1 = get[2] + "-" + get[1] + "-" + get[0];
   
   
   	if (Date.parse(get1) > Date.parse(dateformat) || get1 == "undefined-undefined-") {
   		alert("Manufacturing Date should not be future date.");
   		mfg = document.getElementById("mfg_" + i).value = "";
   
   		var mf = document.getElementById("mfg_" + i).focus();
   
   		alert(mf.innerHTML);
   	}
   }
   
   function calculateAmt() {
   var total = 0, tax = 0, basicamt = 0;
   $('input[id^=pending_]').each(function(i) {
   var rc = parseFloat($('#reciveqty_' + (i+1)).val()) || 0;
   
   var rate = parseFloat($(this).data('rate')) || 0;
   var taxRate = parseFloat($(this).data('tax')) || 0;
   
   //    var itemTotal = parseFloat($('#mrprate_' + (i+1)).val()) || 0;
   
   var itemTotal = rate * rc;
   
   	total += itemTotal;
   	tax += itemTotal * (taxRate / 100);
   
   });
   
   var avg = total / ($('#total_item_amount').data('val') || 1);
   
   var freight = $('#TotalCharge').val();
   
   var insurance = ($('#insurance').data('val') * avg).toFixed(2);
   var misc = ($('#miscellaneous').data('val') * avg).toFixed(2);
   
   	
   
   var fgst = (parseFloat(freight) * 18) / 100;
   	
   tax += fgst;
   
   var gross = total + tax + parseFloat(freight) + parseFloat(insurance) + parseFloat(misc);
   var roundOff = Math.round(gross) - gross;
   var roundSymbol = roundOff >= 0 ? '+' : '-';
   var roundValue = Math.abs(roundOff).toFixed(2);
   $('#total_item_amount').val(total.toFixed(2));
   $('#taxvalue').val(tax.toFixed(2));
   $('#TotalCharge').val(freight);
   $('#insurance').val(insurance);
   $('#miscellaneous').val(misc);
   $('#GrandTotal').val(Math.round(gross).toFixed(2));
   $('#pluMin').val(roundSymbol);
   $('#roundVal').val(roundValue);
   }
   
</script>
<?php
   $PageName = 'MaterialReceiptNote';
   $url_cancel = "index.php?route=Inventory/transation/material_receipt_note_index" . $rurl;
   $url_add = "index.php?route=Inventory/transation/material_receipt_note_add" . $rurl;
   
   
   //************INSERT RECORD HERE******START HERE**********14-06-2013***********AS**********************************
   if ($_REQUEST['save']) {
   	//echo "<pre>"; print_r($_REQUEST); echo "</pre>";
   	date_default_timezone_set('Asia/Calcutta');
   	$pending_status = 0;
   	$prefix_sql = DB_query("Select * from prefix_tbl where prefix_name='" . $_REQUEST['frmid'] . "' and module_id='" . $_REQUEST['modid'] . "' ", $db);
   	$prefix_row = DB_fetch_array($prefix_sql);
   	//$prefixf=explode("/",$prefix_row['prefix_code']);
   	$prefix1 = $prefix_row['prefix_code'];
   	$financial = substr($_SESSION['YearStart'], -2) . "-" . substr($_SESSION['YearEnd1'], -2);
   	$sql = "Select MRNNo from addmrn where site='" . $_REQUEST['sitecode'] . "' 
   	and INSTR(`MRNNo`, '$financial') > 0 order by id desc limit 0,1";
   
   	$result = DB_query($sql, $db);
   	$myrow = DB_fetch_array($result);
   	//echo DB_num_rows($result);
   	if (DB_num_rows($result) > 0) {
   		$ExplBill = explode("/", $myrow['MRNNo']);
   		$maxval = $ExplBill[3];
   		$req_final = $maxval + 1;
   	} else {
   		$req_final = "1";
   	}
   
   	$string = $_REQUEST['sitecode'] . "/" . $financial . "/" . $prefix1 . '/';
   	$final_string = $string . str_pad($req_final, 4, "0", STR_PAD_LEFT);
   
   	$data['MRNNo']                    = $final_string;
   	$data['MRNDate']                  = FormatDateForSQL($_REQUEST['MRNdate']);
   	$data['site']                     = $_REQUEST['sitecode'];
   	$data['StoreCode']                = $_REQUEST['storecode'];
   	$data['ReceivedAgainst']          = $_REQUEST['receiviedagaist'];
   	$data['ReceivedFrom']             = $_REQUEST['vendor'];
   	$data['Type']                     = $_REQUEST['poType'];
   	$data['Po_category']              = $_REQUEST['purch_ord_category'];
   	$data['order_no']                 = $_REQUEST['PONo'];
   	$data['req_no']                   = $_REQUEST['req_no'];
   	$data['DocumentType']             = $_REQUEST['DocumentType'];
   	$data['BillNo']                   = $_REQUEST['billno'];
   	$data['MRNVoucherDate']           = FormatDateForSQL($_REQUEST['MRNVoucherDate']);
   	$data['GetPassNo']                = $_REQUEST['gatepassno'];
   	$data['gatepassdate']             = FormatDateForSQL($_REQUEST['gatepassdate']);
   	$data['VehicleNo']                = $_REQUEST['vehicalno'];
   	$data['TimeIn']                   = $_REQUEST['timein'];
   	$data['Timeout']                  = $_REQUEST['timeout'];
   	$data['LRno']                     = $_REQUEST['lrno'];
   	$data['LRno']                     = $_REQUEST['lrno'];
   	$data['LRdate']                   = FormatDateForSQL($_REQUEST['lrdate']);
   	$data['form_type']                = $_REQUEST['form_type'];
   	$data['form_no']                  = $_REQUEST['form_no'];
   	$data['Transp_name']              = $_REQUEST['transport'];
   	$data['RemarksIfAny']             = $_REQUEST['RemarksIfAny'];
   	$data['mrnstatus']                = "Pending";
   	$data['Grn_Type']                 = "Indirect";
   	$data['companyID']                = $_SESSION['ACGCompanyId'];
   	$data['createdby']                = $_SESSION['UserID'];
   	//$data['duty_type']                =$_REQUEST['dutytype'];
   	$data['totalBillQty']             = $_REQUEST['totalBillQty'];
   	$data['totalRecQty']              = $_REQUEST['totalRecQty'];
   
   	$data['total_Item_Amount']        = $_REQUEST['basic_amt'];
   	$data['tot_freight']              = $_REQUEST['Freight'];
   	$data['vat_cst_val']              = $_REQUEST['tax_amt'];
   	$data['insurancecharges_amt']     = $_REQUEST['insr_amt'];
   	$data['othercharges']             = $_REQUEST['other_amt'];
   	$data['round_off']                = $_REQUEST['pluMin'].$_REQUEST['roundVal'];
   	$data['grandtotal']               = $_REQUEST['GrandTotal'];
   	$data['transaction_time']         = FormatDateForSQL($_REQUEST['MRNdate']) . " " . date('H:i:s', time());
   
   	$s->RecordInsert('addmrn', $data);
   	$Lastreq_id = DB_Last_Insert_ID($db, 'addmrn', $ErrMsg);
   	$coldata1 = 0;
   	$numdata1 = 0;
   
   	if ($Lastreq_id && $_REQUEST['receiviedagaist'] == 'stock_transfer') {
   		DB_query("Update invoice  set invoice_status=1 where invoice_id = '" . $_REQUEST['PONo'] . "'  ", $db);
   	}
   
   
   	for ($i = 0; $i < count($_REQUEST['mst_itemid']); $i++) {
   		if ($_REQUEST['mst_itemid'][$i] != '') {
   			$data_arr['issue_id']           = $Lastreq_id;
   			//$data_arr['issue_qty']          =$_POST['issuebalanc'][$i];
   			$data_arr['mst_unitid']         = $_REQUEST['unit'][$i];
   			$data_arr['mst_sec_unitid']       = $_REQUEST['unit2'][$i];
   			$data_arr['mst_itemid']         = $_POST['mst_itemid'][$i];
   			$data_arr['POQty']              = $_REQUEST['poqty'][$i];
   			$data_arr['qty_as_per_bill']    = $_REQUEST['qtyasperbill'][$i];
   
   			$data_arr['reciveqty']          = $_REQUEST['reciveqty'][$i];
   			$data_arr['stock_qty2']         = $_REQUEST['reciveqty2'][$i];
   
   			$data_arr['qty_type']           = $_REQUEST['qtytype'][$i];
   			$data_arr['short_accessid']     = $_REQUEST['shortaccessid'][$i];
   			$data_arr['batch_no']           = $_REQUEST['batchNo'][$i];
   			$data_arr['mfg']                = FormatDateForSQL($_REQUEST['mfg'][$i]);
   			$data_arr['expiry']             = FormatDateForSQL($_REQUEST['expiry'][$i]);
   			$data_arr['minSign']            = $_REQUEST['minSign'][$i];
   			// $data_arr['Gread']              =$_REQUEST['gradesp'][$i];
   			//$data_arr['size']               =$_REQUEST['sizesp'][$i];
   			$data_arr['conv_fac']           = $_REQUEST['conv_fac'][$i];
   			if ($_REQUEST['receiviedagaist'] == 'Indent')
   				$data_arr['grn_type']           = 'Indent';
   			else
   				$data_arr['grn_type']           = 'Indirect';
   			if ($_REQUEST['short_qty'][$i] != 0)
   				$data_arr['status']            = "N";
   			else
   				$data_arr['status']            = "Y";
   			$data_arr['mrprate']          = $_REQUEST['mrprate'][$i];
   			$data_arr['free_qty']         = $_REQUEST['rfreeqty'][$i];
   
   			$s->RecordInsert('addmrnqty', $data_arr);
   
   			$dtls_Lastreq_id = DB_Last_Insert_ID($db, 'addmrnqty', $ErrMsg);
   
   
   
   			$primary_unit = $s->getField('item_master', 'id', $_POST['mst_itemid'][$i], 'mst_unitid');
   			$secondary_unit = $s->getField('item_master', 'id', $_POST['mst_itemid'][$i], 'conv_unit');
   			$data_stock['site']                     = $_REQUEST['sitecode'];
   			$data_stock['store']                    = $_REQUEST['storecode'];
   			$data_stock['mst_itemid']               = $_POST['mst_itemid'][$i];
   			$data_stock['primary_unit']             = $primary_unit;
   			$data_stock['secondary_unit']           = $secondary_unit;
   			$data_stock['against_voucher_main_id']  = $Lastreq_id;
   			$data_stock['against_voucher_dtls_id']  = $dtls_Lastreq_id;
   			$data_stock['type']                     = 'MRN';
   			$data_stock['pending_qty']              = $_REQUEST['reciveqty'][$i] + $_REQUEST['rfreeqty'][$i];
   
   			$data_stock['inwardqty_primary']        = $_REQUEST['reciveqty'][$i] + $_REQUEST['rfreeqty'][$i];
   			$data_stock['inwardqty_secondary']      = $_REQUEST['reciveqty2'][$i];
   			$data_stock['date_of_mfg']              = FormatDateForSQL($_REQUEST['mfg'][$i]);
   			$data_stock['date_of_expiry']           = FormatDateForSQL($_REQUEST['expiry'][$i]);
   
   			$data_stock['trasaction']               = FormatDateForSQL($_REQUEST['MRNdate']) . " " . date('H:i:s', time());
   			$data_stock['batch_no']                 = $_REQUEST['batchNo'][$i];
            $data_stock['inward_rate']                 = $_REQUEST['mrprate'][$i];
   
   			$s->RecordInsert('stock_valuation_tbl', $data_stock);
   
   			/**********************************  Inserting Records in batch table (cake php)*****************************/
   			//echo $_REQUEST['storecode'];
			$majorid = $s->getField('item_master', 'id', $_POST['mst_itemid'][$i], 'CategoryID');
   			$majormainid = $s->getField('stockmaincategory', 'id', $majorid, 'ref_major_id');
   			$storecode = $s->getField('storetype', 'id', $_REQUEST['storecode'], 'StoreCode');
   			$unitcode = $s->getField('unitsofmeasure', 'unitid', $primary_unit, 'unitname');
   			$majorcode = getFieldvalue_cake('majors', 'id', $majormainid, 'major_code');
   
   			$itemcode = $s->getField('item_master', 'id', $_POST['mst_itemid'][$i], 'StockID');
   			$item_name = $s->getField('item_master', 'id', $_POST['mst_itemid'][$i], 'item_name');
   			$batchno = $_REQUEST['batchNo'][$i];
            $_REQUEST['reciveqty'][$i] = $_REQUEST['reciveqty'][$i] + $_REQUEST['rfreeqty'][$i];
   			$insertBatchRec = array(
   				'store_code' => $storecode,
   				'item_code' => $itemcode,
   				'item_desc' => $item_name,
   				'batch_no' => $_REQUEST['batchNo'][$i],
   				'manufacturing_date' => FormatDateForSQL($_REQUEST['mfg'][$i]),
   				'expire_date' => FormatDateForSQL($_REQUEST['expiry'][$i]),
   				'uom' => $unitcode,
   				'qty' => $_REQUEST['reciveqty'][$i],
   				'mrp' => $_REQUEST['mrprate'][$i],
   				'sale_base_rate' => $_REQUEST['rate'][$i],
   				'created_by' => getFieldvalue_cake('userrolls', 'user_name', $_SESSION['c_uid'], 'user_id'),
   				'created' => date('Y-m-d H:i:s'),
   			);
   
   			$query_batch_item1 = mysqli_query($link1, "select SUM(qty) as qty,id FROM batchdetails WHERE item_code='" . $itemcode . "' and store_code='" . $storecode . "' and batch_no='" . $batchno . "' GROUP BY item_code");
   			$query_batch_item = mysqli_fetch_array($query_batch_item1);
   
   			if (mysqli_num_rows($query_batch_item1) > 0) {
   				$stockbatchqty = $_REQUEST['reciveqty'][$i] + $query_batch_item['qty'];
   				$update_batch = mysqli_query($link1, "update batchdetails set qty ='" . $stockbatchqty . "',mrp='" . $_REQUEST['mrprate'][$i] . "' where item_code='" . $itemcode . "' and store_code='" . $storecode . "' and batch_no='" . $batchno . "'");
   			} else {
   				$sql_insert = "Insert into batchdetails set ";
   				$t = 0;
   				foreach ($insertBatchRec as $key => $val) {
   					if ($t == 0)
   						$sql_insert .= " " . $key . " = '" . $val . "'";
   					else
   						$sql_insert .= ", " . $key . " = '" . $val . "'";
   					$t++;
   				}
   				mysqli_query($link1, $sql_insert);
   			}
   
   			$query_item = mysqli_fetch_array(mysqli_query($link1, "select SUM(stock_level),id FROM storeitems WHERE item='" . $itemcode . "' and store_code='" . $storecode . "' GROUP BY item"));
   			$stockqty = $_REQUEST['reciveqty'][$i] + $query_item['SUM(stock_level)'];
   			$update = mysqli_query($link1, "update storeitems set qty ='" . $_REQUEST['reciveqty'][$i] . "', stock_level ='" . $stockqty . "', modified_by ='" . getFieldvalue_cake('userrolls', 'user_name', $_SESSION['c_uid'], 'user_id') . "',modified_date ='" . date('Y-m-d H:i:s') . "' where item='" . $itemcode . "' and store_code='" . $storecode . "' and major_code='" . $majorcode . "'");
   
   			/******************************************************************************************************************/
   			/************************************UPDATE MRN DETAILS TBL**************************************/
   			$reciveqty_name = 'reciveqty';
   			if ($_REQUEST['receiviedagaist'] == 'PO') {   
   				if ($_REQUEST[$reciveqty_name][$i] >= $_REQUEST['pending_qty'][$i]) {
   					/*                    $updatePO=DB_query("Update purchorderdetails set status='received' where 
   				    parantId='".$_REQUEST['PONo']."' and mst_itemid='".$_REQUEST['mst_itemid'][$i]."' and mst_unitid='".$_REQUEST['unit2'][$i]."'",$db);*/
   					$updatePO = DB_query("Update purchorderdetails set status='received' where 
                       parantId='" . $_REQUEST['PONo'] . "' and mst_itemid='" . $_REQUEST['mst_itemid'][$i] . "'", $db);
   				}
   			}
 
   			if ($_REQUEST['receiviedagaist'] == 'Indent') {
   				if ($_REQUEST[$reciveqty_name][$i] >= $_REQUEST['pending_qty'][$i]) {
   					/*                    $updatePO=DB_query("Update requisitionorderdetails set mrn_status='received' where 
   				    requsitionno='".$_REQUEST['PONo']."' and mst_itemid='".$_REQUEST['mst_itemid'][$i]."' and uom='".$_REQUEST['unit2'][$i]."'",$db);*/
   					$updatePO = DB_query("Update requisitionorderdetails set mrn_status='received' where 
                       requsitionno='" . $_REQUEST['PONo'] . "' and mst_itemid='" . $_REQUEST['mst_itemid'][$i] . "'", $db);
   				}
   			}
   		}
   	}
   	if ($_REQUEST['receiviedagaist'] == 'PO') {
   		$get_num_rows = DB_query("Select * from purchorderdetails where parantId='" . $_REQUEST['PONo'] . "'", $db);
   		$num_rows = DB_num_rows($get_num_rows);
   		$check_item_stat = DB_query("Select * from purchorderdetails where parantId='" . $_REQUEST['PONo'] . "'
   		and status='received'", $db);
   		$received_num_rows = DB_num_rows($check_item_stat);
   
   		if ($num_rows == $received_num_rows) {
   			$updatePOStat = DB_query("Update purchorders set Po_recive_status='Receive' where 
   			id='" . $_REQUEST['PONo'] . "'", $db);
   		}
   	}
   
   
   	if ($_REQUEST['receiviedagaist'] == 'Indent') {
   		$get_num_rows = DB_query("Select * from requisitionorderdetails where requsitionno='" . $_REQUEST['PONo'] . "'", $db);
   		$num_rows = DB_num_rows($get_num_rows);
   		$check_item_stat = DB_query("Select * from requisitionorderdetails where requsitionno='" . $_REQUEST['PONo'] . "'
   		and mrn_status='received'", $db);
   		$received_num_rows = DB_num_rows($check_item_stat);
   
   		if ($num_rows == $received_num_rows) {
   			$updatePOStat = DB_query("Update materialrequisitions set MRN_Receive_status='1' where 
   			requisitionno='" . $_REQUEST['PONo'] . "'", $db);
   		}
   	}
   
   
   
   
   	//exit('jk');
   	$s->pageLocation("index.php?route=Inventory/transation/material_receipt_note_index" . $rurl);
   }
   ?>
<style>
   table.thborder tr td {
   font-size: 12px;
   font-weight: normal;
   border-bottom: #b0b0b0 1px solid;
   padding: 1px 1px !important;
   }
</style>
<script type="text/javascript">
   function grnDisabled1(str) {
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   
   			var data = xmlhttp.responseText.split("__");
   			//alert(data[0]);
   			document.getElementById("alldatadetails").innerHTML = data[0];
   			document.getElementById("basicamtdetails").innerHTML = data[1];
   
   		}
   	}
   
   	var pono = document.getElementById("PONo").value;
   	var purtype = document.getElementById("PoType").value;
   
   	xmlhttp.open("GET", "ajax_getpodetails.php?POID=" + pono + "&POType=" + purtype + "&ordertype=" + str, true);
   	xmlhttp.send();
   }
   
   
   function GetStore(str) {
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			//alert(xmlhttp.responseText);	
   
   			var data = xmlhttp.responseText.split("__");
   			document.getElementById("storecode").innerHTML = data[0];
   			if (document.getElementById('receiviedagaist').value == 'stock_transfer') {
   				ChkGRNType("stock_transfer");
   			} else {
   				document.getElementById("vendor").innerHTML = data[1];
   			}
   		}
   	}
   	xmlhttp.open("GET", "ajax_getstore1.php?branchcode=" + str, true);
   	xmlhttp.send();
   }
   
   function ChkGRNType(str) {
   	if (str == 'stock_transfer') {
   		var branch = document.getElementById("sitecode").value
   		if (branch != '000') {
   			$.post("ajax_quotation.php", {
   				"site": branch
   			}, function(data) {
   				$("#vendor").html(data);
   			});
   		} else {
   			alert("Please select Branch first");
   			return false;
   		}
   
   	}
   }
   
   function loadInvoice(branch, client) {
   	$.post("ajax_get_indent_po_no1.php", {
   		'client': client,
   		"invoice": "yes"
   	}, function(data) {
   		document.getElementById('PONo').innerHTML = data;
   		document.getElementById('poType').innerHTML = "<option value='DO'>Domestic Order</option";
   	});
   }
   
   
   function GetIndentPONo(str) {
   	var site = document.getElementById("sitecode").value;
   	var receag = document.getElementById("receiviedagaist").value;
   	if (str == '0') {
   		return;
   	}
   	if (receag == 'stock_transfer') {
   
   		loadInvoice(site, str);
   		return;
   	}
   
   
   	if (str.length == 0) {
   		document.getElementById("poname").innerHTML = "";
   		document.getElementById("inprno").innerHTML = "";
   		return;
   	}
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			if (receag == 'PO') {
   				var data = xmlhttp.responseText.split("__");
   				document.getElementById("GtT4").innerHTML = data[0];
   			} else {
   				var data = xmlhttp.responseText.split("__");
   				document.getElementById("GtT4").innerHTML = data[0];
   				document.getElementById("inprno").innerHTML = data[1];
   				document.getElementById("inprno1").innerHTML = data[2];
   			}
   		}
   	}
   	xmlhttp.open("GET", "ajax_get_indent_po_no1.php?supplierId=" + str + "&ReciveAng=" + receag + "&Branch=" + site, true);
   	xmlhttp.send();
   }
   
   
   function check_bill_qty(str, id) {
   	var poqty = parseInt(document.getElementById("pending_qty_" + id).value);
   	var tolerance = document.getElementById("tolerance_" + id).value;
   	if (tolerance == '') {
   		tolerance = 0;
   	}
   	str1 = parseInt(str);
   	if (poqty != '') {
   		var qty = (poqty * tolerance) / 100;
   		var poqty1 = parseInt(poqty) + parseInt(qty);
   		//var poqty2=poqty-qty;	
   		if (str1 > poqty1) {
   			var altmsg = "Quantity As Per Bill Cannot Be Greater Than " + tolerance + " % more of PO Quantity";
   			alert(altmsg);
   			document.getElementById("qty_as_per_bill_" + id).value = '';
   			document.getElementById("qty_received_" + id).value = '';
   			document.getElementById("qty_as_per_bill_" + id).focus();
   			return false;
   		}
   	}
   }
   
   
   
   function check_po_qty1(i) {
   	var poqty = parseInt(document.getElementById("pending_qty_" + i).value);
   	var str = parseInt(document.getElementById("qty_received_" + i).value);
   	var tolerance = document.getElementById("tolerance_" + i).value;
   	if (tolerance == '') {
   		tolerance = 0;
   	}
   	str1 = parseInt(str);
   	if (poqty != '') {
   		var qty = (poqty * tolerance) / 100;
   		var poqty1 = parseInt(poqty) + parseInt(qty);
   		//var poqty2=poqty-qty;	
   		if (str1 > poqty1) {
   			var altmsg = "QTY Received Cannot Be Greater Than " + tolerance + " % more of PO Quantity";
   			alert(altmsg);
   			document.getElementById("qty_received_" + i).value = '';
   			document.getElementById("qty_received_" + i).focus();
   			return false;
   		}
   	}
   }
   
   
   function calculate_poshort(id) {
   	var qty_per_bill = parseInt(document.getElementById("qty_as_per_bill_" + id).value);
   	var reciveqty = parseInt(document.getElementById("qty_received_" + id).value);
   	if (document.getElementById("qty_received_" + id).value == '') {
   		var reciveqty = 0;
   	} else {
   		var reciveqty = parseInt(document.getElementById("qty_received_" + id).value);
   	}
   	var short_accessid = qty_per_bill - reciveqty;
   	if (short_accessid < 0) {
   		short_accessid = 0;
   	}
   	document.getElementById("short_qty_" + id).value = short_accessid;
   }
   
   
   function calc_total_price(str) {
   
   	var item_total_rate = 0;
   	var reciveqty = document.getElementById("qty_received_" + str).value;
   	var itemrate = document.getElementById("Rate_" + str).value;
   
   	if (reciveqty != '' && itemrate != '') {
   		document.getElementById("totalValue_" + str).value = (parseFloat(reciveqty) * parseFloat(itemrate)).toFixed(2);
   	}
   }
   
   function DiscountAmount(DA, i) {
   
   	var discount_percent = document.getElementById("PerAmo_" + i).value;
   	var rate = document.getElementById("Rate_" + i).value;
   	var discount = document.getElementById("Discount_" + i).value;
   	var quantity = document.getElementById("qty_received_" + i).value;
   	var totalPrice = parseFloat(quantity) * parseFloat(rate);
   	if (discount_percent == 'PercentAmt') {
   		if (discount == '') {
   			discount = 0;
   		}
   		var percent = parseFloat(totalPrice) * parseFloat(discount) / 100;
   		var subTotal = parseFloat(totalPrice) - parseFloat(percent);
   	} else if (discount_percent == 'Amount') {
   		var percent = parseFloat(document.getElementById("Discount_" + i).value);
   		if (isNaN(percent)) {
   			percent = 0;
   		}
   		var subTotal = totalPrice - parseFloat(percent);
   	}
   	document.getElementById("perc_" + i).value = percent.toFixed(2);
   	document.getElementById("NetRate_" + i).value = subTotal.toFixed(2);
   	document.getElementById("basic_" + i).value = subTotal.toFixed(2);
   }
   
   
   
   
   function CustomDutyType(val, i) {
   	if (document.getElementById("cuntomDuty_Flag_" + i).value == '2') {
   		document.getElementById("CustonDuty_" + i).value = '';
   		document.getElementById("CustomDutyAmt_" + i).value = '';
   		document.getElementById("CustonDuty_" + i).disabled = true;
   		document.getElementById("CustomDutyAmt_" + i).disabled = true;
   	} else {
   		document.getElementById("CustonDuty_" + i).value = document.getElementById("custonduty1_" + i).value;
   		document.getElementById("CustomDutyAmt_" + i).value = document.getElementById("custondutyamt1_" + i).value;
   		document.getElementById("CustonDuty_" + i).disabled = false;
   		document.getElementById("CustomDutyAmt_" + i).disabled = false;
   	}
   }
   
   
   
   
   function cal_grandtotalImp(i) {
   	//var type_of_bill=document.getElementById("cuntomDuty_Flag_"+i).value;
   	var basic = document.getElementById("basic_" + i).value;
   	var Totaltaxable = document.getElementById("CustomDutyAmt_" + i).value;
   	var Totaltaxable1 = document.getElementById("TotalSpecial_" + i).value;
   	var Totaltaxable2 = document.getElementById("customecess_" + i).value;
   	var Totaltaxable3 = document.getElementById("customsececess_" + i).value;
   	var Totaltaxable4 = document.getElementById("adduty_" + i).value;
   	if (basic == '') {
   		basic = 0;
   	}
   	if (Totaltaxable1 == '') {
   		Totaltaxable1 = 0;
   	}
   	if (Totaltaxable2 == '') {
   		Totaltaxable2 = 0;
   	}
   	if (Totaltaxable3 == '') {
   		Totaltaxable3 = 0;
   	}
   	if (Totaltaxable4 == '') {
   		Totaltaxable4 = 0;
   	}
   	if (Totaltaxable == '') {
   		Totaltaxable = 0;
   	}
   
   	var grand_tot1 = parseFloat(basic) + parseFloat(Totaltaxable) + parseFloat(Totaltaxable1) + parseFloat(Totaltaxable2) + parseFloat(Totaltaxable3) + parseFloat(Totaltaxable4);
   	var grand_tot = grand_tot1.toFixed(2);
   
   	//alert(grand_tot);
   	document.getElementById("TotalSpecial_amt_" + i).value = grand_tot;
   }
   
   
   function cal_totalamount_consolidate() {
   	var total = 0;
   	var t = document.getElementById("conterimp").value;
   	for (var i = 0; i < t; i++) {
   		var amt = parseFloat(document.getElementById("basic_" + i).value);
   		total = parseFloat(total) + amt;
   	}
   	var fintotal = parseFloat(total);
   	document.getElementById("total_item_amount").value = fintotal.toFixed(2);
   
   
   
   }
   
   function cal_totalamount_impdata() {
   	var total = 0;
   	var t = document.getElementById("conterimp").value;
   	for (var i = 0; i < t; i++) {
   		var amt = parseFloat(document.getElementById("TotalSpecial_amt_" + i).value);
   		total = parseFloat(total) + amt;
   	}
   	var fintotal = parseFloat(total);
   	document.getElementById("total_item_amount").value = fintotal.toFixed(2);
   
   
   
   
   }
   
   function cal_totalamount() {
   	var total = 0;
   	var t = document.getElementById("conterimp").value;
   	for (var i = 0; i < t; i++) {
   		var amt = parseFloat(document.getElementById("TotalSpecial_" + i).value);
   		total = parseFloat(total) + amt;
   	}
   	var fintotal = parseFloat(total);
   	document.getElementById("total_item_amount").value = fintotal.toFixed(2);
   
   
   	var hdcnt = document.getElementById("conterimp").value;
   	var flag1 = 0;
   	if (hdcnt != '') {
   		for (var j = 0; j < hdcnt; j++) {
   			if (document.getElementById("cuntomDuty_Flag_" + j).value == 1) {
   				flag1 = 1;
   			}
   		}
   	}
   	if (flag1 == 1) {
   		document.getElementById("CustomDuty").disabled = true;
   	} else {
   		document.getElementById("CustomDuty").disabled = false;
   	}
   
   }
   
   
   function CalculateCustomDuty(id, val) {
   	var id1 = id.split("_");
   	var i = id1[1];
   
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   
   			document.getElementById("CustomDutyAmt_" + i).value = data[1];
   		}
   	}
   
   	var basicamt = document.getElementById("basic_" + i).value;
   	xmlhttp.open("GET", "ajax_get_cutom_duty.php?ids=" + id + "&vls=" + val + "&bamt=" + basicamt, true);
   	xmlhttp.send();
   }
   
   
   function claculateExcisetotal(id, str) {
   	var b = document.getElementById("total_item_amount").value;
   
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   			document.getElementById("rateval").value = data[0];
   			document.getElementById("custondutyval").value = data[1];
   		}
   	}
   	xmlhttp.open("GET", "ajax_calculate_customduty.php?quotTaxId=" + str + "&data=" + b, true);
   	xmlhttp.send();
   
   
   }
   
   
   function cal_totalamountwithduty() {
   	var hdcnt = document.getElementById("conterimp").value;
   	var chka = document.getElementById("CustomDuty").value;
   	if (chka == 0) {
   		var total = 0;
   		for (var j = 0; j < hdcnt; j++) {
   			if (document.getElementById("CustomDutyAmt_" + j).value != '') {
   				var amt = parseFloat(document.getElementById("CustomDutyAmt_" + j).value);
   				total = parseFloat(total) + amt;
   			} else {
   				total = 0;
   			}
   		}
   		total = total;
   		document.getElementById("custondutyval").value = total.toFixed(2);
   	} else {
   		var basic = document.getElementById("total_item_amount").value;
   		var rate = document.getElementById("rateval").value;
   		if (basic == '') {
   			basic = 0;
   		}
   		var calexc = (basic * rate) / 100;
   		document.getElementById("custondutyval").value = calexc.toFixed(2);
   
   	}
   }
   
   
   
   
   function calsuroctamtipm(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (amt * str) / 100;
   	document.getElementById("insurancecharges_amt").value = amount.toFixed(2);
   }
   
   function reversecalsuroctamt(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (100 * str) / amt;
   	document.getElementById("insurancecharges").value = amount.toFixed(2);
   }
   
   function caloverfreight(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (amt * str) / 100;
   	document.getElementById("overseasfrieght_amt").value = amount.toFixed(2);
   }
   
   function reversecaloverfreight(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (100 * str) / amt;
   	document.getElementById("overseasfrieght").value = amount.toFixed(2);
   }
   
   function callocalfreight(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (amt * str) / 100;
   	document.getElementById("localfreight_amt").value = amount.toFixed(2);
   }
   
   function reversecallocalfreight(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var per = parseFloat(document.getElementById("localfreight").value);
   	var amount = (100 * str) / amt;
   	document.getElementById("localfreight").value = amount.toFixed(2);
   }
   
   
   function calclearingforwarding(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (amt * str) / 100;
   	document.getElementById("calclearingforwarding_amt").value = amount.toFixed(2);
   }
   
   function reversecalclearingforwarding(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var per = parseFloat(document.getElementById("clearingforwarding").value);
   	var amount = (100 * str) / amt;
   	document.getElementById("clearingforwarding").value = amount.toFixed(2);
   }
   
   function caldetetioncharges(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var amount = (amt * str) / 100;
   	document.getElementById("detetioncharges_amt").value = amount.toFixed(2);
   }
   
   function reversecaldetetioncharges(str) {
   	var amt = parseFloat(document.getElementById("total_item_amount").value);
   	var per = parseFloat(document.getElementById("detetioncharges").value);
   	var amount = (100 * str) / amt;
   	document.getElementById("detetioncharges").value = amount.toFixed(2);
   }
   
   
   
   
   function cal_grandamountimp() {
   
   	var total = document.getElementById("total_item_amount").value;
   	if (document.getElementById("custondutyval"))
   		var cdis_amt = document.getElementById("custondutyval").value;
   	else
   		var cdis_amt = 0;
   	var insurancecharges_amt = document.getElementById("insurancecharges_amt").value;
   	var overseasfrieght_amt = document.getElementById("overseasfrieght_amt").value;
   	var localfreight_amt = document.getElementById("localfreight_amt").value;
   	var calclearingforwarding_amt = document.getElementById("calclearingforwarding_amt").value;
   	var detetioncharges_amt = document.getElementById("detetioncharges_amt").value;
   	var othercharges = document.getElementById("othercharges").value;
   
   	if (total == '') {
   		total = 0;
   	}
   	if (cdis_amt == '') {
   		cdis_amt = 0;
   	}
   	if (insurancecharges_amt == '') {
   		insurancecharges_amt = 0;
   	}
   	if (overseasfrieght_amt == '') {
   		overseasfrieght_amt = 0;
   	}
   	if (localfreight_amt == '') {
   		localfreight_amt = 0;
   	}
   	if (calclearingforwarding_amt == '') {
   		calclearingforwarding_amt = 0;
   	}
   	if (detetioncharges_amt == '') {
   		detetioncharges_amt = 0;
   	}
   	if (othercharges == '') {
   		othercharges = 0;
   	}
   
   	var grand = document.getElementById("GrandTotal").value;
   
   	grandtotal = parseFloat(total) + parseFloat(cdis_amt) + parseFloat(insurancecharges_amt) + parseFloat(overseasfrieght_amt) + parseFloat(localfreight_amt) + parseFloat(calclearingforwarding_amt) + parseFloat(detetioncharges_amt) + parseFloat(othercharges);
   	document.getElementById("GrandTotal").value = grandtotal.toFixed(2);
   	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
   
   }
   
   
   
   function checkCustomtype(i) {
   	if (document.getElementById("cuntomDuty_Flag_" + i).value == '') {
   		alert("please Select The Custom Duty Flag First !");
   		return false;
   	}
   }
   
   
   <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --INPORT ORDER CALCULATION PART-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- >
   
   
   
   
   <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --DOMESTIC ORDER CALCULATION PART-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- >
   
   
   function checkExcisable(str, i) {
   	if (str == 'NonExcisable') {
   		document.getElementById("exciseDuty_" + i).disabled = true;
   		document.getElementById("exciseValue_" + i).disabled = true;
   		document.getElementById("cess_ID1_" + i).disabled = true;
   		document.getElementById("ECessValue_" + i).disabled = true;
   		document.getElementById("cess_ID2_" + i).disabled = true;
   		document.getElementById("SAHCessValue_" + i).disabled = true;
   		document.getElementById("taxable_amt_" + i).disabled = true;
   
   
   		document.getElementById("exciseDuty_" + i).value = '0';
   		document.getElementById("exciseValue_" + i).value = '';
   		document.getElementById("cess_ID1_" + i).value = '';
   		document.getElementById("ECessValue_" + i).value = '';
   		document.getElementById("cess_ID2_" + i).value = '';
   		document.getElementById("SAHCessValue_" + i).value = '';
   		document.getElementById("taxable_amt_" + i).value = '';
   	} else if (str == 'Excisable' || str == 0) {
   		document.getElementById("exciseDuty_" + i).disabled = false;
   		document.getElementById("exciseValue_" + i).disabled = false;
   		document.getElementById("cess_ID1_" + i).disabled = false;
   		document.getElementById("ECessValue_" + i).disabled = false;
   		document.getElementById("cess_ID2_" + i).disabled = false;
   		document.getElementById("SAHCessValue_" + i).disabled = false;
   		document.getElementById("taxable_amt_" + i).disabled = false;
   	} else {
   		document.getElementById("exciseDuty_" + i).disabled = true;
   		document.getElementById("exciseValue_" + i).disabled = true;
   		document.getElementById("cess_ID1_" + i).disabled = true;
   		document.getElementById("ECessValue_" + i).disabled = true;
   		document.getElementById("cess_ID2_" + i).disabled = true;
   		document.getElementById("SAHCessValue_" + i).disabled = true;
   		document.getElementById("taxable_amt_" + i).disabled = true;
   
   
   		document.getElementById("exciseDuty_" + i).value = '0';
   		document.getElementById("exciseValue_" + i).value = '';
   		document.getElementById("cess_ID1_" + i).value = '';
   		document.getElementById("ECessValue_" + i).value = '';
   		document.getElementById("cess_ID2_" + i).value = '';
   		document.getElementById("SAHCessValue_" + i).value = '';
   		document.getElementById("taxable_amt_" + i).value = '';
   	}
   	document.getElementById("hid_billing_type_" + i).value = str;
   }
   
   
   
   function claculateExcise(id, val) {
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   			var k = data[0];
   			document.getElementById("exciseValue_" + k).value = data[1];
   		}
   	}
   	var id1 = id.split("_");
   	var i = id1[1];
   	var basicamt = document.getElementById("basic_" + i).value;
   	xmlhttp.open("GET", "ajax_getexcisevalue.php?ids=" + id + "&vls=" + val + "&bamt=" + basicamt, true);
   	xmlhttp.send();
   }
   
   
   function checkexiseflag(i) {
   	if (document.getElementById("hid_billing_type_" + i).value == '') {
   		alert("Select Tax Type");
   		document.getElementById("hid_billing_type_" + i).focus();
   	}
   }
   
   
   
   function calEcessonchange(id, val) {
   
   
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   			var k = data[0];
   			document.getElementById("ECessValue_" + k).value = data[1];
   		}
   	}
   	var id1 = id.split("_");
   	var i = id1[2];
   	var ecessval = document.getElementById("exciseValue_" + i).value;
   	xmlhttp.open("GET", "ajax_ecesscalculation.php?ids=" + id + "&vls=" + val + "&Ecessval=" + ecessval, true);
   	xmlhttp.send();
   }
   
   
   
   function calSHEcessonchange(id, val) {
   
   
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   			var k = data[0];
   			document.getElementById("SAHCessValue_" + k).value = data[1];
   		}
   	}
   	var id1 = id.split("_");
   	var i = id1[2];
   	var ecessval = document.getElementById("exciseValue_" + i).value;
   	xmlhttp.open("GET", "ajax_ecesscalculation.php?ids=" + id + "&vls=" + val + "&Ecessval=" + ecessval, true);
   	xmlhttp.send();
   }
   
   
   function calculateTaxable(i) {
   
   	var exciseValue = document.getElementById("exciseValue_" + i).value;
   	var ECessValue = document.getElementById("ECessValue_" + i).value;
   	var SAHCessValue = document.getElementById("SAHCessValue_" + i).value;
   
   	if (exciseValue == '') {
   		exciseValue = 0;
   	}
   	if (ECessValue == '') {
   		ECessValue = 0;
   	}
   	if (SAHCessValue == '') {
   		SAHCessValue = 0;
   	}
   	var TOTAL = parseFloat(exciseValue) + parseFloat(ECessValue) + parseFloat(SAHCessValue);
   	document.getElementById("taxable_amt_" + i).value = TOTAL.toFixed(2);
   }
   
   
   
   function cal_cvd_total_amount(str) {
   	var id_brk = str.split('_');
   	var i = id_brk[1];
   	var basic = document.getElementById("basic_" + i).value;
   	var Totaltaxable = document.getElementById("CustomDutyAmt_" + i).value;
   	if (basic == '') {
   		basic = 0;
   	}
   	if (Totaltaxable == '') {
   		Totaltaxable = 0;
   	}
   
   
   	var grand_tot1 = parseFloat(basic) + parseFloat(Totaltaxable);
   	var cvdPer = document.getElementById("cvd_percentage_" + i).value;
   	var cvd = grand_tot1 * (cvdPer / 100);
   	var grand_tot = cvd.toFixed(2);
   
   	document.getElementById("TotalSpecial_" + i).value = grand_tot;
   
   
   
   
   
   
   }
   
   function cal_e_cess1(id) {
   	var id_brk = id.split('_');
   	var i = id_brk[1];
   
   	var b = document.getElementById("CustomDutyAmt_" + i).value;
   	if (b == '') {
   		b = 0;
   	}
   	var c = document.getElementById("TotalSpecial_" + i).value;
   	var tot1 = parseFloat(b) + parseFloat(c);
   	var ecessPer = document.getElementById("ecess_percentage_" + i).value;
   	var tot = tot1 * (ecessPer / 100);
   	var final_eces = tot.toFixed(2);
   	document.getElementById("customecess_" + i).value = final_eces;
   }
   
   function cal_esec_cess1(id) {
   	var id_brk = id.split('_');
   	var i = id_brk[1];
   	var b = document.getElementById("CustomDutyAmt_" + i).value;
   	if (b == '') {
   		b = 0;
   	}
   	var c = document.getElementById("TotalSpecial_" + i).value;
   	var tot1 = parseFloat(b) + parseFloat(c);
   	var secEcessPer = document.getElementById("secess_percentage_" + i).value;
   	var tot = tot1 * (secEcessPer / 100);
   	var final_eces1 = tot.toFixed(2);
   	document.getElementById("customsececess_" + i).value = final_eces1;
   }
   
   function cal_add_duty1(id) {
   	var id_brk = id.split('_');
   	var i = id_brk[1];
   	var a = document.getElementById("basic_" + i).value;
   	var b = document.getElementById("CustomDutyAmt_" + i).value;
   	if (b == '') {
   		b = 0;
   	}
   	var c = document.getElementById("TotalSpecial_" + i).value;
   	var d = document.getElementById("customecess_" + i).value;
   	var e = document.getElementById("customsececess_" + i).value;
   	var tot12 = parseFloat(a) + parseFloat(b) + parseFloat(c) + parseFloat(d) + parseFloat(e);
   	var addPer = document.getElementById("add_percentage_" + i).value;
   	var tot1 = tot12 * (addPer / 100);
   	var final_eces2 = tot1.toFixed(2);
   	document.getElementById("adduty_" + i).value = final_eces2;
   
   }
   
   
   
   function cal_grandtotal(i) {
   	var type_of_bill = document.getElementById("hid_billing_type_" + i).value;
   	var basic = document.getElementById("basic_" + i).value;
   	var Totaltaxable = document.getElementById("taxable_amt_" + i).value;
   	if (basic == '') {
   		basic = 0;
   	}
   	if (Totaltaxable == '') {
   		Totaltaxable = 0;
   	}
   	if (document.getElementById("hid_billing_type_" + i).value == 'NonExcisable') {
   		var grand_tot1 = parseFloat(basic);
   		var grand_tot = grand_tot1.toFixed(2);
   	} else if (document.getElementById("hid_billing_type_" + i).value == 'IncludeTax') {
   		var grand_tot1 = parseFloat(basic);
   		var grand_tot = grand_tot1.toFixed(2);
   	} else {
   		var grand_tot1 = parseFloat(basic) + parseFloat(Totaltaxable);
   		var grand_tot = grand_tot1.toFixed(2);
   	}
   	document.getElementById("TotalSpecial_" + i).value = grand_tot;
   }
   
   
   
   function calcPackaging(str) {
   	if (str != '') {
   		var tota_amt = document.getElementById("total_item_amount").value;
   		var pckgng_val = (str / 100) * tota_amt;
   		document.getElementById("pkg_charges1").value = pckgng_val.toFixed(2);
   	}
   }
   
   
   
   function tax_rate1(str) {
   	var taxableAmount = document.getElementById("total_item_amount").value;
   	var taxableAmount1 = document.getElementById("pkg_charges1").value;
   	if (taxableAmount1 == '') {
   		taxableAmount1 = 0;
   	}
   	var taxableAmount2 = parseFloat(taxableAmount) + parseFloat(taxableAmount1);
   	if (str.length == 0) {
   		document.getElementById("taxval").innerHTML = "";
   		return;
   	}
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			document.getElementById("taxval").innerHTML = xmlhttp.responseText;
   		}
   	}
   	xmlhttp.open("GET", "get_tax_valdata.php?taxid=" + str + "&amt=" + taxableAmount2, true);
   	xmlhttp.send();
   }
   
   
   function calsuroctamt(str) {
   	var amt = parseFloat(document.getElementById("taxvalue").value);
   	var suroctper = parseFloat(document.getElementById("sur_oct_per").value);
   	var amount = (amt * suroctper) / 100;
   	document.getElementById("sur_oct_amt").value = amount.toFixed(2);
   }
   
   
   function cal_grandamount() {
   
   	var total = document.getElementById("total_item_amount").value;
   	var sur_oct_amt = document.getElementById("sur_oct_amt").value;
   	var TotalCharge = document.getElementById("TotalCharge").value;
   	var taxamt = document.getElementById("taxvalue").value;
   	var packagingCharges = document.getElementById("pkg_charges1").value;
   	var additionalCharges = document.getElementById("additionalCharges").value;
   	if (total == '') {
   		total = 0;
   	}
   	if (sur_oct_amt == '') {
   		sur_oct_amt = 0;
   	}
   	if (TotalCharge == '') {
   		TotalCharge = 0;
   	}
   	if (packagingCharges == '') {
   		packagingCharges = 0;
   	}
   	if (additionalCharges == '') {
   		additionalCharges = 0;
   	}
   	if (taxamt == '') {
   		taxamt = 0;
   	}
   	var grand = document.getElementById("GrandTotal").value;
   	grandtotal = parseFloat(total) + parseFloat(sur_oct_amt) + parseFloat(TotalCharge) + parseFloat(packagingCharges) + parseFloat(additionalCharges) + parseFloat(taxamt);
   	document.getElementById("GrandTotal").value = grandtotal.toFixed(2);
   	document.getElementById("orig_grand_tot").value = grandtotal.toFixed(2);
   }
   
   function ajax_cur_rate_cal(str, id) {
   	var basicAmt = document.getElementById("NetRate_" + id).value;
   	if (document.getElementById("conv_rate_" + id).value != '')
   		var con_fac = document.getElementById("conv_rate_" + id).value;
   	else
   		var con_fac = 1;
   	var total = parseFloat(basicAmt) * parseFloat(con_fac);
   	document.getElementById("basic_" + id).value = total.toFixed(2);
   
   
   
   
   }
   
   function ajax_cur_rate(str, id) {
   	var basicAmt = document.getElementById("NetRate_" + id).value;
   	var oldid = document.getElementById("itemCurrency_" + id).value;
   	if (str == '') {
   		document.getElementById("conv_rate_" + id).value = "";
   		return;
   	}
   
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   
   			var data = xmlhttp.responseText.split("__");
   			if (data[0] == "") {
   				alert('Conversion Rate is Empty');
   				document.getElementById("conv_curr_" + id).focus();
   				return false;
   			} else {
   				document.getElementById("conv_rate_" + id).value = data[0];
   			}
   			document.getElementById("basic_" + id).value = data[1];
   		}
   	}
   	xmlhttp.open("GET", "ajax_get_rate.php?oldCur=" + oldid + "&newCur=" + str + "&basicAmount=" + basicAmt, true);
   	xmlhttp.send();
   }
   
   function ajax_cur_rate_tot(str) {
   	var basicAmt = document.getElementById("total_item_amount").value;
   	var oldid = document.getElementById("oldCurrency").value;
   	if (str == '') {
   		document.getElementById("tot_conv_rate").value = "";
   		return;
   	}
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   			var data = xmlhttp.responseText.split("__");
   			if (data[0] == "") {
   				alert('Conversion Rate is Empty');
   				document.getElementById("tot_conv_rate").focus();
   				return false;
   			} else {
   				document.getElementById("tot_conv_rate").value = data[0];
   			}
   			document.getElementById("tot_conv_amt").value = data[1];
   		}
   	}
   	xmlhttp.open("GET", "ajax_get_rate.php?oldCur=" + oldid + "&newCur=" + str + "&basicAmount=" + basicAmt, true);
   	xmlhttp.send();
   }
   
   function claculateExcise(id, str) {
   	var id_brk = id.split('_');
   	var i = id_brk[1];
   	if (id_brk.length > 1) {
   		var b = document.getElementById("basic_" + i).value;
   	} else {
   		var b = document.getElementById("basic").value;
   	}
   
   
   
   	if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
   		xmlhttp = new XMLHttpRequest();
   	} else { // code for IE6, IE5
   		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   	}
   	xmlhttp.onreadystatechange = function() {
   		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
   
   			if (id_brk.length > 1) {
   				var data = xmlhttp.responseText.split("__");
   				document.getElementById("dutyamount_" + i).value = data[1];
   
   			} else {
   				var data = xmlhttp.responseText.split("__");
   				document.getElementById("dutyamount").value = data[1];
   			}
   		}
   	}
   	xmlhttp.open("GET", "calculatecustomduty.php?quotTaxId=" + str + "&data=" + b, true);
   	xmlhttp.send();
   	var count = document.getElementById("count").value;
   	var tot_cvd1 = 0;
   	for (var h = 0; h < count; h++) {
   		var discAmt = document.getElementById("basic_" + h).value;
   		if (discAmt == '') {
   			discAmt = 0;
   		}
   		tot_cvd1 = parseFloat(tot_cvd1) + parseFloat(discAmt);
   	}
   	document.getElementById("total_item_amount12").value = tot_cvd1.toFixed(2);
   }
   
   function cal_cvd_total(id) {
   	var count = document.getElementById("conterimp").value;
   	var tot_cvd = 0;
   	for (var i = 0; i < count; i++) {
   		var cvd = document.getElementById("TotalSpecial_" + i).value;
   		if (cvd == '') {
   			cvd = 0;
   		}
   		tot_cvd = parseFloat(tot_cvd) + parseFloat(cvd);
   	}
   	//alert(tot_cvd);
   	document.getElementById("cvd_total").value = tot_cvd.toFixed(2);
   }
   
   
   function cal_cvd_total11(id) {
   	var count = document.getElementById("conterimp").value;
   	var tot_cvd = 0;
   	for (var i = 0; i < count; i++) {
   		var cvd = document.getElementById("TotalSpecial_" + i).value;
   		if (cvd == '') {
   			cvd = 0;
   		}
   		tot_cvd = parseFloat(tot_cvd) + parseFloat(cvd);
   	}
   
   
   	var cvdtot = document.getElementById("cvd_total").value;
   	if (cvdtot == "") {
   		document.getElementById("cvd_total").value = document.getElementById("TotalSpecial_" + i).value;
   	} else {
   		var sum2 = parseFloat(cvdtot) + parseFloat(document.getElementById("TotalSpecial_" + i).value);
   		document.getElementById("cvd_total").value = sum2.toFixed(2);
   	}
   }
   
   function cal_ecess_total(id) {
   	var ecestot = document.getElementById("custom_ecess").value;
   	if (ecestot == "") {
   		document.getElementById("custom_ecess").value = document.getElementById("customecess_" + i).value;
   	} else {
   		var sum3 = parseFloat(ecestot) + parseFloat(document.getElementById("customecess_" + i).value);
   		document.getElementById("custom_ecess").value = sum3.toFixed(2);
   	}
   }
   
   function cal_ecess_sec_total(id) {
   	var ecesectot = document.getElementById("custom_sec_ecess").value;
   	if (ecesectot == "") {
   		document.getElementById("custom_sec_ecess").value = document.getElementById("customsececess_" + i).value;
   	} else {
   		var sum4 = parseFloat(ecesectot) + parseFloat(document.getElementById("customsececess_" + i).value);
   		document.getElementById("custom_sec_ecess").value = sum4.toFixed(2);
   	}
   }
   
   function cal_addcharg_total(id) {
   	var adcharge = document.getElementById("additionalCharges").value;
   	if (adcharge == "") {
   		document.getElementById("additionalCharges").value = document.getElementById("adduty_" + i).value;
   	} else {
   		var sum5 = parseFloat(adcharge) + parseFloat(document.getElementById("adduty_" + i).value);
   		document.getElementById("additionalCharges").value = sum5.toFixed(2);
   	}
   }
   
   <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --DOMESTIC ORDER CALCULATION PART-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- >
   function validation() {
   	if (document.getElementById("sitecode").value == '000') {
   		alert('Select Branch');
   		document.getElementById("sitecode").focus();
   		return false;
   	}
   
   	if (document.getElementById("receiviedagaist").value == '0') {
   		alert('Select Received Against');
   		document.getElementById("receiviedagaist").focus();
   		return false;
   	}
   
   	if (document.getElementById("vendor").value == '') {
   		alert('Select Received From');
   		document.getElementById("vendor").focus();
   		return false;
   	}
   
   	if (document.getElementById("gatepassno").value == '') {
   		alert('Enter Gate Entry No');
   		document.getElementById("gatepassno").focus();
   		return false;
   	}
   
   	if (document.getElementById("gatepassdate").value == '') {
   		alert('Enter Gate Pass Date');
   		document.getElementById("gatepassdate").focus();
   		return false;
   	}
   }
</script>
<!-------------------------------------------JS PART END HERE--------------AS---------14-06-2013---------------->
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div" style="width:100.5%">
<h1><?php echo $s->getField('modules_form', 'id', $_REQUEST['frmid'], 'frm_name'); ?></h1>
<form action="" method="post" onsubmit="return validation()">
   <div id="inprno1"></div>
   <table width="100%" border="0" cellspacing="0" cellpadding="3">
      <tr class="row1">
         <td width="13%" align="right">Branch <font color="#FF0000">*</font>
         </td>
         <?php //echo "<pre>"; print_r( $_SESSION);die("EE");?>
         <td width="20%">
            <?php $SQLSite = DB_query("Select loccode,locationname from locations where CompanyId='" . $_SESSION['ACGCompanyId'] . "' and loccode in ('" . $_SESSION['AssignedBranch'] . "')", $db); ?>
            <select name="sitecode" id="sitecode" onchange="GetStore(this.value)">
               <option value="000">Select Branch</option>
               <?php while ($site_row = DB_fetch_array($SQLSite)) { ?>
               <option value="<?php echo $site_row['loccode']; ?>" <?php echo ($sitecode == $site_row['loccode'] ? 'selected' : '') ?>><?php echo $site_row['locationname']; ?></option>
               <?php } ?>
            </select>
         </td>
         <td width="13%" align="right">GRN No.</td>
         <td width="20%"><input type="text" value="Will Be Generated On Saving" name="MRNNo" readonly="true"></td>
         <td width="13%" align="right">GRN Date</td>
         <td align="left" valign="top"><input type="text" name="MRNdate" value="<?php if (isset($_SESSION['MRNdate'])) echo $MRNdate;
            else echo date('d/m/Y'); ?>" id="MRNdate" class="datepicker"></td>
      </tr>
      <tr class="row1">
         <td align="right">Store <font color="#FF0000">*</font>
         </td>
         <td>
            <select id="storecode" name="storecode" onfocus="check_po()">
               <option value="">Select Store</option>
               <?php $sql_store = DB_query("select id, StoreName from storetype where Store_Site IN('" . $_SESSION['AssignedBranch'] . "') and CompanyId='" . $_SESSION['ACGCompanyId'] . "' order by StoreCode ASC", $db); ?>
               <?php while ($Storedetail = DB_fetch_array($sql_store)) { ?>
               <option value="<?php echo $Storedetail['id']; ?>"><?php echo $Storedetail['StoreName']; ?></option>
               <?php } ?>
            </select>
         </td>
         <td align="right">Received Against <font color="#FF0000">*</font>
         </td>
         <td>
            <select name="receiviedagaist" id="receiviedagaist" onchange="ChkGRNType(this.value)">
               <option value="PO">PO</option>
               <option value="stock_transfer">Stock Transfer</option>
            </select>
         </td>
         <td align="right">Received From <font color="#FF0000">*</font>
         </td>
         <td>
            <select name="vendor" id="vendor" style="width:98%;" onchange='GetIndentPONo(this.value)'>
               <option value="">Select</option>
               <?php $sql = "select id  ,vendor_code, vendor_name from suppliers where CompanyId='" . $_SESSION['ACGCompanyId'] . "'";
                  $result = DB_query($sql, $db);
                  while ($myrow = DB_fetch_array($result)) {
                  	$p = '';
                  	if ($vendor == $myrow['id'])
                  		$p = "selected";
                  ?>
               <option value="<?php echo $myrow['id']; ?>" <?php echo $p; ?>><?php echo  str_replace(array("M/s ", "M/S"), '', $myrow['vendor_name']); ?></option>
               <?php }	?>
            </select>
         </td>
      </tr>
      <tr class="row1">
         <td align="right">PO No.</td>
         <td align="left" valign="top" id="GtT4">
            <select name="PONo" id="PONo" onchange="loadInvoiceDetails(this.value);">
               <option value="">Select</option>
            </select>
         </td>
         <td align="right">Type</td>
         <td id="inprno">
            <select name="poType" id="poType">
               <option value="">Select</option>
            </select>
         </td>
         <td align="right">Transporter Name:</td>
         <td>
            <select name="transport" id="transport">
               <option value="0">Select</option>
               <?php $trans = DB_query("select * from transport_master where CompanyId='" . $_SESSION['ACGCompanyId'] . "'", $db);
                  while ($trow = DB_fetch_array($trans)) {
                  	$p = '';
                  	if ($trow['id'] == $mrn_query_result['Transp_name'])
                  		$p = "selected";
                  ?>
               <option value="<?php echo $trow['id']; ?>" <?php echo $p; ?>><?php echo $trow['TransportName']; ?></option>
               <?php } ?>
            </select>
         </td>
      </tr>
      <tr class="row1">
         <td align="right">PO Category</td>
         <td id="GtT6">
            <select name="purch_ord_category" id="purch_ord_category">
               <option value="0">Select</option>
               <option value='AT'>Asset</option>
               <option value='MT'>Material</option>
               <option value='SV'>Service</option>
            </select>
         </td>
         <td align="right">Document Type</td>
         <td>
            <select name="DocumentType" id="DocumentType">
               <option value="Challan">Challan</option>
               <option value="Bill">Bill</option>
            </select>
         </td>
         <td align="right">Document No.</td>
         <td><input name="billno" type="text" id="billno" value="<?php echo $billno; ?>" /></td>
      </tr>
      <tr class="row1">
         <td align="right">Challan / Bill Date</td>
         <td><input type="text" name="MRNVoucherDate" class="datepicker" onblur="valdate();" value="<?php if (isset($_SESSION['MRNVoucherDate'])) echo $MRNVoucherDate;
            else echo date('d/m/Y'); ?>" /></td>
         <td align="right">Gate Entry No.<font color="#FF0000">*</font>
         </td>
         <td>
            <input type="text" name="gatepassno" id="gatepassno" value="<?php echo $gatepassno; ?>"
               onkeyup="checkgatentyno(this.value)" ; />
            <div id="entrycheck1"><input type="hidden" name="entrycheck" id="entrycheck" value="<?php echo $entrycheck; ?>" /></div>
         </td>
         <td align="right">Gate Entry Date<font color="#FF0000">*</font>
         </td>
         <td><input type="text" name="gatepassdate" id="gatepassdate" class="datepicker" /></td>
      </tr>
      <tr class="row1">
         <td align="right">Receiving Time</td>
         <td>
            <select name="timein" id="timein" style="width:49%;">
               <option value="Day" <?php echo $timein == 'Day' ? 'selected' : '' ?>>Day</option>
               <option value="Night" <?php echo $timein == 'Night' ? 'selected' : '' ?>>Night</option>
            </select>
            <input type="text" name="timeout" value="<?php if (isset($_SESSION['timeout'])) echo $timeout;
               else echo date("h:i:s", time()); ?>" style="width:49%;">
         </td>
         <td align="right">Vehicle No.</td>
         <td><input name="vehicalno" type="text" id="vehicalno" value="<?php echo $vehicalno; ?>" /></td>
         <td align="right">L R No.</td>
         <td><input name="lrno" type="text" id="lrno" value="<?php echo $lrno; ?>" /></td>
      </tr>
      <tr class="row1">
         <td align="right">L R Date</td>
         <td><input name="lrdate" type="text" id="lrdate" value="<?php if (isset($_SESSION['lrdate'])) echo $lrdate;
            else echo date('d/m/Y'); ?>" onblur="LRdate();" class="datepicker" /></td>
         <td align="right">Form Type</td>
         <td><input type="text" name="form_type" id="form_type" /></td>
         <td align="right">Form No.</td>
         <td><input type="text" name="form_no" id="form_no" /></td>
      </tr>
      <tr class="row1">
         <td align="right">Remarks</td>
         <td colspan="5"><textarea name="RemarksIfAny" id="RemarksIfAny" style="width:100%;"><?php echo $RemarksIfAny; ?></textarea></td>
      </tr>
   </table>
   <div id="alldatadetails" style="width:100%;overflow-x:scroll;"></div>
   <div id="basicamtdetails"></div>
   <p style="text-align:center;">
      <input type="submit" name="save" value="Save" class="search" onclick="return confirmPost()" /><!--<input type="reset" name="reset" value="Reset" class="search" />-->&nbsp;<a href="index.php?route=Inventory/transation/material_receipt_note_index&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>&NewReturn=yes"><input type="button" class="search" value="Cancel" name="Back" /></a>
   </p>
</form>
<script type="text/javascript">
   function confirmPost() {
   	var check = 0;
   	jQuery('input[id^=qtyasperbill_]').each(function() {
   		var amount = jQuery(this).val();
   		if (amount == '0' || amount == '')
   			check = 1;
   	});
   	if (check == 1) {
   		alert("Bill Qty cannot be 0");
   		return false;
   	}
   }
   
   function loadInvoiceDetails(invoice_id) {
   	$.post("ajax_getpodetails1.php", {
   		"invoice_id": invoice_id,
   		"invoice_details": "yes"
   	}, function(data) { //alert(data);
   		if (data != '') {
   			document.getElementById("alldatadetails").innerHTML = data;
   		}
   	});
   }
</script>