<!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
  $this->load->view('user/common_style');
  ?>



<style type="text/css">
.dataTables_filter > label
{
  display: block;
  color: rgb(239, 239, 239);
  background: rgb(239, 239, 239);
}

.dataTables_filter label > input[type=search]::after {
    font-family: 'FontAwesome';
    /*color:red;*/
    position: relative;
    left: -5px;
    content: "\f007";
}

</style>      
<link rel="stylesheet" href="<?php echo base_url();?>styles/css/table.css">
<style>
  .contact_one .contact_left_content form input[type="text"]{border:0px;}

  .prfledit select {
    margin: 0;
  }
  .help-block {
    color: #eb5055;
    margin: 0em 0em 0em !important;
  }
  ul.prfledit  li {
  color: #444;
  display: inline-block;
  font-family: "Open Sans",sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  margin-bottom: 10px;
  padding: 10px 0;
  width: 100%;
  }
  .prfledit textarea {
  border: 1px solid #ededed;
  height: 200px;
  padding: 10px 20px;
  width: 100%;
  }
      
.main-table tbody tr td {
    padding: 26px 18px;
}
.btn-green {
    background-color: rgb(120, 162, 64);
    border-color: rgb(120, 162, 64);
    color: rgb(255, 255, 255);
}
.control-label 
{
color: rgb(5, 22, 73);
}
.btn-md {
    border-radius: 1px;
    font-size: 13px;
    padding: 0 30px;
}
.btn {
    border: 1px solid rgba(0, 0, 0, 0);
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 0;
    padding: 6px 12px;
    text-align: center;
    vertical-align: middle;
}
td{
  padding-right:5px;
}
h4 {
  color: rgb(245, 171, 53);
  font-size: 30px;
  font-weight: 700;
}

input[type="text"] {
  padding-top: 5px;
  padding-left: 1px;
}
.col-lg-8 {
   min-height: 1px;
    padding-left: 15px;
    padding-right: 15px;
    position: relative;
}

.modal-dialog {
    height: 561px;
}
.btn-modal-header {
    background-color: rgb(26, 140, 255);
    border-color: rgb(245, 171, 53);
    color: rgb(255, 255, 255);
}

