<section id="profile" class="content_wrapper innerPage">
    <div class="container clearfix">
    <?php if($this->session->userdata('pay_book_first')){ ?>
      <div class="error-alert"> <?php echo getLang('Please_pay_the_open_invoices_first'); ?>.</div>
    <?php $this->session->unset_userdata('pay_book_first'); } ?>  
      <!--<div class="tab">
        <button class="tablinks active" data-id="bookings">Bookings</button>
        <button class="tablinks" data-id="orders">Membership Order</button>
        
      </div>-->
         <div class="invoice-row">
          <div class="orders tab-div" >
           <h1><?php echo getLang('Membership_Orders'); ?></h1>
           <input type="hidden" id="baseUrl" value="<?php echo base_url();?>">
           <table style="width:100%">
            <?php if(!empty($orders)) {
                   foreach ($orders as $order) { ?>
                    
             <tr>
               <td><?php echo $order['order_id_masked']; ?></td>
               <td><span class="name"><?php echo ucfirst($order['alias']); ?></span> </td>
               <td><strong>EUR <?php echo number_format($order['total_sum']/100, 2,',', '.'); ?></strong><br/> <?php echo getLang('ordered'); ?> 
			   <?php if($order['upgrade_date']>0){ $cdate = $order['upgrade_date'];}else{$cdate = $order['created'];} ?>
			   <?php echo date('d.m.Y',$cdate); ?>
			   
			   <br/><?php if($order['trn_id']!=''){ echo 'Code: '.$order['trn_id']; }?></td>
               <td><a href="javascript:void(0)" class="order-details modal_popup orderDetails" data-type="1" data-id="order-details" data-cart="<?php echo $order['cart_id']; ?>" data-order="<?php echo $order['order_id_masked']; ?>"><?php echo getLang('Order_details'); ?></a></td>
               <td>
               <?php if($order['payed']==1 ){ ?>
                     <span class="badgeOrange grey"><?php echo getLang('Paid'); ?><i class="fa fa-check" aria-hidden="true"></i></sp                
               <?php } else { ?>
                      <span class="badgeOrange"><?php echo getLang('Unfinished_payment'); ?></span>
               <?php } ?>    
               </td>
               <!--<td>
                   <a href="javascript:void(0);" class="print" data-id="<?php echo $value['cart_id']; ?>"><i class="fa fa-print"></i></a>
               </td>-->
                
             </tr>
             <?php } } else { echo '<div class="invoiceNotFound">'.getLang('No_record_found').'</div>'; } ?> 
            </table>
            </div> 
            <div class="bookings tab-div" >
              <h1><?php echo getLang('Booking_Invoice'); ?></h1>
             <table style="width:100%">  
             <?php if(!empty($invoices)) {
                   foreach ($invoices as $value) { ?>
             <tr>
               <td><?php echo $value['order_id_masked']; ?></td>
               <td><span class="name"><?php echo $value['title']; ?></span> <?php echo eventDetails($value['evt_id']); ?></td>
               <td><strong>EUR <?php echo number_format($value['total_sum']/100, 2,',', '.'); ?></strong><br/> <?php echo getLang('ordered'); ?> <?php echo date('d.m.Y',$value['created']); ?><br/><?php if($value['trn_id']!=''){ echo 'Code: '.$value['trn_id']; }?></td>
               <td><a href="javascript:void(0)" class="order-details modal_popup orderDetails" data-type="2" data-id="order-details" data-cart="<?php echo $value['cart_id']; ?>" data-order="<?php echo $value['order_id_masked']; ?>"><?php echo getLang('Order_details'); ?></a></td>
               <td>
               <?php if($value['payed']==1 ){ 
                       if($value['checkin_payed'] == 1){ ?>
                            <span class="badgeOrange grey"><?php echo getLang('Paid'); ?><i class="fa fa-check" aria-hidden="true"></i>, check-in<i class="fa fa-check" aria-hidden="true"></i></span>
                      <?php } else { ?>
                            <span class="badgeOrange grey"><?php echo getLang('Paid'); ?><i class="fa fa-check" aria-hidden="true"></i></span>   
                      <?php } ?>            
               <?php } else { ?>
                      <span class="badgeOrange"><?php echo getLang('Unfinished_payment'); ?></span>
               <?php } ?>    
               </td>
               <!--<td>
                   <a href="javascript:void(0);" class="print" data-id="<?php echo $value['cart_id']; ?>"><i class="fa fa-print"></i></a>
               </td>-->
                <td><?php if($value['payed']==1 && $value['time_from']>=time()){ 
                       if($value['checkin_payed'] == 1){ ?>
                            <a href="javascript:void(0)" class="pay-bttn modal_popup partyDetails" data-id="print-details" data-cart="<?php echo $value['cart_id']; ?>"><?php echo getLang('Partydetails'); ?></a>
                      <?php } else { ?>
                        <?php 
                        $postponed = 0;
                        $url = base_url().'checkin/'.$value['alias'].'/'.base64_encode($value['cart_id']);
                        $btn = getLang('Check_in');
                        if(isset($value['is_postponed'])){ 
                           if($value['is_postponed'] == 1){
                              $postponed = 1;
                              $url = 'javascript:void(0)';
                              $btn = getLang('postponed');
                           }
                        }
                        ?>
                           <a href="<?php echo $url; ?>" class="pay-bttn"><?php echo $btn; ?></a>
                      <?php } ?>            
               <?php } elseif($value['time_from']>=time()) { ?>
                      <a href="javascript:void(0)" class="pay-bttn modal_popup payInvoice" id="payInvoice_<?php echo $value['cart_id']; ?>" data-id="pay-now" data-price="<?php echo $value['total_sum']/100; ?>" data-amount = "<?php echo number_format($value['total_sum']/100,2,',','.');?>" data-cart="<?php echo $value['cart_id']; ?>"><?php echo getLang('pay_Now'); ?></a>
               <?php } ?>  
               </td>
             </tr>
             <?php } } ?> 

             <?php if(!empty($old_invoices)) {
                   foreach ($old_invoices as $value) { ?>
             <tr>
               <td><?php echo $value['order_id_masked']; ?></td>
               <td><span class="name"><?php echo $value['title']; ?></span> <?php echo eventDetails($value['evt_id']); ?></td>
               <td><strong>EUR <?php echo number_format($value['total_sum']/100, 2,',', '.'); ?></strong><br/> booked <?php echo date('d.m.Y',$value['created']); ?><br/><?php if($value['trn_id']!=''){ echo 'Code: '.$value['trn_id']; }?></td>
               <td></td>
               <td>
               <?php if($value['payed']==1 ){ 
                       if($value['checkin_payed'] == 1){ ?>
                            <span class="badgeOrange grey"><?php echo getLang('Paid'); ?><i class="fa fa-check" aria-hidden="true"></i>, check-in<i class="fa fa-check" aria-hidden="true"></i></span>
                      <?php } else { ?>
                            <span class="badgeOrange grey"><?php echo getLang('Paid'); ?><i class="fa fa-check" aria-hidden="true"></i></span>   
                      <?php } ?>            
               <?php } else { ?>
                      <span class="badgeOrange"><?php echo getLang('Unfinished_payment'); ?></span>
               <?php } ?>    
               </td>
               <!--<td>
                   <a href="javascript:void(0);" class="print" data-id="<?php echo $value['cart_id']; ?>"><i class="fa fa-print"></i></a>
               </td>-->
                <td>
               </td>
             </tr>
             <?php } } ?> 
             <?php if(empty($invoices) && empty($old_invoices)){ echo '<div class="invoiceNotFound">'.getLang('No_record_found').'</div>'; }?>
             
           </table>
           </div>
         </div>
    </div>
