fix user bugs
This commit is contained in:
@@ -1,177 +1,177 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
USER CLASS
|
||||
ősosztály
|
||||
USER COACH adatszerkezet
|
||||
az öszes user rendelkezik ezekkel a tulajdonságokkal
|
||||
USER CLASS
|
||||
ősosztály
|
||||
USER COACH adatszerkezet
|
||||
az öszes user rendelkezik ezekkel a tulajdonságokkal
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class user {
|
||||
private $user_id;
|
||||
private $user_name;
|
||||
private $user_last_name;
|
||||
private $user_first_name;
|
||||
private $user_password;
|
||||
private $user_last_login;
|
||||
private $user_admin;
|
||||
private $logged_in;
|
||||
private $user_type;
|
||||
private $user_deleted;
|
||||
private $user_id;
|
||||
private $user_name;
|
||||
private $user_last_name;
|
||||
private $user_first_name;
|
||||
private $user_password;
|
||||
private $user_last_login;
|
||||
private $user_admin;
|
||||
private $logged_in;
|
||||
private $user_type;
|
||||
private $user_deleted;
|
||||
|
||||
public function set_ua_id($_uid) {
|
||||
$this->user_id = $_uid;
|
||||
}
|
||||
public function set_ua_id($_uid) {
|
||||
$this->user_id = $_uid;
|
||||
}
|
||||
|
||||
public function set_ua_name($_uname) {
|
||||
$this->user_name = $_uname;
|
||||
}
|
||||
public function set_ua_name($_uname) {
|
||||
$this->user_name = $_uname;
|
||||
}
|
||||
|
||||
public function set_ua_last_name($_u_last_name) {
|
||||
$this->user_last_name = $_u_last_name;
|
||||
}
|
||||
public function set_ua_last_name($_u_last_name) {
|
||||
$this->user_last_name = $_u_last_name;
|
||||
}
|
||||
|
||||
public function set_ua_first_name($_u_first_name) {
|
||||
$this->user_first_name = $_u_first_name;
|
||||
}
|
||||
public function set_ua_first_name($_u_first_name) {
|
||||
$this->user_first_name = $_u_first_name;
|
||||
}
|
||||
|
||||
public function set_ua_password($_u_pass) {
|
||||
$this->user_password = $_u_pass;
|
||||
}
|
||||
public function set_ua_password($_u_pass) {
|
||||
$this->user_password = $_u_pass;
|
||||
}
|
||||
|
||||
public function set_ua_last_login($_u_last_login) {
|
||||
$this->user_last_login = $_u_last_login;
|
||||
}
|
||||
public function set_ua_last_login($_u_last_login) {
|
||||
$this->user_last_login = $_u_last_login;
|
||||
}
|
||||
|
||||
public function set_ua_admin($_u_admin) {
|
||||
$this->user_admin = $_u_admin;
|
||||
}
|
||||
public function set_ua_admin($_u_admin) {
|
||||
$this->user_admin = $_u_admin;
|
||||
}
|
||||
|
||||
public function set_ua_deleted($_u_deleted) {
|
||||
$this->user_deleted = $_u_deleted;
|
||||
}
|
||||
public function set_ua_deleted($_u_deleted) {
|
||||
$this->user_deleted = $_u_deleted;
|
||||
}
|
||||
|
||||
public function get_ua_id() {
|
||||
return $this->user_id;
|
||||
}
|
||||
public function get_ua_id() {
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
public function get_ua_name() {
|
||||
return $this->user_name;
|
||||
}
|
||||
public function get_ua_name() {
|
||||
return $this->user_name;
|
||||
}
|
||||
|
||||
public function get_ua_last_name() {
|
||||
return $this->user_last_name;
|
||||
}
|
||||
public function get_ua_last_name() {
|
||||
return $this->user_last_name;
|
||||
}
|
||||
|
||||
public function get_ua_first_name() {
|
||||
return $this->user_first_name;
|
||||
}
|
||||
public function get_ua_first_name() {
|
||||
return $this->user_first_name;
|
||||
}
|
||||
|
||||
public function get_ua_password() {
|
||||
return $this->user_password;
|
||||
}
|
||||
public function get_ua_password() {
|
||||
return $this->user_password;
|
||||
}
|
||||
|
||||
public function get_ua_admin() {
|
||||
return $this->user_admin;
|
||||
}
|
||||
public function get_ua_admin() {
|
||||
return $this->user_admin;
|
||||
}
|
||||
|
||||
public function get_ua_deleted() {
|
||||
return $this->user_deleted;
|
||||
}
|
||||
public function get_ua_deleted() {
|
||||
return $this->user_deleted;
|
||||
}
|
||||
|
||||
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
|
||||
return $this->logged_in;
|
||||
}
|
||||
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
|
||||
return $this->logged_in;
|
||||
}
|
||||
|
||||
public function set_login($_login) {
|
||||
//bool-t kap paraméterül
|
||||
$this->logged_in = $_login;
|
||||
}
|
||||
public function set_login($_login) {
|
||||
//bool-t kap paraméterül
|
||||
$this->logged_in = $_login;
|
||||
}
|
||||
|
||||
public function set_user_data_by_id($_ua_id) {
|
||||
global $sql, $user;
|
||||
$user_data_assoc_array = $sql->assoc_array("select * from user_coach where ua_id = " . $_ua_id);
|
||||
$user_data_array = $user_data_assoc_array[0];
|
||||
foreach ($user_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
$this->set_ua_type(1); //coach típus beállítása
|
||||
$this->set_login(true);
|
||||
}
|
||||
public function set_user_data_by_id($_ua_id) {
|
||||
global $sql, $user;
|
||||
$user_data_assoc_array = $sql->assoc_array("select * from user_coach where ua_id = " . $_ua_id);
|
||||
$user_data_array = $user_data_assoc_array[0];
|
||||
foreach ($user_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
$this->set_ua_type(1); //coach típus beállítása
|
||||
$this->set_login(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function is_coach_at_training($_training_id) {
|
||||
global $sql;
|
||||
//kap egy training id-t, és megmondja, hogy az user be van-e jelölve edzőként azon az edzésen
|
||||
$query = "SELECT * FROM training_coach WHERE trc_coach_uc_id = '" . $this->get_ua_id() . "' AND trc_training_tr_id = '" . $_training_id ."' AND trc_helper = 0;";
|
||||
return $sql->num_of_rows($query);
|
||||
}
|
||||
public function is_coach_at_training($_training_id) {
|
||||
global $sql;
|
||||
//kap egy training id-t, és megmondja, hogy az user be van-e jelölve edzőként azon az edzésen
|
||||
$query = "SELECT * FROM training_coach WHERE trc_coach_uc_id = '" . $this->get_ua_id() . "' AND trc_training_tr_id = '" . $_training_id ."' AND trc_helper = 0;";
|
||||
return $sql->num_of_rows($query);
|
||||
}
|
||||
|
||||
public function is_helper_at_training($_training_id) {
|
||||
global $sql;
|
||||
//kap egy training id-t, és megmondja, hogy az user be van-e jelölve segédedzőként azon az edzésen
|
||||
$query = "SELECT * FROM training_coach WHERE trc_coach_uc_id = '" . $this->get_ua_id() . "' AND trc_training_tr_id = '" . $_training_id ."' AND trc_helper = 1;";
|
||||
return $sql->num_of_rows($query);
|
||||
}
|
||||
public function is_helper_at_training($_training_id) {
|
||||
global $sql;
|
||||
//kap egy training id-t, és megmondja, hogy az user be van-e jelölve segédedzőként azon az edzésen
|
||||
$query = "SELECT * FROM training_coach WHERE trc_coach_uc_id = '" . $this->get_ua_id() . "' AND trc_training_tr_id = '" . $_training_id ."' AND trc_helper = 1;";
|
||||
return $sql->num_of_rows($query);
|
||||
}
|
||||
|
||||
public function update_login_time($_ua_id = null) {
|
||||
global $sql;
|
||||
//az adott user_id-n updateli a login_time-ot
|
||||
$sql->update_table('user_coach', array('ua_last_login' => date('Y-m-d')), array('ua_id' => (empty($_ua_id)?$this->get_ua_id():$_ua_id)));
|
||||
}
|
||||
public function update_login_time($_ua_id = null) {
|
||||
global $sql;
|
||||
//az adott user_id-n updateli a login_time-ot
|
||||
$sql->update_table('user_coach', array('ua_last_login' => date('Y-m-d')), array('ua_id' => (empty($_ua_id)?$this->get_ua_id():$_ua_id)));
|
||||
}
|
||||
|
||||
public function set_ua_type($_type) {
|
||||
$this->user_type = $_type;
|
||||
}
|
||||
public function set_ua_type($_type) {
|
||||
$this->user_type = $_type;
|
||||
}
|
||||
|
||||
public function get_training_count_in_month($_year, $_month) {
|
||||
global $sql;
|
||||
return $sql->single_variable('select count(distinct trc_id) from training_coach join training on tr_id = trc_training_tr_id where year(tr_date) = '.$_year.' and month(tr_date) = '.$_month.' and trc_coach_uc_id = '.$this->get_ua_id().';');
|
||||
}
|
||||
public function get_training_count_in_month($_year, $_month) {
|
||||
global $sql;
|
||||
return $sql->single_variable('select count(distinct trc_id) from training_coach join training on tr_id = trc_training_tr_id where year(tr_date) = '.$_year.' and month(tr_date) = '.$_month.' and trc_coach_uc_id = '.$this->get_ua_id().' and tr_deleted = 0;');
|
||||
}
|
||||
|
||||
public static function create_user($_name, $_password) {
|
||||
global $sql;
|
||||
return $sql->insert_into('user_coach', array(
|
||||
'ua_name' => $_name,
|
||||
'ua_password' => $_password
|
||||
)
|
||||
);
|
||||
}
|
||||
public static function create_user($_name, $_password) {
|
||||
global $sql;
|
||||
return $sql->insert_into('user_coach', array(
|
||||
'ua_name' => $_name,
|
||||
'ua_password' => $_password
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function update_user($_name, $_password, $_admin, $_ua_id) {
|
||||
global $sql;
|
||||
if ($_password != "-1") {
|
||||
return $sql->update_table('user_coach',
|
||||
array(
|
||||
'ua_name' => $_name,
|
||||
'ua_admin' => ($_admin?1:0),
|
||||
'ua_password' => $_password
|
||||
),
|
||||
array(
|
||||
'ua_id' => $_ua_id
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $sql->update_table('user_coach',
|
||||
array(
|
||||
'ua_name' => $_name,
|
||||
'ua_admin' => ($_admin?1:0),
|
||||
),
|
||||
array(
|
||||
'ua_id' => $_ua_id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
public static function update_user($_name, $_password, $_admin, $_ua_id) {
|
||||
global $sql;
|
||||
if ($_password != "-1") {
|
||||
return $sql->update_table('user_coach',
|
||||
array(
|
||||
'ua_name' => $_name,
|
||||
'ua_admin' => ($_admin?1:0),
|
||||
'ua_password' => $_password
|
||||
),
|
||||
array(
|
||||
'ua_id' => $_ua_id
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return $sql->update_table('user_coach',
|
||||
array(
|
||||
'ua_name' => $_name,
|
||||
'ua_admin' => ($_admin?1:0),
|
||||
),
|
||||
array(
|
||||
'ua_id' => $_ua_id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -531,17 +531,17 @@ class user_kid extends user_parent {
|
||||
if ($_de->get_de_type() == 'training') {
|
||||
//ha edzés, akkor -1200 levonás, kivéve, ha kedvezményes:
|
||||
//1-nél több edzés / nap
|
||||
//8-nál több edzés / hónap
|
||||
//10-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) {
|
||||
if ($_de->get_de_first_two() > 0 || $_de->get_de_training_per_month() > 10 || $_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!
|
||||
//TODO: ha van már havi 10+ 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() > 10) $_de->set_de_discount_id(2);
|
||||
|
||||
Reference in New Issue
Block a user