<?php include("_config/dbconfig.php");
include("_includes/head.php");?>
<title>Exhibitions</title>
<style>
    .deactive_row td { background-color: #FFAAAA !important; }
</style>
<?php include("_includes/header.php"); 
       if(isset($_SESSION['user_session'])){
            $agent_id = $_SESSION['user_session'];
        } 


       if(isset($_GET['del'])){
            $id = base64_decode($_GET['del']);
            $obj_events_class->delEvent($id);
            echo "<script>window.location='events.php'</script>";
            die();
       }
       
        if($_SESSION['user_role_session']=="Admin"){ 
            $event_all   =   $obj_events_class->getAgetEvent();
        }else {
            $event_all   =   $obj_events_class->getAgetEvent($agent_id);
        }
       
?>
<div class="col-sm-12 right_form">
        <div class="title">
            <div class="row">
                <div class="col-md-8 col-sm-12">
                    <h1>Exhibitions</h1>
                </div>
                     <div class="col-md-4 col-sm-12">
			<a href="event_controls.php" style="cursor: pointer;" class="btn btn-primary btn-o add-event"> Add New </a>
                </div>
            </div>
        </div>
    
        <ol class="breadcrumb white">
          <li><a href="dashboard.php">Dashboard</a></li>
          <li class="active">Exhibitions</li>
        </ol>
</div> 

<?php 
/*        echo "<pre>";
        print_r($_SESSION);
        echo '</pre>';
   */     
?>
  	<div class="col-sm-12 form_inner">
			<div class="col-md-12 table_inner" style="padding:0;">
                <div class="table-responsive">
                    <table id="example" class="display nowrap lisitng_table" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                            	<th>Sr. </th>
                                <th>Event Name </th>
                                <th>Industry </th>
                                <th>Organizer</th>
                                <th>Date</th>
                                <th>Venue</th>
                                 <?php if($_SESSION['user_role_session']=="Agent" || $_SESSION['user_role_session']=="Admin" ){?>
                                    <th class="center-align">Assigning Details</th>
                                 <?php }?>
                                <th>Status</th>
                                <th>Modify</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php $i=1; foreach($event_all as $event){ 
                            if($event['status']=='Deactive'){$cc= 'deactive_row';}
                            else { $cc= ''; }
                            ?>    
                            <tr class="<?= $cc ?>">
                        <td><?php echo $i++;?></td>
                        <td> 
                                <a href="assign_client_step2.php?event=<?php echo base64_encode($event['event_id']); ?>" style="color: #000;" >
                                <img src="img/info.png" width="15" />
                                    <?php echo $event['event_name']?> 
                                </a>
                        </td>
                        <td><?php echo $event['categories']?></td>
                        <td><?php echo $event['organizer']?></td>
                        <td><?php echo $event['start_date']?></td>
                        <td><?php echo $event['venue']?></td>
                        <?php if($_SESSION['user_role_session']=="Agent" || $_SESSION['user_role_session']=="Admin"){?>
                        <td class="center-align"> 
                            <a href="assign_client.php?event=<?php echo base64_encode($event['event_id']); ?>">Step 1</a> &nbsp; | &nbsp;
                            <a href="assign_client_step2.php?event=<?php echo base64_encode($event['event_id']); ?>">Step 2</a> &nbsp; | &nbsp;
                            <a href="assign_client_step3.php?event=<?php echo base64_encode($event['event_id']); ?>">Step 3</a>
                            
                            
                        </td><?php }?>
                        <td>    <?php echo $event['status']; ?> </td>
                        <td>
                            <a href="event_controls.php?view=<?php echo base64_encode($event['event_id'])?>"> <i class="fa fa-list-ul"></i>  </a> | 
                            <a href="event_controls.php?edit=<?php echo base64_encode($event['event_id'])?>"> <i class="fa fa-pencil-square-o"></i>  </a> | 
                            <a href="events.php?del=<?php echo base64_encode($event['event_id'])?>" onclick="return window.confirm('Are you sure you want to Deactive this Event?'); "> <i class="fa fa-times"></i>  </a>
                        </td>
                        <td></td>
                    </tr>
                        <?php  } ?> 
                        </tbody>
                    </table>
                </div>
            </div>
		</div>

<?php include("_includes/footer.php"); ?>
<script>
$(document).ready(function() {
    $('#example').DataTable( {
        responsive: {
            details: {
                type: 'column',
                target: -1
            }
        },
        columnDefs: [ {
            className: 'control',
            orderable: false,
            targets:   -1
        }]
    });
});
</script>