496 lines
17 KiB
PHP
496 lines
17 KiB
PHP
<?php
|
|
|
|
|
|
if (isset($_POST['action'])) {
|
|
|
|
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
|
switch ($_POST['action']) {
|
|
case 'user_register':
|
|
# REGISZTRÁCIÓ
|
|
$check_user_exists = $sql->num_of_rows("SELECT * FROM camp_user WHERE cu_email = '" . $_POST['user_email'] . "';");
|
|
if ($check_user_exists) {
|
|
//van már reg ezzel az email címmel
|
|
setcookie('bc_reg_error', 1);
|
|
header("Location: /tabor/regisztracio");
|
|
}
|
|
else {
|
|
//sikeres reg. visszairányítjuk a bejelentkező felületre
|
|
$new_camp_user = camp_user::create_camp_user($_POST['user_email'], $_POST['user_password'], date("Y-m-d H:i:s"));
|
|
log::register('new_camp_user', $new_camp_user, date("Y-m-d H:i:s"), $new_camp_user);
|
|
header("Location: /tabor");
|
|
}
|
|
break;
|
|
case 'login':
|
|
# login
|
|
/*
|
|
USER TYPES: 1 - coach, 2 - kid, 3 - parent
|
|
*/
|
|
$login = new login();
|
|
|
|
$user_admin_id = null;
|
|
$user_kid_id = null;
|
|
$user_coach_id = null;
|
|
$user_camp_id = null;
|
|
|
|
if ($_REQUEST['page'] == 'admin') $user_admin_id = $login->check_admin_login($_POST['user_name'], $_POST['user_password']);
|
|
if ($_REQUEST['page'] == 'view') $user_kid_id = $login->check_kid_login($_POST['user_name'], $_POST['user_password']);
|
|
if ($_REQUEST['page'] == 'coach') $user_coach_id = $login->check_coach_login($_POST['user_name'], $_POST['user_password']);
|
|
if ($_REQUEST['page'] == 'tabor') $user_camp_id = $login->check_camp_login($_POST['user_name'], $_POST['user_password']);
|
|
|
|
if ($user_admin_id) {
|
|
//sikeres bejelentkezés adminként
|
|
$login->login_user($user_admin_id, 'badminton_admin_user', 1);
|
|
log::register('admin_login', $user_admin_id, null, $user_admin_id);
|
|
header("Location: " . $actual_link);
|
|
}
|
|
elseif ($user_kid_id) {
|
|
//sikeres bejelentkezés szülőként
|
|
$login->login_user($user_kid_id, 'badminton_parent_user', 2);
|
|
log::register('kid_login', $user_kid_id, null, $user_kid_id);
|
|
header("Location: " . $actual_link);
|
|
}
|
|
elseif ($user_coach_id) {
|
|
//sikeres bejelentkezés szülőként
|
|
$login->login_user($user_coach_id, 'badminton_coach_user', 3);
|
|
log::register('coach_login', $user_coach_id, null, $user_coach_id);
|
|
header("Location: " . $actual_link);
|
|
}
|
|
elseif ($user_camp_id) {
|
|
//sikeres bejelentkezés szülőként
|
|
var_dump('itt');
|
|
$login->login_user($user_camp_id, 'badminton_camp_user', 4);
|
|
log::register('camp_user_login', $user_camp_id, null, $user_camp_id);
|
|
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);
|
|
log::register('update_member', $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);
|
|
log::register('new_member', $new_user_id);
|
|
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;
|
|
$new_parent_id = user_parent::create_parent($_POST['up_name'], $_POST['up_email'], $_POST['up_facebook'], $_POST['up_phone']);
|
|
log::register('new_parent', $new_parent_id);
|
|
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);
|
|
log::register('update_parent', $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);
|
|
log::register('update_training', $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);
|
|
log::register('new_training_type', $new_trt_id);
|
|
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));
|
|
}
|
|
log::register('update_training_type', 'update all');
|
|
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";
|
|
}
|
|
|
|
$new_coach_id = user::create_user($_POST['ua_name'], $psw);
|
|
log::register('new_coach', $new_coach_id);
|
|
header("Location: /admin/coaches");
|
|
break;
|
|
case 'coach_data_edit':
|
|
# edző update
|
|
if (!empty($_POST['ua_password'])) {
|
|
$psw = md5($_POST['ua_password']);
|
|
}
|
|
else {
|
|
$psw = "-1"; //ez jelzi h nem szabad updatelni
|
|
}
|
|
|
|
user::update_user($_POST['ua_name'], $psw, isset($_POST['ua_admin']), $_POST['ua_id']);
|
|
log::register('update_coach', $_POST['ua_id']);
|
|
header("Location: /admin/coaches");
|
|
break;
|
|
case 'shirt_create':
|
|
# póló létrehozása
|
|
//todo: shirt object
|
|
$new_shirt_id = $sql->insert_into('shirt', array(
|
|
'shirt_name' => $_POST['shirt_name']
|
|
)
|
|
);
|
|
log::register('new_shirt', $new_shirt_id);
|
|
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']
|
|
)
|
|
);
|
|
log::register('update_shirt', $_POST['shirt_id']);
|
|
header("Location: /admin/shirts");
|
|
break;
|
|
case 'city_create':
|
|
# település létrehozása
|
|
$new_city_id = school_city::create_school_city($_POST['scc_city']);
|
|
log::register('new_city', $new_city_id);
|
|
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];
|
|
if ($key_parts[0] != "order") {
|
|
$sql->update_table('school_city', array('scc_city' => $value), array('scc_id' => $scc_id));
|
|
}
|
|
else {
|
|
$sql->update_table('school_city', array('scc_order' => ($value==0?'null':$value)), array('scc_id' => $scc_id));
|
|
}
|
|
}
|
|
log::register('update_city', 'update all');
|
|
header("Location: /admin/cities");
|
|
break;
|
|
case 'region_create':
|
|
# körzet létrehozása
|
|
//todo: körzet object
|
|
$new_reg_id = $sql->insert_into('region', array(
|
|
'reg_name' => $_POST['reg_name'],
|
|
)
|
|
);
|
|
log::register('new_region', $new_reg_id);
|
|
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));
|
|
}
|
|
log::register('update_region', 'update all');
|
|
header("Location: /admin/regions");
|
|
break;
|
|
case 'school_data_create':
|
|
# iskola létrehozása
|
|
$new_school_id = school::create_school($_POST['sc_name'], $_POST['sc_school_city_scc_id']);
|
|
log::register('new_school', $new_school_id);
|
|
header("Location: /admin/schools");
|
|
break;
|
|
case 'school_data_edit':
|
|
# iskola módosítása
|
|
unset($_POST['action']);
|
|
school::update_school($_POST['sc_id'], $_POST['sc_name'], $_POST['sc_school_city_scc_id']);
|
|
log::register('update_school', $_POST['sc_id']);
|
|
header("Location: /admin/schools");
|
|
break;
|
|
case 'money_deposit_create':
|
|
# új befizetés létrehozása
|
|
$new_mod_id = money_deposit::create_money_deposit($_POST['mod_user_kid_uk_id'], $_POST['mod_date'], $_POST['mod_sum']);
|
|
$tmp_user = new user_kid();
|
|
$tmp_user->set_user_data_by_id($_POST['mod_user_kid_uk_id']);
|
|
log::register('new_money_deposit', $tmp_user->get_uk_name() . ': ' . $_POST['mod_sum']. ' Ft (' . $_POST['mod_date'] . ')');
|
|
header("Location: /admin/money_deposit");
|
|
break;
|
|
case 'money_deposit_update':
|
|
# befizetés módosítás
|
|
money_deposit::update_money_deposit($_POST['mod_user_kid_uk_id'], $_POST['mod_date'], $_POST['mod_sum'], $_POST['mod_id']);
|
|
$tmp_user = new user_kid();
|
|
$tmp_user->set_user_data_by_id($_POST['mod_user_kid_uk_id']);
|
|
log::register('update_money_deposit', $tmp_user->get_uk_name() . ': ' . $_POST['mod_sum']. ' Ft (' . $_POST['mod_date'] . ')');
|
|
header("Location: /admin/money_deposit");
|
|
break;
|
|
case 'moxc_create':
|
|
# befizetés kategória létrehozása
|
|
$new_moxc_id = money_expense_category::create_money_expense_category($_POST['moxc_name']);
|
|
log::register('new_moxc', $new_moxc_id);
|
|
header("Location: /admin/money_expense_category");
|
|
break;
|
|
case 'moxc_update':
|
|
# befizetés kategória módosítása
|
|
money_expense_category::update_money_expense_category($_POST['moxc_name'], $_POST['moxc_id']);
|
|
log::register('update_moxc', $_POST['moxc_id']);
|
|
header("Location: /admin/money_expense_category");
|
|
break;
|
|
case 'mox_create':
|
|
# befizetés létrehozása
|
|
$new_mox_id = money_expense::create_money_expense($_POST['mox_name'], $_POST['mox_date'], $_POST['mox_item'], $_POST['mox_sum'], $_POST['mox_moxc_id']);
|
|
log::register('new_mox', $_POST['mox_item'] . ": " . $_POST['mox_sum'] . " Ft");
|
|
header("Location: /admin/money_expense");
|
|
break;
|
|
case 'mox_update':
|
|
# befizetés módosítása
|
|
money_expense::update_money_expense($_POST['mox_name'], $_POST['mox_date'], $_POST['mox_item'], $_POST['mox_sum'], $_POST['mox_moxc_id'], $_POST['mox_id']);
|
|
log::register('update_mox', $_POST['mox_item'] . ": " . $_POST['mox_sum'] . " Ft");
|
|
header("Location: /admin/money_expense");
|
|
break;
|
|
case 'settings_data_edit':
|
|
$sql->update_table('setting_value',
|
|
array(
|
|
'setv_'.$_POST['st_name'] => $_POST['set_val'],
|
|
'setv_set_date' => date("Y-m-d H:i:s")
|
|
),
|
|
array(
|
|
'setv_id' => $_POST['setv_id']
|
|
)
|
|
|
|
);
|
|
break;
|
|
case 'camp_type_create':
|
|
# tábor típus létrehozása
|
|
$new_ct_id = camp_type::create_camp_type($_POST['ct_name']);
|
|
log::register('new_ct', $new_ct_id);
|
|
header("Location: /admin/camp_types");
|
|
break;
|
|
case 'camp_type_update':
|
|
# tábor típus módosítása
|
|
unset($_POST['action']);
|
|
foreach ($_POST as $key => $value) {
|
|
$key_parts = explode('_', $key);
|
|
$ct_id = $key_parts[1];
|
|
//$sql->update_table('region', array('reg_name' => $value), array('reg_id' => $reg_id));
|
|
camp_type::update_camp_type($ct_id, $value);
|
|
}
|
|
log::register('update_ct', 'update all');
|
|
header("Location: /admin/camp_types");
|
|
break;
|
|
case 'camp_create':
|
|
# tábor létrehozása
|
|
unset($_POST['action']);
|
|
//meg kell vizsgálni, hogy a checkboxos mezők léteznek-e
|
|
$shuttles = array();
|
|
if (!empty($_POST['shuttles'])) {
|
|
$shuttles = $_POST['shuttles'];
|
|
}
|
|
|
|
$accoms = array();
|
|
if (!empty($_POST['accomodations'])) {
|
|
$accoms = $_POST['accomodations'];
|
|
}
|
|
|
|
camp::create_camp($_POST['camp_city'], $_POST['camp_from'], $_POST['camp_to'], (!empty($_POST['camp_is_open'])?1:0), $_POST['camp_camp_type_ct_id'], $shuttles, $accoms);
|
|
log::register('new_camp', $_POST['camp_from'] . " (" . $_POST['camp_city'] . ")");
|
|
break;
|
|
case 'camp_update':
|
|
# tábor módosítás
|
|
$shuttles = array();
|
|
if (!empty($_POST['shuttles'])) {
|
|
$shuttles = $_POST['shuttles'];
|
|
}
|
|
|
|
$accoms = array();
|
|
if (!empty($_POST['accomodations'])) {
|
|
$accoms = $_POST['accomodations'];
|
|
}
|
|
|
|
camp::update_camp($_POST['camp_city'], $_POST['camp_from'], $_POST['camp_to'], (!empty($_POST['camp_is_open'])?1:0), $_POST['camp_camp_type_ct_id'], $shuttles, $accoms, $_POST['camp_id']);
|
|
log::register('update_camp', $_POST['camp_from'] . " (" . $_POST['camp_city'] . ")");
|
|
header('Location: /admin/camps/' . $_POST['camp_id']);
|
|
|
|
break;
|
|
case 'camp_shirt_create':
|
|
# tábori póló létrehozása
|
|
//todo: shirt object
|
|
$new_shirt_id = $sql->insert_into('camp_shirt', array(
|
|
'cshirt_name' => $_POST['shirt_name']
|
|
)
|
|
);
|
|
log::register('new_camp_shirt', $new_shirt_id);
|
|
header("Location: /admin/camp_shirt_type");
|
|
break;
|
|
case 'camp_shirt_data_edit':
|
|
# camp shirt update
|
|
//todo: shirt object
|
|
$sql->update_table('camp_shirt', array(
|
|
'cshirt_name' => $_POST['shirt_name'],
|
|
),
|
|
array(
|
|
'cshirt_id' => $_POST['shirt_id']
|
|
)
|
|
);
|
|
log::register('update_camp_shirt', $_POST['shirt_id']);
|
|
header("Location: /admin/camp_shirt_type");
|
|
break;
|
|
case 'apply_1':
|
|
//jelentkezés 1. lépés - jelentkező adatai
|
|
|
|
$new_camp_kid_id = camp_kid::create_camp_kid(
|
|
$_POST['ck_name'],
|
|
$_POST['ck_birth_year'],
|
|
$_POST['ck_ss_number'],
|
|
$_POST['ck_email'],
|
|
$_POST['ck_mobile'],
|
|
$_POST['ck_shirt_size_id'],
|
|
array(
|
|
'ck_sport_history' => $_POST['ck_sport_history'],
|
|
'ck_badminton_history' => $_POST['ck_badminton_history'],
|
|
'ck_food_info' => $_POST['ck_food_info'],
|
|
'ck_hygiene_info' => $_POST['ck_hygiene_info'],
|
|
'ck_health_info' => $_POST['ck_health_info'],
|
|
'ck_pharma_info' => $_POST['ck_pharma_info'],
|
|
'ck_other_info' => $_POST['ck_other_info'],
|
|
),
|
|
$_POST['ck_list'],
|
|
$_POST['ck_owner_id']
|
|
);
|
|
//létrehozzuk az apply objektumot és berakjuk cookieba az id-t, azzal azonosítjuk a sessiont
|
|
$new_apply_id = camp_apply::create_camp_apply($new_camp_kid_id);
|
|
setcookie('badminton_camp_session_id', $new_apply_id, time()+60*60, '/');
|
|
header('Location: /tabor/jelentkezes/2');
|
|
break;
|
|
case 'apply_2':
|
|
# jelentkezés 2. lépés - kapcsolattartó adatai
|
|
|
|
//leellenőrizzük, hogy új kapcsolat típust adott-e meg, ha igen, fetöltjük, és kivesszük az id-t
|
|
if ($_POST['cc_camp_contact_type_cct_id'] == 'new') {
|
|
$new_cct_id = $sql->insert_into('camp_contact_type', array('cct_name' => $_POST['cct_add_new'], 'cct_owner' => $_POST['cc_owner_id']));
|
|
$_POST['cc_camp_contact_type_cct_id'] = $new_cct_id;
|
|
}
|
|
|
|
$new_cc_id = camp_contact::create_camp_contact(
|
|
$_POST['cc_name'],
|
|
$_POST['cc_mobile'],
|
|
$_POST['cc_email'],
|
|
$_POST['cc_facebook'],
|
|
$_POST['cc_camp_contact_type_cct_id'],
|
|
$_POST['cc_owner_id'],
|
|
$_POST['cc_list']
|
|
);
|
|
|
|
//hozzáadjuk a jelentkezéshez az új contact-ot
|
|
$sql->insert_into('camp_apply_contact', array(
|
|
'cac_camp_apply_capp_id' => $_COOKIE['badminton_camp_session_id'],
|
|
'cac_camp_contact_cc_id' => $new_cc_id,
|
|
'cac_is_responsible' => (!empty($_POST['cc_is_responsible'])?1:0),
|
|
)
|
|
);
|
|
|
|
//megnézzük, hogy továbblépünk, vagy vissza a contact megadós oldalra
|
|
if (1 == $_POST['add_more']) {
|
|
header('Location: /tabor/jelentkezes/2');
|
|
}
|
|
else {
|
|
//megnézzük, hogy adott-e meg felelős kapcsolattartót
|
|
//ha nem, akkor a 3-as oldalon kilistázzuk a megadott kapcsolattartókat, és kattintással lehet választani
|
|
//ha igen, akkor a negyedik oldalra megyünk
|
|
if (camp_apply::has_responsible_contact($_COOKIE['badminton_camp_session_id'])) {
|
|
header('Location: /tabor/jelentkezes/4');
|
|
}
|
|
else {
|
|
header('Location: /tabor/jelentkezes/3');
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
case 'apply_3':
|
|
# kiválasztott felelős kapcsolattartó beállítása
|
|
camp_apply::make_contact_responsible($_COOKIE['badminton_camp_session_id'], $_POST['cc_is_responsible'], true);
|
|
header("Location: /tabor/jelentkezes/4");
|
|
break;
|
|
case 'apply_4':
|
|
# jelentkezés lezárása
|
|
camp_apply::update_camp_apply($_POST['camp_apply_id'], 2, $_POST['camp_accomodation'], $_POST['camp_shuttle'], date('Y-m-d H:i:s'), 'null', $_POST['camp_id']);
|
|
header('Location: /tabor/jelentkezes/5');
|
|
break;
|
|
default:
|
|
# code...
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|