.modal-footer
{
  text-align:center;
}
    </style>
  </head>

  <body>
    
      <?php
        $this->load->view('user/header');
        $this->load->view('user/login_header');
        $currency_info = defaultcurrency();
      ?>
      <div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
      <div class="table-list clearfix">
      <?php if($this->session->flashdata('success_message')) {?>
      <p class="frgtpwd frgtpwd1"><i class="fa fa-thumbs-up"></i><?php echo $this->session->flashdata('success_message');?></p>
      <?php } elseif ($this->session->flashdata('error_message')) { ?>
       <p class="frgtpwd frgtpwd1 frgtpwdred"><i class="fa fa-thumbs-down"></i><?php echo $this->session->flashdata('error_message');?></p>
      <?php } else { }?>

                        <?php 
                         $id=$this->uri->segment(4);
                        $this->load->library('MyEncrypt');
                        $myencrypt = new MyEncrypt;
                        foreach ($list as $row) 
                        {
                            $amount=$row->amount;
                            $co_id=$row->coin_id;
                            $condition = "coid = '".$co_id."'";  
                            $coin_info = $this->common_model->GetRow('coin_info',$condition);

                            $buy_bal=curbalance($this->session->userdata('uusersid'),$co_id);
                            $buy_bal1=str_replace(",","", $buy_bal);
                          ?> 
                                <form id="frm" class="steps-validation strategy" action="<?php echo base_url();?>user/trade/trade_history/<?php echo $id;?>" method="post">
                                    <div class="row">
                                        <div class="col-xs-12">
                                        <h4 class="other-title theme-color">Invest Copy-Trade</h4>
                                        <br>
                                        <div class="form-group">
                                          <label class="control-label col-sm-5 right">
                                          <?php echo $this->lang->line('lbl_available_balance');?></label>:&nbsp;
                                          <strong style="margin-top: 5px;border:none;" > &nbsp;<label id="balanceVal"> <?php echo $buy_bal; ?></label> <?php echo strtoupper($coin_info->coin_symbol);?></strong>
                                                            
                                        </div>
                                        <div class="form-group">
                                          <label  class="control-label col-sm-5 right"><?php echo $this->lang->line('lbl_account_name');?></label>
                                          <label  class="control-label col-sm-4 left">:&nbsp;
                                            <strong><?php echo ucfirst($row->ac_name); ?></strong>
                                          </label>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="form-group">
                                          <label  class="control-label col-sm-5 right"><?php echo $this->lang->line('lbl_trade_mode');?></label>
                                          <label  class="control-label col-sm-5 left">:&nbsp;
                                            <strong><?php echo $row->trade_mode;?></strong>
                                          </label>
                                        </div>
                                      <br>
                                        <br>
                                        <div class="form-group">
                                          <label  class="control-label col-sm-5 right"><?php echo $this->lang->line('lbl_currency');?></label>
                                          <label  class="control-label col-sm-4 left">:&nbsp;
                                            <strong><?php echo ucfirst($coin_info->coin_name); ?></strong>
                                          </label>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="form-group">
                                          <label  class="control-label col-sm-5 right"><?php echo $this->lang->line('lbl_minimum_amount');?></label>
                                          <label  class="control-label col-sm-4 left">:&nbsp;
                                            <strong><?php echo $row->min_deposit.' '.$coin_info->coin_symbol; ?></strong>
                                          </label>
                                        </div>
                                        <br>
                                        <br>
                                        <div class="form-group">
                                          <label  class="control-label col-sm-5 right"><?php echo $this->lang->line('lbl_maximum_amount');?></label>
                                          <label  class="control-label col-sm-5 left">:&nbsp;
                                            <strong><?php echo $row->max_deposit.' '.$coin_info->coin_symbol;?></strong>
                                          </label>
                                        </div>

                                      <br>
                                        <br>
                                          
                                          <input type="hidden" name="ac_name"  value="<?php echo $row->ac_name;?>">
                                          <input type="hidden" name="ac_name"  value="<?php echo $row->coin_id;?>">
                                         <input type="hidden" name="stratgy"  value="<?php echo $row->stratgy;?>">
                                         <input type="hidden" name="min_deposit" value="<?php echo $row->min_deposit;?>">
                                         <input type="hidden" name="max_deposit"  value="<?php echo $row->max_deposit;?>">
                                         <input type="hidden" name="profit"  value="<?php echo $row->profit;?>">
                                         <input type="hidden" name="duration"  value="<?php echo $row->duration;?>">
                                         <input type="hidden" name="admin_fee"  value="<?php echo $row->admin_fee;?>">

                                         <div class="form-group">
                                         <label  class="control-label col-sm-5 right">Amount</label>
                                         <label  class="control-label col-sm-4 left"><input  id="amount" required type="text" name="amount" value="">
                                         </label>
                                         <input type="hidden" name="id" id="str_id" value="<?php echo $row->id;?>">


                                         </div>
                                         <br>
                                         <br>
                              <div class="col-lg-12 form-group">
                                <center> 
                                <div class="">
                                  <div class="cmmn">
                                    <div class="contact_page_btn">                                      
                                    <button class="yellow-btn" id="submit"><?php echo $this->lang->line('contact_submit'); ?></button>
                                    <div id="ip-exist" style="display:none;color:#d84315;" class="error_msg"><?php echo $this->lang->line('fund_balance'); ?></div>
                                    </div>
                                    
                                  </div>
                                </div>
                                </center>
                              </div>
                              </div>
                              </div>

                              <div style="clear:both;"><Br></div>
                              <div class="cht" id="chart">
                              <div class="row">
                              <div class="col-xs-12">
                              <div  id="chartContainer" style="height: 470px; width: 100%;"></div>

                              </div>
                              </div>
                              </div>

                          </form>
                  <?php } ?>

                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        </div>
        </div> 

<?php

