<?php

/* $Id: SelectCustomer.php 7133 2015-02-07 03:23:51Z daintree $*/

//include('includes/session.inc');
//$Title = _('HRMS');
//include('includes/header.inc');
//include('includes/SQL_CommonFunctions.inc');
//echo '<link href="' . $RootPath . '/css/evergreen2'.'/default.css" rel="stylesheet" type="text/css" media="screen"/>';

      

//check.php  

$connect = new mysqli("localhost", "sooggoo", "4Compassion*", "evergreenint"); 


//
$request = $_POST['request']; // request

// Get username list
if($request == 1){
 $search = $_POST['search'];

 $query = "SELECT id,location FROM westpac_costcenter WHERE location like'%".$search."%'";
 $result = mysqli_query($connect,$query);  
 
 while($row = mysqli_fetch_array($result) ){
  $response[] = array("value"=>$row['id'],"label"=>$row['location']);
 }

 // encoding array to json format
 echo json_encode($response);
 exit;
}

// Get details
if($request == 2){
 $id = $_POST['id'];
 $sql1 = "SELECT id,cost_center_no FROM westpac_costcenter WHERE id='".$id."'";

 $result = mysqli_query($connect,$sql1); 

 $users_arr = array();

 while( $row = mysqli_fetch_array($result) ){
   $id = $row['id'];
  $cost_center_no = $row['cost_center_no'];

  $users_arr[] = array("id" =>$id,"cc" =>$cost_center_no);
 }

 // encoding array to json format
 echo json_encode($users_arr);
 exit;
}

?>

