added money_expense to coach preview
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
|
||||
class money_expense {
|
||||
private $mox_id;
|
||||
private $mox_name;
|
||||
private $mox_user_coach_ua_id;
|
||||
private $mox_coach = null; //user obj
|
||||
private $mox_date;
|
||||
private $mox_item;
|
||||
private $mox_sum;
|
||||
@@ -16,8 +17,8 @@ class money_expense {
|
||||
$this->mox_id = $_item;
|
||||
}
|
||||
|
||||
public function set_mox_name($_item) {
|
||||
$this->mox_name = $_item;
|
||||
public function set_mox_user_coach_ua_id($_item) {
|
||||
$this->mox_user_coach_ua_id = $_item;
|
||||
}
|
||||
|
||||
public function set_mox_date($_item) {
|
||||
@@ -40,6 +41,10 @@ class money_expense {
|
||||
$this->mox_moxc = $_item;
|
||||
}
|
||||
|
||||
public function set_mox_coach($_item) {
|
||||
$this->mox_coach = $_item;
|
||||
}
|
||||
|
||||
|
||||
public function set_mox_deleted($_item) {
|
||||
$this->mox_deleted = $_item;
|
||||
@@ -49,12 +54,18 @@ class money_expense {
|
||||
return $this->mox_id;
|
||||
}
|
||||
|
||||
public function get_mox_name() {
|
||||
return $this->mox_name;
|
||||
public function get_mox_user_coach_ua_id() {
|
||||
return $this->mox_user_coach_ua_id;
|
||||
}
|
||||
|
||||
public function get_mox_date() {
|
||||
return $this->mox_date;
|
||||
public function get_mox_date($_formatted = false) {
|
||||
return !$_formatted ? $this->mox_date : date("Y. F d. H:i", strtotime($this->mox_date));
|
||||
}
|
||||
|
||||
public function get_mox_date_day() {
|
||||
$day = date("d", strtotime($this->mox_date));
|
||||
if (substr($day, 0, 1) == '0') return substr($day, 1, 1);
|
||||
return date("d", strtotime($this->mox_date));
|
||||
}
|
||||
|
||||
public function get_mox_item() {
|
||||
@@ -69,6 +80,10 @@ class money_expense {
|
||||
return $this->mox_moxc;
|
||||
}
|
||||
|
||||
public function get_mox_coach() {
|
||||
return $this->mox_coach;
|
||||
}
|
||||
|
||||
public function get_mox_money_expense_category_moxc_id() {
|
||||
return $this->mox_moxc_id;
|
||||
}
|
||||
@@ -77,6 +92,20 @@ class money_expense {
|
||||
return $this->mox_deleted;
|
||||
}
|
||||
|
||||
private static function name_to_ua_id($_ua_name) {
|
||||
global $sql;
|
||||
//a paraméterül kapott nevet megpróbálja coach ID-ra alakítani
|
||||
//ha sikerül, akkor visszaadja a coach ID-t
|
||||
//egyébként beszúr egy újat, törölt stáusszal, majd visszatér annak az id-jával
|
||||
if ($sql->num_of_rows("select ua_id from user_coach where ua_name = '".$_ua_name."';")) {
|
||||
return $sql->single_variable("select ua_id from user_coach where ua_name = '".$_ua_name."';");
|
||||
}
|
||||
else {
|
||||
return $sql->insert_into('user_coach', array('ua_name' => $_ua_name, 'ua_deleted' => 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function set_mox_data_by_id($_id) {
|
||||
global $sql;
|
||||
$set_data_assoc_array = $sql->assoc_array("select * from money_expense where mox_id = " . $_id);
|
||||
@@ -90,6 +119,12 @@ class money_expense {
|
||||
$new_moxc->set_moxc_data_by_id($value);
|
||||
$this->set_mox_moxc($new_moxc);
|
||||
}
|
||||
|
||||
if ($field == 'mox_user_coach_ua_id' && $value != null) {
|
||||
$new_user = new user();
|
||||
$new_user->set_user_data_by_id($value);
|
||||
$this->set_mox_coach($new_user);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,7 +133,7 @@ class money_expense {
|
||||
global $sql;
|
||||
|
||||
return $sql->insert_into('money_expense', array(
|
||||
'mox_name' => $_name,
|
||||
'mox_user_coach_ua_id' => (empty($_name)?'null':self::name_to_ua_id($_name)),
|
||||
'mox_date' => $_date,
|
||||
'mox_item' => $_item,
|
||||
'mox_sum' => $_sum,
|
||||
@@ -111,7 +146,7 @@ class money_expense {
|
||||
|
||||
$sql->update_table('money_expense',
|
||||
array(
|
||||
'mox_name' => $_name,
|
||||
'mox_user_coach_ua_id' => (empty($_name)?'null':self::name_to_ua_id($_name)),
|
||||
'mox_date' => $_date,
|
||||
'mox_item' => $_item,
|
||||
'mox_sum' => $_sum,
|
||||
|
||||
Reference in New Issue
Block a user