$jan_amount= '0';
$feb_amount= '0';
$mar_amount= '0';
$apr_amount= '0';
$may_amount= '0';
$jun_amount= '0';
$jul_amount= '0';
$aug_amount= '0';
$sep_amount= '0';
$oct_amount= '0';
$nov_amount= '0';
$dec_amount= '0';
//$dataPoints=array();
$query1=$this->db->query("SELECT sum(`amount`) as amount,invest_date  FROM `trade_history` WHERE strategy_name = '".$row->stratgy."' and trade_id = '".$row->id."' and status != '0'  GROUP BY MONTH(`invest_date`)");
$query=$query1->result();
foreach ($query as $key) 
{
  if(date('M',strtotime($key->invest_date)) == "Jan")
  {
      $jan_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Feb")
  {
      $feb_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Mar")
  {
    $mar_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Apr")
  {
    $apr_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "May")
  {
    $may_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Jun")
  {
      $jun_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Jul")
  {
      $jul_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Aug")
  {
    $aug_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Sep")
  {
    $sep_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Oct")
  {
    $oct_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Nov")
  {
      $nov_amount += $key->amount;
  }
  if(date('M',strtotime($key->invest_date)) == "Dec")
  {
    $dec_amount += $key->amount;
  } 
          $dataPoints = array(array("label" => "Jan" ,"y" => number_format($jan_amount,2)),
              array("label" => "Feb" ,"y" => number_format($feb_amount,2)),
              array("label" => "Mar" ,"y" => number_format($mar_amount,2)),
              array("label" => "Apr" ,"y" => number_format($apr_amount,2)),
              array("label" => "May" ,"y" => number_format($may_amount,2)),
              array("label" => "Jun" ,"y" => number_format($jun_amount,2)),
              array("label" => "Jul" ,"y" => number_format($jul_amount,2)),
              array("label" => "Aug" ,"y" => number_format($aug_amount,2)),
              array("label" => "Sep" ,"y" => number_format($sep_amount,2)),
              array("label" => "Oct" ,"y" => number_format($oct_amount,2)),
              array("label" => "Nov" ,"y" => number_format($nov_amount,2)),
              array("label" => "Dec" ,"y" => number_format($dec_amount),2)
              );    
 }
?>
                   
<?php
$this->load->view('user/footer');
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>  
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>styles/js/jquery-1.12.2.min.js"></script>   
<script src="<?php echo base_url();?>styles/js/bootstrap.min.js"></script>    
<script type="text/javascript" src="<?php echo base_url();?>assets/js/formValidation.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/bootstrap.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>styles/js/datatables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/validation/validate.min.js"></script>
<script src="http://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script src="http://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script type="text/javascript"></script>
<script>
$(document).ready(function() {
$('#submit').click(function(){  
  var id = $('#str_id').val();
  var amount = $('#amount').val();
  var balance = $('#balanceVal').val();
  if(amount != '')
  {
   $.ajax({  

    url:'<?php echo base_url();?>user/trade/trade_history/'+id,  
    method:"POST",  
    data:{'amount':amount},  
    success:function(data){  

     $('#frm')[0].reset();     
  
    if(amount != '' && amount != balance)
    {
       location.reload(); 
    }    

    }
  }); 
 }  
  
 });




window.onload = function () {
 
var chart = new CanvasJS.Chart("chartContainer", {
  animationEnabled: true,
  theme: "light2",
  title:{
    text: "Strategy Chart"
  },

   xAxis: [{
       type: 'String',
          }],
   yAxis: [{
         type: 'Number',
        includeZero: true,
        prefix: '<?php echo $coin_info->coin_symbol;?>'

       }],

  data: [{
    type: "area",
    showInLegend: "true",
    xValueType: "dateTime",
    xValueFormatString: "MMM YYYY",
    yValueFormatString: "<?php echo $coin_info->coin_symbol;?> #.#00",
    dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
  }]
});
 
chart.render();
 
}

// $.noConflict();

//       $('.strategy').formValidation({

//                             framework: 'bootstrap',
//                             //excluded: [':disabled'],
//                             icon: {
                                
//                                 validating: 'glyphicon glyphicon-refr esh'
//                             },
//                             fields: {
//                                 amount: {
//                                   validators: {
//                                     notEmpty: {
//                                         message: '<?php echo "Invest Amount Required";?>'
//                                     },
//                                     regexp: {
//                                         regexp: /^[0-9.]+$/,
//                                         message: '<?php echo "please Check Format";?>'
//                                     }                                   
//                                     remote: {
//                                         url: function(validator, value) {

//                                             return '<?php echo base_url();?>user/trade/validamount/'+$('#str_id').val();

//                                         },
//                                         type: 'POST',
//                                         dataType:"json",
//                                         delay: 1000,

//                                         dataFilter: function(json) {
//                                         var json = JSON.parse(json);
//                                         if(json['valid']) {
//                                             return true;
//                                         } else {
//                                             return false;
                                            
//                                         }
//                                         if(json['valid'] = false)
//                                         {
//                                            $('#submit').removeAttr('disabled');
//                                         }
//                                       }

//                                     }
//                                   }
//                                 }
                                
//                               //}
//                         });
//       });

  </script>

</body>
</html>

