<?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($_GET['del'])){
            $id = base64_decode($_GET['del']);
            $obj_events_class->delEvent($id);
            echo "<script>window.location='events_marketing.php'</script>";
            die();
       }
       
       $event_all   =   $obj_events_class->getEvent();
       
?>
<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">
			
                </div>
            </div>
        </div>
    
        <ol class="breadcrumb white">
          <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>  </th>
                                <th>Event Name </th>
                                <th>Organizer</th>
                                <th>Start Date</th>
                                <th>End Date</th>
                                <th>Venue</th>
                                <th class="center-align"> View </th>
                                <th>Status</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><?php if($event['market_status']==1){ $ck = 'checked="checked"'; }else {$ck='';} ?>
                            <input type="checkbox" <?= $ck; ?> onclick="check_event(<?php echo $event['event_id'] ?>);" id="check_<?php echo $event['event_id'] ?>_" /></td>
                        <td> 
                                <a href="assign_client_marketing.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['organizer']?></td>
                        <td>
                                <?php if(!empty($event['start_date']))echo $obj_jobs_class->change_date2($event['start_date'])?>
                        </td>
                        <td><?php if(!empty($event['end_date']))echo $obj_jobs_class->change_date2($event['end_date'])?></td>
                        <td><?php echo $event['venue']?></td>
                        
                        <td class="center-align"> 
                            <a href="assign_client_marketing.php?event=<?php echo base64_encode($event['event_id']); ?>">Details</a> &nbsp; | &nbsp;
                            
                            <a href="send_sms.php?event=<?php echo base64_encode($event['event_id']); ?>"> Send SMS </a> &nbsp; | &nbsp;
                            
                            <a href="event_graph.php?event=<?php echo base64_encode($event['event_id']); ?>">Graph</a>
                             
                            
                            
                        </td>
                        <td>    <?php echo $event['status']; ?> </td>
                        <td></td>
                    </tr>
                        <?php  } ?> 
                        </tbody>
                    </table>
                </div>
            </div>
		</div>

<?php include("_includes/footer.php"); ?>
<script>
    
    function check_event(id){
        if($("#check_"+id+"_").is(':checked')){ stat = 1;  }
        else stat = 0;
        
        var url = 'ajax.php?task=changeOrderStatus&id='+id+'&status='+stat;
            $.ajax({
              type: "POST",
              url: url,
              data: 'id', // serializes the form's elements.
              success: function(data){
                console.log(data);
                //$("#tr_row_"+as_id).css('background-color','#BBEF7E');
              }
            });            
            
            
    }
    
$(document).ready(function() {
    $('#example').DataTable( {
        responsive: {
            details: {
                type: 'column',
                target: -1
            }
        },
        columnDefs: [ {
            className: 'control',
            orderable: false,
            targets:   -1
        }]
    });
});
</script>