add new properties to camp

This commit is contained in:
2021-04-15 19:11:33 +02:00
parent fed9986180
commit a304871aa3
6 changed files with 451 additions and 354 deletions

View File

@@ -1,11 +1,15 @@
<?php
/**
* tábor osztály
*/
* tábor osztály.
*/
class camp
{
private $camp_id;
private $camp_name;
private $camp_count;
private $camp_price;
private $camp_info;
private $camp_city;
private $camp_from;
private $camp_to;
@@ -13,14 +17,9 @@ class camp
private $camp_helpers;
private $camp_camp_type_ct_id; //ID
private $camp_type; //OBJ
private $camp_shuttle = array(); //array
private $camp_sleep;
private $camp_deleted;
private $camp_is_open;
/**
* Gets the value of camp_id.
*
@@ -38,13 +37,109 @@ class camp
*
* @return self
*/
private function set_camp_id($camp_id)
public function set_camp_id($camp_id)
{
$this->camp_id = $camp_id;
return $this;
}
/**
* Gets the value of camp_name.
*
* @return mixed
*/
public function get_camp_name()
{
return $this->camp_name;
}
/**
* Sets the value of camp_name.
*
* @param mixed $camp_name the camp name
*
* @return self
*/
public function set_camp_name($camp_name)
{
$this->camp_name = $camp_name;
return $this;
}
/**
* Gets the value of camp_count.
*
* @return mixed
*/
public function get_camp_count()
{
return $this->camp_count;
}
/**
* Sets the value of camp_count.
*
* @param mixed $camp_count the camp count
*
* @return self
*/
public function set_camp_count($camp_count)
{
$this->camp_count = $camp_count;
return $this;
}
/**
* Gets the value of camp_price.
*
* @return mixed
*/
public function get_camp_price()
{
return $this->camp_price;
}
/**
* Sets the value of camp_price.
*
* @param mixed $camp_price the camp price
*
* @return self
*/
public function set_camp_price($camp_price)
{
$this->camp_price = $camp_price;
return $this;
}
/**
* Gets the value of camp_info.
*
* @return mixed
*/
public function get_camp_info()
{
return $this->camp_info;
}
/**
* Sets the value of camp_info.
*
* @param mixed $camp_info the camp info
*
* @return self
*/
public function set_camp_info($camp_info)
{
$this->camp_info = $camp_info;
return $this;
}
/**
* Gets the value of camp_city.
*
@@ -62,7 +157,7 @@ class camp
*
* @return self
*/
private function set_camp_city($camp_city)
public function set_camp_city($camp_city)
{
$this->camp_city = $camp_city;
@@ -79,18 +174,25 @@ class camp
return $this->camp_from;
}
public function get_camp_from_day() {
$day = date("d", strtotime($this->camp_from));
if (substr($day, 0, 1) == '0') return substr($day, 1, 1);
return date("d", strtotime($this->camp_from));
public function get_camp_from_day()
{
$day = date('d', strtotime($this->camp_from));
if ('0' == substr($day, 0, 1)) {
return substr($day, 1, 1);
}
return date('d', strtotime($this->camp_from));
}
public function get_camp_to_day() {
$day = date("d", strtotime($this->camp_to));
if (substr($day, 0, 1) == '0') return substr($day, 1, 1);
return date("d", strtotime($this->camp_to));
}
public function get_camp_to_day()
{
$day = date('d', strtotime($this->camp_to));
if ('0' == substr($day, 0, 1)) {
return substr($day, 1, 1);
}
return date('d', strtotime($this->camp_to));
}
/**
* Sets the value of camp_from.
@@ -99,7 +201,7 @@ class camp
*
* @return self
*/
private function set_camp_from($camp_from)
public function set_camp_from($camp_from)
{
$this->camp_from = $camp_from;
@@ -123,7 +225,7 @@ class camp
*
* @return self
*/
private function set_camp_to($camp_to)
public function set_camp_to($camp_to)
{
$this->camp_to = $camp_to;
@@ -147,7 +249,7 @@ class camp
*
* @return self
*/
private function set_camp_camp_type_ct_id($camp_camp_type_ct_id)
public function set_camp_camp_type_ct_id($camp_camp_type_ct_id)
{
$this->camp_camp_type_ct_id = $camp_camp_type_ct_id;
@@ -171,85 +273,98 @@ class camp
*
* @return self
*/
private function set_camp_type($camp_type)
public function set_camp_type($camp_type)
{
$this->camp_type = $camp_type;
return $this;
}
public function get_camp_deleted() {
public function get_camp_deleted()
{
return $this->camp_deleted;
}
private function set_camp_deleted($_item) {
public function set_camp_deleted($_item)
{
$this->camp_deleted = $_item;
return $this;
}
public function get_camp_is_open() {
public function get_camp_is_open()
{
return $this->camp_is_open;
}
private function set_camp_is_open($_item) {
public function set_camp_is_open($_item)
{
$this->camp_is_open = $_item;
return $this;
}
public function get_camp_leader() {
public function get_camp_leader()
{
return $this->camp_leader;
}
private function set_camp_leader($_item) {
public function set_camp_leader($_item)
{
$this->camp_leader = $_item;
return $this;
}
public function get_camp_helpers() {
public function get_camp_helpers()
{
return $this->camp_helpers;
}
private function set_camp_helpers($_item) {
public function set_camp_helpers($_item)
{
$this->camp_helpers = $_item;
return $this;
}
public function has_pending_apply() {
public function has_pending_apply()
{
global $sql;
return $sql->num_of_rows("select * from camp join camp_apply on capp_camp_id = camp_id where capp_status = 2 AND camp_id = " . $this->get_camp_id());
return $sql->num_of_rows('select * from camp join camp_apply on capp_camp_id = camp_id where capp_status = 2 AND camp_id = '.$this->get_camp_id());
}
public function has_deleted_apply() {
public function has_deleted_apply()
{
global $sql;
return $sql->num_of_rows("select * from camp join camp_apply on capp_camp_id = camp_id where capp_status = 5 AND camp_id = " . $this->get_camp_id());
return $sql->num_of_rows('select * from camp join camp_apply on capp_camp_id = camp_id where capp_status = 5 AND camp_id = '.$this->get_camp_id());
}
public function get_camp_applies() {
public function get_camp_applies()
{
//visszaadja az elfogadott jelentkezéseket ABC sorrendben
global $sql;
$apply_assoc_array = $sql->assoc_array("SELECT * FROM camp_apply JOIN camp_kid ON ck_id = capp_camp_kid_ck_id WHERE capp_status = 3 AND capp_camp_id = " . $this->get_camp_id() . " ORDER BY ck_name ASC;");
$apply_array = array();
$apply_assoc_array = $sql->assoc_array('SELECT * FROM camp_apply JOIN camp_kid ON ck_id = capp_camp_kid_ck_id WHERE capp_status = 3 AND capp_camp_id = '.$this->get_camp_id().' ORDER BY ck_name ASC;');
$apply_array = [];
foreach ($apply_assoc_array as $apply) {
$new_apply = new camp_apply();
$new_apply->set_capp_data_by_id($apply['capp_id']);
$apply_array[] = $new_apply;
}
return $apply_array;
}
public function set_camp_data_by_id($_camp_id) {
public function set_camp_data_by_id($_camp_id)
{
global $sql;
$camp_data_assoc_array = $sql->assoc_array("select * from camp where camp_id = " . $_camp_id);
$camp_data_assoc_array = $sql->assoc_array('select * from camp where camp_id = '.$_camp_id);
$camp_data_array = $camp_data_assoc_array[0];
//alapadatok
foreach ($camp_data_array as $field => $value) {
$function_name = "set_" . $field;
$function_name = 'set_'.$field;
$this->$function_name($value);
if ('camp_camp_type_ct_id' == $field) {
$new_ct = new camp_type();
@@ -257,80 +372,79 @@ class camp
$this->set_camp_type($new_ct);
}
}
//labdatípusok hozzáadása tömbbe
$shuttle_assoc_array = $sql->assoc_array("SELECT cs_shuttle_id FROM camp_shuttle WHERE cs_camp_id = " . $_camp_id . ";");
if (!empty($shuttle_assoc_array)) {
foreach ($shuttle_assoc_array as $shuttle_array) {
$this->camp_shuttle[] = $shuttle_array['cs_shuttle_id'];
}
}
}
public static function create_camp($_city, $_from, $_to, $_leader, $_helpers, $_is_open, $_ct_id, $_shuttles, $_accoms) {
public static function create_camp($_city, $_from, $_to, $_leader, $_helpers, $_is_open, $_ct_id, $_name, $_count, $_price, $_info)
{
global $sql;
$new_camp_id = $sql->insert_into('camp',array(
if ("" === $_name) {
$_name = 'null';
}
if ("" === $_count) {
$_count = 'null';
}
if ("" === $_price) {
$_price = 'null';
}
if ("" === $_info) {
$_info = 'null';
}
$new_camp_id = $sql->insert_into('camp', [
'camp_name' => $_name,
'camp_count' => $_count,
'camp_price' => $_price,
'camp_info' => $_info,
'camp_city' => $_city,
'camp_from' => $_from,
'camp_to' => $_to,
'camp_leader' => $_leader,
'camp_helpers' => $_helpers,
'camp_is_open' => $_is_open,
'camp_camp_type_ct_id' => $_ct_id
));
if (!empty($_shuttles)) {
foreach ($_shuttles as $_shuttle_id) {
$sql->insert_into('camp_shuttle', array('cs_camp_id' => $new_camp_id, 'cs_shuttle_id' => $_shuttle_id));
}
}
if (!empty($_accoms)) {
foreach ($_accoms as $_accom_id) {
$sql->insert_into('camp_accomodation', array('ca_camp_id' => $new_camp_id, 'ca_accomodation_id' => $_accom_id));
}
}
'camp_camp_type_ct_id' => $_ct_id,
]);
}
public static function update_camp($_city, $_from, $_to, $_leader, $_helpers, $_is_open, $_ct_id, $_shuttles, $_accoms, $_camp_id) {
public static function update_camp($_city, $_from, $_to, $_leader, $_helpers, $_is_open, $_ct_id, $_name, $_count, $_price, $_info, $_camp_id)
{
global $sql;
$new_camp_id = $sql->update_table('camp',array(
if ("" === $_name) {
$_name = 'null';
}
if ("" === $_count) {
$_count = 'null';
}
if ("" === $_price) {
$_price = 'null';
}
if ("" === $_info) {
$_info = 'null';
}
$new_camp_id = $sql->update_table('camp', [
'camp_name' => $_name,
'camp_count' => $_count,
'camp_price' => $_price,
'camp_info' => $_info,
'camp_city' => $_city,
'camp_from' => $_from,
'camp_to' => $_to,
'camp_leader' => $_leader,
'camp_helpers' => $_helpers,
'camp_is_open' => $_is_open,
'camp_camp_type_ct_id' => $_ct_id
),
array(
'camp_id' => $_camp_id
)
'camp_camp_type_ct_id' => $_ct_id,
],
[
'camp_id' => $_camp_id,
]
);
//kitöröljük a korábbi shuttle és accom sorokat
$sql->execute_query('DELETE FROM camp_shuttle WHERE cs_camp_id = ' . $_camp_id);
$sql->execute_query('DELETE FROM camp_accomodation WHERE ca_camp_id = ' . $_camp_id);
if (!empty($_shuttles)) {
foreach ($_shuttles as $_shuttle_id) {
$sql->insert_into('camp_shuttle', array('cs_camp_id' => $_camp_id, 'cs_shuttle_id' => $_shuttle_id));
}
}
if (!empty($_accoms)) {
foreach ($_accoms as $_accom_id) {
$sql->insert_into('camp_accomodation', array('ca_camp_id' => $_camp_id, 'ca_accomodation_id' => $_accom_id));
}
}
}
}
?>