<?php
	if(($this->session->userdata('sv_meetingcrm_filter_month') && $this->session->userdata('sv_meetingcrm_filter_month') != 'no result')){
		if($this->session->userdata('sv_meetingcrm_filter_month') == '01'){
	         $month = "JANUARY";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '02'){
	         $month = "FEBRUARY";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '03'){
	         $month = "MARCH";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '04'){
	         $month = "APRIL";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '05'){
	         $month = "MAY";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '06'){
	         $month = "JUNE";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '07'){
	         $month = "JULY";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '08'){
	         $month = "AUGUST";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '09'){
	         $month = "SEPTEMBER";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '10'){
	         $month = "OCTOBER";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '11'){
	         $month = "NOVEMBER";
	    }else if($this->session->userdata('sv_meetingcrm_filter_month') == '12'){
	         $month = "DECEMBER";
        }else if($this->session->userdata('sv_meetingcrm_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>
					<td class="divider">
						<span class="line">&nbsp;</span>
						<span><b>NAME &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo $_SESSION['user']['name'] ?></b></span>
						<?php if(!empty($this->session->userdata('filter_year'))){ ?>
							<span><b>YEAR &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: <?php echo $this->session->userdata('filter_year'); ?></b></span>
						<?php } else {?>
							<span><b>YEAR &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: ALL</b></span>
						<?php } ?>

						<?php if(!empty($this->session->userdata('filter_month'))){ ?>
							<span><b>MONTH &nbsp;&nbsp;&nbsp;&nbsp;: <?php echo $this->session->userdata('filter_month'); ?></b></span>
						<?php } else {?>
							<span><b>MONTH &nbsp;&nbsp;&nbsp;&nbsp;: ALL</b></span>
						<?php } ?>
					</td>
				</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 REPORT REQUEST</b></h3>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<p style="border-top: 3px solid; width: 45rem;"></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($meetingCrmList[0]['requestor']))?$meetingCrmList[0]['requestor']:''; ?>
								</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($meetingCrmList[0]['staff_id']))?strtoupper($meetingCrmList[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($meetingCrmList[0]['dept_name']))?$meetingCrmList[0]['dept_name']:''; ?>
								</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($meetingCrmList[0]['createdTS']))?date('d-m-Y',strtotime($meetingCrmList[0]['createdTS'])):''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>COMPANY NAME</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['company_name']))?$meetingCrmList[0]['company_name']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>CONTACT PERSON</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($meetingCrmList[0]['contact_person']))?$meetingCrmList[0]['contact_person']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>CONTACT NUMBER</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['contact_number']))?$meetingCrmList[0]['contact_number']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>CONTACT EMAIL</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['contact_email']))?$meetingCrmList[0]['contact_email']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>DIRECTOR(S) BRIEF INFO</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['director_info']))?$meetingCrmList[0]['director_info']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>PREPARED BY</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($meetingCrmList[0]['preparedByName']))?$meetingCrmList[0]['preparedByName']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>ATTENDED BY</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php //echo (!empty($attendName[0]['attendedListName']))?$attendName[0]['attendedListName']:'N/A'; ?>
                                    <?php if((!empty($meetingCrmList))) {  foreach($meetingCrmList as $key => $row){ ?>
                                        <input type="hidden" id="attendListNameID" name="attendListNameID" value="<?php echo $row['ID']; ?>">
                                        <?php $i=0; $i++; ?>
                                            <?php if(!empty($attendListName)){ ?>
                                                <?php foreach ($attendListName as $key => $rowItem) { //debug($key); ?>
                                                    <?php if($rowItem['meeting_crm_report_id'] == $row['ID']) { ?>
                                                        <?php echo ($i++).' - '; echo $rowItem['attendedListName']; ?><br>
                                                    <?php } ?>
                                                <?php }?>
                                            <?php } ?>
                                        <?php } ?>
                                    <?php } ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>PRINCIPLE BUSINESS</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['principle_business']))?$meetingCrmList[0]['principle_business']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>OBJECTIVE OF MEETING</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['objective_meeting']))?$meetingCrmList[0]['objective_meeting']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>MEETING RESULT</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['meeting_result']))?$meetingCrmList[0]['meeting_result']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>RECOMMENDED DIRECTION IN RESPONSE TO MEETING</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['recommended_direction']))?$meetingCrmList[0]['recommended_direction']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>ENGAGEMENT</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($meetingCrmList[0]['engagementName']))?$meetingCrmList[0]['engagementName']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>POTENTIAL SERVICES</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['potentialServiceName']))?$meetingCrmList[0]['potentialServiceName']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>CURRENT/EXPECTED FEE</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['fee']))?$meetingCrmList[0]['fee']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>ACTION REQUIRED</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($meetingCrmList[0]['action_required']))?$meetingCrmList[0]['action_required']:''; ?>
								</p>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>
	</div>
<?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" rowspan="1" colspan="1" aria-label="#: activate to sort column ascending" style="width: 0px;">
					#
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Company
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Director(s) brief info
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Prepared By
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Attended by
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Principle Business
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Objective of Meeting
				</th>
				<!-- <th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Meeting Result			
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Recommended Direction
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Engagement
				</th> -->
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Potential Services
				</th>
				<!-- <th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Current/Expected Fee
				</th> -->
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Action required
				</th>

			</thead>	

			<tbody>
				<?php if((!empty($meetingCrmList))) {  foreach($meetingCrmList as $key => $row){ ?>
					<tr>
						<td><?php echo $key+1; ?></td>
						<td><?php echo $row['company_name']; ?><br>
                        	<?php echo $row['contact_person']; ?><br>
                        </td>
						<!-- <td><?php echo $row['company_name']; ?></td>
						<td><?php echo $row['contact_person']; ?><br>
							<?php echo $row['contact_number']; ?><br>
							<?php echo $row['contact_email']; ?>
						</td> -->
						<td><?php echo $row['director_info']; ?></td>
						<td><?php echo $row['preparedByName']; ?></td>
						<td>
							 <input type="hidden" id="attendListNameID" name="attendListNameID" value="<?php echo $row['ID']; ?>">
							 <?php $i=0; $i++; ?>
							 <?php if(!empty($attendListName)){ ?>
							 	<?php foreach ($attendListName as $key => $rowItem) { //debug($key); ?>
							 		<?php if($rowItem['meeting_crm_report_id'] == $row['ID']) { ?>
							 			<?php echo ($i++).' - '; echo $rowItem['attendedListName']; ?><br>
							 		<?php } ?>
							 	<?php }?>
							 <?php } ?>
						</td>
						<td><?php echo $row['principle_business']; ?></td>
						<td><?php echo $row['objective_meeting']; ?></td>
						<!-- <td><?php echo $row['meeting_result']; ?></td>
						<td><?php echo $row['recommended_direction']; ?></td>
						<td><?php echo $row['engagementName']; ?></td> -->
						<td><?php echo $row['potentialServiceName']; ?></td>
						<!-- <td><?php echo $row['fee']; ?></td> -->
						<td><?php echo $row['action_required']; ?></td>	          
					</tr>
				<?php } } ?>
			</tbody>
		</table>	
	</div>
<?php } ?>	


