<?php

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





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

	$new_mox = new money_expense();
	$new_mox->set_mox_data_by_id($this->get_id());

	$moxc_query = "SELECT * FROM money_expense_category WHERE moxc_deleted = 0 ORDER BY moxc_name ASC;";
	$moxc_array = array();
	$moxc_assoc_array = $sql->assoc_array($moxc_query);

	foreach ($moxc_assoc_array as $mox) {
		$new_moxc = new money_expense_category();
		$new_moxc->set_moxc_data_by_id($mox['moxc_id']);
		$moxc_array[] = $new_moxc;
	}

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


	$smarty->assign("moxc_array", $moxc_array);
	$smarty->assign('pt_assoc_array', $pt_assoc_array);
	$smarty->assign("mox", $new_mox);
	$smarty->display("money_expense_data_edit.tpl");

}
else {
	# KIADÁS LISTA
	$mox_query = "SELECT * FROM money_expense WHERE mox_deleted = 0 ORDER BY mox_date DESC, mox_id DESC;";
	$mox_array = array();
	$mox_assoc_array = $sql->assoc_array($mox_query);

	foreach ($mox_assoc_array as $mod) {
		$new_mox = new money_expense();
		$new_mox->set_mox_data_by_id($mod['mox_id']);
		$mox_array[] = $new_mox;
	}

	$smarty->assign("mox_array", $mox_array);
	$smarty->display("money_expense.tpl");

}

?>
