diff --git a/_class/class_camp_apply.php b/_class/class_camp_apply.php index 9d51091..0d95a43 100644 --- a/_class/class_camp_apply.php +++ b/_class/class_camp_apply.php @@ -1,18 +1,14 @@ capp_accomodation_type; - } - - /** - * Sets the value of capp_accomodation_type. - * - * @param mixed $capp_accomodation_type the capp accomodation type - * - * @return self - */ - private function set_capp_accomodation_type($capp_accomodation_type) - { - $this->capp_accomodation_type = $capp_accomodation_type; - - return $this; - } - - /** - * get_s the value of capp_shuttle_type. - * - * @return mixed - */ - public function get_capp_shuttle_type() - { - return $this->capp_shuttle_type; - } - - /** - * Sets the value of capp_shuttle_type. - * - * @param mixed $capp_shuttle_type the capp shuttle type - * - * @return self - */ - private function set_capp_shuttle_type($capp_shuttle_type) - { - $this->capp_shuttle_type = $capp_shuttle_type; - - return $this; - } - /** * get_s the value of capp_date. * @@ -206,44 +154,41 @@ class camp_apply { } //STATIC! - public static function has_responsible_contact($_capp_id) { + public static function has_responsible_contact($_capp_id) + { global $sql; - return $sql->num_of_rows('SELECT * FROM camp_apply_contact WHERE cac_camp_apply_capp_id = ' . $_capp_id . ' AND cac_is_responsible = 1;'); + + return $sql->num_of_rows('SELECT * FROM camp_apply_contact WHERE cac_camp_apply_capp_id = '.$_capp_id.' AND cac_is_responsible = 1;'); } - public static function apply_response($_apply_id, $_status_id) { + public static function apply_response($_apply_id, $_status_id) + { global $sql; - $sql->update_table('camp_apply', array('capp_status' => $_status_id, 'capp_accept_date' => date("Y-m-d H:i:s")), array('capp_id' => $_apply_id)); + $sql->update_table('camp_apply', ['capp_status' => $_status_id, 'capp_accept_date' => date('Y-m-d H:i:s')], ['capp_id' => $_apply_id]); } - public static function has_contact($_capp_id) { + public static function has_contact($_capp_id) + { global $sql; - return $sql->num_of_rows('SELECT * FROM camp_apply_contact WHERE cac_camp_apply_capp_id = ' . $_capp_id . ';'); + + return $sql->num_of_rows('SELECT * FROM camp_apply_contact WHERE cac_camp_apply_capp_id = '.$_capp_id.';'); } - public function set_capp_data_by_id($_id) { + public function set_capp_data_by_id($_id) + { global $sql; - $capp_data_assoc_array = $sql->assoc_array("select * from camp_apply where capp_id = " . $_id); + $capp_data_assoc_array = $sql->assoc_array('select * from camp_apply where capp_id = '.$_id); $capp_array = $capp_data_assoc_array[0]; foreach ($capp_array as $field => $value) { - $function_name = "set_" . $field; + $function_name = 'set_'.$field; $this->$function_name($value); - if ($field == 'capp_camp_kid_ck_id') { + if ('capp_camp_kid_ck_id' == $field) { $new_kid = new camp_kid(); $new_kid->set_ck_data_by_id($value); $this->$function_name($new_kid); } - if ($field == 'capp_accomodation_type' && $value !== null) { - $new_cat = new camp_accomodation_type(); - $new_cat->set_cat_data_by_id($value); - $this->$function_name($new_cat); - } - if ($field == 'capp_shuttle_type' && $value !== null) { - $new_cst = new camp_shuttle_type(); - $new_cst->set_cst_data_by_id($value); - $this->$function_name($new_cst); - } - if ($field == 'capp_camp_id') { + + if ('capp_camp_id' == $field) { $new_camp = new camp(); $new_camp->set_camp_data_by_id($value); $this->$function_name($new_camp); @@ -251,57 +196,55 @@ class camp_apply { } } - public function get_responsible_contact() { + public function get_responsible_contact() + { global $sql; - $cc_id = $sql->single_variable("SELECT cac_camp_contact_cc_id FROM camp_apply_contact WHERE cac_camp_apply_capp_id = " . $this->get_capp_id() . " AND cac_is_responsible = 1;"); + $cc_id = $sql->single_variable('SELECT cac_camp_contact_cc_id FROM camp_apply_contact WHERE cac_camp_apply_capp_id = '.$this->get_capp_id().' AND cac_is_responsible = 1;'); $cc = new camp_contact(); $cc->set_cc_data_by_id($cc_id); + return $cc; } //egy létező jelentkezésnél felelős kapcsolattartóra állít valakit - public static function make_contact_responsible($_apply_id, $_cc_id, $_is_responsible = false) { + public static function make_contact_responsible($_apply_id, $_cc_id, $_is_responsible = false) + { global $sql; //TODO: itt majd cac objektumot adjunk át, és akkor nem így kell updatelni hanem primary key alapján $sql->update_table('camp_apply_contact', - array( - 'cac_is_responsible' => $_is_responsible - ), - array( + [ + 'cac_is_responsible' => $_is_responsible, + ], + [ 'cac_camp_apply_capp_id' => $_apply_id, - 'cac_camp_contact_cc_id' => $_cc_id - ) + 'cac_camp_contact_cc_id' => $_cc_id, + ] ); } - public static function create_camp_apply($_camp_kid, $_status = 1, $_camp_accom = 'null', $_camp_shuttle = 'null', $_camp_date = 'null', $_camp_accept_date = 'null', $_camp = 'null') { + public static function create_camp_apply($_camp_kid, $_status = 1, $_camp_date = 'null', $_camp_accept_date = 'null', $_camp = 'null') + { global $sql; - return $sql->insert_into('camp_apply', array( + + return $sql->insert_into('camp_apply', [ 'capp_camp_kid_ck_id' => $_camp_kid, - 'capp_accomodation_type' => $_camp_accom, - 'capp_shuttle_type' => $_camp_shuttle, 'capp_date' => $_camp_date, 'capp_accept_date' => $_camp_accept_date, 'capp_status' => $_status, 'capp_camp_id' => $_camp, - ) + ] ); } //ezzel nem lehet kid-et updatelni, arra külön function kell - public static function update_camp_apply($_apply_id, $_status = 1, $_camp_accom = 'null', $_camp_shuttle = 'null', $_camp_date = 'null', $_camp_accept_date = 'null', $_camp = 'null') { + public static function update_camp_apply($_apply_id, $_status = 1, $_camp_date = 'null', $_camp_accept_date = 'null', $_camp = 'null') + { global $sql; - $sql->update_table('camp_apply', array( - 'capp_accomodation_type' => $_camp_accom, - 'capp_shuttle_type' => $_camp_shuttle, + $sql->update_table('camp_apply', [ 'capp_date' => $_camp_date, 'capp_accept_date' => $_camp_accept_date, 'capp_status' => $_status, 'capp_camp_id' => $_camp, - ), array('capp_id' => $_apply_id)); + ], ['capp_id' => $_apply_id]); } } - - - -?> diff --git a/event_handler.php b/event_handler.php index ffe886a..0848f13 100644 --- a/event_handler.php +++ b/event_handler.php @@ -517,7 +517,7 @@ if (isset($_POST['action'])) { 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']); + camp_apply::update_camp_apply($_POST['camp_apply_id'], 2, date('Y-m-d H:i:s'), 'null', $_POST['camp_id']); header('Location: /tabor/jelentkezes/5'); break; case 'user_camp_leader_create': diff --git a/queries/202104_camp_updates.sql b/queries/202104_camp_updates.sql index 4a65753..88d0d13 100644 --- a/queries/202104_camp_updates.sql +++ b/queries/202104_camp_updates.sql @@ -1,7 +1,16 @@ -ALTER TABLE badminton_coach.camp_kid DROP FOREIGN KEY fk_camp_kid_1`;` +ALTER TABLE `camp_kid` DROP FOREIGN KEY fk_camp_kid_1`;` ALTER TABLE `camp_kid` DROP INDEX `fk_camp_kid_1_idx`; ALTER TABLE `camp_kid` DROP `ck_shirt_size_id`; DELETE FROM `subpage` WHERE `subpage`.`spage_id` = 29; ALTER TABLE `camp` ADD `camp_name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL AFTER `camp_id`, ADD `camp_count` INT NULL DEFAULT NULL AFTER `camp_name`, ADD `camp_price` INT NULL DEFAULT NULL AFTER `camp_count`, ADD `camp_info` TEXT CHARACTER SET utf8 COLLATE utf8_hungarian_ci NULL DEFAULT NULL AFTER `camp_price`; + +ALTER TABLE `camp_kid` DROP FOREIGN KEY fk_camp_apply_2; +ALTER TABLE `camp_kid` DROP FOREIGN KEY fk_camp_apply_3; +ALTER TABLE `camp_apply` DROP INDEX `fk_camp_apply_2_idx`; +ALTER TABLE `camp_apply` DROP INDEX `fk_camp_apply_3_idx`; + +ALTER TABLE `camp_apply` + DROP `capp_accomodation_type`, + DROP `capp_shuttle_type`;