</section>
            
<section class="all_popups">
         <div class="modal_container register" id="order-details_modal" >
            <span class="modal_close"><i class="fa  fa-times-circle-o"></i></span>
            <form action="" >
               <div id="" class="">
                <input type="hidden" id="cart_number">
                <input type="hidden" id="print_type">
                  <h2><span id="order_number"></span><span id="printSpace"><a href="javascript:void(0);" class="print" data-id=""><i class="fa fa-print"></i></a></span></h2>
                  <div class="center showOrder">
                     
                  </div>
               </div>
            </form>
         </div>

         <div class="modal_container register" id="print-details_modal" >
            <span class="modal_close"><i class="fa  fa-times-circle-o"></i></span>
            
               <div id="" class="">
               <h2><span id="order_number"></span><span id="printSpace"><a href="javascript:void(0);" class="prints" data-id=""><i class="fa fa-print"></i></a></span></h2>
                  <div class="center showPrint">
                     
                  </div>
               </div>
            
         </div>

         <div class="modal_container register" id="pay-now_modal" >
            <span class="modal_close"><i class="fa  fa-times-circle-o"></i></span>
            <form action="" id="booking-form" method="POST" autocomplete="on" class="inv-book-form">
               <div id="" class=""><span class="show_total"></span>
                  <h2><?php echo getLang('Payment_Form'); ?></h2>
                  <div class="center">
                     <div class="center">
                     <span class="booking-errors" style="color:red;"></span>
                          <span class="payment_details"></span>
                          <span class="payimg"> <img src="images/paymen_icon.png" alt=""></span>
                          <p class="ssl_text"><img src="<?php echo  base_url().'assets/images/ssl-icon.png'; ?>">
                           <?php echo getLang('To_guarantee_for_maximum_safety__your_data_will_be_SSL_encrypted_and_processed'); ?>.
                          </p>
                          <span id="terms-error" style="color:red"></span>  
                          <p id="terms"><label><input type="checkbox" name="terms"> <?php echo getLang('I_have_read__understood_and_agree_the'); ?> <a href="<?php echo base_url().'terms'; ?>" target="_blank"><?php echo getLang('terms_and_conditions'); ?>.</a></label></p>
                           <div class="form_group">
                     
                             <label><?php echo getLang('Card_Holder'); ?></label>
                             <input type="text" size="20" name="card_holder" id="card_holder" placeholder="<?php echo getLang('Enter_Holder_name'); ?>">
                           
                         </div>

                         <div class="form_group">
                           
                             <label><?php echo getLang('Card_Number'); ?></label>
                             <input type="text" size="20" name="card_number" id="card_number" placeholder="<?php echo getLang('Enter_Card_Number'); ?>">
                           
                         </div>
                        
                         <div class="form_group doubleinput clearfix expiry_cvc">
                           
                              <label><?php echo getLang('Expiration'); ?> (MM/YY)</label>
                              <select name="exp_month" id="exp_month">
                                    <option value=""><?php echo getLang('Month'); ?></option>
                                    <option value="1">Jan</option>
                                    <option value="2">Feb</option>
                                    <option value="3">Mar</option>
                                    <option value="4">Apr</option>
                                    <option value="5">May</option>
                                    <option value="6">Jun</option>
                                    <option value="7">Jul</option>
                                    <option value="8">Aug</option>
                                    <option value="9">Sep</option>
                                    <option value="10">Oct</option>
                                    <option value="11">Nov</option>
                                    <option value="12">Dec</option>
                              </select>
                              <select name="exp_year" id="exp_year">
                                 <option value=""><?php echo getLang('Year'); ?></option>
                                    <?php for($i=date('Y');$i<date('Y')+50;$i++){ ?>
                                       <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                    <?php } ?>  
                             </select>
                              <div class="cvc">
                                <label><?php echo getLang('CVC'); ?></label>
                                <input type="text" size="4" name="card_cvc" id="card_cvc" placeholder="<?php echo getLang('Enter_CVC'); ?>">
                              </div>
                           </div>
                           <input type="hidden" id="cart_total" value="">
                           <input type="hidden" id="cart_id" value="">
                         <!--<div class="form_group cvc">
                             <label>CVC</label>
                             <input type="text" size="4" data-stripe="cvc" placeholder="Enter CVC">
                         </div>-->
                        <div class="text_center margin_top30">
                        <button type="submit" class="btn_gold" id=""><?php echo getLang('Pay'); ?></button>
                     </div>
                  </div>
                  </div>
               </div>
            </form>
         </div>
      <div class="modalmask"></div>
</section>  
<div class="printData" style="display:none"></div>          
<div class="showParty" style="display:none"></div>          

<style type="text/css">
  span#order_number {
      float: left;
      border: none;
  }
  span#printSpace {
      border: none;
  }
  @media print
{
    * {-webkit-print-color-adjust:exact;}
}
</style>