<!DOCTYPE html>
<html lang="en">
   <head>
      <!-- Main navbar -->
      <?php
         use App\Libraries\MyEncrypt;
         $session = session();
         
         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;
         }
       
		.image
		{
			width:70px;
			height:70px;
		}


      </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">
            <div class="page-title">
               <h4><i id="icon-bck" class="icon-arrow-left52 position-left"></i> <span class="text-semibold"><?php echo 'Rank Settings'; ?></h4>
               <ul class="breadcrumb breadcrumb-caret position-right">
                  <?php foreach ($breadcrumbs as $breadcrumb) { if(isset($breadcrumb['href'])){?>
                  <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
                  <?php } else { ?> 
                  <li><?php echo $breadcrumb['text']; ?></li>
                  <?php } } ?>
               </ul>
            </div>
            <?php 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 'Rank Settings';?></h5>
                     <div class="heading-elements">
                        <ul class="icons-list">
                           <li><a href="<?php echo base_url('admin/rewardsettings/add');?>" 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();?>
                  <?php
                     $this->db = db_connect();
                     $one=$this->db->query("SELECT * FROM rewardsettings");
                     $two=$one->getResult();
                                                                                                                                                                                                                                                                                                            
                     ?>                                                                                                         
                  <table class="table datatable-responsive-row-control table-hover">
                     <col width="5%">
                     <col width="15%">
                     <col width="15%">
                     <col width="15%">
                     <col width="15%">
                     <col width="15%">
                     <col width="15%">
                     <thead>
                        <tr>
                           <th></th>
                           <th class=""><?php echo 'SI.No';?></th>
                           <th class="text-center"><?php echo 'Rank name';?></th>
                           <th class="text-center"><?php echo 'Amount';?></th>
                           <th class="text-center">Image</th>
                           <!-- <th class="text-center"><?php //echo 'Direct Sponsor Count';?></th> -->
                           <th class="text-center"><?php echo 'Team Reward';?></th>
                           <th class="text-center"><?php echo 'Gas Fee Reward';?></th>
                         
                           <!-- <th class="text-center"> Sponsor eligible Rank</th>
                           <th class="text-center"> Sponsor eligible Count</th> -->
                           <th class="text-center"><?php echo 'Group Sales';?></th>
                           <th class="text-center">Status</th>
                           <th class="text-center"><?php echo lang('language_lang.lbl_action');?></th>
                        </tr>
                     </thead>
                     <tbody>
                        <?php
                           $i=1;
                           
                           foreach($two as $row)
                           {
                               if($row->status=='1'){
                                   $label_status = 'label-success';
                                   $status = lang('language_lang.active');
                               } else {
                                   $label_status = 'label-danger';
                                   $status = lang('language_lang.in_active');
                               }
                           
                                $this->db = db_connect();
                               
                               $rank = $this->db->query('select rank_name from rewardsettings where id="'.$row->sponsor_elg_rank.'"')->getRow();
                           
                               $rname = ($rank == NULL) ? '---' : $rank->rank_name;
                           
                               
                           ?>	
                        <tr>
                           <td></td>
                           <td class=""><?php echo $i;?></td>
                           <td class="" style="text-align:center;"><?php echo ucwords($row->rank_name);?></td>
                           <td class="" style="text-align:center;"><?php echo  $row->amount;?>&nbsp;USDT</td>
                           <td class="text-center"><img src="<?php echo base_url();?>/assets/images/rank/<?php echo $row->image;?>" class="image"></th>
                           <!-- <td class="" style="text-align:center;"><?php //echo $row->direct_spon_count;?></td> -->
                           <td  class="text-center"><?php echo $row->team_reward;?> %</td>
                           <td  class="text-center"><?php echo $row->gas_reward;?> %</td>
                           <!-- <td class="text-center"><?php //echo $rname;?></td>
                           <td class="text-center"><?php //echo $row->sponsor_elg_count;?></td> -->
                           <td  class="text-center"><?php echo $row->group_sales;?>&nbsp;USDT</td>
                           <td class="text-center"><span class="label <?php echo $label_status;?>"><?php echo $status;?></span></td>
                           <td class="text-center">
                              <a class="btns" data-popup="tooltip" title="<?php echo 'edit';?>"  href="<?php echo base_url('admin/rewardsettings/edit/'.$row->id);?>"><i class="fa fa-edit"></i></a>
                              <a class="btns" data-popup="tooltip" title="<?php echo 'Delete';?>"  onclick="confirmdelete('<?php echo $row->id;?>')" href="javascript:void(0)" ><i class="fa fa-remove"></i></a>
                           </td>
                        </tr>
                        <?php
                           $i++;
                           }
                           
                           ?>
                     </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 if($session->getFlashData('error_message')) { ?>
         $.jGrowl("<?php echo $session->getFlashData('error_message');?>", {
         header: '<?php echo lang("language_lang.error");?>',
         theme: 'bg-danger'
         });
         
         <?php } ?>
         
         <?php if($session->getFlashData('success_message')) { ?>
         
         $.jGrowl("<?php echo $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 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/users/changeStatus');?>',
         data: {'id':valus1},
         success : function(resp)
         {
         if(resp){
         window.location.href = "<?php echo base_url('admin/users');?>";
         } 
         }
         });
         }
         });
         }
         function changeActiveStatus(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/users/changeActiveStatus');?>',
         data: {'id':valus1},
         success : function(resp)
         {
         if(resp){
         window.location.href = "<?php echo base_url('admin/users');?>";
         }
         
         }
         });
         }
         });
         
         }
         
         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){
         if (inputValue === false) {
         return false;
         } else {
         window.location.href = "<?php echo base_url('admin/rewardsettings/delete/');?>"+'/'+value;
         }
         });
         }
         
         function confirmreset(value) {
         
         swal({
         title: "<?php echo lang('language_lang.confirm_reset_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/users/resetpassword/');?>"+'/'+value;
         }
         });
         
         }
         
         function confirmdeposit(value) {
         
         if(value != ''){
         window.location.href = "<?php echo base_url('admin/finance/deposit/');?>"+'/'+value;
         }
         
         }
         
         function sendbonus(value) {
         
         if(value != ''){
         window.location.href = "<?php echo base_url('admin/finance/bonus/');?>"+'/'+value;
         }
         
         }
         
         function sendpenalty(value) {
         
         if(value != ''){
         window.location.href = "<?php echo base_url('admin/finance/penalty/');?>"+'/'+value;
         }
         
         }
         
         
         
         
         
      </script>
   </body>
</html>