2022-07-06 12:37:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class KolektorResponse {
|
|
|
|
|
|
|
|
|
|
|
|
private $response = array();
|
|
|
|
|
|
|
|
|
|
|
|
function __construct($response_id){
|
|
|
|
global $site_url;
|
|
|
|
global $lang;
|
|
|
|
|
|
|
|
// Dobimo podatke responsa
|
|
|
|
$sql = sisplet_query("SELECT * FROM kolektor_survey_response WHERE id='".$response_id."'");
|
|
|
|
|
|
|
|
if(mysqli_num_rows($sql) == 0){
|
|
|
|
echo 'Napaka! Odgovor ne obstaja.';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$row = mysqli_fetch_array($sql);
|
|
|
|
$this->response = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStatus(){
|
|
|
|
return $this->response['status'];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Dodajanje responsa
|
|
|
|
public static function addResponse($response_data){
|
2022-07-25 12:21:16 +02:00
|
|
|
global $global_user_id;
|
2022-07-06 12:37:25 +02:00
|
|
|
|
|
|
|
|
2022-07-26 12:27:52 +02:00
|
|
|
// Najprej zgeneriramo kodo in cookie
|
|
|
|
$SI = new SurveyInvitationsNew($response_data['ank_id']);
|
|
|
|
list($code, $cookie) = $SI->generateCode();
|
|
|
|
|
|
|
|
// Ustvarimo respondenta v srv_user
|
|
|
|
$sql_user = sisplet_query("INSERT INTO srv_user
|
|
|
|
(ank_id, email, cookie, pass, last_status, time_insert)
|
|
|
|
VALUES
|
|
|
|
('".$response_data['ank_id']."', '".$response_data['respondent_email']."', '".$cookie."', '".$code."', '0', NOW())
|
|
|
|
");
|
|
|
|
$respondent_id = mysqli_insert_id($GLOBALS['connect_db']);
|
|
|
|
|
|
|
|
|
|
|
|
// Url za individualiziran dostop do ankete
|
|
|
|
$nice_url = SurveyInfo::getSurveyLink();
|
|
|
|
$url = $nice_url.'&code='.$code;
|
|
|
|
$url .= '&kolemail='.$response_data['respondent_email'];
|
|
|
|
$url .= '&kolprojekt='.$response_data['respondent_projekt_id'];
|
|
|
|
$url .= '&kolfunkc='.$response_data['respondent_funkcija'];
|
|
|
|
$url .= '&kolactivat='.$response_data['respondent_remote_activation'];
|
|
|
|
|
|
|
|
// Poslji email z vabilom na anketo - TODO
|
|
|
|
echo 'URL: '.$url;
|
|
|
|
|
|
|
|
// Ce vse ok, nastavimo status na e-posta - neodgovor
|
|
|
|
$sql_user = sisplet_query("UPDATE srv_user SET last_status='1' WHERE id='".$respondent_id."'");
|
2022-07-06 12:37:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Dodaj respondenta v kolektor bazo
|
2022-07-26 12:27:52 +02:00
|
|
|
$sql_kolektor = sisplet_query("INSERT INTO kolektor_survey_response
|
2022-07-25 12:21:16 +02:00
|
|
|
(ank_id,
|
|
|
|
usr_id,
|
|
|
|
insert_time,
|
|
|
|
status,
|
|
|
|
respondent_id,
|
|
|
|
respondent_email,
|
|
|
|
respondent_funkcija,
|
|
|
|
respondent_projekt_id,
|
|
|
|
respondent_remote_activation,
|
|
|
|
respondent_message)
|
2022-07-06 12:37:25 +02:00
|
|
|
VALUES
|
2022-07-25 12:21:16 +02:00
|
|
|
('".$response_data['ank_id']."',
|
|
|
|
'".$global_user_id."',
|
|
|
|
NOW(),
|
|
|
|
'0',
|
|
|
|
'".$respondent_id."',
|
|
|
|
'".$response_data['respondent_email']."',
|
|
|
|
'".$response_data['respondent_funkcija']."',
|
|
|
|
'".$response_data['respondent_projekt_id']."',
|
|
|
|
'".$response_data['respondent_remote_activation']."',
|
|
|
|
'".$response_data['respondent_message']."')
|
2022-07-06 12:37:25 +02:00
|
|
|
");
|
2022-07-26 12:27:52 +02:00
|
|
|
if (!$sql_kolektor){
|
2022-07-25 12:21:16 +02:00
|
|
|
echo mysqli_error($GLOBALS['connect_db']);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-06 12:37:25 +02:00
|
|
|
|
|
|
|
$response_id = mysqli_insert_id($GLOBALS['connect_db']);
|
|
|
|
|
2022-07-25 12:21:16 +02:00
|
|
|
if($response = new KolektorResponse($response_id)){
|
2022-07-26 10:14:04 +02:00
|
|
|
|
|
|
|
echo '<div class="popup_close"><a href="#" onclick="window.location.reload();">✕</a></div>';
|
|
|
|
|
|
|
|
echo '<h2>Dodajanje novega respondenta</h2>';
|
|
|
|
|
|
|
|
echo 'Anketa uspešno sprožena in email uspešno poslan respondentu ('.$response_data['respondent_email'].').';
|
|
|
|
|
|
|
|
// Gumb koncaj
|
|
|
|
echo '<div class="button_holder">';
|
|
|
|
echo ' <button class="medium white-blue" type="button" onClick="window.location.reload();">Zapri</button>';
|
|
|
|
echo '</div>';
|
|
|
|
|
2022-07-06 12:37:25 +02:00
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
echo 'Napaka pri dodajanju odgovora!';
|
|
|
|
return false;
|
2022-07-25 12:21:16 +02:00
|
|
|
}
|
2022-07-06 12:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|