<?php
//tag listánál ez adja vissza a keresés eredményét
ini_set('include_path', '../_class/');
include('class_sql.php');
include('class_user_group_filter.php');
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach.hu') $sql = new sql('bc_mysql','root','','badminton_coach');
else $sql = new sql('localhost','tollashodos','uprRscU8bGpJ','tollashodos');

if ($_POST['filter_id'] == 'null') {
	echo json_encode(null);
}
else {
	$ugf = new user_group_filter();
	$ugf->set_ugf_data_by_id($_POST['filter_id']);

	//megvizsgáljuk, hogy külön táblából kell-e szedni az adatokat
	if ($ugf->get_ugf_table()) {
		$ugf_query = "SELECT DISTINCT ".$ugf->get_ugf_value()." AS ugf_id, ".$ugf->get_ugf_label()." AS ugf_name FROM " . $ugf->get_ugf_table() . " WHERE " . $ugf->get_ugf_condition();
	}
	else {
		$ugf_query = "SELECT DISTINCT uk_" . $ugf->get_ugf_field() . " AS ugf_id, uk_".$ugf->get_ugf_field()." as ugf_name FROM user_kid WHERE uk_".$ugf->get_ugf_field()." IS NOT NULL ORDER BY uk_" . $ugf->get_ugf_field() . " ASC;";
	}
	//var_dump($ugf_query);
	$ugf_assoc_array = $sql->assoc_array($ugf_query);

	echo json_encode($ugf_assoc_array);
}

?>