<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$odenecek_tutar=$detay['general']["remaining_payment"];

$site=genel::site_bilgi();
//print_r($detay);
?>
	<!DOCTYPE html>
	<html lang="pt">
	<head>
<?php $this->load->view('includes/header',isset($data) ? $data : NULL);?>		

	</head>
	<body>
<?php $this->load->view('includes/top',isset($data) ? $data : NULL);?>	

<div class="xs-spacer30 sm-spacer30">
</div>


<div class="article">
<div class="container">
<div class="sm-spacer120">
</div>
<style>
    
    @media screen and (max-width: 992px) {
  .mobilekisim {
    margin-top:35px;
  }
}

</style>
<div class="row">
<div class="col-md-8">



<div class="panel panel-success mobilekisim">
<div class="panel-heading" style="background-color: #e31d1a;color: #fff;font-weight: bold;">Rezervasyon Ödeme / Payment</div>
<div class="panel-body">
<?php 
$OdemeMiktari=$_POST['NewAmount'] ?? $detay["general"]['remaining_payment'];
?>
<form method="POST">
<div class="input-group">
<input type="search" class="form-control" name="NewAmount" value="<?=$OdemeMiktari?>">
<span class="input-group-btn">
<button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true">
</span> Ödeme Miktarını Güncelle</button>
</span>
</div>
</form>
<form class="" method="POST" action="/reservation/make_cc_payment?token=<?=$token?>" id="sanalpos_odeme_form" target="_blank">
<input class="form-control" type="hidden" name="token" value="<?=$token?>">  
<input class="form-control" type="hidden" name="kullanici_id" value="<?=$eccbilgi->user_id?>"> 
<input type="hidden" name="kur" value="TRY">
<input type="hidden" name="grup_id" value="<?=$grup_id?>">


<input name="amount" value="<?=$OdemeMiktari?>" required="" type="hidden" id="sanal_pos_amount" class="spinner-input form-control" AutoComplete="off" />







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




                                                                            
<div class="col-md-12">
 <div class="form-group">
<label for="cph_main_tb_odeme_card_number">
<b> Kart Numarası / Card Number</b>
<span class="require">*</span></label>
  <div class="input-group ">
<span class="input-group-addon"><i class="fa fa-credit-card"></i></span>    
<input name="number" type="text"  required="" id="card_number"  class=" form-control" AutoComplete="off" minlength="19" autofocus="" />


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

 <div class="col-md-6">
<div class="form-group">
<label for="cph_main_ddl_expiration_month">
<b>Son Kul. / Exp. Date</b>
<span class="require">*</span></label>
<div class="clearfix">
</div>
  <div class="input-group ">
<input name="expiry" type="text" id="skt"   maxlength="7" class="form-control skt" AutoComplete="off" required="" />
<span class="input-group-addon"><a id="cph_main_a_cvc2_tooltip" class="a_tooltip" data-toggle="tooltip" data-placement="bottom" title="Kartın Son Kullanma Tarihi"><i class="fa fa-question"></i></a></span>
</div>
<div class="clearfix">
</div>
</div>
</div>
 <div class="col-md-6">

<div class="form-group">
<label for="cph_main_tb_odeme_cvc2">
<b>     <?=Genel::dil_ceviri("booking_page_card_cvc2")?></b>
<span class="require">*</span></label>
<div class="input-group ">
<input name="cvc" type="text" maxlength="4" minlength="3" id="cvc2" required="" class="form-control" AutoComplete="off" />
<span class="input-group-addon"><a id="cph_main_a_cvc2_tooltip" class="a_tooltip" data-toggle="tooltip" data-placement="bottom" title="Kartınızın arkasındaki son 3 haneli rakam"><i class="fa fa-question"></i></a></span>
</div>
</div>
</div>

<div class="col-md-12">
<div class="form-group">
<label for="cph_main_tb_odeme_isim">
<b> Kart Sahibi / Name Last Name of card owner</b>
<span class="require">*</span></label>
<input name="name" required="" type="text" id="card_holdername" class="spinner-input form-control" AutoComplete="off" />
</div>
</div>
</div>  
</div>
<div class="col-md-6 col-lg-5 card-wrapper"></div>
</div>  

<?php
$this->load->model('api');

$RequestUrl="Reservations/PaymentServices/PaymentTypes";

$dataForPost=[
"token"=>$token,
"Amount"=>$OdemeMiktari,
"Currency"=>"TRY",
"issite"=>1
];
$Apikey=genel::get_apikey();

$PaymentTypes=api::curlPost($Apikey,$RequestUrl, "POST", $dataForPost);
$PaymentTypes=json_decode($PaymentTypes);

//print_r($PaymentTypes);

$PaymentOptions=$PaymentTypes->data->PaymentOprions;



