From 7bd93e173029d3c9420589ba0b3aba11990e3946 Mon Sep 17 00:00:00 2001 From: Ricsi Date: Sun, 30 Apr 2017 00:31:26 +0200 Subject: [PATCH] added money_expense to coach preview --- _class/class_money_expense.php | 53 ++++++-- _css/default_coach.css | 10 +- template/templates/coach_diary.tpl | 114 ++++++++++++------ template/templates/money_expense.tpl | 4 +- template/templates/money_expense_create.tpl | 3 +- .../templates/money_expense_data_edit.tpl | 2 +- 6 files changed, 133 insertions(+), 53 deletions(-) diff --git a/_class/class_money_expense.php b/_class/class_money_expense.php index 3f175ac..84558e7 100644 --- a/_class/class_money_expense.php +++ b/_class/class_money_expense.php @@ -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, diff --git a/_css/default_coach.css b/_css/default_coach.css index 29c4962..657b0f0 100644 --- a/_css/default_coach.css +++ b/_css/default_coach.css @@ -30,13 +30,13 @@ ul.topnav li a:hover, ul.topnav li a span:hover { } div.list div.money_deposit { - background-color: #0F1953; - border-left: 2px solid #2281DD; - color: #020372; + background-color: #9FC0E1; + border-left: 2px solid #002E4C; + color: #101469; } .list .money_deposit:hover { - background-color: #F3BF75; + background-color: #5D5FDB; border-left: 2px solid #000; - color: #2281DD; + color: #fff; } \ No newline at end of file diff --git a/template/templates/coach_diary.tpl b/template/templates/coach_diary.tpl index b162e88..202e71f 100644 --- a/template/templates/coach_diary.tpl +++ b/template/templates/coach_diary.tpl @@ -1,43 +1,87 @@
-{foreach $trainings as $training} - {if - $training@first || - ( - $trainings[$training@index]->get_tr_date()|substr:5:2 != $trainings[$training@index-1]->get_tr_date()|substr:5:2 - ) - - } - {if !$training@first && - $trainings[$training@index]->get_tr_date()|substr:5:2 != $trainings[$training@index-1]->get_tr_date()|substr:5:2 - } -
- {/if} - {$trainings[$training@index]->get_tr_date()|substr:0:4}. - {$months[$trainings[$training@index]->get_tr_date()|substr:5:2]} ({$user_login->get_training_count_in_month($training->get_tr_date()|substr:0:4,$training->get_tr_date()|substr:5:2)}) - - -
- {/if} -
- - {$training->get_tr_date()|substr:0:4}. - {$months[$trainings[$training@index]->get_tr_date()|substr:5:2]} - {$training->get_tr_date_day()}. - {$days[$training->get_tr_date_day_of_week()]} - {$training->get_tr_date_time()} +{foreach $actions as $action} + {if $actions[$action@index]|is_a:'training'} + {if !$action@first && + $actions[$action@index-1]|is_a:'training' && + $actions[$action@index]->get_tr_date()|substr:5:2 != $actions[$action@index-1]->get_tr_date()|substr:5:2 + + || + + !$action@first && + $actions[$action@index-1]|is_a:'money_expense' && + $actions[$action@index]->get_tr_date()|substr:5:2 != $actions[$action@index-1]->get_mox_date()|substr:5:2 + + } +
+ + {$actions[$action@index]->get_tr_date()|substr:0:4}. + {$months[$actions[$action@index]->get_tr_date()|substr:5:2]} ({$user_login->get_training_count_in_month($action->get_tr_date()|substr:0:4,$action->get_tr_date()|substr:5:2)} edzés) + -
- {if $training->get_tr_training_type_trt_id()}{$training->get_tr_type_name_by_id()} edzés{/if} - {$training->get_tr_duration()} p - {if $training->is_coach()} - {foreach $training->get_tr_coaches_name() as $coach_name} - {if $coach_name@first}({/if}{$coach_name}{if $coach_name@last}){else}, {/if} - {/foreach} +
+ {elseif $action@first} + {$actions[$action@index]->get_tr_date()|substr:0:4}. + {$months[$actions[$action@index]->get_tr_date()|substr:5:2]} ({$user_login->get_training_count_in_month($action->get_tr_date()|substr:0:4,$action->get_tr_date()|substr:5:2)} edzés) + + +
{/if} +
+ + {$action->get_tr_date()|substr:0:4}. + {$months[$actions[$action@index]->get_tr_date()|substr:5:2]} + {$action->get_tr_date_day()}. + {$days[$action->get_tr_date_day_of_week()]} + {$action->get_tr_date_time()} + +
+ {if $action->get_tr_training_type_trt_id()}{$action->get_tr_type_name_by_id()} edzés{/if} + {$action->get_tr_duration()} p + {if $action->is_coach()} + {foreach $action->get_tr_coaches_name() as $coach_name} + {if $coach_name@first}({/if}{$coach_name}{if $coach_name@last}){else}, {/if} + {/foreach} + {/if} +
+ {elseif $actions[$action@index]|is_a:'money_expense'} + {if !$action@first && + $actions[$action@index-1]|is_a:'training' && + $actions[$action@index]->get_mox_date()|substr:5:2 != $actions[$action@index-1]->get_tr_date()|substr:5:2 + || -
- {if $training@last} + !$action@first && + $actions[$action@index-1]|is_a:'money_expense' && + $actions[$action@index]->get_mox_date()|substr:5:2 != $actions[$action@index-1]->get_mox_date()|substr:5:2 + + } +
+ + {$actions[$action@index]->get_mox_date()|substr:0:4}. + {$months[$actions[$action@index]->get_mox_date()|substr:5:2]} ({$user_login->get_training_count_in_month($action->get_mox_date()|substr:0:4,$action->get_mox_date()|substr:5:2)} edzés) + + +
+ {elseif $action@first} + {$actions[$action@index]->get_mox_date()|substr:0:4}. + {$months[$actions[$action@index]->get_mox_date()|substr:5:2]} ({$user_login->get_training_count_in_month($action->get_mox_date()|substr:0:4,$action->get_mox_date()|substr:5:2)} edzés) + + +
+ {/if} +
+ + {$action->get_mox_date()|substr:0:4}. + {$months[$actions[$action@index]->get_mox_date()|substr:5:2]} + {$action->get_mox_date_day()}. + +
+ {$action->get_mox_item()} +
+ {$action->get_mox_sum()|number_format:0:'':' '} Ft +
+ {/if} + {if $action@last}
{/if} {/foreach} diff --git a/template/templates/money_expense.tpl b/template/templates/money_expense.tpl index 7e5b2bd..49006b6 100644 --- a/template/templates/money_expense.tpl +++ b/template/templates/money_expense.tpl @@ -34,7 +34,9 @@ {if $mox->get_mox_money_expense_category_moxc_id()}{$mox->get_mox_moxc()->get_moxc_name()}{else}nincs megadva{/if} - {$mox->get_mox_name()} + {if $mox->get_mox_coach()|is_a:'user'} + {$mox->get_mox_coach()->get_ua_name()} + {/if} {$mox->get_mox_item()} diff --git a/template/templates/money_expense_create.tpl b/template/templates/money_expense_create.tpl index 93434c8..484b701 100644 --- a/template/templates/money_expense_create.tpl +++ b/template/templates/money_expense_create.tpl @@ -9,9 +9,8 @@
-
+
-
diff --git a/template/templates/money_expense_data_edit.tpl b/template/templates/money_expense_data_edit.tpl index 52fbf4b..6063161 100644 --- a/template/templates/money_expense_data_edit.tpl +++ b/template/templates/money_expense_data_edit.tpl @@ -8,7 +8,7 @@
-
+