custom training price

This commit is contained in:
Tóth Richárd
2019-07-25 12:22:15 +02:00
parent 161453e9b5
commit 2c663d7ed1
20 changed files with 266 additions and 156 deletions

View File

@@ -2,7 +2,7 @@
//tag listánál ez adja vissza a keresés eredményét //tag listánál ez adja vissza a keresés eredményét
ini_set('include_path', '../_class/'); ini_set('include_path', '../_class/');
include('class_sql.php'); include('class_sql.php');
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu') $sql = new sql('bcd_mysql','root','','badminton_coach'); if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos'); else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
//megnézzük, hogy a KID benne van-e olyan category-val, ami az adott grouphoz tartozik //megnézzük, hogy a KID benne van-e olyan category-val, ami az adott grouphoz tartozik

View File

@@ -2,7 +2,7 @@
ini_set('include_path', '../_class/'); ini_set('include_path', '../_class/');
include('class_sql.php'); include('class_sql.php');
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu') $sql = new sql('bcd_mysql','root','','badminton_coach'); if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos'); else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
if ($_POST['parent_id'] == 'null') { if ($_POST['parent_id'] == 'null') {

View File

@@ -2,7 +2,7 @@
//tag listánál ez adja vissza a keresés eredményét //tag listánál ez adja vissza a keresés eredményét
ini_set('include_path', '../_class/'); ini_set('include_path', '../_class/');
include('class_sql.php'); include('class_sql.php');
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu') $sql = new sql('bcd_mysql','root','','badminton_coach'); if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos'); else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
if (empty($_GET['template_id'])) { if (empty($_GET['template_id'])) {

View File

@@ -0,0 +1,19 @@
<?php
//tag listánál ez adja vissza a keresés eredményét
ini_set('include_path', '../_class/');
include('class_sql.php');
if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
if (empty($_GET['trt_id'])) {
echo json_encode(null);
}
else {
$trt_query = "SELECT trt_default_price FROM training_type WHERE trt_id = " . $_GET['trt_id'];
$trt_default_price = $sql->single_variable($trt_query);
echo json_encode($trt_default_price);
}
?>

View File

@@ -2,7 +2,7 @@
//tag listánál ez adja vissza a keresés eredményét //tag listánál ez adja vissza a keresés eredményét
ini_set('include_path', '../_class/'); ini_set('include_path', '../_class/');
include('class_sql.php'); include('class_sql.php');
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu') $sql = new sql('bcd_mysql','root','','badminton_coach'); if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos'); else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
$filter1 = ""; $filter1 = "";

View File

@@ -7,7 +7,7 @@ foreach ($_POST as $key => $value) {
trigger_error($_SERVER['HTTP_HOST'], E_USER_NOTICE); trigger_error($_SERVER['HTTP_HOST'], E_USER_NOTICE);
} }
*/ */
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu') $sql = new sql('bcd_mysql','root','','badminton_coach'); if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos'); else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
$check_query = "SELECT * FROM presence WHERE pr_training_tr_id = " . $_POST['tr_id'] . " AND pr_user_kid_uk_id = " . $_POST['user_id'] . ";"; $check_query = "SELECT * FROM presence WHERE pr_training_tr_id = " . $_POST['tr_id'] . " AND pr_user_kid_uk_id = " . $_POST['user_id'] . ";";

View File

@@ -3,7 +3,7 @@
/* /*
PAGE CLASS PAGE CLASS
url alapjan lekeri a template-et url alapjan lekeri a template-et
http://badmintoncoach-demo.hu/PAGE/SUBPAGE/ID http://cegledcoach.hu/PAGE/SUBPAGE/ID
*/ */

View File

