<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cheque_pay_view_report</title>
<link rel="stylesheet" href="css/table_min.css" type="text/css"/>	
</head>

<body>
<div class="CSSTableGenerator" id="chq_table1" >
<table width="1000" border="0">
  <tr>
    <td>Date</td>
    <td>Ref No</td>
     <td>Inv No</td>
     <td>Name</td>
     <td>Value</td>
     <td>Pay</td>
    <td>CheNo</td>  
     <td>Account No</td> 
  </tr>
  <!--asha-->
  <?php
  include('connectioni.php');
      $sql = "select * from paymas where  (bdate>='" . $_GET['from'] . "' and  bdate<='" . $_GET['to'] . "') ORDER BY refno desc  ";
      
    $result = mysqli_query($GLOBALS['dbacc'], $sql);
    $recDate = "";
    while ($row = mysqli_fetch_array($result)) {

        $sql1 = "select * from s_sttr where  ST_REFNO='" . $row['refno'] . "'";
        $result1 = mysqli_query($GLOBALS['dbinv'], $sql1);
        
         $sql2 = "select * from tmp_cheque_pay where  entno='" . $row['refno'] . "'";
        $result2 = mysqli_query($GLOBALS['dbacc'], $sql2);
        $row2 = mysqli_fetch_array($result2);
        
        
        
        // $recDate = "";
        
        while ($row1 = mysqli_fetch_array($result1)) {
            			 //if ($recDate != $row['refno']) {
                //                       $recDate = $row['refno'];
                //                         	echo "  
                                      
                //                       <td> ".""."</td> <td> ".""."</td> <td> ".""." ";
                //         }
                        $sql3 = "Select * from s_purmas where REFNO='" . $row1["ST_INVONO"] . "' ";
            $result3 = mysqli_query($GLOBALS['dbinv'],$sql3);
            $row3 = mysqli_fetch_array($result3);
            
            $sql4 = "Select * from vendor where CODE='" . $row1["cus_code"] . "' ";
            $result4 = mysqli_query($GLOBALS['dbinv'],$sql4);
            $row4 = mysqli_fetch_array($result4);
            
            $sql5 = "Select * from lcodes where c_code='" . $row['code'] . "' ";
            // echo $sql5;
            $result5 = mysqli_query($GLOBALS['dbacc'],$sql5);
            $row5 = mysqli_fetch_array($result5);
             
            echo "<tr>                
                             <td style='width: 150px;'>".$row1['ST_DATE']."</a></td>
                                 <td style='width: 150px;'>" . $row1['ST_INVONO'] . "</a></td>
                                 <td style='width: 100px;'>" . $row3['LCNO'] . "</a></td>
                              <td style='width: 200px;'>" . $row4['NAME'] . "</a></td>
                                <td style='width: 150px;'>" . $row3['AMOUNT'] . "</a></td>
                                <td style='width: 150px;'>" . $row1['ST_PAID'] . "</a></td>
                              <td style='width: 150px;'>" . $row1['ST_CHNO'] . "</a></td>
                         	  <td style='width: 150px;'>" . $row5['c_name'] . "</a></td> </tr>";
                         	  
                        
        }
        
        
    } 
  ?>
</table>
</div>
</body>
</html>
