<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<html lang="en">
<?php
 use App\Libraries\MyEncrypt;
 use App\Helpers\site_helper;

$session =  \Config\Services::session();
$validation =  \Config\Services::validation();
$this->db = db_connect();
$userid = $session->get('uusersid');
$confirm = $this->db->table('history')->where('uusersid',$userid)->where('type','activation')->where('status',1)->get()->getRow();
echo view('user/common_style1');

$referral1=$this->db->query("SELECT * FROM bind_process WHERE uusersid='".$uusersid."'")->getResult();
$ref=$referral1[0];
$key = $ref->api_key;
$secret = $ref->secret_key;

if(empty($ref)){
  $key = "sFlTSc2Y56NQpdTBcjFw2vxESWXyeWBozax5gP3CoRQx8n70XgPw960G2pQWUeFg";
  $secret = "BZZswPqHBAYkY9Oz8YQIe9afnqEmY6VxfJLF44TI8rNDDaB6EuyWa6cN3Hy32pQG";
  $api = new Binance\API($key,$secret);
}else{
   $api = new Binance\API($key,$secret);
   $account = $api->accountStatus();
   if($account['sapi']['code'] == "-2008" || $account['sapi']['code'] == "-1022" || $account['sapi']['code'] == "-2015")
    {
        $key = "tJuR6dN9AZp9KiAn41avxq64KsyDxa8FIaRjxTf0k1qplZIv1MRnHrS3zQIqHuzZ";
        $secret = "GlRLQS2VGYfa1sOUaS3NIgGmszJOAuxu7Xk0anY1r4ifRmGYVYxoG25LOBnESE67";
        $api = new Binance\API($key,$secret);
    }
 }


$marketpair = $api->prevDay();

$ticker = $api->prices(); // Make sure you have an updated ticker object for this to work

$balances = $api->balances($ticker);

if(!empty($required_pairs)) { 
$i=0;
foreach ($marketpair as $key => $value) {
  if(substr($value['symbol'], -4) == "USDT"){
    if(in_array(substr_replace($value['symbol'] ,"",-4), $required_pairs)){
      $output[$i]['symbol'] = $value['symbol'];
      $output[$i]['price'] = $value['lastPrice'];
      $output[$i]['change'] = $value['priceChangePercent'];
    }
      $i++;
  }
}
$k = 0;
foreach ($output as $key => $value) {
  $output[$k] = $value;
  $k++;
}
$output =  array_unique($output,SORT_REGULAR);
}else {
  $output = "";
}

?>

</head>
  <style type="text/css">
.span
{
  font-size: 12px;
color: #9395a1;
margin-top: 14px;
font-weight: 900;
}
.btn-primary{
  background: rgb(32, 60, 157) !important;
  color: white !important;
}
.trade{
  top: 0px !important;
}
.selects {
    text-transform: none;
    background: none;
    border: none;
    font-size: 800;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    background: transparent;
}

#myCarousel {
  z-index: 1;
}

.carousel.slide{
    max-width: 2000px;
    overflow: hidden;
}
.common_class{
  padding: 0 !important;
}
@media only screen and (max-width:768px){
   .common_class{
  padding: 0px !important;
}
  }

</style>

</style>
<body>
<?php echo view('user/common_header');?>

<section class="trading-bg">
  <div class="container-fluid">
    <?php
echo view('user/dashboard_header');


?>

<!-- <?php if($session->getFlashData('success_message')) {?>
<div class="row"><div class="col-lg-12 ">     <p class="frgtpwd frgtpwd1"><i class="fa fa-thumbs-up"></i><?php echo $session->getFlashData('success_message');?></p></div></div>
<?php } 
else if ($session->getFlashData('error_message')) 
{ 
?>
<div class="row"><div class="col-lg-12">  <p class="frgtpwd frgtpwd1 frgtpwdred"><i class="fa fa-thumbs-down"></i><?php echo $session->getFlashData('error_message');?></p></div></div>
<?php } else { }?> -->
<br/><br/><br/>
  <section class=" bg-white position-relative common_class">
  <div>
  <div id="myCarousel" class="carousel slide" data-bs-ride="carousel">
    <div class="carousel-indicators">
      <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
      <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="1" aria-label="Slide 2"></button>
      <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="2" aria-label="Slide 3"></button>
    </div>
    <div class="carousel-inner">
    <?php
    if($sliders) {
              $i = 0;
              foreach ($sliders as $slider) { $i++;
              $slider_image = '/content/slider/'.$slider->image;
              if($i == 1)
                 $active = "active";
              else
                 $active = "";
              ?> 
              <div class="carousel-item <?php echo $active;?>">
              <div class="row">
              <div class="col-lg-12 col-md-12 col-sm-12 wow fadeInUp"  data-wow-delay="0.5s">
          <div class="trade" ><img src="<?php echo base_url().$slider_image;?>"  class="img-fluid" alt="trade" ></div>
              </div>
              </div>

              </div>
     <?php } } ?>
    </div>
  </div>