@@ -3,9 +3,6 @@
/* /*
TRAINING osztály TRAINING osztály
Edzések Edzések
*/ */
class training { class training {
@@ -16,13 +13,12 @@ class training {
private $tr_duration; private $tr_duration;
private $tr_note; private $tr_note;
private $tr_locked; private $tr_locked;
private $tr_price;
private $tr_deleted; private $tr_deleted;
private $coaches = array(); private $coaches = array();
private $helpers = array(); private $helpers = array();
public function set_tr_id($_tr_id) { public function set_tr_id($_tr_id) {
$this->tr_id = $_tr_id; $this->tr_id = $_tr_id;
} }
@@ -47,6 +43,10 @@ class training {
$this->tr_locked = $_tr_locked; $this->tr_locked = $_tr_locked;
} }
public function set_tr_price($_tr_price) {
$this->tr_price = $_tr_price;
}
public function set_tr_deleted($_tr_deleted) { public function set_tr_deleted($_tr_deleted) {
$this->tr_deleted = $_tr_deleted; $this->tr_deleted = $_tr_deleted;
} }
@@ -89,6 +89,10 @@ class training {
return $this->tr_locked; return $this->tr_locked;
} }
public function get_tr_price() {
return $this->tr_price;
}
public function get_tr_deleted() { public function get_tr_deleted() {
return $this->tr_deleted; return $this->tr_deleted;
} }
@@ -209,6 +213,9 @@ class training {
if ($_training_value_array['tr_note'] == "") { if ($_training_value_array['tr_note'] == "") {
$_training_value_array['tr_note'] = null; $_training_value_array['tr_note'] = null;
} }
if ($_training_value_array['tr_price'] == "") {
$_training_value_array['tr_price'] = null;
}
$new_tr_id = $sql->insert_into('training', $_training_value_array); $new_tr_id = $sql->insert_into('training', $_training_value_array);
log::register('new_training', $new_tr_id); log::register('new_training', $new_tr_id);
if (isset($coaches)) { if (isset($coaches)) {

View File

@@ -2,10 +2,10 @@
# EDZÉS TÍPUS OSZTÁLY # EDZÉS TÍPUS OSZTÁLY
class training_type { class training_type {
private $trt_id; private $trt_id;
private $trt_name; private $trt_name;
private $trt_default_price;
private $trt_deleted; private $trt_deleted;
public function set_trt_id($_id) { public function set_trt_id($_id) {
@@ -20,6 +20,10 @@ class training_type {
$this->trt_deleted = $_deleted; $this->trt_deleted = $_deleted;
} }
public function set_trt_default_price($_price) {
$this->trt_default_price = $_price;
}
public function get_trt_id() { public function get_trt_id() {
return $this->trt_id; return $this->trt_id;
} }
@@ -28,15 +32,31 @@ class training_type {
return $this->trt_name; return $this->trt_name;
} }
public function get_trt_default_price() {
return $this->trt_default_price;
}
public function get_trt_deleted() { public function get_trt_deleted() {
return $this->trt_deleted; return $this->trt_deleted;
} }
public static function create_training_type($_trt_value_array) { public static function create_training_type($_trt_value_array) {
global $sql; global $sql;
if ('' == $_trt_value_array['trt_default_price']) {
$_trt_value_array['trt_default_price'] = 'null';
}
return $sql->insert_into('training_type', $_trt_value_array); return $sql->insert_into('training_type', $_trt_value_array);
} }
public static function update_training_type($_trt_value_array) {
global $sql;
$default_price = $_trt_value_array['trt_default_price'];
if ('' == $default_price) {
$default_price = 'null';
}
return $sql->update_table('training_type', array('trt_name' => $_trt_value_array['trt_name'], 'trt_default_price' => $default_price), array('trt_id' => $_trt_value_array['trt_id']));
}
public function set_trt_data_by_id($_id) { public function set_trt_data_by_id($_id) {
global $sql; global $sql;
$trt_data_assoc_array = $sql->assoc_array("select * from training_type where trt_id = " . $_id); $trt_data_assoc_array = $sql->assoc_array("select * from training_type where trt_id = " . $_id);
@@ -49,5 +69,4 @@ class training_type {
} }
} }
?> ?>

View File

@@ -531,7 +531,9 @@ class user_kid extends user_parent {
if ($_de->get_de_type() == 'training') { if ($_de->get_de_type() == 'training') {
//$balance -= 1200; //$balance -= 1200;
$_de->set_de_transaction(-1000); //beállítjuk, mennyivel csökken az egyenleg $training = $_de->get_de_training();
$trainingPrice = $training->get_tr_price();
$_de->set_de_transaction(-$trainingPrice); //beállítjuk, mennyivel csökken az egyenleg
if (0 == $i) { if (0 == $i) {
$_de->set_de_balance($balance+$_de->get_de_transaction()); //beállítjuk az új egyenleget $_de->set_de_balance($balance+$_de->get_de_transaction()); //beállítjuk az új egyenleget
} }
@@ -588,7 +590,7 @@ class user_kid extends user_parent {
if(pr_training_tr_id is not null, 'training', null) as object_type if(pr_training_tr_id is not null, 'training', null) as object_type
FROM FROM
presence presence
JOIN training ON tr_id = pr_training_tr_id JOIN training ON (tr_id = pr_training_tr_id AND tr_locked = 1)
WHERE WHERE
pr_user_kid_uk_id = ".$userId." pr_user_kid_uk_id = ".$userId."
AND tr_deleted = 0) UNION (SELECT AND tr_deleted = 0) UNION (SELECT

View File

@@ -15,6 +15,18 @@ if ($this->is_id()) {
) )
); );
log::register(($locked?'training_open':'training_close'), $this->get_id()); log::register(($locked?'training_open':'training_close'), $this->get_id());
if (true) {
//ha most zárjuk le
$kid_ids = $sql->assoc_array('SELECT pr_user_kid_uk_id FROM presence WHERE pr_training_tr_id = ' . $this->get_id());
foreach ($kid_ids as $k_array) {
$kid = new user_kid();
$kid->set_user_data_by_id($k_array['pr_user_kid_uk_id']);
$kid->update_balance();
}
}
//SEND NOTIFICATION //SEND NOTIFICATION
/* /*

View File

@@ -1,13 +1,16 @@
<?php <?php
# HA NINCS ID, AKKOR EDZÉSTÍPUSLISTA # HA NINCS ID, AKKOR EDZÉSTÍPUSLISTA
if ($this->is_id()) { if ($this->is_id()) {
# EDZÉS TÍPUS SZERKESZTÉSE # EDZÉS TÍPUS SZERKESZTÉSE
$trt = new training_type();
$trt->set_trt_data_by_id($this->get_id());
$smarty->assign('trt', $trt);
$smarty->display('training_type_edit.tpl');
} }
else { else {
@@ -17,14 +20,16 @@ else {
$tr_type_query = "SELECT * FROM training_type WHERE trt_deleted = 0 ORDER BY trt_name ASC"; $tr_type_query = "SELECT * FROM training_type WHERE trt_deleted = 0 ORDER BY trt_name ASC";
$tr_type_assoc_array = $sql->assoc_array($tr_type_query); $tr_type_assoc_array = $sql->assoc_array($tr_type_query);
$smarty->assign('tr_type_assoc_array',$tr_type_assoc_array); $trt_array = array();
$smarty->display('training_type_list.tpl'); foreach ($tr_type_assoc_array as $trt_data) {
$new_trt = new training_type();
$new_trt->set_trt_data_by_id($trt_data['trt_id']);
$trt_array[] = $new_trt;
} }
$smarty->assign('tr_type_assoc_array',$tr_type_assoc_array);
$smarty->assign('trt_array',$trt_array);
$smarty->display('training_type_list.tpl');
}
?> ?>

View File

@@ -33,7 +33,6 @@ if ($this->is_id()) {
$trc_coaches[] = $new_coach; $trc_coaches[] = $new_coach;
} }
$smarty->assign("coach_data_assoc_array", $coach_data_assoc_array); $smarty->assign("coach_data_assoc_array", $coach_data_assoc_array);
$smarty->assign("coach_array", $coach_array); //összes coach $smarty->assign("coach_array", $coach_array); //összes coach
$smarty->assign("trc_coaches", $trc_coaches); //csak a bejelölt coach coach $smarty->assign("trc_coaches", $trc_coaches); //csak a bejelölt coach coach
@@ -60,11 +59,5 @@ else {
$smarty->assign("training_array", $training_array); $smarty->assign("training_array", $training_array);
$smarty->display("training_list.tpl"); $smarty->display("training_list.tpl");
} }
?> ?>

View File

@@ -96,15 +96,15 @@ $smarty->assign('today', date('Y-m-d'));
$smarty->assign('error_msg', $error_msg); $smarty->assign('error_msg', $error_msg);
//SQL KAPCSOLAT BEÁLLÍTÁSA //SQL KAPCSOLAT BEÁLLÍTÁSA
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu') $sql = new sql('bcd_mysql','root','','badminton_coach'); if ($_SERVER['HTTP_HOST'] == 'cegledcoach.hu') $sql = new sql('bcd_mysql','root','','badminton_coach');
else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos'); else $sql = new sql('localhost','id9073794_tollashodos','uprRscU8bGpJ','id9073794_tollashodos');
$dev = $_SERVER['HTTP_HOST'] == 'badmintoncoach-demo.hu'; $dev = $_SERVER['HTTP_HOST'] == 'cegledcoach.hu';
$config = array(); $config = array();
if ($dev) { if ($dev) {
$config['domain'] = 'badmintoncoach-demo.hu'; $config['domain'] = 'cegledcoach.hu';
} }
else { else {
$config['domain'] = '000webhostapp.com'; $config['domain'] = '000webhostapp.com';

View File

@@ -169,11 +169,12 @@ if (isset($_POST['action'])) {
case 'training_type_update': case 'training_type_update':
# edzés típus lista updatelése ABí-ba # edzés típus lista updatelése ABí-ba
unset($_POST['action']); unset($_POST['action']);
foreach ($_POST as $key => $value) { // foreach ($_POST as $key => $value) {
$key_parts = explode('_', $key); // $key_parts = explode('_', $key);
$trt_id = $key_parts[1]; // $trt_id = $key_parts[1];
$sql->update_table('training_type', array('trt_name' => $value), array('trt_id' => $trt_id)); // $sql->update_table('training_type', array('trt_name' => $value), array('trt_id' => $trt_id));
} // }
training_type::update_training_type($_POST);
log::register('update_training_type', 'update all'); log::register('update_training_type', 'update all');
header("Location: " . $actual_link); header("Location: " . $actual_link);
break; break;

View File

@@ -0,0 +1,5 @@
ALTER TABLE `badminton_coach`.`training_type`
ADD COLUMN `trt_default_price` INT NULL DEFAULT NULL AFTER `trt_deleted`;
ALTER TABLE `badminton_coach`.`training`
ADD COLUMN `tr_price` INT NULL DEFAULT NULL AFTER `tr_deleted`;

View File

@@ -44,6 +44,10 @@
<div><input type="text" name="tr_duration" id="tr_duration" required></div> <div><input type="text" name="tr_duration" id="tr_duration" required></div>
</div> </div>
<div>
<label class="desc" for="tr_price">Ár:</label>
<div><input type="text" name="tr_price" id="tr_price" required></div>
</div>
<div> <div>
<label class="desc" id="title1" for="every_week">Minden héten ebben az időpontban: (az adott hónapban)</label> <label class="desc" id="title1" for="every_week">Minden héten ebben az időpontban: (az adott hónapban)</label>
@@ -96,7 +100,6 @@
$('#training_templates').on('change', function(e) { $('#training_templates').on('change', function(e) {
let selectedTemplate = $('#training_templates option:selected').val(); let selectedTemplate = $('#training_templates option:selected').val();
console.log(selectedTemplate);
$.ajax({ $.ajax({
url: '/_ajax/get_training_template.php', url: '/_ajax/get_training_template.php',
//method: 'GET', //method: 'GET',
@@ -110,6 +113,7 @@
$('#tr_date').val(''); $('#tr_date').val('');
$('#tr_training_type_trt_id').val('null'); $('#tr_training_type_trt_id').val('null');
$('#tr_training_type_trt_id').trigger('change');
$('#tr_duration').val(''); $('#tr_duration').val('');
return; return;
@@ -128,10 +132,36 @@
if (null != pdata['tt_time']) $('#tr_date').val(output + ' ' + pdata['tt_time']); if (null != pdata['tt_time']) $('#tr_date').val(output + ' ' + pdata['tt_time']);
if (null != pdata['tt_training_type']) $('#tr_training_type_trt_id').val(pdata['tt_training_type']); if (null != pdata['tt_training_type']) {
$('#tr_training_type_trt_id').val(pdata['tt_training_type']);
$('#tr_training_type_trt_id').trigger('change');
}
if (null != pdata['tt_duration']) $('#tr_duration').val(pdata['tt_duration']); if (null != pdata['tt_duration']) $('#tr_duration').val(pdata['tt_duration']);
} }
}); });
}); });
$('#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> </script>

View File

@@ -6,13 +6,15 @@
<label class="desc" id="title1" for="trt_name">Új edzés típus neve:</label> <label class="desc" id="title1" for="trt_name">Új edzés típus neve:</label>
<div><input type="text" name="trt_name" id="trt_name" required></div> <div><input type="text" name="trt_name" id="trt_name" required></div>
</div> </div>
<div>
<label class="desc" id="title1" for="trt_default_price">Alapértelmezett edzésdíj:</label>
<div><input type="text" name="trt_default_price" id="trt_default_price"></div>
</div>
<div> <div>
<div> <div>
<input class="button black" type="submit" value="Létrehozás"> <input class="button black" type="submit" value="Létrehozás">
</div> </div>
</div> </div>
</form> </form>
</div> </div>

View File

@@ -0,0 +1,23 @@
<div class="form_wrapper">
<form method="post">
<input type="hidden" name="action" value="training_type_update">
<input type="hidden" name="trt_id" value="{$trt->get_trt_id()}">
<div class="buttons">
<a href="/admin/delete_training_type/{$trt->get_trt_id()}" class="addbutton delete-big">Törlés</a>
</div>
<div>
<label class="desc" id="title1" for="trt_name">Név:</label>
<div><input type="text" name="trt_name" id="trt_name" value="{$trt->get_trt_name()}" required></div>
</div>
<div>
<label class="desc" id="title1" for="trt_default_price">Alapértelmezett edzésdíj:</label>
<div><input type="text" name="trt_default_price" id="trt_default_price" value="{$trt->get_trt_default_price()}"></div>
</div>
<div>
<div>
<input class="button black" type="submit" value="Mentés">
</div>
</div>
</form>
</div>

View File

@@ -1,23 +1,15 @@
<div class="form_wrapper">
<form method="post">
<input type="hidden" name="action" value="training_type_update">
<div class="buttons"> <div class="buttons">
<a href="/admin/create/training_type" class="addbutton add-big">Új edzés típus hozzáadása</a> <a href="/admin/create/training_type" class="addbutton add-big">Új edzés típus hozzáadása</a>
</div> </div>
{foreach $tr_type_assoc_array as $tr_type} {foreach $trt_array as $tr_type}
<div> <div class="list">
<div style="float: left;"> <a href="/admin/training_types/{$tr_type->get_trt_id()}">
<input type="text" name="trt_{$tr_type.trt_id}" id="trt_{$tr_type.trt_id}" value="{$tr_type.trt_name}"> <div class="list_item">
<a href="/admin/delete_training_type/{$tr_type.trt_id}" class="addbutton delete">Törlés</a> <img src="/_image/training.png">
{$tr_type->get_trt_name()}
</div> </div>
</a>
</div> </div>
{/foreach} {/foreach}
<div>
<div style="float: left;">
<input class="button black" type="submit" value="Mentés">
</div>
</div>
</form>
</div>