<script src="https://cdn.ckeditor.com/4.7.1/standard/ckeditor.js"></script>
        <section class="content-header">

      <h1>

        Orders 

      </h1>

      <ol class="breadcrumb">

        <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>

        <li><a href="<?php echo base_url('admin/order');?>">Orders</a></li>

        <li class="active"> View</li>

      </ol>

    </section>

    

    <section class="content">

      <div class="row">

      <?php echo $this->utility->showMsg();?>

        <div class="col-md-12">

        <div class="loader" style="display:none;"><img src='<?php echo base_url();?>assets/images/loading.gif' alt='loading' /></div>

          <!-- Horizontal Form -->

          <div class="box box-info">

            <div class="box-header with-border">

              <h3 class="box-title">View </h3>

            </div>

            <!-- /.box-header -->

            <!-- form start -->

            <form id="add_frm" name="add_frm" class="form-horizontal" method="post" action="" enctype="multipart/form-data">

              <div class="box-body">
                <div class="form-group">

                  <label class="col-sm-2 control-label">Description</label>

                  <div class="col-sm-4">
                  <?php $eventData = getValue('evt_events',array('id'=>$orderDetails[0]['event_id']));?>
                  <label><?php if(!empty($eventData)){ echo $eventData['title']; } elseif($orderDetails[0]['name']!=''){ echo ucfirst($orderDetails[0]['alias']).' Membership'; }?></label>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Order NO.</label>

                  <div class="col-sm-4">
                  <label><?php if(!empty($orderDetails)){ echo $orderDetails[0]['order_id_masked']; }?></label>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Username</label>

                  <div class="col-sm-4">
                  <label><a style="color: #b3975b;" href="<?php echo base_url().'admin/users/edit/'.base64_encode($orderDetails[0]['user_id']); ?>" >
                    <?php if(!empty($orderDetails)){ 
                            if(!empty($orderDetails[0]['username'])){ 
                              echo $orderDetails[0]['username'];
                            } else {
                              $unames = getUserDataByEmail($orderDetails[0]['invoiceAddress']);
                              if($unames) {
                                echo $unames;
                              }
                            }
                          }?>
                      
                    </a></label>
                  </div>

                </div>
                <?php $numberDetails = getValue('feu_userdetails',array('user_id'=>$orderDetails[0]['user_id']));
                  $userPhones = getValue('usr_phones',array('user_id'=>$orderDetails[0]['user_id']));
                  $number = '';
                  if($numberDetails['mobile_number'] != '')
                  {
                    if(strpos($numberDetails['mobile_number'],'+') === false)
                    {
                      $number = '+'.$numberDetails['mobile_number'];
                    }
                    else
                    {
                      $number = $numberDetails['mobile_number'];
                    }
                  }
                  elseif($userPhones)
                  {
                    if(strpos($userPhones['mobile_number'],'+') === false)
                    {
                      $number = '+'.$userPhones['mobile_number'];
                    }
                    else
                    {
                      $number = $userPhones['mobile_number'];
                    }
                  }
                ?>
                <?php if($this->session->userdata('admin_id')=='19624' || $this->session->userdata('admin_id')=='25267'){ ?>
                <?php if($number!=''){ ?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Mobile Number</label>

                  <div class="col-sm-4">
                  <label><?php echo $number; ?></label>
                  </div>

                </div>
                <?php } ?>
                <?php } ?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Date</label>

                  <div class="col-sm-4">
				  
                  <label><?php if(!empty($orderDetails)){ 
				   if($orderDetails[0]['upgrade_date'] > 0 ){ $cdate = $orderDetails[0]['upgrade_date'];}else{$cdate = $orderDetails[0]['created'];} 
					echo date('d-m-Y H:i:s',$cdate); }
				  			  
				  ?></label>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">IP Address</label>

                  <div class="col-sm-4">
                  <label><?php if(!empty($orderDetails)){ echo $orderDetails[0]['ip_address']; }?></label>
                  </div>

                </div>
                <?php if($orderDetails[0]['booked_by']==1){ ?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Booked By</label>

                  <div class="col-sm-4">
                  <label>Castleevents Admin</label>
                  </div>

                </div>
                <?php } ?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Payment Status</label>

                  <div class="col-sm-4">
                  <label>
                    <?php 
                    if($orderDetails[0]['is_exchanged']==1){ 
                      echo 'No Payment'; 
                    } else {
                      if($orderDetails[0]['payed']==1){ 
                        echo 'Paid'; 
                      } elseif($orderDetails[0]['is_renewed']==1){ 
                        echo 'Unpaid | Invoice mail sent'; 
                      } else{ 
                        echo 'Unpaid'; 
                      }
                    }
                    ?></label>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Payment Method</label>

                  <div class="col-sm-4">
                  <label>
                    <?php 
                    if($orderDetails[0]['is_exchanged']==1){ 
                      echo 'Exchange'; 
                    } else {
                      if($orderDetails[0]['payment_method_id']==13){ 
                        echo 'Saferpay'; 
                      } elseif($orderDetails[0]['payment_method_id']==14){ 
                        echo 'Credit Card';
                      } elseif($orderDetails[0]['payment_method_id']==12){ 
                        echo 'Bank Transfer'; 
                      } else{ 
                        echo 'Pay By Bank'; 
                      }
                    }
                    ?>
                    </label>
                  </div>

                </div>

                <div class="form-group">

                  <label class="col-sm-2 control-label">Transaction Reference</label>

                  <div class="col-sm-4">
                  <label><?php if($orderDetails[0]['trn_id']){ echo $orderDetails[0]['trn_id']; } else { echo 'N/A'; }?></label>
                  </div>

                </div>

                <?php if($orderDetails[0]['payment_date']!=''){?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Payment Date</label>

                  <div class="col-sm-4">
                  <label><?php echo $orderDetails[0]['payment_date']; ?></label>
                  </div>

                </div>
                <?php } ?>
                <?php if($orderDetails[0]['is_exchanged'] == 1){?>
                <div class="form-group">
                  <label class="col-sm-2 control-label">Exchange Date</label>
                  <div class="col-sm-4">
                  <label><?php echo $orderDetails[0]['exchange_date']; ?></label>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">Exchange Note</label>
                  <div class="col-sm-4">
                  <label><?php echo $orderDetails[0]['exchange_note']; ?></label>
                  </div>
                </div>
                <?php } ?>

                <?php if($orderDetails[0]['fail_reason']!=''){?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Fail Reason</label>

                  <div class="col-sm-4">
                  <label><?php if($orderDetails[0]['fail_reason']!=''){ echo $orderDetails[0]['fail_reason']; } ?></label>
                  </div>

                </div>
                <?php } ?>

                <?php if($orderDetails[0]['refund_trn_id']!='' && $orderDetails[0]['refund_date']!=''){?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Refunded On: </label>

                  <div class="col-sm-4">
                  <label><?php if($orderDetails[0]['refund_date']!=''){ echo $orderDetails[0]['refund_date']; } ?></label>
                  </div>

                </div>
                <?php } ?>
                <?php if($orderDetails[0]['is_booking']==1 && $orderDetails[0]['checkin_amount']!=''){?>
                
                <div class="form-group">
                  <label class="col-sm-2 control-label">Checkin Amount</label>
                  <div class="col-sm-4">
                  <label><?php echo $orderDetails[0]['checkin_amount']; ?></label>
                  </div>
                </div>

                <div class="form-group">
                  <label class="col-sm-2 control-label">Checkin Date</label>
                  <div class="col-sm-4">
                  <label><?php echo $orderDetails[0]['checkin_date']; ?></label>
                  </div>
                </div>
                <?php if($orderDetails[0]['checkin_trasaction_id']){ ?>
                <div class="form-group">
                  <label class="col-sm-2 control-label">Checkin Transaction ID</label>
                  <div class="col-sm-4">
                  <label><?php echo $orderDetails[0]['checkin_trasaction_id']; ?></label>
                  </div>
                </div>
                <?php } ?>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Checkin Payment Status</label>

                  <div class="col-sm-4">
                  <label><?php if($orderDetails[0]['checkin_payed']==1){ echo 'Paid'; } else{ echo 'Unpaid'; }?></label>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Checkin Payment Method</label>

                  <div class="col-sm-4">
                  <label><?php if($orderDetails[0]['checkin_payment_method_id']==1){ echo 'Saferpay'; } elseif($orderDetails[0]['checkin_payment_method_id']==3){ echo 'Premium account so not to be paid'; } elseif($orderDetails[0]['checkin_payment_method_id']==2){ echo 'Bank Transfer'; } else{ echo 'Bank Transfer'; }?></label>
                  </div>

                </div>
                <?php } ?>
              </div>
            </form>

            <?php if($orderDetails[0]['is_booking']==1 && $orderDetails[0]['real_name']==''){ ?>
              <form action="<?php echo base_url().'admin/order/update_real_name'?>" method="post">
                <div class="box-body">
                <div class="form-group">
                  <label class="col-sm-2 control-label">Member Real Name</label>
                  <div class="col-sm-4" style="margin-bottom: 10px">
                    <input type="text" name="real_name" value="" class="form-control">
                    <input type="hidden" name="order_id" value="<?php echo $orderDetails[0]['order_id']; ?>" class="form-control">
                  </div>
                  <div class="col-sm-4">
                    <input type="submit" value="Save" class="btn btn-success">
                  </div>
                </div>
              </div>
              </form>
              <?php } ?>
              <br/>
            <?php if($orderDetails[0]['is_booking']==1){ ?>
              <form action="<?php echo base_url().'admin/order/update_total_amount'?>" method="post">
                <div class="box-body">
                <div class="form-group">
                  <label class="col-sm-2 control-label">Update Total Amount</label>
                  <div class="col-sm-4" style="margin-bottom: 10px">
                    <input type="text" name="total_amount" value="" class="form-control">
                    <input type="hidden" name="order_id" value="<?php echo $orderDetails[0]['order_id']; ?>" class="form-control">
                  </div>
                  <div class="col-sm-4">
                    <input type="submit" value="Update" class="btn btn-success">
                  </div>
                </div>
              </div>
              </form>
            <?php } ?>
          </div>
          <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Description</th>
                  <th>Number</th>
                  <th>Price(&euro;)</th>
                 
                </tr>
                </thead>
                 
                <tbody>
                <?php if(!empty($orderDetails)){ 
                      foreach ($orderDetails as $value) {
                        if($value['price'] > 0 || $value['base_price'] > 0)
                        {
                  ?>
                      <tr>
                      <?php $name = array(); 
                        if($value['is_booking']==1)
                        {
                          $name = getValue('event_features_lang_values',array('event_feature_id'=>$value['fea_id'],'lang_id'=>2));
                          $dates = explode(',', $value['fea_id']);
                          $date='';
                          
                          if(!empty($dates))
                          {
                            foreach ($dates as $dateVal) {
                              $val = getValue('event_features',array('id'=>$value['fea_id']));
                              $date .= date('d.m.Y',$val['date']).',';
                            }
                          }
                          
                          if(!empty($name))
                          {
                            if($value['feature_type']==1)
                            {
                              $value['name'] = 'Event services';
                            }
                            elseif ($value['feature_type']==2) {
                              $value['name'] = 'Room ('.$name['title'].')';
                            }
                            else
                            {
                              $value['name'] = $name['title'];
                            }
                          }
                          else
                          {
                            $nightsAvailable = '';
                            if($value['feature_id']!='')
                            {
                              $extra_ids = explode(',', $value['feature_id']);
                              if(count($extra_ids)>0)
                              {
                                $date = '';
                                foreach ($extra_ids as $key => $res) {
                                  $result = getValue('event_features',array('id'=>$res));
                                  $date .= date('d.m.Y',$result['date']).',';
                                  $room_ID = $result['room_id'];
                                  $nightsAvailable = getNights('event_features',array('room_id'=>$room_ID));
                                }
                                $value['quantity'] = count($extra_ids);
                              }
                            }
                            if(count($extra_ids)==1) {
                              if($nightsAvailable > 0)
                              {
                                $value['name'] = 'Extra Night ('.date('d.m.Y',$nightsAvailable['date']).')';
                              } else {
                                $value['name'] = 'Extra Night ('.rtrim($date,',').')';
                              }
                              
                            } else {
                              $value['name'] = 'Extra Nights ('.rtrim($date,',').')';
                            }
                          }
                        }
                        $eventData = getValue('evt_events',array('id'=>$value['event_id']));
                      ?>
                          <td><?php if($value['is_booking']==1){ echo $value['name'];} elseif (count($eventData)>0) { echo $eventData['title']; } else{ echo ucfirst($value['alias']); }?></td>
                          <td><?php echo $value['quantity']; ?></td>
                          <td><?php 
                            if($value['is_booking']==1 || count($eventData)>0){
                              if($value['feature_type']==1 ){ 
                                if($orderDetails[0]['user_discount']>0){
                                  echo number_format($value['price'], 2,',', '.'); 
                                }
                                elseif($value['fea_base_price']>0){
                                  echo number_format($value['price']+($orderDetails[0]['discount']/100), 2,',', '.'); 
                                } else {
                                  echo number_format(($value['price']+($orderDetails[0]['discount']/100)), 2,',', '.'); 
                                }
                              } elseif($value['feature_type']==2 && $orderDetails[0]['room_discount'] > 0){ 
                                if($orderDetails[0]['room_discount']>0){
                                  echo number_format($value['price']+($orderDetails[0]['room_discount']/100), 2,',', '.'); 
                                } else {
                                  echo number_format(($value['price']), 2,',', '.'); 
                                }
                              }
                              else { 
                                echo number_format($value['price'], 2,',', '.'); 
                              } 
                            } 
                            else{
                              echo number_format($orderDetails[0]['total_base']/100, 2,',', '.'); 
                            } ?>
                          </td>
                      </tr>
                    <?php if($value['feature_type']==1){ ?>
                      <?php if($orderDetails[0]['discount']>0){ ?>
                      <tr>
                          <td></td>
                          <td>
                            <?php 
                            $total_discounts = 'Discount ';
                            $total_discount = '';
                            if($orderDetails[0]['party_discount']>0){ 
                                $total_discount .= '(Early bird-'.$orderDetails[0]['party_discount'].'%)';
                            } 
                            if($orderDetails[0]['user_discount']>0){ 
                                $total_discount .= ', (User-'.$orderDetails[0]['user_discount'].'%)';
                            }
                            if($orderDetails[0]['party_discount']==0 && $orderDetails[0]['user_discount']==0){
                              $total_discount .= '('.round($orderDetails[0]['discount']/$value['price']).'%)';
                            }  
                            ?>
                            <?php echo $total_discounts.trim($total_discount,','); ?>
                          </td>
                          <td> <?php echo number_format($orderDetails[0]['discount']/100, 2,',', '.'); ?> </td>
                      </tr>
                      <?php } ?>
                      <tr>
                          <td></td>
                          <td>Sub Total:</td>
                          <td> <?php if($orderDetails[0]['user_discount']>0){ echo number_format(($value['price'] - ($orderDetails[0]['discount']/100)), 2,',', '.'); } elseif($value['fea_base_price']>0){ echo number_format($value['price'], 2,',', '.'); } else { echo number_format($value['price'], 2,',', '.'); } ?> </td>
                      </tr>
                    <?php } ?>
                    <!--room discount-->
                    <?php if($value['feature_type']==2){ ?>
                      <?php if($orderDetails[0]['room_discount']>0){ ?>
                      <tr>
                          <td></td>
                          <td>
                            <?php 
                            $total_discounts = 'Discount ';
                            $total_discount = '';
                            if($orderDetails[0]['user_discount']>0){ 
                                $total_discount .= '(User-'.$orderDetails[0]['user_discount'].'%)';
                            }
                            ?>
                            <?php echo $total_discounts.trim($total_discount,','); ?>
                          </td>
                          <td> <?php echo number_format($orderDetails[0]['room_discount']/100, 2,',', '.'); ?> </td>
                      </tr>
                      
                      <tr>
                          <td></td>
                          <td>Sub Total:</td>
                          <td> <?php if($value['fea_base_price']>0){ echo number_format($value['fea_base_price']-($orderDetails[0]['room_discount']/100), 2,',', '.'); } else { echo number_format($value['base_price'], 2,',', '.'); } ?> </td>
                      </tr>
                      <?php } ?>
                    <?php } ?>
                    <!--room discount-->

                <?php } } } ?>
                <?php if($orderDetails[0]['is_booking']==0){ ?>
                <tr>
                    <td></td>
                    <td>Sub Total:</td>
                    <td> <?php echo number_format($orderDetails[0]['total_base']/100, 2,',', '.'); ?> </td>
                </tr>
                <?php } ?>
                <tr>
                    <td></td>
                    <td>Vat:</td>
                    <td> <?php echo number_format($orderDetails[0]['vat']/100, 2,',', '.'); ?> &euro;</td>
                </tr>
                <tr>
                    <td></td>
                    <td>Payment Fee: </td>
                    <td><?php echo number_format($orderDetails[0]['payment_fee']/100, 2,',', '.'); ?> &euro;</td>
                </tr>
                
                <tr>
                    <td></td>
                    <td>Grand Total:</td>
                    <?php $setting = getValue('sys_settings', array('key'=>'reservation_fee')); ?>
                    <td> 
                      <?php if($orderDetails[0]['is_recomended']==1) {
                              echo number_format($orderDetails[0]['total_sum']/100, 2,',', '.');
                            } else {
                              echo number_format($orderDetails[0]['total_sum']/100, 2,',', '.');
                            } 
                      ?> &euro;
                      <?php if($orderDetails[0]['is_recomended']==1) { 
                        echo $setting ? '('.$setting['value']. '% Deposit)' : ''; 
                      } ?>
                    </td>
                </tr>
                <?php if($orderDetails[0]['is_recomended']==1) { ?>
                <tr>
                    <td></td>
                    <td>Rest payment at arrival</td>
                    <td> <?php echo number_format($orderDetails[0]['reservation_rest_amount']/100, 2,',', '.'); ?> &euro;</td>
                </tr>
                <?php } ?>
                </tr>
                </tbody>
                
                <tfoot>
               
                </tfoot>
              </table>


              <?php if($orderDetails[0]['is_booking']==1 && $orderDetails[0]['checkin_date']!=''){?>
              <h5>Checkin Details</h5>
               <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Description</th>
                  <th>Number</th>
                  <th>Price(&euro;)</th>
                </tr>
                </thead>
                <tbody>
                <?php if($orderDetails[0]['drinking_package']) { ?>
                <tr>
                    <td><?php echo $orderDetails[0]['drinking_package']; ?> package</td>
                    <td>1</td>
                    <td> <?php echo number_format($orderDetails[0]['drink_price'], 2,',', '.'); ?> &euro;</td>
                </tr>
                <?php } ?>
                <?php if($orderDetails[0]['cape'] > 0) { ?>
                <tr>
                    <td>Cape</td>
                    <td><?php echo $orderDetails[0]['cape']; ?></td>
                    <td> <?php if($orderDetails[0]['guest_id'] < 323) { echo number_format((50*$orderDetails[0]['cape']), 2,',', '.'); } else { echo number_format($orderDetails[0]['cape_price'], 2,',', '.'); } ?> &euro;</td>
                </tr>
                <?php } ?>
                <?php if($orderDetails[0]['additional'] > 0) { ?>
                <tr>
                    <td>Extras</td>
                    <td>1</td>
                    <td> <?php echo number_format($orderDetails[0]['additional'], 2,',', '.');  ?> &euro;</td>
                </tr>
                <?php } ?>
                <tr>
                    <td></td>
                    <td>Grand Total:</td>
                    <td> <?php if($orderDetails[0]['guest_id'] < 323) { echo number_format(((50*$orderDetails[0]['cape'])+$orderDetails[0]['drink_price']), 2,',', '.'); } else { echo number_format($orderDetails[0]['checkin_amount'], 2,',', '.'); } ?> &euro;</td>
                </tr>
                </tbody>
                <tfoot>
                </tfoot>
              </table>
            <?php } ?>
              <?php if($order_to_reminder['total']>0){?>
              <div class="box-body">
                <div class="form-group">
                  <label class="col-sm-4 control-label">Last Reminder Send: </label>
                  <div class="col-sm-4">
                  <label><?php echo $order_to_reminder['remind_date']; ?></label>
                  </div>
                </div><br/>
                <div class="form-group">
                  <label class="col-sm-4 control-label">Time Of Reminder Send: </label>
                  <div class="col-sm-4">
                  <label><?php echo $order_to_reminder['total']; ?></label>
                  </div>
                </div>
              </div>  
              <?php } ?>


              <div>Action:</div>
              <div>
                <a class="btn btn-danger" href="<?php echo base_url();?>admin/order/delete/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Delete" onclick="return confirm('Are you sure to delete ?');"><span class="fa fa-ban"></span></a>
                <?php if($orderDetails[0]['payed']!=1 && ($orderDetails[0]['payment_method_id']==12 || $orderDetails[0]['payment_method_id']==14)){ ?>
                  <a class="btn btn-primary" href="<?php echo base_url();?>admin/order/status/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Make paid" onclick="return confirm('Are you sure to change status to paid ?');"><span class="fa fa-check"></span></a>
                <?php } ?>
                <?php if(($orderDetails[0]['checkin_payed']==0 || $orderDetails[0]['checkin_payed']=='') && ($orderDetails[0]['checkin_amount'] > 0 && $orderDetails[0]['checkin_payment_method_id']==2)){ ?>
                  <a class="btn btn-primary" href="<?php echo base_url();?>admin/order/checkin_status/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Make checkin payment paid" onclick="return confirm('Are you sure to change checkin payment status to paid ?');"><span class="fa fa-check-circle-o"></span></a>
                <?php } ?>
                <?php if($orderDetails[0]['payment_date']==''){ ?>
                  <a class="btn btn-danger" href="javascript: void(0)" class="payment_date" data-toggle="modal" data-target="#myModal1" data-id="<?php echo $orderDetails[0]['order_id'];?>" title="Add payment date" ><span class="fa fa-calendar"></span></a> 
                <?php } ?>
                <?php if($orderDetails[0]['is_exchanged']==0){ ?>
                  <a class="btn btn-danger" href="javascript: void(0)" class="exchange" data-toggle="modal" data-target="#myModal_exchange" data-id="<?php echo $orderDetails[0]['order_id'];?>" title="Add exchange" ><span class="fa fa-exchange"></span></a> 
                <?php } ?>
                <?php if($orderDetails[0]['payed']!=1 && $orderDetails[0]['payment_method_id']==12 && $orderDetails[0]['is_booking']==1){ ?>
                  <a class="btn btn-info" href="<?php echo base_url();?>admin/order/reminder/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Remind by email" onclick="return confirm('Are you sure to remind ?');"><span class="fa fa-envelope"></span></a>
                <?php } ?>
                <?php if($orderDetails[0]['refund_trn_id']=='' && $orderDetails[0]['payed']==1 && $orderDetails[0]['payment_method_id']==13){ ?>
                  <a class="btn btn-info" href="<?php echo base_url();?>admin/order/refund/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Refund" onclick="return confirm('Are you sure to refund ?');"><span class="fa fa-reply"></span></a>
                <?php } ?>
                <?php if($this->session->userdata('admin_id')=='19624' || $this->session->userdata('admin_id')=='25267' || $this->session->userdata('admin_id')=='11330'){ ?>
                <a class="btn btn-success" target="_blank" href="<?php echo base_url();?>admin/order/download/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Download"><span class="fa fa-download"></span></a>
                <a class="btn btn-success" target="_blank" href="<?php echo base_url();?>admin/order/download_for_user/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Download without details"><span class="fa fa-cloud-download"></span></a>
                <?php } ?>
                <?php if($this->session->userdata('admin_id')=='19624' || $this->session->userdata('admin_id')=='25267' || $this->session->userdata('admin_id')=='11330'){
                  if($orderDetails[0]['checkin_date']!=''){
                 ?>
                <a class="btn btn-success" target="_blank" href="<?php echo base_url();?>admin/order/checkin_download/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Checkin Download"><span class="fa fa-file"></span></a>
                <?php } } ?>

                <?php if($orderDetails[0]['is_renewed']==1 && $orderDetails[0]['payed']==0){ ?>
                  <a class="btn btn-success" target="_blank" href="<?php echo base_url();?>admin/order/change_membership/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Change Membership Type"><span class="fa fa-pencil-square"></span></a>
                  <?php if($this->session->userdata('admin_id')=='25267'){ ?>
                  <a class="btn btn-primary" href="<?php echo base_url();?>admin/renew_payment/payment/<?php echo base64_encode($orderDetails[0]['order_id']);?>" title="Manaul Charge" onclick="return confirm('Are you sure to charge ?');"><span class="fa fa-credit-card"></span></a>
                  <?php } ?>
                  <?php } ?>
                </div>
            </div>
        </div>

        <!--/.col (right) -->

      </div>

      <!-- /.row -->

    </section>

    <div id="myModal1" class="modal fade" role="dialog">
      <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Enter Payment Date</h4>
          </div>
          <div class="modal-body">
            <form action="<?php echo base_url().'admin/order/add_payment_date'; ?>" method="post">
                <div class="box-body">
                  <div class="form-group">
                    <label class="col-sm-2 control-label">Payment Date</label>
                    <div class="col-sm-6">
                    <input type="text" id="payment_date" name="payment_date" class="form-control" placeholder="Enter Payment Date" value="">
                    <input name="payment_order_id" id="payment_order_id" class="form-control" type="hidden" value="<?php echo $orderDetails[0]['order_id']; ?>">
                    <input name="uri" id="" class="form-control" type="hidden" value="<?php echo str_replace('/','-',uri_string()); ?>">
                    </div>
                  </div>
              </div>
              <div class="text-center">
                <input type="submit" class="btn btn-info " value="Add" id="add">
              </div>
                
            </form>
          </div>
          
        </div>
      </div>
    </div>

    <div id="myModal_exchange" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">Exchange Order</h4>
            </div>
            <div class="modal-body">
              <form action="<?php echo base_url().'admin/latest_order/add_exchange'; ?>" class="form-horizontal" method="post">
                  <div class="box-body">
                    <div class="form-group">
                      <label class="col-sm-2 control-label">Exchange Date</label>
                      <div class="col-sm-10">
                      <input type="text" id="exchange_date" name="exchange_date" class="form-control" placeholder="Enter Exchange Date" value="">
                      <input name="exchange_order_id" id="exchange_order_id" class="form-control" type="hidden" value="<?php echo $orderDetails[0]['order_id']; ?>">
                      <input name="uri" id="" class="form-control" type="hidden" value="<?php echo str_replace('/','-',uri_string()); ?>">
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">Exchange Note</label>
                      <div class="col-sm-10">
                      <textarea id="exchange_note" name="exchange_note" class="form-control" placeholder="Enter Exchange Note" value=""></textarea>
                      </div>
                    </div>
                </div>
                <div class="text-center">
                  <input type="submit" class="btn btn-info " value="make Exchange Order" id="exchange">
                </div>
                  
              </form>
            </div>
            
          </div>
      </div>
    </div>
</div>

    <style type="text/css">

    .loader{

      position: fixed;

      left: 0;

      top: 0;

      right: 0;

      bottom: 0;

      width: 100%;

      height: 100%;

      background-color: rgba(0, 0, 0, 0.60);

      z-index: 9999;

      text-align: center;

    }

    .loader img{

      z-index: 99999;

      margin-top: 10%;

    }

    </style>
   <script type="text/javascript">
    function return_back()
    {
      var back_url='<?php echo base_url()?>admin/order';
      window.location=back_url;
    }
    $("#payment_date").datetimepicker();
    $("#exchange_date").datetimepicker();
   </script>