<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Main navbar -->
  <?php 
  use App\Libraries\MyEncrypt;
  $this->db = db_connect();

  echo view('admin/common_header');

  ?>
  <!-- /main navbar -->

  <!-- select box theme JS files -->
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/forms/selects/bootstrap_select.min.js"></script>

  <!-- Theme JS files -->
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/tables/datatables/datatables.min.js"></script>
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/tables/datatables/extensions/responsive.min.js">
  </script>
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/forms/selects/select2.min.js"></script>
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/core/app.js"></script>
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/pages/datatables_responsive.js"></script>
  <!-- /theme JS files -->

  <!-- notify JS files -->
    <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/notifications/jgrowl.min.js"></script>
    <!-- Theme JS files -->

  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/notifications/bootbox.min.js"></script>
  <script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/notifications/sweet_alert.min.js"></script>
    
    <style type="text/css">
      .icons-list a[data-action="reload1"]:after {
      content: '\e9fb';
    }
    .btns {
      padding: 5px;
    }
  </style>
</head>
<style>
.icons-list > li {
    display: inline-block;
    font-size: 26px;
    }
    .heading-elements .icons-list {
    margin-top: 5px;
}
</style>
<body class="navbar-top-md-md pace-done">
  <!-- Fixed navbars wrapper -->
  <div class="navbar-fixed-top">
    <!-- Main navbar -->
    <?php echo view('admin/mainnav'); ?>
    <!-- /main navbar -->
    <!-- Second navbar -->
    <?php echo view('admin/secondnav'); ?>
    <!-- /second navbar -->
  </div>
  <!-- /fixed navbars wrapper -->

  <!-- Page header -->
  <div class="page-header">
    <div class="page-header-content">
      
      <?php
      // echo $module_name;
       echo view('admin/'.$module_name.'_header'); ?>
    </div>
  </div>
  <!-- /page header -->


  <!-- Page container -->
  <div class="page-container">

    <!-- Page content -->
    <div class="page-content">

      <!-- Main content -->
      <div class="content-wrapper">


        <!-- Basic responsive configuration -->
        <div class="panel panel-flat">
          <div class="panel-heading">
            <h5 class="panel-title"><?php echo "Pending Deposit" ?></h5>
            <div class="heading-elements">
              <ul class="icons-list">
                <li><a href="<?php echo base_url();?>/admin/pendingdeposit" class="icon-plus-circle2"></a></li>
                        <li><a data-action="collapse"></a></li>
                        <li><a data-action="reload1"></a></li>
                        <li><a data-action="close"></a></li>
                      </ul>
                    </div>
          </div>
          <?php 
          $currency_info = defaultcurrency();
          $session = \Config\Services::session();
          $admin_login=$session->get('userid');
          $get_admin=$this->db->query("select * from admin where id='".$admin_login."'")->getRow();
          $user_group = $get_admin->user_group;
          
          ?>

        
          <!-- <div class="ajax-refresh">  -->
          <table class="table datatable-responsive-user table-hover">
        

            <thead>
              <tr>
               <th class="">Date</th>      
                <th class="">Transaction ID</th>
				       <th class="">Username</th>          
                <th class="">Amount</th>
                <th class="">Depsit Address</th>
                <th class="">Attachment</th>
                <th class="">Options</th>
				
				<th style="display:none;"></th>
              </tr>
            </thead>
            <tbody>
				<?php 
					if($history)
					{
						foreach ($history as $row) 
						{
                $flag=0;
                $get_user=$this->db->query("SELECT * FROM uusers WHERE uusersid='".$row->uusersid."'")->getRow();
                
                if($user_group=='0')
                  $flag=1;
                else if($user_group=='1')
                {
                   if($get_user->new_entry=='0')
                    $flag=1;
                }
                else
                {
                  if($get_user->new_entry=='1')
                   $flag=1;
                }
                  
                 if($flag=='1')
                 {
							?>
								<tr>
									<td class=""><?php echo date('Y-m-d H:i:s', strtotime($row->date));?></td>
									<td class=""><?php echo $row->transactionid;?></td>
									<td class=""><?php echo $row->username;?></td>
									<td class=""><?php echo number_format($row->amount,4);?> USDT</td>
									<td class=""><?php echo $row->address;?></td>
									<td class="">
										<?php 
										if($row->attachment=='')
											echo '---';
										else
										{
											echo '<a href='.base_url().'/assets/images/profile/'.$row->attachment.' target="_blank">'.$row->attachment.'</a>';
										}
										?>
									</td>
									<td class="text-center">
	                                	<a class="btns" data-popup="tooltip" title="Approve Deposit"  href="javascript:void(0)" onClick="payouts('<?php echo $row->historyid;?>')" ><i class="fa fa-thumbs-up"></i></a>
	                                	<a class="btns" data-popup="tooltip" title="Reject Deposit"  href="javascript:void(0)" onClick="confirmdelete('<?php echo $row->historyid;?>')" ><i class="fa fa-thumbs-down"></i></a>
	                                </td>
									<td style="display:none;"></td>
									<td style="display:none;"></td>
								</tr>

							<?php
                 }
						}


					}
				?>
			</tbody>
            


          </table>
          <!-- </div> -->
        </div>
        <!-- /basic responsive configuration -->

      </div>
      <!-- /main content -->

    </div>
    <!-- /page content -->


    <!-- Footer -->
    <div class="footer text-muted">
      <?php echo site_footer();?>
    </div>
    <!-- /footer -->    
  </div>
  <!-- /page container -->

  <script type="text/javascript">
    
  (function($) {

      $(document).ready(function() {

        $.jGrowl.defaults.closer = false;

      <?php
      $this->session = \Config\Services::session();
       if($this->session->getFlashData('error_message')) { ?>
        $.jGrowl("<?php echo $this->session->getFlashData('error_message');?>", {
                header: '<?php echo lang('language_lang.error');?>',
                theme: 'bg-danger'
            });

            <?php } ?>
                    
            <?php if($this->session->getFlashData('success_message')) { ?>
                
                $.jGrowl("<?php echo $this->session->getFlashData('success_message');?>", {
                header: '<?php echo lang('language_lang.success');?>',
                theme: 'bg-success'
            });

            <?php } ?>
            

      $('.panel [data-action=reload1]').click(function (e) {
            e.preventDefault();
            var block = $(this).parent().parent().parent().parent().parent();
            jQuery.ajax({
                url:'<?php echo base_url();?>/admin/users/dataview',
                beforeSend: function() {
                  $(block).block({ 
                    message: '<i class="icon-spinner2 spinner"></i>',
                    overlayCSS: {
                        backgroundColor: '#fff',
                        opacity: 0.8,
                        cursor: 'wait',
                        'box-shadow': '0 0 0 1px #ddd'
                    },
                    css: {
                        border: 0,
                        padding: 0,
                        backgroundColor: 'none'
                    }
                });
                $('.panel .panel-heading').find('.dataTables_wrapper').remove();
                
                $('#DataTables_Table_0_wrapper').remove();
              },
              complete: function() {
                  $(block).unblock();
              },
                success : function(resp)
                {
                  $('.panel .panel-heading').after(resp);
                  location.reload();
                }
            });
            
        });

      $('#icon-bck').on('click',function() {
        window.history.back();
      });
          
    });

  })(jQuery);
  
         

  function confirmdelete(value) {

    swal({
            title: "Do You want Reject Deposit?",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            cancelButtonColor: true,
            showLoaderOnConfirm: true
        },

        function(inputValue){
          //alert(value);
      //exit();
            if (inputValue === false) {
              return false;
            } else {
              window.location.href = "<?php echo base_url('admin/finance/Deleterequest/');?>"+'/'+value;
            }
        });
    }


  function payouts(value) {

    swal({
            title: "<?php echo 'Do you confirm the deposit';?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            cancelButtonColor: true,
            showLoaderOnConfirm: true
        },

        function(inputValue){
          //alert(value);
      //exit();
            if (inputValue === false) {
              return false;
            } else {
              window.location.href = "<?php echo base_url('admin/finance/approverequest/');?>"+'/'+value;
            }
        });
    }

  
  </script>
</body>
</html>
