
			
		<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>
							<td class="divider">
								<span class="line">&nbsp;</span>
								<span><b>NAME &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo $name; ?></b></span>
								<span><b>YEAR &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo (isset($year) ? $year : ' '); ?></b></span>
								<span><b>MONTH &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo (isset($month) ? $month : ' '); ?></b></span>
                                <span><b>CLAIM STATUS &nbsp;&nbsp;&nbsp;&nbsp;: <?php echo (isset($claim_status) ? $claim_status : ' '); ?></b></span>
                                <span><b>PAID STATUS &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo (isset($paid_status) ? $paid_status : ' '); ?></b></span>
							</td>
						</tr>
					</table>
				</div>
			</div>
		</header>

		<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_contact" rowspan="1" colspan="1" aria-label="#: activate to sort column ascending" style="width: 0px;">
						#
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Company Code/ Cost Centre: activate to sort column ascending" style="width: 0px;">
						Date
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Company Name: activate to sort column ascending" style="width: 0px;">
						Client
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Task
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Meal Allowance
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Start Time
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						End Time
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Break (minutes)
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Total Hours
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Day Type
					</th>
					<th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="Employee Total Upload: activate to sort column ascending" style="width: 0px;">
						Status
					</th>						
				</thead>	

				<tbody>
					<?php if (!empty($otLists)): ?>
                        <?php foreach ($otLists as $key => $ot): ?>       
                        <tr>
                            <td><?php echo $key+1;?></td>
                            <td><?php echo date('d/m/Y',strtotime($ot['otDate']));?></td>
                            <td><?php if($ot['clientID'] > 0 ){ echo $ot['clientName']; }else{ echo 'Others';};?></td>
                            <td><?php echo $ot['task'];?></td>                                          
                            <td><?php if($ot['mealAllowance'] == 1){
                                        echo 'Claimable (Included)';
                                      } else if($ot['mealAllowance'] == 2){
                                        echo 'Claimable (Not Included)';
                                      } else {
                                        echo 'Unclaimable';
                                      } ?>  
                            </td>
                            <td><?php echo date("h:i A", strtotime($ot['startTime']));?></td>
                            <td><?php echo date("h:i A", strtotime($ot['endTime']));?></td>
                            <td><?php echo $ot['refreshment'];?></td>
                            <td><?php echo $ot['totalHoursApplied'];?></td>
                            <td><?php 
                                if($ot['dayType'] == 1){
                                    echo 'Normal Day';
                                }else if($ot['dayType'] == 2){
                                    echo 'Rest Day';
                                }else if($ot['dayType'] == 3){
                                    echo 'Public Holiday';
                                }else if($ot['dayType'] == 4){
                                    echo 'Weekend';
                                }else if($ot['dayType'] == 5){
                                    echo 'Weekdays';
                                }
                             ?></td>
                            <td id="otID" class="text-left" otDetailID="<?php echo $ot['ID']; ?>" otID="<?php echo $ot['otID']; ?>">
                                <?php if($ot['status'] == 0) { ?>
	                                <span class="badge badge-warning text-white">Pending</span><br>
	                                <small><i><b>*Remarks : </b><?php echo $ot['remarks'];?></i><br></small>
	                            <?php } else if($ot['status'] == 1) { ?>
	                                <span class="badge badge-success text-white">Approved</span><br>
	                                <small><i><b>*Remarks : </b><?php echo $ot['remarks'];?></i><br></small>
	                                <small><i><b>*Approved by : </b><?php echo $ot['status_by_name'];?></i><br></small>
	                            <?php }else { ?>
	                                <span class="badge badge-danger text-white">Rejected</span><br>
	                                <small><i><b>*Remarks : </b><?php echo $ot['remarks'];?></i><br></small>
	                                <small><i><b>*Rejected by : </b><?php echo $ot['status_by_name'];?></i><br></small>
	                            <?php } ?> 
                            </td>                                                
                        </tr> 
                        <?php endforeach ?>
                    <?php endif ?>
				</tbody>		
			</table> -->				
		</div>	
		<div class="card-body">
            <table class="table-bordered" width="100%">
                <h5>Claim Summary By Job for <?php echo date("F Y",mktime(0,0,0, $rsOt['month'],1,$rsOt['year'])) ?>
                <thead>
                    <th colspan="2" class="text-center bg-light py-3">Department</th>
                    <th colspan="2" class="text-center bg-light">Details</th>
                </thead>
                <tbody>
                    <?php $sum = 0; ?>
                    <?php foreach($OTSummaryByDept as $row): ?>
                        <tr>
                            <?php if($row['svDeptID'] !=0){ ?>
                                <td colspan="2" class="text-center"><?php echo $row['dept']; ?></td>
                            <?php } else { ?>
                                <td colspan="2" class="text-center"><?php echo $department_name; ?></td>
                            <?php }?>
                            <td class="text-left">
                                &nbsp;OT Applied (Hours)<br>
                                &nbsp;OT Approved (Hours)<br> 
                                <hr> 
                                <?php if($row['svDeptID'] !=0){ ?>
                                    &nbsp;<b>Total for <?php echo $row['dept']; ?></b>
                                <?php } else { ?>
                                    &nbsp;<b>Total for <?php echo $department_name; ?></b>
                                <?php }?>
                                
                            </td>
                            <td colspan="2" class="text-center">
                                
                                <?php 
                                    if(!empty($row['totalHoursApproved'])){ $row['totalHoursApproved'] = $row['totalHoursApproved']; } else { $row['totalHoursApproved'] = 0; };

                                    $totalClaim = $row['totalHoursApproved'];

                                    $totalDept = $totalClaim;

                                    $sum+=$totalDept;

                                ?>

                                <?php echo $row['totalHoursApplied']; ?><br>
                                <?php echo $row['totalHoursApproved']; ?><br>
                                <hr>
                                <b><?php echo $row['totalHoursApproved']; ?></b>
                            </td>
                        </tr>
                    <?php endforeach ?>
                </tbody>
                <tfoot>
                    <td colspan="3" class="text-right bg-light py-3"><b>Total Claim Approved (Hours) </b></td>
                    <td colspan="2" class="text-center bg-light"><b><?php echo $sum; ?></b></td>
                </tfoot>
            </table><br>

            <table class="table-bordered" width="100%" >
                <h5>Claim Summary for <?php echo date("F Y",mktime(0,0,0, $rsOt['month'],1,$rsOt['year'])) ?></h5><br>
                <thead>
                    <?php 
                    // debug($ot);
                        if(!empty($ot['otID'])){ $ot['otID']             = $ot['otID']; } else { $ot['otID'] = 0; };
                        if(!empty($ot['NormalMeal'])){ $ot['NormalMeal'] = $ot['NormalMeal']; } else { $ot['NormalMeal'] = 0; };
                        if(!empty($ot['RestMeal'])){ $ot['RestMeal']     = $ot['RestMeal']; } else { $ot['RestMeal'] = 0; };
                        if(!empty($ot['PublicMeal'])){ $ot['PublicMeal'] = $ot['PublicMeal']; } else { $ot['PublicMeal'] = 0; };
                        if(!empty($ot['WeekendMeal'])){ $ot['WeekendMeal']     = $ot['WeekendMeal']; } else { $ot['WeekendMeal'] = 0; };
                        if(!empty($ot['WeekdaysMeal'])){ $ot['WeekdaysMeal']   = $ot['WeekdaysMeal']; } else { $ot['WeekdaysMeal'] = 0; };

                        if(!empty($ot['normal'])){ $ot['normal']     = $ot['normal']; } else { $ot['normal'] = 0; };
                        if(!empty($ot['rest'])){ $ot['rest']         = $ot['rest']; } else { $ot['rest'] = 0; };
                        if(!empty($ot['public'])){ $ot['public']     = $ot['public']; } else { $ot['public'] = 0; };
                        if(!empty($ot['weekend'])){ $ot['weekend']   = $ot['weekend']; } else { $ot['weekend'] = 0; };
                        if(!empty($ot['weekdays'])){ $ot['weekdays'] = $ot['weekdays']; } else { $ot['weekdays'] = 0; };
                        if(!empty($ot['totalHoursAppliedTotal'])){ $ot['totalHoursAppliedTotal'] = $ot['totalHoursAppliedTotal']; } else { $ot['totalHoursAppliedTotal'] = 0; };
                        if(!empty($ot['totalHoursApproved'])){ $ot['totalHoursApproved'] = $ot['totalHoursApproved']; } else { $ot['totalHoursApproved'] = 0; };
                        if(!empty($ot['claim_status'])){ $ot['claim_status'] = $ot['claim_status']; } else { $ot['claim_status'] = 0; };

                        if(!empty($prev_balanceCarryForward[0]->balanceCarryForward)){ $prev_balanceCarryForward[0]->balanceCarryForward = $prev_balanceCarryForward[0]->balanceCarryForward; } else { $prev_balanceCarryForward[0]->balanceCarryForward = 0; };

                        if($ot['WeekdaysMeal'] > 0){
                            $WeekdaysMeal = $ot['WeekdaysMeal']*5;
                        }else{
                             $WeekdaysMeal = 0;
                        }
                        if($ot['WeekendMeal'] > 0){
                            $WeekendMeal = $ot['WeekendMeal']*10;
                        }else{
                            $WeekendMeal = 0;
                        }

                        $totalMeal = $WeekdaysMeal + $WeekendMeal;
            
                        $weekendTotal2   = $ot['weekend']*7;
                        $weekdaysTotal2  = $ot['weekdays']*7;
                        $total2          = $weekendTotal2+$weekdaysTotal2; 

                        $prev_bringforward = $prev_balanceCarryForward[0]->balanceCarryForward;
                        $totalHourConvert  = $ot['totalHoursApproved'] + $prev_bringforward;
                        $convertALHour     = intval($totalHourConvert/4)*4;
                        $next_carryforward = $totalHourConvert - $convertALHour;
                        $convertALDays     = $convertALHour/8;

                        $convertALHourValue = $convertALHour*7;
                        $total2Final        = $total2-$convertALHourValue;

                    ?>
                </thead>
                <tbody>
                    <tr>
                        <td colspan="3" class="text-center bg-light py-3"><b>OT Applied Details</b></td>
                        <td colspan="2" class="text-center bg-light"><b>OT Applied Details Approved (Hours)</b></td>
                        <td colspan="2" class="text-center bg-light"><b>Meal Allowance Details Approved (RM)</b></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="text-center">Weekend</td>
                        <td colspan="2" class="text-center"><?php if($ot['weekend']){ echo $ot['weekend']; }else{ echo "0"; } ?></td>
                        <td colspan="2" class="text-center">RM<?php if($WeekendMeal){ echo $WeekendMeal; }else{ echo "0"; } ?></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="text-center">Weekdays</td>
                        <td colspan="2" class="text-center"><?php if($ot['weekdays']){ echo $ot['weekdays']; }else{ echo "0"; } ?></td>
                        <td colspan="2" class="text-center">RM<?php if($WeekdaysMeal){ echo $WeekdaysMeal; }else{ echo "0"; } ?></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="text-center bg-light py-3"><b>Total OT Applied (Hours)</b></td>
                        <td colspan="2" class="text-center bg-light"><b>Total OT Approved (Hours)</b></td>
                        <td colspan="3" class="text-center bg-light"><b>Total Meal Allowances Approved (RM)</b></td>
                    </tr>
                    <tr>
                        <td colspan="3" class="text-center"><input type="hidden" value="<?php echo $ot['totalHoursAppliedTotal']; ?>" id="totalOT"><?php echo $ot['totalHoursAppliedTotal']; ?></td>
                        <td colspan="2" class="text-center"><input type="hidden" value="<?php echo $ot['totalHoursApproved']; ?>" id="totalApprovedOT"><?php echo $ot['totalHoursApproved']; ?></td>
                        <td colspan="2" class="text-center">RM<?php if($totalMeal){ echo $totalMeal; }else{ echo "0"; } ?></td>
                    </tr>
                    <tr><td class="bg-light"></td></tr>
                    <tr><td class="bg-light"></td></tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="3" class="text-center bg-light py-3"><b>AL Conversion Summary <br> <small>*Minimum 4 hours for 0.5 day</small></b></td>
                        <td colspan="2" class="text-right">
                            Total OT Approved (Hours) &nbsp;&nbsp;&nbsp; <br>
                            OT to Convert (Hours) &nbsp;&nbsp;&nbsp;  <br>
                            Balance OT Brought Forward (Hours) &nbsp;&nbsp;&nbsp;  <br>
                            Total OT to Convert (Hours) &nbsp;&nbsp;&nbsp;  <br><br>
                            Total Valid to Convert (Hours) &nbsp;&nbsp;&nbsp;  <br>
                            Final Conversion Leave (Days) &nbsp;&nbsp;&nbsp;  <br>
                            Balance OT Carry Forward (Hours) &nbsp;&nbsp;&nbsp;  <br>
                        </td>
                        <td colspan="2" class="text-center" id="al_conversion" data-convertALDays="<?php echo $convertALDays; ?>" data-balanceCarryForward="<?php echo $next_carryforward; ?>">
                            <?php echo $ot['totalHoursApproved']; ?><br>
                            <?php echo $ot['totalHoursApproved']; ?><br>
                            <?php echo $prev_bringforward; ?><br>
                            <?php echo $totalHourConvert; ?><br><br>
                            <?php echo $convertALHour; ?><br>
                            <?php echo $convertALDays; ?><br>
                            <?php echo $next_carryforward; ?><br>
                        </td>
                    </tr>
                </tfoot>
            </table>
        </div>
									

