<?php 
ob_start();
$PageSecurity = 2;
$title = _('Purchase Bill Book List');

if($_SESSION['AssignedBranch']!='')
{	  	

    $SQL = "SELECT * FROM addmrn where site in('".$_SESSION['AssignedBranch']."') and mrnstatus!='closed'
   and companyID='".$_SESSION['ACGCompanyId']."' and Cancel_Status='N' or Cancel_Status IS NULL order by id DESC";
}
else
{
 $SQL = "SELECT * FROM addmrn where  mrnstatus!='closed' and  companyID='".$_SESSION['ACGCompanyId']."' and Cancel_Status='N' or Cancel_Status IS NULL order by id DESC";
}   

// $resultpaging_SQL = "Select MRNNo, MRNDate, OrderFromSite, StoreName, ReceivedAgainst, createdby from addmrn
					 // Where 1=1 ORDER BY MRNNo ASC ";
		 
		  if(isset($_SESSION['filter1']))
		  {
		  $SQL="select * from addmrn ".$_SESSION['filter1'];
		  } 
     
	 //echo $SQL;

        $ErrMsg = _('No orders were returned by the SQL because');
		$purchordersResult = DB_query($SQL,$db,$ErrMsg);
		
		/*show a table of the orders returned by the SQL */
	

?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1 align="center">Purchase Bill Book</h1>
<form name="" method="post">
<table border="0" cellpadding="3" cellspacing="0" width="100%" class="thborder">
<tr>
	<th width="15%">Branch</th>
	<th width="10%">MRN No.</th>
	<th width="10%">MRN Date</th>
	<th>Vendor Name</th>    
	<th width="20%">Created by</th>
	<th width="8%" style="text-align:center;">Action</th>	
	<!--//<td><strong>Export</strong></td>-->	
</tr>
      <?php 	  
	    //echo $SQL;
	
		if(DB_num_rows($purchordersResult)>0){		
			
			while($myrow = DB_fetch_array($purchordersResult)) {
	$SQLCHECK = DB_query("SELECT mrn_no FROM purchase_billbook where  mrn_no='".$myrow['id']."'",$db);			
			$SQLRESULT = DB_fetch_array($SQLCHECK);	
                        
                        if(!$SQLRESULT){
                        	$vendortype=$s->getField('suppliers','id',$myrow['ReceivedFrom'],'vendor_type');
			 ?> 
<tr>
        <td><?php echo $s->getField('locations','loccode',$myrow['site'],'locationname');?></td>
        <td><?php echo $myrow['MRNNo'];?></td>
        <td><?php echo ConvertSQLDate($myrow['MRNDate']);?></td>
        <td><?php echo $s->getField('suppliers','id',$myrow['ReceivedFrom'],'vendor_name');?></td>  
        <td><?php echo $username=$s->getField('www_users','id',$myrow['createdby'],'realname'); ?></td>
        <td width="4%" style="text-align:center;"><a href="index.php?route=purchBillVerify_gst&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $myrow['id']?>"><input type="button" value="ADD BILL" class="search" /></a>
       </td>      
      </tr>
            <?php }
                }}
		else
		{?>
      <tr>
        <td colspan="10"><strong>No Record Found!</strong></td>
      </tr>
      <?php }
		//end of while loop ?>
    </table>
</form>

</div>
</div>
