created money expense

This commit is contained in:
Ricsi
2017-02-11 22:42:44 +01:00
parent 73db6b620a
commit 08ed5a85d4
20 changed files with 814 additions and 4 deletions

View File

@@ -119,6 +119,23 @@ switch ($this->get_id()) {
$smarty->assign('user_kids', $user_kids);
$smarty->display('money_deposit_create.tpl');
break;
case 'money_expense':
# ÚJ KIADÁS
$moxc_assoc_array = $sql->assoc_array('SELECT * FROM money_expense_category WHERE moxc_deleted = 0 ORDER BY moxc_name ASC;');
$moxc_array = array();
foreach ($moxc_assoc_array as $key => $moxc) {
$new_moxc = new money_expense_category();
$new_moxc->set_moxc_data_by_id($moxc['moxc_id']);
$moxc_array[] = $new_moxc;
}
$smarty->assign('moxc_array', $moxc_array);
$smarty->display('money_expense_create.tpl');
break;
case 'money_expense_category':
# ÚJ KIADÁS KATEGÓRIA
$smarty->display('money_expense_category_create.tpl');
break;
default:
# code...

View File

@@ -0,0 +1,10 @@
<?php
if ($this->is_id()) {
$sql->update_table('money_expense', array('mox_deleted' => 1), array('mox_id' => $this->get_id()));
log::register('delete_mox', $this->get_id());
header("Location: /admin/money_expense");
}
?>

View File

@@ -0,0 +1,10 @@
<?php
if ($this->is_id()) {
$sql->update_table('money_expense_category', array('moxc_deleted' => 1), array('moxc_id' => $this->get_id()));
log::register('delete_moxc', $this->get_id());
header("Location: /admin/money_expense_category");
}
?>

View File

@@ -0,0 +1,50 @@
<?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;
}
$smarty->assign("moxc_array", $moxc_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");
}
?>

View File

@@ -0,0 +1,37 @@
<?php
# HA NINCS ID, AKKOR KIADÁS KATEGÓRIA LISTA
# HA VAN ID, AKKOR KIADÁS KATEGÓRIA ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA
if ($this->is_id()) {
# ADOTT KIADÁS KATEGÓRIA ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA
$new_moxc = new money_expense_category();
$new_moxc->set_moxc_data_by_id($this->get_id());
$smarty->assign("moxc", $new_moxc);
$smarty->display("money_expense_category_data_edit.tpl");
}
else {
# KIADÁS KATEGÓRIA LISTA
$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;
}
$smarty->assign("moxc_assoc_array", $moxc_array);
$smarty->display("money_expense_category.tpl");
}
?>

View File

@@ -0,0 +1,146 @@
<?php
$users = $sql->assoc_array('select * from user_kid order by uk_name asc;');
foreach ($users as $key => $value) {
$user = new user_kid();
$user->set_user_data_by_id($value['uk_id']);
# EDZÉS LISTA
$action_list_query = "
SELECT
object_id,
timestamp(object_date) as object_date,
object_type,
(SELECT
count(distinct date(tr_date))
FROM
presence
JOIN
training ON tr_id = pr_training_tr_id
WHERE
YEAR(tr_date) = YEAR(object_date)
AND MONTH(tr_date) = MONTH(object_date)
AND tr_date <= object_date
AND pr_user_kid_uk_id = ".$user->get_uk_id()."
AND tr_date > (select
if(max(trd) is null,
'1900-01-01',
max(trd))
from
(select
tr_date trd
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$user->get_uk_id()."
and tr_date >= (SELECT
tr_date
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$user->get_uk_id()."
and date(tr_date) = uk_first_training
ORDER BY tr_date ASC
limit 1)
order by tr_date ASC
limit 2) as elso_ket_edzes)) as 'training_per_month',
(SELECT
count(pr_id)
FROM
presence
JOIN
training ON tr_id = pr_training_tr_id
WHERE
DATE(tr_date) = DATE(object_date)
AND tr_date <= object_date
AND pr_user_kid_uk_id = ".$user->get_uk_id().") as 'training_per_day',
(select
if(sum(if(trd = object_date, 1, 0)) > 0,
1,
0)
from
(select
tr_date trd
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$user->get_uk_id()."
and tr_date >= (SELECT
tr_date
from
presence
join training ON tr_id = pr_training_tr_id
join user_kid ON uk_id = pr_user_kid_uk_id
where
pr_user_kid_uk_id = ".$user->get_uk_id()."
and date(tr_date) = uk_first_training
ORDER BY tr_date ASC
limit 1)
order by tr_date ASC
limit 2) elso2edzes) as 'first_two'
FROM
((SELECT
pr_training_tr_id as object_id,
timestamp(tr_date) as object_date,
if(pr_training_tr_id is not null, 'training', null) as object_type
FROM
presence
JOIN training ON tr_id = pr_training_tr_id
WHERE
pr_user_kid_uk_id = ".$user->get_uk_id()."
AND tr_deleted = 0) UNION (SELECT
mod_id,
timestamp(mod_date),
if(mod_id is not null, 'money_deposit', null) as object_type
FROM
money_deposit
WHERE
mod_user_kid_uk_id = ".$user->get_uk_id()."
and mod_deleted = 0)) actions
order by object_date ASC;
";
$action_assoc_array = $sql->assoc_array($action_list_query);
$actions = array();
$de_array = array();
foreach ($action_assoc_array as $action) {
if ($action['object_type'] == 'training') {
$new_training = new training();
$new_training->set_training_data_by_id($action['object_id']);
//$actions[] = $new_training;
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], $action['training_per_month'], $action['training_per_day'], $action['first_two'], $new_training);
}
elseif ($action['object_type'] == 'money_deposit') {
$new_mod = new money_deposit();
$new_mod->set_mod_data_by_id($action['object_id']);
//$actions[] = $new_mod;
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], $action['training_per_month'], $action['training_per_day'], $action['first_two'], null, $new_mod);
}
$de_array[] = $new_diary_entry;
}
//itt csak hivatkozással adjuk át a tömböt, a calculate_balance kiszámolja, belerakja és visszadja
$user->calculate_balance($de_array, $user);
//var_dump($de_array);
//$smarty->assign('actions', $actions);
}
?>