</div>
</section>

    <div class="row">
      <div class="col-lg-12">
        <div class="trading_pairbg bg-white inner-box mt-3 px-3 py-4">
          <div class="inner-title pb-3">
            <h6 class="color-2"><i class="fab fa-bitcoin"></i>Operation Strategy</h6>
          </div>
          <div class="row">
            <div class="col-lg-9"></div>
                   <div class="col-lg-3">
            <div class="search-input">
            <input type="text" id="id_search" placeholder="please enter the trading pair" class="form-control" style="display: block;">
            </div>
            </div>
          </div>
          <br/>
          <div class="operation_list"></div>
          <div class="trading-table operation_list_table">
        <div class="table-responsive">
          <table class="table-striped display nowrap" id="table_example" style="width:100%">
            <thead>
              <tr>
                <td> List </td>
                <td>Quantity </td>
                <td> Profit / Loss </td>
                <td> Price </td>
                <td> Charge% </td>
                <td> Rate of Return </td>
                
              </tr>
            </thead><tbody>
              <?php

              

// $j=0;
//    if($output){
//   foreach ($output as $key => $value) {
//     foreach($required_pairs as $key => $value1){
//     if($value['symbol'] == $value1){
//           $output3[$j] = $value;
//     }
//     }
//   }
//           $j++;

// }
// echo"<pre>";
// print_r($output3);
// echo"</pre>";
// die;

