<?php
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <?php

        use App\Libraries\MyEncrypt;
        use App\Helpers\site_helper;
        $this->db = db_connect();
        $session = session();
        $validation = \Config\Services::validation();
        $this->common_model = model('CommonModel');
       echo view('user/common_style1');
       echo view('user/common_header');
    ?> 

<link rel="stylesheet" href="<?php echo base_url('styles/css/table.css');?>">
<!-- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"> -->
<!-- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css"> -->
<style type="text/css">
  /* your CSS goes here*/
 body {
    background: #eee
}

#regForm {
    background-color: #ffffff;
    margin: 0px auto;
    font-family: Raleway;
    padding: 40px;
    border-radius: 10px
}

h1 {
    text-align: center
}

input {
    padding: 10px;
    width: 100%;
    font-size: 17px;
    font-family: Raleway;
    border: 1px solid #aaaaaa
}

input.invalid {
    background-color: #ffdddd
}

.tab {
    display: none
}

button {
    background-color: #4CAF50;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    font-size: 17px;
    font-family: Raleway;
    cursor: pointer
}

button:hover {
    opacity: 0.8
}

#prevBtn {
    background-color: #bbbbbb
}

.step {
    height: 15px;
    width: 15px;
    margin: 0 2px;
    background-color: #bbbbbb;
    border: none;
    border-radius: 50%;
    display: inline-block;
    opacity: 0.5
}

.step.active {
    opacity: 1
}

.step.finish {
    background-color: #4CAF50
}

.all-steps {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 30px
}

.thanks-message {
    display: none
}

.container {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 22px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}


/* Hide the browser's default radio button */

.container input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}


/* Create a custom radio button */

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border-radius: 50%;
}


/* On mouse-over, add a grey background color */

.container:hover input~.checkmark {
    background-color: #ccc;
}


/* When the radio button is checked, add a blue background */

.container input:checked~.checkmark {
    background-color: #2196F3;
}


/* Create the indicator (the dot/circle - hidden when not checked) */

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}


/* Show the indicator (dot/circle) when checked */

.container input:checked~.checkmark:after {
    display: block;
}


/* Style the indicator (dot/circle) */

.container .checkmark:after {
    top: 9px;
    left: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}
</style>
</head>
<body class="admin-inner">

<section class="white pt-10 pb-10">
<div class="container">
<div class="row  trading_pairbg bg-white inner-box mt-3 px-3 py-4">

<div class="col-lg-12">
<div class="right-block">
	<div class="inner-title pb-3">
	<h6 class="color-2"><i class="fab fa-bitcoin"></i> Circle Registration</h6>
	</div>
