<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>COMPLAINT TO</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<?php if(!empty($this->session->userdata('sv_complaint_filter_dept')) && $this->session->userdata('sv_complaint_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>CLIENT TYPE</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;">
										<?php if(($this->session->userdata('sv_complaint_filter_type') == null) || $this->session->userdata('sv_complaint_filter_type') == 'ALL'){ 
											echo 'ALL'; 
										} else if($this->session->userdata('sv_complaint_filter_type') == 0){ 
											echo 'Internal Client'; 
										} else if($this->session->userdata('sv_complaint_filter_type') == 1){ 
											echo 'External Client'; 
										} ?>

										</b></span>
									</td>
								</tr>
								<tr>
									<td><span><b>CLIENT NAME</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;">

										<?php if(($this->session->userdata('sv_complaint_filter_client') == null) || $this->session->userdata('sv_complaint_filter_client') == 'ALL'){ 
											echo 'ALL'; 
										} else if($this->session->userdata('sv_complaint_filter_type') == 0){ 
											echo $client['name'].' | '.$client['branch_name']; 
										} else if($this->session->userdata('sv_complaint_filter_type') == 1){ 
											echo $client[0]->name; 
										} ?>
										
										</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 if(($this->session->userdata('sv_complaint_filter_status') == null) || $this->session->userdata('sv_complaint_filter_status') == 'ALL'){ 
											echo 'ALL'; 
										} else if($this->session->userdata('sv_complaint_filter_status') == 0){ 
											echo 'New!'; 
										} else if($this->session->userdata('sv_complaint_filter_status') == 1) { 
											echo 'In Progress'; 
										} else if($this->session->userdata('sv_complaint_filter_status') == 2) {
											echo 'Action Taken';
										} else if($this->session->userdata('sv_complaint_filter_status') == 3){
											echo 'Verified';
										} else {
											echo 'Approved';
										} ?>
											
										</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_complaint_filter_year')))?($this->session->userdata('sv_complaint_filter_year')):'ALL'; ?></b></span></td>
								</tr>
							</table>
						</td>
					<?php } ?>
				</tr>
			</table>
		</div>
	</div>
</header>

<div class="col-12">
	<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" style="width: 0px;">
	                #
	            </th>
	            <th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
	                Complaint Register
	            </th>
	            <th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
	                Client Name
	            </th>
	            <th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
	                Nature of Complaint
	            </th>
	            <th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
	                Status
	            </th>
	             <th class="sorting border-top text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
	                Action Taken Date
	            </th>      
	        </thead>	

			<tbody>
				<?php if($this->session->userdata('sv__crm__complaint') && $this->session->userdata('sv__crm__complaint') != 'No Data') {  
					foreach($this->session->userdata('sv__crm__complaint') as $key => $row) {?>
	                    <tr>
	                        <td class="text-center"><small><?php echo $key+1; ?></small></td>
	                        <td>
	                            <small>
	                                Ref. No : <?php echo str_pad($row['ref_no'], 4,'0', STR_PAD_LEFT); ?><br>
	                                Date : <?php echo date('d-m-Y', strtotime($row['date'])); ?><br>
	                                Complaint to : <?php echo $row['department_name']; ?> | <?php echo $row['branch_name'] ?><br>
	                                Register by : <?php echo $row['reg_name']; ?> 
	                            </small>
	                        </td>
	                        <td><small><?php if($row['complaint_for'] == 1){echo "External Complaint";}else{echo "Internal Complaint";} ?> by <?php echo $row['client_name']; ?></small></td>
	                        <td>
	                            <small>
	                                Services : <?php echo $row['service']; ?><br>
	                                Type of Job : <?php echo $row['job']; ?><br>
	                                Person In Charge : <?php echo $row['pic_name']; ?>
	                            </small>
	                        </td>
	                        <td class="text-center">
	                            <?php if($row['status'] == 0){ ?>
	                                <span class="badge badge-pill badge-danger"> New! </span>
	                            <?php }else if($row['status'] == 1){?>
	                                <span class="badge badge-pill badge-warning"> In Progress </span>
	                            <?php }else if($row['status'] == 2){?>
	                                <span class="badge badge-pill badge-info"> Action Taken </span>
	                            <?php }else if($row['status'] == 3){?>
	                                <span class="badge badge-pill badge-success"> Verified </span>
	                            <?php }else{?>
	                                <span class="badge badge-pill badge-dark"> Approved </span>
	                            <?php } ?>
	                        </td>
	                        <td class="text-center"><small><?php if($row['date_solved'] != '0000-00-00'){ echo date ('d-m-Y', strtotime($row['date_solved'])); }else{ echo '';} ?></small></td> 
	                    </tr>
	                <?php } ?>
	            <?php } else { 
	            	if($complaint_list){ //debug($complaint_list);
	            		foreach ($complaint_list as $key => $row) { ?>
	            			<tr>
		                        <td class="text-center"><small><?php echo $key+1; ?></small></td>
		                        <td>
		                            <small>
		                                Ref. No : <?php echo str_pad($row->ref_no, 4,'0', STR_PAD_LEFT); ?><br>
		                                Date : <?php echo date('d-m-Y', strtotime($row->date)); ?><br>
		                                Complaint to : <?php echo $row->department_name; ?> | <?php echo $row->branch_name; ?><br>
		                                Register by : <?php echo $row->reg_name; ?> 
		                            </small>
		                        </td>
		                        <td><small><?php if($row->complaint_for == 1){echo "External Complaint";}else{echo "Internal Complaint";} ?> by <?php echo $row->client_name; ?></small></td>
		                        <td>
		                            <small>
		                                Services : <?php echo $row->service; ?><br>
		                                Type of Job : <?php echo $row->job; ?><br>
		                                Person In Charge : <?php echo $row->pic_name; ?>
		                            </small>
		                        </td>
		                        <td class="text-center">
		                            <?php if($row->status == 0){ ?>
		                                <span class="badge badge-pill badge-danger"> New! </span>
		                            <?php }else if($row->status == 1){?>
		                                <span class="badge badge-pill badge-warning"> In Progress </span>
		                            <?php }else if($row->status == 2){?>
		                                <span class="badge badge-pill badge-info"> Action Taken </span>
		                            <?php }else if($row->status == 3){?>
		                                <span class="badge badge-pill badge-success"> Verified </span>
		                            <?php }else{?>
		                                <span class="badge badge-pill badge-dark"> Approved </span>
		                            <?php } ?>
		                        </td>
		                        <td class="text-center"><small><?php if($row->date_solved != '0000-00-00'){ echo date ('d-m-Y', strtotime($row->date_solved)); }else{ echo '';} ?></small></td> 
		                    </tr>
	            		<?php } } ?>
	            <?php } ?>
	        </tbody>
		</table>
	</div>
</div>
	