$this->session = session();
$uusersid = $this->session->get('uusersid');
 

              if($output){
  foreach ($output as $key => $value) {

   
    $pair =  $value['symbol'];
      
      // return $session;

      $where_ = array(
        'pair' => $pair,
        'uusersid' => $uusersid,
        'trade_status != ' => '2',
      );

      $trade_record =  $this->db->table('trade_process')->where($where_)->orderBy('id','DESC')->get()->getRow();
     


      if ($trade_record) {
        
           $api_trade_data = array(
          'trade_process_id' => $trade_record->id,
          'uuserid' => $uusersid,
          'type' => '1',
          'status' => 0
        );

        $api_trade_data1 = array(
          'trade_process_id' => $trade_record->id,
          'uuserid' => $uusersid,
          'type' => '2',
          'description' => 'manual_sell',
          'status' => 0
        );

        $api_trade_data2 = array(
          'trade_process_id' => $trade_record->id,
          'uuserid' => $uusersid,
          'type' => '1',
          'status' => 0,
          'margin_call_drops = ' => 0
        );


         $profit_where = array(
            'uuserid' => $uusersid,
            'type' => '3',
            'trade_process_id' => $trade_record->id,
            'status' => 0
        );

        $total_position_amount = $this->db->table('api_trade_history')->selectSum('quantity')->where($api_trade_data)->get()->getRow();
        $total_sell_amount = $this->db->table('api_trade_history')->selectSum('quantity')->where($api_trade_data1)->get()->getRow();

      

        $total_position_amount->quantity = $total_position_amount->quantity - $total_sell_amount->quantity;


        $tradeupdate['current_position_amount'] = number_format($last_call_drop->quantity,5);
              $total_position_quantity = $this->db->table('api_trade_history')->selectSum('received_amount')->where($api_trade_data)->get()->getRow();
        $total_sell_quantity = $this->db->table('api_trade_history')->selectSum('received_amount')->where($api_trade_data1)->get()->getRow();
        $total_position_quantity->received_amount = $total_position_quantity->received_amount - $total_sell_quantity->received_amount;

        if ($total_position_amount->quantity > 0) {
          
          $tradeupdate['trade_position_amount'] = number_format($total_position_amount->quantity,5);  
        }else{
          $tradeupdate['trade_position_amount'] = 0.00;
        }

        if ($total_position_quantity->received_amount > 0) {
        $tradeupdate['trade_position_quantity'] = number_format($total_position_quantity->received_amount,5);
        }else{
          $tradeupdate['trade_position_quantity'] = 0.00;
        }
        
        // $avg_position_amount = $this->db->table('api_trade_history')->selectAvg('live_price')->where($api_trade_data)->get()->getRow();
               // $avg_position_amount = $this->db->table('api_trade_history')->selectAvg('live_price')->where($api_trade_data)->get()->getRow();
 if($trade_record->strategy_mode == 1){
        $total_contract = $this->db->table('api_trade_history')->selectSum('received_amount')->where($api_trade_data)->get()->getRow();
        $total_usdt  = $this->db->table('api_trade_history')->selectSum('quantity')->where($api_trade_data)->get()->getRow();
        if($total_contract->received_amount && $total_usdt->quantity)
          $avg_position_amount = $total_usdt->quantity / $total_contract->received_amount;
        else
          $avg_position_amount = 0;
  }else{
        if($trade_record->strategy_mode == 3) {
        $total_contract = $this->db->table('api_trade_history')->selectSum('received_amount')->where($api_trade_data)->where('margin_call_drops <=',4)->get()->getRow();
        $total_usdt = $this->db->table('api_trade_history')->selectSum('quantity')->where($api_trade_data)->where('margin_call_drops <=',4)->get()->getRow();
        if($total_contract->received_amount && $total_usdt->quantity)
          $avg_position_amount = $total_usdt->quantity / $total_contract->received_amount;
        else
          $avg_position_amount = 0;
      }else{
        $total_contract = $this->db->table('api_trade_history')->selectSum('received_amount')->where($api_trade_data)->where('margin_call_drops <=',4)->get()->getRow();
        $total_usdt = $this->db->table('api_trade_history')->selectSum('quantity')->where($api_trade_data)->where('margin_call_drops <=',4)->get()->getRow();
        $total_contract2 = $this->db->table('api_trade_history')->selectSum('received_amount')->where($profit_where)->get()->getRow();
        $total_contract = $total_contract->received_amount + $total_contract2->received_amount;
        $total_usdt2 = $this->db->table('api_trade_history')->selectSum('quantity')->where($profit_where)->get()->getRow();
        $total_usdt = $total_usdt->quantity + $total_usdt2->quantity;
        if($total_contract && $total_usdt)
          $avg_position_amount = $total_usdt / $total_contract;
        else
          $avg_position_amount = 0;
      }
      }

    
        if ($avg_position_amount > 0) {
          $tradeupdate['trade_avg_position'] = number_format($avg_position_amount,5);
        }else{
          $tradeupdate['trade_avg_position'] = 0.00;
        }



      

       $ticker = $api->prices($value['symbol']); 
          $live_price =  $ticker[$value['symbol']];

          $api_trade_data = array(
            'trade_process_id' => $trade_record->id,
            'uuserid' => $uusersid,
            'type' => '1',
          );

          // $first_buy =  $this->db->table('api_trade_history')->where($api_trade_data)->like('description','first_buy')->get()->getRow();


          // $tradeupdate['trade_avg_position'] = $first_buy->live_price;

            $tradeupdate['trade_avg_position'] = str_replace(',', '', $tradeupdate['trade_avg_position']);
          $tradeupdate['trade_position_amount'] = str_replace(',', '', $tradeupdate['trade_position_amount']);


          if($avg_position_amount == 0 &&  $tradeupdate['trade_position_amount'] == 0){
            $check_percentage = '0';
            $tradeupdate['floating_loss'] = 0;
          }
          else if ($avg_position_amount > $live_price) {
            
            // echo "first_buy = ".$tradeupdate['trade_avg_position'].'  -  ';
            // echo "live_price  = ".$live_price;
            // echo "<br>";
            // echo "decrease";

            // $tradeupdate['floating_loss'] = '-'.$tradeupdate['trade_avg_position'] - $live_price;
            
        $check_percentage = ($avg_position_amount - $live_price) / $avg_position_amount * 100 ;
            $check_percentage = '-'.$check_percentage;
            $floating_loss = $total_position_amount->quantity * $check_percentage / 100;
            $tradeupdate['floating_loss'] = number_format($floating_loss,5);
          }elseif ($avg_position_amount == $live_price) {
            
            // echo "first_buy = ".$tradeupdate['trade_avg_position'].'  -  ';
            // echo "live_price  = ".$live_price;
            // echo "<br>";

            // echo "same";
            $check_percentage = '0.00';
            $tradeupdate['floating_loss'] = 0;
          }else{
            
            // echo "first_buy = ".$tradeupdate['trade_avg_position'].'  -  ';
            // echo "live_price  = ".$live_price;
            // echo "<br>";

            // echo "increase";
            $check_percentage = ($live_price - $avg_position_amount) / $live_price * 100 ;
            $floating_loss = $total_position_amount->quantity * $check_percentage / 100;
            $tradeupdate['floating_loss'] = number_format($floating_loss,5);

            // $tradeupdate['floating_loss'] = '+'.$live_price - $tradeupdate['trade_avg_position'];

          }

          $tradeupdate['trade_rate_percentage'] = number_format($check_percentage,2).'%';


        

 

      }else{
        $tradeupdate['trade_position_amount'] = "";
        $tradeupdate['floating_loss'] = "";
        $tradeupdate['trade_rate_percentage'] = "";
      }

    if($value['change'] > 0){
      $class = "up";
      $change = '+'.$value['change'];
    }else{
      $class = 'down';
      $change = $value['change'];
    }


    if($tradeupdate['trade_rate_percentage'] == 0){
        $default_style = "dark";
    }else if($tradeupdate['trade_rate_percentage'] > 0){
        $default_style = "primary";
    }else{
        $default_style = "danger";
    }

    if($trade_record != "") { 
    
?>
               <tr>
                <td class="get" data-href="<?php echo base_url('tradedetails/'.$value['symbol']);?>"><img src="<?php echo base_url('styles/images/tradingpair_images/'.$value['symbol'].'.png');?>"  class="img-fluid me-1" height="50px" width="50px;"><?php echo $value['symbol'];?> </td>
                <td class="text-center get" data-href="<?php echo base_url('tradedetails/'.$value['symbol']);?>"><?php echo $tradeupdate['trade_position_amount'] ? $tradeupdate['trade_position_amount'] : "0.000000" ;?></td>
                <td class="text-center get" data-href="<?php echo base_url('tradedetails/'.$value['symbol']);?>"><?php echo $tradeupdate['floating_loss'] ? $tradeupdate['floating_loss'] : "0" ;?></td>
                <td class="text-center get" data-href="<?php echo base_url('tradedetails/'.$value['symbol']);?>"><?php echo $value['price'];?></td>
                <td class="text-center get" data-href="<?php echo base_url('tradedetails/'.$value['symbol']);?>"><span class="<?php echo $class;?>"><?php echo $change;?></span></td>
                <td class="text-center get" data-href="<?php echo base_url('tradedetails/'.$value['symbol']);?>"><button class="btn btn-<?php echo $default_style; ?>"><?php echo $tradeupdate['trade_rate_percentage'] ? $tradeupdate['trade_rate_percentage'] : "0%" ;?></button></td>
              </tr>
              <?php 
            }else{ ?>
              <tr>
              <td colspan="6">No Active Pairs Found</td>
            </tr>
           <?php }
            }
               } 
      ?>
             
            </tbody>
          </table>
        </div>
      </div> 
  </div>
