<?php session_start(); ob_start(); ?>

<?php  include 'header.php'; ?>

<?php
ini_set('display_errors', 0);
if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}

date_default_timezone_set('Asia/Dhaka');
									
include("user.php");
$t_type=$_GET['type'];
$search_t=$_GET['search_t'];
$dayBookDate1=date('Y-m-d');

$dayBookDate2=date('Y-m-d', strtotime($dayBookDate1. ' + 60 days'));


	
if (isset($_POST['day_submit'])) {
	$dayBookDate1=$_POST['date1'];
	$dayBookDate2=$_POST['date2'];
	$sub=2;
	$photographer_search_id=$_POST['photographer_search_id'];
    $videographer_search_id=$_POST['videographer_search_id'];
}

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Events</title>
    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">
    <!-- Styles -->
     <link href="assets/css/lib/data-table/buttons.bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/owl.carousel.min.css" rel="stylesheet" />
    <link href="assets/css/lib/owl.theme.default.min.css" rel="stylesheet" />
    <link href="assets/css/lib/weather-icons.css" rel="stylesheet" />
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/unix.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
	   <link href="assets/css/lib/select2/select2.min.css" rel="stylesheet">
</head>

<body>

    
	
	  <?php include("sidebar.php"); ?>
	
	
    <!-- /# sidebar -->
     <?php include("top.php"); ?>
	<!-- /# topebar --> 
	
	
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-8 p-r-0 title-margin-right">
                        <div class="page-header">
                            <div class="page-title">
                                <h1>Hello, <span>Welcome Here</span></h1>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                    <div class="col-lg-4 p-l-0 title-margin-left">
                        <div class="page-header">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li>
                                    <li class="active">Home</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                </div>
                <!-- /# row -->
				<?php if ($user_type==4){ ?>
				
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Event List</div>
                                            <div class="panel-body">
						
                          
                             

								  
								  
								  	<div class="row-form clearfix">
					       <form action='event_list.php?type=<?php echo $t_type; ?>'  method='POST'> 
	
						
						   
						   
						   
                           <div class="col-sm-2">  <div class="span3"> From <input class="date" type="date" value="<?php echo $dayBookDate1; ?>" name="date1" id="datetimepicker2"/></div>  </div>
						     
                           <div class="col-sm-2"> <div class="span3"> To <input class="date" type="date"  value="<?php echo $dayBookDate2; ?>" name="date2" id="datetimepicker2"/></div>  </div>						   
                            <div class="col-sm-6">  <div class="span3"> &nbsp; </div><input class="submit" type="submit"  name="day_submit"  value="Search" />  </div>
							
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
							 
						</form>	
                     </div> 
								  
								  
								  
								  
								  
								  
								  
								  
								  
								  
								  
								  
								  
								  
								  

                                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card alert">
                               
							   
							
								
								 <div class="bootstrap-data-table-panel">
                                    <div class="table-responsive">
                                        <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
										
							
								
								
							
							   
							   
							   
							   
							   
							   
							   
							   
							   
							   
                                            <thead>
                                                <tr>
												     <th> SL</th>
                                                    <th>Date</th>
													<th>Remarks</th>
                                                    <th>Diary of</th>
                                                    <th>ID</th>
                                                  
													<th>Event</th>
													<th>Venue</th>
													<th>Time</th>
													
													<th>PR</th>
													<th>SP</th>
													<th>Photographer</th>
													
													<th>Vid Man</th>
													<th>Asst.</th>
													
													<th>MakeOver</th>
													<th>Decor</th>
													
                                                </tr>
                                            </thead>
                                            <tbody>
											
											
											<?php
                            
							$sl=0;
							
						$sqlSelectedLG = "select * from (SELECT v1.* , GROUP_CONCAT(v2.name ORDER BY v2.id) as vd_names FROM (SELECT p1.* , GROUP_CONCAT(p2.name ORDER BY p2.id) as ph_names FROM (select a1.* , a2.name as event_type from (SELECT t1.*, t2.name as client_name, t2.booking_id,t2.booking_name, t2.cell_1,t2.cell_2 FROM `events` as t1 left join bookings as t2 on t1.temp_id=t2.id order by t1.date) as a1 left join event_types as a2 on a1.type=a2.id) as p1 left join artists as p2 ON FIND_IN_SET(p2.id, p1.photographers) group by p1.id) as v1 left join artists as v2 ON FIND_IN_SET(v2.id, v1.videographers) group by v1.id ORDER BY TIMESTAMP(v1.date,v1.time) ) as evtbl where booking_id!=0 AND (date BETWEEN '$dayBookDate1' AND '$dayBookDate2' ) ORDER BY TIMESTAMP(date,time)";

						if($sub=="2")
								{$sqlSelectedLG = "select * from (SELECT v1.* , GROUP_CONCAT(v2.name ORDER BY v2.id) as vd_names FROM (SELECT p1.* , GROUP_CONCAT(p2.name ORDER BY p2.id) as ph_names FROM (select a1.* , a2.name as event_type from (SELECT t1.*, t2.name as client_name, t2.booking_id,t2.booking_name, t2.cell_1,t2.cell_2 FROM `events` as t1 left join bookings as t2 on t1.temp_id=t2.id order by t1.date) as a1 left join event_types as a2 on a1.type=a2.id) as p1 left join artists as p2 ON FIND_IN_SET(p2.id, p1.photographers) group by p1.id) as v1 left join artists as v2 ON FIND_IN_SET(v2.id, v1.videographers) group by v1.id ORDER BY TIMESTAMP(v1.date,v1.time) ) as evtbl where booking_id!=0 AND (date BETWEEN '$dayBookDate1' AND '$dayBookDate2' ) ORDER BY TIMESTAMP(date,time) ";
							
						
							
							}
						
						
						
						
						
						
						
						
$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {

                                    
                                   
                                    $idn = $list->id;
								    $date = $list->date;
									$time = $list->time;
									
									$t_color="info";
									$danger_time="16:00:00";
									
									$today=date('Y-m-d');
									
									if(strtotime($danger_time) > strtotime($time)) {$t_color="danger";}
									
									
									
									
									$eventSQL = mysqli_query($connection, "SELECT t1.* FROM `events` as t1 left join bookings as t2 on t1.temp_id=t2.id WHERE t2.booking_id!=0 AND t1.date = '$date' ORDER BY t1.time LIMIT 1");
									$eventSQL = mysqli_fetch_object($eventSQL);
									$dateid= $eventSQL->id;
									if($idn==$dateid){
										$new_date=$date;
										$new_date = date("M d, Y", strtotime($new_date));
										}
									else {
										$new_date = date("M d", strtotime($date));
										}
									
									
									
									$name = $list->client_name;
									$diary_of = $list->booking_name;
									$booking_id = $list->booking_id;
									$cell_1 = $list->cell_1;
									$cell_2 = $list->cell_2;
									$event_type = $list->event_type;
									$venue = $list->venue;
									$time=strtotime($time);
									$time=date("h.i A", $time);
								
									
									$ph_package = $list->ph_package;
									$pr = $list->pr;
									if($pr=="checked"){$pr="Yes";}
										$pr_time=$list->pr_time;
										$sp = $list->sp;
									if($sp=="checked"){$sp="Yes";}
										$sp_time=$list->sp_time;
									$photographers = $list->photographers;
									$ph_names = $list->ph_names;
									$vd_package = $list->vd_package;
									$videographers = $list->videographers;
									$vd_names = $list->vd_names;
									$no_of_ph = $list->no_of_ph;
									$no_of_vd = $list->no_of_vd;
									 $asst = $list->asst;
									 $makeover = $list->parlar;
									  $decor = $list->decor;
									 	$ev_notes = $list->ev_notes;
										
										$ph_namesArray = explode(',', $ph_names);
										$photographersArray = explode(',', $photographers);
										$vd_namesArray = explode(',', $vd_names);
										$videographersArray = explode(',', $videographers);
										$sl=$sl+1;
									
                                ?>
											
											
											
											
                                                <tr>
												
												<form method="POST">
                                                    <td> <?php echo $sl;  ?> 
													
													  
													 
													
													
													
													
													
													
													
													</td>
													 <td><?php echo $new_date;  ?></td>
													  <td>
													
													   <?php echo $ev_notes;  ?>
													   
													
													  
													  
													  </td>
                                                   <td><?php echo $diary_of;  ?></td>
                                                    <td><?php echo $booking_id;  ?></td>
                                                 
													 <td><?php echo $event_type;  ?></td>
													 <td><?php echo $venue;  ?></td>
												 <td><span class="badge badge-<?php echo $t_color;  ?>"><?php echo $time;  ?></span> </td>
													
												 <td><?php echo $pr;  ?> <?php echo $pr_time;  ?></td>
												  <td><?php echo $sp;  ?> <?php echo $sp_time;  ?></td>
													 <td>
													 
													
													   <?php echo $ph_names;  ?>
													  ( <?php echo $no_of_ph.'ph'; ?>  )
													 
													 
													 
													 
													 
													 
													 
													</td>
												
													 <td>
													 
													 
													 
													  
													   <?php echo $vd_names;  ?>
													     ( <?php echo $no_of_vd.'vd'; ?>  )
													 
													 
													  
													 
													 </td>
													 <td>
													
													   <?php echo $asst;  ?>
													   
													
													 
													  
													  
													  
													  </td>
												 <td><?php echo $makeover;  ?></td>
												 	 <td><?php echo $decor;  ?></td>
													
												
</form>												
                                                </tr>
                                                
												 <?php } ?>		
												 
												 
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <!-- /# card -->
                        </div>
                        <!-- /# column -->
                    </div>

                                   


							 </div> </div>
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                   
				   
				   
				           <?php include("footer.php"); ?>
						   
						   
                </section>
				
				<?php } ?>
				
            </div>
        </div>
    </div>

   <div id="search">
        <button type="button" class="close">×</button>
        <form action="search.php">
            <input type="search" name="search" value="" placeholder="type keyword(s) here" />
            <button type="submit" class="btn btn-primary">Search</button>
        </form>
    </div>


    </div>
    <script src="assets/js/lib/jquery.min.js"></script>
    <!-- jquery vendor -->
    <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>
    <!-- nano scroller -->
    <script src="assets/js/lib/menubar/sidebar.js"></script>
    <script src="assets/js/lib/preloader/pace.min.js"></script>
    <!-- sidebar -->
    <script src="assets/js/lib/bootstrap.min.js"></script>
    <!-- bootstrap -->
   
    <script src="assets/js/scripts.js"></script>
	
	 <script src="assets/js/lib/data-table/datatables.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.dataTables.min.js"></script>
    <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.flash.min.js"></script>
    <script src="assets/js/lib/data-table/jszip.min.js"></script>
    <script src="assets/js/lib/data-table/pdfmake.min.js"></script>
    <script src="assets/js/lib/data-table/vfs_fonts.js"></script>
    <script src="assets/js/lib/data-table/buttons.html5.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.print.min.js"></script>
    <script src="assets/js/lib/data-table/datatables-init.js"></script>
	
	<script>
        $(document).ready(function() {
            $('.select2').select2();
        });
    </script>

		 <script src="assets/js/lib/select2/select2.full.min.js"></script>
		 
		 
</body>

</html>