extended user diary, added diary entry class, added view deposit option to user list
This commit is contained in:
@@ -7,6 +7,7 @@ class user_kid extends user_parent {
|
||||
private $user_id;
|
||||
private $user_name;
|
||||
private $user_is_active;
|
||||
private $user_balance;
|
||||
private $user_last_name;
|
||||
private $user_first_name;
|
||||
private $user_password;
|
||||
@@ -242,6 +243,12 @@ class user_kid extends user_parent {
|
||||
public function get_uk_school() {
|
||||
return $this->user_school;
|
||||
}
|
||||
public function set_uk_balance($_balance) {
|
||||
$this->user_balance = $_balance;
|
||||
}
|
||||
public function get_uk_balance() {
|
||||
return $this->user_balance;
|
||||
}
|
||||
public function is_logged_in() {
|
||||
//leellenőrzi cookie alapján h be vagyunk-e jelentkezve
|
||||
//JAVÍTVA: adja vissza az adattag igazságértékét
|
||||
@@ -446,5 +453,59 @@ class user_kid extends user_parent {
|
||||
if (!isset($_user_value_array['uk_is_active'])) $_user_value_array['uk_is_active'] = 0;
|
||||
$sql->update_table('user_kid', $_user_value_array, array('uk_id' => $_user_id));
|
||||
}
|
||||
|
||||
public function calculate_balance(&$_de_obj_array, $_user_obj = null) {
|
||||
//kiszámolja az egyenleget a diary entry-k alapján, amik tömbben érkeznek
|
||||
//a tömbben feltölti a pénzmozgást, és minden lépésben befrissíti az egyenleget
|
||||
//az update-elt tömböt adja vissza
|
||||
//ha user_obj null, akkor az aktuális usernél állítja be
|
||||
global $sql;
|
||||
|
||||
//kezdetben 0
|
||||
$balance = 0;
|
||||
foreach ($_de_obj_array as $i => $_de) {
|
||||
//minden lépésben az balance-t be kell állítani az előző lépésben updatelt balance-ra
|
||||
if (isset($_de_obj_array[$i-1])) {
|
||||
$_de->set_de_balance($_de_obj_array[$i-1]->get_de_balance());
|
||||
}
|
||||
if ($_de->get_de_type() == 'training') {
|
||||
//ha edzés, akkor -1000 levonás, kivéve, ha kedvezményes:
|
||||
//1-nél több edzés / nap
|
||||
//8-nál több edzés / hónap
|
||||
//első két alkalom egyike
|
||||
//var_dump($_de);
|
||||
//echo $_de->get_de_first_two() . '<br>';
|
||||
//echo $_de->get_de_training_per_month() . '<br>';
|
||||
//echo $_de->get_de_training_per_day() . '<br><br><br>';
|
||||
if ($_de->get_de_first_two() > 0 || $_de->get_de_training_per_month() > 8 || $_de->get_de_training_per_day() > 1) {
|
||||
//do nothing
|
||||
$_de->set_de_transaction(0);
|
||||
$_de->set_de_has_discount(true);
|
||||
//TODO: ha van már havi 8+ akk ne nézze a duplázót!
|
||||
if ($_de->get_de_first_two() > 0) $_de->set_de_discount_id(1);
|
||||
if ($_de->get_de_training_per_day() > 1) $_de->set_de_discount_id(3);
|
||||
if ($_de->get_de_training_per_month() > 8) $_de->set_de_discount_id(2);
|
||||
}
|
||||
else {
|
||||
//$balance -= 1000;
|
||||
$_de->set_de_transaction(-1000); //beállítjuk, mennyivel csökken az egyenleg
|
||||
$_de->set_de_balance($_de->get_de_balance()+$_de->get_de_transaction()); //beállítjuk az új egyenleget
|
||||
//echo $_de->get_de_date() . " minusz 1000<br><br>";
|
||||
}
|
||||
}
|
||||
elseif ($_de->get_de_type() == 'money_deposit') {
|
||||
$_de->set_de_transaction($_de->get_de_money_deposit()->get_mod_sum());
|
||||
$_de->set_de_balance($_de->get_de_balance()+$_de->get_de_transaction());
|
||||
//$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>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql->update_table('user_kid', (array('uk_balance' => $_de->get_de_balance())), array('uk_id' => (is_object($_user_obj)?$_user_obj->get_uk_id():$this->get_uk_id())), false);
|
||||
|
||||
return $_de_obj_array;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user