<div class="container mt-5">
    <div class="row d-flex justify-content-center align-items-center">
        <div class="col-md-12">
               <form class="create-user" id="TransactionModel" method="post" action="<?php echo base_url();?>/circle_add" enctype="multipart/form-data">
                <div class="all-steps" id="all-steps"> <span class="step"></span> <span class="step"></span> <span class="step"></span> <span class="step"></span> </div>
                <div class="tab">
                  <div class="row">
                                <div class="col-lg-6 col-md-6">
                    <div class="form-block mb-3">
                <input name="trade_mode" class="form-control" placeholder="Trade Name"  type="text" id="trade_mode" value="<?php echo $qry->trade_mode ? $qry->trade_mode : '';?>"/>
                    </div>

                    <div class="form-block mb-3">
                      <input name="stratgy" class="form-control"  type="text" id="stratgy" required="" placeholder="Strategy Name" value="<?php echo $qry->stratgy ? $qry->stratgy : '';?>"/>
                    </div>
                    <div class="form-block mb-3">
                    <input name="address" class="form-control"  type="text" id="address" required="" placeholder="Address" value="<?php echo $qry->address ? $qry->address : '';?>"/>
                    </div>
                <div class="form-block mb-3">
                <input name="twitter" class="form-control"  type="text" id="twitter" required="" value="<?php echo $qry->twitter ? $qry->twitter : '';?>" placeholder="<?php echo ('twitter'); ?>"/>
                </div>

                  <div class="form-block mb-3">
                  <input name="youtube" class="form-control"  type="text" id="about" required="" value="<?php echo $qry->youtube ? $qry->youtube : '';?>" placeholder="<?php echo ('youtube'); ?>"/>
                  </div>

                    <div class="form-block mb-3">
                          <select name="strategy_mode" id="strategy_mode" class="select-search form-control">
                    <option value=""><?php echo "Select strategy mode" ?></option>
             
                    
                    <option value="1" <?php if($qry->strategy_mode == 1) echo "selected"; ?>>Whole ware house mode</option>
                    <option value="2" <?php if($qry->strategy_mode == 2) echo "selected"; ?>>Subbin mode</option>
                    <option value="3" <?php if($qry->strategy_mode == 3) echo "selected"; ?>>Subbin Realtime Settlement mode</option>
                    
                  </select>
                  
                    </div>
                    <div class="form-block mb-3">
                      <?php if($qry->trade_image) { ?>
                      <img src="<?php echo base_url();?>/uploads/trader/<?php echo $qry->trade_image;?>" width="100" height="100">
                    <?php } else {  ?>
                      <img src="<?php echo base_url('/uploads/trader/2.jpeg');?>" width="100" height="100">
                    <?php }  ?>
                    </div>
              

                  </div>
                <div class="col-lg-6 col-md-6">

                <div class="form-block mb-3">
                <select id="coin_id" class="form-control" name="coin_id">
                <option value="" required>--select trading pair--</option>
                <?php
                foreach ($get_active as $keys) 
                {
                ?>
                <option value="<?php echo $keys;?>" <?php if($qry->coin_id == $keys) echo "selected"; ?>><?php echo $keys;?></option>
                <?php
                }
                ?>
                </select>
                </div>
                <div class="form-block mb-3">
                <input name="description" class="form-control" placeholder="About your Circle"  type="text" id="description" value="<?php echo $qry->description ? $qry->description : '';?>"/>
                </div>

                    <div class="form-block mb-3">
          <input name="facebook" class="form-control"  type="text" id="facebook" value="<?php echo $qry->facebook ? $qry->facebook : '';?>" required="" placeholder="<?php echo ('facebook'); ?>"/>
                    </div>

                    <div class="form-block mb-3">
                      <input name="profit" class="form-control" value="<?php echo $qry->profit ? $qry->profit : '';?>"  type="text" id="profit" required="" placeholder="Profit ( % )"/>
                    </div>
                    <div class="form-block mb-3">
            <input name="telegram" class="form-control"  type="text" id="telegram" value="<?php echo $qry->telegram ? $qry->telegram : '';?>" required="" placeholder="<?php echo ('telegram'); ?>"/>
                    </div>
                    <div class="form-block mb-3">
                    <select name="strategy_type" id="strategy_type" class="select-search form-control" >
                    <option value=""><?php echo "Select Strategy Type" ?></option>
                    <option value="Cycle Strategy" <?php if($qry->strategy_type == "Cycle Strategy") echo "selected"; ?>>Cycle Strategy</option>
                    <option value="Oneshot Strategy" <?php if($qry->strategy_type == "Oneshot Strategy") echo "selected"; ?>>Oneshot Strategy</option>
                    </select>
                    </div>

                              <div class="form-block mb-3">
                                  <input type="file"  class="file-input-extensions" name="trade_image" value="" id="trade_image"/>
                                  <span class="help-block"><?php echo lang('language_lang.site_logo_extension');?></span>
                                  <?php echo $validation->getError('trade_image', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
                                    <div class="messageContainer"></div>
                              </div>
                              <input type="hidden" name="id" value="<?php echo $id;?>">
                  </div>
               </div>
                </div>
                <div class="tab">
                  <div class="row">
                   <div class="col-lg-3">
            <div class="modal-form mb-4">
              <label class="">First order amount</label>
      <input type="text" class="form-control mt-1" placeholder="" name="first_buy_amount" id="first_buy_amount" value="<?php echo $qry->first_buy_amount;?>">
            </div>
             <div class="modal-form mb-4">
              <label class="">Double open position</label>
            <div class="form-check form-switch form-switch-lg mb-3" dir="ltr">
            <input type="checkbox" class="form-check-input" data-on-text="<?php echo $on?>" data-off-text="<?php echo $off; ?>" data-on-color="primary" data-off-color="default" name="open_position_doubled" <?php if($qry->open_position_doubled==='on'){ echo 'checked="checked"'; } ?>>
            </div>
            </div>
            <div class="modal-form mb-4">
              <label class="">Replenishment times</label>
              <input type="text" class="form-control mt-1"  id="replenishment_time" name="replenishment_time" placeholder="" value="<?php echo $qry->margin_column_limit;?>" >
            </div>
            <div class="modal-form mb-4">
              <label class="">Whole position take profit ratio</label>
              <div class="input-group">
                <input type="text" class="form-control mt-1" placeholder="" name="whole_profit_ratio" value="<?php echo $qry->whole_profit_ratio;?>">
                <span class="input-group-text mt-1">% </span> </div>
            </div>
            <div class="modal-form mb-4">
              <label class="">Whole position take profit Callback</label>
              <div class="input-group">
                <input type="text" class="form-control mt-1" placeholder="" name="whole_profit_callback" value="<?php echo $qry->whole_profit_callback;?>">
                <span class="input-group-text mt-1">% </span> </div>
            </div>
            
          <div class="modal-form mb-4">
          <label class="">Buy in callback</label>
          <div class="input-group">
          <input type="text" class="form-control mt-1" placeholder="" name="buyin_callback" value="<?php echo $qry->buyin_callback;?>">
          <span class="input-group-text mt-1">% </span> </div>
          </div>
            <div class="modal-form mb-4" id="subposition">
              <label class="">Sub-Position take-profit callback</label>
              <div class="input-group">
                <input type="text" class="form-control mt-1" placeholder="" name="sub_position_callback" value="<?php echo $qry->sub_position_callback;?>">
                <span class="input-group-text mt-1">% </span> </div>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="modal-head">
              <h6 class="mont">Margin Configuration</h6>
            </div>
            <div class="row">
              <div class="col-lg-6">
                <div class="modal-head">
                  <h5 class="text-black mont">Margin Call drop</h5>
                </div>

                  <span id="ex_demo1"></span>

              </div>
              <div class="col-lg-6">
                <div class="modal-head">
                  <h5 class="text-black mont">Multiply Buy in ratio</h5>
                </div>

                <span id="ex_demo2"></span>

              </div>
            </div>
          </div>
          <div class="col-lg-3">
            <div class="modal-head">
              <h6 class="mont">Distributed and take profit Allocation</h6>
              <h5 class="text-black mont">Percentage of spilt-to-profit</h5>
            </div>
            <span id="ex_demo"></span>
          </div>
                </div>

                <div style="overflow:auto;" id="nextprevious">
                    <div style="float:right;"> <button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button> <button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button> </div>
                </div>
            </form>
        </div>
    </div>
</div>
    </div>
    </div>
    </div>
  </div>
</div>
</section>

<br>
<br>


        
        

<?php
 echo view('user/footer1');
  echo view('user/common_script');
?>
  </body>
</html>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo base_url('/styles/js/datatables.min.js');?>"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script type="text/javascript">
     $(document).ready(function() {
 
    $('#subposition').css('display', 'none');

        var num = $('#replenishment_time').val();

      if(num >= 5)
        {

          $('#subposition').css('display', 'block');
        }
        else
        {
          $('#subposition').css('display', 'none');
        }

        });
</script>

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

      $('.main-table table').dataTable({
          "language": { search: "" },
          "Info": false
    });

      $('#sub').click(function(){
      var first_buy_amount =  $("[name=first_buy_amount]").val();
      var whole_profit_ratio =  $("[name=whole_profit_ratio]").val();
      var whole_profit_callback =  $("[name=whole_profit_callback]").val();
      var buyin_callback =  $("[name=buyin_callback]").val();
      var flag = 1;
      if(!(whole_profit_ratio > 0)){
          $.notify(' <i class="fas fa-exclamation-triangle"></i> Please enter a value greater than 1', 'danger');
          flag = 0;
      }
      if(whole_profit_ratio < whole_profit_callback && flag == 1){
          $.notify(' <i class="fas fa-exclamation-triangle"></i> Take profit ratio will be greater than take profit callback', 'danger');
          flag = 0;
        }
        if(!(buyin_callback >= 0) && flag == 1){
          $.notify(' <i class="fas fa-exclamation-triangle"></i> Please enter a positive value', 'danger');
          flag = 0;
        }
          if(!(first_buy_amount >= 11 && flag == 1)){
          $.notify(' <i class="fas fa-exclamation-triangle"></i> Minimum first buy amount is 11 USDT', 'danger');
          flag = 0;
      }

       var empty = true;

      $('#TransactionModel input[type="text"]').each(function() {
      if($(this).val() == ''){
      $flag = 0;
      empty = false;
      }
      });

      if(empty == false){
      $.notify(' <i class="fas fa-exclamation-triangle"></i> Some fields are empty', 'danger');
      }

        if(flag == 1 && empty == true){
          $('#TransactionModel').submit();
          $.notify('<i class="fas fa-check"></i>  Set Successfully', 'success');
        }


          
    });  

      var num = $('#replenishment_time').val();
var uusersid = $('#uusersid').val();
  $.ajax({
  type: 'post',
  dataType:'html',
  url : '<?php echo base_url("/replenishment_time1");?>',
  data : {'number1':num,'uusersid':uusersid,'pair':'<?php echo $symbol; ?>'},
  headers: {'X-Requested-With': 'XMLHttpRequest'},
  success : function(msg)
  {
  if(msg)
  {
  $('#ex_demo1').html(msg);
  }
  }
  });

  $.ajax({
  type: 'post',
  dataType:'html',
  url : '<?php echo base_url("/replenishment_time2");?>',
  data : {'number2':num,'uusersid':uusersid,'pair':'<?php echo $symbol; ?>'},
  headers: {'X-Requested-With': 'XMLHttpRequest'},
  success : function(msg)
  {
    if(msg)
    {
    $('#ex_demo2').html(msg);
    }
  }
  });

  $.ajax({
  type: 'post',
  dataType:'html',
  url : '<?php echo base_url("/replenishment_time");?>',
  data : {'number':num,'uusersid':uusersid,'pair':'<?php echo $symbol; ?>'},
  headers: {'X-Requested-With': 'XMLHttpRequest'},
  success : function(msg)
    {
      if(msg)
      {
      $('#ex_demo').html(msg);
      }
    }
  });




$('#replenishment_time').on('change',function(){

  var num = $('#replenishment_time').val();
  var uusersid = $('#uusersid').val();

  if(num >= 5)
    {
      $('#subposition').css('display', 'block');
    }
    else
      {
        $('#subposition').css('display', 'none');
      }

  if(num>=5)
  {
    $.ajax({
    type: 'post',
    dataType:'html',
    url : '<?php echo base_url("/replenishment_time");?>',
    data : {'number':num,'uusersid':uusersid},
    headers: {'X-Requested-With': 'XMLHttpRequest'},
    success : function(msg)
    {
        if(msg)
        {
        $('#ex_demo').html(msg);
        }
      }
    });
  }
  else
  {
     $('#ex_demo').html("");
  }

  if(num>0)
  {
    $.ajax({
      type: 'post',
      dataType:'html',
      url : '<?php echo base_url("/replenishment_time1");?>',
      data : {'number1':num,'uusersid':uusersid},
      headers: {'X-Requested-With': 'XMLHttpRequest'},
      success : function(msg)
      {
        if(msg)
        {
        $('#ex_demo1').html(msg);
        }
      }
    });

  }

if(num>0)
{
  $.ajax({
    type: 'post',
    dataType:'html',
    url : '<?php echo base_url("/replenishment_time2");?>',
    data : {'number2':num,'uusersid':uusersid},
    headers: {'X-Requested-With': 'XMLHttpRequest'},
    success : function(msg)
    {
      if(msg)
      {
      $('#ex_demo2').html(msg);
      }
    }
  });
}

});
});

