337 lines
8.3 KiB
PHP
337 lines
8.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* tábor osztály
|
|
*/
|
|
class camp
|
|
{
|
|
private $camp_id;
|
|
private $camp_city;
|
|
private $camp_from;
|
|
private $camp_to;
|
|
private $camp_leader;
|
|
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.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_camp_id()
|
|
{
|
|
return $this->camp_id;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of camp_id.
|
|
*
|
|
* @param mixed $camp_id the camp id
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_camp_id($camp_id)
|
|
{
|
|
$this->camp_id = $camp_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets the value of camp_city.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_camp_city()
|
|
{
|
|
return $this->camp_city;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of camp_city.
|
|
*
|
|
* @param mixed $camp_city the camp city
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_camp_city($camp_city)
|
|
{
|
|
$this->camp_city = $camp_city;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets the value of camp_from.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_camp_from()
|
|
{
|
|
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_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));
|
|
}
|
|
|
|
|
|
/**
|
|
* Sets the value of camp_from.
|
|
*
|
|
* @param mixed $camp_from the camp from
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_camp_from($camp_from)
|
|
{
|
|
$this->camp_from = $camp_from;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets the value of camp_to.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_camp_to()
|
|
{
|
|
return $this->camp_to;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of camp_to.
|
|
*
|
|
* @param mixed $camp_to the camp to
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_camp_to($camp_to)
|
|
{
|
|
$this->camp_to = $camp_to;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets the value of camp_camp_type_ct_id.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_camp_camp_type_ct_id()
|
|
{
|
|
return $this->camp_camp_type_ct_id;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of camp_camp_type_ct_id.
|
|
*
|
|
* @param mixed $camp_camp_type_ct_id the camp camp type ct id
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_camp_camp_type_ct_id($camp_camp_type_ct_id)
|
|
{
|
|
$this->camp_camp_type_ct_id = $camp_camp_type_ct_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Gets the value of camp_type.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_camp_type()
|
|
{
|
|
return $this->camp_type;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of camp_type.
|
|
*
|
|
* @param mixed $camp_type the camp type
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_camp_type($camp_type)
|
|
{
|
|
$this->camp_type = $camp_type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
|
|
public function get_camp_deleted() {
|
|
return $this->camp_deleted;
|
|
}
|
|
|
|
private function set_camp_deleted($_item) {
|
|
$this->camp_deleted = $_item;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function get_camp_is_open() {
|
|
return $this->camp_is_open;
|
|
}
|
|
|
|
private function set_camp_is_open($_item) {
|
|
$this->camp_is_open = $_item;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function get_camp_leader() {
|
|
return $this->camp_leader;
|
|
}
|
|
|
|
private function set_camp_leader($_item) {
|
|
$this->camp_leader = $_item;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function get_camp_helpers() {
|
|
return $this->camp_helpers;
|
|
}
|
|
|
|
private function set_camp_helpers($_item) {
|
|
$this->camp_helpers = $_item;
|
|
|
|
return $this;
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
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();
|
|
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) {
|
|
global $sql;
|
|
$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;
|
|
$this->$function_name($value);
|
|
if ('camp_camp_type_ct_id' == $field) {
|
|
$new_ct = new camp_type();
|
|
$new_ct->set_ct_data_by_id($value);
|
|
$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) {
|
|
global $sql;
|
|
|
|
$new_camp_id = $sql->insert_into('camp',array(
|
|
'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));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public static function update_camp($_city, $_from, $_to, $_leader, $_helpers, $_is_open, $_ct_id, $_shuttles, $_accoms, $_camp_id) {
|
|
global $sql;
|
|
|
|
$new_camp_id = $sql->update_table('camp',array(
|
|
'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
|
|
)
|
|
);
|
|
|
|
//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));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
?>
|