<?php 
use App\Models\UserModel;
use App\Models\AdmissionModel;
$user = new UserModel();
$adm = new AdmissionModel();
?>
<div class="content-wrapper">
  <div class="content-header">
     <div class="container-fluid">
        <div class="row mb-2">
           <div class="col-sm-6">
              <h1 class="m-0 text-dark">All Booking</h1>
           </div>
           <div class="col-sm-6">
              <ol class="breadcrumb float-sm-right">
                 <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
                 <li class="breadcrumb-item"><a href="#">Venue</a></li>
                 <li class="breadcrumb-item active">All Booking</li>
              </ol>
           </div>
        </div>
     </div>
  </div>

  <section class="content">
    <div class="container-fluid">
      <div class="card card-default">
        <div class="card-header">
          <h3 class="card-title">View All Booking</h3>
          <div class="card-tools">
             <a href="<?php echo base_url()?>/admin/venue/add_new_venue" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add New Booking</a>
          </div>
        </div>
        <div class="card-body">
           <table id="example1" class="table table-bordered table-striped">
             <thead>
                <tr>
                   <th>id</th>
                   <th>Name & Photo</th>
                   <th>Details</th>
                   <th>Added By</th>
                   <?php if(check_user_permission('delete') || check_user_permission('edit')): ?>
                     <th></th>
                  <?php endif;?>
                </tr>
             </thead>
             <tbody>
                <?php $i=1; foreach ($all_venue as $key => $venue):
                $added_by = $user->get_user_by_id($venue->venue_added_by);
                ?>
                <tr>
                   <td><?php echo $i ?></td>
                   <td>
                     <?php echo $venue->venue_wedding_name; ?>
                     <br/>
                     <br/>
                     <?php if($venue->venue_wedding_is_bride_or_groom != 'Other Ocassions'): ?>
                        <img src="<?php echo base_url(); ?><?php echo $venue->venue_wedding_image; ?>" width="70px">
                     <?php else: ?>
                        <img src="<?php echo base_url(); ?><?php echo $venue->venue_wedding_application_form; ?>" width="70px">
                     <?php endif; ?>
                   </td>
                   <td>
                     Booking For : <b><?php echo $venue->venue_wedding_is_bride_or_groom; ?></b>
                     <br/>
                     <?php if($venue->venue_wedding_is_bride_or_groom != 'Other Ocassions'): ?>
                        Age : <b><?php echo $venue->venue_wedding_age; ?></b>
                        <br/>
                     <?php endif;?>
                     <?php if($venue->venue_wedding_is_bride_or_groom != 'Other Ocassions'): ?>
                        Wedding 
                     <?php else: ?>
                        Event
                     <?php endif;?>
                        Date : <b><?php echo date('d-m-Y', strtotime($venue->venue_wedding_date)); ?></b>
                   </td>
                   <td>
                     <?php if($venue->venue_added_by == 2 || $venue->venue_added_by == 3): ?>
                        <b><?php echo $added_by->user_name; ?> (Admin)</b>
                     <?php else: ?>
                        <b><?php echo $added_by->user_name; ?></b>
                     <?php endif;?>
                   </td>

                   <?php if(check_user_permission('delete') || check_user_permission('edit')): ?>
                      <td>
                        <?php if(check_user_permission('edit')): ?>
                           <a href="<?php echo base_url()?>/admin/venue/edit_venue/<?php echo $venue->venue_id; ?>" class="btn btn-info btn-sm"><i class="fa fa-edit" aria-hidden="true"></i></a>
                        <?php endif; ?>
                        <?php if(check_user_permission('delete')): ?>
                           <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')" href="<?php echo base_url() ?>/admin/venue/delete_venue/<?php echo $venue->venue_id ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                        <?php endif; ?>
                      </td>
                  <?php endif;?>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
             </tbody>
          </table>
        </div>
      </div>
    </div>
  </section>
</div>
