diff --git a/_class/class_news.php b/_class/class_news.php new file mode 100644 index 0000000..c78ddf9 --- /dev/null +++ b/_class/class_news.php @@ -0,0 +1,211 @@ +assoc_array("select * from news where n_id = " . $_n_id); + $news_data_array = $news_data_assoc_array[0]; + foreach ($news_data_array as $field => $value) { + $function_name = "set_" . $field; + $this->$function_name($value); //alapadatok beállítása + if ($field == 'n_user_ua_id' && !empty($value)) { + $coach = new user(); + $coach->set_user_data_by_id($value); + $this->set_n_user($coach); + } + } + } + + public static function create_news($_values, $user_id = null) { + global $sql, $user; + if (null === $user_id) { + $user_id = $user->get_ua_id(); + } + + if (!isset($_values['n_title'])) { + $title = 'null'; + } + else { + $title = $_values['n_title']; + } + + return $sql->insert_into('news', array( + 'n_title' => $title, + 'n_user_ua_id' => $user_id, + 'n_text' => $_values['n_text'], + 'n_date' => $_values['n_date'] + )); + } + + public static function update_news($_values, $n_id) { + global $sql, $user; + + if (!isset($_values['n_title'])) { + $title = 'null'; + } + else { + $title = $_values['n_title']; + } + + $sql->update_table('news', array( + 'n_title' => $title, + 'n_text' => $_values['n_text'], + 'n_date' => $_values['n_date'] + ), array( + 'n_id' => $n_id, + )); + } + + /** + * @return mixed + */ + public function get_n_id() + { + return $this->n_id; + } + + /** + * @param mixed $n_id + * + * @return self + */ + public function set_n_id($n_id) + { + $this->n_id = $n_id; + + return $this; + } + + /** + * @return mixed + */ + public function get_n_title() + { + return $this->n_title; + } + + /** + * @param mixed $n_title + * + * @return self + */ + public function set_n_title($n_title) + { + $this->n_title = $n_title; + + return $this; + } + + /** + * @return mixed + */ + public function get_n_date() + { + return $this->n_date; + } + + /** + * @param mixed $n_date + * + * @return self + */ + public function set_n_date($n_date) + { + $this->n_date = $n_date; + + return $this; + } + + /** + * @return mixed + */ + public function get_n_text() + { + return $this->n_text; + } + + /** + * @param mixed $n_text + * + * @return self + */ + public function set_n_text($n_text) + { + $this->n_text = $n_text; + + return $this; + } + + /** + * @return mixed + */ + public function get_n_deleted() + { + return $this->n_deleted; + } + + /** + * @param mixed $n_deleted + * + * @return self + */ + public function set_n_deleted($n_deleted) + { + $this->n_deleted = $n_deleted; + + return $this; + } + + /** + * @return mixed + */ + public function get_n_user_ua_id() + { + return $this->n_user_ua_id; + } + + /** + * @param mixed $n_user_ua_id + * + * @return self + */ + public function set_n_user_ua_id($n_user_ua_id) + { + $this->n_user_ua_id = $n_user_ua_id; + + return $this; + } + + /** + * @return mixed + */ + public function get_n_user() + { + return $this->n_user; + } + + /** + * @param mixed $n_user + * + * @return self + */ + public function set_n_user($n_user) + { + $this->n_user = $n_user; + + return $this; + } +} + + +?> diff --git a/_class/class_page.php b/_class/class_page.php index 6749ac2..c1a0221 100644 --- a/_class/class_page.php +++ b/_class/class_page.php @@ -244,6 +244,10 @@ class page { # STATISZTIKÁK include('include_stats.php'); break; + case 'news': + # INFORMÁCIÓS FAL + include('include_information.php'); + break; case 'delete_training_type': # EDZÉS TÍPUS TÖRLÉS include('include_delete_training_type.php'); @@ -288,6 +292,10 @@ class page { # BEVÉTEL TÖRLÉS include('include_delete_money_income.php'); break; + case 'delete_news': + # HÍR TÖRLÉS + include('include_delete_news.php'); + break; case 'logout': # kijelentkezés $from = "admin"; @@ -321,7 +329,7 @@ class page { break; case 'information': # információk - include('include_information.php'); + include('include_information_wall.php'); break; default: include('include_diary.php'); @@ -341,7 +349,7 @@ class page { break; case 'information': # információk - include('include_information.php'); + include('include_information_wall.php'); break; default: include('include_diary.php'); diff --git a/_css/default.css b/_css/default.css index 2f7e7f7..3a6b520 100644 --- a/_css/default.css +++ b/_css/default.css @@ -317,6 +317,15 @@ a.addbutton.noti { margin-bottom: 5px; } +.list.news .date_separator { + color: black; + background-color: #19f40c; +} + +.list.news .date_separator:hover { + background-color: #24991e; +} + .list_item label { font-weight: bold; } @@ -604,6 +613,12 @@ h1.apply { border-left: 3px solid black; } +.info-wall { + border-top: 2px solid #0a4404; + border-left: none; + margin-top: 20px; +} + .toggle { width: 50px; height: 120px; @@ -847,6 +862,12 @@ form#auto_filters > div > label { margin: 20px; } + .info-wall { + border-left: 2px solid #0a4404; + border-top: none; + margin-top: 0; + } + .diary_header { width: 35%; } diff --git a/_css/default_view.css b/_css/default_view.css index 0a03ae8..7714407 100644 --- a/_css/default_view.css +++ b/_css/default_view.css @@ -97,3 +97,25 @@ div.list div.actual_balance:hover { .full { display: inline-block; } + +.diary_container { + display: flex; + justify-content: stretch; + flex-wrap: wrap; + flex-direction: column; +} + +.diary_container > div { + flex: 1 1 50%; +} + +@media (min-width: 1250px) { + .diary_container { + flex-direction: row; + } + + .list.news, .list.entries { + width: 100%; + padding: 15px; + } +} diff --git a/_image/news.png b/_image/news.png new file mode 100644 index 0000000..ef53c32 Binary files /dev/null and b/_image/news.png differ diff --git a/_include/include_create.php b/_include/include_create.php index 944494a..f4abb94 100644 --- a/_include/include_create.php +++ b/_include/include_create.php @@ -186,6 +186,10 @@ switch ($this->get_id()) { $smarty->display('training_template_create.tpl'); break; + case 'news': + # hír létrehozása + $smarty->display('news_create.tpl'); + break; default: # code... break; diff --git a/_include/include_delete_news.php b/_include/include_delete_news.php new file mode 100644 index 0000000..3291cb5 --- /dev/null +++ b/_include/include_delete_news.php @@ -0,0 +1,9 @@ +is_id()) { + $sql->update_table('news', array('n_deleted' => 1), array('n_id' => $this->get_id())); + log::register('delete_news', $this->get_id()); + header("Location: /admin/news"); +} + +?> diff --git a/_include/include_diary.php b/_include/include_diary.php index ba62783..7ce1833 100644 --- a/_include/include_diary.php +++ b/_include/include_diary.php @@ -70,6 +70,18 @@ order by object_date ASC; $smarty->assign('actions', $de_array); $smarty->assign('balance_transfer', $balance_transfer); + //get news + $news_assoc_array = $sql->assoc_array('SELECT * FROM news WHERE n_deleted = 0 ORDER BY n_date DESC;'); + + $news_array = array(); + foreach ($news_assoc_array as $key => $news) { + $new_news = new news(); + $new_news->set_news_data_by_id($news['n_id']); + $news_array[] = $new_news; + } + + $smarty->assign('news_array',$news_array); + //$smarty->assign('balance', $balance); $smarty->display('user_diary.tpl'); diff --git a/_include/include_information.php b/_include/include_information.php index cd98a8d..854128c 100644 --- a/_include/include_information.php +++ b/_include/include_information.php @@ -1,14 +1,29 @@ is_id()) { + $news = new news(); + $news->set_news_data_by_id($this->get_id()); - $setv_id = $sql->single_variable($info_query); + $smarty->assign('news',$news); + $smarty->display('news_data_edit.tpl'); +} +else { + //lista + $news_query = "SELECT * FROM news WHERE n_deleted = 0 AND n_user_ua_id = " . $user->get_ua_id() . " ORDER BY n_date DESC"; - $new_setval = new setting_value(); - $new_setval->set_setting_value_data_by_id($setv_id); - $smarty->assign('setting', $new_setval); + $news_assoc_array = $sql->assoc_array($news_query); + + $news_array = array(); + foreach ($news_assoc_array as $key => $news) { + $new_news = new news(); + $new_news->set_news_data_by_id($news['n_id']); + $news_array[] = $new_news; + } + + $smarty->assign('news_array', $news_array); + $smarty->display('news_list.tpl'); +} - $smarty->display('information.tpl'); ?> diff --git a/_include/include_information_wall.php b/_include/include_information_wall.php new file mode 100644 index 0000000..cd98a8d --- /dev/null +++ b/_include/include_information_wall.php @@ -0,0 +1,14 @@ +single_variable($info_query); + + $new_setval = new setting_value(); + $new_setval->set_setting_value_data_by_id($setv_id); + $smarty->assign('setting', $new_setval); + + $smarty->display('information.tpl'); +?> diff --git a/event_handler.php b/event_handler.php index 28ca85a..0efefa5 100644 --- a/event_handler.php +++ b/event_handler.php @@ -568,6 +568,21 @@ if (isset($_POST['action'])) { log::register('update_training_template', $_POST['tt_id']); header('Location: /admin/training_templates/'.$_POST['tt_id']); break; + case 'news_create': + # új hír + unset($_POST['action']); + $new_news_id = news::create_news($_POST); + log::register('new_news', $new_news_id); + header('Location: /admin/news/'.$new_news_id); + break; + case 'news_update': + unset($_POST['action']); + $n_id = $_POST['n_id']; + unset($_POST['n_id']); + news::update_news($_POST, $n_id); + log::register('update_news', $n_id); + header('Location: /admin/news/'.$n_id); + break; default: # code... break; diff --git a/queries/news_20190729.sql b/queries/news_20190729.sql new file mode 100644 index 0000000..bb0c04a --- /dev/null +++ b/queries/news_20190729.sql @@ -0,0 +1,16 @@ +CREATE TABLE `news` ( + `n_id` INT NOT NULL AUTO_INCREMENT, + `n_title` VARCHAR(255) NULL DEFAULT NULL, + `n_date` DATETIME NOT NULL, + `n_text` TEXT NULL DEFAULT NULL, + `n_user_ua_id` INT NOT NULL, + `n_deleted` INT NULL DEFAULT 0, + PRIMARY KEY (`n_id`)); + +INSERT INTO `subpage` (`spage_url`, `spage_title`, `spage_page_id`) VALUES ('news', 'Információk', '1'); + +INSERT INTO `log_category` (`logc_name`, `logc_title`, `logc_type`, `logc_table`, `logc_field`, `logc_selector`) VALUES ('new_news', 'Új hír', '1', 'news', 'n_title', 'n_id'); +INSERT INTO `log_category` (`logc_name`, `logc_title`, `logc_type`, `logc_table`, `logc_field`, `logc_selector`) VALUES ('update_news', 'Hír módosítása', '1', 'news', 'n_title', 'n_id'); +INSERT INTO `log_category` (`logc_name`, `logc_title`, `logc_type`, `logc_table`, `logc_field`, `logc_selector`) VALUES ('delete_news', 'Hír törlése', '1', 'news', 'n_title', 'n_id'); + +DELETE FROM `subpage` WHERE `spage_name` = 'information'; diff --git a/template/templates/news_create.tpl b/template/templates/news_create.tpl new file mode 100644 index 0000000..9b95575 --- /dev/null +++ b/template/templates/news_create.tpl @@ -0,0 +1,27 @@ +
+
+ + +
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ + diff --git a/template/templates/news_data_edit.tpl b/template/templates/news_data_edit.tpl new file mode 100644 index 0000000..5eba347 --- /dev/null +++ b/template/templates/news_data_edit.tpl @@ -0,0 +1,31 @@ +
+
+ Hír törlése +
+
+ + + +
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ + diff --git a/template/templates/news_list.tpl b/template/templates/news_list.tpl new file mode 100644 index 0000000..c5611cb --- /dev/null +++ b/template/templates/news_list.tpl @@ -0,0 +1,15 @@ +
+ Új hír hozzádása +
+ +
+{foreach $news_array as $news} + +
+ + {$news->get_n_title()} + {$news->get_n_date()|date_format:"%Y.%m.%d %H:%M"} +
+
+{/foreach} +
diff --git a/template/templates/user_diary.tpl b/template/templates/user_diary.tpl index 6d44f9a..733abee 100644 --- a/template/templates/user_diary.tpl +++ b/template/templates/user_diary.tpl @@ -1,155 +1,175 @@ -
+
- {foreach $actions as $action} +
- {if $action@first} -
-
- - Aktuális egyenleg: {$action->get_de_balance()|number_format:0:'':' '} Ft - + {foreach $actions as $action} + + {if $action@first} +
+
+ + Aktuális egyenleg: {$action->get_de_balance()|number_format:0:'':' '} Ft + +
+ {/if} + + {if $action->get_de_training()|is_a:'training'} + + {if !$action@first && + $actions[$action@index-1]->get_de_training()|is_a:'training' && + $actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2 != $actions[$action@index-1]->get_de_training()->get_tr_date()|substr:5:2 + + || + + !$action@first && + $actions[$action@index-1]->get_de_money_deposit()|is_a:'money_deposit' && + $actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2 != $actions[$action@index-1]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 + + } +
- {/if} - - {if $action->get_de_training()|is_a:'training'} - - {if !$action@first && - $actions[$action@index-1]->get_de_training()|is_a:'training' && - $actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2 != $actions[$action@index-1]->get_de_training()->get_tr_date()|substr:5:2 - - || - - !$action@first && - $actions[$action@index-1]->get_de_money_deposit()|is_a:'money_deposit' && - $actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2 != $actions[$action@index-1]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 - - } - -
- {$actions[$action@index]->get_de_training()->get_tr_date()|substr:0:4}. - {$months[$actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2]} - ({$user_login->get_training_number_in_month({$action->get_de_training()->get_tr_date()|substr:0:4},{$action->get_de_training()->get_tr_date()|substr:5:2})} edzés) -
- Egyenleg - -
-
-
- - {elseif $action@first} - {$actions[$action@index]->get_de_training()->get_tr_date()|substr:0:4}. - {$months[$actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2]} - ({$user_login->get_training_number_in_month({$action->get_de_training()->get_tr_date()|substr:0:4},{$action->get_de_training()->get_tr_date()|substr:5:2})} edzés) -
- Egyenleg - -
-
-
- - {/if} -
-
- - {$action->get_de_training()->get_tr_date()|substr:0:4}. + {$actions[$action@index]->get_de_training()->get_tr_date()|substr:0:4}. {$months[$actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2]} - {$action->get_de_training()->get_tr_date_day()}. - {$days[$action->get_de_training()->get_tr_date_day_of_week()]} - {$action->get_de_training()->get_tr_date_time()} + ({$user_login->get_training_number_in_month({$action->get_de_training()->get_tr_date()|substr:0:4},{$action->get_de_training()->get_tr_date()|substr:5:2})} edzés) +
+ Egyenleg + +
-
- {if $action->get_de_training()->get_tr_training_type_trt_id()}{$action->get_de_training()->get_tr_type_name_by_id()} edzés{/if} - {$action->get_de_training()->get_tr_duration()} p - {if $action->get_de_training()->is_coach()} - {foreach $action->get_de_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_de_training()->get_tr_date()|substr:0:4}. + {$months[$actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2]} + ({$user_login->get_training_number_in_month({$action->get_de_training()->get_tr_date()|substr:0:4},{$action->get_de_training()->get_tr_date()|substr:5:2})} edzés) +
+ Egyenleg + +
+
+
+ {/if} - - {assign var="discount" value=""} - {if $action->get_de_has_discount()} - {if $action->get_de_discount_id() == 1} - {assign var="discount" value="Próba kedvezmény"} - {elseif $action->get_de_discount_id() == 2} - {assign var="discount" value="Havi 10+ kedvezmény"} - {elseif $action->get_de_discount_id() == 3} - {assign var="discount" value="Duplázó kedvezmény"} - {/if} - {/if} - -
- Egyenleg: {if $action->get_de_balance()>0}+{/if}{$action->get_de_balance()|number_format:0:'':' '} Ft - {if $discount != ""}
{$discount}{/if} -
-
- -
- - - {if $action->get_de_balance()>0}+{/if}{$action->get_de_balance()|number_format:0:'':' '} Ft
{$discount} -
-
- - {elseif $action->get_de_money_deposit()|is_a:'money_deposit'} - - - {if !$action@first && - $actions[$action@index-1]->get_de_training()|is_a:'training' && - $actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 != $actions[$action@index-1]->get_de_training()->get_tr_date()|substr:5:2 - - || - - !$action@first && - $actions[$action@index-1]->get_de_money_deposit()|is_a:'money_deposit' && - $actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 != $actions[$action@index-1]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 - - } - -
- {$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4}. - {$months[$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2]} - ({$user_login->get_training_number_in_month({$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4},{$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2})} edzés) - - -
- - {elseif $action@first} - - {$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4}. - {$months[$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2]} - ({$user_login->get_training_number_in_month({$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4},{$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2})} edzés) - - -
- - - {/if} -
-
+
+
- {$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4}. - {$months[$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2]} - {$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date_day()}. + {$action->get_de_training()->get_tr_date()|substr:0:4}. + {$months[$actions[$action@index]->get_de_training()->get_tr_date()|substr:5:2]} + {$action->get_de_training()->get_tr_date_day()}. + {$days[$action->get_de_training()->get_tr_date_day_of_week()]} + {$action->get_de_training()->get_tr_date_time()}
- befizetés: {$action->get_de_money_deposit()->get_mod_money_income()->get_mi_sum(true)} Ft + {if $action->get_de_training()->get_tr_training_type_trt_id()}{$action->get_de_training()->get_tr_type_name_by_id()} edzés{/if} + {$action->get_de_training()->get_tr_duration()} p + {if $action->get_de_training()->is_coach()} + {foreach $action->get_de_training()->get_tr_coaches_name() as $coach_name} + {if $coach_name@first}({/if}{$coach_name}{if $coach_name@last}){else}, {/if} + {/foreach} + {/if} + + {assign var="discount" value=""} + {if $action->get_de_has_discount()} + {if $action->get_de_discount_id() == 1} + {assign var="discount" value="Próba kedvezmény"} + {elseif $action->get_de_discount_id() == 2} + {assign var="discount" value="Havi 10+ kedvezmény"} + {elseif $action->get_de_discount_id() == 3} + {assign var="discount" value="Duplázó kedvezmény"} + {/if} + {/if} + +
+ Egyenleg: {if $action->get_de_balance()>0}+{/if}{$action->get_de_balance()|number_format:0:'':' '} Ft + {if $discount != ""}
{$discount}{/if} +
- {assign var="discount" value=""} + + {if $action->get_de_balance()>0}+{/if}{$action->get_de_balance()|number_format:0:'':' '} Ft
{$discount}
+
+ + {elseif $action->get_de_money_deposit()|is_a:'money_deposit'} + + + {if !$action@first && + $actions[$action@index-1]->get_de_training()|is_a:'training' && + $actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 != $actions[$action@index-1]->get_de_training()->get_tr_date()|substr:5:2 + + || + + !$action@first && + $actions[$action@index-1]->get_de_money_deposit()|is_a:'money_deposit' && + $actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 != $actions[$action@index-1]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2 + + } + +
+ {$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4}. + {$months[$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2]} + ({$user_login->get_training_number_in_month({$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4},{$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2})} edzés) + + +
+ + {elseif $action@first} + + {$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4}. + {$months[$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2]} + ({$user_login->get_training_number_in_month({$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4},{$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2})} edzés) + + +
+ + + {/if} +
+
+ + {$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:0:4}. + {$months[$actions[$action@index]->get_de_money_deposit()->get_mod_money_income()->get_mi_date()|substr:5:2]} + {$action->get_de_money_deposit()->get_mod_money_income()->get_mi_date_day()}. + +
+ befizetés: {$action->get_de_money_deposit()->get_mod_money_income()->get_mi_sum(true)} Ft +
+ +
+ {assign var="discount" value=""} + {if $action->get_de_balance()>0}+{/if}{$action->get_de_balance()|number_format:0:'':' '} Ft
{$discount} +
+
+ + {/if} + + {if $action@last} + +
+ + {/if} + {/foreach} +
+
+
+
+

+ Hírek, információk +

- - {/if} - - {if $action@last} - -
- - {/if} - {/foreach} + {foreach $news_array as $news} + + {$news->get_n_title()} - {$news->get_n_date()|date_format:"%Y.%m.%d %H:%M"} + +
+ {$news->get_n_text()} +
+ {/foreach} +
+