<!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');
 ?>
 <link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>styles/css/countdown.css" />
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<link rel="stylesheet" href="<?php echo base_url();?>styles/fonts/Socialico/stylesheet.css">
<link href="<?php echo base_url();?>styles/css/table.css" type="text/css" rel="stylesheet" />
	<script src="<?php echo base_url();?>styles/js/modernizr.js"></script>
  <style>
    .accordion_top_button_area button[type=submit]{
      font-size: 14px;
      color: #fff;
      text-transform: uppercase;
      font-family: 'Poppins', sans-serif;
      font-weight: 700;
      line-height: 50px;
      display: block;
      text-align: center;
    }
    .datatable select {
      background-size: 35% auto;
    }

    #demo1 a{
  padding: 20px;
  font-weight: 600;
  color: #fff;
    }
   
  </style>
          <style>
        .project_area figure {
            display: inherit !important; float:left
        }
        .modal-open
        {
          overflow-y:auto !important;
        }
        
        .modal-dialog {
            width: 500px;
            margin-top:120px !important;
        }
        .modal-content {
            background: rgba(34, 49, 63, 0.9) url("../img/choose_us_area_bg.png") no-repeat scroll 0 0 / cover ;
            border: 1px solid #22313f;
            border-radius: 0px 0;
            box-shadow: 5px 0 14px 1px rgba(0, 0, 0, 0.63) inset;
        }
        .modal-body {
            color: #f5ab35;
            padding: 25px;

        }
        .modal-header {
            color: #fff;
            padding: 15px 25px;

        }
        .modal-footer{
            padding: 15px 25px;

        }
        .dynamic {
            color: #fff;
            font-weight: bold;
        }
        .close span {
            color: #fff;
        }
        input[type="text"] {
            background: rgba(255, 255, 255, 0.9) none repeat scroll 0 0;
            border: 0 none;
            color: #22313f;
            font-weight: 600;
            padding: 5px 10px;
        }

        .dmain1 table tr th
        {
          padding:10px 6px;
          font-size:13px;
        }
        .btn
{
  background:#F5AB35;
}
        
        </style>
