108 lines
2.6 KiB
PHP
Executable File
108 lines
2.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_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);
|
|
}
|
|
else {
|
|
//sikertelen bejelentkezés
|
|
}
|
|
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']);
|
|
$new_user_id = user_kid::create_user($_POST);
|
|
header("Location: /admin/edit_member/" . $new_user_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']);
|
|
|
|
//coaches array alapján insertálunk
|
|
|
|
if (isset($_POST['coaches'])) {
|
|
$coaches = $_POST['coaches'];
|
|
unset($_POST['coaches']);
|
|
}
|
|
|
|
$every_week = isset($_POST['every_week']);
|
|
if ($every_week) unset($_POST['every_week']);
|
|
$new_training_id = training::create_training($_POST, $every_week);
|
|
//TRAINING_COACH kezelése
|
|
if ($coaches) {
|
|
foreach ($coaches as $coach_id) {
|
|
$sql->insert_into('training_coach', array('trc_training_tr_id' => $new_training_id, 'trc_coach_uc_id' => $coach_id));
|
|
}
|
|
}
|
|
|
|
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;
|
|
default:
|
|
# code...
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|