<?php
require_once("../config/config.php");
@extract($_POST);
if($_POST){
	if ($_POST['upd']=='Process'){
  		if($total_qty!='' && $total_qty!=0){
			///// initialize variable
			mysqli_autocommit($link1, false);
			$flag = true;
			$err_msg = "";
    		//// Make System generated ref no.//////
			$res_po=mysqli_query($link1,"select max(temp_no) as no from vendor_order_master where po_to='".$parentcode."' and req_type='VRN'");
			$row_po=mysqli_fetch_array($res_po);
			$c_nos=$row_po['no']+1;
			$po_no=$parentcode."VRN".$c_nos;
			///// Insert Master Data
			$query1= "INSERT INTO vendor_order_master set po_to='".$parentcode."',po_from='".$partycode."',po_no='".$po_no."',temp_no='".$c_nos."',ref_no='".$ref_no."',requested_date='".$today."',entry_date='".$today."',entry_time='".$currtime."',req_type='VRN',status='Dispatched',po_value='".$sub_total."',create_by='".$_SESSION['userid']."',ip='".$ip."',taxtype='".$tax_type0."',taxper='".$tax_per0."',taxamount='".$tax_total0."',
 taxtype1='".$tax_type1."',tax_per1='".$tax_per1."',taxamount1='".$tax_total1."', taxtype2='".$tax_type2."',tax_per2='".$tax_per2."',taxamount2='".$tax_total2."', taxtype3='".$tax_type3."',tax_per3='".$tax_per3."',taxamount3='".$tax_total3."',  taxtype4='".$tax_type4."',tax_per4='".$tax_per4."',taxamount4='".$tax_total4."',currency_type='".$currency_type."',invoice_no='".$invoiceno."',invoice_date='".$invoicedate."',remark='".$remark."',grand_total='".$grand_total."',delivery_address='".$delivery_address."',payment_status='".$payment_terms."'";
			
			$result = mysqli_query($link1,$query1);
			//// check if query is not executed
			if (!$result) {
				$flag = false;
				$err_msg = "Error details1: " . mysqli_error($link1) . ".";
			}	///// Insert in item data by picking each data row one by one
			foreach($prod_code as $k=>$val)
			{   
				// checking row value of product and qty should not be blank
				$getstk = getCurrentStock($parentcode,$val,"okqty",$link1);
				//// check stock should be available ////
				if($getstk < $req_qty[$k]){ 
				   $flag = false;
				   $err_msg = "Error Code3: Stock is not available";
				}
	    		else{}
	    		// checking row value of product and qty should not be blank
				if($prod_code[$k]!='' && $req_qty[$k]!='' && $req_qty[$k]!=0) {
					/////////// insert data
	  				$query2="insert into vendor_order_data set po_no='".$po_no."', prod_code='".$val."', req_qty='".$req_qty[$k]."', po_price='".$price[$k]."', po_value='".$linetotal[$k]."', mrp='".$mrp[$k]."', totalval='".$linetotal[$k]."',currency_type='".$currency_type."',uom='PCS', deliv_schedule='".$deliv_date[$k]."'";
					
					$result = mysqli_query($link1, $query2);
				   //// check if query is not executed
				   if (!$result) {
					   $flag = false;
					   $err_msg =  "Error details2: " . mysqli_error($link1) . ".";
				   }
				   //// update stock of from loaction
				 	$result=mysqli_query($link1, "update stock_status set okqty=okqty-'".$req_qty[$k]."',updatedate='".$datetime."' where asc_code='".$parentcode."' and partcode='".$val."'");
				   //// check if query is not executed
				   if (!$result) {
					   $flag = false;
					   $err_msg =  "Error details4: " . mysqli_error($link1) . ".";
				   }
				   if($_POST[$okqty]!="" && $_POST[$okqty]!=0 && $_POST[$okqty]!=0.00){
					  $flag=stockLedger($po_no,$today,$val,$parentcode,$partycode,$parentcode,"OUT","OK","Vendor Return",$req_qty[$k],$price[$k],$_SESSION['userid'],$today,$currtime,$ip,$link1,$flag);
				   }
				}// close if loop of checking row value of product and qty should not be blank
			}/// close for loop
			////// maintain party ledger////
			$flag=partyLedger($partycode,$parentcode,$po_no,$today,$today,$currtime,$_SESSION['userid'],"VRN",$grand_total,"DR",$link1,$flag);
			////// insert in activity table////
			$flag=dailyActivity($_SESSION['userid'],$po_no,"VRN","ADD",$ip,$link1,$flag);
			if ($flag) {
				mysqli_commit($link1);
				$msg = "Purchase Return is successfully placed with ref. no. ".$po_no;
			} else {
				mysqli_rollback($link1);
				$msg = "Request could not be processed. Please try again.".$err_msg;
			} 
    		mysqli_close($link1);
		}else{
	 		$msg = "Request could not be processed . Please dispatch some qty.".$err_msg;
		}
     	///// move to parent page
		header("location:vendor_return.php?msg=".$msg."".$pagenav);
   		exit;
	}
}

