<?php

# HA NINCS ID, AKKOR TAGLISTA
# HA VAN ID, AKKOR TAG ADATAINAK MEGJELENÍTÉSE/SZERKESZTÉSE
if ($this->is_id()) {
	# ADOTT TAG ADATAINAK MEGJELENÍTÉSE
	//user adatok
	$user_data_query = "SELECT * FROM user_coach WHERE ua_id = " . $this->get_id();
	$user_data_assoc_array = $sql->assoc_array($user_data_query);
	
	$new_coach = new user();
	$new_coach->set_user_data_by_id($user_data_assoc_array[0]['ua_id']);
	
	//smarty thingz
	
	$smarty->assign('user_data', $user_data_assoc_array[0]);
	$smarty->assign('coach', $new_coach);
	$smarty->display('coach_data_edit.tpl');
}
else {
	# TAG LISTA

	$user_list_query = "SELECT * FROM user_coach WHERE ua_deleted = 0 ORDER BY ua_name ASC;";
	$user_list_assoc_array = $sql->assoc_array($user_list_query);
	//végigmegyünk a tömbbön, objektumot csinálunk belőlük, és átadjuk egy array-ben a template-nek
	$user_array = array();
	foreach ($user_list_assoc_array as $user_list_array) {
		$current_user = new user();
		$current_user->set_user_data_by_id($user_list_array['ua_id']);
		$user_array[] = $current_user;
	}
	$smarty->assign('user_array', $user_array);
	$smarty->display('coach_list.tpl');
	//var_dump($user_array);
}

?>