extended user diary, added diary entry class, added view deposit option to user list
This commit is contained in:
@@ -9,44 +9,135 @@ else {
|
||||
|
||||
$action_list_query = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
((SELECT
|
||||
pr_training_tr_id as object_id,
|
||||
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,
|
||||
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 DESC;
|
||||
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_id 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_id 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;
|
||||
//$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;
|
||||
//$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;
|
||||
|
||||
}
|
||||
$smarty->assign('actions', $actions);
|
||||
|
||||
//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);
|
||||
$de_array = array_reverse($de_array);
|
||||
$smarty->assign('actions', $de_array);
|
||||
//$smarty->assign('balance', $balance);
|
||||
$smarty->display('user_diary.tpl');
|
||||
|
||||
}
|
||||
|
||||
31
_include/include_view_deposit.php
Normal file
31
_include/include_view_deposit.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
# HA NINCS ID, AKKOR SEMMI
|
||||
# HA VAN ID, AKKOR BEFIZETÉS / USER
|
||||
|
||||
|
||||
|
||||
if ($this->is_id()) {
|
||||
# USERHEZ TARTOZÓ BEFIZETÉSEK
|
||||
$user_mod_query = "SELECT * FROM money_deposit WHERE mod_user_kid_uk_id = " . $this->get_id() . " and mod_deleted = 0 ORDER BY mod_date DESC;";
|
||||
$umod_assoc_array = $sql->assoc_array($user_mod_query);
|
||||
|
||||
$mods = array();
|
||||
foreach ($umod_assoc_array as $key => $value) {
|
||||
$new_mod = new money_deposit();
|
||||
$new_mod->set_mod_data_by_id($value['mod_id']);
|
||||
$mods[] = $new_mod;
|
||||
}
|
||||
|
||||
$smarty->assign("mod_array", $mods);
|
||||
$smarty->assign("balance", $sql->single_variable('SELECT uk_balance FROM user_kid WHERE uk_id = ' . $this->get_id()));
|
||||
$smarty->assign("mod_user_kid_id", $this->get_id());
|
||||
$smarty->display("view_deposit.tpl");
|
||||
|
||||
}
|
||||
else {
|
||||
# EMPTY
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user