<?php
	if(($this->session->userdata('sv_room_booking_filter_month') && $this->session->userdata('sv_room_booking_filter_month') != 'no result')){
		if($this->session->userdata('sv_room_booking_filter_month') == '01'){
	         $month = "JANUARY";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '02'){
	         $month = "FEBRUARY";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '03'){
	         $month = "MARCH";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '04'){
	         $month = "APRIL";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '05'){
	         $month = "MAY";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '06'){
	         $month = "JUNE";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '07'){
	         $month = "JULY";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '08'){
	         $month = "AUGUST";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '09'){
	         $month = "SEPTEMBER";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '10'){
	         $month = "OCTOBER";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '11'){
	         $month = "NOVEMBER";
	    }else if($this->session->userdata('sv_room_booking_filter_month') == '12'){
	         $month = "DECEMBER";
        }else if($this->session->userdata('sv_room_booking_filter_month') == 'ALL'){
	         $month = "ALL";
	    }else  $month = "Unknown";
	}
?>

<header>
	<div class="row">
		<div class="col-12">
			<div class="t-corp pull-left">
				<div class="t-corp-logo">
					<img src="<?php echo base_url().'assets/images/logo/salihin-logo.png'; ?>" alt="company logo" />
				</div>
				<div class="t-corp-name"><b>SPS</b> | HR SYSTEM</div>
			</div>
			<div class="report-title pull-right" style="padding-top: 30px;">
				<h5><?php echo (isset($title) ? $title : 'Report'); ?></h5>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<table class="company">
				<tr>
					<td class="divider">
						<span class="line">&nbsp;</span>
					</td>
					<td class="details">
						<span><b>SALIHIN (AF 1426)</b></span>
						<span>555, Jalan Samudra Utara 1, Taman Samudra, Batu Caves,</span>
						<span>68100, Batu Caves, Selangor</span>
						<span>Phone: 03-6185 9970 &nbsp;&nbsp; Fax: 03-6185 9970</span>
						<span>Website: salihin.com.my</span>
					</td>
					<?php if(!empty($ID)) { ?>
						<td class="divider">
							<span class="line">&nbsp;</span>
						</td>
					<?php } else { ?>
						<td class="divider">
							<span class="line">&nbsp;</span>
							<table>
								<tr>
									<td><span><b>DEPARTMENT</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<?php if(!empty($this->session->userdata('sv_room_booking_filter_dept')) && $this->session->userdata('sv_room_booking_filter_dept') != 'ALL'){ ?>
										<td><span><b style="padding-left: 1rem;"><?php echo $department['name'].' ['.$department['branch_name'].']'; ?></b></span></td>
									<?php } else {?>
										<?php if($_SESSION['module_data']['role']=='admin'){ ?>
											<td><span><b style="padding-left: 1rem;">ALL</b></span></td>
										<?php } else{ ?>
											<td><span><b style="padding-left: 1rem;"><?php echo $_SESSION['user']['department_name'].' ['.$_SESSION['user']['branch_name'].']'; ?></b></span></td>
										<?php } ?>
									<?php } ?>
								</tr>
								<tr>
									<td><span><b>ROOM</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_room_booking_filter_room')))?($this->session->userdata('sv_room_booking_filter_room')):'ALL'; ?></b></span></td>
								</tr>
								<tr>
									<td><span><b>STATUS</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_room_booking_filter_status')))?(str_replace('_',' ',$this->session->userdata('sv_room_booking_filter_status'))):'ALL'; ?></b></span></td>
								</tr>
								<tr>
									<td><span><b>YEAR</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_room_booking_filter_year')))?($this->session->userdata('sv_room_booking_filter_year')):'ALL'; ?></b></span></td>
								</tr>
								<tr>
									<td><span><b>MONTH</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_room_booking_filter_month')))?($this->session->userdata('sv_room_booking_filter_month')):'ALL'; ?></b></span></td>
								</tr>
							</table>
						</td>
					<?php } ?>
				</tr>
			</table>
		</div>
	</div>
</header>