</head>
<body>

  <div id="preloader">
    <div class="preloader_spinner"> </div>
  </div>
  <section class="body_wrapper home_one">
    <?php
        $this->load->view('user/header');
        $this->load->view('user/login_header');
    ?>
 
 
  <section class="dmain">
  	<div class="container">
    
    </div>
    </section>
    <section class="dmain1">
  	<div class="container">
    <div class="row">

    
    <?php if($this->session->flashdata('success_message')) 
    { 
      ?>
                             <div class="row">
                             <div class="col-lg-12 ">     
                             <p class="frgtpwd frgtpwd1"><i class="fa fa-thumbs-up"></i><?php echo $this->session->flashdata('success_message');?></p></div></div>
                              <?php 
                            } 
                              else if ($this->session->flashdata('error_message')) { 
                                ?>
                                <div class="row"><div class="col-lg-12">  <p class="frgtpwd frgtpwd1 frgtpwdred"><i class="fa fa-thumbs-down"></i><?php echo $this->session->flashdata('error_message');?></p></div></div>
                              <?php } else {echo ""; }?>
        <!--<section class="dmain">
        <div class="container">
          <div class="row">
           
              <div class="gry clearfix wgrp" style="border-radius:0px;">
               <div class="col-xs-12">
                    
                        <h2 style="margin-left:80px;">  <?php echo $this->lang->line('icolendingstart');?></h2>
                         <input type="hidden" name="date" id="date1" value="<?php echo $date2;?>">
                        <div align="center" class="countdown" id="demo1"></div>
                </div>
              </div>
            </div>
            </div>
           </section>   --> 
            
            <section class="dmain1">
    <div class="container">
    <div class="row">
         <div class="col-lg-4">
         </div>
         <div class="col-lg-4">


                <div style="border: medium none;border-radius: 0px;padding: 5px;" class="gry clearfix wgrp" >
                <div class="nren">
                 
                  <div class="col-xs-12">
                    <h2 id="icocald" style="font-size: 21px;padding-bottom: 5px;color:green;">
                          <i class="fa fa-clock-o">  <?php echo $this->lang->line('icolendingstart');?></i></h2>
                                <input type="hidden" name="date" id="date1" value="<?php echo $date2;?>">
                                 <div style="margin-left: 0px;margin-bottom: 25px;text-align:center;" class="countdown" id="demo1"></div>
                                  <input type="hidden" name="date" value="<?php echo $date2; ?>" id="date1">
                  </div>
                </div>
              </div>
          
        </div>
        </div>
        </div>
        </section>     
      <div class="col-lg-12">
           <!-- <h2 class="section_hedings1">Lending <span>Details</span></h2> -->

            <div class="datatable" id="datatable">
              <?php 
              $currency_info = defaultcurrency();

              $queryz=$this->db->query("select * from icoset where icoid='1' ");
              $rest1=$queryz->result();
              $en=$rest1[0]->enddate;
              $nowx=date("Y-m-d H:i:s");
              $data_disp=0;
              if(strtotime($nowx)>strtotime($en))
              {
                $data_disp="1";
              }

            

              ?>

                      <table id="example">
                      <colgroup>
                      <col width="10%" style="display:none;">
                      <col width="30%">
                      <col width="30%">
                      <col width="20%">
                      <?php
                      if($data_disp=='1')
                      {
                      ?>
                          <col width="20%">
                        <?php
                      }
                      ?>
                      </colgroup>
                      <thead>
                        <tr>
                        <th style="display:none;" >sno</th>
                        <th><?php echo $this->lang->line('lbl_lending_amnt'); ?> </th>
                        <th><?php echo $this->lang->line('lbl_calc_profit'); ?></th>
                        <th><?php echo $this->lang->line('lbl_capitalback'); ?></th>
                        <?php
                      if($data_disp=='1')
                      {
                      ?>

                        <th><?php echo $this->lang->line('label_cur_status'); ?></th>
                        <?php
                      }
                      ?>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 


                        $sno=0;
                          if($lendingdetails) 
                          {
                            foreach ($lendingdetails as $lending) 
                            {
                            $sno++; 
                            ?>
                          <td style="display:none;"><?php echo $sno;?></td>
                        <td><?php echo $lending->minimum_amount;?>$ - <?php echo $lending->maximum_amount;?>$</td>
                        <td><strong>Balance System</strong> +<font style="color:#F5AB35;"><?php echo number_format($lending->profit, 2, '.', '');?>%</td>
                        <td>In <?php echo $lending->duration.' '.strtoupper("days");?></td>
                        <?php
                        if($data_disp=='1')
                        {
                        ?>
                          <td><a href="<?php echo base_url().'user/lending/buy/'.$lending->lendingid;?>">Invest</a></td>
                        <?php 
                        }
                        ?>
                        </tr>

                          <?php

                        }

                        }?>

                        </tbody>
                    </table>
                    </div>
            </div>
    
     </div>
            </div>
            </div>
    </div>

 </section>
                
  <section class="dmain">
  </section>

  <?php
