<?php //print_r($usertype);exit; ?>
    <section class="content-header">
      <h1>
        Events
      </h1>
      <ol class="breadcrumb">
        <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">List</li>
      </ol>
    </section>

    <section class="content">
      <div class="row">
        <?php echo $this->utility->showMsg();?>
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Management</h3>
              <?php if(chkWritePermission('Manage_Event',$this->session->userdata('admin_id'))!=0 || $this->session->userdata('admin_id')=='19624' ){ ?>
              <a class="btn btn-primary margin-right pull-right" href="<?php echo base_url()?>admin/event/add">Add</a>
              <?php } ?>
              </div>
               
              <div></div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>#</th>
                  <th>Title</th>
                  <th>Location</th>
                  <th>Party Date</th>
                  <th>Image</th>
                  <th>Status</th>
                  <?php if(chkWritePermission('Manage_Event',$this->session->userdata('admin_id'))!=0 || $this->session->userdata('admin_id')=='19624' ){ ?>
                  <th>Action</th>
                   <?php } ?>
                </tr>
                </thead>
                 <?php if(count($events)>0)
                {?>
                <tbody>
               <?php
                $i=1;
                foreach ($events as $data) 
                {
                ?>
                <tr>
                    <td><?php echo $i;?></td>
                    <td><?php echo $data['title']; ?></td>
                    <?php $location = $data['name'];
                        if($data['city']!='')
                        {
                          $location.=','.$data['city'];
                        }
                        if($data['country']!='')
                        {
                          $location.=','.$data['country'];
                        }
                        if($data['zipcode']!='')
                        {
                          $location.=','.$data['zipcode'];
                        }
                     ?>
                    <td><?php echo $location; ?></td>
                    <td><?php echo date('d-m-Y H:i:s',$data['time_from']); ?></td>
                    <td><img src="<?php echo base_url().'assets/userfiles/'.$data['path'].'/'.$data['filename'].'.'.$data['extension'];  ?>" width="80"></td>
                    <td><?php if($data['time_from']>time()){ echo 'Upcoming';}else{ echo 'Past'; } ?></td>
                    <?php if(chkWritePermission('Manage_Event',$this->session->userdata('admin_id'))!=0 || $this->session->userdata('admin_id')=='19624' ){ ?>
                    <td>
                      <a href="<?php echo base_url();?>admin/event/edit/<?php echo base64_encode($data['id']);?>" title="edit"><span class="fa fa-pencil-square"></span></a>
                      <a href="<?php echo base_url();?>admin/event/delete/<?php echo base64_encode($data['id']);?>" title="Delete" onclick="return confirm('Are you sure to delete ?');"><span class="fa fa-ban"></span></a>
                      <a href="<?php echo base_url();?>admin/event/entrylist/<?php echo base64_encode($data['id']);?>" title="Entry List"><span class="fa fa-plus"></span></a>
                      <a href="<?php echo base_url();?>admin/event/guestlist/<?php echo base64_encode($data['id']);?>" title="Guest List"><span class="fa fa-user"></span></a>
                      <?php if($data['visible']==0){?>
                        <a href="<?php echo base_url();?>admin/event/visibility/<?php echo base64_encode($data['id']);?>/1" title="Active" onclick="return confirm('Are you sure to active ?');"><span class="fa fa-eye-slash"></span></a>
                      <?php } else { ?>
                        <a href="<?php echo base_url();?>admin/event/visibility/<?php echo base64_encode($data['id']);?>/2" title="Inactive" onclick="return confirm('Are you sure to inactive ?');"><span class="fa fa-eye"></span></a>
                      <?php } ?>
                      <?php if($data['is_sold']==0){?>
                        <a href="<?php echo base_url();?>admin/event/is_sold/<?php echo base64_encode($data['id']);?>/1" title="Make Sold" onclick="return confirm('Are you sure to make sold ?');"><span class="fa fa-check"></span></a>
                      <?php } ?>
                    </td> 
                    <?php } ?>
                </tr>

               <?php $i++; } ?>

                </tbody>
                <?php } ?>
                <tfoot>
               
                </tfoot>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    

    
<script>
  $(function () {
    $("#example1").DataTable();
  });
</script>