<?php


# HA NINCS ID, AKKOR SABLONLISTA

if ($this->is_id()) {

	# SABLON SZERKESZTÉSE

    //training adatok
    $training_template_data_query = "SELECT * FROM training_template WHERE tt_id = " . $this->get_id();
    $tt_data_assoc_array = $sql->assoc_array($training_template_data_query);
    $smarty->assign('template_data', $tt_data_assoc_array[0]);

    //TRAINING TYPE ARRAY
    $training_type_query = "SELECT * FROM training_type WHERE trt_deleted = 0 ORDER BY trt_name ASC;";
    $training_type_assoc_array = $sql->assoc_array($training_type_query);
    $smarty->assign("training_type_assoc_array", $training_type_assoc_array);

    $smarty->display('training_template_edit.tpl');

}

else {

	# SABLON LISTA

	$tt_query = "SELECT * FROM training_template WHERE tt_deleted = 0 ORDER BY tt_name ASC";
	$tt_assoc_array = $sql->assoc_array($tt_query);

    $tts = array();

    foreach ($tt_assoc_array as $tt) {
        $new_tt = new training_template();
        $new_tt->set_tt_data_by_id($tt['tt_id']);
        $tts[] = $new_tt;
    }

	$smarty->assign('tts',$tts);
	$smarty->display('training_template_list.tpl');


}

?>
