<?php
require_once 'class_user.php';
$user_home = new USER();
$eventlog = EVENTLOG;
function event_log($text){
if(EVENTLOG == Y){
$text=$uid."\t".$text;
$file = "logs"."/".APP_NAME.date("Y-m-d").".log";
//$file = "logs/dailyroll".date("Y-m-d").".log";
error_log(date("[Y-m-d H:i:s]")."\t[INFO][".basename(__FILE__)."]\t".$text."\r\n", 3, $file);
}
}
if (isset($_POST['user_id'])) {
event_log("begining of get account");
//$user_id = '5c326b8115a2a8.52878195';
$user_id = $_POST['user_id'];
//$user_id = '5c2dcee2e21538.17188314';
event_log($user_id);
$id=$user_home->getUseridByUniq($user_id);
$sql="SELECT a.account_id,b.accountname FROM groups a , accounts b WHERE a.account_id = b.account_id and a.`account_status`='active' and a.group_status='Y' and a.userstatus='active' and a.`added_user_id`='$id' group by a.account_id ";
$stmt = $user_home->runQuery($sql);
$stmt->execute();
event_log($sql);
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$response['account_id'] = $row['account_id'];
$response['accountname'] = $row['accountname'];
$responsearray[] = $response;
}
echo json_encode($responsearray);
event_log(json_encode($responsearray));
event_log("End of get account");
}
else {
$response["error"] = TRUE;
$response["error_msg"] = "Required Parameters are missing";
echo json_encode($response);
event_log("Required Pa missing");
}
?>