big changes
everything with lease and expire dates
This commit is contained in:
@@ -587,7 +587,11 @@ class user_kid extends user_parent {
|
||||
}
|
||||
elseif ($_de->get_de_type() == 'money_deposit') {
|
||||
$_de->set_de_transaction($_de->get_de_money_deposit()->get_mod_money_income()->get_mi_sum());
|
||||
$_de->set_de_balance($_de->get_de_balance()+$_de->get_de_transaction());
|
||||
if (!$_de->get_de_expired()) {
|
||||
$_de->set_de_balance($_de->get_de_balance()+$_de->get_de_transaction());
|
||||
} else {
|
||||
$_de->set_de_balance(0);
|
||||
}
|
||||
//$balance += $_de->get_de_money_deposit()->get_mod_sum();
|
||||
//echo $_de->get_de_date() . " plussz " . $_de->get_de_money_deposit()->get_mod_sum() . "<br><br>";
|
||||
}
|
||||
@@ -600,20 +604,20 @@ class user_kid extends user_parent {
|
||||
return $_de_obj_array;
|
||||
}
|
||||
|
||||
public function get_groups() {
|
||||
global $sql;
|
||||
// public function get_groups() {
|
||||
// global $sql;
|
||||
|
||||
$group_array = array();
|
||||
$g_assoc = $sql->assoc_array("select * from user_group_kid join user_group on ug_id = ugk_user_group_ug_id where ug_is_automatic = 1 and ugk_user_kid_uk_id = ".$this->get_uk_id().";");
|
||||
// $group_array = array();
|
||||
// $g_assoc = $sql->assoc_array("select * from user_group_kid join user_group on ug_id = ugk_user_group_ug_id where ug_is_automatic = 1 and ugk_user_kid_uk_id = ".$this->get_uk_id().";");
|
||||
|
||||
foreach ($g_assoc as $g) {
|
||||
$group = new user_group();
|
||||
$group->set_ug_data_by_id($g['ugk_user_group_ug_id']);
|
||||
$group_array[] = $group;
|
||||
}
|
||||
// foreach ($g_assoc as $g) {
|
||||
// $group = new user_group();
|
||||
// $group->set_ug_data_by_id($g['ugk_user_group_ug_id']);
|
||||
// $group_array[] = $group;
|
||||
// }
|
||||
|
||||
return $group_array;
|
||||
}
|
||||
// return $group_array;
|
||||
// }
|
||||
|
||||
public function update_balance() {
|
||||
global $sql;
|
||||
@@ -622,35 +626,39 @@ class user_kid extends user_parent {
|
||||
|
||||
$action_list_query = "
|
||||
SELECT
|
||||
object_id,
|
||||
timestamp(object_date) as object_date,
|
||||
object_type
|
||||
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
|
||||
object_id,
|
||||
TIMESTAMP(object_date) AS object_date,
|
||||
object_type,
|
||||
expire_date,
|
||||
IF(expire_date <= NOW(), 1, 0) AS expired
|
||||
FROM
|
||||
presence
|
||||
JOIN training ON (tr_id = pr_training_tr_id AND tr_locked = 1)
|
||||
WHERE
|
||||
pr_user_kid_uk_id = ".$userId."
|
||||
AND tr_deleted = 0) UNION (SELECT
|
||||
mod_id,
|
||||
timestamp(mi_date),
|
||||
if(mod_id is not null, 'money_deposit', null) as object_type
|
||||
FROM
|
||||
money_deposit
|
||||
JOIN
|
||||
money_income ON mi_id = mod_money_income_mi_id
|
||||
WHERE
|
||||
mod_user_kid_uk_id = ".$userId."
|
||||
and mod_deleted = 0)) actions
|
||||
order by object_date ASC;
|
||||
((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,
|
||||
NULL AS expire_date
|
||||
FROM
|
||||
presence
|
||||
JOIN training ON (tr_id = pr_training_tr_id
|
||||
AND tr_locked = 1)
|
||||
WHERE
|
||||
pr_user_kid_uk_id = ".$userId."
|
||||
AND tr_deleted = 0) UNION (SELECT
|
||||
mod_id,
|
||||
TIMESTAMP(mi_date),
|
||||
IF(mod_id IS NOT NULL, 'money_deposit', NULL) AS object_type,
|
||||
mod_expire_date AS expire_date
|
||||
FROM
|
||||
money_deposit
|
||||
JOIN money_income ON mi_id = mod_money_income_mi_id
|
||||
WHERE
|
||||
mod_user_kid_uk_id = ".$userId."
|
||||
AND mod_deleted = 0)) actions
|
||||
ORDER BY object_date ASC;
|
||||
";
|
||||
|
||||
$action_assoc_array = $sql->assoc_array($action_list_query);
|
||||
|
||||
var_dump($action_assoc_array);
|
||||
$actions = array();
|
||||
$de_array = array();
|
||||
foreach ($action_assoc_array as $action) {
|
||||
@@ -660,13 +668,14 @@ class user_kid extends user_parent {
|
||||
$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'], 0, 0, 0, $new_training);
|
||||
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], 0, 0, 0, 0, $new_training, null);
|
||||
}
|
||||
elseif ($action['object_type'] == 'money_deposit') {
|
||||
$new_mod = new money_deposit();
|
||||
$new_mod->set_mod_data_by_id($action['object_id']);
|
||||
//var_dump($new_mod);
|
||||
//$actions[] = $new_mod;
|
||||
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], 0, 0, 0, null, $new_mod);
|
||||
$new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], 0, 0, 0, $action['expired'], null, $new_mod);
|
||||
}
|
||||
|
||||
$de_array[] = $new_diary_entry;
|
||||
@@ -702,5 +711,42 @@ class user_kid extends user_parent {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function balance_meta_update() {
|
||||
global $sql;
|
||||
|
||||
$lastDeposit = 'null';
|
||||
$expireDate = 'null';
|
||||
|
||||
$deposits = $sql->assoc_array('
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
money_deposit
|
||||
JOIN
|
||||
money_income ON mi_id = mod_money_income_mi_id
|
||||
WHERE
|
||||
mod_user_kid_uk_id = '.$this->get_uk_id().'
|
||||
AND mod_deleted = 0
|
||||
AND mod_expire_date > NOW()
|
||||
ORDER BY mi_date DESC
|
||||
LIMIT 1;
|
||||
');
|
||||
|
||||
if (count($deposits)) {
|
||||
$lastDeposit = $deposits[0]['mi_date'];
|
||||
$expireDate = money_deposit::calculate_expire_date($deposits[0]['mod_id']);
|
||||
}
|
||||
|
||||
$sql->update_table('user_kid',
|
||||
array(
|
||||
'uk_last_deposit' => $lastDeposit,
|
||||
'uk_balance_expire_date' => $expireDate,
|
||||
),
|
||||
array(
|
||||
'uk_id' => $this->get_uk_id(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user