<?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');?>">
</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 bootstrap snippets bootdeys">
<div class="row">
     <form class="steps-validation create-user" id="TransactionModel" method="post" action="<?php echo base_url();?>/circle_add" enctype="multipart/form-data">
                  <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>
                  <h5 style="font-weight: bold;"> Transaction Settings</h5>
                    <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 class="form-btn text-center ">
                      <button type="submit"  name="sub" id="sub" class="btn btn-primary">SUBMIT</button>
                    </div>
              </div>
             </form>
</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">
     $(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);
      }
    }
  });
}

});
});



</script>