
			
		<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>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>
							</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;">
						Job Owner (Department)
					</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;">
						Total (RM)
					</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;">
						Converted to AL
					</th>		
				</thead>	

				<tbody>
					<?php 
                        $i = 1;
                        if($cross_job_dept) foreach($cross_job_dept as $row) { ?>
                            <tr>
                                <td scope="row" class="text-center"><?php echo $i; ?></td>
                                <td><b><?php echo $row->job_deptName; ?> - <?php echo $row->job_branchName; ?></b>
                                    <?php 
                                        $cross_job_details = $this->model_ot->getSummaryCrossJOb($row->svDeptID,$row->month,$row->year); //echo $this->db->last_query();
                                        $j = 1;
                                        if($cross_job_details) foreach($cross_job_details as $row_det) { ?>
                                            <br><small><?php echo $j; ?>. <?php echo $row_det['staffName']; ?> 
                                            [<?php echo $row_det['staff_deptName']; ?> - <?php echo $row_det['staff_branchName']; ?>] <i>Submission : <?php echo $row_det['month']; ?>, <?php echo $row_det['year']; ?></i></small>
                                    <?php $j++; } ?>
                                </td>
                                <td class="text-right">
                                    <?php $cross_job_details = $this->model_ot->getSummaryCrossJOb($row->svDeptID,$row->month,$row->year);
                                        if($cross_job_details) foreach($cross_job_details as $row_det) { ?>
                                            <?php $sum = 0; ?>
                                            <?php if($row_det['basic_pay'] <= 2000 && $row_det['position'] == 'Trainee'){ ?>
                                                <?php 
                                                    if(!empty($row_det['totalHoursApproved'])){ $row_det['totalHoursApproved'] = $row_det['totalHoursApproved']; } else { $row_det['totalHoursApproved'] = 0; };

                                                    $totalClaim = $row_det['totalHoursApproved']*6; //trainee fix rate

                                                    if(!empty($row_det['NormalMeal'])){ $row_det['NormalMeal'] = $row_det['NormalMeal']; } else { $row_det['NormalMeal'] = 0; };
                                                    if(!empty($row_det['RestMeal'])){ $row_det['RestMeal']     = $row_det['RestMeal']; } else { $row_det['RestMeal'] = 0; };
                                                    if(!empty($row_det['PublicMeal'])){ $row_det['PublicMeal'] = $row_det['PublicMeal']; } else { $row_det['PublicMeal'] = 0; };

                                                    if($row_det['NormalMeal'] > 0){
                                                        $NormalMeal = $row_det['NormalMeal']*5;
                                                    }else{
                                                         $NormalMeal = 0;
                                                    }
                                                    if($row_det['RestMeal'] > 0){
                                                        $RestMeal = $row_det['RestMeal']*10;
                                                    }else{
                                                        $RestMeal = 0;
                                                    }
                                                    if($row_det['PublicMeal'] > 0){
                                                        $PublicMeal = $row_det['PublicMeal']*10;
                                                    }else{
                                                        $PublicMeal = 0;
                                                    }

                                                    $totalMeal = $NormalMeal + $RestMeal + $PublicMeal;

                                                    $totalDept = $totalClaim + $totalMeal;

                                                    $sum+=$totalDept;

                                                ?>
                                            <?php } else if(!empty($row_det['basic_pay']) && $row_det['basic_pay'] <= 2000){ ?>
                                                <?php 
                                                    if(!empty($row_det['totalHoursApproved'])){ $row_det['totalHoursApproved'] = $row_det['totalHoursApproved']; } else { $row_det['totalHoursApproved'] = 0; };

                                                    if(!empty($row_det['NormalMeal'])){ $row_det['NormalMeal'] = $row_det['NormalMeal']; } else { $row_det['NormalMeal'] = 0; };
                                                    if(!empty($row_det['RestMeal'])){ $row_det['RestMeal']     = $row_det['RestMeal']; } else { $row_det['RestMeal'] = 0; };
                                                    if(!empty($row_det['PublicMeal'])){ $row_det['PublicMeal'] = $row_det['PublicMeal']; } else { $row_det['PublicMeal'] = 0; };

                                                    if(!empty($row_det['Normal'])){ $row_det['Normal'] = $row_det['Normal']; } else { $row_det['Normal'] = 0; };
                                                    if(!empty($row_det['Rest'])){ $row_det['Rest']     = $row_det['Rest']; } else { $row_det['Rest'] = 0; };
                                                    if(!empty($row_det['Public'])){ $row_det['Public'] = $row_det['Public']; } else { $row_det['Public'] = 0; };

                                                    if($row_det['NormalMeal'] > 0){
                                                        $NormalMeal = $row_det['NormalMeal']*5;
                                                    }else{
                                                         $NormalMeal = 0;
                                                    }
                                                    if($row_det['RestMeal'] > 0){
                                                        $RestMeal = $row_det['RestMeal']*10;
                                                    }else{
                                                        $RestMeal = 0;
                                                    }
                                                    if($row_det['PublicMeal'] > 0){
                                                        $PublicMeal = $row_det['PublicMeal']*10;
                                                    }else{
                                                        $PublicMeal = 0;
                                                    }

                                                    $totalMeal = $NormalMeal + $RestMeal + $PublicMeal;

                                                    if($row_det['Normal'] > 0){
                                                        $normalDayTotal = $row_det['basic_pay']/208*1.5*$row_det['Normal'];
                                                    }else{
                                                        $normalDayTotal = 0;
                                                    }
                                                    if($row_det['Rest'] > 0){
                                                        $restDayTotal   = $row_det['basic_pay']/208*2.0*$row_det['Rest'];
                                                    }else{
                                                        $restDayTotal   = 0;
                                                    }
                                                    if($row_det['Public'] > 0){
                                                        $publicDayTotal = $row_det['basic_pay']/208*3.0*$row_det['Public'];
                                                    }else{
                                                        $publicDayTotal = 0;
                                                    }

                                                    $totalClaim = $normalDayTotal+$restDayTotal+$publicDayTotal; 

                                                    $totalDept = $totalClaim + $totalMeal;

                                                    $sum+=$totalDept;
                                                ?>
                                            <?php } else if($row_det['basic_pay'] > 2000){ ?>
                                                <?php 
                                                    if(!empty($row_det['totalHoursApproved'])){ $row_det['totalHoursApproved'] = $row_det['totalHoursApproved']; } else { $row_det['totalHoursApproved'] = 0; };

                                                    $totalClaim = $row_det['totalHoursApproved']*10;

                                                    if(!empty($row_det['NormalMeal'])){ $row_det['NormalMeal'] = $row_det['NormalMeal']; } else { $row_det['NormalMeal'] = 0; };
                                                    if(!empty($row_det['RestMeal'])){ $row_det['RestMeal']     = $row_det['RestMeal']; } else { $row_det['RestMeal'] = 0; };
                                                    if(!empty($row_det['PublicMeal'])){ $row_det['PublicMeal'] = $row_det['PublicMeal']; } else { $row_det['PublicMeal'] = 0; };

                                                    if($row_det['NormalMeal'] > 0){
                                                        $NormalMeal = $row_det['NormalMeal']*5;
                                                    }else{
                                                         $NormalMeal = 0;
                                                    }
                                                    if($row_det['RestMeal'] > 0){
                                                        $RestMeal = $row_det['RestMeal']*10;
                                                    }else{
                                                        $RestMeal = 0;
                                                    }
                                                    if($row_det['PublicMeal'] > 0){
                                                        $PublicMeal = $row_det['PublicMeal']*10;
                                                    }else{
                                                        $PublicMeal = 0;
                                                    }

                                                    $totalMeal = $NormalMeal + $RestMeal + $PublicMeal;

                                                    $totalDept = $totalClaim + $totalMeal;

                                                    $sum+=$totalDept;

                                                ?>
                                            <?php } ?>
                                            <br><small><?php echo number_format((float)$totalDept, 2, '.', ''); ?></small>
                                        <?php } ?>
                                </td>
                                <td class="text-center">
                                    <?php 
                                        $cross_job_details = $this->model_ot->getSummaryCrossJOb($row->svDeptID,$row->month,$row->year);  
                                        if($cross_job_details) foreach($cross_job_details as $row_det) { ?>
                                            <br><small><?php echo $row_det['convertAL']; ?></small>
                                    <?php } ?>
                                </td>
                            </tr>
                        <?php
                        $i++;
                    } ?>
				</tbody>		
			</table>				
		</div>	
									