if(isset($this->data['id']))
{
  $id=$this->data['id'];
  $qry=$this->db->query("select * from lending where lendingid='$id'");
  $rest=$qry->result();

  $user=$this->session->userdata('uusersid');

  $find_pur=$this->db->query("select sum(amount) as amount from tokens where uuserid='$user' and type!='sell'");
  $rest1=$find_pur->result();
  $bal=$rest1[0]->amount;


  $find_pur2=$this->db->query("select sum(amount) as amount from tokens where uuserid='$user' and type='sell'");
  $rest2=$find_pur2->result();
  $bal2=$rest2[0]->amount;

  $find_pur1=$this->db->query("select sum(amount) as amount from deposit where uusersid='$user' and description='lending request'");
  $rest2=$find_pur1->result();
  $bal1=$rest2[0]->amount;

 $bal=$bal-($bal1+$bal2);
  if($bal< 0)
    $bal=0;

?>
 <div class="modal fade" id="tokenModal" tabindex="-1" role="dialog" aria-labelledby="tokenModalLabel" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title" id="tokenModalLabel" style="padding: 0px 20px;"><?php echo $this->lang->line('buylending');?></h4>
    </div>
    <div class="modal-body">

        <form method="post" name="lending" action="<?php echo $action;?>" method="post">
      <div id="tok-resp"></div>

          <div class="form-group row">
          <label for="from-date" class="form-control-label col-md-6"><!--<?php echo $this->lang->line('youhaveicotokenlbl');?>-->
            <?php
            $tokenname=tokenname('1');
            ?>
            Your <?php echo $tokenname;?> Balance  IN (<?php echo strtoupper($currency_info->currency_unit);?>)

          </label>
          <label class="col-md-6"><?php echo $currency_info->currency_symbol;?> <?php echo number_format($bal,$currency_info->deimal_point);?> </label>
          <label style="display:none;" id="avabal"><?php echo $bal; ?></label>
          <input type="hidden" id="bal" name="bal" value="<?php echo $bal;?>">
          <input type="hidden" id="min" name="min" value="<?php echo $rest[0]->minimum_amount;?>">
          <input type="hidden" id="max" name="max" value="<?php echo $rest[0]->maximum_amount;?>">
          <input type="hidden" id="days" name="days" value="<?php echo $rest[0]->duration;?>">
      </div>
      <div class="form-group row">
          <label for="to-date" class="form-control-label col-md-6"><?php echo $this->lang->line('lbl_lending_amnt'); ?> </label>
          <label class="col-md-6" id="price"><?php echo $currency_info->currency_symbol.''.$rest[0]->minimum_amount." - ".$currency_info->currency_symbol.' '.$rest[0]->maximum_amount; ?></label>
          
      </div>
      <div class="form-group row">
          <label for="days" class="form-control-label col-md-6"><?php echo $this->lang->line('lbl_calc_profit'); ?> :</label>
          <label class="dynamic col-md-6" id="maxpurchase"><?php echo $rest[0]->profit; ?> %</label>
      </div>
      
      <div class="form-group row">
          <label for="date" class="form-control-label col-md-6"><?php echo $this->lang->line('buyamount');?> :</label>
          <input type="text" name="amount" class="col-md-5" id="amount"  value="">
          <br><Br>
          <div style='color:red;text-align:center;' id="amt_err"></div>
          
      </div>
      
      <input type="hidden" name="icocalid" class="col-md-6" id="icocalid" value="<?php echo $id; ?>">
     
     <div id="cal-resp"></div>
    </form>
    </div>
    <div class="modal-footer">
      <div align="center">
      <div class="accordion_button_wrapper">
        <div class="accordion_top_button_area">
          <a id="btn" class="accrodion_top_btn tokenbutton" onClick="BuyFunc()">Invest</a>
        </div>
      </div>
      </div>
    </div>
     </div>
                </div>
            </div>
  
     <?php
   }
     ?>       
  
            <?php
                $this->load->view('user/footer');
            ?>
  </section>
        
                   

<script src="<?php echo base_url();?>styles/js/jquery-1.12.2.min.js"></script>

<script src="<?php echo base_url();?>styles/js/jquery.meanmenu.js"></script>
<script src="<?php echo base_url();?>styles/js/owl.carousel.min.js"></script>
<script src="<?php echo base_url();?>styles/js/waypoints.min.js"></script>
<script src="<?php echo base_url();?>styles/js/jquery.counterup.min.js"></script>
<script src="<?php echo base_url();?>styles/js/jquery.mixitup.min.js"></script>
<script src="<?php echo base_url();?>styles/js/waypoints.min.js"></script>
<script src="<?php echo base_url();?>styles/js/instafeed.min.js"></script>
<script src="<?php echo base_url();?>styles/js/bootstrap.min.js"></script>



