-
-
+
- {$user->get_uk_name()}
+ diff --git a/_ajax/update_presence.php b/_ajax/update_presence.php index d830120..94e2b7d 100644 --- a/_ajax/update_presence.php +++ b/_ajax/update_presence.php @@ -12,13 +12,21 @@ else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id907379 $check_query = "SELECT * FROM presence WHERE pr_training_tr_id = " . $_POST['tr_id'] . " AND pr_user_kid_uk_id = " . $_POST['user_id'] . ";"; -if (!$sql->num_of_rows($check_query) && $_POST['checked'] == "true") { +if (!$sql->num_of_rows($check_query) && $_POST['checked'] == "false") { $sql->insert_into('presence', array('pr_user_kid_uk_id' => $_POST['user_id'], 'pr_training_tr_id' => $_POST['tr_id'])); log::register('new_presence', 'Edzés: ' . $_POST['tr_id'] . ', gyerek: ' . $_POST['user_id'], null, $_POST['admin_id']); + + if ($_POST['credited']) { + $sql->update_table('user_kid', array('uk_credit' => $_POST['credit'] + 1), array('uk_id' => $_POST['user_id'])); + } } -elseif ($sql->num_of_rows($check_query) && $_POST['checked'] != "true") { +elseif ($sql->num_of_rows($check_query) && $_POST['checked'] == "true") { $sql->execute_query('delete from presence where pr_user_kid_uk_id = ' . $_POST['user_id'] . ' AND pr_training_tr_id = ' . $_POST['tr_id']); log::register('delete_presence', 'Edzés: ' . $_POST['tr_id'] . ', gyerek: ' . $_POST['user_id'], null, $_POST['admin_id']); + + if ($_POST['credit'] > 0) { + $sql->update_table('user_kid', array('uk_credit' => $_POST['credit'] - 1), array('uk_id' => $_POST['user_id'])); + } } ?> diff --git a/_class/class_user_kid.php b/_class/class_user_kid.php index b27204c..99235ec 100644 --- a/_class/class_user_kid.php +++ b/_class/class_user_kid.php @@ -657,11 +657,34 @@ class user_kid extends user_parent { } $de_array[] = $new_diary_entry; - } //itt csak hivatkozással adjuk át a tömböt, a calculate_balance kiszámolja, belerakja és visszadja $this->calculate_balance($de_array, $this); } + + public function get_credit_color($has_credit, $credit, $trainingPrice) { + //vizsgálni kell, hogy: negatív egyenleg előfordulhat-e + //ha igen, van-e hitelezés + //ha igen, túllepte-e PIROS + //ha nem, akkor SÁRGA + //ha nincs, akkor azonnal PIROS + + if ($this->get_uk_balance() < 0 || ($this->get_uk_balance() - $trainingPrice) < 0) { + if (!$has_credit) { + return 'restricted'; + } + else { + if ($this->get_uk_credit() < $credit) { + return 'credit-warning'; + } + else { + return 'credit-restricted'; + } + } + + } + return false; + } } ?> diff --git a/_css/default.css b/_css/default.css index 3a6b520..46ac2f4 100644 --- a/_css/default.css +++ b/_css/default.css @@ -241,7 +241,15 @@ a.addbutton.noti { border-left: 2px solid #000; font-size: 18px; font-family: Arial; +} +.list .name_tag.credit-warning { + background-color: rgb(255, 190, 120); +} + +.list .name_tag.restricted, .list .name_tag.credit-restricted { + background-color: #fd4d4d; + cursor: not-allowed; } .user_mod_form { @@ -727,82 +735,85 @@ form#auto_filters > div > label { @media (min-width: 680px) { -.categories { - width: unset; - text-align: left; - margin: 0px 0px 0px 45px; - padding: 0; -} + .categories { + width: unset; + text-align: left; + margin: 0px 0px 0px 45px; + padding: 0; + } -.toggle { - width: 50px; - height: 50px; - position: relative; - right: -5px; - top: -10px; - background-color: #edfc5a; - float: right; - border-right: 3px solid; - cursor: pointer; -} + .toggle { + width: 50px; + height: 50px; + position: relative; + right: -5px; + top: -10px; + background-color: #edfc5a; + float: right; + border-right: 3px solid; + cursor: pointer; + } -.list .list_item .toggle img { - position: relative; - left: 12px; - top: 10px; - width: 25px; - height: 25px; -} + .list .list_item .toggle img { + position: relative; + left: 12px; + top: 10px; + width: 25px; + height: 25px; + } -.name_span { - min-width: 200px; - display: inline-block; - margin: 0; -} + .name_span { + min-width: 200px; + display: inline-block; + margin: 0; + } -.category_list { - width: 25%; - margin: 0; - display: inline; -} + .category_list { + width: 25%; + margin: 0; + display: inline; + } -.add_category { - width: 25%; - margin: 0; -} + .add_category { + width: 25%; + margin: 0; + } -.list .date_separator { - width: 100%; -} + .list .date_separator { + width: 100%; + } -.balance { - clear: both; - text-align: left; - margin: 10px 0px 15px 0px; - font-size: 20px; - font-weight: bold; - padding-left: 5px; - border-bottom: 2px solid; - width: 30%; -} + .balance { + clear: both; + text-align: left; + margin: 10px 0px 15px 0px; + font-size: 20px; + font-weight: bold; + padding-left: 5px; + border-bottom: 2px solid; + width: 30%; + } -.list_item table.money td.no_mobile_show { - display: table-cell; -} + .list_item table.money td.no_mobile_show { + display: table-cell; + } -.list_item table.money td.sum { - width: 1%; - white-space: nowrap; -} - -.list_item table.money td.quarter_width { - width: 25%; - min-width: 100px; - text-align: left; -} + .list_item table.money td.sum { + width: 1%; + white-space: nowrap; + } + .list_item table.money td.quarter_width { + width: 25%; + min-width: 100px; + text-align: left; + } + .credit-text { + float: right; + margin-right: 15px; + } } @media (min-width: 1250px) { @@ -875,6 +886,4 @@ form#auto_filters > div > label { .diary_header .balance_text { } - - } diff --git a/_include/include_presence.php b/_include/include_presence.php index 2a3f780..f79f457 100644 --- a/_include/include_presence.php +++ b/_include/include_presence.php @@ -129,6 +129,8 @@ if ($this->is_id()) { $s_users[] = $s_user; } + //lekérjük a hitelalkalom beállítást + $credit = $sql->single_variable("SELECT setv_int FROM setting_value JOIN setting ON setv_setting_set_id = set_id WHERE set_name = 'Hitelalkalom';"); $smarty->assign('training', $training); @@ -141,12 +143,11 @@ if ($this->is_id()) { $smarty->assign('sorted_users', $s_users); $smarty->assign('rest_users', $rest_users); $smarty->assign('tr_id', $this->get_id()); + $smarty->assign('has_credit', $credit !== null); + $smarty->assign('credit', $credit); $smarty->display("presence.tpl"); } - - - } else { diff --git a/event_handler.php b/event_handler.php index 2885d5c..44a78fe 100644 --- a/event_handler.php +++ b/event_handler.php @@ -296,6 +296,10 @@ if (isset($_POST['action'])) { $tmp_user->update_balance(); + //ha pozitiv az egyenleg, akkor lenullázhatjuk a hitelalkalmait (???) + if (($tmp_user->get_uk_balance() + $_POST['mod_sum']) > 0) { + $sql->update_table('user_kid', array('uk_credit' => '0'), array('uk_id' => $_POST['mod_user_kid_uk_id'])); + } header("Location: /admin/money_deposit"); break; case 'money_deposit_update': diff --git a/template/templates/presence.tpl b/template/templates/presence.tpl index a9dbfeb..d3f7449 100644 --- a/template/templates/presence.tpl +++ b/template/templates/presence.tpl @@ -42,22 +42,30 @@ {if $trc_coaches || $trc_helpers} -
-
-
+
- {$user->get_uk_name()}
+