<?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_kid WHERE uk_id = " . $this->get_id();
    $user_data_assoc_array = $sql->assoc_array($user_data_query);
    //pólóméret array
    $shirt_size_query = "SELECT * FROM shirt WHERE shirt_deleted = 0;";
    $shirt_size_assoc_array = $sql->assoc_array($shirt_size_query);
    //szülő array
    $parent_query = "SELECT * FROM user_parent WHERE up_deleted = 0 ORDER BY up_name ASC;";
    $parent_assoc_array = $sql->assoc_array($parent_query);
    //SCHOOL ARRAY
    $school_query = "SELECT * FROM school WHERE sc_deleted = 0 ORDER BY sc_name ASC;";
    $school_assoc_array = $sql->assoc_array($school_query);
    $schools = array();
    foreach ($school_assoc_array as $key => $value) {
        $new_school = new school();
        $new_school->set_school_data_by_id($value['sc_id']);
        $schools[] = $new_school;
    }
    //SCHOOL CITY ARRAY
    $school_city_query = "SELECT * FROM school_city WHERE scc_deleted = 0 ORDER BY - scc_order DESC, scc_city ASC;";
    $school_city_assoc_array = $sql->assoc_array($school_city_query);
    $school_cities = array();
    foreach ($school_city_assoc_array as $key => $value) {
        $new_scc = new school_city();
        $new_scc->set_school_city_data_by_id($value['scc_id']);
        $school_cities[] = $new_scc;
    }
    //REGION ARRAY
    $region_query = "SELECT * FROM region WHERE reg_deleted = 0 ORDER BY reg_name ASC;";
    $region_assoc_array = $sql->assoc_array($region_query);

    //training type array
    //$tt_assoc_array = $sql->assoc_array("SELECT * FROM training_type WHERE trt_deleted = 0 ORDER by trt_name ASC;");
    
    //lease assoc array
    $l_assoc_array = $sql->assoc_array("SELECT * FROM lease WHERE l_deleted = 0 ORDER BY l_name ASC;");

    //smarty thingz
    $smarty->assign('school_assoc_array', $schools);
    $smarty->assign('school_city_assoc_array', $school_cities);
    $smarty->assign('region_assoc_array', $region_assoc_array);
    $smarty->assign('user_data', $user_data_assoc_array[0]);
    $smarty->assign('shirt_size_assoc_array', $shirt_size_assoc_array);
    $smarty->assign('parent_assoc_array', $parent_assoc_array);
    //$smarty->assign('tt_assoc_array', $tt_assoc_array);
    $smarty->assign('l_assoc_array', $l_assoc_array);
    $smarty->display('user_data_'.$tpl.'.tpl');
}
else {
    # TAG LISTA
    $activeUserCount = $sql->single_variable("SELECT count(DISTINCT uk_id) FROM user_kid WHERE uk_deleted = 0 AND uk_is_active = 1");
    $passiveUserCount = $sql->single_variable("SELECT count(DISTINCT uk_id) FROM user_kid WHERE uk_deleted = 0 AND uk_is_active = 0");

    $smarty->assign('edit', $tpl == "edit");
    $smarty->assign('activeUserCount',$activeUserCount);
    $smarty->assign('passiveUserCount',$passiveUserCount);
    $smarty->display('user_list.tpl');
    //var_dump($user_array);
}

?>
