diff --git a/_ajax/get_lease_sum.php b/_ajax/get_lease_sum.php new file mode 100644 index 0000000..1e34503 --- /dev/null +++ b/_ajax/get_lease_sum.php @@ -0,0 +1,19 @@ +single_variable($l_query); + + echo json_encode($l_sum); +} + +?> diff --git a/_class/class_money_deposit.php b/_class/class_money_deposit.php index 4c5a94b..7861a40 100644 --- a/_class/class_money_deposit.php +++ b/_class/class_money_deposit.php @@ -12,6 +12,7 @@ class money_deposit { private $mod_money_income; //OBJECT private $mod_deleted; private $mod_sets_expire_date; + private $mod_lease_l_id; //OBJECT public function set_mod_id($_id) { $this->mod_id = $_id; @@ -41,6 +42,10 @@ class money_deposit { $this->mod_sets_expire_date = $_sets_expire_date; } + public function set_mod_lease_l_id($_lease_l_id) { + $this->mod_lease_l_id = $_lease_l_id; + } + public function get_mod_id() { return $this->mod_id; } @@ -69,6 +74,10 @@ class money_deposit { return $this->mod_sets_expire_date; } + public function get_mod_lease_l_id() { + return $this->mod_lease_l_id; + } + public function set_mod_data_by_id($_id) { global $sql; $mod_query = "SELECT * FROM money_deposit WHERE mod_id = " . $_id . ";"; @@ -87,10 +96,15 @@ class money_deposit { $new_mi->set_mi_data_by_id($value); $this->set_mod_money_income($new_mi); } + if ($field == "mod_lease_l_id" && $value !== null) { + $new_l = new lease(); + $new_l->set_l_data_by_id($value); + $this->set_mod_lease_l_id($new_l); + } } } - public static function create_money_deposit($_user_id, $_date, $_sum, $_pt, $_sets_date = false) { + public static function create_money_deposit($_user_id, $_date, $_sum, $_lease, $_pt = 1, $_sets_date = false) { global $sql; $income_id = $sql->insert_into('money_income', array( @@ -113,11 +127,12 @@ class money_deposit { return $sql->insert_into('money_deposit', array( 'mod_user_kid_uk_id' => $_user_id, 'mod_money_income_mi_id' => $income_id, - 'mod_sets_expire_date' => $_sets_date + 'mod_sets_expire_date' => $_sets_date, + 'mod_lease_l_id' => $_lease, )); } - public static function update_money_deposit($_user_id, $_date, $_sum, $_mod_id, $_pt, $_mi_id) { + public static function update_money_deposit($_user_id, $_date, $_sum, $_lease, $_mod_id, $_pt, $_mi_id) { global $sql; $sql->update_table('money_income', array( //'mod_user_kid_uk_id' => $_user_id, @@ -130,6 +145,7 @@ class money_deposit { $sql->update_table('money_deposit', array( 'mod_user_kid_uk_id' => $_user_id, + 'mod_lease_l_id' => $_lease, ), array( 'mod_id' => $_mod_id )); diff --git a/_include/include_create.php b/_include/include_create.php index 6187e0b..c416fa1 100644 --- a/_include/include_create.php +++ b/_include/include_create.php @@ -132,6 +132,17 @@ switch ($this->get_id()) { $pt_assoc_array = $sql->assoc_array('SELECT * FROM payment_type ORDER BY pt_id ASC;'); + //bérlettípusok + $l_assoc_array = $sql->assoc_array('SELECT * FROM lease WHERE l_deleted = 0 ORDER BY l_name ASC;'); + $l_array = array(); + + foreach ($l_assoc_array as $key => $lease) { + $new_lease = new lease(); + $new_lease->set_l_data_by_id($lease['l_id']); + $l_array[] = $new_lease; + } + + $smarty->assign('lease_array',$l_array); $smarty->assign('user_kids', $user_kids); $smarty->assign('pt_assoc_array', $pt_assoc_array); $smarty->display('money_deposit_create.tpl'); diff --git a/_include/include_money_deposit.php b/_include/include_money_deposit.php index ccc1c83..df38bb8 100644 --- a/_include/include_money_deposit.php +++ b/_include/include_money_deposit.php @@ -3,47 +3,52 @@ # HA NINCS ID, AKKOR BEFIZETÉS LISTA # HA VAN ID, AKKOR BEFIZETÉS ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA - - - - if ($this->is_id()) { - # ADOTT BEFIZETÉS ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA - $mod = new money_deposit(); - $mod->set_mod_data_by_id($this->get_id()); + # ADOTT BEFIZETÉS ADATINAK MEGTEKINTÉSE/MÓDOSÍTÁSA + $mod = new money_deposit(); + $mod->set_mod_data_by_id($this->get_id()); - $user_kid_query = "SELECT * FROM user_kid WHERE uk_is_active = 1 AND uk_deleted = 0 order by uk_name ASC;"; - $user_kid_assoc_array = $sql->assoc_array($user_kid_query); - $user_kids = array(); - foreach ($user_kid_assoc_array as $key => $value) { - $new_kid = new user_kid(); - $new_kid->set_user_data_by_id($value['uk_id']); - $user_kids[] = $new_kid; - } + $user_kid_query = "SELECT * FROM user_kid WHERE uk_is_active = 1 AND uk_deleted = 0 order by uk_name ASC;"; + $user_kid_assoc_array = $sql->assoc_array($user_kid_query); + $user_kids = array(); + foreach ($user_kid_assoc_array as $key => $value) { + $new_kid = new user_kid(); + $new_kid->set_user_data_by_id($value['uk_id']); + $user_kids[] = $new_kid; + } - $pt_assoc_array = $sql->assoc_array('SELECT * FROM payment_type ORDER BY pt_id ASC;'); + $pt_assoc_array = $sql->assoc_array('SELECT * FROM payment_type ORDER BY pt_id ASC;'); + $l_assoc_array = $sql->assoc_array('SELECT * FROM lease WHERE l_deleted = 0 ORDER BY l_name ASC;'); + $l_array = array(); - $smarty->assign('user_kids', $user_kids); - $smarty->assign("mod", $mod); - $smarty->assign('pt_assoc_array', $pt_assoc_array); - $smarty->display("money_deposit_update.tpl"); + foreach ($l_assoc_array as $key => $lease) { + $new_lease = new lease(); + $new_lease->set_l_data_by_id($lease['l_id']); + $l_array[] = $new_lease; + } + + $smarty->assign('lease_array',$l_array); + $smarty->assign('user_kids', $user_kids); + $smarty->assign("mod", $mod); + $smarty->assign('pt_assoc_array', $pt_assoc_array); + $smarty->display("money_deposit_update.tpl"); } else { - # BEFIZETÉS LISTA - $mod_query = "SELECT * FROM money_deposit JOIN money_income ON mod_money_income_mi_id = mi_id WHERE mod_deleted = 0 ORDER BY mi_date DESC, mi_id DESC;"; - $mod_array = array(); - $mod_assoc_array = $sql->assoc_array($mod_query); + # BEFIZETÉS LISTA + $mod_query = "SELECT * FROM money_deposit JOIN money_income ON mod_money_income_mi_id = mi_id WHERE mod_deleted = 0 ORDER BY mi_date DESC, mi_id DESC;"; + $mod_array = array(); + $mod_assoc_array = $sql->assoc_array($mod_query); - foreach ($mod_assoc_array as $mod) { - $new_mod = new money_deposit(); - $new_mod->set_mod_data_by_id($mod['mod_id']); - $mod_array[] = $new_mod; - } + foreach ($mod_assoc_array as $mod) { + $new_mod = new money_deposit(); + $new_mod->set_mod_data_by_id($mod['mod_id']); + $mod_array[] = $new_mod; + } - $smarty->assign("mod_array", $mod_array); - $smarty->display("money_deposit.tpl"); + $smarty->assign("mod_array", $mod_array); + $smarty->display("money_deposit.tpl"); } diff --git a/event_handler.php b/event_handler.php index 3f0da6a..3cd349d 100644 --- a/event_handler.php +++ b/event_handler.php @@ -290,7 +290,7 @@ if (isset($_POST['action'])) { # új befizetés létrehozása $sets_date = (isset($_POST['mod_sets_expire_date']) && $_POST['mod_sets_expire_date']) ? $_POST['mod_sets_expire_date'] : false; - $new_mod_id = money_deposit::create_money_deposit($_POST['mod_user_kid_uk_id'], $_POST['mod_date'], $_POST['mod_sum'], $_POST['mod_payment_type'], $sets_date); + $new_mod_id = money_deposit::create_money_deposit($_POST['mod_user_kid_uk_id'], $_POST['mod_date'], $_POST['mod_sum'], $_POST['mod_lease_l_id'], 1, $sets_date); $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'] . ')'); @@ -305,7 +305,7 @@ if (isset($_POST['action'])) { 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'], $_POST['mod_payment_type'], $_POST['mi_id']); + money_deposit::update_money_deposit($_POST['mod_user_kid_uk_id'], $_POST['mod_date'], $_POST['mod_sum'], $_POST['mod_lease_l_id'], $_POST['mod_id'], 1, $_POST['mi_id']); $tmp_user = new user_kid(); $tmp_user->set_user_data_by_id($_POST['mod_user_kid_uk_id']); $tmp_user->update_balance(); diff --git a/queries/lease_201908241.sql b/queries/lease_201908241.sql index 2c79271..0751c39 100644 --- a/queries/lease_201908241.sql +++ b/queries/lease_201908241.sql @@ -28,3 +28,13 @@ CREATE TABLE `lease_training_type` ( INSERT INTO `log_category` (`logc_id`, `logc_name`, `logc_title`, `logc_type`, `logc_table`, `logc_field`, `logc_selector`) VALUES (NULL, 'new_lease', 'Új bérlettípus', '1', 'lease', 'l_name', 'l_id'); INSERT INTO `log_category` (`logc_id`, `logc_name`, `logc_title`, `logc_type`, `logc_table`, `logc_field`, `logc_selector`) VALUES (NULL, 'update_lease', 'Bérlettípus módosítása', '1', 'lease', 'l_name', 'l_id'); INSERT INTO `log_category` (`logc_id`, `logc_name`, `logc_title`, `logc_type`, `logc_table`, `logc_field`, `logc_selector`) VALUES (NULL, 'delete_lease', 'Bérlettípus törlése', '1', 'lease', 'l_name', 'l_id'); + +ALTER TABLE `money_deposit` +ADD COLUMN `mod_lease_l_id` INT NULL DEFAULT NULL, +ADD INDEX `fk_money_deposit_2_idx` (`mod_lease_l_id` ASC); +ALTER TABLE `money_deposit` +ADD CONSTRAINT `fk_money_deposit_2` + FOREIGN KEY (`mod_lease_l_id`) + REFERENCES `lease` (`l_id`) + ON DELETE SET NULL + ON UPDATE CASCADE; diff --git a/template/templates/money_deposit_create.tpl b/template/templates/money_deposit_create.tpl index 854cfaf..3db955b 100644 --- a/template/templates/money_deposit_create.tpl +++ b/template/templates/money_deposit_create.tpl @@ -13,7 +13,7 @@ -
+ {*
-
+
*}
+
+ +
+ +
+
+
@@ -46,6 +60,27 @@
- + + diff --git a/template/templates/money_deposit_update.tpl b/template/templates/money_deposit_update.tpl index 18c74a1..8d2e24f 100644 --- a/template/templates/money_deposit_update.tpl +++ b/template/templates/money_deposit_update.tpl @@ -1,52 +1,88 @@
-
- - - - + + + + + -
- -
- -
-
+
+ +
+ +
+
-
- -
- -
-
+ {*
+ +
+ +
+
*} -
- -
-
+
+ +
+
-
- -
-
+
+ +
+ +
+
+
+ +
+
-
-
- -
-
+
+
+ +
+
-
+
+ + + diff --git a/template/templates/training_data_create.tpl b/template/templates/training_data_create.tpl index 5c1be28..74abc4a 100644 --- a/template/templates/training_data_create.tpl +++ b/template/templates/training_data_create.tpl @@ -152,7 +152,7 @@ }, success: function(data, status, jqXHR) { let pdata = JSON.parse(data); - console.log(pdata); + //console.log(pdata); if (null === pdata) { $('#tr_price').val(''); return;