<?php  session_start(); error_reporting(0); ?>
<?php if(!isset($_SESSION['j_admin']) && !isset($_SESSION['j_admin'])){ 
    $url = urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); header('location:../login/?url='.$url.'');  
} ?>
<!doctype html>
<html lang="en"> 
<head>
	<?php
    require_once("../j_conn/url.php");
    require_once("../j_conn/dbc.php");
    require_once("../j_incs/functions.php");
    $page_name="All Deposits";
    $page_desc="$page_name";
    $page_img="".$dir."j_files/j_img/logo/logo-meta.png";
    $page_author="$company";
    $page_keywords="".$company.", $page_name, $page_desc, ".$company_motto.", $company_desc";
    $page_url="".$dir."deposits/";
    require_once("../j_incs/metas.php");
    require_once("../j_incs/scripts-top.php");
    ?>
    <style>
        @media(min-width:0px) and (max-width:767px){
            .datex{
                display: none !important;
            }
        }
    </style>
</head>
<body>
    
    <div class="app">
        <div class="layout">
            <?php 
            require_once("../j_incs/header.php");
            require_once("../j_incs/nav.php");
            ?>
            <!-- Page Container START -->
            <div class="page-container">
                

                <!-- Content Wrapper START -->
                <div class="main-content">
                    
                    
                     <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="page-header">
									<div class="header-sub-title">
										<nav class="breadcrumb breadcrumb-dash">
											<a href="<?php echo $dir; ?>" class="breadcrumb-item"><i class="anticon anticon-dashboard m-r-5"></i>Dashboard</a>
											<!--<a class="breadcrumb-item" href="#"> </a>-->
											<span class="breadcrumb-item active"><?php echo $page_name; ?></span>
										</nav>
									</div>
								</div>
                            </div>
                        </div>
                    </div>
                     
                    
                    
                    
                    <div class="container">
                        
                        
                        <div class="card">
                        
						
						
							
							
							
							<?php
							$sql4="SELECT * from j_pays WHERE j_deleted < 1 AND j_type ='credit' AND j_kind = 'Fund Wallet' AND j_status > 0";  
							$result4 = runSQL($sql4);
							$total = mysqli_num_rows($result4);
							//
							$limit =500;
							$offset = RMC($_GET['m']);
							if($offset<1){
								$offset = 0;
								$num = 1;
							}else{
								$num=$offset+1;
							}
						
							$sql4="SELECT * from j_pays WHERE j_deleted < 1 AND j_type ='credit' AND j_kind = 'Fund Wallet' AND j_status > 0 order by j_id desc limit $limit offset $offset";  
							$result4 = runSQL($sql4);
							$count = mysqli_num_rows($result4); 
							?>
							<?php /*
							<div class="container-fluid">
								<h4 class="welcome_text"><?php echo $page_name; if($count > 0){ echo "(".number_format($count).")"; } ?>
									<a href="javascript:void(0);" onclick="history.back()" class='back text-danger font-size-16 float-right'>Back</a> 
								</h4>
							</div>
							*/
							?>
							<div class="container-fluid">
								
								
								<div class="card">
									<div class="card-body">
										
										
										<?php 
										
										
										if($total>0){
											
										?>						
										<div class="">
											
										
											 <div class="table-responsive my-content" id="my-content">
												<table id="order-listing" class="table">
													<thead>
														<tr>
															<th>S/N</th>
															  <th>User</th>
															  <th>Email</th>
															  <th>Phone</th>
															  <th>Ref. ID</th>
															<th>Amount</th>
															<th>Charge</th>
															<th>Total</th>
															<?php /*<th>Balance</th>*/ ?>
															<th>Gateway</th>
															<th>Date</th>
															<th>Status</th>
															<th>Proof</th>
															<th>Menu</th>
														</tr>
													</thead>
													<tbody>
														<?php 
											while ($row = mysqli_fetch_array($result4)){
												/*
												$cd = get_cd($row['j_currency']);
												$currency_in_use = $cd[0];
												$currency_code_in_use = $cd[1];
												$currency_sort_in_use = $cd[2];
												*/
												
												//user profile
												$sql25="SELECT * from j_users WHERE 
												j_id='".$row['j_user_id']."'"; //  
												$result25 = runSQL($sql25);
												$data25 = mysqli_fetch_array($result25);
												$a_username = $data25['j_username'];
												$a_passport = $data25['j_passport'];
												$a_email = $data25['j_email'];
												$a_phone = $data25['j_phone'];
												$a_firstname = $data25['j_firstname'];
												$a_lastname = $data25['j_lastname'];
												$a_name = "$a_firstname $a_lastname"; $a_name = trim($a_name);
												//
												if($row['j_total'] > 0){ }else{ $row['j_total'] = $row['j_amount']; }
												?>
												<tr id="i<?php echo $row['j_transact_id']; ?>">
													<td id="nums<?php echo $row['j_transact_id']; ?>"><?php echo $num++; ?></td>
													<td> <?php echo $a_name; ?> </td>
													<td> <?php echo $a_email; ?> </td>
													<td> <?php echo $a_phone; ?> </td>
													<td> <?php echo $row['j_transact_id']; ?> </td>
													<td> <?php echo "".num_format($row['j_amount'])." ".$row['j_currency'].""; ?> </td>
													<td> <?php echo "".num_format($row['j_charge'])." ".$row['j_currency'].""; ?> </td>
													<td> <?php echo "".num_format($row['j_total'])." ".$row['j_currency'].""; ?> </td>
													<td> <?php echo $row['j_gateway']; ?> </td>
												   <td> <?php echo FULL_DATE($row['j_date']); ?> </td>
												   <?php /* <td> <?php echo amount_w_c($row['j_bal'],$row['j_currency']); ?> </td>*/ ?>
													<td> 
														<?php 
														echo t_status2($row['j_status'],$row['j_paid'],$row['j_disburse'],$row['j_id']);
														?>
													</td>
													
													
													<td>
														<?php if(!empty($row['j_proof'])) { ?>
														<a target="_blank" href="
														<?php echo $user_dir; ?>j_files/j_img/payments/<?php echo $row['j_proof']; ?>
														">
														Download Proof  
														</a>
														<?php }else{ echo "..."; } ?>
												   </td>
												   
													<td>
													<div class="btn-group dropup-left">
														<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
															Options
														</button>
														<div class="dropdown-menu">
														  <a href="<?php echo $dir; ?>receipt/?ref=<?php echo $row['j_transact_id']; ?>" class="dropdown-item del-item">View</a>
														 <div class="dropdown-divider"></div>
														
														<?php if($row['j_status'] < 2){ ?>
														  <!--<div class="dropdown-divider"></div>-->
														 <a href="<?php echo $dir; ?>deposits/status.php?s=Cancel&ref=<?php echo $row['j_id']; ?>" class="dropdown-item del-item">Cancel</a>
														 <div class="dropdown-divider"></div>
														 <?php /*
														 <a href="<?php echo $dir; ?>deposits/status.php?s=Approve&ref=<?php echo $row['j_id']; ?>" class="dropdown-item del-item">Approve Payment</a>
														 <div class="dropdown-divider"></div>
														*/
														?>
														<a href="<?php echo $dir; ?>deposits/status.php?s=Activate&ref=<?php echo $row['j_id']; ?>" class="dropdown-item del-item">Credit Account</a>
														 <div class="dropdown-divider"></div> 
														<?php } ?>
														
														
														 
														 
														  <a class="dropdown-item r_del" href="javascript:void()" num="<?php echo $row['j_transact_id']; ?>">
																<i class="fa fa-trash"></i>
																<span class="m-l-10">Delete</span>
															</a>
															
														</div>
													</div>

													</td>
													
													 
												</tr>
												
											<?php } ?>

													</tbody>
												</table>
												 <br/>
												<p align="center">
													<?php if($offset+$limit < $total){ ?>
													<a class="btn btn-sm btn-default" href="?m=<?php echo $offset+$limit; ?>">Load Next<i class="fa fa-chevron-right text-2 ml-2"></i></a>
													<?php } ?>
													&nbsp; &nbsp;
													<?php if($offset > 0){ ?>
													<a class="btn btn-sm btn-default" href="?m=<?php echo $offset-$limit; ?>"><i class="fa fa-chevron-left text-2 ml-2"></i>  Previous</a>
													<?php } ?>
												</p>
											</div>
											
											
										</div>
										



										<?php }else{ //no record ?> 
										<div class="">
											<div class="container">
												<div class="row">
													 <div class="col-md-12" style="text-align:center;">
														<div class="avatar avatar-image avatar-lg avatar-red">
															<i class="fa fa-times"></i>
														 </div>
														 <p class="text-center">No record found.</p>

													 </div>
												</div>

											</div>
										</div>
										<?php } ?>
										
							
							
										
									</div>
								</div>
								
								
							</div>
							<div class="m-b-100"></div>
				
				
				
                            
                            
                            
                            
                            
                            
                        </div>
    
                    </div>
                    
 
                </div>
                <!-- Content Wrapper END -->

                <?php
                require_once("../j_incs/footer.php");
                ?>

            </div>
            <!-- Page Container END -->
        </div>
    </div>
    
    
    <?php
    require_once("../j_incs/scripts-bottom.php");
    ?>
    <?php 
    /*
    $(window).bind('scroll', function() {
    if($(window).scrollTop() >= $('.posts').offset().top + $('.posts').outerHeight() - window.innerHeight) {
            alert('end reached');
        }
    });
    */
    ?>
	<script>
		$('#datatable').DataTable();
	</script>
     <script>
        $("#searchAnything").click(function(){
            $(this).hide();
            $("#my-content").hide();
            $("#my_saearch").slideDown("slow");
            $("#hide_searchAnything").slideDown("slow");
        });
        $("#hide_searchAnything").click(function(){
            $(this).hide();
            $("#my-content").show();
            $("#my_saearch").slideUp("slow");
             $("#searchAnything").slideDown("slow");
        });
         
        var form = "#form";
        var button = "#submit";
        var button_val = $(button).html();
        var result = "#formresult";
        //
        $(form).on('submit',(function(e) {
        e.preventDefault();
        $(button).attr('disabled', '');
        $(button).html("<i class='anticon anticon-loading'></i> Processing");
        $(result).html("<div class='alert alert-warning'> Taking too long? <a href=''>Reload </a></div>");
         $.ajax({
        url: "save.php",
        type: "POST",
        data: new FormData(this),
        contentType: false,
        cache: false,
        processData:false,
        success: function(data)
        {
        if(data){
         $(button).removeAttr('disabled');
        $(button).html(button_val);
        $(result).html(data);
        }else{
        $(result).html("Error occurred.");
        $(button).removeAttr('disabled');
        $(button).html(button_val);
        }
        }
        });
        }));
        </script>
</body>
</html>