<script src="<?php echo base_url();?>styles/js/main.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>styles/js/owl.carousel.min.js"></script>
<script type="text/javascript">



	$(document).ready(function($) {


    $('#example').DataTable({
     "order": [ 0, "asc"],
      "searching": false,
     
   });


	$("#owl-example").owlCarousel({   
	 nav:true,
	 
	 items : 8, 
    itemsCustom : false,
    itemsDesktop : [1199,8],
    itemsDesktopSmall : [980,5],
    itemsTablet: [768,5],
    itemsTabletSmall: [768,4],
    itemsMobile : [479,2],
    singleItem : false,
    itemsScaleUp : true,
	
	    navigation : true,
    navigationText : ["",""],
    rewindNav : true,
    scrollPerPage : true,
	});
	})



function BuyFunc()
{

  var bal=document.getElementById("bal").value;
  var amt=document.getElementById("amount").value;
  var min_amt=document.getElementById("min").value;
  var max_amt=document.getElementById("max").value;
  if(amt=='')
  {
    document.getElementById("amt_err").innerHTML="Please Enter Amount";
  }
  if(amt!='')
  {
    var mq =/^[0-9.]+$/;
    if(!mq.test(amt))
    {
       document.getElementById("amt_err").innerHTML="Invalid Amout Format";
    }
    else
    {
      if(parseFloat(amt)>parseFloat(bal))
      {
        document.getElementById("amt_err").innerHTML="Insufficent Balance";   
      }
      else
      {
        if(parseFloat(min_amt)>parseFloat(amt) || parseFloat(amt)>parseFloat(max_amt))
        {
          document.getElementById("amt_err").innerHTML="Pls Enter Amount Between Selected lending";
        }
        else
        {
            lending.submit();
        }

      }
    }
  }


  
}

   
 
	
	</script>
    
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.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();?>styles/js/application.js"></script>

<script src="<?php echo base_url();?>styles/js/jquery.min.js"></script>

<?php
if(isset($this->data['id']))
{
  ?>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {

        $('#tokenModal').modal('show');
});
  </script>
  <?php

  
}
?>

<script type="text/javascript">



$(document).ready(function() {


// Set the date we're counting down to
var date1=document.getElementById("date1").value;
//var countDownDate = new Date("Dec 08, 2017 15:37:25").getTime();
var countDownDate1 = new Date(date1).getTime();



var x = setInterval(function() {

    // Get todays date and time
    var now = new Date().getTime();
    
    // Find the distance between now an the count down date
    var distance = countDownDate1 - now;
    
    // Time calculations for days, hours, minutes and seconds
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    if(days < 10)
        days="0"+days;

    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
     if(hours < 10)
        hours="0"+hours;

   
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    if(minutes < 10)
        minutes="0"+minutes;

    var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    if(seconds < 10)
        seconds="0"+seconds;
    
    // Output the result in an element with id="demo"
    /*document.getElementById("demo").innerHTML = days + "Days " + hours + "Hours"
    + minutes + "min" + seconds + "sec";*/

       var html="";

        
            html+="<div class='countdown-container days'>"
                html+="<span class='countdown-heading days-top'>Days</span>";
                html+="<span class='countdown-value days-bottom'>"+days+"</span>";
            html+="</div>";
        

        html+="<div class='countdown-container hours'>"
            html+="<span class='countdown-heading hours-top'>Hours</span>";
            html+="<span class='countdown-value hours-bottom'>"+hours+"</span>";
        html+="</div>";

        html+="<div class='countdown-container minutes'>"
            html+="<span class='countdown-heading minutes-top'>Minutes</span>";
            html+="<span class='countdown-value minutes-bottom'>"+minutes+"</span>";
        html+="</div>";

        html+="<div class='countdown-container seconds'>"
            html+="<span class='countdown-heading seconds-top'>Seconds</span>";
            html+="<span class='countdown-value seconds-bottom'>"+seconds+"</span>";
        html+="</div>";
    // alert(html);
    document.getElementById("demo1").innerHTML=html;
    console.log(document.getElementById("demo1").innerHTML);
    // If the count down is over, write some text 

    if (distance < 0) {
          clearInterval(x);
        document.getElementById("demo1").innerHTML = "Let's Start Lending";

        
    }
}, 1000);



$('.datatable table').dataTable(
{
        "paginate": false,
        "filter": false,
        "Info": false
                 } );

 
} );



</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>
 
</body>
</html>