<?php if(!empty($ID)){ ?>
<div class="container">
	<div class="col-12" style="margin-top:2rem">
		<div class="row">
			<div class="col">
				<h3><b>DETAIL OF MEETING & TRAINING BOOKING</b></h3>
			</div>
		</div>
		<div class="row">
			<div class="col">
				<p style="border-top: 3px solid; width: 50rem;"></p><br>
			</div>
		</div>
		<div class="row">
			<div class="col-1" >
			</div>
			<div class="col d-flex">
				<div class="align-self-end w-100">
					<div class="row">
						<div class="col-4">
							<b>STAFF NAME</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['name']))?$booking_room[0]['name']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>STAFF ID</b>
						</div>
						<div class="col">
							<p class="report-font">:
								<?php echo (!empty($booking_room[0]['staff_id']))?strtoupper($booking_room[0]['staff_id']):'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>DEPARTMENT</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['dept_name']))?$booking_room[0]['dept_name'].'/'.$booking_room[0]['branchName']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>DATE REQUEST</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['createdTS']))?date('d-m-Y',strtotime($booking_room[0]['createdTS'])):'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>MEETING ROOM</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo ($booking_room[0]['room_id'] == 7)?$booking_room[0]['other_room']:$booking_room[0]['room']; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>NO. OF PAX</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['pax']))?$booking_room[0]['pax']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>TABLE SETUP</b>
						</div>
						<div class="col">
							<p class="report-font">:
								<?php echo (!empty($booking_room[0]['table_setup'])&&$booking_room[0]['table_setup']!="-- Please Select --")?$booking_room[0]['table_setup']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>EQUIPMENT</b>
						</div>
						<div class="col">
	                            <?php if(!empty($booking_room[0]['equipment'])) { 
	                                $equipment = explode(',',$booking_room[0]['equipment']);
	                            	for($a = 0; $a < sizeof($equipment); $a++)
	                            	{
	                            		if($equipment > 0){
	                            			echo '<p class="report-font">: '.$equipment[$a].'</p>';
	                            		}
	                            	}
	                            } else{
	                            	echo '<p class="report-font">: N/A</p>';
	                            }?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>EVENT TITLE</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['event_title']))?$booking_room[0]['event_title']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>CLIENT</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['client']))?$booking_room[0]['client']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>DATE AND TIME START</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['start_date'] && $booking_room[0]['start_time']))?date('d-m-Y',strtotime($booking_room[0]['start_date'])).' / '.$booking_room[0]['start_time']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>DATE AND TIME END</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['end_date'] && $booking_room[0]['end_time']))?date('d-m-Y',strtotime($booking_room[0]['end_date'])).' / '.$booking_room[0]['end_time']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>PACKAGE</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['package']) && $booking_room[0]['package'] != '-- Please Select --')?$booking_room[0]['package']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>BREAKFAST MENU</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['breakfast']) && $booking_room[0]['breakfast'] != '-- Please Select --')?$booking_room[0]['breakfast']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>LUNCH MENU</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php
								if(!empty($booking_room[0]['lunch'] || $booking_room[0]['other_menu']) && $booking_room[0]['lunch'] != '-- Please Select --')
								{
									echo (!empty($booking_room[0]['other_menu']))?$booking_room[0]['other_menu']:$booking_room[0]['lunch'];
								}else
								{
									echo 'N/A';
								}
								?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>HI-TEA MENU</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['hi_tea']) && $booking_room[0]['hi_tea'] != '-- Please Select --')?$booking_room[0]['hi_tea']:'N/A'; ?>
							</p>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<b>SPECIAL REQUEST</b>
						</div>
						<div class="col">
							<p class="report-font">: 
								<?php echo (!empty($booking_room[0]['special_request']))?$booking_room[0]['special_request']:'N/A'; ?>
							</p>
						</div>
					</div>
                    
                    <div class="row">
							<div class="col-4">
								<b>STATUS</b>
							</div>
							<div class="col">
								<p class="report-font">: <?php //debug($rsCarBookingList);?>
                                    <?php echo ($booking_room[0]['status_app']==null || $booking_room[0]['status_app']=='Pending' )?'Pending ':str_replace('_',' ',$booking_room[0]['status_app']); ?>
								</p>
							</div>
						</div>

				</div>
			</div>
		</div>
	</div>
</div>

<?php echo $approval; ?>

