<?php 
	include_once("../view/header-footer/InnerHeader.php");   
	include_once("leftMenu.php");   
?>
 
<div id="main-content">
    <div class="container-fluid">
        <div class="block-header">
            <div class="row">
                <div class="col-lg-5 col-md-8 col-sm-12">                        
                    <h2><a href="javascript:void(0);"  class="btn btn-xs btn-link btn-toggle-fullwidth"><i class="fa fa-arrow-left"></i></a>Monthly  Income </h2>
                      <ul class="breadcrumb">  
                        <li style="color:green;font-style:bold"> <?php if(isset($_SESSION['Regis']))  echo $_SESSION['Regis'];?></li>
                    </ul>
                </div>            
            </div>
        </div>
        <div class="row clearfix">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="card">  
                    <div class="body">
                        <div class="table-responsive">
                            <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer">
                                <div class="row"><div class="col-sm-12 col-md-6">
                                    
                                        </div>
                                        
                                            </div><div class="row">
                                                <div class="col-sm-12">
                                                    <table class="table table-hover js-basic-example  " >
                                <thead>
                                    <tr role="row">
                                        <th>Sr</th>  
                                        <th>By</th> 
                                        <th>Name</th> 
                                        <th>Pay Amt</th> 
                                        <th>Auto Withdraw</th> 
                                        <th>Received</th> 
                                        <th>Bank</th> 
                                        <th>Account</th> 
                                        <th>IFSC</th>  
                                        <th>Status</th>    
									</tr>
                                </thead>
                                <tbody>
                                
                               <?php 
		$sr = 1;
		//foreach($UI__DChstr as $dmm) 
	   
                
                $stmt=$conn->prepare("select  *  from UI__Rgst  where cuurentId=:cuurentId");  
                $stmt->bindValue(':cuurentId', $users->Rid , PDO::PARAM_STR);
                $stmt->execute(); 
                $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);  
                
                
                
                $amtM = 0;
                $stmt=$conn->prepare("select  * from  UI__DailyROIGene   where custId=:custId   and paidStatus=1 ");  
                $stmt->bindValue(':custId', $users->Rid  , PDO::PARAM_STR); 
                $stmt->execute(); 
                $fetch1 = $stmt->fetchAll(PDO::FETCH_OBJ); 
                
                foreach($fetch1 as $dmt)
                $amtM +=$dmt->amount;
                
                $stmt=$conn->prepare("select  * from   UI__Bns   where Rid=:Rid  and paidStatus=1 ");  
                $stmt->bindValue(':Rid', $users->Rid   , PDO::PARAM_STR); 
                $stmt->execute(); 
                $fetch2 = $stmt->fetchAll(PDO::FETCH_OBJ); 
                
                foreach($fetch2 as $dmt)
                $amtM +=$dmt->Tamt;        
                
                $amtM1 = 0;
                $stmt=$conn->prepare("select  * from  UI__DailyROIGene   where custId=:custId  and paidStatus=0  ");  
                $stmt->bindValue(':custId', $users->Rid  , PDO::PARAM_STR); 
                $stmt->execute(); 
                $fetch1 = $stmt->fetchAll(PDO::FETCH_OBJ); 
                
                foreach($fetch1 as $dmt)
                $amtM1 +=$dmt->amount;
                
                $stmt=$conn->prepare("select  * from   UI__Bns   where Rid=:Rid  and paidStatus=0 ");  
                $stmt->bindValue(':Rid', $users->Rid   , PDO::PARAM_STR); 
                $stmt->execute(); 
                $fetch2 = $stmt->fetchAll(PDO::FETCH_OBJ); 
                
                foreach($fetch2 as $dmt)
                $amtM1 +=$dmt->Tamt;      
                
                $mtow = 0;
                $stmt=$conn->prepare("select  id from    UI__DailyROIGene   where custId=:Rid  and paidStatus=1 ");  
                $stmt->bindValue(':Rid', $users->Rid   , PDO::PARAM_STR); 
                $stmt->execute(); 
                $mtow = $stmt->rowCount();


	?>
	     <?php 
							        if(($amtM+$amtM1)>700)  {
							    ?>
							<tr class="odd gradeX"> 
							
							   
								<td><?php echo $sr++;?> </td> 
								<td><?php echo $users->Rid;?> </td>
								<td><?php echo $UI__Rgst->nm;?> </td>   
								<td><?php echo $amtM1;?></td>
								<td><?php echo $amtM;?></td>
								<td><?php echo ($amtM)-(($amtM*10)/100);?> </td>
								<td><?php echo $UI__Rgst->Bname;?> </td>
								<td><?php echo $UI__Rgst->Bnumber;?> </td>
								<td><?php echo $UI__Rgst->Bifsc;?> </td>
								<?php 
								    if($amtM1 >= 700) {
								?>
								    <td> Unpaid </td> 
								<?php  } else { ?> 
								<td>   <?php if($mtow > 0) echo "paid"; ?></td>
								<?php } ?>
							</tr>  
            <?php   
                        }
            
            ?>

                    	
                    	    					
							</tbody>
                            </table></div></div>
                             
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
    unset($_SESSION['Regis']);
	include_once("../view/header-footer/footer.php");    
?>