diff --git a/_class/class_money_expense.php b/_class/class_money_expense.php new file mode 100644 index 0000000..e2c3b80 --- /dev/null +++ b/_class/class_money_expense.php @@ -0,0 +1,130 @@ +mox_id = $_item; + } + + public function set_mox_name($_item) { + $this->mox_name = $_item; + } + + public function set_mox_date($_item) { + $this->mox_date = $_item; + } + + public function set_mox_item($_item) { + $this->mox_item = $_item; + } + + public function set_mox_sum($_item) { + $this->mox_sum = $_item; + } + + public function set_mox_money_expense_category_moxc_id($_item) { + $this->mox_moxc_id = $_item; + } + + public function set_mox_moxc($_item) { + $this->mox_moxc = $_item; + } + + + public function set_mox_deleted($_item) { + $this->mox_deleted = $_item; + } + + public function get_mox_id() { + return $this->mox_id; + } + + public function get_mox_name() { + return $this->mox_name; + } + + public function get_mox_date() { + return $this->mox_date; + } + + public function get_mox_item() { + return $this->mox_item; + } + + public function get_mox_sum() { + return $this->mox_sum; + } + + public function get_mox_moxc() { + return $this->mox_moxc; + } + + public function get_mox_money_expense_category_moxc_id() { + return $this->mox_moxc_id; + } + + public function get_mox_deleted() { + return $this->mox_deleted; + } + + 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); + $set_data_array = $set_data_assoc_array[0]; + foreach ($set_data_array as $field => $value) { + $function_name = "set_" . $field; + $this->$function_name($value); //alapadatok beállítása + + if ($field == 'mox_money_expense_category_moxc_id' && $value != null) { + $new_moxc = new money_expense_category(); + $new_moxc->set_moxc_data_by_id($value); + $this->set_mox_moxc($new_moxc); + } + } + + } + + public static function create_money_expense($_name, $_date, $_item, $_sum, $_moxc_id) { + global $sql; + + return $sql->insert_into('money_expense', array( + 'mox_name' => $_name, + 'mox_date' => $_date, + 'mox_item' => $_item, + 'mox_sum' => $_sum, + 'mox_money_expense_category_moxc_id' => $_moxc_id + )); + } + + public static function update_money_expense_category($_name, $_date, $_item, $_sum, $_moxc_id, $_id) { + global $sql; + + $sql->update_table('money_expense_category', + array( + 'mox_name' => $_name, + 'mox_date' => $_date, + 'mox_item' => $_item, + 'mox_sum' => $_sum, + 'mox_money_expense_category_moxc_id' => $_moxc_id + ), + array( + 'mox_id' => $_id + ) + + + ); + } +} + + +?> \ No newline at end of file diff --git a/_class/class_money_expense_category.php b/_class/class_money_expense_category.php new file mode 100644 index 0000000..3d5dcb1 --- /dev/null +++ b/_class/class_money_expense_category.php @@ -0,0 +1,59 @@ +moxc_id = $_item; + } + + public function set_moxc_name($_item) { + $this->moxc_name = $_item; + } + + public function set_moxc_deleted($_item) { + $this->moxc_deleted = $_item; + } + + public function get_moxc_id() { + return $this->moxc_id; + } + + public function get_moxc_name() { + return $this->moxc_name; + } + + public function get_moxc_deleted() { + return $this->moxc_deleted; + } + + public function set_moxc_data_by_id($_id) { + global $sql; + $set_data_assoc_array = $sql->assoc_array("select * from money_expense_category where moxc_id = " . $_id); + $set_data_array = $set_data_assoc_array[0]; + foreach ($set_data_array as $field => $value) { + $function_name = "set_" . $field; + $this->$function_name($value); //alapadatok beállítása + + } + + } + + public static function create_money_expense_category($_name) { + global $sql; + + return $sql->insert_into('money_expense_category', array('moxc_name' => $_name)); + } + + public static function update_money_expense_category($_name, $_id) { + global $sql; + + $sql->update_table('money_expense_category', array('moxc_name' => $_name), array('moxc_id' => $_id)); + } + +} + + +?> \ No newline at end of file diff --git a/_class/class_page.php b/_class/class_page.php index 7ac0566..3dfc37f 100755 --- a/_class/class_page.php +++ b/_class/class_page.php @@ -141,6 +141,18 @@ class page { # BEFIZETÉSEK / USER include('include_view_deposit.php'); break; + case 'money_expense': + # KIADÁSOK + include('include_money_expense.php'); + break; + case 'money_expense_category': + # KIADÁS KATEGÓRIÁK + include('include_money_expense_category.php'); + break; + case 'money_update': + # FRISSÍTÉS + include('include_money_update.php'); + break; case 'delete_training_type': # EDZÉS TÍPUS TÖRLÉS include('include_delete_training_type.php'); @@ -169,6 +181,14 @@ class page { # BEFIZETÉS TÖRLÉS include('include_delete_money_deposit.php'); break; + case 'delete_money_expense_category': + # BEFIZETÉS KATEGÓRIA TÖRLÉS + include('include_delete_money_expense_category.php'); + break; + case 'delete_money_expense': + # BEFIZETÉS TÖRLÉS + include('include_delete_money_expense.php'); + break; case 'logout': # kijelentkezés $from = "coach"; diff --git a/_class/class_user_kid.php b/_class/class_user_kid.php index 82e123e..d82a276 100644 --- a/_class/class_user_kid.php +++ b/_class/class_user_kid.php @@ -501,9 +501,9 @@ class user_kid extends user_parent { } } - + - $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); + if (isset($_de)) $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; } diff --git a/_css/default.css b/_css/default.css index f82b2f4..b5a2825 100644 --- a/_css/default.css +++ b/_css/default.css @@ -150,7 +150,8 @@ td.create a { } .list_item table.money td.sum { - width: 1%; + width: unset; + text-align: right; white-space: nowrap; } @@ -159,6 +160,11 @@ td.create a { padding-right: 25px; } + +.list_item table.money td.no_mobile_show { + display: none; +} + .list .name_tag { text-align: left; @@ -369,6 +375,19 @@ table.log tr.delete:hover { width: 30%; } +.list_item table.money td.no_mobile_show { + display: table-cell; +} + +.list_item table.money td.sum { + width: 1%; + white-space: nowrap; +} + +.list_item table.money td.quarter_width { + width: 25%; +} + } @@ -377,6 +396,10 @@ table.log tr.delete:hover { width: 50% !important; } + .full_width { + width: 90% !important; + } + .list_item label { float: left; padding-right: 5px; @@ -421,6 +444,8 @@ table.log tr.delete:hover { width: 100%; } + + } \ No newline at end of file diff --git a/_include/include_create.php b/_include/include_create.php index 187c6de..500eed6 100755 --- a/_include/include_create.php +++ b/_include/include_create.php @@ -119,6 +119,23 @@ switch ($this->get_id()) { $smarty->assign('user_kids', $user_kids); $smarty->display('money_deposit_create.tpl'); + break; + case 'money_expense': + # ÚJ KIADÁS + $moxc_assoc_array = $sql->assoc_array('SELECT * FROM money_expense_category WHERE moxc_deleted = 0 ORDER BY moxc_name ASC;'); + $moxc_array = array(); + foreach ($moxc_assoc_array as $key => $moxc) { + $new_moxc = new money_expense_category(); + $new_moxc->set_moxc_data_by_id($moxc['moxc_id']); + $moxc_array[] = $new_moxc; + } + + $smarty->assign('moxc_array', $moxc_array); + $smarty->display('money_expense_create.tpl'); + break; + case 'money_expense_category': + # ÚJ KIADÁS KATEGÓRIA + $smarty->display('money_expense_category_create.tpl'); break; default: # code... diff --git a/_include/include_delete_money_expense.php b/_include/include_delete_money_expense.php new file mode 100644 index 0000000..ac66fc9 --- /dev/null +++ b/_include/include_delete_money_expense.php @@ -0,0 +1,10 @@ +is_id()) { + $sql->update_table('money_expense', array('mox_deleted' => 1), array('mox_id' => $this->get_id())); + log::register('delete_mox', $this->get_id()); + header("Location: /admin/money_expense"); +} + + +?> \ No newline at end of file diff --git a/_include/include_delete_money_expense_category.php b/_include/include_delete_money_expense_category.php new file mode 100644 index 0000000..115c0ca --- /dev/null +++ b/_include/include_delete_money_expense_category.php @@ -0,0 +1,10 @@ +is_id()) { + $sql->update_table('money_expense_category', array('moxc_deleted' => 1), array('moxc_id' => $this->get_id())); + log::register('delete_moxc', $this->get_id()); + header("Location: /admin/money_expense_category"); +} + + +?> \ No newline at end of file diff --git a/_include/include_money_expense.php b/_include/include_money_expense.php new file mode 100644 index 0000000..020bc48 --- /dev/null +++ b/_include/include_money_expense.php @@ -0,0 +1,50 @@ +is_id()) { + # ADOTT KIADÁS ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA + + $new_mox = new money_expense(); + $new_mox->set_mox_data_by_id($this->get_id()); + + $moxc_query = "SELECT * FROM money_expense_category WHERE moxc_deleted = 0 ORDER BY moxc_name ASC;"; + $moxc_array = array(); + $moxc_assoc_array = $sql->assoc_array($moxc_query); + + foreach ($moxc_assoc_array as $mox) { + $new_moxc = new money_expense_category(); + $new_moxc->set_moxc_data_by_id($mox['moxc_id']); + $moxc_array[] = $new_moxc; + } + + + $smarty->assign("moxc_array", $moxc_array); + + $smarty->assign("mox", $new_mox); + $smarty->display("money_expense_data_edit.tpl"); + +} +else { + # KIADÁS LISTA + $mox_query = "SELECT * FROM money_expense WHERE mox_deleted = 0 ORDER BY mox_date DESC, mox_id DESC;"; + $mox_array = array(); + $mox_assoc_array = $sql->assoc_array($mox_query); + + foreach ($mox_assoc_array as $mod) { + $new_mox = new money_expense(); + $new_mox->set_mox_data_by_id($mod['mox_id']); + $mox_array[] = $new_mox; + } + + $smarty->assign("mox_array", $mox_array); + $smarty->display("money_expense.tpl"); + +} + +?> \ No newline at end of file diff --git a/_include/include_money_expense_category.php b/_include/include_money_expense_category.php new file mode 100644 index 0000000..3b9d745 --- /dev/null +++ b/_include/include_money_expense_category.php @@ -0,0 +1,37 @@ +is_id()) { + # ADOTT KIADÁS KATEGÓRIA ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA + + $new_moxc = new money_expense_category(); + $new_moxc->set_moxc_data_by_id($this->get_id()); + + $smarty->assign("moxc", $new_moxc); + $smarty->display("money_expense_category_data_edit.tpl"); + +} +else { + # KIADÁS KATEGÓRIA LISTA + $moxc_query = "SELECT * FROM money_expense_category WHERE moxc_deleted = 0 ORDER BY moxc_name ASC;"; + $moxc_array = array(); + $moxc_assoc_array = $sql->assoc_array($moxc_query); + + foreach ($moxc_assoc_array as $mox) { + $new_moxc = new money_expense_category(); + $new_moxc->set_moxc_data_by_id($mox['moxc_id']); + $moxc_array[] = $new_moxc; + } + + $smarty->assign("moxc_assoc_array", $moxc_array); + $smarty->display("money_expense_category.tpl"); + +} + +?> \ No newline at end of file diff --git a/_include/include_money_update.php b/_include/include_money_update.php new file mode 100644 index 0000000..12e425a --- /dev/null +++ b/_include/include_money_update.php @@ -0,0 +1,146 @@ +assoc_array('select * from user_kid order by uk_name asc;'); + + foreach ($users as $key => $value) { + $user = new user_kid(); + $user->set_user_data_by_id($value['uk_id']); + + + + # EDZÉS LISTA + + $action_list_query = " + SELECT + object_id, + timestamp(object_date) as object_date, + object_type, + (SELECT + count(distinct date(tr_date)) + FROM + presence + JOIN + training ON tr_id = pr_training_tr_id + WHERE + YEAR(tr_date) = YEAR(object_date) + AND MONTH(tr_date) = MONTH(object_date) + AND tr_date <= object_date + AND pr_user_kid_uk_id = ".$user->get_uk_id()." + AND tr_date > (select + if(max(trd) is null, + '1900-01-01', + max(trd)) + from + (select + tr_date trd + from + presence + join training ON tr_id = pr_training_tr_id + join user_kid ON uk_id = pr_user_kid_uk_id + where + pr_user_kid_uk_id = ".$user->get_uk_id()." + and tr_date >= (SELECT + tr_date + from + presence + join training ON tr_id = pr_training_tr_id + join user_kid ON uk_id = pr_user_kid_uk_id + where + pr_user_kid_uk_id = ".$user->get_uk_id()." + and date(tr_date) = uk_first_training + ORDER BY tr_date ASC + limit 1) + order by tr_date ASC + limit 2) as elso_ket_edzes)) as 'training_per_month', + (SELECT + count(pr_id) + FROM + presence + JOIN + training ON tr_id = pr_training_tr_id + WHERE + DATE(tr_date) = DATE(object_date) + AND tr_date <= object_date + AND pr_user_kid_uk_id = ".$user->get_uk_id().") as 'training_per_day', + (select + if(sum(if(trd = object_date, 1, 0)) > 0, + 1, + 0) + from + (select + tr_date trd + from + presence + join training ON tr_id = pr_training_tr_id + join user_kid ON uk_id = pr_user_kid_uk_id + where + pr_user_kid_uk_id = ".$user->get_uk_id()." + and tr_date >= (SELECT + tr_date + from + presence + join training ON tr_id = pr_training_tr_id + join user_kid ON uk_id = pr_user_kid_uk_id + where + pr_user_kid_uk_id = ".$user->get_uk_id()." + and date(tr_date) = uk_first_training + ORDER BY tr_date ASC + limit 1) + order by tr_date ASC + limit 2) elso2edzes) as 'first_two' +FROM + ((SELECT + pr_training_tr_id as object_id, + timestamp(tr_date) as object_date, + if(pr_training_tr_id is not null, 'training', null) as object_type + FROM + presence + JOIN training ON tr_id = pr_training_tr_id + WHERE + pr_user_kid_uk_id = ".$user->get_uk_id()." + AND tr_deleted = 0) UNION (SELECT + mod_id, + timestamp(mod_date), + if(mod_id is not null, 'money_deposit', null) as object_type + FROM + money_deposit + WHERE + mod_user_kid_uk_id = ".$user->get_uk_id()." + and mod_deleted = 0)) actions +order by object_date ASC; + "; + + $action_assoc_array = $sql->assoc_array($action_list_query); + + $actions = array(); + $de_array = array(); + foreach ($action_assoc_array as $action) { + + + if ($action['object_type'] == 'training') { + $new_training = new training(); + $new_training->set_training_data_by_id($action['object_id']); + //$actions[] = $new_training; + $new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], $action['training_per_month'], $action['training_per_day'], $action['first_two'], $new_training); + } + elseif ($action['object_type'] == 'money_deposit') { + $new_mod = new money_deposit(); + $new_mod->set_mod_data_by_id($action['object_id']); + //$actions[] = $new_mod; + $new_diary_entry = new diary_entry($action['object_id'], $action['object_date'], $action['object_type'], $action['training_per_month'], $action['training_per_day'], $action['first_two'], null, $new_mod); + } + + $de_array[] = $new_diary_entry; + + } + + //itt csak hivatkozással adjuk át a tömböt, a calculate_balance kiszámolja, belerakja és visszadja + $user->calculate_balance($de_array, $user); + //var_dump($de_array); + //$smarty->assign('actions', $actions); + + +} + +?> \ No newline at end of file diff --git a/event_handler.php b/event_handler.php index 2e3b1d1..0a72707 100644 --- a/event_handler.php +++ b/event_handler.php @@ -258,6 +258,30 @@ if (isset($_POST['action'])) { log::register('update_money_deposit', $tmp_user->get_uk_name() . ': ' . $_POST['mod_sum']. ' Ft (' . $_POST['mod_date'] . ')'); header("Location: /admin/money_deposit"); break; + case 'moxc_create': + # befizetés kategória létrehozása + $new_moxc_id = money_expense_category::create_money_expense_category($_POST['moxc_name']); + log::register('new_moxc', $new_moxc_id); + header("Location: /admin/money_expense_category"); + break; + case 'moxc_update': + # befizetés kategória módosítása + money_expense_category::update_money_expense_category($_POST['moxc_name'], $_POST['moxc_id']); + log::register('update_moxc', $_POST['moxc_id']); + header("Location: /admin/money_expense_category"); + break; + case 'mox_create': + # befizetés létrehozása + $new_mox_id = money_expense::create_money_expense($_POST['mox_name'], $_POST['mox_date'], $_POST['mox_item'], $_POST['mox_sum'], $_POST['mox_moxc_id']); + log::register('new_mox', $new_mox_id); + header("Location: /admin/money_expense"); + break; + case 'mox_update': + # befizetés módosítása + money_expense::update_money_expense($_POST['mox_name'], $_POST['mox_date'], $_POST['mox_item'], $_POST['mox_sum'], $_POST['mox_moxc_id'], $_POST['mox_id']); + log::register('update_mox', $_POST['mox_id']); + header("Location: /admin/money_expense"); + break; default: # code... break; diff --git a/index.php b/index.php index fd42391..bed0264 100644 --- a/index.php +++ b/index.php @@ -42,7 +42,7 @@ setlocale(LC_ALL, 'hu_HU'); ?> - Badminton Coach v 0.1 + Badminton Coach diff --git a/template/templates/money_expense.tpl b/template/templates/money_expense.tpl new file mode 100644 index 0000000..a4ac39c --- /dev/null +++ b/template/templates/money_expense.tpl @@ -0,0 +1,90 @@ +
+ + Új kiadás + Kiadás kategóriák kezelése + +
+ +
+ {foreach $mox_array as $mox} + + {if !$mox@first && $mox_array[$mox@index]->get_mox_date()|substr:5:2 != $mox_array[$mox@index-1]->get_mox_date()|substr:5:2} +
+ {/if} + + {if $mox@first || $mox_array[$mox@index]->get_mox_date()|substr:5:2 != $mox_array[$mox@index-1]->get_mox_date()|substr:5:2} + {$mox_array[$mox@index]->get_mox_date()|substr:0:4}. + {$months[$mox_array[$mox@index]->get_mox_date()|substr:5:2]} + + +
+ + {/if} + +
+ + + + + + + + + + +
+ + + {$mox->get_mox_date()} + + {if $mox->get_mox_money_expense_category_moxc_id()}{$mox->get_mox_moxc()->get_moxc_name()}{else}nincs megadva{/if} + + {$mox->get_mox_name()} + + {$mox->get_mox_item()} + + {$mox->get_mox_sum()|number_format:0:'':' '} Ft +
+
+
+ + {if $mox@last} +
+ {/if} + + {/foreach} + + + + + \ No newline at end of file diff --git a/template/templates/money_expense_category.tpl b/template/templates/money_expense_category.tpl new file mode 100644 index 0000000..135348b --- /dev/null +++ b/template/templates/money_expense_category.tpl @@ -0,0 +1,18 @@ +
+ + Új kiadás kategória + +
+ +
+ {foreach $moxc_assoc_array as $moxc} + +
+ + {$moxc->get_moxc_name()} +
+
+ {/foreach} + +
+ diff --git a/template/templates/money_expense_category_create.tpl b/template/templates/money_expense_category_create.tpl new file mode 100644 index 0000000..7424043 --- /dev/null +++ b/template/templates/money_expense_category_create.tpl @@ -0,0 +1,17 @@ +
+
+ + +
+ +
+
+ +
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/template/templates/money_expense_category_data_edit.tpl b/template/templates/money_expense_category_data_edit.tpl new file mode 100644 index 0000000..f96278c --- /dev/null +++ b/template/templates/money_expense_category_data_edit.tpl @@ -0,0 +1,21 @@ +
+
+ + + + +
+ +
+
+ +
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/template/templates/money_expense_create.tpl b/template/templates/money_expense_create.tpl new file mode 100644 index 0000000..6422a81 --- /dev/null +++ b/template/templates/money_expense_create.tpl @@ -0,0 +1,44 @@ +
+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ + {/foreach} + +
+
+ +
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/template/templates/money_expense_data_edit.tpl b/template/templates/money_expense_data_edit.tpl new file mode 100644 index 0000000..5f68282 --- /dev/null +++ b/template/templates/money_expense_data_edit.tpl @@ -0,0 +1,48 @@ +
+
+ + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ + {/foreach} + +
+
+ +
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/template/templates/money_expense_date_edit.tpl b/template/templates/money_expense_date_edit.tpl new file mode 100644 index 0000000..c60f2f2 --- /dev/null +++ b/template/templates/money_expense_date_edit.tpl @@ -0,0 +1,44 @@ +
+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ + {/foreach} + +
+
+ +
+
+ +
+
+ +
+
\ No newline at end of file