<style>
	@media print 
	{
		.break{ 
			page-break-before: always;
		}
	}
</style>

<section class="container">

	<div class="row">
		<div class="col-4 mx-auto py-5 text-center">
			<img src="<?php echo base_url('assets/images/logo/salihin-logo.png'); ?>" class="img img-fluid">
			<h5 class="text-uppercase mt-3"><b><?php echo (!empty($submission_business_entity))?$submission_business_entity:''; ?> claim <?php echo (!empty($submission_month))?$submission_month:''; ?></b></h5>
		</div>
	</div>

	<div class="row">
		<div class="col-12 mb-5">

			<table class="table table-bordered bg-white">
				<thead>
					<tr>
						<th rowspan="3" class="border-top">NO</th>
						<th rowspan="3" class="border-top">Name</th>
						<th rowspan="3" class="border-top">Overtime</th>
						<th colspan="3" class="border-top">Allowance</th>
						<th colspan="7" class="border-top">Other</th>
					</tr>
					<tr>
						<th rowspan="2">Mileage</th>
						<th rowspan="2">Meal All.</th>
						<th rowspan="2">Outstation All.</th>

						<th rowspan="2">SSM</th>
						<th rowspan="2">Oath</th>
						<th rowspan="2">Medical</th>
						<th rowspan="2">Dental/Optical</th>
						<th rowspan="2">Courier/Postage</th>
						<th rowspan="2">Printing Stationary</th>
						<th rowspan="2">Motor Vehicle</th>
					</tr>
				
				</thead>
				<tbody>
					<?php 
						$counter = 0;
						$total_overtime = 0;
						$total_mileage = 0;
						$total_meal_allowance = 0;
						$total_outstation_allowance = 0;
						$total_ssm = 0;
						$total_oath = 0;
						$total_medical = 0;
						$total_dental_optical = 0;
						$total_courier = 0;
						$total_printing_stationary = 0;
						$total_motor_vehicle = 0;						
					?>
					<?php if(!empty($reports)):foreach($reports as $key => $report): ?>
						
						<tr>
							<td><?php echo ++$counter; ?></td>
							<td><?php echo $report['name']?></td>
							<td>
								<?php 
									echo $report['overtime']; 
									$total_overtime += $report['overtime']; 
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['mileage_approved'])) ? $report['mileage_approved'] : '0.00';
									$total_mileage += $report['mileage_approved']; 
								?>
							</td>
							<td>
								<?php 
									echo number_format($report['meals_approved']+$report['subsistence_meals'],2);
									$total_meal_allowance += number_format($report['meals_approved']+$report['subsistence_meals'],2);
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['subsistence_outstation'])) ? $report['subsistence_outstation'] : '0.00';  
									$total_outstation_allowance += $report['subsistence_outstation']; 
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['others_ssm_search'])) ? $report['others_ssm_search'] : '0.00';
									$total_ssm += $report['others_ssm_search']; 
								?>
							</td>
							<td>
								<?php
									echo (!empty($report['other_stamping'])) ? $report['other_stamping'] : '0.00';
									$total_oath += $report['other_stamping']; 
								?>
							</td>
							<td>
								<?php 
									echo number_format($report['hospitalization_approved'] + $report['outpatient_approved']  + $report['medical_screening_approved'],2); 
									$total_medical += number_format($report['hospitalization_approved'] + $report['outpatient_approved'] + $report['medical_screening_approved'],2);
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['dental_approved'])) ? $report['dental_approved'] : '0.00';
									$total_dental_optical += $report['dental_approved']; 
								?>
							</td>
							<td>
								<?php
									echo (!empty($report['other_courier'])) ? $report['other_courier'] : '0.00'; 
									$total_courier += $report['other_courier'];
								?>
							</td>
							<td>
								<?php 
									echo number_format($report['other_stationary']+$report['other_printing'],2);
									$total_printing_stationary += number_format($report['other_stationary']+$report['other_printing'],2);
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['others_motor_expenses'])) ? $report['others_motor_expenses'] : '0.00';
									$total_motor_vehicle += $report['others_motor_expenses'];
								?>
							</td>
						</tr>

					<?php endforeach;endif; ?>
				
					<?php if(!empty($otlist)):foreach($otlist as $index => $ot): ?>
						<tr>
							<td><?php echo ++$counter; ?></td>
							<td><?php echo $ot['name']; ?></td>
							<td>
								<?php 
									echo $ot['totalClaim']; 
									$total_overtime += $ot['totalClaim'];      
								?>
							</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
						</tr>
					<?php endforeach;endif;?>

				</tbody>
				<tfoot>
					<tr>
						<td class="text-right" colspan="2"><strong>TOTAL</strong></td>
						<td><?php echo number_format($total_overtime,2); ?></td>
						<td><?php echo number_format($total_mileage,2); ?></td>
						<td><?php echo number_format($total_meal_allowance,2); ?></td>
						<td><?php echo number_format($total_outstation_allowance,2); ?></td>
						<td><?php echo number_format($total_ssm,2); ?></td>
						<td><?php echo number_format($total_oath,2); ?></td>
						<td><?php echo number_format($total_medical,2); ?></td>
						<td><?php echo number_format($total_dental_optical,2); ?></td>
						<td><?php echo number_format($total_courier,2); ?></td>
						<td><?php echo number_format($total_printing_stationary,2); ?></td>
						<td><?php echo number_format($total_motor_vehicle,2); ?></td>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
		
	<!-- <div class="row">
		<div class="col-4">
			<strong>PREPARED BY : </strong>
		</div>
		<div class="col-4">
			<strong>VERIFIED BY:</strong>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			SHAFIANA MOHAMED SALLEH
		</div>
		<div class="col-4">
			<strong>APPROVED BY:</strong>
		</div>
	</div> -->









	<div class="row break">
		<div class="col-12 mb-5">
			<table class="table table-bordered bg-white">
				<thead>
					<tr>
						<th rowspan="3" class="border-top">NO</th>
						<th rowspan="3" class="border-top">Name</th>
						<th colspan="6" class="border-top">Travelling, Lodging, Accomodation</th>
						<th rowspan="3" class="border-top">Entertainment / Refreshment</th>
						<th rowspan="3" class="border-top">Membership</th>
						<th rowspan="3" class="border-top">Training Allowance</th>
						<th rowspan="3" class="border-top">Total</th>

					</tr>
					<tr>
						<th rowspan="2">Toll</th>
						<th rowspan="2">Petrol</th>
						<th rowspan="2">Parking</th>
						<th rowspan="2">Grab/Uber/LRT/KLIA Express</th>
						<th rowspan="2">Flight</th>
						<th rowspan="2">Hotel/Accomodation</th>
					</tr>
					<!-- <tr>
						<th>Staff</th>
						<th>Client</th>
					</tr> -->
					
				</thead>
				<tbody>
					<?php 
					
						$counter = 0;
						$total_toll = 0;
						$total_petrol = 0;
						$total_parking = 0;
						$total_ehailing = 0;
						$total_flight = 0;
						$total_accomodation = 0;
						$total_entertainment_staff = 0;
						$total_entertainment_client = 0;
						$total_entertainment = 0;
						$total_membership = 0;
						$total_training_allowance = 0;
						
					?>
					<?php if(!empty($reports)):foreach($reports as $key => $report): ?>
						
						<tr>
							<td><?php echo ++$counter; ?></td>
							<td><?php echo $report['name']?></td>
							<td>
								<?php 
									echo number_format($report['toll_claim_approved']+$report['others_tng'],2); 
									$total_toll += number_format($report['toll_claim_approved']+$report['others_tng'],2); 
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['petrol_claim_approved'])) ? $report['petrol_claim_approved'] : '0.00'; 
									$total_petrol += $report['petrol_claim_approved']; 
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['parking_claim_approved'])) ? $report['parking_claim_approved'] : '0.00'; 
									$total_parking += $report['parking_claim_approved']; 
								?>
							</td>
							<td>
								<?php 
									echo number_format($report['transportation_e_hailing_approved']+$report['transportation_car_rental_approved']+$report['transportation_public_transport_approved']+$report['transportation_trains_approved'],2); 
									$total_ehailing += number_format($report['transportation_e_hailing_approved']+$report['transportation_car_rental_approved']+$report['transportation_public_transport_approved']+$report['transportation_trains_approved'],2); 
								?>
							</td>
							<td>
								<?php 
									echo number_format($report['transportation_flight_approved']+$report['others_airport_taxes']+$report['others_service_taxes']+$report['others_excess_baggage'],2); 
									$total_flight += number_format($report['transportation_flight_approved']+$report['others_airport_taxes']+$report['others_service_taxes']+$report['others_excess_baggage'],2); 
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['accomodation_claim_approved'])) ? $report['accomodation_claim_approved'] : '0.00';
									$total_accomodation += $report['accomodation_claim_approved'];
								?>
							</td>
							<td>
								<?php
                                    echo number_format($report['entertainment_claim_staff']+$report['entertainment_claim_client'],2); 
                                    $total_entertainment += number_format($report['entertainment_claim_staff']+$report['entertainment_claim_client'],2);
                                ?>
							</td>
							<td>
								<?php 
									echo number_format($report['other_membership']+$report['other_license'],2); 
									$total_membership += number_format($report['other_membership']+$report['other_license'],2); 
								?>
							</td>
							<td>
								<?php 
									echo (!empty($report['trainer_claim_approved'])) ? $report['trainer_claim_approved'] : '0.00'; 
									$total_training_allowance += $report['trainer_claim_approved']; 
								?>
							</td>
							<td>
								<?php
									$total_claim =  $report['overtime'] 
                                    +  $report['mileage_approved']
                                    +  $report['meals_approved']
                                    +  $report['subsistence_meals']  
                                    +  $report['subsistence_outstation']
                                    +  $report['petrol_claim_approved']
                                    +  $report['others_tng']
                                    +  $report['toll_claim_approved']
                                    +  $report['hospitalization_approved'] 
                                    +  $report['outpatient_approved'] 
                                    +  $report['dental_approved']
                                    +  $report['parking_claim_approved'] 
                                    +  $report['medical_screening_approved']  
                                    +  $report['trainer_claim_approved']
                                    +  $report['other_license']
                                    +  $report['other_membership']
                                    +  $report['other_printing']
                                    +  $report['accomodation_claim_approved']
                                    +  $report['transportation_car_rental_approved']
                                    +  $report['transportation_flight_approved']
                                    +  $report['transportation_public_transport_approved']
                                    +  $report['transportation_e_hailing_approved']
                                    +  $report['transportation_trains_approved']
                                    // +  $report['other_book']
                                    // +  $report['others_purchase']
                                    // +  $report['others_call']
                                    +  $report['others_airport_taxes']
                                    +  $report['others_service_taxes']
                                    // +  $report['others_tips_and_portage']
                                    // +  $report['others_laundry']
                                    +  $report['others_excess_baggage']
                                    // +  $report['others_loss_in_foreign_exchange']
                                    // +  $report['others_firm_Event']
                                    +  $report['others_motor_expenses']
                                    +  $report['others_ssm_search']
                                    +  $report['other_stationary']
                                    +  $report['other_stamping']
                                    +  $report['other_courier']
                                    +  $report['entertainment_claim_staff']
                                    +  $report['entertainment_claim_client'];

									echo number_format($total_claim,2);
								?>
							</td>
						</tr>

					<?php endforeach;endif; ?>
				
					<?php if(!empty($otlist)):foreach($otlist as $index => $ot): ?>
						<tr>
							<td><?php echo ++$counter; ?></td>
							<td><?php echo $ot['name']; ?></td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td>0.00</td>
							<td><?php echo $ot['totalClaim']; ?></td>
						</tr>
					<?php endforeach;endif;?>

				</tbody>
				<tfoot>
					<tr>
						<td class="text-right" colspan="2"><strong>TOTAL</strong></td>
						<td><?php echo number_format($total_toll,2); ?></td>
						<td><?php echo number_format($total_petrol,2); ?></td>
						<td><?php echo number_format($total_parking,2); ?></td>
						<td><?php echo number_format($total_ehailing,2); ?></td>
						<td><?php echo number_format($total_flight,2); ?></td>
						<td><?php echo number_format($total_accomodation,2); ?></td>
						<td><?php echo number_format($total_entertainment,2); ?></td>
						<td><?php echo number_format($total_membership,2); ?></td>
						<td><?php echo number_format($total_training_allowance,2); ?></td>
						<td>
							<?php
								echo number_format(
                                    $total_overtime
                                    + $total_mileage
                                    + $total_meal_allowance
                                    + $total_outstation_allowance
                                    + $total_ssm
                                    + $total_oath
                                    + $total_medical
                                    + $total_dental_optical
                                    + $total_courier
                                    + $total_printing_stationary
                                    + $total_motor_vehicle
                                    + $total_toll
                                    + $total_petrol
                                    + $total_parking
                                    + $total_ehailing
                                    + $total_flight
                                    + $total_accomodation
                                    + $total_entertainment
                                    + $total_membership
                                    + $total_training_allowance,
                                    2
                                );     

							?>
						</td>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
	
	<!-- <div class="row">
		<div class="col-4">
			<strong>PREPARED BY : </strong>
		</div>
		<div class="col-4">
			<strong>VERIFIED BY:</strong>
			<br>
			<br>
			<br>
			<br>
			<br>
			<br>
			SHAFIANA MOHAMED SALLEH
		</div>
		<div class="col-4">
			<strong>APPROVED BY:</strong>
		</div>
	</div> -->

</section>