From f9e6e1ecbbff8990ec4e22be2cb94967fe9551f8 Mon Sep 17 00:00:00 2001 From: Ricsi Date: Sun, 20 Nov 2016 22:55:27 +0100 Subject: [PATCH] Jelenlet alapfunkcio OK. Edzes torles OK. --- .htaccess | 4 +- _ajax/update_presence.php | 20 +++-- _class/class_page.php | 8 +- _class/class_user_kid.php | 4 +- _class/class_user_parent.php | 20 +++++ _include/include_create.php | 7 +- _include/include_delete_training.php | 10 +++ _include/include_parents.php | 6 ++ _include/include_presence.php | 8 +- _include/include_trainings.php | 2 +- event_handler.php | 22 +++++ index.php | 16 ++++ template/templates/parent_create.tpl | 42 ++++++++++ template/templates/parent_data_edit.tpl | 43 ++++++++++ template/templates/parent_list.tpl | 4 +- template/templates/presence.tpl | 93 +++++++++++++++++---- template/templates/presence_list.tpl | 18 ++++ template/templates/training_data_view.tpl | 3 +- template/templates/training_type_create.tpl | 3 - 19 files changed, 289 insertions(+), 44 deletions(-) create mode 100644 _include/include_delete_training.php create mode 100644 template/templates/parent_create.tpl create mode 100644 template/templates/parent_data_edit.tpl create mode 100644 template/templates/presence_list.tpl diff --git a/.htaccess b/.htaccess index 70a3610..5634439 100644 --- a/.htaccess +++ b/.htaccess @@ -3,7 +3,9 @@ Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / -# RewriteRule ^product/(([0-9]/[0-9a-zA-Z-\s]+)+)$ product.php?id=$1&string=$2 + +RewriteRule ^\/?(_ajax\/)([a-zA-Z0-9_]+)\.php$ _ajax/$2.php [NC,L] + RewriteRule ^([a-z_]+)\/?([0-9a-z_]*)\/?([0-9a-z]*)$ index.php?page=$1&subpage=$2&id=$3 [NC,L] diff --git a/_ajax/update_presence.php b/_ajax/update_presence.php index 056e7d9..f1da2f5 100755 --- a/_ajax/update_presence.php +++ b/_ajax/update_presence.php @@ -1,11 +1,17 @@ insert_into('presence', array('pr_user_kid_uk_id' => $_GET['userid'], 'pr_training_tr_id' => '9')); +ini_set('include_path', '/opt/lampp/htdocs/badminton_coach/_class'); +include('class_sql.php'); +$sql = new sql('localhost','root','','badminton_coach'); +/* +foreach ($_POST as $key => $value) { + trigger_error($key . " : " . $value, E_USER_NOTICE); +} +*/ +if ($_POST['checked'] == "true") { + $sql->insert_into('presence', array('pr_user_kid_uk_id' => $_POST['user_id'], 'pr_training_tr_id' => $_POST['tr_id'])); +} +else { + $sql->execute_query('delete from presence where pr_user_kid_uk_id = ' . $_POST['user_id'] . ' AND pr_training_tr_id = ' . $_POST['tr_id']); } ?> \ No newline at end of file diff --git a/_class/class_page.php b/_class/class_page.php index 0fc2dcf..643ddeb 100755 --- a/_class/class_page.php +++ b/_class/class_page.php @@ -29,8 +29,8 @@ class page { public function get_page_content() { global $sql, $user, $smarty; //var_dump($user); - //ini_set('include_path', '/opt/lampp/htdocs/badminton_coach/_include'); - ini_set('include_path', '/var/www/badminton_coach/_include'); + ini_set('include_path', '/opt/lampp/htdocs/badminton_coach/_include'); + //ini_set('include_path', '/var/www/badminton_coach/_include'); if (!empty($user) && $user->is_logged_in()) { if ($this->is_page()) { //TODO: mi van ha nincs page? átirányítás v 404? @@ -66,6 +66,10 @@ class page { $tpl = "edit"; include('include_trainings.php'); break; + case 'delete_training': + # EDZÉS TÖRLÉS + include('include_delete_training.php'); + break; case 'create': # LÉTREHOZÓS OLDALAK include('include_create.php'); diff --git a/_class/class_user_kid.php b/_class/class_user_kid.php index 69a7d3d..1aea1d1 100755 --- a/_class/class_user_kid.php +++ b/_class/class_user_kid.php @@ -194,8 +194,8 @@ class user_kid extends user_parent { foreach ($user_data_array as $field => $value) { $function_name = "set_" . $field; $this->$function_name($value); //alapadatok beállítása - $this->set_ua_type(2); //kid típus beállítása - $this->set_login(true); + //$this->set_ua_type(2); //kid típus beállítása + //$this->set_login(true); } } diff --git a/_class/class_user_parent.php b/_class/class_user_parent.php index 6ca1918..01f2027 100755 --- a/_class/class_user_parent.php +++ b/_class/class_user_parent.php @@ -86,6 +86,26 @@ class user_parent { } } + + public static function create_parent($_parent_name, $_email, $_facebook, $_phone) { + global $sql; + //beilleszti AB-ba + //visszaadja az ID-t + + return $sql->insert_into('user_parent', + array( + 'up_name' => $_parent_name, + 'up_email' => $_email, + 'up_facebook' => $_facebook, + 'up_phone' => $_phone + ) + ); + } + + public static function update_parent($_parent_value_array, $_up_id) { + global $sql; + $sql->update_table('user_parent', $_parent_value_array, array('up_id' => $_up_id)); + } } diff --git a/_include/include_create.php b/_include/include_create.php index f5c6271..90ef8dd 100755 --- a/_include/include_create.php +++ b/_include/include_create.php @@ -27,7 +27,6 @@ switch ($this->get_id()) { break; case 'training': - # code... //TRAINING TYPE ARRAY $training_type_query = "SELECT * FROM training_type ORDER BY trt_name ASC;"; $training_type_assoc_array = $sql->assoc_array($training_type_query); @@ -53,7 +52,11 @@ switch ($this->get_id()) { $smarty->display('training_type_create.tpl'); break; - + case 'parent': + # PARENT LÉTREHOZÁSA + $smarty->display('parent_create.tpl'); + + break; default: # code... break; diff --git a/_include/include_delete_training.php b/_include/include_delete_training.php new file mode 100644 index 0000000..37d8393 --- /dev/null +++ b/_include/include_delete_training.php @@ -0,0 +1,10 @@ +is_id()) { + $delete_query = "DELETE FROM training WHERE tr_id = " . $this->get_id() . ";"; + $sql->execute_query($delete_query); + header("Location: /admin/trainings"); +} + + +?> \ No newline at end of file diff --git a/_include/include_parents.php b/_include/include_parents.php index 06e4f4c..277f486 100644 --- a/_include/include_parents.php +++ b/_include/include_parents.php @@ -5,6 +5,12 @@ if ($this->is_id()) { # ADOTT TAG ADATAINAK MEGJELENÍTÉSE + + $parent = new user_parent(); + $parent->set_user_data_by_id($this->get_id()); + + $smarty->assign('parent', $parent); + $smarty->display('parent_data_edit.tpl'); } else { diff --git a/_include/include_presence.php b/_include/include_presence.php index ca1a914..a644d3c 100755 --- a/_include/include_presence.php +++ b/_include/include_presence.php @@ -8,7 +8,7 @@ if ($this->is_id()) { # GYEREKEK BEJELÖLÉSE # lekérjük, hogy az elmúlt 4 héten kik voltak ilyen típusú edzésen [egyeznie kell a dayofweeknek és a type-nak] - $presence_query = "SELECT * FROM user_kid ORDER BY uk_last_name, uk_first_name;"; + $presence_query = "SELECT * FROM user_kid ORDER BY uk_name;"; $presence_assoc_array = $sql->assoc_array($presence_query); //végig kell menni rajta h legeneráljuk az usereket @@ -31,9 +31,7 @@ if ($this->is_id()) { } else { - $actual_month = date('m'); - $actual_month = 10; - $traning_list_query = "SELECT * FROM training WHERE MONTH(tr_date) = " . $actual_month . ";"; + $traning_list_query = "SELECT * FROM training ORDER BY tr_date DESC;"; $training_list_assoc_array = $sql->assoc_array($traning_list_query); $training_array = array(); @@ -45,7 +43,7 @@ else { //var_dump($training_array); $smarty->assign('edit', $tpl); $smarty->assign("training_array", $training_array); - $smarty->display("training_list.tpl"); + $smarty->display("presence_list.tpl"); } diff --git a/_include/include_trainings.php b/_include/include_trainings.php index 2ac42a3..1d66199 100755 --- a/_include/include_trainings.php +++ b/_include/include_trainings.php @@ -48,7 +48,7 @@ else { $actual_month = date('m'); //$actual_month = 10; - $traning_list_query = "SELECT * FROM training WHERE MONTH(tr_date) = " . $actual_month . ";"; + $traning_list_query = "SELECT * FROM training ORDER BY tr_date DESC;"; $training_list_assoc_array = $sql->assoc_array($traning_list_query); $training_array = array(); diff --git a/event_handler.php b/event_handler.php index 7184621..2d48144 100755 --- a/event_handler.php +++ b/event_handler.php @@ -47,6 +47,28 @@ if (isset($_POST['action'])) { header("Location: /admin/edit_member/" . $new_user_id); break; + case 'parent_create': + # parent létrehozása + unset($_POST['action']); + if (!isset($_POST['up_email'])) $_POST['up_email'] = null; + if (!isset($_POST['up_phone'])) $_POST['up_phone'] = null; + if (!isset($_POST['up_facebook'])) $_POST['up_facebook'] = null; + user_parent::create_parent($_POST['up_name'], $_POST['up_email'], $_POST['up_facebook'], $_POST['up_phone']); + header("Location: /admin/parents"); + break; + + case 'parent_data_update': + # parent updatelés + unset($_POST['action']); + $up_id = $_POST['up_id']; + unset($_POST['up_id']); + if (!isset($_POST['up_email'])) $_POST['up_email'] = null; + if (!isset($_POST['up_phone'])) $_POST['up_phone'] = null; + if (!isset($_POST['up_facebook'])) $_POST['up_facebook'] = null; + user_parent::update_parent($_POST, $up_id); + header("Location: /admin/parents/" . $up_id); + break; + case 'training_data_edit': #training edit $tr_id = $_POST['tr_id']; diff --git a/index.php b/index.php index 179ff0f..fb2367f 100755 --- a/index.php +++ b/index.php @@ -29,6 +29,22 @@ line-height: 18px; font-size: 18px; } + .name_tag { + width: 200px; + text-align: left; + padding: 10px 0px 10px 10px; + margin: 5px; + background-color: #e2edff; + cursor: pointer; + } + .name_tag_checked { + width: 200px; + text-align: left; + padding: 10px 0px 10px 10px; + margin: 5px; + background-color: #1eea0b; + cursor: pointer; + } diff --git a/template/templates/parent_create.tpl b/template/templates/parent_create.tpl new file mode 100644 index 0000000..957a2b4 --- /dev/null +++ b/template/templates/parent_create.tpl @@ -0,0 +1,42 @@ +
+ + + + + + + + + + + + + + + + + + + + + +
+ Név: + + +
+ E-mail cím: + + +
+ Telefonszám: + + +
+ Facebook: + + +
+ +
+
\ No newline at end of file diff --git a/template/templates/parent_data_edit.tpl b/template/templates/parent_data_edit.tpl new file mode 100644 index 0000000..2ee64ea --- /dev/null +++ b/template/templates/parent_data_edit.tpl @@ -0,0 +1,43 @@ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ Név: + + +
+ E-mail cím: + + +
+ Telefonszám: + + +
+ Facebook: + + +
+ +
+
\ No newline at end of file diff --git a/template/templates/parent_list.tpl b/template/templates/parent_list.tpl index f7427b7..7806f54 100644 --- a/template/templates/parent_list.tpl +++ b/template/templates/parent_list.tpl @@ -7,8 +7,8 @@ {foreach $parent_array as $parent} - - {$user->get_up_name()} + + {$parent->get_up_name()} diff --git a/template/templates/presence.tpl b/template/templates/presence.tpl index f90b205..91ca020 100755 --- a/template/templates/presence.tpl +++ b/template/templates/presence.tpl @@ -1,28 +1,85 @@ - - -{foreach $users as $user} - - - - -{/foreach} -
{$user->get_uk_last_name()} {$user->get_uk_first_name()}get_uk_presence($tr_id)}checked{/if}>
- \ No newline at end of file diff --git a/template/templates/presence_list.tpl b/template/templates/presence_list.tpl new file mode 100644 index 0000000..def31fa --- /dev/null +++ b/template/templates/presence_list.tpl @@ -0,0 +1,18 @@ +

Jelenlét

+ + + + + +{foreach $training_array as $training} + + + + +{/foreach} + +
+ + {$training->get_tr_date()|substr:0:-3} ({$training->get_tr_type_name_by_id()}) + +
\ No newline at end of file diff --git a/template/templates/training_data_view.tpl b/template/templates/training_data_view.tpl index ad53cc0..ffc2afb 100755 --- a/template/templates/training_data_view.tpl +++ b/template/templates/training_data_view.tpl @@ -1,6 +1,7 @@ - + + diff --git a/template/templates/training_type_create.tpl b/template/templates/training_type_create.tpl index b9109b6..b93a250 100644 --- a/template/templates/training_type_create.tpl +++ b/template/templates/training_type_create.tpl @@ -1,9 +1,6 @@
SZERKESZTÉSSZERKESZTÉSTÖRLÉS
- - -
Új edzés típus neve: