<!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 "Trade 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="">Trade Mode</th>
                <th class="">Coin</th>
                <th class="">Strategy</th>
                
                <th class="">Profit(%)</th>
                <th class="">Startegy Type</th>                
                
                <th class="">Telegram</th>                
                <th class="" style="margin-left: 20px;">Action</th>
              </tr>
            </thead>
            <tbody>
            <?php 
              
                          
                            
              if($trader) {
               $i=0;

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



              ?>
              <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 $row->trade_mode;?></td>      
                  <td class=""><?php echo $row->coin_id ;?></td>
                <td class=""><?php echo ucwords($row->stratgy);?></td>
                
                <td class=""><?php echo $row->profit;?></td>
                <td class=""><?php echo $row->strategy_type;?></td>                
                <td class=""><?php echo $row->telegram;?></td>
                                <td class=""> 
                                  <a class="btns" data-popup="tooltip" title="Approve"  href="javascript:void(0)" onclick="confirmaccept('<?php echo $myencrypt->encode($row->id);?>')"><i class="fa fa-thumbs-up"></i></a>                                
                                  <a class="btns" href="<?php echo base_url().'/admin/finance/edit_trader/'.$myencrypt->encode($row->id);?>"><i class="fa fa-edit"></i></a>
                                  <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 } ?>
            

      $('.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 changemarket(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/makepairinactive',
                data: {'id':valus1},
                success : function(resp)
                {
                  alert(resp);
                    if(resp){
                        window.location.href = "<?php echo base_url();?>admin/finance/currencypairlist";
                    } 
                }
            });
        }
        });
  }

  function changeinStatus(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/changepairstatus',
                data: {'id':valus1},
                success : function(resp)
                {
                    if(resp)
                    {
                        window.location.href = "<?php echo base_url();?>admin/finance/currencypairlist";
                    }
                }
            });
            }
        });
  }         

  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;
            }
        });
    }


  function confirmaccept(value) {

    swal({
            title: "<?php echo 'Do you confirm the trader';?>",
            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/tradeaccept/');?>"+'/'+value;
            }
        });
    }

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