From 44b96b0073c4dde147ac3976f7c744e7a790ae4e Mon Sep 17 00:00:00 2001 From: Ricsi Date: Tue, 7 Feb 2017 23:18:53 +0100 Subject: [PATCH] settings added; information textarea added --- _class/class_page.php | 8 ++ _class/class_setting.php | 62 ++++++++++++++ _class/class_setting_type.php | 46 +++++++++++ _class/class_setting_value.php | 100 +++++++++++++++++++++++ _css/default.css | 4 +- _include/include_information.php | 28 +++++++ _include/include_settings.php | 37 +++++++++ event_handler.php | 11 +++ template/templates/information.tpl | 3 + template/templates/setting_data_edit.tpl | 26 ++++++ template/templates/settings.tpl | 11 +++ 11 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 _class/class_setting.php create mode 100644 _class/class_setting_type.php create mode 100644 _class/class_setting_value.php create mode 100644 _include/include_information.php create mode 100644 _include/include_settings.php create mode 100644 template/templates/information.tpl create mode 100644 template/templates/setting_data_edit.tpl create mode 100644 template/templates/settings.tpl diff --git a/_class/class_page.php b/_class/class_page.php index 7ac0566..7a11275 100755 --- a/_class/class_page.php +++ b/_class/class_page.php @@ -141,6 +141,10 @@ class page { # BEFIZETÉSEK / USER include('include_view_deposit.php'); break; + case 'settings': + # BEÁLLÍTÁSOK + include('include_settings.php'); + break; case 'delete_training_type': # EDZÉS TÍPUS TÖRLÉS include('include_delete_training_type.php'); @@ -200,6 +204,10 @@ class page { # napló, edzéslista include('include_diary.php'); break; + case 'information': + # információk + include('include_information.php'); + break; default: include('include_diary.php'); break; diff --git a/_class/class_setting.php b/_class/class_setting.php new file mode 100644 index 0000000..98a061b --- /dev/null +++ b/_class/class_setting.php @@ -0,0 +1,62 @@ +assoc_array("select * from setting where set_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 == 'set_setting_type_st_id') { + $new_st = new setting_type(); + $new_st->set_setting_type_data_by_id($value); + $this->set_set_setting_type($new_st); + } + } + + } + + public function set_set_id($_item) { + $this->set_id = $_item; + } + + public function set_set_name($_item) { + $this->set_name = $_item; + } + + public function set_set_setting_type_st_id($_item) { + $this->set_setting_type_st_id = $_item; + } + + public function set_set_setting_type($_item) { + $this->set_setting_type = $_item; + } + + + public function get_set_id() { + return $this->set_id; + } + + public function get_set_name() { + return $this->set_name; + } + + public function get_set_setting_type_st_id() { + return $this->set_setting_type_st_id; + } + + public function get_set_setting_type() { + return $this->set_setting_type; + } + +} + + +?> \ No newline at end of file diff --git a/_class/class_setting_type.php b/_class/class_setting_type.php new file mode 100644 index 0000000..c5b9cfa --- /dev/null +++ b/_class/class_setting_type.php @@ -0,0 +1,46 @@ +assoc_array("select * from setting_type where st_id = " . $_id); + $st_data_array = $st_data_assoc_array[0]; + foreach ($st_data_array as $field => $value) { + $function_name = "set_" . $field; + $this->$function_name($value); //alapadatok beállítása + } + + } + + public function set_st_id($_item) { + $this->st_id = $_item; + } + + public function set_st_name($_item) { + $this->st_name = $_item; + } + + public function set_st_setting_data_type($_item) { + $this->st_setting_data_type = $_item; + } + + public function get_st_id() { + return $this->st_id; + } + + public function get_st_name() { + return $this->st_name; + } + + public function get_st_setting_data_type() { + return $this->st_setting_data_type; + } + +} + + +?> \ No newline at end of file diff --git a/_class/class_setting_value.php b/_class/class_setting_value.php new file mode 100644 index 0000000..35a4d9f --- /dev/null +++ b/_class/class_setting_value.php @@ -0,0 +1,100 @@ +setv_id = $_item; + } + + public function set_setv_set_date($_item) { + $this->setv_set_date = $_item; + } + + public function set_setv_setting_set_id($_item) { + $this->setv_setting_set_id = $_item; + } + + public function set_setv_setting($_item) { + $this->setv_setting = $_item; + } + + public function set_setv_int($_item) { + $this->setv_int = $_item; + } + + public function set_setv_varchar($_item) { + $this->setv_varchar = $_item; + } + + public function set_setv_text($_item) { + $this->setv_text = $_item; + } + + public function set_setv_date($_item) { + $this->setv_date = $_item; + } + + public function get_setv_id() { + return $this->setv_id; + } + + public function get_setv_set_date() { + return $this->setv_set_date; + } + + public function get_setv_setting_set_id() { + return $this->setv_setting_set_id; + } + + public function get_setv_setting() { + return $this->setv_setting; + } + + public function get_setv_int() { + return $this->setv_int; + } + + public function get_setv_varchar() { + return $this->setv_varchar; + } + + public function get_setv_text() { + return $this->setv_text; + } + + public function get_setv_date() { + return $this->setv_date; + } + + public function set_setting_value_data_by_id($_id) { + //SETTING ID ALAPJÁN KÉRI LE; + //HA KELL, LEHET KÜLÖN FUNCTION-T ÍRNI HOGY ID ALAPJÁN KÉRJE + global $sql; + $set_data_assoc_array = $sql->assoc_array("select * from setting_value where setv_setting_set_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 == 'setv_setting_set_id') { + $new_set = new setting(); + $new_set->set_setting_data_by_id($value); + $this->set_setv_setting($new_set); + } + } + + } + +} + + +?> \ No newline at end of file diff --git a/_css/default.css b/_css/default.css index f82b2f4..3710037 100644 --- a/_css/default.css +++ b/_css/default.css @@ -421,6 +421,8 @@ table.log tr.delete:hover { width: 100%; } - + .info { + margin: 20px; + } } \ No newline at end of file diff --git a/_include/include_information.php b/_include/include_information.php new file mode 100644 index 0000000..9b39acf --- /dev/null +++ b/_include/include_information.php @@ -0,0 +1,28 @@ +is_id()) { + # EMPTY + + +} +else { + # INFORMÁCIÓK + + $info_query = "SELECT setv_id FROM setting_value JOIN setting ON setv_setting_set_id = set_id WHERE set_name = 'Információk'"; + + $setv_id = $sql->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'); + + + +} + +?> \ No newline at end of file diff --git a/_include/include_settings.php b/_include/include_settings.php new file mode 100644 index 0000000..28b9a75 --- /dev/null +++ b/_include/include_settings.php @@ -0,0 +1,37 @@ +is_id()) { + # ADOTT BEÁLLÍTÁS + + $new_setting = new setting_value(); + $new_setting->set_setting_value_data_by_id($this->get_id()); + + $smarty->assign("setting", $new_setting); + + $smarty->display("setting_data_edit.tpl"); + +} +else { + # BEÁLLÍTÁSOK + + $settings_query = "SELECT * FROM setting ORDER BY set_name ASC"; + $settings_assoc_array = $sql->assoc_array($settings_query); + + $settings = array(); + + foreach ($settings_assoc_array as $value) { + $new_setting = new setting(); + $new_setting->set_setting_data_by_id($value['set_id']); + $settings[] = $new_setting; + } + + $smarty->assign('settings',$settings); + $smarty->display('settings.tpl'); + + + +} + +?> \ No newline at end of file diff --git a/event_handler.php b/event_handler.php index 2e3b1d1..379894d 100644 --- a/event_handler.php +++ b/event_handler.php @@ -258,6 +258,17 @@ 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 'settings_data_edit': + $sql->update_table('setting_value', + array( + 'setv_'.$_POST['st_name'] => $_POST['set_val'] + ), + array( + 'setv_id' => $_POST['setv_id'] + ) + + ); + break; default: # code... break; diff --git a/template/templates/information.tpl b/template/templates/information.tpl new file mode 100644 index 0000000..6b9fd7e --- /dev/null +++ b/template/templates/information.tpl @@ -0,0 +1,3 @@ +

+{nl2br($setting->get_setv_text())} +

\ No newline at end of file diff --git a/template/templates/setting_data_edit.tpl b/template/templates/setting_data_edit.tpl new file mode 100644 index 0000000..2d918df --- /dev/null +++ b/template/templates/setting_data_edit.tpl @@ -0,0 +1,26 @@ +
+
+ + + + + + +
+ +
+ {if $setting->get_setv_setting()->get_set_setting_type_st_id() == 1} + + {/if} +
+
+ + +
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/template/templates/settings.tpl b/template/templates/settings.tpl new file mode 100644 index 0000000..9edb4ca --- /dev/null +++ b/template/templates/settings.tpl @@ -0,0 +1,11 @@ +
+ {foreach $settings as $setting} + +
+ + {$setting->get_set_name()} +
+
+ {/foreach} + +