<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
		<?php 
			use App\Libraries\MyEncrypt;
      		use App\Helpers\site_helper;
      		use App\Helpers\form_helper;
      		$this->db = db_connect();      
      
      	$this->form_validation =  \Config\Services::validation();
		$this->finance_model = model('finance_model');
		$this->finance_model = model('CommonModel');
		//use App\Libraries\MyEncrypt;
        $this->session = session();
        $this->uri = service('uri');
		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>

<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 -->
	<?php echo view('admin/'.$module_name.'_header'); ?>
	<!-- /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 $page_title; ?></h5>
						<div class="heading-elements">
							<ul class="icons-list">
								<!-- <li><a href="<?php echo base_url();?>admin/users/add" class="glyphicon-plus"></a></li> -->
		                		<li><a data-action="collapse"></a></li>
		                		<li><a data-action="reload"></a></li>
		                		<li><a data-action="close"></a></li>
		                	</ul>
	                	</div>
					</div>
					<?php $currency_info = defaultcurrency();?>
					<?php if(!$type) {
					 ?>
						<table class="table datatable-responsive table-hover">
							<colgroup>
								<col width="13%"/>
		  						<col width="12%"/>
		  						<col width="15%"/>
		  						<col width="23%"/>
		  						<col width="10%"/>
		  						<col width="13%"/>
		  						<!-- <col width="13%"/> -->
		  						<col width="13%" style="display:none;"/>
	  						</colgroup>
							<thead>
								<tr>
									<th class=""><?php echo lang('language_lang.lbl_trans_date');?></th>
									<th class="text-center"><?php echo lang('language_lang.lbl_transaction_id');?></th>
									<th class=""><?php echo "Email";?></th>
									<th class=""><?php  if($type1 == "deposit") echo "Deposited Address"; else if($type1 == "withdrawal") echo "Withdrawal Address"; else echo "Transferred By";?></th>
									<th class=""><?php echo "Chain Name";?></th>
									<th class="" style="display:none;"></th>
									<th class=""><?php echo lang('language_lang.lbl_amount');?></th>
								</tr>
							</thead>
							<tbody>
							<?php 
							
								if($history) {

									
									$row_count = count($history);
									// $this->load->library('MyEncrypt');
									$myencrypt = new MyEncrypt;
									foreach ($history as $row) {

										if($row->uusersid=='0') {
											$username = 'Admin';
										} else {
											$usernme = $row->uusersid;
										$referral1=$this->db->query("SELECT * FROM uusers WHERE uusersid='".$usernme."'")->getResult();
    									$user=$referral1[0];
										$username=$user->email;
										if($type1 == "deposit"){
											$deposit_address = $this->db->query("SELECT * FROM uusers_address WHERE uusersid='".$usernme."'")->getRow()->address;
										}
										}

										/*$cur=$row->currency;
			                            if($cur=='1')
			                            	$curr_name="USD";
			                            else if($cur=='2')
			                               $curr_name='BTC';
			                            else if($cur=='3')
			                            	$curr_name='ETH';
			                            else
			                            	$curr_name=strtoupper($currency_info->currency_unit); */
			                            	if($row->amount > 0) { 
								?>
								<tr>
									<td class=""><?php echo date('Y-m-d H:i:s', strtotime($row->date));?></td>
									<td class="text-center"><?php echo $row->transactionid ? $row->transactionid : '---';?></td>
									<td class=""><?php echo $username;?></td>
									<td class=""><?php  if($type1 == "deposit") echo $deposit_address; else echo $row->address;?></td>
									<td class=""><?php echo "TRC 20";?></td>
									<td class="" style="display:none;"></td>
									<td class=""><?php echo $row->amount.' '."USDT";?></td>
									<!-- <td class=""><?php echo ucfirst($payment_name);?></td> -->
								</tr>
							<?php 
                                   }
									}
								}  else { 

							?>
								<?php } ?>
							</tbody>
						</table>
					<?php } else { 
						?>
						<table class="table datatable-responsive table-hover">
							<col width="13%">
	  						<col width="12%">
	  						<col width="15%">
	  						<col width="22%">
	  						<col width="10%" style="display:none;">
	  						<col width="13%">
	  						<col width="11%">
	  						<col width="10%" style="display:none;">
	  						<thead>
								<tr>
									<th class=""><?php echo lang('language_lang.lbl_date');?></th>
									<th class="text-center"><?php echo lang('language_lang.lbl_transaction_id');?></th>
									<th class=""><?php echo lang('language_lang.lbl_user_name');?></th>
									<th class=""><?php echo lang('language_lang.lbl_description');?></th>
									<th class="" style="display:none;"></th>
									<th class="" style="display:none;"></th>
									<th class=""><?php echo lang('language_lang.lbl_amount');?></th>
									
									
									<th class=""><?php echo lang('language_lang.lbl_payment_gateway');?></th>
									<?php if($this->uri->getSegment(3)=='deposit') { ?>
											<th class=""><?php echo lang('language_lang.lbl_options');?></th>
									<?php } ?>
								</tr>
							</thead>
							<tbody>
							<?php 
								if($history) {
								
									
									$row_count = count($history);
									//$this->load->library('MyEncrypt');
									$myencrypt = new MyEncrypt;
									foreach ($history as $row) {


										
										$coinid=$row->currency;
									
										$condition = "coid ='".$coinid."'";
										$cointable = $this->common_model->GetRow('coin_info',$condition);
										$pay_mode=$cointable->pay_mode;
										
				                        $payment_name = "--";

										$usernme = $row->uusersid;
										$referral1=$this->db->query("SELECT * FROM uusers WHERE uusersid='".$usernme."'")->getResult();
    									$user=$referral1[0];
										$username=$user->email;

										if($row->is_delete =='0'){


											  // $cur=$row->currency;
				         //                       if($cur=='1')
				         //                        $curr_name="USD";
				         //                      if($cur=='2')
				         //                        $curr_name='BTC';
				         //                      if($cur=='3')
				         //                        $curr_name='ETH';

								?>
								<tr>
									<td class=""><?php echo date('Y-m-d H:i:s', strtotime($row->date));?></td>
									<td class="text-center"><?php echo $row->transactionid ? $row->transactionid : '---';?></td>
									<td class=""><?php echo $username;?></td>
									<td class=""><?php echo ucfirst($row->description);?></td>
									<td class="" style="display:none;"></td>
									<th class="" style="display:none;"></th>
									<td class=""><?php echo $row->amount.' '.$row->coin_symbol;?></td>
									
									<td class=""><?php echo ucfirst($payment_name);?></td>
									<?php 
									if($row->type == 'deposit' || $row->type == 'reinvest')
									{?>
										<td class="text-center">
	                                		<!-- <a class="btns" data-popup="tooltip" title="<?php echo lang('language_lang.lbl_approve_withdraw');?>"  href="javascript:void(0)" onClick="payouts('<?php echo $myencrypt->encode($row->historyid);?>')" ><i class="fa fa-thumbs-up"></i></a> -->
	                                		<!-- <a class="btns cancelbtn" value="<?php echo $myencrypt->encode($row->historyid);?>" data-popup="tooltip" title="<?php echo lang('language_lang.lbl_cancel_deposit');?>"  href="javascript:void(0)" ><i class="fa fa-thumbs-down"></i></a> -->
	                                		<button type="button" class="btn btn-danger" onclick="canceldeposit('<?php echo $myencrypt->encode($row->historyid);?>')" value="" data-popup="tooltip" title="<?php echo lang('language_lang.lbl_cancel_deposit');?>"><i class="fa fa-thumbs-down"></i></button>
	                                	</td>
	                                <?php
	                                }?>
								</tr>
							<?php 

									}
								}
								}  else { 

							?>
								<?php } ?>
							</tbody>
						</table>
					<?php } ?>
					<!-- </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 if($this->session->getFlashData('error_message')) { ?>
					$.jGrowl("<?php echo $this->session->getFlashData('error_message');?>", {
			            header: '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 } ?>

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

				$('.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/finance/history');?>',
			            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();
			            }
			        });
			        
			    });
				/*
				$('.cancelbtn').click(function (e) {
					e.preventDefault();
					var id = this.value;
					swal({
			            title: "<?php echo lang('language_lang.confirm_cancel_deposit_text');?>",
			            showCancelButton: true,
			            closeOnConfirm: false,
			            confirmButtonColor: "#2196F3",
			            cancelButtonColor: true,
			            showLoaderOnConfirm: true
			        },
			        function(inputValue){
			            if (inputValue === false) {
			            	return false;
			            } else {
			            	window.location.href = "<?php echo base_url();?>admin/finance/Canceldeposit/"+id;
			            }
			        });
				})*/
			    
		});

	})(jQuery);

	function canceldeposit(id) {

		swal({
            title: "<?php echo lang('language_lang.confirm_cancel_deposit_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            cancelButtonColor: true,
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	window.location.href = "<?php echo base_url('admin/finance/Canceldeposit/');?>"+id;
            }
        });

	}

	/*
	function approvedeposit(id) {

		swal({
            title: "Do you want to approve deposit?",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            cancelButtonColor: true,
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	window.location.href = "<?php echo base_url();?>admin/finance/approverequest/"+id;
            }
        });

	}
	*/
    
	
	</script>

</body>
</html>
