348 lines
10 KiB
PHP
348 lines
10 KiB
PHP
<?php
|
|
|
|
class camp_apply
|
|
{
|
|
private $capp_id;
|
|
private $capp_camp_kid_ck_id;
|
|
private $capp_date = null;
|
|
private $capp_status = null;
|
|
private $capp_accept_date = null;
|
|
private $capp_camp_id = null;
|
|
private $capp_money;
|
|
|
|
/**
|
|
* get_s the value of capp_id.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_id()
|
|
{
|
|
return $this->capp_id;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_id.
|
|
*
|
|
* @param mixed $capp_id the capp id
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_capp_id($capp_id)
|
|
{
|
|
$this->capp_id = $capp_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* get_s the value of capp_camp_kid_ck_id.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_camp_kid_ck_id()
|
|
{
|
|
return $this->capp_camp_kid_ck_id;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_camp_kid_ck_id.
|
|
*
|
|
* @param mixed $capp_camp_kid_ck_id the capp camp user ck id
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_capp_camp_kid_ck_id($capp_camp_kid_ck_id)
|
|
{
|
|
$this->capp_camp_kid_ck_id = $capp_camp_kid_ck_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* get_s the value of capp_date.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_date()
|
|
{
|
|
return $this->capp_date;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_date.
|
|
*
|
|
* @param mixed $capp_date the capp date
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_capp_date($capp_date)
|
|
{
|
|
$this->capp_date = $capp_date;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* get_s the value of capp_status.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_status()
|
|
{
|
|
return $this->capp_status;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_status.
|
|
*
|
|
* @param mixed $capp_status the capp status
|
|
*
|
|
* @return self
|
|
*/
|
|
public function set_capp_status($capp_status)
|
|
{
|
|
$this->capp_status = $capp_status;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* get_s the value of capp_accept_date.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_accept_date()
|
|
{
|
|
return $this->capp_accept_date;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_accept_date.
|
|
*
|
|
* @param mixed $capp_accept_date the capp accept date
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_capp_accept_date($capp_accept_date)
|
|
{
|
|
$this->capp_accept_date = $capp_accept_date;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* get_s the value of capp_camp_id.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_camp_id()
|
|
{
|
|
return $this->capp_camp_id;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_camp_id.
|
|
*
|
|
* @param mixed $capp_camp_id the capp camp id
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_capp_camp_id($capp_camp_id)
|
|
{
|
|
$this->capp_camp_id = $capp_camp_id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* get_s the value of capp_money.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function get_capp_money()
|
|
{
|
|
return $this->capp_money;
|
|
}
|
|
|
|
/**
|
|
* Sets the value of capp_money.
|
|
*
|
|
* @param mixed $capp_money the capp money
|
|
*
|
|
* @return self
|
|
*/
|
|
private function set_capp_money($capp_money)
|
|
{
|
|
$this->capp_money = $capp_money;
|
|
|
|
return $this;
|
|
}
|
|
|
|
//STATIC!
|
|
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;');
|
|
}
|
|
|
|
public static function apply_response($_apply_id, $_status_id)
|
|
{
|
|
global $sql;
|
|
$sql->update_table('camp_apply', ['capp_status' => $_status_id, 'capp_accept_date' => date('Y-m-d H:i:s')], ['capp_id' => $_apply_id]);
|
|
|
|
if (3 == $_status_id) {
|
|
$email_template_id = $sql->single_variable('select et_id from email_template where et_name = \'camp_reply\'');
|
|
if (null !== $email_template_id) {
|
|
$emailTemplate = new email_template();
|
|
$emailTemplate->set_et_data_by_id($email_template_id);
|
|
|
|
//felelős kapcstartó emailere küld
|
|
$contact = self::get_responsible_contact2($_apply_id);
|
|
$campId = $sql->single_variable("SELECT capp_camp_id FROM camp_apply WHERE capp_id = {$_apply_id}");
|
|
$camp = new camp();
|
|
$camp->set_camp_data_by_id($campId);
|
|
|
|
$raw_subject = $emailTemplate->get_et_subject();
|
|
$raw_message = $emailTemplate->get_et_message();
|
|
//var_dump($toNotify_array);
|
|
//foreach ($toNotify_array as $toNotify) {
|
|
$personalizedSubject = $emailTemplate->personalize($raw_subject, [
|
|
]);
|
|
|
|
$personalizedMessage = $emailTemplate->personalize($raw_message, [
|
|
'name' => $contact->get_cc_name(),
|
|
'from' => $camp->get_camp_from(true),
|
|
'to' => $camp->get_camp_to(true),
|
|
]);
|
|
|
|
$mail = new PHPMailer(true); // Passing `true` enables exceptions
|
|
|
|
$mail->SMTPDebug = 0; // Enable verbose debug output
|
|
$mail->isSMTP(); // Set mailer to use SMTP
|
|
$mail->CharSet = PHPMailer::CHARSET_UTF8; // UTF-8
|
|
$mail->Host = 'mail.livingsport.hu'; // Specify main and backup SMTP servers
|
|
$mail->SMTPAuth = true; // Enable SMTP authentication
|
|
$mail->Username = 'notify@livingsport.hu'; // SMTP username
|
|
$mail->Password = 'dpDiKSqU0V'; // SMTP password
|
|
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
|
|
$mail->Port = 465;
|
|
|
|
//Recipients
|
|
$mail->setFrom($emailTemplate->get_et_from_email(), $emailTemplate->get_et_from_name());
|
|
$mail->addAddress($contact->get_cc_email(), $contact->get_cc_name());
|
|
//$mail->addAddress('tricsusz@gmail.com', 'Tóth Richárd'); // TEST
|
|
|
|
//Content
|
|
$mail->isHTML(true); // Set email format to HTML
|
|
$mail->Subject = $personalizedSubject;
|
|
$mail->Body = $personalizedMessage;
|
|
$mail->AltBody = 'Az Ön levelezője nem támogatja a HTML tartalom megjelenítését!';
|
|
|
|
//send mail
|
|
$mail->send();
|
|
}
|
|
}
|
|
}
|
|
|
|
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.';');
|
|
}
|
|
|
|
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_array = $capp_data_assoc_array[0];
|
|
foreach ($capp_array as $field => $value) {
|
|
$function_name = 'set_'.$field;
|
|
$this->$function_name($value);
|
|
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 ('capp_camp_id' == $field) {
|
|
$new_camp = new camp();
|
|
$new_camp->set_camp_data_by_id($value);
|
|
$this->$function_name($new_camp);
|
|
}
|
|
}
|
|
}
|
|
|
|
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 = new camp_contact();
|
|
$cc->set_cc_data_by_id($cc_id);
|
|
|
|
return $cc;
|
|
}
|
|
|
|
public static function get_responsible_contact2($_id)
|
|
{
|
|
global $sql;
|
|
$cc_id = $sql->single_variable('SELECT cac_camp_contact_cc_id FROM camp_apply_contact WHERE cac_camp_apply_capp_id = '.$_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)
|
|
{
|
|
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',
|
|
[
|
|
'cac_is_responsible' => $_is_responsible,
|
|
],
|
|
[
|
|
'cac_camp_apply_capp_id' => $_apply_id,
|
|
'cac_camp_contact_cc_id' => $_cc_id,
|
|
]
|
|
);
|
|
}
|
|
|
|
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', [
|
|
'capp_camp_kid_ck_id' => $_camp_kid,
|
|
'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_date = 'null', $_camp_accept_date = 'null', $_camp = 'null')
|
|
{
|
|
global $sql;
|
|
$sql->update_table('camp_apply', [
|
|
'capp_date' => $_camp_date,
|
|
'capp_accept_date' => $_camp_accept_date,
|
|
'capp_status' => $_status,
|
|
'capp_camp_id' => $_camp,
|
|
], ['capp_id' => $_apply_id]);
|
|
}
|
|
|
|
public static function set_money($_money, $_capp_id)
|
|
{
|
|
global $sql;
|
|
|
|
$sql->update_table('camp_apply', [
|
|
'capp_money' => $_money,
|
|
], ['capp_id' => $_capp_id]);
|
|
}
|
|
}
|