menu authorities
This commit is contained in:
48
_class/class_authority.php
Normal file
48
_class/class_authority.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
AUTHORITY CLASS
|
||||||
|
*/
|
||||||
|
|
||||||
|
class authority {
|
||||||
|
private $a_id;
|
||||||
|
private $a_name;
|
||||||
|
private $a_title;
|
||||||
|
|
||||||
|
public function set_a_id($_id) {
|
||||||
|
$this->a_id = $_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_a_id() {
|
||||||
|
return $this->a_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_a_name($_name) {
|
||||||
|
$this->a_name = $_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_a_name() {
|
||||||
|
return $this->a_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_a_title($_title) {
|
||||||
|
$this->a_title = $_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_a_title() {
|
||||||
|
return $this->a_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_a_data_by_id($_id) {
|
||||||
|
global $sql;
|
||||||
|
$a_query = "SELECT * FROM authority WHERE a_id = " . $_id . ";";
|
||||||
|
$a_assoc_array = $sql->assoc_array($a_query);
|
||||||
|
foreach ($a_assoc_array[0] as $field => $value) {
|
||||||
|
$function_name = "set_" . $field;
|
||||||
|
$this->$function_name($value); //alapadatok beállítása
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -21,10 +21,28 @@ class page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_page_nav() {
|
public function get_page_nav() {
|
||||||
global $smarty, $sql;
|
global $smarty, $sql, $user;
|
||||||
//nem kell if, hanem page alapján beillesztük az id-t
|
//nem kell if, hanem page alapján beillesztük az id-t
|
||||||
if ($this->get_page() == 'admin') {
|
if ($this->get_page() == 'admin') {
|
||||||
$menus_query = "SELECT * FROM subpage WHERE spage_page_id = 1;";
|
if ($user) {
|
||||||
|
$menus_query = "
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
subpage
|
||||||
|
LEFT JOIN
|
||||||
|
authority ON a_name = spage_url
|
||||||
|
JOIN
|
||||||
|
user_authority ON (ua_authority_a_id = a_id
|
||||||
|
OR ua_authority_a_id = 1)
|
||||||
|
WHERE
|
||||||
|
spage_page_id = 1
|
||||||
|
AND ua_user_kid_uk_id = " . $user->get_ua_id() .";
|
||||||
|
";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$menus_query = "SELECT * FROM subpage WHERE spage_page_id = 1;";
|
||||||
|
}
|
||||||
$menu_assoc_array = $sql->assoc_array($menus_query);
|
$menu_assoc_array = $sql->assoc_array($menus_query);
|
||||||
$smarty->assign('menus', $menu_assoc_array);
|
$smarty->assign('menus', $menu_assoc_array);
|
||||||
}
|
}
|
||||||
@@ -53,8 +71,22 @@ class page {
|
|||||||
$smarty->display('nav.tpl');
|
$smarty->display('nav.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function findInStructure($id, &$array) {
|
||||||
|
if (array_key_exists($id, $array)) {
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($array as $key => $submenu) {
|
||||||
|
if (in_array($id, $submenu)) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function get_page_content() {
|
public function get_page_content() {
|
||||||
global $sql, $user, $smarty;
|
global $sql, $user, $smarty, $structure;
|
||||||
//var_dump($user);
|
//var_dump($user);
|
||||||
ini_set('include_path', '_include/');
|
ini_set('include_path', '_include/');
|
||||||
//ini_set('include_path', '/var/www/badminton_coach/_include');
|
//ini_set('include_path', '/var/www/badminton_coach/_include');
|
||||||
@@ -63,6 +95,23 @@ class page {
|
|||||||
//TODO: mi van ha nincs page? átirányítás v 404?
|
//TODO: mi van ha nincs page? átirányítás v 404?
|
||||||
//page alapján betölti a tpl-t
|
//page alapján betölti a tpl-t
|
||||||
|
|
||||||
|
if ($this->is_subpage() && $this->get_page() == 'admin') {
|
||||||
|
if ('create' == $this->get_subpage()) {
|
||||||
|
$toFind = $this->get_id();
|
||||||
|
} elseif (strpos($this->get_subpage(), 'delete') !== false) {
|
||||||
|
//delete_ utáni rész
|
||||||
|
$toFind = substr($this->get_subpage(), 7);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$toFind = $this->get_subpage();
|
||||||
|
}
|
||||||
|
$subPage = $this->findInStructure($toFind, $structure);
|
||||||
|
if ('exception' != $subPage && !$user->has_authority_by_name($subPage)) {
|
||||||
|
include('include_access_denied.php');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->get_page()) {
|
switch ($this->get_page()) {
|
||||||
case 'admin':
|
case 'admin':
|
||||||
# ADMIN OLDALAK
|
# ADMIN OLDALAK
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class sql extends mysqli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function execute_query($_query) {
|
public function execute_query($_query) {
|
||||||
|
//var_dump($_query);
|
||||||
return self::query($_query);
|
return self::query($_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class user {
|
|||||||
private $user_admin;
|
private $user_admin;
|
||||||
private $logged_in;
|
private $logged_in;
|
||||||
private $user_type;
|
private $user_type;
|
||||||
|
private $authorities = array();
|
||||||
private $user_deleted;
|
private $user_deleted;
|
||||||
|
|
||||||
public function set_ua_id($_uid) {
|
public function set_ua_id($_uid) {
|
||||||
@@ -92,6 +93,16 @@ class user {
|
|||||||
$this->logged_in = $_login;
|
$this->logged_in = $_login;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add_ua_authority($_a_id) {
|
||||||
|
$this->authorities[] = $_a_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove_ua_authority($_a_id) {
|
||||||
|
if (($key = array_search($del_val, $messages)) !== false) {
|
||||||
|
unset($messages[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function set_user_data_by_id($_ua_id) {
|
public function set_user_data_by_id($_ua_id) {
|
||||||
global $sql, $user;
|
global $sql, $user;
|
||||||
$user_data_assoc_array = $sql->assoc_array("select * from user_coach where ua_id = " . $_ua_id);
|
$user_data_assoc_array = $sql->assoc_array("select * from user_coach where ua_id = " . $_ua_id);
|
||||||
@@ -103,6 +114,11 @@ class user {
|
|||||||
$this->set_login(true);
|
$this->set_login(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$authorities_aa = $sql->assoc_array('SELECT * FROM user_authority WHERE ua_user_kid_uk_id = ' . $_ua_id);
|
||||||
|
|
||||||
|
foreach($authorities_aa as $key => $authority) {
|
||||||
|
$this->add_ua_authority($authority['ua_authority_a_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -135,40 +151,77 @@ class user {
|
|||||||
return $sql->single_variable('select count(distinct trc_id) from training_coach join training on tr_id = trc_training_tr_id where year(tr_date) = '.$_year.' and month(tr_date) = '.$_month.' and trc_coach_uc_id = '.$this->get_ua_id().' and tr_deleted = 0;');
|
return $sql->single_variable('select count(distinct trc_id) from training_coach join training on tr_id = trc_training_tr_id where year(tr_date) = '.$_year.' and month(tr_date) = '.$_month.' and trc_coach_uc_id = '.$this->get_ua_id().' and tr_deleted = 0;');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create_user($_name, $_password) {
|
public function has_authority($a_id) {
|
||||||
global $sql;
|
global $sql;
|
||||||
return $sql->insert_into('user_coach', array(
|
return $sql->num_of_rows('SELECT * FROM user_authority WHERE ua_user_kid_uk_id = ' . $this->get_ua_id() . ' AND ua_authority_a_id = ' . $a_id. ';');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function has_authority_by_name($a_name) {
|
||||||
|
global $sql;
|
||||||
|
return $sql->num_of_rows("SELECT * FROM user_authority JOIN authority ON a_id = ua_authority_a_id WHERE ua_user_kid_uk_id = " . $this->get_ua_id() . " AND (a_name = '" . $a_name. "' OR a_name = 'admin');");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_authorities() {
|
||||||
|
return $this->authorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create_user($_name, $_password, $_authorities = array()) {
|
||||||
|
global $sql;
|
||||||
|
$new_user_id = $sql->insert_into('user_coach', array(
|
||||||
'ua_name' => $_name,
|
'ua_name' => $_name,
|
||||||
'ua_password' => $_password
|
'ua_password' => $_password
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (is_array($_authorities) && !empty($_authorities)) {
|
||||||
|
foreach ($_authorities as $key => $authority_id) {
|
||||||
|
$sql->insert_into('user_authority', array(
|
||||||
|
'ua_user_kid_uk_id' => $new_user_id,
|
||||||
|
'ua_authority_a_id' => $authority_id,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update_user($_name, $_password, $_admin, $_ua_id) {
|
public static function update_user($_name, $_password, $_admin, $_ua_id, $_authorities = array()) {
|
||||||
global $sql;
|
global $sql;
|
||||||
if ($_password != "-1") {
|
if ($_password != "-1") {
|
||||||
return $sql->update_table('user_coach',
|
$sql->update_table('user_coach',
|
||||||
array(
|
array(
|
||||||
'ua_name' => $_name,
|
'ua_name' => $_name,
|
||||||
'ua_admin' => ($_admin?1:0),
|
'ua_admin' => ($_admin?1:0),
|
||||||
'ua_password' => $_password
|
'ua_password' => $_password
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'ua_id' => $_ua_id
|
'ua_id' => $_ua_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $sql->update_table('user_coach',
|
$sql->update_table('user_coach',
|
||||||
array(
|
array(
|
||||||
'ua_name' => $_name,
|
'ua_name' => $_name,
|
||||||
'ua_admin' => ($_admin?1:0),
|
'ua_admin' => ($_admin?1:0),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'ua_id' => $_ua_id
|
'ua_id' => $_ua_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql->execute_query('DELETE FROM user_authority WHERE ua_user_kid_uk_id = ' . $_ua_id);
|
||||||
|
if (is_array($_authorities) && !empty($_authorities)) {
|
||||||
|
foreach ($_authorities as $key => $authority_id) {
|
||||||
|
$sql->insert_into('user_authority', array(
|
||||||
|
'ua_user_kid_uk_id' => $_ua_id,
|
||||||
|
'ua_authority_a_id' => $authority_id,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
3
_include/include_access_denied.php
Normal file
3
_include/include_access_denied.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
$smarty->display('access_denied.tpl');
|
||||||
|
?>
|
||||||
@@ -3,35 +3,46 @@
|
|||||||
# HA NINCS ID, AKKOR TAGLISTA
|
# HA NINCS ID, AKKOR TAGLISTA
|
||||||
# HA VAN ID, AKKOR TAG ADATAINAK MEGJELENÍTÉSE/SZERKESZTÉSE
|
# HA VAN ID, AKKOR TAG ADATAINAK MEGJELENÍTÉSE/SZERKESZTÉSE
|
||||||
if ($this->is_id()) {
|
if ($this->is_id()) {
|
||||||
# ADOTT TAG ADATAINAK MEGJELENÍTÉSE
|
# ADOTT TAG ADATAINAK MEGJELENÍTÉSE
|
||||||
//user adatok
|
//user adatok
|
||||||
$user_data_query = "SELECT * FROM user_coach WHERE ua_id = " . $this->get_id();
|
$user_data_query = "SELECT * FROM user_coach WHERE ua_id = " . $this->get_id();
|
||||||
$user_data_assoc_array = $sql->assoc_array($user_data_query);
|
$user_data_assoc_array = $sql->assoc_array($user_data_query);
|
||||||
|
|
||||||
$new_coach = new user();
|
$new_coach = new user();
|
||||||
$new_coach->set_user_data_by_id($user_data_assoc_array[0]['ua_id']);
|
$new_coach->set_user_data_by_id($user_data_assoc_array[0]['ua_id']);
|
||||||
|
|
||||||
//smarty thingz
|
//smarty thingz
|
||||||
|
|
||||||
$smarty->assign('user_data', $user_data_assoc_array[0]);
|
$a_assoc_array = $sql->assoc_array('SELECT * FROM authority');
|
||||||
$smarty->assign('coach', $new_coach);
|
|
||||||
$smarty->display('coach_data_edit.tpl');
|
$a_array = array();
|
||||||
|
foreach ($a_assoc_array as $key => $a) {
|
||||||
|
$new_a = new authority();
|
||||||
|
$new_a->set_a_data_by_id($a['a_id']);
|
||||||
|
$a_array[] = $new_a;
|
||||||
|
}
|
||||||
|
|
||||||
|
$smarty->assign('a_array', $a_array);
|
||||||
|
|
||||||
|
$smarty->assign('user_data', $user_data_assoc_array[0]);
|
||||||
|
$smarty->assign('coach', $new_coach);
|
||||||
|
$smarty->display('coach_data_edit.tpl');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# TAG LISTA
|
# TAG LISTA
|
||||||
|
|
||||||
$user_list_query = "SELECT * FROM user_coach WHERE ua_deleted = 0 ORDER BY ua_name ASC;";
|
$user_list_query = "SELECT * FROM user_coach WHERE ua_deleted = 0 ORDER BY ua_name ASC;";
|
||||||
$user_list_assoc_array = $sql->assoc_array($user_list_query);
|
$user_list_assoc_array = $sql->assoc_array($user_list_query);
|
||||||
//végigmegyünk a tömbbön, objektumot csinálunk belőlük, és átadjuk egy array-ben a template-nek
|
//végigmegyünk a tömbbön, objektumot csinálunk belőlük, és átadjuk egy array-ben a template-nek
|
||||||
$user_array = array();
|
$user_array = array();
|
||||||
foreach ($user_list_assoc_array as $user_list_array) {
|
foreach ($user_list_assoc_array as $user_list_array) {
|
||||||
$current_user = new user();
|
$current_user = new user();
|
||||||
$current_user->set_user_data_by_id($user_list_array['ua_id']);
|
$current_user->set_user_data_by_id($user_list_array['ua_id']);
|
||||||
$user_array[] = $current_user;
|
$user_array[] = $current_user;
|
||||||
}
|
}
|
||||||
$smarty->assign('user_array', $user_array);
|
$smarty->assign('user_array', $user_array);
|
||||||
$smarty->display('coach_list.tpl');
|
$smarty->display('coach_list.tpl');
|
||||||
//var_dump($user_array);
|
//var_dump($user_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -77,6 +77,16 @@ switch ($this->get_id()) {
|
|||||||
break;
|
break;
|
||||||
case 'coach':
|
case 'coach':
|
||||||
# COACH létrehozása
|
# COACH létrehozása
|
||||||
|
$a_assoc_array = $sql->assoc_array('SELECT * FROM authority');
|
||||||
|
|
||||||
|
$a_array = array();
|
||||||
|
foreach ($a_assoc_array as $key => $a) {
|
||||||
|
$new_a = new authority();
|
||||||
|
$new_a->set_a_data_by_id($a['a_id']);
|
||||||
|
$a_array[] = $new_a;
|
||||||
|
}
|
||||||
|
|
||||||
|
$smarty->assign('a_array', $a_array);
|
||||||
$smarty->display('coach_create.tpl');
|
$smarty->display('coach_create.tpl');
|
||||||
break;
|
break;
|
||||||
case 'shirt':
|
case 'shirt':
|
||||||
|
|||||||
49
common.php
49
common.php
@@ -112,6 +112,55 @@ else {
|
|||||||
|
|
||||||
//var_dump($sql);
|
//var_dump($sql);
|
||||||
|
|
||||||
|
//PAGE STRUCTURE FOR AUTHORITIES
|
||||||
|
$structure = array(
|
||||||
|
'members' => array(
|
||||||
|
'parents',
|
||||||
|
'shirts',
|
||||||
|
'cities',
|
||||||
|
'schools',
|
||||||
|
'regions',
|
||||||
|
'member',
|
||||||
|
'parent',
|
||||||
|
'shirt',
|
||||||
|
'city',
|
||||||
|
'school',
|
||||||
|
'region'
|
||||||
|
),
|
||||||
|
'trainings' => array(
|
||||||
|
'training_types',
|
||||||
|
'training_templates',
|
||||||
|
'training',
|
||||||
|
'training_type',
|
||||||
|
'training_template',
|
||||||
|
'edit_training',
|
||||||
|
),
|
||||||
|
'presence' => array(
|
||||||
|
'lock_training',
|
||||||
|
),
|
||||||
|
'coaches' => array(
|
||||||
|
'coach'
|
||||||
|
),
|
||||||
|
'money_deposit' => array(
|
||||||
|
'balance_list',
|
||||||
|
'money_update',
|
||||||
|
'money_deposit',
|
||||||
|
),
|
||||||
|
'money_expense' => array(
|
||||||
|
'money_expense_category',
|
||||||
|
'money_expense',
|
||||||
|
),
|
||||||
|
'money_income' => array(
|
||||||
|
'money_incode_category',
|
||||||
|
'money_income'
|
||||||
|
),
|
||||||
|
'settings' => array(),
|
||||||
|
'exception' => array(
|
||||||
|
'logout'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//echo $_GET['page'];
|
//echo $_GET['page'];
|
||||||
|
|
||||||
$logout = false; //meg kell-e jeleníteni a kijelentkezés gombot
|
$logout = false; //meg kell-e jeleníteni a kijelentkezés gombot
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ if (isset($_POST['action'])) {
|
|||||||
$psw = "null";
|
$psw = "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_coach_id = user::create_user($_POST['ua_name'], $psw);
|
$new_coach_id = user::create_user($_POST['ua_name'], $psw, $_POST['authorities']);
|
||||||
log::register('new_coach', $new_coach_id);
|
log::register('new_coach', $new_coach_id);
|
||||||
header("Location: /admin/coaches");
|
header("Location: /admin/coaches");
|
||||||
break;
|
break;
|
||||||
@@ -200,9 +200,9 @@ if (isset($_POST['action'])) {
|
|||||||
$psw = "-1"; //ez jelzi h nem szabad updatelni
|
$psw = "-1"; //ez jelzi h nem szabad updatelni
|
||||||
}
|
}
|
||||||
|
|
||||||
user::update_user($_POST['ua_name'], $psw, isset($_POST['ua_admin']), $_POST['ua_id']);
|
user::update_user($_POST['ua_name'], $psw, isset($_POST['ua_admin']), $_POST['ua_id'], $_POST['authorities']);
|
||||||
log::register('update_coach', $_POST['ua_id']);
|
log::register('update_coach', $_POST['ua_id']);
|
||||||
header("Location: /admin/coaches");
|
header("Location: /admin/coaches/".$_POST['ua_id']);
|
||||||
break;
|
break;
|
||||||
case 'shirt_create':
|
case 'shirt_create':
|
||||||
# póló létrehozása
|
# póló létrehozása
|
||||||
|
|||||||
31
queries/authority_20190725.sql
Normal file
31
queries/authority_20190725.sql
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
CREATE TABLE `authority` (
|
||||||
|
`a_id` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`a_name` VARCHAR(126) CHARACTER SET 'utf8' COLLATE 'utf8_hungarian_ci' NOT NULL,
|
||||||
|
`a_title` VARCHAR(126) CHARACTER SET 'utf8' COLLATE 'utf8_hungarian_ci' NOT NULL,
|
||||||
|
PRIMARY KEY (`a_id`));
|
||||||
|
|
||||||
|
CREATE TABLE `user_authority` (
|
||||||
|
`ua_id` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`ua_user_kid_uk_id` INT NOT NULL,
|
||||||
|
`ua_authority_a_id` INT NOT NULL,
|
||||||
|
PRIMARY KEY (`ua_id`),
|
||||||
|
INDEX `index2` (`ua_user_kid_uk_id` ASC),
|
||||||
|
INDEX `index3` (`ua_authority_a_id` ASC));
|
||||||
|
|
||||||
|
CREATE TABLE `user_authority` (
|
||||||
|
`ua_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`ua_user_kid_uk_id` int(11) NOT NULL,
|
||||||
|
`ua_authority_a_id` int(11) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`ua_id`),
|
||||||
|
INDEX `index2` (`ua_user_kid_uk_id` ASC),
|
||||||
|
INDEX `index3` (`ua_authority_a_id` ASC));
|
||||||
|
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('admin', 'Admin');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('members', 'Tagok');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('trainings', 'Edzések');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('presence', 'Jelenlét');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('coaches', 'Edzők');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('money_deposit', 'Befizetések');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('money_expense', 'Kiadások');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('money_income', 'Bevételek');
|
||||||
|
INSERT INTO `authority` (`a_name`, `a_title`) VALUES ('settings', 'Beállítások');
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
ALTER TABLE `badminton_coach`.`training_type`
|
ALTER TABLE `training_type`
|
||||||
ADD COLUMN `trt_default_price` INT NULL DEFAULT NULL AFTER `trt_deleted`;
|
ADD COLUMN `trt_default_price` INT NULL DEFAULT NULL AFTER `trt_deleted`;
|
||||||
|
|
||||||
ALTER TABLE `badminton_coach`.`training`
|
ALTER TABLE `training`
|
||||||
ADD COLUMN `tr_price` INT NULL DEFAULT NULL AFTER `tr_deleted`;
|
ADD COLUMN `tr_price` INT NULL DEFAULT NULL AFTER `tr_deleted`;
|
||||||
|
|||||||
1
template/templates/access_denied.tpl
Normal file
1
template/templates/access_denied.tpl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<h2>Nincs jogosultsága ehhez a menüponthoz!</h2>
|
||||||
@@ -1,39 +1,66 @@
|
|||||||
<div class="form_wrapper">
|
<div class="form_wrapper">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="hidden" name="action" value="coach_create">
|
<input type="hidden" name="action" value="coach_create">
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="desc" id="title1" for="ua_name">Név:</label>
|
|
||||||
<div><input type="text" name="ua_name" id="ua_name" required></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title1" for="ua_can_login">Be tud lépni:</label>
|
<label class="desc" id="title1" for="ua_name">Név:</label>
|
||||||
<div><input type="checkbox" name="ua_can_login" id="ua_can_login"></div>
|
<div><input type="text" name="ua_name" id="ua_name" required></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="password">
|
<div>
|
||||||
<label class="desc" id="title1" for="ua_password">Jelszó:</label>
|
<label class="desc" id="title1" for="ua_can_login">Be tud lépni:</label>
|
||||||
<div><input type="text" name="ua_password" id="ua_password"></div>
|
<div><input type="checkbox" name="ua_can_login" id="ua_can_login"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div id="password" class="admin_area">
|
||||||
<div>
|
<label class="desc" for="ua_password">Jelszó:</label>
|
||||||
<input class="button black" type="submit" value="Létrehozás">
|
<div><input type="text" name="ua_password" id="ua_password"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="admin_area">
|
||||||
|
<label>Jogosultságok:</label>
|
||||||
|
<table id="authorities">
|
||||||
|
{foreach $a_array as $a}
|
||||||
|
<tr id="a_{$a->get_a_id()}">
|
||||||
|
<td><label for="authority_{$a->get_a_id()}">{$a->get_a_title()}</label></td>
|
||||||
|
<td><input class="authorities" value="{$a->get_a_id()}" type="checkbox" name="authorities[]" id="authority_{$a->get_a_id()}"></td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
<div>
|
||||||
|
<div>
|
||||||
|
<input class="button black" type="submit" value="Létrehozás">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$( document ).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#password").hide();
|
$(".admin_area").hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#ua_can_login').click(function() {
|
$('#ua_can_login').click(function() {
|
||||||
$("#password").toggle(this.checked);
|
$(".admin_area").toggle(this.checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
$('.authorities').on('change', function () {
|
||||||
|
if ($('#authority_1').is(':checked')) {
|
||||||
|
$('.authorities').each(function (k,v) {
|
||||||
|
if ($(v).val() > 1) {
|
||||||
|
$(this).prop('checked', false);
|
||||||
|
$(this).prop('disabled', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.authorities').each(function (k,v) {
|
||||||
|
if ($(v).val() > 1) {
|
||||||
|
$(this).removeAttr('disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,32 +1,68 @@
|
|||||||
<div class="form_wrapper">
|
<div class="form_wrapper">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="/admin/delete_coach/{$coach->get_ua_id()}" class="addbutton delete-big">Edző törlése</a>
|
<a href="/admin/delete_coach/{$coach->get_ua_id()}" class="addbutton delete-big">Edző törlése</a>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="action" value="coach_data_edit">
|
<input type="hidden" name="action" value="coach_data_edit">
|
||||||
<input type="hidden" name="ua_id" value="{$coach->get_ua_id()}">
|
<input type="hidden" name="ua_id" value="{$coach->get_ua_id()}">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title1" for="ua_name">Név:</label>
|
<label class="desc" id="title1" for="ua_name">Név:</label>
|
||||||
<div><input type="text" name="ua_name" id="ua_name" value="{$coach->get_ua_name()}" required></div>
|
<div><input type="text" name="ua_name" id="ua_name" value="{$coach->get_ua_name()}" required></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title1" for="ua_can_login">Admin:</label>
|
<label class="desc" id="title1" for="ua_can_login">Be tud lépni:</label>
|
||||||
<div><input type="checkbox" name="ua_admin" id="ua_admin" {if $coach->get_ua_admin()}checked{/if}></div>
|
<div><input type="checkbox" name="ua_admin" id="ua_admin" {if $coach->get_ua_admin()}checked{/if}></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="password">
|
<div id="password">
|
||||||
<label class="desc" id="title1" for="ua_password">Új jelszó:</label>
|
<label class="desc" id="title1" for="ua_password">Új jelszó:</label>
|
||||||
<div><input type="text" name="ua_password" id="ua_password"></div>
|
<div><input type="text" name="ua_password" id="ua_password"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="admin_area">
|
||||||
<div>
|
<label>Jogosultságok:</label>
|
||||||
<input class="button black" type="submit" value="Mentés">
|
<table id="authorities">
|
||||||
</div>
|
{foreach $a_array as $a}
|
||||||
</div>
|
<tr id="a_{$a->get_a_id()}">
|
||||||
|
<td><label for="authority_{$a->get_a_id()}">{$a->get_a_title()}</label></td>
|
||||||
|
<td><input class="authorities" value="{$a->get_a_id()}" type="checkbox" name="authorities[]" id="authority_{$a->get_a_id()}" {if $coach->has_authority($a->get_a_id())}checked{/if}></td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
<div>
|
||||||
</div>
|
<div>
|
||||||
|
<input class="button black" type="submit" value="Mentés">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('.authorities').on('change', function () {
|
||||||
|
if ($('#authority_1').is(':checked')) {
|
||||||
|
$('.authorities').each(function (k,v) {
|
||||||
|
if ($(v).val() > 1) {
|
||||||
|
$(this).prop('checked', false);
|
||||||
|
$(this).prop('disabled', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.authorities').each(function (k,v) {
|
||||||
|
if ($(v).val() > 1) {
|
||||||
|
$(this).removeAttr('disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.authorities').trigger('change');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -1,65 +1,95 @@
|
|||||||
<div class="form_wrapper">
|
<div class="form_wrapper">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a href="/admin/delete_training/{$training_data.tr_id}" class="addbutton delete-big">Törlés</a>
|
<a href="/admin/delete_training/{$training_data.tr_id}" class="addbutton delete-big">Törlés</a>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="action" id="action" value="training_data_edit">
|
<input type="hidden" name="action" id="action" value="training_data_edit">
|
||||||
<input type="hidden" name="tr_id" id="tr_id" value="{$training_data.tr_id}">
|
<input type="hidden" name="tr_id" id="tr_id" value="{$training_data.tr_id}">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title1" for="tr_date">Dátum:</label>
|
<label class="desc" id="title1" for="tr_date">Dátum:</label>
|
||||||
<div><input type="text" name="tr_date" id="tr_date" value="{$training_data.tr_date|substr:0:-3}" required></div>
|
<div><input type="text" name="tr_date" id="tr_date" value="{$training_data.tr_date|substr:0:-3}" required></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title2" for="tr_training_type_trt_id">Típus:</label>
|
<label class="desc" id="title2" for="tr_training_type_trt_id">Típus:</label>
|
||||||
<div>
|
<div>
|
||||||
<select name="tr_training_type_trt_id" id="tr_training_type_trt_id">
|
<select name="tr_training_type_trt_id" id="tr_training_type_trt_id">
|
||||||
<option value="null"> - </option>
|
<option value="null"> - </option>
|
||||||
{foreach $training_type_assoc_array as $training_type_array}
|
{foreach $training_type_assoc_array as $training_type_array}
|
||||||
<option value="{$training_type_array.trt_id}"{if $training_type_array.trt_id == $training_data.tr_training_type_trt_id} selected{/if}>
|
<option value="{$training_type_array.trt_id}"{if $training_type_array.trt_id == $training_data.tr_training_type_trt_id} selected{/if}>
|
||||||
{$training_type_array.trt_name}
|
{$training_type_array.trt_name}
|
||||||
</option>
|
</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title1" for="tr_duration">Időtartam (perc):</label>
|
<label class="desc" id="title1" for="tr_duration">Időtartam (perc):</label>
|
||||||
<div><input type="text" name="tr_duration" id="tr_duration" value="{$training_data.tr_duration}" required></div>
|
<div><input type="text" name="tr_duration" id="tr_duration" value="{$training_data.tr_duration}" required></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" for="tr_note">Megjegyzés:</label>
|
<label class="desc" for="tr_price">Ár:</label>
|
||||||
<div>
|
<div><input type="text" name="tr_price" id="tr_price" value="{$training_data.tr_price}" required></div>
|
||||||
<textarea rows="4" name="tr_note" id="tr_note">{$training_data.tr_note}</textarea>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="desc" id="title1" for="coaches">Edző(k):</label>
|
<label class="desc" for="tr_note">Megjegyzés:</label>
|
||||||
<table>
|
<div>
|
||||||
<tr>
|
<textarea rows="4" name="tr_note" id="tr_note">{$training_data.tr_note}</textarea>
|
||||||
<td class="bold">Név</td>
|
</div>
|
||||||
<td class="bold center">E</td>
|
</div>
|
||||||
<td class="bold center">SE</td>
|
|
||||||
</tr>
|
|
||||||
{foreach $coach_array as $coach}
|
|
||||||
<tr>
|
|
||||||
<td class="coach">{$coach->get_ua_name()}</td>
|
|
||||||
<td><input type="checkbox" name="coaches[]" value="{$coach->get_ua_id()}" class="coach_type"{if $coach->is_coach_at_training($tr_id)} checked{/if}></td>
|
|
||||||
<td><input type="checkbox" name="helpers[]" value="{$coach->get_ua_id()}" class="coach_type"{if $coach->is_helper_at_training($tr_id)} checked{/if}></td>
|
|
||||||
</tr>
|
|
||||||
{/foreach}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<label class="desc" id="title1" for="coaches">Edző(k):</label>
|
||||||
<input class="button black" type="submit" value="Mentés">
|
<table>
|
||||||
</div>
|
<tr>
|
||||||
</div>
|
<td class="bold">Név</td>
|
||||||
|
<td class="bold center">E</td>
|
||||||
|
<td class="bold center">SE</td>
|
||||||
|
</tr>
|
||||||
|
{foreach $coach_array as $coach}
|
||||||
|
<tr>
|
||||||
|
<td class="coach">{$coach->get_ua_name()}</td>
|
||||||
|
<td><input type="checkbox" name="coaches[]" value="{$coach->get_ua_id()}" class="coach_type"{if $coach->is_coach_at_training($tr_id)} checked{/if}></td>
|
||||||
|
<td><input type="checkbox" name="helpers[]" value="{$coach->get_ua_id()}" class="coach_type"{if $coach->is_helper_at_training($tr_id)} checked{/if}></td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
<div>
|
||||||
|
<div>
|
||||||
|
<input class="button black" type="submit" value="Mentés">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$('#tr_training_type_trt_id').on('change', function(e) {
|
||||||
|
//get trt default price by ajax
|
||||||
|
let selectedType = $('#tr_training_type_trt_id option:selected').val();
|
||||||
|
$.ajax({
|
||||||
|
url: '/_ajax/get_trt_default_price.php',
|
||||||
|
//method: 'GET',
|
||||||
|
data: {
|
||||||
|
'trt_id' : selectedType
|
||||||
|
},
|
||||||
|
success: function(data, status, jqXHR) {
|
||||||
|
let pdata = JSON.parse(data);
|
||||||
|
console.log(pdata);
|
||||||
|
if (null === pdata) {
|
||||||
|
$('#tr_price').val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#tr_price').val(pdata);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user