added money_expense to coach preview

This commit is contained in:
Ricsi
2017-04-30 00:31:26 +02:00
parent f1d6e2f002
commit 7bd93e1730
6 changed files with 133 additions and 53 deletions

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -1,43 +1,87 @@
<div class="list half_width">
{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
}
</div>
{/if}
<span onclick="block_action('block_{$training->get_tr_date()|substr:0:4}{$training->get_tr_date()|substr:5:2}');" class="date_separator clickable">{$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)})
<img src="/_image/open_folder.png">
</span>
<div id="block_{$training->get_tr_date()|substr:0:4}{$training->get_tr_date()|substr:5:2}" class="month_block">
{/if}
<div class="list_item line_height14 bigger_space">
<span class="size20 bold">
{$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
}
</div>
<span onclick="block_action('block_{$action->get_tr_date()|substr:0:4}{$action->get_tr_date()|substr:5:2}');" class="date_separator clickable">{$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)
<img src="/_image/open_folder.png">
</span>
<br>
{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}
<div id="block_{$action->get_tr_date()|substr:0:4}{$action->get_tr_date()|substr:5:2}" class="month_block">
{elseif $action@first}
<span onclick="block_action('block_{$action->get_tr_date()|substr:0:4}{$action->get_tr_date()|substr:5:2}');" class="date_separator clickable">{$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)
<img src="/_image/open_folder.png">
</span>
<div id="block_{$action->get_tr_date()|substr:0:4}{$action->get_tr_date()|substr:5:2}" class="month_block">
{/if}
<div class="list_item line_height14 bigger_space">
<span class="size20 bold">
{$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()}
</span>
<br>
{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}
</div>
{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
||
</div>
{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
}
</div>
<span onclick="block_action('block_{$action->get_mox_date()|substr:0:4}{$action->get_mox_date()|substr:5:2}');" class="date_separator clickable">{$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)
<img src="/_image/open_folder.png">
</span>
<div id="block_{$action->get_mox_date()|substr:0:4}{$action->get_mox_date()|substr:5:2}" class="month_block">
{elseif $action@first}
<span onclick="block_action('block_{$action->get_mox_date()|substr:0:4}{$action->get_mox_date()|substr:5:2}');" class="date_separator clickable">{$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)
<img src="/_image/open_folder.png">
</span>
<div id="block_{$action->get_mox_date()|substr:0:4}{$action->get_mox_date()|substr:5:2}" class="month_block">
{/if}
<div class="list_item line_height14 bigger_space money_deposit">
<span class="size20 bold">
{$action->get_mox_date()|substr:0:4}.
{$months[$actions[$action@index]->get_mox_date()|substr:5:2]}
{$action->get_mox_date_day()}.
</span>
<br>
{$action->get_mox_item()}
<br>
{$action->get_mox_sum()|number_format:0:'':' '} Ft
</div>
{/if}
{if $action@last}
</div>
{/if}
{/foreach}

View File

@@ -34,7 +34,9 @@
{if $mox->get_mox_money_expense_category_moxc_id()}{$mox->get_mox_moxc()->get_moxc_name()}{else}<span class="italic">nincs megadva</span>{/if}
</td>
<td class="no_mobile_show quarter_width">
{$mox->get_mox_name()}
{if $mox->get_mox_coach()|is_a:'user'}
{$mox->get_mox_coach()->get_ua_name()}
{/if}
</td>
<td class="quarter_width">
{$mox->get_mox_item()}

View File

@@ -9,9 +9,8 @@
<div>
<label for="mox_date">Dátum:</label>
<div><input type="text" name="mox_date" id="mox_date" placeholder="ÉÉÉÉ-HH-NN" required></div>
<div><input type="text" name="mox_date" id="mox_date" placeholder="ÉÉÉÉ-HH-NN" value="{$today}" required></div>
</div>
<div>
<label for="mox_item">Tétel:</label>
<div><input type="text" name="mox_item" id="mox_item" required></div>

View File

@@ -8,7 +8,7 @@
<div>
<label for="mox_name">Név:</label>
<div><input type="text" name="mox_name" id="mox_name" value="{$mox->get_mox_name()}"></div>
<div><input type="text" name="mox_name" id="mox_name" value="{if $mox->get_mox_coach()|is_a:'user'}{$mox->get_mox_coach()->get_ua_name()}{/if}"></div>
</div>
<div>