false); // za shrambo parametrov in sporocil
var $pdf;
var $currentStyle;
var $db_table = '';
public static $ss = null; //SurveyStatistic class
public static $sas = null; // $sas = new SurveyAdminSettings();class
/**
* @desc konstruktor
*/
function __construct ($anketa = null, $ssData)
{
global $site_path;
global $global_user_id;
//error_log(json_encode($_GET));
// preverimo ali imamo stevilko ankete
if ( is_numeric($anketa) )
{
$this->anketa['id'] = $anketa;
$this->anketa['podstran'] = $podstran;
// create new PDF document
$this->pdf = new enka_TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
}
else
{
$this->pi['msg'] = "Anketa ni izbrana!";
$this->pi['canCreate'] = false;
return false;
}
$this->sas = new SurveyAdminSettings(0,$this->anketa['id']);
//ustvarimo SurveyStatistic objekt in mu napolnimo variable
$this->ss = new SurveyStatistic();
$this->ss->Init($this->anketa['id'],true);
/*
$this->ss->realUsersByStatus_base = $ssData[0];
$this->ss->type = $ssData[1];
$this->ss->period = $ssData[2];
*/
/* intervali se več ne pošiljajo preko get, ker se polovijo iz porfila
if($ssData[1] != 'undefined')
$this->ss->startDate = $ssData[1];
if($ssData[2] != 'undefined')
$this->ss->endDate = $ssData[2];
$this->ss->type = $ssData[3];
$this->ss->period = $ssData[4];
//$this->ss->isDefaultFilters = false;
*/
if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
{
$this->anketa['uid'] = $global_user_id;
SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
}
else
return false;
// ce smo prisli do tu je vse ok
$this->pi['canCreate'] = true;
return true;
}
// SETTERS && GETTERS
function checkCreate()
{
return $this->pi['canCreate'];
}
function getFile($fileName)
{
//Close and output PDF document
ob_end_clean();
$this->pdf->Output($fileName, 'I');
}
function init()
{
global $lang;
// array used to define the language and charset of the pdf file to be generated
$language_meta = Array();
$language_meta['a_meta_charset'] = 'UTF-8';
$language_meta['a_meta_dir'] = 'ltr';
$language_meta['a_meta_language'] = 'sl';
$language_meta['w_page'] = $lang['page'];
//set some language-dependent strings
$this->pdf->setLanguageArray($language_meta);
//set margins
$this->pdf->setPrintHeaderFirstPage(true);
$this->pdf->setPrintFooterFirstPage(true);
$this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$this->pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$this->pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set header and footer fonts
$this->pdf->setHeaderFont(Array(FNT_HEADER_TEXT, "I", FNT_HEADER_SIZE));
$this->pdf->setFooterFont(Array(FNT_HEADER_TEXT, 'I', FNT_HEADER_SIZE));
// set document information
$this->pdf->SetAuthor('An Order Form');
$this->pdf->SetTitle('An Order');
$this->pdf->SetSubject('An Order');
// set default header data
$this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()));
//set auto page breaks
$this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', FNT_MAIN_SIZE);
//set image scale factor
$this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
return true;
}
function encodeText($text)
{ // popravimo sumnike ce je potrebno
$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
$text = str_replace(array("š","š","č"),array("š","š","č"),$text);
return strip_tags($text);
}
function createPdf()
{
global $site_path;
global $lang;
$this->pdf->AddPage();
$this->pdf->setFont('','B','11');
$this->display();
}
public function display() {
global $lang;
$this->pdf->setDrawColor(200, 200, 200);
$this->pdf->setFillColor(150, 220, 150);
$sea=new SurveyEditsAnalysis($this->anketa['id']);
//se ponovi v funkciji ajax_drawContinuEditsTable
if ($_GET['seansa'] > 0)
$seansa = $_GET['seansa'];
else
$seansa = '30';
if (isset ($_GET['time']))
$time = $_GET['time'];
else
$time = '1 month';
if (isset ($_GET['status']))
$status = $_GET['status'];
else
$status = 0;
if (isset ($_GET['from']))
$from = $_GET['from'];
else
$from = '';
if (isset ($_GET['to']))
$to = $_GET['to'];
else
$to = '';
//create iterval - SQL where statement
$interval = $sea->createInterval($time, $from, $to);
//get object of all edits data
$data = $sea->getData($status, $interval);
}
/** Funkcija prikaze osnovnih informacij
*
*/
function DisplayInfoView() {
global $lang;
global $site_url;
$X = 10;
$Y = 25;
$height = 80;
$this->pdf->setXY($X, $Y);
//izrisemo okvir
$this->pdf->setFont('','B','8');
$this->pdf->SetTextColor(180, 0, 0);
$this->pdf->MultiCell(90, $height, $this->encodeText($lang['srv_statistic_info_title']), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->setXY($X, $Y+8);
$this->pdf->setFont('','','6');
$this->pdf->SetTextColor(0, 0, 0);
//ime ankete
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_name'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(70, 3, $this->encodeText(SurveyInfo::getSurveyTitle()), 0, 1, 'L', 0);
$this->pdf->setX($X);
//katere napredne možnosti so vklopljene
$row = SurveyInfo::getSurveyRow();
$enabled_advanced = null;
$prefix = '';
if ($row['uporabnost'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_4'];
$prefix = ', ';
}
if ($row['user_from_cms'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_5'];
$prefix = ', ';
}
if ($row['quiz'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_6'];
$prefix = ', ';
}
if ($row['phone'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_7'];
$prefix = ', ';
}
if ($row['social_network'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_8'];
$prefix = ', ';
}
//tip ankete
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_type'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_vrsta_survey_type_'.SurveyInfo::getSurveyType()] . ($enabled_advanced != null ? ' ('.$enabled_advanced.')' : '' )), 0, 1, 'L', 0);
$this->pdf->setX($X);
//vprašanj, variabel
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_questions'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(15, 3, $this->encodeText(SurveyInfo::getSurveyQuestionCount()), 0, 0, 'L', 0);
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_variables'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(15, 3, $this->encodeText(SurveyInfo::getSurveyVariableCount()), 0, 1, 'L', 0);
$this->pdf->setX($X);
//uporabnikov, odgovorov
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_analiza_stUporabnikov'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(15, 3, $this->encodeText(SurveyInfo::getSurveyAnswersCount()), 0, 0, 'L', 0);
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_answers_valid'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(15, 3, $this->encodeText(SurveyInfo::getSurveyApropriateAnswersCount()), 0, 1, 'L', 0);
$this->pdf->setX($X);
//jezik ankete
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_language'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(70, 3, $this->encodeText(SurveyInfo::getRespondentLanguage()), 0, 1, 'L', 0);
$this->pdf->setX($X);
//avtor
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_creator'].':'), 0, 0, 'L', 0);
$text = '';
$text .= SurveyInfo::getSurveyInsertName();
if (SurveyInfo::getSurveyInsertDate() && SurveyInfo::getSurveyInsertDate() != "00.00.0000")
$text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyInsertDate(),DATE_FORMAT_SHORT);
if (SurveyInfo::getSurveyInsertTime() && SurveyInfo::getSurveyInsertTime() != "00:00:00")
$text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyInsertTime(),TIME_FORMAT_SHORT);
$this->pdf->Cell(70, 3, $this->encodeText($text), 0, 1, 'L', 0);
$this->pdf->setX($X);
//spreminjal
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_modify'].':'), 0, 0, 'L', 0);
$text = '';
$text .= SurveyInfo::getSurveyEditName();
if (SurveyInfo::getSurveyEditDate() && SurveyInfo::getSurveyEditDate() != "00.00.0000")
$text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyEditDate(),DATE_FORMAT_SHORT);
if (SurveyInfo::getSurveyEditTime() && SurveyInfo::getSurveyEditTime() != "00:00:00")
$text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyEditTime(),TIME_FORMAT_SHORT);
$this->pdf->Cell(70, 3, $this->encodeText($text), 0, 1, 'L', 0);
$this->pdf->setX($X);
//dostop, Kdo razen avtorja ima dostop
$dostop = SurveyInfo::getSurveyAccessUsers();
if ($dostop) {
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_access'].':'), 0, 0, 'L', 0);
$prefix='';
foreach ( $dostop as $user) {
$prefix .= $user['name'].'; ';
}
$prefix = substr($prefix, 0, -2);
$this->pdf->Cell(70, 3, $this->encodeText($prefix), 0, 1, 'L', 0);
$this->pdf->setX($X);
}
//aktivnost
$activity = SurveyInfo:: getSurveyActivity();
$_last_active = end($activity);
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_displaydata_status'].':'), 0, 0, 'L', 0);
if (SurveyInfo::getSurveyColumn('active') == 1) {
$this->pdf->SetTextColor(0,150,0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_anketa_active2']), 0, 1, 'L', 0);
} else {
# preverimo ali je bila anketa že aktivirana
if (!isset($_last_active['starts'])) {
# anketa še sploh ni bila aktivirana
$this->pdf->SetTextColor(255,120,0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_survey_non_active_notActivated']), 0, 1, 'L', 0);
} else {
# anketa je že bila aktivirna ampak je sedaj neaktivna
$this->pdf->SetTextColor(255,120,0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_survey_non_active']), 0, 1, 'L', 0);
}
}
$this->pdf->SetTextColor(0);
$this->pdf->setX($X);
//trajanje: datumi aktivnosti
if ( count($activity) > 0 ) {
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_activity'].':'), 0, 0, 'L', 0);
$prefix = '';
foreach ($activity as $active) {
$_starts = explode('-',$active['starts']);
$_expire = explode('-',$active['expire']);
$prefix .= $_starts[2].'.'.$_starts[1].'.'.$_starts[0].'-'.$_expire[2].'.'.$_expire[1].'.'.$_expire[0];
$prefix .= '; ';
}
$this->pdf->Cell(70, 3, $this->encodeText($prefix), 0, 1, 'L', 0);
$this->pdf->setX($X);
}
# predviceni cas trajanja enkete
$skupni_cas = $this->sas->testiranje_cas(1);
$skupni_predvideni_cas = $this->sas->testiranje_predvidenicas(1);
$d = new Dostop();
//predviceni cas trajanja enkete
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_duration'].':'), 0, 0, 'L', 0);
$text = '';
$text .= ($skupni_cas != '') ? $skupni_cas.', ' : '';
$text .= $lang['srv_predvideno'].': '.$skupni_predvideni_cas;
$this->pdf->Cell(70, 3, $this->encodeText($text), 0, 1, 'L', 0);
$this->pdf->setX($X);
//VNOSI - pvi / zadnji vnos
$prvi_vnos_date = SurveyInfo::getSurveyFirstEntryDate();
$prvi_vnos_time = SurveyInfo::getSurveyFirstEntryTime();
$zadnji_vnos_date = SurveyInfo::getSurveyLastEntryDate();
$zadnji_vnos_time = SurveyInfo::getSurveyLastEntryTime();
if ($prvi_vnos_date != null) {
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_first_entry'].':'), 0, 0, 'L', 0);
$text = '';
$text .= $this->ss->dateFormat($prvi_vnos_date,DATE_FORMAT_SHORT);
$text .= $prvi_vnos_time != null ? (SurveyInfo::$dateTimeSeperator .$this->ss->dateFormat($prvi_vnos_time,TIME_FORMAT_SHORT)) : '';
$this->pdf->Cell(15, 3, $this->encodeText($text), 0, 0, 'L', 0);
}
if ($zadnji_vnos_date != null) {
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_last_entry'].':'), 0, 0, 'L', 0);
$text = '';
$text .= $this->ss->dateFormat($zadnji_vnos_date,DATE_FORMAT_SHORT);
$text .= $zadnji_vnos_time != null ? (SurveyInfo::$dateTimeSeperator .$this->ss->dateFormat($zadnji_vnos_time,TIME_FORMAT_SHORT)) : '';
$this->pdf->Cell(15, 3, $this->encodeText($text), 0, 0, 'L', 0);
}
$this->pdf->Cell(0, 0, '', 0, 1, 'L', 0);
$this->pdf->setX($X);
// Komentarji
$SD = new SurveyDiagnostics($this->anketa['id']);
$comments = $SD->testComments();
list($commentsAll,$commentsUnresolved,$commentsQuestionAll,$commentsQuestionUnresolved,$commentsUser,$commentsUserFinished) = $comments;
$commentsUserUnresolved = $commentsUser - $commentsUserFinished;
if (( (int)$commentsAll
+(int)$commentsUnresolved
+(int)$commentsQuestionAll
+(int)$commentsQuestionUnresolved
+(int)$commentsUser
+(int)$commentsUserFinished
) > 0 ) {
$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_diagnostic_4_element_0'].':'), 0, 0, 'L', 0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_diagnostic_4_element_1'].': '.(int)$commentsAll.' / '.(int)$commentsUnresolved), 0, 1, 'L', 0);
$this->pdf->setX($X);
$this->pdf->Cell(20, 3, $this->encodeText(''), 0, 0, 'L', 0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_diagnostic_4_element_6'].': '.(int)$commentsQuestionAll.' / '.(int)$commentsQuestionUnresolved), 0, 1, 'L', 0);
$this->pdf->setX($X);
$this->pdf->Cell(20, 3, $this->encodeText(''), 0, 0, 'L', 0);
$this->pdf->Cell(70, 3, $this->encodeText($lang['srv_diagnostic_4_element_7'].': '.(int)$commentsUser.' / '.(int)$commentsUserUnresolved), 0, 1, 'L', 0);
$this->pdf->setX($X);
}
}
/** Funkcija prikaže statuse
*
*/
function DisplayStatusView() {
global $lang;
$X = 105;
$Y = 25;
$height = 80;
$this->pdf->setXY($X, $Y);
//izrisemo okvir
$this->pdf->setFont('','B','8');
$this->pdf->SetTextColor(180, 0, 0);
$this->pdf->MultiCell(90, $height, $this->encodeText($lang['srv_statistic_status_title']), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->setXY($X, $Y+8);
$this->pdf->setFont('','','6');
$this->pdf->SetTextColor(0, 0, 0);
$cntValid = 0; // da vemo ali izpisemo skupne
$cntNonValid = 0; // da vemo ali izpisemo skupne
foreach ($this->ss->appropriateStatus as $status) {
if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['valid'][$status] == 0)) {// da ne delamo po neporebnem
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :'), 0, 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText($this->ss->userByStatus['valid'][$status]), 0, 1, 'L', 0);
$cntValid++;
$this->pdf->setX($X);
}
}
// vsota vlejavnih
if ($cntValid > 0 || !$this->ss->hideNullValues_status) {
$this->pdf->setFont('','B','6');
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum_valid']), 'T', 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['valid']), 'T', 1, 'L', 0);
$this->pdf->setY($this->pdf->getY() + 3);
$this->pdf->setX($X);
$this->pdf->setFont('','','6');
}
// izpišemo še neveljavne
foreach ($this->ss->unAppropriateStatus as $status) {
if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['nonvalid'][$status] == 0)) {// da ne delamo po neporebnem
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :'), 0, 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText($this->ss->userByStatus['nonvalid'][$status]), 0, 1, 'L', 0);
$cntNonValid++;
$this->pdf->setX($X);
}
}
// se status null (neznan status)
if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['nonvalid'][-1] == 0)) {// da ne delamo po neporebnem
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_null']), 0, 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText(isset($this->ss->userByStatus['nonvalid'][-1]) ? $this->ss->userByStatus['nonvalid'][-1] : '0'), 0, 1, 'L', 0);
$cntNonValid++;
$this->pdf->setX($X);
}
// vsota nevlejavnih
if ($cntNonValid > 0 || !$this->ss->hideNullValues_status) {
$this->pdf->setFont('','B','6');
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum_nonvalid']), 'T', 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['nonvalid']), 'T', 1, 'L', 0);
$this->pdf->setY($this->pdf->getY() + 3);
$this->pdf->setX($X);
$this->pdf->setFont('','','6');
}
$this->pdf->setFont('','B','6');
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum']), 'T', 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['valid']+$this->ss->cntUserByStatus['nonvalid']), 'T', 1, 'L', 0);
$this->pdf->setFont('','','6');
$this->pdf->setX($X);
# preštejemo še neposlana vabila
$str = "SELECT count(*) FROM srv_invitations_recipients WHERE ank_id='".$this->anketa['id']."' AND sent='0' AND deleted='0'";
$qry = sisplet_query($str);
list($cntUnsent) = mysqli_fetch_row($qry);
$this->ss->userByStatus['invitation'][0] = (int)$cntUnsent;
# še email vabila
foreach ($this->ss->invitationStatus as $status)
{
if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['invitation'][$status] == 0))
{// da ne delamo po neporebnem
//echo '' . $lang['srv_userstatus_'.$status] . ' ('.$status.') :' . $this->ss->userByStatus['invitation'][$status].'
';
$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :'), 0, 0, 'L', 0);
$this->pdf->Cell(45, 0, $this->encodeText($this->ss->userByStatus['invitation'][$status]), 0, 1, 'L', 0);
$cntInvitation++;
$this->pdf->setX($X);
}
}
// vsota emaili
if ($cntInvitation > 0 || !$this->ss->hideNullValues_status) {
//echo '