$address=mysqli_query($link1,"Select * from vendor_order_master where po_no='".$_REQUEST['inv_no']."' and po_to='".$_REQUEST['po_to']."' and po_from='".$_REQUEST['po_from']."'"); 
$row1=mysqli_fetch_assoc($address);
?>
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title><?=siteTitle?></title>
 <script src="../js/jquery.min.js"></script>
 <link href="../css/font-awesome.min.css" rel="stylesheet">
 <link href="../css/abc.css" rel="stylesheet">
 <script src="../js/bootstrap.min.js"></script>
 <link href="../css/abc2.css" rel="stylesheet">
 <link rel="stylesheet" href="../css/bootstrap.min.css">
 <link rel="stylesheet" href="../css/bootstrap-select.min.css">
 <script src="../js/bootstrap-select.min.js"></script>

 <link rel="stylesheet" href="../css/jquery.dataTables.min.css">
 <script type="text/javascript" src="../js/jquery.dataTables.min.js"></script>
 <script type="text/javascript">
$(document).ready(function(){
    $('#myTable').dataTable();
});
$(document).ready(function(){
    $("#frm2").validate();
});
</script>
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="../js/common_js.js"></script>
<script type="text/javascript" src="../js/ajax.js"></script>
<script type="text/javascript" >
/////////// function to get available stock of ho
  function getAvlStk(indx){
   var productCode=document.getElementById("prod_code["+indx+"]").value;
   var locationCode=$('#po_from').val();
   var stocktype="okqty";
   $.ajax({
     type:'post',
  url:'../includes/getAzaxFields.php',
  data:{locstk:productCode,loccode:locationCode,stktype:stocktype,indxx:indx},
  success:function(data){ 
   var getdata=data.split("~");
  
         document.getElementById("avl_stock["+getdata[1]+"]").value=getdata[0];
     }
   });
   //rowTotal(indx);
  }
//////////////////chk enter qty should not exceed by avl qty ///////
function  check_qty(ind){
	
	var avl="req["+ind+"]";
	
  var req1="req_qty["+ind+"]";
  
	var availble=document.getElementById(avl).value;
	
  var requested=document.getElementById(req1).value;
  if(parseFloat(requested) > parseFloat(availble)){
	  
     alert("Entered Qty is more then Bill  Qty.");
     document.getElementById(req1).value="0.00";
	  return false;
  }
  rowTotal(ind);
}
 /////// calculate line total /////////////
