<?php
include "config.php";
header('Content-Type: application/json');
$valid_passwords = array("LifeLCT" => "LifLinCnslt");
$valid_users = array_keys($valid_passwords);

$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];

$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);

if (!$validated) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    $responsefull = array('error_message' => 'Unathorized: please provide a valid password!', 'data' => []);
} else {


    $datas = json_decode(file_get_contents('php://input'), true);

	$departments = array();

		 //categories
	    $query_menu = "SELECT a.term_id,a.name FROM `wp_terms` a join wp_term_taxonomy b WHERE a.term_id = b.term_id and b.parent=4";
	    $res_menu = mysqli_query($con, $query_menu);
		while ($row_menu = mysqli_fetch_array($res_menu)) {
			// $depimg=$row_menu['app_icon'];
			// $dep_img_path = "https://online.lifelinehospitalkerala.com/".$depimg;

			if($row_menu['term_id']!=16 && $row_menu['term_id']!=13 && $row_menu['term_id']!=35 && $row_menu['term_id']!=36 ){
				$departments[] = array(
				'dep_id' => $row_menu['term_id'],
				'dep_name' => $row_menu['name']
				//'dep_image' => $dep_img_path,
				);
			}
		}



		$data = array("departments" => $departments );

$response = array("status" => "true","message" => "Success", "data" => $data);


}
if(isset($response))
{
	echo json_encode($response, JSON_UNESCAPED_SLASHES);
}
?>