<?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'];

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


$dayBookDate1=date('Y-m-01', strtotime($dayBookDate1. ' - 1 years'));

if($_SESSION['DATEs1']==""){
	$_SESSION['DATEs1']=$dayBookDate1;
    $_SESSION['DATEs2']=$dayBookDate2;
}


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

$dayBookDate1=$_SESSION['DATEs1'];
$dayBookDate2=$_SESSION['DATEs2'];

?>



<!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>Assignments</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">
</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 -->
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Assignments</div>
                                            <div class="panel-body">
						
								

								   
								  
								  
								
								  
								  
								  
								  
								  
								  
								  
                                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card alert">
							
							
							
							
							
							
							
							
							
							
							
                               
								
								
								
								
								
								
								
								
								
						<?php if ($user_type==4 ){  ?>
								
								
									
								
								<div class="row-form clearfix">
					       <form action='assignments_list.php?type=export'  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>
							 <div class="col-sm-2">  <div class="span3"> <a href="assignments.php"> <span class="badge badge-danger">Reload</span>  <a href="assignments.php?type=export"> <span class="badge badge-primary">exportable</span>  </a></div>  </div>
							 
						</form>	
                     </div> 
								
								
							</br>	
								
								
								<?php if($t_type=="export") { ?>
								
								 <div class="bootstrap-data-table-panel">
                                    <div class="table-responsive">
                                        <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
										
								<?php } ?>	
								
								
								<?php if($t_type!="export") { ?>
								
								<div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-bordered">
										
								<?php } ?>	
										
                                            <thead>
                                                <tr>
												 <th>SL</th>
												  <th>Diary of</th>
												 <th>Event Name</th>
												<th>Booking ID</th>
												
												<th>Program Date</th>
												
												<th>P.Editor</th>
                                                <th>P.HDD No</th>
												<th>V.HDD No</th>
                                                <th>RG Edit</th>
												<th>RG Status</th>
												<th>SP Editor</th>
                                                <th>SP Edit</th>
												<th>SP Status</th>
												<th>Photo Remarks</th>
												
												<th>PG Names</th>
												
												<th>V.Editor</th>
                                                
												<th>VD Status</th>
												<th>Video Remarks</th>
												
												<th>VG Names</th>
												<th>Songs</th>
												
													
													
                                                </tr>
                                            </thead>
                                            <tbody>
											
											<?php
$sl=0;
						
						
						$sqlSelectedLG = "select q1.*,q2.name as ph_editor_name,q3.name as vd_editor_name,q4.name as sp_editor_name from (select h1.* ,h2.editor as ph_editor,h2.sp_editor,h2.ph_sp_status, h2.date as ph_date, h2.hdd as ph_hdd, h2.rg_edit as ph_rg_edit, h2.sp_edit as ph_sp_edit, h2.remarks as ph_remarks, h2.status as ph_status,h3.editor as vd_editor, h3.date as vd_date, h3.hdd as vd_hdd, h3.remarks as vd_remarks, h3.status as vd_status 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_name, t2.booking_id, t2.cell_1,t2.cell_2,t2.status as booking_status 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 h1 left join photo_edit as h2 on h1.id=h2.event_id left join vd_edit as h3 on h1.id=h3.event_id) as q1 left join users as q2 on q1.ph_editor=q2.id left join users as q3 on  q1.vd_editor=q3.id left join users as q4 on q1.sp_editor=q4.id where q1.booking_status=1 AND (q1.date BETWEEN '$dayBookDate1' AND '$dayBookDate2') order by q1.date DESC limit 200";
						
						if($sub=="2")
								{$sqlSelectedLG = "select q1.*,q2.name as ph_editor_name,q3.name as vd_editor_name,q4.name as sp_editor_name from (select h1.* ,h2.editor as ph_editor,h2.sp_editor,h2.ph_sp_status, h2.date as ph_date, h2.hdd as ph_hdd, h2.rg_edit as ph_rg_edit, h2.sp_edit as ph_sp_edit, h2.remarks as ph_remarks, h2.status as ph_status,h3.editor as vd_editor, h3.date as vd_date, h3.hdd as vd_hdd, h3.remarks as vd_remarks, h3.status as vd_status 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_name, t2.booking_id, t2.cell_1,t2.cell_2,t2.status as booking_status 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 h1 left join photo_edit as h2 on h1.id=h2.event_id left join vd_edit as h3 on h1.id=h3.event_id) as q1 left join users as q2 on q1.ph_editor=q2.id left join users as q3 on  q1.vd_editor=q3.id left join users as q4 on q1.sp_editor=q4.id where q1.booking_status=1 AND (q1.date BETWEEN '$dayBookDate1' AND '$dayBookDate2') order by q1.date DESC ";}

$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {

$ev_id = $list->id;


                                    $diary_of = $list->booking_name;
                                    $temp_id = $list->temp_id;
									$booking_id = $list->booking_id;
                                    $cell_1 = $list->cell_1;
									$event_type = $list->event_type;
									$date = $list->date;
									$date = date("d.m.y", strtotime($date));
									$ph_date = $list->ph_date;
                                    $ph_editor_name = $list->ph_editor_name;
									$ph_editor = $list->ph_editor;
									$ph_sp_editor = $list->sp_editor;
									$ph_sp_editor_name = $list->sp_editor_name;
									$ph_hdd = $list->ph_hdd;
									$ph_rg_edit = $list->ph_rg_edit;
									$ph_sp_edit = $list->ph_sp_edit;
									$ph_remarks = $list->ph_remarks;
									$ph_names = $list->ph_names;
									$ph_status = $list->ph_status;
									$ph_sp_status = $list->ph_sp_status;
									$vd_date = $list->vd_date;
                                    $vd_editor_name = $list->vd_editor_name;
									$vd_editor = $list->vd_editor;
									$vd_hdd = $list->vd_hdd;
									$vd_remarks = $list->vd_remarks;
									$vd_names = $list->vd_names;
									$vd_status = $list->vd_status;
									$videoincluded = $list->videoincluded;
									$state = $list->state;
									
									$eventCT = mysqli_query($connection, "SELECT count(id) e_total FROM `events` WHERE `temp_id` = '$temp_id' ");
									$eventCT = mysqli_fetch_object($eventCT);
									$eventCT= $eventCT->e_total;
									
									if($eventCT==1){$star="&#9733;";}
									if($eventCT==2){$star="&#9733;&#9733;";}
									if($eventCT==3){$star="&#9733;&#9733;&#9733;";}
									if($eventCT==4){$star="&#9733;&#9733;&#9733;&#9733;";}
									if($eventCT==5){$star="&#9733;&#9733;&#9733;&#9733;&#9733;";}
									if($eventCT==6){$star="&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;";}
									if($eventCT==7){$star="&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;";}
									if($eventCT==8){$star="&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;";}
									if($eventCT==9){$star="&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;";}
									if($eventCT==10){$star="&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;&#9733;";}
									
									
									
									
									
									
									
									$ph_color="red";
									$sp_color="red";
									$vd_color="red";
									
									if($ph_status=="checked"){$ph_color='yellow';}
									if($ph_sp_status=="checked"){$sp_color='yellow';}
									if($vd_status=="checked"){$vd_color='yellow';}
									
									if($videoincluded=="checked" AND $state=="12") {
										$ph_color='green';
										$sp_color='green';
										$vd_color='green';
									}
									
									if($videoincluded!="checked"){
										$vd_color='white';
									}
									
									
									if($videoincluded!="checked" AND $state=="6") {
										$ph_color='green';
										$sp_color='green';
										$vd_color='green';
									}
									
									
									
									
									
									
										$sl=$sl+1;
								
                                    
                                   
                                ?>
											
											
											
										
                                                <tr>
												
												
												
												<td><?php echo $sl;  ?> 
												</td>
												  <td> <span class="badge badge-info"> <?php echo $diary_of;  ?> </span> <?php echo " ".$star; ?></td>
												
												  <td> <span class="badge badge-danger"> <?php echo $event_type;  ?> </span> </td>
											<td><a href="booking_details.php?id=<?php echo $temp_id;  ?>" target="_blank"> <?php echo $booking_id;  ?></a></td>
											
												<td> <?php echo $date;  ?></td>
											
												<td> <?php echo $ph_editor_name;  ?> </td>
												<td> <?php echo $ph_hdd;  ?>  </td>
												<td> 
												<?php if($videoincluded=="checked") { ?>
										<?php echo $vd_hdd;  ?> 
							<?php		} ?>
												
												
												</td>
                                                <td bgcolor="<?php echo $ph_color; ?>"><?php echo $ph_rg_edit;  ?></td>
													<td bgcolor="<?php echo $ph_color; ?>">

													<input type='checkbox' <?php echo $ph_status; ?> name='ph_status' value='checked'>		

													</td>
												<td>  <?php echo $ph_sp_editor_name;  ?> </td>
												
                                                <td bgcolor="<?php echo $sp_color; ?>"> <?php echo $ph_sp_edit;  ?></td>
													<td bgcolor="<?php echo $sp_color; ?>">

													<input type='checkbox' <?php echo $ph_sp_status; ?> name='ph_sp_status' value='checked'>

													</td>
                                                <td> <?php echo $ph_remarks;  ?> </td>
												
											
												
												
												
												
												
												<td> <?php echo $ph_names;  ?></td>
												
												<td> 
												<?php if($videoincluded=="checked") { ?>
									<?php echo $vd_editor_name;  ?> 
														
							   <?php } ?>
												
												
											
							
												
												
												</td>
												
                                                
												
												<td bgcolor="<?php echo $vd_color; ?>">
										<?php if($videoincluded=="checked") { ?>
											<input type='checkbox' <?php echo $vd_status; ?> name='vd_status' value='checked'>	
							<?php		} ?>
											

												</td>
												<td > 
												<?php if($videoincluded=="checked") { ?>
											<?php echo $vd_remarks;  ?>
							<?php		} ?>
												
											
												
												
												</td>
												
												<td>
<?php if($videoincluded=="checked") { ?>
										<?php echo $vd_names;  ?>
							<?php		} ?>

												
												
												
												</td>
												<td> <a href="event_print.php?id=<?php echo $ev_id;  ?>" target="_blank"> <button class="info" type="button"> <i class="ti-printer"></i> </button> </a></td>
												
												
														
													
													
													
                                                </tr>
                                              
												
<?php } ?>			
												
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
								
								
								
		
												
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
					
					
					<?php } ?>
								
								
								
                            </div>
                            <!-- /# card -->
                        </div>
                        <!-- /# column -->
                    </div>

                                   


							 </div> </div>
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                     <?php include("footer.php"); ?>
                </section>
            </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>



</body>

</html>