function rowTotal(ind){
  	var req="req["+ind+"]";
  	var ent_qty="req_qty["+ind+"]";
 	var hident_qty="hidreq_qty["+ind+"]";
 	var line="linetotal["+ind+"]";
  	var ent_rate="price["+ind+"]";
	var availableQty="avl_stock["+ind+"]";
  	var prodCodeField="prod_code["+ind+"]";	

/////  check if entered qty is somthing
 if(document.getElementById(ent_qty).value){ var qty=document.getElementById(ent_qty).value;
 }else{ var qty=0;}

  /////  check if entered price is somthing
  if(document.getElementById(ent_rate).value){ var price=document.getElementById(ent_rate).value;}else{ var price=0.00;} 

  ////// check entered qty should be available
  if(parseFloat(qty) <= parseFloat(document.getElementById(availableQty).value)){
	 var total= parseFloat(qty)*parseFloat(price);
     var totalcost= parseFloat(total);
     var var3="linetotal["+ind+"]";
     document.getElementById(var3).value=formatCurrency(total);
     calculatetotal();
  }
  else if(parseFloat(document.getElementById(availableQty).value)=='0.00'){
	  alert("Stock is not Available");  
	  document.getElementById(ent_qty).value="";
	  //document.getElementById(availableQty).value="";
	  document.getElementById(ent_rate).value="";
	  document.getElementById(hold_rate).value="";
	  document.getElementById(prodCodeField).value="";
	  document.getElementById(prodmrpField).value="";
	  document.getElementById(prodCodeField).focus();
	  }
  else{
	 alert("Stock is  not Available");
	  document.getElementById(ent_qty).value="";
	  //document.getElementById(availableQty).value="";
	  //document.getElementById(ent_rate).value="";
	  //document.getElementById(hold_rate).value="";
	 // document.getElementById(prodCodeField).value="";
	  //document.getElementById(prodmrpField).value="";
	 // document.getElementById(prodCodeField).focus();
  }
}
////// calculate final value of form /////
function calculatetotal(){
	var rowno = document.getElementById("rownoo").value;
	//alert(rowno);
	var sum_qty=0.00;
	var total_dis=0.00;
	var total_tax=0.00;
	var grand=0.00; 
	var linewisetot = 0.00;
	
    for(var i=0;i<rowno;i++){
	    var temp_qty="req_qty["+i+"]";
		var linetot ="linetotal["+i+"]";

		
		if(document.getElementById(temp_qty).value){ qty= document.getElementById(temp_qty).value;}else{ qty=0.00;}			
		///// check total qty
		sum_qty+=parseFloat(qty);
		linewisetot+=parseFloat(document.getElementById(linetot).value);		
		
}/// close for loop

    document.getElementById("total_qty").value=formatCurrency(sum_qty);
   document.getElementById("sub_total").value=formatCurrency(linewisetot);
   
   getTax();
}
////////////////////////////calculate tax /////////////////////////////////////////////////////////////
 function getTax() {
	var total_tax = 0.00;
	var ctax = $("#taxrow").val();									
	var sub_amt = $("#sub_total").val();												
	//////////
	for (i = 0; i < ctax; i++) {
		//total.push($("#tax_per" + i).val());
		var taxper = $("#tax_per" + i).val();
		var taxamt = ((parseFloat(sub_amt) * parseFloat(taxper))/100).toFixed(2);
		//alert(taxamt);
		$("#tax_total" + i).val(taxamt);
		total_tax += parseFloat(taxamt);
	}
	var gd = parseFloat(total_tax) + parseFloat(sub_amt);
	//alert(gd);
	$("#grand_total").val(parseFloat(Math.round(gd)).toFixed(2));
}
////////////////////////////////////////////End //////////////////////////////////////////////
</script>
</head>
<body onKeyPress="return keyPressed(event);">
<div class="container-fluid">
  <div class="row content">
	<?php 
    include("../includes/leftnav2.php");
    ?>
    <div class="col-sm-9">
      <h2 align="center"><i class="fa fa-reply-all fa-lg"></i> Add New Purchase Return </h2><br/>
      <div class="form-group"  id="page-wrap" style="margin-left:10px;">
          <form id="frm1" name="frm1" class="form-horizontal" action="" method="post">
          <div class="form-group">
            <div class="col-md-10"><label class="col-md-3 control-label">Purhase Return From<span style="color:#F00">*</span></label>
              <div class="col-md-9">
                 <select name="po_from" id="po_from" required class="form-control selectpicker required" data-live-search="true" onChange="document.frm1.submit();">
                    <option value="" selected="selected">Please Select </option>
                    <?php 
					$sql_chl="select * from access_location where uid='$_SESSION[userid]' and status='Y' and location_id like '%HO%'";
					$res_chl=mysqli_query($link1,$sql_chl);
					while($result_chl=mysqli_fetch_array($res_chl)){
	                      $party_det=mysqli_fetch_array(mysqli_query($link1,"select name , city, state,id_type from asc_master where asc_code='$result_chl[location_id]'"));
	                      if($party_det['id_type']=='HO'){
                          ?>
                    <option data-tokens="<?=$party_det['name']." | ".$result_chl['location_id']?>" value="<?=$result_chl['location_id']?>" <?php if($result_chl['location_id']==$_REQUEST['po_from'])echo "selected";?> >
                       <?=$party_det['name']." | ".$party_det['city']." | ".$party_det['state']." | ".$result_chl['location_id']?>
                    </option>
                    <?php
						  }
					}
                    ?>
                 </select>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-10"><label class="col-md-3 control-label">Purhase Return To<span style="color:#F00">*</span></label>
              <div class="col-md-9">
                 <select name="po_to" id="po_to" required class="form-control selectpicker required" data-live-search="true" onChange="document.frm1.submit();">
                 <option value="" selected="selected">Please Select </option>
                    <?php 
					$sql_parent="select * from vendor_master where status='active' and id!=''";
					$res_parent=mysqli_query($link1,$sql_parent);
					while($result_parent=mysqli_fetch_array($res_parent)){
                          ?>
                    <option data-tokens="<?=$result_parent['name']." | ".$result_parent['id']?>" value="<?=$result_parent['id']?>" <?php if($result_parent['id']==$_REQUEST['po_to'])echo "selected";?> >
                       <?=$result_parent['name']." | ".$result_parent['city']." | ".$result_parent['state']." | ".$result_parent['country']?>
                    </option>
                    <?php
					}
                    ?>
                 </select>
              </div>
            </div>
          </div>
		  
          <div class="form-group">
		  <?php if($_REQUEST['po_to']!='' && $_REQUEST['po_from']!=''){?>
		  <div class="col-md-10">
              <label class="col-md-3 control-label">PO Number</label>
              <div class="col-md-4">
			 <select name="inv_no" id="inv_no" required class="form-control selectpicker required" data-live-search="true" onChange="document.frm1.submit();">
                 <option value="" selected="selected">Please Select </option>
                    <?php 
					$sql_parent="select po_no from vendor_order_master where po_to='$_REQUEST[po_to]' and po_from='$_REQUEST[po_from]' and req_type='VPO' and status='Received'";
					$res_parent=mysqli_query($link1,$sql_parent);
					while($result_parent=mysqli_fetch_array($res_parent)){
	                      ?>
                    <option data-tokens="<?=$result_parent['po_no']?>" value="<?=$result_parent['po_no']?>"<?php if($result_parent['po_no']==$_REQUEST['inv_no'])echo "selected";?>>
                       <?=$result_parent['po_no']?>
                    </option>
                     <?php
					}
                    ?>
                 </select>
              </div>
          </div>
		  <?php }?>
        </div>
         </form>
         <form id="frm2" name="frm2" class="form-horizontal" action="" method="post">
          <div class="form-group"  id="page-wrap" style="margin-left:10px;"><br/><br/>
		   <?php if($_REQUEST['inv_no']!=''){ ?> 
          <table width="100%" id="myTable" class="table table-bordered table-hover">
            <thead>
              <tr class="<?=$tableheadcolor?>" >
                <th data-class="expand" class="col-md-3" style="font-size:12px;">Product</th>
                <th class="col-md-1" style="font-size:12px">Qty</th>
                <th data-hide="phone"  class="col-md-1" style="font-size:12px">Price</th>
                <th data-hide="phone"  class="col-md-1" style="font-size:12px">Value</th>
              </tr>
            </thead>
            <tbody>
			<?php
			$i=0;
			$total_qty=0.00;
			$sql=mysqli_query($link1,"Select * from vendor_order_data  where po_no='$_REQUEST[inv_no]'");
			while($row=mysqli_fetch_assoc($sql)){
			?>
              <tr>
				<td align="left"><input type="text" style="width:130px;"   class="form-control"   value="<?php echo getProduct($row['prod_code'],$link1);?>" readonly>
                <input type="hidden" name="req[<?php echo $i;?>]" id="req[<?php echo $i;?>]" value="<?php echo $row[req_qty];?>"/>
                <input type="hidden" name="avl_stock[<?php echo $i;?>]" id="avl_stock[<?php echo $i;?>]" value="<?php echo getCurrentStock($_REQUEST['po_from'], $row['prod_code'], 'okqty', $link1);?>" />
				
				<input type="hidden" name="prod_code[<?php echo $i;?>]" id="prod_code[<?php echo $i;?>]" class="form-control" value="<?php echo $row['prod_code'];?>">
                
                <input type="hidden" name="prod_cat[<?php echo $i;?>]" id="prod_cat[<?php echo $i;?>]" class="form-control" value="<?php echo $row['prod_cat'];?>">
                <input type="hidden" name="mrp[<?php echo $i;?>]" id="mrp[<?php echo $i;?>]" class="form-control" value="<?php echo $row['mrp'];?>">  
                </td>
				<td align="left"><input type="text" style="width:53px;text-align:right" name="req_qty[<?php echo $i;?>]" id="req_qty[<?php echo $i;?>]" onKeyUp="return check_qty(<?php echo $i;?>);getAvlStk(<?php echo $i;?>);rowTotal(<?php echo $i;?>);"   class="form-control digits" value="<?php echo round($row['req_qty']);?>" />
				</td>
				<td align="left"><input type="text" style="width:85px;" name="price[<?php echo $i;?>]" id="price[<?php echo $i;?>]" class="form-control" value="<?php echo $row['po_price'];?>" onKeyUp="rowTotal(<?php echo $i;?>);" ></td>
				<td align="left"><input type="text" style="width:85px;" name="linetotal[<?php echo $i;?>]" id="linetotal[<?php echo $i;?>]" class="form-control" value="<?php echo $row['po_value'];?>" readonly></td>
			 </tr>
			  <?php 
			$total_qty+=$row[req_qty];
			$i++;   }?>
			
				 <?php }
				 //// tax row count
				 $tx = 0;
				 ?>
            </tbody>
           
          </table>
          </div>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Total Qty</label>
              <div class="col-md-3">
              <input type="text" name="total_qty" id="total_qty" class="form-control"  value="<?=$total_qty;?>"  readonly/>
              <input type="hidden" name="rownoo" id="rownoo" value="<?php echo $i;?>" /> 
              </div>
               <label class="col-md-3 control-label">Sub total</label>
              <div class="col-md-3">
                <input type="text" name="sub_total" id="sub_total" class="form-control"   value="<?=$row1['po_value'];?>"  readonly  />
              </div>
            </div>
          </div>
          <?php if($row1["taxper"]!="0.00"){ ?>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Tax </label>
              <div class="col-md-1">
              	<input type="text" name="tax_type0" id="tax_type0" class="form-control" value="<?=$row1['taxtype'];?>" readonly style="width:100px"/>
              </div>
              <div class="col-md-2">
              	<input type="text" name="tax_per0" id="tax_per0" class="form-control number" value="<?=$row1['taxper'];?>" readonly style="width:100px"/>
              </div>
               <label class="col-md-3 control-label">Tax Amount</label>
              <div class="col-md-3">
                <input type="text" name="tax_total0" id="tax_total0" class="form-control" value="<?=$row1['taxamount'];?>" readonly/>
              </div>
            </div>
          </div>
          <?php $tx++;}?>
          <?php if($row1["taxper1"]!=0.00){ ?>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Tax 1</label>
              <div class="col-md-1">
              	<input type="text" name="tax_type1" id="tax_type1" class="form-control" value="<?=$row1['taxtype1'];?>" readonly style="width:100px"/>
              </div>
              <div class="col-md-2">
              <input type="text" name="tax_per1" id="tax_per1" class="form-control number" value="<?=$row1['taxper1'];?>" readonly style="width:100px"/>
              </div>
               <label class="col-md-3 control-label">Tax Amount</label>
              <div class="col-md-3">
                <input type="text" name="tax_total1" id="tax_total1" class="form-control" value="<?=$row1['taxamount1'];?>" readonly/>
              </div>
            </div>
          </div>
          <?php $tx++;}?>
          <?php if($row1["taxper2"]!=0.00){ ?>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Tax 2</label>
              <div class="col-md-1">
              	<input type="text" name="tax_type2" id="tax_type2" class="form-control" value="<?=$row1['taxtype2'];?>" readonly style="width:100px"/>
              	
              </div>
              <div class="col-md-2">
              <input type="text" name="tax_per2" id="tax_per2" class="form-control number" value="<?=$row1['taxper2'];?>" readonly style="width:100px"/>
              </div>
               <label class="col-md-3 control-label">Tax Amount</label>
              <div class="col-md-3">
                <input type="text" name="tax_total2" id="tax_total2" class="form-control" value="<?=$row1['taxamount2'];?>" readonly/>
              </div>
            </div>
          </div>
          <?php $tx++;}?>
          <?php if($row1["taxper3"]!=0.00){ ?>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Tax 3</label>
              <div class="col-md-1">
              	<input type="text" name="tax_type3" id="tax_type3" class="form-control" value="<?=$row1['taxtype3'];?>" readonly style="width:100px"/>
              	
              </div>
              <div class="col-md-2">
              <input type="text" name="tax_per3" id="tax_per3" class="form-control number" value="<?=$row1['taxper3'];?>" readonly style="width:100px"/>
              </div>
               <label class="col-md-3 control-label">Tax Amount</label>
              <div class="col-md-3">
                <input type="text" name="tax_total3" id="tax_total3" class="form-control" value="<?=$row1['taxamount3'];?>" readonly/>
              </div>
            </div>
          </div>
          <?php $tx++;}?>
          <?php if($row1["taxper4"]!=0.00){ ?>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Tax 4</label>
              <div class="col-md-1">
              	<input type="text" name="tax_type4" id="tax_type4" class="form-control" value="<?=$row1['taxtype4'];?>" readonly style="width:100px"/>
              	
              </div>
              <div class="col-md-2">
              <input type="text" name="tax_per4" id="tax_per4" class="form-control number" value="<?=$row1['taxper4'];?>" readonly style="width:100px"/>
              </div>
               <label class="col-md-3 control-label">Tax Amount</label>
              <div class="col-md-3">
                <input type="text" name="tax_total4" id="tax_total4" class="form-control" value="<?=$row1['taxamount4'];?>" readonly/>
              </div>
            </div>
          </div>
          <?php $tx++;}?>
		  <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label"></label>
              <div class="col-md-3">
              </div>
              <label class="col-md-3 control-label">Grand Total</label>
              <div class="col-md-3">
              <input type="text" name="grand_total" id="grand_total" value="<?=$row1['grand_total'];?>" class="form-control"  readonly/>
              <input type="hidden" name="taxrow" id="taxrow" value="<?php echo $tx;?>" /> 
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-10">
              <label class="col-md-3 control-label">Delivery Address<span style="color:#F00">*</span></label>
              <div class="col-md-3">
                <textarea name="delivery_address" id="delivery_address" class="form-control required"  value=""style="resize:none" required></textarea>
              </div>
              <label class="col-md-3 control-label">Remark</label>
              <div class="col-md-3">
                <textarea name="remark" id="remark" class="form-control" style="resize:none"></textarea>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-10">              
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-12" align="center">
              <input type="submit" class="btn<?=$btncolor?>" name="upd" id="upd" value="Process" title="Process this purchase return">
                <input type="hidden" name="parentcode" id="parentcode" value="<?=$_REQUEST['po_from']?>"/>
                <input type="hidden" name="partycode" id="partycode" value="<?=$_REQUEST['po_to']?>"/>
                <input type="hidden" name="inv" id="inv" value="<?=$_REQUEST[inv_no]?>"/>
              <input title="Back" type="button" class="btn<?=$btncolor?>" value="Back" onClick="window.location.href='vendor_return.php?<?=$pagenav?>'">
            </div>
          </div>
         </form>
      </div>
    </div>
  </div>
</div>
<?php
include("../includes/footer.php");
include("../includes/connection_close.php");
?>
</body>
</html>
<?php if($_REQUEST[po_to]=='' || $_REQUEST[po_from]==''){ ?>
<script>
$("#frm2").find("input[type='submit']:enabled, select:enabled, textarea:enabled").attr("disabled", "disabled");
</script>
<?php } ?>