103 lines
2.7 KiB
PHP
103 lines
2.7 KiB
PHP
<?php
|
|
|
|
|
|
class KolektorNotifications {
|
|
|
|
|
|
private $response;
|
|
|
|
// Statusi responsa
|
|
private $statuses = array(
|
|
1 => 'proženo',
|
|
2 => 'opozorilo 1',
|
|
3 => 'opozorilo 3',
|
|
4 => 'neodgovorjeno',
|
|
5 => 'končano'
|
|
);
|
|
|
|
|
|
function __construct($respondent_id){
|
|
global $site_url;
|
|
global $lang;
|
|
|
|
if($respondent_id != '' && $respondent_id > 0){
|
|
$kr = new KolektorResponse($respondent_id);
|
|
$this->response = $kr->getResponse();
|
|
}
|
|
}
|
|
|
|
|
|
// Posljemo mail z obvestilom uredniku, da je bil spremenjen status responsa
|
|
public function sendNotification(){
|
|
|
|
$survey_title = SurveyInfo::getInstance()->getSurveyTitle();
|
|
$user_email = User::getInstance($this->response['usr_id'])->primaryEmail();
|
|
|
|
$subject = 'Kolektor ETRA 1KA - sprememba statusa respondenta';
|
|
|
|
$body = 'Status respondenta '.$this->response['respondent_email'].' ('.$this->response['respondent_funkcija'].') v anketi '.$survey_title.' je bil spremenjen na '.$this->response['status'].' - '.$this->statuses[$this->response['status']].'.';
|
|
|
|
|
|
// Posljemo mail
|
|
try{
|
|
$MA = new MailAdapter();
|
|
$MA->addRecipients($user_email);
|
|
|
|
echo $subject;
|
|
echo '<br>';
|
|
echo $body;
|
|
//$resultX = $MA->sendMail($body, $subject);
|
|
}
|
|
catch (Exception $e){
|
|
}
|
|
}
|
|
|
|
// Posljemo mail respondentu z vabilom na anketo
|
|
public function sendRespondentNotification(){
|
|
|
|
$subject = 'Kolektor ETRA - vabilo na anketo';
|
|
|
|
// Dobimo url povezave na anketo
|
|
$kr = new KolektorResponse($this->response['respondent_id']);
|
|
$url = $kr->getResponseURL();
|
|
|
|
$body = $this->response['respondent_message'];
|
|
$body .= '<br><br>'.$url;
|
|
|
|
|
|
// Posljemo mail
|
|
try{
|
|
$MA = new MailAdapter();
|
|
$MA->addRecipients($this->response['respondent_email']);
|
|
|
|
echo $subject;
|
|
echo '<br>';
|
|
echo $body;
|
|
//$resultX = $MA->sendMail($body, $subject);
|
|
}
|
|
catch (Exception $e){
|
|
}
|
|
}
|
|
|
|
|
|
// Loop cez vse response in posljemo notificatione glede na statuse
|
|
public static function executeCronJob(){
|
|
|
|
|
|
// Status 1 - "prozeno" - preklopimo na status 2 "opozorilo 1"
|
|
if($this->response['status'] == 0){
|
|
|
|
}
|
|
// Status 2 - "opozorilo 1" - preklopimo na status 3 "opozorilo 3"
|
|
elseif($this->response['status'] == 1){
|
|
|
|
}
|
|
// Status 3 "opozorilo 3" - preklopimo na status 4 "neodgovorjeno"
|
|
elseif($this->response['status'] == 2){
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
?>
|