<?php } else { ?>

	<div class="col-12 table-responsive " style="margin-top:2rem">
		<table class="table table-bordered" width="100%" border="1">
			<thead>
				<th class="sorting border-top text-center" tabindex="0" aria-controls="table_booking_list" rowspan="1" colspan="1" aria-label="#: activate to sort column ascending" width="1%">
					#
                </th>
                <th class="sorting border-top text-center" width="10%">
                    Packages
                </th>
                <th class="sorting border-top text-center" width="8%">
                    Meeting Room
                </th>
                <th class="sorting border-top text-center" width="8%">
                    Equipment
                </th>
                <th class="sorting border-top text-center" width="12%">
                    Event
                </th>
                <th class="sorting border-top text-center" width="15%">
                    Meal
                </th>
                <th class="sorting border-top text-center" width="6%">
                    Date and Time Start 
                </th>
                <th class="sorting border-top text-center" width="6%">
                    Date and Time End
                </th>  
                <th class="sorting border-top text-center" width= "6%">
                    Status
                </th>   
			</thead>	

			<tbody id="print_booking_room">
				<?php if(!empty($booking_room) && is_array($booking_room)) { foreach($booking_room as $key => $row){ ?>
					<tr>
                        <td class="text-center"><?php echo $key+1; ?></td>
                        <td><?php echo $row['package']; ?></td>
                        <td>
                        	<?php 
                                if(!empty($row['other_room']))
                                {
                                    echo $row['other_room'];
                                }else{
                                    echo $row['room'];
                                }

                                if($row['pax'] > 0)
                                {
                                    echo '<br>('.$row['pax'].' pax)';
                                }else{
                                    echo '';
                                }

                                if(!empty($row['table_setup']) && $row['table_setup'] != "-- Please Select --")
                                {
                                    echo '<br>['.$row['table_setup'].']';
                                }else{
                                    echo '';
                                }
                            ?>
                        </td>
                        <td>
                        	<?php if(!empty($row['equipment']))
                            {
                                $equipment = explode(',',$row['equipment']);

                                foreach($equipment as $eqpt) {
                                    echo '<li>'.$eqpt.'</li>'; 
                                }

                            } else {
                                echo 'N/A';
                            } ?>
                        </td>
                        <td>
                        	<div class="row">
								<div class="col-2">
									Title
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php echo (!empty($row['event_title']))?$row['event_title']:'N/A'; ?>
									</p>
								</div>
							</div>
							<div class="row">
								<div class="col-2">
									Host
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php echo (!empty($row['dept_name']))?$row['dept_name'].'/'.$row['branchName']:'N/A'; ?>
									</p>
								</div>
							</div>
							<div class="row">
								<div class="col-2">
									Client
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php echo (!empty($row['client']))?$row['client']:'N/A'; ?>
									</p>
								</div>
							</div>
                        </td>
                        <td>
                        	<div class="row">
								<div class="col-3">
									Breakfast
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php echo (!empty($row['breakfast']) && $row['breakfast'] != '-- Please Select --')?$row['breakfast']:'N/A'; ?>
									</p>
								</div>
							</div>
							<div class="row">
								<div class="col-3">
									Lunch
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php
										if(!empty($row['lunch'] || $row['other_menu']) && ($row['lunch'] != '-- Please Select --'))
										{
											echo (!empty($row['other_menu']))?$row['other_menu']:$row['lunch']; 
										}else{
											echo 'N/A'; 
										}
										?>
									</p>
								</div>
							</div>
							<div class="row">
								<div class="col-3">
									Hi-Tea
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php echo (!empty($row['hi_tea']) && $row['hi_tea'] != '-- Please Select --')?$row['hi_tea']:'N/A'; ?>
									</p>
								</div>
							</div>
							<div class="row">
								<div class="col-3">
									Special Request
								</div>
								<div class="col">
									<p class="report-font">: 
										<?php echo (!empty($row['special_request']))?$row['special_request']:'N/A'; ?>
									</p>
								</div>
							</div>
                        </td>
                        <td class="text-center">
                            <?php echo date ('d-m-Y',strtotime($row['start_date'])) . '<br> (' . $row['start_time'].')'; ?>
                        </td>
                        <td class="text-center">
                            <?php echo date('d-m-Y',strtotime($row['end_date'])) . '<br> (' . $row['end_time'].')'; ?>
                        </td>
                        <td class="text-center">
                            <?php echo ($row['status_app']==null || $row['status_app']=='Pending' )?'Pending':str_replace('_',' ',$row['status_app']); ?>
                        </td>
					</tr>

				<?php } } ?>
			</tbody>	
		</table>	
	</div>
<?php } ?>