241 lines
6.6 KiB
PHP
Executable File
241 lines
6.6 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
if (isset($_POST['action'])) {
|
|
|
|
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
|
switch ($_POST['action']) {
|
|
case 'login':
|
|
# login
|
|
/*
|
|
USER TYPES: 1 - coach, 2 - kid, 3 - parent
|
|
*/
|
|
$login = new login();
|
|
|
|
$user_coach_id = $login->check_coach_login($_POST['user_name'], $_POST['user_password']);
|
|
$user_kid_id = $login->check_kid_login($_POST['user_name'], $_POST['user_password']);
|
|
if ($user_coach_id) {
|
|
//sikeres bejelentkezés
|
|
$login->login_user($user_coach_id, 'badminton_coach_user', 1);
|
|
header("Location: " . $actual_link);
|
|
}
|
|
elseif ($user_kid_id) {
|
|
//sikeres bejelentkezés
|
|
$login->login_user($user_kid_id, 'badminton_parent_user', 2);
|
|
header("Location: " . $actual_link);
|
|
}
|
|
else {
|
|
//die($user_coach_id);
|
|
//sikertelen bejelentkezés
|
|
}
|
|
/*
|
|
$user_id = $login->check_login($_POST['user_name'], $_POST['user_password']);
|
|
if ($user_id) {
|
|
//sikeres bejelentkezés
|
|
$login->login_user($user_id, $_POST['user_type']);
|
|
header("Location: " . $actual_link);
|
|
}
|
|
*/
|
|
break;
|
|
|
|
case 'user_data_edit':
|
|
switch ($_POST['user_type']) {
|
|
case '1':
|
|
# KID
|
|
unset($_POST['user_type']);
|
|
unset($_POST['action']);
|
|
$uid = $_POST['uk_id'];
|
|
unset($_POST['uk_id']);
|
|
user_kid::update_user($_POST, $uid);
|
|
header("Location: " . $actual_link);
|
|
break;
|
|
|
|
default:
|
|
# code...
|
|
break;
|
|
}
|
|
break;
|
|
case 'user_data_create':
|
|
# user létrehozása
|
|
# nincs elágazás user_type szerint
|
|
unset($_POST['action']);
|
|
//var_dump($_POST);
|
|
//die("aaa");
|
|
$new_user_id = user_kid::create_user($_POST);
|
|
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'];
|
|
unset($_POST['tr_id']);
|
|
unset($_POST['action']);
|
|
//var_dump($_POST);
|
|
training::update_training($_POST, $tr_id);
|
|
header("Location: " . $actual_link);
|
|
break;
|
|
|
|
case 'training_data_create':
|
|
# training create
|
|
# a training_list-re ugrik vissza, mert lehet h többet is létrehoz
|
|
unset($_POST['action']);
|
|
|
|
$every_week = isset($_POST['every_week']);
|
|
if ($every_week) unset($_POST['every_week']);
|
|
training::create_training($_POST, $every_week);
|
|
header("Location: /admin/trainings/");
|
|
|
|
|
|
break;
|
|
case 'training_type_create':
|
|
# edzés típus létrehozása
|
|
unset($_POST['action']);
|
|
$new_trt_id = training_type::create_training_type($_POST);
|
|
header("Location: /admin/training_types");
|
|
|
|
break;
|
|
case 'training_type_update':
|
|
# edzés típus lista updatelése ABí-ba
|
|
unset($_POST['action']);
|
|
foreach ($_POST as $key => $value) {
|
|
$key_parts = explode('_', $key);
|
|
$trt_id = $key_parts[1];
|
|
$sql->update_table('training_type', array('trt_name' => $value), array('trt_id' => $trt_id));
|
|
header("Location: " . $actual_link);
|
|
}
|
|
break;
|
|
case 'coach_create':
|
|
# edző létrehozása
|
|
if (isset($_POST['ua_can_login']) && !empty($_POST['ua_can_login'])) {
|
|
$psw = md5($_POST['ua_password']);
|
|
}
|
|
else {
|
|
$psw = "null";
|
|
}
|
|
|
|
user::create_user($_POST['ua_name'], $psw);
|
|
header("Location: /admin/coaches");
|
|
break;
|
|
case 'coach_data_edit':
|
|
# edző update
|
|
if (isset($_POST['ua_can_login']) && !empty($_POST['ua_can_login']) && !empty($_POST['ua_password'])) {
|
|
$psw = md5($_POST['ua_password']);
|
|
}
|
|
elseif (isset($_POST['ua_can_login']) && !empty($_POST['ua_can_login']) && empty($_POST['ua_password'])) {
|
|
$psw = "-1"; //ez jelzi h nem szabad updatelni
|
|
}
|
|
else {
|
|
$psw = "null";
|
|
}
|
|
user::update_user($_POST['ua_name'], $psw, $_POST['ua_id']);
|
|
header("Location: /admin/coaches");
|
|
break;
|
|
case 'shirt_create':
|
|
# póló létrehozása
|
|
//todo: shirt object
|
|
$sql->insert_into('shirt', array(
|
|
'shirt_name' => $_POST['shirt_name']
|
|
)
|
|
);
|
|
header("Location: /admin/shirts");
|
|
break;
|
|
case 'shirt_data_edit':
|
|
# shirt update
|
|
//todo: shirt object
|
|
$sql->update_table('shirt', array(
|
|
'shirt_name' => $_POST['shirt_name'],
|
|
),
|
|
array(
|
|
'shirt_id' => $_POST['shirt_id']
|
|
)
|
|
);
|
|
header("Location: /admin/shirts");
|
|
break;
|
|
case 'city_create':
|
|
# település létrehozása
|
|
//todo: település object
|
|
$sql->insert_into('school_city', array(
|
|
'scc_city' => $_POST['scc_city'],
|
|
)
|
|
);
|
|
header("Location: /admin/cities");
|
|
break;
|
|
case 'city_update':
|
|
# city lista updatelése AB-ba
|
|
unset($_POST['action']);
|
|
foreach ($_POST as $key => $value) {
|
|
$key_parts = explode('_', $key);
|
|
$scc_id = $key_parts[1];
|
|
$sql->update_table('school_city', array('scc_city' => $value), array('scc_id' => $scc_id));
|
|
header("Location: /admin/cities");
|
|
}
|
|
break;
|
|
case 'region_create':
|
|
# körzet létrehozása
|
|
//todo: körzet object
|
|
$sql->insert_into('region', array(
|
|
'reg_name' => $_POST['reg_name'],
|
|
)
|
|
);
|
|
header("Location: /admin/regions");
|
|
break;
|
|
case 'region_update':
|
|
# region lista updatelése AB-ba
|
|
unset($_POST['action']);
|
|
foreach ($_POST as $key => $value) {
|
|
$key_parts = explode('_', $key);
|
|
$reg_id = $key_parts[1];
|
|
$sql->update_table('region', array('reg_name' => $value), array('reg_id' => $reg_id));
|
|
header("Location: /admin/regions");
|
|
}
|
|
break;
|
|
case 'school_create':
|
|
# iskola létrehozása
|
|
//todo: iskola object
|
|
$sql->insert_into('school', array(
|
|
'sc_name' => $_POST['sc_name'],
|
|
)
|
|
);
|
|
header("Location: /admin/schools");
|
|
break;
|
|
case 'school_update':
|
|
# school lista updatelése AB-ba
|
|
unset($_POST['action']);
|
|
foreach ($_POST as $key => $value) {
|
|
$key_parts = explode('_', $key);
|
|
$sc_id = $key_parts[1];
|
|
$sql->update_table('school', array('sc_name' => $value), array('sc_id' => $sc_id));
|
|
header("Location: /admin/schools");
|
|
}
|
|
break;
|
|
default:
|
|
# code...
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|