</div>
</div>
</div>
</section>
</body>
  <?php
 echo view('user/footer1');
  // echo view('user/common_script');
?>
<!-- <script src="https://code.jquery.com/jquery-3.5.1.js"></script>


<script src="<?php echo base_url();?>/styles/new_style/js/jquery-2.1.4.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="<?php echo base_url();?>/styles/new_style/js/owl.carousel.min.js"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/script.js"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/wow.min.js"></script> -->


<!-- <script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/loaders/pace.min.js')?>"></script>
<script type="text/javascript" src="<?php echo base_url('/assets/js/core/libraries/jquery.min.js')?>"></script>
<script type="text/javascript" src="<?php echo base_url('/assets/js/core/libraries/bootstrap.min.js')?>"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/loaders/blockui.min.js')?>"></script>
<script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/ui/nicescroll.min.js')?>"></script>
<script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/ui/drilldown.js')?>"></script> -->


<!-- <script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/forms/selects/bootstrap_multiselect.js');?>"></script>
<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/forms/selects/bootstrap_select.min.js');?>"></script> -->
<!-- <script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/forms/styling/uniform.min.js');?>"></script>
<script type="text/javascript" src="<?php echo base_url('/assets/js/plugins/notifications/pnotify.min.js');?>"></script> -->
<!-- <script src="<?php echo base_url();?>/styles/new_style/js/jquery-2.1.4.min.js"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/owl.carousel.min.js"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/script.js"></script>
<script src="<?php echo base_url();?>/styles/new_style/js/wow.min.js"></script>  -->
<script src="<?php echo base_url('styles/new_style/js/jquery-2.1.4.min.js');?>"></script>
<script src="<?php echo base_url('/assets/js/plugins/notifications/jquery.quicksearch.js');?>"></script>
<script src="<?php echo base_url('styles/new_style/js/bootstrap.min.js');?>"></script>
<script src="<?php echo base_url('styles/new_style/js/owl.carousel.min.js');?>"></script>
<script src="<?php echo base_url('styles/new_style/js/script.js');?>"></script>
<script src="<?php echo base_url('styles/new_style/js/wow.min.js');?>"></script> 