foreach ($PaymentOptions as $OdemeSekilleri) {
?>
<div class="clearfix"></div>
<ul class="nav nav-tabs">
<?php 
$pos_turumm=1;
$sira=0;

    foreach ($OdemeSekilleri->Options AS $kartlar){
$sira=$sira+1;
  ?>  
<li <?php if($sira==1){?>class="active"<?php }?> onclick='$(".<?=$pos_turumm?>tam_odeme<?=$kartlar->posId?>1").prop("checked", true);'><a data-toggle="tab" href="#tam_odeme<?=$kartlar->posId?>" style="padding:5px 5px 5px 5px"><img style="width: 75px;" src="<?=$kartlar->logo?>"></a></li>
<?php  }?>




</ul>

<div class="tab-content">
<?php 
$sira=0;
foreach ($OdemeSekilleri->Options as $kartlar) {
$sira=$sira+1;
  ?>
  <div id="tam_odeme<?=$kartlar->posId?>" class="tab-pane fade <?php if($sira==1){?>in active<?php }?>">
   
   <table class="table table-condensed table-taksit">
    <tbody>
  <?php 
$taksit_sira=0;
foreach ($kartlar->installments as $taksitlerim) {
$taksit_sira=$taksit_sira+1;

if($taksitlerim->installment==1){
$taksit_adi="Tek Çekim" ;
}else{
$taksit_adi=$taksitlerim->installment." Taksit"  ; 
}
    $toplam_taksit_sayisi=$taksitlerim->installment+$taksitlerim->extra_installment;
  ?>
                        <!-- TODO: hangi taksit seçiliyse tr'nin class="info" olmalı -->
                            <!-- <tr class="info"> -->

<tr <?php if($taksit_sira==1){?>class="info"<?php }?>>
<td>
  <label> <input id="bankDiv<?=$kartlar->posId?>_<?=$taksitlerim->installment?>" name="taksit_id" class="installmentr <?=$pos_turumm?>tam_odeme<?=$kartlar->posId?><?=$taksit_sira?>" value="<?=$kartlar->GroupId?>_<?=$kartlar->posId?>_<?=$taksitlerim->installment?>_<?=$taksitlerim->extra_installment?>" type="radio" <?php if($sira==1 && $taksit_sira==1){?>checked <?php }?> > <?=$taksit_adi?></label></td>

<td><?php if($taksitlerim->extra_installment>0){?>+<?=$taksitlerim->extra_installment?> Taksit<?php }?></td>
                              <td>
                                <div class="ratedPrice" >
<span class="ratedPrice" ><?=$taksitlerim->Amount?></span> <span class="currency"><?=$taksitlerim->Currency?></span>
                                </div>
                              </td>
  
  
<td>
<?php if($taksitlerim->installment==1){?><img style="width: 75px;" src="<?=$kartlar->logo?>"> <span class="badge selectedCard">Seçildi</span>
<?php }else{?>
<small>  (<b> <?=$toplam_taksit_sayisi?> x <span class="ratedPrice2" rate="0.00" installment="2" extrainstallment="2" amount="3795.96" currency="TL"><?=$taksitlerim->MontlyPayment?></span> <span class="currency">TL</span>
                                    </b>)
                                    </small>
<?php }?>
                                  </td>
  
                            </tr>
<?php }?> 
                      


                          </tbody></table>

  </div>

<?php }?>



  

</div>

<?php }?>

<button type="submit" class="btn btn-primary btn-block">Ödeme Yap / Checkout</button>



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

</div>
<div class="col-md-4">
<?php require_once("includes/reservation_summary_last.php") ?>
</div>

</div>



<div class="sm-spacer60">
</div>
</div>
</div>













<div class="modal fade in" id="paymentModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" data-backdrop="static" data-keyboard="false" >


    <div class="modal-dialog" role="document">
        
<div class="modal-content">
            
<div class="modal-header">
                
<h4 class="modal-title" id="paymentModalLabel"><?=Genel::dil_ceviri("booking_page_reservation_payment")?></h4>
            </div>
            

<div class="modal-body" style="padding:0;">
                
<iframe name="paymentModalFrame" id="paymentModalFrame" style="width: 100%;height: 600px;border:0;"></iframe>


            </div>
 <div class="modal-footer">
     <button data-dismiss="modal" type="button" class="btn btn-warning hidden btnpaymentmodalclose">Kapat / Close</button>
 </div>
       </div>
  
  </div>

</div> 

	<?php $this->load->view('includes/footer',isset($data) ? $data : NULL);?>	


<script src="/assets/js/jquery.mask.js" type="text/javascript"></script>
<script src="/assets/plugins/cardjs/dist/card.js"></script>
<script>

	$( document ).ready(function() {

$( "#sanalpos_odeme_form" ).submit(function( event ) {

//$('#paymentModal').modal('show'); 
});

});


	        new Card({
            form: document.querySelector('#sanalpos_odeme_form'),
            container: '.card-wrapper'
        });
</script>
	</body>
	</html>