<?php include("_config/dbconfig.php");
include("_includes/head.php");?>
<title>Exhibition Tasks </title>
<style>
    .deactive_row td { background-color: #FFAAAA !important; }
    .dropdown-menu { background: #eee;}
    .dropdown-menu li{border-bottom: 1px solid #ccc;}
    .pendinggg{}
    .processss td{background-color:#FDF704 !important; border-bottom: 1px solid #999;}
    .completed td{background-color:#BBEF7E !important; border-bottom: 1px solid #999;}
.dropdown-menu { min-width: 100px !important;}

.table-responsive{     overflow-x: visible; }

#example_wrapper td{  }
</style>
<?php include("_includes/header.php"); 

if(isset($_SESSION['user_session'])){
$agent_id = $_SESSION['user_session'];
}else {
$agent_id = 0;	
}

$event_all      = $obj_events_class->getEvent();   

       if(isset($_GET['st']) && isset($_GET['id']) ){
            $id     = base64_decode($_GET['id']);
            $status = base64_decode($_GET['st']);
            $obj_jobs_class->updateEventTasks($id, $status);
            echo "<script>window.location='event_tasks.php'</script>";
            die();
       }
       
       
        if(isset($_GET['event']) && !empty($_GET['event']) ){
                 $ev_id = base64_decode($_GET['event']);
                $tasks_all      = $obj_jobs_class->getEventTasks('',$ev_id, $agent_id);
        }else {
                $tasks_all      = $obj_jobs_class->getEventTasks('','', $agent_id);
        }
       /*echo '<pre>';
       print_r($tasks_all);
       echo '</pre>';*/
       
?>
<div class="col-sm-12 right_form">
        <div class="title">
            <div class="row">
                <div class="col-md-10 col-sm-12">
                    <h1>Exhibition Tasks</h1>
                </div>
                
                 
                
                
            </div>
        </div>
    
    <div class="col-sm-8">
      <ol class="breadcrumb white">
        <li><a href="dashboard.php">Dashboard</a></li> 
        <li><a href="events.php">Exhibition</a></li> 
        <li class="active">Exhibition Tasks  </li>
       
    </ol>
    </div>
      <div class="col-sm-4">
          <select class="form-control chosen-select" style="width:100%;" id="exi_id" tabindex="2" name="event" required="required" onchange="goEvent();">
                      
                                <option value="">--- Select Exhibition ---</option>
                                <?php foreach($event_all as $tl){   $sel = '';
                                    if (isset($_GET['event']) && !empty($_GET['event'])) {
                                    $ev_id = base64_decode($_GET['event']);
                                    if($ev_id == $tl['event_id']){$sel = "selected='selected'";}
                                    }
                                    ?>
                                <option value="<?php echo base64_encode($tl['event_id']);?>" <?= $sel ?>><?php echo $tl['event_name'];?></option>
                                <?php } ?>
                            </select>
      </div>
    
    
</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" style="min-height: 300px;">
                    <table id="example" class="display nowrap lisitng_table" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                            	<th >Sr. </th>
                                <th>Task Title</th>
                                <th>Start Date</th>
                                <th>End Date</th>
                                <th>Exhibition</th> 
                                <th>Status</th>
                                <th>Modify</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php $i=1; foreach($tasks_all as $task){ 
                            if($task['status']=='1'){$cc= 'processss';}
                            else if($task['status']=='2'){$cc= 'completeee';}
                            else { $cc= ''; }
                            ?>    
                            <tr  class="<?= $cc ?> <?= $task['status'] ?>">
                        <td><?php echo $i++;?></td>
                        <td>   <?php echo $task['title']?> 
                        <br> <span style="color:#F47721" ><?php $c_id= $obj_clients_class->getClients($task['client_id']); echo $c_id['company_name']; ?></span>
                        </td>
                        <td><?php echo $obj_jobs_class->change_date3($task['start_date']);?></td>
                        <td><?php echo $obj_jobs_class->change_date3($task['end_date']);?></td>
                        <td><?php 
                                    $evv = $obj_events_class->getEvent($task['event_id']);
                                    echo $evv['event_name'];
                            ?>
                        </td>
                         
                        <td style="text-transform: capitalize;">    <?php   echo  $task['status']; ?> 
                        <?php 
                                if($task['status']=='pending')  'Pending';
                                
                        ?>
                        
                        
                        </td>
                        <td> 
                            <div class="dropdown">
                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" aria-haspopup="true" aria-expanded="false">
                                    Action <span class="caret"></span>
                                </button>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                        <li>
                            <a href="event_tasks.php?id=<?php echo base64_encode($task['task_id']) ?>&st=<?php echo base64_encode('completed') ?>">
                                Complete</a>
                        </li>
                        </ul>
                            </div>
                        </td>
                        <td></td>
                    </tr>
                        <?php  } ?> 
                        </tbody>
                    </table>
                </div>
            </div>
		</div>

<div class="modal fade modal-aside horizontal right events-modal"  id="newFullEvent" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog modal-sm">
        <div class="modal-content">
            <form class="form-full-event" action="#" method="POST">
                <div class="modal-body"> 
                <div class="form-group">
                    <label>  Task Title </label>
                    <input type="text" id="title" placeholder="Enter title" required="required" class="form-control underline text-large" name="title">
                </div>
                <div class="form-group">
                        <label> Description </label>
                        <span class="input-icon">
                            <textarea class="form-control"  name="descp"></textarea>
                        </span>
                </div>
                    
                <div class="form-group">
                        <label> Start Date</label>
                        <span class="input-icon">
                        <input type="text" autocomplete="off" onkeydown="return false;" id="start_date1" class="form-control underline  date calendar_icons" required="required" name="eventStartDate"/>
                        <i class="ti-calendar"></i> </span>
                </div>
                <div class="form-group">
                        <label> End Date </label>
                        <span class="input-icon">
                            <input type="text" autocomplete="off" onkeydown="return false;" id="end_date1" class="form-control date underline calendar_icon" required="required" name="eventEndDate" />
                            <i class="ti-calendar"></i> </span>
                </div>

                <div class="form-group">
                        <label> Exhibition </label>
                        <span class="input-icon">
                            <select class="chosen-select" name="exhibition" required="required">
                                <?php foreach($event_all as $event){?>
                                    <option><?php echo $event['event_name']; ?></option>
                                <?php } ?>
                            </select>
                        </span>
                </div>
            </div>
            <div class="modal-footer"> 
                <input type="submit" name="task_submit" class="btn btn-primary btn-o save-event" value="Save" >
            </div>
            </form>
        </div>
</div>
</div>




<?php include("_includes/footer.php"); ?>
<script>
$(document).ready(function() {
    
      $("#start_date1").datepicker({
            dateFormat: 'yy-mm-dd',
            numberOfMonths: 1,
            onSelect: function(selected) {
              $("#end_date1").datepicker("option","minDate", selected)
            }
        });
        $("#end_date1").datepicker({
            dateFormat: 'yy-mm-dd',
            numberOfMonths: 1,
            onSelect: function(selected) {
               // $("#start_date1").datepicker("option","maxDate", selected)
            }
        });   
        
        
    
    $('.dropdown-toggle').dropdown()
    
    
    $('#example').DataTable( {
        responsive: {
            details: {
                type: 'column',
                target: -1
            }
        },
        columnDefs: [ {
            className: 'control',
            orderable: false,
            targets:   -1
        }]
    });
});




    function goEvent(){
        vv = $("#exi_id").val();
        if(vv!=''){
            window.location = 'event_tasks.php?event='+vv+'&1=1';        
        }else{
            window.location = 'event_tasks.php';        
        }
    } 
    
    
</script>