balance list can be sorted. balanace can be updated
This commit is contained in:
@@ -1,27 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
# HA NINCS ID, AKKOR EGYENLEGLISTA
|
# HA NINCS ID, AKKOR EGYENLEGLISTA
|
||||||
# HA VAN ID, AKKOR EMPTY
|
# HA VAN ID, AKKOR RENDEZÉS IS VAN
|
||||||
|
|
||||||
if ($this->is_id()) {
|
if ($this->is_id()) {
|
||||||
# EMPTY
|
# RENDEZÉS
|
||||||
|
|
||||||
|
/*
|
||||||
|
1 - egyenleg szerint növekvő
|
||||||
|
*/
|
||||||
|
|
||||||
|
$order_by = 'uk_balance ASC';
|
||||||
|
$url_postfix = '/' . $this->get_id();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# EGYENLEG LISTA
|
# EGYENLEG LISTA
|
||||||
|
$order_by = 'uk_name ASC';
|
||||||
$active_kid_assoc_array = $sql->assoc_array('select * from user_kid where uk_deleted = 0 and uk_is_active = 1 order by uk_name asc;');
|
$url_postfix = '';
|
||||||
$user_kids = array();
|
|
||||||
foreach ($active_kid_assoc_array as $kid) {
|
|
||||||
$new_kid = new user_kid();
|
|
||||||
$new_kid->set_user_data_by_id($kid['uk_id']);
|
|
||||||
$user_kids[] = $new_kid;
|
|
||||||
}
|
|
||||||
|
|
||||||
$smarty->assign('user_kids', $user_kids);
|
|
||||||
$smarty->display('user_balance_list.tpl');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$active_kid_assoc_array = $sql->assoc_array('select * from user_kid where uk_deleted = 0 and uk_is_active = 1 order by '. $order_by .';');
|
||||||
|
$user_kids = array();
|
||||||
|
foreach ($active_kid_assoc_array as $kid) {
|
||||||
|
$new_kid = new user_kid();
|
||||||
|
$new_kid->set_user_data_by_id($kid['uk_id']);
|
||||||
|
$user_kids[] = $new_kid;
|
||||||
|
}
|
||||||
|
|
||||||
|
$smarty->assign('user_kids', $user_kids);
|
||||||
|
$smarty->assign('url_postfix', $url_postfix);
|
||||||
|
$smarty->display('user_balance_list.tpl');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -9,28 +9,64 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# EDZÉS LISTA
|
# EDZÉS LISTA
|
||||||
|
|
||||||
$action_list_query = "
|
$action_list_query = "
|
||||||
SELECT
|
SELECT
|
||||||
object_id,
|
object_id,
|
||||||
timestamp(object_date) as object_date,
|
timestamp(object_date) as object_date,
|
||||||
object_type,
|
object_type,
|
||||||
(SELECT
|
(SELECT
|
||||||
count(distinct date(tr_date))
|
count(distinct date(tr_date))
|
||||||
FROM
|
FROM
|
||||||
presence
|
presence
|
||||||
JOIN
|
JOIN
|
||||||
training ON tr_id = pr_training_tr_id
|
training ON tr_id = pr_training_tr_id
|
||||||
WHERE
|
WHERE
|
||||||
YEAR(tr_date) = YEAR(object_date)
|
YEAR(tr_date) = YEAR(object_date)
|
||||||
AND MONTH(tr_date) = MONTH(object_date)
|
AND MONTH(tr_date) = MONTH(object_date)
|
||||||
AND tr_date <= object_date
|
AND tr_date <= object_date
|
||||||
AND pr_user_kid_uk_id = ".$user->get_uk_id()."
|
AND pr_user_kid_uk_id = ".$user->get_uk_id()."
|
||||||
AND tr_date > (select
|
AND tr_date > (select
|
||||||
if(max(trd) is null,
|
if(max(trd) is null,
|
||||||
'1900-01-01',
|
'1900-01-01',
|
||||||
max(trd))
|
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
|
from
|
||||||
(select
|
(select
|
||||||
tr_date trd
|
tr_date trd
|
||||||
@@ -52,95 +88,61 @@
|
|||||||
ORDER BY tr_date ASC
|
ORDER BY tr_date ASC
|
||||||
limit 1)
|
limit 1)
|
||||||
order by tr_date ASC
|
order by tr_date ASC
|
||||||
limit 2) as elso_ket_edzes)) as 'training_per_month',
|
limit 2) elso2edzes) as 'first_two'
|
||||||
(SELECT
|
|
||||||
count(pr_id)
|
|
||||||
FROM
|
FROM
|
||||||
presence
|
((SELECT
|
||||||
JOIN
|
pr_training_tr_id as object_id,
|
||||||
training ON tr_id = pr_training_tr_id
|
timestamp(tr_date) as object_date,
|
||||||
WHERE
|
if(pr_training_tr_id is not null, 'training', null) as object_type
|
||||||
DATE(tr_date) = DATE(object_date)
|
FROM
|
||||||
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
|
presence
|
||||||
join training ON tr_id = pr_training_tr_id
|
JOIN training ON tr_id = pr_training_tr_id
|
||||||
join user_kid ON uk_id = pr_user_kid_uk_id
|
WHERE
|
||||||
where
|
|
||||||
pr_user_kid_uk_id = ".$user->get_uk_id()."
|
pr_user_kid_uk_id = ".$user->get_uk_id()."
|
||||||
and tr_date >= (SELECT
|
AND tr_deleted = 0) UNION (SELECT
|
||||||
tr_date
|
mod_id,
|
||||||
from
|
timestamp(mod_date),
|
||||||
presence
|
if(mod_id is not null, 'money_deposit', null) as object_type
|
||||||
join training ON tr_id = pr_training_tr_id
|
FROM
|
||||||
join user_kid ON uk_id = pr_user_kid_uk_id
|
money_deposit
|
||||||
where
|
WHERE
|
||||||
pr_user_kid_uk_id = ".$user->get_uk_id()."
|
mod_user_kid_uk_id = ".$user->get_uk_id()."
|
||||||
and date(tr_date) = uk_first_training
|
and mod_deleted = 0)) actions
|
||||||
ORDER BY tr_date ASC
|
order by object_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);
|
$action_assoc_array = $sql->assoc_array($action_list_query);
|
||||||
|
|
||||||
$actions = array();
|
$actions = array();
|
||||||
$de_array = array();
|
$de_array = array();
|
||||||
foreach ($action_assoc_array as $action) {
|
foreach ($action_assoc_array as $action) {
|
||||||
|
|
||||||
|
|
||||||
if ($action['object_type'] == 'training') {
|
if ($action['object_type'] == 'training') {
|
||||||
$new_training = new training();
|
$new_training = new training();
|
||||||
$new_training->set_training_data_by_id($action['object_id']);
|
$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);
|
$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') {
|
elseif ($action['object_type'] == 'money_deposit') {
|
||||||
$new_mod = new money_deposit();
|
$new_mod = new money_deposit();
|
||||||
$new_mod->set_mod_data_by_id($action['object_id']);
|
$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);
|
$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;
|
$de_array[] = $new_diary_entry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//itt csak hivatkozással adjuk át a tömböt, a calculate_balance kiszámolja, belerakja és visszadja
|
//itt csak hivatkozással adjuk át a tömböt, a calculate_balance kiszámolja, belerakja és visszadja
|
||||||
$user->calculate_balance($de_array, $user);
|
$user->calculate_balance($de_array, $user);
|
||||||
//var_dump($de_array);
|
//var_dump($de_array);
|
||||||
//$smarty->assign('actions', $actions);
|
//$smarty->assign('actions', $actions);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header('Location: /admin/balance_list' . ($this->is_id()?'/'.$this->get_id():''));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
|
<div class="buttons">
|
||||||
|
|
||||||
|
<a href="/admin/balance_list" class="addbutton big">Név szerinti rendezés</a>
|
||||||
|
<a href="/admin/balance_list/1" class="addbutton big">Egyenleg szerinti rendezés</a>
|
||||||
|
<a href="/admin/money_update{$url_postfix}" class="addbutton add-big">Egyenleg frissítése</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="list">
|
<div class="list">
|
||||||
{foreach $user_kids as $user}
|
{foreach $user_kids as $user}
|
||||||
<a href="#">
|
<a href="#">
|
||||||
|
|||||||
Reference in New Issue
Block a user