<script type="text/javascript">

$(document).ready(function(){


    // var table = $('#table_example').DataTable( {
    //     rowReorder: {
    //         selector: 'td:nth-child(2)'
    //     },
    //     responsive: true
    // } );

    //     var table = $('#table_example1').DataTable( {
    //     rowReorder: {
    //         selector: 'td:nth-child(2)'
    //     },
    //     responsive: true
    // } );

    //         var table = $('#table_example2').DataTable( {
    //     rowReorder: {
    //         selector: 'td:nth-child(2)'
    //     },
    //     responsive: true
    // } );

    //             var table = $('#table_example3').DataTable( {
    //     rowReorder: {
    //         selector: 'td:nth-child(2)'
    //     },
    //     responsive: true
    // } );

    //                 var table = $('#table_example4').DataTable( {
    //     rowReorder: {
    //         selector: 'td:nth-child(2)'
    //     },
    //     responsive: true
    // } );

      var pairs = "";
      $.ajax({
      'method': 'POST',
      'url': '<?php echo base_url("/getPairDetails");?>',
      data:{'pair':pairs},
      success:function(msg)
      {
      if(msg!='')
      {
      $('.get_active').html(msg);   
      }
      else
      {
      }
      }
      });


$('#userlist').on('change',function(){
  
  var pair = $('#userlist').find(":selected").val();
  if(pair)
  {

    $.ajax({
    'method': 'POST',
    'url': '<?php echo base_url("/getPairDetails");?>',
     data:{'pair':pair},
    success:function(msg)
    {
    if(msg!='')
    {
     $('.get_active').html(msg);   
    }
    else
    {
    }
    }
    })


  }
  else
  {

      var pairs = "";
      $.ajax({
      'method': 'POST',
      'url': '<?php echo base_url("/getPairDetails");?>',
      data:{'pair':pairs},
      success:function(msg)
      {
      if(msg!='')
      {
      $('.get_active').html(msg);   
      }
      else
      {
      }
      }
      })
  }
});


$('input#id_search').quicksearch('table#table_example tbody tr');


    $('.get').click(function(){
        window.location = $(this).data('href');
        return false;
    });

});


     $('#subposition').css('display', 'none');

        var num = $('#replenishment_time').val();
      if(num >= 5)
        {

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



$('#sell').on('click',function()
  {
    var val = $('#limit_clk1').val();
    var num=  $('#code2').val();
    var id=$('#pair1').val();
    $.ajax({
      'method': 'POST',
      'url': '<?php echo base_url("/tradingsell");?>',
      data:{'val':val,'num':num,'id':id},
       
      success:function(msg)
        {
          if(msg!='')
          {
            $('#sellsuccess').css('display','inline-block');    
          }
          else
          {
            $('#sellfailure').css('display','inline-block');
          }
        }
    })
  });



// $('#replenishment_time').keyup(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("/dashboard/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("/dashboard/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("/dashboard/replenishment_time2");?>',
//     data : {'number2':num,'uusersid':uusersid},
//     headers: {'X-Requested-With': 'XMLHttpRequest'},
//     success : function(msg)
//     {
//       if(msg)
//       {
//       $('#ex_demo2').html(msg);
//       }
//     }
//   });
// }

// });




$(document).ready(function(){

  setInterval(function(){
$.ajax({
type:'post',
method: 'POST',
url: '<?php echo base_url("/autoLoad1");?>',
dataType:"html",
data:{
'_token':'1',
},
success: function (data) {

    $('.operation_list').html(data);
    $('.operation_list_table').css('display','none');
}
});

  }, 6000);


function update(){
  $("#loadpair").load('<?php echo base_url();?>/loadpair');
}

setInterval(update, 1000);

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

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

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


});
function doalert(obj) {
        $('#one').css('display','none');
        $('#cycle').css('display','inline-block');
        var b = $('#Cstartegy_Name').text();
        $('#crypto-strategy').html(b);
        var uusersid = $('#uusersid').val();
        $.ajax({

          type: 'post',
          url : '<?php echo base_url("/tradedetails/strategy_type");?>',
          data : {'strategy_type':b,'uusersid':uusersid},
          headers: {'X-Requested-With': 'XMLHttpRequest'},
          success : function(msg)
          {
            if(msg)
            {
              
            }
          }
      });     
    }

     function Ooalert(obj) {
        $('#one').css('display','inline-block');
        $('#cycle').css('display','none');
         var a = $('#Ostartegy_Name').text();
        $('#crypto-strategy').html(a);
        var uusersid = $('#uusersid').val();
        $.ajax({
          type: 'post',
          url : '<?php echo base_url("/tradedetails/strategy_type");?>',
          data : {'strategy_type':a,'uusersid':uusersid},
          headers: {'X-Requested-With': 'XMLHttpRequest'},
          success : function(msg)
          {
            if(msg)
            {
              
            }
          }
      });
    }
 function fa_heart(b)
     {   
        var uusersid = $('#uusersid').val();    
        var symbl = b;
       
        $.ajax({
          type: 'post',
          url : '<?php echo base_url("/dashboard/favourites");?>',
          data : {'uusersid':uusersid,'symbl':symbl},
          headers: {'X-Requested-With': 'XMLHttpRequest'},
          success : function(msg)
          {
            location.reload(true);
            if(msg)
            {
               
            }
          }
      });     
    }  


     function fa_heart1(a)
     {
        var uusersid = $('#uusersid').val();
        var symbl = a;
      
        $.ajax({
          type: 'post',
          url : '<?php echo base_url("/dashboard/favourites1");?>',
          data : {'uusersid':uusersid,'symbl':symbl},
          headers: {'X-Requested-With': 'XMLHttpRequest'},
          success : function(msg)
          {
            location.reload(true);
            if(msg)
            {
              
            }
          }
      }); 
    }

  $(".heart.fa").click(function() 
  {
    $(this).toggleClass("fa-heart fa-heart-o");

  });

   $('#sure_price').click(function(){

  var uusersid = $('#uusersid').val();
  var first_preset_drop = $('#first_preset_drop').val();
  $.ajax({
          type: 'post',
          url : '<?php echo base_url("/dashboard/first_preset_drop");?>',
          data : {'first_preset_drop':first_preset_drop,'uusersid':uusersid},
          headers: {'X-Requested-With': 'XMLHttpRequest'},
          success : function(msg)
          {
            if(msg)
            {
              
            }
          }
      });
  

  });

  </script>
    <script>
    wow = new WOW(
      {
        animateClass: 'animated',
        offset:       100,
        callback:     function(box) {
          console.log("WOW: animating <" + box.tagName.toLowerCase() + ">")
        }
      }
    );
    wow.init();
    document.getElementById('moar').onclick = function() {
      var section = document.createElement('section');
      section.className = 'section--purple wow fadeInDown';
      this.parentNode.insertBefore(section, this);
    };
  </script>
</html>

