<?php

//split locationName with rental_desc
$projectLocation = $_SESSION["projectLocation"];
$locationName = substr($projectLocation, strpos($projectLocation, "-") + 1);   

$arr = explode("-", $projectLocation, 2);
$projectName = $arr[0];

//dapatkan code rentalDesc
   $sqlRentalProgram = "SELECT * FROM `projects` WHERE `project_name` LIKE '$projectName' ORDER BY `id` DESC";
$runRentalProgram = mysqli_query($link, $sqlRentalProgram);
if($runRentalProgram === FALSE){
	die(mysqli_error($link));
}
$resultRentalProgram  = mysqli_fetch_assoc($runRentalProgram);
$project_id = $resultRentalProgram["id"];
$project_code = $resultRentalProgram["project_code"];

//dapatkan location id 
//$sqlLocationID = "select location_id from  locations where location_desc = '$locationName' ";
 $sqlLocationID = "select id, location_code from  locations where project_id = $project_id and location_name = '$locationName'";
$runLocationID = mysqli_query($link,$sqlLocationID);
if($runLocationID === FALSE){
	die(mysqli_error($link));
}
$resultLocationID  = mysqli_fetch_assoc($runLocationID);
 "location id in split location: ".$location_id = $resultLocationID["id"];
 "location id in split location: ".$location_code = $resultLocationID["location_code"];

$_SESSION["location_id"] = $location_id;
 "LOCATION CODE :: ".$_SESSION["location_code"] = $location_code;
$_SESSION["project_id"] = $project_id;
$_SESSION["project_code"] = $project_code;
$_SESSION["projectName"] = $projectName;
$_SESSION["locationName"] = $locationName;
 "PROJECT LOCATION SESSION: " .$_SESSION["projectLocation"] = $projectName . "-" . $locationName;
?>
