<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
	<?php 
	use App\Libraries\MyEncrypt;

	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 "Circle List" ?></h5>
						<div class="heading-elements">
							<ul class="icons-list">
								<li><a href="<?php echo base_url();?>/admin/finance/trader" 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();?>
					<!-- <div class="ajax-refresh">  -->
					<table class="table datatable-responsive-user table-hover">
						<colgroup>
						<col width="10%">
  						<col width="13%">
  						<col width="13%">
  						<col width="13%">
  						<col width="13%">
  						<col width="13%">
  						<col width="15%">
  						<col width="15%">
  						<col width="15%">
  						<col width="15%">
  						<col width="15%">
  						<col width="15%">
  						</colgroup>

						<thead>
							<tr>
								<th class="" style="display:none;"></th>	
								<th class="" style="display:none;"></th>
								<th class="" style="display:none;"></th>
								<th class="">S.No</th>
								<th class="">Promotion By</th>
								<th class="">Circle Name</th>
								<th class="">Title</th>
								<th class="" width="20%">Description</th>
								
					                
                <th class="">Attachments</th>
                <!-- <th class="">Startegy Type</th>                 -->
                
                <!-- <th class="">Telegram</th>     							 -->
								<th class="">Action</th>
								<th class="" width="25%">Process</th>
							</tr>
						</thead>
						<tbody>
						<?php 
							
                             // $trader=$this->db->query("SELECT * FROM trader")->getResult();
                            
							if($trader) {
								$i=0;

								$myencrypt = new MyEncrypt;
									
								foreach ($trader as $row) { 

									if($row->uusersid != 0) { $i++;


									 // $id=$row->coin_id;
          //                     $coin = $this->db->query("SELECT * FROM coin_info WHERE coid=$id")->getResult();
          //                     $con=$coin[0];
                  if($row->strategy_mode == 1){
                     $strategy_name = "Whole Warehouse Mode";
                  }else if($row->strategy_mode == 2){
                     $strategy_name = "Subbin Mode";
                  }else{
                     $strategy_name = "Subbin Realtime Settlement";
                  }

                  		if($row->status=='1'){
										$label_status = 'label-success';
										$status = lang('language_lang.active');
									} else {
										$label_status = 'label-danger';
										$status = lang('language_lang.in_active');
									}

  $email = $this->db->query("Select * from uusers where uusersid = '".$row->uusersid."'")->getRow()->email;
  $trader_name = $this->db->query("Select * from trader where id = '".$row->trader_id."'")->getRow()->trade_mode;
                  

							?>
							<tr>
							<td class="" style="display:none"></td>
							<td class="" style="display:none"></td>
							<td class="" style="display:none"></td>
							<td class=""><?php echo $i;?></td>
								<td class=""><?php echo $email;?></td>			
								<td class=""><?php echo $trader_name;?></td>			
							    <td class=""><?php echo $row->title ;?></td>
								<td class=""><?php echo ucwords($row->description);?></td>
								
								<td class=""><a href="<?php echo base_url();?>/uploads/promotion/<?php echo $row->profile;?>" target="_blank"><img src="<?php echo base_url();?>/uploads/promotion/<?php echo $row->profile;?>" target="_blank" width="50" height="50" >
									<?php if($row->profile1 && file_exists(base_url('uploads/promotion/'.$row->profile1))) { ?>
									<a href="<?php echo base_url();?>/uploads/promotion/<?php echo $row->profile1;?>" target="_blank"><img src="<?php echo base_url();?>/uploads/promotion/<?php echo $row->profile1;?>" target="_blank" width="50" height="50" ></a><?php } ?></td>
							             <!-- <td class=""><?php echo $row->strategy_type;?></td>                 -->
                <!-- <td class=""><?php echo $row->telegram;?></td> -->
                		<?php if($row->status=='1')
							{                                                                

							 ?>
						    <td class=""><span class="label <?php echo $label_status;?>"><a style="color:#fff;text-transform:none;font-size:13px;" data-popup="tooltip" title="<?php echo lang('language_lang.click_to_deactive');?>" onclick="changeStatus('<?php echo $myencrypt->encode($row->id);?>')"><?php echo $status;?></a></span></td>
								
								<?php } else { ?>

 						   <td class=""><span class="label <?php echo $label_status;?>"><a style="color:#fff;text-transform:none;font-size:13px;" data-popup="tooltip" title="<?php echo lang('language_lang.click_to_active');?>" onclick="changeActiveStatus('<?php echo $myencrypt->encode($row->id); ?>')"><?php echo $status;?></a></span></td>
                                <?php 

                                } ?>
                                  <td>                	
                               		<a class="btns" id="del" data-popup="tooltip" title="<?php echo lang('language_lang.delete');?>"  onclick="confirmdelete('<?php echo $myencrypt->encode($row->id);?>')" href="javascript:void(0)" ><i class="fa fa-remove"></i></a>
                                
                                </td>
							</tr>
						<?php 
					}
						//$i++;
                         }
							}?>


					</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 } ?>
            



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

	})(jQuery);

		function changeStatus(valus) {

		swal({
            title: "<?php echo lang('language_lang.confirm_status_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
	            var valus1 =  valus;
				jQuery.ajax({
		            type: 'post',
		            url:'<?php echo base_url('admin/finance/changePromotionStatus');?>',
		            data: {'id':valus1},
		            success : function(resp)
		            {
		                if(resp){
		                    window.location.href = "<?php echo base_url('admin/finance/promotionlist');?>";
		                } 
		            }
		        });
		    }
        });
	}
	function changeActiveStatus(valus,status) {
		swal({
            title: "<?php echo lang('language_lang.confirm_status_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	var valus1 =  valus;
				jQuery.ajax({
		            type: 'post',
		            url:'<?php echo base_url('admin/finance/changePromotionActiveStatus');?>',
		            data: {'id':valus1},
		            success : function(resp)
		            {
		                if(resp){
		                    window.location.href = "<?php echo base_url('admin/finance/promotionlist');?>";
		                }
		                
		            }
		        });
            }
        });
		
	}       	

	function confirmdelete(value) {

		swal({
            title: "<?php echo lang('language_lang.confirm_delete_text');?>",
            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/tradedelete/');?>"+'/'+value;
            }
        });
    }

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