//your javascript goes here
var currentTab = 0;
document.addEventListener("DOMContentLoaded", function(event) {


    showTab(currentTab);

});

function showTab(n) {
    var x = document.getElementsByClassName("tab");
    x[n].style.display = "block";
    if (n == 0) {
        document.getElementById("prevBtn").style.display = "none";
    } else {
        document.getElementById("prevBtn").style.display = "inline";
    }
    if (n == (x.length - 1)) {
        document.getElementById("nextBtn").innerHTML = "Submit";
    } else {
        document.getElementById("nextBtn").innerHTML = "Next";
    }
    fixStepIndicator(n)
}

function nextPrev(n) {
    var x = document.getElementsByClassName("tab");
    if (n == 1 && !validateForm()) return false;
    x[currentTab].style.display = "none";
    currentTab = currentTab + n;
    if (currentTab >= x.length) {
        document.getElementById("TransactionModels").submit();
        // return false;
        //alert("sdf");
        document.getElementById("nextprevious").style.display = "none";
        document.getElementById("all-steps").style.display = "none";
        document.getElementById("register").style.display = "none";
        document.getElementById("text-message").style.display = "block";




    }
    showTab(currentTab);
}

function validateForm() {
    var x, y, i, valid = true;
    x = document.getElementsByClassName("tab");
    y = x[currentTab].getElementsByTagName("input");
    for (i = 0; i < y.length; i++) {
        if (y[i].value == "") {
            y[i].className += " invalid";
            valid = false;
        }
    }
    if (valid) { document.getElementsByClassName("step")[currentTab].className += " finish"; }
    return valid;
}

function fixStepIndicator(n) {
    var i, x = document.getElementsByClassName("step");
    for (i = 0; i < x.length; i++) { x[i].className = x[i].className.replace(" active", ""); }
    x[n].className += " active";
}



</script>