<?php include "headerLink.php"?>
<!DOCTYPE html>
<html lang="en">


<body class="animsition">
    <div class="page-wrapper">
        <!-- HEADER MOBILE-->
        <?php include "menuSideBar_mobile.php" ;?>
        <!-- END HEADER MOBILE-->
		
        <!-- MENU SIDEBAR-->
        <?php include "menuSideBar.php" ;?>
        <!-- END MENU SIDEBAR-->

        <!-- PAGE CONTAINER-->
        <div class="page-container">
            <!-- HEADER DESKTOP-->
			<?php include "headerPage.php"?>
            <!-- END HEADER DESKTOP-->
			
			
			
			<!-- MAIN CONTENT-->
			<?php
			if($_SESSION["projectName"] == "PPR" || $_SESSION["projectName"] == "SKIM SMART SEWA"){
				$sqlProjectLocationsListing = "SELECT projects.project_code, projects.project_name,locations.location_name  from locations 
												inner join projects on locations.project_id  = projects.id 
												where project_name <> 'ADMIN'";
			}
			else { //HARTANAH PELABURAN
				$sqlProjectLocationsListing = "select projects.project_code, projects.project_name,locations.location_name  from locations 
									inner join projects on locations.project_id  = projects.id 
									where project_name <> 'ADMIN'
									order by  CASE WHEN projects.project_code = '004' THEN 1
													WHEN projects.project_code = '006' THEN 2
													WHEN projects.project_code = '005' THEN 3
													ELSE 4  END, locations.location_name asc
													";
			}
			
			$runProjectLocationsListing = mysqli_query($link, $sqlProjectLocationsListing);//or die ("Cannot execute program");
			if($runProjectLocationsListing === FALSE){
				die(mysqli_error($link));
			}
			//ECHO $sqlProjectLocationsListing;
			?>
            <!--main content upper start-->
			<?php include "main-content-upper.php"?>
            <!--main content upper end-->
			<!--main content middle start-->
			<div class="row">
				<div class="col-lg-12">
					<div class="table-responsive table--no-card m-b-30">
						<table class="table table-bordered table-hover table-sm" id="dataTable" width="100%" cellspacing="0" style="font-size: 12px">
							<thead>
								<tr>
									<th>#</th>
									<th>Projects</th>
									<th>Locations</th>
									<th></th>
								</tr>
							</thead>
							<tbody>
							<?php 
							$no = 1;
							while($resultProjectLocationsListing = mysqli_fetch_array($runProjectLocationsListing)){ ?>
								<tr>
									<td><?php echo $no; ?></td>
									<td><?php echo $resultProjectLocationsListing["project_name"]; ?></td>
									<td><?php echo strtoupper($resultProjectLocationsListing["location_name"]); ?></td>
									<td></td>
								</tr>
							<?php 
								$no++;
							} ?>
							   
							</tbody>
						</table>
					</div>
				</div>
			</div>
            <!--main content middle end-->
			<!--main content bottom start-->
				<?PHP include "main-content-bottom.php";?>
			<!--main content bottom end-->
			
            <!-- END MAIN CONTENT-->
            <!-- END PAGE CONTAINER-->
        </div>
    </div>
    <?PHP include "footerLink.php";?>
</body>
</html>
<!-- end document-->
