<?php

# HA NINCS ID, AKKOR BEVÉTEL LISTA
# HA VAN ID, AKKOR BEVÉTEL ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA





if ($this->is_id()) {
	# ADOTT BEVÉTEL ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA

	$new_mi = new money_income();
	$new_mi->set_mi_data_by_id($this->get_id());

	$mic_query = "SELECT * FROM money_income_category WHERE mic_deleted = 0 AND mic_id != 4 ORDER BY mic_name ASC;";
	$mic_array = array();
	$mic_assoc_array = $sql->assoc_array($mic_query);

	foreach ($mic_assoc_array as $mi) {
		$new_mic = new money_income_category();
		$new_mic->set_mic_data_by_id($mi['mic_id']);
		$mic_array[] = $new_mic;
	}

	$pt_assoc_array = $sql->assoc_array('SELECT * FROM payment_type ORDER BY pt_id ASC;');


	$smarty->assign("mic_array", $mic_array);
	$smarty->assign('pt_assoc_array', $pt_assoc_array);
	$smarty->assign("mi", $new_mi);
	$smarty->display("money_income_data_edit.tpl");

}
else {
	# BEVÉTEL LISTA
	$mi_query = "SELECT * FROM money_income WHERE mi_deleted = 0 AND mi_money_income_category_mic_id != 4 ORDER BY mi_date DESC, mi_id DESC;";
	$mi_array = array();
	$mi_assoc_array = $sql->assoc_array($mi_query);

	foreach ($mi_assoc_array as $mod) {
		$new_mi = new money_income();
		$new_mi->set_mi_data_by_id($mod['mi_id']);
		$mi_array[] = $new_mi;
	}

	$smarty->assign("mi_array", $mi_array);
	$smarty->display("money_income.tpl");

}

?>
