summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/surveyAnalysis
diff options
context:
space:
mode:
Diffstat (limited to 'admin/survey/classes/surveyAnalysis')
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyAnalysis.php8156
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyAnalysisArchive.php1264
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyAnalysisHelper.php126
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyBreak.php1578
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyChart.php10829
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyCrosstabs.php2606
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyEditsAnalysis.php984
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyMeans.php1369
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyMultiCrosstabs.php2489
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyTTest.php1207
-rw-r--r--admin/survey/classes/surveyAnalysis/class.SurveyTableChart.php2853
11 files changed, 33461 insertions, 0 deletions
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyAnalysis.php b/admin/survey/classes/surveyAnalysis/class.SurveyAnalysis.php
new file mode 100644
index 0000000..16e8eea
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyAnalysis.php
@@ -0,0 +1,8156 @@
+<?php
+/**
+ * @author Gorazd Veselič
+ * @date Juny 2010
+ *
+ * | -> \x7C
+ * ` -> \x60
+ * ' -> \x27
+ * " -> \x22
+ */
+
+define("EXPORT_FOLDER", "admin/survey/SurveyData");
+
+define('DATE_FORMAT', 'Y-m-d');
+define("ALLOW_HIDE_ZERRO_REGULAR", false); # omogočimo delovanje prikazovanja/skrivanja ničelnih vrednosti za navadne odgovore
+define("ALLOW_HIDE_ZERRO_MISSING", true); # omogočimo delovanje prikazovanja/skrivanja ničelnih vrednosti za missinge
+define("AUTO_HIDE_ZERRO_VALUE", 20); # nad koliko kategorij skrivamo ničelne vrednosti
+
+
+# mejne vrednosti za barvanje residualov
+define("RESIDUAL_COLOR_LIMIT1", 1.00);
+define("RESIDUAL_COLOR_LIMIT2", 2.00);
+define("RESIDUAL_COLOR_LIMIT3", 3.00);
+
+
+DEFINE (STR_DLMT, '|');
+DEFINE (NEW_LINE, "\n");
+DEFINE (TMP_EXT, '.tmp');
+DEFINE (DAT_EXT, '.dat');
+
+class SurveyAnalysis {
+
+ static public $inited = false; # ali smo razred inicializirali
+
+ static public $sid; # id ankete
+ static public $folder = ''; # pot do folderja
+ static private $headFileName = null; # pot do header fajla
+ static private $dataFileName = null; # pot do data fajla
+ static private $dataFileStatus = null; # status data datoteke
+ static private $dataFileUpdated = null; # kdaj je bilo updejtano
+ static private $noHeader = false; # errorchecking - če header datoteka ne obstaja
+
+ static private $survey = null; # podatki ankete
+
+ static public $podstran; # podstran
+ static public $db_table; # katere tabele uporabljamo
+
+ static public $_CURRENT_STATUS_FILTER = ''; # filter po statusih, privzeto izvažamo 6 in 5
+ static public $_FILTRED_VARIABLES = array(); # filter po spremenljivkah
+ static public $_FILTRED_TYPES = array(); # filter po tipih spremenljivk
+ static public $_FILTRED_OTHER = array(); # filter za polja drugo
+
+ static public $_SHOW_LEGENDA = false; # ali izrisujemo legendo
+
+ static public $_LOOPS = array(); # array z loopi
+ static public $_CURRENT_LOOP = null; # v kateri zanki smo
+
+ static public $_tmp_file_prefix = null; # predpona začasnih datotek za analizo
+ static public $_tmp_file_ext = '.tmp'; # končnicazačasnih datotek za analizo
+
+ static public $appropriateStatus = array(6,5); # Statusi anket katere štejemo kot ustrezne
+ static public $unAppropriateStatus = array(4,3,2,1,0); # Statusi anket katere štejemo kot neustrezne
+ static public $unKnownStatus = array('null'); # Statusi anket katere štejemo kot neustrezne
+
+ static public $currentMissingProfile = 1; # Kateri Missing profil je izbran
+ static public $missingProfileData = null; # Nastavitve trenutno izbranega manjkajočega profila
+ //static public $currentZankaProfile = 0; # Kateri zanka profil je izbran
+ static public $currentFilterProfile = 1; # Kateri IF profil je izbran
+
+
+ static public $_PROFILE_ID_STATUS = null;
+ static public $_PROFILE_ID_VARIABLE = null;
+ static public $_PROFILE_ID_CONDITION = null;
+
+ static public $printPreview = false; # ali prikazujemo podatke kot print preview;
+
+
+ static public $_HEADERS = array(); # shranimo podatke vseh variabel
+ static public $_FREQUENCYS = array(); # v to variablo shranemo frekvence
+ static public $_DESCRIPTIVES = array(); # v to variablo shranemo opisne statistike
+
+ static public $_HAS_TEST_DATA = false; # ali anketa vsebuje testne podatke
+
+ static public $show_spid_div = true; # ali prikazuje spremenljivke v posameznem divu ( pride prav pri ajaxu, ko loadamo v star div
+
+ static public $setUpJSAnaliza = true; # ali nastavimo __analiza = 1 v JS
+
+ static public $crossTabClass = null; # razred za crostabulacije
+
+ static public $returnAsHtml = false; # ali vrne rezultat analiz kot html ali ga izpiše
+ static public $isArchive = false; # nastavimo na true če smo v arhivu
+
+ static public $enableInspect = true; # checkbox enableInspect
+
+ static public $frequencyAddInvalid = true; # ali pri frekvencah dodajamo neveljavne
+
+ static public $_forceShowEmpty = false; # vsili prikaz spremenljivke tudi če je prazna
+
+ static public $hideEmptyValue = false; # Ali skrivamo prazne enote če je več kot 20 kategorij
+
+ static public $publicAnalyse = false; # Ali je javna analaiza
+
+ # CSS STILI
+ static public $cssColors = array (
+ '0_0' => 'anl_bck_0_0',
+ '0_1' => 'anl_bck_0_1',
+ '1_0' => 'anl_bck_1_0',
+ '1_1' => 'anl_bck_1_1',
+ '2_0' => 'anl_bck_2_0',
+ '2_1' => 'anl_bck_2_1',
+ 'text_0' => 'anl_bck_text_0',
+ 'text_1' => 'anl_bck_text_1'
+
+ );
+
+ static public $textAnswersMore = array('0'=>'10','10'=>'30','30'=>'300','300'=>'600','600'=>'900','900'=>'100000');
+
+
+ /**
+ * Inicializacija
+ *
+ * @param int $anketa
+ */
+ static function Init( $anketa = null ) {
+ global $surveySkin, $global_user_id, $site_path, $lang;
+
+ self::$folder = $site_path . EXPORT_FOLDER.'/';
+
+ if ((int)$anketa > 0) { # če je poadan anketa ID
+
+ session_start();
+ self::$sid = $anketa;
+
+ if (self::$inited == false){
+
+ SurveyAnalysisHelper::getInstance()->Init(self::$sid);
+
+ Common::deletePreviewData($anketa);
+
+
+ // Poskrbimo za datoteko s podatki
+ $SDF = SurveyDataFile::get_instance();
+ $SDF->init($anketa);
+ $SDF->prepareFiles();
+
+ self::$headFileName = $SDF->getHeaderFileName();
+ self::$dataFileName = $SDF->getDataFileName();
+ self::$dataFileStatus = $SDF->getStatus();
+ self::$dataFileUpdated = $SDF->getFileUpdated();
+
+
+ if (isset($_GET['podstran'])) {
+ self::$podstran = $_GET['podstran'];
+ } else if (isset($_POST['podstran'])) {
+ self::$podstran = $_POST['podstran'];
+ } else if (isset($_GET['m'])) {
+ self::$podstran = $_GET['m'];
+ } else {
+ self::$podstran = M_ANALYSIS_SUMMARY;
+ }
+
+ # če smo v crostabih, jih incializiramo
+ if (self::$podstran == M_ANALYSIS_CROSSTAB) {
+ self::$crossTabClass = new SurveyCrosstabs();
+ self::$crossTabClass->Init(self::$sid);
+ }
+
+ self::$_CURRENT_STATUS_FILTER = STATUS_FIELD.' ~ /6|5/';
+ # začasni folder kamor se shranjujejo začasni podatki
+ self::$_tmp_file_prefix = 'analysis_'.self::$sid.'_'.self::$podstran.'_';
+
+ # Inicializiramo in polovimo nastavitve missing profila
+ SurveyStatusProfiles :: Init(self::$sid,$global_user_id);
+ SurveyMissingProfiles :: Init(self::$sid,$global_user_id);
+ SurveyVariablesProfiles :: Init(self::$sid);
+ SurveyUserSetting :: getInstance()->Init(self::$sid, $global_user_id);
+
+ SurveyConditionProfiles :: Init(self::$sid, $global_user_id);
+ SurveyZankaProfiles :: Init(self::$sid, $global_user_id);
+ SurveyTimeProfiles :: Init(self::$sid, $global_user_id);
+ SurveyDataSettingProfiles :: Init(self::$sid);
+
+ $smv = new SurveyMissingValues(self::$sid);
+ $zs = new SurveyZoom(self::$sid);
+
+
+ if ( self::$dataFileStatus == FILE_STATUS_NO_DATA || self::$dataFileStatus == FILE_STATUS_SRV_DELETED) {
+ if (self::$podstran != M_ANALYSIS_ARCHIVE)
+ Common::noDataAlert();
+
+ return false;
+ }
+
+ SurveyInfo :: getInstance()->SurveyInit(self::$sid);
+ self::$survey = SurveyInfo::getInstance()->getSurveyRow();
+
+ UserSetting :: getInstance()->Init($global_user_id);
+
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ self::$db_table = '_active';
+ }
+
+ # nastavimo vse filtre
+ self::setUpFilter();
+ self::$inited = true;
+ }
+ } else {
+ die("Napaka!");
+ }
+ }
+
+ /** Funkcija ki nastavi vse filtre
+ *
+ */
+ static public function setUpFilter($pid=null) {
+ if (self::$dataFileStatus == FILE_STATUS_SRV_DELETED) {
+ return false;
+ }
+
+ if (self::$headFileName !== null && self::$headFileName != '' && file_exists(self::$headFileName)) {
+ self::$_HEADERS = unserialize(file_get_contents(self::$headFileName));
+
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ self::removeSystemVariables();
+
+ #
+ # poiščemo kater profil uporablja uporabnik
+ $_currentMissingProfile = SurveyUserSetting :: getInstance()->getSettings('default_missing_profile');
+ self::$currentMissingProfile = (isset($_currentMissingProfile) ? $_currentMissingProfile : 1);
+
+ # poiščemo kateri profil variabel imamo
+ $dvp = SurveyUserSetting :: getInstance()->getSettings('default_variable_profile');
+ $_currentVariableProfile = SurveyVariablesProfiles :: checkDefaultProfile($dvp);
+ if ($dvp != $_currentVariableProfile) {
+ SurveyUserSetting :: getInstance()->saveSettings('default_variable_profile', $_currentVariableProfile);
+ }
+ self::$_PROFILE_ID_VARIABLE = $_currentVariableProfile;
+
+ # filtriranje po statusih
+ self::$_CURRENT_STATUS_FILTER = SurveyStatusProfiles :: getStatusAsAWKString($pid);
+
+ # filtriranje po časih
+ $_time_profile_awk = SurveyTimeProfiles :: getFilterForAWK(self::$_HEADERS['unx_ins_date']['grids']['0']['variables']['0']['sequence']);
+
+ # dodamo še ife
+ SurveyConditionProfiles :: setHeader(self::$_HEADERS);
+ $_condition_profile_AWK = SurveyConditionProfiles:: getAwkConditionString();
+
+ # dodamo dodatne pogoje za GORENJE FILTRIRANJE
+ if(Common::checkModule('gorenje')){
+ $SAG = new SurveyAnalysisGorenje(self::$sid);
+ $_gorenje_filter_AWK = $SAG->getAWKString(self::$_HEADERS);
+ if($_gorenje_filter_AWK != ''){
+ // Ce imamo oba samo pripnemo dodatne filtre
+ if($_gorenje_filter_AWK != '' && $_condition_profile_AWK != '')
+ $_condition_profile_AWK .= '&&'.$SAG->getAWKString(self::$_HEADERS);
+ else
+ $_condition_profile_AWK = $SAG->getAWKString(self::$_HEADERS);
+ }
+ }
+
+ # dodamo še ife za inspect
+ $SI = new SurveyInspect(self::$sid);
+ $_inspect_condition_awk = $SI->generateAwkCondition();
+
+ # dodamo še zoom
+ $_zoom_condition = SurveyZoom::generateAwkCondition();
+
+ # ali imamo filter na testne podatke
+ #$filter_testdata = isset($_SESSION['testData'][self::$sid]['includeTestData']) && $_SESSION['testData'][self::$sid]['includeTestData'] == 'false';
+ if (isset(self::$_HEADERS['testdata']['grids'][0]['variables'][0]['sequence']) && (int)self::$_HEADERS['testdata']['grids'][0]['variables'][0]['sequence'] > 0) {
+ $test_data_sequence = self::$_HEADERS['testdata']['grids'][0]['variables'][0]['sequence'];
+ $filter_testdata = SurveyStatusProfiles :: getStatusTestAsAWKString($test_data_sequence);
+ }
+
+ # ali imamo filter na uporabnost
+ if (isset(self::$_HEADERS['usability']['variables'][0]['sequence']) && (int)self::$_HEADERS['usability']['variables'][0]['sequence'] > 0) {
+ $usability_data_sequence = self::$_HEADERS['usability']['variables'][0]['sequence'];
+ $filter_usability = SurveyStatusProfiles :: getStatusUsableAsAWKString($usability_data_sequence);
+ }
+
+ if (($_condition_profile_AWK != "" && $_condition_profile_AWK != null )
+ || ($_inspect_condition_awk != "" && $_inspect_condition_awk != null)
+ || ($_time_profile_awk != "" && $_time_profile_awk != null)
+ || ($_zoom_condition != "" && $_zoom_condition != null)
+ || ($filter_testdata != null)
+ || ($filter_usability != null)) {
+ self::$_CURRENT_STATUS_FILTER = '('.self::$_CURRENT_STATUS_FILTER;
+
+ if ($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) {
+ self::$_CURRENT_STATUS_FILTER .= ' && '.$_condition_profile_AWK;
+ }
+
+ if ($_inspect_condition_awk != "" && $_inspect_condition_awk != null ) {
+ self::$_CURRENT_STATUS_FILTER .= ' && '.$_inspect_condition_awk;
+ }
+
+ if ($_time_profile_awk != "" && $_time_profile_awk != null) {
+ self::$_CURRENT_STATUS_FILTER .= ' && '.$_time_profile_awk;
+ }
+
+ if ($_zoom_condition != "" && $_zoom_condition != null) {
+ self::$_CURRENT_STATUS_FILTER .= ' && '.$_zoom_condition;
+ }
+
+ if ($filter_testdata != null ) {
+ self::$_CURRENT_STATUS_FILTER .= '&&('.$filter_testdata.')';
+ /*
+ $test_data_sequence = self::$_HEADERS['testdata']['grids'][0]['variables'][0]['sequence'];
+ if ((int)$test_data_sequence > 0) {
+ self::$_CURRENT_STATUS_FILTER .= '&&($'.$filter_testdata.')';
+ }
+ */
+ }
+
+ if ($filter_usability != null ) {
+ self::$_CURRENT_STATUS_FILTER .= '&&('.$filter_usability.')';
+ }
+
+ self::$_CURRENT_STATUS_FILTER .= ')';
+ }
+
+ # filtriranje po spremenljivkah
+ self::$_FILTRED_VARIABLES = null;
+ self::$_FILTRED_VARIABLES = SurveyVariablesProfiles :: getProfileVariables(null);
+
+ # upoštevamo tudi filtriranje po tipu : kategorija, števila, besedilo
+ self::$_FILTRED_TYPES = SurveyDataSettingProfiles :: getSetting('spr_types');
+ self::$_FILTRED_OTHER = SurveyDataSettingProfiles :: getSetting('showOther');
+
+ # če smo radio enableInspect
+ $SI = new SurveyInspect(self::$sid);
+ self::$enableInspect = $SI->isInspectEnabled();
+
+ # ali izrisujemo legendo
+ self::$_SHOW_LEGENDA = (SurveyDataSettingProfiles :: getSetting('analiza_legenda') == true) ? true : false;
+
+
+ if (self::$dataFileStatus >= 0) {
+
+ if (isset(self::$_HEADERS['testdata'])) {
+ self::$_HAS_TEST_DATA = true;
+ }
+ }
+ }
+ else
+ {
+ self::$noHeader = true;
+ }
+ }
+
+ /** Prikazuje filtre
+ *
+ */
+ static function DisplayFilters($hq=1) {
+ global $lang;
+
+ if (self::$dataFileStatus == FILE_STATUS_NO_DATA || self::$noHeader == true) {
+ return false;
+ }
+
+ if (self::$dataFileStatus != FILE_STATUS_SRV_DELETED) {
+
+ if (self::$setUpJSAnaliza == true) {
+ echo '<script> window.onload = function() { __analiza = 1; } </script>';
+ }
+
+ echo '<iframe id="ifmcontentstoprint" style="height: 0px; width: 0px; position: absolute"></iframe>';
+
+
+ # ali imamo testne podatke
+ if (self::$_HAS_TEST_DATA) {
+ # izrišemo bar za testne podatke
+ $SSH = new SurveyStaticHtml(self::$sid);
+ $SSH -> displayTestDataBar(true);
+ }
+
+
+ if (self::$podstran == M_ANALYSIS_DESCRIPTOR || self::$podstran == M_ANALYSIS_FREQUENCY || self::$podstran == M_ANALYSIS_SUMMARY || self::$podstran == M_ANALYSIS_CHARTS || self::$podstran == M_ANALYSIS_LINKS || self::$podstran == M_ANALYSIS_CREPORT) {
+
+ echo '<div id="globalSetingsHolder">';
+
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyZoom :: displayZoomConditions();
+
+ echo '</div>'; # id="globalSetingsHolder"
+
+
+ // Posebni filtri za Gorenje
+ if(Common::checkModule('gorenje')){
+
+ $SAG = new SurveyAnalysisGorenje(self::$sid);
+
+ if($SAG->hasSpremenljivke()){
+ echo '<div id="gorenjeFiltersHolder">';
+ $SAG->displayFilters();
+ echo '</div>';
+ }
+ }
+ }
+ }
+ else {
+ echo "Anketa je bila izbrisana! Prikaz podatkov ni mogoč!";
+ }
+ }
+
+ /** Prikazuje podatke analize
+ *
+ */
+ static function Display() {
+ global $lang;
+
+ if (self::$dataFileStatus == FILE_STATUS_NO_DATA || self::$dataFileStatus == -3 || self::$noHeader == true) {
+ if (self::$podstran != M_ANALYSIS_ARCHIVE)
+ return false;
+ }
+ # zakeširamo vsebino, in jo nato po potrebi zapišpemo v html
+
+ ob_start();
+
+ # če nismo v crostabih
+ if (self::$podstran != M_ANALYSIS_CROSSTAB)
+ {
+ # v arhivih ne izpisujemo
+ if (self::$isArchive == false)
+ {
+ echo '<div id="displayFilterNotes">';
+ # če imamo filter zoom ga izpišemo
+ SurveyZoom::getConditionString();
+ # če imamo filter ifov ga izpišemo
+ SurveyConditionProfiles:: getConditionString();
+ # če imamo filter ifov za inspect ga izpišemo
+ $SI = new SurveyInspect(self::$sid);
+ $SI->getConditionString();
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyTimeProfiles :: printIsDefaultProfile();
+ # če imamo filter spremenljivk ga izpišemo
+ SurveyVariablesProfiles:: getProfileString();
+ # če imamo rekodiranje
+ $SR = new SurveyRecoding(self::$sid);
+ $SR -> getProfileString();
+
+ SurveyDataSettingProfiles::getVariableTypeNote();
+ echo '</div>';
+ }
+
+ }
+
+ if (self::$dataFileStatus == FILE_STATUS_OLD && self::$podstran != M_ANALYSIS_ARCHIVE) {
+ echo "Posodobljeno: ".date("d.m.Y, H:i:s", strtotime(self::$dataFileUpdated));
+ }
+
+ # krostabe naredimo
+ if(self::$podstran == M_ANALYSIS_CROSSTAB ) {
+ self::$crossTabClass->Display();
+ } else {
+ # polovimo nastavtve missing profila
+ self::$missingProfileData = SurveyMissingProfiles::getProfile(self::$currentMissingProfile);
+ if (self::$podstran != M_ANALYSIS_ARCHIVE) {
+ self::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ }
+ if (!is_countable(self::$_LOOPS) || count(self::$_LOOPS) == 0) {
+
+ # če nimamo zank
+ switch (self::$podstran) {
+
+ case M_ANALYSIS_SUMMARY :
+ self::displaySums();
+ break;
+ case M_ANALYSIS_DESCRIPTOR :
+ self::displayDescriptives();
+ break;
+ case M_ANALYSIS_FREQUENCY :
+ self::displayFrequency();
+ break;
+ case M_ANALYSIS_ARCHIVE :
+ self::displayAnalysisArchive();
+ break;
+ default :
+ self::$podstran = M_ANALYSIS_SUMMARY;
+ self::Display();
+ break;
+ }
+ } else {
+ $loop_cnt = 0;
+ # če mamo zanke
+ foreach ( self::$_LOOPS AS $loop)
+ {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ self::$_CURRENT_LOOP = $loop;
+ echo '<h2 data-loopId="'.self::$_CURRENT_LOOP['cnt'].'">'.$lang['srv_zanka_note'].$loop['text'].'</h2>';
+ switch (self::$podstran)
+ {
+ case M_ANALYSIS_SUMMARY :
+ self::displaySums();
+ break;
+ case M_ANALYSIS_DESCRIPTOR :
+ self::displayDescriptives();
+ break;
+ case M_ANALYSIS_FREQUENCY :
+ self::displayFrequency();
+ break;
+ case M_ANALYSIS_ARCHIVE :
+ self::displayAnalysisArchive();
+ break;
+ default :
+ self::$podstran = M_ANALYSIS_SUMMARY;
+ self::Display();
+ break;
+ }
+
+ }
+ }
+
+ }
+ #ob_flush(); flush();
+ if (self::$returnAsHtml == false) {
+ ob_flush(); flush();
+ return;
+ } else {
+ $result = ob_get_clean();
+ ob_flush(); flush();
+ return $result;
+ }
+ }
+
+ /** Izrišemo opisne
+ *
+ */
+ static function displayDescriptives($_spid = null) {
+ global $site_path, $lang;
+ # preberemo header
+
+ if (self::$headFileName !== null ) {
+ #preberemo HEADERS iz datoteke
+ self::$_HEADERS = unserialize(file_get_contents(self::$headFileName));
+
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ self::removeSystemVariables();
+
+ # polovimo frekvence
+ self::getDescriptives();
+
+ # izpišemo opisne statistike
+ $vars_count = count(self::$_FILTRED_VARIABLES);
+ $line_break = '';
+
+
+ # dodamo še kontrolo če kličemo iz displaySingleVar
+ if (isset($_spid) && $_spid !== null) {
+ self::$_HEADERS = array($_spid => self::$_HEADERS[$_spid]);
+ }
+
+ # ali prikazujemo spremenljivke brez veljavnih odgovorov
+ $show_spid = array();
+ foreach (self::$_HEADERS AS $spid => $spremenljivka) {
+ # preverjamo ali je meta
+ if ($spremenljivka['tip'] != 'm'
+ && ( count(self::$_FILTRED_VARIABLES) == 0 || (count(self::$_FILTRED_VARIABLES) > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ))
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES) ){
+ $only_valid = 0;
+
+ $show_enota = false;
+ # preverimo ali imamo samo eno variablo in če iammo enoto
+ if ((int)$spremenljivka['enota'] != 0 || $spremenljivka['cnt_all'] > 1 ) {
+ $show_enota = true;
+ }
+
+ # izpišemo glavno vrstico z podatki
+ $_sequence = null;
+ # za enodimenzijske tipe izpišemo podatke kar v osnovni vrstici
+ if (!$show_enota) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_DESCRIPTIVES[$_sequence]['validCnt'];
+ } else {
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $show_enota = false;
+ }
+ #zloopamo skozi variable
+ $_sequence = null;
+ $grd_cnt=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ # dodamo dodatne vrstice z albelami grida
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ # dodamo ostale vrstice
+ $do_show = ($variable['other'] !=1 && ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3 || $spremenljivka['tip'] == 5 || $spremenljivka['tip'] == 8 ))
+ ? false
+ : true;
+ if ($do_show) {
+ $only_valid += (int)self::$_DESCRIPTIVES[$variable['sequence']]['validCnt'];
+ }
+ }
+ }
+ } //else: if (!$show_enota)
+
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ $show_spid[$spid] = false;
+ } else {
+ $show_spid[$spid] = true;
+ }
+
+ }
+ }
+ echo '<table class="anl_tbl anl_ba" >';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb anl_w90">&nbsp;<span>'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb anl_w110">' . $lang['srv_analiza_opisne_variable'] .'<span>'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_variable_text'] .'<span>'.'</span></td>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_variable_type'] .'<span >'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_variable_expression'] .'<span >'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_variable_skala'] .'<span >'.'</span></td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_m'] .'<span >'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_num_units'] .'<span >'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_povprecje_odstotek'] .'<span >'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb">' . $lang['srv_analiza_opisne_odklon'] .'<span >'.'</span></td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_variabla_line anl_bb" >' . $lang['srv_analiza_opisne_min'] .'<span >'.'</span></td>';
+ echo '<td class=" anl_ac anl_bck anl_variabla_line anl_bb" >' . $lang['srv_analiza_opisne_max'] .'<span >'.'</span></td>';
+ echo '</tr>';
+
+ foreach (self::$_HEADERS AS $spid => $spremenljivka) {
+ # dajemo v bufer, da da ne prikazujemo vprašanj brez veljavnih odgovorov če imamo tako nastavljeno
+
+ # preverjamo ali je meta
+ if ($show_spid[$spid] && $spremenljivka['tip'] != 'm'
+ && ( count(self::$_FILTRED_VARIABLES) == 0 || (count(self::$_FILTRED_VARIABLES) > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ))
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES) ){
+
+ $show_enota = false;
+ # preverimo ali imamo samo eno variablo in če iammo enoto
+ if ((int)$spremenljivka['enota'] != 0 || $spremenljivka['cnt_all'] > 1 ) {
+ $show_enota = true;
+ }
+
+ # izpišemo glavno vrstico z podatki
+ $_sequence = null;
+ # za enodimenzijske tipe izpišemo podatke kar v osnovni vrstici
+ if (!$show_enota) {
+ // if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3
+ // || $spremenljivka['tip'] == 4 || $spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 8) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ self::displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+
+ } else {
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $show_enota = false;
+ }
+ self::displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ #zloopamo skozi variable
+ $_sequence = null;
+ $grd_cnt=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ if (count($spremenljivka['grids']) > 1 && $grd_cnt !== 0 && $spremenljivka['tip'] != 6) {
+ $grid['new_grid'] = true;
+ }
+ $grd_cnt++;
+ $var_cnt=0;
+ # dodamo dodatne vrstice z albelami grida
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ # dodamo ostale vrstice
+ $do_show = ($variable['other'] !=1 && ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3 || $spremenljivka['tip'] == 5 || $spremenljivka['tip'] == 8 ))
+ ? false
+ : true;
+ if ($do_show) {
+ $variable['var_cnt'] = $var_cnt;
+ self::displayDescriptivesVariablaRow($spremenljivka,$grid,$variable,$_css);
+
+ }
+ $grid['new_grid'] = false;
+ $var_cnt++;
+ }
+ }
+ } //else: if (!$show_enota)
+ } // end if $spremenljivka['tip'] != 'm'
+ } // end foreach self::$_HEADERS
+ echo '</table >';
+
+ // Izrisemo ikone na dnu
+ if ( (!isset($_spid) || $_spid == null) && (count(self::$_LOOPS) == 0 || self::$_CURRENT_LOOP['cnt'] == count(self::$_LOOPS)) && ($_GET['m'] != 'analysis_creport') )
+ self::displayBottomSettings('desc');
+
+ } // end if else ($_headFileName == null)
+
+ }
+
+ /** Izriše vrstico z opisnimi
+ *
+ * @param unknown_type $spremenljivka
+ * @param unknown_type $variable
+ */
+ static function displayDescriptivesVariablaRow($spremenljivka,$grid,$variable=null) {
+ global $lang;
+
+ $cssBack = $variable['other'] != 1 ? ' anl_bck_desc_2' : ' anl_bck_desc_3';
+ $cssMove = $variable['other'] != 1 ? ' anl_tin' : ' anl_tin1';
+ $cssBack .= (int)$grid['new_grid'] == 1 ? ' anl_bt ' : ' anl_bt_dot ';
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($_sequence != null) {
+ $_desc = self::$_DESCRIPTIVES[$_sequence];
+ }
+
+ # pokličemo objekt SpremenljivkaSkala
+ $objectSkala = new SpremenljivkaSkala($spremenljivka['spr_id']);
+
+ # če smo na začetku grida dodamo podatke podvprašanja
+ if ($variable['var_cnt'] == 0 && in_array($spremenljivka['tip'],array(16,19,20) ) ) {
+ echo '<tr>';
+ echo '<td class="anl_bck anl_ac anl_br link_no_decoration">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_variabla_sub anl_double_bt anl_bb">';
+ echo $grid['variable'];
+ echo '</td>';
+ echo '<td class="anl_al anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb" colspan="'.(self::$_SHOW_LEGENDA ? '10' : '7').'">';
+ echo $grid['naslov'];
+ echo '</td>';
+ /*
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ }
+ echo '<td class="anl_ac ss=anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td cla"anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br link_no_decoration anl_bck_desc_1 anl_double_bt anl_bb">&nbsp;</td>';
+ */
+ echo '</tr>';
+ }
+ echo '<tr>';
+ echo '<td class="anl_bck anl_ac anl_br link_no_decoration">';
+ echo '&nbsp;';
+ echo '</td>';
+ echo '<td class="'.$cssBack.' anl_ac anl_br link_no_decoration anl_variabla_sub">';
+ echo $variable['variable'];
+ echo '</td>';
+ echo '<td class="' . $cssBack . $cssMove . ' anl_br">';
+ //echo $grid['naslov'] . ' - ' .$variable['naslov'];
+ echo $variable['naslov'];
+ echo ($spremenljivka['enota'] == 1) ? ' - '.$variable['naslov2'] : '';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="' . $cssBack . ' anl_ac anl_br" title="'.$_tip.'">'.'&nbsp;'.'</td>';
+ echo '<td class="' . $cssBack . ' anl_ac anl_br" title="'.$_tip.'">'.$_tip.'</td>';
+ echo '<td class="' . $cssBack . ' anl_ac anl_br" title="'.$_oblika.'">' .$_oblika. '</td>';
+ }
+ #veljavno
+ echo '<td class="' . $cssBack . ' anl_br anl_ac">'.(int)$_desc['validCnt'].'</td>';
+
+ #ustrezno
+ echo '<td class="' . $cssBack . ' anl_br anl_ac">'.(int)$_desc['allCnt'].'</td>';
+ echo '<td class="' . $cssBack . ' anl_br anl_ac">';
+
+
+ if ( isset($_desc['avg']) && (int)$objectSkala->getSkala() !== 1 ) {
+ echo self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ } else if (isset($_desc['avg']) && $spremenljivka['tip'] == 2 && (int)$objectSkala->getSkala() == 1 ) {
+ echo self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%');
+ }
+ echo '</td>';
+ echo '<td class="' . $cssBack . ' anl_br anl_ac">';
+ if (isset($_desc['div']) && (int)$objectSkala->getSkala() !== 1) {
+ echo self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ }
+ echo '</td>';
+ echo '<td class="' . $cssBack . ' anl_br anl_ac">'.((int)$objectSkala->getSkala() !== 1 ? $_desc['min'] : '').'</td>';
+ echo '<td class="' . $cssBack . ' anl_ac">'.((int)$objectSkala->getSkala() !== 1 ? $_desc['max'] : '').'</td>';
+
+ echo '</tr>';
+
+ }
+ /** Izriše vrstico z opisnimi
+ *
+ * @param unknown_type $spremenljivka
+ * @param unknown_type $variable
+ */
+ static function displayDescriptivesSpremenljivkaRow($spid,$spremenljivka,$show_enota,$_sequence = null) {
+ global $lang;
+ $cssBack = " anl_bck_desc_1";
+ if ($_sequence != null) {
+ $_desc = self::$_DESCRIPTIVES[$_sequence];
+ }
+
+ # pokličemo objekt SpremenljivkaSkala
+ $objectSkala = new SpremenljivkaSkala($spremenljivka['spr_id']);
+
+ echo '<tr>';
+ echo '<td class="anl_bck anl_ac anl_br anl_bt link_no_decoration">';
+ self::showIcons($spid,$spremenljivka,'desc');
+ echo '</td>';
+ echo '<td class="'.$cssBack.' anl_ac anl_br anl_bt">';
+ self::showVariable($spid,$spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="' . $cssBack . ' anl_br anl_bt">';
+ echo ($spremenljivka['naslov']) . '</td>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="' . $cssBack . ' anl_ac anl_br anl_bt" title="'.$_tip.'">'.
+ self::getSpremenljivkaLegenda($spremenljivka,'tip')
+ .'</td>';
+ echo '<td class="' . $cssBack . ' anl_ac anl_br anl_bt" title="'.$_tip.'">'.(!$show_enota ? $_tip : '&nbsp').'</td>';
+ echo '<td class="' . $cssBack . ' anl_ac anl_br anl_bt" title="'.$_oblika.'">'.(!$show_enota ? $_oblika : '&nbsp;'). '</td>';
+ }
+ #veljavno
+ echo '<td class="' . $cssBack . ' anl_br anl_ac anl_bt">'.(!$show_enota ? (int)$_desc['validCnt'] : '&nbsp;') .'</td>';
+ #ustrezno
+ echo '<td class="' . $cssBack . ' anl_br anl_ac anl_bt">'.(!$show_enota ? (int)$_desc['allCnt'] : '&nbsp;').'</td>';
+
+ echo '<td class="' . $cssBack . ' anl_br anl_ac anl_bt">';
+ if (isset($_desc['avg']) && (int)$objectSkala->getSkala() !== 1) {
+ echo self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ }
+ echo '</td>';
+ echo '<td class="' . $cssBack . ' anl_br anl_ac anl_bt">';
+ if (isset($_desc['div']) && (int)$objectSkala->getSkala() !== 1) {
+ echo self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ }
+ echo '</td>';
+ echo '<td class="' . $cssBack . ' anl_br anl_ac anl_bt">'.((int)$objectSkala->getSkala() !== 1 ? $_desc['min'] : '').'</td>';
+ echo '<td class="' . $cssBack . ' anl_ac anl_bt">'.((int)$objectSkala->getSkala() !== 1 ? $_desc['max'] : '').'</td>';
+
+ echo '</tr>';
+
+ }
+ /** Izrišemo fekvence
+ *
+ */
+ static function displayFrequency($_spid = null) {
+ global $site_path, $lang;
+ # preberemo header
+ if (self::$headFileName !== null ) {
+ #preberemo HEADERS iz datoteke
+ self::$_HEADERS = unserialize(file_get_contents(self::$headFileName));
+
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ self::removeSystemVariables();
+
+ # polovimo frekvence
+ self::getFrequencys();
+ $vars_count = count(self::$_FILTRED_VARIABLES);
+ $line_break = '';
+ foreach (self::$_HEADERS AS $spid => $spremenljivka) {
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))) {
+ # ali imamo sfiltrirano spremenljivko
+ if ($vars_count == 0 || ($vars_count > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ) ) {
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ case 2: #checkbox če je dihotomna:
+ case 3: # dropdown - prikjaže navpično
+ case 6: # multigrid
+ case 4: # text
+ case 7:# variabla tipa »število«
+ case 8: # datum
+ case 16: #multicheckbox če je dihotomna:
+ case 17: #razvrščanje če je ordinalna
+ case 18: # vsota
+ case 19: # multitext
+ case 20: # multi number
+ case 21: # besedilo*
+ case 22: # kalkulacija
+ case 25: # kvota
+ case 26: # lokacija
+ self::frequencyVertical($spid);
+ break;
+ case 5:
+ # nagovor
+ self::sumNagovor($spid,'freq');
+ break;
+
+ }
+
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+ } // end foreach self::$_HEADERS
+
+ // Izrisemo ikone na dnu
+ if ( (!isset($_spid) || $_spid == null) && (count(self::$_LOOPS) == 0 || self::$_CURRENT_LOOP['cnt'] == count(self::$_LOOPS)) && ($_GET['m'] != 'analysis_creport') )
+ self::displayBottomSettings('freq');
+
+ } // end if else ($_headFileName == null)
+ }
+
+ /** Izriše frekvence v vertikalni obliki
+ *
+ * @param unknown_type $spid
+ */
+ static function frequencyVertical($spid) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+
+ # odstranimo še možne nepotrebne zapise za multigride
+ if ($spremenljivka['tip'] == 6 || $spremenljivka['tip'] == 16 ) {
+ $allGrids = count($spremenljivka['grids']);
+ if ($allGrids > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $cntValidInGrid = 0;
+ # dodamo dodatne vrstice z labelami grida
+ if (count($grid['variables']) > 0 ) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $cntValidInGrid+= (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ }
+ }
+ # preverjamo ali lahko prikazujemo podkategorije
+ if ($allGrids < AUTO_HIDE_ZERRO_VALUE || (int)$cntValidInGrid > 0) {
+ $gidsCanShow[$gid] = true;
+ } else {
+ $gidsCanShow[$gid] = false;
+ }
+ }
+ }
+ }
+ if (self::$hideEmptyValue == true || (is_countable(self::$_FREQUENCYS[$_sequence]['valid']) && count(self::$_FREQUENCYS[$_sequence]['valid']) > AUTO_HIDE_ZERRO_VALUE)) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $key => $valid) {
+ if ((int)$valid['cnt'] == 0) {
+ unset (self::$_FREQUENCYS[$_sequence]['valid'][$key]);
+ }
+ }
+ }
+
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (self::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+ echo '<div id="freq_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_analiza_holder">';
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_br tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ self::showVariable($spid,$spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA ? 7 : 5).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if($spremenljivka['tip'] == 2){
+ echo ' <span class="anl_variabla_info">('.$lang['srv_info_checkbox'].')</span>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+
+ if (!$inline_legenda) {
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>'; # .' / '.$_oblika
+ }
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo'</td>';
+ echo '</tr>';
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck anl_w110">';
+ self::showIcons($spid,$spremenljivka,'freq');
+ echo '</td>';
+ #odgovori
+
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">'.$lang['srv_analiza_frekvence_titleAnswers'] . '</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleFrekvenca'] .'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleOdstotek'] .'</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleVeljavni'] .'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleKumulativa'] .'</td>';
+ echo '</tr>';
+ // konec naslovne vrstice
+ // zeleno vrstico prikažemo samo skupaj z legendo
+ if (self::$_SHOW_LEGENDA && $inline_legenda && in_array($spremenljivka['tip'],array(1,4,8)) ) {
+ $css_bck = 'anl_bck_0_0 ';
+ echo '<tr >';
+ echo '<td class="anl_bl anl_bb anl_br anl_al '.$css_bck.'link_no_decoration">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br anl_al '.$css_bck.'">&nbsp;</td>';
+
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq anl_w90">'.$_tip.'</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq anl_w90">'.$_oblika.'</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ }
+ echo '<td class="anl_bb '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '</tr>';
+ }
+ $_answersOther = array();
+
+ # dodamo opcijo kje izrisujemo legendo
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'num_show_records' => $num_show_records);
+
+ # izpišemo vlejavne odgovore
+ $_current_grid = null;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+
+ # indikator da smo na prvi variabli
+ $first_variable = true;
+
+ # dodamo še kontrolo za prikaz mgridov in mcheckov za več kot 20 vrednosti
+ if ((!is_array($gidsCanShow) && !isset($gidsCanShow[$gid]))
+ || (is_array($gidsCanShow) && isset($gidsCanShow[$gid]) && $gidsCanShow[$gid]== true))
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+
+ if (($variable['text'] != true && $variable['other'] != true)
+ || (in_array($spremenljivka['tip'],array(4,8,21,22,25,26,27)))){
+ # dodamo ime podvariable
+ //if ($_variables_count > 1 && in_array($spremenljivka['tip'],array(2,6,7,16,17,18,19,20,21))) {
+ if ($inline_legenda) {
+ # ali rišemo dvojno črto med grupami
+ if ( $_current_grid != $gid && $_current_grid !== null && $spremenljivka['tip'] != 6&& $spremenljivka['tip'] != 16) {
+ $options['doubleTop'] = true;
+ } else {
+ $options['doubleTop'] = false;
+ }
+ if ($first_variable == true && $spremenljivka['tip'] == 16) {
+ if ($_current_grid !== null) {
+ $options['doubleTop'] = true;
+ }
+ self::outputSubGridVertical($spremenljivka,$variable,$grid,$spid,$options);
+ $options['doubleTop'] = false;
+ }
+ $_current_grid = $gid;
+ self::outputSubVariablaVertical($spremenljivka,$variable,$grid,$spid,$options);
+ }
+ $counter = 0;
+ $_kumulativa = 0;
+
+
+ #po potrebi posortiramo podatke
+ if ($spremenljivka['tip'] == 7 && is_array(self::$_FREQUENCYS[$_sequence]['valid'])) {
+ ksort(self::$_FREQUENCYS[$_sequence]['valid']);
+ }
+ //self::$_FREQUENCYS[$_sequence]
+ if (count(self::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ # tekstovne odgovore posortiramo kronološko
+ if ($spremenljivka['tip'] == 21 || $spremenljivka['tip'] == 4) {
+ $_valid_answers = self :: sortTextValidAnswers($spid,$variable,self::$_FREQUENCYS[$_sequence]['valid']);
+ } else {
+ $_valid_answers = self::$_FREQUENCYS[$_sequence]['valid'];
+ }
+ foreach ($_valid_answers AS $vkey => $vAnswer) {
+ if ($counter < $num_show_records) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+ if (in_array($spremenljivka['tip'],array(4,7,8,19,20,21,26,27))) { // text, number, datum, mtext, mnumber, text*, lokacija,heatmap
+ $options['isTextAnswer'] = true;
+ } else {
+ $options['isTextAnswer'] = false;
+ }
+ $counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ if (count(self::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ $counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $first_variable = false;
+ }
+ }
+
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+ echo '</div>';
+ echo '<br />';
+ }
+
+ static function outputSubGridVertical($spremenljivka,$variable,$grid,$spid,$_options = array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'doubleTop' =>false, # ali imamo novo grupa in nardimo dvojni rob
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $css_bck = 'anl_bck_freq_2 ';
+ echo '<tr'.($options['doubleTop'] ? ' class="anl_double_bt"' : '').'>';
+ echo '<td class="anl_bl anl_bb anl_br anl_ac '.$css_bck.'anl_variabla_sub">';
+ echo $grid['variable'];
+ #echo $variable['variable'];
+ echo '</td>';
+ echo '<td class="anl_bb anl_br anl_al '.$css_bck.'">';
+ // echo $grid['naslov'] . ' - ' .$variable['naslov'];
+ echo $grid['naslov'];
+ #echo $variable['naslov'];
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq">'.$_tip.'</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq">'.$_oblika.'</td>';
+ }
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ }
+ echo '<td class="anl_bb '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '</tr>';
+ }
+ static function outputSubVariablaVertical($spremenljivka,$variable,$grid,$spid,$_options = array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'doubleTop' =>false, # ali imamo novo grupa in nardimo dvojni rob
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $css_bck = 'anl_bck_freq_2 ';
+ echo '<tr'.($options['doubleTop'] ? ' class="anl_double_bt"' : '').'>';
+ echo '<td class="anl_bl anl_bb anl_br anl_ac '.$css_bck.'anl_variabla_sub">';
+ echo $variable['variable'];
+ echo '</td>';
+ echo '<td class="anl_bb anl_br anl_al '.$css_bck.'">';
+ // echo $grid['naslov'] . ' - ' .$variable['naslov'];
+ echo $variable['naslov'];
+ echo ($spremenljivka['enota'] == 1) ? ' - '.$variable['naslov2'] : '';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq">'.$_tip.'</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq">'.$_oblika.'</td>';
+ }
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ }
+ echo '<td class="anl_bb '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '</tr>';
+ }
+
+ /** izrišemo arhive analiz
+ *
+ */
+ static function displayAnalysisArchive() {
+ global $lang;
+
+
+ if (self::$dataFileStatus != FILE_STATUS_NO_DATA && self::$dataFileStatus != -3 && self::$noHeader != true) {
+ echo '<div id="div_archive_content">';
+ SurveyAnalysisArchive :: Init(self::$sid);
+ SurveyAnalysisArchive :: ListArchive();
+ echo '</div>';
+
+ echo '<br class="clr" />';
+ }
+ else{
+ echo '<div id="div_archive_content">';
+
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_archive_analysis'].'</legend>';
+ Common::noDataAlert();
+ echo '</fieldset>';
+
+ echo '</div>';
+
+ echo '<br class="clr" />';
+ }
+ }
+
+ /** Izrišemo sumarnik
+ *
+ */
+ static function displaySums($_spid = null) {
+ global $site_path;
+ # preberemo header
+ if (self::$headFileName === null ) {
+ // die ('<div>NAPAKA!!! Manjkajo datoteke s podatki. <a href="#" onClick="createCollectData();return false;">Kreiraj datoteke s podatki!</a></div>');
+ } else {
+ #preberemo HEADERS iz datoteke
+ if (self::$headFileName == null) {
+ echo "<br><b>Napaka</b>";
+ die();
+ }
+ self::$_HEADERS = unserialize(file_get_contents(self::$headFileName));
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ self::removeSystemVariables();
+ #print_r("<pre>");
+ #print_r(self::$_HEADERS);
+ #print_r("</pre>");
+ # polovimo frekvence
+ self::getFrequencys();
+ $vars_count = count(self::$_FILTRED_VARIABLES);
+ $line_break = '';
+
+ if (!empty(self::$_HEADERS))
+ foreach (self::$_HEADERS AS $spid => $spremenljivka) {
+ # preverjamo ali je meta
+ if (
+ ($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES )
+ )
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ )
+ {
+ # ali imamo sfiltrirano spremenljivko
+ if ($vars_count == 0 || ($vars_count > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ) )
+ {
+ echo $line_break;
+ #print_r($spremenljivka['tip']);
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+
+ switch ($spremenljivka['tip']) {
+ case 1:
+ # radio - prikjaže navpično
+ self::sumVertical($spid,'sums');
+
+ break;
+ case 2:
+ #checkbox če je dihotomna:
+ //self::sumHorizontalCheckbox($spid);
+ self::sumVerticalCheckbox($spid,'sums');
+ break;
+ case 3:
+ # dropdown - prikjaže navpično
+ self::sumVertical($spid,'sums');
+ break;
+
+ case 6:
+
+ if ($spremenljivka['enota'] != 3) {
+ # multigrid
+ self::sumHorizontal($spid,'sums');
+ } else {
+ #imamo dvojni mgrid
+ self::sumDoubleHorizontal($spid,'sums*');
+ }
+ break;
+ case 16:
+ #multicheckbox če je dihotomna:
+ self::sumMultiHorizontalCheckbox($spid,'sums');
+ break;
+ case 17:
+
+ #razvrščanje če je ordinalna
+ self::sumHorizontal($spid,'sums');
+ break;
+ case 4: # text
+ case 8: # datum
+ # varabla tipa »besedilo« je v sumarniku IDENTIČNA kot v FREKVENCAH.
+ self::sumTextVertical($spid,'sums');
+ break;
+ case 21: # besedilo*
+ # varabla tipa »besedilo« je v sumarniku IDENTIČNA kot v FREKVENCAH.
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ self::sumTextVertical($spid,'sums');
+ } else {
+ self::sumMultiText($spid,'sums');
+ }
+ break;
+ case 19: # multitext
+ self::sumMultiText($spid,'sums');
+ break;
+ case 7:
+ case 18:
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ self::sumNumberVertical($spid,'sums');
+ break;
+ case 20:
+
+ # Če je v gridu le ene variabla naj bo default prikazan f* in ne SUMA
+ if ($spremenljivka['grids'][0]['cnt_vars'] == 1 ) {
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ self::sumMultiNumberVertical($spid,'sums');
+
+ } else {
+
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ self::sumMultiNumber($spid,'sums');
+ }
+ break;
+ case 22:
+ case 25:
+ # kalkulacija
+ self::sumNumberVertical($spid,'sums');
+ break;
+ case 26:
+ # lokacija
+ self::sumMultiText($spid,'sums');
+ break;
+ case 27:
+ # heatmap
+ self::sumMultiTextHeatMap($spid,'sums',true, true);
+
+ break;
+ case 5:
+ # nagovor
+ self::sumNagovor($spid,'sums');
+ break;
+ default:
+ print_r("TODO: Sums for type:".$spremenljivka['tip']);
+ break;
+ }
+
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+ } // end foreach self::$_HEADERS
+
+ // Izrisemo ikone na dnu
+ if ( (!isset($_spid) || $_spid == null) && (!is_countable(self::$_LOOPS) || count(self::$_LOOPS) == 0 || self::$_CURRENT_LOOP['cnt'] == count(self::$_LOOPS)) && ($_GET['m'] != 'analysis_creport') )
+ self::displayBottomSettings('sums');
+
+ } // end if else ($_headFileName == null)
+ }
+
+ /** Izrišemo nov sumarnik za določene spremenljivke
+ *
+ */
+ static function displaySumsNew($_spid = null) {
+ global $site_path;
+ # preberemo header
+ if (self::$headFileName === null ) {
+ // die ('<div>NAPAKA!!! Manjkajo datoteke s podatki. <a href="#" onClick="createCollectData();return false;">Kreiraj datoteke s podatki!</a></div>');
+ } else {
+
+ #preberemo HEADERS iz datoteke
+ self::$_HEADERS = unserialize(file_get_contents(self::$headFileName));
+
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ self::removeSystemVariables();
+
+ # polovimo frekvence
+ self::getFrequencys();
+ $vars_count = count(self::$_FILTRED_VARIABLES);
+ $line_break = '';
+ foreach (self::$_HEADERS AS $spid => $spremenljivka) {
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))) {
+ # ali imamo sfiltrirano spremenljivko
+ if ($vars_count == 0 || ($vars_count > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ) ) {
+ echo $line_break;
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1:
+ # radio - prikjaže navpično
+ self::sumHorizontal($spid,'sums*');
+ break;
+ case 2:
+ #checkbox če je dihotomna:
+ #self::sumVerticalCheckbox($spid,'sums*');
+ self::sumHorizontalCheckbox($spid,'sums*');
+ break;
+ case 3:
+ # dropdown - prikjaže navpično
+ self::sumVertical($spid,'sums*');
+ break;
+ case 6:
+ # multigrid
+ self::sumHorizontal($spid,'sums');
+ /*
+ if ($spremenljivka['enota'] != 3) {
+ # multigrid
+ self::sumHorizontal($spid,'sums');
+ } else {
+ #imamo dvojni mgrid
+ self::sumDoubleHorizontal($spid,'sums*');
+ }
+ */
+ break;
+ case 16:
+ #multicheckbox če je dihotomna:
+ self::sumVerticalCheckbox($spid,'sums*');
+ break;
+ case 17:
+ #razvrščanje če je ordinalna
+ self::sumHorizontal($spid,'sums*');
+ break;
+ case 4: # text
+ case 8: # datum
+ case 19: # multitext
+ case 21: # besedilo*
+ # varabla tipa »besedilo« je v sumarniku IDENTIČNA kot v FREKVENCAH.
+ self::sumTextVertical($spid,'sums*');
+ break;
+ case 7:
+ case 18:
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ self::sumNumberVertical($spid,'sums*');
+ break;
+ case 20:
+ self::sumMultiNumberVertical($spid,'sums*');
+ /*
+ # Če je v gridu le ene variabla naj bo default prikazan f* in ne SUMA
+ if ($spremenljivka['grids'][0]['cnt_vars'] == 1) {
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ self::sumMultiNumberVertical($spid,'sums');
+
+ } else {
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ self::sumMultiNumber($spid,'sums');
+ }
+ */
+ break;
+ case 26:
+ # lokacija
+ self::sumMultiText($spid,'sums');
+ break;
+ case 27:
+ # heatmap
+ self::sumMultiTextHeatMap($spid,'sums',true, true);
+ break;
+ case 5:
+ # nagovor
+ self::sumNagovor($spid,'sums*');
+ break;
+
+ }
+ if (self :: $show_spid_div == true) {
+ echo '</div>'; // id="sum_'.$keyGrupe.'">';
+ }
+ $line_break = "<br/>";
+
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+ } // end foreach self::$_HEADERS
+ } // end if else ($_headFileName == null)
+ }
+
+
+ /** Izriše sumarnik v vertikalni obliki
+ *
+ * @param unknown_type $spid
+ */
+ static function sumVertical($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ $inline_legenda = false;
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'num_show_records' => $num_show_records);
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+
+ if (self::$hideEmptyValue == true || (is_countable(self::$_FREQUENCYS[$_sequence]['valid']) && count(self::$_FREQUENCYS[$_sequence]['valid']) > AUTO_HIDE_ZERRO_VALUE)) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $key => $valid) {
+ if ((int)$valid['cnt'] == 0) {
+ unset (self::$_FREQUENCYS[$_sequence]['valid'][$key]);
+ }
+ }
+ }
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_br tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ $show_valid_percent = (self::$_HEADERS[$spid]['show_valid_percent'] == true) ? 1 : 0;
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA ? (4+((int)$inline_legenda * 2)+$show_valid_percent) : (4+$show_valid_percent)).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck anl_w110">';
+
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ #odgovori
+
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">'.$lang['srv_analiza_frekvence_titleAnswers'] . '</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleFrekvenca'] .'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleOdstotek'] .'</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleVeljavni'] .'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleKumulativa'] .'</td>';
+ echo '</tr>';
+ // konec naslovne vrstice
+ // zeleno vrstico prikažemo samo skupaj z legendo
+ if (self::$_SHOW_LEGENDA && false) {
+ $css_bck = 'anl_bck_0_0 ';
+ echo '<tr >';
+ echo '<td class="anl_bl anl_bb anl_br anl_al '.$css_bck.'link_no_decoration">&nbsp;</td>';
+
+ echo '<td class="anl_bb anl_br anl_al '.$css_bck.'">&nbsp;</td>';
+
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq anl_w90">'.$_tip.'</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_ac anl_legend anl_legenda_freq anl_w90">'.$_oblika.'</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_bb anl_br '.$css_bck.' anl_w70">&nbsp;</td>';
+ }
+ echo '<td class="anl_bb '.$css_bck.' anl_w70">&nbsp;</td>';
+ echo '</tr>';
+ }
+ $_answersOther = array();
+ $sum_xi_fi=0;
+ $N = 0;
+
+ $_tmp_for_div = array();
+ # izpišemo vlejavne odgovore
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['text'] != true && $variable['other'] != true) {
+ $counter = 0;
+ $_kumulativa = 0;
+ //self::$_FREQUENCYS[$_sequence]
+ if (count(self::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ // za povprečje
+ $xi = (int)$vkey;
+ $fi = (int)$vAnswer['cnt'];
+
+ $sum_xi_fi += $xi * $fi;
+ $N += $fi;
+
+ if ($counter < $num_show_records) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ }
+ # za poznejše računannje odklona
+ $_tmp_for_div[] = array('xi'=>$xi, 'fi'=>$fi, 'sequence'=>$_sequence);
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+
+ }
+ if (count(self::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ $counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+
+ # odklon
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ foreach ( $_tmp_for_div as $tkey => $_tmp_div_data) {
+ $xi = (int)$_tmp_div_data['xi'];
+ $fi = (int)$_tmp_div_data['fi'];
+
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ $div = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+ # izpišemo še odklon in povprečje
+ if ($show_valid_percent == 1 && self::$_HEADERS[$spid]['skala'] != 1) {
+ $css_bck = 'anl_bck';
+ echo '<tr >';
+ echo '<td class="cll_clps" style="font-size: 1px; height:2px; line-height:3px; border-right: 1px solid white;" colspan="'.(self::$_SHOW_LEGENDA ? 6+((int)$inline_legenda*2) : 6+((int)$inline_legenda*2)).'">&nbsp;</td>';
+ echo '</tr>';
+ echo '<tr >';
+ echo '<td class="anl_br" colspan="'.(self::$_SHOW_LEGENDA ? 2+((int)$inline_legenda*2) : 2+((int)$inline_legenda*2)).'">&nbsp;</td>';
+ echo '<td class="anl_bb anl_bt anl_br anl_p5 anl_ac anl_variabla_line '.$css_bck.'">'.$lang['srv_analiza_opisne_povprecje'].'</td>';
+ echo '<td class="anl_bb anl_bt anl_br anl_ac '.$css_bck.'">'. self::formatNumber($avg,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'').'</td>';
+ echo '<td class="anl_bb anl_bt anl_br anl_p5 anl_ac anl_variabla_line '.$css_bck.'">'.$lang['srv_analiza_opisne_odklon'].'</td>';
+ echo '<td class="anl_bb anl_bt anl_ac '.$css_bck.'">'.self::formatNumber($div,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'').'</td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** Izriše sumarnik v horizontalni obliki za multi checbox
+ *
+ * @param unknown_type $spid - spremenljivka ID
+ */
+ static function sumMultiHorizontalCheckbox($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ $gidsCanShow=array();
+ $allGrids = count($spremenljivka['grids']);
+ if ($allGrids > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $cntValidInGrid = 0;
+ # dodamo dodatne vrstice z labelami grida
+ if (count($grid['variables']) > 0 ) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ #$only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $cntValidInGrid+= (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ }
+ }
+ # preverjamo ali lahko prikazujemo podkategorije
+ if ($allGrids < AUTO_HIDE_ZERRO_VALUE || (int)$cntValidInGrid > 0) {
+ $gidsCanShow[$gid] = true;
+ } else {
+ $gidsCanShow[$gid] = false;
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ $_answersOther = array();
+
+ # ugotovimo koliko imamo kolon
+ $gid=0;
+ $_clmn_cnt = self::$_HEADERS[$spid]['grids'][$gid]['cnt_vars']-self::$_HEADERS[$spid]['grids'][$gid]['cnt_other'];
+ # tekst vprašanja
+
+ $css_hide_enote = isset($_POST['navedbe']) && $_POST['navedbe'] == '1' ? ' displayNone' : '';
+ $css_hide_navedbe = isset($_POST['navedbe']) && $_POST['navedbe'] == '1' ? '' : ' displayNone';
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # odgovori
+ echo '<div id="div_navedbe_1_'.$spid.'" class="'.$css_hide_enote.'">';
+ echo '<table class="anl_tbl anl_ba tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_bck_desc_1">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_al anl_bck anl_bb anl_bck_desc_1" colspan="'. ($_clmn_cnt+(self::$_SHOW_LEGENDA ? 5 : 3)) .'">';
+ echo '<span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type">&nbsp;&nbsp;<span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ // echo '<span name="span_show_navedbe_1_'.$spid.'" class="span_navedbe"><a href="javascript:show_navedbe(\''.$spid.'\',\'3\');">&nbsp;(<span class="blue">'.$lang['srv_analiza_opisne_answers'].'&nbsp;</span>/<span class="blue">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '<span name="span_show_navedbe_2_'.$spid.'" class="span_navedbe'.$css_hide_enote.'"><a href="javascript:show_navedbe(\''.$spid.'\',\'2\');">&nbsp;(<span class="blue" title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '<span name="span_show_navedbe_3_'.$spid.'" class="span_navedbe'.$css_hide_navedbe.'"><a href="javascript:show_navedbe(\''.$spid.'\',\'1\');">&nbsp;(<span title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span class="blue" title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb">';
+ self::showIcons($spid,$spremenljivka,$_from, array('navedbe'=>false));
+ echo '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line">';
+ echo $lang['srv_analiza_opisne_subquestion'];
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line" colspan="'.($_clmn_cnt).'">';
+ echo $lang['srv_analiza_opisne_answers'].'&nbsp;';
+ echo '<span id="img_analysis_f_p_1_'.$spid.'" class="img_analysis_f_p"><a href="javascript:show_single_percent(\''.$spid.'\',\'2\');">&nbsp;(<span class="blue">f&nbsp;</span>/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '<span id="img_analysis_f_1_'.$spid.'" class="img_analysis_f displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'1\');">&nbsp;(<span class="blue">f&nbsp;</span>/&nbsp;%)</a></span>';
+ echo '<span id="img_analysis_p_1_'.$spid.'" class="img_analysis_p displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'0\');">&nbsp;(f&nbsp;/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_valid'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_num_units'].'</td>';
+ echo '</tr>';
+
+ $bck_css = ' anl_bck_0_0';
+ $_variables = self::$_HEADERS[$spid]['grids'][$gid]['variables'];
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb'.$bck_css .'">&nbsp;</td>';
+ echo '<td class="anl_bl anl_br anl_bb'.$bck_css .'">&nbsp;</td>';
+ if (self::$_SHOW_LEGENDA) {
+
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ echo '<td class="anl_bb anl_br anl_ac anl_legend anl_legenda_freq'.$bck_css.'">&nbsp;</td>'; //'.$_tip.'
+ echo '<td class="anl_bb anl_br anl_ac anl_legend anl_legenda_freq'.$bck_css.'">&nbsp;</td>'; // '.$_oblika.'
+ }
+ if (count($_variables) > 0) {
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ echo '<td class="anl_bb anl_ac anl_dash_br'.$bck_css.'">' . $variable['naslov'].' ('.$variable['gr_id']. ') </td>';
+ }
+ }
+ }
+ //echo '<td class="anl_bb anl_ac anl_br red'.$bck_css.'">' . $lang['srv_anl_suma1'] . '</td>';
+ echo '<td class="anl_bb anl_br anl_bl anl_ac'.$bck_css.'">'. $_valid_cnt .'</td>';
+ echo '<td class="anl_bb anl_bl anl_br anl_ac'.$bck_css.'">'.$_approp_cnt. '</td>';
+ echo '</tr>';
+ foreach (self::$_HEADERS[$spid]['grids'] AS $gid => $grids) {
+ if ($gidsCanShow[$gid]) {
+ $_cnt = 0;
+ # vodoravna vrstice s podatki
+ $css_back = ' anl_bck_desc_2';
+ echo '<tr>';
+ echo '<td class="anl_br anl_bt anl_ac anl_variabla_sub'.$css_back.'">'.$grids['variable'].'</td>';
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$grids['naslov'].'</td>';
+ if (self::$_SHOW_LEGENDA) {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$_tip.'</td>';
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$_oblika.'</td>';
+ }
+
+ $_arguments = 0;
+
+ $_max_appropriate = 0;
+ $_max_cnt = 0;
+ // prikaz frekvenc
+ if (count($grids['variables']) > 0)
+ foreach ($grids['variables'] AS $vkey => $variable) {
+ $_sequence = $variable['sequence'];
+ $_valid = self::$_FREQUENCYS[$_sequence]['validCnt'];
+ $_cnt = self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $_arguments += $_cnt;
+
+ $_max_appropriate = max($_max_appropriate, (int)self::$_FREQUENCYS[$_sequence]['allCnt']);
+ $_max_cnt = max ($_max_cnt, ((int)(self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)self::$_FREQUENCYS[$_sequence]['valid']['0']['cnt'])));
+
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vkey,'sequence'=>$_sequence);
+ }
+
+ if ($variable['other'] != true) {
+ echo '<td class="anl_bb anl_dash_br anl_ac cll_clps '.$css_back.'">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr id="'.$spid.'_'.$_sequence.'" name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac' . (self::$enableInspect == true && (int)$_cnt > 0 ? ' mc_inspect' : '').'"'
+ . (self::$enableInspect == true && (int)$_cnt > 0 ? ' vkey="1"' : '')
+ .'" style="padding:5px 0px;">'.$_cnt.'</td>';
+ echo '</tr>';
+ echo '<tr name="single_sums_percent_'.$spid.'">';
+ echo '<td style="padding:5px 0px;">';
+
+ $_percent = ($_valid > 0 ) ? $_cnt * 100 / $_valid : 0;
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr></table>';
+
+ echo '</td>';
+ }
+ }
+ # veljavno
+ echo '<td class="anl_bt anl_ac anl_br anl_bl red'.$css_back.'">'.$_max_cnt.'</td>';
+ #ustrezno
+ echo '<td class="anl_bt anl_ac anl_br'.$css_back.'">'.$_max_appropriate.'</td>';
+
+ echo '</tr>';
+ }
+ }
+ echo '</table>';
+ echo '</div>';
+
+ # navedbe
+ echo '<div id="div_navedbe_2_'.$spid.'" class="div_navedbe'.$css_hide_navedbe.'">';
+ echo '<table class="anl_tbl anl_ba tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_bck_desc_1">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_al anl_bck anl_bb anl_bck_desc_1" colspan="'. ( $_clmn_cnt +(self::$_SHOW_LEGENDA ? 4 : 2)) .'">';
+ echo '<span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type">&nbsp;&nbsp;<span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ // echo '<span name="span_show_navedbe_1_'.$spid.'" class="span_navedbe"><a href="javascript:show_navedbe(\''.$spid.'\',\'3\');">&nbsp;(<span class="blue">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span class="blue">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '<span name="span_show_navedbe_2_'.$spid.'" class="span_navedbe'.$css_hide_enote.'"><a href="javascript:show_navedbe(\''.$spid.'\',\'2\');">&nbsp;(<span class="blue" title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '<span name="span_show_navedbe_3_'.$spid.'" class="span_navedbe'.$css_hide_navedbe.'"><a href="javascript:show_navedbe(\''.$spid.'\',\'1\');">&nbsp;(<span title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span class="blue" title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb">';
+ self::showIcons($spid,$spremenljivka,$_from, array('navedbe'=>true));
+ echo '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line">';
+ echo $lang['srv_analiza_opisne_subquestion'];
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line" colspan="'.($_clmn_cnt+1).'">';
+ echo $lang['srv_analiza_opisne_arguments'].'&nbsp;';
+
+ echo '<span id="img_analysis_f_p_2_'.$spid.'" class="img_analysis_f_p "><a href="javascript:show_single_percent(\''.$spid.'\',\'2\');">&nbsp(<span class="blue">f&nbsp;</span>/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '<span id="img_analysis_f_2_'.$spid.'" class="img_analysis_f displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'1\');">&nbsp(<span class="blue">f&nbsp;</span>/&nbsp;%)</a></span>';
+ echo '<span id="img_analysis_p_2_'.$spid.'" class="img_analysis_p displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'0\');">&nbsp(f&nbsp;/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '</td>';
+ echo '</tr>';
+
+ $bck_css = ' anl_bck_0_0';
+ $_variables = self::$_HEADERS[$spid]['grids'][$gid]['variables'];
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb'.$bck_css .'">&nbsp;</td>';
+ echo '<td class="anl_bl anl_br anl_bb'.$bck_css .'">&nbsp;</td>';
+ if (self::$_SHOW_LEGENDA) {
+
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ echo '<td class="anl_bb anl_br anl_ac anl_legend anl_legenda_freq'.$bck_css.'">&nbsp;</td>'; //'.$_tip.'
+ echo '<td class="anl_bb anl_br anl_ac anl_legend anl_legenda_freq'.$bck_css.'">&nbsp;</td>'; // '.$_oblika.'
+ }
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ echo '<td class="anl_bb anl_ac anl_dash_br'.$bck_css.'">' . $variable['naslov'].' ('.$variable['gr_id']. ') </td>';
+ }
+ }
+ echo '<td class="anl_bb anl_ac anl_dash_br red'.$bck_css.'">' . $lang['srv_anl_suma1'] . '</td>';
+ echo '</tr>';
+ foreach (self::$_HEADERS[$spid]['grids'] AS $gid => $grids) {
+ $_cnt = 0;
+ # vodoravna vrstice s podatki
+ $css_back = ' anl_bck_desc_2';
+ echo '<tr>';
+
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$grids['variable'].'</td>';
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$grids['naslov'].'</td>';
+ if (self::$_SHOW_LEGENDA) {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$_tip.'</td>';
+ echo '<td class="anl_br anl_bt'.$css_back.'">'.$_oblika.'</td>';
+ }
+
+ $_arguments = 0;
+
+ $_max_appropriate = 0;
+ $_max_cnt = 0;
+ // prikaz frekvenc
+ foreach ($grids['variables'] AS $vkey => $variable) {
+ $_sequence = $variable['sequence'];
+ $_valid = self::$_FREQUENCYS[$_sequence]['validCnt'];
+ $_cnt = self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $_arguments += $_cnt;
+
+ $_max_appropriate = max($_max_appropriate, (int)self::$_FREQUENCYS[$_sequence]['allCnt']);
+ $_max_cnt = max ($_max_cnt, ((int)(self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)self::$_FREQUENCYS[$_sequence]['valid']['0']['cnt'])));
+
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vkey,'sequence'=>$_sequence);
+ }
+
+ if ($variable['other'] != true) {
+ $_percent = ($_valid > 0 ) ? $_cnt * 100 / $_valid : 0;
+ }
+ }
+ foreach ($grids['variables'] AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+ $_cnt = self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ echo '<td class="anl_bb anl_dash_br anl_ac cll_clps '.$css_back.'">';
+
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr id="'.$spid.'_'.$_sequence.'" name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac' . (self::$enableInspect == true && (int)$_cnt > 0 ? ' mc_inspect' : '').'"'
+ . (self::$enableInspect == true && (int)$_cnt > 0 ? ' vkey="1"' : '')
+ .' style="padding:5px 0px;">'.$_cnt.'</td>';
+ echo '</tr>';
+ echo '<tr name="single_sums_percent_'.$spid.'">';
+ echo '<td style="padding:5px 0px;">';
+ $_percent = ($_arguments > 0 ) ? $_cnt * 100 / $_arguments : 0;
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr></table>';
+
+ echo '</td>';
+ }
+ }
+ echo '<td class="anl_bb anl_ac anl_dash_br cll_clps '.$css_back.'">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac" style="padding:5px 0px;">'.$_arguments.'</td>';
+ echo '</tr>';
+ echo '<tr name="single_sums_percent_'.$spid.'">';
+ echo '<td style="padding:5px 0px;">';
+ $_percent = ($_arguments > 0 ) ? $_arguments * 100 / $_arguments : 0;
+ echo self::formatNumber('100',SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr></table>';
+ echo '</td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+
+ echo '</div>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** Izriše sumarnik v horizontalni obliki za checbox
+ *
+ * @param unknown_type $spid - spremenljivka ID
+ */
+ static function sumHorizontalCheckbox($spid,$_from) {
+ global $lang;
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ $_answersOther = array();
+
+ # ugotovimo koliko imamo kolon
+ $gid=0;
+ $_clmn_cnt = self::$_HEADERS[$spid]['grids'][$gid]['cnt_vars']-self::$_HEADERS[$spid]['grids'][$gid]['cnt_other'];
+ foreach (self::$_HEADERS[$spid]['grids'][$gid]['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+
+ $_valid_cnt = max($_valid_cnt, self::$_FREQUENCYS[$_sequence]['validCnt']);
+ $_approp_cnt = max($_approp_cnt, self::$_FREQUENCYS[$_sequence]['allCnt']);
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_bl tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_bck_desc_1">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_al anl_bck anl_bb anl_bck_desc_1" colspan="'. ($_clmn_cnt+(self::$_SHOW_LEGENDA ? 4 : 2)) .'">';
+ echo '<span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line" colspan="'.$_clmn_cnt.'">'.$lang['srv_analiza_opisne_answers'];
+ echo '<span id="img_analysis_f_p_1_'.$spid.'" class="img_analysis_f_p"><a href="javascript:show_single_percent(\''.$spid.'\',\'2\');">&nbsp(<span class="blue">f&nbsp;</span>/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '<span id="img_analysis_f_1_'.$spid.'" class="img_analysis_f displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'1\');">&nbsp(<span class="blue">f&nbsp;</span>/&nbsp;%)</a></span>';
+ echo '<span id="img_analysis_p_1_'.$spid.'" class="img_analysis_p displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'0\');">&nbsp(f&nbsp;/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_valid'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_num_units'].'</td>';
+ echo '</tr>';
+
+ $bck_css = ' anl_bck_desc_2';
+ $_variables = self::$_HEADERS[$spid]['grids'][$gid]['variables'];
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb'.$bck_css .'">&nbsp;</td>';
+ if (self::$_SHOW_LEGENDA) {
+
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ echo '<td class="anl_bb anl_br anl_ac anl_legend anl_legenda_freq'.$bck_css.'">'.$_tip.'</td>';
+ echo '<td class="anl_bb anl_br anl_ac anl_legend anl_legenda_freq'.$bck_css.'">'.$_oblika.'</td>';
+ }
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ echo '<td class="anl_bb anl_ac anl_dash_br'.$bck_css.'">' . $variable['naslov'] . '</td>';
+ }
+ }
+ echo '<td class="anl_bb anl_bl anl_br anl_ac'.$bck_css.'">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br anl_ac'.$bck_css.'">&nbsp;</td>';
+ echo '</tr>';
+ # vodoravna vrstice s podatki
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'">';
+ echo '<td class="anl_br anl_bt anl_ar anl_ita gray anl_dash_bb" colspan="'.(self::$_SHOW_LEGENDA ? 3 : 1).'">'.$lang['srv_analiza_frekvence_titleFrekvenca'].'</td>';
+ // prikaz frekvenc
+ foreach ($_variables AS $vkey => $variable) {
+
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+ $cnt = self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ echo '<td class="anl_p5 anl_bt anl_ac anl_dash_br anl_dash_bb">'.$cnt.'</td>';
+ }
+ }
+ echo '<td class="anl_bt anl_bl anl_ac anl_bb">'.$_valid_cnt.'</td>';
+ echo '<td class="anl_bt anl_bl anl_ac anl_bb anl_br">'.$_approp_cnt.'</td>';
+ echo '</tr>';
+
+ // dodamo še veljavne procente
+ echo '<tr name="single_sums_percent_'.$spid.'" >';
+ echo '<td class="anl_br anl_dash_bb anl_ar anl_ita gray" colspan="'.(self::$_SHOW_LEGENDA ? 3 : 1).'">'.$lang['srv_analiza_frekvence_titleOdstotekVeljavni'].'</td>';
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+ $cnt = self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $percent = ( $_valid_cnt > 0) ? 100*$cnt / $_valid_cnt : 0;
+ echo '<td class="anl_p5 anl_ac anl_dash_br anl_dash_bb">'.self::formatNumber($percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').'</td>';
+ }
+ }
+ echo '<td class="anl_bl">&nbsp;</td>';
+ echo '<td>&nbsp;</td>';
+ echo '</tr>';
+
+ // dodamo še procente
+ echo '<tr name="single_sums_percent_'.$spid.'" >';
+ echo '<td class="anl_br anl_ar anl_ita gray anl_bb" colspan="'.(self::$_SHOW_LEGENDA ? 3 : 1).'">'.$lang['srv_analiza_frekvence_titleOdstotekEnote'].'</td>';
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+ $cnt = self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $percent = ( $_approp_cnt > 0) ? 100*$cnt / $_approp_cnt : 0;
+ echo '<td class="anl_p5 anl_ac anl_dash_br anl_bb">'.self::formatNumber($percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').'</td>';
+ }
+ }
+ echo '<td class="anl_bl">&nbsp;</td>';
+ echo '<td>&nbsp;</td>';
+ echo '</tr>';
+
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ static function sumVerticalCheckbox($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $all_categories_cnt = 0;
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 ) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $all_categories_cnt++;
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ $_answersOther = array();
+
+ $inline_legenda = count ($spremenljivka['grids']) > 1;
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ # ugotovimo koliko imamo kolon
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_clmn_cnt[$gid] = $grid['cnt_vars']-$grid['cnt_other'];
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ $_valid_cnt[$gid] = max($_valid_cnt[$gid], self::$_FREQUENCYS[$_sequence]['validCnt']);
+ $_approp_cnt[$gid] = max($_approp_cnt[$gid], self::$_FREQUENCYS[$_sequence]['allCnt']);
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $_valid[$gid][$vid] = self::$_FREQUENCYS[$_sequence]['valid'];
+ $_navedbe[$gid] += self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ }
+ }
+ $veljavni_percent = ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16) ? true : false;
+
+ $css_txt = 'anl_variabla_line';
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ echo '<div id="div_navedbe_1_'.$spid.'">';
+ echo '<table class="anl_tbl anl_bt anl_br tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA && $inline_legenda ? 7+(int)$veljavni_percent : 5+(int)$veljavni_percent).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span> <span class="anl_variabla_info">('.$lang['srv_info_checkbox'].')</span>';
+ if (self::$_SHOW_LEGENDA && !$inline_legenda) {
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type">&nbsp;&nbsp;<span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '<span name="span_show_navedbe_2_'.$spid.'" class="span_navedbe"><a href="javascript:show_navedbe(\''.$spid.'\',\'2\');">&nbsp;(<span class="blue" title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '<span name="span_show_navedbe_3_'.$spid.'" class="span_navedbe displayNone"><a href="javascript:show_navedbe(\''.$spid.'\',\'1\');">&nbsp;(<span title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span class="blue" title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '</td>';
+ echo '</tr>';
+ $css_txt = 'anl_variabla_line';
+
+ echo '<tr>';
+ echo '<td class="anl_p5 anl_bl anl_br anl_ac anl_bck anl_bb anl_w110 '.$css_txt.'">';
+ self::showIcons($spid,$spremenljivka,$_from, array('navedbe'=>false));
+ echo '</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb '.$css_txt.'" style="width:280px">'.$lang['srv_analiza_opisne_subquestion'].'</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda) {
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb anl_w70 '.$css_txt.'">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb anl_w110 '.$css_txt.'">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb anl_w70 '.$css_txt.'">'.$lang['srv_analiza_opisne_frequency'].'</td>';
+
+ echo '<td class="anl_p5 anl_ac anl_dash_br anl_bck anl_bb anl_w70 '.$css_txt.'">'.$lang['srv_analiza_opisne_valid'].'</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb anl_w70 '.$css_txt.'">% - '.$lang['srv_analiza_opisne_valid'].'</td>';
+
+ echo '<td class="anl_p5 anl_'.($veljavni_percent?'dash_':'').'br anl_ac anl_bck anl_bb anl_w70 '.$css_txt.'">'.$lang['srv_analiza_num_units_valid'].'</td>';
+ if ($veljavni_percent) {
+ echo '<td class="anl_p5 anl_ac anl_bck anl_bb anl_w70 '.$css_txt.'">% - '.$lang['srv_analiza_num_units_valid'].'</td>';
+ }
+ echo '</tr>';
+
+ $cssBack = "anl_bck anl_variabla_line ";
+
+ $_max_valid = 0;
+ $_max_appropriate = 0;
+ if (count ($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] as $gid => $grid) {
+ $_max_valid = 0;
+ $_max_appropriate = 0;
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ #po potrebi prikažemo samo tiste ki imajo vrednosti
+ if (($all_categories_cnt <= AUTO_HIDE_ZERRO_VALUE) || (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] > 0 )
+ if ($variable['other'] != 1) {
+
+
+ # dodamo labele podvprašanja
+ if ($spremenljivka['tip'] == 16 && (($vid == 0 && $gid != 0) || ($vid == 0 && $gid == 0))) {
+ $cssBack = "anl_bck_desc_2 ".($vid == 0 && $gid != 0 ? 'anl_double_bt ' : '');
+ echo '<tr>';
+ echo '<td class="'.$cssBack.'anl_bl anl_br anl_bb anl_ac anl_variabla_sub">'.$grid['variable'].'</td>';
+ echo '<td class="'.$cssBack.'anl_br anl_bb" colspan="'.(self::$_SHOW_LEGENDA && $inline_legenda ? 7+(int)$veljavni_percent : 5+(int)$veljavni_percent ).'">'.$grid['naslov'].'</td>';
+ echo '</tr>';
+ }
+ $cssBack = "anl_bck_desc_2 ";
+ echo '<tr id="'.$spid.'_'.$_sequence.'" name="valid_row_'.$_sequence.'" vkey="1">';
+ echo '<td class="anl_p5 anl_tin1 '.$cssBack.'anl_bl anl_br anl_bb anl_ac anl_variabla_sub">'.$variable['variable'].'</td>';
+ echo '<td class="anl_p5 anl_tin1 '.$cssBack.'anl_br anl_bb">'.$variable['naslov'].'</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda) {
+ echo '<td class="anl_p5 '.$cssBack.'anl_br anl_bb anl_ac">'.$_tip.'</td>';
+ echo '<td class="anl_p5 '.$cssBack.'anl_br anl_bb anl_ac">'.$_oblika.'</td>';
+ }
+ echo '<td class="anl_p5 anl_bb anl_ac anl_br '.$cssBack.( self::$enableInspect == true ? ' fr_inspect' : '').'" >';
+ echo (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ echo '</td>';
+
+ $_max_appropriate = max($_max_appropriate, (int)self::$_FREQUENCYS[$_sequence]['allCnt']);
+ $_max_valid = max ($_max_valid, ((int)(self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)self::$_FREQUENCYS[$_sequence]['valid']['0']['cnt'])));
+
+ # veljavno
+ echo '<td class="anl_p5 anl_dash_br anl_ac anl_bb '.$cssBack.'">';
+ echo (int)(self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)self::$_FREQUENCYS[$_sequence]['valid']['0']['cnt']);
+ echo '</td>';
+ echo '<td class="anl_p5 anl_bb anl_br anl_ac '.$cssBack.'" >';
+ $_percent = (self::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] / self::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ #ustrezno
+ echo '<td class="anl_p5 anl_'.($veljavni_percent?'dash_':'').'br anl_ac anl_bb '.$cssBack.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['allCnt'];
+ echo '</td>';
+ # veljavno %
+ if ($veljavni_percent) {
+
+ $valid = (int)(self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)self::$_FREQUENCYS[$_sequence]['valid']['0']['cnt']);
+ $valid = (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $_percent = ($_max_appropriate > 0 ) ? 100*$valid / $_max_appropriate : 0;
+
+ echo '<td class="anl_p5 anl_br anl_ac anl_bb '.$cssBack.'">';
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ }
+ echo '</tr>';
+
+ } else {
+ # drugo
+ }
+ }
+ $cssBack = " anl_bck_2 red";
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb anl_al anl_ita'.$cssBack.'" >&nbsp;</td>';
+ echo '<td class="anl_p5 anl_tin1 anl_br anl_bl anl_bb anl_al anl_ita'.$cssBack.'" colspan="'.(self::$_SHOW_LEGENDA && $inline_legenda ? 3 : 1).'">'.$lang['srv_anl_suma_valid'].'</td>';
+ echo '<td class="anl_bb anl_ac anl_br anl_ita'.$cssBack.'" >&nbsp;</td>'; //.$_approp_cnt[$gid].
+ echo '<td class="anl_p5 anl_ac anl_dash_br anl_bb anl_ita'.$cssBack.'">'.$_max_valid.'</td>';
+ echo '<td class="anl_bb anl_br'.$cssBack.'">&nbsp;</td>'; //.self::formatNumber('100',SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%')
+
+
+ echo '<td class="anl_p5 anl_'.($veljavni_percent?'dash_':'').'br anl_ac anl_bb anl_ita'.$cssBack.'">'.$_max_appropriate.'</td>'; //$lang['srv_anl_suma_entries']
+ if ($veljavni_percent) {
+ $_percent = ($_max_appropriate > 0 ) ? 100*$_max_valid / $_max_appropriate : 0;
+ echo '<td class="anl_p5 anl_br anl_ac anl_bb anl_ita'.$cssBack.'">';
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ }
+ echo '</tr>';
+
+ }
+ echo '</table>';
+ echo '</div>'; // div_navedbe_1_'.$spid.'
+
+ # še navedbe
+ echo '<div id="div_navedbe_2_'.$spid.'" class="div_navedbe displayNone">';
+ echo '<table class="anl_tbl anl_bt anl_br tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA && $inline_legenda? 5 : 3).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA && !$inline_legenda) {
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type">&nbsp;&nbsp;<span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '<span name="span_show_navedbe_2_'.$spid.'" class="span_navedbe"><a href="javascript:show_navedbe(\''.$spid.'\',\'2\');">&nbsp;(<span class="blue" title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '<span name="span_show_navedbe_3_'.$spid.'" class="span_navedbe displayNone"><a href="javascript:show_navedbe(\''.$spid.'\',\'1\');">&nbsp;(<span title="'.$lang['srv_enote_navedbe_1'].'">'.$lang['srv_analiza_opisne_units'].'&nbsp;</span>/<span class="blue" title="'.$lang['srv_enote_navedbe_2'].'">&nbsp;'.$lang['srv_analiza_opisne_arguments'].'</span>)</a></span>';
+ echo '</td>';
+ echo '</tr>';
+ $css_txt = 'anl_variabla_line';
+ echo '<tr>';
+ echo '<td class="anl_p5 anl_bl anl_br anl_ac anl_bck anl_bb anl_w110 '.$css_txt.'">';
+ self::showIcons($spid,$spremenljivka,$_from, array('navedbe'=>true));
+ echo '</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb '.$css_txt.'" style="width:280px">'.$lang['srv_analiza_opisne_subquestion'].'</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda) {
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb anl_w70 '.$css_txt.'">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb anl_w110 '.$css_txt.'">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_p5 anl_dash_br anl_ac anl_bck anl_bb '.$css_txt.'">'.$lang['srv_analiza_opisne_frequency'].'</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb '.$css_txt.'">%</td>';
+ echo '</td>';
+ echo '</tr>';
+
+ $cssBack = "anl_bck anl_variabla_line ";
+
+ if (count ($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] as $gid => $grid) {
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ #po potrebi prikažemo samo tiste ki imajo vrednosti
+ if (($all_categories_cnt <= AUTO_HIDE_ZERRO_VALUE) || (int)self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] > 0 )
+ if ($variable['other'] != 1) {
+
+ # dodamo labele podvprašanja
+ if ($spremenljivka['tip'] == 16 && (($vid == 0 && $gid != 0) || ($vid == 0 && $gid == 0))) {
+ $cssBack = 'anl_bck_desc_2'.($vid == 0 && $gid != 0 ? ' anl_double_bt ' : '');
+ echo '<tr>';
+ echo '<td class="anl_p5 '.$cssBack.' anl_bl anl_br anl_bb anl_ac anl_variabla_sub">'.$grid['variable'].'</td>';
+ echo '<td class="anl_p5 '.$cssBack.' anl_br anl_bb"'.(self::$_SHOW_LEGENDA && $inline_legenda ? ' colspan="5"' : ' colspan="3"' ).'>'.$grid['naslov'].'</td>';
+ echo '</tr>';
+ }
+ $cssBack = "anl_bck_desc_2 ";
+ echo '<tr>';
+ echo '<td class="anl_p5 anl_tin1 '.$cssBack.'anl_bl anl_br anl_bb anl_ac anl_variabla_sub">'.$variable['variable'].'</td>';
+ echo '<td class="anl_p5 anl_tin1 '.$cssBack.'anl_br anl_bb">'.$variable['naslov'].'</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda) {
+ echo '<td class="anl_p5 '.$cssBack.'anl_br anl_bb anl_ac">'.$_tip.'</td>';
+ echo '<td class="anl_p5 '.$cssBack.'anl_br anl_bb anl_ac">'.$_oblika.'</td>';
+ }
+
+ echo '<td class="anl_p5 anl_dash_br anl_ac anl_bb '.$cssBack.'">'. self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'].'</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bb '.$cssBack.'">';
+ $_percent = ($_navedbe[$gid] > 0 ) ? 100*self::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] / $_navedbe[$gid] : 0;
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr>';
+
+ } else {
+ # drugo
+ }
+ }
+ $cssBack = " anl_bck_2 red";
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb anl_al anl_ita'.$cssBack.'" >&nbsp;</td>';
+ echo '<td class="anl_p5 anl_tin1 anl_bl anl_br anl_bb anl_al anl_ita'.$cssBack.'" colspan="'.(self::$_SHOW_LEGENDA && $inline_legenda ? 3 : 1).'">'.$lang['srv_anl_suma_valid'].'</td>';
+ echo '<td class="anl_p5 anl_dash_br anl_ac anl_bb anl_ita'.$cssBack.'">'.$_navedbe[$gid].'</td>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bb anl_ita'.$cssBack.'">'.self::formatNumber('100',SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').'</td>';
+ echo '</tr>';
+
+ }
+ echo '</table>';
+ echo '</div>'; // Konec div_navedbe_2_$spid
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+
+ }
+
+ /** Izriše sumarnik v horizontalni obliki za multigrid
+ *
+ * @param unknown_type $spid - spremenljivka ID
+ */
+ static function sumHorizontal($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ #$_invalidAnswers = self :: getInvalidAnswers (MISSING_TYPE_FREQUENCY);
+ $_invalidAnswers = self :: getInvalidAnswers (MISSING_TYPE_DESCRIPTOR);
+ #$_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+
+ # opcije nareedimo posebej, da po potrebi zajamemo tudi misinge
+ $str_qry = "SELECT id, spr_id, REPLACE(REPLACE(REPLACE(naslov,'\n',' '),'\r','<br>'),'|',' ') as naslov, variable, other, part, REPLACE(REPLACE(REPLACE(naslov_graf,'\n',' '),'\r','<br>'),'|',' ') as naslov_graf, vrstni_red FROM srv_grid WHERE spr_id='".$spid."' ORDER BY vrstni_red";
+ $qry = sisplet_query($str_qry);
+ while ($row = mysqli_fetch_assoc($qry)) {
+ if ($row['other'] != 0 && !isset($_invalidAnswers[$row['other']])) {
+ # če prikazujemo misinge dodamo -99 kot mising
+ $spremenljivka['options'][$row['other']] = $row['naslov'];
+ }
+ }
+
+ $_answersOther = array();
+ $_clmn_cnt = count($spremenljivka['options']);
+
+ # pri razvrščanju dodamo dva polja za povprečje in odklon
+ $additional_field = false;
+ $add_fld = 0;
+
+ if ($spremenljivka['tip'] == 17 || $spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3 || ($spremenljivka['tip'] == 6 && $spremenljivka['skala'] != 1)) {
+ $additional_field = true;
+ $add_fld = 2;
+ }
+
+ # pri radiu in dropdown ne prikazujemo podvprašanj
+ $_sub_question_col = 1;
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ $_sub_question_col = 0;
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ echo '<table class="anl_tbl anl_ba tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_bck_desc_1">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_al anl_bck anl_bb anl_bck_desc_1" colspan="'. ($_clmn_cnt+$add_fld+(self::$_SHOW_LEGENDA ? 5+$_sub_question_col : 3+$_sub_question_col)) .'">';
+ echo '<span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ $css_txt = 'anl_variabla_line';
+
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ if ($_sub_question_col) {
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb '.$css_txt.'" style="width:280px">'.$lang['srv_analiza_opisne_subquestion'].'</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line" colspan="'.($_clmn_cnt+1).'">'.$lang['srv_analiza_opisne_answers'];
+ echo '<span id="img_analysis_f_p_1_'.$spid.'" class="img_analysis_f_p"><a href="javascript:show_single_percent(\''.$spid.'\',\'2\');">&nbsp(<span class="blue">f&nbsp;</span>/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '<span id="img_analysis_f_1_'.$spid.'" class="img_analysis_f displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'1\');">&nbsp(<span class="blue">f&nbsp;</span>/&nbsp;%)</a></span>';
+ echo '<span id="img_analysis_p_1_'.$spid.'" class="img_analysis_p displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'0\');">&nbsp(f&nbsp;/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_valid'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_num_units'].'</td>';
+ if ($additional_field) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_povprecje'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_odklon'].'</td>';
+ }
+ echo '</tr>';
+
+ $cssBack = "anl_bck_0_0 ";
+ $_variables = $grid['variables'];
+ echo '<tr>';
+ echo '<td class="anl_tin ' . $cssBack . 'anl_bl anl_br anl_bb">&nbsp;</td>';
+ if ( $_sub_question_col ) {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">&nbsp;</td>'; //$_tip
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">&nbsp;</td>'; // $_oblika
+ }
+
+ //nastavitve iz baze za ureditev pravilnega izrisa analize za tabelo s trakom
+ $row = Cache::srv_spremenljivka($spid);
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0);
+ $diferencial_trak_starting_num = ($spremenljivkaParams->get('diferencial_trak_starting_num') ? $spremenljivkaParams->get('diferencial_trak_starting_num') : 0);
+ //nastavitve iz baze za ureditev pravilnega izrisa analize za tabelo s trakom
+
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ if($diferencial_trak){ //ce je trak, je potrebno naslove stolpcev spremeniti v vrednosti na traku
+ $_label = $diferencial_trak_starting_num;
+ $diferencial_trak_starting_num++;
+ }else{
+ // misinge imamo zdruzene
+ $_label = $kategorija;
+ }
+
+ echo '<td class="' . $cssBack . ' anl_bb anl_ac anl_dash_br ">'.$_label.'</td>';
+ }
+ }
+
+ echo '<td class="' . $cssBack . ' anl_bb anl_br anl_ac red anl_w70">'.$lang['srv_anl_suma1'].'</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ if ($additional_field) {
+
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ }
+ echo '</tr>';
+
+
+ $part=null;
+ #zlopamo skozi gride
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ # za dvojne gride
+ if ((int)$grid['part'] > 0) {
+ if ($part == null || $part == $grid['part'] ) {
+ $part_css = '';
+ } else {
+ $part_css = ' anl_double_bt ';
+ }
+ $part = $grid['part'];
+ }
+ else {
+ $part_css = '';
+ }
+
+ $cssBack = "anl_bck_desc_2 ";
+ # zloopamo skozi variable
+ if (count($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ) {
+ $_sequence = $variable['sequence'];
+ #popotrebi izpisujemo samo veljavne
+ if ((count($spremenljivka['grids']) <= AUTO_HIDE_ZERRO_VALUE ||
+ (self::$_FREQUENCYS[$_sequence]['allCnt'] - self::$_FREQUENCYS[$_sequence]['invalidCnt']) > 0))
+ if ($variable['other'] != true) {
+ echo '<tr id="'.$spid.'_'.$_sequence.'"'.($part_css != '' ? ' class="'.$part_css.'"' : '').'>';
+ if ($_sub_question_col) {
+ echo '<td class="anl_tin1 ' . $cssBack . 'anl_bl anl_br anl_bb anl_ac anl_variabla_sub">';
+
+ echo $variable['variable'];
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">';
+
+ echo $variable['naslov'];
+
+ // dodatek desne strani sem. diferenciala
+ echo ($spremenljivka['enota'] == 1) ? ' - '.$variable['naslov2'] : '';
+ echo '</td>';
+ } else {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">'.$_tip.'</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">'.$_oblika.'</td>';
+ }
+ # za odklon in povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ if ($additional_field) { # za odklon in povprečje
+ $xi = $key;
+ $fi = self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ }
+ echo '<td class="anl_bb anl_dash_br anl_ac cll_clps ' . $cssBack . '">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac'.(self::$enableInspect == true && (int)self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'] > 0 ? ' mg_inspect' : '').'"'
+ .(self::$enableInspect == true && (int)self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'] > 0 ? ' vkey="'.$key.'"' : '')
+ .' style="padding:5px 0px;">'.self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'].'</td>';
+ echo '</tr><tr name="single_sums_percent_'.$spid.'">';
+ echo '<td style="padding:5px 0px;">';
+ $_percent = (self::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'] * 100 / self::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr></table>';
+ echo '</td>';
+
+
+ }
+ }
+ // suma
+ echo '<td class="anl_bb anl_br anl_ac cll_clps ' . $cssBack . '">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac red" style="padding:5px 0px;">'.((int)self::$_FREQUENCYS[$_sequence]['validCnt']).'</td>';
+ echo '</tr><tr name="single_sums_percent_'.$spid.'">';
+ echo '<td class="red" style="padding:5px 0px;">'.self::formatNumber(100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').'</td>';
+ echo '</tr></table>';
+ echo '</td>';
+ // zamenjano veljavni ustrezni
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac" >';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ echo '</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac" >'.(int)self::$_FREQUENCYS[$_sequence]['allCnt'].'</td>';
+ if ($additional_field) { # za odklon in povprečje
+ # povprečje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $xi => $kategorija) {
+ $fi = self::$_FREQUENCYS[$_sequence]['valid'][$xi]['cnt'];
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ }
+ $div = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac" >';
+ echo self::formatNumber($avg,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac" >';
+ echo self::formatNumber($div,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ echo '</td>';
+ }
+ echo '</tr>';
+
+ } else {
+ # immamo polje drugo
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** Izriše sumarnik v horizontalni obliki za dvojni multigrid
+ *
+ * @param unknown_type $spid - spremenljivka ID
+ */
+ static function sumDoubleHorizontal($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ $_answersOther = array();
+ $_clmn_cnt = count($spremenljivka['options'])*2;
+
+ # pri radiu in dropdown ne prikazujemo podvprašanj
+ $_sub_question_col = 6;
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ echo '<table class="anl_tbl anl_ba tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_bck_desc_1">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_br anl_al anl_bck anl_bb anl_bck_desc_1" colspan="'. ($_clmn_cnt+2+$_sub_question_col+(self::$_SHOW_LEGENDA ? 2 : 0)) .'">';
+ echo '<span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ $css_txt = 'anl_variabla_line';
+
+ echo '<tr>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ if ($_sub_question_col) {
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck anl_bb '.$css_txt.'" style="width:280px">'.$lang['srv_analiza_opisne_subquestion'].'</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w110 anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line" colspan="'.($_clmn_cnt+6).'">'.$lang['srv_analiza_opisne_answers'];
+ echo '<span id="img_analysis_f_p_1_'.$spid.'" class="img_analysis_f_p"><a href="javascript:show_single_percent(\''.$spid.'\',\'2\');">&nbsp(<span class="blue">f&nbsp;</span>/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '<span id="img_analysis_f_1_'.$spid.'" class="img_analysis_f displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'1\');">&nbsp(<span class="blue">f&nbsp;</span>/&nbsp;%)</a></span>';
+ echo '<span id="img_analysis_p_1_'.$spid.'" class="img_analysis_p displayNone"><a href="javascript:show_single_percent(\''.$spid.'\',\'0\');">&nbsp(f&nbsp;/<span class="blue">&nbsp;%</span>)</a></span>';
+ echo '</td>';
+ #št. enot
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_variabla_line" >&nbsp;</td>';
+ echo '</tr>';
+ #naslovi podskupin
+ $cssBack = "anl_bck_0_0 ";
+ $_variables = $grid['variables'];
+ echo '<tr>';
+ echo '<td class="anl_tin ' . $cssBack . 'anl_bl anl_br anl_bb">&nbsp;</td>';
+ if ( $_sub_question_col ) {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">&nbsp;</td>'; //$_tip
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">&nbsp;</td>'; // $_oblika
+ }
+ echo '<td class="' . $cssBack . ' anl_bb anl_ac anl_br" colspan="'.(count($spremenljivka['options'])+3).'">'.($spremenljivka['double'][1]['subtitle'] == '' ? $lang['srv_grid_subtitle_def'].' 1' : $spremenljivka['double'][1]['subtitle']).'</td>';
+ echo '<td class="' . $cssBack . ' anl_bb anl_ac anl_br" colspan="'.(count($spremenljivka['options'])+3).'">'.($spremenljivka['double'][2]['subtitle'] == '' ? $lang['srv_grid_subtitle_def'].' 2' : $spremenljivka['double'][2]['subtitle']).'</td>';
+ #št. enot
+ echo '<td class="' . $cssBack . ' anl_bb anl_ac anl_br" >&nbsp;</td>';
+
+ echo '</tr>';
+
+ # naslovi variabel
+ $cssBack = "anl_bck_0_0 ";
+ $_variables = $grid['variables'];
+ echo '<tr>';
+ echo '<td class="anl_tin ' . $cssBack . 'anl_bl anl_br anl_bb">&nbsp;</td>';
+ if ( $_sub_question_col ) {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">&nbsp;</td>'; //$_tip
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">&nbsp;</td>'; // $_oblika
+ }
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ // misinge imamo zdruzene
+ $_label = $kategorija;
+ echo '<td class="' . $cssBack . ' anl_bb anl_ac anl_dash_br ">'.$_label.'</td>';
+ }
+ }
+ echo '<td class="' . $cssBack . ' anl_bb anl_br anl_ac red anl_w70">'.$lang['srv_anl_suma1'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_povprecje'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_odklon'].'</td>';
+
+
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ // misinge imamo zdruzene
+ $_label = $kategorija;
+ echo '<td class="' . $cssBack . ' anl_bb anl_ac anl_dash_br ">'.$_label.'</td>';
+ }
+ }
+ echo '<td class="' . $cssBack . ' anl_bb anl_br anl_ac red anl_w70">'.$lang['srv_anl_suma1'].'</td>';
+ echo '<td class="' . $cssBack . ' anl_bb anl_br anl_ac anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_povprecje'].'</td>';
+ echo '<td class="' . $cssBack . ' anl_bb anl_br anl_ac anl_w70 anl_variabla_line">'.$lang['srv_analiza_opisne_odklon'].'</td>';
+
+ # št enot
+ echo '<td class="' . $cssBack . ' anl_bb anl_br anl_ac anl_w70 anl_variabla_line">'.$lang['srv_analiza_num_units'].'</td>';
+
+ echo '</tr>';
+ #zloopamo skozi gride in nardimo
+ $_tmp_table = array();
+ $_part = 1;
+ $cnt = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if ( $_part == $grid['part'] ) {
+ $cnt++;
+ } else {
+ $_part = $grid['part'];
+ $cnt = 1;
+ }
+ # zloopamo skozi variable
+ if (count($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ) {
+
+ $_sequence = $variable['sequence'];
+ if ($variable['other'] != true) {
+ # za odklon in povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ $xi = $key;
+ $fi = self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+
+ $_percent = (self::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'] * 100 / self::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_tmp_table[$grid['part']][$cnt]['variables'][] = array('key'=>$key, 'freq'=>self::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'],'percent'=>$_percent);
+ }
+ }
+ $_tmp_table[$grid['part']][$cnt]['seq'] = $variable['seq'];
+ $_tmp_table[$grid['part']][$cnt]['vr_id'] = $variable['vr_id'];
+ $_tmp_table[$grid['part']][$cnt]['variable'] = substr($variable['variable'], 0, strrpos($variable['variable'], "_"));
+ $_tmp_table[$grid['part']][$cnt]['naslov'] = $variable['naslov'];
+ $_tmp_table[$grid['part']][$cnt]['suma'] = self::$_FREQUENCYS[$_sequence]['validCnt'];
+ $_tmp_table[$grid['part']][$cnt]['allCnt'] = (int)self::$_FREQUENCYS[$_sequence]['allCnt'];
+
+ # odklon
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $xi => $kategorija) {
+ $fi = self::$_FREQUENCYS[$_sequence]['valid'][$xi]['cnt'];
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ }
+ $div = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+ $_tmp_table[$grid['part']][$cnt]['avg'] = $avg;
+ $_tmp_table[$grid['part']][$cnt]['div'] = $div;
+ } //end if ($variable['other'] != true)
+ } // end foreach variables
+ }
+ }
+ }
+
+
+
+ #zlopamo skozi gride
+ if (count($_tmp_table[1]) > 0) {
+ foreach ($_tmp_table[1] AS $tkey => $grid) {
+ $cssBack = "anl_bck_desc_2 ";
+ echo '<tr id="'.$spid.'_'.$grid['vr_id'].'">';
+ if ($_sub_question_col) {
+ echo '<td class="anl_tin1 ' . $cssBack . 'anl_bl anl_br anl_bb anl_ac anl_variabla_sub">'.$grid['variable'].'</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">'.$grid['naslov'].'</td>';
+ } else {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb">&nbsp;</td>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">'.$_tip.'</td>';
+ echo '<td class="anl_p5 ' . $cssBack . 'anl_br anl_bb anl_ac">'.$_oblika.'</td>';
+ }
+
+ # zloopamo skozi variable
+ if (count($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ) {
+ #mg_inspectž
+ echo '<td class="anl_bb anl_dash_br anl_ac cll_clps '.$cssBack.'">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac'.(self::$enableInspect == true && (int)$variable['freq'] > 0 ? ' dmg_inspect' : '').'" style="padding:5px 0px;"'.(self::$enableInspect == true && (int)$variable['freq'] > 0 ? ' gid="'.$variable['key'].'_1"' : '').'>'.$variable['freq'].'</td>';
+ echo '</tr><tr name="single_sums_percent_'.$spid.'">';
+ echo '<td style="padding:5px 0px;">';
+ echo self::formatNumber($variable['percent'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr></table>';
+ echo '</td>';
+ } // end foreach variables
+ } // end if (count($grid['variables']) > 0)
+ // suma
+ echo '<td class="anl_bb anl_br anl_ac cll_clps ' . $cssBack . '">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac red" style="padding:5px 0px;">'.(int)$grid['suma'].'</td>';
+ echo '</tr><tr name="single_sums_percent_'.$spid.'">';
+ echo '<td class="red" style="padding:5px 0px;">'.self::formatNumber(100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').'</td>';
+ echo '</tr></table>';
+ echo '</td>';
+
+ // povpreje
+ echo '<td class="anl_bb anl_br anl_ac ' . $cssBack . '" >';
+ echo self::formatNumber($grid['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+
+ // odklon
+ echo '<td class="anl_bb anl_br anl_ac ' . $cssBack . '" >';
+ echo self::formatNumber($grid['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+
+ # dodamo desni del grida
+ $_right_grid = $_tmp_table[2][$tkey];
+ if (count($_right_grid['variables']) > 0) {
+ foreach ($_right_grid['variables'] AS $vid => $variable ) {
+ echo '<td class="anl_bb anl_dash_br anl_ac cll_clps '.$cssBack.'">';
+ #mg_inspect
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac'.(self::$enableInspect == true && (int)$variable['freq'] > 0 ? ' dmg_inspect' : '').'" style="padding:5px 0px;"'.(self::$enableInspect == true && (int)$variable['freq'] > 0 ? ' gid="'.$variable['key'].'_2"' : '').'>'.$variable['freq'].'</td>';
+ echo '</tr><tr name="single_sums_percent_'.$spid.'">';
+ echo '<td style="padding:5px 0px;">';
+ echo self::formatNumber($variable['percent'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '</td>';
+ echo '</tr></table>';
+ echo '</td>';
+ } // end foreach variables
+ } // end if (count($grid['variables']) > 0)
+ // suma
+ echo '<td class="anl_bb anl_br anl_ac cll_clps '.$cssBack.'">';
+ echo '<table class="fullWidth anl_ac tbl_clps">';
+ echo '<tr name="single_sums_percent_cnt_'.$spid.'" class="anl_dash_bb">';
+ echo '<td class="anl_ac red" style="padding:5px 0px;">'.(int)$_right_grid['suma'].'</td>';
+ echo '</tr><tr name="single_sums_percent_'.$spid.'">';
+ echo '<td class="red" style="padding:5px 0px;">'.self::formatNumber(100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').'</td>';
+ echo '</tr></table>';
+ echo '</td>';
+
+ // povpreje
+ echo '<td class="anl_bb anl_br anl_ac ' . $cssBack . '" >';
+ echo self::formatNumber($_right_grid['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+
+ # odklon
+ echo '<td class="anl_bb anl_br anl_ac ' . $cssBack . '" >';
+ echo self::formatNumber($_right_grid['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+
+ # št enot
+ echo '<td class="anl_bb anl_br anl_ac ' . $cssBack . '" >';
+ echo $grid['allCnt'];
+ echo '</td>';
+ echo '</tr>';
+ } // end foreach ($_tmp_table[1] AS $tkey => $grid)
+ }
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+
+ }
+
+ /** Izriše multi number odgovore. izpiše samo povprečja
+ *
+ * @param unknown_type $spid
+ */
+ static function sumMultiNumber($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_bb tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA ? 3+$_cols : 1+$_cols).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck anl_w110">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ #odgovori
+
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">'.$lang['srv_analiza_opisne_subquestion'] . '</td>';
+ if (self::$_SHOW_LEGENDA){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line" colspan="'.($_cols).'">'. $lang['srv_analiza_sums_average'] .'</td>';
+
+ echo '</tr>';
+ // konec naslovne vrstice
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0) {
+ # naslovna vrstica
+ $_row = $spremenljivka['grids'][0];
+ echo '<tr>';
+ echo '<td class="anl_bl anl_bb anl_bck">&nbsp;</td>';
+ echo '<td class="anl_bl anl_br anl_bb anl_bck">&nbsp;</td>';
+
+ if (self::$_SHOW_LEGENDA){
+ echo '<td class="anl_br anl_bb anl_bck">&nbsp;</td>';
+ echo '<td class="anl_br anl_bb anl_bck">&nbsp;</td>';
+ }
+ if (count($_row['variables']) > 0 )
+ foreach ($_row['variables'] AS $rid => $_col ){
+ $_sequence = $_col['sequence']; # id kolone z podatki
+
+ if ($_col['other'] != true) {
+ echo '<td class="anl_br anl_bb anl_bck anl_ac">';
+ // echo $_col['variable'];
+ echo $_col['naslov'];
+ echo '</td>';
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ echo '</tr>';
+ $_css_bck = 'anl_bck_desc_2 anl_ac anl_bt_dot ';
+ $last = 0;
+ //anl_bck_desc_2 anl_bl anl_br anl_variabla_sub
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ echo '<tr class="'.$_css_bck.'">';
+ echo '<td class="anl_bl anl_br anl_variabla_sub">';
+ echo $grid['variable'];
+ echo '</td>';
+ echo '<td class="anl_br anl_al">';
+ echo $grid['naslov'];
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA){
+ echo '<td class="anl_br">'.$_tip.'</td>';
+ echo '<td class="anl_br">'.$_oblika.'</td>';
+ }
+
+ if ($_variables_count > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ if ($variable['other'] != true) {
+ # tabela z navedbami
+ echo '<td class="anl_at anl_br">';
+ echo self::formatNumber(self::$_FREQUENCYS[$_sequence]['average'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+
+ }
+ }
+
+ }
+ echo '</tr>';
+ }
+ }
+ echo '</table>';
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** Izriše multi number odgovore. v Navpični obliki (podobno kot opisne)
+ *
+ * @param unknown_type $spid
+ */
+ static function sumMultiNumberVertical($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (self::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false);
+
+ # ali izpisujemo enoto:
+ $show_enota = true;
+ if ((int)$spremenljivka['enota'] == 0 && self::$_HEADERS[$spid]['cnt_all'] == 1) {
+ $show_enota = false;
+ }
+
+ # ugotovimo koliko imamo kolon
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_clmn_cnt[$gid] = $grid['cnt_vars']-$grid['cnt_other'];
+ if (count($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ $_approp_cnt[$gid] = max($_approp_cnt[$gid], self::$_FREQUENCYS[$_sequence]['allCnt']);
+
+ # za povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ $min = null;
+ $max = null;
+
+ if (count(self::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $xi => $_validFreq) {
+
+ # popravimo morebitne . in -
+ $fnkey = (float)$xi;
+
+ if (is_numeric($xi) && is_numeric($fnkey) && trim($fnkey) != '') {
+ $fi = $_validFreq['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+
+ $min = $min != null ? min($min,$fnkey) : $fnkey;
+ $max = $max != null ? max($max,$fnkey) : $fnkey;
+
+ }
+ }
+ }
+ # povprešje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+
+ self::$_FREQUENCYS[$_sequence]['validAvg'] = $avg;
+ self::$_FREQUENCYS[$_sequence]['validMin'] = $min;
+ self::$_FREQUENCYS[$_sequence]['validMax'] = $max;
+
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ if (count(self::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $xi => $_validFreq) {
+ $fi = $_validFreq['cnt'];
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ }
+ self::$_FREQUENCYS[$_sequence]['validDiv'] = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+ #določimo še polja drugo za kasnejši prikaz
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+ $isSingleGrid = ($spremenljivka['cnt_all'] == $spremenljivka['cnt_grids']) ? true : false;
+
+ # če je cnt_all == cnt_grids pomeni da imamo samo 1 grid
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_br anl_bb tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA ? 7+(int)$inline_legenda*2 : 7).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+
+ if (!$inline_legenda) {
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck">';
+
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+
+
+ if ($show_enota) {
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">';
+ if ($spremenljivka['tip'] == 20 || $spremenljivka['tip'] == 7) {
+ echo $lang['srv_analiza_opisne_subquestion'];
+ } else {
+ echo $lang['srv_analiza_opisne_variable_text'];
+ }
+ echo'</td>';
+ } else { # če mamo number brez labele izrisujemo drugače
+ echo '<td class="anl_br">';
+ echo '&nbsp;';
+ echo'</td>';
+ }
+
+ if (self::$_SHOW_LEGENDA && $inline_legenda){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line" >'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line" >'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_m'] . '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_num_units'] . '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_povprecje'] . '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_odklon'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_min'] . '</td>';
+ echo '<td class="anl_bck anl_ac anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_max'] . '</td>';
+ echo '</tr>';
+
+ $_answersOther = array();
+ $_grupa_cnt = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (count($spremenljivka['grids']) > 1 && $_grupa_cnt !== 0 && $spremenljivka['tip'] != 6) {
+ $grid['new_grid'] = true;
+ }
+
+ $_grupa_cnt ++;
+ if (count($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+
+ $cssBrdr = (int)$grid['new_grid'] == 1 && $isSingleGrid == false? ' anl_double_bt' : ' anl_bt_dot';
+
+ echo '<tr>';
+ if (!$show_enota && $spremenljivka['tip'] == 7) {
+ echo '<td style="border-bottom:1px solid white;">' ;
+ } else {
+ echo '<td class="anl_bck_desc_2 anl_ac anl_bl anl_br anl_variabla_sub'.$cssBrdr.'">' ;
+ }
+ echo $_css_double_line;
+ # za number (7) ne prikazujemo variable
+ if ($spremenljivka['tip'] != 7 ) {
+ echo $variable['variable'];
+ }
+ echo '</td>' ;
+ if (!$show_enota && $spremenljivka['tip'] == 7) {
+ echo '<td style="border-bottom:1px solid white;">' ;
+ } else {
+ echo '<td class="anl_bck_desc_2 anl_al anl_br'.$cssBrdr.'">' ;
+ }
+
+ if ($show_enota) {
+ # če ni enojni grid
+ if ($isSingleGrid == false) {
+ echo (count($grid['variables']) > 1 && $spremenljivka['tip'] == 20 ? $grid['naslov'] . ' - ' : '' ).$variable['naslov'];
+ } else {
+ # če je enojni, izpišemo labele variable
+ echo $grid['naslov'];
+ }
+ } else {
+ echo '&nbsp;';
+ }
+ echo '</td>' ;
+ if (self::$_SHOW_LEGENDA && $inline_legenda) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'" title="'.$_tip.'">'.$_tip.'</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'" title="'.$_oblika.'">' .$_oblika. '</td>';
+ }
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br anl_bl'.$cssBrdr.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo (int)$_approp_cnt[$gid];
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo self::formatNumber(self::$_FREQUENCYS[$_sequence]['validAvg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo self::formatNumber(self::$_FREQUENCYS[$_sequence]['validDiv'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validMin'];
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validMax'];;
+ echo '</td>';
+
+ echo '</tr>';
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $grid['new_grid'] = false;
+ }
+
+ }
+ }
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+ /** Izriše number odgovore v vertikalni obliki
+ *
+ * @param unknown_type $spid
+ */
+ static function sumNumberVertical($spid,$_from) {
+ global $lang;
+ $spremenljivka = self::$_HEADERS[$spid];
+
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (self::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false);
+
+ # ali izpisujemo enoto:
+ $show_enota = true;
+ if (((int)$spremenljivka['enota'] == 0 && self::$_HEADERS[$spid]['cnt_all'] == 1) || $spremenljivka['tip'] == 22 || $spremenljivka['tip'] == 25) {
+ $show_enota = false;
+ }
+ $sum_avg = 0;
+ # ugotovimo koliko imamo kolon
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_clmn_cnt[$gid] = $grid['cnt_vars']-$grid['cnt_other'];
+ if (count($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ $_approp_cnt[$gid] = max($_approp_cnt[$gid], self::$_FREQUENCYS[$_sequence]['allCnt']);
+
+ # za povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+
+ $min = null;
+ $max = null;
+ if (count(self::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $xi => $_validFreq) {
+
+ # popravimo morebitne . in -
+ $fnkey = (float)$xi;
+
+ if (is_numeric($xi) && is_numeric($fnkey) && trim($fnkey) != '') {
+ $fi = $_validFreq['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ $min = $min != null ? min($min,$fnkey) : $fnkey;
+ $max = $max != null ? max($max,$fnkey) : $fnkey;
+ }
+ }
+ }
+
+ #povprečje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $sum_avg += $avg;
+ self::$_FREQUENCYS[$_sequence]['validAvg'] = $avg;
+ self::$_FREQUENCYS[$_sequence]['validMin'] = $min;
+ self::$_FREQUENCYS[$_sequence]['validMax'] = $max;
+
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ if (count(self::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $xi => $_validFreq) {
+ $fi = $_validFreq['cnt'];
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ }
+ self::$_FREQUENCYS[$_sequence]['validDiv'] = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+ #določimo še polja drugo za kasnejši prikaz
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_br anl_bb tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ $num_cols = 7 + ($spremenljivka['tip'] == 18 ? 1 : 0);
+ #odgovori
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA ? $num_cols+(int)$inline_legenda*2 : $num_cols).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+
+ if (!$inline_legenda) {
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+
+
+ if ($show_enota == true) {
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">';
+ if ($spremenljivka['tip'] == 20 || $spremenljivka['tip'] == 7) {
+ echo $lang['srv_analiza_opisne_subquestion'];
+ } else {
+ echo $lang['srv_analiza_opisne_variable_text'];
+ }
+ echo'</td>';
+ } else { # če mamo number brez labele izrisujemo drugače
+ echo '<td class="anl_br">';
+ echo '&nbsp;';
+ echo'</td>';
+ }
+
+ if (self::$_SHOW_LEGENDA && $inline_legenda){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line" >'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line" >'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_m'] . '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_num_units'] . '</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_povprecje'] . '</td>';
+ if ($spremenljivka['tip'] == 18) {
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">%</td>';
+ }
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_odklon'].'</td>';
+ echo '<td class="anl_br anl_ac anl_bck anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_min'] . '</td>';
+ echo '<td class="anl_bck anl_ac anl_bb anl_w70 anl_legend anl_variabla_line">' . $lang['srv_analiza_opisne_max'] . '</td>';
+ echo '</tr>';
+
+ $_answersOther = array();
+ $_grupa_cnt = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (count($spremenljivka['grids']) > 1 && $_grupa_cnt !== 0 && $spremenljivka['tip'] != 6) {
+ $grid['new_grid'] = true;
+ }
+
+ $_grupa_cnt ++;
+ if (count($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+
+ $cssBrdr = (int)$grid['new_grid'] == 1 ? ' anl_double_bt' : ' anl_bt_dot';
+
+ echo '<tr>';
+ if (!$show_enota && $spremenljivka['tip'] == 7) {
+ echo '<td style="border-bottom:1px solid white;">' ;
+ } else {
+ echo '<td class="anl_bck_desc_2 anl_ac anl_bl anl_br anl_variabla_sub'.$cssBrdr.'">' ;
+ }
+ echo $_css_double_line;
+ # za number (7) ne prikazujemo variable
+ if ($spremenljivka['tip'] != 7 || ($show_enota == true && $spremenljivka['tip'] == 7 )) {
+ if ($variable['variable'] == $spremenljivka['variable']) {
+ echo $variable['variable'].'_1';
+ } else {
+ echo $variable['variable'];
+ }
+ }
+ echo '</td>' ;
+ if ((!$show_enota && $spremenljivka['tip'] == 7 ) || $spremenljivka['tip'] == 22 || $spremenljivka['tip'] == 25) {
+ echo '<td style="border-bottom:1px solid white;">' ;
+ } else {
+ echo '<td class="anl_bck_desc_2 anl_al anl_br'.$cssBrdr.'">' ;
+ }
+ if ($show_enota) {
+ echo (count($grid['variables']) > 1 && $spremenljivka['tip'] == 20 ? $grid['naslov'] . ' - ' : '' ).$variable['naslov'];
+ } else {
+ echo '&nbsp;';
+ }
+ echo '</td>' ;
+ if (self::$_SHOW_LEGENDA && $inline_legenda) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'" title="'.$_tip.'">'.$_tip.'</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'" title="'.$_oblika.'">' .$_oblika. '</td>';
+ }
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br anl_bl'.$cssBrdr.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo (int)$_approp_cnt[$gid];
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo self::formatNumber(self::$_FREQUENCYS[$_sequence]['validAvg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+ if ($spremenljivka['tip'] == 18) {
+ $_percent = ($sum_avg > 0 ) ? 100 * self::$_FREQUENCYS[$_sequence]['validAvg'] / $sum_avg : 0;
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'%');
+ echo '</td>';
+ }
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo self::formatNumber(self::$_FREQUENCYS[$_sequence]['validDiv'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ echo '</td>';
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validMin'];
+ echo '<td class="anl_bck_desc_2 anl_ac anl_br'.$cssBrdr.'">';
+ echo (int)self::$_FREQUENCYS[$_sequence]['validMax'];;
+ echo '</td>';
+
+ echo '</tr>';
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $grid['new_grid'] = false;
+ }
+
+ }
+ }
+ if ($spremenljivka['tip'] == 18) {
+ $css_back = 'anl_bck_text_1 anl_bt';
+ echo '<tr>';
+ echo '<td class="'.$css_back.' anl_bl red">';
+ echo $lang['srv_anl_suma1'];
+ echo '</td>';
+ echo '<td class="'.$css_back.'">&nbsp;</td>';
+
+ if (self::$_SHOW_LEGENDA && $inline_legenda){
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ }
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ echo '<td class="'.$css_back.' anl_ac anl_bl anl_br" >';
+ echo self::formatNumber($sum_avg,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ echo '</td>';
+ # skupna suma
+ echo '<td class="'.$css_back.' anl_br anl_ac" >100%</td>';
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ echo '<td class="'.$css_back.'" >&nbsp;</td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** Izriše nagovor
+ *
+ */
+ static function sumNagovor($spid,$_from) {
+ global $lang;
+ $spremenljivka = self::$_HEADERS[$spid];
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ $cssBack = "anl_bck_freq_1 ";
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ echo '<table class="anl_tbl_inner anl_ba" >';
+ echo '<tr>';
+ echo '<td class="anl_p5 anl_br anl_ac anl_bck_desc_1 anl_bb anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ echo '<td class="anl_p5 anl_br anl_al anl_bck_desc_1 anl_bb"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ echo '</table>';
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** Izriše tekstovne odgovore kot tabelo z navedbami
+ *
+ * @param unknown_type $spid
+ */
+ //static function sumMultiText($spid,$_from, $lokacija=false) {
+ static function sumMultiText($spid,$_from) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+ $lokacija=false;
+ $heatmap=false;
+ if($spremenljivka['tip'] == 26)
+ $lokacija=true;
+ else if ($spremenljivka['tip'] == 27)
+ $heatmap=true;
+
+ $anketa = self::$sid;
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ // $num_show_records = $_max_answers_cnt <= (int)$num_show_records ? $_max_answers_cnt : $num_show_records;
+
+ //za tip lokacija (ne enota 3) se rabi user_id, ker se kasneje delajo linki
+ $need_user_id = !($spremenljivka['tip'] != 26 || ($spremenljivka['tip'] == 26 && $spremenljivka['enota'] == 3));
+ $_answers = self::getAnswers($spremenljivka, $num_show_records, $need_user_id);
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_bb tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(!$lokacija ? (self::$_SHOW_LEGENDA ? 3+$_cols : 1+$_cols) : 3+$_cols).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck anl_w110">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ #odgovori
+
+ if(!$lokacija)
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">'.$lang['srv_analiza_opisne_subquestion'] . '</td>';
+ if (self::$_SHOW_LEGENDA){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ if(!$lokacija){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line" colspan="'.(!$lokacija ? $_cols : 3+$_cols).'">'. $lang['srv_analiza_opisne_arguments'] .'</td>';
+ echo '</tr>';
+ }
+ // konec naslovne vrstice
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0) {
+ # naslovna vrstica
+ $_row = $spremenljivka['grids'][0];
+ if(!$lokacija){
+ echo '<tr>';
+ echo '<td class="anl_bl anl_bb anl_bck">&nbsp;</td>';
+ echo '<td class="anl_bl anl_br anl_bb anl_bck">&nbsp;</td>';
+ }
+
+ if (self::$_SHOW_LEGENDA){
+ echo '<td class="anl_br anl_bb anl_bck">&nbsp;</td>';
+ echo '<td class="anl_br anl_bb anl_bck">&nbsp;</td>';
+ }
+ if (count($_row['variables'])>0)
+ foreach ($_row['variables'] AS $rid => $_col ){
+
+ $_sequence = $_col['sequence']; # id kolone z podatki
+ if ($_col['other'] != true) {
+ echo '<td class="anl_br anl_bb anl_bck anl_ac">';
+ // echo $_col['variable'];
+ echo $_col['naslov'];
+ echo '</td>';
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ echo '</tr>';
+ $_css_bck = 'anl_bck_desc_2 anl_ac anl_bt_dot ';
+ $last = 0;
+ //anl_bck_desc_2 anl_bl anl_br anl_variabla_sub
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $_variables_count = count($grid['variables']);
+ echo '<tr class="'.$_css_bck.'">';
+ echo '<td class="anl_bl anl_br anl_variabla_sub">';
+ if(!$lokacija)
+ echo $grid['variable'];
+ //else{
+ else if ($lokacija && $heatmap == false){
+ //echo $grid['naslov'].'<br>';//ni potrebno, ker je ze v glavi?
+ $sprid = explode('_',$spid);
+ $loopid = $sprid[1];
+ $sprid = $sprid[0];
+
+ self::displayMapDataAll($spid);
+ }
+ elseif($heatmap){
+ //echo $grid['naslov'].'<br>';//ni potrebno, ker je ze v glavi?
+ $sprid = explode('_',$spid);
+ $loopid = $sprid[1];
+ $sprid = $sprid[0];
+ SurveyUserSession::Init($anketa);
+
+ $heatmapId = 'heatmap'.$sprid;
+ //echo $heatmapId;
+ //SurveyChart::displayExportIcons($sprid);
+ echo '<a class="fHeatMap" id="heatmap_'.$sprid.'" title="'.$lang['srv_view_data_on_map'].
+ '" href="javascript:void(0);" onclick="passHeatMapData('.$sprid.', -1, '.$loopid.', '.$anketa.');">';
+
+ echo 'Heatmap';
+ echo '</a>';
+ }
+ echo '</td>';
+ if(!$lokacija){
+ echo '<td class="anl_br anl_al">';
+ echo $grid['naslov'];
+ echo '</td>';
+ }
+ if (self::$_SHOW_LEGENDA){
+ echo '<td class="anl_br">'.$_tip.'</td>';
+ echo '<td class="anl_br">'.$_oblika.'</td>';
+ }
+
+ if ($_variables_count > 0) {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,self::$_FREQUENCYS[$_sequence]['validCnt']));
+ }
+
+ # za barvanje
+ $last = ($last & 1) ? 0 : 1 ;
+ $moreBound = 3;
+
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ # tabela z navedbami
+ echo '<td class=" anl_at cll_clps">';
+ echo '<table id="'.$spid.'_'.$_sequence.'" class="fullWidth anl_ac tbl_clps" style="vertical-align:top;">';
+ #$_valid_cnt = count(self::$_FREQUENCYS[$_sequence]['valid']);
+ $index=0;
+ if (count($_valid_answers) > 0) {
+ foreach ($_valid_answers AS $key => $answer) {
+ $index++;
+ $cssBck = ' '.self::$cssColors['0_' . ($index & 1)];
+ $_ans = $answer[$_sequence];
+
+ if($index <= $moreBound){
+ //if($index < $moreBound){
+ echo '<tr class="notmore">';
+ echo '<td class="'.$cssBck.' anl_br anl_user_text'
+ .($_ans != null && $_ans != '' && self::$enableInspect == true ? ' mt_inspect' : '')
+ .'"'
+ .($index == 1 && $_ans != null && $_ans != '' && self::$enableInspect == true ? ' vkey="'.$_ans.'"' : '').'>';
+ # narišemo printereček za izpis posameznih textovnih odgovorov
+ if ($index == 1) {
+ //echo '<span class="anl_single_ans_ico as_link" onclick="showSpremenljivkaTextAnswersPopup(\''.$spid.'\',\''.$_sequence.'\'); return false;">';
+
+ //TODO! zakomentiral, ker nima funkcije, ikona pa pokvarjena
+ /*echo '<span class="anl_single_ans_ico as_link">';
+ echo '&nbsp;';
+ echo '</span>';*/
+ }
+ if ($_ans != null && $_ans != '') {
+ if(!($need_user_id && $lokacija))
+ echo $_ans;
+ else
+ echo '<a class="fMap" title="'.$lang['srv_view_data_on_map'].
+ '" href="javascript:void(0);" onclick="passMapData('.$sprid.', '
+ .$key.', '.$loopid.', '.$anketa.');">'.$_ans.'</a>';
+ } else {
+ echo '&nbsp;';
+ }
+
+ if($index == $moreBound){
+ #more - več
+ echo '<br />';
+ echo '&nbsp;';
+ echo '<div class="srv_heatmap_info_more_'.$sprid.' as_link" onclick="$(\'.more_'.$sprid.', .srv_heatmap_info_more_'.$sprid.', .srv_objava_info_more2_'.$sprid.'\').toggle();">'.$lang['srv_more'].'</div>';
+ #more - več - konec
+ }
+ echo '</td>';
+ echo '</tr>';
+ }
+ else {
+ echo '<tr class="more_'.$sprid.' displayNone" >';
+ echo '<td class="'.$cssBck.' anl_br anl_user_text'
+ .($_ans != null && $_ans != '' && self::$enableInspect == true ? ' mt_inspect' : '')
+ .'"'
+ .($index == 1 && $_ans != null && $_ans != '' && self::$enableInspect == true ? ' vkey="'.$_ans.'"' : '').'>';
+ # narišemo printereček za izpis posameznih textovnih odgovorov
+ if ($index == 1) {
+ //echo '<span class="anl_single_ans_ico as_link" onclick="showSpremenljivkaTextAnswersPopup(\''.$spid.'\',\''.$_sequence.'\'); return false;">';
+
+ //TODO! zakomentiral, ker nima funkcije, ikona pa pokvarjena
+ /*echo '<span class="anl_single_ans_ico as_link">';
+ echo '&nbsp;';
+ echo '</span>';*/
+ }
+ if ($_ans != null && $_ans != '') {
+ if(!($need_user_id && $lokacija))
+ echo $_ans;
+ else
+ echo '<a class="fMap" title="'.$lang['srv_view_data_on_map'].
+ '" href="javascript:void(0);" onclick="passMapData('.$sprid.', '
+ .$key.', '.$loopid.', '.$anketa.');">'.$_ans.'</a>';
+ } else {
+ echo '&nbsp;';
+ }
+
+ if($index == $_max_i){
+ #less - manj
+ echo '<br />';
+ echo '&nbsp;';
+ echo '<div class="srv_heatmap_info_more2_'.$sprid.' as_link" onclick="$(\'.more_'.$sprid.', .srv_heatmap_info_more_'.$sprid.', .srv_heatmap_info_more2_'.$sprid.' \').toggle();">'.$lang['srv_less'].'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ }
+ }
+ }
+
+ if ($_all_valid_answers_cnt > $index) {
+ $index++;
+ $cssBck = ' '.self::$cssColors['0_' . ($index & 1)];
+ echo '<tr>';
+ echo '<td class="'.$cssBck.' anl_br anl_user_text">';
+ // Pri javni povezavi drugace izpisemo
+ if(self::$printPreview == false)
+ echo '<div id="valid_row_togle_more_'.$vid.'" class="floatRight blue pointer anl_more" onclick="showHidenTextTable(\''.$spid.'\', \''.$num_show_records.'\', \''.self::$_CURRENT_LOOP['cnt'].'\');return false;">'.$lang['srv_anl_more'].'</div>';
+ else
+ echo '<div id="valid_row_togle_more_'.$vid.'" class="floatRight anl_more">'.$lang['srv_anl_more'].'</div>';
+ echo '</td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+
+ echo '</td>';
+ }
+ }
+ $last = $_max_i;
+
+ }
+ echo '</tr>';
+ }
+ }
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /**
+ *
+ * @global type $lang
+ * @param string $spid - [spremenljivka_id]_[loop_id]
+ */
+ private static function displayMapDataAll($spid){
+ global $lang;
+
+ $sprid = explode('_',$spid);
+ $loopid = $sprid[1];
+ $sprid = $sprid[0];
+
+ $spremenljivka = Cache::srv_spremenljivka($sprid);
+ $enota = $spremenljivka["enota"];
+
+ //za choose location naredi isto, kot za vsak userja posebej - dobi direkt iz baze ne glede na filterje
+ if($enota == 3){
+ echo '<a class="fMap" title="'.$lang['srv_view_data_on_map'].
+ '" href="javascript:void(0);" onclick="passMapData('.$sprid.', -1, '.$loopid.', '.self::$sid.', \'mapData\');">';
+ echo '<img src="img_0/Google_Maps_Icon.png" height="24" width="24" />';
+ echo '</a>';
+ }
+ //prikaz glede na filterje
+ else{
+ echo '<a class="fMap" title="'.$lang['srv_view_data_on_map'].
+ '" href="javascript:void(0);" onclick="passMapData('.$sprid.', -1, '.$loopid.', '.self::$sid.', \'mapDataAll\');">';
+ echo '<img src="img_0/Google_Maps_Icon.png" height="24" width="24" />';
+ echo '</a>';
+ }
+ }
+
+
+ /** Izriše tekstovne odgovore v vertikalni obliki
+ *
+ * @param unknown_type $spid
+ */
+ static function sumTextVertical($spid,$_from) {
+ global $lang;
+ # dajemo v bufer, da da ne prikazujemo vprašanj brez veljavnih odgovorov če imamo tako nastavljeno
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (self::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'num_show_records' => $num_show_records);
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_br tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(self::$_SHOW_LEGENDA ? 5+(int)$inline_legenda*2 : 5).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ if (self::$_SHOW_LEGENDA) {
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+
+ if (!$inline_legenda) {
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+
+ echo '<div class="anl_variable_type"><span>'.$lang['srv_analiza_opisne_variable_type'].': </span>'.self::getSpremenljivkaLegenda($spremenljivka,'tip').'</div>';
+ }
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck anl_w110">';
+ self::showIcons($spid,$spremenljivka,$_from);
+ echo '</td>';
+ #odgovori
+
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_variabla_line">'.$lang['srv_analiza_frekvence_titleAnswers'] . '</td>';
+ if (self::$_SHOW_LEGENDA && $inline_legenda){
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_legend anl_variabla_line">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleFrekvenca'] .'</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleOdstotek'] .'</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleVeljavni'] .'</td>';
+ }
+ echo '<td class="anl_br anl_bb anl_ac anl_bck anl_w70 anl_variabla_line">'. $lang['srv_analiza_frekvence_titleKumulativa'] .'</td>';
+ echo '</tr>';
+ // konec naslovne vrstice
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ if ($variable['other'] != true) {
+ # dodamo dodatne vrstice z labelami grida
+ if ($_variables_count > 1) {
+ self::outputGridLabelVertical($gid,$grid,$vid,$variable,$spid,$options);
+ }
+
+ $counter = 0;
+ $_kumulativa = 0;
+ //self::$_FREQUENCYS[$_sequence]
+ if (count(self::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ $_valid_answers = self :: sortTextValidAnswers($spid,$variable,self::$_FREQUENCYS[$_sequence]['valid']);
+
+ foreach ($_valid_answers AS $vkey => $vAnswer) {
+ if ($counter < $num_show_records || self::$isArchive) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+ $options['isTextAnswer']=true;
+ $counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ if (count(self::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ $counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+
+ echo '</table>';
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ /** za multi grid tekstovne vrstice doda vrstico z labeliami grida
+ *
+ * @param $gkey
+ * @param $gAnswer
+ * @param $spid
+ * @param $_options
+ */
+ static function outputGridLabelVertical($gid,$grid,$vid,$variable,$spid,$_options=array()) {
+ echo '<tr id="'.$spid.'_'.$counter.'">';
+ echo '<td class="anl_bck_freq_2 anl_bl anl_bb anl_br anl_ac anl_variabla_sub">';
+ echo $variable['variable'];
+ echo '</td>';
+ echo '<td class="anl_bck_freq_2 anl_al anl_bb anl_br">';
+ //echo ($grid['naslov'] != '' ? $grid['naslov']. '&nbsp;-&nbsp;' : '').$variable['naslov'];
+ echo $variable['naslov'];
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA) {
+
+ $spremenljivka = self::$_HEADERS[$spid];
+ if ($variable['other'] != '1' && $variable['text'] != '1') {
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ $_oblika = self::getSpremenljivkaLegenda($spremenljivka,'skala');
+ } else {
+ global $lang;
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ }
+
+ echo '<td class="anl_bck_freq_2 anl_ac anl_bb anl_br ">'.$_tip.'</td>';
+ echo '<td class="anl_bck_freq_2 anl_ac anl_bb anl_br ">'.$_oblika.'</td>';
+ }
+ echo '<td class="anl_bck_freq_2 anl_bb anl_br">&nbsp;</td>';
+
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_bck_freq_2 anl_bb anl_br">&nbsp;</td>';
+ }
+ echo '<td class="anl_bck_freq_2 anl_bb anl_br">&nbsp;</td>';
+ echo '<td class="anl_bck_freq_2 anl_bb anl_br">&nbsp;</td>';
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,&$_kumulativa,$_options=array()) {
+ global $lang;
+ # opcije
+
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ $cssBck = ' '.self::$cssColors['0_' . ($counter & 1)];
+
+ $_valid = (self::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / self::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (self::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / self::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_kumulativa += $_valid;
+
+ # če smo v arhivih dodamovse odgovore vendar so nekateri skriti
+ if ($counter >= $options['num_show_records'] && self::$isArchive) {
+ $cssHide=' class="displayNone"';
+ }
+ echo '<tr id="'.$spid.'_'.$_sequence.'_'.$counter.'" name="valid_row_'.$_sequence.'"'.(self::$enableInspect == true && (int)$vAnswer['cnt'] > 0 ? ' vkey="'.$vkey.'"' : '').$cssHide.'>';
+ echo '<td class="anl_bl anl_ac anl_br gray">&nbsp;</td>';
+ echo '<td class="anl_br'.$cssBck.'">';
+ echo '<div class="anl_user_text_more">'.$vkey.'</div>';
+ echo (($options['isTextAnswer'] == false && (string)$vkey != $vAnswer['text']) ? ' ('.$vAnswer['text'] .')' : '');
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true ) {
+ echo '<td class="anl_ac anl_br'.$cssBck.'">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br'.$cssBck.'">&nbsp;</td>';
+ }
+
+ echo '<td class="anl_ac anl_br'.$cssBck.(self::$enableInspect == true && $options['isOtherAnswer']== false && (int)$vAnswer['cnt'] > 0 ? ' fr_inspect' : '').'">';
+ echo (int)$vAnswer['cnt'];
+ echo '</td>';
+ echo '<td class="anl_ar anl_br'.$cssBck.' anl_pr10">';
+ echo self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br'.$cssBck.' anl_pr10">';
+ echo self::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ echo '<td class="anl_ar'.$cssBck.' anl_pr10">';
+ echo self::formatNumber($_kumulativa, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+
+ echo '</td>';
+ echo '</tr>';
+
+ # če mamo več
+ if ( $counter+1 == $options['num_show_records'] && $options['num_show_records'] < count(self::$_FREQUENCYS[$_sequence]['valid'])) {
+ if (self::$isArchive == false ) {
+ echo '<tr id="'.$spid.'_'.$_sequence.'_'.$counter.'" name="valid_row_'.$_sequence.'" >';
+ echo '<td class="anl_bl anl_ac anl_br gray">&nbsp;</td>';
+ echo '<td class="anl_br'.$cssBck.'">';
+ // Pri javni povezavi drugace izpisemo
+ if(self::$printPreview == false){
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatLeft blue pointer anl_more" onclick="showHidenTextTable(\''.$spid.'\', \''.$options['num_show_records'].'\', \''.self::$_CURRENT_LOOP['cnt'].'\');return false;">'.$lang['srv_anl_more'].'</div>';
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatRight blue pointer anl_more" onclick="showHidenTextTable(\''.$spid.'\', \''.$options['num_show_records'].'\', \''.self::$_CURRENT_LOOP['cnt'].'\');return false;">'.$lang['srv_anl_more'].'</div>';
+ }
+ else{
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatLeft anl_more">'.$lang['srv_anl_more'].'</div>';
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatRight anl_more">'.$lang['srv_anl_more'].'</div>';
+ }
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true ) {
+ echo '<td class="anl_ac anl_br'.$cssBck.'">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br'.$cssBck.'">&nbsp;</td>';
+ }
+ echo '<td class="anl_ac anl_br'.$cssBck.'">'.'</td>';
+ echo '<td class="anl_ar anl_br'.$cssBck.' anl_pr10">'.'</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br'.$cssBck.' anl_pr10">'.'</td>';
+ }
+ echo '<td class="anl_ar'.$cssBck.' anl_pr10">'.'</td>';
+ echo '</tr>';
+ } else {
+ #v arhivie dodamo vse odgovore vendar so skriti
+ echo '<tr id="'.$spid.'_'.$_sequence.'_'.$counter.'" name="valid_row_'.$_sequence.'" >';
+ echo '<td class="anl_bl anl_ac anl_br gray">&nbsp;</td>';
+ echo '<td class="anl_br'.$cssBck.'">';
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatLeft blue pointer" onclick="$(this).parent().parent().parent().find(\'tr.displayNone\').removeClass(\'displayNone\');$(this).parent().parent().addClass(\'displayNone\');return false;">'.$lang['srv_anl_all'].'</div>';
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatRight blue pointer" onclick="$(this).parent().parent().parent().find(\'tr.displayNone\').removeClass(\'displayNone\');$(this).parent().parent().addClass(\'displayNone\');return false;">'.$lang['srv_anl_all'].'</div>';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true ) {
+ echo '<td class="anl_ac anl_br'.$cssBck.'">&nbsp;</td>';
+ echo '<td class="anl_ac anl_br'.$cssBck.'">&nbsp;</td>';
+ }
+ echo '<td class="anl_ac anl_br'.$cssBck.'">'.'</td>';
+ echo '<td class="anl_ar anl_br'.$cssBck.' anl_pr10">'.'</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br'.$cssBck.' anl_pr10">'.'</td>';
+ }
+ echo '<td class="anl_ar'.$cssBck.' anl_pr10">'.'</td>';
+ echo '</tr>';
+ }
+ }
+
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaValidAnswerVertical($counter,$_sequence,$spid,$_options=array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ // $cssBck = ' '.self::$cssColors['0_' . ($counter & 1)]; $_percent = (self::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*self::$_FREQUENCYS[$_sequence]['validCnt'] / self::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $cssBck = ' '.self::$cssColors['text_1'];
+
+ $_brez_MV = ((int)self::$missingProfileData['display_mv_type'] === 0 ) ? TRUE : FALSE;
+ $_hide_minus = ((int)self::$missingProfileData['display_mv_type'] === 2 ) ? TRUE : FALSE;
+ $value =((int)self::$missingProfileData['display_mv_type'] === 0 ) ? 0 : 1;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="anl_click_missing_tr_'.$_sequence.$_sufix.'" class="'.($_brez_MV ? 'anl_bb' : 'anl_dash_red_bb').'">';
+ echo '<td class="anl_bl anl_br anl_al gray anl_ti_20'.$cssBck.'">'.$lang['srv_anl_valid'];
+
+ echo '<span id="click_missing_'.$_sequence.$_sufix.'" class="anl_click_missing gray'.($_brez_MV ? '' : ' displayNone').'" value="'.$value.'">&nbsp;&nbsp;<span class="faicon plus_orange icon-orange_hover_red folder_plusminus"></span></span>';
+ echo '<span id="single_missing_title_'.$_sequence.$_sufix.'" class="anl_click_missing_hide gray'.($_brez_MV || $_hide_minus? ' displayNone' : '').'">&nbsp;&nbsp;<span class="faicon minus_orange icon-orange_hover_red folder_plusminus"></span></span>';
+ echo '</td>';
+
+ echo '<td class="anl_br anl_al anl_ita red'.$cssBck.'" >'.$lang['srv_anl_suma1'].'</td>';
+
+
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<th class="anl_ita red anl_br anl_ac'.$cssBck.'">&nbsp;</th>';
+ echo '<th class="anl_ita red anl_br anl_ac'.$cssBck.'">&nbsp;</th>';
+ }
+ echo '<td class="anl_ita red anl_br anl_ac'.$cssBck.'" >';
+
+ echo self::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ? self::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ echo '</td>';
+ $_percent = self::$_FREQUENCYS[$_sequence]['allCnt'] > 0
+ ? 100 * self::$_FREQUENCYS[$_sequence]['validCnt'] / self::$_FREQUENCYS[$_sequence]['allCnt']
+ : 0;
+ echo '<td class="anl_ita red anl_br anl_ar'.$cssBck.' anl_pr10">' . self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%') . '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_ita red anl_br anl_ar'.$cssBck.' anl_pr10">' . self::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%') . '</td>';
+ }
+ echo '<td class="anl_ita red anl_ac'.$cssBck.'">&nbsp;</td>';
+ echo '</tr>';
+ // $counter++;
+ return $counter;
+
+ }
+
+ static function outputInvalidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_options=array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ //$cssBck = ' '.self::$cssColors['text_' . ($counter & 1)];
+ $cssBck = ' '.self::$cssColors['0_' . ($counter & 1)];
+
+ $_percent = (self::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / self::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (self::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / self::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ $_Z_MV = ((int)self::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ echo '<tr name="missing_detail_'.$_sequence.$_sufix.'"'.($_Z_MV ? '': ' class="displayNone"').'>';
+ echo '<td class="anl_bl anl_br anl_ac gray" style="width:10px">&nbsp;</td>';
+ echo '<td class="anl_br'.$cssBck.'">';
+ echo '<div class="floatLeft"><div class="anl_tin2">'.'<span class="anl_user_text">' . $vkey . '</span>' . ' (' . $vAnswer['text'].')'.'</div></div>';
+ echo '<div class="floatRight anl_detail_percent anl_w50 anl_ac anl_dash_bl">'.self::formatNumber($_invalid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%').'</div>';
+ echo '<div class="floatRight anl_detail_percent anl_w30 anl_ac">'.$vAnswer['cnt'].'</div>';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<th class="anl_ac anl_br'.$cssBck.'">&nbsp;</th>';
+ echo '<th class="anl_ac anl_br'.$cssBck.'">&nbsp;</th>';
+ }
+ echo '<td class="anl_ac anl_br'.$cssBck.'">';
+ echo (int)$vAnswer['cnt'];
+ echo '</td>';
+ echo '<td class="anl_ar anl_br'.$cssBck.'">';
+ echo self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br anl_detail_percent anl_ita'.$cssBck.'">';
+ echo '&nbsp;';
+ echo '</td>';
+ }
+ echo '<td class="'.$cssBck.'" >';
+ echo '&nbsp;';
+ echo '</td>';
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$_options = array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ //$cssBck = ' '.self::$cssColors['text_' . ($counter & 1)];
+ $cssBck = ' '.self::$cssColors['text_1'];
+ $_percent = (self::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*self::$_FREQUENCYS[$_sequence]['invalidCnt'] / self::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $_brez_MV = ((int)self::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+ $_hide_minus = ((int)self::$missingProfileData['display_mv_type'] === 1 || (int)self::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="click_missing_1_'.$_sequence.$_sufix.'" class="anl_dash_red_bb'.($_brez_MV ?' displayNone' : '').'">';
+ echo '<td class="anl_bl anl_al anl_br gray anl_ti_20'.$cssBck.'">';
+ echo $lang['srv_anl_missing'];
+ echo '</td>';
+ echo '<td class="anl_br anl_ita red'.$cssBck.'" >';
+ echo $lang['srv_analiza_manjkajocevrednosti'];
+ // podrobno za missinge
+ echo '<span id="single_missing_0'.$_sequence.$_sufix.'" class="printHide anl_ita anl_detail_percent'.($_hide_minus ? '' : ' displayNone').'">&nbsp;&nbsp;';
+ echo '<a href="#single_missing_'.$_sequence.$_sufix.'" onclick="show_single_missing(\''.$_sequence.$_sufix.'\', 0);return false;" > ' ;
+ //echo $lang['srv_analiza_missingSpremenljivke'] ;
+ echo ' <span class="faicon plus_orange icon-orange_hover_red folder_plusminus"></span> </a>';
+ echo '</span>';
+ echo '<span id="single_missing_1'.$_sequence.$_sufix.'" class="printHide anl_ita anl_detail_percent'.($_hide_minus ? ' displayNone' : '').'">&nbsp;&nbsp;';
+ echo '<a href="#single_missing_'.$_sequence.$_sufix.'" onclick="show_single_missing(\''.$_sequence.$_sufix.'\', 1);return false;" > ' ;
+ // echo $lang['srv_analiza_missingSpremenljivke'] ;
+ echo ' <span class="faicon minus_orange icon-orange_hover_red folder_plusminus"></span> </a>';
+ echo '</span>';
+
+ echo '<div id="single_missing_suma_'.$_sequence.$_sufix.'" class="floatRight anl_w50 anl_dash_bl anl_dash_bt anl_ac anl_detail_percent displayNone">100.0%</div>';
+ echo '<div id="single_missing_suma_freq_'.$_sequence.$_sufix.'" class="floatRight anl_w30 anl_dash_bt anl_ac anl_detail_percent displayNone">'.self::$_FREQUENCYS[$_sequence]['invalidCnt'].'</div>';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<th class="anl_ac anl_br anl_ita red'.$cssBck.'">&nbsp;</th>';
+ echo '<th class="anl_ac anl_br anl_ita red'.$cssBck.'">&nbsp;</th>';
+ }
+
+ echo '<td class="anl_ac anl_br anl_detail_cnt anl_ita red'.$cssBck.'">';
+ $answer['cnt'] = self::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ? self::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+ echo (int)$answer['cnt'];
+ echo '</td>';
+ echo '<td class="anl_ar anl_br anl_ita red'.$cssBck.' anl_pr10">';
+ echo self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br anl_ita red'.$cssBck.' anl_pr10">';
+ echo '<span id="single_missing_percent_'.$_sequence.$_sufix.'" class="'.($detail ? 'displayNone' : '' ).'">&nbsp;</span>';
+ echo '</td>';
+ }
+ echo '<td class="anl_ar anl_ita red'.$cssBck.' anl_pr10">&nbsp;</td>';
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaVertical($counter,$_sequence,$spid, $_options = array()) {
+ global $lang;
+ # opcije
+
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ // $cssBck = ' '.self::$cssColors['0_' .($counter & 1)];
+ $cssBck = ' anl_bck_text_0';
+ $_brez_MV = ((int)self::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="click_missing_suma_'.$_sequence.$_sufix.'" class="'.($_brez_MV ? 'displayNone' : '').'">';
+ //echo '<td class="anl_bl anl_ac anl_dash_bt anl_br anl_bb gray">&nbsp;</td>'; // $lang['srv_anl_appropriate']
+ //echo '<td class="anl_al anl_dash_bt anl_br anl_bb red anl_ita'.$cssBck.'">'.$lang['srv_anl_suma2'].'</td>';
+ echo '<td class="anl_bl anl_ac anl_dash_bt anl_bb red anl_ita'.$cssBck.'">'.$lang['srv_anl_suma2'].'</td>';
+ echo '<td class="anl_dash_bt anl_br anl_bb'.$cssBck.'">&nbsp;</td>';
+
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita'.$cssBck.'" >&nbsp;</td>';
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita'.$cssBck.'" >&nbsp;</td>';
+ }
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.'" >' . (self::$_FREQUENCYS[$_sequence]['allCnt'] ? self::$_FREQUENCYS[$_sequence]['allCnt'] : 0) . '</td>';
+ echo '<td class="anl_ar anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.' anl_pr10">' . self::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%') . '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.' anl_pr10">&nbsp;</td>';
+ }
+ echo '<td class="anl_ac anl_dash_bt anl_bb anl_ita red'.$cssBck.'">&nbsp;</td>';
+ echo '</tr>';
+
+ }
+
+
+
+ static function outputSumaValidAnswerHeatmap($counter,$_sequence,$spid,$_options=array(), $validHeatmapRegion) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ $cssBck = ' '.self::$cssColors['text_1'];
+
+ $_brez_MV = ((int)self::$missingProfileData['display_mv_type'] === 0 ) ? TRUE : FALSE;
+ $_hide_minus = ((int)self::$missingProfileData['display_mv_type'] === 2 ) ? TRUE : FALSE;
+ $value =((int)self::$missingProfileData['display_mv_type'] === 0 ) ? 0 : 1;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="anl_click_missing_tr_'.$_sequence.$_sufix.'" class="'.($_brez_MV ? 'anl_bb' : 'anl_dash_red_bb').'">';
+ echo '<td class="anl_bl anl_br anl_al gray anl_ti_20'.$cssBck.'">'.$lang['srv_anl_valid'];
+
+ echo '<span id="click_missing_'.$_sequence.$_sufix.'" class="anl_click_missing gray'.($_brez_MV ? '' : ' displayNone').'" value="'.$value.'">&nbsp;&nbsp;<span class="faicon plus_orange icon-orange_hover_red folder_plusminus"></span></span>';
+ echo '<span id="single_missing_title_'.$_sequence.$_sufix.'" class="anl_click_missing_hide gray'.($_brez_MV || $_hide_minus? ' displayNone' : '').'">&nbsp;&nbsp;<span class="faicon minus_orange icon-orange_hover_red folder_plusminus"></span></span>';
+ echo '</td>';
+ echo '<td class="anl_br anl_al anl_ita red'.$cssBck.'" >'.$lang['srv_anl_suma1'].'</td>';
+
+
+
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<th class="anl_ita red anl_br anl_ac'.$cssBck.'">&nbsp;</th>';
+ echo '<th class="anl_ita red anl_br anl_ac'.$cssBck.'">&nbsp;</th>';
+ }
+
+ //Veljavni - Skupaj
+ echo '<td class="anl_ita red anl_br anl_ac'.$cssBck.'" >';
+ echo $validHeatmapRegion;
+ //echo self::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ? self::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ echo '</td>';
+
+
+/* $_percent = self::$_FREQUENCYS[$_sequence]['allCnt'] > 0
+ ? 100 * self::$_FREQUENCYS[$_sequence]['validCnt'] / self::$_FREQUENCYS[$_sequence]['allCnt']
+ : 0;
+ echo '<td class="anl_ita red anl_br anl_ar'.$cssBck.' anl_pr10">' . self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%') . '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent'] == true) {
+ echo '<td class="anl_ita red anl_br anl_ar'.$cssBck.' anl_pr10">' . self::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%') . '</td>';
+ }
+ echo '<td class="anl_ita red anl_ac'.$cssBck.'">&nbsp;</td>'; */
+ echo '</tr>';
+ // $counter++;
+ return $counter;
+
+ }
+
+ static function outputInvalidAnswerHeatmap($counter,$vkey,$vAnswer,$_sequence,$spid,$_options=array(), $manjkajoci) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ //$cssBck = ' '.self::$cssColors['text_' . ($counter & 1)];
+ $cssBck = ' '.self::$cssColors['0_' . ($counter & 1)];
+
+ $_percent = (self::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / self::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (self::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / self::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ $_Z_MV = ((int)self::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ echo '<tr name="missing_detail_'.$_sequence.$_sufix.'"'.($_Z_MV ? '': ' class="displayNone"').'>';
+ echo '<td class="anl_bl anl_br anl_ac gray" style="width:10px">&nbsp;</td>';
+ echo '<td class="anl_br'.$cssBck.'">';
+ echo '<div class="floatLeft"><div class="anl_tin2">'.'<span class="anl_user_text">' . $vkey . '</span>' . ' (' . $vAnswer['text'].')'.'</div></div>';
+ echo '<div class="floatRight anl_detail_percent anl_w50 anl_ac anl_dash_bl">'.self::formatNumber($_invalid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%').'</div>';
+ echo '<div class="floatRight anl_detail_percent anl_w30 anl_ac">'.$vAnswer['cnt'].'</div>';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<th class="anl_ac anl_br'.$cssBck.'">&nbsp;</th>';
+ echo '<th class="anl_ac anl_br'.$cssBck.'">&nbsp;</th>';
+ }
+ echo '<td class="anl_ac anl_br'.$cssBck.'">';
+ echo (int)$vAnswer['cnt'];
+ echo '</td>';
+ echo '<td class="anl_ar anl_br'.$cssBck.'">';
+ echo self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br anl_detail_percent anl_ita'.$cssBck.'">';
+ echo '&nbsp;';
+ echo '</td>';
+ }
+ echo '<td class="'.$cssBck.'" >';
+ echo '&nbsp;';
+ echo '</td>';
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaInvalidAnswerHeatmap($counter,$_sequence,$spid,$_options = array(), $manjkajoci) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ //$cssBck = ' '.self::$cssColors['text_' . ($counter & 1)];
+ $cssBck = ' '.self::$cssColors['text_1'];
+ $_percent = (self::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*self::$_FREQUENCYS[$_sequence]['invalidCnt'] / self::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $_brez_MV = ((int)self::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+ $_hide_minus = ((int)self::$missingProfileData['display_mv_type'] === 1 || (int)self::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="click_missing_1_'.$_sequence.$_sufix.'" class="anl_dash_red_bb'.($_brez_MV ?' displayNone' : '').'">';
+
+ echo '<td class="anl_bl anl_al anl_br gray anl_ti_20'.$cssBck.'">';
+ echo $lang['srv_anl_missing'];
+ echo '</td>';
+
+ echo '<td class="anl_br anl_ita red'.$cssBck.'" >';
+ echo $lang['srv_analiza_manjkajocevrednosti'];
+
+ // podrobno za missinge
+ echo '<span id="single_missing_0'.$_sequence.$_sufix.'" class="printHide anl_ita anl_detail_percent'.($_hide_minus ? '' : ' displayNone').'">&nbsp;&nbsp;';
+ echo '<a href="#single_missing_'.$_sequence.$_sufix.'" onclick="show_single_missing(\''.$_sequence.$_sufix.'\', 0);return false;" > ' ;
+ //echo $lang['srv_analiza_missingSpremenljivke'] ;
+ echo ' <span class="faicon plus_orange icon-orange_hover_red folder_plusminus"></span> </a>';
+ echo '</span>';
+ echo '<span id="single_missing_1'.$_sequence.$_sufix.'" class="printHide anl_ita anl_detail_percent'.($_hide_minus ? ' displayNone' : '').'">&nbsp;&nbsp;';
+ echo '<a href="#single_missing_'.$_sequence.$_sufix.'" onclick="show_single_missing(\''.$_sequence.$_sufix.'\', 1);return false;" > ' ;
+ // echo $lang['srv_analiza_missingSpremenljivke'] ;
+ echo ' <span class="faicon minus_orange icon-orange_hover_red folder_plusminus"></span> </a>';
+ echo '</span>';
+
+ echo '<div id="single_missing_suma_'.$_sequence.$_sufix.'" class="floatRight anl_w50 anl_dash_bl anl_dash_bt anl_ac anl_detail_percent displayNone">100.0%</div>';
+ //echo '<div id="single_missing_suma_freq_'.$_sequence.$_sufix.'" class="floatRight anl_w30 anl_dash_bt anl_ac anl_detail_percent displayNone">'.self::$_FREQUENCYS[$_sequence]['invalidCnt'].'</div>';
+ echo '<div id="single_missing_suma_freq_'.$_sequence.$_sufix.'" class="floatRight anl_w30 anl_dash_bt anl_ac anl_detail_percent displayNone">'.$manjkajoci.'</div>';
+ echo '</td>';
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<th class="anl_ac anl_br anl_ita red'.$cssBck.'">&nbsp;</th>';
+ echo '<th class="anl_ac anl_br anl_ita red'.$cssBck.'">&nbsp;</th>';
+ }
+
+ //Mankajoci - Skupaj
+ echo '<td class="anl_ac anl_br anl_detail_cnt anl_ita red'.$cssBck.'">';
+ echo $manjkajoci;
+ //$answer['cnt'] = self::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ? self::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+ //echo (int)$answer['cnt'];
+ echo '</td>';
+
+ //stolpec "Veljavni kliki"
+/* echo '<td class="anl_ar anl_br anl_ita red'.$cssBck.' anl_pr10">';
+ echo self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ */
+
+/* if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_br anl_ita red'.$cssBck.' anl_pr10">';
+ echo '<span id="single_missing_percent_'.$_sequence.$_sufix.'" class="'.($detail ? 'displayNone' : '' ).'">&nbsp;</span>';
+ echo '</td>';
+ } */
+
+ echo '<td class="anl_ar anl_ita red'.$cssBck.' anl_pr10">&nbsp;</td>';
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaHeatmap($counter,$_sequence,$spid, $_options = array(), $ustrezniHeatmapRegion) {
+ global $lang;
+ # opcije
+
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ // $cssBck = ' '.self::$cssColors['0_' .($counter & 1)];
+ $cssBck = ' anl_bck_text_0';
+ $_brez_MV = ((int)self::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+ $_sufix = (self::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(self::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.self::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="click_missing_suma_'.$_sequence.$_sufix.'" class="'.($_brez_MV ? 'displayNone' : '').'">';
+ //echo '<td class="anl_bl anl_ac anl_dash_bt anl_br anl_bb gray">&nbsp;</td>'; // $lang['srv_anl_appropriate']
+ //echo '<td class="anl_al anl_dash_bt anl_br anl_bb red anl_ita'.$cssBck.'">'.$lang['srv_anl_suma2'].'</td>';
+ echo '<td class="anl_bl anl_ac anl_dash_bt anl_bb red anl_ita'.$cssBck.'">'.$lang['srv_anl_suma2'].'</td>';
+ echo '<td class="anl_dash_bt anl_br anl_bb'.$cssBck.'">&nbsp;</td>';
+
+ if (self::$_SHOW_LEGENDA && $options['isOtherAnswer'] == false && $options['inline_legenda'] == true) {
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita'.$cssBck.'" >&nbsp;</td>';
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita'.$cssBck.'" >&nbsp;</td>';
+ }
+
+ //SKUPAJ
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.'" >' .$ustrezniHeatmapRegion. '</td>';
+
+ //echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.'" >' . (self::$_FREQUENCYS[$_sequence]['allCnt'] ? self::$_FREQUENCYS[$_sequence]['allCnt'] : 0) . '</td>';
+
+ //echo '<td class="anl_ar anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.' anl_pr10">' . self::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%') . '</td>';
+ /*if (self::$_HEADERS[$spid]['show_valid_percent']) {
+ echo '<td class="anl_ar anl_dash_bt anl_br anl_bb anl_ita red'.$cssBck.' anl_pr10">&nbsp;</td>';
+ } */
+ //echo '<td class="anl_ac anl_dash_bt anl_bb anl_ita red'.$cssBck.'">&nbsp;</td>';
+ echo '</tr>';
+
+ }
+
+ /** izpišemo tabelo z tekstovnimi odgovori drugo
+ *
+ * @param $skey
+ * @param $oAnswers
+ * @param $spid
+ */
+ static function outputOtherAnswers($oAnswers) {
+ global $lang;
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ $spid = $oAnswers['spid'];
+ $_variable = self::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+ $_frekvence = self::$_FREQUENCYS[$_variable['sequence']];
+
+ echo '<table class="anl_tbl anl_bt anl_bl anl_br tbl_clps">';
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_desc_1 anl_w110 anl_variabla_sub" >'. $_variable['variable'] . '</td>';
+ echo '<td class="anl_bl anl_br anl_bb anl_al anl_bck_desc_1" colspan="'.(self::$_SHOW_LEGENDA && false ? 7 : 5).'">';
+ echo '<span class="anl_variabla_label">'.self::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )</span>';
+ if (self::$_SHOW_LEGENDA) {
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+ echo '<div class="floatRight"><span>&nbsp;('.$_tip.')</span>'.'</div>';
+ }
+ if (self::$_SHOW_LEGENDA) {
+ echo self::getSpremenljivkaLegenda(0,'tip');
+ }
+
+ echo '</td>';
+ echo '</tr>';
+ $css_txt = 'anl_variabla_line';
+ echo '<tr>';
+ echo '<td class="anl_bb anl_bl anl_br anl_ac anl_bck anl_w110"><span class="anl_variabla">';
+ //self::showIcons($spid,$spremenljivka,$_from);
+ echo '</span></td>';
+
+ echo '<td class="anl_bb anl_br anl_ac anl_bck '.$css_txt.'">'. $lang['srv_analiza_frekvence_titleAnswers'] .'</td>';
+ if (self::$_SHOW_LEGENDA && false){
+ echo '<td class="anl_bb anl_br anl_ac anl_bck anl_w70 '.$css_txt.'">'.$lang['srv_analiza_opisne_variable_expression'].'</td>';
+ echo '<td class="anl_bb anl_br anl_ac anl_bck anl_w70 '.$css_txt.'">'.$lang['srv_analiza_opisne_variable_skala'].'</td>';
+ }
+ echo '<td class="anl_bb anl_br anl_ac anl_bck anl_w70 '.$css_txt.'">'. $lang['srv_analiza_frekvence_titleFrekvenca'] .'</td>';
+ echo '<td class="anl_bb anl_br anl_ac anl_bck anl_w70 '.$css_txt.'">'. $lang['srv_analiza_frekvence_titleOdstotek'] .'</td>';
+ echo '<td class="anl_bb anl_br anl_ac anl_bck anl_w70 '.$css_txt.'">'. $lang['srv_analiza_frekvence_titleVeljavni'] .'</td>';
+ echo '<td class="anl_bb anl_br anl_ac anl_bck anl_w70 '.$css_txt.'">'. $lang['srv_analiza_frekvence_titleKumulativa'] .'</td>';
+ echo '</tr>';
+ // konec naslovne vrstice
+ if (self::$_SHOW_LEGENDA && false){
+ $cssBck = 'anl_bck ';
+ echo '<tr>';
+ echo '<td class="anl_tin anl_bl anl_bb anl_br anl_al '.$cssBck.'link_no_decoration">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br anl_al '.$cssBck.'">'.'</td>';
+
+ $_tip = $lang['srv_analiza_vrsta_bese'];
+ $_oblika = $lang['srv_analiza_oblika_nomi'];
+
+ echo '<td class="anl_bb anl_br '.$cssBck.'anl_ac anl_w90">'.$_tip.'</td>';
+ echo '<td class="anl_bb anl_br '.$cssBck.'anl_ac anl_w90 ">'.$_oblika.'</td>';
+
+ echo '<td class="anl_bb anl_br '.$cssBck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br '.$cssBck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb anl_br '.$cssBck.' anl_w70">&nbsp;</td>';
+ echo '<td class="anl_bb '.$cssBck.' anl_w70">&nbsp;</td>';
+ echo '</tr>';
+ }
+ $counter = 1;
+ $_kumulativa = 0;
+ if ( is_countable(self::$_FREQUENCYS[$_sequence]['valid']) && count(self::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ if ($counter < $num_show_records) {
+ $counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,array('isOtherAnswer'=>true,'num_show_records' => $num_show_records));
+ }
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ }
+ if (count(self::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,array('isOtherAnswer'=>true));
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ }
+ #izpišemo še skupno sumo
+ $counter = self::outputSumaVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+
+ echo '</table>';
+ }
+
+ static public function showVariable($spid,$variable,$_options= array()) {
+ global $lang;
+ # globalne nastavitve funkcije
+ $options = array('prev'=>true,'align'=>'center');
+ #ponastavimo uporabniške funkcije
+ if (count($_options) > 0) {
+ foreach ($_options as $okey => $option) {
+ $options[$okey] = $option;
+ }
+ }
+
+ $sccFloat = ($options['align'] == 'center')
+ ? ''
+ : ( $options['align'] == 'left'
+ ? ' floatLeft'
+ : ' floatRight');
+
+ echo '<span class="spaceLeft anl_variabla'.$sccFloat.'">';
+ if (self::$isArchive == false && self::$printPreview == false){
+ echo '<a href="#" onclick="showspremenljivkaSingleVarPopup(\''.$spid.'\'); return false;">';
+ #echo '<a href="/" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="(\'' . $spid . '\'); return false;">'
+ echo $variable;
+ echo '</a>';
+ }
+ else{
+ echo $variable;
+ }
+ echo '</span>';
+ }
+
+
+ static public function showIcons($spid, $spremenljivka, $_from = 'freq', $additional=array()) {
+ global $lang;
+
+ $sccFloat = 'taCenter ';
+ #kateri skin
+ $skin = 0;
+ $options = array('sums'=>true,'sums*'=>true,'desc'=>true,'freq'=>true,'sums_spec'=>false);
+ $from_navedbe = (isset($additional['navedbe']) && $additional['navedbe'] == true) ? true : false;
+ $showReport = (isset($additional['noReport']) && $additional['noReport'] == true) ? false: true;
+ $showChart = (isset($additional['showChart']) && $additional['showChart'] == false) ? false: true;
+ $printIcon = (isset($additional['printIcon']) && $additional['printIcon'] == true) ? true: false;
+
+ if ($_from == 'para') {
+ $showReport = false;
+ }
+
+ switch ($_from) {
+ case 'freq':
+ case 'para':
+ case 'charts':
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ if ($spremenljivka['show_valid_percent'] == true && $spremenljivka['skala'] != 1) {
+ # če za ordinalno prikazujemo povprečje in st. oddklon
+ $options['sums'] = true;
+ $options['sums*'] = true;
+ } else {
+ # za nominalno ne prikazujemo povprečje in st. oddklon, zato je F == F*
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ }
+ break;
+ case 2: #checkbox če je dihotomna:
+ break;
+ case 3: # dropdown - prikjaže navpično
+ break;
+ case 6: # multigrid
+ $options['sums*'] = false;
+ if ( $spremenljivka['enota'] == 3 ) {
+ $options['sums_spec'] = true;
+ }
+ break;
+ case 7: # variabla tipa »število«
+ $options['sums*'] = false;
+ break;
+ case 8: # datum
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ break;
+ case 16: #multicheckbox če je dihotomna:
+ break;
+ case 17: #razvrščanje če je ordinalna
+ $options['sums'] = false;
+ break;
+ case 18: # vsota
+ $options['sums*'] = false;
+ break;
+ case 19: # multitext
+ $options['sums*'] = false;
+ break;
+ case 20: # multi number
+
+ break;
+ case 4: # text
+ case 21: # besedilo*
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ break;
+ case 26: # lokacija
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ break;
+ case 27: # heatmap
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ break;
+ case 22: # kalkulacija
+ case 25: # kvota
+ $options['sums*'] = false;
+ break; # kalkulacija
+ }
+ $export = ($_from == 'charts') ? 'charts' : 'frequency';
+ break;
+ case 'desc':
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ if ($spremenljivka['skala'] == 1) {
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ }
+ break;
+ case 2: #checkbox če je dihotomna:
+ break;
+ case 3: # dropdown - prikjaže navpično
+ break;
+ case 6: # multigrid
+ $options['sums*'] = false;
+ if ( $spremenljivka['enota'] == 3 ) {
+ $options['sums_spec'] = true;
+ }
+ break;
+ case 7: # variabla tipa »število«
+ $options['sums*'] = false;
+ break;
+ case 8: # datum
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ break;
+ case 16: #multicheckbox če je dihotomna:
+ break;
+ case 17: #razvrščanje če je ordinalna
+ $options['sums'] = false;
+ break;
+ case 18: # vsota
+ $options['sums*'] = false;
+ break;
+ case 19: # multitext
+ $options['sums*'] = false;
+ break;
+ case 20: # multi number
+ break;
+ case 4: # text
+ case 21: # besedilo*
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ break;
+ case 26: # Lokacija
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ break;
+ case 27: # heatmap
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ break;
+ case 22: # kalkulacija
+ case 25: # kvota
+ $options['sums*'] = false;
+ break; # kalkulacija
+ }
+ $export = 'statistics';
+ break;
+ case 'sums':
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ if ($spremenljivka['skala'] == 1) {
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ $_from = 'freq';
+ } else {
+ $_from = 'sums*';
+ }
+ break;
+ case 2: #checkbox če je dihotomna
+ $_from = 'sums*';
+ break;
+ case 3: # dropdown - prikjaže navpično
+ break;
+ case 6: # multigrid
+ $options['sums*'] = false;
+ if ( $spremenljivka['enota'] == 3 ) {
+ $options['sums_spec'] = true;
+ $_from = 'sums*';
+ }
+ break;
+ case 7: # variabla tipa »število«
+ $options['sums*'] = false;
+ break;
+ case 8: # datum
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ $_from = 'freq';
+ break;
+
+ case 16: #multicheckbox če je dihotomna
+ break;
+ case 17: #razvrščanje če je ordinalna
+ $options['sums'] = false;
+ $_from = 'sums*';
+ break;
+ case 18: # vsota
+ $options['sums*'] = false;
+ break;
+ case 19: # multitext
+ $options['sums*'] = false;
+ break;
+ case 20: # multi number
+ break;
+ case 21: # besedilo*
+ $_from = 'sums';
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ $options['sums'] = false;
+ $_from = 'freq';
+ }
+
+ $options['sums*'] = false;
+ break;
+ case 26: # lokacija
+ $_from = 'sums';
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ $_from = 'freq';
+ }
+
+ $options['sums*'] = false;
+ break;
+ case 27: # heatmap
+ $_from = 'sums';
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ $_from = 'freq';
+ }
+
+ $options['sums*'] = false;
+ break;
+ case 4: # text
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ $_from = 'freq';
+ break;
+ case 22: # kalkulacija
+ case 25: # kvota
+ $options['sums*'] = false;
+ break; # kalkulacija
+ }
+ $export = 'sums';
+ break;
+ case 'sums*':
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ if ($spremenljivka['skala'] == 1) {
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ $_from = 'freq';
+ } else {
+ $_from = 'sums';
+ }
+ break;
+ case 2: #checkbox če je dihotomna:
+ $_from = 'sums';
+ break;
+ case 3: # dropdown - prikjaže navpično
+ break;
+ case 6: # multigrid
+ $options['sums*'] = false;
+ if ( $spremenljivka['enota'] == 3 ) {
+ $options['sums_spec'] = true;
+ $_from = 'sums';
+ }
+ break;
+ case 7: # variabla tipa »število«
+ $options['sums*'] = false;
+ $_from = 'sums';
+ break;
+ case 8: # datum
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ break;
+
+ case 16: #multicheckbox če je dihotomna:
+ break;
+ case 17: #razvrščanje če je ordinalna
+ $options['sums'] = false;
+ break;
+ case 18: # vsota
+ $options['sums*'] = false;
+ $_from = 'sums';
+ break;
+ case 19: # multitext
+ $options['sums*'] = false;
+ break;
+ case 20: # multi number
+ break;
+ case 4: # text
+ $options['sums'] = false;
+ $options['sums*'] = false;
+ $_from = 'freq';
+ break;
+ case 21: # besedilo*
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ $_from = 'freq';
+ break;
+ case 26: # lokacija
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ $_from = 'freq';
+ break;
+ case 27: # heatmap
+ if ($spremenljivka['cnt_all'] == 1) {
+ $options['sums'] = false;
+ }
+ $options['sums*'] = false;
+ $_from = 'freq';
+ break;
+ case 22: # kalkulacija
+ case 25: # kvota
+ $options['sums*'] = false;
+ $_from = 'sums';
+ break; # kalkulacija
+ }
+ $export = 'sums';
+ break;
+ case 'none':
+ break;
+ }
+
+ // Javna povezava nima teh ikon
+ if ($printIcon == false && self::$printPreview == false) {
+
+ echo '<span class="'.$sccFloat.'printHide iconHide">';
+
+ if ($options['sums'] == true) {
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3 ) {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_SUMMARY_NEW.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ } else {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_SUMMARY.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ }
+
+ echo '<span class="faicon an_sigma large '.($_from == 'sums' ? '' : 'icon-blue_soft_link').'" title="' . $lang['srv_analysis_icon_sumary'] . '"></span> ';
+ echo '</a>';
+ }
+
+ if ($options['sums_spec'] == true) {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_SUMMARY_NEW.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ echo '<span class="faicon an_sigmax large '.($_from == 'sums*' ? '' : 'icon-blue_soft_link').'" title="' . $lang['srv_analysis_icon_frequency*'] . '"></span> ';
+ echo '</a>';
+ }
+
+ if ($options['sums*'] == true) {
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3) {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_SUMMARY.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ }else {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_SUMMARY_NEW.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ }
+ echo '<span class="faicon an_freqx large '.($_from == 'sums*' ? '' : 'icon-blue_soft_link').'" title="' . $lang['srv_analysis_icon_frequency*'] . '"></span> ';
+ echo '</a>';
+ }
+ if ($options['desc'] == true) {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_DESCRIPTOR.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ echo '<span class="faicon an_stat large '.($_from == 'desc' ? '' : 'icon-blue_soft_link').'" title="' . $lang['srv_analysis_icon_descriptor'] . '"></span> ';
+ echo '</a>';
+ }
+ if ($options['freq'] == true) {
+ echo '<a href="#" onclick="showAnalizaSingleVarPopup(\''.$spid.'\',\''.M_ANALYSIS_FREQUENCY.'\',\''.$from_navedbe.'\',\''.self::$_CURRENT_LOOP['cnt'].'\'); return false;">';
+ echo '<span class="faicon an_freq large '.($_from == 'freq' ? '' : 'icon-blue_soft_link').'" title="' . $lang['srv_analysis_icon_frequency'] . '"></span> ';
+ echo '</a>';
+ }
+
+ // Ikona za prikaz grafa
+ if($showChart == true && in_array($spremenljivka['tip'],array(1,2,3,6,7,8,16,17,18,20,22)) && $_from != 'charts'){
+ echo '<a href="#" onclick="showAnalizaSingleChartPopup(\''.$spid.'\',\''.M_ANALYSIS_CHARTS.'\'); return false;">';
+ echo '<span class="faicon an_chart_bar icon-blue_soft_link" title="' . $lang['6'] . '"></span> ';
+ echo '</a>';
+ }
+
+ // Ikona za vkljucitev v porocilo
+ switch ($_from) {
+ case 'sums':
+ case 'sums*':
+ $type=1;
+ break;
+ case 'freq':
+ $type=2;
+ break;
+ case 'desc':
+ $type=3;
+ break;
+ case 'charts':
+ $type=4;
+ break;
+ }
+ if ($showReport == true) {
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type, $sub_type=0, $spid);
+ }
+
+
+ echo '</span>';
+ } else {
+
+ }
+ }
+
+
+
+ /** polovi opisne za vse spremenljivke
+ *
+ */
+ static public function getDescriptives() {
+ global $site_path;
+ $folder = $site_path . EXPORT_FOLDER.'/';
+ #array za imeni tmp fajlov, ki jih nato izbrišemo
+ $tmp_files = array( 'filtred'=>$folder . 'tmp_export_'.self::$sid.'_filtred'.TMP_EXT,
+ 'filtred1'=>$folder . 'tmp_export_'.self::$sid.'_filtred1'.TMP_EXT,
+ 'frequency'=>$folder . 'tmp_export_'.self::$sid.'_freqency'.'.php',
+ 'frequency1'=>$folder . 'tmp_export_'.self::$sid.'_freqency1'.'.php');
+
+ # naredimo datoteko z frekvencami
+ # za windows sisteme in za linux sisteme
+
+ # dodamo filter za loop-e
+ if (isset(self::$_CURRENT_LOOP['filter']) && self::$_CURRENT_LOOP['filter'] != '') {
+ $status_filter = self::$_CURRENT_STATUS_FILTER.' && '.self::$_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = self::$_CURRENT_STATUS_FILTER;
+ }
+
+ # s katero sekvenco se začnejo podatki, da ne delamo po nepotrebnem za ostala polja
+ $start_sequence = (isset(self::$_HEADERS['_settings']['dataSequence']) && (int)self::$_HEADERS['_settings']['dataSequence'] > 0 )
+ ? (int)self::$_HEADERS['_settings']['dataSequence']
+ : 8;
+
+ if (IS_WINDOWS) {
+ # sfiltriramo statuse
+ # $cmdLn1 = 'awk -F"|" "BEGIN {{OFS=\"\x7C\"} {ORS=\"\n\"} {FS=\"\x7C\"} {SUBSEP=\"\x7C\"}} '.$status_filter.' {for (i=4;i<=NF;i++) { arr[i,$i]++}} END {{for (n in arr) { print n,arr[n]}}}" '.self::$dataFileName. ' > '.$tmp_files['filtred'];
+ # odstranimo '
+ # $cmdLn2 = 'sed "s*\x27*`*g" '.$tmp_files['filtred'].' > '.$tmp_files['filtred1'];
+ # v loopu naredimo frekvence za vsa polja razen za prva 3 ki so tako unikatna
+ # $cmdLn3 = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} { print \"$frequency[\",$1,\"]\",\"[\x27\",$2,\"\x27]\",\"=\x27\",$3,\"\x27;\"}" '.$tmp_files['filtred1'].' >> '.$tmp_files['frequency'];
+
+ # združimo v eno vrstico da bo strežnik bol srečen
+ $command = 'awk -F"|" "BEGIN {{OFS=\"\x7C\"} {ORS=\"\n\"} {FS=\"\x7C\"} {SUBSEP=\"\x7C\"}} '.$status_filter.' {for (i='.$start_sequence.';i<=NF;i++) { arr[i,$i]++}} END {{for (n in arr) { print n,arr[n]}}}" '.self::$dataFileName;
+ $command .= ' | sed "s*\x27*`*g"';
+ $command .= ' | awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} { print \"$frequency[\",$1,\"]\",\"[\x27\",$2,\"\x27]\",\"=\x27\",$3,\"\x27;\"}" >> '.$tmp_files['frequency'];
+ } else {
+ #$cmdLn1 = 'awk -F"|" \'BEGIN {{OFS="|"} {ORS="\n"} {FS="|"} {SUBSEP="|"}} '.$status_filter.' {for (i=4;i<=NF;i++) { arr[i,$i]++}} END {{for (n in arr) { print n,arr[n]}}}\' '.self::$dataFileName. ' > '.$tmp_files['filtred'];
+ #$cmdLn2 = 'sed \'s*\x27*`*g\' '.$tmp_files['filtred'].' > '.$tmp_files['filtred1'];
+ #$cmdLn3 = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} { print "$frequency[",$1,"]","[\x27",$2,"\x27]","=\x27",$3,"\x27;"}\' '.$tmp_files['filtred1'].' >> '.$tmp_files['frequency'];
+
+ # združimo v eno vrstico da bo strežnik bol srečen
+ $command = 'awk -F"|" \'BEGIN {{OFS="|"} {ORS="\n"} {FS="|"} {SUBSEP="|"}} '.$status_filter.' {for (i='.$start_sequence.';i<=NF;i++) { arr[i,$i]++}} END {{for (n in arr) { print n,arr[n]}}}\' '.self::$dataFileName;
+ $command .= ' | sed \'s*\x27*`*g\'';
+ $command .= ' | awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} { print "$frequency[",$1,"]","[\x27",$2,"\x27]","=\x27",$3,"\x27;"}\' >> '.$tmp_files['frequency'];
+ }
+
+ #$out1 = shell_exec($cmdLn1);
+ #$out2 = shell_exec($cmdLn2);
+ $file_handler = fopen($tmp_files['frequency'],"w");
+ fwrite($file_handler,"<?php\n");
+ fclose($file_handler);
+ #$out3 = shell_exec($cmdLn3);
+
+ $out = shell_exec($command);
+
+ $file_handler = fopen($tmp_files['frequency'],"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_files['frequency']);
+
+
+ if (file_exists($tmp_files['frequency'])) {
+ unlink($tmp_files['frequency']);
+ }
+
+ if ($_GET['debug'] == 1) {
+ print_r("<pre>");
+ print_r("cl:".$command);
+ print_r("<br>Out".$out);
+ print_r("</pre>");
+ }
+
+ # inicializiramo
+ self::$_DESCRIPTIVES = array();
+
+ # kateri odgovori so z profilom nastavljeni kot manjkajoči
+ # se dodelijo k missing values in se ne upoštevajo pri povprečju
+ $_invalidAnswers = self :: getInvalidAnswers (MISSING_TYPE_DESCRIPTOR);
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ # izračunamo vse kar rabimo pri opisnih
+ foreach (self::$_HEADERS AS $spid => $spremenljivka) {
+ # kadar imamo pri spremenljvki missinge, tudi prikazujemmo veljavne procente najprej damo na false
+ # preverjamo da ni meta variabla
+ $vars_count = count(self::$_FILTRED_VARIABLES);
+ # frekvence delamo samo za izbrane variable
+ if ($spremenljivka['tip'] != 'm'
+ # filter po id spremenljivki
+ && ($vars_count == 0 || ($vars_count > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ) )
+ # filter po tipu (kategorije, besedila, number, drugo)
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES ) )
+ { // if != m
+
+ if (count($spremenljivka['grids'])>0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (count($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_freq = $frequency[$_sequence];
+ $min = null;
+ $max = null;
+
+ $_tmp_div = array();
+ self::$_DESCRIPTIVES[$_sequence]['sum_xi_fi'] = null;
+
+ #najprej odstranimo neveljavne, vse kaj ostane je veljavno
+ foreach ($_invalidAnswers AS $ikey =>$iAnswer) {
+ if (isset($_freq[$ikey])) {
+ self::$_DESCRIPTIVES[$_sequence]['invalidCnt'] += $_freq[$ikey];
+ self::$_DESCRIPTIVES[$_sequence]['allCnt'] += $_freq[$ikey];
+
+ unset($_freq[$ikey]);
+
+ }
+ }
+ # poiščemo minimum in maximum in povprečje
+
+ # opcijske odgovore dodamo samo vprašanjem ki niso tipa other in text
+ # zloopamo skozi vse opcije in jih dodamo k veljavnim
+ if ($variable['text'] != true && $variable['other'] != true && count($spremenljivka['options']) > 0) {
+ if (count($_freq) > 0) {
+
+ foreach($_freq AS $fKey => $fCnt) {
+ $flKey = (float)$fKey;
+
+ if (is_numeric($flKey) && trim($flkey) != '' ) {
+
+ self::$_DESCRIPTIVES[$_sequence]['validCnt'] += $fCnt;
+ self::$_DESCRIPTIVES[$_sequence]['allCnt'] += $fCnt;
+
+ $min = $min === null ? $flKey : min($min,$flKey) ;
+ $max = $max === null ? $flKey : max($max,$flKey) ;
+ self::$_DESCRIPTIVES[$_sequence]['sum_xi_fi'] += $flKey * $fCnt;
+ #vrednosti si shranimo za računanje divergence
+ $_tmp_div[$flKey] = $fCnt;
+ unset($_freq[$fKey]);
+ } else if (is_numeric($fKey) ) {
+ self::$_DESCRIPTIVES[$_sequence]['validCnt'] += $fCnt;
+ self::$_DESCRIPTIVES[$_sequence]['allCnt'] += $fCnt;
+
+ $min = $min === null ? $fKey : min($min,$fKey) ;
+ $max = $max === null ? $fKey : max($max,$fKey) ;
+ self::$_DESCRIPTIVES[$_sequence]['sum_xi_fi'] += $fKey * $fCnt;
+ #vrednosti si shranimo za računanje divergence
+ $_tmp_div[$fKey] = $fCnt;
+ unset($_freq[$fKey]);
+
+ }
+ }
+ }
+ }
+
+ #porihtamo še numerične in datumske spremenljivke
+ if (($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 8 || $spremenljivka['tip'] == 20 || $spremenljivka['tip'] == 18)
+ && ($variable['text'] != true && $variable['other'] != true)) {
+ if (count($_freq) > 0) {
+ foreach ($_freq AS $nkey => $nCnt) {
+ $fnkey = (float)$nkey; # popravimo morebitne .
+
+ if (is_numeric($nkey) && is_numeric($fnkey) && trim($fnkey) != '') {
+ self::$_DESCRIPTIVES[$_sequence]['validCnt'] += $nCnt;
+ self::$_DESCRIPTIVES[$_sequence]['allCnt'] += $nCnt;
+
+ $min = $min != null ? min($min,$fnkey) : $fnkey;
+ $max = $max != null ? max($max,$fnkey) : $fnkey;
+ self::$_DESCRIPTIVES[$_sequence]['sum_xi_fi'] += $fnkey * $nCnt;
+ #vrednosti si shranimo za računanje divergence
+ $_tmp_div[$fnkey] = $nCnt;
+ unset($_freq[$nkey]);
+ }
+ }
+ }
+
+ }
+ # lahko bi še za datum
+
+ # vse kaj ostane so textovni odgovori ali pa opcijski z nenumeričnim ključem
+ if (count($_freq) > 0) {
+ foreach ($_freq AS $tkey => $tCnt) {
+ if (isset($_allMissing_answers[$tkey])) {
+ $text = $_allMissing_answers[$tkey];
+ } else {
+ $text = $tkey;
+ }
+ self::$_DESCRIPTIVES[$_sequence]['valid'][$tkey] = array('text'=>$text,'cnt'=>$tCnt);
+
+ # samo prištejemo veljavne
+ self::$_DESCRIPTIVES[$_sequence]['validCnt'] += $tCnt;
+ self::$_DESCRIPTIVES[$_sequence]['allCnt'] += $tCnt;
+ unset($_freq[$tkey]);
+ }
+ }
+
+ # minimum in maximum
+ self::$_DESCRIPTIVES[$_sequence]['min'] = $min;
+ self::$_DESCRIPTIVES[$_sequence]['max'] = $max;
+ # povprečje
+
+ if (isset(self::$_DESCRIPTIVES[$_sequence]['sum_xi_fi'])) {
+ self::$_DESCRIPTIVES[$_sequence]['avg'] = self::$_DESCRIPTIVES[$_sequence]['validCnt'] > 0 ? self::$_DESCRIPTIVES[$_sequence]['sum_xi_fi'] / self::$_DESCRIPTIVES[$_sequence]['validCnt'] : 0;
+ }
+ #standardna diviacija
+ if (isset (self::$_DESCRIPTIVES[$_sequence]['avg'])) {
+ $N = self::$_DESCRIPTIVES[$_sequence]['validCnt'];
+ $avg = self::$_DESCRIPTIVES[$_sequence]['avg'];
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ foreach ($_tmp_div as $xi => $fi) {
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ self::$_DESCRIPTIVES[$_sequence]['div'] = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+ }
+ }
+ }
+ }
+ }
+ } // end if tip != m
+ } // end foreach
+ }
+
+ /** polovi frekvence za vse spremenljivke
+ *
+ */
+ static public function getFrequencys($awk_filter = null) {
+ global $site_path;
+ $folder = $site_path . EXPORT_FOLDER.'/';
+
+ # pobrišemo morebitne stare vrednosti
+ self::$_FREQUENCYS = array();
+
+ #array za imeni tmp fajlov, ki jih nato izbrišemo
+ $tmp_files = array( 'frequency'=>$folder . 'tmp_export_'.self::$sid.'_freqency'.'.php');
+
+
+ # dodamo filter za loop-e
+ if (isset(self::$_CURRENT_LOOP['filter']) && self::$_CURRENT_LOOP['filter'] != '') {
+ $status_filter = self::$_CURRENT_STATUS_FILTER.' && '.self::$_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = self::$_CURRENT_STATUS_FILTER;
+ }
+
+ # dodamo še dodaten awk filter če je nastavljen - (za break)
+ if ($awk_filter != null) {
+ $status_filter = '('.$status_filter.'&&'.$awk_filter.')';
+ }
+
+ # s katero sekvenco se začnejo podatki, da ne delamo po nepotrebnem za ostala polja
+ $start_sequence = (isset(self::$_HEADERS['_settings']['dataSequence']) && (int)self::$_HEADERS['_settings']['dataSequence'] > 0 )
+ ? (int)self::$_HEADERS['_settings']['dataSequence']
+ : 8;
+
+ # s katero sekvenco se končajo podatki da ne delamo po nepotrebnem za ostala polja
+ $end_sequence = $start_sequence;
+ if (!empty(self::$_HEADERS))
+ {
+ foreach (self::$_HEADERS AS $skey => $spremenljivka)
+ {
+ $tip = $spremenljivka['tip'];
+
+ if (is_numeric($tip)) {
+
+ if (count($spremenljivka['grids'] ) > 0) {
+
+ foreach ($spremenljivka['grids'] as $gid => $grid ){
+
+ if (is_countable($grid['variables']) && count($grid['variables']) > 0) {
+
+ foreach ($grid['variables'] as $vid => $variable ){
+ $end_sequence = max($end_sequence, (int)$variable['sequence']);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ # naredimo datoteko z frekvencami
+ # za windows sisteme in za linux sisteme
+ if (IS_WINDOWS ) {
+ # TEST z LINUX načinom
+ # združimo v eno vrstico da bo strežnik bol srečen
+ $command = 'awk -F"|" "BEGIN {{OFS=\"\x7C\"} {ORS=\"\n\"} {FS=\"\x7C\"} {SUBSEP=\"\x7C\"}} '.$status_filter.' {for (i='.$start_sequence.';i<='.$end_sequence.';i++) { arr[i,$i]++}} END {{for (n in arr) { print n,arr[n]}}}" '.self::$dataFileName;
+ $command .= ' | sed "s*\x27*`*g" ';
+ $command .= ' | awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} { print \"$frequency[\",$1,\"]\",\"[\x27\",$2,\"\x27]\",\"=\x27\",$3,\"\x27;\"}" >> '.$tmp_files['frequency'];
+ }
+ else {
+ # združimo v eno vrstico da bo strežnik bol srečen
+ $command = 'awk -F"|" \'BEGIN {{OFS="|"} {ORS="\n"} {FS="|"} {SUBSEP="|"}} '.$status_filter.' {for (i='.$start_sequence.';i<='.$end_sequence.';i++) { arr[i,$i]++}} END {{for (n in arr) { print n,arr[n]}}}\' '.self::$dataFileName;
+ $command .= ' | sed \'s*\x27*`*g\' ';
+ $command .= ' | awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} { print "$frequency[",$1,"]","[\x27",$2,"\x27]","=\x27",$3,"\x27;"}\' >> '.$tmp_files['frequency'];
+ }
+
+ $file_handler = fopen($tmp_files['frequency'],"w");
+ fwrite($file_handler,"<?php\n");
+ fclose($file_handler);
+
+ $out = shell_exec($command);
+
+ $file_handler = fopen($tmp_files['frequency'],"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_files['frequency']);
+
+
+ # pobrišemo sfiltrirane podatke, ker jih več ne rabimo
+ if (file_exists($tmp_files['frequency'])) {
+ unlink($tmp_files['frequency']);
+ }
+
+
+ # kateri odgovori so z profilom nastavljeni kot manjkajoči
+ # se dodelijo k missing values in se ne upoštevajo pri povprečju
+ # dodano se za break, ker drugace so bila v breaku negativna povprecja. Mozno da to ne bo ok za nekatere primere breaka??
+ if (self::$podstran == M_ANALYSIS_BREAK || self::$podstran == M_ANALYSIS_SUMMARY || self::$podstran == M_ANALYSIS_SUMMARY_NEW || self::$podstran == 'sums' || self::$podstran == 'sums_rtf' || self::$podstran == 'sums_xls') {
+ $_invalidAnswers = self :: getInvalidAnswers (MISSING_TYPE_DESCRIPTOR);
+ } else {
+ $_invalidAnswers = self :: getInvalidAnswers (MISSING_TYPE_FREQUENCY);
+ }
+
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ # izračunamo vse frekvence oziroma vse kar rabimo pri analizah
+ if(!empty(self::$_HEADERS))
+ foreach (self::$_HEADERS AS $spid => $spremenljivka)
+ {
+ # kadar imamo pri spremenljvki missinge, tudi prikazujemmo veljavne procente najprej damo na false
+ self::$_HEADERS[$spid]['show_valid_percent'] = false;
+ # preverjamo da ni meta variabla
+ $vars_count = count(self::$_FILTRED_VARIABLES);
+ # frekvence delamo samo za izbrane variable
+ if ($spremenljivka['tip'] != 'm'
+ # filter po id spremenljivki
+ && ($vars_count == 0 || ($vars_count > 0 && isset(self::$_FILTRED_VARIABLES[$spid]) ) )
+ # filter po tipu (kategorije, besedila, number, drugo)
+ && in_array($spremenljivka['tip'], self::$_FILTRED_TYPES ) ) {
+
+
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ self::$_HEADERS[$spid]['show_valid_percent'] = true;
+ }
+ if (count ($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_freq = $frequency[$_sequence];
+
+ #najprej dodamo neveljavne, vse kaj ostane je veljavno
+ foreach ($_invalidAnswers AS $ikey =>$iAnswer) {
+ if (self::$frequencyAddInvalid) {
+ self::$_FREQUENCYS[$_sequence]['invalid'][$ikey] = $iAnswer;
+ }
+ if (isset($_freq[$ikey])) {
+ if (self::$frequencyAddInvalid) {
+ self::$_FREQUENCYS[$_sequence]['invalid'][$ikey]['cnt'] = $_freq[$ikey];
+ self::$_FREQUENCYS[$_sequence]['invalidCnt'] += $_freq[$ikey];
+ self::$_FREQUENCYS[$_sequence]['allCnt'] += $_freq[$ikey];
+ }
+ unset($_freq[$ikey]);
+
+ # kadar imamo pri spremenljvki missinge, tudi prikazujemmo veljavne procente
+ self::$_HEADERS[$spid]['show_valid_percent'] = true;
+ }
+ }
+ # opcijske odgovore dodamo samo vprašanjem ki niso tipa other in text
+ # zloopamo skozi vse opcije in jih dodamo k veljavnim
+ if ($variable['text'] != true && $variable['other'] != true && is_countable($spremenljivka['options']) && count($spremenljivka['options']) > 0) {
+ foreach ($spremenljivka['options'] AS $okey => $oAnswer) {
+
+ self::$_FREQUENCYS[$_sequence]['valid'][$okey]['text'] = $oAnswer;
+ self::$_FREQUENCYS[$_sequence]['valid'][$okey]['text_graf'] = $spremenljivka['options_graf'][$okey];
+ self::$_FREQUENCYS[$_sequence]['valid'][$okey]['cnt'] = 0;
+
+ if (isset($_freq[$okey])) {
+ self::$_FREQUENCYS[$_sequence]['valid'][$okey]['cnt'] = $_freq[$okey];
+ self::$_FREQUENCYS[$_sequence]['validCnt'] += $_freq[$okey];
+ self::$_FREQUENCYS[$_sequence]['allCnt'] += $_freq[$okey];
+
+ unset($_freq[$okey]);
+ }
+
+ }
+ }
+
+ # vse kaj ostane so textovni ali numerični odgovori
+ if (is_countable($_freq) && count($_freq) > 0) {
+ $_ifreq = array();
+ # nardimo case-insensitive
+ foreach ($_freq AS $tkey => $tCnt) {
+ //if($spremenljivka['tip'] != 26)
+ if($spremenljivka['tip'] != 26 && $spremenljivka['tip'] != 27)
+ $tkey = mb_strtolower($tkey,'UTF-8');
+ $_ifreq[$tkey] += $tCnt;
+ }
+
+ $_average = array();
+
+ if(is_countable($spremenljivka['options']))
+ $i = count($spremenljivka['options']) + 1;
+ else
+ $i = 0;
+
+ foreach ($_ifreq AS $tkey => $tCnt) {
+
+ # preverimo ali je slučanjo odgovor missing vendar je določen kot veljavni odgovor
+ if (isset($_allMissing_answers[$tkey])) {
+ $text = $tkey . ' '.$_allMissing_answers[$tkey];
+ }
+ else {
+ $text = $tkey;
+ }
+
+ self::$_FREQUENCYS[$_sequence]['valid'][$tkey] = array('text'=>$text,'cnt'=>$tCnt,'text_graf'=>$spremenljivka['options_graf'][$i]);
+ self::$_FREQUENCYS[$_sequence]['validCnt'] += $tCnt;
+ self::$_FREQUENCYS[$_sequence]['allCnt'] += $tCnt;
+ //Uros dodal, ker se drugace pri radio ne ve, kaksen je text opcije drugo
+ if($variable['other'])
+ self::$_FREQUENCYS[$_sequence]['valid'][$tkey]['other'] = $variable['naslov'];
+
+ # povprečje
+ if (is_numeric($tkey)) {
+ $_average['product'] = $_average['product'] + ($tkey * $tCnt);
+ $_average['cnt'] = $_average['cnt'] + $tCnt;
+ }
+ unset($_freq[$tkey]);
+
+ $i++;
+ }
+ self::$_FREQUENCYS[$_sequence]['average'] = ($_average['cnt'] > 0) ? $_average['product'] / $_average['cnt'] : $_average['cnt'];
+ }
+ unset($frequency[$_sequence]);
+ }
+ }
+ } // end if tip != m
+ }
+ unset($frequency);
+
+ return self::$_FREQUENCYS;
+ }
+
+ static function frequencyAddInvalid($doAdd = true) {
+ self::$frequencyAddInvalid = $doAdd;
+ }
+ /** polovi dejanske odgovore za spremenljivko
+ * @param $need_user_id - ali se rabi tudi vrniti user_id?
+ */
+ static public function getAnswers($spremenljivka, $limit=10, $need_user_id = false) {
+ global $site_path;
+
+ $folder = $site_path . EXPORT_FOLDER.'/';
+ $result = array();
+ $sequences = array();
+ $sequenc_filter = array();
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ) {
+ $sequences[] = '$'.$variable['sequence'];
+ if (IS_WINDOWS ) {
+ $sequenc_filter[] = '\''.$variable['sequence'].'\'=\x3E\",\"\x27\",$'.$variable['sequence'].',\"\x27';
+ } else {
+ $sequenc_filter[] = '\''.$variable['sequence'].'\'=\x3E","\x27",$'.$variable['sequence'].',"\x27';
+ }
+ }
+ }
+ }
+ }
+
+ # pobrišemo morebitne stare vrednosti
+ #array za imeni tmp fajlov, ki jih nato izbrišemo
+ $tmp_files = array( 'filtred'=>$folder . 'tmp_export_'.self::$sid.'_filtred'.TMP_EXT,
+ 'filtred1'=>$folder . 'tmp_export_'.self::$sid.'_filtred1'.TMP_EXT,
+ 'filtred_pagination'=>$folder . 'tmp_export_'.self::$sid.'_pagination'.TMP_EXT,
+ 'answers'=>$folder . 'tmp_export_'.self::$sid.'_answers'.'.php');
+
+ # dodamo filter za loop-e
+ if (isset(self::$_CURRENT_LOOP['filter']) && self::$_CURRENT_LOOP['filter'] != '') {
+ $status_filter = self::$_CURRENT_STATUS_FILTER.' && '.self::$_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = self::$_CURRENT_STATUS_FILTER;
+ }
+
+ // Limit po novem omejimo z filtriranjem array-a
+ //$_REC_LIMIT = ' NR==1,NR=='.$limit;
+
+ //za tip lokacija (ne enota 3) se rabi user_id, ker se kasneje delajo linki
+ $array_key = $need_user_id ? '{x=$1}' : '{x++}';
+
+ # naredimo datoteko z frekvencami
+ # za windows sisteme in za linux sisteme
+ if (IS_WINDOWS ) {
+ # TEST z LINUX načinom
+ # $cmdLn1 = 'awk -F"|" "BEGIN {{OFS=\"\x7C\"} {ORS=\"\n\"} {FS=\"\x7C\"} {SUBSEP=\"\x7C\"}} '.$status_filter.' { print $0}" '.self::$dataFileName. ' > '.$tmp_files['filtred'];
+ # $cmdLn2 = 'sed "s*\x27*`*g" '.$tmp_files['filtred'].' > '.$tmp_files['filtred1'];
+ # $cmdLn4 = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} {x++} { print \"$answers[\",x,\"]=array('.implode(',',$sequenc_filter).');\"}" '.$tmp_files['filtred1'].' >> '.$tmp_files['answers'];
+
+ $command = 'awk -F"|" "BEGIN {{OFS=\"\x7C\"} {ORS=\"\n\"} {FS=\"\x7C\"} {SUBSEP=\"\x7C\"}} '.$status_filter.' { print $0}" '.self::$dataFileName;
+ $command .= ' | sed "s*\x27*`*g"';
+ $command .= ' | awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$array_key.' { print \"$answers[\",x,\"]=array('.implode(',',$sequenc_filter).');\"}" >> '.$tmp_files['answers'];
+ } else {
+ # $cmdLn1 = 'awk -F"|" \'BEGIN {{OFS="|"} {ORS="\n"} {FS="|"} {SUBSEP="|"}} '.$status_filter.' {print $0}\' '.self::$dataFileName. ' > '.$tmp_files['filtred'];
+ # $cmdLn2 = 'sed \'s*\x27*`*g\' '.$tmp_files['filtred'].' > '.$tmp_files['filtred1'];
+ # $cmdLn4 = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} {x++} { print "$answers[",x,"]=array('.implode(',',$sequenc_filter).');"}\' '.$tmp_files['filtred1'].' >> '.$tmp_files['answers'];
+
+ $command = 'awk -F"|" \'BEGIN {{OFS="|"} {ORS="\n"} {FS="|"} {SUBSEP="|"}} '.$status_filter.' {print $0}\' '.self::$dataFileName;
+ $command .= ' | sed \'s*\x27*`*g\'';
+ $command .= ' | awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$array_key.' { print "$answers[",x,"]=array('.implode(',',$sequenc_filter).');"}\' >> '.$tmp_files['answers'];
+ }
+
+ #$out1 = shell_exec($cmdLn1);
+ #$out2 = shell_exec($cmdLn2);
+ $file_handler = fopen($tmp_files['answers'],"w");
+ fwrite($file_handler,"<?php\n");
+ fclose($file_handler);
+ // limit po novem omejimo z filtriranjem arraya
+ #$out3 = shell_exec($cmdLn3);
+ #$out4 = shell_exec($cmdLn4);
+ $out = shell_exec($command);
+
+ $file_handler = fopen($tmp_files['answers'],"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_files['answers']);//tukaj se deklarira spremenljivka $answers
+
+
+ if (file_exists($tmp_files['answers'])) {
+ unlink($tmp_files['answers']);
+ }
+
+ # PREFILTRIRAMO PODATKE PO POTREBI ODSTRANIMO MANJKAJOČE VREDNOSTI
+ # zloopamo skozi celotne odgovore in odstranimo tiste ki so missingi
+
+ # kateri odgovori so z profilom nastavljeni kot manjkajoči
+ # se dodelijo k missing values in se ne upoštevajo pri povprečju
+ $_invalidAnswers = self :: getInvalidAnswers (MISSING_TYPE_FREQUENCY);
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ $_result_answers = array();
+ $_result_answers['validCnt'] = 0;
+
+ if (count($answers) > 0) {
+ foreach ($answers AS $akey => $answer) {
+ $cnt++;
+ $all_invalid = true; # ali je vse neveljavno
+ foreach ($answer AS $seq => $value) {
+ # preverimo ali je kateri odgovor od userja vlejaven
+ if (!isset($_allMissing_answers[$value]) && !isset($_invalidAnswers[$value])) {
+ $all_invalid = false;
+ }
+ # ločimo odgovore na veljavne in nevlejavne
+ }
+
+ if ($all_invalid == FALSE) {
+ # imamo vsaj en veljaven odgovor
+ if ($limit == -1 || $_result_answers['validCnt'] < $limit) {
+ //ce smo nastavili $need_user_id, vkljucimo user_id kot key odgovorov v valid array
+ if(!$need_user_id)
+ $_result_answers['valid'][] = $answer;
+ else
+ $_result_answers['valid'][$akey] = $answer;
+ }
+ # koliko je vseh veljavnih
+ $_result_answers['validCnt']++;
+ } else {
+ # vsi odgovori so neveljavni
+ $_result_answers['invalid'][] = $answer;
+ $_result_answers['invalidCnt']++;
+ }
+ $_result_answers['allCnt']++;
+ }
+ }
+ return $_result_answers;
+ }
+
+ public static function showspremenljivkaSingleVarPopup($id) {
+ global $lang;
+
+ self::$_forceShowEmpty = true;
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+
+ $anketa = $_REQUEST['anketa'];
+ if ($anketa > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '$anketa'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['value'];
+ }
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ # vse elemente forem
+ echo "<script>"."\n";
+ echo "$(document).ready(function(){ $('#div_analiza_single_var input:[type=radio], #div_analiza_single_var input:[type=checkbox], #div_analiza_single_var input:[type=text], #div_analiza_single_var select, #div_analiza_single_var textarea').attr('disabled',true); })"."\n";
+ echo "</script>";
+ echo '</head>';
+
+ echo '<body onBlur="window.close()" style="margin:5px; padding:5px;">';
+ echo '<input type="hidden" name="podstran" id="srv_meta_podstran" value="' . $zaPodstran . '" />';
+ echo '<input type="hidden" name="anketa_id" id="srv_meta_anketa_id" value="' . $_REQUEST['anketa'] . '" />';
+ $id = $_POST['id'];
+ $spremenljivka = self::$_HEADERS[$id];
+ $_tip = self::getSpremenljivkaLegenda($spremenljivka,'tip');
+ $zaPodstran = $_POST['zaPodstran'];
+
+ $legend = Cache::spremenljivkaLegenda($id);
+
+ echo '<span class="spaceRight">';
+ self::showIcons($id,$spremenljivka,'desc');
+ echo '</span>';
+ echo '<span class="spaceRight">'.$lang['srv_analiza_opisne_variable_type'].': ';
+ echo $_tip.' ';
+ echo '('.$legend['izrazanje'].' - '.$legend['lestvica'].')';
+ echo ' </span>';
+ echo '<br class="clr"/>';
+ echo '<br class="clr"/>';
+ echo '<div id="div_analiza_single_var" class="container"> ';
+ self:: showPreviewSpremenljivka($id);
+ echo '</div>';
+ echo '<div id="navigationBottom" class="printHide">';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="close_win(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="window.print();return false;"><span><img src="icons/icons/printer.png" alt="'.$lang['hour_print2'].'" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+ echo '<div class="clr"></div>';
+ echo '</div>';
+ echo '</body>';
+ echo '</html>';
+ }
+
+ public static function showSpremenljivkaTextAnswersPopup($id,$seq) {
+ global $lang;
+ self::$_forceShowEmpty = true;
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+
+ $anketa = $_REQUEST['anketa'];
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ echo '</head>';
+
+ echo '<body onBlur="window.close()" style="margin:5px; padding:5px;">';
+
+ echo '<input type="hidden" name="podstran" id="srv_meta_podstran" value="' . $zaPodstran . '" />';
+ echo '<input type="hidden" name="anketa_id" id="srv_meta_anketa_id" value="' . $_REQUEST['anketa'] . '" />';
+ echo '<div id="div_analiza_single_var" class="container">';
+ $id = $_POST['id'];
+ $seq = $_POST['seq'];
+ $zaPodstran = $_POST['zaPodstran'];
+ $spremenljivka = self::$_HEADERS[$id];
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ $num_show_records = 9999999;
+ # poiščemo navedbe textovne spremenljivke tako kot v grafih
+ $_answers = self::getAnswers($spremenljivka,$num_show_records);
+ if (count($_answers['valid']) > 0) {
+ echo '<table class="anl_tbl anl_bl anl_bt tbl_clps">';
+ foreach ($_answers['valid'] AS $vkey => $valid) {
+ $_valid = $valid[$seq];
+
+
+ echo '<tr><td class="anl_bck_0_1 anl_br anl_bb anl_user_text">';
+ echo $_valid;
+ echo '</td></tr>';
+ }
+ echo '</table>';
+ echo '<br />';
+ }
+ echo '</div>';
+ echo '<div id="navigationBottom" class="printHide">';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="close_win(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="window.print();return false;"><span><img src="icons/icons/printer.png" alt="'.$lang['hour_print2'].'" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+ echo '<div class="clr"></div>';
+ echo '</div>';
+ echo '</body>';
+ echo '</html>';
+ }
+
+ /** Prikaže opsine, frekvence, sumarnik, za samo eno variablo
+ *
+ * @param unknown_type $id
+ */
+ public static function DisplaySingleVarPopup ($id,$zaPodstran)
+ {
+ global $site_url, $lang;
+ self::$_forceShowEmpty = true;
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+
+ $anketa = $_REQUEST['anketa'];
+
+ if ($anketa > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '$anketa'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['value'];
+ }
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;} .chart_settings {display: none;} .chart_holder{width: 800px;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ echo '</head>';
+
+ #echo '<body onBlur="window.close()" style="margin:5px; padding:5px;">';
+ echo '<body style="margin:5px; padding:5px;">';
+ echo '<input type="hidden" name="podstran" id="srv_meta_podstran" value="' . $zaPodstran . '" />';
+ echo '<input type="hidden" name="anketa_id" id="srv_meta_anketa_id" value="' . $_REQUEST['anketa'] . '" />';
+
+ echo '<div id="div_analiza_single_var" class="container">';
+ $id = $_POST['id'];
+ $zaPodstran = $_POST['zaPodstran'];
+
+ # polovimo nastavtve missing profila
+ self::$missingProfileData = SurveyMissingProfiles::getProfile(self::$currentMissingProfile);
+ if (self::$podstran != M_ANALYSIS_ARCHIVE)
+ {
+ self::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ }
+ if (!is_array(self::$_LOOPS))
+ {
+ self::$_LOOPS[] = array('filter'=>null,'text'=>null);
+ }
+
+ $loop_cnt = 0;
+ # ce mamo zanke
+ foreach ( self::$_LOOPS AS $loop)
+ {
+ if ($loop['filter'] != null)
+ {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ self::$_CURRENT_LOOP = $loop;
+ if ((int)$loop_cnt == (int)$_POST['loop'])
+ {
+
+ echo '<h2 data-loopId="'.self::$_CURRENT_LOOP['cnt'].'">'.$lang['srv_zanka_note'].$loop['text'].'</h2>';
+ }
+ }
+ if ((int)$loop_cnt == (int)$_POST['loop'])
+ {
+ switch ($zaPodstran)
+ {
+ case M_ANALYSIS_SUMMARY_NEW :
+ self::displaySumsNew($id);
+ $export = 'sums';
+ break;
+ case M_ANALYSIS_SUMMARY :
+ self::displaySums($id);
+ $export = 'sums';
+ break;
+ case M_ANALYSIS_DESCRIPTOR :
+ self::displayDescriptives($id);
+ $export = 'statistics';
+ break;
+ case M_ANALYSIS_FREQUENCY :
+ self::displayFrequency($id);
+ $export = 'frequency';
+ break;
+ case M_ANALYSIS_CHARTS :
+ $chartClass = new SurveyChart();
+ $chartClass->Init($anketa);
+ $chartClass->displaySingle($id);
+ $export = 'charts';
+ break;
+ }
+ //Izvoz v PDF/RTF
+ $loop_exp = (isset(self::$_CURRENT_LOOP)) ? self::$_CURRENT_LOOP['cnt'] : 'undefined';
+ $_url1 = $site_url.'admin/survey/izvoz.php?dc='.base64_encode(
+ serialize(
+ array( 'b'=>'export',
+ 'm'=>$export,
+ 'anketa'=>$anketa,
+ 'sprID'=>$id,
+ 'loop'=>$loop_exp)));
+ $_url2 = $site_url.'admin/survey/izvoz.php?dc='.base64_encode(
+ serialize(
+ array( 'b'=>'export',
+ 'm'=>$export.'_rtf',
+ 'anketa'=>$anketa,
+ 'sprID'=>$id,
+ 'loop'=>$loop_exp)));
+ $_url3 = $site_url.'admin/survey/izvoz.php?dc='.base64_encode(
+ serialize(
+ array( 'b'=>'export',
+ 'm'=>$export.'_xls',
+ 'anketa'=>$anketa,
+ 'sprID'=>$id,
+ 'loop'=>$loop_exp)));
+
+ echo '<div id="single_export" class="printHide">';
+ echo '<a href="'.$_url1.'" target="_blank"><span class="faicon pdf"></span></a>';
+ echo '&nbsp;&nbsp;<a href="'.$_url2.'" target="_blank"><span class="faicon rtf"></span>&nbsp;</a>';
+ //if($export == 'frequency')
+ if($zaPodstran != M_ANALYSIS_CHARTS )
+ {
+ echo '&nbsp;&nbsp;<a href="'.$_url3.'" target="_blank"><span class="faicon xls"></span>&nbsp;</a>';
+ }
+ }
+
+ }
+
+ echo '</div>';
+ echo '<div class="clr"></div>';
+ echo '<div id="navigationBottom" class="printHide">';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="close_win(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="window.print();return false;"><span><img src="icons/icons/printer.png" alt="'.$lang['hour_print2'].'" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+ echo '<div class="clr"></div>';
+ echo '</div>';
+ echo '</body>';
+ echo '</html>';
+ }
+
+ /** Sestavi array nepravilnih odgovorov
+ *
+ */
+ static function getInvalidAnswers($type) {
+ $result = array();
+ $missingValuesForAnalysis = SurveyMissingProfiles :: GetMissingValuesForAnalysis($type);
+
+ foreach ($missingValuesForAnalysis AS $k => $answer) {
+ $result[$k] = array('text'=>$answer,'cnt'=>0);
+ }
+ return $result;
+ }
+
+
+ static function formatNumber ($value, $digit = 0, $sufix = "") {
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+ # polovimo decimalna mesta in vejice za tisočice
+
+ $decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+
+ $result = number_format($result, $digit, $decimal_point, $thousands) . $sufix;
+
+ return $result;
+ }
+
+ static function getSpremenljivkaLegenda ($spremenljivka, $what='') {
+
+ $legenda = Cache::spremenljivkaLegenda($spremenljivka['spr_id']);
+
+ return $legenda[$what];
+ }
+
+
+ /** razdelek za Ajax klice
+ *
+ */
+ public function ajax() {
+ if (isset ($_POST['corssVar1']))
+ $corssVar1 = $_POST['corssVar1'];
+ if (isset ($_POST['corssVar2']))
+ $corssVar2 = $_POST['corssVar2'];
+ if (isset ($_POST['corssZanka']))
+ $corssZanka = $_POST['corssZanka'];
+ if (isset ($_POST['crossChk0']))
+ $crossChk0 = $_POST['crossChk0'];
+ if (isset ($_POST['crossChk1']))
+ $crossChk1 = $_POST['crossChk1'];
+ if (isset ($_POST['crossChk2']))
+ $crossChk2 = $_POST['crossChk2'];
+ if (isset ($_POST['crossChk3']))
+ $crossChk3 = $_POST['crossChk3'];
+ if (isset ($_POST['crossChkEC']))
+ $crossChkEC = $_POST['crossChkEC'];
+ if (isset ($_POST['crossChkRE']))
+ $crossChkRE = $_POST['crossChkRE'];
+ if (isset ($_POST['crossChkSR']))
+ $crossChkSR = $_POST['crossChkSR'];
+ if (isset ($_POST['crossChkAR']))
+ $crossChkAR = $_POST['crossChkAR'];
+ if (isset ($_POST['doColor']))
+ $doColor = $_POST['doColor'];
+
+ switch ($_GET['a']) {
+ case 'loadMissingProfile' :
+ self :: loadMissingProfile();
+ break;
+ case 'reloadData' :
+ self :: Display();
+ break;
+ case 'showAnalizaSingleVarPopup' :
+ self :: DisplaySingleVarPopup($_POST['id'],$_POST['zaPodstran']);
+ break;
+ case 'showspremenljivkaSingleVarPopup' :
+ self :: showspremenljivkaSingleVarPopup($_POST['id']);
+ break;
+ case 'showSpremenljivkaTextAnswersPopup' :
+ self :: showSpremenljivkaTextAnswersPopup($_POST['id'],$_POST['seq']);
+ break;
+ case 'show_crostabs_dropdowns' :
+ self :: displayDropdowns($corssVar1, $corssVar2, $corssZanka);
+ break;
+ case 'show_crostabs_table' :
+ self :: displayCrosstabsTable($corssVar1, $corssVar2, $corssZanka, $crossChk0, $crossChk1, $crossChk2, $crossChk3, $crossChkEC, $crossChkRE, $crossChkSR, $crossChkAR, $doColor);
+ break;
+ case 'preview_spremenljivka' :
+ self:: showPreviewSpremenljivka($_POST['spremenljivka']);
+ break;
+ case 'printPreview_spremenljivka' :
+ self:: printPreviewSpremenljivka($_POST['id']);
+ break;
+ case 'toggleAnalysisAdvanced' :
+ self:: toggleAnalysisAdvanced();
+ break;
+ case 'changeAnalizaPreview' :
+ self:: changeAnalizaPreview();
+ break;
+ case 'show_spid_more_table' :
+ self:: show_sum_more_table();
+ break;
+ case 'changeSpremenljivkaLestvica' :
+ self:: changeSpremenljivkaLestvica();
+ break;
+ default:
+ echo 'Error! (class: SurveyAnalysis->ajax() - missing action)';
+ break;
+ }
+ }
+ /** izpiše linke - povezave do pdf ,rtf datotek vprašalnika in analiz
+ *
+ */
+ public static function DisplayReportsLinks() {
+ global $lang, $global_user_id;
+
+ if (self::$dataFileStatus == FILE_STATUS_NO_DATA || self::$dataFileStatus == -3 || self::$noHeader == true) {
+ return false;
+ }
+
+ SurveyUserSetting :: getInstance()->Init(self::$sid, $global_user_id);
+
+ SurveyAnalysis::DisplayFilters();
+
+ /*
+ // Link na navadna porocila
+ echo '<div id="custom_report_switch" class="creport"><a href="index.php?anketa='.self::$sid.'&a=analysis&m=analysis_links"><span>'.$lang['srv_standard_report'].'</span></a></div>';
+ // Link na porocilo po meri
+ echo '<div id="custom_report_switch"><a href="index.php?anketa='.self::$sid.'&a=analysis&m=analysis_creport"><span>'.$lang['srv_custom_report'].'</span></a></div>';
+ */
+
+ echo '<table class="analysis_reports"><tr>';
+
+ // ANALIZE
+ echo '<td>';
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_analiza'].'</legend>';
+
+ # linki - analize sumarnik
+ echo '<span class="subtitle">' . $lang['srv_sumarnik'] . '</span>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=sums&anketa='.self::$sid).'" target="_blank">' .
+ '<span class="faicon pdf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;PDF - (Adobe Acrobat)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=sums_rtf&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon rtf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;DOC - (Microsoft Word)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=sums_xls&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon xls" title="' . $lang['srv_reporti'] . '"></span>&nbsp;XLS - (Microsoft Excel)</a>';
+
+ # linki - analize opisne statistike
+ echo '<span class="subtitle">' . $lang['srv_descriptor'] . '</span>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=statistics&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon pdf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;PDF - (Adobe Acrobat)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=statistics_rtf&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon rtf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;DOC - (Microsoft Word)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=statistics_xls&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon xls" title="' . $lang['srv_reporti'] . '"></span>&nbsp;XLS - (Microsoft Excel)</a>';
+
+ # linki - analize frekvence
+ echo '<span class="subtitle">' . $lang['srv_frequency'] . '</span>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=frequency&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon pdf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;PDF - (Adobe Acrobat)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=frequency_rtf&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon rtf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;DOC - (Microsoft Word)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=frequency_xls&anketa=' . self::$sid).'" target="_blank">' .
+ '<span class="faicon xls" title="' . $lang['srv_reporti'] . '"></span>&nbsp;XLS - (Microsoft Excel)</a>';
+
+ echo '</fieldset>';
+
+ // VPRASALNIK
+ echo '</td><td>';
+ echo '<fieldset style="padding-top: 10px;">';
+ echo '<legend>'.$lang['srv_analysis_links_survey'].'</legend>';
+
+ # linki - vprašalnik
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?a=' . A_REPORT_VPRASALNIK_PDF . '&anketa=' . self::$sid) . '" target="_blank">' .
+ '<span class="faicon pdf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;PDF - (Adobe Acrobat)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?a=' . A_REPORT_VPRASALNIK_RTF . '&anketa=' . self::$sid) . '" target="_blank">' .
+ '<span class="faicon rtf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;DOC - (Microsoft Word)</a>';
+
+ echo '</fieldset>';
+
+ // IZPIS
+ echo '</td><td>';
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_statistic'].'</legend>';
+
+ # linki - vpogled
+ echo '<span class="subtitle">' . $lang['srv_analysis_links_vpogled'] . '</span>';
+ echo '<a href="index.php?anketa='.self::$sid.'&a=data&m=quick_edit&quick_view=1" >' .
+ '<span title="' . $lang['srv_link_data_view'] . '"></span>' . $lang['srv_link_data_view'] . '</a>';
+
+ # linki - izpis vseh odgovorov
+ echo '<span class="subtitle">' . $lang['srv_analysis_links_allAnswers'] . '</span>';
+ echo '<span class="clr">' . $lang['srv_analysis_links_allAnswers_note'] . '</span><br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?a=pdf_results&anketa=' . self::$sid) . '" target="_blank">' .
+ '<span class="faicon pdf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;PDF - (Adobe Acrobat)</a>';
+ echo '<br/>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?a=rtf_results&anketa=' . self::$sid) . '" target="_blank">' .
+ '<span class="faicon rtf" title="' . $lang['srv_reporti'] . '"></span>&nbsp;DOC - (Microsoft Word)</a>';
+
+ echo '</fieldset>';
+ echo '</td>';
+
+ echo '</tr></table>';
+ }
+
+ private static function printAnalizaSingleVar() {
+ global $lang;
+
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+
+ $anketa = $_REQUEST['anketa'];
+ if ($anketa > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '$anketa'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['value'];
+ }
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ echo '</head>';
+
+ echo '<body onBlur="window.close()" style="margin:5px; padding:5px;">';
+ echo '<div class="container"> ';
+ $id = $_POST['id'];
+ $zaPodstran = $_POST['zaPodstran'];
+ switch ($zaPodstran) {
+ case M_ANALYSIS_SUMMARY_NEW :
+ self::displaySumsNew($id);
+ break;
+ case M_ANALYSIS_SUMMARY :
+ self::displaySums($id);
+ break;
+ case M_ANALYSIS_DESCRIPTOR :
+ self::displayDescriptives($id);
+ break;
+ case M_ANALYSIS_FREQUENCY :
+ self::displayFrequency($id);
+ break;
+ }
+ echo '</div>';
+ echo '<div id="navigationBottom" class="printHide">';
+ echo '<span class="floatRight spaceLeft"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="close_win(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="print_win(); return false;"><span><img src="icons/icons/printer.png" alt="'.$lang['hour_print2'].'" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+ echo '<br class="clr"/>';
+ echo '</div>';
+ echo '</body>';
+ echo '</html>';
+
+ }
+
+ function showPreviewSpremenljivka($spremenljivka) {
+ global $lang, $site_path;
+
+ SurveyInfo :: getInstance()->SurveyInit($anketa);
+
+ $offset = 0;
+ $zaporedna = 0;
+ $count_type = SurveyInfo :: getInstance()->getSurveyCountType();
+
+ if ($count_type) {
+
+ // Preštejemo koliko vprašanj je bilo do sedaj
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = (SELECT gru_id FROM srv_spremenljivka WHERE id = '" . $spremenljivka . "')");
+ $rowg = mysqli_fetch_assoc($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+
+ $sqlCountPast = sisplet_query("SELECT count(*) as cnt FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . self :: $sid . "' AND s.gru_id=g.id AND g.vrstni_red < '$vrstni_red' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
+ $rowCount = mysqli_fetch_assoc($sqlCountPast);
+ $offset = $rowCount['cnt'];
+
+ // poiscemo vprasanja / spremenljivke
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id=(SELECT gru_id FROM srv_spremenljivka WHERE id = '" . $spremenljivka . "') AND visible='1' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($row['id'] == $spremenljivka) {
+ $zaporedna++;
+ break;
+ }
+ }
+ }
+
+ echo '<div id="preview_spremenljivka">';
+
+ include_once('../../main/survey/app/global_function.php');
+ new \App\Controllers\SurveyController(true);
+
+ if (isset($_POST['lang_id'])) {
+ save('lang_id', (int)$_POST['lang_id']);
+ }
+ echo ' <div id="spremenljivka_preview">';
+ if ( $spremenljivka == -1 ) {
+ \App\Controllers\BodyController::getInstance()->displayIntroduction();
+ }
+ elseif ( $spremenljivka == -2 ) {
+ \App\Controllers\BodyController::getInstance()->displayKonec();
+ }
+ elseif ( $spremenljivka == -3 ) {
+ \App\Controllers\StatisticController::displayStatistika();
+ }
+ else {
+ save('forceShowSpremenljivka', true);
+ \App\Controllers\Vprasanja\VprasanjaController::getInstance()->displaySpremenljivka($spremenljivka, $offset, $zaporedna);
+ }
+ echo ' </div>';
+ echo '<div class="clr"></div>';
+
+ echo '</div>';
+
+
+ }
+
+ function printPreviewSpremenljivka($spremenljivka) {
+ global $lang;
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+
+ $anketa = $_REQUEST['anketa'];
+ if ($anketa > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '$anketa'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['value'];
+ }
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ echo '</head>';
+ echo '<body onBlur="window.close()" style="margin:5px; padding:5px;" >';
+
+ global $lang, $site_path;
+
+ SurveyInfo :: getInstance()->SurveyInit($anketa);
+
+ $offset = 0;
+ $zaporedna = 0;
+ $count_type = SurveyInfo :: getInstance()->getSurveyCountType();
+
+ if ($count_type) {
+
+ // Preštejemo koliko vprašanj je bilo do sedaj
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = (SELECT gru_id FROM srv_spremenljivka WHERE id = '" . $spremenljivka . "')");
+ $rowg = mysqli_fetch_assoc($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+
+ $sqlCountPast = sisplet_query("SELECT count(*) as cnt FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . self :: $sid . "' AND s.gru_id=g.id AND g.vrstni_red < '$vrstni_red' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
+ $rowCount = mysqli_fetch_assoc($sqlCountPast);
+ $offset = $rowCount['cnt'];
+
+ // poiscemo vprasanja / spremenljivke
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id=(SELECT gru_id FROM srv_spremenljivka WHERE id = '" . $spremenljivka . "') AND visible='1' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($row['id'] == $spremenljivka) {
+ $zaporedna++;
+ break;
+ }
+ }
+ }
+
+
+ include_once('../../main/survey/app/global_function.php');
+ new \App\Controllers\SurveyController(true);
+
+ if (isset($_POST['lang_id'])) {
+ save('lang_id', (int)$_POST['lang_id']);
+ }
+ echo '<div id="spremenljivka_preview" class="container">';
+ if ( $spremenljivka == -1 ) {
+ \App\Controllers\BodyController::getInstance()->displayIntroduction();
+ }
+ elseif ( $spremenljivka == -2 ) {
+ \App\Controllers\BodyController::getInstance()->displayKonec();
+ }
+ elseif ( $spremenljivka == -3 ) {
+ \App\Controllers\StatisticController::displayStatistika();
+ } else {
+ save('forceShowSpremenljivka', true);
+ \App\Controllers\Vprasanja\VprasanjaController::getInstance()->displaySpremenljivka($_GET['spremenljivka']);
+ }
+
+ echo '</div>';// id="spremenljivka_preview"
+ echo '<div id="navigationBottom" class="printHide">';
+ echo '<span class="floatRight spaceLeft"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="close_win(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="print_win(); return false;"><span><img src="icons/icons/printer.png" alt="'.$lang['hour_print2'].'" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+ echo '<br class="clr"/>';
+ echo '</div>';
+ echo '</body>';
+ echo '</html>';
+
+ }
+
+ static function show_sum_more_table() {
+ self :: $show_spid_div = false;
+ self::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ if (count(self::$_LOOPS) == 0 ) {
+ if ($_POST['podstran'] == M_ANALYSIS_SUMMARY) {
+ self :: displaySums($_POST['spid']);
+ } else if ($_POST['podstran'] == M_ANALYSIS_SUMMARY_NEW) {
+ self :: displaySumsNew($_POST['spid']);
+ } else if ($_POST['podstran'] == M_ANALYSIS_FREQUENCY) {
+ self :: displayFrequency($_POST['spid']);
+ }
+ } else {
+ # če mamo zanke
+ $loop_cnt = 0;
+ foreach ( self::$_LOOPS AS $loop) {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ self::$_CURRENT_LOOP = $loop;
+
+ if ($loop['cnt'] == $_POST['loop_id']) {
+ if ($_POST['podstran'] == M_ANALYSIS_SUMMARY) {
+ self :: displaySums($_POST['spid']);
+ } else if ($_POST['podstran'] == M_ANALYSIS_SUMMARY_NEW) {
+ self :: displaySumsNew($_POST['spid']);
+ } else if ($_POST['podstran'] == M_ANALYSIS_FREQUENCY) {
+ self :: displayFrequency($_POST['spid']);
+ }
+ }
+ }
+ }
+
+ echo '<script type="text/javascript" charset="utf-8">
+ analiza_init ();
+ </script>';
+ }
+
+ static function getNumRecords() {
+ if (isset($_POST['num_records']) && (int)$_POST['num_records'] > 0) {
+ $result = (int)self::$textAnswersMore[$_POST['num_records']];
+ } else {
+ $result = (int)SurveyDataSettingProfiles :: getSetting('numOpenAnswers');
+ }
+ return $result;
+ }
+
+
+ /** @desc: Prikaže vsebino diva za izbiro filtriranja
+ *
+ */
+ function showFilterProfiles ($pid = -1) {
+ global $lang;
+
+ // profili za filtriranje
+ echo '<div style="float:left; width:auto; text-align: center;">';
+
+ echo '<span class="as_link" id="link_filter_profile" title="'.$lang['srv_analiza_filter'].'">'.$lang['srv_analiza_filter'].'</span><br />';
+ SurveyFilterProfiles::Init(self::$sid, $global_user_id);
+ $current_filter_profiles = SurveyFilterProfiles::getCurrentProfile();
+ $available_filter_profiles = SurveyFilterProfiles::getAvailableProfiles();
+
+ echo '<span id="div_analiza_filter_profile_dropdown">';
+ echo '<select id="analiza_current_filter_profile" name="analize_current_filter_profile" onchange="changeFilterProfileDropdown();">';
+ foreach ($available_filter_profiles AS $key => $val) {
+ echo ' <option value="'.$val['id'].'"'.($val['id']==$current_filter_profiles['id']?' selected="selected"':'').'>'.$val['name'].'</option>';
+ }
+ echo '</select>';
+ echo '</span>';
+
+ echo '</div>';
+ }
+
+ /**
+ *
+ * # odstranimo sistemske variable tipa email, ime, priimek, geslo oz. ce imamo vklopljeno nastavitev da skrivamo vse sistemske skrijemo vse sistem == 1
+ */
+ static function removeSystemVariables() {
+ if (!empty(self::$_HEADERS))
+ {
+ foreach (self::$_HEADERS AS $skey => $spremenljivka) {
+ if ((int)$spremenljivka['hide_system'] == 1 && in_array($spremenljivka['variable'],array('email','ime','priimek','telefon','naziv','drugo'))) {
+ unset(self::$_HEADERS[$skey]);
+ }
+ else if ((int)$spremenljivka['sistem'] == 1 && SurveyDataSettingProfiles :: getSetting('hideAllSystem') == 1) {
+ unset(self::$_HEADERS[$skey]);
+ }
+ }
+ }
+ }
+
+ /*
+ * posortiramo veljavne odgovore kronološko, po datumu
+ *
+ */
+ static function sortTextValidAnswers($_spid,$variable,$answers) {
+ if (is_string($answers)) {
+ $answers = mb_strtolower($answers,'UTF-8');
+ }
+
+ # Polovimo kronološki potek odgovorov
+ $spid = explode('_',$_spid);
+ $spid = $spid[0];
+ $result = array();
+
+ $string = "SELECT distinct TRIM(REPLACE(REPLACE(REPLACE(sdt.text,'\n',' '),'\r',' '),'|',' ')) as text FROM srv_data_text".self::$db_table." AS sdt JOIN srv_user AS u ON sdt.usr_id = u.id WHERE sdt.spr_id = '".$spid."' AND sdt.vre_id = '".$variable['vr_id']."' ORDER BY u.time_insert ASC";
+
+ $sql = sisplet_query($string);
+ while ( list($text) = mysqli_fetch_row($sql) ) {
+ $text = mb_strtolower($text,'UTF-8');
+ $text = str_replace('\'','`',addslashes(strip_tags($text)));
+ if (isset($answers[$text])) {
+ $result[$text] = $answers[$text];
+ }
+ }
+
+ return $result;
+ }
+
+ static function setUpReturnAsHtml($returnAsHtml = false) {
+ self::$returnAsHtml = $returnAsHtml; # ali vrne rezultat analiz kot html ali ga izpiše
+ }
+ static function setUpIsForArchive($isArchive = false) {
+ self::$isArchive = $isArchive; # nastavimo da smo v arhivu
+ }
+ static function setForceShowEmpty($_forceShowEmpty = false) {
+ self::$_forceShowEmpty = $_forceShowEmpty;
+ }
+
+
+ function showChartColorProfiles(){
+ global $lang;
+ $skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
+ echo '<span style="display: inline; font-weight: bold;">'.$lang['srv_chart_skin_long'].'</span><br/>';
+ echo '<span style="font-size: 10px; font-style: italic;">'.$lang['srv_chart_skin_info'].'</span><br/>';
+ echo '<select id="chart_skin" name="chart_skin" onchange="changeChartGlobalSettings(\'skin\', this.value); return false;" >';
+ echo '<option' . ($skin == 0 ? ' selected="selected"' : '') . ' value="0">'.$lang['srv_chart_skin_0'].'</option>';
+ echo '<option' . ($skin == 1 ? ' selected="selected"' : '') . ' value="1">'.$lang['srv_chart_skin_1'].'</option>';
+ echo '<option' . ($skin == 6 ? ' selected="selected"' : '') . ' value="6">'.$lang['srv_chart_skin_6'].'</option>';
+ echo '<option' . ($skin == 2 ? ' selected="selected"' : '') . ' value="2">'.$lang['srv_chart_skin_2'].'</option>';
+ echo '<option' . ($skin == 3 ? ' selected="selected"' : '') . ' value="3">'.$lang['srv_chart_skin_3'].'</option>';
+ echo '<option' . ($skin == 4 ? ' selected="selected"' : '') . ' value="4">'.$lang['srv_chart_skin_4'].'</option>';
+ echo '<option' . ($skin == 5 ? ' selected="selected"' : '') . ' value="5">'.$lang['srv_chart_skin_5'].'</option>';
+ echo '</select>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="close_chartColor(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+ }
+
+ function toggleAnalysisAdvanced() {
+
+ session_start();
+ $_SESSION['AnalysisAdvancedLinks'][self::$sid] = ($_POST['what'] == 1) ? true : false;
+ $SSH = new SurveyStaticHtml(self::$sid);
+
+ # izrišemo desne linke do posameznih nastavitev
+ $SSH -> displayAnalizaRightOptions($_POST['podstran'],true);
+
+ }
+
+ function changeAnalizaPreview() {
+ global $global_user_id;
+ UserSetting :: getInstance()->Init($global_user_id);
+ UserSetting:: getInstance()->setUserSetting('showAnalizaPreview', (int)$_POST['value'] );
+ UserSetting:: getInstance()->saveUserSetting();
+ $SSH = new SurveyStaticHtml(self::$sid);
+ $SSH -> displayAnalizaSubNavigation(false);
+
+ }
+
+ static function addCustomReportElement($type, $sub_type, $spr1, $spr2=''){
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type, $sub_type=0, $spid);
+ }
+
+ // Nastavitve na dnu
+ static function displayBottomSettings($page){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+
+ // Preverimo, ce je funkcionalnost v paketu, ki ga ima uporabnik
+ $userAccess = UserAccess::getInstance($global_user_id);
+
+ $lan_print = ' title="'.$lang['PRN_Izpis'].'"';
+ $lan_pdf = ' title="'.$lang['PDF_Izpis'].'"';
+ $lan_rtf = ' title="'.$lang['RTF_Izpis'].'"';
+ $lan_xls = ' title="'.$lang['XLS_Izpis'].'"';
+
+ echo '<div class="analysis_bottom_settings printHide">';
+
+ // Pri javni povezavi nimamo tega
+ if(self::$printPreview == false){
+ // Nastavitve na dnu pri sumarniku
+ if($page == 'sums'){
+
+ echo '<a href="#" onClick="addCustomReportAllElementsAlert(1);" title="'.$lang['srv_custom_report_comments_add_hover'].'" class="'.(!$userAccess->checkUserAccess('analysis_analysis_creport') ? 'user_access_locked' : '').'" user-access="analysis_analysis_creport" style="margin-right: 40px;"><span class="spaceRight faicon comments_creport" ></span><span class="bold">'.$lang['srv_custom_report_comments_add'].'</span></a>';
+
+ echo '<a href="#" onClick="printAnaliza(\'Sumarnik\'); return false;"'.$lan_print.' class="srv_ico"><span class="faicon print icon-grey_dark_link"></span></a>';
+
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=sums&anketa=' . self::$sid) . '" target="_blank"'.$lan_pdf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon pdf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=sums_rtf&anketa=' . self::$sid) . '" target="_blank"'.$lan_rtf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon rtf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=sums_xls&anketa=' . self::$sid) . '" target="_blank"'.$lan_xls.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon xls black very_large"></span></a>';
+
+ echo '<a href="#" onclick="doArchiveAnaliza();" title="'.$lang['srv_analiza_arhiviraj_ttl'].'" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv black very_large"></span></a>';
+ echo '<a href="#" onclick="createArchiveBeforeEmail();" title="'.$lang['srv_analiza_arhiviraj_email_ttl'] . '" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv_mail black very_large"></span></a>';
+ }
+
+ // Nastavitve na dnu pri frekvencah
+ elseif($page == 'freq'){
+
+ echo '<a href="#" onClick="addCustomReportAllElementsAlert(2);" title="'.$lang['srv_custom_report_comments_add_hover'].'" class="'.(!$userAccess->checkUserAccess('analysis_analysis_creport') ? 'user_access_locked' : '').'" user-access="analysis_analysis_creport" style="margin-right: 40px;"><span class="spaceRight faicon comments_creport" ></span><span class="bold">'.$lang['srv_custom_report_comments_add'].'</span></a>';
+
+ echo '<a href="#" onClick="printAnaliza(\'Frekvence\'); return false;"'.$lan_print.' class="srv_ico"><span class="faicon print icon-grey_dark_link"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=frequency&anketa=' . self::$sid) . '" target="_blank"'.$lan_pdf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon pdf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=frequency_rtf&anketa=' . self::$sid) . '" target="_blank"'.$lan_rtf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon rtf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=frequency_xls&anketa=' . self::$sid) . '" target="_blank"'.$lan_xls.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon xls black very_large"></span></a>';
+
+ echo '<a href="#" onclick="doArchiveAnaliza();" title="'.$lang['srv_analiza_arhiviraj_ttl'].'" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv black very_large"></span></a>';
+ echo '<a href="#" onclick="createArchiveBeforeEmail();" title="'.$lang['srv_analiza_arhiviraj_email_ttl'] . '" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv_mail black very_large"></span></a>';
+ }
+
+ // Nastavitve na dnu pri opisnih statistikah
+ else{
+
+ echo '<a href="#" onClick="addCustomReportAllElementsAlert(3);" title="'.$lang['srv_custom_report_comments_add_hover'].'" class="'.(!$userAccess->checkUserAccess('analysis_analysis_creport') ? 'user_access_locked' : '').'" user-access="analysis_analysis_creport" style="margin-right: 40px;"><span class="spaceRight faicon comments_creport" ></span><span class="bold">'.$lang['srv_custom_report_comments_add'].'</span></a>';
+
+ echo '<a href="#" onClick="printAnaliza(\'Opisne statistike\'); return false;"'.$lan_print.' class="srv_ico"><span class="faicon print icon-grey_dark_link"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=statistics&anketa=' . self::$sid) . '" target="_blank"'.$lan_pdf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon pdf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=statistics_rtf&anketa=' . self::$sid) . '" target="_blank"'.$lan_rtf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon rtf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=statistics_xls&anketa=' . self::$sid) . '" target="_blank"'.$lan_xls.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon xls black very_large"></span></a>';
+
+ echo '<a href="#" onclick="doArchiveAnaliza();" title="'.$lang['srv_analiza_arhiviraj_ttl'].'" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv black very_large"></span></a>';
+ echo '<a href="#" onclick="createArchiveBeforeEmail();" title="'.$lang['srv_analiza_arhiviraj_email_ttl'] . '" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv_mail black very_large"></span></a>';
+ }
+ }
+
+ echo '</div>';
+
+ // Javascript s katerim povozimo urlje za izvoze, ki niso na voljo v paketu
+ global $app_settings;
+ if($app_settings['commercial_packages'] == true){
+ echo '<script> userAccessExport(); </script>';
+ }
+ }
+
+ static function displayQuickIcons($id) {
+ global $site_url;
+ global $global_user_id;
+
+ $return = '<span class="" style="">';
+ $anketa = self::$sid;
+ switch (self::$podstran) {
+
+ case M_ANALYSIS_SUMMARY_NEW :
+ $export = 'sums';
+ break;
+
+ case M_ANALYSIS_SUMMARY :
+ $export = 'sums';
+ break;
+
+ case M_ANALYSIS_DESCRIPTOR :
+ $export = 'statistics';
+ break;
+
+ case M_ANALYSIS_FREQUENCY :
+ $export = 'frequency';
+ break;
+
+ case M_ANALYSIS_CHARTS :
+ $export = 'charts';
+ break;
+ }
+
+ $loop = (isset(self::$_CURRENT_LOOP)) ? self::$_CURRENT_LOOP['cnt'] : 'undefined';
+
+ //Izvoz v PDF/RTF
+ $_url1 = $site_url.'admin/survey/izvoz.php?dc='.base64_encode(
+ serialize(
+ array( 'b'=>'export',
+ 'm'=>$export,
+ 'anketa'=>$anketa,
+ 'sprID'=>$id,
+ 'loop'=>$loop)));
+ $_url2 = $site_url.'admin/survey/izvoz.php?dc='.base64_encode(
+ serialize(
+ array( 'b'=>'export',
+ 'm'=>$export.'_rtf',
+ 'anketa'=>$anketa,
+ 'sprID'=>$id,
+ 'loop'=>$loop)));
+ $_url3 = $site_url.'admin/survey/izvoz.php?dc='.base64_encode(
+ serialize(
+ array( 'b'=>'export',
+ 'm'=>$export.'_xls',
+ 'anketa'=>$anketa,
+ 'sprID'=>$id,
+ 'loop'=>$loop)));
+
+ $return = '<span class="faicon print_small icon-grey_dark_link" onclick="printCurrentAnalysis(\''.$id.'\');"></span>&nbsp;&nbsp';
+
+ $userAccess = UserAccess::getInstance($global_user_id);
+ if($userAccess->checkUserAccess($what='data_export')){
+ $return .= '<a href="'.$_url1.'" target="_blank"><span class="faicon pdf"></span></a>';
+ $return .= '&nbsp;&nbsp;<a href="'.$_url2.'" target="_blank"><span class="faicon rtf"></span></a>';
+
+ if(self::$podstran != M_ANALYSIS_CHARTS ) {
+ $return .= '&nbsp;&nbsp;<a href="'.$_url3.'" target="_blank"><span class="faicon xls"></span></a>';
+ }
+ }
+ else{
+ $return .= '<a href="#" onClick="popupUserAccess(\'analysis_export\');"><span class="faicon pdf user_access_locked"></span></a>';
+ $return .= '&nbsp;&nbsp;<a href="#" onClick="popupUserAccess(\'analysis_export\');"><span class="faicon rtf user_access_locked"></span></a>';
+
+ if(self::$podstran != M_ANALYSIS_CHARTS ) {
+ $return .= '&nbsp;&nbsp;<a href="#" onClick="popupUserAccess(\'analysis_export\');"><span class="faicon xls user_access_locked"></span></a>';
+ }
+ }
+
+ $return .= '</span>';
+
+ return $return;
+ }
+
+ function changeSpremenljivkaLestvica() {
+
+ #shranimo nastavitve
+ $spremenljivka = $_POST['spid'];
+ $skala = $_POST['skala'];
+
+ # popravimo skalo spremenljivke
+ # skala - 0 Ordinalna
+ # skala - 1 Nominalna
+ if ( isset($skala) && (int)$spremenljivka) {
+ $sql = sisplet_query("UPDATE srv_spremenljivka SET skala='".$skala."' WHERE id='$spremenljivka'");
+ #Common::updateEditStamp();
+ # popravimo v header datoteki
+ self::$_HEADERS[$spremenljivka]['skala'] = $skala;
+ file_put_contents(self::$headFileName, serialize(self::$_HEADERS));
+ }
+
+ }
+
+ static function displaySpremenljivkaIcons($spid) {
+
+ if (self::$isArchive == false){
+ echo '<div class="div_analiza_icons">'.self::displayQuickIcons($spid).'</div>';
+
+ // Javna povezava nima js preklopov
+ if(self::$printPreview == false)
+ self::displayQuickScale($spid);
+ }
+ }
+
+ static function displayQuickScale($spid) {
+ global $lang;
+
+ $spr_id = self::$_HEADERS[$spid]['spr_id'];
+
+ # pokličemo objekt SpremenljivkaSkala
+ $objectSkala = new SpremenljivkaSkala($spr_id);
+
+ if ($objectSkala->canChangeSkala()) {
+ echo '<div class="div_analiza_scale">';
+ if ($objectSkala->is(SpremenljivkaSkala::ORD)) {
+ echo '<a href="#" onclick="changeSpremenljivkaLestvica(\''.$spid.'\',\''.SpremenljivkaSkala::NOM.'\'); return false;">';
+ echo '<span class="strong" title="'.$lang['srv_skala_long_'.SpremenljivkaSkala::ORD].'">';
+ echo $lang['srv_skala_'.SpremenljivkaSkala::ORD];
+ echo '</span>';
+ echo ' / ';
+ echo '<span title="'.$lang['srv_skala_long_'.SpremenljivkaSkala::NOM].'">';
+ echo $lang['srv_skala_'.SpremenljivkaSkala::NOM];
+ echo '</span>';
+ echo '</a>';
+ }
+ if ($objectSkala->is(SpremenljivkaSkala::NOM)) {
+ echo '<a href="#" onclick="changeSpremenljivkaLestvica(\''.$spid.'\',\''.SpremenljivkaSkala::ORD.'\'); return false;">';
+ echo '<span title="'.$lang['srv_skala_long_'.SpremenljivkaSkala::ORD].'">';
+ echo $lang['srv_skala_'.SpremenljivkaSkala::ORD];
+ echo '</span>';
+ echo ' / ';
+ echo '<span class="strong" title="'.$lang['srv_skala_long_'.SpremenljivkaSkala::NOM].'">';
+ echo $lang['srv_skala_'.SpremenljivkaSkala::NOM];
+ echo '</span>';
+ echo '</a>';
+ }
+ echo '</div>';
+ } else {
+ echo '<div class="div_analiza_scale">';
+ echo '<span title="'.$lang['srv_skala_long_'.$objectSkala->getSkala()].'">';
+ echo $lang['srv_skala_'.$objectSkala->getSkala()];
+ echo '</span>';
+ echo '</div>';
+ }
+ }
+
+ static function displayPublicAnalysis($properties = array()) {
+ global $lang;
+ global $site_url;
+
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+
+ $anketa = self::$sid;
+ if ($anketa > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '$anketa'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['value'];
+ }
+
+ self::Init($anketa);
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="'.$site_url.'admin/survey/script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="'.$site_url.'admin/survey/minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="'.$site_url.'admin/survey/minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="'.$site_url.'admin/survey/minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ echo '</head>';
+
+ echo '<body style="margin:5px; padding:5px;" >';
+ echo '<h2>'.$lang['srv_publc_analysis_title_for'].self::$survey['naslov'].'</h2>';
+
+ echo '<input type="hidden" name="anketa_id" id="srv_meta_anketa_id" value="' . $anketa . '" />';
+ echo '<div id="analiza_data">';
+
+ if (isset($properties['profile_id_variable']))
+ {
+ self::$_PROFILE_ID_VARIABLE = $properties['profile_id_variable'];
+
+ SurveyVariablesProfiles::setCurrentProfileId(self::$_PROFILE_ID_VARIABLE);
+ }
+
+ if (isset($properties['profile_id_condition']))
+ {
+ self::$_PROFILE_ID_CONDITION = $properties['profile_id_condition'];
+
+ SurveyConditionProfiles::setCurrentProfileId(self::$_PROFILE_ID_CONDITION);
+ }
+
+
+ self::$printPreview = true;
+
+ # ponastavimo nastavitve- filter
+ self::Display();
+ echo '</div>';
+
+ echo '<div id="navigationBottom" class="printHide">';
+
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="window.print();return false;"><span><img src="'.$site_url.'admin/survey/icons/icons/printer.png" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+ echo '<span class="spaceRight floatRight printHide" style="margin-top:6px;">';
+ echo '<a href="'.$_url1.'" target="_blank"><span class="faicon pdf"></span></a>&nbsp;&nbsp;';
+ echo '<a href="'.$_url2.'" target="_blank"><span class="faicon rtf"></span></a>&nbsp;&nbsp;';
+ echo '<a href="'.$_url3.'" target="_blank"><span class="faicon xls"></span></a>';
+ echo '</span>';
+
+ echo '<br class="clr" />';
+ echo '</div>';
+
+ echo '</body>';
+ echo '</html>';
+ }
+
+ static function heatmapGraph($spid,$_from, $lokacija=false, $heatmap=false) {
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+ $anketa = self::$sid;
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ // $num_show_records = $_max_answers_cnt <= (int)$num_show_records ? $_max_answers_cnt : $num_show_records;
+
+ $_answers = self::getAnswers($spremenljivka,$num_show_records);
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ //self::displaySpremenljivkaIcons($spid);
+ }
+
+ //echo '<div class="heatmapGrapshContainer" style=" width: 800px; text-align:center; margin-left:auto; margin-right:auto;">';
+ echo '<div class="heatmapGrapshContainer" style=" width: 600px; text-align:center; margin-left:auto; margin-right:auto;">';
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_bb tbl_clps">';
+ # naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ //echo self::showVariable($spid, $spremenljivka['variable']);
+ echo $spremenljivka['variable'].' - '.$spremenljivka['naslov'];
+ echo '</td>';
+
+ echo '</tr>';
+ echo '<tr>';
+ #variabla
+
+ // konec naslovne vrstice
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0) {
+
+ $_css_bck = 'anl_bck_desc_2 anl_ac anl_bt_dot ';
+ $last = 0;
+ //anl_bck_desc_2 anl_bl anl_br anl_variabla_sub
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $_variables_count = count($grid['variables']);
+ echo '<tr class="'.$_css_bck.'">';
+ echo '<td class="anl_bl anl_br anl_variabla_sub">';
+ if($heatmap){
+ //echo $grid['naslov'].'<br>';//ni potrebno, ker je ze v glavi?
+ $sprid = explode('_',$spid);
+ $loopid = $sprid[1];
+ $sprid = $sprid[0];
+ SurveyUserSession::Init($anketa);
+
+ $heatmapId = 'heatmap'.$sprid;
+ //echo $heatmapId;
+
+ echo '<a class="fHeatMap" id="heatmap_'.$sprid.'" title="'.$lang['srv_view_data_on_map'].
+ '" href="javascript:void(0);" onclick="passHeatMapData('.$sprid.', -1, '.$loopid.', '.$anketa.');">';
+ //echo '<img src="img_0/Google_Maps_Icon.png" alt="Smiley face" height="24" width="24" />';
+ echo 'Heatmap';
+ echo '</a>';
+ }
+ echo '</td>';
+
+
+ echo '</tr>';
+ }
+ }
+ echo '</table>';
+ echo '</div>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ // ikone za izvoz za heatmap porocila
+ static function displayExportIcons4Heatmap($spid, $anketa){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = self::$_HEADERS[$spid];
+
+ $loop = (isset(self::$_CURRENT_LOOP)) ? self::$_CURRENT_LOOP['cnt'] : 'undefined';
+
+ // linki
+ echo '<div class="chart_setting_exportLinks">'.$lang['srv_export_as'].': ';
+
+ //Izvoz heatmap slike
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=heatmap_image&anketa='.$anketa.'&sprID='.$spid.'&loop='.$loop).'" target="_blank" onclick="exportHeatmapAsImage(\''.$spid.'\');" class="srv_ico" title="'.$lang['heatMapGenerateImage'].'"><span class="sprites heatmapImageSave"></span></a>';
+
+ //Izvoz heatmap slike v pdf
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=heatmap_image_pdf&anketa='.$anketa.'&sprID='.$spid.'&loop='.$loop) . '" target="_blank" onclick="exportHeatmapAsImage(\''.$spid.'\');" title="'.$lang['PDF_Izpis'].'" class="srv_ico"><span class="faicon pdf"></span></a>';
+
+ //Izvoz heatmap slike v rtf
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=heatmap_image_rtf&anketa='.$anketa.'&sprID='.$spid.'&loop='.$loop) . '" target="_blank" onclick="exportHeatmapAsImage(\''.$spid.'\');" title="'.$lang['RTF_Izpis'].'" class="srv_ico"><span class="faicon rtf"></span></a>';
+
+ //Izvoz heatmap slike v ppt
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=heatmap_image_ppt&anketa='.$anketa.'&sprID='.$spid.'&loop='.$loop) . '" target="_blank" onclick="exportHeatmapAsImage(\''.$spid.'\');" title="'.$lang['PPT_Izpis'].'" class="srv_ico"><span class="faicon ppt"></span></a>';
+
+ echo '</div>';
+ }
+
+ /** Izriše tekstovne odgovore kot tabelo za heatmap
+ *
+ * @param unknown_type $spid
+ */
+ static function sumMultiTextHeatMap($spid,$_from, $lokacija=false, $heatmap=false) {
+ global $lang;
+
+ $RegionPresent = true;
+ $spremenljivka = self::$_HEADERS[$spid];
+ $anketa = self::$sid;
+
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)self::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && self::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = self::getNumRecords();
+
+ // $num_show_records = $_max_answers_cnt <= (int)$num_show_records ? $_max_answers_cnt : $num_show_records;
+
+ $_answers = self::getAnswers($spremenljivka,$num_show_records);
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+ if (self :: $show_spid_div == true) {
+ echo '<div id="sum_'.$spid.'" loop="'.self::$_CURRENT_LOOP['cnt'].'" class="div_sum_variable div_analiza_holder">';
+ }
+
+ self::displaySpremenljivkaIcons($spid);
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_bb tbl_clps">'; //zacetek tabele
+ # 1. vrstica - naslovna vrstica
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck_freq_1 anl_w110">';
+ echo self::showVariable($spid, $spremenljivka['variable']);
+ echo '</td>';
+ #odgovori
+ //echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="'.(!$lokacija ? (self::$_SHOW_LEGENDA ? 3+$_cols : 1+$_cols) : 3+$_cols).'"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+ echo '<td class="anl_br anl_bb anl_al anl_bck_freq_1" colspan="6"><span class="anl_variabla_label">'.$spremenljivka['naslov'].'</span>';
+
+ echo '</td>';
+ echo '</tr>';
+ //konec 1. vrstice
+
+ //2. vrstica - prikazovanje povezave do heatmap
+ echo '<tr>';
+ #variabla
+ echo '<td class="anl_bl anl_br anl_bb anl_ac anl_bck anl_w110">';
+ //self::showIcons($spid,$spremenljivka,$_from); //za enkrat skrijem ikone za izvoze in druge moznosti
+ echo '</td>';
+ echo '<td class="anl_br anl_bb anl_ac" colspan="6">';
+ //echo $grid['naslov'].'<br>';//ni potrebno, ker je ze v glavi?
+ $sprid = explode('_',$spid);
+ $loopid = $sprid[1];
+ $sprid = $sprid[0];
+ SurveyUserSession::Init($anketa);
+
+ $heatmapId = 'heatmap'.$sprid;
+ //echo $heatmapId;
+ //SurveyChart::displayExportIcons($sprid);
+ echo '<a class="fHeatMap" id="heatmap_'.$sprid.'" title="'.$lang['srv_view_data_heatmap'].
+ '" href="javascript:void(0);" onclick="passHeatMapData('.$sprid.', -1, '.$loopid.', '.$anketa.');">';
+ //echo '<img src="img_0/Google_Maps_Icon.png" alt="Smiley face" height="24" width="24" />';
+ echo 'Heatmap ';
+ echo '</a>';
+
+ echo '</td>';
+ echo '</tr>';
+ //konec - 2. vrstice
+
+ //Koordinate
+ //naslovna vrstica za koordinate
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bck anl_bb anl_ac" colspan="7">';
+ echo '<b>'.$lang['srv_analiza_heatmap_clicked_coords'].'</b>';
+ echo '</td>';
+ echo '</tr>';
+ //naslovna vrstica za koordinate - konec
+ //vrstica s podnaslovi celic
+ echo '<tr>';
+ echo '<td class="anl_variabla_line anl_bl anl_br anl_bb anl_bck anl_ac">';
+ echo $lang['coordinates'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_bl anl_br anl_bb anl_bck anl_ac anl_w70">';
+ echo $lang['srv_analiza_opisne_valid_heatmap'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac anl_w70">';
+ echo $lang['srv_analiza_num_units_valid_heatmap'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac anl_w70">';
+ echo $lang['srv_means_label'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac anl_w70">';
+ echo $lang['srv_analiza_opisne_odklon'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac anl_w70">';
+ echo $lang['srv_analiza_opisne_min'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac anl_w70">';
+ echo $lang['srv_analiza_opisne_max'];
+ echo '</td>';
+ echo '</tr>';
+ //vrstica s podnaslovi celic - konec
+
+ //vrstica za x
+ echo '<tr>';
+ //1. stolpcev z imenom koordinate
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">';
+ echo 'x';
+ echo '</td>';
+ //1. stolpcev z imenom koordinate - konec
+
+ //2. stolpec - Veljavni
+ $validHeatmapRegion = self::validHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers);
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$validHeatmapRegion.'</td>';
+ //2. stolpec - Veljavni - konec
+
+ //3. stolpec - Ustrezni
+ $ustrezniHeatmapRegion = self::ustrezniHeatmapRegion($spid, $_valid_answers, $_sequence); //vsi mozni kliki
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$ustrezniHeatmapRegion.'</td>';
+ //3. stolpec - Ustrezni - konec
+
+ //4. stolpec - Povprecje
+ $povprecjeHeatmapClicksX = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'povprecje'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$povprecjeHeatmapClicksX.'</td>';
+ //4. stolpec - Povprecje - konec
+
+ //5. stolpec - Standardni odklon
+ $stdevHeatmapClicksX = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'stdev'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$stdevHeatmapClicksX.'</td>';
+ //5. stolpec - Standardni odklon - konec
+
+ //6. stolpec - Minimum
+ $minHeatmapClicksX = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'min'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$minHeatmapClicksX.'</td>';
+ //6. stolpec - Minimum - konec
+
+ //7. stolpec - Max
+ $maxHeatmapClicksX = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'max'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$maxHeatmapClicksX.'</td>';
+ //7. stolpec - Max - konec
+
+ echo '</tr>';
+ //vrstica za x - konec
+
+ //vrstica za y
+ echo '<tr>';
+ //1. stolpcev z imenom koordinate
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">';
+ echo 'y';
+ echo '</td>';
+ //1. stolpcev z imenom koordinate - konec
+
+ //2. stolpec - Veljavni
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$validHeatmapRegion.'</td>';
+ //2. stolpec - Veljavni - konec
+
+ //3. stolpec - Ustrezni
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$ustrezniHeatmapRegion.'</td>';
+ //3. stolpec - Ustrezni - konec
+
+ //4. stolpec - Povprecje
+ $povprecjeHeatmapClicksY = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'povprecje'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$povprecjeHeatmapClicksY.'</td>';
+ //4. stolpec - Povprecje - konec
+
+ //5. stolpec - Standardni odklon
+ $stdevHeatmapClicksY = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'stdev'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$stdevHeatmapClicksY.'</td>';
+ //5. stolpec - Standardni odklon - konec
+
+ //6. stolpec - Minimum
+ $minHeatmapClicksY = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'min'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$minHeatmapClicksY.'</td>';
+ //6. stolpec - Minimum - konec
+
+ //7. stolpec - Max
+ $maxHeatmapClicksY = self::formatNumber(self::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'max'),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$maxHeatmapClicksY.'</td>';
+ //7. stolpec - Max - konec
+
+ echo '</tr>';
+ //vrstica za y - konec
+
+ //Koordinate - konec
+
+ //preveri, ali je prisotno kaksno obmocje, nadaljuj izris tabele
+ $RegionPresent = self::HeatmapRegionPresence($spremenljivka['grids'], $spid, $_valid_answers);
+ //preveri, ali je prisotno kaksno obmocje, nadaljuj izris tabele - konec
+
+ if($RegionPresent){ //ce imamo obmocja
+ //3. vrstica - naslovna za obmocja
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bck anl_bb anl_ac" colspan="7">';
+ echo '<b>'.$lang['srv_analiza_heatmap_clicked_regions'].'</b>';
+ echo '</td>';
+ echo '</tr>';
+ //konec - 3. vrstice
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ $_css_bck = 'anl_bck_desc_2 anl_ac anl_bt_dot ';
+ $last = 0;
+
+ if ($_grids_count > 0) {
+ $_row = $spremenljivka['grids'][0];
+ $indeks = 0;
+ //$veljavnaSkupnaFreq = 0;
+ if (count($_row['variables'])>0)
+ foreach ($_row['variables'] AS $rid => $_col ){
+
+ $_sequence = $_col['sequence']; # id kolone z podatki
+ if ($_col['other'] != true) {
+ echo '<tr>';
+ if($indeks == 0) //4. vrstica, naslovna vrstica
+ {
+ echo '<td class="anl_variabla_line anl_bl anl_br anl_bb anl_bck anl_ac" colspan="2">';
+ echo $lang['srv_hot_spot_regions_menu'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac">';
+ echo $lang['srv_analiza_opisne_frequency_heatmap'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac">';
+ echo $lang['srv_analiza_opisne_valid_heatmap'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac">';
+ echo '% - '.$lang['srv_analiza_opisne_valid_heatmap'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac">';
+ echo $lang['srv_analiza_num_units_valid_heatmap'];
+ echo '</td>';
+
+ echo '<td class="anl_variabla_line anl_br anl_bb anl_bck anl_ac">';
+ echo '% - '.$lang['srv_analiza_num_units_valid_heatmap'];
+ echo '</td>';
+ }else //od 5. vrstice dalje, kjer so po vrsticah obmocja in njihovi podatki
+ {
+ //1. stolpcev z imenom obmocja
+ echo '<td class="anl_bl anl_br anl_bb anl_ac" colspan="2">';
+ echo $_col['naslov'];
+ echo '</td>';
+ //1. stolpcev z imenom obmocja - konec
+
+ //2. stolpec - Frekvenca
+ $freqHeatmapRegion = self::freqHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers, $indeks);
+ $veljavnaSkupnaFreq = $veljavnaSkupnaFreq + $freqHeatmapRegion;
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$freqHeatmapRegion.'</td>';
+ //2. stolpec - Frekvenca - konec
+
+ //3. stolpec - Veljavni
+ //$validHeatmapRegion = self::validHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers);
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$validHeatmapRegion.'</td>';
+ //3. stolpec - Veljavni - konec
+
+ //4. stolpec - % Veljavni
+ $_procentValidHeatmapRegion = ($validHeatmapRegion > 0 ) ? 100*$freqHeatmapRegion / $validHeatmapRegion : 0;
+ $_procentValidHeatmapRegion = self::formatNumber($_procentValidHeatmapRegion, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$_procentValidHeatmapRegion.'</td>';
+ //4. stolpec - % Veljavni - konec
+
+ //5. stolpec - Ustrezni
+ $ustrezniHeatmapRegion = self::ustrezniHeatmapRegion($spid, $_valid_answers, $_sequence); //vsi mozni kliki
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$ustrezniHeatmapRegion.'</td>';
+ //5. stolpec - Ustrezni - konec
+
+ //6. stolpec - % Ustrezni
+ $_procentUstrezniHeatmapRegion = ($ustrezniHeatmapRegion > 0 ) ? 100*$freqHeatmapRegion / $ustrezniHeatmapRegion : 0;
+ $_procentUstrezniHeatmapRegion = self::formatNumber($_procentUstrezniHeatmapRegion, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$_procentUstrezniHeatmapRegion.'</td>';
+ //6. stolpec - % Ustrezni - konec
+ }
+
+ //echo '</td>';
+ echo '</tr>';
+
+ //*********** Izris veljavnih in manjkajocih vrednosti
+ if($indeks != 0) //ce ni naslovna vrsticam je potrebno dodati se dodatne poglede veljavnih in manjkajocih vrednosti
+ {
+ echo '<tr>';
+ $counter = 0;
+ $options['isTextAnswer'] = false;
+ $manjkajoci = $ustrezniHeatmapRegion - $validHeatmapRegion;
+ $counter = self::outputSumaValidAnswerHeatmap($counter,$_sequence,$spid,$options, $validHeatmapRegion);
+
+ if (count(self::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (self::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki niso 0
+ $counter = self::outputInvalidAnswerHeatmap($counter,$ikey,$iAnswer,$_sequence,$spid,$options, $manjkajoci);
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaInvalidAnswerHeatmap($counter,$_sequence,$spid,$options, $manjkajoci);
+ }
+ #izpišemo še skupno sumo
+ $counter = self::outputSumaHeatmap($counter,$_sequence,$spid,$options, $ustrezniHeatmapRegion);
+ echo '</tr>';
+ $veljavnaSkupnaFreq = 0;
+ }
+ //*********** Izris veljavnih in manjkajocih vrednosti - konec
+
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $indeks++;
+ }
+ }
+ }
+ echo '</table>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ }
+
+ if (self :: $show_spid_div == true) {
+ echo '</div>';
+ echo '<br/>';
+ }
+ }
+
+ static function freqHeatmapRegion($spremenljivkaGrids, $spid, $_valid_answers, $indeks, $export=0){
+ $steviloPodatkov = count($_valid_answers);
+ $freqHeatMapRegion = 0;
+ foreach ($spremenljivkaGrids AS $gid => $grid)
+ {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ //$numObmocij = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,self::$_FREQUENCYS[$_sequence]['validCnt']));
+ //$numObmocij++;
+ }
+
+ $indeksZaObmocja = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true)
+ {
+ #$_valid_cnt = count(self::$_FREQUENCYS[$_sequence]['valid']);
+
+ if (count($_valid_answers) > 0) {
+
+ foreach ($_valid_answers AS $answer) {
+ $_ans = $answer[$_sequence];
+
+ //if ($_ans != null && $_ans != '' && $indeksZaObmocja == count($_valid_answers)+$indeks) {
+ if ($_ans != null && $_ans != '' && $indeksZaObmocja >= count($_valid_answers)*$indeks && $steviloPodatkov != 0)
+ {
+ $freqHeatMapRegion = $freqHeatMapRegion + $_ans;
+ $steviloPodatkov--;
+ }
+ else {
+ if($export==0){
+ echo '&nbsp;';
+ }
+ }
+ $indeksZaObmocja++;
+ }
+ }
+ }
+
+ }
+
+ }
+ }
+ return $freqHeatMapRegion;
+ }
+
+ static function validHeatmapRegion($spremenljivkaGrids, $spid, $_valid_answers, $export=0){
+ $validHeatmapRegion = 0;
+ foreach ($spremenljivkaGrids AS $gid => $grid)
+ {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ {
+ //$numObmocij = 0;
+ $brs = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true)
+ {
+ #$_valid_cnt = count(self::$_FREQUENCYS[$_sequence]['valid']);
+ if (count($_valid_answers) > 0) {
+ //echo '<script>console.log("count($_valid_answers):'.count($_valid_answers).'"); </script>';
+ //$brs = 0;
+ foreach ($_valid_answers AS $answer) {
+ $_ans = $answer[$_sequence];
+ $vejice = substr_count($_ans, ",");
+ if ($_ans != null && $_ans != '' && $vejice != 0)
+ {
+ //echo '<script>console.log("$_ans:'.$_ans.'"); </script>';
+ $brs = $brs + substr_count($_ans, "<br>");
+ //echo '<script>console.log("<br>s in $_ans:'.$brs.'"); </script>';
+ }
+ else {
+ if($export == 0){
+ echo '&nbsp;';
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ $validHeatmapRegion = $brs;
+ //echo '<script>console.log("validHeatmapRegion konec:'.$validHeatmapRegion.'"); </script>';
+ return $validHeatmapRegion;
+ }
+
+ static function ustrezniHeatmapRegion($spid, $_valid_answers, $_sequence){
+ $row = Cache::srv_spremenljivka($spid);
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $heatmap_num_clicks = ($spremenljivkaParams->get('heatmap_num_clicks') ? $spremenljivkaParams->get('heatmap_num_clicks') : 1);
+ return self::$_FREQUENCYS[$_sequence]['validCnt'] * $heatmap_num_clicks; //vrni vse mozne klike = stev. odgovorov * stev. moznih klikov
+ }
+
+ static function HeatmapRegionPresence($spremenljivkaGrids, $spid, $_valid_answers){
+ $HeatmapRegionPresence = false;
+ foreach ($spremenljivkaGrids AS $gid => $grid)
+ {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ //$numObmocij = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,self::$_FREQUENCYS[$_sequence]['validCnt']));
+ //$numObmocij++;
+ }
+
+ $indeksZaObmocja = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true)
+ {
+ if (count($_valid_answers) > 0) {
+
+ foreach ($_valid_answers AS $answer) {
+ $_ans = $answer[$_sequence];
+ if ($_ans != null && $_ans != '' && $indeksZaObmocja >= count($_valid_answers))
+ {
+ $HeatmapRegionPresence = true;
+ }
+ $indeksZaObmocja++;
+ }
+ }
+ }
+
+ }
+
+ }
+ }
+ return $HeatmapRegionPresence;
+ }
+
+ static function heatmapClicksCalc($spremenljivkaGrids, $spid, $_valid_answers, $coords, $veljavnikliki, $what, $export=0){
+ $heatmapClicksCalc = 0;
+ $stdevCoordsArray = array();
+ $minCoords = 0;
+ $maxCoords = 0;
+ foreach ($spremenljivkaGrids AS $gid => $grid)
+ {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ //$numObmocij = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,self::$_FREQUENCYS[$_sequence]['validCnt']));
+ //$numObmocij++;
+ }
+
+ $indeksZaObmocja = 0;
+ foreach ($grid['variables'] AS $vid => $variable )
+ {
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true)
+ {
+ #$_valid_cnt = count(self::$_FREQUENCYS[$_sequence]['valid']);
+
+ if (count($_valid_answers) > 0) {
+
+ foreach ($_valid_answers AS $answer) {
+ $_ans = $answer[$_sequence];
+ if ($_ans != null && $_ans != '' && $_ans >= 0 && $indeksZaObmocja < count($_valid_answers))
+ {
+ //$validHeatmapRegion = $validHeatmapRegion + $_ans;
+ //echo '<td>'.$_ans.'</td>';
+ $_ans = substr($_ans, 4); //odstrani <br> iz zacetka koordinat
+ $coordinates = explode('<br>',$_ans);
+ foreach($coordinates AS $key => $coordinate){
+ $coordinate = explode(',',$coordinate);
+ foreach($coordinate AS $coordskey => $subcoords)
+ {
+ if($coords == 'x' && ($coordskey == 0 || $coordskey%2 == 0) )
+ {
+ array_push($stdevCoordsArray, $subcoords);
+ }else if($coords == 'y' && ($coordskey != 0 || $coordskey%2 != 0) )
+ {
+ array_push($stdevCoordsArray, $subcoords);
+ }
+ }
+ }
+ }
+ else {
+ if($export == 0){
+ echo '&nbsp;';
+ }
+ }
+ $indeksZaObmocja++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if($what == 'povprecje')
+ {
+ $heatmapClicksCalc = array_sum($stdevCoordsArray) / count($stdevCoordsArray);
+ }else if($what == 'stdev')
+ {
+ if(is_array($stdevCoordsArray)){
+ $mean = array_sum($stdevCoordsArray) / count($stdevCoordsArray);
+ foreach($stdevCoordsArray as $key => $num) $devs[$key] = pow($num - $mean, 2);
+ if(count($devs) != 1)
+ $heatmapClicksCalc = sqrt(array_sum($devs) / (count($devs) - 1));
+ }
+ }else if($what == 'min')
+ {
+ $heatmapClicksCalc = min($stdevCoordsArray);
+ }else if($what == 'max')
+ {
+ $heatmapClicksCalc = max($stdevCoordsArray);
+ }
+
+ return $heatmapClicksCalc;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisArchive.php b/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisArchive.php
new file mode 100644
index 0000000..6d937c5
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisArchive.php
@@ -0,0 +1,1264 @@
+<?php
+/**
+* @author Gorazd Veselič
+* @date May 2010
+*
+* Funkcije za arhive analiz
+*
+* Polja v tabeli - srv_analysis_archive:
+* - id int(11) NOT NULL auto_increment # id arhiva
+* - sid int(11) NOT NULL default 0, # id ankete
+* - uid int(11) NOT NULL default 0, # id uporabnika kateri je skreiral arhiv
+* - name varchar(200) NOT NULL, # dodaljeno ime arhiva
+* - filename varchar(50) NOT NULL, # dodeljeno ime datoteke na FS
+* - date datetime NOT NULL, # datum kreacije
+* - note varchar(200) NOT NULL, # opomba
+* - access TINYINT NOT NULL DEFAULT 0; # 0 - vidijo vsi, 1 - vidijo samo uporabniki z dostopom
+* - type TINYINT NOT NULL DEFAULT 0; # 0 - sumarnik, 1 - opisne, 2 - frekvence, 3 - crostabi, 4 - means, 5 - ttest, 6 - break, 7 - charts, 8 - creport
+* - duration date NOT NULL; # datum do kdaj je arhiv aktiven, potem se briše iz baze in FS
+* - editid int(11) NOT NULL default 0; # id avtorja ki je zadnji spremnijal
+*
+*/
+
+
+define("SAA_FOLDER", "AnalysisArchive");
+define("DEFAULT_DURATION", " +3 month"); // privzet čas trajanja athiva
+
+class SurveyAnalysisArchive {
+
+
+ static private $sid;
+
+ // konstrutor
+ protected function __construct() {}
+ // kloniranje
+ final private function __clone() {}
+
+ /**
+ * Inicializacija
+ *
+ * @param int $anketa
+ */
+ static function Init( $anketa = null )
+ {
+ if ($anketa)
+ self::$sid = $anketa;
+
+ # pobrišemo linke, ki so pretekli
+ $s = sisplet_query("SELECT id FROM srv_analysis_archive WHERE date_add(duration, INTERVAL 1 DAY) < NOW()");
+ while ($row = mysqli_fetch_assoc($s)) {
+ $successDelete = self::DoDeleteArchive($row['id']);
+ }
+ }
+
+ /**
+ * @desc Vrne ID trenutnega uporabnika (ce ni prijavljen vrne 0)
+ */
+ static function uid() {
+ global $global_user_id;
+
+ return $global_user_id;
+ }
+
+ static function ListArchive($fields=array()) {
+ global $lang, $site_url;
+ $defaultFields = array(
+ 'create_new'=>true, #fieldset z linkom za generiranje novega arhiva
+ 'delete'=>true, #stolpec delete
+ 'edit'=>true, #stolpec editiraj
+ 'email'=>true, #stolpec pošlji po mailu
+ 'name'=>true, #stolpec ime
+ 'note'=>true, #stolpec opomba
+ 'date'=>true, #stolpec datum
+ 'access'=>true, #stolpec access (dostop) # 0 - vsi, 1 - uporabniki iz srv_dostop
+ 'type'=>true, #stolpec type (vrsta analize) # 0 - sumarnik, 1 - opisne, 2 - frekvence, 3 - crostabi, 4 - means, 5 - ttest, 6 - break, 7 - charts, 8 - creport
+ 'name_link' => true,#ali se ime pokaže kot link
+ 'duration' => true, #stolpec trajanje (duration)
+ 'insert' => true, #stolpec autor
+ 'edit' => true #stolpec spreminajl
+
+ );
+ $ArchiveTypes = array(M_ANALIZA_SUMS => 0, M_ANALIZA_DESCRIPTOR=>1, M_ANALIZA_FREQUENCY=>2, M_ANALIZA_CROSSTAB=>3, M_ANALYSIS_MEANS=>4, M_ANALYSIS_TTEST=>5, M_ANALYSIS_BREAK=>6, M_ANALYSIS_CHARTS=>7, M_ANALYSIS_CREPORT=>8);
+ #ponastavimo želene vrednosti
+ foreach ($fields AS $key => $value) {
+ $defaultFields[$key] = $value;
+ }
+
+ $users = array();
+ $qry = "SELECT saa.*, UNIX_TIMESTAMP(saa.date) as insert_date, UNIX_TIMESTAMP(saa.duration) as duration_d, DATEDIFF(saa.duration, CURDATE()) as days_left"
+ # da ne delamo vlkege poizvedbe kadar ni potrebno
+ . ($defaultFields['insert'] ? " , us1.name as iname, us1.surname as isurname, us1.email as iemail " : "" )
+ . ($defaultFields['edit'] ? " , us2.name as ename, us2.surname as esurname, us2.email as eemail " : "" )
+ . " FROM srv_analysis_archive as saa "
+ . ($defaultFields['insert'] ? " LEFT OUTER JOIN ( SELECT us1.name, us1.surname, us1.id, us1.email FROM users as us1 ) AS us1 ON us1.id = saa.uid " : "" )
+ . ($defaultFields['edit'] ? " LEFT OUTER JOIN ( SELECT us2.name, us2.surname, us2.id, us2.email FROM users as us2 ) AS us2 ON us2.id = saa.editid " : "" )
+ . " WHERE sid='".self::$sid."' ORDER BY date DESC";
+
+ $s = sisplet_query($qry);
+ if (mysqli_num_rows($s) > 0 ) {
+
+ if($defaultFields['create_new']){
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_archive_analysis'].'</legend>';
+
+ echo $lang['srv_analiza_archive_generate_quick'];
+
+ echo '</fieldset>';
+
+ echo '<br />';
+ }
+
+ echo '<table class="arch_tbl anl_bt anl_bl" style="width:100%">';
+ echo '<tr>';
+ if ($defaultFields['delete'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_delete'].'</td>';
+ if ($defaultFields['edit'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_edit'].'</td>';
+ if ($defaultFields['email'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_send'].'</td>';
+ if ($defaultFields['name'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_name'].'</td>';
+ if ($defaultFields['note'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_note'].'</td>';
+ if ($defaultFields['access'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_access'].'</td>';
+ if ($defaultFields['type'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_type'].'</td>';
+ if ($defaultFields['date'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_date'].'</td>';
+ if ($defaultFields['duration'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_duration'].'</td>';
+ if ($defaultFields['insert'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_author'].'</td>';
+ if ($defaultFields['edit'])
+ echo '<td class="anl_bck gray anl_bb anl_br anl_ac">'.$lang['srv_analiza_archive_lbl_editor'].'</td>';
+ echo '</tr>';
+
+ while ($row = mysqli_fetch_assoc($s)) {
+ echo '<tr id="AnalysisArchiveRow_'.$row['id'].'">';
+ if ($defaultFields['delete']) {
+ echo '<td class="anl_bb anl_br anl_ac">';
+ echo '<span>';
+ echo '<a href="/" onclick="AnalysisArchiveDelete(\'' . $row['id'] . '\'); return false;" title="">';
+ echo '<img src="img_0/delete_red.png" alt="" />';
+ echo '</a>';
+ echo '</span>';
+ echo '</td>';
+ }
+ if ($defaultFields['edit']) {
+ echo '<td class="anl_bb anl_br anl_ac">';
+ echo '<span>';
+ echo '<a href="/" onclick="AnalysisArchiveEdit(\'' . $row['id'] . '\'); return false;" title="">';
+ echo '<img src="img_0/edit.png" alt="" />';
+ echo '</a>';
+ echo '</span>';
+ echo '</td>';
+ }
+ if ($defaultFields['email']) {
+ echo '<td class="anl_bb anl_br anl_ac">';
+ echo '<span>';
+ echo '<a href="/" onclick="emailArchiveAnaliza(\'' . $row['id'] . '\'); return false;" title="">';
+ echo '<img src="icons/icons/email_link.png" alt="" />';
+ echo '</a>';
+ echo '</span>';
+ echo '</td>';
+ }
+ if ($defaultFields['name']) {
+ echo '<td class="anl_bb anl_br">';
+ echo '<span>';
+ if ($defaultFields['name_link']) {
+ echo '<a href="'.$site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='. $row['id'] . '" target="_blank" title="' . $row['name'] . '">';
+ echo $row['name'];
+ echo '</a>';
+ } else {
+ echo $row['name'];
+ }
+ echo '</span>';
+
+ echo '</td>';
+ }
+ if ($defaultFields['note']) {
+ echo '<td class="anl_bb anl_br">'.$row['note'].'</td>';
+ }
+ if ($defaultFields['access']) {
+ echo '<td class="anl_bb anl_br">'.$lang['srv_analiza_arhiviraj_access_'.$row['access']].'</td>';
+ }
+ if ($defaultFields['type']) {
+ $key = $lang['srv_analiza_arhiviraj_type_'.$row['type']];
+ echo '<td class="anl_bb anl_br anl_ac">'.$key.'</td>';
+ }
+ if ($defaultFields['date']) {
+ echo '<td class="anl_bb anl_br anl_ac" title="'.date('d.m.Y H:m:s',$row['insert_date']).'">';
+ echo date('d.m.Y',$row['insert_date']);
+ echo '</td>';
+ }
+ if ($defaultFields['duration']) {
+ # koliko dni damo v title
+ $days = ($row['days_left'] == 1)
+ ? $lang['1day']
+ : $row['days_left'].' '.$lang['hour_days'];
+ echo '<td class="anl_bb anl_br anl_ac" title="'.$days.'">';
+ echo date('d.m.Y',$row['duration_d']);
+ echo '</td>';
+ }
+ if ($defaultFields['insert']) {
+ $users = array();
+ echo '<td class="anl_bb anl_br" title="'.$row['iname'].' '.$row['isurname'].'">';
+ echo $row['iemail'];
+ echo '</td>';
+ }
+ if ($defaultFields['edit']) {
+ echo '<td class="anl_bb anl_br" title="'.$row['ename'].' '.$row['esurname'].'">';
+ echo $row['eemail'];
+ echo '</td>';
+ }
+ echo '</tr>';
+ }
+ echo '</table>';
+ }
+ else {
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_archive_analysis'].'</legend>';
+
+ echo $lang['srv_analiza_archive_note_no_archive'];
+ echo '<br/><br/>';
+ echo $lang['srv_analiza_archive_generate_quick'];
+
+ echo '</fieldset>';
+ }
+ }
+
+ /** Skreira tekstovni fajl in shrani zapis o fajlu v bazo.
+ *
+ * @param unknown_type $content
+ * @param unknown_type $name
+ */
+ static function CreateArchive($content,$name=null, $note=null, $access='0',$type=null,$duration=null,$durationType='0',$settings=array(), $access_password=null) {
+ global $site_path, $site_url, $global_user_id, $lang;
+
+ #če ni imena ga zgeneriramo
+ if ($name==null) {
+
+ $name = 'Arhiv: '.date("d.m.Y H:i:s");
+ }
+ $folder = $site_path . 'admin/survey/'.SAA_FOLDER.'/';
+ $filename = 'saa_'.self::$sid.'_'.time().'.txt';
+
+ # če imamo durationType = 2, imamo trajen arhiv (do leta 2038 - max za 32bit server)
+ if ($durationType == 2) {
+ $duration = strtotime(date("d.m.Y", strtotime('1.1.2038')));
+ }
+ else{
+ # če imamo durationType = 0, imamo privzet interval 3 mesece
+ if ($durationType == 0) {
+ $duration = null;
+ }
+ if ( $duration == null ) { #če ni časa trajanja ga zgeneriramo
+ $duration = date("Y-m-d");// current date
+ $duration = strtotime(date("Y-m-d", strtotime($duration)) . DEFAULT_DURATION);
+ } else { # če je ga pretvorimo v datum
+ $duration = strtotime(date("d.m.Y", strtotime($duration)));
+ }
+ }
+ $duration = date("Y-m-d",$duration);
+
+ $settings = serialize($settings);
+ #dodamo zapis o arhivu v bazo
+ $s = sisplet_query("INSERT INTO srv_analysis_archive (sid, uid, name, filename, date, note, access, type, duration, editid, settings, access_password) "
+ ."VALUES ('".self::$sid."', '$global_user_id', '$name', '$filename', NOW(), '$note', '$access', '$type', '$duration', '$global_user_id', '$settings', '$access_password')");
+ $id = mysqli_insert_id($GLOBALS['connect_db']);
+
+
+ // Na zacetek dodamo glavo -> po novem se shrani v file
+ SurveyInfo::getInstance()->SurveyInit(self::$sid);
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('akronim');
+ if ($naslov == null || trim($naslov) == '') {
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('naslov');
+ }
+
+ $text = '<div id="arch_body_div">';
+
+ SurveySetting::getInstance()->Init(self::$sid);
+ $survey_hide_title = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hide_title');
+
+ // Ce ne prikazujemo naslova ankete to skrijemo
+ if($survey_hide_title == 0){
+ $text .= '<div class="arch_head_date">'
+ .$lang['srv_analiza_archive_date_created']
+ .date("d.m.Y")
+ .'</div><h2>'.$naslov.'</h2>';
+ }
+
+ // Porocilo po meri ima custom naslov
+ $text .= ($survey_hide_title == 1) ? '<h2>' : '<h3>';
+ if($type == 8){
+ $SCR = new SurveyCustomReport(self::$sid);
+ $creport_title = $SCR->getTitle();
+ $text .= $creport_title;
+ }
+ else{
+ $text .= $lang['srv_analiza_archive_title'].$lang['srv_analiza_arhiviraj_type_'.$type];
+ }
+ $text .= ($survey_hide_title == 1) ? '</h2>' : '</h3>';
+
+ $content = $text.$content;
+
+
+ if ($id) { # če smo dodali zapis v bazo shranimo še datoteko
+ # zapišemo fajl na disk
+ $fh = fopen($folder.$filename, 'w') or die("can't open file");
+ fwrite($fh, $content);
+ fclose($fh);
+
+ }
+ self :: DisplayCreatedArchive($id,$name);
+ }
+
+ static function DisplayDoArchive() {
+ global $lang, $site_url;
+
+ echo '<div id="div_analiza_archive_name" class="divPopUp">'."\n";
+
+ echo '<div class="popup_close"><a href="#" onClick="cancleArchiveAnaliza(); return false;">✕</a></div>';
+
+ echo '<h2>'.$lang['srv_analiza_arhiv'].'</h2>';
+
+ echo $lang['srv_analiza_arhiviraj_ime'];
+ echo ':&nbsp;<input id="newAnalysisArchiveName" name="newAnalysisArchiveName" type="text" size="60" />'."\n";
+
+ echo '<br class="clr" />';
+
+ echo '<div>';
+ echo $lang['srv_analiza_archive_note'].':';
+ echo '<textarea name="newAnalysisArchiveNote" id="newAnalysisArchiveNote" style="height:50px; width:100%"></textarea>';
+ echo '</div>';
+ echo '<br class="clr" />';
+ echo '<div>';
+ // dostop
+ echo '<div class="floatLeft">';
+ echo $lang['srv_analiza_archive_access'].':';
+ echo '<br/><input type="radio" name="newAnalysisArchiveAccess" value="0" checked="true" onchange="toggleAnalysisArchiveAccessPassword();"/>&nbsp;'.$lang['srv_analiza_archive_access_all'];
+ echo '<br/><input type="radio" name="newAnalysisArchiveAccess" value="1" onchange="toggleAnalysisArchiveAccessPassword();"/>&nbsp;'.$lang['srv_analiza_archive_access_admins'];
+ echo '<br/><input type="radio" name="newAnalysisArchiveAccess" value="2" onchange="toggleAnalysisArchiveAccessPassword();"/>&nbsp;'.$lang['srv_analiza_archive_access_password'];
+ echo '<br/><div id="newAnalysisArchiveAccessPasswordDiv" style="visibility: hidden;">'.$lang['srv_analiza_archive_access_password_label'].'<input type="text" name="newAnalysisArchiveAccessPassword" id="newAnalysisArchiveAccessPassword" maxlength="25" />';
+ echo '</div></div>';
+ echo '<div class="floatLeft anl_w110" >&nbsp;</div>';
+
+ // trajanje
+ echo '<div class="floatLeft">';
+ echo $lang['srv_analiza_archive_duration'].':';
+ echo '<br/>';
+ $date = date("Y-m-d");// current date
+ $duration = strtotime(date("Y-m-d", strtotime($date)) . " +3 month");
+ $duration = date("d.m.Y",$duration);
+ echo '<input type="radio" name="newAADurationType" id="newAADurationFixed" value="0" checked="true" />';
+ printf ($lang['srv_analiza_archive_duration_default'], $duration);
+ echo '<br/>';
+ echo '<input type="radio" name="newAADurationType" id="newAADurationUser" value="1" />'.$lang['srv_analiza_archive_duration_custom'].'&nbsp;<input id="newAnalysisArchiveDuration" type="text" name="newAnalysisArchiveDuration" value="' . $duration . '" disabled/>
+ <span class="faicon calendar_icon icon-as_link" id="duration_img"></span>
+ <script type="text/javascript">
+ Calendar.setup({
+ inputField : "newAnalysisArchiveDuration",
+ ifFormat : "%d.%m.%Y",
+ button : "duration_img",
+ singleClick : true
+ });
+ </script>
+ ';
+ echo '<br/>';
+ echo '<input type="radio" name="newAADurationType" id="newAADurationPermanent" value="2" />'.$lang['srv_permanent_archive'];
+ echo '</div>';
+
+ echo '<div class="clr"></div>';
+ echo '</div>';
+
+ echo '<div class="div_curent_archives">'."\n";
+ echo $lang['srv_analiza_current_archives'];
+ if (true) {
+ self :: ListArchive(array('create_new'=>false, 'delete'=>false, 'edit'=>false, 'email'=>false, 'access'=>false, 'note'=>false, 'type'=>true, 'access'=>false, 'name_link'=>true,'duration'=>false, 'insert'=>true, 'edit'=>false));
+ #self :: ListArchive(array('delete'=>false, 'edit'=>false, 'email'=>false, 'access'=>false, 'note'=>false, 'type'=>false, 'access'=>false, 'name_link'=>true, 'duration'=>false, 'insert'=>false, 'edit'=>false));
+ } else {
+ echo $lang['srv_analiza_no_current_archives'];
+ }
+
+ echo '</div>'."\n"; // end: div_curent_archives
+
+
+ if ($_GET['podstran'] == M_ANALYSIS_CROSSTAB || $_POST['podstran'] == M_ANALYSIS_CROSSTAB) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveCrosstabs(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ } else if ($_GET['podstran'] == M_ANALYSIS_MEANS || $_POST['podstran'] == M_ANALYSIS_MEANS) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveMeans(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ } else if ($_GET['podstran'] == M_ANALYSIS_TTEST || $_POST['podstran'] == M_ANALYSIS_TTEST) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveTTest(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ } else if ($_GET['podstran'] == M_ANALYSIS_BREAK || $_POST['podstran'] == M_ANALYSIS_BREAK) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveBreak(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ } else if ($_GET['podstran'] == M_ANALYSIS_CHARTS || $_POST['podstran'] == M_ANALYSIS_CHARTS) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveChart(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ } else if ($_GET['podstran'] == M_ANALYSIS_CREPORT || $_POST['podstran'] == M_ANALYSIS_CREPORT) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveCReport(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ } else {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_create'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="submitArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_create'].'</span></a></span></span>'."\n";
+ }
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_cancle'].'"><a class="ovalbutton ovalbutton_gray" href="#" onclick="cancleArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_cancle'].'</span></a></span></span>'."\n";
+
+
+ echo '</div>'."\n"; // end div_analiza_archive_name
+ }
+
+ static function DisplayCreatedArchive($aid=null, $name) {
+ global $lang, $site_url;
+
+ echo '<div id="div_analiza_archive_name" class="divPopUp">'."\n";
+
+ echo '<div class="popup_close"><a href="#" onClick="closeArchiveAnaliza(); return false;">✕</a></div>';
+
+ echo '<h2>'.$lang['srv_analiza_arhiv'].'</h2>';
+
+ $CAE = self::CheckArchiveExistance($aid);
+ if ( $CAE > 0) {
+ echo '<div>';
+ printf( $lang['srv_analiza_arhiviraj_success'],$name);
+ echo '</div>';
+ echo '<br/>';
+
+ echo '<div>';
+ echo $lang['srv_analiza_arhiviraj_success_note'];
+ echo '<br/>';
+ echo '<span>';
+ echo '<a href="'.$site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='. $aid . '" target="_blank" title="">';
+ echo $site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='. $aid;
+ echo '</a>';
+ echo '</span>';
+ echo '</div>';
+
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_close'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="closeArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_close'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_send_mail'].'"><a class="ovalbutton ovalbutton_gray" href="#" onclick="emailArchiveAnaliza(\''.$aid.'\'); return false;" ><span><img src="icons/icons/email_link.png" alt="" /> '.$lang['srv_analiza_arhiviraj_send_mail'].'</span></a></span></span>'."\n";
+ } else {
+ self::DisplayError($CAE);
+ }
+
+ # seznam arhivov
+ echo '<br class="clr" />';
+ echo '<div class="div_curent_archives">'."\n";
+ echo $lang['srv_analiza_current_archives'];
+ if (true) {
+ self :: ListArchive(array('delete'=>false, 'edit'=>false, 'email'=>false, 'access'=>false, 'note'=>false, 'type'=>true, 'access'=>false, 'name_link'=>true,'duration'=>false, 'insert'=>true, 'edit'=>false));
+ } else {
+ echo $lang['srv_analiza_no_current_archives'];
+ }
+ echo '</div>'."\n"; // end: div_curent_archives
+
+ echo '</div>'."\n"; // end div_analiza_archive_name
+ }
+
+ static function EmailArchive($aid) {
+ global $lang;
+
+ echo '<div id="div_analiza_archive_name" class="divPopUp">'."\n";
+
+ echo '<div class="popup_close"><a href="#" onClick="cancleArchiveAnaliza(); return false;">✕</a></div>';
+
+ echo '<h2>'.$lang['srv_analiza_arhiv'].'</h2>';
+
+ # preverimo obstoj datoteke, in dostop
+ $CAE = self::CheckArchiveExistance($aid);
+
+ if ( $CAE > 0) {
+ # vsebina emaila in naslovi
+ echo '<div id="div_archives_email_left">'."\n";
+
+ echo '<p>'.$lang['srv_analiza_archive_message_note'].'</p>';
+
+ echo '<div ><label for="email_archive_list">'.$lang['srv_analiza_archive_message_emails'].':</label>'."\n";
+ echo '<textarea name="email_archive_list" rows="4" id="email_archive_list" ></textarea>'."\n";
+ echo '</div>';
+
+ echo '<br>';
+
+ echo '<div class="anl_dash_bt">';
+ echo '<br/><label for="subject">' . $lang['subject'] . ': </label>';
+ echo '<input type="text" name="email_archive_subject" id="email_archive_subject" value="'.$lang['srv_analiza_arhiviraj_mail_subject'].'" size="90"/></p>';
+ echo '<p><label for="email_archive_text">' . $lang['text'] . ':</label>'."\n";
+
+ $signature = Common::getEmailSignature();
+ echo '<textarea name="email_archive_text" id="email_archive_text" rows="2" >' . nl2br($lang['srv_analiza_arhiviraj_mail_text'].$signature). '</textarea>'."\n";
+ echo '</div>';
+
+ echo '<script type="text/javascript">'."\n";
+ echo 'if ($("#email_archive_text")) {'."\n";
+ echo ' create_editor(\'email_archive_text\', false);'."\n";
+ echo '}'."\n";
+ echo '</script>'."\n";
+
+ echo '</div>'."\n";
+ #gumbi
+ echo '<div id="div_archives_email_right" >'."\n";
+
+ echo '<div id="div_archives_email_buttons">';
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_do_send_mail'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="sendEmailArchiveAnaliza(\''.$aid.'\'); return false;"><span>'.$lang['srv_analiza_arhiviraj_do_send_mail'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_close'].'"><a class="ovalbutton ovalbutton_gray" href="#" onclick="cancleArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_close'].'</span></a></span></span>'."\n";
+ echo '<br class="clr" />';
+ echo '</div>';
+ echo '<div id="div_error">';
+ # navodila
+ echo $lang['srv_analiza_arhiviraj_mail_note_0'];
+ echo '</div>';
+ echo '<br/>';
+ echo '<br/>';
+ echo '<div id="div_error">';
+ # navodila
+ echo $lang['srv_analiza_arhiviraj_mail_note_1'];
+ echo '</div>';
+ echo '</div>';
+ echo '<br class="clr" />';
+ } else {
+ self::DisplayError($CAE);
+ }
+ echo '</div>'."\n"; // end div_analiza_archive_name
+ }
+
+ static function SendEmailArchive($aid = null, $subject, $text, $emails) {
+ global $lang, $site_url, $site_path, $global_user_id;
+
+ echo '<div id="div_analiza_archive_name" class="divPopUp">'."\n";
+
+ echo '<div class="popup_close"><a href="#" onClick="cancleArchiveAnaliza(); return false;">✕</a></div>';
+
+ echo '<h2>'.$lang['srv_analiza_arhiv'].'</h2>';
+
+ $CAE = self::CheckArchiveExistance($aid);
+ if ( $CAE > 0) {
+ if (isset($emails) && trim($emails) != "") {
+ $_subject = ( isset($subject) && trim($subject) != "" )
+ ? stripcslashes ($subject)
+ : stripcslashes ($lang['srv_analiza_arhiviraj_mail_subject']);
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+
+ $_text = ( isset($text) && trim($text) != "" )
+ ? stripcslashes ($text)
+ : stripcslashes (nl2br($lang['srv_analiza_arhiviraj_mail_text'].$signature));
+
+ # polovimo podatke ankete
+ SurveyInfo::getInstance()->SurveyInit(self::$sid);
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ #polovimo podatke arhiva
+ $archQry = sisplet_query("SELECT date FROM srv_analysis_archive WHERE sid='".self::$sid."' AND id='".$aid."'");
+ $archRow = mysqli_fetch_assoc($archQry);
+
+ $userQry = sisplet_query("SELECT name, surname, id, email FROM users WHERE id='$global_user_id'");
+ $userRow = mysqli_fetch_assoc($userQry);
+
+ /* zamenjave
+ [LINK]</dt><dd>HTML povezava do arhiva
+ [URL]</dt><dd>URL povezave do arhiva
+ [NAME]</dt><dd>ime uporabnika (iz baze (CMS))
+ [SURVEY]</dt><dd>ime ankete
+ [DATE]</dt><dd>datum
+ [SITE]</dt><dd>URL do ankete</dd></dl>",
+ */
+ $in = array('[LINK]','[URL]','[NAME]','[SURVEY]','[DATE]','[SITE]');
+
+ $repl_link = '<a href="'.$site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='.$aid.'">'.$site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='.$aid.'</a>';
+ $repl_url = $site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='.$aid;
+ $repl_name = $userRow['name'].' '.$userRow['surname'].' ('.$userRow['email'].')';
+ $repl_survey = $row['naslov'];
+ $repl_date = $archRow['date'];
+ $repl_site = $site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid;
+
+ $out = array($repl_link,$repl_url,$repl_name,$repl_survey,$repl_date,$repl_site);
+
+ $_subject = str_replace($in,$out,$_subject);
+ $_text= str_replace($in,$out,$_text);
+
+ # v loopu pošljemo maile
+ $email_addresses = explode("\n", $emails);
+ if (count($email_addresses)) {
+
+ $status_success = array();
+ $status_error = array();
+ foreach ($email_addresses AS $email) {
+ $email = trim($email);
+ if (strlen ($email) > 1) {
+ // Posljemo mail vsakemu uporabniku posebej
+ try
+ {
+ $MA = new MailAdapter(self::$sid, $type='alert');
+ $MA->addRecipients($email);
+ $resultX = $MA->sendMail($_text, $_subject);
+ }
+ catch (Exception $e)
+ {
+ }
+
+ if ($resultX) {
+ $status_success[] = $email; // poslalo ok
+ } else {
+ $status_error[] = $email; // ni poslalo
+ }
+ }
+ } // end foreach
+
+ // zlistamo uspešne in neuspešne naslove
+ echo '<b>Sporočilo:</b><br/><br/>' . $_subject . ',<br/> ' . $_text . '<br/>';
+ if (count($status_success) > 0) {
+ echo '<b>je bilo uspešno poslano na naslednje naslove:<br/></b>';
+ foreach ($status_success as $email) {
+ echo $email . ",<br/>";
+ }
+ echo "<br/>";
+ }
+ if (count($status_error) > 0) {
+ echo '<br/><b>ni bilo uspešno poslano na naslednje naslove:<br/></b>';
+ foreach ($status_error as $email) {
+ echo $email . ",<br/>";
+ }
+ }
+
+ } else {
+ echo 'No email adress!';
+ }
+
+ } else {
+ echo 'Pri pošiljanju e-mailov je prišlo do napake!';
+ }
+
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_close'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="cancleArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_close'].'</span></a></span></span>'."\n";
+ echo '<br class="clr" />';
+ } else {
+ self::DisplayError($CAE);
+ }
+
+ echo '</div>'."\n"; // end div_analiza_archive_name
+ }
+
+ static function EditArchive($aid) {
+ global $lang, $site_url, $site_path, $global_user_id;
+
+ echo '<div id="div_analiza_archive_name" class="divPopUp">'."\n";
+
+ echo '<div class="popup_close"><a href="#" onClick="cancleArchiveAnaliza(); return false;">✕</a></div>';
+
+ echo '<h2>'.$lang['srv_analiza_arhiv'].'</h2>';
+
+ $CAE = self::CheckArchiveExistance($aid);
+ if ( $CAE > 0) {
+ # polovimo podatke o arhivu
+ $s = sisplet_query("SELECT *, UNIX_TIMESTAMP(duration) as duration_d FROM srv_analysis_archive WHERE id='".$aid."' AND sid='".self::$sid."'");
+ $row = mysqli_fetch_assoc($s);
+
+ echo $lang['srv_analiza_arhiviraj_ime'];
+ echo ':&nbsp;<input id="newAnalysisArchiveName" name="newAnalysisArchiveName" type="text" size="60" value="'.$row['name'].'"/>'."\n";
+
+ echo '<br class="clr" />';
+ echo '<div>';
+ echo $lang['srv_analiza_archive_note'].':';
+ echo '<textarea name="newAnalysisArchiveNote" id="newAnalysisArchiveNote" style="height:50px; width:100%">'.$row['note'].'</textarea>';
+ echo '</div>';
+ echo '<div>';
+ // dostop
+ echo '<div class="floatLeft">';
+ echo $lang['srv_analiza_archive_access'].':';
+ echo '<br/><input type="radio" name="newAnalysisArchiveAccess" value="0"'.((int)$row['access'] == 0 ? ' checked="true"' : '').' onchange="toggleAnalysisArchiveAccessPassword();"/>&nbsp;'.$lang['srv_analiza_archive_access_all'];
+ echo '<br/><input type="radio" name="newAnalysisArchiveAccess" value="1"'.((int)$row['access'] == 1 ? ' checked="true"' : '').' onchange="toggleAnalysisArchiveAccessPassword();"/>&nbsp;'.$lang['srv_analiza_archive_access_admins'];
+ echo '<br/><input type="radio" name="newAnalysisArchiveAccess" value="2"'.((int)$row['access'] == 2 ? ' checked="true"' : '').' onchange="toggleAnalysisArchiveAccessPassword();"/>&nbsp;'.$lang['srv_analiza_archive_access_password'];
+ echo '<br/><div id="newAnalysisArchiveAccessPasswordDiv" style="visibility: '.((int)$row['access'] == 2 ? 'visible' : 'hidden').';">'.$lang['srv_analiza_archive_access_password_label'].'<input type="text" name="newAnalysisArchiveAccessPassword" id="newAnalysisArchiveAccessPassword" maxlength="25" value="'.$row['access_password'].'"/>';
+ echo '</div></div>';
+
+ echo '<div class="floatLeft anl_w110" >&nbsp;</div>';
+ // trajanje
+ echo '<div class="floatLeft">';
+ echo $lang['srv_analiza_archive_duration'].':';
+ echo '<br/>';
+ echo '<input id="newAnalysisArchiveDuration" type="text" name="newAnalysisArchiveDuration" value="' . date('d.m.Y',$row['duration_d']) . '" disabled/>
+ <span class="faicon calendar_icon icon-as_link" id="duration_img"></span>
+ <script type="text/javascript">
+ Calendar.setup({
+ inputField : "newAnalysisArchiveDuration",
+ ifFormat : "%d.%m.%Y",
+ button : "duration_img",
+ singleClick : true
+ });
+ </script>
+ ';
+
+ echo '</div>';
+ echo '<div class="clr"></div>';
+ echo '</div>';
+
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_save'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="saveArchiveAnaliza(\''.$aid.'\'); return false;"><span>'.$lang['srv_analiza_arhiviraj_save'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_close'].'"><a class="ovalbutton ovalbutton_gray" href="#" onclick="cancleArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_close'].'</span></a></span></span>'."\n";
+ echo '<br class="clr" />';
+ } else {
+ self::DisplayError($CAE);
+ }
+ echo '</div>'."\n"; // end div_analiza_archive_name
+ }
+
+ static function SaveArchive($aid,$name,$note,$access,$duration,$access_password) {
+ global $lang, $site_url, $site_path, $global_user_id;
+
+ $CAE = self::CheckArchiveExistance($aid);
+ if ( $CAE > 0) {
+ if ($name==null || trim($name) == "") {
+ $name = 'Arhiv: '.date("d.m.Y H:i:s");
+ }
+
+ if ( $duration == null ) { #če ni časa trajanja ga zgeneriramo
+ $duration = date("Y-m-d");// current date
+ $duration = strtotime(date("Y-m-d", strtotime($duration)) . DEFAULT_DURATION);
+ } else { # če je ga pretvorimo v datum
+ $duration = strtotime(date("d.m.Y", strtotime($duration)));
+ }
+ # pripravimo pravilno obliko datuma za insert v bazo
+ $duration = date("Y-m-d",$duration);
+
+ $updated = sisplet_query("UPDATE srv_analysis_archive SET name= '$name', note='$note', access='$access', duration='$duration', editid='$global_user_id', access_password='$access_password' WHERE id = '$aid'");
+
+ echo $updated;
+ } else {
+ echo $CAE;
+ }
+
+ }
+
+ /**
+ *
+ * @param $aid
+ *
+ * @return -1 = invalid $aid
+ * @return -2 = file not exist
+ * @return -3 = no access
+ * @return -4 = invalid profile id
+ * @return -5 = no access, pass needed
+ */
+ static function CheckArchiveExistance($aid) {
+ global $site_path;
+
+ if ($aid < 1 || $aid == null || trim($aid) == "") {
+ # invalid $aid
+ return -1;
+ }
+
+ #podtki profila
+ $s = sisplet_query("SELECT filename, access FROM srv_analysis_archive WHERE id='".$aid."' AND sid='".self::$sid."'");
+ if ($_GET['debug'] == 1) {
+ print_r("SELECT * FROM srv_analysis_archive WHERE id='".$aid."' AND sid='".self::$sid."'");
+ }
+ if (mysqli_num_rows($s)) {
+
+ $row = mysqli_fetch_assoc($s);
+
+ # najprej preverimo obstoj datoteke
+ $filename = $site_path . 'admin/survey/'.SAA_FOLDER.'/'.$row['filename'];
+ if (file_exists($filename)) {
+ #preverimo dostop
+ if ($row['access'] == '0') {
+ return true;
+ } else {
+ # preverimo ali ima trenuten uid dostop do ankete
+ if (self::CheckArchiveAccess()) {
+ return true;
+ }
+ #dostop z geslom
+ elseif($row['access'] == '2'){
+ if(isset($_SESSION['archive_access'][$aid]) && $_SESSION['archive_access'][$aid] == '1')
+ #uporabnik je vpisal pravileno geslo
+ return true;
+ else
+ #uporabnik nima dostopa, za dostop vpogleda je potrebno geslo
+ return -5;
+ }
+ else {
+ # uporabnik nima dostopa
+ return -3;
+ }
+ }
+
+ } else { # return -2 => file not exist
+ # pobrišemo morebiten zapis iz baze
+ $sqlDelete = sisplet_query("DELETE FROM srv_analysis_archive WHERE id='".$aid."' AND sid='".self::$sid."'");
+
+ return -2;
+ }
+
+ } else {
+ #invalid profile ID;
+ return -4;
+ }
+ }
+
+ static function CheckArchiveAccess($uid=null) {
+ global $global_user_id, $admin_type;
+
+ if ($uid == null) {
+ $uid = $global_user_id;
+ }
+
+ #podtki dostopa
+ $a = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id = '".self::$sid."' AND uid='".$uid."'");
+
+ if (mysqli_num_rows($a) || $admin_type === '0') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ static function ViewArchive($aid) {
+ global $site_path, $global_user_id, $lang, $site_url;
+
+ #izpišemo osnovni html
+ $sql = sisplet_query("SELECT * FROM misc WHERE what='name'");
+ $row = mysqli_fetch_array($sql);
+
+ // nastavimo jezik
+ if (self::$sid > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '".self::$sid."'");
+ $row = mysqli_fetch_array($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_array($sql);
+ $lang_admin = $row['value'];
+ }
+
+ // Naložimo jezikovno datoteko (da se datumin naslov izpiseta v pravem jeziku)
+ $file = '../../lang/'.$lang_admin.'.php';
+ include($file);
+ $_SESSION['langX'] = $site_url .'lang/'.$lang_admin.'.php';
+
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'."\n";
+ echo '<head>'."\n";
+ echo '<title>'.$row['value'].'</title>'."\n";
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n";
+ echo '<script type="text/javascript" src="script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ if ($_GET['mode'] != 'old') {
+ echo '<script type="text/javascript" src="minify/g=jsnew"></script>'."\n";
+ } else {
+ echo '<script type="text/javascript" src="minify/g=js"></script>'."\n";
+ }
+ echo '<link type="text/css" href="minify/g=css" media="screen" rel="stylesheet" />'."\n";
+ echo '<link type="text/css" href="minify/g=cssPrint" media="print" rel="stylesheet" />'."\n";
+ echo '<style type="text/css">.iconHide{display:none;}</style>'."\n";
+
+ echo '</head>'."\n";
+ echo '<body id="arch_body" >'."\n";
+
+ #polovimo podatke ankete
+ SurveyInfo::getInstance()->SurveyInit(self::$sid);
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('akronim');
+ if ($naslov == null || trim($naslov) == '') {
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('naslov');
+ }
+
+ # podatki arhiva
+ $s = sisplet_query("SELECT filename, date, type FROM srv_analysis_archive WHERE id='".$aid."'");
+ $row = mysqli_fetch_assoc($s);
+
+ $CAE = self::CheckArchiveExistance($aid);
+
+ if ( $CAE > 0) {
+ $folder = $site_path . 'admin/survey/'.SAA_FOLDER.'/';
+
+
+ $fh = fopen($folder.$row['filename'], 'r');
+ $theData = fread($fh, filesize($folder.$row['filename']));
+ fclose($fh);
+
+ $in = array('\"', "\'");
+ $out = array('"', "'",);
+
+ $theData = str_replace($in, $out, $theData);
+
+ // Zaradi kompatibilnosti za nazaj -> ko se se ni naslov in datum shranjeval v file
+ if(substr($theData, 0, 24) != '<div id="arch_body_div">'){
+ echo '<div id="arch_body_div">'."\n";
+
+ echo '<div class="arch_head_date">';
+ echo $lang['srv_analiza_archive_date_created'];
+ $datetime = strtotime($row['date']);
+ echo date("d.m.Y",$datetime);
+ echo '</div>';
+
+ echo '<h2>'.$naslov.'</h2>';
+
+ echo '<h3>'.$lang['srv_analiza_archive_title'].$lang['srv_analiza_arhiviraj_type_'.$row['type']].'</h3>';
+ }
+
+ echo $theData;
+
+ }
+ else {
+ // Zaradi kompatibilnosti za nazaj -> ko se se ni naslov in datum shranjeval v file
+ if(substr(0, 25, $theData) != '<div id="arch_body_div">'){
+ echo '<div id="arch_body_div">'."\n";
+
+ echo '<div class="arch_head_date">';
+ echo $lang['srv_analiza_archive_date_created'];
+ $datetime = strtotime($row['date']);
+ echo date("d.m.Y",$datetime);
+ echo '</div>';
+ }
+
+ //to access, password is needed
+ if($CAE == -5){
+ // form for access with password
+ self::DisplayAccessPassword($aid);
+ }
+ //no access/other error
+ else{
+ // Izpišemo error
+ self::DisplayError($CAE,false);
+ }
+ }
+
+ #izpišemo še zaključek html
+ echo '</div>'."\n";
+ echo '</body>'."\n";
+ echo '</html>';
+ }
+
+ static function DisplayError($CAE, $showButton=true) {
+ global $lang;
+
+ echo '<div>';
+ echo $lang['srv_analiza_arhiviraj_error_'.$CAE];
+ echo '</div>';
+
+ if ($showButton) {
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_close'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="closeArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_close'].'</span></a></span></span>'."\n";
+ echo '<br class="clr" />';
+ }
+ }
+
+ /**
+ * Display from for password to access archive
+ * @global type $lang
+ * @param type $aid - archive id
+ */
+ static function DisplayAccessPassword($aid) {
+ global $lang, $site_url;
+
+ echo '<br><div style="float:left"><fieldset>';
+ echo '<legend>' . $lang['srv_analiza_archive_access'] . '</legend>';
+
+ echo '<form name="archive_access_pass_form" id="archive_access_pass_form" method="post" action="'.$site_url.'admin/survey/AnalysisArchive.php?anketa='.self::$sid.'&aid='. $aid . '">';
+ //echo '<input type="hidden" name="archive_id" value="' . $aid . '">';
+
+ //user insertet wrong password
+ if(isset($_SESSION['archive_access'][$aid]) && $_SESSION['archive_access'][$aid] == '0')
+ echo '<i class="red" id="archive_access_wrong_pass_warning">' . $lang['srv_analiza_archive_access_wrong_pass'] . '</i><br>';
+
+ echo '<br>'.$lang['srv_analiza_archive_access_password_label'].': ';
+ echo '<input type="password" name="archive_access_pass" id="archive_access_pass" maxlength="25" value="" /><br><br>';
+
+ echo '<span class="spaceRight floatLeft"><div class="buttonwrapper">'
+ . '<a class="ovalbutton ovalbutton_orange btn_savesettings" href="#" onclick="$(\'#archive_access_pass_form\').submit();">';
+ echo $lang['srv_analiza_archive_access_button'];
+ echo '</a></div></span><br><br>';
+ echo '</form></fieldset></div>';
+ }
+
+ /**
+ * Check if archive access password matches
+ * @return boolean
+ */
+ static function CheckArchiveAccessPass() {
+ $sql = sisplet_query("SELECT access_password AS pass FROM srv_analysis_archive WHERE id = '".$_POST['archive_id']."'");
+ if($sql){
+ $row = mysqli_fetch_array($sql);
+ if($row['pass'] == $_POST['archive_access_pass'])
+ return true;
+ else
+ return false;
+ }
+ return false;
+ }
+
+ static function AskDeleteArchive($aid) {
+ global $lang;
+
+ echo '<div id="div_analiza_archive_name" class="divPopUp">'."\n";
+
+ $CAE = self::CheckArchiveExistance($aid);
+
+ if ( $CAE > 0) {
+ echo '<h2>Ali ste prepričani?</h2>';
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_delete'].'"><a class="ovalbutton ovalbutton_orange" href="#" onclick="doDeleteArchiveAnaliza(\''.$aid.'\'); return false;"><span>'.$lang['srv_analiza_arhiviraj_delete'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper" title="'.$lang['srv_analiza_arhiviraj_cancle'].'"><a class="ovalbutton ovalbutton_gray" href="#" onclick="cancleArchiveAnaliza(); return false;"><span>'.$lang['srv_analiza_arhiviraj_cancle'].'</span></a></span></span>'."\n";
+
+ echo '<br class="clr" />';
+ }
+ else {
+ #izpišemo error
+ self::DisplayError($CAE,true);
+ }
+
+ echo '</div>'."\n"; // end: div_analiza_archive_name
+ }
+
+ static function DoDeleteArchive($aid) {
+ global $site_path;
+
+ $CAE = self::CheckArchiveExistance($aid);
+
+ if ( $CAE > 0) {
+ $sqlSelect = sisplet_query("SELECT filename FROM srv_analysis_archive WHERE id='".$aid."' AND sid='".self::$sid."'");
+ $rowSelect = mysqli_fetch_assoc($sqlSelect);
+
+ #izbrišemo datoteko
+ $filename = $site_path . 'admin/survey/'.SAA_FOLDER.'/'.$rowSelect['filename'];
+ unlink($filename);
+
+ #izbrišemo zapis iz baze
+ $sqlDelete = sisplet_query("DELETE FROM srv_analysis_archive WHERE id='".$aid."' AND sid='".self::$sid."'");
+ return 1;
+ } else {
+ #vrnemo error
+ return $CAE;
+ }
+ }
+
+ static function archiveCrosstabBeforeEmail() {
+ global $site_path, $site_url, $global_user_id, $lang;
+
+ $ArchiveTypes = array(M_ANALIZA_SUMS => 0, M_ANALIZA_DESCRIPTOR=>1, M_ANALIZA_FREQUENCY=>2, M_ANALIZA_CROSSTAB=>3, M_ANALYSIS_MEANS=>4, M_ANALYSIS_TTEST=>5, M_ANALYSIS_BREAK=>6, M_ANALYSIS_CHARTS=>7, M_ANALYSIS_CREPORT=>8);
+ if (isset($_POST['podstran'])) {
+ $type = $ArchiveTypes[$_POST['podstran']];
+ }
+
+ $content = $_POST['content'];
+
+ if (isset($content) && trim($content) != null) {
+
+ #ime zgeneriramo
+ $name = 'Arhiv: '.date("d.m.Y H:i:s");
+ $access = 0;
+
+ $folder = $site_path . 'admin/survey/'.SAA_FOLDER.'/';
+ $filename = 'saa_'.self::$sid.'_'.time().'.txt';
+
+ #če ni časa trajanja ga zgeneriramo
+ $duration = date("Y-m-d");// current date
+ $duration = strtotime(date("Y-m-d", strtotime($duration)) . DEFAULT_DURATION);
+ # pripravimo pravilno obliko datuma za insert v bazo
+ $duration = date("Y-m-d",$duration);
+
+ #dodamo zapis o arhivu v bazo
+ $s = sisplet_query("INSERT INTO srv_analysis_archive (sid, uid, name, filename, date, note, access, type, duration, editid) "
+ ."VALUES ('".self::$sid."', '$global_user_id', '$name', '$filename', NOW(), '', '$access', '$type', '$duration', '$global_user_id')");
+ $id = mysqli_insert_id($GLOBALS['connect_db']);
+
+
+ // Na zacetek dodamo glavo -> po novem se shrani v file
+ SurveyInfo::getInstance()->SurveyInit(self::$sid);
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('akronim');
+ if ($naslov == null || trim($naslov) == '') {
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('naslov');
+ }
+
+ $text = '<div id="arch_body_div"><div class="arch_head_date">'
+ .$lang['srv_analiza_archive_date_created']
+ .date("d.m.Y")
+ .'</div><h2>'.$naslov.'</h2>';
+
+ $text .= '<h3>'.$lang['srv_analiza_archive_title'].$lang['srv_analiza_arhiviraj_type_'.$type].'</h3>';
+
+ $content = $text.$content;
+
+
+ if ($id > 0) { # če smo dodali zapis v bazo shranimo še datoteko
+ # zapišemo fajl na disk
+ $fh = fopen($folder.$filename, 'w') or die("can't open file");
+ fwrite($fh, $content);
+ fclose($fh);
+
+ echo $id;
+ return $id;
+
+ } else {
+ echo 0;
+ return 0;
+ }
+ } else {
+ echo '-1';
+ return '-1';
+ }
+ }
+
+ static function createArchiveBeforeEmail() {
+ global $site_path, $site_url, $global_user_id, $lang;
+
+ $ArchiveTypes = array(M_ANALIZA_SUMS => 0, M_ANALIZA_DESCRIPTOR=>1, M_ANALIZA_FREQUENCY=>2, M_ANALIZA_CROSSTAB=>3, M_ANALYSIS_MEANS=>4, M_ANALYSIS_TTEST=>5, M_ANALYSIS_BREAK=>6, M_ANALYSIS_CHARTS=>7, M_ANALYSIS_CREPORT=>8);
+ if (isset($_POST['podstran'])) {
+ $type = $ArchiveTypes[$_POST['podstran']];
+ }
+
+ SurveyAnalysis::Init(self::$sid);
+ SurveyAnalysis::setUpReturnAsHtml(true);
+
+ if($_POST['podstran'] == 'charts'){
+ # kreiramo arhiv za grafe
+ $SC = new SurveyChart();
+ $SC->Init(self::$sid);
+ $SC->setUpReturnAsHtml(true);
+ $chartTime = $SC->setUpIsForArchive(true);
+ $content = $SC->display();
+ $settings = array( 'chartTime' => $chartTime);
+ }
+ elseif($_POST['podstran'] == 'analysis_creport'){
+ #kreiramo arhiv za creport
+ $SCR = new SurveyCustomReport(self::$sid);
+ $SCR->setUpReturnAsHtml(true);
+ $SCR->setUpIsForArchive(true);
+ $content = $SCR->displayReport();
+ }
+ else{
+ if (isset($_POST['content']) && trim($_POST['content']) != '') {
+ $content = $_POST['content'];
+ } else {
+ $content = SurveyAnalysis::Display();
+ }
+ }
+
+ if (isset($content) && trim($content) != null) {
+
+ #ime zgeneriramo
+ $name = 'Arhiv: '.date("d.m.Y H:i:s");
+ $access = 0;
+
+ $folder = $site_path . 'admin/survey/'.SAA_FOLDER.'/';
+ $filename = 'saa_'.self::$sid.'_'.time().'.txt';
+
+ #če ni časa trajanja ga zgeneriramo
+ $duration = date("Y-m-d");// current date
+ $duration = strtotime(date("Y-m-d", strtotime($duration)) . DEFAULT_DURATION);
+ # pripravimo pravilno obliko datuma za insert v bazo
+ $duration = date("Y-m-d",$duration);
+
+ #dodamo zapis o arhivu v bazo
+ $s = sisplet_query("INSERT INTO srv_analysis_archive (sid, uid, name, filename, date, note, access, type, duration, editid) "
+ ."VALUES ('".self::$sid."', '$global_user_id', '$name', '$filename', NOW(), '', '$access', '$type', '$duration', '$global_user_id')");
+ $id = mysqli_insert_id($GLOBALS['connect_db']);
+
+
+ // Na zacetek dodamo glavo -> po novem se shrani v file
+ SurveyInfo::getInstance()->SurveyInit(self::$sid);
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('akronim');
+ if ($naslov == null || trim($naslov) == '') {
+ $naslov = SurveyInfo::getInstance()->getSurveyColumn('naslov');
+ }
+
+ $text = '<div id="arch_body_div">';
+
+ SurveySetting::getInstance()->Init(self::$sid);
+ $survey_hide_title = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hide_title');
+
+ // Ce ne prikazujemo naslova ankete to skrijemo
+ if($survey_hide_title == 0){
+ $text .= '<div class="arch_head_date">'
+ .$lang['srv_analiza_archive_date_created']
+ .date("d.m.Y")
+ .'</div><h2>'.$naslov.'</h2>';
+ }
+
+ // Porocilo po meri ima custom naslov
+ $text .= ($survey_hide_title == 1) ? '<h2>' : '<h3>';
+ if($type == 8){
+ $SCR = new SurveyCustomReport(self::$sid);
+ $creport_title = $SCR->getTitle();
+ $text .= $creport_title;
+ }
+ else{
+ $text .= $lang['srv_analiza_archive_title'].$lang['srv_analiza_arhiviraj_type_'.$type];
+ }
+ $text .= ($survey_hide_title == 1) ? '</h2>' : '</h3>';
+
+ $content = $text.$content;
+
+
+ if ($id > 0) { # če smo dodali zapis v bazo shranimo še datoteko
+ # zapišemo fajl na disk
+ $fh = fopen($folder.$filename, 'w') or die("can't open file");
+ fwrite($fh, $content);
+ fclose($fh);
+
+ echo $id;
+ return $id;
+
+ } else {
+ echo 0;
+ return 0;
+ }
+ } else {
+ echo '-1';
+ return '-1';
+ }
+
+ }
+
+ /** zgenerira html iz analize in ga shrani kot arhiv.
+ *
+ */
+ static function createArchiveFromAnaliza() {
+ $content = null;
+ if($_POST['podstran'] == 'charts'){
+ # kreiramo arhiv za grafe
+ $SC = new SurveyChart();
+ $SC->Init(self::$sid);
+ $SC->setUpReturnAsHtml(true);
+ $chartTime = $SC->setUpIsForArchive(true);
+ $content = $SC->display();
+ $settings = array( 'chartTime' => $chartTime);
+ }
+ elseif($_POST['podstran'] == 'analysis_creport'){
+ #kreiramo arhiv za creport
+ $SCR = new SurveyCustomReport(self::$sid);
+ $SCR->setUpReturnAsHtml(true);
+ $SCR->setUpIsForArchive(true);
+ $content = $SCR->displayReport();
+ }
+ else{
+ if ($_POST['podstran'] == 'anal_arch') {
+ $_POST['podstran'] = 'sumarnik';
+ }
+ if (!isset($_POST['content'])) {
+ SurveyAnalysis::Init(self::$sid);
+ SurveyAnalysis::setUpIsForArchive(true);
+ SurveyAnalysis::setUpReturnAsHtml(true);
+
+ $content = SurveyAnalysis::Display();
+ } else {
+ $content = $_POST['content'];
+ }
+ }
+
+ $name = (isset($_POST['name']) && trim($_POST['name'])) ? trim($_POST['name']) : null;
+ $note = (isset($_POST['note']) && trim($_POST['note'])) ? trim($_POST['note']) : null;
+ $access = (isset($_POST['access']) && trim($_POST['access'])) ? trim($_POST['access']) : 0;
+ $access_password = (isset($_POST['access_password']) && trim($_POST['access_password'])) ? trim($_POST['access_password']) : null;
+ $duration = (isset($_POST['duration']) && trim($_POST['duration'])) ? trim($_POST['duration']) : null;
+ $durationType = (isset($_POST['durationType']) && trim($_POST['durationType'])) ? trim($_POST['durationType']) : 0;
+
+ $ArchiveTypes = array(M_ANALIZA_SUMS => 0, M_ANALIZA_DESCRIPTOR=>1, M_ANALIZA_FREQUENCY=>2, M_ANALIZA_CROSSTAB=>3, M_ANALYSIS_MEANS=>4, M_ANALYSIS_TTEST=>5, M_ANALYSIS_BREAK=>6, M_ANALYSIS_CHARTS=>7, M_ANALYSIS_CREPORT=>8);
+ if (isset($_POST['podstran']))
+ $type = $ArchiveTypes[$_POST['podstran']];
+ if (isset($content) && trim($content) != null && self::$sid > 0) {
+
+ SurveyAnalysisArchive :: Init(self::$sid);
+ SurveyAnalysisArchive :: CreateArchive($content,$name,$note,$access,$type,$duration,$durationType,$settings,$access_password);
+
+ } else {
+ echo 'Error! (SurveyAnalysisArchive :: CreateArchive)';
+ }
+
+ }
+}
+?> \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisHelper.php b/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisHelper.php
new file mode 100644
index 0000000..5c0a562
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisHelper.php
@@ -0,0 +1,126 @@
+<?php
+class SurveyAnalysisHelper {
+
+ static private $instance;
+ static private $anketa;
+ static private $db_table = '';
+
+ /**
+ * Poskrbimo za samo eno instanco
+ */
+ static function getInstance()
+ {
+ if(!self::$instance)
+ {
+ self::$instance = new SurveyAnalysisHelper();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Inicializacija
+ *
+ * @param int $anketa
+ */
+ function Init( $anketa = null )
+ {
+ if ($anketa) {
+ self::$anketa = $anketa;
+
+ SurveyInfo::getInstance()->SurveyInit(self::$anketa);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
+ self::$db_table = '_active';
+
+ }
+ }
+
+ function addCustomReportElement($type, $sub_type, $spr1, $spr2=''){
+ global $lang;
+ global $global_user_id;
+
+ if($_GET['m'] != 'analysis_creport' && $_GET['t'] != 'custom_report'){
+ $creportProfile = SurveyUserSetting :: getInstance()->getSettings('default_creport_profile');
+ $creportProfile = isset($creportProfile) ? $creportProfile : 0;
+
+ $creportAuthor = SurveyUserSetting :: getInstance()->getSettings('default_creport_author');
+ $creportAuthor = isset($creportAuthor) ? $creportAuthor : $global_user_id;
+
+ $sql = sisplet_query("SELECT id FROM srv_custom_report WHERE ank_id='".self::$anketa."' AND usr_id='".$creportAuthor."' AND type='$type' AND sub_type='$sub_type' AND spr1='$spr1' AND spr2='$spr2' AND profile='$creportProfile'");
+ $insert = (mysqli_num_rows($sql)) ? 0 : 1;
+ $id = $type.'-'.$sub_type.'-'.$spr1.'-'.$spr2;
+ // Samo zvezdica (sums, grafi, freq...)
+ if($type < 5)
+ echo '<a href="#" title="'.($insert == 0 ? $lang['srv_custom_report_inserted_title'] : $lang['srv_custom_report_insert_title']).'" onClick="addCustomReportElement(\''.$type.'\', \''.$sub_type.'\', \''.$spr1.'\', \''.$spr2.'\', 0); return false;"><span style="margin-left: 3px;" id="'.$id.'" class="faicon pointer '.($insert == 0 ? ' star_on' : ' star_off').'"></span></a>';
+ // Zvezdica s textom
+ else{
+ echo '<div class="custom_report_include">';
+
+ echo '<a href="#" title="'.($insert == 0 ? $lang['srv_custom_report_inserted_title'] : $lang['srv_custom_report_insert_title']).'" onClick="addCustomReportElement(\''.$type.'\', \''.$sub_type.'\', \''.$spr1.'\', \''.$spr2.'\', 1); return false;">';
+ echo '<span id="'.$id.'" class="faicon pointer '.($insert == 0 ? ' star_on' : ' star_off').'"></span>';
+ echo '<span id="'.$id.'_insert" '.($insert == 0 ? ' style="display:none;" ' : '').'> '.$lang['srv_custom_report_insert'].'</span>';
+ echo '<span id="'.$id.'_inserted" '.($insert == 0 ? '' : ' style="display:none;" ').'> '.$lang['srv_custom_report_inserted'].'</span>';
+ echo '</a>';
+
+ echo '</div>';
+ }
+ }
+ }
+
+ function displayMissingLegend(){
+ global $lang;
+
+ echo '<div id="bottom_data_legend" class="floatLeft">';
+ echo '<div>';
+ echo '<div id="bdld1" class="as_link strong" onclick="$(\'#bottom_data_legend_detail, #bdld1, #bdld2\').toggle();"><span class="faicon plus"></span></div>';
+ echo '<div id="bdld2" class="as_link strong" style="display:none" onclick="$(\'#bottom_data_legend_detail, #bdld1, #bdld2\').toggle();"><span class="faicon minus"></span></div> '.$lang['srv_bottom_data_legend_note'];
+ echo '</div>';
+ echo '<div id="bottom_data_legend_detail" style="display:none">';
+ echo '<ul>';
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li1'].'</li>';
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li2'].'</li>';
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li3'].'</li>';
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li4'].'</li>';
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li5'].'</li>';
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li0'].'</li>';
+ echo '</ul>';
+ echo '</div>';
+ echo '</div>';
+ }
+
+ function displayStatusLegend(){
+ global $lang;
+
+ echo '<div id="bottom_data_legend" class="floatLeft bg_blue">';
+ echo '<div>';
+ echo '<div id="bdlds1" class="as_link strong" onclick="$(\'#bottom_data_legend_detail_status, #bdlds1, #bdlds2\').toggle();"><span class="faicon plus"></span></div>';
+ echo '<div id="bdlds2" class="as_link strong" style="display:none" onclick="$(\'#bottom_data_legend_detail_status, #bdlds1, #bdlds2\').toggle();"><span class="faicon minus"></span></div> '.$lang['srv_bottom_data_legend_status_note'];
+ echo '</div>';
+ echo '<div id="bottom_data_legend_detail_status" style="display:none">';
+ echo '<ul>';
+ for ($i = 0; $i <= 6; $i++) {
+ echo '<li>'.$i.' - '.$lang['srv_userstatus_'.$i].'</li>';
+ }
+ echo '<li>'.$lang['srv_bottom_data_legend_note_li0'].'</li>';
+ echo '</ul>';
+ echo '</div>';
+ echo '</div>';
+ }
+
+ function displayTestLegend(){
+ global $lang;
+
+ echo '<div id="bottom_data_legend" class="floatLeft test">';
+ echo '<div>';
+ echo '<div id="bdldt1" class="as_link strong" onclick="$(\'#bottom_data_legend_detail_test, #bdldt1, #bdldt2\').toggle();"><span class="faicon plus"></span></div>';
+ echo '<div id="bdldt2" class="as_link strong" style="display:none" onclick="$(\'#bottom_data_legend_detail_test, #bdldt1, #bdldt2\').toggle();"><span class="faicon minus"></span></div> '.$lang['srv_bottom_data_legend_test_note'];
+ echo '</div>';
+ echo '<div id="bottom_data_legend_detail_test" style="display:none">';
+ echo '<ul>';
+ echo '<li>0 - '.$lang['srv_bottom_data_legend_test_note_li0'].'</li>';
+ echo '<li>1 - '.$lang['srv_bottom_data_legend_test_note_li1'].'</li>';
+ echo '<li>2 - '.$lang['srv_bottom_data_legend_test_note_li2'].'</li>';
+ echo '</ul>';
+ echo '</div>';
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyBreak.php b/admin/survey/classes/surveyAnalysis/class.SurveyBreak.php
new file mode 100644
index 0000000..aa2a829
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyBreak.php
@@ -0,0 +1,1578 @@
+<?php
+/** Class ki skrbi za T-test
+ * December 2011
+ *
+ *
+ * Enter description here ...
+ * @author Gorazd_Veselic
+ *
+ */
+
+define("EXPORT_FOLDER", "admin/survey/SurveyData");
+define("BREAK_OPTION_LIMIT", 15);
+
+class SurveyBreak
+{
+ private $sid; # id ankete
+ private $db_table; # katere tabele uporabljamo
+ public $_HEADERS = array(); # shranimo podatke vseh variabel
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $SDF = null; # class za inkrementalno dodajanje fajlov
+
+ public $variablesList = null; # Seznam vseh variabel nad katerimi lahko izvajamo break(zakeširamo)
+
+ public $_CURRENT_STATUS_FILTER = ''; # filter po statusih, privzeto izvažamo 6 in 5
+
+ public $_HAS_TEST_DATA = false; # ali anketa vsebuje testne podatke
+
+ public $break_percent = false; # ali prikazujemo procente
+ public $break_charts = 0; # ali prikazujemo 0->tabele ali 1->grafe
+
+ private $sessionData; # podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ private $SurveyAnaliza; # klas analiza
+ private $SurveyCrosstab; # klas Crosstab
+
+
+ private $decimal_point = ',';
+ private $thousands = '.';
+ private $num_digit_average = NUM_DIGIT_AVERAGE;
+ private $num_digit_percent = NUM_DIGIT_PERCENT;
+
+ function __construct($sid) {
+ if ((int)$sid > 0) {
+ $this->sid = $sid;
+
+ SurveyAnalysisHelper::getInstance()->Init($this->sid);
+
+ # polovimo vrsto tabel (aktivne / neaktivne)
+ SurveyInfo :: getInstance()->SurveyInit($this->sid);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ $this->db_table = '_active';
+ }
+ $this->_CURRENT_STATUS_FILTER = STATUS_FIELD.' ~ /6|5/';
+
+ #inicializiramo class za datoteke
+ $this->SDF = SurveyDataFile::get_instance();
+ $this->SDF->init($this->sid);
+ $this->headFileName = $this->SDF->getHeaderFileName();
+ $this->dataFileStatus = $this->SDF->getStatus();
+
+ # Inicializiramo in polovimo nastavitve missing profila
+ SurveyStatusProfiles::Init($this->sid);
+ SurveyUserSetting::getInstance()->Init($this->sid, $global_user_id);
+
+ SurveyStatusProfiles::Init($this->sid);
+ SurveyMissingProfiles :: Init($this->sid,$global_user_id);
+ SurveyConditionProfiles :: Init($this->sid, $global_user_id);
+ SurveyZankaProfiles :: Init($this->sid, $global_user_id);
+ SurveyTimeProfiles :: Init($this->sid, $global_user_id);
+ SurveyVariablesProfiles :: Init($this->sid, $global_user_id);
+
+ SurveyDataSettingProfiles :: Init($this->sid);
+ # polovimo decimalna mesta in vejice za tisočice
+ $this->decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $this->thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+ $this->num_digit_average = SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE');
+ $this->num_digit_percent = SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT');
+
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->sid);
+ $this->sessionData = SurveyUserSession::getData();
+
+
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA || $this->dataFileStatus == FILE_STATUS_NO_FILE || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ Common::noDataAlert();
+ exit();
+ }
+
+ if ($this->headFileName !== null && $this->headFileName != '') {
+ $this->_HEADERS = unserialize(file_get_contents($this->headFileName));
+ }
+
+ $this->SurveyAnaliza = new SurveyAnalysis();
+ $this->SurveyAnaliza->Init($this->sid);
+
+ $this->SurveyCrosstab = new SurveyCrosstabs();
+ $this->SurveyCrosstab->Init($this->sid);
+
+ # nastavimo vse filtre
+ $this->setUpFilter();
+
+ } else {
+ echo 'Invalid Survey ID!';
+ exit();
+ }
+ }
+
+ function ajax() {
+
+ # spremenljivko in sekvenco shranimo v session
+ if (isset($_POST['spr'])) {
+ $this->sessionData['break']['spr'] = $_POST['spr'];
+ if (isset($_POST['seq'])) {
+ $this->sessionData['break']['seq'] = $_POST['seq'];
+ }
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ # izvedemo akcijo
+ switch ($_GET['a']) {
+ case 'spremenljivkaChange':
+ $this->doBreakForSpremenljivka();
+ break;
+ case 'change_break_percent':
+ $this->setSessionPercent();
+ break;
+ break;
+ case 'change_break_charts':
+ $this->setSessionCharts();
+ break;
+ break;
+ default:
+ print_r("<pre>");
+ print_r($_GET);
+ print_r($_POST);
+ print_r("</pre>");
+ break;
+ }
+ }
+
+
+ /** Funkcija ki nastavi vse filtre
+ *
+ */
+ private function setUpFilter() {
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ return false;
+ }
+
+ # ali prikazujemo procente
+ $this->break_percent = (isset($this->sessionData['break']['break_percent']) && (int)$this->sessionData['break']['break_percent'] == 1) ? true : false;
+
+ # poiščemo kater profil uporablja uporabnik
+ $_currentMissingProfile = SurveyUserSetting :: getInstance()->getSettings('default_missing_profile');
+ $this->currentMissingProfile = (isset($_currentMissingProfile) ? $_currentMissingProfile : 1);
+
+ # filtriranje po statusih
+ $this->_CURRENT_STATUS_FILTER = SurveyStatusProfiles :: getStatusAsAWKString();
+
+ # filtriranje po časih
+ $_time_profile_awk = SurveyTimeProfiles :: getFilterForAWK($this->_HEADERS['unx_ins_date']['grids']['0']['variables']['0']['sequence']);
+
+ # dodamo še ife
+
+ SurveyConditionProfiles :: setHeader($this->_HEADERS);
+ $_condition_profile_AWK = SurveyConditionProfiles:: getAwkConditionString();
+
+ if (($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) || ($_time_profile_awk != "" && $_time_profile_awk != null)) {
+ $this->_CURRENT_STATUS_FILTER = '('.$this->_CURRENT_STATUS_FILTER;
+ if ($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_condition_profile_AWK;
+ }
+ if ($_time_profile_awk != "" && $_time_profile_awk != null) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_time_profile_awk;
+ }
+ $this->_CURRENT_STATUS_FILTER .= ')';
+ }
+
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+
+ if ($this->dataFileStatus == FILE_STATUS_OK || $this->dataFileStatus == FILE_STATUS_OLD) {
+
+ if (isset($this->_HEADERS['testdata'])) {
+ $this->_HAS_TEST_DATA = true;
+ }
+ }
+
+ }
+
+ function Display() {
+ global $lang;
+
+ # ali imamo testne podatke
+ if ($this->_HAS_TEST_DATA) {
+ # izrišemo bar za testne podatke
+ $SSH = new SurveyStaticHtml($this->sid);
+ $SSH -> displayTestDataBar(true);
+ }
+
+ /*echo '<div id="dataOnlyValid">';
+ SurveyStatusProfiles::displayOnlyValidCheckbox();
+ echo '</div>';*/
+
+ # ali prikazujemo tabele ali grafe
+ $this->break_charts = (isset($this->sessionData['break']['break_show_charts']) && (int)$this->sessionData['break']['break_show_charts'] == 1) ? 1 : 0;
+
+ //$this->DisplayLinks();
+ //$this->DisplayFilters();
+
+ echo '<div id="div_break_data">';
+ $this->displayData();
+ echo '</div>'; #id="div_break_data"
+
+ }
+
+
+ function DisplayLinks() {
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->sid);
+ $SSH -> displayAnalizaSubNavigation();
+ }
+
+
+ /** Prikazuje filtre
+ *
+ */
+ function DisplayFilters() {
+ global $lang;
+
+ if ($this->dataFileStatus == FILE_STATUS_SRV_DELETED || $this->dataFileStatus == FILE_STATUS_NO_DATA){
+ return false;
+ }
+
+
+ if ($this->setUpJSAnaliza == true) {
+ echo '<script>
+ window.onload = function() {
+ __analiza = 1;
+ __tabele = 1;
+ }
+ </script>';
+ }
+
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->sid);
+ # izrišemo desne linke do posameznih nastavitev
+ $SSH -> displayAnalizaRightOptions(M_ANALYSIS_BREAK);
+ }
+
+ function displayData() {
+ global $lang;
+ echo '<div id="break_variables">';
+ $variables = $this->getVariableList(2);
+
+ echo '<span id="breakSpremenljivkaSpan" class="floatLeft spaceRight">';
+ echo $lang['srv_break_label1'];
+ echo '<br />';
+ echo '<select id="breakSpremenljivka" name="breakSpremenljivka" onchange="breakSpremenljivkaChange();" autocomplete="off">';
+ echo '<option value="0" selected="selected" >'. $lang['srv_break_select1_option'] . '</option>';
+ if (count($variables)) {
+ foreach ($variables as $variable) {
+ echo '<option value="'.$variable['spr_id'].'"'
+ . ( isset($variable['sequence']) ? ' seq="'.$variable['sequence'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ .($this->sessionData['break']['seq'] == $variable['sequence'] && (int)$variable['canChoose'] == 1 ? ' selected="selected"':'')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] . '</option>';
+ }
+ }
+ echo '</select>'; # name="breakSpremenljivka"
+ echo '</span>';
+
+ echo '<span id="div_crossCheck" class="floatLeft spaceLeft" style="margin-top:14px;">' ;
+ $this->displayLinePercent();
+ $this->displayLineCharts(); // V DELU...
+ echo '</span>';
+
+ echo '<br class="clr" />';
+ echo '</div>'; # id="break_variables"
+ if (isset($this->sessionData['break']['spr']) && (int)$this->sessionData['break']['spr'] > 0
+ && isset($this->sessionData['break']['seq']) && (int)$this->sessionData['break']['seq'] > 0) {
+ echo '<div id="breakResults" >';
+ $this->doBreakForSpremenljivka();
+ echo '</div>'; # id="breakResults"
+ } else {
+ echo '<div id="breakResults" />';
+ }
+ }
+
+ /** funkcija vrne seznam primern variabel za crostabe
+ *
+ */
+ function getVariableList($witch) {
+ # pobrišemo array()
+ $this->variablesList = array();
+ # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence)
+ foreach ($this->_HEADERS AS $skey => $spremenljivka) {
+
+ $tip = $spremenljivka['tip'];
+ {
+ #drugi dropdown
+ # tekstovnih in numeričnih tipov ne dodajamo
+ $_dropdown_condition = is_numeric($tip)
+ #&& $tip != 2# checkbox - 21.11.2012 baje mormo checkboxe p
+ && $tip != 4 #text
+ && $tip != 5 #label
+ && $tip != 7 #number
+ && $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ && $tip != 16 #multicheck
+ && $tip != 18 #vsota
+ && $tip != 19 #multitext
+ && $tip != 20 #multinumber
+ && $tip != 21 #besedilo*
+ && $tip != 22 #compute
+ && $tip != 25 #kvota
+ ? true : false;
+ }
+
+ if ($_dropdown_condition) {
+ $cnt_all = (int)$spremenljivka['cnt_all'];
+ # radio in select in checkbox
+ if ($cnt_all == '1' || $tip == 1 || $tip == 3 || $tip == 2) {
+ # pri tipu radio ali select dodamo tisto variablo ki ni polje "drugo"
+ if ($tip == 1 || $tip == 3 ) {
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][$vid]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+
+ }
+ }
+ }
+ }
+ } else if ($tip == 2){
+ if ($witch == 1) {
+ #pri checkboxu ponudimo vsako podvariablo posebej
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # imampo samo eno sekvenco grids[0]
+ if (count ($spremenljivka['grids'][0]['variables']) > 0) {
+
+ foreach ($spremenljivka['grids'][0]['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'vr_id'=>$vid,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } else {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+
+ } else {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+
+ } else if ($cnt_all > 1){
+ # imamo več skupin ali podskupin, zato zlopamo skozi gride in variable
+ if (count($spremenljivka['grids']) > 0 ) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # ali imamo en grid, ali več (tabele
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } else if($tip == 16||$tip == 18) {
+ # imamo multicheckbox
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>$gid,
+ 'sequence'=>$grid['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ } else {
+ # imamo več gridov - tabele
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>$sub);
+ }
+ if (count ($grid['variables']) > 0) {
+ $sub++;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>$sub);
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ return $this->variablesList;
+ }
+
+ function doBreakForSpremenljivka() {
+ global $lang;
+
+ # ali prikazujemo procente
+ $this->break_percent = isset($this->sessionData['break']['break_percent']) && (int)$this->sessionData['break']['break_percent'] == 1 ? true : false;
+ $this->break_charts = isset($this->sessionData['break']['break_show_charts']) && (int)$this->sessionData['break']['break_show_charts'] == 1 ? 1 : 0;
+
+ if (isset($this->sessionData['break']['spr']) && $this->sessionData['break']['spr'] != 0){
+ $_spr = explode('_',$this->sessionData['break']['spr']);
+ $spr = $this->sessionData['break']['spr'];
+ # poiščemo pripadajoče variable
+ $_spr_data = $this->_HEADERS[$this->sessionData['break']['spr']];
+
+ # poiščemo sekvenco
+ $sekvenca = $this->sessionData['break']['seq'];
+
+ # poiščemo opcije
+ $opcije = $_spr_data['options'];
+
+ # izrisemo ikone za izvoz pdf/rtf
+ $this->displayExport($spr, $sekvenca);
+
+ if ((int)$_spr_data['tip'] != 2) {
+ $seqences[] = $sekvenca;
+ $options = $opcije;
+ } else {
+ # za checkboxe imamo več sekvenc
+ $seqences = explode('_',$_spr_data['sequences']);
+ $options[1] = $opcije[1];
+ }
+
+
+ # za vsako opcijo posebej izračunamo povprečja za vse spremenljivke
+ $frequencys = array();
+ if (count($seqences) > 0) {
+ foreach ($seqences as $seq) {
+
+ if (count($options) > 0) {
+ foreach ($options as $oKey => $option) {
+ # zloopamo skozi variable
+ $oKeyfrequencys = $this->getAllFrequencys($oKey, $seq, $spr);
+ if ($oKeyfrequencys != null) {
+ $frequencys[$seq][$oKey] = $oKeyfrequencys;
+ }
+ }
+ }
+ }
+ }
+ $this->displayBreak($spr,$frequencys);
+
+ } else {
+ echo '<br class="clr">';
+ echo '<p class="red strong">'.$lang['srv_break_error_note_1'].'</p>';
+ }
+ }
+
+ /** za posamezno opcijo izračunamo frekvence za vse spremenljivke
+ *
+ * @param unknown_type $oKey
+ * @param unknown_type $seq
+ */
+ function getAllFrequencys($oKey, $seq, $spr) {
+ $result = null;
+ # sestavimo dodaten awk filter
+ $awk_filter = $this->getAwkFilter($oKey, $seq, $spr);
+ if ($awk_filter != null) {
+ # pridobimo frekvence
+ $this->SurveyAnaliza->setUpFilter();
+ $this->SurveyAnaliza->frequencyAddInvalid(false);
+ $result = $this->SurveyAnaliza->getFrequencys($awk_filter);
+ }
+ return $result;
+ }
+
+ function getAwkFilter($oKey, $seq, $spr) {
+ $result = null;
+ $_spr_data = $this->_HEADERS[$spr];
+ $tip = $_spr_data['tip'];
+
+ $result = '$'.$seq.'=='.$oKey;
+ return $result;
+
+ }
+
+ function formatNumber ($value, $digit = 0, $sufix = "") {
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+
+ $result = number_format($result, $digit, $this->decimal_point, $this->thousands) . $sufix;
+
+ return $result;
+ }
+
+ function displayBreak($forSpr, $frequencys) {
+
+
+ ob_start(); // outer buffer
+ # če imamo filter spremenljivk ga izpišemo
+ echo '<br/>';
+
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyTimeProfiles :: printIsDefaultProfile(false);
+
+ # če imamo filter ifov ga izpišemo
+ SurveyConditionProfiles:: getConditionString();
+
+ # če imamo filter spremenljivk ga izpišemo
+ SurveyVariablesProfiles:: getProfileString(true);
+ SurveyDataSettingProfiles :: getVariableTypeNote();
+
+ # filtriranje po spremenljivkah
+ $_FILTRED_VARIABLES = SurveyVariablesProfiles::getProfileVariables(SurveyVariablesProfiles::checkDefaultProfile(), true);
+ foreach ($this->_HEADERS AS $skey => $spremenljivka) {
+
+ if ((int)$spremenljivka['hide_system'] == 1 && in_array($spremenljivka['variable'],array('email','ime','priimek','telefon','naziv','drugo'))) {
+ continue;
+ }
+ $spremenljivka['id'] = $skey;
+ $tip = $spremenljivka['tip'];
+ if ( is_numeric($tip)
+ && $tip != 4 #text
+ && $tip != 5 #label
+ && $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ && $tip != 19 #multitext
+ && $tip != 21 #besedilo*
+ && ( count($_FILTRED_VARIABLES) == 0 || (count($_FILTRED_VARIABLES) > 0 && isset($_FILTRED_VARIABLES[$skey]) ))
+ ) {
+
+ $this->displayBreakSpremenljivka($forSpr,$frequencys,$spremenljivka);
+ } else if ( is_numeric($tip)
+ && (
+ $tip == 4 #text
+ || $tip == 19 #multitext
+ || $tip == 21 #besedilo*
+ || $tip == 20 #multi numer*
+ ) && ( count($_FILTRED_VARIABLES) == 0 || (count($_FILTRED_VARIABLES) > 0 && isset($_FILTRED_VARIABLES[$skey]) ) )
+ ) {
+ $this->displayBreakSpremenljivka($forSpr,$frequencys,$spremenljivka);
+ }
+
+ ob_end_flush();
+ }
+
+ // Izpisemo nastavitve na dnu (izvozi, arhiv, vabila...)
+ $this->displayBottomSettings();
+ }
+
+ function displayBreakSpremenljivka($forSpr,$frequencys,$spremenljivka) {
+
+ $tip = $spremenljivka['tip'];
+
+ if ($forSpr != $spremenljivka['id']) {
+
+ switch ($tip) {
+ # radio, dropdown
+ case 1:
+ case 3:
+ $this->displayCrosstabTable($forSpr,$frequencys,$spremenljivka);
+ break;
+
+ #multigrid
+ case 6:
+ $skala = Common::getSpremenljivkaSkala($spremenljivka['id']);
+ if ($skala == 0) {
+ $this->displayBreakTableMgrid($forSpr,$frequencys,$spremenljivka);
+ }
+ else {
+ $this->displayCrosstabTable($forSpr,$frequencys,$spremenljivka);
+ }
+ break;
+
+ # checkbox
+ case 2:
+ $this->displayCrosstabTable($forSpr,$frequencys,$spremenljivka);
+ break;
+ #number
+ case 7:
+ #ranking
+ case 17:
+ #vsota
+ case 18:
+ #multinumber
+ case 20:
+ $this->displayBreakTableNumber($forSpr,$frequencys,$spremenljivka);
+ break ;
+
+ case 19:
+ $this->displayBreakTableText($forSpr,$frequencys,$spremenljivka);
+ break ;
+ #multicheck
+ case 16:
+ $this->displayCrosstabTable($forSpr,$frequencys,$spremenljivka);
+ break;
+
+ case 4:
+ case 21:
+ # po novem besedilo izpisujemo v klasični tabeli
+ $this->displayBreakTableText($forSpr,$frequencys,$spremenljivka);
+
+ #$this->displayCrosstabTable($forSpr,$frequencys,$spremenljivka);
+ break;
+
+ default:
+ $this->displayCrosstabTable($forSpr,$frequencys,$spremenljivka);
+ break;
+ }
+ }
+ }
+
+ function displayBreakTableMgrid($forSpr,$frequencys,$spremenljivka){
+ #mgrid - 16:
+
+ // Ce izrisujemo graf
+ if($this->break_charts == 1){
+ $tableChart = new SurveyTableChart($this->sid, $this, 'break');
+ $tableChart->setBreakVariables($forSpr,$frequencys,$spremenljivka);
+ $tableChart->display();
+ }
+
+ // Ce izrisujemo tabelo
+ else{
+
+ $keysCount = count($frequencys);
+ $sequences = explode('_',$spremenljivka['sequences']);
+ $forSpremenljivka = $this->_HEADERS[$forSpr];
+ $tip = $spremenljivka['tip'];
+
+ # izračunamo povprečja za posamezne sekvence
+ $means = array();
+ $totalMeans = array();
+ $totalFreq = array();
+ foreach ($frequencys AS $fkey => $options) {
+ foreach ($options AS $oKey => $option) {
+ foreach ($sequences AS $sequence) {
+ $txt = $this->getMeansFromKey($option[$sequence]);
+ if ($txt) {
+ $cnt[$fkey]++;
+ $means[$fkey][$oKey][$sequence] = $txt;
+ }
+ }
+ }
+ }
+
+ # ce imamo vec kot 20 kategorij,izpisujemo samo tiste ki imajo vrednosti
+ $displayAll = (count($options) > 20) ? false : true;
+
+ echo '<div id="'.$spremenljivka['id'].'" class="breakTableDiv">';
+ if (isset($spremenljivka['double']) && $spremenljivka['double'] > 1) {
+ $doubleGridParts = $spremenljivka['double'];
+ $multiply = 1;
+ $isDoubleGrid = true;
+ } else {
+ $doubleGridParts[1]['subtitle'] = '';
+ $multiply = 2;
+ $isDoubleGrid = false;
+ }
+
+
+ # če imamo dvojno tabelo
+
+ $rowspan = ' rowspan="3"';
+ $colspan = ' colspan="'.($multiply*count($sequences)).'"';
+
+ foreach ($doubleGridParts AS $part => $doubleGridTitle) {
+ echo '<br/>';
+ # če ni multicheck in multi grid
+ echo '<table>';
+ echo '<tr>';
+ echo '<th'.$rowspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $forSpr . '\'); return false;">';
+ echo $forSpremenljivka['naslov'];
+ echo '('.$forSpremenljivka['variable'].')';
+ echo '</a>';
+ echo '</span>';
+
+ echo '</th>';
+ echo '<th'.$colspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $spremenljivka['id'] . '\'); return false;">';
+ echo $spremenljivka['naslov'];
+ echo '('.$spremenljivka['variable'].')';
+ echo '</a>';
+ if (isset ($doubleGridTitle['subtitle'])) {
+ echo ' - '.$doubleGridTitle['subtitle'];
+ }
+ echo '</span>';
+ echo '</th>';
+ echo '</tr>';
+
+ echo '<tr>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if ($isDoubleGrid == false || ($isDoubleGrid == true && $grid['part'] == $part)) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+
+ echo '<th class="sub" colspan="2">';
+ echo $variable['naslov'];
+ echo '('.$variable['variable'].')';
+ echo '</th>';
+ }
+ }
+ }
+ echo '</tr>';
+ echo '<tr>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if ($isDoubleGrid == false || ($isDoubleGrid == true && $grid['part'] == $part)) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ echo '<th class="sub">Povprečje'.$lang[''];
+ echo '</th>';
+ echo '<th class="sub red">Št. enot'.$lang[''];
+ echo '</th>';
+ }
+ }
+ }
+ echo '</tr>';
+ $cnt=0;
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ $cbxLabel = $forSpremenljivka['grids'][0]['variables'][$cnt]['naslov'];
+ $cnt++;
+ foreach ($options AS $oKey => $option) {
+ if ($means[$fkey][$oKey] != null || $displayAll) {
+ echo '<tr>';
+ echo '<td'.$break_percentRowSpan.' class="rsdl_bck_variable1">';
+ if ($forSpremenljivka['tip'] == 2) {
+ echo $cbxLabel;
+ } else {
+ echo $forSpremenljivka['options'][$oKey];
+ }
+ echo '</td>';
+ $css = '';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if ($isDoubleGrid == false || ($isDoubleGrid == true && $grid['part'] == $part)) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ echo '<td'.$css.$break_percentRowSpan.'>';
+ echo $this->formatNumber($means[$fkey][$oKey][$sequence],$this->num_digit_average,'');
+ echo '</td>';
+ # enote
+ echo '<td class="red strong">';
+ echo (int)$frequencys[$fkey][$oKey][$sequence]['validCnt'];
+ echo '</td>';
+ $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$frequencys[$fkey][$oKey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$frequencys[$fkey][$oKey][$sequence]['validCnt'];
+ }
+
+ }
+ }
+ }
+ echo '</tr>';
+ }
+ }
+ }
+ #dodamo še skupno sumo in povprečje
+ echo '<tr>';
+ echo '<td class="rsdl_bck_variable1 red">';
+ echo 'Skupaj';
+ echo '</td>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if ($isDoubleGrid == false || ($isDoubleGrid == true && $grid['part'] == $part)) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ echo '<td class="red strong">';
+ $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0;
+ echo $this->formatNumber($totalMean ,$this->num_digit_average,'');
+ echo '</td>';
+ # enote
+ echo '<td class="red strong">';
+ echo (int)$totalFreq[$sequence];
+ echo '</td>';
+ }
+
+ }
+ }
+ }
+ echo '</tr>';
+ echo '</table>';//$forSpremenljivka['grids'][0]['variables']
+
+ }
+ // Zvezdica za vkljucitev v porocilo
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $spremenljivka['grids'][0]['variables'][0]['sequence'].'-'.$spremenljivka['id'].'-undefined';
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type=9, $sub_type=0, $spr1, $spr2);
+ echo '</div>';
+ }
+ }
+
+ function displayBreakTableNumber($forSpr,$frequencys,$spremenljivka){
+ #number - 7:
+ #ranking - 17:
+ #vsota - 18:
+ #multinumber - 20:
+
+ $keysCount = count($frequencys);
+ $sequences = explode('_',$spremenljivka['sequences']);
+ $forSpremenljivka = $this->_HEADERS[$forSpr];
+ $tip = $spremenljivka['tip'];
+
+ # izračunamo povprečja za posamezne sekvence
+ $means = array();
+ $totalMeans = array();
+ $totalFreq = array();
+ foreach ($frequencys AS $fkey => $options) {
+ foreach ($options AS $oKey => $option) {
+ foreach ($sequences AS $sequence) {
+ $txt = $this->getMeansFromKey($option[$sequence]);
+ if ($txt) {
+ $means[$fkey][$oKey][$sequence] = $txt;
+ }
+ }
+ }
+ }
+ # ce imamo vec kot 20 kategorij,izpisujemo samo tiste ki imajo vrednosti
+ $displayAll = (count($options) > 20) ? false : true;
+
+ // Ce izrisujemo graf
+ if($this->break_charts == 1){
+
+ // Number, vsota, ranking graf
+ if($tip != 20 ){
+ $tableChart = new SurveyTableChart($this->sid, $this, 'break');
+ $tableChart->setBreakVariables($forSpr,$frequencys,$spremenljivka);
+ $tableChart->display();
+ }
+
+ // Multinumber graf
+ else{
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ // Izrisujemo samo 1 graf v creportu
+ if($_GET['m'] == 'analysis_creport'){
+
+ if($spremenljivka['break_sub_table']['key'] == $gkey){
+ $tableChart = new SurveyTableChart($this->sid, $this, 'break');
+ $tableChart->setBreakVariables($forSpr,$frequencys,$spremenljivka);
+ $tableChart->display();
+ }
+ }
+
+ // Izrisujemo vse zaporedne grafe
+ else{
+ $spremenljivka['break_sub_table']['key'] = $gkey;
+ $spremenljivka['break_sub_table']['sequence'] = $grid['variables'][0]['sequence'];
+
+ $tableChart = new SurveyTableChart($this->sid, $this, 'break');
+ $tableChart->setBreakVariables($forSpr,$frequencys,$spremenljivka);
+ $tableChart->display();
+ }
+ }
+ }
+
+ }
+ // Ce izrisujemo tabelo
+ else{
+
+ echo '<div id="'.$spremenljivka['id'].'" class="breakTableDiv">';
+ echo '<br/>';
+ # za multi number naredimo po skupinah
+ if ($tip != 20 ) {
+ $rowspan = ' rowspan="3"';
+ $colspan = ' colspan="'.(2*count($sequences)).'"';
+
+ # ali prikazujemo procente
+ if ((int)$this->break_percent > 0) {
+ $break_percentRowSpan = ' rowspan="2"';
+ }
+ # če ni multicheck in multi grid
+ echo '<table>';
+ echo '<tr>';
+ echo '<th'.$rowspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $forSpr . '\'); return false;">';
+ echo $forSpremenljivka['naslov'];
+ echo '('.$forSpremenljivka['variable'].')';
+ echo '</a>';
+ echo '</span>';
+
+ echo '</th>';
+ echo '<th'.$colspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $spremenljivka['id'] . '\'); return false;">';
+ echo $spremenljivka['naslov'];
+ echo '('.$spremenljivka['variable'].')';
+ echo '</a>';
+ echo '</span>';
+ echo '</th>';
+ echo '</tr>';
+
+ echo '<tr>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ echo '<th class="sub" colspan="2">';
+ echo $variable['naslov'];
+ echo '('.$variable['variable'].')';
+ echo '</th>';
+ }
+ }
+ echo '</tr>';
+ echo '<tr>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ echo '<th class="sub">Povprečje'.$lang[''];
+ echo '</th>';
+ echo '<th class="sub red">Št. enot'.$lang[''];
+ echo '</th>';
+ }
+ }
+ echo '</tr>';
+
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+
+ foreach ($options AS $oKey => $option) {
+ if ($displayAll || $means[$fkey][$oKey] != null) {
+ echo '<tr>';
+ echo '<td'.$break_percentRowSpan.' class="rsdl_bck_variable1">';
+ echo $forSpremenljivka['options'][$oKey];
+ echo '</td>';
+ $css = '';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ echo '<td'.$css.$break_percentRowSpan.'>';
+ echo $this->formatNumber($means[$fkey][$oKey][$sequence],$this->num_digit_average,'');
+ #echo $this->formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ echo '</td>';
+ # enote
+ echo '<td class="red strong">';
+ echo (int)$frequencys[$fkey][$oKey][$sequence]['validCnt'];
+ #echo (int)$frequencys[$fkey][$sequence]['validCnt'];
+ echo '</td>';
+ #$totalMeans[$sequence] += ($this->getMeansFromKey($fkeyFrequency[$sequence])*(int)$frequencys[$fkey][$sequence]['validCnt']);
+ #$totalFreq[$sequence]+= (int)$frequencys[$fkey][$sequence]['validCnt'];
+ $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$frequencys[$fkey][$oKey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$frequencys[$fkey][$oKey][$sequence]['validCnt'];
+ }
+
+ }
+
+ }
+ echo '</tr>';
+ if ((int)$this->break_percent) {
+ echo '<tr>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['other'] != 1) {
+ $sequence = $variable['sequence'];
+ echo '<td class="">';
+ #echo (int)$frequencys[$fkey][$sequence]['validCnt'];
+ $percent = 0;
+ if ($frequencys[$fkey][$sequence]['validCnt'] > 0 ) {
+ $percent = 100;
+ }
+ echo $this->formatNumber($percent,$this->num_digit_percent,'%');
+ echo '</td>';
+ }
+ }
+
+ }
+ echo '</tr>';
+ }
+ }
+ }
+ }
+ #dodamo še skupno sumo in povprečje
+ echo '<tr>';
+ echo '<td class="rsdl_bck_variable1">';
+ echo $lang[''].'Skupaj';
+ echo '</td>';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ echo '<td class="red strong">';
+ $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0;
+ echo $this->formatNumber($totalMean ,$this->num_digit_average,'');
+ echo '</td>';
+ # enote
+ echo '<td class="red strong">';
+ echo (int)$totalFreq[$sequence];
+ echo '</td>';
+ }
+
+ }
+
+ }
+ echo '</tr>';
+ echo '</table>';
+
+
+ // Zvezdica za vkljucitev v porocilo
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $spremenljivka['grids'][0]['variables'][0]['sequence'].'-'.$spremenljivka['id'].'-undefined';
+
+ #xxxxx
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type=9, $sub_type=0, $spr1, $spr2);
+
+
+ } else if ($tip == 20){
+ # za multi number razdelimo na grupe - skupine
+ $rowspan = ' rowspan="3"';
+ $colspan = ' colspan="'.(2*count($spremenljivka['grids'][0]['variables'])).'"';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ // Ce smo v porocilu po meri in ni prava tabela jo preskocimo
+ if(isset($spremenljivka['break_sub_table']['key']) && $spremenljivka['break_sub_table']['key'] != $gkey){
+ continue;
+ }
+
+ // Ce smo v porocilu po meri in je prava tabelo jo izpisemo brez naslova
+ if(!isset($spremenljivka['break_sub_table']['sequence'])){
+ echo '<br/><b>'.$lang['srv_break_table_for'];
+ echo $spremenljivka['naslov'].' (';
+ echo $spremenljivka['variable'].') = ';
+ echo $grid['naslov'];
+ echo ' ('.$grid['variable'].')';
+ echo '</b>';
+ }
+
+ echo '<table>';
+ #labele
+ echo '<tr>';
+ echo '<th'.$rowspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $forSpr . '\'); return false;">';
+ echo $forSpremenljivka['naslov'];
+ echo '('.$forSpremenljivka['variable'].')';
+ echo '</a>';
+ echo '</span>';
+ echo '</th>';
+
+ echo '<th'.$colspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $spremenljivka['id'] . '\'); return false;">';
+ echo $spremenljivka['naslov']. ' - ';
+ echo $grid['naslov'];
+ echo '('.$grid['variable'].')';
+ echo '</a>';
+ echo '</span>';
+ echo '</th>';
+ echo'</tr>';
+ #labele
+ echo '<tr>';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ echo '<th class="sub" colspan="2">';
+ echo $variable['naslov'];
+ echo '('.$variable['variable'].')';
+ echo '</th>';
+ }
+ echo '</tr>';
+ echo '<tr>';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ echo '<th class="sub">Povprečje'.$lang[''];
+ echo '</th>';
+ echo '<th class="sub red">Št. enot'.$lang[''];
+ echo '</th>';
+ }
+ echo '</tr>';
+ $cnt=0;
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ $cbxLabel = $forSpremenljivka['grids'][0]['variables'][$cnt]['naslov'];
+ $cnt++;
+ foreach ($forSpremenljivka['options'] AS $oKey => $option) {
+ if ($displayAll || $means[$fkey][$oKey] != null) {
+ # če je osnova checkbox vzamemo samo tam ko je 1
+ if(($forSpremenljivka['tip'] == 2 && $option == 1) || $forSpremenljivka['tip'] != 2 ) {
+ echo '<tr>';
+ echo '<td'.$break_percentRowSpan.' class="rsdl_bck_variable1">';
+ if ($forSpremenljivka['tip'] == 2) {
+ echo $cbxLabel;
+ } else {
+ echo $forSpremenljivka['options'][$oKey];
+ }
+
+ #echo ' ('.$oKey.')';
+ echo '</td>';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ #povprečje
+ echo '<td>';
+ echo $this->formatNumber($means[$fkey][$oKey][$sequence],$this->num_digit_average,'');
+ echo '</td>';
+ # enote
+ echo '<td class="red strong">';
+ echo (int)$frequencys[$fkey][$oKey][$sequence]['validCnt'];
+ echo '</td>';
+ $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$frequencys[$fkey][$oKey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$frequencys[$fkey][$oKey][$sequence]['validCnt'];
+
+ }
+ echo '</tr>';
+ }
+ }
+ }
+ }
+ #dodamo še skupno sumo in povprečje
+ echo '<tr>';
+ echo '<td class="rsdl_bck_variable1">';
+ echo 'Skupaj';
+ echo '</td>';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ echo '<td class="red strong">';
+ $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0;
+ echo $this->formatNumber($totalMean ,$this->num_digit_average,'');
+ echo '</td>';
+ # enote
+ echo '<td class="red strong">';
+ echo (int)$totalFreq[$sequence];
+ echo '</td>';
+ }
+ }
+ echo '</tr>';
+ echo '</table>';
+
+
+ // Zvezdica za vkljucitev v porocilo
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $grid['variables'][0]['sequence'].'-'.$spremenljivka['id'].'-undefined';
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type=9, $sub_type=0, $spr1, $spr2);
+
+ echo '<br/>';
+ }
+
+ }
+ echo '</div>';
+ }
+
+ }
+
+ function displayBreakTableText($forSpr,$frequencys,$spremenljivka){
+ #text - 21:
+ #multi text - 19:
+ $keysCount = count($frequencys);
+ $sequences = explode('_',$spremenljivka['sequences']);
+ $forSpremenljivka = $this->_HEADERS[$forSpr];
+
+ $tip = $spremenljivka['tip'];
+ # izračunamo povprečja za posamezne sekvence
+ $texts = array();
+ $totalMeans = array();
+ $totalFreq = array();
+ $forSequences = array();
+ $cnt = array();
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ $forSequences[] = $fkey;
+ foreach ($forSpremenljivka['options'] AS $oKey => $option) {
+ foreach ($sequences AS $sequence) {
+ $txt = $this->getTextFromKey($fkeyFrequency[$oKey][$sequence]);
+ if ($txt) {
+ $cnt[$fkey]++;
+ $texts[$fkey][$oKey][$sequence] = $txt;
+ }
+ }
+ }
+ }
+
+ # če imamo več kot 20 kategorij,izpisujemo samo tiste ki imajo vrednosti
+ $displayAll = (count($forSpremenljivka['options']) > 20) ? false : true;
+
+ echo '<div id="'.$spremenljivka['id'].'" class="breakTableDiv">';
+ echo '<br/>';
+ # za multi text razdelimo na grupe - skupine
+ $rowspan = ' rowspan="2"';
+ $colspan = ' colspan="'.(count($spremenljivka['grids'][0]['variables'])).'"';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ // Ce smo v porocilu po meri in ni prava tabela jo preskocimo
+ if(isset($spremenljivka['break_sub_table']['sequence']) && $spremenljivka['break_sub_table']['key'] != $gkey){
+ continue;
+ }
+
+ // Ce smo v porocilu po meri in je prava tabelo jo izpisemo brez naslova
+ if(!isset($spremenljivka['break_sub_table']['sequence'])){
+ echo '<br/>';
+ if($tip != '21'){
+ echo '<b>';
+ echo $lang['srv_break_table_for'];
+ echo $spremenljivka['naslov'].' (';
+ echo $spremenljivka['variable'].') = ';
+ echo $grid['naslov'];
+ echo ' ('.$grid['variable'].')';
+ echo '</b>';
+ }
+ }
+
+ echo '<table>';
+ #labele
+ echo '<tr>';
+ echo '<th'.$rowspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $forSpr . '\'); return false;">';
+ echo $forSpremenljivka['naslov'];
+ echo '('.$forSpremenljivka['variable'].')';
+ echo '</a>';
+ echo '</span>';
+ echo '</th>';
+
+ echo '<th'.$colspan.'>';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $spremenljivka['id'] . '\'); return false;">';
+ echo $spremenljivka['naslov']. ' - ';
+ echo $grid['naslov'];
+ echo '('.$grid['variable'].')';
+ echo '</a>';
+ echo '</span>';
+ echo '</th>';
+ echo'</tr>';
+ #labele
+ echo '<tr>';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ echo '<th class="sub" >';
+ echo $variable['naslov'];
+ echo '('.$variable['variable'].')';
+ echo '('.$variable['sequence'].')';
+ echo '</th>';
+ }
+ echo '</tr>';
+ $cntCbx= 0;
+ foreach ($forSequences AS $fKey => $forSequence) {
+ $cbxLabel = $forSpremenljivka['grids'][0]['variables'][$cntCbx]['naslov'];
+ $cntCbx++;
+ foreach ($forSpremenljivka['options'] AS $oKey => $option) {
+ if ($displayAll || $texts[$forSequence][$oKey] != null) {
+ if(($forSpremenljivka['tip'] == 2 && $option == 1) || $forSpremenljivka['tip'] != 2 ) {
+ echo '<tr>';
+ echo '<td'.$break_percentRowSpan.' class="rsdl_bck_variable1">';
+ if ($forSpremenljivka['tip'] == 2) {
+ echo $cbxLabel;
+ } else {
+ echo $forSpremenljivka['options'][$oKey];
+ }
+ echo '</td>';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ #povprečje
+ echo '<td class="anl_at cll_clps" style="vertical-align:top;">';
+ if (count($texts[$forSequence][$oKey][$sequence]) > 0) {
+ $cnt=1;
+ $count = count($texts[$forSequence][$oKey][$sequence]);
+ foreach ($texts[$forSequence][$oKey][$sequence] AS $ky => $units) {
+ echo '<div class="'.($cnt<=$count && $cnt>1?'anl_bt_dot ':'').('').'"style="line-height: 150%; padding:3px;">';
+ echo $units['text'];
+ echo '</div>';
+ $cnt++;
+ }
+ }
+
+
+ #echo $this->formatNumber($texts[$oKey][$sequence],$this->num_digit_average,'');
+ echo '</td>';
+
+ }
+ echo '</tr>';
+ }
+ }
+ }
+ }
+ echo '</table>';
+
+
+ // Zvezdica za vkljucitev v porocilo
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $grid['variables'][0]['sequence'].'-'.$spremenljivka['id'].'-undefined';
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type=9, $sub_type=0, $spr1, $spr2);
+
+ echo '<br/>';
+ }
+
+ echo '</div>';
+
+ }
+
+ function displayCrosstabTable($forSpr,$frequencys,$spremenljivka){
+
+ #polovimo sekvence in spremenljivke
+ // Ce smo v creportu imamo nastavljeno prvo spremenljivko posebej (ne v sessionu)
+ if(isset($spremenljivka['break_sub_table']['sequence'])){
+ $spr1 = $spremenljivka['creport_first_spr']['spr'];
+ $seq1 = $spremenljivka['creport_first_spr']['seq'];
+ }
+ else{
+ $spr1 = $this->sessionData['break']['spr'];
+ $seq1 = $this->sessionData['break']['seq'];
+ }
+ $grd1 = 'undefined';
+ foreach ($this->_HEADERS[$spr1]['grids'] AS $gid => $grid) {
+ foreach ($grid['variables'] AS $vkey => $vrednost) {
+ if ($vrednost['sequence'] == $seq1) {
+ $grd1 = $gid;
+ }
+ }
+ }
+
+ $this->SurveyCrosstab->displayHi2 = false;
+ $this->SurveyCrosstab->fromBreak = true;
+ $this->SurveyCrosstab->showAverage = $this->break_percent;
+ if ($spremenljivka['tip'] == 2
+ || $spremenljivka['tip'] == 16
+ || $spremenljivka['tip'] == 4
+ || $spremenljivka['tip'] == 19
+ || $spremenljivka['tip'] == 21
+ || ($spremenljivka['tip'] == 6 && $spremenljivka['skala'] != 0)
+ || ($spremenljivka['tip'] == 1 && $spremenljivka['skala'] != 0)){
+ $this->SurveyCrosstab->showAverage = false;
+ }
+ $spr2 = $spremenljivka['id'];
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ // Ce smo v porocilu po meri in ni prava tabela jo preskocimo
+ if(isset($spremenljivka['break_sub_table']['sequence']) && $spremenljivka['break_sub_table']['key'] != $gid){
+ continue;
+ }
+
+ // Ce smo v porocilu po meri in je prava tabelo jo izpisemo brez naslova
+ if(!isset($spremenljivka['break_sub_table']['sequence']) && ($spremenljivka['tip'] == 16 || $spremenljivka['tip'] == 6) && $this->break_charts != 1){
+ echo '<br/><b>'.$lang['srv_break_table_for'];
+ echo $spremenljivka['naslov'].' (';
+ echo $spremenljivka['variable'].') = ';
+ echo $grid['naslov'];
+ if ($spremenljivka['tip'] != 6) {
+ echo ' ('.$grid['variable'].')';
+ }
+ echo '</b>';
+ }
+
+ $seq2 = $grid['variables'][0]['sequence'];
+ $grd2 = $gid;
+ $this->SurveyCrosstab->setColor(false);
+ # ali rišemo povprečje po stolpcih v zadnji vrstici
+ if ($spremenljivka['tip'] == 1 && $spremenljivka['skala'] == 0 ) {
+ $this->SurveyCrosstab->showBottomAverage (true);
+ }
+
+ if($this->break_charts == 1){
+ $this->SurveyCrosstab->setVariables($seq1,$spr1,'undefined'/*$grd1*/,$seq2,$spr2,$grd2);
+ $this->SurveyCrosstab->fromBreak = false;
+ $tableChart = new SurveyTableChart($this->sid, $this->SurveyCrosstab, 'break');
+ $tableChart->break_crosstab = 1;
+ $tableChart->display();
+ }
+ else{
+ $this->SurveyCrosstab->setVariables($seq1,$spr1,$grd1,$seq2,$spr2,$grd2);
+ $this->SurveyCrosstab->displayCrosstabsTable();
+ }
+
+ echo '<br/>';
+ }
+
+ }
+ function getMeansFromKey($frequencys) {
+ $sum = 0;
+ if (count($frequencys['valid']) > 0) {
+ foreach ($frequencys['valid'] AS $fkey => $tmp) {
+
+ $sum += (int)$fkey * (int)$tmp['cnt'];
+ }
+ }
+ $mean = (int)$frequencys['validCnt'] > 0 ? (int)$sum / (int)$frequencys['validCnt'] : 0;
+ return $mean;
+ }
+
+ function getTextFromKey($frequencys) {
+ $texts = array();
+ if (count($frequencys['valid']) > 0) {
+ foreach ($frequencys['valid'] AS $fkey => $tmp) {
+ $texts[] = $tmp;
+ }
+ }
+ return $texts;
+ }
+
+ function DisplayLink($hideAdvanced = true) {
+ global $lang;
+ if ($_GET['m'] == M_ANALYSIS_BREAK) {
+ $css = ' black';
+ } else {
+ $css = ' gray';
+ }
+
+ if ($hideAdvanced == false) {
+ echo '<li>';
+ echo '<span class="as_link'.$css.'" title="' . $lang['srv_break'] . '"><a class="gray" href="index.php?anketa='.$this->sid.'&a=analysis&m=break">' . $lang['srv_break'] . '</a></span>'."\n";
+ echo '</li>';
+ echo '<li class="space">&nbsp;</li>';
+ }
+ }
+
+
+ // Izvoz pdf in rtf
+ function displayExport ($spr, $seq) {
+
+ if ((int)$spr > 0 && (int)$seq > 0) {
+ $href_pdf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=break_izpis&anketa='.$this->sid);
+ $href_rtf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=break_izpis_rtf&anketa='.$this->sid);
+ $href_xls = makeEncodedIzvozUrlString('izvoz.php?b=export&m=break_izpis_xls&anketa='.$this->sid);
+ echo '<script>';
+ # nastavimopravilne linke
+ echo '$("#secondNavigation_links a#breakDoPdf").attr("href", "'.$href_pdf.'");';
+ echo '$("#secondNavigation_links a#breakDoRtf").attr("href", "'.$href_rtf.'");';
+ echo '$("#secondNavigation_links a#breakDoXls").attr("href", "'.$href_xls.'");';
+ # prikažemo linke
+ echo '$("#hover_export_icon").removeClass("hidden");';
+ echo '$("#secondNavigation_links a").removeClass("hidden");';
+ echo '</script>';
+ }
+ }
+
+ // Nastavitve na dnu
+ function displayBottomSettings(){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+
+ // Preverimo, ce je funkcionalnost v paketu, ki ga ima uporabnik
+ $userAccess = UserAccess::getInstance($global_user_id);
+
+ $lan_print = ' title="'.$lang['PRN_Izpis'].'"';
+ $lan_pdf = ' title="'.$lang['PDF_Izpis'].'"';
+ $lan_rtf = ' title="'.$lang['RTF_Izpis'].'"';
+ $lan_xls = ' title="'.$lang['XLS_Izpis'].'"';
+
+ echo '<div class="analysis_bottom_settings printHide">';
+
+ echo '<a href="#" onClick="addCustomReportAllElementsAlert(9);" title="'.$lang['srv_custom_report_comments_add_hover'].'" class="'.(!$userAccess->checkUserAccess('analysis_analysis_creport') ? 'user_access_locked' : '').'" user-access="analysis_analysis_creport" style="margin-right: 40px;"><span class="spaceRight faicon comments_creport" ></span><span class="bold">'.$lang['srv_custom_report_comments_add'].'</span></a>';
+
+ echo '<a href="#" onClick="printAnaliza(\'Break\'); return false;"'.$lan_print.' class="srv_ico"><span class="faicon print icon-grey_dark_link"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=break_izpis&anketa=' . $this->sid) . '" target="_blank"'.$lan_pdf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon pdf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=break_izpis_rtf&anketa=' . $this->sid) . '" target="_blank"'.$lan_rtf.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon rtf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?b=export&m=break_izpis_xls&anketa=' . $this->sid) . '" target="_blank"'.$lan_xls.' class="srv_ico '.(!$userAccess->checkUserAccess('analysis_export') ? 'user_access_locked' : '').'" user-access="analysis_export"><span class="faicon xls black very_large"></span></a>';
+
+ echo '<a href="#" onclick="doArchiveBreak();" title="'.$lang['srv_analiza_arhiviraj_ttl'].'" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv black very_large"></span></a>';
+ echo '<a href="#" onclick="createArchiveBreakBeforeEmail();" title="'.$lang['srv_analiza_arhiviraj_email_ttl'] . '" class="'.(!$userAccess->checkUserAccess('archive') ? 'user_access_locked' : '').'" user-access="archive"><span class="faicon arhiv_mail black very_large"></span></a>';
+
+ echo '</div>';
+
+ // Javascript s katerim povozimo urlje za izvoze, ki niso na voljo v paketu
+ global $app_settings;
+ if($app_settings['commercial_packages'] == true){
+ echo '<script> userAccessExport(); </script>';
+ }
+ }
+
+ function setSessionPercent() {
+
+ if (isset($_POST['break_percent'])) {
+ $this->sessionData['break']['break_percent'] = ($_POST['break_percent'] == 'true') ? true : false;
+ $this->break_percent = $this->sessionData['break']['break_percent'];
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ $this->break_percent = isset($this->sessionData['break']['break_percent']) && (int)$this->sessionData['break']['break_percent'] == 1 ? true : false;
+ }
+
+ function setSessionCharts() {
+
+ if (isset($_POST['break_charts'])) {
+ $this->sessionData['break']['break_show_charts'] = ($_POST['break_charts'] == 1) ? 1 : 0;
+ $this->break_charts = $this->sessionData['break']['break_show_charts'];
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ $this->break_charts = isset($this->sessionData['break']['break_show_charts']) && (int)$this->sessionData['break']['break_show_charts'] == 1 ? 1 : 0;
+ }
+
+ function displayLinePercent() {
+ global $lang;
+ echo '<label><input id="break_percent" name="break_percent" onchange="change_break_percent();" type="checkbox" ' . ((int)$this->break_percent == 1 ? ' checked="checked" ' : '') . ' autocomplete="off"/>';
+ echo $lang['srv_analiza_crosstab_odstotek_vrstice_short'].'</label>';
+ }
+
+ function displayLineCharts() {
+ global $lang;
+
+ echo '<span class="spaceLeft">';
+
+ echo ' <label for="break_charts_0"><input type="radio" value="0" name="break_charts" id="break_charts_0" '.((int)$this->break_charts == 0 ? ' checked="checked" ' : '').' onClick="change_break_charts(this.value)" />'.$lang['srv_tables'].'</label>';
+ echo ' <label for="break_charts_1"><input type="radio" value="1" name="break_charts" id="break_charts_1" '.((int)$this->break_charts == 1 ? ' checked="checked" ' : '').' onClick="change_break_charts(this.value)" />'.$lang['srv_charts'].'</label>';
+
+ echo '</span>';
+ }
+} \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyChart.php b/admin/survey/classes/surveyAnalysis/class.SurveyChart.php
new file mode 100644
index 0000000..461468f
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyChart.php
@@ -0,0 +1,10829 @@
+<?php
+/**
+* @author Peter Hrvatin
+* @date Februar 2011
+*/
+
+define("SAA_FOLDER", "AnalysisArchive");
+
+class SurveyChart {
+
+ public static $anketa; # id ankete
+ public static $folder = ''; # pot do folderja
+ private static $headFileName = null; # pot do header fajla
+ private static $dataFileName = null; # pot do data fajla
+ private static $dataFileStatus = null; # status data datoteke
+ private static $SDF = null; # class za inkrementalno dodajanje fajlov
+
+ public static $uid; # id userja
+
+ public static $inited = false; # ali smo razred inicializirali
+
+ public static $current_loop = 'undefined'; # v kateri zanki smo (ce imamo skupine)
+
+ public static $skin = '1ka'; # nastavitev skina za grafe
+ public static $numbering = 0; # stevilcenje vprasanj
+ public static $fontSize = 8; # velikost fonta v grafih
+ public static $quality = 1; # kvaliteta (sirina) slike (1 -> 800px, 2 -> 1600px)
+
+ public static $num_records = 10;
+ public static $numerusText = ''; // dodaten text pri numerusu (veljavni, navedbe)
+
+ public static $settings = array(); // nastavitve grafa
+
+ public static $settings_mode=0; // zavihek nastavitev (osnovno/napredno)
+
+ public static $returnChartAsHtml = false; # ali vrne rezultat analiz kot html ali ga izpiše
+ public static $isArchive = false; # nastavimo na true če smo v arhivu
+ public static $chartArchiveTime = ''; # unikatnost
+ public static $publicChart = false; # ali smo preko public povezave
+
+ private static $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ private static $survey = null; # podatki ankete
+
+ private static $baseImageUrl = "";
+
+
+ /**
+ * Inicializacija
+ *
+ * @param int $anketa
+ */
+ static function Init( $anketa = null ) {
+ global $global_user_id, $site_path, $site_url;
+
+ self::$folder = $site_path . EXPORT_FOLDER.'/';
+
+ if ((int)$anketa > 0) { # če je poadan anketa ID
+
+ self::$anketa = $anketa;
+
+ self::$baseImageUrl = $site_url . 'admin/survey/';
+ #inicializiramo SurveyAnalasys
+ SurveyAnalysis::Init(self::$anketa);
+
+ //SurveyAnalysis::$setUpJSAnaliza = false;
+
+ #inicializiramo class za datoteke
+ self::$SDF = SurveyDataFile::get_instance();
+ self::$SDF->init($anketa);
+ self::$headFileName = self::$SDF->getHeaderFileName();
+ self::$dataFileName = self::$SDF->getDataFileName();
+ self::$dataFileStatus = self::$SDF->getStatus();
+
+ if (self::$dataFileStatus == FILE_STATUS_NO_DATA
+ || self::$dataFileStatus == FILE_STATUS_NO_FILE
+ || self::$dataFileStatus == FILE_STATUS_SRV_DELETED){
+
+ // Zakaj je treba da je tukaj exit?
+ //exit;
+ return false;
+ }
+
+ //polovimo podatke o nastavitvah trenutnega profila (missingi..)
+ SurveyAnalysis::$missingProfileData = SurveyMissingProfiles::getProfile(SurveyAnalysis::$currentMissingProfile);
+
+ #preberemo HEADERS iz datoteke
+ SurveyAnalysis::$_HEADERS = unserialize(file_get_contents(self::$headFileName));
+
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ SurveyAnalysis::removeSystemVariables();
+
+ SurveyInfo :: getInstance()->SurveyInit(self::$anketa);
+ self::$survey = SurveyInfo::getInstance()->getSurveyRow();
+
+ }
+ else {
+ die("Napaka!");
+ }
+
+ if ( SurveyInfo::getInstance()->SurveyInit(self::$anketa))
+ {
+ self::$uid = $global_user_id;
+ SurveyUserSetting::getInstance()->Init(self::$anketa, self::$uid);
+ }
+
+ SurveyZankaProfiles :: Init(self::$anketa, $global_user_id);
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init(self::$anketa);
+ self::$sessionData = SurveyUserSession::getData('charts');
+
+ //$chartTableMore = SurveyDataSettingProfiles :: getSetting('chartTableMore');
+ //self::$num_records = ($chartTableMore == 0) ? 10 : 1000;
+ $result = SurveyDataSettingProfiles :: getSetting('numOpenAnswers');
+ self::$num_records = ($result > 0) ? $result : 30;
+
+ self::$skin = (SurveyUserSetting::getInstance()->getSettings('default_chart_profile_skin') == null ? '1ka' : SurveyUserSetting::getInstance()->getSettings('default_chart_profile_skin'));
+ self::$numbering = SurveyDataSettingProfiles :: getSetting('chartNumbering');
+ self::$fontSize = SurveyDataSettingProfiles :: getSetting('chartFontSize');
+
+ self::$quality = (isset(self::$sessionData['hq']) && self::$sessionData['hq'] == 1) ? 3 : 1;
+ }
+
+ /**
+ * Funkcija ki jo klicemo periodicno za vzdrzevanje cacha
+ *
+ * @param int $charts_num - stevilo grafov ki jih ustvarimo za vsako anketo
+ * @param int $expire_time - starejse grafe od $expire_time dni brisemo
+ */
+ static function chartCache($charts_num = 5, $expire_time = 10){
+
+ // loop cez vse ankete za katere urejamo cache
+ $sql = sisplet_query("SELECT id FROM srv_anketa WHERE edit_time >= NOW() - INTERVAL ".$expire_time." DAY");
+ while($row = mysqli_fetch_assoc($sql)){
+
+ echo $row['id'].'<br>';
+
+ self::Init($row['id']);
+ self::createCache($charts_num);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+ }
+
+ // Na koncu pobrisemo vse stare grafe - ki so bili ustvarjeni vec kot 3 mesece nazaj
+ self::clearCache($expire_time * 9);
+ }
+
+ // Pobrisemo stare (starejse od $expire_time v dnevih) slike grafov iz cache folderja
+ static function clearCache($expire_time = 14){
+
+ $folderPath = dirname(__FILE__).'/../../pChart/Cache/';
+ $fileTypes = '*';
+
+ // Pobrisemo file starejse od
+ $expire_time = $expire_time * 24 * 60 * 60;
+
+ foreach (glob($folderPath . $fileTypes) as $Filename) {
+
+ // preberemo cas dostopa do fila
+ //$FileCreationTime = fileatime($Filename);
+ // preberemo cas ustvarjanja fila
+ $FileCreationTime = filemtime($Filename);
+
+ // starost v dnevih
+ $FileAge = round( (time() - $FileCreationTime) / $expire_time );
+
+ if ($FileAge >= ($expire_time)){
+
+ // brisemo stare file
+ //echo 'Datoteka '.$Filename.' je starejša od '.$expire_time.' min in je bila zbrisana.<br />';
+ unlink($Filename);
+ }
+ }
+ }
+
+ // Zgeneriramo prvih $charts_num grafov v cache
+ static function createCache($charts_num = 5){
+ global $site_path;
+
+ # preberemo header
+ if (self::$headFileName !== null ) {
+
+ $vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+ foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
+
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid)) && in_array($spremenljivka['tip'],array(1,2,3,6,7,8,16,17,18,20) )) {
+
+ # ali imamo sfiltrirano spremenljivko
+ if ( $vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid])) ) {
+
+ // defult nastavitve posameznega grafa
+ self::$settings = self::getDefaultSettings();
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, self::$settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0 in ni variabel v vprasanju preskocimo graf
+ if($DataSet != 0 && $DataSet != -1){
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, self::$settings, $DataSet->GetNumerus());
+
+ if($charts_num > 0){
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1: # radio
+ case 3: # dropdown
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 2: #checkbox
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 6: # multigrid
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 7: # število
+ case 8: # datum
+ case 22: # compute
+ case 25: # kvota
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 16: # multicheckbox
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createVerStructBars($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 17: # razvrščanje
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 20: # multi number
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createRadar($DataSet, $spremenljivka);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ case 18: # vsota
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+ $Test = self::createPie($DataSet, $spremenljivka, self::$settings['show_legend']);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+ $charts_num--;
+ break;
+
+ default: # vsi ostali
+ break;
+ }
+ }
+
+ // Dosezemo limit stevila grafov za generiranje
+ else
+ break;
+
+ }
+
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+
+ } // end foreach self::$_HEADERS
+
+ } // end if else ($_headFileName == null)
+ }
+
+ static function display(){
+ global $site_path;
+ global $lang;
+
+ # zakeširamo vsebino, in jo nato po potrebi zapišpemo v html
+ if (self::$returnChartAsHtml != false) {
+ ob_start();
+ }
+
+ // prikazemo nastavitve
+ if (self::$isArchive != true && self::$publicChart != true) {
+ self::displayGlobalSettings();
+ echo "<br/>\n";
+ }
+
+ # preberemo header
+ if (self::$headFileName !== null ) {
+
+ echo '<div id="div_analiza_data" class="charts">';
+
+ if(self::$isArchive != true && self::$publicChart != true) {
+ SurveyAnalysis::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ }
+
+ # če nimamo zank
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0){
+ self::$current_loop = 'undefined';
+ self::displayCharts();
+ }
+ else{
+ $loop_cnt = 0;
+ # če mamo zanke
+ foreach(SurveyAnalysis::$_LOOPS AS $loop) {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+
+ self::$current_loop = $loop_cnt;
+
+ echo '<h2>'.$lang['srv_zanka_note'].$loop['text'].'</h2>';
+
+ self::displayCharts();
+ }
+ }
+
+ echo '</div>';
+
+ if (self::$isArchive != true && self::$publicChart != true) {
+ self::displayBottomSettings();
+ }
+
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData(self::$sessionData, 'charts');
+
+ } // end if else ($_headFileName == null)
+
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ return;
+ } else {
+ $result = ob_get_clean();
+ ob_flush(); flush();
+ return $result;
+ }
+
+ }
+
+ static function displayCharts(){
+ global $lang;
+ global $site_path;
+
+ # polovimo frekvence
+ SurveyAnalysis::getFrequencys();
+
+ $vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+
+ foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ && $spremenljivka['tip'] != 5) {
+ # ali imamo sfiltrirano spremenljivko
+ if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ) ) {
+
+ // preberemo ze nastavljene nastavitve posameznega grafa iz sessiona
+ if(isset(self::$sessionData[$spid][self::$current_loop]) && self::$current_loop != 'undefined'){
+ self::$settings = self::$sessionData[$spid][self::$current_loop];
+ }
+ else if(isset(self::$sessionData[$spid]) && self::$current_loop == 'undefined'){
+ self::$settings = self::$sessionData[$spid];
+ }
+ // nastavimo default nastavitve za vsak graf
+ else{
+ self::$settings = self::getDefaultSettings();
+
+
+ // ce imamo numeric dropdown popravimo default graf na skupinski
+ if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
+ self::$settings['type'] = 5;
+ }
+ else{
+ // Ce imamo radio tip in manj kot 5 variabel in numeric oz 2 variabli - po defaultu prikazemo piechart
+ $vars = (is_countable($spremenljivka['options'])) ? count($spremenljivka['options']) : 0;
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && (($vars < 5 && $spremenljivka['skala'] == 1) || $vars < 3) ){
+ self::$settings['type'] = 2;
+ }
+
+ // Ce imamo radio tip in vec kot 20 variabel -> po defaultu ne prikazujemo praznih
+ $vars = (is_countable($spremenljivka['options'])) ? count($spremenljivka['options']) : 0;
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $vars > 20 ){
+ self::$settings['hideEmptyVar'] = 1;
+ }
+ }
+
+
+ // Ce imamo checkbox ga po defaultu uredimo po velikosti
+ if($spremenljivka['tip'] == 2){
+ self::$settings['sort'] = 1;
+ }
+ // Ce imamo checkbox in vec kot 20 variabel -> po defaultu ne prikazujemo praznih
+ $vars = (is_countable($spremenljivka['grids'][0]['variables'])) ? count($spremenljivka['grids'][0]['variables']) : 0;
+ if( $spremenljivka['tip'] == 2 && $vars > 20 ){
+ self::$settings['hideEmptyVar'] = 1;
+ }
+
+
+ // Ce imamo multigrid ali multicheckbox in vec kot 20 variabel -> po defaultu ne prikazujemo praznih
+ $vars = (is_countable($spremenljivka['grids'])) ? count($spremenljivka['grids']) : 0;
+ if( ($spremenljivka['tip'] == 6 || $spremenljivka['tip'] == 16) && $vars > 20 ){
+ self::$settings['hideEmptyVar'] = 1;
+ }
+
+ // Ce imamo semanticni diferencial po defaultu prikazemo vertikalno crto
+ $vars = (is_countable($spremenljivka['options'])) ? count($spremenljivka['options']) : 0;
+ if($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 1){
+ self::$settings['type'] = 6;
+ }
+ // Ce imamo mg tip in manj kot 4 gridov po defaultu prikazemo strukturne stolpce
+ elseif($spremenljivka['tip'] == 6 && $vars < 4 && $spremenljivka['enota'] != 3){
+ self::$settings['type'] = 2;
+ }
+
+ // Ce imamo MG vedno sortiramo po povprecijh razen ce imamo semanicni diferencial z 1 variablo
+ $vars = (is_countable($spremenljivka['grids'])) ? count($spremenljivka['grids']) : 0;
+ if($spremenljivka['tip'] == 6 && ($vars != 1 || $spremenljivka['enota'] != 1)){
+ self::$settings['sort'] = 1;
+ }
+ // Pri multigridu imamo default obrnjene gride/variable ???
+ /*if( $spremenljivka['tip'] == 6 ){
+ self::$settings['rotate'] = 1;
+ }*/
+
+
+ // pri number po defaultu prikazemo legendo
+ if($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22){
+ self::$settings['show_legend'] = 1;
+ }
+
+
+ // Ce imamo razvrscanje ga po defaultu uredimo po velikosti
+ if($spremenljivka['tip'] == 17){
+ self::$settings['sort'] = 1;
+ }
+
+
+ // Vsota ima po novem default hor. stolpce
+ if($spremenljivka['tip'] == 18)
+ self::$settings['type'] = 2;
+
+
+ // Ce imamo multinumber in samo en grid po defaultu prikazemo stolpce in zarotiramo grids/vars
+ $vars = $spremenljivka['grids']['0']['cnt_vars'];
+ if( $spremenljivka['tip'] == 20 && $vars == 1 ){
+ self::$settings['type'] = 1;
+ self::$settings['rotate'] = 1;
+ }
+ }
+
+ // Spremenimo default alignment vseh tabel ce imamo vklopljeno levo poravnavo
+ $chartTableAlign = SurveyDataSettingProfiles :: getSetting('chartTableAlign');
+ if($chartTableAlign == 1){
+ //popravimo tabele za other
+ self::$settings['otherType'] = 1;
+
+ //popravimo se vse ostale tabele
+ if(in_array($spremenljivka['tip'], array(19,21,4))){
+ self::$settings['show_legend'] = 1;
+ }
+ }
+ else{
+ //popravimo tabele za other
+ self::$settings['otherType'] = 0;
+
+ //popravimo se vse ostale tabele
+ if(in_array($spremenljivka['tip'], array(19,21,4))){
+ self::$settings['show_legend'] = 0;
+ }
+ }
+
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1: # radio
+ case 3: # dropdown
+ self::displayRadioChart($spid, self::$settings);
+ break;
+
+ case 2: #checkbox
+ self::displayCheckboxChart($spid, self::$settings);
+ break;
+
+ case 6: # multigrid
+ // dvojna tabela
+ if($spremenljivka['enota'] == 3)
+ self::displayDoubleMultigridChart($spid, self::$settings);
+ else
+ self::displayMultigridChart($spid, self::$settings);
+ break;
+
+ case 7: # število
+ case 22: # compute
+ self::displayNumberChart($spid, self::$settings);
+ break;
+
+ case 8: # datum
+ self::displayDateChart($spid, self::$settings);
+ break;
+
+ case 25: # kvota
+ break;
+
+ case 16: # multicheckbox
+ self::displayMulticheckboxChart($spid, self::$settings);
+ break;
+
+ case 17: # razvrščanje
+ self::displayRankingChart($spid, self::$settings);
+ break;
+
+ case 20: # multi number
+ self::displayMultinumberChart($spid, self::$settings);
+ break;
+
+ case 18: # vsota
+ self::displayVsotaChart($spid, self::$settings);
+ break;
+
+ case 4: # text
+ self::frequencyVertical($spid);
+ break;
+
+ case 5: # nagovor
+ /*if(self::$view == 0)
+ SurveyAnalysis::sumNagovor($spid,'sums');*/
+ break;
+
+ case 19: # multitext
+ self::sumMultiText($spid);
+ break;
+
+ case 21: # besedilo*
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ self::frequencyVertical($spid);
+ } else {
+ self::frequencyVertical($spid);
+ }
+ break;
+ case 27:
+ # heatmap
+ SurveyAnalysis::heatmapGraph($spid,'sums',true, true);
+ break;
+
+ default:
+ break;
+ }
+ //echo '</div>'.NEW_LINE;
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+
+ } // end foreach self::$_HEADERS
+
+ }
+
+ static function displaySingle($spid){
+ global $site_path;
+ global $lang;
+
+ // Ce delamo arhiv iz custom reporta ne izvajamo ob_starta in ob_get_clean
+ $archiveFromCReport = (($_GET['a'] == 'submitArchiveAnaliza' || $_GET['a'] == 'createArchiveBeforeEmail') && $_POST['podstran'] == 'analysis_creport') ? true : true;
+
+ # zakeširamo vsebino, in jo nato po potrebi zapišpemo v html
+ if (self::$returnChartAsHtml != false && $archiveFromCReport == false) {
+ ob_start();
+ }
+
+ // prikazemo nastavitve
+ /*self::displaySettings();
+ echo "<br/>\n";
+ echo "<br/>\n";*/
+
+ # preberemo header
+ if (self::$headFileName !== null ) {
+
+ echo '<div id="div_analiza_data" class="charts">';
+
+ $vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ SurveyAnalysis::getFrequencys();
+
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ && $spremenljivka['tip'] != 5) {
+ # ali imamo sfiltrirano spremenljivko
+ if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ) ) {
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'">';
+
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'"></div>';
+
+ // defult nastavitve posameznega grafa
+ if(isset(self::$sessionData[$spid])){
+ self::$settings = self::$sessionData[$spid];
+ }
+ else{
+
+ self::$settings = self::getDefaultSettings();
+
+ // Ce imamo radio tip in manj kot 5 variabel po defaultu prikazemo piechart
+ $vars = count($spremenljivka['options']);
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $vars < 5 && $spremenljivka['skala'] == 1){
+ self::$settings['type'] = 2;
+ }
+
+ // Ce imamo mg tip in manj kot 5 variabel po defaultu prikazemo en strukturni stolpec
+ /*$vars = $spremenljivka['cnt_all'];
+ if( ($spremenljivka['tip'] == 6) && $vars < 5 ){
+ self::$settings['type'] = 2;
+ }*/
+ // Ce imamo semanticni diferencial po defaultu prikazemo vertikalno crto
+ if($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 1){
+ self::$settings['type'] = 6;
+ }
+ // Ce imamo mg tip in manj kot 5 gridov po defaultu prikazemo strukturne stolpce
+ elseif($spremenljivka['tip'] == 6 && $vars < 5 && $spremenljivka['enota'] != 3){
+ self::$settings['type'] = 2;
+ }
+
+ // Vsota ima po novem default hor. stolpce
+ if($spremenljivka['tip'] == 18)
+ self::$settings['type'] = 2;
+
+ // Ce imamo multinumber in samo en grid po defaultu prikazemo stolpce in zarotiramo grids/vars
+ $vars = $spremenljivka['grids']['0']['cnt_vars'];
+ if( $spremenljivka['tip'] == 20 && $vars == 1 ){
+ self::$settings['type'] = 1;
+ self::$settings['rotate'] = 1;
+ }
+ }
+
+ // Spremenimo default alignment vseh tabel ce imamo vklopljeno levo poravnavo
+ $chartTableAlign = SurveyDataSettingProfiles :: getSetting('chartTableAlign');
+ if($chartTableAlign == 1){
+ //popravimo tabele za other
+ self::$settings['otherType'] = 1;
+
+ //popravimo se vse ostale tabele
+ if(in_array($spremenljivka['tip'], array(19,21,4))){
+ self::$settings['show_legend'] = 1;
+ }
+ }
+ else{
+ //popravimo tabele za other
+ self::$settings['otherType'] = 0;
+
+ //popravimo se vse ostale tabele
+ if(in_array($spremenljivka['tip'], array(19,21,4))){
+ self::$settings['show_legend'] = 0;
+ }
+ }
+
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1: # radio
+ case 3: # dropdown
+ self::displayRadioChart($spid, self::$settings);
+ break;
+ case 2: #checkbox
+ self::displayCheckboxChart($spid, self::$settings);
+ break;
+ case 6: # multigrid
+ // dvojna tabela
+ if($spremenljivka['enota'] == 3)
+ self::displayDoubleMultigridChart($spid, self::$settings);
+ else
+ self::displayMultigridChart($spid, self::$settings);
+ break;
+ case 7: # število
+ case 22: # compute
+ self::displayNumberChart($spid, self::$settings);
+ break;
+ case 8: # datum
+ self::displayDateChart($spid, self::$settings);
+ break;
+ case 25: # kvota
+ //self::displayNumberChart($spid, self::$settings);
+ break;
+ case 16: # multicheckbox
+ self::displayMulticheckboxChart($spid, self::$settings);
+ break;
+ case 17: # razvrščanje
+ self::displayRankingChart($spid, self::$settings);
+ break;
+ case 20: # multi number
+ self::displayMultinumberChart($spid, self::$settings);
+ //self::frequencyVertical($spid);
+ break;
+ case 18: # vsota
+ self::displayVsotaChart($spid, self::$settings);
+ break;
+ case 4: # text
+ //SurveyAnalysis::sumTextVertical($spid,'sums');
+ self::frequencyVertical($spid);
+ break;
+ case 5: # nagovor
+ /*if(self::$view == 0)
+ SurveyAnalysis::sumNagovor($spid,'sums');*/
+ break;
+ case 19: # multitext
+ //SurveyAnalysis::sumMultiText($spid,'sums');
+ //self::frequencyVertical($spid);
+ self::sumMultiText($spid);
+ break;
+ case 21: # besedilo*
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ //SurveyAnalysis::sumTextVertical($spid,'sums');
+ self::frequencyVertical($spid);
+ } else {
+ //SurveyAnalysis::sumMultiText($spid,'sums');
+ self::frequencyVertical($spid);
+ }
+ break;
+ default:
+ break;
+ }
+ echo '</div>'.NEW_LINE;
+
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData(self::$sessionData, 'charts');
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+
+ echo '</div>';
+
+ //self::displayBottomSettings();
+
+ } // end if else ($_headFileName == null)
+
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ return;
+ }
+ else {
+ if($archiveFromCReport == false){
+ $result = ob_get_clean();
+ ob_flush(); flush();
+ return $result;
+ }
+ }
+ }
+
+ /**
+ * Izrise graf za posamezno spremenljivko
+ */
+ static function displayRadioChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Ce smo ravnokar preklopili na pieChart vklopimo sortiranje
+ if(self::$current_loop != 'undefined'){
+ if((self::$sessionData[$spid][self::$current_loop]['type'] != 2 && $settings['type'] == 2) || (self::$sessionData[$spid][self::$current_loop]['type'] != 8 && $settings['type'] == 8)){
+ $settings['sort'] = 1;
+ self::$settings['sort'] = 1;
+ }
+ }
+ else{
+ if((self::$sessionData[$spid]['type'] != 2 && $settings['type'] == 2) || (self::$sessionData[$spid]['type'] != 8 && $settings['type'] == 8)){
+ $settings['sort'] = 1;
+ self::$settings['sort'] = 1;
+ }
+ }
+
+ // popravimo nastavitve za numeric dropdown
+ if(self::$current_loop != 'undefined'){
+ if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
+ // Ce smo ravnokar preklopili na linijski - po skupinah imamo default vse intervale
+ if(self::$sessionData[$spid][self::$current_loop]['type'] != 7 && $settings['type'] == 7 ){
+ $settings['interval'] = -1;
+ self::$settings['interval'] = -1;
+ }
+ // Ce smo ravnokar preklopili na navaden - po skupinah imamo default 10 intervalov
+ if(self::$sessionData[$spid][self::$current_loop]['type'] < 5 && $settings['type'] > 4){
+ $settings['interval'] = 10;
+ self::$settings['interval'] = 10;
+ }
+ }
+ }
+ else{
+ if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
+ // Ce smo ravnokar preklopili na linijski - po skupinah imamo default vse intervale
+ if(self::$sessionData[$spid]['type'] != 7 && $settings['type'] == 7 ){
+ $settings['interval'] = -1;
+ self::$settings['interval'] = -1;
+ }
+ // Ce smo ravnokar preklopili na navaden - po skupinah imamo default 10 intervalov
+ if(self::$sessionData[$spid]['type'] < 5 && $settings['type'] > 4){
+ $settings['interval'] = 10;
+ self::$settings['interval'] = 10;
+ }
+ }
+ }
+
+ // Popravimo pri preklopu na povprecje - prikazujemo notranje vrednosti in izklopimo prikaz povprecja
+ if(self::$sessionData[$spid]['type'] != 9 && $settings['type'] == 9){
+ $settings['barLabel'] = 1;
+ self::$settings['barLabel'] = 1;
+
+ $settings['show_avg'] = 0;
+ self::$settings['show_avg'] = 0;
+ }
+
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa - ali ce refreshamo grafe
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Horizontalni stolpci
+ case 0:
+ // Horizontalni stolpci - numeric dropdown
+ case 5:
+ // Horizontalen stolpec - povprecje
+ case 9:
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ break;
+
+ // Navpicni stolpci
+ case 1:
+ // Navpicni stolpci - numeric dropdown
+ case 6:
+ $Test = self::createVerBars($DataSet, $spremenljivka);
+ break;
+
+ // Pie chart
+ case 2:
+ $Test = self::createPie($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // 3D Pie chart
+ case 8:
+ $Test = self::create3DPie($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // Sestavljeni stolpec - horizontalen
+ case 3:
+ $Test = self::createHorStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Sestavljeni stolpec - vertikalen
+ case 4:
+ $Test = self::createVerStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Linijski graf - numeric dropdown
+ case 7:
+ case 22:
+ $Test = self::createLine($DataSet, $spremenljivka);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+
+ if(is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+ static function displayCheckboxChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Popravimo pri preklopu na enote (kjer ne moremo imeti strukturnih stolpcev)
+ if( ($settings['type'] == 2 || $settings['type'] == 7 || $settings['type'] == 3 || $settings['type'] == 4) && $settings['base'] == 0 ){
+ $settings['type'] = 0;
+ }
+ // Popravimo pri preklopu na navedbe (kjer ne moremo imeti radarja in linijskega grafa)
+ if( ($settings['type'] == 5 || $settings['type'] == 6) && $settings['base'] == 1 ){
+ $settings['type'] = 0;
+ }
+
+ // Ce smo ravnokar preklopili na pieChart vklopimo sortiranje
+ if(self::$current_loop != 'undefined'){
+ if((self::$sessionData[$spid][self::$current_loop]['type'] != 2 && $settings['type'] == 2) || (self::$sessionData[$spid][self::$current_loop]['type'] != 7 && $settings['type'] == 7)){
+ $settings['sort'] = 1;
+ self::$settings['sort'] = 1;
+ }
+ }
+ else{
+ if((self::$sessionData[$spid]['type'] != 2 && $settings['type'] == 2) || (self::$sessionData[$spid]['type'] != 7 && $settings['type'] == 7)){
+ $settings['sort'] = 1;
+ self::$settings['sort'] = 1;
+ }
+ }
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Horizontalni stolpci
+ case 0:
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ break;
+
+ // Vodoravni stolpci
+ case 1:
+ $Test = self::createVerBars($DataSet, $spremenljivka);
+ break;
+
+ // Pie chart
+ case 2:
+ $Test = self::createPie($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // 3D Pie chart
+ case 7:
+ case 22:
+ $Test = self::create3DPie($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // Sestavljeni stolpec - horizontalen
+ case 3:
+ $Test = self::createHorStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Sestavljeni stolpec - vertikalen
+ case 4:
+ $Test = self::createVerStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Radar
+ case 5:
+ $Test = self::createRadar($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // Linijski graf
+ case 6:
+ $Test = self::createLine($DataSet, $spremenljivka);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ if($settings['base'] == 1)
+ echo '(r = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ else
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '<br /><span class="subtitle">'.$lang['srv_info_checkbox'];
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ $addHeight = ($settings['type'] == 2) ? 'style="height: 245px"' : '';
+
+ echo '<div class="chart_settings printHide iconHide" '.$addHeight.'>';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+
+ if(is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+ static function displayNumberChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ if(self::$current_loop != 'undefined'){
+ // Ce smo ravnokar preklopili na linijski - po skupinah imamo default vse intervale
+ if(self::$sessionData[$spid][self::$current_loop]['type'] != 2 && $settings['type'] == 2){
+ $settings['interval'] = -1;
+ self::$settings['interval'] = -1;
+ }
+ // Ce smo ravnokar preklopili na navaden - po skupinah imamo default 10 intervalov
+ if(self::$sessionData[$spid][self::$current_loop]['type'] >= 2 && $settings['type'] < 2){
+ $settings['interval'] = 10;
+ self::$settings['interval'] = 10;
+ }
+ }
+ else{
+ // Ce smo ravnokar preklopili na linijski - po skupinah imamo default vse intervale
+ if(self::$sessionData[$spid]['type'] != 2 && $settings['type'] == 2){
+ $settings['interval'] = -1;
+ self::$settings['interval'] = -1;
+ }
+ // Ce smo ravnokar preklopili na navaden - po skupinah imamo default 10 intervalov
+ if(self::$sessionData[$spid]['type'] >= 2 && $settings['type'] < 2){
+ $settings['interval'] = 10;
+ self::$settings['interval'] = 10;
+ }
+ }
+
+ // Popravimo pri preklopu na povprecje - prikazujemo notranje vrednosti in izklopimo prikaz povprecja
+ if(self::$sessionData[$spid]['type'] != 9 && $settings['type'] == 9){
+ $settings['barLabel'] = 1;
+ self::$settings['barLabel'] = 1;
+
+ $settings['show_avg'] = 0;
+ self::$settings['show_avg'] = 0;
+ }
+
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Horizontalni stolpci - po skupinah ali navadno
+ case 0:
+ case 3:
+ // Horizontalen stolpec - povprecje
+ case 9:
+ $Test = self::createHorBars($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // Vertikalni stolpci - po skupinah ali navadno
+ case 1:
+ case 4:
+ $Test = self::createVerBars($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // Line chart - po skupinah
+ case 2:
+ $Test = self::createLine($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ echo '</div>';
+ }
+
+ static function displayDateChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Horizontalni stolpci - po skupinah ali navadno
+ case 0:
+ case 3:
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ break;
+
+ // Vertikalni stolpci - po skupinah ali navadno
+ case 1:
+ case 4:
+ $Test = self::createVerBars($DataSet, $spremenljivka);
+ break;
+
+ // Line chart
+ case 2:
+ $Test = self::createLine($DataSet, $spremenljivka);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ echo '</div>';
+ }
+
+ static function displayMultigridChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ //ce imamo nominalno spremenljivko ali ce je samo 1 variabla nimamo povprecij
+ if( ($spremenljivka['cnt_all'] == 1 || $spremenljivka['skala'] == 1) && ($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6) ){
+ $settings['type'] = 2;
+ }
+
+ //ce imamo navadne stolpce (ne povprecij) - ugasnemo labele vrednosti na stolpcih
+ if( $settings['type'] == 3 || $settings['type'] == 4 ){
+ $settings['barLabel'] = 0;
+ self::$settings['barLabel'] = 0;
+ }
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Povprecja - horizontalni stolpci
+ case 0:
+ $Test = self::createHorBars($DataSet, $spremenljivka, $settings['show_legend'], $settings['noFixedScale']/*$fixedScale=1*/);
+ break;
+
+ // Povprecja - vertikalna crta
+ case 6:
+ $Test = self::createVerLine($DataSet, $spremenljivka, $settings['show_legend'], $settings['noFixedScale']);
+ break;
+
+ // Povprecja - radar
+ case 5:
+ $Test = self::createRadar($DataSet, $spremenljivka, $settings['show_legend'], $settings['noFixedScale']);
+ break;
+
+ // Sestavljeni stolpci - navpicni
+ case 1:
+ $Test = self::createVerStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Sestavljeni stolpci - vodoravni
+ case 2:
+ $Test = self::createHorStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Navpicni stolpci
+ case 3:
+ $Test = self::createVerBars($DataSet, $spremenljivka, 1);
+ break;
+
+ // Horizontalni stolpci
+ case 4:
+ $Test = self::createHorBars($DataSet, $spremenljivka, 1);
+ break;
+
+ // Nominalni radar
+ case 7:
+ case 22:
+ $Test = self::createRadar($DataSet, $spremenljivka, 1, $fixedScale=0);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+
+ if(is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+ static function displayDoubleMultigridChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Horizontal chart
+ case 0:
+ $Test = self::createHorBars($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
+ break;
+
+ // Vertical chart
+ case 1:
+ $Test = self::createVerBars($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
+ break;
+
+ // Line chart
+ case 2:
+ $Test = self::createLine($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
+ break;
+
+ // Vertical line chart
+ case 3:
+ $Test = self::createVerLine($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
+ break;
+
+ // Radar chart
+ case 4:
+ $Test = self::createRadar($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+
+ if(is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+ static function displayMulticheckboxChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+
+ //Popravimo pri preklopu na enote (kjer ne moremo imeti strukturnih stolpcev)
+ if( ($settings['type'] == 2 || $settings['type'] == 3) && $settings['base'] == 0 ){
+ $settings['type'] = 0;
+ }
+ //Popravimo pri preklopu na navedbe (kjer ne moremo imeti radarja)
+ if( $settings['type'] == 4 && $settings['base'] == 1 ){
+ $settings['type'] = 0;
+ }
+
+ // Popravimo ce preklopimo iz veljavnih enot na navedbe
+ if($settings['base'] == 1 && $settings['value_type'] == 0){
+ $settings['value_type'] = 1;
+ }
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Povprecja
+ /*case 0:
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ break;*/
+
+ // Horizontalni stolpci
+ case 0:
+ $Test = self::createHorBars($DataSet, $spremenljivka, 1);
+ break;
+
+ // Navpicni stolpci
+ case 1:
+ $Test = self::createVerBars($DataSet, $spremenljivka, 1);
+ break;
+
+ // Sestavljeni stolpci - navpicni
+ case 2:
+ $Test = self::createVerStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Sestavljeni stolpci - vodoravni
+ case 3:
+ $Test = self::createHorStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Radar
+ case 4:
+ $Test = self::createRadar($DataSet, $spremenljivka, 1);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+
+ if($settings['base'] == 1)
+ echo '(r = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ else
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+
+ if(is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+ static function displayVsotaChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Ce smo ravnokar preklopili (je session se prazen) na pieChart vklopimo sortiranje
+ if(self::$current_loop != 'undefined'){
+ if((self::$sessionData[$spid][self::$current_loop]['type'] != 0 && $settings['type'] == 0) || (self::$sessionData[$spid][self::$current_loop]['type'] != 5 && $settings['type'] == 5)){
+ $settings['sort'] = 1;
+ self::$settings['sort'] = 1;
+ }
+ }
+ else{
+ if((self::$sessionData[$spid]['type'] != 0 && $settings['type'] == 0) || (self::$sessionData[$spid]['type'] != 5 && $settings['type'] == 5)){
+ $settings['sort'] = 1;
+ self::$settings['sort'] = 1;
+ }
+ }
+
+ // Pri radarju ni sortiranja
+ if($settings['type'] == 4){
+ $settings['sort'] = 0;
+ self::$settings['sort'] = 0;
+ }
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Pie chart - povprecja
+ case 0:
+ $Test = self::createPie($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // 3D Pie chart - povprecja
+ case 5:
+ $Test = self::create3DPie($DataSet, $spremenljivka, $settings['show_legend']);
+ break;
+
+ // Line chart
+ case 1:
+ $Test = self::createLine($DataSet, $spremenljivka);
+ break;
+
+ // Horizontal bars
+ case 2:
+ $Test = self::createHorBars($DataSet, $spremenljivka);
+ break;
+
+ // Vertical bars
+ case 3:
+ $Test = self::createVerBars($DataSet, $spremenljivka);
+ break;
+
+ // Radar
+ case 4:
+ $Test = self::createRadar($DataSet, $spremenljivka);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ echo '</div>';
+ }
+
+ static function displayRankingChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ //$Cache->GetFromCache($ID,$DataSet->GetData());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Povprecja
+ case 0:
+ $Test = self::createHorBars($DataSet, $spremenljivka, $legend=0, $settings['noFixedScale']/*$fixedScale=1*/);
+ break;
+
+ // Sestavljeni stolpci - navpicni
+ case 1:
+ $Test = self::createHorStructBars($DataSet, $spremenljivka);
+ break;
+
+ // Sestavljeni stolpci - vodoravni
+ case 2:
+ $Test = self::createVerStructBars($DataSet, $spremenljivka);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ echo '</div>';
+ }
+
+ static function displayMultinumberChart($spid, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // ni variabel v vprasanju preskocimo graf
+ if($DataSet == -1){
+ return;
+ }
+
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'_loop_'.self::$current_loop.'"></div>';
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ // Ce se nimamo zgeneriranega grafa
+ $refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
+ if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
+
+ switch($settings['type']){
+
+ // Povprecja - radar
+ case 0:
+ $Test = self::createRadar($DataSet, $spremenljivka, 1);
+ break;
+
+ // Povprecja - vertikalni stolpci
+ case 1:
+ $Test = self::createVerBars($DataSet, $spremenljivka, 1);
+ break;
+
+ // Povprecja - horizontalni stolpci
+ case 2:
+ $Test = self::createHorBars($DataSet, $spremenljivka, 1);
+ break;
+
+ // Povprecja - linijski graf
+ case 3:
+ $Test = self::createLine($DataSet, $spremenljivka, 1);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ if (self::$isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+ $imgUrl = self::$baseImageUrl . $imgPath;
+
+ // zapisemo ime slike v session za izvoze
+ $settings['name'] = $imgName;
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title;
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus()/*.self::$numerusText*/.')';
+ echo '</span>';
+ }
+ echo '</div>';
+
+ echo '<div class="chart_img" title="'.$lang['srv_chart_editirajspremenljivko'].'" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ self::displaySingleSettings($spid, $settings);
+ echo '</div>';
+
+ // ce imamo vklopljen nuimerus pod grafom
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
+ self::displayBottomChartInfo($DataSet, $spremenljivka);
+
+ if (self::$returnChartAsHtml == false) {
+ flush(); ob_flush();
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+
+ if(is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+
+ // Default nastavitve grafov
+ public static function getDefaultSettings(){
+
+ $colors = array_fill(0, 6, '');
+ $limits = array('advanced_settings' => 0);
+
+ $settings = array(
+ 'type' => 0, // tip grafa
+ 'sort' => 0, // sortiranje po velikosti (0->brez, 1->padajoce, 2->narascajoce)
+ // ali MG (0->brez, 1->kategorije (trenutno), 2->povprecje, 3->prva ketegorija)
+ 'value_type' => 0, // tip vrednosti (veljavni, frekvence, procenti...)
+ 'base' => 0, // checkbox / multicheckbox osnova (enote / navedbe)
+ 'show_legend' => 0, // prikaz legende
+ 'scale_limit' => 1, // zacni skalo z 0 / z najmanjso vrednostjo pri numericih ALI prikazi desno skalo pri semanticnem diferencialu
+ 'interval' => 10, // stevilo intervalov pri numericih
+ 'min' => '0', // minimalna vrednost po kateri delamo intervale pri numericih (max-min)/interval
+ 'max' => '', // maximalna vrednost po kateri delamo intervale pri numericih (max-min)/interval
+ 'open_up' => 0, // polodprt interval navzgor (ce so vrednosti nad max) pri numericih
+ 'open_down' => 0, // polodprt interval navzdol (ce so vrednosti pod min) pri numericih
+ 'limits' => $limits, // napredne meje number grafov (custom intervali) - ce je $limits['advanced_settings']==1
+ 'radar_type' => 0, // tip radarja (crte / liki)
+ 'radar_scale' => 0, // skala pri radarju (na osi / diagonalno)
+ '3d_pie' => 0, // tip kroznega grafa (navaden / 3d)
+ 'labelWidth' => 50, // sirina label (50% / 20%)
+ 'barLabel' => 1, // prikaz label v stolpicnih grafih
+ 'barLabelSmall' => 1, // prikaz label pod 5% v stolpicnih grafih (zraven stolpca)
+ 'rotate' => 0, // obrnjeni gridi in variable (pri vseh MG - multiradio, multinumber...)
+ 'colors' => $colors, // custom barve grafa
+ 'show_avg' => -1, // prikaz povprecja na grafu (samo pri ordinalnih radio)
+ 'show_numerus' => 1, // prikaz numerusa na grafu
+ 'otherType' => 0, // poravnava other tabel
+ 'otherFreq' => 0, // izpis frekvenc v other tabeli
+ 'hideEmptyVar' => 0, // ali izpuscamo prazne opcije brez odgovora (ce je nad 20 variabel -> default 1)
+ 'noFixedScale' => 0, // ce izklopimo skalo ki se zacne z 1 (samo pri multigrid povprecjih in ranking povprecjih) ALI prikazi polno skalo pri checkboxu (ce je 1)
+ );
+
+ return $settings;
+ }
+
+ // Zgeneriramo ID grafa za hash
+ public static function generateChartId($spid, $settings, $numerus){
+
+ // ce posebej prizgemo legendo pri pie chartu
+ if($settings['show_legend'] == 1 && $settings['type'] == 2)
+ $legend = '_legend';
+ else
+ $legend = '';
+
+ $ID = self::$anketa.'_chart_'.$spid.'_mv_'.SurveyAnalysis::$missingProfileData['display_mv_type'];
+
+ foreach ($settings AS $key => $val) {
+ if($key == 'colors'){
+
+ $ID .= '_colors';
+
+ foreach ($val AS $colKey => $color){
+ $ID .= '_'.$color;
+ }
+ }
+
+ elseif($key != 'name')
+ $ID .= '_'.$key.'_'.$val;
+ }
+
+ $ID .= '_skin_'.self::$skin;
+
+ $ID .= '_numerus_'.$numerus.'_numerusText_'.SurveyDataSettingProfiles :: getSetting('chartNumerusText');
+
+ $ID .= '_chartAvgText_'.SurveyDataSettingProfiles :: getSetting('chartAvgText');
+
+ $ID .= '_pieZeros_'.SurveyDataSettingProfiles :: getSetting('chartPieZeros');
+
+ $ID .= '_chartFontSize_'.SurveyDataSettingProfiles :: getSetting('chartFontSize');
+
+ $ID .= '_hq_'.self::$quality;
+
+ return $ID;
+ }
+
+ // nastavimo prave barve ustrezne skinu
+ public static function setChartColors($chart, $skin){
+
+ // Ce nimmo posebej nastavljenih barv
+ if(self::$settings['colors'][0] == ''){
+
+ // ce je nastavljen globalen custom skin
+ if(is_numeric($skin)){
+ $skin = self::getCustomSkin($skin);
+ $colors = explode('_', $skin['colors']);
+
+ $count = 0;
+ foreach($colors as $color){
+
+ $rgb = self::html2rgb($color);
+ $chart->setColorPalette($count,$rgb[0],$rgb[1],$rgb[2]);
+ $chart->setColorPalette($count+7,$rgb[0]+50,$rgb[1]+50,$rgb[2]+50);
+ $chart->setColorPalette($count+14,$rgb[0]+100,$rgb[1]+100,$rgb[2]+100);
+
+ $count++;
+ }
+ }
+
+ // imamo nastavljenega enega od default skinov
+ else{
+ switch ($skin){
+
+ // nov 1ka default skin
+ case '1ka':
+ default:
+ $chart->setColorPalette(0,30,136,229);
+ $chart->setColorPalette(1,255,166,8);
+ $chart->setColorPalette(2,72,229,194);
+ $chart->setColorPalette(3,242,87,87);
+ $chart->setColorPalette(4,117,70,68);
+ $chart->setColorPalette(5,248,202,0);
+ $chart->setColorPalette(6,255,112,166);
+
+ $chart->setColorPalette(7,63,81,180);
+ $chart->setColorPalette(8,76,174,80);
+ $chart->setColorPalette(9,204,219,57);
+ $chart->setColorPalette(10,255,235,59);
+ $chart->setColorPalette(11,0,149,135);
+ $chart->setColorPalette(12,121,85,72);
+ $chart->setColorPalette(13,157,157,157);
+ $chart->setColorPalette(14,96,125,138);
+ $chart->setColorPalette(15,155,39,175);
+ $chart->setColorPalette(16,103,58,182);
+ $chart->setColorPalette(17,255,255,103);
+ $chart->setColorPalette(18,255,249,100);
+ $chart->setColorPalette(19,100,255,255);
+ $chart->setColorPalette(20,255,100,255);
+ break;
+
+ // zivahen skin
+ case 'lively':
+ $chart->setColorPalette(0,224,9,13);
+ $chart->setColorPalette(1,4,23,227);
+ $chart->setColorPalette(2,0,255,8);
+ $chart->setColorPalette(3,255,247,3);
+ $chart->setColorPalette(4,255,149,0);
+ $chart->setColorPalette(5,0,251,255);
+ $chart->setColorPalette(6,166,0,255);
+
+ $chart->setColorPalette(7,255,59,63);
+ $chart->setColorPalette(8,54,73,255);
+ $chart->setColorPalette(9,50,255,58);
+ $chart->setColorPalette(10,255,255,53);
+ $chart->setColorPalette(11,255,199,35);
+ $chart->setColorPalette(12,50,255,255);
+ $chart->setColorPalette(13,216,50,255);
+ $chart->setColorPalette(14,255,109,113);
+ $chart->setColorPalette(15,104,123,255);
+ $chart->setColorPalette(16,100,255,108);
+ $chart->setColorPalette(17,255,255,103);
+ $chart->setColorPalette(18,255,249,100);
+ $chart->setColorPalette(19,100,255,255);
+ $chart->setColorPalette(20,255,100,255);
+ break;
+
+ // blag skin
+ case 'mild':
+ $chart->setColorPalette(0,188,224,46);
+ $chart->setColorPalette(1,224,100,46);
+ $chart->setColorPalette(2,224,214,46);
+ $chart->setColorPalette(3,46,151,224);
+ $chart->setColorPalette(4,176,46,224);
+ $chart->setColorPalette(5,224,46,117);
+ $chart->setColorPalette(6,92,224,46);
+
+ $chart->setColorPalette(7,238,255,96);
+ $chart->setColorPalette(8,255,150,96);
+ $chart->setColorPalette(9,255,255,96);
+ $chart->setColorPalette(10,96,201,255);
+ $chart->setColorPalette(11,226,96,255);
+ $chart->setColorPalette(12,255,96,167);
+ $chart->setColorPalette(13,142,255,96);
+ $chart->setColorPalette(14,255,255,146);
+ $chart->setColorPalette(15,255,200,146);
+ $chart->setColorPalette(16,255,255,146);
+ $chart->setColorPalette(17,146,251,255);
+ $chart->setColorPalette(18,255,146,255);
+ $chart->setColorPalette(19,255,146,217);
+ $chart->setColorPalette(20,192,255,146);
+ break;
+
+ // Office skin
+ case 'office':
+ $chart->setColorPalette(0,79,129,189);
+ $chart->setColorPalette(1,192,80,77);
+ $chart->setColorPalette(2,155,187,89);
+ $chart->setColorPalette(3,128,100,162);
+ $chart->setColorPalette(4,75,172,198);
+ $chart->setColorPalette(5,247,150,70);
+ $chart->setColorPalette(6,146,169,207);
+
+ $chart->setColorPalette(7,129,179,239);
+ $chart->setColorPalette(8,242,130,127);
+ $chart->setColorPalette(9,205,237,139);
+ $chart->setColorPalette(10,178,150,212);
+ $chart->setColorPalette(11,125,222,248);
+ $chart->setColorPalette(12,255,200,120);
+ $chart->setColorPalette(13,196,219,255);
+ $chart->setColorPalette(14,179,229,255);
+ $chart->setColorPalette(15,255,180,177);
+ $chart->setColorPalette(16,255,255,189);
+ $chart->setColorPalette(17,228,200,255);
+ $chart->setColorPalette(18,175,255,255);
+ $chart->setColorPalette(19,255,250,170);
+ $chart->setColorPalette(20,226,255,255);
+ break;
+
+ // Pastel skin
+ case 'pastel':
+ $chart->setColorPalette(0,121,159,11);
+ $chart->setColorPalette(1,215,161,37);
+ $chart->setColorPalette(2,146,100,190);
+ $chart->setColorPalette(3,24,132,132);
+ $chart->setColorPalette(4,76,198,139);
+ $chart->setColorPalette(5,138,136,35);
+ $chart->setColorPalette(6,108,153,210);
+
+ $chart->setColorPalette(7,171,209,61);
+ $chart->setColorPalette(8,255,211,87);
+ $chart->setColorPalette(9,196,150,240);
+ $chart->setColorPalette(10,74,182,182);
+ $chart->setColorPalette(11,126,255,189);
+ $chart->setColorPalette(12,188,186,85);
+ $chart->setColorPalette(13,158,203,255);
+ $chart->setColorPalette(14,221,255,111);
+ $chart->setColorPalette(15,255,255,137);
+ $chart->setColorPalette(16,246,200,255);
+ $chart->setColorPalette(17,124,232,255);
+ $chart->setColorPalette(18,176,255,239);
+ $chart->setColorPalette(19,238,236,135);
+ $chart->setColorPalette(20,208,253,255);
+ break;
+
+ // zelen skin
+ case 'green':
+ $chart->createColorGradientPalette(168,188,56,248,255,136,5);
+ $chart->setColorPalette(5,255,255,0);
+ $chart->setColorPalette(6,232,3,182);
+
+ $chart->setColorPalette(7,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
+ $chart->setColorPalette(8,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
+ $chart->setColorPalette(9,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
+ $chart->setColorPalette(10,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
+ $chart->setColorPalette(11,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
+ $chart->setColorPalette(12,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
+ $chart->setColorPalette(13,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
+ $chart->setColorPalette(14,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
+ $chart->setColorPalette(15,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
+ $chart->setColorPalette(16,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
+ $chart->setColorPalette(17,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
+ $chart->setColorPalette(18,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
+ $chart->setColorPalette(19,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
+ $chart->setColorPalette(20,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
+ break;
+
+ // moder skin
+ case 'blue':
+ //$chart->createColorGradientPalette(82,124,148,174,216,240,5);
+ $chart->setColorPalette(0,30,136,229);
+ $chart->setColorPalette(1,59,151,234);
+ $chart->setColorPalette(2,110,166,238);
+ $chart->setColorPalette(3,137,181,243);
+ $chart->setColorPalette(4,162,196,247);
+ $chart->setColorPalette(5,186,211,251);
+ $chart->setColorPalette(6,209,227,255);
+
+ $chart->setColorPalette(7,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
+ $chart->setColorPalette(8,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
+ $chart->setColorPalette(9,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
+ $chart->setColorPalette(10,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
+ $chart->setColorPalette(11,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
+ $chart->setColorPalette(12,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
+ $chart->setColorPalette(13,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
+ $chart->setColorPalette(14,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
+ $chart->setColorPalette(15,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
+ $chart->setColorPalette(16,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
+ $chart->setColorPalette(17,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
+ $chart->setColorPalette(18,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
+ $chart->setColorPalette(19,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
+ $chart->setColorPalette(20,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
+ break;
+
+ // rdeč skin
+ case 'red':
+ $chart->createColorGradientPalette(255,0,0,80,10,10,5);
+ $chart->setColorPalette(5,255,255,0);
+ $chart->setColorPalette(6,232,3,182);
+
+ $chart->setColorPalette(7,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
+ $chart->setColorPalette(8,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
+ $chart->setColorPalette(9,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
+ $chart->setColorPalette(10,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
+ $chart->setColorPalette(11,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
+ $chart->setColorPalette(12,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
+ $chart->setColorPalette(13,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
+ $chart->setColorPalette(14,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
+ $chart->setColorPalette(15,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
+ $chart->setColorPalette(16,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
+ $chart->setColorPalette(17,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
+ $chart->setColorPalette(18,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
+ $chart->setColorPalette(19,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
+ $chart->setColorPalette(20,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
+ break;
+
+ // skin za vec kot 5 moznosti
+ case 'multi':
+ $chart->setColorPalette(0,140,0,0);
+ $chart->setColorPalette(1,240,8,0);
+ $chart->setColorPalette(2,255,138,130);
+ $chart->setColorPalette(3,242,196,200);
+ $chart->setColorPalette(4,11,3,135);
+ $chart->setColorPalette(5,4,0,252);
+ $chart->setColorPalette(6,151,148,242);
+ $chart->setColorPalette(7,0,133,31);
+ $chart->setColorPalette(8,24,217,3);
+ $chart->setColorPalette(9,139,245,157);
+ $chart->setColorPalette(10,237,202,45);
+ $chart->setColorPalette(11,253,255,120);
+ $chart->setColorPalette(12,156,0,125);
+ $chart->setColorPalette(13,255,0,246);
+ $chart->setColorPalette(14,242,3,162);
+ $chart->setColorPalette(15,237,154,216);
+ $chart->setColorPalette(16,0,123,145);
+ $chart->setColorPalette(17,0,204,250);
+ $chart->setColorPalette(18,174,238,245);
+ $chart->setColorPalette(19,0,255,200);
+ $chart->setColorPalette(20,255,111,0);
+ $chart->setColorPalette(21,255,162,0);
+ $chart->setColorPalette(22,255,201,120);
+ $chart->setColorPalette(23,161,92,133);
+ $chart->setColorPalette(24,205,159,245);
+ $chart->setColorPalette(25,179,245,103);
+ $chart->setColorPalette(26,135,171,108);
+ $chart->setColorPalette(27,73,132,145);
+ $chart->setColorPalette(28,70,96,99);
+ $chart->setColorPalette(29,156,95,103);
+ break;
+ }
+ }
+ }
+
+ // Graf ima posebej nastavljen skin
+ else{
+ for($i=0; $i<7; $i++){
+
+ $color = self::$settings['colors'][$i];
+ $rgb = self::html2rgb($color);
+
+ $chart->setColorPalette($i,$rgb[0],$rgb[1],$rgb[2]);
+ $chart->setColorPalette($i+7,$rgb[0]+50,$rgb[1]+50,$rgb[2]+50);
+ $chart->setColorPalette($i+14,$rgb[0]+100,$rgb[1]+100,$rgb[2]+100);
+ }
+ }
+
+ return $chart;
+ }
+
+ public static function getDefaultColors($skin){
+
+ // ce je nastavljen globalen custom skin
+ if(is_numeric($skin)){
+ $skin = self::getCustomSkin($skin);
+ $default_colors = explode('_', $skin['colors']);
+ }
+
+ else{
+ switch($skin){
+ case '1ka':
+ $default_colors = array(0=>'#1e88e5', 1=>'#ffa608', 2=>'#48e5c2', 3=>'#f25757', 4=>'#754668', 5=>'#f8ca00', 6=>'#ff70a6');
+ break;
+ case 'lively':
+ $default_colors = array(0=>'#e9090d', 1=>'#0417e3', 2=>'#00ff08', 3=>'#fff703', 4=>'#ff9500', 5=>'#00fbff', 6=>'#a600ff');
+ break;
+ case 'mild':
+ $default_colors = array(0=>'#bce02e', 1=>'#e0642e', 2=>'#e0d62e', 3=>'#2e97e0', 4=>'#b02ee0', 5=>'#00fbff', 6=>'#5ce02e');
+ break;
+ case 'office':
+ $default_colors = array(0=>'#4f81bd', 1=>'#c0504d', 2=>'#9bbb59', 3=>'#8064a2', 4=>'#4bacc6', 5=>'#f79646', 6=>'#92a9cf');
+ break;
+ case 'pastel':
+ $default_colors = array(0=>'#799f0b', 1=>'#d7a125', 2=>'#9264be', 3=>'#188484', 4=>'#4cc68b', 5=>'#8a8823', 6=>'#6c99d2');
+ break;
+ case 'green':
+ $default_colors = array(0=>'#a8bc38', 1=>'#b8c948', 2=>'#c8d658', 3=>'#d8e468', 4=>'#e8e178', 5=>'#ffff00', 6=>'#e803b6');
+ break;
+ case 'blue':
+ $default_colors = array(0=>'#1e88e5', 1=>'#4f97ea', 2=>'#6ea6ee', 3=>'#89b5f3', 4=>'#a2c4f7', 5=>'#bad3fb', 6=>'#d1e3ff');
+ break;
+ case 'red':
+ $default_colors = array(0=>'#ff0000', 1=>'#dc0202', 2=>'#b90404', 3=>'#960606', 4=>'#730808', 5=>'#ffff00', 6=>'#e803b6');
+ break;
+ case 'multi':
+ $default_colors = array(0=>'#8c0000', 1=>'#f00800', 2=>'#ff8a82', 3=>'#f2c4c8', 4=>'#0b0387', 5=>'#0400fc', 6=>'#9794f2');
+ break;
+ }
+ }
+
+ return $default_colors;
+ }
+
+ public static function html2rgb($color){
+
+ if ($color[0] == '#')
+ $color = substr($color, 1);
+
+ if (strlen($color) == 6)
+ list($r, $g, $b) = array($color[0].$color[1],
+ $color[2].$color[3],
+ $color[4].$color[5]);
+ elseif (strlen($color) == 3)
+ list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
+ else
+ return false;
+
+ $r = hexdec($r);
+ $g = hexdec($g);
+ $b = hexdec($b);
+
+ return array($r, $g, $b);
+ }
+
+
+ // Napolnimo podatke za posamezen graf
+ public static function getDataSet($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ $dataArray = array();
+ $fullPercent = 0;
+ self::$numerusText = '';
+ $_answersOther = array();
+
+ $emptyData = true;
+
+ // napolnimo podatke za DROPDOWN, ki ima samo numeric variable
+ if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
+
+ $dataArray = array();
+
+ $i=0;
+ $N = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+
+ $avg_count = 0;
+ $avg_sum = 0;
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ $N = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $vAnswer['cnt'];
+
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+
+ $tempArray['key'] = $vkey;
+
+ // ce je znotraj nastavljenih mej
+ if( ($settings['max'] == '' || ($settings['open_up'] == 1 || (int)$vAnswer['text'] <= (int)$settings['max']))
+ && ($settings['min'] == '' || ($settings['open_down'] == 1 || (int)$vAnswer['text'] >= (int)$settings['min'])) ){
+
+ $avg_count += $vAnswer['cnt'];
+ $avg_sum += $vAnswer['cnt'] * (int)$vAnswer['text'];
+ }
+ else{
+ $N -= $vAnswer['cnt'];
+ }
+
+ // nastavimo da graf ni prazen
+ $emptyData = false;
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $vAnswer['text'] : $vAnswer['text_graf'];
+ $tempArray['variable'] = $text;
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+
+ //$N = ($settings['value_type'] == 0) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ $N = ((int)$N > 0) ? $N : 0;
+ $DataSet->SetNumerus($N);
+
+ // nastavimo POVPRECJE
+ $avg = ($avg_count > 0) ? $avg_sum / $avg_count : 0;
+ $DataSet->SetAverage(round($avg, 1));
+
+
+ // Sortiramo podatke - ce imamo izpis vsakega vnosa posebej sortiramo po freq, ce pa po skupinah pa po key
+ if($settings['type'] > 4){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['key'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+ elseif($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ $max = (int)$dataArray[count($dataArray,0)-1]['variable'];
+ $min = (int)$dataArray[0]['variable'];
+ $stIntervalov = ((int)$settings['interval'] == 0 ? 10 : (int)$settings['interval']);
+
+
+ // Ce imamo napredno napredne intervale
+ if($settings['limits']['advanced_settings'] == 1){
+ $limits = $settings['limits'];
+
+ $max = $limits['interval_'. ($stIntervalov-1) ]['max'];
+ $min = $limits['interval_0']['min'];
+ }
+ // Ce imamo osnovne intervale
+ else{
+ // Nastavimo custom zgornjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je max vnos vecji od nastavljenega max)
+ if($settings['max'] != '' /*&& ($settings['open_up'] == 0 || (int)$settings['max'] > $max)*/)
+ $max = (int)$settings['max'];
+ // Nastavimo custom spodnjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je min vnos manjsi od nastavljenega min)
+ if($settings['min'] != '' /*&& ($settings['open_down'] == 0 || (int)$settings['min'] < $min)*/)
+ $min = (int)$settings['min'];
+
+ $stIntervalov = ($stIntervalov == -1 ? $max-$min : $stIntervalov);
+ $part = ($max-$min) / $stIntervalov;
+ $part = ($part < 1) ? 1 : round($part);
+ }
+
+
+ // Poberemo podatke v posamezne tabele - po intervalih oz normalno
+ if($settings['type'] > 4){
+
+ // Ce imamo polodprt intrerval navzdol
+ if($settings['open_down'] == 1){
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] < $min){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $count;
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $valid;
+ $vrednostiKey[] = $lang['srv_chart_less'].' '.$min;
+ $vrednostiVariable[] = $lang['srv_chart_less'].' '.$min;
+ }
+
+ // loop cez intervale - default 10
+ for($interval=0; $interval<$stIntervalov; $interval++){
+
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // Ce imamo napredno napredne intervale (custom dolocene)
+ if($settings['limits']['advanced_settings'] == 1){
+ $maxVal = $limits['interval_'.$interval]['max'];
+ $minVal = $limits['interval_'.$interval]['min'];
+ }
+ // Ce imamo osnovne intervale (racunamo sproti)
+ else{
+ $maxVal = ($interval < ($stIntervalov-1) ? $min + (($interval+1) * $part) : $max);
+ $minVal = ($interval > 0 ? $min + ($interval * $part) + 1 : $min);
+ }
+
+ // prekinemo ce zaradi zaokrozevanja pride do min > max
+ if($minVal > $maxVal)
+ break;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] <= $maxVal && $dataArray[$i]['variable'] >= $minVal && $dataArray[$i]['field'] == 0){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $count;
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $valid;
+
+ // Ce imamo napredne intervale (custom dolocene labele)
+ if($settings['limits']['advanced_settings'] == 1 && $limits['interval_'.$interval]['label'] != ''){
+ $vrednostiKey[] = $limits['interval_'.$interval]['label'];
+ $vrednostiVariable[] = $limits['interval_'.$interval]['label'];
+ }
+ elseif($minVal == $maxVal){
+ $vrednostiKey[] = $minVal;
+ $vrednostiVariable[] = $minVal;
+ }
+ else{
+ $vrednostiKey[] = $minVal.'-'.$maxVal;
+ $vrednostiVariable[] = $minVal.'-'.$maxVal;
+ }
+ }
+
+ // Ce imamo polodprt intrerval navzgor
+ if($settings['open_up'] == 1){
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] > $max){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $count;
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $valid;
+ $vrednostiKey[] = $lang['srv_chart_more'].' '.$max;
+ $vrednostiVariable[] = $lang['srv_chart_more'].' '.$max;
+ }
+ }
+
+ else{
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ if($dataArray[$i]['field'] == 0){
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $dataArray[$i]['percent'];
+ $vrednostiValid[] = $dataArray[$i]['valid'];
+ }
+ else{
+ $vrednosti[] = 0;
+ $vrednostiPercent[] = 0;
+ $vrednostiValid[] = 0;
+ }
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti');
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti');
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $var_title[0] = ($var_title[0] == '' ? 'Vrednosti' : $var_title[0]);
+ $DataSet->SetSerieName($var_title[0],'Vrednosti');
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+
+ if($settings['value_type'] > 0){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+ }
+
+ // napolnimo podatke za RADIO, DROPDOWN
+ elseif($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3){
+
+ $dataArray = array();
+
+ $i=0;
+ $N = 0;
+ $N_average = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ // Ce skrivamo prazne vrednosti
+ if($settings['hideEmptyVar'] == 1){
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $key => $valid) {
+ if ((int)$valid['cnt'] == 0) {
+ unset (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]);
+ }
+ }
+ }
+
+ if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $vAnswer['cnt'];
+
+ // nastavimo da graf ni prazen
+ if($vAnswer['cnt'] > 0)
+ $emptyData = false;
+
+ $N = ($settings['value_type'] == 0) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+
+ $tempArray['key'] = $vkey;
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $vAnswer['text'] : $vAnswer['text_graf'];
+ $tempArray['variable'] = $text;
+
+ $fullPercent += $tempArray['percent'];
+
+ // ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
+ if($_valid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 8))
+ $dataArray[] = $tempArray;
+
+ // Ce je ordinalen racunamo povprecje
+ if($spremenljivka['skala'] != 1){
+ $xi = (int)$vkey;
+ $fi = (int)$vAnswer['cnt'];
+
+ $sum_xi_fi += $xi * $fi;
+ $N_average += $fi;
+ }
+ }
+ }
+ }
+ }
+ // polnimo array za drugo
+ else{
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+
+ $N = ($settings['value_type'] == 0) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+
+ $fullPercent += $tempArray['percent'];
+
+ // ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
+ if($_invalid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 8))
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ $N = ((int)$N > 0) ? $N : 0;
+ $DataSet->SetNumerus($N);
+ self::$numerusText = ($settings['value_type'] == 0) ? ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')' : '';
+
+ //nastavimo povprecje ce je ordinalen
+ if($spremenljivka['skala'] != 1){
+ $avg = ($N_average > 0) ? $sum_xi_fi / $N_average : 0;
+ $DataSet->SetAverage(round($avg, 1));
+ }
+
+ // Sortiramo podatke ce je potrebno
+ if($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $dataArray[$i]['percent'];
+ $vrednostiValid[] = $dataArray[$i]['valid'];
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+
+
+ if(is_countable($vrednosti) && count($vrednosti) > 0){
+ if($settings['type'] < 3 || $settings['type'] == 8){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Frekvence','Vrednosti');
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+ }
+ // Graf povprecja
+ elseif($settings['type'] == 9){
+ $DataSet->AddPoint(round($avg, 1),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Frekvence','Vrednosti');
+ }
+ else{
+ for($i=0; $i<count($vrednosti); $i++){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti[$i],'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent[$i],'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid[$i],'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ $DataSet->SetSerieName($vrednostiVariable[$i],'Vrednosti_'.$i);
+ }
+
+ $DataSet->AddPoint('','Variable');
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->SetAbsciseLabelSerie('Variable');
+
+ if($settings['value_type'] != 1 && $settings['type'] != 9){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+ }
+
+ // napolnimo podatke za CHECKBOX
+ elseif($spremenljivka['tip'] == 2){
+ $dataArray = array();
+ $fullPercent = 0;
+
+ $i=0;
+ $nValid = 0;
+ $nAll = 0;
+ $nNavedbe = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ if ($variable['text'] != true && $variable['other'] != true){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $vAnswer = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
+
+ // nastavimo da graf ni prazen
+ if($tempArray['freq'] > 0)
+ $emptyData = false;
+
+ $nValid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > $nValid) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : $nValid;
+ $nAll = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+ $nNavedbe += (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
+
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $fullPercent += $tempArray['percent'];
+
+ // ce imamo vklopljeno da izpuscamo 0 spustimo nicelne vrednosti
+ if(($_valid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 7))
+ && ((int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] > 0) || $settings['hideEmptyVar'] == 0)
+ $dataArray[] = $tempArray;
+ }
+ // polnimo array za drugo
+ else{
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = (int)$iAnswer['cnt'];
+
+ //$nValid = SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'];
+ $nAll = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+ $nNavedbe += (int)$iAnswer['cnt'];
+
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+
+ $fullPercent += $tempArray['percent'];
+
+ // ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
+ if($_invalid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 7))
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ if($settings['base'] == 0){
+
+ //nastavimo numerus, ki se izpise pod legendo
+ if($settings['value_type'] == 0){
+ $numerus = $nValid;
+ self::$numerusText = ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')';
+ }
+ else
+ $numerus = $nAll;
+
+ $numerus = ((int)$numerus > 0) ? $numerus : 0;
+ $DataSet->SetNumerus($numerus);
+
+ //$valid = ($fullPercent * $dataArray[$i]['percent'] > 0) ? 100 / $fullPercent * $dataArray[$i]['percent'] : 0;
+ $valid = ($nValid > 0 ) ? $dataArray[$i]['freq'] * 100 / $nValid : 0;
+
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $dataArray[$i]['percent'];
+ $vrednostiValid[] = $valid;
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+
+
+ }
+ else{
+ //nastavimo numerus, ki se izpise pod legendo
+ $nNavedbe = ((int)$nNavedbe > 0) ? $nNavedbe : 0;
+ $DataSet->SetNumerus($nNavedbe);
+ self::$numerusText = ' ('.$lang['srv_analiza_opisne_arguments'].')';
+
+ $percent = ($fullPercent * $dataArray[$i]['percent'] > 0) ? 100 / $fullPercent * $dataArray[$i]['percent'] : 0;
+
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $percent;
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['type'] < 3 || $settings['type'] == 5 || $settings['type'] == 6 || $settings['type'] == 7){
+ if($settings['value_type'] == 1 || ($settings['value_type'] == 0 && $settings['base'] == 1)){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Frekvence','Vrednosti');
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+ }
+ else{
+ for($i=0; $i<count($vrednosti); $i++){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti[$i],'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent[$i],'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid[$i],'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ $DataSet->SetSerieName($vrednostiVariable[$i],'Vrednosti_'.$i);
+ }
+
+ $DataSet->AddPoint('','Variable');
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->SetAbsciseLabelSerie('Variable');
+
+ if(($settings['value_type'] == 0 && $settings['base'] == 0) || $settings['value_type'] == 2){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+ }
+
+ // napolnimo podatke za DVOJNI MULTIGRID
+ elseif($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 3){
+ $DataSet = new pData;
+ $dataArray = array();
+ $fullPercent = array();
+
+ $gridCount=0;
+ $sql = sisplet_query("SELECT count(*) AS count FROM srv_grid WHERE spr_id='$spid'");
+ $row = mysqli_fetch_array($sql);
+ $_variables_count = $row['count'];
+
+ $nArray = array();
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ // Prva podtabela
+ if($grid['part'] == 1){
+
+ # dodamo dodatne vrstice z albelami grida
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ if ($variable['text'] != true && $variable['other'] != true){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ $xi = $key;
+ $fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ }
+ }
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $nArray[] = $N;
+
+ $tempArray = array();
+
+ // nastavimo da graf ni prazen
+ if($N > 0)
+ $emptyData = false;
+
+ $avg = $avg < 1 ? 1 : $avg;
+ $tempArray['freq'] = $avg;
+ $tempArray['percent'] = $avg;
+ $tempArray['valid'] = $avg;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $dataArray[] = $tempArray;
+ }
+
+ // polnimo array za drugo
+ if ($variable['text'] == true || $variable['other'] == true){
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+ $tempArray['grid'] = $grid['variables'][0]['naslov'];
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $gridCount++;
+ }
+
+ else{
+ # dodamo dodatne vrstice z albelami grida
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ if ($variable['text'] != true && $variable['other'] != true){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ $xi = $key;
+ $fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ }
+ }
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $nArray[] = $N;
+
+ $tempArray = array();
+
+ // nastavimo da graf ni prazen
+ if($N > 0)
+ $emptyData = false;
+
+ $avg = $avg < 1 ? 1 : $avg;
+ $tempArray['freq'] = $avg;
+ $tempArray['percent'] = $avg;
+ $tempArray['valid'] = $avg;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $dataArray2[] = $tempArray;
+ }
+
+ // polnimo array za drugo
+ if ($variable['text'] == true || $variable['other'] == true){
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+ $tempArray['grid'] = $grid['variables'][0]['naslov'];
+
+ $dataArray2[] = $tempArray;
+ }
+ }
+ }
+ }
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if(count($spremenljivka['grids']) == 0)
+ return -1;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ rsort($nArray);
+ $numerus = ((int)$nArray[0] > 0) ? $nArray[0] : 0;
+ $DataSet->SetNumerus($numerus);
+ self::$numerusText = ($settings['value_type'] == 0) ? ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')' : '';
+
+ // Poberemo podatke v posamezne tabele
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $dataArray[$i]['percent'];
+ $vrednostiValid[] = $dataArray[$i]['valid'];
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+
+ for($i=0; $i<count($dataArray2,0); $i++){
+
+ $vrednosti2[] = $dataArray2[$i]['freq'];
+ $vrednostiPercent2[] = $dataArray2[$i]['percent'];
+ $vrednostiValid2[] = $dataArray2[$i]['valid'];
+
+ $vrednostiKey2[] = $dataArray2[$i]['key'];
+ $vrednostiVariable2[] = $dataArray2[$i]['variable'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ $DataSet->AddPoint($vrednosti2,'Vrednosti2');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti');
+ $DataSet->AddPoint($vrednostiPercent2,'Vrednosti2');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti');
+ $DataSet->AddPoint($vrednostiValid2,'Vrednosti2');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else{
+ $DataSet->AddPoint(array(0),'Vrednosti');
+ $DataSet->AddPoint(array(0),'Vrednosti2');
+ }
+
+ $title1 = ($spremenljivka['double'][1]['subtitle'] != '') ? $spremenljivka['double'][1]['subtitle'] : 'Tabela 1';
+ $title2 = ($spremenljivka['double'][2]['subtitle'] != '') ? $spremenljivka['double'][2]['subtitle'] : 'Tabela 2';
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName($title1,'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti2');
+ $DataSet->SetSerieName($title2,'Vrednosti2');
+
+
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ // napolnimo podatke za MULTIGRID
+ elseif($spremenljivka['tip'] == 6){
+ $DataSet = new pData;
+ $dataArray = array();
+ $fullPercent = array();
+
+ $gridCount=0;
+
+
+ // Prefiltriramo other, ki so manjkajoci
+ $_invalidAnswers = SurveyAnalysis :: getInvalidAnswers (2);
+ $noOthers = (isset($_invalidAnswers['-99'])) ? ' AND other!=-99' : '';
+ $noOthers .= (isset($_invalidAnswers['-98'])) ? ' AND other!=-98' : '';
+ $noOthers .= (isset($_invalidAnswers['-97'])) ? ' AND other!=-97' : '';
+
+ // Napolnimo vse gride, ki jih obravnavamo
+ $stolpci = array();
+ $sqlG = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$spid' ".$noOthers." ");
+ while($rowG = mysqli_fetch_array($sqlG)){
+ $stolpci[] = $rowG;
+ }
+
+ $_variables_count = count($stolpci);
+
+
+ # odstranimo še možne nepotrebne zapise za multigride
+ if($settings['hideEmptyVar'] == 1){
+ $allGrids = count($spremenljivka['grids']);
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $cntValidInGrid = 0;
+ # dodamo dodatne vrstice z labelami grida
+ if (count($grid['variables']) > 0 ) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ foreach(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $valid){
+ $cntValidInGrid+= (int)$valid['cnt'];
+ }
+ }
+ }
+ # preverjamo ali lahko prikazujemo podkategorije
+ if((int)$cntValidInGrid > 0) {
+ $gidsCanShow[$gid] = true;
+ } else {
+ $gidsCanShow[$gid] = false;
+ }
+ }
+ }
+ }
+
+
+ $nArray = array();
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ // Kontrola ce ne prikazujemo praznih variabel
+ if ((!is_array($gidsCanShow) && !isset($gidsCanShow[$gid]))
+ || (is_array($gidsCanShow) && isset($gidsCanShow[$gid]) && $gidsCanShow[$gid]== true)){
+
+ # dodamo dodatne vrstice z albelami grida
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ if ($variable['text'] != true && $variable['other'] != true){
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ // Ce izrisujemo graf za povprecja
+ if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ $xi = $key;
+ $fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ }
+ }
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $nArray[] = $N;
+
+ $tempArray = array();
+
+ // nastavimo da graf ni prazen
+ if($N > 0)
+ $emptyData = false;
+
+ $avg = $avg < 1 ? 1 : $avg;
+ $tempArray['freq'] = $avg;
+ $tempArray['percent'] = $avg;
+ $tempArray['valid'] = $avg;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ // dodamo vrednosti na desni ce imamo vklopljen diferencial
+ if($spremenljivka['enota'] == 1){
+ $sqlV = sisplet_query("SELECT naslov2 FROM srv_vrednost WHERE spr_id='$spid' AND id='$variable[vr_id]'");
+ $rowV = mysqli_fetch_array($sqlV);
+ $tempArray['variable2'] = strip_tags($rowV['naslov2']);
+ }
+
+ $dataArray[] = $tempArray;
+ }
+
+ // izpisujemo navaden graf (ne povprecij)
+ else{
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ foreach ($stolpci as $key => $stolpec) {
+
+ $vkey = $stolpec['vrstni_red'];
+
+ // imamo OTHER grid (ne vem, zavrnil...)
+ if($stolpec['other'] != 0){
+
+ $vAnswer = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$stolpec['other']];
+
+ if($vAnswer != null){
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+ if($settings['value_type'] == 0){
+ $nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ else{
+ $nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+ }
+
+ // nastavimo da graf ni prazen
+ if($vAnswer['cnt'] > 0)
+ $emptyData = false;
+
+ $tempArray['freq'] = $vAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+ }
+
+ // ce missling (-99, -98...) nima nobene vrednosti potem ga ni v tabeli - zato ga rocno napolnimo
+ else{
+ $tempArray = array();
+
+ $nArray[] = 0;
+
+ $tempArray['freq'] = 0;
+ $tempArray['percent'] = 0;
+ $tempArray['valid'] = 0;
+ }
+
+ $tempArray['key'] = $vkey;
+
+ $text = $stolpec['other'].' '.$stolpec['naslov'];
+ $tempArray['variable'] = $text;
+
+ $textGrid = $spremenljivka['edit_graf'] == 0 ? $grid['variables'][0]['naslov'] : $grid['variables'][0]['naslov_graf'];
+ $tempArray['grid'] = $textGrid;
+
+ $dataArray[] = $tempArray;
+
+ $fullPercent[$gridCount] += $tempArray['percent'];
+ }
+
+ // imamo NAVADEN GRID
+ else{
+ $vAnswer = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$vkey];
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ // Za sortiranje po povprecju
+ $sum_xi_fi=0;
+ $N = 0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ $xi = $key;
+ $fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ }
+ }
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $avg = $avg < 1 ? 1 : $avg;
+
+ $tempArray = array();
+
+ if($settings['value_type'] == 0){
+ $nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ else{
+ $nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+ }
+
+ // nastavimo da graf ni prazen
+ if($vAnswer['cnt'] > 0)
+ $emptyData = false;
+
+ $tempArray['avg'] = $avg;
+ $tempArray['freq'] = $vAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+
+ $tempArray['key'] = $vkey;
+
+ $text = ($spremenljivka['edit_graf'] == 0) ? $vAnswer['text'] : $vAnswer['text_graf'];
+ $tempArray['variable'] = ($text == '') ? $vkey : $text;
+
+ $textGrid = $spremenljivka['edit_graf'] == 0 ? $grid['variables'][0]['naslov'] : $grid['variables'][0]['naslov_graf'];
+ $tempArray['grid'] = $textGrid;
+
+ // dodamo vrednosti na desni ce imamo vklopljen diferencial
+ if($spremenljivka['enota'] == 1){
+ $sqlV = sisplet_query("SELECT naslov2 FROM srv_vrednost WHERE spr_id='$spid' AND id='$variable[vr_id]'");
+ $rowV = mysqli_fetch_array($sqlV);
+ $tempArray['variable2'] = strip_tags($rowV['naslov2']);
+ }
+
+ $dataArray[] = $tempArray;
+
+ $fullPercent[$gridCount] += $tempArray['percent'];
+ }
+ }
+ }
+ }
+ }
+
+ // polnimo array za drugo
+ if ($variable['text'] == true || $variable['other'] == true){
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+ $tempArray['grid'] = $grid['variables'][0]['naslov'];
+
+ $dataArray[] = $tempArray;
+
+ $fullPercent[$gridCount] += $tempArray['percent'];
+ }
+ }
+ }
+
+ $gridCount++;
+ }
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if(count($spremenljivka['grids']) == 0)
+ return -1;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ rsort($nArray);
+ $numerus = ((int)$nArray[0] > 0) ? $nArray[0] : 0;
+ $DataSet->SetNumerus($numerus);
+ self::$numerusText = ($settings['value_type'] == 0) ? ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')' : '';
+
+ // Ce prikazujemo POVPRECJA napolnimo podatke samo na koncu
+ if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $dataArray[$i]['percent'];
+ $vrednostiValid[] = $dataArray[$i]['valid'];
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+
+ // se vrednosti na desni pri sem. diferencialu
+ if($spremenljivka['enota'] == 1)
+ $vrednostiVariable2[] = $dataArray[$i]['variable2'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Povprečja','Vrednosti');
+
+
+ // Pri povprecjih vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ // se vrednosti na desni pri sem. diferencialu
+ if($spremenljivka['enota'] == 1){
+ $DataSet->AddPoint($vrednostiVariable2,"Variable2");
+ $DataSet->SetRightLabelSerie("Variable2");
+ }
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ // Prikazujemo navadne podatke
+ else{
+
+ // Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
+ if($settings['rotate'] != 1){
+
+ // Sortiramo podaatke ce je potrebno - Po kategorijah
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sort po povprecjih
+ elseif($settings['sort'] == 2){
+
+ $tmp = Array();
+
+ // preberemo povprecje iz vsake prve vrednosti vrstice
+ for($j=0; $j<$gridCount; $j++){
+ $offset = $j*$_variables_count;
+ $tmp[] = $dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sort po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsake vrstice
+ for($j=0; $j<$gridCount; $j++){
+ $offset = $j*$_variables_count;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+
+ for($i=0; $i<$_variables_count; $i++){
+
+ unset($vrednosti);
+ unset($vrednostiPercent);
+ unset($vrednostiValid);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+ unset($vrednostiGrid);
+ unset($vrednostiVariable2);
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$gridCount; $j++){
+
+ // ce sortiramo uporabimo sortirane kljuce
+ if($settings['sort'] == 1)
+ $offset = $sorted_keys[$i] + ($j*$_variables_count);
+
+ // sort po povprecjih
+ elseif($settings['sort'] == 2)
+ $offset = ($sorted_keys[$j]*$_variables_count) + $i;
+
+ // sort po prvi kategoriji
+ elseif($settings['sort'] == 3)
+ $offset = ($sorted_keys[$j]*$_variables_count) + $i;
+
+ else
+ $offset = $i + ($j*$_variables_count);
+
+
+ $vrednosti[] = $dataArray[$offset]['freq'];
+ $vrednostiPercent[] = $dataArray[$offset]['percent'];
+ $vrednostiValid[] = $dataArray[$offset]['valid'];
+
+ $vrednostiKey[] = $dataArray[$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$offset]['variable'];
+ $vrednostiGrid[] = $dataArray[$offset]['grid'];
+
+ // se vrednosti na desni pri sem. diferencialu
+ if($spremenljivka['enota'] == 1)
+ $vrednostiVariable2[] = $dataArray[$offset]['variable2'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ $DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti_'.$i);
+ }
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiGrid,"Variable");
+
+ // se vrednosti na desni pri sem. diferencialu
+ if($spremenljivka['enota'] == 1){
+ $DataSet->AddPoint($vrednostiVariable2,"Variable2");
+ $DataSet->SetRightLabelSerie("Variable2");
+ }
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ // Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
+ else{
+ // prej moramo napolniti imena serij (variabel)
+ for($i=0; $i<$gridCount; $i++){
+ $vrednostiGrid[] = $dataArray[$i*$_variables_count]['grid'];
+ }
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$gridCount; $j++){
+ $offset = $j*$_variables_count;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sort po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsake vrstice
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+
+ for($i=0; $i<$gridCount; $i++){
+
+ unset($vrednosti);
+ unset($vrednostiPercent);
+ unset($vrednostiValid);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+ unset($vrednostiVariable2);
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$_variables_count; $j++){
+
+ // ce sortiramo uporabimo sortirane kljuce
+ if($settings['sort'] == 1)
+ $offset = ($sorted_keys[$i]*$_variables_count) + $j;
+
+ // sort po prvi kategoriji
+ elseif($settings['sort'] == 3)
+ $offset = $sorted_keys[$j] + ($i*$_variables_count);
+
+ else
+ $offset = ($i*$_variables_count) + $j;
+
+
+ $vrednosti[] = $dataArray[$offset]['freq'];
+ $vrednostiPercent[] = $dataArray[$offset]['percent'];
+ $vrednostiValid[] = $dataArray[$offset]['valid'];
+
+ $vrednostiKey[] = $dataArray[$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$offset]['variable'];
+
+ // se vrednosti na desni pri sem. diferencialu
+ if($spremenljivka['enota'] == 1)
+ $vrednostiVariable2[] = $dataArray[$offset]['variable2'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ if($settings['sort'] == 1)
+ $DataSet->SetSerieName($vrednostiGrid[$sorted_keys[$i]],'Vrednosti_'.$i);
+ else
+ $DataSet->SetSerieName($vrednostiGrid[$i],'Vrednosti_'.$i);
+ }
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+
+ // se vrednosti na desni pri sem. diferencialu
+ if($spremenljivka['enota'] == 1){
+ $DataSet->AddPoint($vrednostiVariable2,"Variable2");
+ $DataSet->SetRightLabelSerie("Variable2");
+ }
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+ }
+
+
+ if( $settings['value_type'] != 1 && $settings['type'] != 0 && $settings['type'] != 6 ){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+ }
+
+ // napolnimo podatke za NUMBER
+ elseif($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22){
+ $dataArray = array();
+
+ $has_decimal = false;
+
+ $i=0;
+ $N=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+ $field = 0;
+
+ $avg_count = 0;
+ $avg_sum = 0;
+ $avg_count2 = 0;
+ $avg_sum2 = 0;
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+ $var_title[] = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($spremenljivka['tip'] == 22 || (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21))))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ if($field == 0)
+ $N = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+
+ foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $vAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+
+ $tempArray['key'] = $vkey;
+
+ if(floor($vkey) != $vkey)
+ $has_decimal = true;
+
+ // racunamo povprecje (za prvo variablo)
+ if($field == 0){
+
+ // ce je znotraj nastavljenih mej
+ if( ($settings['max'] == '' || ($settings['open_up'] == 1 || (int)$vAnswer['text'] <= (int)$settings['max']))
+ && ($settings['min'] == '' || ($settings['open_down'] == 1 || (int)$vAnswer['text'] >= (int)$settings['min'])) ){
+
+ $avg_count += $vAnswer['cnt'];
+ $avg_sum += $vAnswer['cnt'] * (int)$vAnswer['text'];
+ }
+ else{
+ $N--;
+ }
+ }
+ // racunamo povprecje (samo za drugo variablo)
+ if($field == 1){
+
+ // ce je znotraj nastavljenih mej
+ if( ($settings['max'] == '' || ($settings['open_up'] == 1 || (int)$vAnswer['text'] <= (int)$settings['max']))
+ && ($settings['min'] == '' || ($settings['open_down'] == 1 || (int)$vAnswer['text'] >= (int)$settings['min'])) ){
+
+ $avg_count2 += $vAnswer['cnt'];
+ $avg_sum2 += $vAnswer['cnt'] * (int)$vAnswer['text'];
+ }
+ else{
+ $N--;
+ }
+ }
+
+ // nastavimo da graf ni prazen
+ $emptyData = false;
+
+ $text = $vAnswer['text'];
+ $tempArray['variable'] = $text;
+
+ $tempArray['field'] = $field;
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+ }
+ $field++;
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ //$N = ($settings['value_type'] == 2) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+
+ // nastavimo NUMERUS, ki se izpise pod legendo
+ $N = ((int)$N > 0) ? $N : 0;
+ $DataSet->SetNumerus($N);
+
+ // nastavimo POVPRECJE
+ $avg = ($avg_count > 0) ? $avg_sum / $avg_count : 0;
+ $DataSet->SetAverage(round($avg, 1));
+
+ // Povprecje za 2. variablo (rabimo pri grafu povprecja)
+ $avg2 = ($avg_count2 > 0) ? $avg_sum2 / $avg_count2 : 0;
+
+ // Sortiramo podatke - ce imamo izpis vsakega vnosa posebej sortiramo po freq, ce pa po skupinah pa po key
+ if($settings['type'] <= 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['key'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+ elseif($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ $max = (double)$dataArray[count($dataArray,0)-1]['variable'];
+ $min = (double)$dataArray[0]['variable'];
+ $stIntervalov = ((int)$settings['interval'] == 0 ? 10 : (int)$settings['interval']);
+
+
+ // Ce imamo napredno napredne intervale
+ if($settings['limits']['advanced_settings'] == 1){
+ $limits = $settings['limits'];
+
+ $max = $limits['interval_'. ($stIntervalov-1) ]['max'];
+ $min = $limits['interval_0']['min'];
+ }
+ // Ce imamo osnovne intervale
+ else{
+ // Nastavimo custom zgornjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je max vnos vecji od nastavljenega max)
+ if($settings['max'] != '' /*&& ($settings['open_up'] == 0 || (int)$settings['max'] > $max)*/)
+ $max = (double)$settings['max'];
+ // Nastavimo custom spodnjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je min vnos manjsi od nastavljenega min)
+ if($settings['min'] != '' /*&& ($settings['open_down'] == 0 || (int)$settings['min'] < $min)*/)
+ $min = (double)$settings['min'];
+
+
+ $stIntervalov = ($stIntervalov == -1 ? $max-$min : $stIntervalov);
+ $part = ($max-$min) / $stIntervalov;
+
+ if(!$has_decimal)
+ $part = ($part < 1) ? 1 : round($part);
+ }
+
+ // Poberemo podatke v posamezne tabele - po intervalih oz normalno
+ if($settings['type'] <= 2){
+
+ // Ce imamo polodprt intrerval navzdol
+ if($settings['open_down'] == 1){
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] < $min && $dataArray[$i]['field'] == 0){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $count;
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $valid;
+ $vrednostiKey[] = $lang['srv_chart_less'].' '.$min;
+ $vrednostiVariable[] = $lang['srv_chart_less'].' '.$min;
+ }
+
+ // loop cez intervale - default 10
+ for($interval=0; $interval<$stIntervalov; $interval++){
+
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // Ce imamo napredno napredne intervale (custom dolocene)
+ if($settings['limits']['advanced_settings'] == 1){
+ $maxVal = $limits['interval_'.$interval]['max'];
+ $minVal = $limits['interval_'.$interval]['min'];
+ }
+ // Ce imamo osnovne intervale (racunamo sproti)
+ else{
+ // Ce imamo decimalke
+ if($has_decimal){
+ $maxVal = ($interval < ($stIntervalov-1) ? $min-0.01 + (($interval+1) * $part) : $max);
+ $minVal = ($interval > 0 ? $min + ($interval * $part) : $min);
+ }
+ else{
+ $maxVal = ($interval < ($stIntervalov-1) ? $min + (($interval+1) * $part) : $max);
+ $minVal = ($interval > 0 ? $min + ($interval * $part) + 1 : $min);
+ }
+ }
+
+ // prekinemo ce zaradi zaokrozevanja pride do min > max
+ if($minVal > $maxVal)
+ break;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] <= $maxVal && $dataArray[$i]['variable'] >= $minVal && $dataArray[$i]['field'] == 0){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $count;
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $valid;
+
+ // Ce imamo napredne intervale (custom dolocene labele)
+ if($settings['limits']['advanced_settings'] == 1 && $limits['interval_'.$interval]['label'] != ''){
+ $vrednostiKey[] = $limits['interval_'.$interval]['label'];
+ $vrednostiVariable[] = $limits['interval_'.$interval]['label'];
+ }
+ elseif($minVal == $maxVal){
+ $vrednostiKey[] = $minVal;
+ $vrednostiVariable[] = $minVal;
+ }
+ else{
+ $vrednostiKey[] = $minVal.'-'.$maxVal;
+ $vrednostiVariable[] = $minVal.'-'.$maxVal;
+ }
+ }
+
+ // Ce imamo polodprt intrerval navzgor
+ if($settings['open_up'] == 1){
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] > $max && $dataArray[$i]['field'] == 0){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $count;
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $valid;
+ $vrednostiKey[] = $lang['srv_chart_more'].' '.$max;
+ $vrednostiVariable[] = $lang['srv_chart_more'].' '.$max;
+ }
+
+ //ponovimo ce imamo 2 polja
+ if($field == 2){
+
+ // Ce imamo polodprt intrerval navzdol
+ if($settings['open_down'] == 1){
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] < $min && $dataArray[$i]['field'] == 1){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti2[] = $count;
+ $vrednostiPercent2[] = $percent;
+ $vrednostiValid2[] = $valid;
+ }
+
+ // loop cez intervale - default 10
+ for($interval=0; $interval<$stIntervalov; $interval++){
+
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // Ce imamo napredno napredne intervale (custom dolocene)
+ if($settings['limits']['advanced_settings'] == 1){
+ $maxVal = $limits['interval_'.$interval]['max'];
+ $minVal = $limits['interval_'.$interval]['min'];
+ }
+ // Ce imamo osnovne intervale (racunamo sproti)
+ else{
+ // Ce imamo decimalke
+ if($has_decimal){
+ $maxVal = ($interval < ($stIntervalov-1) ? $min-0.01 + (($interval+1) * $part) : $max);
+ $minVal = ($interval > 0 ? $min + ($interval * $part) : $min);
+ }
+ else{
+ $maxVal = ($interval < ($stIntervalov-1) ? $min + (($interval+1) * $part) : $max);
+ $minVal = ($interval > 0 ? $min + ($interval * $part) + 1 : $min);
+ }
+ }
+
+ // prekinemo ce zaradi zaokrozevanja pride do min > max
+ if($minVal > $maxVal)
+ break;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] <= $maxVal && $dataArray[$i]['variable'] >= $minVal && $dataArray[$i]['field'] == 1){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti2[] = $count;
+ $vrednostiPercent2[] = $percent;
+ $vrednostiValid2[] = $valid;
+ }
+
+ // Ce imamo polodprt intrerval navzgor
+ if($settings['open_up'] == 1){
+ $count = 0;
+ $percent = 0;
+ $valid = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i]['variable'] > $max && $dataArray[$i]['field'] == 1){
+ $count += $dataArray[$i]['freq'];
+ $percent += $dataArray[$i]['percent'];
+ $valid += $dataArray[$i]['valid'];
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti2[] = $count;
+ $vrednostiPercent2[] = $percent;
+ $vrednostiValid2[] = $valid;
+ }
+ }
+ }
+
+ else{
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ if($dataArray[$i]['field'] == 0){
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiPercent[] = $dataArray[$i]['percent'];
+ $vrednostiValid[] = $dataArray[$i]['valid'];
+ }
+ else{
+ $vrednosti[] = 0;
+ $vrednostiPercent[] = 0;
+ $vrednostiValid[] = 0;
+ }
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+
+ //ponovimo ce imamo 2 polja
+ if($field == 2){
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ if($dataArray[$i]['field'] == 1){
+ $vrednosti2[] = $dataArray[$i]['freq'];
+ $vrednostiPercent2[] = $dataArray[$i]['percent'];
+ $vrednostiValid2[] = $dataArray[$i]['valid'];
+ }
+ else{
+ $vrednosti2[] = 0;
+ $vrednostiPercent2[] = 0;
+ $vrednostiValid2[] = 0;
+ }
+ }
+ }
+ }
+
+ if(count($vrednosti) > 0){
+
+ // Graf povprecja
+ if($settings['type'] == 9){
+ $DataSet->AddPoint(round($avg, 1),'Vrednosti');
+ if($field == 2)
+ $DataSet->AddPoint(round($avg2, 1),'Vrednosti2');
+ }
+ else{
+ if($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ if($field == 2)
+ $DataSet->AddPoint($vrednosti2,'Vrednosti2');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti');
+ if($field == 2)
+ $DataSet->AddPoint($vrednostiPercent2,'Vrednosti2');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti');
+ if($field == 2)
+ $DataSet->AddPoint($vrednostiValid2,'Vrednosti2');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $var_title[0] = ($var_title[0] == '' ? 'Vrednosti' : $var_title[0]);
+ $DataSet->SetSerieName($var_title[0],'Vrednosti');
+
+ if($field == 2){
+ $DataSet->AddSerie('Vrednosti2');
+ $var_title[1] = ($var_title[1] == '' ? 'Vrednosti 2' : $var_title[1]);
+ $DataSet->SetSerieName($var_title[1],'Vrednosti2');
+ }
+
+ // Vedno izpisemo cela imena variabel
+ if($settings['type'] != 9)
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+
+ if($settings['value_type'] > 0){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+ }
+
+ // napolnimo podatke za DATUM
+ elseif($spremenljivka['tip'] == 8){
+ $dataArray = array();
+
+ $i=0;
+ $N=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+ $var_title[] = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ $N = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+
+ foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+
+ // ce je zunaj nastavljenih mej
+ if( ($settings['max'] != '' && ($settings['open_up'] == 0 && (int)$vAnswer['text'] > (int)$settings['max']))
+ || ($settings['min'] != '' && ($settings['open_down'] == 0 && (int)$vAnswer['text'] < (int)$settings['min'])) ){
+
+ $N--;
+ }
+
+ $date = strtotime($vkey);
+
+ $tempArray['day'] = date('j', $date);
+ $tempArray['month'] = date('n', $date);
+ $tempArray['year'] = date('Y', $date);
+
+ $tempArray['freq'] = $vAnswer['cnt'];
+
+ // nastavimo da graf ni prazen
+ $emptyData = false;
+
+ $text = $vAnswer['text'];
+ $tempArray['variable'] = $text;
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ //$N = ($settings['value_type'] == 2) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+
+ $date = strtotime($ikey);
+
+ $tempArray['day'] = date('j', $date);
+ $tempArray['month'] = date('n', $date);
+ $tempArray['year'] = date('Y', $date);
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+ $tempArray['variable'] = $iAnswer['text'];
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ if($settings['value_type'] == 0)
+ $key = 'day';
+ elseif($settings['value_type'] == 1)
+ $key = 'month';
+ else
+ $key = 'year';
+
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ $N = ((int)$N > 0) ? $N : 0;
+ $DataSet->SetNumerus($N);
+
+ // Sortiramo podatke - ce imamo izpis vsakega vnosa posebej sortiramo po datumu, ce pa po skupinah pa po key
+ if($settings['type'] < 3){
+ if($settings['value_type'] == 0){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['day'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+ elseif($settings['value_type'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['month'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+ elseif($settings['value_type'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['year'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+ }
+ elseif($settings['sort'] == 1 ){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2 ){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['freq'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ $max = (int)$dataArray[count($dataArray,0)-1][$key];
+ $min = (int)$dataArray[0][$key];
+ $stIntervalov = ((int)$settings['interval'] == 0 ? 10 : (int)$settings['interval']);
+
+
+ // Ce imamo napredno napredne intervale
+ if($settings['limits']['advanced_settings'] == 1){
+ $limits = $settings['limits'];
+
+ $max = $limits['interval_'. ($stIntervalov-1) ]['max'];
+ $min = $limits['interval_0']['min'];
+ }
+ // Ce imamo osnovne intervale
+ else{
+ // Nastavimo custom zgornjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je max vnos vecji od nastavljenega max)
+ if($settings['max'] != '' /*&& ($settings['open_up'] == 0 || (int)$settings['max'] > $max)*/)
+ $max = (int)$settings['max'];
+ // Nastavimo custom spodnjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je min vnos manjsi od nastavljenega min)
+ if($settings['min'] != '' /*&& ($settings['open_down'] == 0 || (int)$settings['min'] < $min)*/)
+ $min = (int)$settings['min'];
+
+ $stIntervalov = ($stIntervalov == -1 ? $max-$min : $stIntervalov);
+ $part = round( ($max-$min) / $stIntervalov );
+ }
+
+ // Poberemo podatke v posamezne tabele - po intervalih oz normalno
+ if($settings['type'] < 3){
+
+ // Ce imamo polodprt intrerval navzdol
+ if($settings['open_down'] == 1){
+
+ $value = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i][$key] < $min){
+ $value ++;
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $value;
+ $vrednostiVariable[] = $lang['srv_chart_less'].' '.$min;
+ }
+
+ // loop cez intervale - default 10
+ for($interval=0; $interval<$stIntervalov; $interval++){
+
+ $value = 0;
+
+ // Ce imamo napredno napredne intervale (custom dolocene)
+ if($settings['limits']['advanced_settings'] == 1){
+ $maxVal = $limits['interval_'.$interval]['max'];
+ $minVal = $limits['interval_'.$interval]['min'];
+ }
+ // Ce imamo osnovne intervale (racunamo sproti)
+ else{
+ $maxVal = ($interval < ($stIntervalov-1) ? $min + (($interval+1) * $part) : $max);
+ $minVal = ($interval > 0 ? $min + ($interval * $part) + 1 : $min);
+ }
+
+ // prekinemo ce zaradi zaokrozevanja pride do min > max
+ if($minVal > $maxVal)
+ break;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i][$key] <= $maxVal && $dataArray[$i][$key] >= $minVal){
+ $value ++;
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $value;
+
+ // Ce imamo napredne intervale (custom dolocene labele)
+ if($settings['limits']['advanced_settings'] == 1 && $limits['interval_'.$interval]['label'] != ''){
+ $vrednostiVariable[] = $limits['interval_'.$interval]['label'];
+ }
+ elseif($minVal == $maxVal){
+ $vrednostiVariable[] = $minVal;
+ }
+ else{
+ $vrednostiVariable[] = $minVal.'-'.$maxVal;
+ }
+ }
+
+ // Ce imamo polodprt intrerval navzgor
+ if($settings['open_up'] == 1){
+
+ $value = 0;
+
+ // loop cez vse podatke
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ // ce pripada intervalu
+ if($dataArray[$i][$key] > $max){
+ $value ++;
+ }
+ }
+
+ // vnesemo podatke za interval
+ $vrednosti[] = $value;
+ $vrednostiVariable[] = $lang['srv_chart_more'].' '.$max;
+ }
+ }
+
+ else{
+ for($i=0; $i<count($dataArray,0); $i++){
+
+ $vrednosti[] = $dataArray[$i]['freq'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+ }
+
+ if(count($vrednosti) > 0){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $var_title[0] = ($var_title[0] == '' ? 'Vrednosti' : $var_title[0]);
+ $DataSet->SetSerieName($var_title[0],'Vrednosti');
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ // napolnimo podatke za MULTICHECKBOX
+ elseif($spremenljivka['tip'] == 16){
+ $DataSet = new pData;
+ $dataArray = array();
+ $fullPercent = array();
+
+
+ # odstranimo še možne nepotrebne zapise
+ if($settings['hideEmptyVar'] == 1){
+ $allGrids = count($spremenljivka['grids']);
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $cntValidInGrid = 0;
+ # dodamo dodatne vrstice z labelami grida
+ if (count($grid['variables']) > 0 ) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ foreach(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $valid){
+ $cntValidInGrid+= (int)$valid['cnt'];
+ }
+ }
+ }
+ # preverjamo ali lahko prikazujemo podkategorije
+ if((int)$cntValidInGrid > 0) {
+ $gidsCanShow[$gid] = true;
+ } else {
+ $gidsCanShow[$gid] = false;
+ }
+ }
+ }
+ }
+
+
+ $gridCount=0;
+ $nValid = array();
+ $nAll = 0;
+ $nNavedbe = array();
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ // Kontrola ce ne prikazujemo praznih variabel
+ if ((!is_array($gidsCanShow) && !isset($gidsCanShow[$gid]))
+ || (is_array($gidsCanShow) && isset($gidsCanShow[$gid]) && $gidsCanShow[$gid]== true)){
+
+ # dodamo dodatne vrstice z albelami grida
+ $_variables_count=0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ if ($variable['text'] != true && $variable['other'] != true){
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $vAnswer = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $tempArray = array();
+
+ $nValid[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+ $nAll = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+ $nNavedbe[$gid] += SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
+
+ $tempArray['freq'] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_valid;
+
+ // nastavimo da graf ni prazen
+ if($vAnswer > 0)
+ $emptyData = false;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $textGrid = $spremenljivka['edit_graf'] == 0 ? $grid['naslov'] : $grid['naslov_graf'];
+ $tempArray['grid'] = $textGrid;
+
+ $dataArray[] = $tempArray;
+
+ $fullPercent[$gridCount] += $tempArray['percent'];
+ $fullPercentReverse[$_variables_count] += $tempArray['percent'];
+
+ $_variables_count++;
+ }
+
+ // polnimo array za drugo
+ if ($variable['text'] == true || $variable['other'] == true){
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $tempArray = array();
+
+ $tempArray['freq'] = $iAnswer['cnt'];
+ $tempArray['percent'] = $_percent;
+ $tempArray['valid'] = $_invalid;
+
+ $tempArray['key'] = $ikey;
+ $tempArray['variable'] = $iAnswer['text'];
+ $tempArray['grid'] = $grid['naslov'];
+
+ $fullPercent[$gridCount] += $tempArray['percent'];
+ $fullPercentReverse[$_variables_count] += $tempArray['percent'];
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $gridCount++;
+ }
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if(count($spremenljivka['grids']) == 0)
+ return -1;
+
+
+ // Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
+ if($settings['rotate'] != 1){
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sort po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsake vrstice
+ for($j=0; $j<$gridCount; $j++){
+ $offset = $j*$_variables_count;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+
+ // Prikazujemo podatke
+ for($i=0; $i<$_variables_count; $i++){
+
+ unset($vrednosti);
+ unset($vrednostiPercent);
+ unset($vrednostiValid);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+ unset($vrednostiGrid);
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$gridCount; $j++){
+
+ // ce sortiramo uporabimo sortirane kljuce
+ if($settings['sort'] == 1)
+ $offset = $sorted_keys[$i] + ($j*$_variables_count);
+
+ // sort po prvi kategoriji
+ elseif($settings['sort'] == 3)
+ $offset = ($sorted_keys[$j]*$_variables_count) + $i;
+
+ else
+ $offset = $i + ($j*$_variables_count);
+
+
+ // Enote
+ if($settings['base'] != 1){
+ $vrednosti[] = $dataArray[$offset]['freq'];
+ $vrednostiPercent[] = $dataArray[$offset]['percent'];
+ $vrednostiValid[] = $dataArray[$offset]['valid'];
+
+ //nastavimo numerus, ki se izpise pod legendo
+ if($settings['value_type'] == 0){
+ rsort($nValid);
+ $numerus = ((int)$nValid[0] > 0) ? $nValid[0] : 0;
+ $DataSet->SetNumerus($numerus);
+ self::$numerusText = ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')';
+ }
+ else
+ $numerus = ((int)$nAll > 0) ? $nAll : 0;
+
+ $DataSet->SetNumerus($numerus);
+ }
+ // Navedbe
+ else{
+ $percent = ($fullPercent[$j] * $dataArray[$offset]['percent'] > 0) ? 100 / $fullPercent[$j] * $dataArray[$offset]['percent'] : 0;
+
+ $vrednosti[] = $dataArray[$offset]['freq'];
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $percent;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ rsort($nNavedbe);
+ $numerus = ((int)$nNavedbe[0] > 0) ? $nNavedbe[0] : 0;
+ $DataSet->SetNumerus($numerus);
+ self::$numerusText = ' ('.$lang['srv_analiza_opisne_arguments'].')';
+ }
+
+ $vrednostiKey[] = $dataArray[$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$offset]['variable'];
+ $vrednostiGrid[] = $dataArray[$offset]['grid'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ $DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti_'.$i);
+ }
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiGrid,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ // Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
+ else{
+ // prej moramo napolniti imena serij (variabel)
+ for($i=0; $i<$gridCount; $i++){
+ $vrednostiGrid[] = $dataArray[$i*$_variables_count]['grid'];
+ }
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$gridCount; $j++){
+ $offset = $j*$_variables_count;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sort po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsake vrstice
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['valid'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+
+ for($i=0; $i<$gridCount; $i++){
+ unset($vrednosti);
+ unset($vrednostiPercent);
+ unset($vrednostiValid);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$_variables_count; $j++){
+
+ if($settings['sort'] == 1)
+ $offset = ($sorted_keys[$i]*$_variables_count) + $j;
+
+ // sort po prvi kategoriji
+ elseif($settings['sort'] == 3)
+ $offset = $sorted_keys[$j] + ($i*$_variables_count);
+
+ else
+ $offset = ($i*$_variables_count) + $j;
+
+ // Enote
+ if($settings['base'] != 1){
+ $vrednosti[] = $dataArray[$offset]['freq'];
+ $vrednostiPercent[] = $dataArray[$offset]['percent'];
+ $vrednostiValid[] = $dataArray[$offset]['valid'];
+
+ //nastavimo numerus, ki se izpise pod legendo
+ if($settings['value_type'] == 0){
+ rsort($nValid);
+ $numerus = ((int)$nValid[0] > 0) ? $nValid[0] : 0;
+ $DataSet->SetNumerus($numerus);
+ self::$numerusText = ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')';
+ }
+ else
+ $numerus = ((int)$nAll > 0) ? $nAll : 0;
+
+ $DataSet->SetNumerus($numerus);
+ }
+ // Navedbe
+ else{
+ $percent = ($fullPercentReverse[$j] * $dataArray[$offset]['percent'] > 0) ? 100 / $fullPercentReverse[$j] * $dataArray[$offset]['percent'] : 0;
+
+ $vrednosti[] = $dataArray[$offset]['freq'];
+ $vrednostiPercent[] = $percent;
+ $vrednostiValid[] = $percent;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ rsort($nNavedbe);
+ $numerus = ((int)$nNavedbe[0] > 0) ? $nNavedbe[0] : 0;
+ $DataSet->SetNumerus($numerus);
+ self::$numerusText = ' ('.$lang['srv_analiza_opisne_arguments'].')';
+ }
+
+ $vrednostiKey[] = $dataArray[$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$offset]['variable'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ if($settings['sort'] == 1)
+ $DataSet->SetSerieName($vrednostiGrid[$sorted_keys[$i]],'Vrednosti_'.$i);
+ else
+ $DataSet->SetSerieName($vrednostiGrid[$i],'Vrednosti_'.$i);
+ }
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ if($settings['value_type'] == 1 || $settings['value_type'] == 0){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+ }
+
+ // napolnimo podatke za VSOTO
+ elseif($spremenljivka['tip'] == 18){
+ $dataArray = array();
+
+ $i=0;
+ $numerus=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ # za povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ $min = null;
+ $max = null;
+ foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+
+ $fi = $vAnswer['cnt'];
+ $sum_xi_fi += $vkey * $fi ;
+ $N += $fi;
+ $min = $min != null ? min($min,$vkey) : $vkey;
+ $max = max($max,$vkey);
+ }
+
+ #povprečje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+
+ // nastavimo da graf ni prazen
+ if($avg > 0)
+ $emptyData = false;
+
+ $numerus = ($numerus > $N) ? $numerus : $N;
+
+ $tempArray = array();
+
+ $tempArray['avg'] = $avg;
+ $tempArray['max'] = $max;
+ $tempArray['min'] = $min;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ // ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
+ if($avg != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 0 && $settings['type'] != 5))
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ $numerus = ((int)$numerus > 0) ? $numerus : 0;
+ $DataSet->SetNumerus($numerus);
+
+ // Sortiramo podatke in jih razvrstimo po skupinah
+ if($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['avg'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['avg'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($i=0; $i<count($dataArray,0); $i++){
+ $vrednosti[] = $dataArray[$i]['avg'];
+ $vrednostiMax[] = $dataArray[$i]['max'];
+ $vrednostiMin[] = $dataArray[$i]['min'];
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+
+ if(is_countable($vrednosti) && count($vrednosti) > 0){
+ if($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiMax,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiMin,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Povprečja','Vrednosti');
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ if($settings['type'] != 2)
+ $DataSet->SetYAxisName($lang['srv_analiza_sums_average']);
+ }
+
+ // napolnimo podatke za RANKING
+ elseif($spremenljivka['tip'] == 17){
+ $dataArray = array();
+
+ $i=0;
+ $numerus=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ $rankingArray = array();
+ $_variables_count=0;
+
+ # za povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ $min = null;
+ $max = null;
+ foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+
+ $fi = $vAnswer['cnt'];
+ $sum_xi_fi += $vkey * $fi ;
+ $N += $fi;
+ $min = $min != null ? min($min,$vkey) : $vkey;
+ $max = max($max,$vkey);
+
+ $rankingArray[] = $vAnswer['cnt'];
+ $_variables_count++;
+ }
+
+ // nastavimo da graf ni prazen
+ if($N > 0)
+ $emptyData = false;
+
+ #povprečje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $avg = $avg < 1 ? 1 : $avg;
+
+ if($settings['type'] == 0){
+ $numerus = ($numerus > $N) ? $numerus : $N;
+ }
+ else{
+ $numerus = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
+ }
+
+ $tempArray = array();
+
+ $tempArray['cnt'] = $N;
+ $tempArray['avg'] = $avg;
+ $tempArray['max'] = $max;
+ $tempArray['min'] = $min;
+
+ $tempArray['rankings'] = $rankingArray;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $dataArray[] = $tempArray;
+ }
+ }
+ }
+
+ $i++;
+ }
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ $numerus = ((int)$numerus > 0) ? $numerus : 0;
+ $DataSet->SetNumerus($numerus);
+
+ // Sortiramo podatke in jih razvrstimo po skupinah
+ if($settings['sort'] == 1){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['avg'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
+ }
+ elseif($settings['sort'] == 2){
+ $tmp = Array();
+ foreach($dataArray as &$data)
+ $tmp[] = &$data['avg'];
+ array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
+ }
+
+ if($settings['type'] == 0){
+ // Poberemo podatke v posamezne tabele
+ for($i=0; $i<count($dataArray,0); $i++){
+ $vrednosti[] = $dataArray[$i]['avg'];
+ $vrednostiMax[] = $dataArray[$i]['max'];
+ $vrednostiMin[] = $dataArray[$i]['min'];
+
+ $vrednostiKey[] = $dataArray[$i]['key'];
+ $vrednostiVariable[] = $dataArray[$i]['variable'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednosti,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiMax,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiMin,'Vrednosti');
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Povprečja','Vrednosti');
+ }
+
+ //polnimo podatke po posameznih serijah
+ else{
+ // loop cez variable za posamezno serijo
+ for($i=0; $i<$_variables_count; $i++){
+
+ unset($vrednosti);
+ unset($vrednostiPercent);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ for($j=0; $j<count($dataArray,0); $j++){
+ $vrednosti[] = $dataArray[$j]['rankings'][$i];
+
+ if($dataArray[$j]['cnt'] > 0)
+ $percent = $dataArray[$j]['rankings'][$i] / $dataArray[$j]['cnt'] * 100;
+ else
+ $percent = 0;
+
+ $vrednostiPercent[] = $percent;
+
+ $vrednostiKey[] = $dataArray[$j]['key'];
+ $vrednostiVariable[] = $dataArray[$j]['variable'];
+ }
+
+ if(count($vrednosti) > 0){
+ if($settings['value_type'] == 0){
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_freq']);
+ }
+ elseif($settings['value_type'] == 1){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_percent']);
+ }
+ elseif($settings['value_type'] == 2){
+ $DataSet->AddPoint($vrednostiPercent,'Vrednosti'.$i);
+ //$DataSet->SetYAxisName($lang['srv_chart_valid']);
+ }
+ }
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$i);
+
+ $DataSet->AddSerie('Vrednosti'.$i);
+ $DataSet->SetSerieName($i+1,'Vrednosti'.$i);
+ }
+ }
+
+
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ if($settings['type'] > 1)
+ $DataSet->SetYAxisName("Povprečje");
+ }
+
+ // napolnimo podatke za MULTINUMBER
+ elseif($spremenljivka['tip'] == 20){
+ $dataArray = array();
+
+ $i=0;
+ $numerus=0;
+
+ $sql = sisplet_query("SELECT count(*) AS count FROM srv_grid WHERE spr_id='$spid'");
+ $row = mysqli_fetch_array($sql);
+ $_variables_count = $row['count'];
+
+ $vrednostiGrid = array();
+
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $legendTitle = '';
+ $vrednostiGrid[] = $spremenljivka['edit_graf'] == 0 ? $grid['naslov'] : $grid['naslov_graf'];
+
+ //$_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
+
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+
+ # za povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ $min = null;
+ $max = null;
+ foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+
+ $fi = $vAnswer['cnt'];
+ $sum_xi_fi += $vkey * $fi ;
+ $N += $fi;
+ $min = $min != null ? min($min,$vkey) : $vkey;
+ $max = max($max,$vkey);
+ }
+
+ #povprečje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+
+ // nastavimo da graf ni prazen
+ if($avg > 0)
+ $emptyData = false;
+
+ $numerus = ($numerus > $N) ? $numerus : $N;
+
+ $tempArray = array();
+
+ $tempArray['avg'] = $avg;
+ $tempArray['max'] = $max;
+ $tempArray['min'] = $min;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $dataArray[] = $tempArray;
+ }
+
+ // ce missling (-99, -98...) nima nobene vrednosti potem ga ni v tabeli - zato ga rocno napolnimo
+ else{
+ $tempArray = array();
+
+ $tempArray['avg'] = 0;
+ $tempArray['max'] = 0;
+ $tempArray['min'] = 0;
+
+ $tempArray['key'] = $variable['variable'];
+
+ $text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
+ $tempArray['variable'] = $text;
+
+ $dataArray[] = $tempArray;
+ }
+ }
+
+ // polnimo array za drugo
+ if ($variable['text'] == true || $variable['other'] == true){
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+
+ $i++;
+ }
+
+ // zascita pred praznimi vprasanji (brez variabel)
+ if($_variables_count == 0)
+ return -1;
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ //nastavimo numerus, ki se izpise pod legendo
+ $numerus = ((int)$numerus > 0) ? $numerus : 0;
+ $DataSet->SetNumerus($numerus);
+
+
+ // Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
+ if($settings['rotate'] != 1 /*$_variables_count > 1*/){
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j*$_variables_count;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sortiramo podaatke po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ else{
+ for($j=0; $j<(count($spremenljivka['grids'])*$_variables_count); $j++){
+ $sorted_keys[] = $j;
+ }
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<count($spremenljivka['grids']); $j++){
+
+ unset($vrednosti);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ // odmik glede na sortirane po prvem gridu (sort po kategorijah ali brez)
+ if($settings['sort'] < 3){
+ $offset = $sorted_keys[$j] /*$j*/ * $_variables_count;
+
+ for($i=0; $i<$_variables_count; $i++){
+ $vrednosti[] = $dataArray[$i+$offset]['avg'];
+ $vrednostiMax[] = $dataArray[$i+$offset]['max'];
+ $vrednostiMin[] = $dataArray[$i+$offset]['min'];
+
+ $vrednostiKey[] = $dataArray[$i+$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$i+$offset]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$sorted_keys[$j]);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$sorted_keys[$j]);
+
+ $DataSet->AddSerie('Vrednosti'.$sorted_keys[$j]);
+ $DataSet->SetSerieName($vrednostiGrid[$sorted_keys[$j]],'Vrednosti'.$sorted_keys[$j]);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,'Variable'.$sorted_keys[$j]);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$sorted_keys[$j]);
+ }
+
+ // sort po prvi kategoriji
+ else{
+ for($i=0; $i<$_variables_count; $i++){
+ $vrednosti[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['avg'];
+ $vrednostiMax[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['max'];
+ $vrednostiMin[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['min'];
+
+ $vrednostiKey[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['key'];
+ $vrednostiVariable[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$j);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$j);
+
+ $DataSet->AddSerie('Vrednosti'.$j);
+ $DataSet->SetSerieName($vrednostiGrid[$j],'Vrednosti'.$j);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,'Variable'.$j);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$j);
+ }
+ }
+ }
+ // Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
+ else{
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$_variables_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sortiramo podaatke po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<count($spremenljivka['grids']); $j++){
+ $offset = $j * $_variables_count;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ else{
+ for($j=0; $j<$_variables_count; $j++){
+ $sorted_keys[] = $j;
+ }
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$_variables_count; $j++){
+
+ // odmik glede na sortirane po prvem gridu (sort po kategorijah ali brez)
+ if($settings['sort'] < 3){
+ $offset = $sorted_keys[$j];
+
+ unset($vrednosti);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ for($i=0; $i<count($spremenljivka['grids']); $i++){
+
+ $vrednosti[] = $dataArray[$i*$_variables_count+$offset]['avg'];
+ $vrednostiMax[] = $dataArray[$i*$_variables_count+$offset]['max'];
+ $vrednostiMin[] = $dataArray[$i*$_variables_count+$offset]['min'];
+
+ $vrednostiKey[] = $dataArray[$i*$_variables_count+$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$i*$_variables_count+$offset]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$vrednostiKey[0]);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$vrednostiKey[0]);
+
+ $DataSet->AddSerie('Vrednosti'.$vrednostiKey[0]);
+ $DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti'.$vrednostiKey[0]);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiGrid,'Variable'.$vrednostiKey[0]);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$vrednostiKey[0]);
+ }
+
+ // sort po prvi kategoriji
+ else{
+ $offset = $sorted_keys[$j];
+
+ unset($vrednosti);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ for($i=0; $i<count($spremenljivka['grids']); $i++){
+
+ $vrednosti[] = $dataArray[$sorted_keys[$i]*$_variables_count + $j]['avg'];
+ $vrednostiMax[] = $dataArray[$sorted_keys[$i]*$_variables_count + $j]['max'];
+ $vrednostiMin[] = $dataArray[$sorted_keys[$i]*$_variables_count + $j]['min'];
+
+ $vrednostiKey[] = $dataArray[$sorted_keys[$i]*$_variables_count + $j]['key'];
+ $vrednostiVariable[] = $dataArray[$sorted_keys[$i]*$_variables_count + $j]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$vrednostiKey[0]);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$vrednostiKey[0]);
+
+ $DataSet->AddSerie('Vrednosti'.$vrednostiKey[0]);
+ $DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti'.$vrednostiKey[0]);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiGrid,'Variable'.$vrednostiKey[0]);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$vrednostiKey[0]);
+ }
+ }
+ }
+
+ //$DataSet->SetYAxisName($lang['srv_analiza_sums_average']);
+ }
+
+ // Nastavimo other vrednosti
+ $DataSet->SetOther($_answersOther);
+
+ // ce imamo prazno in de prikazujemo praznih grafov
+ $hideEmpty = SurveyDataSettingProfiles :: getSetting('hideEmpty');
+ if($emptyData && $hideEmpty == 1)
+ return 0;
+ else
+ return $DataSet;
+ }
+
+
+ // Preverimo ce ima dropdown samo numeric vrednosti -> potem ga obravnavamo kot tip number
+ static function checkDropdownNumeric($spid){
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ $check = true;
+
+ foreach ($spremenljivka['options'] AS $option) {
+ if(!is_numeric($option))
+ $check = false;
+ }
+
+ return $check;
+ }
+
+
+ // Funkcije za izris posameznih tipov grafov - vertikalni stolpci
+ static function createVerBars($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
+
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+
+ $angle = 0;
+ $addHeight = 0;
+ $roundText = 15;
+ if($countGrids > 5){
+ $angle = 45;
+ $addHeight = 110;
+ $roundText = 25;
+ }
+ if($show_legend == 1)
+ $addHeight += 70;
+
+ // Initialise the graph
+ $Test = new pChart(self::$quality*800,self::$quality*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ $Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*220);
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+ // Pri checkboxu lahko naredimo fiksno skalo
+ if($spremenljivka['tip'] == 2 && self::$settings['noFixedScale'] == 1){
+ // Frekvence
+ if(self::$settings['value_type'] == 1){
+ // Dobimo sum frekvenc
+ $sum = 0;
+ foreach($Data as $vrednost){
+ $sum += $vrednost['Vrednosti'];
+ }
+ $Test->setFixedScale(0, $sum);
+ }
+ // Odstotki
+ else
+ $Test->setFixedScale(0, 100);
+ }
+
+ // Pri dvojnem multigridu prikazemo skalo od 1 do stevila variabel
+ if($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 3){
+
+ $VMax = count($spremenljivka['options']);
+
+ // Zacnemo skalo z 1
+ if($fixedScale == 0){
+ $Divisions = $VMax-1;
+ $VMin = 1;
+ }
+ // Zacnemo skalo z 0
+ else{
+ $VMax--;
+ $Divisions = $VMax;
+ $VMin = 0;
+ }
+
+ $Test->setFixedScale($VMin, $VMax, $Divisions);
+ }
+
+ $Test->drawScale($Data,$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
+ $Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ // Draw the bar graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ $Test->drawBarGraph($Data,$DataSet->GetDataDescription(), false, 95, self::$settings['barLabel'], self::$settings['barLabelSmall']);
+
+ // Finish the graph
+ if($show_legend == 1)
+ //$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
+ // pri vodoravnih strukturnih stolpcih izrisemo legendo na dnu
+ $Test->drawVerticalLegend(self::$quality*400,self::$quality*(190+$addHeight),$DataSet->GetDataDescription(),255,255,255);
+
+ //$Test->setFontProperties("Fonts/verdana.ttf",10);
+ //$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*210,self::$quality*795,self::$quality*220,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $vars = isset($spremenljivka['options']) ? count($spremenljivka['options']) : 0;
+ // Prikaz povprecja na grafu (samo pri ordinalnem radiu)
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
+ && $spremenljivka['skala'] != 1
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*40,self::$quality*795,self::$quality*45,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*680,self::$quality*45,self::$quality*795,self::$quality*50,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+ // Prikaz povprecja za number
+ if( ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22)
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*90,self::$quality*795,self::$quality*95,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*680,self::$quality*95,self::$quality*795,self::$quality*100,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - horizontalni stolpci
+ static function createHorBars($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
+ global $lang;
+
+ // Nastavimo visino grafa (ce imamo vec kot 7 variabel/gridov)
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+ $addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
+
+ // Dodamo prostor na dnu za legendo pri multigrid povprecjih
+ $addLegendSpace = 0;
+ if($show_legend == 1 && $spremenljivka['tip'] == 6 && self::$settings['type'] == 0 && $spremenljivka['enota'] != 3)
+ $addLegendSpace = 70;
+
+
+ // Initialise the graph
+ $Test = new MyHorBar(self::$quality*800,self::$quality*(250+$addHeight+$addLegendSpace));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Sirina label
+ // Ce iamo povprecje ni labele
+ if(in_array($spremenljivka['tip'],array(1,3,7)) && self::$settings['type'] == 9){
+ $startX = 160;
+ $roundText = 35;
+ }
+ elseif(self::$settings['labelWidth'] == 20){
+ $startX = 225;
+ $roundText = 35;
+ }
+ elseif(self::$settings['labelWidth'] == 75){
+ $startX = 500;
+ $roundText = 80;
+ }
+ else{
+ $startX = 360;
+ $roundText = 60;
+ }
+
+ $Test->setGraphArea(self::$quality*$startX,self::$quality*50,self::$quality*650,self::$quality*(220+$addHeight));
+
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight+$addLegendSpace),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight+$addLegendSpace),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+ // Pri ordinalnih multigridih prikazemo skalo od 1 do stevila variabel (ce prikazujemo povprecja)
+ if( ($spremenljivka['tip'] == 6 && self::$settings['type'] == 0) || ($spremenljivka['tip'] == 17 && self::$settings['type'] == 0) ){
+
+ $VMax = count($spremenljivka['options']);
+
+ // Zacnemo skalo z 1
+ if($fixedScale == 0){
+ $Divisions = $VMax-1;
+ $VMin = 1;
+ }
+ // Zacnemo skalo z 0
+ else{
+ $VMax--;
+ $Divisions = $VMax;
+ $VMin = 0;
+ }
+
+ $Test->setFixedScale($VMin, $VMax, $Divisions);
+ }
+
+ // Pri checkboxu lahko naredimo fiksno skalo
+ if($spremenljivka['tip'] == 2 && self::$settings['noFixedScale'] == 1){
+ // Frekvence
+ if(self::$settings['value_type'] == 1){
+ // Dobimo sum frekvenc
+ $sum = 0;
+ foreach($DataSet->GetData() as $vrednost){
+ $sum += $vrednost['Vrednosti'];
+ }
+ $Test->setFixedScale(0, $sum);
+ }
+ // Odstotki
+ else
+ $Test->setFixedScale(0, 100);
+ }
+
+ // Pri povprecju (radio) poiscemo najvecjo vrednost
+ if(in_array($spremenljivka['tip'],array(1,3)) && self::$settings['type'] == 9){
+
+ $VMax = count($spremenljivka['options']);
+ foreach($DataSet->GetData() as $vrednost){
+ $VMax = ($VMax < $vrednost['Vrednosti']) ? $vrednost['Vrednosti'] : $VMax;
+ }
+
+ $VMin = 0;
+
+ $Test->setFixedScale($VMin, $VMax);
+ }
+ // Pri povprecju (numeric) poiscemo najvecjo vrednost
+ elseif(($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22) && self::$settings['type'] == 9){
+
+ $VMax = 1;
+ $sequences = explode('_', $spremenljivka['sequences']);
+ foreach($sequences as $sequence){
+ if (count(SurveyAnalysis::$_FREQUENCYS[$sequence]['valid']) > 0 ) {
+ foreach(SurveyAnalysis::$_FREQUENCYS[$sequence]['valid'] AS $vkey => $vAnswer) {
+ $VMax = ($VMax < (int)$vAnswer['text']) ? (int)$vAnswer['text'] : $VMax;
+ }
+ }
+ }
+
+ $VMin = 0;
+
+ $Test->setFixedScale($VMin, $VMax);
+ }
+
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,0,0,TRUE,1,FALSE,$roundText);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Draw the bar graph
+ $Test->drawHorBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), self::$settings['barLabel'], self::$settings['barLabelSmall']);
+
+ // Finish the graph
+ if($show_legend == 1){
+ // posebna legenda pri povprecjih
+ if($spremenljivka['tip'] == 6 && self::$settings['type'] == 0 && $spremenljivka['enota'] != 3)
+ //$Test->drawAvgVerticalLegend(self::$quality*680,self::$quality*30,$spremenljivka['options'],255,255,255);
+ $Test->drawAvgVerticalLegend(self::$quality*400,self::$quality*(190+$addHeight+$addLegendSpace),$spremenljivka['options'],255,255,255);
+ else
+ $Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
+ }
+
+ if($spremenljivka['tip'] == 18 || $spremenljivka['tip'] == 20)
+ $Test->drawTitle(self::$quality*200,self::$quality*22,$lang['srv_analiza_sums_average'],0,0,0,self::$quality*680);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $vars = isset($spremenljivka['options']) ? count($spremenljivka['options']) : 0;
+ // Prikaz povprecja na grafu (samo pri ordinalnem radiu)
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
+ && $spremenljivka['skala'] != 1
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*50,self::$quality*795,self::$quality*55,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*680,self::$quality*55,self::$quality*795,self::$quality*60,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+ // Prikaz povprecja za number
+ if( ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22)
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*90,self::$quality*795,self::$quality*95,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*680,self::$quality*95,self::$quality*795,self::$quality*100,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - vertikalni sestavljeni stolpci
+ static function createVerStructBars($DataSet, $spremenljivka){
+
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+
+ $angle = 0;
+ $addHeight = 0;
+ $roundText = 15;
+ if($countGrids > 5){
+ $angle = 45;
+ $addHeight = 110;
+ $roundText = 30;
+ }
+
+ // Initialise the graph
+ $Test = new pChart(self::$quality*800,self::$quality*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Pri navadnem radio in checkbox vprasanju imamo samo en stolpec - zato so dimenzije drugacne
+ if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
+ $Test->setGraphArea(self::$quality*250,self::$quality*40,self::$quality*500,self::$quality*220);
+ else
+ $Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*220);
+
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
+ $Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ // Draw the bar graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ $Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), self::$settings['barLabel'], 95);
+
+ // Finish the graph
+ if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
+ $Test->drawLegend(self::$quality*580,self::$quality*30,$DataSet->GetDataDescription(),255,255,255,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=false,$reverse=true);
+ else
+ $Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=false,$reverse=true);
+
+ $Test->setFontProperties("Fonts/verdana.ttf",self::$quality*10);
+ //$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
+ $Test->drawTextBox(self::$quality*540,self::$quality*210,self::$quality*645,self::$quality*220,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ else
+ $Test->drawTextBox(self::$quality*680,self::$quality*210,self::$quality*795,self::$quality*220,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $vars = count($spremenljivka['options']);
+ // Prikaz povprecja na grafu (samo pri ordinalnem radiu)
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
+ && $spremenljivka['skala'] != 1
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*350,self::$quality*25,self::$quality*400,self::$quality*30,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*350,self::$quality*30,self::$quality*400,self::$quality*35,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - horizontalni sestavljeni stolpci
+ static function createHorStructBars($DataSet, $spremenljivka){
+
+ // Nastavimo visino graffa (ce imamo vec kot 7 variabel/gridov)
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+ $addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
+
+ // Imamo semanticni dif. - izpisujemo labele na desni
+ $rightScale = ($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 1 && self::$settings['scale_limit'] == 1) ? true : false;
+
+ // Initialise the graph
+ $Test = new MyHorBar(self::$quality*800,self::$quality*(250+$addHeight+50));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Sirina label
+ if(self::$settings['labelWidth'] == 20){
+ $startX = 225;
+ $roundText = 35;
+ }
+ elseif(self::$settings['labelWidth'] == 75){
+ $startX = 500;
+ $roundText = 80;
+ }
+ else{
+ $startX = 360;
+ $roundText = 60;
+ }
+
+ // Pri navadnem radio in checkbox vprasanju imamo samo en stolpec - zato so dimenzije drugacne
+ if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3){
+ $Test->setGraphArea(self::$quality*200,self::$quality*50,self::$quality*630,self::$quality*220);
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*243,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*295,200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,0,0,TRUE);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+ }
+ // Semanticni diferencial s skalo na desni
+ elseif($rightScale){
+ $Test->setGraphArea(self::$quality*270,self::$quality*50,self::$quality*530,self::$quality*(220+$addHeight));
+ $Test->drawFilledRoundedRectangle(7,7,793,243+$addHeight,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(295+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0/*SCALE_START0*/,0,0,0,TRUE,0,0,TRUE,1,$rightScale,$roundText=40);
+ $Test->drawHorGrid(4,false,230,230,230,50);
+ }
+ else{
+ $Test->setGraphArea(self::$quality*$startX,self::$quality*50,self::$quality*650,self::$quality*(220+$addHeight));
+ $Test->drawFilledRoundedRectangle(7,7,793,243+$addHeight,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(295+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,0,0,TRUE,1,FALSE,$roundText);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+ }
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Draw the bar graph
+ $Test->drawStackedHorBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$settings['barLabel'],95);
+
+ // Finish the graph
+ /*if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
+ $Test->drawLegend(560,30,$DataSet->GetDataDescription(),255,255,255);
+ else
+ $Test->drawLegend(680,30,$DataSet->GetDataDescription(),255,255,255);*/
+
+ // pri vodoravnih strukturnih stolpcih izrisemo legendo na dnu
+ $Test->drawVerticalLegend(self::$quality*400,self::$quality*(240+$addHeight),$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties("Fonts/verdana.ttf",self::$quality*10);
+ //$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ /*if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
+ $Test->drawTextBox(570,210+$addHeight,795,220+$addHeight,'n = '.$DataSet->GetNumerus().self::$numerusText,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ else*/
+ $Test->drawTextBox(self::$quality*680,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $vars = count($spremenljivka['options']);
+ // Prikaz povprecja na grafu (samo pri ordinalnem radiu)
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
+ && $spremenljivka['skala'] != 1
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*50,self::$quality*795,self::$quality*55,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*680,self::$quality*55,self::$quality*795,self::$quality*60,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - krozni graf
+ static function createPie($DataSet, $spremenljivka, $show_legend=1){
+ global $lang;
+
+ // Initialise the graph
+ $Test = new pChart(self::$quality*800,self::$quality*280);
+
+ // Pri pie grafu uporabimo antialiasing
+ $Test->setAntialias(true, 20);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ //$Test->setGraphArea(50,40,685,220);
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*273,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*275,200,200,200);
+ //$Test->createColorGradientPalette(195,204,56,223,110,41,3);
+ //$Test->createColorGradientPalette(168,188,56,248,255,136,5);
+
+
+ // Pri vsoti ne izpisujemo procentov
+ if($spremenljivka['tip'] == 18 || ($spremenljivka['tip'] == 1 && self::$settings['type'] == 2 && self::$settings['value_type'] == 1))
+ $labels = (self::$settings['sort'] == 1) ? 'custom_sort' : 'custom';
+ else
+ $labels = (self::$settings['sort'] == 1) ? 'custom_percent_sort' : 'custom_percent';
+
+
+ // Izrisemo navaden krozni graf
+ $Test->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$quality*390,self::$quality*145,self::$quality*95,$labels);
+
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ //$Test->drawLegend(700,30,$DataSet->GetDataDescription(),255,255,255);
+
+ if($show_legend == 1)
+ $Test->drawPieLegend(self::$quality*600,self::$quality*50,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*10);
+
+ if($spremenljivka['tip'] == 18)
+ $Test->drawTitle(self::$quality*180,self::$quality*30,$lang['srv_analiza_sums_average'],0,0,0,self::$quality*610);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ $Test->setAntialias(false, 0);
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*600,self::$quality*220,self::$quality*715,self::$quality*230,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $vars = count($spremenljivka['options']);
+ // Prikaz povprecja na grafu (samo pri ordinalnem radiu)
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
+ && $spremenljivka['skala'] != 1
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*600,self::$quality*240,self::$quality*715,self::$quality*245,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*600,self::$quality*245,self::$quality*715,self::$quality*250,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - 3D krozni graf
+ static function create3DPie($DataSet, $spremenljivka, $show_legend=1){
+ global $lang;
+
+ // Initialise the graph
+ $Test = new pChart(self::$quality*800,self::$quality*280);
+
+ // Pri 3d pie grafu uporabimo antialiasing
+ $Test->setAntialias(true, 20);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ //$Test->setGraphArea(50,40,685,220);
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*273,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*275,200,200,200);
+ //$Test->createColorGradientPalette(195,204,56,223,110,41,3);
+ //$Test->createColorGradientPalette(168,188,56,248,255,136,5);
+
+
+ // Pri vsoti ne izpisujemo procentov
+ if($spremenljivka['tip'] == 18 || ($spremenljivka['tip'] == 1 && self::$settings['type'] == 2 && self::$settings['value_type'] == 1))
+ $labels = (self::$settings['sort'] == 1) ? 'custom_sort' : 'custom';
+ else
+ $labels = (self::$settings['sort'] == 1) ? 'custom_percent_sort' : 'custom_percent';
+
+
+ // Izrisemo 3d krozni graf
+ $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$quality*390,self::$quality*130,self::$quality*95,$labels,$EnhanceColors=true,$Skew=50,$SpliceHeight=self::$quality*20,$SpliceDistance=0,$Decimals=0);
+
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ //$Test->drawLegend(700,30,$DataSet->GetDataDescription(),255,255,255);
+
+ if($show_legend == 1)
+ $Test->drawPieLegend(self::$quality*600,self::$quality*50,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*10);
+
+ if($spremenljivka['tip'] == 18)
+ $Test->drawTitle(self::$quality*180,self::$quality*30,$lang['srv_analiza_sums_average'],0,0,0,self::$quality*610);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ $Test->setAntialias(false, 0);
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*600,self::$quality*220,self::$quality*715,self::$quality*230,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $vars = count($spremenljivka['options']);
+ // Prikaz povprecja na grafu (samo pri ordinalnem radiu)
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
+ && $spremenljivka['skala'] != 1
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*600,self::$quality*240,self::$quality*715,self::$quality*245,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*600,self::$quality*245,self::$quality*715,self::$quality*250,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - linijski graf
+ //spremenljivka je lahko null za linijski graf analize editiranja (SurveyEditsAnalysis)
+ static function createLine($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
+
+ // Initialise the graph
+ $Test = new pChart(self::$quality*800,self::$quality*280);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ if($spremenljivka != null && ($spremenljivka['tip'] == 6 && $fixedScale == 1 && $spremenljivka['enota'] != 3) || ($spremenljivka['tip'] == 6 && $fixedScale == 0 && $spremenljivka['enota'] == 3)){
+
+ $VMax = count($spremenljivka['options']);
+ $Divisions = $VMax-1;
+
+ $Test->setFixedScale($VMin=1, $VMax, $Divisions);
+ }
+
+ $count = count($DataSet->GetData());
+
+ // Ce imamo numeric vse vrednosti in jih je vec kot 20 omejimo max 20 label na X osi
+ $SkipLabels = 1;
+ if($spremenljivka != null && ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22) && $count > 20)
+ $SkipLabels = $count / 20;
+
+ // Kot label na x osi
+ $angle = 0;
+ if($count > 6)
+ $angle = 45;
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ $Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*220);
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*273,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*275,200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+ // Pri checkboxu lahko naredimo fiksno skalo
+ if($spremenljivka != null && $spremenljivka['tip'] == 2 && self::$settings['noFixedScale'] == 1){
+ // Frekvence
+ if(self::$settings['value_type'] == 1){
+ // Dobimo sum frekvenc
+ $sum = 0;
+ foreach($DataSet->GetData() as $vrednost){
+ $sum += $vrednost['Vrednosti'];
+ }
+ $Test->setFixedScale(0, $sum);
+ }
+ // Odstotki
+ else
+ $Test->setFixedScale(0, 100);
+ }
+
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,$angle,0,TRUE, $SkipLabels);
+ if($count <= 20)
+ $Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ //$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ // Draw the bar graph
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
+ if($count <= 20)
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$quality*3,self::$quality*2,255,255,255);
+
+ if($show_legend == 1)
+ $Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka != null && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16))) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*690,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ // Prikaz povprecja za number
+ if($spremenljivka != null && ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22)
+ && (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
+
+ $Test->drawTextBox(self::$quality*690,self::$quality*80,self::$quality*795,self::$quality*85,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox(self::$quality*690,self::$quality*85,self::$quality*795,self::$quality*90,'&#8254;',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - linijski graf
+ static function createVerLine($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
+
+ // Nastavimo visino grafa (ce imamo vec kot 7 variabel/gridov)
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+ $addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
+
+ // Imamo semanticni dif. - izpisujemo labele na desni
+ $rightScale = ($spremenljivka['enota'] == 1 && self::$settings['scale_limit'] == 1) ? true : false;
+
+ // Initialise the graph
+ $Test = new MyHorBar(self::$quality*800,self::$quality*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ if($spremenljivka['tip'] == 6 && $fixedScale == 0){
+
+ $VMax = count($spremenljivka['options']);
+ $Divisions = $VMax-1;
+
+ $Test->setFixedScale($VMin=1, $VMax, $Divisions);
+ }
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ $Test->setGraphArea(self::$quality*270,self::$quality*50,self::$quality*530,self::$quality*(220+$addHeight));
+
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,0,0,TRUE,1,$rightScale,$roundText=40);
+ $Test->drawHorGrid(4,false,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Draw the line graph
+ $Test->drawVerLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(), $insideValues=false);
+
+ // Finish the graph
+ if($show_legend == 1){
+ // posebna legenda pri povprecjih
+ if($spremenljivka['tip'] == 6 && self::$settings['type'] == 6)
+ $Test->drawAvgLegend(self::$quality*680,self::$quality*30,$spremenljivka['options'],255,255,255);
+ else
+ $Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
+ }
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ if($spremenljivka['tip'] == 18)
+ $Test->drawTitle(self::$quality*200,self::$quality*22,'Povprečje',150,150,150,self::$quality*585);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*680,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - vertikalni stolpci
+ static function createRadar($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
+
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+
+ // Initialise the graph
+ $Test = new pChart(self::$quality*800,self::$quality*350);
+
+ // Pri radarju uporabimo antialiasing
+ $Test->setAntialias(true, 20);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = self::setChartColors($Test, self::$skin);
+
+ $Test->setLineStyle(self::$quality,$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ $Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*320);
+ $Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*343,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*345,200,200,200);
+ //$Test->drawGraphArea(255,255,255,TRUE);
+ //$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,20,20,20,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
+ //$Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+
+ // Pri ordinalnih multigridih prikazemo skalo od 1 do stevila variabel (ce prikazujemo povprecja)
+ if($spremenljivka['tip'] == 6 /*&& $spremenljivka['skala'] == 0*/ && $fixedScale == 0){
+
+ $VMax = count($spremenljivka['options']) - 1;
+ $Divisions = $VMax-1;
+
+ $Test->setFixedScale($VMin=1, $VMax, $Divisions);
+ }
+ else
+ $VMax = -1;
+
+
+ // Draw the radar
+ $Test->drawRadarAxis($DataSet->GetData(),$DataSet->GetDataDescription(),true,5,0,0,0,160,160,160,$VMax,self::$settings['radar_scale']);
+ // Tip radarja - navaden ali samo crte
+ if(self::$settings['radar_type'] == 1)
+ $Test->drawFilledRadar($DataSet->GetData(),$DataSet->GetDataDescription(),50,5,$VMax);
+ else{
+ $Test->setLineStyle($Width=(2*self::$quality),$DotSize=0);
+ $Test->drawRadar($DataSet->GetData(),$DataSet->GetDataDescription(),5,$VMax);
+ }
+
+ $Test->setAntialias(false, 0);
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ if($show_legend == 1){
+ // posebna legenda pri povprecjih
+ if($spremenljivka['tip'] == 6 && self::$settings['type'] == 5)
+ $Test->drawAvgLegend(self::$quality*680,self::$quality*30,$spremenljivka['options'],255,255,255);
+ else
+ $Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
+ }
+
+ $Test->setFontProperties("Fonts/verdana.ttf",self::$quality*10);
+ //$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
+
+ // Prikaz numerusa na grafu
+ $char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
+ if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
+ $numerus = $char.' = '.$DataSet->GetNumerus();
+ elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
+ $numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
+ else
+ $numerus = '';
+
+ $Test->drawTextBox(self::$quality*600,self::$quality*220,self::$quality*715,self::$quality*230,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+ return $Test;
+ }
+
+
+ // Nastavitve na vrhu
+ static function displayGlobalSettings(){
+ global $lang;
+ global $admin_type;
+ global $site_url;
+
+ self::$skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
+
+ //moznost osvezevanja grafov - ne uporabljamo zaenkrat
+ if($admin_type < 2 && false)
+ echo '<a href="'.$site_url.'?anketa='.self::$anketa.'&a=analysis&m=charts&refresh=1"><img src="img_0/random_off.png" title="Osveži grafe" /></a>';
+
+ // Izrisemo ostale filtre
+ SurveyAnalysis::DisplayFilters(self::$quality);
+
+ // prklop na vecjo resolucijo grafov (zaenkrat tukaj - kasneje v globalne nastavitve)
+ //self::displayHQSetting();
+
+
+ echo '<div id="displayFilterNotes">';
+ # če imamo filter zoom ga izpišemo
+ SurveyZoom::getConditionString();
+ # če imamo filter ifov ga izpišemo
+ SurveyConditionProfiles:: getConditionString();
+ # če imamo filter ifov za inspect ga izpišemo
+ $SI = new SurveyInspect(self::$anketa);
+ $SI->getConditionString();
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyTimeProfiles :: printIsDefaultProfile();
+ # če imamo filter spremenljivk ga izpišemo
+ SurveyVariablesProfiles:: getProfileString(true);
+
+ # če imamo rekodiranje
+ $SR = new SurveyRecoding(self::$anketa);
+ $SR -> getProfileString();
+
+ SurveyDataSettingProfiles :: getVariableTypeNote($doNewLine);
+ echo '</div>';
+ }
+
+ public static function displayHQSetting(){
+ global $lang;
+
+ echo '<div id="chart_hq_setting" class="analiza">';
+
+ echo '<ul>';
+ echo '<li>';
+ echo $lang['srv_chart_hq'].': ';
+ echo '<input type="checkbox" name="chart_hq" id="chart_hq" onClick="changeChartHq(this)" '.(self::$quality == 3 ? ' checked="checked"' : '').'>';
+ echo '</li>';
+
+ # nastavitev skina grafov
+ echo '<li>';
+ $SSH = new SurveyStaticHtml(self::$anketa);
+ $SSH -> displayLinkChart(false);
+ echo '</li>';
+
+ echo '</div>';
+ }
+
+ // Nastavitve na dnu
+ static function displayBottomSettings(){
+ global $site_path;
+ global $lang;
+
+ echo '<div class="chart_bottom_settings">';
+
+ echo '<a href="#" onClick="addCustomReportAllElementsAlert(4);" title="'.$lang['srv_custom_report_comments_add_hover'].'" style="margin-right: 40px;"><span class="spaceRight faicon comments_creport" ></span><span class="bold">'.$lang['srv_custom_report_comments_add'].'</span></a>';
+
+ echo '<a href="#" onClick="printAnaliza(\'Grafi\'); return false;" title="'.$lang['hour_print2'].'" class="srv_ico"><span class="faicon print icon-grey_dark_link"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts&anketa=' . self::$anketa) . '" target="_blank" title="'.$lang['PDF_Izpis'].'"><span class="faicon pdf black very_large" ></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts_rtf&anketa=' . self::$anketa) . '" target="_blank" title="'.$lang['RTF_Izpis'].'"><span class="faicon rtf black very_large"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts_ppt&anketa=' . self::$anketa) . '" target="_blank" title="'.$lang['PPT_Izpis'].'"><span class="faicon ppt black very_large"></span></a>';
+
+ echo '<a href="#" onclick="doArchiveAnaliza();" title="'.$lang['srv_analiza_arhiviraj_ttl'].'"><span class="faicon arhiv black very_large"></span></a>';
+ echo '<a href="#" onclick="createArchiveBeforeEmail();" title="'.$lang['srv_analiza_arhiviraj_email_ttl'] . '"><span class="faicon arhiv_mail black very_large"></span></a>';
+
+ echo '</div>';
+ }
+
+ // Pripis pod grafom (numerus, povprecje, spremenljivka...)
+ static function displayBottomChartInfo($DataSet, $spremenljivka){
+ global $site_path;
+ global $lang;
+
+ echo '<div class="chart_bottom_info">';
+ echo '<ul>';
+
+ // spremenljivka
+ echo '<li>'.$lang['srv_spremenljivka'].': <span class="strong">'.$spremenljivka['variable'].'</span> <span class="anl_ita">('.$lang['srv_vprasanje_tip_'.$spremenljivka['tip']].')</span></li>';
+
+ // numerus
+ if(self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16))
+ echo '<li>,&nbsp; r = <span class="strong">'.$DataSet->GetNumerus().'</span> <span class="anl_ita">'.self::$numerusText.'</span></li>';
+ else
+ echo '<li>,&nbsp; n = <span class="strong">'.$DataSet->GetNumerus().'</span> <span class="anl_ita">'.self::$numerusText.'</span></li>';
+
+ // povprecje (ce je radio ali droipdown ordinalna)
+ if(($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $spremenljivka['skala'] != 1)
+ echo '<li>,&nbsp; <span style="text-decoration: overline;">x</span> = <span class="strong">'.$DataSet->GetAverage().'</span></li>';
+
+ echo '</ul>';
+ echo '</div>';
+ }
+
+
+ // Nastavitve posameznega grafa
+ static function displaySingleSettings($spid, $settings=0){
+ global $site_path;
+ global $lang;
+ if (self::$publicChart == true) {
+ return false;
+ }
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Ikone izvoza na vrhu posameznih nastavitev
+ self::displayExportIcons($spid);
+
+
+ echo '<div id="switch_left_'.$spid.'_loop_'.self::$current_loop.'" class="switch_left '.(self::$settings_mode == 1 ? ' non-active' : '').'" onClick="chartSwitchSettings(\''.$spid.'\', \'0\', \''.self::$current_loop.'\')">'.$lang['srv_chart_settings_basic'].'</div>';
+ //echo '<span id="switch_middle_'.$spid.'_loop_'.self::$current_loop.'" class="'.(self::$settings_mode == 1 ? 'rightHighlight' : 'leftHighlight').'"></span>';
+ echo '<div id="switch_right_'.$spid.'_loop_'.self::$current_loop.'" class="switch_right '.(self::$settings_mode == 0 ? ' non-active' : '').'" onClick="chartSwitchSettings(\''.$spid.'\', \'1\', \''.self::$current_loop.'\')">'.$lang['srv_chart_settings_advanced'].'</div>';
+
+
+ // OSNOVNE NASTAVITVE
+ echo '<div class="chart_settings_inner" id="chart_settings_basic_'.$spid.'_loop_'.self::$current_loop.'" '.(self::$settings_mode == 1 ? ' style="display:none;"' : '').'>';
+
+ //echo '<span class="title">'.$lang['srv_chart_settings'].'</span>';
+
+ switch($spremenljivka['tip']){
+ case 1:
+ case 3:
+ self::displayRadioSettings($spid, $settings);
+ break;
+
+ case 2:
+ self::displayCheckboxSettings($spid, $settings);
+ break;
+
+ case 6:
+ if($spremenljivka['enota'] == 3)
+ self::displayDoubleMultigridSettings($spid, $settings);
+ else
+ self::displayMultigridSettings($spid, $settings);
+ break;
+
+ case 7:
+ case 22:
+ self::displayNumberSettings($spid, $settings);
+ break;
+
+ case 8:
+ self::displayDateSettings($spid, $settings);
+ break;
+
+ case 16:
+ self::displayMulticheckboxSettings($spid, $settings);
+ break;
+
+ case 17:
+ self::displayRankingSettings($spid, $settings);
+ break;
+
+ case 18:
+ self::displayVsotaSettings($spid, $settings);
+ break;
+
+ case 20:
+ self::displayMultinumberSettings($spid, $settings);
+ break;
+
+ case 21:
+ case 4:
+ self::displayTableSettings($spid);
+ break;
+
+ case 19:
+ self::displayMultitextSettings($spid, $settings);
+ break;
+
+ default:
+ break;
+ }
+
+ // Preview vprasanja
+ //SurveyAnalysis::showVariable($spid, $spremenljivka['variable']);
+ echo '<div class="chart_setting" style="text-align: center; margin-top: 20px;">';
+ echo '<span style="margin-right: 6px; line-height: 6px; font-weight: 600; font-size: 11px;">';
+ //echo $lang['srv_vprasanje'].': ';
+ echo $spremenljivka['variable'];
+ echo '</span>';
+ //echo '<a href="/" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="preview_spremenljivka_analiza(\'' . $spid . '\'); return false;"><span class="sprites preview"></span></a>';
+ echo '<a href="#" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\''.$spid.'\'); return false;"><span class="faicon preview"></span></a> ';
+ //echo '</div>';
+
+ //echo '<div class="chart_setting" style="text-align: center;">';
+ SurveyAnalysis::showIcons($spid,$spremenljivka,$_from='charts');
+ echo '</div>';
+
+ echo '</div>';
+
+
+ // NAPREDNE NASTAVITVE
+ echo '<div class="chart_settings_inner" id="chart_settings_advanced_'.$spid.'_loop_'.self::$current_loop.'" '.(self::$settings_mode == 0 ? ' style="display:none;"' : '').'>';
+
+ switch($spremenljivka['tip']){
+ case 1:
+ case 3:
+ self::displayAdvancedRadioSettings($spid, $settings);
+ break;
+
+ case 2:
+ self::displayAdvancedCheckboxSettings($spid, $settings);
+ break;
+
+ case 6:
+ if($spremenljivka['enota'] == 3)
+ self::displayAdvancedDoubleMultigridSettings($spid, $settings);
+ else
+ self::displayAdvancedMultigridSettings($spid, $settings);
+ break;
+
+ case 7:
+ case 22:
+ self::displayAdvancedNumberSettings($spid, $settings);
+ break;
+
+ case 8:
+ self::displayAdvancedDateSettings($spid, $settings);
+ break;
+
+ case 16:
+ self::displayAdvancedMulticheckboxSettings($spid, $settings);
+ break;
+
+ case 17:
+ self::displayAdvancedRankingSettings($spid, $settings);
+ break;
+
+ case 18:
+ self::displayAdvancedVsotaSettings($spid, $settings);
+ break;
+
+ case 20:
+ self::displayAdvancedMultinumberSettings($spid, $settings);
+ break;
+
+ default:
+ break;
+ }
+
+ // Link na urejanje label
+ echo '<span class="edit" style="margin-top:15px;" onclick="chartAdvancedSettings(\''.$spid.'\', 1, \''.self::$current_loop.'\');">'.$lang['srv_chart_advancedLink_labels'].'</span>';
+ // Vprasajcek za pomoc
+ echo Help :: display('displaychart_settings_labels');
+
+ // Link na urejanje barv
+ echo '<span class="edit" onclick="chartAdvancedSettings(\''.$spid.'\', \'2\', \''.self::$current_loop.'\');">'.$lang['srv_chart_advancedLink_colors'].'</span>';
+ // Vprasajcek za pomoc
+ echo Help :: display('displaychart_settings_colors');
+
+ // Link na rekodiranje
+ echo '<span class="edit" onclick="chartAdvancedSettings(\''.$spid.'\', \'3\', \''.self::$current_loop.'\');">'.$lang['srv_chart_advancedLink_recoding'].'</span>';
+ // Vprasajcek za pomoc
+ echo Help :: display('displaychart_settings_recoding');
+
+ // Link na napredne number (radio dropdown numeric, number, date) nastavitve
+ if(($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)) || $spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 8 || $spremenljivka['tip'] == 22){
+ echo '<span class="edit" onclick="chartAdvancedSettings(\''.$spid.'\', \'4\', \''.self::$current_loop.'\');">'.$lang['srv_chart_advancedLink_limits'].'</span>';
+ // Vprasajcek za pomoc
+ //echo Help :: display('displaychart_settings_number');
+ }
+
+
+ echo '</div>';
+ }
+
+ // ikone na vrhu posameznih nastavitev (izvozi)
+ static function displayExportIcons($spid){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ $loop = (isset(SurveyAnalysis::$_CURRENT_LOOP)) ? SurveyAnalysis::$_CURRENT_LOOP['cnt'] : 'undefined';
+
+ // linki
+ echo '<div class="chart_setting_exportLinks">';
+
+ // Ikona za print
+ echo '<a href="#" onclick="showAnalizaSingleChartPopup(\''.$spid.'\',\''.M_ANALYSIS_CHARTS.'\'); return false;">';
+ echo '<span class="faicon print_small icon-grey_dark_link" title="' . $lang['PRN_Izpis'] . '"></span>';
+ echo '</a>';
+
+ // Izvoz posameznega grafa v PDF/RTF/PPT
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts&anketa='.self::$anketa.'&sprID='.$spid.'&loop='.$loop).'" target="_blank" title="'.$lang['PDF_Izpis'].'"><span class="faicon pdf"></span></a>';
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts_rtf&anketa='.self::$anketa.'&sprID='.$spid.'&loop='.$loop).'" target="_blank" title="'.$lang['RTF_Izpis'].'"><span class="faicon rtf"></span></a>';
+ // V PPT zaenkrat ne izvazamo tabel
+ if($spremenljivka['tip'] != 4 && $spremenljivka['tip'] != 19 && $spremenljivka['tip'] != 21)
+ echo '<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts_ppt&anketa='.self::$anketa.'&sprID='.$spid.'&loop='.$loop).'" target="_blank" title="'.$lang['PPT_Izpis'].'"><span class="faicon ppt"></span></a>';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za radio grafe (tip 1,3)
+ static function displayRadioSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Nastavitve numeric dropdowna - obravnavamo kot number
+ if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 1, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="5" '.($settings['type']=='5'?' selected="selected"':'').'>'.$lang['srv_chart_group_horizontal'].'</option>';
+ echo ' <option value="6" '.($settings['type']=='6'?' selected="selected"':'').'>'.$lang['srv_chart_group_vertical'].'</option>';
+ echo ' <option value="7" '.($settings['type']=='7'?' selected="selected"':'').'>'.$lang['srv_chart_group_line'].'</option>';
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // tip izpisa vrednosti
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 1, \'value_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ if($settings['type'] < 5){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 1, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // stevilo intervalov
+ if($settings['type'] > 4){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_interval'].': <select id="chart_interval_'.$spid.'_loop_'.self::$current_loop.'" name="chart_interval" onchange="changeChart(\''.$spid.'\', 1, \'interval\', \''.self::$current_loop.'\');">';
+
+ for($i=3; $i<=10; $i++){
+ echo ' <option value="'.$i.'" '.($settings['interval']==$i ?' selected="selected"':'').'>'.$i.'</option>';
+ }
+ echo ' <option value="20" '.($settings['interval']=='20'?' selected="selected"':'').'>20</option>';
+ //echo ' <option value="50" '.($settings['interval']=='50'?' selected="selected"':'').'>50</option>';
+ //echo ' <option value="100" '.($settings['interval']=='100'?' selected="selected"':'').'>100</option>';
+ echo ' <option value="-1" '.($settings['interval']=='-1'?' selected="selected"':'').'>Vsi</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 0 || $settings['type'] == 1 || $settings['type'] == 3 || $settings['type'] == 4){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 1, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve radia in navadnega dropdowna
+ else{
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 1, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_pie'].'</option>';
+ echo ' <option value="8" '.($settings['type']=='8'?' selected="selected"':'').'>'.$lang['srv_chart_3Dpie'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_structure1_hor'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_structure1_ver'].'</option>';
+ if($spremenljivka['skala'] != 1)
+ echo ' <option value="9" '.($settings['type']=='9'?' selected="selected"':'').'>'.$lang['srv_chart_avg_single'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ if($settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 1, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // tip izpisa vrednosti
+ if($settings['type'] != 9){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 1, \'value_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ if($settings['type'] != 2 && $settings['type'] != 8)
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // prikaz legende
+ if($settings['type'] == 2 || $settings['type'] == 8){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_analiza_legenda'].': ';
+ echo '<input type="checkbox" id="chart_show_legend_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_legend" '.($settings['show_legend']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 1, \'show_legend\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 0 || $settings['type'] == 1 || $settings['type'] == 3 || $settings['type'] == 4 || $settings['type'] == 9){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 1, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+ }
+
+ // Nastavitve za radio grafe (tip 1,3) - NAPREDNO
+ static function displayAdvancedRadioSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 1, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // prikaz povprecja
+ if($spremenljivka['skala'] != 1 && $settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ $vars = count($spremenljivka['options']);
+ $checked = ($settings['show_avg']=='1' || ($settings['show_avg']=='-1' && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showAvg'].': ';
+ echo '<input type="checkbox" id="chart_show_avg_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_avg" '.$checked.' onchange="changeChart(\''.$spid.'\', 1, \'show_avg\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 1, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // 3D strukturni krog
+ /*if($settings['type'] == 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_3d_pie'].': ';
+ echo '<input type="checkbox" id="chart_3d_pie_'.$spid.'_loop_'.self::$current_loop.'" name="chart_3d_pie" '.($settings['3d_pie']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 1, \'3d_pie\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }*/
+
+ // Izpusti variable brez odgovora
+ if(($spremenljivka['tip'] != 3 || !self::checkDropdownNumeric($spid)) && $settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_hideEmtyVar'].': ';
+ echo '<input type="checkbox" id="chart_hideEmptyVar_'.$spid.'_loop_'.self::$current_loop.'" name="chart_hideEmptyVar" '.($settings['hideEmptyVar']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 1, \'hideEmptyVar\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label majhnih vrednosti zraven stolpcov
+ if($settings['barLabel'] == 1 && ($settings['type'] == 0 || $settings['type'] == 1)){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabelSmall'].': ';
+ echo '<input type="checkbox" id="chart_barLabelSmall_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabelSmall" '.($settings['barLabelSmall']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 1, \'barLabelSmall\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // Preklop med ordinalno in nominalno spremenljivko - ce imamo povprecja ne smemo preklopiti na nominalno
+ if($settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ $lestvica = SurveyAnalysis::getSpremenljivkaLegenda($spremenljivka,'skalaAsValue');
+
+ echo $lang['srv_skala'].': ';
+ // Vprasajcek za pomoc
+ echo Help :: display('srv_skala_edit');
+
+ echo '<span class="spaceLeft"></span>';
+ echo '<a onclick="chartAdvancedSettingsSkala(\''.$spid.'\', \'0\', \''.self::$current_loop.'\'); return false;" href="#" title="'.$lang['srv_skala_long_0'].'"><span '.($lestvica == 0 ? ' class="strong"' : '').'>'.$lang['srv_skala_short_0'].'</span></a>';
+ echo '<span class="blue"> / </span>';
+ echo '<a onclick="chartAdvancedSettingsSkala(\''.$spid.'\', \'1\', \''.self::$current_loop.'\'); return false;" href="#" title="'.$lang['srv_skala_long_1'].'"><span '.($lestvica == 1 ? ' class="strong"' : '').'>'.$lang['srv_skala_short_1'].'</span></a>';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za checkbox grafe (tip 2)
+ static function displayCheckboxSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // omejitev skale
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_base'].': <select id="chart_base_'.$spid.'_loop_'.self::$current_loop.'" name="chart_base" onchange="changeChart(\''.$spid.'\', 2, \'base\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['base']=='0'?' selected="selected"':'').'>'.$lang['srv_analiza_opisne_units'].'</option>';
+ echo ' <option value="1" '.($settings['base']=='1'?' selected="selected"':'').'>'.$lang['srv_analiza_opisne_arguments'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 2, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ if($settings['base'] != '0'){
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_pie'].'</option>';
+ echo ' <option value="7" '.($settings['type']=='7'?' selected="selected"':'').'>'.$lang['srv_chart_3Dpie'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_structure1_hor'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_structure1_ver'].'</option>';
+ }
+ else{
+ echo ' <option value="5" '.($settings['type']=='5'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+ echo ' <option value="6" '.($settings['type']=='6'?' selected="selected"':'').'>'.$lang['srv_chart_line'].'</option>';
+ }
+
+ echo '</select>';
+ echo '</div>';
+
+ // Tip radarja
+ if($settings['type'] == '5'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="chart_radar_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_type" onchange="changeChart(\''.$spid.'\', 2, \'radar_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == '5'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="chart_radar_scale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_scale" onchange="changeChart(\''.$spid.'\', 2, \'radar_scale\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // tip izpisa vrednosti
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 2, \'value_type\', \''.self::$current_loop.'\');" '.($settings['type'] == 2 ? 'disabled="disabled"' : '').'>';
+
+ if($settings['base'] != '1')
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ if($settings['type'] != 5){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 2, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // prikaz legende
+ if($settings['type'] == 2 || $settings['type'] == 7){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_analiza_legenda'].': ';
+ echo '<input type="checkbox" id="chart_show_legend_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_legend" '.($settings['show_legend']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 2, \'show_legend\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 0 || $settings['type'] == 1 || $settings['type'] == 3 || $settings['type'] == 4){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 2, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za checkbox grafe (tip 2)
+ static function displayAdvancedCheckboxSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 2, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 2, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // Izpusti variable brez odgovora
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_hideEmtyVar'].': ';
+ echo '<input type="checkbox" id="chart_hideEmptyVar_'.$spid.'_loop_'.self::$current_loop.'" name="chart_hideEmptyVar" '.($settings['hideEmptyVar']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 2, \'hideEmptyVar\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // prikaz polne skale
+ if($settings['type'] == 0 || $settings['type'] == 1 || $settings['type'] == 6){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_settings_fullScale'].': ';
+ echo '<input type="checkbox" id="chart_noFixedScale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_noFixedScale" '.($settings['noFixedScale']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 2, \'noFixedScale\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label majhnih vrednosti zraven stolpcov
+ if($settings['barLabel'] == 1 && ($settings['type'] == 0 || $settings['type'] == 1)){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabelSmall'].': ';
+ echo '<input type="checkbox" id="chart_barLabelSmall_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabelSmall" '.($settings['barLabelSmall']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 2, \'barLabelSmall\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // 3D strukturni krog
+ /*if($settings['type'] == 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_3d_pie'].': ';
+ echo '<input type="checkbox" id="chart_3d_pie_'.$spid.'_loop_'.self::$current_loop.'" name="chart_3d_pie" '.($settings['3d_pie']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 2, \'3d_pie\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }*/
+ }
+
+ // Nastavitve za number grafe (tip 7)
+ static function displayNumberSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 7, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_group_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_group_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_group_line'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="9" '.($settings['type']=='9'?' selected="selected"':'').'>'.$lang['srv_chart_avg_single'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // tip izpisa vrednosti
+ if($settings['type'] != 9){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 7, \'value_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // sortiranje
+ if($settings['type'] > 2 && $settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 7, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // stevilo intervalov
+ if($settings['type'] < 3){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_interval'].': <select id="chart_interval_'.$spid.'_loop_'.self::$current_loop.'" name="chart_interval" onchange="changeChart(\''.$spid.'\', 7, \'interval\', \''.self::$current_loop.'\');">';
+
+ for($i=3; $i<=10; $i++){
+ echo ' <option value="'.$i.'" '.($settings['interval']==$i ?' selected="selected"':'').'>'.$i.'</option>';
+ }
+ echo ' <option value="20" '.($settings['interval']=='20'?' selected="selected"':'').'>20</option>';
+ //echo ' <option value="50" '.($settings['interval']=='50'?' selected="selected"':'').'>50</option>';
+ //echo ' <option value="100" '.($settings['interval']=='100'?' selected="selected"':'').'>100</option>';
+ echo ' <option value="-1" '.($settings['interval']=='-1'?' selected="selected"':'').'>Vsi</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // prikaz legende
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_analiza_legenda'].': ';
+ echo '<input type="checkbox" id="chart_show_legend_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_legend" '.($settings['show_legend']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 7, \'show_legend\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // div z nastavitvami za zgornjo in spodnjo mejo
+ /*echo '<fieldset class="chart_num_limits"><legend>'.$lang['srv_chart_num_limit'].'</legend>';
+
+ // min
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_min'].': ';
+ echo '<input type="text" id="chart_min_'.$spid.'_loop_'.self::$current_loop.'" name="chart_min" value="'.$settings['min'].'" onBlur="changeChart(\''.$spid.'\', 7, \'min\', \''.self::$current_loop.'\');" onkeypress="checkNumber(this, 6, 0);" onkeyup="checkNumber(this, 6, 0);" />';
+
+ echo '</div>';
+
+ // polodprt interval navzdol
+ echo '<div class="chart_setting" style="text-align:right;">';
+
+ echo $lang['srv_chart_open_down'].': ';
+ echo '<input type="checkbox" id="chart_open_down_'.$spid.'_loop_'.self::$current_loop.'" name="chart_open_down" '.($settings['open_down']=='1'?' checked="checked"':'').' '.($settings['min']==''?' disabled="disabled"':'').' onchange="changeChart(\''.$spid.'\', 7, \'open_down\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // max
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_max'].': ';
+ echo '<input type="text" id="chart_max_'.$spid.'_loop_'.self::$current_loop.'" name="chart_max" value="'.$settings['max'].'" onBlur="changeChart(\''.$spid.'\', 7, \'max\', \''.self::$current_loop.'\');" onkeypress="checkNumber(this, 6, 0);" onkeyup="checkNumber(this, 6, 0);" />';
+
+ echo '</div>';
+
+ // polodprt interval navzgor
+ echo '<div class="chart_setting" style="text-align:right;">';
+
+ echo $lang['srv_chart_open_up'].': ';
+ echo '<input type="checkbox" id="chart_open_up_'.$spid.'_loop_'.self::$current_loop.'" name="chart_open_up" '.($settings['open_up']=='1'?' checked="checked"':'').' '.($settings['max']==''?' disabled="disabled"':'').' onchange="changeChart(\''.$spid.'\', 7, \'open_up\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ echo '</fieldset>';*/
+ }
+
+ // Nastavitve za number grafe (tip 7)
+ static function displayAdvancedNumberSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 7, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // prikaz povprecja
+ if($settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_avg']=='1' || ($settings['show_avg']=='-1' && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showAvg'].': ';
+ echo '<input type="checkbox" id="chart_show_avg_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_avg" '.$checked.' onchange="changeChart(\''.$spid.'\', 7, \'show_avg\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] != 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 7, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label majhnih vrednosti zraven stolpcov
+ if($settings['barLabel'] == 1 && $settings['type'] != 2 && $settings['type'] != 9){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabelSmall'].': ';
+ echo '<input type="checkbox" id="chart_barLabelSmall_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabelSmall" '.($settings['barLabelSmall']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 7, \'barLabelSmall\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 7, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za datum grafe (tip 8)
+ static function displayDateSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 8, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_group_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_group_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_line'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // tip izpisa vrednosti
+ if($settings['type'] < 3){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 8, \'value_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_day'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_month'].'</option>';
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_year'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // sortiranje
+ if($settings['type'] > 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 8, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // stevilo intervalov
+ if($settings['type'] < 3){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_interval'].': <select id="chart_interval_'.$spid.'_loop_'.self::$current_loop.'" name="chart_interval" onchange="changeChart(\''.$spid.'\', 8, \'interval\', \''.self::$current_loop.'\');">';
+
+ for($i=3; $i<=10; $i++){
+ echo ' <option value="'.$i.'" '.($settings['interval']==$i ?' selected="selected"':'').'>'.$i.'</option>';
+ }
+ echo ' <option value="20" '.($settings['interval']=='20'?' selected="selected"':'').'>20</option>';
+ //echo ' <option value="50" '.($settings['interval']=='50'?' selected="selected"':'').'>50</option>';
+ //echo ' <option value="100" '.($settings['interval']=='100'?' selected="selected"':'').'>100</option>';
+ echo ' <option value="-1" '.($settings['interval']=='-1'?' selected="selected"':'').'>Vsi</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // div z nastavitvami za zgornjo in spodnjo mejo
+ /*echo '<fieldset class="chart_num_limits"><legend>'.$lang['srv_chart_num_limit'].'</legend>';
+
+ // min
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_min'].': ';
+ echo '<input type="text" id="chart_min_'.$spid.'_loop_'.self::$current_loop.'" name="chart_min" value="'.$settings['min'].'" onBlur="changeChart(\''.$spid.'\', 8, \'min\', \''.self::$current_loop.'\');" onkeypress="checkNumber(this, 6, 0);" onkeyup="checkNumber(this, 6, 0);" />';
+
+ echo '</div>';
+
+ // polodprt interval navdol
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_open_down'].': ';
+ echo '<input type="checkbox" id="chart_open_down_'.$spid.'_loop_'.self::$current_loop.'" name="chart_open_down" '.($settings['open_down']=='1'?' checked="checked"':'').' '.($settings['min']==''?' disabled="disabled"':'').' onchange="changeChart(\''.$spid.'\', 8, \'open_down\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // max
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_max'].': ';
+ echo '<input type="text" id="chart_max_'.$spid.'_loop_'.self::$current_loop.'" name="chart_max" value="'.$settings['max'].'" onBlur="changeChart(\''.$spid.'\', 8, \'max\', \''.self::$current_loop.'\');" onkeypress="checkNumber(this, 6, 0);" onkeyup="checkNumber(this, 6, 0);" />';
+
+ echo '</div>';
+
+ // polodprt interval navgor
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_open_up'].': ';
+ echo '<input type="checkbox" id="chart_open_up_'.$spid.'_loop_'.self::$current_loop.'" name="chart_open_up" '.($settings['open_up']=='1'?' checked="checked"':'').' '.($settings['max']==''?' disabled="disabled"':'').' onchange="changeChart(\''.$spid.'\', 8, \'open_up\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ echo '</fieldset>';*/
+ }
+
+ // Nastavitve za datum grafe (tip 8)
+ static function displayAdvancedDateSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 8, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 8, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za multigrid grafe (tip 6)
+ static function displayMultigridSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 6, \'type\', \''.self::$current_loop.'\');">';
+
+ // Pri nominalnih ne prikazujemo povprecij
+ if($spremenljivka['skala'] != 1 && $spremenljivka['cnt_all'] != 1){
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_avg_hor'].'</option>';
+ echo ' <option value="5" '.($settings['type']=='5'?' selected="selected"':'').'>'.$lang['srv_chart_avg_radar'].'</option>';
+ echo ' <option value="6" '.($settings['type']=='6'?' selected="selected"':'').'>'.$lang['srv_chart_avg_line'].'</option>';
+ }
+ // Pri nominalnih pokazemo posebej radar
+ if($spremenljivka['skala'] == 1){
+ echo ' <option value="7" '.($settings['type']=='7'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+ }
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_structure_ver'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_structure_hor'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // Obrnjeni gridi in variable
+ if(($settings['type'] > 0 && $settings['type'] < 5) || $settings['type'] == 7){
+ echo '<div class="chart_setting">';
+ if($settings['rotate']=='1'){
+ echo $lang['srv_chart_rotate_grids'].' ';
+ //echo '<input type="checkbox" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" '.($settings['rotate']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');">';
+ echo '<span onclick="changeChart(\''.$spid.'\', 6, \'rotate\', \''.self::$current_loop.'\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" value="0">';
+ echo ' '.$lang['srv_chart_rotate_vars'].' ';
+ }
+ else{
+ echo $lang['srv_chart_rotate_vars'].' ';
+ //echo '<input type="checkbox" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" '.($settings['rotate']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');">';
+ echo '<span onclick="changeChart(\''.$spid.'\', 6, \'rotate\', \''.self::$current_loop.'\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" value="1">';
+ echo ' '.$lang['srv_chart_rotate_grids'];
+ }
+ echo '</div>';
+ }
+
+ // sortiranje - pri povprecjih sortiramo po velikosti (brez, narascajoce, padajoce)
+ if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 6, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+ // sortiranje - pri navadnih grafih za gride (ne povprecja) sortiramo po povprecju, 1. kategoriji ali kategorijah
+ else{
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 6, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_category'].'</option>';
+ if($settings['rotate']=='0')
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_avg'].'</option>';
+ echo ' <option value="3" '.($settings['sort']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_sort_first'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // tip izpisa vrednosti
+ if(($settings['type'] > 0 && $settings['type'] < 5) || $settings['type'] == 7){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 6, \'value_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Tip radarja
+ if($settings['type'] == 5 || $settings['type'] == 7){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="chart_radar_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_type" onchange="changeChart(\''.$spid.'\', 6, \'radar_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == 5 || $settings['type'] == 7){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="chart_radar_scale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_scale" onchange="changeChart(\''.$spid.'\', 6, \'radar_scale\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // prikaz desne skale pri sem. diferencialu (ver. linijski graf ali hor. strukturni stolpci)
+ if($spremenljivka['enota'] == 1 && ($settings['type'] == 2 || $settings['type'] == 6)){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_right_scale'].': ';
+ echo '<input type="checkbox" id="chart_scale_limit_'.$spid.'_loop_'.self::$current_loop.'" name="chart_scale_limit" '.($settings['scale_limit']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 6, \'scale_limit\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz legende - opcija samo pri povprecjih (drugje je vedno vklopljena)
+ if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_analiza_legenda'].': ';
+ echo '<input type="checkbox" id="chart_show_legend_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_legend" '.($settings['show_legend']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 6, \'show_legend\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 0 || $settings['type'] == 1 || $settings['type'] == 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 6, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za multigrid grafe (tip 6)
+ static function displayAdvancedMultigridSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 6, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 2 || $settings['type'] == 4){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 6, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // Izpusti variable brez odgovora
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_hideEmtyVar'].': ';
+ echo '<input type="checkbox" id="chart_hideEmptyVar_'.$spid.'_loop_'.self::$current_loop.'" name="chart_hideEmptyVar" '.($settings['hideEmptyVar']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 6, \'hideEmptyVar\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // prikaz label majhnih vrednosti zraven stolpcov
+ if($settings['barLabel'] == 1 && $settings['type'] == 0){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabelSmall'].': ';
+ echo '<input type="checkbox" id="chart_barLabelSmall_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabelSmall" '.($settings['barLabelSmall']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 6, \'barLabelSmall\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // zacni skalo z 0 (samo pri povprecju)
+ if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_noFixedScale'].': ';
+ echo '<input type="checkbox" id="chart_noFixedScale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_noFixedScale" '.($settings['noFixedScale']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 6, \'noFixedScale\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // Preklop med ordinalno in nominalno spremenljivko
+ echo '<div class="chart_setting">';
+
+ $lestvica = SurveyAnalysis::getSpremenljivkaLegenda($spremenljivka,'skalaAsValue');
+
+ echo $lang['srv_skala'].': ';
+ // Vprasajcek za pomoc
+ echo Help :: display('srv_skala_edit');
+
+ echo '<span class="spaceLeft"></span>';
+ echo '<a onclick="chartAdvancedSettingsSkala(\''.$spid.'\', \'0\', \''.self::$current_loop.'\'); return false;" href="#" title="'.$lang['srv_skala_long_0'].'"><span '.($lestvica == 0 ? ' class="strong"' : '').'>'.$lang['srv_skala_short_0'].'</span></a>';
+ echo '<span class="blue"> / </span>';
+ echo '<a onclick="chartAdvancedSettingsSkala(\''.$spid.'\', \'1\', \''.self::$current_loop.'\'); return false;" href="#" title="'.$lang['srv_skala_long_1'].'"><span '.($lestvica == 1 ? ' class="strong"' : '').'>'.$lang['srv_skala_short_1'].'</span></a>';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za dvojne multigrid grafe (tip 6, enota 3)
+ static function displayDoubleMultigridSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 62, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_line_hor'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_line_ver'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+
+
+ echo '</select>';
+ echo '</div>';
+
+ // Tip radarja
+ if($settings['type'] == '4'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="chart_radar_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_type" onchange="changeChart(\''.$spid.'\', 62, \'radar_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == '4'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="chart_radar_scale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_scale" onchange="changeChart(\''.$spid.'\', 62, \'radar_scale\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 0 || $settings['type'] == 1){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 62, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za dvojne multigrid grafe (tip 6, enota 3)
+ static function displayAdvancedDoubleMultigridSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 62, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 0){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 62, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // zacni skalo z 0
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_noFixedScale'].': ';
+ echo '<input type="checkbox" id="chart_noFixedScale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_noFixedScale" '.($settings['noFixedScale']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 62, \'noFixedScale\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za multicheckbox grafe (tip 16)
+ static function displayMulticheckboxSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // omejitev skale
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_base'].': <select id="chart_base_'.$spid.'_loop_'.self::$current_loop.'" name="chart_base" onchange="changeChart(\''.$spid.'\', 16, \'base\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['base']=='0'?' selected="selected"':'').'>'.$lang['srv_analiza_opisne_units'].'</option>';
+ echo ' <option value="1" '.($settings['base']=='1'?' selected="selected"':'').'>'.$lang['srv_analiza_opisne_arguments'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 16, \'type\', \''.self::$current_loop.'\');">';
+
+ if($settings['base'] == '1'){
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_structure_ver'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_structure_hor'].'</option>';
+ }
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ if($settings['base'] == '0'){
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+ }
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 16, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_category'].'</option>';
+ echo ' <option value="3" '.($settings['sort']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_sort_first'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+
+ // Obrnjeni gridi in variable
+ echo '<div class="chart_setting">';
+
+ if($settings['rotate']=='1'){
+ echo $lang['srv_chart_rotate_grids'].' ';
+ //echo '<input type="checkbox" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" '.($settings['rotate']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');">';
+ echo '<span onclick="changeChart(\''.$spid.'\', 16, \'rotate\', \''.self::$current_loop.'\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" value="0">';
+ echo ' '.$lang['srv_chart_rotate_vars'].' ';
+ }
+ else{
+ echo $lang['srv_chart_rotate_vars'].' ';
+ //echo '<input type="checkbox" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" '.($settings['rotate']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');">';
+ echo '<span onclick="changeChart(\''.$spid.'\', 16, \'rotate\', \''.self::$current_loop.'\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" value="1">';
+ echo ' '.$lang['srv_chart_rotate_grids'];
+ }
+ echo '</div>';
+
+ // Tip radarja
+ if($settings['type'] == '4'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="chart_radar_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_type" onchange="changeChart(\''.$spid.'\', 16, \'radar_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == '4'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="chart_radar_scale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_scale" onchange="changeChart(\''.$spid.'\', 16, \'radar_scale\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // tip izpisa vrednosti
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 16, \'value_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+ echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ if($settings['base'] == '0')
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 2 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 16, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za multicheckbox grafe (tip 16)
+ static function displayAdvancedMulticheckboxSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 16, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 16, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // Izpusti variable brez odgovora
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_hideEmtyVar'].': ';
+ echo '<input type="checkbox" id="chart_hideEmptyVar_'.$spid.'_loop_'.self::$current_loop.'" name="chart_hideEmptyVar" '.($settings['hideEmptyVar']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 16, \'hideEmptyVar\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za vsoto (tip 18)
+ static function displayVsotaSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 18, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_pie'].'</option>';
+ echo ' <option value="5" '.($settings['type']=='5'?' selected="selected"':'').'>'.$lang['srv_chart_3Dpie'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_line'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // Tip radarja
+ if($settings['type'] == '4'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="chart_radar_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_type" onchange="changeChart(\''.$spid.'\', 18, \'radar_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == '4'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="chart_radar_scale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_scale" onchange="changeChart(\''.$spid.'\', 18, \'radar_scale\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // sortiranje
+ if($settings['type'] != '4'){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 18, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // prikaz legende
+ if($settings['type'] == 0 || $settings['type'] == 5){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_analiza_legenda'].': ';
+ echo '<input type="checkbox" id="chart_show_legend_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_legend" '.($settings['show_legend']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 18, \'show_legend\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // prikaz label v stolpcih
+ if($settings['type'] == 2 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 18, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za vsoto (tip 18)
+ static function displayAdvancedVsotaSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 18, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 18, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // prikaz label majhnih vrednosti zraven stolpcov
+ if($settings['barLabel'] == 1 && ($settings['type'] == 2 || $settings['type'] == 3)){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabelSmall'].': ';
+ echo '<input type="checkbox" id="chart_barLabelSmall_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabelSmall" '.($settings['barLabelSmall']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 18, \'barLabelSmall\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // 3D strukturni krog
+ /*if($settings['type'] == 0){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_3d_pie'].': ';
+ echo '<input type="checkbox" id="chart_3d_pie_'.$spid.'_loop_'.self::$current_loop.'" name="chart_3d_pie" '.($settings['3d_pie']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 18, \'3d_pie\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }*/
+ }
+
+ // Nastavitve za ranking grafe (tip 17)
+ static function displayRankingSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 17, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_avg'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_structure_hor'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_structure_ver'].'</option>';
+ //echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_structure'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 17, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_desc'].'</option>';
+ echo ' <option value="2" '.($settings['sort']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_sort_asc'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+
+ // tip izpisa vrednosti
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="chart_value_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_value_type" onchange="changeChart(\''.$spid.'\', 17, \'value_type\', \''.self::$current_loop.'\');" '.($settings['type'] == 0 ? 'disabled="disabled"' : '').'>';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+ //echo ' <option value="2" '.($settings['value_type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_valid'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // prikaz label v stolpcih
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="chart_barLabel_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 17, \'barLabel\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za ranking grafe (tip 17)
+ static function displayAdvancedRankingSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 17, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 0 || $settings['type'] == 1){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 17, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+ // prikaz label majhnih vrednosti zraven stolpcov
+ if($settings['barLabel'] == 1 && $settings['type'] == 0){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabelSmall'].': ';
+ echo '<input type="checkbox" id="chart_barLabelSmall_'.$spid.'_loop_'.self::$current_loop.'" name="chart_barLabelSmall" '.($settings['barLabelSmall']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 17, \'barLabelSmall\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // zacni skalo z 0 (samo pri povprecju)
+ if($settings['type'] == 0){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_noFixedScale'].': ';
+ echo '<input type="checkbox" id="chart_noFixedScale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_noFixedScale" '.($settings['noFixedScale']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 17, \'noFixedScale\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za multinumber (tip 20)
+ static function displayMultinumberSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 20, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_line'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="chart_sort_'.$spid.'_loop_'.self::$current_loop.'" name="chart_sort" onchange="changeChart(\''.$spid.'\', 20, \'sort\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_category'].'</option>';
+ echo ' <option value="3" '.($settings['sort']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_sort_first'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+
+ // Obrnjeni gridi in variable
+ echo '<div class="chart_setting">';
+
+ if($settings['rotate']=='1'){
+ echo $lang['srv_chart_rotate_grids'].' ';
+ //echo '<input type="checkbox" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" '.($settings['rotate']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');">';
+ echo '<span onclick="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" value="0">';
+ echo ' '.$lang['srv_chart_rotate_vars'].' ';
+ }
+ else{
+ echo $lang['srv_chart_rotate_vars'].' ';
+ //echo '<input type="checkbox" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" '.($settings['rotate']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');">';
+ echo '<span onclick="changeChart(\''.$spid.'\', 20, \'rotate\', \''.self::$current_loop.'\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="chart_rotate_'.$spid.'_loop_'.self::$current_loop.'" name="chart_rotate" value="1">';
+ echo ' '.$lang['srv_chart_rotate_grids'];
+ }
+ echo '</div>';
+
+ // Tip radarja
+ if($settings['type'] == '0'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="chart_radar_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_type" onchange="changeChart(\''.$spid.'\', 20, \'radar_type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == '0'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="chart_radar_scale_'.$spid.'_loop_'.self::$current_loop.'" name="chart_radar_scale" onchange="changeChart(\''.$spid.'\', 20, \'radar_scale\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za multinumber (tip 20)
+ static function displayAdvancedMultinumberSettings($spid, $settings){
+ global $site_path;
+ global $lang;
+
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1' || ($settings['show_numerus']=='-1' && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1)) ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="chart_show_numerus_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_numerus" '.$checked.' onchange="changeChart(\''.$spid.'\', 20, \'show_numerus\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ // sirina label
+ if($settings['type'] == 2){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="chart_labelWidth_'.$spid.'_loop_'.self::$current_loop.'" name="chart_labelWidth" onchange="changeChart(\''.$spid.'\', 20, \'labelWidth\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="75" '.($settings['labelWidth']=='75'?' selected="selected"':'').'>75%</option>';
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za vse tabele
+ static function displayTableSettings($spid){
+ global $site_path;
+ global $lang;
+
+ // Tip tabele
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_table_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 21, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.(self::$settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_table_type_0'].'</option>';
+ echo ' <option value="1" '.(self::$settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_table_type_1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ //Poravnava texta
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_table_align'].': ';
+ echo '<input type="checkbox" id="chart_show_legend_'.$spid.'_loop_'.self::$current_loop.'" name="chart_show_legend" '.(self::$settings['show_legend']=='1'?' checked="checked"':'').' onchange="changeChart(\''.$spid.'\', 21, \'show_legend\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za vse multitext tabele
+ static function displayMultitextSettings($spid){
+ global $site_path;
+ global $lang;
+
+ // Tip tabele
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_table_type'].':<br /> <select style="width:140px;" id="chart_type_'.$spid.'_loop_'.self::$current_loop.'" name="chart_type" onchange="changeChart(\''.$spid.'\', 19, \'type\', \''.self::$current_loop.'\');">';
+
+ echo ' <option value="0" '.(self::$settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_table_type_0'].'</option>';
+ echo ' <option value="1" '.(self::$settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_table_type_1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Nastavitve za other tabele
+ static function displayOtherSettings($spid){
+ global $site_path;
+ global $lang;
+
+ echo '<div class="chart_settings_inner">';
+ echo '<span class="title">'.$lang['srv_chart_settings'].'</span>';
+
+ //Poravnava texta
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_table_align'].': ';
+ echo '<input type="checkbox" id="chart_other_otherType_'.$spid.'_loop_'.self::$current_loop.'" name="chart_other_otherType" '.(self::$settings['otherType']=='1'?' checked="checked"':'').' onchange="changeOther(\''.$spid.'\', \'otherType\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ //Prikaz frekvenc
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_table_freq'].': ';
+ echo '<input type="checkbox" id="chart_other_otherFreq_'.$spid.'_loop_'.self::$current_loop.'" name="chart_other_otherFreq" '.(self::$settings['otherFreq']=='1'?' checked="checked"':'').' onchange="changeOther(\''.$spid.'\', \'otherFreq\', \''.self::$current_loop.'\');">';
+
+ echo '</div>';
+
+ echo '</div>';
+ }
+
+
+ // Napredne nastavitve za posamezen graf (popup)
+ static function displayAdvancedSettings($spid){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ echo '<h2>'.$spremenljivka['variable'].' - '.$spremenljivka['naslov'].'</h2>';
+
+ echo '<div class="popup_close"><a href="#" onClick="chartCloseAdvancedSettings(); return false;">✕</a></div>';
+
+ echo '<form method="post" name="chart_advanced_settings" onsubmit="chartSaveAdvancedSettings(\''.$spid.'\', \''.self::$current_loop.'\'); return false;">';
+
+ echo '<input type="hidden" name="anketa" value="'.self::$anketa.'" />';
+ echo '<input type="hidden" name="spid" value="'.$spid.'" />';
+ echo '<input type="hidden" name="loop" value="'.self::$current_loop.'" />';
+ echo '<input type="hidden" name="spr_type" value="'.$spremenljivka['tip'].'" />';
+
+ // urejanje label
+ echo '<div id="chartSettingsArea1" class="chartSettingsArea">';
+ self::displayAdvancedSettingsLabels($spid);
+ echo '</div>';
+
+ // urejanje barv
+ echo '<div id="chartSettingsArea2" class="chartSettingsArea" style="visibility: hidden;">';
+ self::displayAdvancedSettingsColors($spid);
+ echo '</div>';
+
+ // urejanje mej pri numericih
+ if(($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)) || $spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 8 || $spremenljivka['tip'] == 22){
+ echo '<div id="chartSettingsArea4" class="chartSettingsArea" style="visibility: hidden;">';
+ self::displayAdvancedSettingsLimits($spid, self::$settings['limits']['advanced_settings']);
+ echo '</div>';
+ }
+
+ /* REKODIRANJE */
+ echo '<div id="chartSettingsArea3" class="chartSettingsArea" style="visibility: hidden;">';
+ $spr_id=explode('_',$spid);
+
+ $vmv = new RecodeValues(self::$anketa,$spr_id[0]);
+ $vmv->DisplayMissingValuesForQuestion(false);
+ echo '</div>';
+
+ echo '</form>';
+
+
+ /* ZAVIHKI NA DESNI */
+ echo '<div id="chartTabs" class="chartSettingsTabs">';
+
+ echo '<ul>';
+ echo '<li id="chartTab1" class="chartTab active" onClick="chartTabAdvancedSettings(\'1\');">';
+ echo $lang['srv_chart_advanced_labels'];
+ echo '</li>';
+ echo '<li id="chartTab2" class="chartTab" onClick="chartTabAdvancedSettings(\'2\');">';
+ echo $lang['srv_chart_advanced_colors'];
+ echo '</li>';
+ echo '<li id="chartTab3" class="chartTab" onClick="chartTabAdvancedSettings(\'3\');">';
+ echo $lang['srv_chart_advanced_recoding'];
+ echo '</li>';
+ // Tab za meje numericov
+ if(($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)) || $spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 8 || $spremenljivka['tip'] == 22){
+ echo '<li id="chartTab4" class="chartTab" onClick="chartTabAdvancedSettings(\'4\');">';
+ echo $lang['srv_chart_advanced_limits'];
+ echo '</li>';
+ }
+ echo '</ul>';
+
+ echo '</div>';
+
+
+ /* GUMBI NA DNU */
+ echo '<div id="chartSettingsButtons" class="buttons_holder">';
+
+ echo '<span class="buttonwrapper spaceRight floatLeft">';
+ echo '<a class="ovalbutton ovalbutton_gray" onclick="chartCloseAdvancedSettings(); return false;"><span>'.$lang['srv_zapri'].'</span></a>';
+ echo '</span>';
+
+ echo '<span class="buttonwrapper floatLeft">';
+ echo '<a class="ovalbutton ovalbutton_orange" onclick="chartSaveAdvancedSettings(\''.$spid.'\', \''.self::$current_loop.'\'); return false;">'.$lang['srv_potrdi'].'</a>';
+ echo '</span>';
+
+ echo '</div>';
+ }
+
+ // Urejanje barv posameznega grafa
+ static function displayAdvancedSettingsColors($spid){
+ global $site_path;
+ global $lang;
+
+ echo '<script type="text/javascript" charset="utf-8">
+ $(document).ready(function() {
+ var f = $.farbtastic(\'#picker\');
+ var p = $(\'#picker\').css(\'opacity\', 0.25);
+ var selected;
+ $(\'.colorwell\')
+ .each(function () { f.linkTo(this); $(this).css(\'opacity\', 0.75); })
+ .focus(function() {
+ if (selected) {
+ $(selected).css(\'opacity\', 0.75).removeClass(\'colorwell-selected\');
+ }
+ f.linkTo(this);
+ p.css(\'opacity\', 1);
+ $(selected = this).css(\'opacity\', 1).addClass(\'colorwell-selected\');
+ });
+ });
+ </script>';
+
+
+ echo ' <div id="picker" style="float: right;"></div>';
+
+ $default_colors = self::getDefaultColors(self::$skin);
+
+ for($i=0; $i<7; $i++){
+ $name = 'color'.($i+1);
+ $value = (self::$settings['colors'][$i] != '') ? self::$settings['colors'][$i] : $default_colors[$i];
+
+ echo ' <div class="form-item"><label for="'.$name.'">'.$lang['srv_color'].' '.($i+1).': </label><input type="text" id="'.$name.'" name="'.$name.'" class="colorwell" value="'.$value.'" /></div>';
+ }
+
+ // reset na default barvo
+ echo '<br /><span class="as_link clr" onClick="chartAdvancedSettingsSetColor(\''.(is_numeric(self::$skin) ? implode("_",$default_colors) : self::$skin).'\')">'.$lang['srv_chart_advanced_default_color'].'</span>';
+
+ // nastavitev ene od palet
+ echo '<br /><span class="clr">'.$lang['srv_chart_advanced_skin'].': ';
+ echo '<select name="chart_advanced_color" id="chart_advanced_color" onChange="chartAdvancedSettingsSetColor(this.value)">';
+ echo ' <option' . (self::$skin == '1ka' ? ' selected="selected"' : '') . ' value="1ka">'.$lang['srv_chart_skin_1ka'].'</option>';
+ echo ' <option' . (self::$skin == 'lively' ? ' selected="selected"' : '') . ' value="lively">'.$lang['srv_chart_skin_0'].'</option>';
+ echo ' <option' . (self::$skin == 'mild' ? ' selected="selected"' : '') . ' value="mild">'.$lang['srv_chart_skin_1'].'</option>';
+ echo ' <option' . (self::$skin == 'office' ? ' selected="selected"' : '') . ' value="office">'.$lang['srv_chart_skin_6'].'</option>';
+ echo ' <option' . (self::$skin == 'pastel' ? ' selected="selected"' : '') . ' value="pastel">'.$lang['srv_chart_skin_7'].'</option>';
+ echo ' <option' . (self::$skin == 'green' ? ' selected="selected"' : '') . ' value="green">'.$lang['srv_chart_skin_2'].'</option>';
+ echo ' <option' . (self::$skin == 'blue' ? ' selected="selected"' : '') . ' value="blue">'.$lang['srv_chart_skin_3'].'</option>';
+ echo ' <option' . (self::$skin == 'red' ? ' selected="selected"' : '') . ' value="red">'.$lang['srv_chart_skin_4'].'</option>';
+ echo ' <option' . (self::$skin == 'multi' ? ' selected="selected"' : '') . ' value="multi">'.$lang['srv_chart_skin_5'].'</option>';
+
+ $customSkins = self::getCustomSkins();
+ foreach($customSkins as $customSkin){
+ echo ' <option' . (self::$skin == $customSkin['id'] ? ' selected="selected"' : '') . ' value="'.$customSkin['colors'].'">'.$customSkin['name'].'</option>';
+ }
+
+
+ echo '</select></span>';
+
+ }
+
+ // Urejanje label posameznega grafa
+ static function displayAdvancedSettingsLabels($spid){
+ global $site_path;
+ global $lang;
+
+ $row = Cache::srv_spremenljivka($spid);
+ $disabled = ($row['edit_graf'] == 0) ? ' disabled="disabled"' : '';
+
+
+ echo '<div><p>';
+ echo $lang['srv_chart_advanced_useLabels'].':';
+ echo '<label for="edit_graf_0"><input type="radio" value="0" name="edit_graf" id="edit_graf_0" '.(($row['edit_graf'] == 0) ? ' checked="checked" ' : '').' onClick="edit_labels(\'0\');" />';
+ echo $lang['no'].'</label>';
+ echo ' <label for="edit_graf_1"><input type="radio" value="1" name="edit_graf" id="edit_graf_1" '.(($row['edit_graf'] == 1) ? ' checked="checked" ' : '').' onClick="edit_labels(\'1\');" />';
+ echo $lang['yes'].'</label>';
+ echo '</p></div>';
+
+
+ echo '<div class="chart_editing">';
+
+ // Urejanje naslova spremenljivke
+ $text = $row['naslov_graf'] == '<p></p>' ? $row['naslov'] : $row['naslov_graf'];
+ if (strtolower(substr($text, 0, 3)) == '<p>' && strtolower(substr($text, -4)) == '</p>' && strrpos($text, '<p>') == 0) {
+ $text = substr($text, 3);
+ $text = substr($text, 0, -4);
+ }
+ echo '<p>';
+ echo '<textarea style="width:99%; height:50px;" name="naslov_graf" id="naslov_graf" class="chart_label" '.$disabled.'>'.$text.'</textarea>';
+ echo '</p>';
+
+
+ // Urejanje label za gride
+ if($row['tip'] == 6 || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20){
+
+ echo '<div class="grid_settings">';
+ echo '<input type="hidden" name="edit_grid_graf" value="1" />';
+
+ echo '<table id="grids" style="width:100%">';
+
+ echo '<tr>';
+ for ($i=1; $i<=$row['grids']; $i++) {
+ echo '<td>'.$i.'</td>';
+ }
+
+ //dodatne vrednosti (ne vem, zavrnil...)
+ if (count($already_set_mv) > 0 ) {
+ echo '<td></td>';
+ if (count($missing_values) > 0) {
+ foreach ($missing_values AS $mv_key => $mv_text) {
+ if (isset($already_set_mv[$mv_key])) {
+ echo '<td>'.$mv_key.'</td>';
+ }
+ }
+ }
+ }
+ echo '</tr>';
+
+ echo '<tr>';
+ for ($i=1; $i<=$row['grids']; $i++) {
+ $sql1 = sisplet_query("SELECT naslov, naslov_graf FROM srv_grid WHERE id='$i' AND spr_id='$spid'");
+ $row1 = mysqli_fetch_array($sql1);
+ $text = $row1['naslov_graf'] == '' ? $row1['naslov'] : $row1['naslov_graf'];
+ echo '<td><input type="text" maxlength="30" name="grid_graf_'.$i.'" id="grid_naslov_'.$i.'_graf" class="chart_label" value="'.$text.'" '.$disabled.' /></td>';
+ }
+
+ //dodatne vrednosti (ne vem, zavrnil...)
+ if (count($already_set_mv) > 0 ) {
+ echo '<td></td>';
+ if (count($missing_values) > 0) {
+ foreach ($missing_values AS $mv_key => $mv_text) {
+ if (isset($already_set_mv[$mv_key])) {
+ echo '<td><input type="text" maxlength="30" name="grid_'.$mv_key.'_graf" class="chart_label" value="'.$already_set_mv[$mv_key].'" '.$disabled.' /></td>';
+ }
+ }
+ }
+ }
+ echo '</tr>';
+
+ echo '</table>';
+ echo '</div>';
+ }
+
+
+ // Urejanje naslovov variabel
+ $sql1 = sisplet_query("SELECT id, variable, naslov, REPLACE(REPLACE(REPLACE(naslov_graf,'\n',' '),'\r',' '),'|',' ') as naslov_graf, other FROM srv_vrednost WHERE spr_id = '$spid' ORDER BY vrstni_red ASC");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+
+ echo '<input type="hidden" name="edit_vrednost_graf" value="1" />';
+
+ echo '<div id="vrednosti_holder"><ul class="vrednost_sort">';
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $text = $row1['naslov_graf'] == '' ? $row1['naslov'] : $row1['naslov_graf'];
+
+ echo '<li id="vrednost_'.$vrednost.'" '.($row1['other'] == 1 ? 'class="li_other"' : '').'>';
+
+ echo '<textarea maxlength="30" name="vrednost_graf_'.$row1['id'].'" id="'.$row1['variable'].'_graf" class="vrednost_textarea chart_label" style="width:60%; height:15px;" '.$disabled.'>'.$text.'</textarea> ';
+ echo '['.$row1['variable'].']</span>';
+ if ($row1['other'] == 1) echo ' <input type="text" disabled style="width:40px" />';
+
+ echo '</li>';
+ }
+ echo '</ul></div>';
+
+ echo '<span class="red" style="font-size:11px;">'.$lang['srv_chart_advanced_labelsWarning'].'</span>';
+
+ echo '</div>';
+ }
+
+ // Urejanje mej za numericne tipe (radio dropdown number, number, date)
+ static function displayAdvancedSettingsLimits($spid, $mode=0){
+ global $site_path;
+ global $lang;
+
+ $spremenljivka = Cache::srv_spremenljivka($spid);
+ $limits = self::$settings['limits'];
+
+
+ // preklop med navadnimi mejami (zgornja/spodnja) in naprednimi (custom za vsak interval)
+ echo '<div class="chart_setting">';
+ echo '<span class="bold">'.$lang['srv_chart_num_limit_basic'].'<input type="radio" name="chart_number_limits_switch" value="0" '.($mode=='0'?' checked="checked"':'').' onClick="chartAdvancedSettingsLimitSwitch(\'0\');" /></span>';
+ echo '<span class="spaceLeft bold">'.$lang['srv_chart_num_limit_advanced'].'<input type="radio" name="chart_number_limits_switch" value="1" '.($mode=='1'?' checked="checked"':'').' onClick="chartAdvancedSettingsLimitSwitch(\'1\');" /></span>';
+ echo '</div>';
+
+
+ // OSNOVNE NASTAVITVE MEJ
+ echo '<div id="chart_number_limits_basic" '.($mode=='1'?' style="display:none;"':'').'>';
+
+ // stevilo intervalov
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_interval'].': <select id="chart_interval_'.$spid.'_loop_'.self::$current_loop.'" name="chart_interval">';
+
+ for($i=3; $i<=10; $i++){
+ echo ' <option value="'.$i.'" '.(self::$settings['interval']==$i ?' selected="selected"':'').'>'.$i.'</option>';
+ }
+ echo ' <option value="20" '.(self::$settings['interval']=='20'?' selected="selected"':'').'>20</option>';
+ echo ' <option value="-1" '.(self::$settings['interval']=='-1'?' selected="selected"':'').'>Vsi</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // Naslov "zgornja in spodnja meja"
+ echo '<div class="chart_setting">';
+ echo '<span class="bold">'.$lang['srv_chart_num_limit'].':</span>';
+ echo '</div>';
+
+ // min in polodprtost navzdol
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_min'].': ';
+ echo '<input type="text" id="chart_min_'.$spid.'_loop_'.self::$current_loop.'" name="chart_min" value="'.self::$settings['min'].'" onkeyup="checkNumber(this, 6, 2);" onkeypress="checkNumber(this, 6, 2);" />';
+
+ echo '<span style="padding-left:20px;">'.$lang['srv_chart_open_down'].': </span>';
+ echo '<input type="checkbox" id="chart_basic_open_down_'.$spid.'_loop_'.self::$current_loop.'" name="chart_basic_open_down" value="1" '.(self::$settings['open_down']=='1'?' checked="checked"':'').' />';
+
+ echo '</div>';
+
+ // max in polodprtost navzgor
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_max'].': ';
+ echo '<input type="text" id="chart_max_'.$spid.'_loop_'.self::$current_loop.'" name="chart_max" value="'.self::$settings['max'].'" onkeyup="checkNumber(this, 6, 2);" onkeypress="checkNumber(this, 6, 2);" />';
+
+ echo '<span style="padding-left:20px;">'.$lang['srv_chart_open_up'].': </span>';
+ echo '<input type="checkbox" id="chart_basic_open_up_'.$spid.'_loop_'.self::$current_loop.'" name="chart_basic_open_up" value="1" '.(self::$settings['open_up']=='1'?' checked="checked"':'').' />';
+
+ echo '</div>';
+ echo '</div>';
+
+
+ // NAPREDNE NASTAVITVE MEJ
+ echo '<div id="chart_number_limits_advanced" '.($mode=='0'?' style="display:none;"':'').'>';
+
+ // stevilo intervalov
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_interval'].': <select id="chart_interval_'.$spid.'_loop_'.self::$current_loop.'" name="chart_interval" onChange="chartAdvancedSettingsLimitInterval(this.value, \''.$spid.'\', \''.self::$current_loop.'\');">';
+
+ for($i=3; $i<=10; $i++){
+ echo ' <option value="'.$i.'" '.(self::$settings['interval']==$i ?' selected="selected"':'').'>'.$i.'</option>';
+ }
+ echo ' <option value="20" '.(self::$settings['interval']=='20'?' selected="selected"':'').'>20</option>';
+ echo ' <option value="-1" '.(self::$settings['interval']=='-1'?' selected="selected"':'').'>Vsi</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // Polodprtost navzdol
+ echo '<span style="padding-left:20px;">'.$lang['srv_chart_open_down'].': </span>';
+ echo '<input type="checkbox" id="chart_advanced_open_down_'.$spid.'_loop_'.self::$current_loop.'" name="chart_advanced_open_down" value="1" '.(self::$settings['open_down']=='1'?' checked="checked"':'').' />';
+
+ echo '<ul>';
+ for($i=0; $i<self::$settings['interval']; $i++){
+ echo '<li>';
+
+ echo '<span class="bold">'.$lang['interval'].' '. ($i+1) .': </span>';
+ echo '<span class="spaceLeft">'.$lang['srv_chart_num_limit_from'].' <input type="text" id="interval_'.$i.'_min_'.$spid.'_loop_'.self::$current_loop.'" name="interval_'.$i.'_min" value="'.$limits['interval_'.$i]['min'].'" class="advanced_interval" style="width:40px;" onBlur="chartAdvancedSettingsLimitLabel(\''.$i.'\', \''.$spid.'\', \''.self::$current_loop.'\'); chartAdvancedSettingsLimitCheck(\''.$i.'\', \''.$spid.'\', \''.self::$current_loop.'\');" onkeyup="checkNumber(this, 6, 2);" onkeypress="checkNumber(this, 6, 2);" /></span>';
+ echo '<span class="spaceLeft">'.$lang['srv_chart_num_limit_to'].' <input type="text" id="interval_'.$i.'_max_'.$spid.'_loop_'.self::$current_loop.'" name="interval_'.$i.'_max" value="'.$limits['interval_'.$i]['max'].'" class="advanced_interval" style="width:40px;" onBlur="chartAdvancedSettingsLimitLabel(\''.$i.'\', \''.$spid.'\', \''.self::$current_loop.'\'); chartAdvancedSettingsLimitCheck(\''.$i.'\', \''.$spid.'\', \''.self::$current_loop.'\');" onkeyup="checkNumber(this, 6, 2);" onkeypress="checkNumber(this, 6, 2);" /></span>';
+
+ // labela intervala
+ $label = ($limits['interval_'.$i]['label'] == '') ? $limits['interval_'.$i]['min'].'-'.$limits['interval_'.$i]['max'] : $limits['interval_'.$i]['label'];
+ echo '<span class="spaceLeft">'.$lang['srv_chart_num_limit_label'].': <input type="text" id="interval_'.$i.'_label_'.$spid.'_loop_'.self::$current_loop.'" name="interval_'.$i.'_label" value="'.$label.'" style="width:120px;" /></span>';
+
+ // Warningi, ce niso intervali v redu nastavljeni po velikosti
+ $show = ($limits['interval_'.$i]['min'] >= $limits['interval_'.$i]['max'] && $limits['interval_'.$i]['min'] != '' && $limits['interval_'.$i]['max'] != '') ? '' : ' style="display:none;"';
+ echo '<div id="chart_advanced_warning_1_interval_'.$i.'" class="chart_advanced_warning" '.$show.'>';
+ echo $lang['srv_chart_num_limit_warning1'];
+ echo '</div>';
+
+ $show = ($limits['interval_'.$i]['min'] <= $limits['interval_'. ($i-1) ]['max'] && $limits['interval_'.$i]['min'] != '' && $limits['interval_'. ($i-1) ]['max'] != '') ? '' : ' style="display:none;"';
+ echo '<div id="chart_advanced_warning_2_interval_'.$i.'" class="chart_advanced_warning" '.$show.'>';
+ echo $lang['srv_chart_num_limit_warning2'];
+ echo '</div>';
+
+ echo '</li>';
+ }
+ echo '</ul>';
+
+ // Polodprtost navzgor
+ echo '<span style="padding-left:20px;">'.$lang['srv_chart_open_up'].': </span>';
+ echo '<input type="checkbox" id="chart_advanced_open_up_'.$spid.'_loop_'.self::$current_loop.'" name="chart_advanced_open_up" value="1" '.(self::$settings['open_up']=='1'?' checked="checked"':'').' />';
+
+ echo '</div>';
+ }
+
+ // Izpis opozorila ce ni vnesenih podatkov in ne prikazujemo grafa
+ static function displayEmptyWarning($spid){
+
+ //$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // Naslov posameznega grafa
+ //echo '<div class="chart_title">Graf '.$spremenljivka['variable'].' nima veljavnih podatkov!</div>';
+ }
+
+ /** Izriše frekvence v vertikalni obliki
+ *
+ * @param unknown_type $spid
+ */
+ static function frequencyVertical($spid) {
+ global $lang;
+
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (SurveyAnalysis::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = (self::$num_records == 0) ? 10 : self::$num_records;
+ //$num_show_records = SurveyAnalysis::getNumRecords();
+
+ // ce imamo prazno in ne prikazujemo praznih tabel
+ $hideEmpty = SurveyDataSettingProfiles :: getSetting('hideEmpty');
+ if($hideEmpty == 1){
+
+ $emptyData = true;
+
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ if(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0)
+ $emptyData = false;
+ }
+ }
+
+ if($emptyData){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+ }
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'"></div>';
+
+ echo '<div id="freq_'.$spid.'_loop_'.self::$current_loop.'" class="freq_chart_table">';
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title.'</div>';
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_br anl_bb" style="font-size: '.(self::$fontSize+3).'px !important; padding:0px; margin-top:5px !important; border-collapse: collapse; width: 800px;">';
+
+ if(self::$settings['type']==1){
+ echo '<tr>';
+ #odgovori
+ echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$lang['srv_analiza_frekvence_titleAnswers'] . '</td>';
+ echo '<td class="anl_br anl_bb anl_ac anl_w70">'. $lang['srv_analiza_frekvence_titleFrekvenca'] .'</td>';
+
+ echo '</tr>';
+ // konec naslovne vrstice
+ }
+
+ $_answersOther = array();
+
+ # dodamo opcijo kje izrisujemo legendo
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'num_show_records' => $num_show_records);
+
+ # izpišemo vlejavne odgovore
+ $_current_grid = null;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true)
+ || (in_array($spremenljivka['tip'],array(4,8,21,22,25)))){
+ # dodamo ime podvariable
+ //if ($_variables_count > 1 && in_array($spremenljivka['tip'],array(2,6,7,16,17,18,19,20,21))) {
+ if ($inline_legenda) {
+ # ali rišemo dvojno črto med grupami
+ if ( $_current_grid != $gid && $_current_grid !== null && $spremenljivka['tip'] != 6) {
+ $options['doubleTop'] = true;
+ $_current_grid = $gid;
+ } else {
+ $options['doubleTop'] = false;
+ $_current_grid = $gid;
+ }
+ self::outputSubVariablaVertical($spremenljivka,$variable,$grid,$spid,$options);
+ }
+ $counter = 0;
+ $_kumulativa = 0;
+
+
+ #po potrebi posortiramo podatke
+ if (($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22) && is_array(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])) {
+ ksort(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']);
+ }
+ //SurveyAnalysis::$_FREQUENCYS[$_sequence]
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+
+ if ($counter < $num_show_records) {
+ if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
+ if (in_array($spremenljivka['tip'],array(4,7,8,19,20,21))) { // text, number, datum, mtext, mnumber, text*
+ $options['isTextAnswer'] = true;
+ } else {
+ $options['isTextAnswer'] = false;
+ }
+ $counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ }
+ }
+ # izpišemo sumo veljavnih
+ if(self::$settings['type'] == 1)
+ $counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 && self::$settings['type'] == 1) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ $counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ if(self::$settings['type'] == 1)
+ $counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</table>'.NEW_LINE;
+ echo '</div>';
+
+ // Izpisemo nastavitve za tabele
+ echo '<div class="chart_settings printHide iconHide" style="margin-top: 5px;">';
+ self::displaySingleSettings($spid);
+ echo '</div>';
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div id="chart_other_text_'.$spid.'_loop_'.self::$current_loop.'" class="chart_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+
+ echo '<div class="chart_settings other_settings printHide iconHide">';
+ self::displayOtherSettings($spid);
+ echo '</div>';
+ }
+ if (self::$returnChartAsHtml == false) {
+ ob_flush(); flush();
+ }
+ }
+
+ echo '</div>';
+ }
+
+ static function outputSubVariablaVertical($spremenljivka,$variable,$grid,$spid,$_options = array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'doubleTop' =>false, # ali imamo novo grupa in nardimo dvojni rob
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $css_bck = 'anl_bck_freq_2 ';
+ echo '<tr'.($options['doubleTop'] ? ' class="anl_double_bt"' : '').'>';
+
+ echo '<td class="anl_bl anl_bt anl_bb anl_br anl_al anl_str">';
+ echo $variable['naslov'];
+ echo '</td>';
+
+ if(self::$settings['type'] == 1)
+ echo '<td class="anl_bb anl_br anl_w70">&nbsp;</td>';
+
+ echo '</tr>';
+ }
+
+ static function outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,&$_kumulativa,$_options=array()) {
+ global $lang;
+ # opcije
+
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ $cssBck = ($counter % 2 == 1) ? ' anl_bck_0_0' : '';
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_kumulativa += $_valid;
+
+ echo '<tr id="'.$spid.'_'.$_sequence.'_'.$counter.'" name="valid_row_'.$_sequence.'" >';
+ //echo '<td class="anl_bl anl_ac anl_br gray">&nbsp;</td>';
+
+ if($options['isOtherAnswer'] == 1){
+ // poravnava celice
+ $cellAlign = (self::$settings['otherType'] == 0) ? ' anl_al' : ' anl_ac';
+
+ echo '<td class="anl_bl anl_br '.$cellAlign.' '.$cssBck.'">'.$vkey;
+
+ if(self::$settings['otherFreq'] == 1){
+ echo '<td class="anl_ac anl_br '.$cssBck.'">';
+ echo (int)$vAnswer['cnt'];
+ echo '</td>';
+ }
+ }
+ elseif(self::$settings['type'] == 0){
+ // poravnava celice
+ $cellAlign = (self::$settings['show_legend'] == 0) ? ' anl_al' : ' anl_ac';
+
+ echo '<td class="anl_bl anl_br '.$cellAlign.' '.$cssBck.'">'.$vkey;
+ }
+ else{
+ // poravnava celice
+ $cellAlign = (self::$settings['show_legend'] == 0) ? ' style="float: none;"' : '';
+
+ echo '<td class="anl_bl anl_br '.$cssBck.'">';
+ echo '<div class="anl_user_text_more_charts" '.$cellAlign.'>'.$vkey.'</div>';
+ echo (($options['isTextAnswer'] == false && (string)$vkey != $vAnswer['text']) ? ' ('.$vAnswer['text'] .')' : '');
+ }
+
+ if ( $counter+1 == $options['num_show_records'] && $options['num_show_records'] < count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])) {
+ echo '<div id="valid_row_togle_more_'.$_sequence.'" class="floatRight '.(self::$publicChart != true ? ' blue pointer' : '').' anl_more" onclick="showHidenTextTable(\''.$spid.'\', \''.$options['num_show_records'].'\', \''.self::$current_loop.'\');return false;">'.$lang['srv_anl_more'].'</div>'.NEW_LINE;
+ }
+ echo '</td>';
+
+ if(self::$settings['type'] == 1){
+ echo '<td class="anl_ac anl_br '.$cssBck.'">';
+ echo (int)$vAnswer['cnt'];
+ echo '</td>';
+ }
+
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaValidAnswerVertical($counter,$_sequence,$spid,$_options=array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $cssBck = ($counter % 2 == 1) ? ' anl_bck_0_0' : '';
+
+ $_brez_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0 ) ? TRUE : FALSE;
+ $_hide_minus = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2 ) ? TRUE : FALSE;
+ $value =((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0 ) ? 0 : 1;
+
+ $_sufix = (SurveyAnalysis::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(SurveyAnalysis::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.SurveyAnalysis::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="anl_click_missing_tr_'.$_sequence.$_sufix.'" class="'.($_brez_MV ? 'anl_bb' : 'anl_dash_red_bb').'">';
+
+ echo '<td class="anl_bl anl_br anl_al anl_ita red '.$cssBck.'" >'.$lang['srv_anl_suma1'].'</td>';
+
+ echo '<td class="anl_ita red anl_br anl_ac '.$cssBck.'" >';
+
+ echo SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ echo '</td>';
+
+ $_percent = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0
+ ? 100 * SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']
+ : 0;
+
+ echo '</tr>';
+ return $counter;
+
+ }
+
+ static function outputInvalidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_options=array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ //$cssBck = ' '.SurveyAnalysis::$cssColors['text_' . ($counter & 1)];
+ $cssBck = ($counter % 2 == 1) ? ' anl_bck_0_0' : '';
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $_sufix = (SurveyAnalysis::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(SurveyAnalysis::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.SurveyAnalysis::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ $_Z_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
+ echo '<tr name="missing_detail_'.$_sequence.$_sufix.'"'.($_Z_MV ? '': ' class="hidden"').'>';
+ //echo '<td class="anl_bl anl_br anl_ac gray" style="width:10px">&nbsp;</td>';
+ echo '<td class="anl_bl anl_br">';
+ echo '<div class="floatLeft"><div class="anl_tin2">'.'<span class="anl_user_text">' . $vkey . '</span>' . ' (' . $vAnswer['text'].')'.'</div></div>'.NEW_LINE;
+ echo '<div class="floatRight anl_detail_percent anl_w50 anl_ac anl_dash_bl">'.SurveyAnalysis::formatNumber($_invalid, 2, '%').'</div>'.NEW_LINE;
+ echo '<div class="floatRight anl_detail_percent anl_w30 anl_ac">'.$vAnswer['cnt'].'</div>'.NEW_LINE;
+ echo '</td>';
+
+ echo '<td class="anl_ac anl_br">';
+ echo (int)$vAnswer['cnt'];
+ echo '</td>';
+
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$_options = array()) {
+ global $lang;
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ //$cssBck = ' '.SurveyAnalysis::$cssColors['text_' . ($counter & 1)];
+ $cssBck = ' '.SurveyAnalysis::$cssColors['text_1'];
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $_brez_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+ $_hide_minus = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 1 || (int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+ $_sufix = (SurveyAnalysis::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(SurveyAnalysis::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.SurveyAnalysis::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="click_missing_1_'.$_sequence.$_sufix.'" class="anl_dash_red_bb'.($_brez_MV ?' hidden' : '').'">';
+
+ echo '<td class="anl_bl anl_br anl_ita red" >';
+ echo $lang['srv_analiza_manjkajocevrednosti'];
+ // podrobno za missinge
+ echo '<span id="single_missing_0'.$_sequence.$_sufix.'" class="printHide anl_ita anl_detail_percent'.($_hide_minus ? '' : ' hidden').'">&nbsp;&nbsp;';
+ echo '<a href="#single_missing_'.$_sequence.$_sufix.'" onclick="show_single_missing(\''.$_sequence.$_sufix.'\', 0);return false;" > ' ;
+ //echo $lang['srv_analiza_missingSpremenljivke'] ;
+ echo ' <span class="faicon plus_orange folder_plusminus"></span> </a>';
+ echo '</span>';
+ echo '<span id="single_missing_1'.$_sequence.$_sufix.'" class="printHide anl_ita anl_detail_percent'.($_hide_minus ? ' hidden' : '').'">&nbsp;&nbsp;';
+ echo '<a href="#single_missing_'.$_sequence.$_sufix.'" onclick="show_single_missing(\''.$_sequence.$_sufix.'\', 1);return false;" > ' ;
+ // echo $lang['srv_analiza_missingSpremenljivke'] ;
+ echo ' <span class="faicon minus_orange folder_plusminus"></span> </a>';
+ echo '</span>';
+
+ echo '<div id="single_missing_suma_'.$_sequence.$_sufix.'" class="floatRight anl_w50 anl_dash_bl anl_dash_bt anl_ac anl_detail_percent hidden">100.0%</div>'.NEW_LINE;
+ echo '<div id="single_missing_suma_freq_'.$_sequence.$_sufix.'" class="floatRight anl_w30 anl_dash_bt anl_ac anl_detail_percent hidden">'.SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'].'</div>'.NEW_LINE;
+ echo '</td>';
+
+ echo '<td class="anl_ac anl_br anl_detail_cnt anl_ita red">';
+ $answer['cnt'] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+ echo (int)$answer['cnt'];
+ echo '</td>';
+
+ echo '</tr>';
+ $counter++;
+ return $counter;
+ }
+
+ static function outputSumaVertical($counter,$_sequence,$spid, $_options = array()) {
+ global $lang;
+ # opcije
+
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $cssBck = ' anl_bck_text_0';
+ $_brez_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+ $_sufix = (SurveyAnalysis::$podstran == M_ANALYSIS_SUMMARY_NEW ? '_NEW' : '');
+ # da deluje razpiranje manjkajočih tudi kadar imamo skupine
+ if (isset(SurveyAnalysis::$_CURRENT_LOOP['cnt'])) {
+ $_sufix = '_loop'.SurveyAnalysis::$_CURRENT_LOOP['cnt'].$_sufix;
+ }
+
+ echo '<tr id="click_missing_suma_'.$_sequence.$_sufix.'" class="'.($_brez_MV ? 'hidden' : '').'">';
+
+ //echo '<td class="anl_bl anl_ac anl_dash_bt anl_bb red anl_ita'.$cssBck.'">'.$lang['srv_anl_suma2'].'</td>';
+ echo '<td class="anl_bl anl_dash_bt anl_br anl_bb">&nbsp;</td>';
+
+ echo '<td class="anl_ac anl_dash_bt anl_br anl_bb anl_ita red" >' . (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0) . '</td>';
+
+ echo '</tr>';
+ }
+
+ /** izpišemo tabelo z tekstovnimi odgovori drugo
+ *
+ * @param $skey
+ * @param $oAnswers
+ * @param $spid
+ */
+ static function outputOtherAnswers($oAnswers) {
+ global $lang;
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+ $_frekvence = SurveyAnalysis::$_FREQUENCYS[$_variable['sequence']];
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $_variable['variable'].' - ' : '');
+ $title = SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )';
+ echo '<div class="chart_title">'.$stevilcenje . $title.'</div>';
+
+
+ echo '<table class="anl_tbl anl_bt anl_br anl_bb" style="font-size: '.(self::$fontSize+3).'px !important; padding:0px; margin:0px; border-collapse: collapse;">' . NEW_LINE;
+
+ $counter = 0;
+ $_kumulativa = 0;
+ if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,array('isOtherAnswer'=>true));
+ }
+ }
+ # izpišemo sumo veljavnih
+ //$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ $counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,array('isOtherAnswer'=>true));
+ }
+ }
+ # izpišemo sumo veljavnih
+ //$counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ }
+ #izpišemo še skupno sumo
+ //$counter = self::outputSumaVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+
+ echo '</table>'.NEW_LINE;
+ }
+
+ /** Izriše tekstovne odgovore kot tabelo z navedbami
+ *
+ * @param unknown_type $spid
+ */
+ static function sumMultiText($spid) {
+ global $lang;
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
+ self::$sessionData[$spid] = $settings;
+ else
+ self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = (self::$num_records == 0) ? 10 : self::$num_records;
+
+ $_answers = SurveyAnalysis::getAnswers($spremenljivka,$num_show_records);
+
+ // ce imamo prazno in de prikazujemo praznih tabel
+ $hideEmpty = SurveyDataSettingProfiles :: getSetting('hideEmpty');
+ if($_answers['validCnt'] == 0 && $hideEmpty == 1){
+ self::displayEmptyWarning($spid);
+ return;
+ }
+
+ echo '<div class="chart_holder" id="chart_'.$spid.'_loop_'.self::$current_loop.'">';
+ //div za pozicijo popupa
+ echo '<div id="'.$spid.'"></div>';
+
+ echo '<div id="freq_'.$spid.'_loop_'.self::$current_loop.'" class="freq_chart_table">';
+
+ // Naslov posameznega grafa
+ $stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
+ echo '<div class="chart_title">'.$stevilcenje . $title.'</div>';
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+ # tekst vprašanja
+ echo '<table class="anl_tbl anl_bt anl_bb" style="font-size: '.(self::$fontSize+3).'px !important; padding:0px; margin:0px; border-collapse: collapse;">' . NEW_LINE;
+
+ # naslovna vrstica
+ if(self::$settings['type']==1){
+ echo '<tr>';
+ #odgovori
+ echo '<td class="anl_br anl_bl anl_bb anl_ac">'.$lang['srv_analiza_opisne_subquestion'] . '</td>';
+
+ echo '<td class="anl_br anl_bb anl_ac" colspan="'.($_cols).'">'. $lang['srv_analiza_opisne_arguments'] .'</td>';
+
+ echo '</tr>';
+ }
+ // konec naslovne vrstice
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0) {
+ # naslovna vrstica
+ $_row = $spremenljivka['grids'][0];
+ echo '<tr>';
+ echo '<td class="anl_bl anl_br anl_bb">&nbsp;</td>';
+
+ if (count($_row['variables'])>0)
+ foreach ($_row['variables'] AS $rid => $_col ){
+ $_sequence = $_col['sequence']; # id kolone z podatki
+ if ($_col['other'] != true) {
+ echo '<td class="anl_br anl_bb anl_ac anl_str">';
+ // echo $_col['variable'];
+ echo $_col['naslov'];
+ echo '</td>';
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ echo '</tr>';
+ $last = 0;
+ //anl_bck_desc_2 anl_bl anl_br anl_variabla_sub
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ echo '<tr class="anl_ac anl_bb">';
+ echo '<td class="anl_br anl_bl anl_ac anl_str">';
+ echo $grid['naslov'];
+ echo '</td>';
+
+ if ($_variables_count > 0) {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']));
+ }
+
+ # za barvanje
+ $last = ($last & 1) ? 0 : 1 ;
+
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ if ($variable['other'] != true) {
+
+ # tabela z navedbami
+ echo '<td class=" anl_at" style="padding: 0pt; margin: 0pt; border-collapse: collapse; vertical-align:top;" >';
+ echo '<table class="fullWidth anl_ac" style="padding:0; margin:0; border-collapse: collapse; vertical-align:top;">';
+
+ $index=0;
+ if (count($_valid_answers) > 0) {
+ foreach ($_valid_answers AS $answer) {
+
+ $cssBck = ($index % 2 == 1) ? ' anl_bck_0_0' : '';
+
+ $index++;
+ $_ans = $answer[$_sequence];
+ echo '<tr>';
+ echo '<td class="anl_br '.$cssBck.'">';
+ if ($_ans != null && $_ans != '') {
+ echo $_ans;
+ } else {
+ echo '&nbsp;';
+ }
+ echo '</td>';
+ echo '</tr>';
+ }
+ }
+ if ($_all_valid_answers_cnt > $index) {
+ $index++;
+ echo '<tr>';
+ echo '<td class="anl_br anl_user_text">';
+ echo '<div id="valid_row_togle_more_'.$vid.'" class="floatRight '.(self::$publicChart != true ? ' blue pointer' : '').' anl_more" onclick="showHidenTextTable(\''.$spid.'\', \''.$num_show_records.'\', \''.self::$current_loop.'\');return false;">'.$lang['srv_anl_more'].'</div>'.NEW_LINE;
+ echo '</td>';
+ echo '</tr>';
+ }
+
+ echo '</table>';
+
+ echo '</td>';
+ }
+ }
+ $last = $_max_i;
+ }
+ echo '</tr>';
+ }
+ }
+ echo '</table>'.NEW_LINE;
+ echo '</div>';
+
+ // Izpisemo nastavitve za tabele
+ echo '<div class="chart_settings printHide iconHide" style="margin-top: 5px;">';
+ self::displaySingleSettings($spid);
+ echo '</div>';
+
+ echo '</div>';
+ }
+
+
+ /** Funkcije ki skrbijo za ajax del
+ *
+ */
+ public static function ajax() {
+ global $global_user_id;
+
+
+ if (isset ($_POST['anketa'])) {
+ $anketa = $_POST['anketa'];
+ self::$anketa = $_POST['anketa'];
+ }
+ if (isset ($_POST['spid']))
+ $spid = $_POST['spid'];
+ if (isset ($_POST['spr_type']))
+ $spr_type = $_POST['spr_type'];
+
+
+ // Ce imamo nastavljene loope (Skupine) - potem nastavimo trenuten loop v katerem se nahaja graf
+ self::$current_loop = (isset ($_POST['loop'])) ? $_POST['loop'] : 'undefined';
+ if(self::$current_loop != 'undefined'){
+ SurveyAnalysis::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+
+ $loop = SurveyAnalysis::$_LOOPS[ (int)self::$current_loop-1 ];
+ $loop['cnt'] = self::$current_loop;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+ }
+
+ SurveyAnalysis::$podstran = 'charts';
+ SurveyAnalysis::getFrequencys();
+
+ if (isset ($_POST['settings_mode']))
+ self::$settings_mode = $_POST['settings_mode'];
+
+
+ // dobimo vse nastavitve iz sessiona
+ if(self::$current_loop != 'undefined'){
+ if(isset(self::$sessionData[$spid][self::$current_loop]))
+ self::$settings = self::$sessionData[$spid][self::$current_loop];
+ else
+ self::$settings = self::getDefaultSettings();
+ }
+ else{
+ if(isset(self::$sessionData[$spid]))
+ self::$settings = self::$sessionData[$spid];
+ else
+ self::$settings = self::getDefaultSettings();
+ }
+
+
+
+ if (isset ($_POST['what']))
+ $what = $_POST['what'];
+ if (isset ($_POST['value']))
+ $value = $_POST['value'];
+
+ self::$settings[$what] = $value;
+
+
+ if (isset ($_POST['num_records'])){
+ $textAnswersMore = array('0'=>'10','10'=>'30','30'=>'300','300'=>'600','600'=>'900','900'=>'100000');
+ self::$num_records = $textAnswersMore[$_POST['num_records']];
+ }
+ if ($_GET['a'] == 'change_chart') {
+
+ switch ($spr_type) {
+ case 1: # radio
+ case 3: # dropdown
+ self::displayRadioChart($spid, self::$settings, $refresh=1);
+ break;
+ case 2: #checkbox
+ self::displayCheckboxChart($spid, self::$settings, $refresh=1);
+ break;
+ case 6: # multigrid
+ self::displayMultigridChart($spid, self::$settings, $refresh=1);
+ break;
+ case 62: # dvojni multigrid
+ self::displayDoubleMultigridChart($spid, self::$settings, $refresh=1);
+ break;
+ case 7: # število
+ case 22: # compute
+ self::displayNumberChart($spid, self::$settings, $refresh=1);
+ break;
+ case 8: # datum
+ self::displayDateChart($spid, self::$settings, $refresh=1);
+ break;
+ case 16: # multicheckbox
+ self::displayMulticheckboxChart($spid, self::$settings, $refresh=1);
+ break;
+ case 17: # razvrščanje
+ self::displayRankingChart($spid, self::$settings, $refresh=1);
+ break;
+ case 20: # multi number
+ self::displayMultinumberChart($spid, self::$settings, $refresh=1);
+ //self::frequencyVertical($spid);
+ break;
+ case 18: # vsota
+ self::displayVsotaChart($spid, self::$settings, $refresh=1);
+ break;
+ case 4: # text
+ case 5: # nagovor
+ case 21: # besedilo*
+ case 25: # kvota
+ self::frequencyVertical($spid);
+ break;
+ case 19: # multitext
+ self::sumMultiText($spid);
+ break;
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData(self::$sessionData, 'charts');
+ }
+
+ // nastavitve tabel za drugo
+ if($_GET['a'] == 'change_other'){
+
+ if(self::$current_loop != 'undefined'){
+ self::$sessionData[$spid][self::$current_loop][$what] = $value;
+ self::$settings = self::$sessionData[$spid][self::$current_loop];
+ }
+ else{
+ self::$sessionData[$spid][$what] = $value;
+ self::$settings = self::$sessionData[$spid];
+ }
+
+ // Napolnimo podatke za graf
+ $DataSet = self::getDataSet($spid, self::$settings);
+
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ self::outputOtherAnswers($oAnswers);
+ }
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData(self::$sessionData, 'charts');
+ }
+
+ // Brisanje cacha za grafe
+ if ($_GET['a'] == 'clear_cache') {
+
+ self::clearCache();
+ }
+
+ if ($_GET['a'] == 'show_spid_more_table') {
+
+ // tabela besedilo
+ if(SurveyAnalysis::$_HEADERS[$spid]['tip'] == 19)
+ self::sumMultiText($spid);
+
+ // navadno besedilo
+ else
+ self::frequencyVertical($spid);
+ }
+
+ if ($_GET['a'] == 'chart_advanced_settings') {
+ self::displayAdvancedSettings($spid);
+ }
+
+ if ($_GET['a'] == 'change_hq_settings') {
+
+ self::$sessionData['hq'] = $value;
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData(self::$sessionData, 'charts');
+ }
+
+ if ($_GET['a'] == 'chart_save_advanced_settings') {
+
+ # shranimo rekodiranje in po potrebi popravimo datoteko s podatki
+ if ((int)$spid > 0 && (int)self::$anketa > 0) {
+ # Shranimo zamenjave manjkajočih vrednosti pri posameznem vprašanu za analize
+ if (isset($_REQUEST['edit_recode_mv']) || isset($_REQUEST['edit_recode_number'])) {
+ $vmv = new RecodeValues(self::$anketa,$spid);
+ $dataChanged = $vmv->SetUpMissingValuesForQuestion();
+ //print_r("changed:".(int)$dataChanged );
+ if ($dataChanged == true ) {
+ $SDF = SurveyDataFile::get_instance();
+ $SDF->init(self::$anketa);
+ //print_r("new:".$createdNewFile);
+ self::$headFileName = $SDF->getHeaderFileName();
+ self::$dataFileName = $SDF->getDataFileName();
+ self::$dataFileStatus = $SDF->getStatus();
+ }
+ }
+ }
+
+ // headers, ki ga popravimo in prepisemo originalnega (zaradi refresha label)
+ $newHeaders = SurveyAnalysis::$_HEADERS;
+
+
+ // SHRANIMO BARVE
+ // preverimo najprej ce shranjujemo vrednosti, ki so enake kot izbran skin
+ $default = true;
+ $default_colors = self::getDefaultColors(self::$skin);
+ for($i=1; $i<8; $i++){
+ if($_POST['color'.$i] != $default_colors[$i-1]){
+ $default = false;
+ break;
+ }
+ }
+ for($i=1; $i<8; $i++){
+
+ // ce niso default vrednosti shranimo nastavljeno barvo
+ if($default == false)
+ $color = $_POST['color'.$i];
+ // ce so default vrednosti shranimo prazno
+ else
+ $color = '';
+
+ self::$settings['colors'][$i-1] = $color;
+ }
+
+
+ // SHRANIMO MEJE
+ if (isset($_POST['chart_interval'])) {
+
+ $limits = array();
+
+ $interval = $_POST['chart_interval'];
+ self::$settings['interval'] = $interval;
+
+ if (isset($_POST['chart_number_limits_switch']))
+ $limits['advanced_settings'] = $_POST['chart_number_limits_switch'];
+
+
+ // Shranjevanje osnovnih nastavitev mej pri number
+ if($limits['advanced_settings'] == 0){
+
+ // shranimo polodprtost
+ self::$settings['open_down'] = (isset($_POST['chart_basic_open_down']) && self::$settings['min'] != '' && $_POST['chart_basic_open_down'] == '1') ? 1: 0;
+ self::$settings['open_up'] = (isset($_POST['chart_basic_open_up']) && self::$settings['max'] != '' && $_POST['chart_basic_open_up'] == '1') ? 1 : 0;
+
+ if (isset($_POST['chart_min']))
+ self::$settings['min'] = $_POST['chart_min'];
+
+ if (isset($_POST['chart_max']))
+ self::$settings['max'] = $_POST['chart_max'];
+
+ self::$settings['limits'] = $limits;
+ }
+
+ // Shranjevanje naprednih nastavitev mej pri number
+ else{
+ for($i=0; $i<$interval; $i++){
+
+ // shranimo polodprtost
+ self::$settings['open_down'] = (isset($_POST['chart_advanced_open_down']) && $_POST['chart_advanced_open_down'] == '1') ? 1 : 0;
+ self::$settings['open_up'] = (isset($_POST['chart_advanced_open_up']) && $_POST['chart_advanced_open_up'] == '1') ? 1 : 0;
+
+ // Minimum posameznega intervala
+ if (isset($_POST['interval_'.$i.'_min']))
+ $limits['interval_'.$i]['min'] = $_POST['interval_'.$i.'_min'];
+
+ // Maximuma posameznega intervala
+ if (isset($_POST['interval_'.$i.'_max']))
+ $limits['interval_'.$i]['max'] = $_POST['interval_'.$i.'_max'];
+
+ // Labela posameznega intervala
+ if (isset($_POST['interval_'.$i.'_label']))
+ $limits['interval_'.$i]['label'] = $_POST['interval_'.$i.'_label'];
+ }
+
+
+ self::$settings['limits'] = $limits;
+ }
+ }
+
+
+ // SHRANIMO LABELE
+ if (isset($_POST['edit_graf'])) {
+ $edit_graf = $_POST['edit_graf'];
+
+ $s = sisplet_query("UPDATE srv_spremenljivka SET edit_graf='$edit_graf' WHERE id='$spid'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ // popravimo upostevanje label v HEADER
+ $newHeaders[$spid]['edit_graf'] = $edit_graf;
+ }
+
+ // naslov spremenljivke za graf
+ if (isset($_POST['naslov_graf'])) {
+ $naslov = $_POST['naslov_graf'];
+ /*if (strtolower(substr($naslov, 0, 3)) != '<p>' && strtolower(substr($naslov, -4)) != '</p>' && strrpos($naslov, '<p>') === false) {
+ //$naslov = '<p>'.nl2br($naslov).'</p>';
+ $naslov = '<p>' . str_replace("\n", "</p>\n<p>", $naslov) . '</p>';
+ }*/
+
+ /*$purifier = New Purifier();
+ $naslov = $purifier->purify_DB($naslov);*/
+
+ $s = sisplet_query("UPDATE srv_spremenljivka SET naslov_graf='$naslov' WHERE id='$spid'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ // popravimo naslov spremenljivke v HEADER
+ $newHeaders[$spid]['naslov_graf'] = $naslov;
+ }
+
+ // shrani dodatne naslove variabel za graf
+ if (isset($_POST['edit_vrednost_graf'])) {
+
+ $i = 1;
+ foreach ($_POST as $key => $v) {
+
+ if (substr($key, 0, 14) == 'vrednost_graf_') {
+ $vrednost = substr($key, 14);
+
+ $naslov = str_replace(array('\n', '\t', '\r'), '', $_POST['vrednost_graf_'.$vrednost]);
+
+ $s = sisplet_query("UPDATE srv_vrednost SET naslov_graf='".$naslov."' WHERE id = '$vrednost'");
+
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+
+ // Popravimo variable v HEADER
+ if($spr_type == 1 || $spr_type == 3){
+ $newHeaders[$spid]['options_graf'][$i] = $naslov;
+ }
+ elseif($spr_type == 6 ){
+ $newHeaders[$spid]['grids'][$i-1]['variables'][0]['naslov_graf'] = $naslov;
+ }
+ elseif($spr_type == 16 || $spr_type == 20){
+ $newHeaders[$spid]['grids'][$i-1]['naslov_graf'] = $naslov;
+ }
+ elseif($spr_type != 7 || $i < 3){
+ $newHeaders[$spid]['grids'][0]['variables'][$i-1]['naslov_graf'] = $naslov;
+ }
+
+ $i++;
+ }
+ }
+ }
+
+ // shrani dodatne naslove gridov za graf
+ if (isset($_POST['edit_grid_graf'])) {
+
+ $vrstni_red = 0;
+ foreach ($_POST as $key => $v) {
+ if (substr($key, 0, 10) == 'grid_graf_') {
+ $vrstni_red++;
+
+ $grid = substr($key, 10);
+ $naslov = $_POST['grid_graf_'.$grid];
+ $variable = $grid;
+ $id= $vrstni_red;
+
+ $other = '0';
+ # manjkoajoče vrednosti (ne vem, zavrnil ...
+ if (isset($_POST['missing_value_checkbox']) && is_array($_POST['missing_value_checkbox'])) {
+ if (in_array($grid, $_POST['missing_value_checkbox'])) {
+ # grid je manjkajoča vrednost
+ $other = $grid.'';
+ $id = $grid;
+ }
+ }
+ $s = sisplet_query("UPDATE srv_grid SET naslov_graf='$naslov' WHERE id='$id' AND spr_id='$spid'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+
+ // Popravimo gride v HEADER
+ if($spr_type == 6 ){
+ $newHeaders[$spid]['options_graf'][$vrstni_red] = $naslov;
+ }
+ elseif($spr_type == 16 || $spr_type == 20){
+
+ foreach($newHeaders[$spid]['grids'] as $grdKey => $grdVal){
+ $newHeaders[$spid]['grids'][$grdKey]['variables'][$vrstni_red-1]['naslov_graf'] = $naslov;
+ }
+ }
+ }
+ }
+ }
+
+
+ // pobrisemo star header
+ if (file_exists(self::$headFileName))
+ unlink(self::$headFileName);
+
+ // shranimo popravljen headers v novo datoteko
+ file_put_contents(self::$headFileName, serialize($newHeaders));
+
+ SurveyAnalysis::$podstran = 'charts';
+ SurveyAnalysis::$_HEADERS = $newHeaders;
+ SurveyAnalysis::getFrequencys();
+
+
+ // Na novo zgeneriramo graf
+ switch ($spr_type) {
+ case 1: # radio
+ case 3: # dropdown
+ self::displayRadioChart($spid, self::$settings, $refresh=1);
+ break;
+ case 2: #checkbox
+ self::displayCheckboxChart($spid, self::$settings, $refresh=1);
+ break;
+ case 6: # multigrid
+ self::displayMultigridChart($spid, self::$settings, $refresh=1);
+ break;
+ case 62: # dvojni multigrid
+ self::displayDoubleMultigridChart($spid, self::$settings, $refresh=1);
+ break;
+ case 22: # compute
+ case 7: # število
+ self::displayNumberChart($spid, self::$settings, $refresh=1);
+ break;
+ case 8: # datum
+ self::displayDateChart($spid, self::$settings, $refresh=1);
+ break;
+ case 16: # multicheckbox
+ self::displayMulticheckboxChart($spid, self::$settings, $refresh=1);
+ break;
+ case 17: # razvrščanje
+ self::displayRankingChart($spid, self::$settings, $refresh=1);
+ break;
+ case 20: # multi number
+ self::displayMultinumberChart($spid, self::$settings, $refresh=1);
+ //self::frequencyVertical($spid);
+ break;
+ case 18: # vsota
+ self::displayVsotaChart($spid, self::$settings, $refresh=1);
+ break;
+ case 4: # text
+ case 5: # nagovor
+ case 21: # besedilo*
+ case 25: # kvota
+ self::frequencyVertical($spid);
+ break;
+ case 19: # multitext
+ self::sumMultiText($spid);
+ break;
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData(self::$sessionData, 'charts');
+ }
+
+ // spremenimo skalo spremenljivke (ordinalna/nominalna)
+ if ($_GET['a'] == 'chart_advanced_settings_skala') {
+
+ $spremenljivka = $_POST['spid'];
+ $skala = $_POST['skala'];
+
+ # popravimo skalo spremenljivke
+ # skala - 0 Ordinalna
+ # skala - 1 Nominalna
+ if ( isset($skala) && (int)$spremenljivka) {
+ $sql = sisplet_query("UPDATE srv_spremenljivka SET skala='".$skala."' WHERE id='$spremenljivka'");
+
+ # popravimo v header datoteki
+ SurveyAnalysis::$_HEADERS[$spremenljivka]['skala'] = $skala;
+ file_put_contents(self::$headFileName, serialize(SurveyAnalysis::$_HEADERS));
+ }
+ }
+
+ // Globalne nastavitve za vse grafe
+ if ($_GET['a'] == 'save_global_settings') {
+
+ SurveyUserSetting :: getInstance()->saveSettings('default_chart_profile_'.$what, $value);
+ }
+
+ // Odpremo okno za izbiro globalnega skina
+ if($_GET['a'] == 'analiza_show_chart_color') {
+
+ $skin = (SurveyUserSetting::getInstance()->getSettings('default_chart_profile_skin') == null ? '1ka' : SurveyUserSetting::getInstance()->getSettings('default_chart_profile_skin'));
+
+ self::displaySettingsProfiles($skin);
+ }
+
+ // Spreminjamo globalen skin
+ if($_GET['a'] == 'analiza_change_chart_color') {
+
+ //$skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
+ if (isset ($_POST['skin']))
+ $skin = $_POST['skin'];
+
+ self::displaySettingsProfiles($skin);
+ }
+
+ // Preimenujemo globalen skin
+ if($_GET['a'] == 'renameSkin') {
+
+ if (isset ($_POST['id']))
+ $id = $_POST['id'];
+ if (isset ($_POST['name']))
+ $name = $_POST['name'];
+
+ $s = sisplet_query("UPDATE srv_chart_skin SET name='$name' WHERE id='$id'");
+
+ self::displaySettingsProfiles($id);
+ }
+
+ // Pobrisemo globalen skin
+ if($_GET['a'] == 'deleteSkin') {
+
+ if (isset ($_POST['id']))
+ $id = $_POST['id'];
+
+ $s = sisplet_query("DELETE FROM srv_chart_skin WHERE id='$id'");
+
+ self::displaySettingsProfiles();
+ }
+
+ // Dodamo nov globalen skin
+ if($_GET['a'] == 'newSkin') {
+
+ if (isset ($_POST['name']))
+ $name = $_POST['name'];
+ if (isset ($_POST['colors']))
+ $colors = $_POST['colors'];
+
+ $s = sisplet_query("INSERT INTO srv_chart_skin (name, colors, usr_id) VALUES('$name', '$colors', '$global_user_id')");
+ $id = mysqli_insert_id($GLOBALS['connect_db']);
+
+ self::displaySettingsProfiles($id);
+ }
+
+ // Popravimo obstojec custom skin
+ if($_GET['a'] == 'editSkin') {
+
+ if (isset ($_POST['id']))
+ $id = $_POST['id'];
+ if (isset ($_POST['colors']))
+ $colors = $_POST['colors'];
+
+ $s = sisplet_query("UPDATE srv_chart_skin SET colors='$colors' WHERE id='$id'");
+ }
+
+ // Preklop stevila intervalov pri mejah v naprednih nastavitvah
+ if($_GET['a'] == 'analiza_num_limit_interval') {
+
+ if (isset ($_POST['interval']))
+ self::$settings['interval'] = $_POST['interval'];
+
+ self::displayAdvancedSettingsLimits($spid, $mode=1);
+ }
+
+ echo '<script>charts_init();</script>';
+ }
+
+ static function setUpReturnAsHtml($returnAsHtml = false) {
+ self::$returnChartAsHtml = $returnAsHtml; # ali vrne rezultat analiz kot html ali ga izpiše
+ }
+
+ static function setUpIsForArchive($isArchive = false) {
+ #nastavimo timestamp, katerega dodamo imenu slike, za unikatnost
+ list($usec, $sec) = explode(" ", microtime());
+ self::$chartArchiveTime = $sec;
+ self::$isArchive = $isArchive; # nastavimo da smo v arhivu
+ return self::$chartArchiveTime;
+ }
+
+
+ static function displaySettingsProfiles($skin='1ka'){
+ global $site_path;
+ global $lang;
+
+
+ echo '<h2 style="margin-bottom:5px;">'.$lang['srv_chart_skin_long'].'</h2>';
+ echo '<span style="font-size: 12px; font-style: italic;">'.$lang['srv_chart_skin_info'].'</span><br/><br/>';
+
+ // Opozorilo na vrhu
+ if(!is_numeric($skin)){
+ echo '<div id="chart_skin_note">';
+ echo $lang['srv_chart_skin_warning'];
+ echo '</div>';
+ echo '<br class="clr" />'."\n";
+ }
+
+ echo '<script type="text/javascript" charset="utf-8">
+ $(document).ready(function() {
+ var f = $.farbtastic(\'#picker\');
+ var p = $(\'#picker\').css(\'opacity\', 0.25);
+ var selected;
+ $(\'.colorwell\')
+ .each(function () { f.linkTo(this); $(this).css(\'opacity\', 0.75); })
+ .focus(function() {
+ if (selected) {
+ $(selected).css(\'opacity\', 0.75).removeClass(\'colorwell-selected\');
+ }
+ f.linkTo(this);
+ p.css(\'opacity\', 1);
+ $(selected = this).css(\'opacity\', 1).addClass(\'colorwell-selected\');
+ });
+ });
+ </script>';
+
+
+ echo '<div id="chart_settings_profiles_left">';
+
+ // Prednastavljeni skini
+ echo '<span class="bold">'.$lang['srv_chart_skin_default'].':</span>';
+ echo '<span class="chart_profiles_holder" style="margin-bottom: 10px; height: 144px;">';
+ echo '<span id="chart_profiles" class="chart_profiles select">';
+
+ echo '<div class="option'.($skin == '1ka' ? ' active' : '').'" id="chart_profile_skin_1ka" value="1ka">'.$lang['srv_chart_skin_1ka'].'</div>';
+ echo '<div class="option'.($skin == 'lively' ? ' active' : '').'" id="chart_profile_skin_0" value="lively">'.$lang['srv_chart_skin_0'].'</div>';
+ echo '<div class="option'.($skin == 'mild' ? ' active' : '').'" id="chart_profile_skin_1" value="mild">'.$lang['srv_chart_skin_1'].'</div>';
+ echo '<div class="option'.($skin == 'office' ? ' active' : '').'" id="chart_profile_skin_6" value="office">'.$lang['srv_chart_skin_6'].'</div>';
+ echo '<div class="option'.($skin == 'pastel' ? ' active' : '').'" id="chart_profile_skin_7" value="pastel">'.$lang['srv_chart_skin_7'].'</div>';
+ echo '<div class="option'.($skin == 'green' ? ' active' : '').'" id="chart_profile_skin_2" value="green">'.$lang['srv_chart_skin_2'].'</div>';
+ echo '<div class="option'.($skin == 'blue' ? ' active' : '').'" id="chart_profile_skin_3" value="blue">'.$lang['srv_chart_skin_3'].'</div>';
+ echo '<div class="option'.($skin == 'red' ? ' active' : '').'" id="chart_profile_skin_4" value="red">'.$lang['srv_chart_skin_4'].'</div>';
+ echo '<div class="option'.($skin == 'multi' ? ' active' : '').'" id="chart_profile_skin_5" value="multi">'.$lang['srv_chart_skin_5'].'</div>';
+
+ echo '</span>';
+ echo '</span>';
+
+
+ // Custom kreirani skini
+ $custom_skins = self::getCustomSkins();
+
+ echo '<span class="bold">'.$lang['srv_chart_skin_custom'].':</span>';
+ echo '<span class="chart_profiles_holder">';
+ echo '<span id="chart_profiles_custom" class="chart_profiles select">';
+
+ foreach ($custom_skins as $custom_skin ){
+ echo '<div class="option'.($skin == $custom_skin['id'] ? ' active' : '').'" id="chart_profile_skin_'.$custom_skin['id'].'" value="'.$custom_skin['id'].'">'.$custom_skin['name'].'</div>';
+ }
+
+ echo '</span>';
+ echo '</span>';
+
+ // Ce je izbran custom skin imamo na dnu gumba brisi in preimenuj
+ if(is_numeric($skin)){
+ echo '<a href="#" onclick="chart_skin_action(\'show_rename\'); return false;">'.$lang['srv_rename_profile'].'</a><br/>'."\n";
+ echo '<a href="#" onclick="chart_skin_action(\'show_delete\'); return false;">'.$lang['srv_delete_profile'].'</a>'."\n";
+ }
+
+ echo '</div>';
+
+
+ echo '<div id="chart_settings_profiles_right">';
+
+ // ce je numeric je custom skin
+ if(is_numeric($skin)){
+
+ $custom_skin = self::getCustomSkin($skin);
+
+ $colors = explode('_', $custom_skin['colors']);
+ $default_colors = $colors;
+ }
+ else{
+ // preview za default skine
+ echo '<div id="div_chart_skin_previews">';
+ echo $lang['srv_chart_skin_preview'].':';
+ self::displayChartSkinPreview($skin);
+ echo '</div>';
+
+ $default_colors = self::getDefaultColors($skin);
+ }
+
+ // Izbira custom skina
+ echo '<div id="chart_custom_skin">';
+
+ echo ' <div id="picker" style="float: right;"></div>';
+
+
+ for($i=0; $i<7; $i++){
+ $name = 'color'.($i+1);
+ //$value = (self::$settings['colors'][$i] != '') ? self::$settings['colors'][$i] : $default_colors[$i];
+ $value = $default_colors[$i];
+
+ echo ' <div class="form-item"><label for="'.$name.'">'.$lang['srv_color'].' '.($i+1).': </label><input type="text" id="'.$name.'" name="'.$name.'" class="colorwell" value="'.$value.'" /></div>';
+ }
+
+ // reset na default barvo
+ echo '<br /><span class="as_link clr" onClick="chartAdvancedSettingsSetColor(\''.(is_numeric($skin) ? implode("_",$colors) : $skin).'\')">'.$lang['srv_chart_advanced_default_color'].'</span>';
+
+ echo '</div>';
+
+ echo '</div>';
+
+
+ // cover Div
+ echo '<div id="dsp_cover_div"></div>'."\n";
+
+ // div za kreacijo novega
+ echo '<div id="newChartSkin">'.$lang['srv_missing_profile_name'].': '."\n";
+ echo '<input id="newChartSkinName" name="newChartSkinName" type="text" value="" size="50" />'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="chart_skin_action(\'new\'); return false;"><span>'.$lang['srv_analiza_arhiviraj_save'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="chart_skin_action(\'cancel_new\'); return false;"><span>'.$lang['srv_close_profile'].'</span></a></span></span>'."\n";
+ echo '</div>'."\n";
+
+ // div za preimenovanje
+ echo '<div id="renameChartSkin">'.$lang['srv_missing_profile_name'].': '."\n";
+ echo '<input id="renameChartSkinName" name="renameChartSkinName" type="text" value="' . $custom_skin['name'] . '" size="50" />'."\n";
+ echo '<input id="renameChartSkinId" type="hidden" value="' . $custom_skin['id'] . '" />'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="chart_skin_action(\'rename\'); return false;"><span>'.$lang['srv_rename_profile_yes'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="chart_skin_action(\'cancel_rename\'); return false;"><span>'.$lang['srv_close_profile'].'</span></a></span></span>'."\n";
+ echo '</div>'."\n";
+
+ // div za brisanje
+ echo '<div id="deleteChartSkin">'.$lang['srv_missing_profile_delete_confirm'].': <b>' . $custom_skin['name'] . '</b>?'."\n";
+ echo '<input id="deleteChartSkinId" type="hidden" value="' . $custom_skin['id'] . '" />'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="chart_skin_action(\'delete\'); return false;"><span>'.$lang['srv_delete_profile_yes'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="chart_skin_action(\'cancel_delete\'); return false;"><span>'.$lang['srv_close_profile'].'</span></a></span></span>'."\n";
+ echo '</div>'."\n";
+
+
+ echo '<span class="clr"></span>';
+
+ echo '<div style="position:absolute; bottom:20px; right:20px;">';
+
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="save_chartColor(); return false;"><span>'.$lang['save'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight" title="'.$lang['srv_save_new_profile'].'"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="chart_skin_action(\'show_new\'); return false;"><span>'.$lang['srv_save_new_profile'] . '</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="close_chartColor(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+
+ echo '</div>';
+ }
+
+ static function displayChartSkinPreview ($skin) {
+ global $lang;
+
+ echo '<div id="div_chart_skin_preview_1ka" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color1ka.png\'); '.($skin == '1ka' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_0" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color0.png\'); '.($skin == 'lively' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_1" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color1.png\'); '.($skin == 'mild' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_2" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color2.png\'); '.($skin == 'green' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_3" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color3.png\'); '.($skin == 'blue' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_4" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color4.png\'); '.($skin == 'red' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_5" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color5.png\'); '.($skin == 'multi' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_6" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color6.png\'); '.($skin == 'office' ? ' display:block;' : '').'">';
+ echo '</div>';
+
+ echo '<div id="div_chart_skin_preview_7" class="div_chart_skin_preview" style="background-image: url(\'pChart/preview/color7.png\'); '.($skin == 'pastel' ? ' display:block;' : '').'">';
+ echo '</div>';
+ }
+
+ static function getCustomSkins(){
+ global $global_user_id;
+
+ $skins = array();
+
+ $sql = sisplet_query("SELECT * FROM srv_chart_skin WHERE usr_id='$global_user_id'");
+ while($row = mysqli_fetch_array($sql)){
+ $skins[] = $row;
+ }
+
+ return $skins;
+ }
+
+ static function getCustomSkin($id){
+ global $global_user_id;
+
+ $sql = sisplet_query("SELECT * FROM srv_chart_skin WHERE usr_id='$global_user_id' AND id='$id'");
+ $skin = mysqli_fetch_array($sql);
+
+ return $skin;
+ }
+
+ static function displayPublicChart($properties = array()) {
+ global $lang;
+ global $site_url;
+
+ header('Cache-Control: no-cache');
+ header('Pragma: no-cache');
+
+ $anketa = self::$anketa;
+
+ if ($anketa > 0) {
+ $sql = sisplet_query("SELECT lang_admin FROM srv_anketa WHERE id = '$anketa'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['lang_admin'];
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_admin'");
+ $row = mysqli_fetch_assoc($sql);
+ $lang_admin = $row['value'];
+ }
+
+
+ #izpišemo HTML
+ echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
+ echo '<head>';
+ echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />';
+ echo '<script type="text/javascript" src="'.$site_url.'admin/survey/script/js-lang.php?lang='.($lang_admin==1?'si':'en').'"></script>';
+ echo '<script type="text/javascript" src="'.$site_url.'admin/survey/minify/g=jsnew"></script>';
+ echo '<link type="text/css" href="'.$site_url.'admin/survey/minify/g=css" media="screen" rel="stylesheet" />';
+ echo '<link type="text/css" href="'.$site_url.'admin/survey/minify/g=cssPrint" media="print" rel="stylesheet" />';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<!--[if lt IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie6hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 7]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie7hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<!--[if IE 8]>';
+ echo '<link rel="stylesheet" href="<?=$site_url?>admin/survey/css/ie8hacks.css" type="text/css" />';
+ echo '<![endif]-->';
+ echo '<style>';
+ echo '.container {margin-bottom:45px;} #navigationBottom {width: 100%; background-color: #f2f2f2; border-top: 1px solid gray; height:25px; padding: 10px 30px 10px 0px !important; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;}';
+ echo '</style>';
+ echo '<script>';
+ echo 'function chkstate(){';
+ echo ' if(document.readyState=="complete"){';
+ echo ' window.close()';
+ echo ' }';
+ echo ' else{';
+ echo ' setTimeout("chkstate()",2000)';
+ echo ' }';
+ echo '}';
+ echo 'function print_win(){';
+ echo ' window.print();';
+ echo ' chkstate();';
+ echo '}';
+ echo 'function close_win(){';
+ echo ' window.close();';
+ echo '}';
+ echo '</script>';
+ echo '</head>';
+
+ echo '<body style="margin:5px; padding:5px;" >';
+ echo '<h2>'.$lang['srv_publc_chart_title_for'] . self::$survey['naslov'].'</h2>';
+
+ echo '<input type="hidden" name="anketa_id" id="srv_meta_anketa_id" value="' . $anketa . '" />';
+ echo '<div id="analiza_data">';
+
+ # ponastavimo nastavitve- filter
+ self::Display();
+ echo '</div>';
+
+ echo '<div id="navigationBottom" class="printHide">';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="window.print();return false;"><span><img src="'.$site_url.'admin/survey/icons/icons/printer.png" vartical-align="middle" /> '.$lang['hour_print2'].'</span></a></div></span>';
+
+ echo '<br class="clr" />';
+ echo '</div>';
+
+ echo '</body>';
+ echo '</html>';
+ }
+}
+?> \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyCrosstabs.php b/admin/survey/classes/surveyAnalysis/class.SurveyCrosstabs.php
new file mode 100644
index 0000000..e0f4e85
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyCrosstabs.php
@@ -0,0 +1,2606 @@
+<?php
+/**
+ * @author Gorazd Veselič
+ * @date December 2010
+ *
+ */
+
+define("EXPORT_FOLDER", "admin/survey/SurveyData");
+# mejne vrednosti za barvanje residualov
+define("RESIDUAL_COLOR_LIMIT1", 1.00);
+define("RESIDUAL_COLOR_LIMIT2", 2.00);
+define("RESIDUAL_COLOR_LIMIT3", 3.00);
+define("AUTO_HIDE_ZERRO_VALUE", 20); # nad koliko kategorij skrivamo ničelne vrednosti
+
+@session_start();
+
+class SurveyCrosstabs {
+
+ public $sid; # id ankete
+ public $folder = ''; # pot do folderja
+
+ public $db_table; # katere tabele uporabljamo
+
+ public $inited = false; # ali smo razred inicializirali
+
+ public $_HEADERS = array(); # shranimo podatke vseh variabel
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $SDF = null; # class za inkrementalno dodajanje fajlov
+
+ # ali obstaja datoteka z podatki in ali je zadnja verzija
+ public $setUpJSAnaliza = true; # ali nastavimo __analiza = 1 v JS
+
+ public $_HAS_TEST_DATA = false; # ali anketa vsebuje testne podatke
+
+ public $_CURRENT_STATUS_FILTER = ''; # filter po statusih, privzeto izvažamo 6 in 5
+ public $currentMissingProfile = 1; # Kateri Missing profil je izbran
+ public $missingProfileData = null; # Nastavitve trenutno izbranega manjkajočega profila
+
+ public $_CURRENT_LOOP = null; # trenutni loop
+
+ # CHECKBOXI
+ public $crossChk0 = true; # checkbox frekvence
+ public $crossChk1 = false; # checkbox odstotek po vrsticah
+ public $crossChk2 = false; # checkbox odstotek po stolpcih
+ public $crossChk3 = false; # checkbox skupni odstotek
+
+ public $crossChkEC = false; # checkbox pričakovana frekvenca
+ public $crossChkRE = false; # checkbox rezidual
+ public $crossChkSR = false; # checkbox standardni rezidual
+ public $crossChkAR = false; # checkbox prilagojen rezidual
+ public $doColor = true; # checkbox Obarvaj celice
+ public $doValues = true; # checkbox Prikaži vrednosti
+
+ public $enableInspect = true; # checkbox enableInspect
+
+ public $variabla1 = array('0'=> array('seq'=>'0','spr'=>'undefined', 'grd'=>'undefined')); # array drugih variable, kamor shranimo spr, grid_id, in sequenco
+ public $variabla2 = array('0'=> array('seq'=>'0','spr'=>'undefined', 'grd'=>'undefined')); # array drugih variable, kamor shranimo spr, grid_id, in sequenco
+
+ public $crossNavVsEno = 1; # ali delamo po navedbah ali po enotah
+ public $displayHi2 = true; # ali prikazujemo hi^2
+ public $fromBreak = false; # ali delamo crosstab iz break-a
+ public $showAverage = true; # ali prikazujemo povprečja - v kombinaciji z from break
+ public $showBottomAverage = false; # ali prikazujemo povprečja - po stolpcih v zadnji vrstici
+ public $showChart = false; # ali prikazujemo graf pod tabelo
+
+ private $sessionData; # podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+
+ /* Variable so definirane v obliki:
+ * '37507_0_0_0' = x_y_z_w
+ * -> x => spr_id
+ * -> y => loop id
+ * -> z => grid_id
+ * -> y => variable id
+ *
+ */
+ public $variablesList = null; # Seznam vseh variabel nad katerimi lahko izvajamo crostabulacije (zakeširamo)
+
+ /**
+ * Inicializacija
+ *
+ * @param int $anketa
+ */
+ function Init( $anketa = null ) {
+ global $global_user_id, $site_path;
+
+ $this->folder = $site_path . EXPORT_FOLDER.'/';
+
+ if ((int)$anketa > 0) { # če je poadan anketa ID
+ $this->sid = $anketa;
+
+ SurveyAnalysisHelper::getInstance()->Init($this->sid);
+
+ #inicializiramo class za datoteke
+ $this->SDF = SurveyDataFile::get_instance();
+ $this->SDF->init($this->sid);
+ $this->headFileName = $this->SDF->getHeaderFileName();
+ $this->dataFileName = $this->SDF->getDataFileName();
+ $this->dataFileStatus = $this->SDF->getStatus();
+
+
+ # polovimo vrsto tabel (aktivne / neaktivne)
+ SurveyInfo :: getInstance()->SurveyInit($this->sid);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ $this->db_table = '_active';
+ }
+ $this->_CURRENT_STATUS_FILTER = STATUS_FIELD.' ~ /6|5/';
+
+ # Inicializiramo in polovimo nastavitve missing profila
+ SurveyStatusProfiles::Init($this->sid);
+ SurveyUserSetting::getInstance()->Init($this->sid, $global_user_id);
+
+ SurveyMissingProfiles :: Init($this->sid,$global_user_id);
+ SurveyConditionProfiles :: Init($this->sid, $global_user_id);
+ SurveyZankaProfiles :: Init($this->sid, $global_user_id);
+ SurveyTimeProfiles :: Init($this->sid, $global_user_id);
+
+ SurveyDataSettingProfiles :: Init($this->sid);
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->sid);
+ $this->sessionData = SurveyUserSession::getData();
+
+ # nastavimo vse filtre
+ $this->setUpFilter();
+
+ # nastavimo uporabniške nastavitve
+ $this->readUserSettings();
+
+ } else {
+ die("Napaka!");
+ }
+ }
+
+ /** Funkcija ki nastavi vse filtre
+ *
+ */
+ private function setUpFilter() {
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ return false;
+ }
+
+ if ($this->headFileName !== null && $this->headFileName != '') {
+ $this->_HEADERS = unserialize(file_get_contents($this->headFileName));
+ }
+
+
+ # poiščemo kater profil uporablja uporabnik
+ $_currentMissingProfile = SurveyUserSetting :: getInstance()->getSettings('default_missing_profile');
+ $this->currentMissingProfile = (isset($_currentMissingProfile) ? $_currentMissingProfile : 1);
+
+ # filtriranje po statusih
+ $this->_CURRENT_STATUS_FILTER = SurveyStatusProfiles :: getStatusAsAWKString();
+
+ # filtriranje po časih
+ $_time_profile_awk = SurveyTimeProfiles :: getFilterForAWK($this->_HEADERS['unx_ins_date']['grids']['0']['variables']['0']['sequence']);
+
+ # dodamo še ife
+
+ SurveyConditionProfiles :: setHeader($this->_HEADERS);
+ $_condition_profile_AWK = SurveyConditionProfiles:: getAwkConditionString();
+
+ if (($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) || ($_time_profile_awk != "" && $_time_profile_awk != null)) {
+ $this->_CURRENT_STATUS_FILTER = '('.$this->_CURRENT_STATUS_FILTER;
+ if ($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_condition_profile_AWK;
+ }
+ if ($_time_profile_awk != "" && $_time_profile_awk != null) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_time_profile_awk;
+ }
+ $this->_CURRENT_STATUS_FILTER .= ')';
+ }
+
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+
+ if ($this->dataFileStatus == FILE_STATUS_OK || $this->dataFileStatus == FILE_STATUS_OLD) {
+
+ if (isset($this->_HEADERS['testdata'])) {
+ $this->_HAS_TEST_DATA = true;
+ }
+ }
+ }
+
+
+ /** funkcija vrne seznam primern variabel za crostabe
+ *
+ */
+ function getVariableList() {
+ if (isset($this->variablesList) && is_array($this->variablesList) && count($this->variablesList) > 0) {
+ return $this->variablesList;
+ } else {
+ # pobrišemo array()
+ $this->variablesList = array();
+ # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence)
+ foreach ($this->_HEADERS AS $skey => $spremenljivka) {
+ if ((int)$spremenljivka['hide_system'] == 1 && in_array($spremenljivka['variable'],array('email','ime','priimek','telefon','naziv','drugo'))) {
+ continue;
+ }
+
+ $tip = $spremenljivka['tip'];
+ if (is_numeric($tip)
+ # tekstovnih tipov ne dodajamo
+
+ && $tip != 4 #text
+ && $tip != 5 #label
+ #&& $tip != 7 #number
+ #&& $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ #&& $tip != 18 #vsota
+ #&& $tip != 19 #multitext
+ #&& $tip != 20 #multinumber
+ #&& $tip != 21 #besedilo*
+ && $tip != 22 #compute
+ && $tip != 25 #kvota
+ ) {
+ $cnt_all = (int)$spremenljivka['cnt_all'];
+ # radio in select in checkbox
+ if ($cnt_all == '1' || $tip == 1 || $tip == 3 || $tip == 2) {
+ # pri tipu radio ali select dodamo tisto variablo ki ni polje "drugo"
+ if ($tip == 1 || $tip == 3 ) {
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][$vid]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+
+ }
+ }
+ }
+ }
+ } else {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+ } else if ($cnt_all > 1){
+ # imamo več skupin ali podskupin, zato zlopamo skozi gride in variable
+ if (count($spremenljivka['grids']) > 0 ) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # ali imamo en grid, ali več (tabele
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } else if($tip == 16||$tip == 18) {
+ # imamo multicheckbox
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>$gid,
+ 'sequence'=>$grid['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ } else {
+ # imamo več gridov - tabele
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>$sub);
+ }
+ if (count ($grid['variables']) > 0) {
+ $sub++;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>$sub);
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ return $this->variablesList;
+ }
+ }
+
+
+ /** Prikazuje filtre
+ *
+ */
+ function DisplayFilters() {
+ if ($this->dataFileStatus == FILE_STATUS_SRV_DELETED || $this->dataFileStatus == FILE_STATUS_NO_DATA){
+ return false;
+ }
+
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->sid);
+ # izrišemo desne linke do posameznih nastavitev
+ $SSH -> displayAnalizaRightOptions(M_ANALYSIS_CROSSTAB);
+
+ if ($this->setUpJSAnaliza == true) {
+ echo '<script>
+ window.onload = function() {
+ __analiza = 1;
+ __tabele = 1;
+ }
+ </script>';
+ }
+ }
+
+ function DisplayLinks() {
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->sid);
+ $SSH -> displayAnalizaSubNavigation();
+ }
+
+ /** Prikazuje podatke analize
+ *
+ */
+ function Display() {
+ # preberemo prednastavljene variable iz seje, če obstajajo
+ $this->presetVariables();
+
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ return false;
+ }
+
+ global $lang;
+
+ # polovimo nastavtve missing profila
+ //$this->missingProfileData = SurveyMissingProfiles::getProfile($this->currentMissingProfile);
+
+ echo '<div id="crosstab_drobdowns">';
+ $resultIsCheckbox = $this->DisplayDropdows();
+ echo '</div>';
+ echo '<div id="div_crossCheck" class="floatLeft spaceLeft">' ;
+ $this->displayLinePercent();
+ $this->displayResidual();
+ $this->displayShowChart();
+ if ( $resultIsCheckbox['is_check']) {
+ echo '<div id="crossNavedbeVsENote">';
+ echo '<input type="radio" name="crossNavVsEno" id="crossNavVsEno0" vlaue="0" '.($this->crossNavVsEno == 0 ? ' checked="checked" ' : '' ).' onchange="change_crosstab(); return false;" autocomplete="off">'.
+ '<label for="crossNavVsEno0">'.$lang['srv_analiza_crosstab_navedbe'].'</label>';
+ echo '<input type="radio" name="crossNavVsEno" id="crossNavVsEno1" vlaue="1" '.($this->crossNavVsEno == 1? ' checked="checked" ' : '' ).' onchange="change_crosstab(); return false;" autocomplete="off">'.
+ '<label for="crossNavVsEno1">'.$lang['srv_analiza_crosstab_enote'].'</label>';
+ echo '</div>';
+ }
+ echo '</div>';
+
+
+ $this->displayExport();
+ $this->displayCrosstabCheckboxes();
+ echo '<div id="crosstab_table">';
+ $this->displayCrosstabsTables();
+ echo '</div>';
+ }
+
+ function DisplayDropdows() {
+ global $lang;
+ $variables = $this->getVariableList();
+ $multiple = true;
+
+ echo '<div id="crossLeftHolder" >';
+
+ # iz header datoteke preberemo spremenljivke
+ #js: $("#crosstab_variable_1, #crosstab_variable_2").live('click', function() {})
+ if (count($this->variabla1) > 0) {
+ $br=null;
+ echo $lang['srv_crosstab_label1'].'<br/>';
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<span class="pointer" id="crosstab_add_new" onclick="add_new_variable(\'1\');"><span class="faicon add small icon-as_link" title=""></span></span>';
+ }
+
+ foreach($this->variabla1 AS $_key => $variabla1) {
+ echo $_br;
+ echo '<span id="v1_'.$_key.'">';
+
+ echo '<select name="crosstab_variable_1" id="crosstab_variable_1" onchange="change_crosstab(); return false;" autocomplete="off">';
+
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ( $variabla1['seq'] == null || $variabla1['seq'] == 0 ) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_izberi_prvo'] . '</option>';
+ }
+ foreach ($variables as $variable) {
+ echo '<option value="' . $variable['sequence'] . '" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . ( ($variabla1['seq'] > 0 &&$variabla1['seq'] == $variable['sequence']) ? ' selected="selected" ' : '')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] . '</option>';
+
+ }
+
+ echo '</select>';
+ if (count($this->variabla1) > 1) {
+ echo '<span class="pointer" id="crosstab_remove" onclick="crs_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+ } else {
+ #echo '<span class="space_crosstab_new">&nbsp;</span>';
+ }
+
+ $_br = '<br/><span class="space_crosstab_new">&nbsp;</span>';
+ echo '</span>';
+ }
+ $_br = null;
+ }
+
+ echo '</div>';
+ echo '<div id="crossImgHolder">';
+ echo '<br/>';
+ if ($this->isSelectedBothVariables()) {
+ echo '<span class="faicon replace icon-as_link" title="'.$lang['srv_replace'].'" onclick="change_crosstab(\'rotate\');return false;" />';
+ } else {
+ echo '<span class="faicon replace icon-grey_normal" title="'.$lang['srv_replace'].'" />';
+ }
+ echo '</div>';
+
+ echo '<div id="crossRightHolder">';
+ echo $lang['srv_crosstab_label2'].'<br/>';
+ # za vsako novo spremenljivko 2 nardimo svoj select
+ if (count($this->variabla2) > 0) {
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<span class="pointer" id="crosstab_add_new" onclick="add_new_variable(\'2\');"><span class="faicon add small icon-as_link" title="'.'"></span></span>';
+ }
+
+ foreach($this->variabla2 AS $_key => $variabla2) {
+ echo $_br;
+ echo '<span id="v2_'.$_key.'">';
+
+ echo '<select name="crosstab_variable_2" id="crosstab_variable_2" onchange="change_crosstab(); return false;" autocomplete="off"'
+ . ((int)$this->variabla1['0']['seq'] > 0 ? '' : ' disabled="disabled" ')
+ .'>';
+
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ((int)$this->variabla1['0']['seq'] == 0) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_najprej_prvo'] . '</option>';
+ } else {
+ # če druga variabla ni izbrana dodamo tekst za izbiro druge variable
+ if ($variabla2['seq'] == null || $variabla2['seq'] == 0) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_izberi_drugo'] . '</option>';
+ }
+ }
+
+ foreach ($variables as $variable) {
+ echo '<option value="' . $variable['sequence'] . '" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . ( $variabla2['seq'] > 0 && $variabla2['seq'] == $variable['sequence'] ? ' selected="selected" ' : '')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] .'</option>';
+
+ }
+ echo '</select>';
+ if (count($this->variabla2) > 1) {
+ echo '<span class="pointer" id="crosstab_remove" onclick="crs_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+ } else {
+ echo '<span class="space_crosstab_new">&nbsp;</span>';
+ }
+
+ $_br = '<br/><span class="space_crosstab_new">&nbsp;</span>';
+ echo '</span>';
+ }
+ }
+ echo '</div>';
+
+ # če je katera od variabel checkbox, ponudimo možnodt izbire ali po enotah ali po navedbah
+ $is_check = false;
+ if (count($this->variabla2) > 0) {
+ foreach ($this->variabla2 AS $key => $var) {
+ $spr_tip = $this->_HEADERS[$var['spr']]['tip'];
+ if ( $spr_tip == 2 || $spr_tip == 16 ) {
+ $is_check = true;
+ }
+ }
+ }
+ if (count($this->variabla1) > 0 && $is_check == false ) { # če še ni bil checkbox
+ foreach ($this->variabla1 AS $key => $var) {
+ $spr_tip = $this->_HEADERS[$var['spr']]['tip'];
+ if ( $spr_tip == 2 || $spr_tip == 16 ) {
+ $is_check = true;
+ }
+ }
+ }
+
+ return array("is_check" => $is_check);
+ }
+
+ function addNewVariable() {
+ global $lang;
+ $variables = $this->getVariableList();
+ $multiple = true;
+
+ $which = $_POST['which'];
+
+
+ if ($which == '1') {
+ echo '<br/>';
+ echo '<span class="space_crosstab_new">&nbsp;</span>';
+ echo '<select name="crosstab_variable_1" id="crosstab_variable_1" onchange="change_crosstab(); return false;" autocomplete="off">';
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ( $variabla1['seq'] == null || $variabla1['seq'] == 0 ) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_izberi_more'] . '</option>';
+ }
+
+ foreach ($variables as $variable) {
+ echo '<option value="' . $variable['sequence'] . '" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] .$variable['sequence']. '</option>';
+
+ }
+ echo '</select>';
+ echo '<span class="pointer" id="crosstab_remove" onclick="crs_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+
+ } else {
+ echo '<br/>';
+ echo '<span class="space_crosstab_new">&nbsp;</span>';
+ echo '<select name="crosstab_variable_'.$which.'" id="crosstab_variable_'.$which.'" onchange="change_crosstab(); return false;" autocomplete="off"'
+ .'>';
+
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_najprej_prvo'] . '</option>';
+ } else {
+ # če druga variabla ni izbrana dodamo tekst za izbiro druge variable
+ echo '<option value="0" selected="selected">'. $lang['srv_analiza_crosstab_izberi_more'] . '</option>';
+ }
+
+ foreach ($variables as $variable) {
+ echo '<option value="' . $variable['sequence'] . '" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] .$variable['sequence']. '</option>';
+
+ }
+ echo '</select>';
+ echo '<span class="pointer" id="crosstab_remove" onclick="crs_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+ }
+ }
+ /**
+ * @desc prikaze tabele za crosstab
+ */
+ function displayCrosstabCheckboxes () {
+ global $lang;
+
+ echo '<div id="div_color_residual_legend" '.($this->isSelectedBothVariables() && $this->doColor ? '' : ' class="hidden"').'>' ;
+
+ echo '<span id="span_color_residual_legend" class="floatLeft">';
+ echo '<span id="span_color_residual_legend1" class="floatLeft">';
+ echo '<span class="floatLeft">';
+ echo '<label>'.$lang['srv_analiza_crosstab_adjs_residual_short'].'</label>';
+ echo '</span>';
+ echo '<span class="floatLeft">';
+ echo '<table id="tbl_color_residual_legend" >';
+ echo '<tr>';
+ echo '<td style="width:15px !important; text-align: center !important; font-weight: bold !important;">-</td>';
+ echo '<td class="rsdl_bck6" title="'.$lang['srv_crosstab_residual_1'].'">&nbsp;</td>';
+ echo '<td class="rsdl_bck5" title="'.$lang['srv_crosstab_residual_2'].'">&nbsp;</td>';
+ echo '<td class="rsdl_bck4" title="'.$lang['srv_crosstab_residual_3'].'">&nbsp;</td>';
+ echo '<td class="rsdl_bck1" title="'.$lang['srv_crosstab_residual_4'].'">&nbsp;</td>';
+ echo '<td class="rsdl_bck2" title="'.$lang['srv_crosstab_residual_5'].'">&nbsp;</td>';
+ echo '<td class="rsdl_bck3" title="'.$lang['srv_crosstab_residual_6'].'">&nbsp;</td>';
+ echo '<td style="width:15px !important; text-align: center !important; font-weight: bold !important;">+</td>';
+ //echo '<td style="width:40px !important; text-align: center !important;"><span id="span_rsdl_legend_togle" class="as_link">'.$lang['srv_more'].'</span></td>';
+ echo '</tr>';
+ echo '</table>';
+ echo '</span>';
+ echo '<span class="floatLeft" style="padding-top:2px;">';
+ echo Help :: display('srv_crosstab_residual');
+ echo '</span>';
+
+ echo '</span>';
+
+ echo '<span id="span_color_residual_legend2" class="floatLeft displayNone">';
+ echo '<span class="floatLeft">';
+ echo '<label></label>';
+ echo '</span>';
+ echo '<span class="floatLeft">';
+ echo '<table id="tbl_color_residual" class="residual">';
+ echo '<tr><td>'.$lang['srv_analiza_crosstab_adjs_residual_long'].':&nbsp;&nbsp;&nbsp;&nbsp;</td><th>+</th><th>-</th></tr>';
+ echo '<tr><td class="anl_al">&nbsp;&nbsp;'.$lang['srv_crosstab_residual_3_0'].'</td><td class="rsdl_bck1 anl_dash_ba" title="'.$lang['srv_crosstab_residual_4'].'">&nbsp;</td><td class="rsdl_bck4 anl_dash_bt anl_dash_br anl_dash_bb" title="'.$lang['srv_crosstab_residual_3'].'">&nbsp;</td></tr>';
+ echo '<tr><td class="anl_al">&nbsp;&nbsp;'.$lang['srv_crosstab_residual_2_0'].'</td><td class="rsdl_bck2 anl_dash_bl anl_dash_bb" title="'.$lang['srv_crosstab_residual_5'].'">&nbsp;</td><td class="rsdl_bck5 anl_dash_br anl_dash_bb" title="'.$lang['srv_crosstab_residual_2'].'">&nbsp;</td></tr>';
+ echo '<tr><td class="anl_al">&nbsp;&nbsp;'.$lang['srv_crosstab_residual_1_0'].'</td><td class="rsdl_bck3 anl_dash_bl anl_dash_bb" title="'.$lang['srv_crosstab_residual_6'].'">&nbsp;</td><td class="rsdl_bck6 anl_dash_br anl_dash_bb" title="'.$lang['srv_crosstab_residual_1'].'">&nbsp;</td></tr>';
+ echo '</table>';
+ //echo '<span class="residual_link"><a href="http://www.1ka.si/db/19/308/Pogosta%20vprasanja/Kaj_pomenijo_residuali/?&p1=226&p2=735&p3=789&p4=0&p5=0&id=789&from1ka=1" target="_blank">'.$lang['srv_residual_link_faq'].'</a></span>';
+ echo '</span>';
+ echo '<span id="span_rsdl_legend_togle" class="floatLeft spaceLeft as_link">'.$lang['srv_less'].'</span>';
+ echo '<span class="floatLeft spaceLeft" style="padding-top:0px;">';
+ echo Help :: display('srv_crosstab_residual');
+ echo '</span>';
+
+ echo '</span>';
+
+
+ echo '<br />';
+ echo '<span id="span_color_residual_legend3" class="floatLeft '.($this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR == 4 ? '' : ' displayNone"').'" style="margin-top:10px; padding-left:18px;">';
+ echo '<span class="floatLeft">';
+ echo '<label>'.$lang['srv_analiza_crosstab_residuals'].'</label>';
+ echo '</span>';
+ echo '<span class="floatLeft">';
+ echo '<table id="tbl_color_residual_legend" >';
+ echo '<tr>';
+ echo '<td style="width:10px !important; text-align: center !important; font-weight: bold !important;"></td>';
+ echo '<td class="crossCheck_EC" title="'.$lang['srv_analiza_crosstab_expected_count'].'">&nbsp;</td>';
+ echo '<td class="crossCheck_RE" title="'.$lang['srv_analiza_crosstab_residual'].'">&nbsp;</td>';
+ echo '<td class="crossCheck_SR" title="'.$lang['srv_analiza_crosstab_stnd_residual'].'">&nbsp;</td>';
+ echo '<td class="crossCheck_AR" title="'.$lang['srv_analiza_crosstab_adjs_residual'].'">&nbsp;</td>';
+ echo '<td style="width:10px !important; text-align: center !important; font-weight: bold !important;"></td>';
+ echo '</tr>';
+ echo '</table>';
+ echo '</span>';
+ echo '<span class="floatLeft" style="padding-top:2px;">';
+ echo Help :: display('srv_crosstab_residual2');
+ echo '</span>';
+
+ echo '</span>';
+
+
+ echo '</span>';
+
+ echo '</div>';
+ echo '<br class="clr"/>';
+ }
+
+ public function displayCrosstabsTables() {
+
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyTimeProfiles :: printIsDefaultProfile();
+
+ # če imamo filter ifov ga izpišemo
+ SurveyConditionProfiles:: getConditionString();
+
+ # če imamo filter spremenljivk ga izpišemo
+ SurveyVariablesProfiles:: getProfileString(true);
+
+ # če imamo rekodiranje
+ $SR = new SurveyRecoding($this->sid);
+ $SR -> getProfileString();
+
+ # preverimo ali imamo izbrano tretjo variablo
+ if ( $this->variabla_third == null || (int)$this->variabla_third == 0) {
+ # tretja variabla ni izbrana, nardimo navadne loope če obstajajo
+ $this->_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ } else {
+ # tretja variabla je izbrana, zamenjamo loope z tretjo variablo
+ $this->_LOOPS = SurveyZankaProfiles::setLoopsForCrostabs($this->variabla_third);
+ }
+
+ if (count($this->_LOOPS) > 0) {
+ # če mamo zanke
+ foreach ( $this->_LOOPS AS $loop) {
+
+ $this->_CURRENT_LOOP = $loop;
+ echo '<h2>'.$lang['srv_zanka_note'].$loop['text'].'</h2>';
+ $this->displayCrosstabsTable();
+ echo '<br/>';
+ }
+ } else {
+ $this->displayCrosstabsTable();
+ }
+ }
+
+ public function displayCrosstabsTable() {
+ global $lang;
+ global $admin_type;
+
+ if ($this->getSelectedVariables(1) !== null && $this->getSelectedVariables(2) !== null) {
+ $variables1 = $this->getSelectedVariables(2);
+ $variables2 = $this->getSelectedVariables(1);
+ $counter = 0;
+ foreach ($variables1 AS $v_first) {
+ foreach ($variables2 AS $v_second) {
+
+ $crosstabs = null;
+ $crosstabs_value = null;
+
+ $crosstabs = $this->createCrostabulation($v_first, $v_second);
+
+ $crosstabs_value = $crosstabs['crosstab'];
+
+ # podatki spremenljivk
+ $spr1 = $this->_HEADERS[$v_first['spr']];
+ $spr2 = $this->_HEADERS[$v_second['spr']];
+
+ $grid1 = $spr1['grids'][$v_first['grd']];
+ $grid2 = $spr2['grids'][$v_second['grd']];
+
+ #število vratic in število kolon
+ $cols = count($crosstabs['options1']);
+ $rows = count($crosstabs['options2']);
+
+ # ali prikazujemo vrednosti variable pri spremenljivkah
+ $show_variables_values = $this->doValues;
+
+ # nastavitve oblike
+ if (($this->crossChk1 || $this->crossChk2 || $this->crossChk3) && ($this->crossChkEC || $this->crossChkRE || $this->crossChkSR || $this->crossChkAR)) {
+ # dodamo procente in residuale
+ $rowSpan = 3;
+ $numColumnPercent = $this->crossChk1 + $this->crossChk2 + $this->crossChk3;
+ $numColumnResidual = $this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR;
+ $tblColumn = max($numColumnPercent,$numColumnResidual);
+ } else if ($this->crossChk1 || $this->crossChk2 || $this->crossChk3) {
+ # imamo samo procente
+ $rowSpan = 2;
+ $numColumnPercent = $this->crossChk1 + $this->crossChk2 + $this->crossChk3;
+ $numColumnResidual = 1;
+ $tblColumn = $numColumnPercent;
+ } else if ($this->crossChkEC || $this->crossChkRE || $this->crossChkSR || $this->crossChkAR) {
+ # imamo samo residuale
+ $rowSpan = 2;
+ $numColumnPercent = 1;
+ $numColumnResidual = $this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR;
+ $tblColumn = $numColumnResidual;
+ } else {
+ #prikazujemo samo podatke
+ $rowSpan = 1;
+ $numColumnPercent = 1;
+ $numColumnResidual = 1;
+ $tblColumn = 1;
+ }
+
+ # za multicheckboxe popravimo naslov, na podtip
+ $sub_q1 = null;
+ $sub_q2 = null;
+ if ($spr1['tip'] == '6' || $spr1['tip'] == '7' || $spr1['tip'] == '16' || $spr1['tip'] == '17' || $spr1['tip'] == '18' || $spr1['tip'] == '19' || $spr1['tip'] == '20' || $spr1['tip'] == '21' ) {
+ foreach ($spr1['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_first['seq']) {
+ $sub_q1 = '<span class="anl_variabla'.$sccFloat.'">';
+ $sub_q1 .= '<a href="/" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $v_first['spr'] . '\'); return false;">';
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ if ($show_variables_values == true ) {
+ $sub_q1 .= '<span class="anl_variabla'.$sccFloat.'">';
+
+ $sub_q1 .= '&nbsp;('.strip_tags($spr1['variable']).')';
+
+ $sub_q1 .= '</span>';
+ }
+ if ($spr1['tip'] == '16') {
+ $sub_q1 .= '<br/>' . strip_tags($grid1['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($grid1['variable']) . ')' : '');
+ } else {
+ $sub_q1 .= '<br/>' . strip_tags($variable['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($variable['variable']) . ')' : '');
+ }
+ $sub_q1 .= '</a>';
+ $sub_q1 .= '</span>' . NEW_LINE;
+ }
+ }
+ }
+ }
+ if ($sub_q1 == null) {
+ $sub_q1 = '<span class="anl_variabla'.$sccFloat.'">';
+ $sub_q1 .= '<a href="/" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $v_first['spr'] . '\'); return false;">';
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ $sub_q1 .= ($show_variables_values == true ? '&nbsp;('.strip_tags($spr1['variable']).')' : '');
+ $sub_q1 .= '</a>';
+ $sub_q1 .= '</span>' . NEW_LINE;
+ }
+ if ($spr2['tip'] == '6' || $spr2['tip'] == '7' || $spr2['tip'] == '16' || $spr2['tip'] == '17' || $spr2['tip'] == '18' || $spr2['tip'] == '19' || $spr2['tip'] == '20' || $spr2['tip'] == '21') {
+ foreach ($spr2['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_second['seq']) {
+ $sub_q2 = '<span class="anl_variabla'.$sccFloat.'">';
+ $sub_q2 .= '<a href="/" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopupiza(\'' . $v_second['spr'] . '\'); return false;">';
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ if ($show_variables_values == true) {
+ $sub_q2 .= '<span class="anl_variabla'.$sccFloat.'">';
+
+ $sub_q2 .= '&nbsp;('.strip_tags($spr2['variable']).')';
+
+ $sub_q2 .= '</span>';
+ }
+ if ($spr2['tip'] == '16') {
+ $sub_q2.= '<br/>' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($grid2['variable']) . ')' : '');
+ } else {
+ $sub_q2.= '<br/>' . strip_tags($variable['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($variable['variable']) . ')' : '');
+ }
+ $sub_q2 .= '</a>';
+ $sub_q2 .= '</span>' . NEW_LINE;
+ }
+ }
+ }
+ }
+ if ($sub_q2 == null) {
+ $sub_q2 = '<span class="anl_variabla'.$sccFloat.'">';
+ $sub_q2 .= '<a href="/" title="' . $lang['srv_predogled_spremenljivka'] . '" onclick="showspremenljivkaSingleVarPopup(\'' . $v_second['spr'] . '\'); return false;">';
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ $sub_q2 .= ($show_variables_values == true ? '&nbsp;('.strip_tags($spr2['variable']).')' : '');
+ $sub_q2 .= '</a>';
+ $sub_q2 .= '</span>' . NEW_LINE;
+ }
+ # izrišemo tabelo
+ # najprej izrišemo naslovne vrstice
+ #echo '<table class="anl_tbl_crosstab fullWidth fullHeight">';
+ echo $_br.'<br/>';
+# $_br = '<br/>';
+# echo '<div class="floatLeft">'.$sub_q1. '</div><div class="floatLeft spaceLeft spaceRight"> ==&gt; </div><div class="floatLeft">'. $sub_q2.'</div><br class="clr" />';
+
+ #Zadnja kolona: Če imamo vodoravno checkboxe in gledamo enote, potem kolono s summo malo razmaknemo
+ if ( $crosstabs['isCheckbox']['spr1'] == true && $this->crossNavVsEno == true) {
+ $addVerticalSpace = 1;
+ } else {
+ $addVerticalSpace = 0;
+ }
+
+ # hi2
+ if ($this->displayHi2 == true) {
+ echo '&#x3A7;<sup>2</sup> = ';
+ echo $this->formatNumber($crosstabs['hi2'], 3, '');
+ }
+
+ echo '<table class="anl_tbl_crosstab" style="padding:0px; margin:0px; margin-top:10px;"'
+ . ' sq1="'.$v_first['seq'].'" sp1="'.$v_first['spr'].'" gd1="'.$v_first['grd'].'" sq2="'.$v_second['seq'].'" sp2="'.$v_second['spr'].'" gd2="'.$v_second['grd'].'" >';
+
+ if ($this->fromBreak == false) {
+ echo '<colgroup>';
+ #echo '<col style="width:auto; min-width:150px;" />';
+ echo '<col style="width:auto; min-width:100px;" />';
+ if (count($crosstabs['options1']) > 0 ) {
+ $_width_percent = round(100 / count($crosstabs['options1'],2));
+ foreach ($crosstabs['options1'] as $ckey1 =>$crossVariabla) {
+ echo '<col style="width:'.$_width_percent.'%;" />';
+ }
+ }
+ if ($addVerticalSpace == 1) {
+ echo '<col style="width:10px;" />';
+ }
+ echo '<col style="width:auto;" />';
+ echo '</colgroup>';
+ }
+ echo '<tr>';
+ echo '<td class="anl_bt anl_bl anl_ac rsdl_bck_title ctbCll" rowspan="2" >';
+ #if ($cntY == 1) {
+ # ime variable
+ #echo '<td rowspan="' . $rows . '">';
+ echo $sub_q2;
+ #echo '</td>';
+ #}
+ echo '</td>';
+ echo '<td class="anl_bt anl_bl anl_ac rsdl_bck_title ctbCll" colspan="' . $cols . '" >';
+ echo $sub_q1;
+ echo '</td>';
+
+ echo '<td class="anl_bl">&nbsp;</td>';
+ if ($this->fromBreak == true && $this->showAverage == true) {
+ # če smo v break-u dodamo še povprečja
+ echo '<td class="">&nbsp;</td>';
+ }
+ echo '</tr>';
+ echo '<tr>';
+ $col_cnt=0;
+ if (count($crosstabs['options1']) > 0 ) {
+ foreach ($crosstabs['options1'] as $ckey1 =>$crossVariabla) {
+ $col_cnt++;
+ #ime variable
+ //$css_backX = 'rsdl_bck_variable'.($col_cnt & 1);
+ $css_backX = ' rsdl_bck_variable1';
+ echo '<td class="anl_bt anl_bl anl_ac'.$css_backX.' ctbCll" >';
+ echo $crossVariabla['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla['type'] != 't' && $show_variables_values == true) {
+ if ($crossVariabla['vr_id'] == null ) {
+ echo '<br/> ( '.$ckey1.' )';
+ } else {
+ echo '<br/> ( '.$crossVariabla['vr_id'].' )';
+ }
+ }
+ echo '</td>';
+ }
+ }
+ $col_cnt++;
+ //$css_backX = 'rsdl_bck_variable'.($col_cnt & 1);
+ if ($addVerticalSpace == 1) {
+ echo '<td class="anl_bl">&nbsp;</td>';
+ }
+ $css_backX = ' rsdl_bck_variable1';
+
+ echo '<td class="anl_bl anl_bt anl_br anl_ac red anl_ita anl_bck_text_0'.$css_backX.' ctbCll">' . $lang['srv_analiza_crosstab_skupaj'] . '</td>';
+ if ($this->fromBreak == true && $this->showAverage == true) {
+ # če smo v break-u dodamo še povprečja
+ echo '<td class="anl_bl anl_bt anl_br anl_ac anl_ita anl_bck_text_0'.$css_backX.' ctbCll">' . $lang['srv_analiza_crosstab_average'] . '</td>';
+
+ }
+ echo '</tr>';
+
+ $cntY = 0;
+ if (count($crosstabs['options2']) > 0) {
+ foreach ($crosstabs['options2'] as $ckey2 =>$crossVariabla2) {
+ $cntY++;
+ echo '<tr>';
+
+
+ //$css_backY = 'rsdl_bck_variable'.($cntY & 1);
+ $css_backY = ' rsdl_bck_variable1';
+
+ echo '<td class="anl_bt anl_bl anl_ac'.$css_backY.' ctbCll">';
+
+ echo $crossVariabla2['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla2['type'] !== 't' && $show_variables_values == true ) {
+ if ($crossVariabla2['vr_id'] == null) {
+ echo '<br/> ( '.$ckey2.' )';
+ } else {
+ echo '<br/> ( '.$crossVariabla2['vr_id'].' )';
+ }
+
+ }
+ echo '</td>';
+
+ foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+ echo '<td class="ct_in_cell'.($this->enableInspect && ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? ' ct_inspect' : '').'" k1="'.$ckey1.'" k2="'.$ckey2.'" n1="'.$crossVariabla1['naslov'].'" n2="'.$crossVariabla2['naslov'].'" v1="'.$crossVariabla1['vr_id'].'" v2="'.$crossVariabla2['vr_id'].'">';
+ # celica z vebino
+ {
+ # prikazujemo eno ali več od: frekvenc, odstotkov, residualov
+ echo '<table class="ct_in_tbl">';
+ if ($this->crossChk0) {
+ # izpišemo frekvence crostabov
+ echo '<tr>';
+ echo '<td class="anl_ac '.($crosstabs['color'][$ckey1][$ckey2]).' ctbCll">';
+ echo ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? $crosstabs_value[$ckey1][$ckey2] : 0;
+ # .$crossTab[$crossVariabla1[cell_id]][$ckey2]
+ #
+
+ echo '</td>';
+ echo '</tr>';
+ }
+
+ if ($this->crossChk1 || $this->crossChk2 || $this->crossChk3) {
+ # sirina celice v %
+ if ( ($this->crossChk1 + $this->crossChk2 + $this->crossChk3) == 3 )
+ $css_width = ' ctb_w33p';
+ elseif (($this->crossChk1 + $this->crossChk2 + $this->crossChk3) == 2 )
+ $css_width = ' ctb_w50p';
+ else
+ $css_width = '';
+ $css_bt = ( $this->crossChk0 ) ? 'anl_dash_bt' : '';
+ # izpisemo procente
+ echo '<tr>';
+ echo '<td class="'.$css_bt.'">';
+
+ echo '<table class="anl_tbl_crosstab fullWidth fullHeight" style="padding:0px; margin:0px;">';
+ echo '<tr>';
+ $col=0;
+
+ if ($this->crossChk1) {
+ #procent vrstica
+ $col++;
+
+ $css_color = ($this->doColor == 'true') ? 'ctbChck_sp1' : 'ctbChck_sp0';
+ $css_br = $numColumnPercent > $col ? ' anl_dash_br' : '';
+ echo '<td class="'.$css_color.$css_br.$css_width.' ctbCll">';
+ echo $this->formatNumber($this->getCrossTabPercentage($crosstabs['sumaVrstica'][$ckey2], $crosstabs_value[$ckey1][$ckey2]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk2) {
+ #procent stolpec
+ $col++;
+ $css_br = $numColumnPercent > $col ? ' anl_dash_br' : '';
+ $css_color = ($this->doColor == 'true') ? 'ctbChck_sp2' : 'ctbChck_sp0';
+ echo '<td class="'.$css_color.$css_br.$css_width.' ctbCll">';
+
+ echo $this->formatNumber($this->getCrossTabPercentage($crosstabs['sumaStolpec'][$ckey1], $crosstabs_value[$ckey1][$ckey2]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk3) {
+ #procent skupni
+ $col++;
+ $css_br = $numColumnPercent > $col ? ' anl_dash_br' : '';
+ $css_color = ($this->doColor == 'true') ? 'ctbChck_sp3' : 'ctbChck_sp0';
+ echo '<td'.$css_br.$css_width.' class="'.$css_color.$css_br.' ctbCll">';
+
+ echo $this->formatNumber($this->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs_value[$ckey1][$ckey2]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ echo '</tr>';
+ echo '</table>';
+
+ echo '</td>';
+ echo '</tr>';
+ }
+ # izpisemo residuale
+ if ($this->crossChkEC || $this->crossChkRE || $this->crossChkSR || $this->crossChkAR) {
+ # sirina celice v %
+ if ( ($this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR) == 4 )
+ $css_width = ' ctb_w25p';
+ elseif ( ($this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR) == 3 )
+ $css_width = ' ctb_w33p';
+ elseif ( ($this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR) == 2 )
+ $css_width = ' ctb_w50p';
+ else
+ $css_width = '';
+ $css_bt = ( $this->crossChk0 || ($this->crossChk1 && $this->crossChk2 && $this->crossChk3)) ? 'anl_dash_bt' : '';
+ echo '<tr>';
+
+ echo '<td class="'.$css_bt.'" style="padding:0px 0px;">';
+ echo '<table class="anl_tbl_crosstab fullWidth fullHeight" style="padding:0px; margin:0px;">';
+ echo '<tr>';
+ $col=0;
+
+ if ($this->crossChkEC) {
+ $col++;
+ $css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
+ $css_color = ($this->doColor == 'true') ? 'crossCheck_EC' : 'ctbChck_sp0';
+ echo '<td class="'.$css_color.$css_br.$css_width.' ctbCll">';
+ echo $this->formatNumber($crosstabs['exC'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
+ echo '</td>';
+ }
+ if ($this->crossChkRE) {
+ $col++;
+ $css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
+ $css_color = ($this->doColor == 'true') ? 'crossCheck_RE' : 'ctbChck_sp0';
+ echo '<td class="'.$css_color.$css_br.$css_width.' ctbCll">';
+ echo $this->formatNumber($crosstabs['res'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
+ echo '</td>';
+ }
+ if ($this->crossChkSR) {
+ $col++;
+ $css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
+ $css_color = ($this->doColor == 'true') ? 'crossCheck_SR' : 'ctbChck_sp0';
+ echo '<td class="'.$css_color.$css_br.$css_width.' ctbCll">';
+ echo $this->formatNumber($crosstabs['stR'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
+ echo '</td>';
+ }
+ if ($this->crossChkAR) {
+ $col++;
+ $css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
+ $css_color = ($this->doColor == 'true') ? 'crossCheck_AR' : 'ctbChck_sp0';
+ echo '<td class="'.$css_color.$css_br.$css_width.' ctbCll">';
+ echo $this->formatNumber($crosstabs['adR'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
+ echo '</td>';
+ }
+ echo '</tr>';
+ echo '</table>';
+ echo '</td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+ }
+ # konec celice z vsebino
+ echo '</td>';
+ }
+ # če mamo checkboxe in sumo malo razmaknemo
+ if ($addVerticalSpace == 1) {
+ echo '<td class="anl_bl">&nbsp;</td>';
+ }
+
+ // vedno rišemo zadnji stolpec.
+ echo '<td class="anl_ac anl_bl anl_bt anl_br rsdl_bck0 anl_bb" >';
+ echo '<table class="anl_tbl_crosstab fullWidth fullHeight" style="padding:0px; margin:0px;">';
+ if ($this->crossChk0) {
+ echo '<tr>';
+ echo '<td class="anl_ac ctbCll crostabSuma" colspan="' . ( $this->crossChk1 + $this->crossChk2 + $this->crossChk3 ).'">';
+ # suma po vrsticah
+ echo (int)$crosstabs['sumaVrstica'][$ckey2];
+ echo '</td>';
+ echo '</tr>';
+ }
+ if ($this->crossChk1 || $this->crossChk2 || $this->crossChk3) {
+ if (($this->crossChk1 + $this->crossChk2 + $this->crossChk3) == 3) {
+ $css_width = ' ctb_w33p';
+ } else if (($this->crossChk1 + $this->crossChk2 + $this->crossChk3) == 2) {
+ $css_width = ' ctb_w50p';
+ } else {
+ $css_width = '';
+ }
+ $css_bt = ( $this->crossChk0 ) ? ' anl_dash_bt' : '';
+ # suma po vrsticah v procentih
+ echo '<tr>';
+ if ($this->crossChk1) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp1' : 'ctbChck_sp0';
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.$css_width.'">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk2) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp2' : 'ctbChck_sp0';
+ $css_border = ($this->crossChk1 ? ' anl_dash_bl ' : '');
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.$css_border.$css_width.'">';
+ echo $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk3) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp3' : 'ctbChck_sp0';
+ $css_border = ($this->crossChk1 || $this->crossChk2 ? ' anl_dash_bl ' : '');
+ echo '<td class="anl_ac'.$css_color.$css_bt.$css_border.$css_width.' ctbCll">';
+ echo $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ echo '</tr>';
+ }
+
+ echo '</table>';
+
+ echo '</td>';
+ if ($this->fromBreak == true && $this->showAverage == true) {
+ # če smo v break dodamo še povprečja
+ echo '<td class="anl_ac anl_bl anl_bt anl_br anl_bb rsdl_bck_variable1" >';
+ echo $this->formatNumber( $crosstabs['avgVrstica'][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'), '');
+ echo '</td>';
+ }
+ echo '</tr>';
+ }
+ }
+ #Zadnja vrstica. Če imamo navpično checkboxe in gledamo enote, potem vrstico z summo malo razmaknemo
+ $cssBT = 'anl_bt';
+ if ( $crosstabs['isCheckbox']['spr2'] == true && $this->crossNavVsEno == true) {
+ echo '<tr>';
+ echo '<td class="'.$cssBT.'">&nbsp;</th>';
+ echo '<td class="'.$cssBT.'">&nbsp;</th>';
+ echo '<td class="'.$cssBT.'" colspan="'.count($crosstabs['options1']).'">&nbsp;</th>';
+ if ($addVerticalSpace == 1) {
+ echo '<td class="">&nbsp;</td>';
+ }
+
+ echo '<td class="'.$cssBT.'">&nbsp;</th>';
+ echo '</tr>';
+ $cssBT = '';
+ }
+
+ $cntY++;
+ echo '<tr>';
+ $css_backY = ' rsdl_bck_variable1';
+ echo '<td class="anl_bb anl_bt anl_bl anl_ac red anl_ita anl_bck_text_0'.$css_backY.' ctbCll">' . $lang['srv_analiza_crosstab_skupaj'] . '</td>';
+ // skupni sestevki po stolpcih
+ if (count($crosstabs['options1']) > 0)
+ foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+ echo '<td class="anl_ac anl_bb anl_bt anl_bl rsdl_bck0" >';
+ {
+ # prikazujemo eno od treh možnosti
+ echo '<table class="anl_tbl_crosstab fullWidth fullHeight" style="padding:0px; margin:0px;">';
+ if ($this->crossChk0) {
+ echo '<tr>';
+ echo '<td class="anl_ac ctbCll crostabSuma" colspan="'.($this->crossChk1 + $this->crossChk2 + $this->crossChk3).'">';
+ # suma po stolpcih
+ echo (int)$crosstabs['sumaStolpec'][$ckey1];
+ echo '</td>';
+ echo '</tr>';
+ }
+ if ($this->crossChk1 || $this->crossChk2 || $this->crossChk3) {
+ # suma po stolpcih v procentih
+ $css_bt = ($this->crossChk0) ? ' anl_dash_bt' : '';
+ echo '<tr>';
+ if ($this->crossChk1) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp1' : 'ctbChck_sp0';
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.'">';
+ echo $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk2) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp2' : 'ctbChck_sp0';
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.($this->crossChk1 ? ' anl_dash_bl' : '').'">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk3)
+ {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp3' : 'ctbChck_sp0';
+ echo '<td class="anl_ac'.$css_color.$css_bt.($this->crossChk2 ? ' anl_dash_bl' : '').' ctbCll">';
+ echo $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ echo '</tr>';
+ }
+ echo '</table>';
+ }
+ echo '</td>';
+ }
+ # če mamo checkboxe in sumo malo razmaknemo
+ if ($addVerticalSpace == 1) {
+ echo '<td class="anl_bl">&nbsp;</td>';
+ }
+
+ # zadnja celica z skupno sumo
+ echo '<td class="anl_ac anl_bt anl_bl anl_br anl_bb rsdl_bck0">';
+ {
+ echo '<table class="anl_tbl_crosstab fullWidth fullHeight" style="padding:0px; margin:0px;">';
+ if ($this->crossChk0) {
+ echo '<tr>';
+ echo '<td class="anl_ac ctbCll crostabSuma" colspan="'.($this->crossChk1 + $this->crossChk2 + $this->crossChk3).'">';
+ # skupna suma
+ echo (int)$crosstabs['sumaSkupna'];
+ echo '</td>';
+ echo '</tr>';
+ }
+ if ($this->crossChk1 || $this->crossChk2 || $this->crossChk3) {
+ # suma po stolpcih v procentih
+ $css_bt = ($this->crossChk0) ? ' anl_dash_bt' : '';
+ echo '<tr>';
+ if ($this->crossChk1) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp1' : 'ctbChck_sp0';
+ $css_border = ($this->crossChk2 || $this->crossChk3) ? ' anl_dash_br' : '';
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.$css_border.'">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk2) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp2' : 'ctbChck_sp0';
+ $css_border = ($this->crossChk3) ? ' anl_dash_br' : '';
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.$css_border.'">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ if ($this->crossChk3) {
+ $css_color = ($this->doColor == 'true') ? ' ctbChck_sp3' : 'ctbChck_sp0';
+ echo '<td class="anl_ac ctbCll'.$css_color.$css_bt.'">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td>';
+ }
+ echo '</tr>';
+ }
+ echo '</table>';
+ }
+ echo '</td>';
+ if ($this->fromBreak == true && $this->showAverage == true) {
+ # če smo v break dodamo še povprečja
+ echo '<td class="anl_bl anl_bt" >';
+ echo '&nbsp;';
+ echo '</td>';
+ }
+ echo '</tr>';
+ #xxx
+ #zadnja vrstica z povprečji - iz break
+ if ($this->showBottomAverage == true && $crosstabs['isCheckbox']['spr2'] == false) {
+ echo '<tr>';
+ $css_backY = ' rsdl_bck_variable1';
+ echo '<td class="anl_bb anl_bt anl_bl anl_br anl_ac anl_ita anl_bck_text_0'.$css_backY.' ctbCll">' . $lang['srv_analiza_crosstab_average'] . '</td>';
+ // skupni sestevki po stolpcih
+ if (count($crosstabs['options1']) > 0) {
+ foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+ echo '<td class="anl_ac anl_bb anl_bt anl_br rsdl_bck_variable1" >';
+ echo $this->formatNumber( $crosstabs['avgStolpec'][$ckey1], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'), '');
+ echo '</td>';
+ }
+ }
+ # če mamo checkboxe in sumo malo razmaknemo
+ if ($addVerticalSpace == 1) {
+ echo '<td>&nbsp;</td>';
+ }
+
+ # zadnja celica z skupno sumo
+ echo '<td>&nbsp;</td>';
+ if ($this->fromBreak == true && $this->showAverage == true) {
+ # če smo v break dodamo še povprečja
+ echo '<td>&nbsp;</td>';
+ }
+ echo '</tr>';
+ }
+ echo '</table>';
+
+ // Zvezdica za vkljucitev v porocilo
+ $spr2 = $v_first['seq'].'-'.$v_first['spr'].'-'.$v_first['grd'];
+ $spr1 = $v_second['seq'].'-'.$v_second['spr'].'-'.$v_second['grd'];
+
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type=5, $sub_type=0, $spr1, $spr2);
+ #SurveyAnalysis::addCustomReportElement($type=5, $sub_type=0, $spr1, $spr2);
+
+ // Izrisemo graf za tabelo
+ if($this->showChart && !$this->fromBreak){
+ $tableChart = new SurveyTableChart($this->sid, $this, 'crosstab', $counter);
+ $tableChart->display();
+ }
+
+ $counter++;
+ }
+ }
+ } else {
+ # crostab variables not set
+ echo $lang['srv_crosstab_note0'];
+ #print_r("Crosstab variables not set!");
+ }
+ }
+
+ /**
+ * @desc prikaze izvoz za PDF/RTF
+ */
+ function displayExport () {
+ # z javascriptom prikažemo ikonce za arhiviranje, emaijlanje arhivov, pdf, rtf, excel...
+ if ($this->isSelectedBothVariables()) {
+ $data1 = '';
+ $data2 = '';
+
+ foreach($this->variabla1 as $var1){
+ $data1 .= implode(',', array_values($var1)).',';
+ }
+ $data1 = substr($data1, 0, -1);
+
+ foreach($this->variabla2 as $var2){
+ $data2 .= implode(',', array_values($var2)).',';
+ }
+ $data2 = substr($data2, 0, -1);
+
+ $href_print = makeEncodedIzvozUrlString('izvoz.php?b=export&m=crosstabs_izpis&anketa=' . $this->sid . '&data1='.$data1.'&data2='.$data2);
+ $href_pdf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=crosstabs_izpis&anketa=' . $this->sid . '&data1='.$data1.'&data2='.$data2);
+ $href_rtf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=crosstabs_izpis_rtf&anketa=' . $this->sid . '&data1='.$data1.'&data2='.$data2);
+ $href_xls = makeEncodedIzvozUrlString('izvoz.php?b=export&m=crosstabs_izpis_xls&anketa=' . $this->sid . '&data1='.$data1.'&data2='.$data2);
+ echo '<script>';
+ # nastavimopravilne linke
+ echo '$("#secondNavigation_links a#crosstabDoPdf").attr("href", "'.$href_pdf.'");';
+ echo '$("#secondNavigation_links a#crosstabDoRtf").attr("href", "'.$href_rtf.'");';
+ echo '$("#secondNavigation_links a#crosstabDoXls").attr("href", "'.$href_xls.'");';
+ # prikažemo linke
+ echo '$("#hover_export_icon").removeClass("hidden");';
+ echo '$("#secondNavigation_links a").removeClass("hidden");';
+ echo '</script>';
+
+ }
+
+ }
+
+ /** kadar kličemo iz Break, ali pri radio grupi dodamo še povprečje po stolpcih
+ *
+ * @param unknown_type $showBottomAverage
+ */
+ function showBottomAverage ($showBottomAverage = false) {
+ $this->showBottomAverage = $showBottomAverage ;
+ }
+ /**
+ * @desc nastavimo spremenljivke/variable za prikaz pdf/rtf
+ */
+ function setVariables($seq1, $spr1, $grd1, $seq2, $spr2, $grd2){
+
+ $this->variabla1[0]['seq'] = $seq1;
+ $this->variabla1[0]['spr'] = $spr1;
+ $this->variabla1[0]['grd'] = $grd1;
+
+ $this->variabla2[0]['seq'] = $seq2;
+ $this->variabla2[0]['spr'] = $spr2;
+ $this->variabla2[0]['grd'] = $grd2;
+ }
+
+
+ public function createCrostabulation($v_first, $v_second) {
+ global $site_path;
+ $folder = $site_path . EXPORT_FOLDER.'/';
+
+ if ($this->dataFileName != '' && file_exists($this->dataFileName)) {
+
+ $spr1 = $this->_HEADERS[$v_first['spr']];
+ $spr2 = $this->_HEADERS[$v_second['spr']];
+
+ $grid1 = $spr1['grids'][$v_first['grd']];
+ $grid2 = $spr2['grids'][$v_second['grd']];
+
+ $sequence1 = $v_first['seq'];
+ $sequence2 = $v_second['seq'];
+
+ # za checkboxe gledamo samo odgovore ki so bili 1 in za vse opcije
+ $sekvences1 = array();
+ $sekvences2 = array();
+ $spr_1_checkbox = false;
+ $spr_2_checkbox = false;
+ if ($spr1['tip'] == 2 || $spr1['tip'] == 16) {
+ $spr_1_checkbox = true;
+ if ($spr1['tip'] == 2) {
+ if (count($spr1['grids'][0]['variables']) > 0)
+ foreach ($spr1['grids'][0]['variables'] AS $_vkey =>$_variable) {
+ if ((int)$_variable['text'] != 1) {
+ $sekvences1[] = $_variable['sequence'];
+ }
+ } else {
+ $sekvences1 = explode('_',$spr1['sequences']);
+ }
+ }
+ if ($spr1['tip'] == 16) {
+
+ foreach ($grid1['variables'] AS $_variables) {
+
+ $sekvences1[] = $_variables['sequence'];
+ }
+
+ #$sekvences1 = explode('_',$this->_HEADERS[$v_first['spr']]['sequences']);
+ }
+ } else {
+ $sekvences1[] = $sequence1;
+ }
+
+ if ($spr2['tip'] == 2 || $spr2['tip'] == 16) {
+ $spr_2_checkbox = true;
+ if ($spr2['tip'] == 2 ) {
+ if (count($this->_HEADERS[$v_second['spr']]['grids'][0]['variables']) > 0)
+ foreach ($this->_HEADERS[$v_second['spr']]['grids'][0]['variables'] AS $_vkey =>$_variable) {
+ if ((int)$_variable['text'] != 1) {
+ $sekvences2[] = $_variable['sequence'];
+ }
+
+ } else {
+ $sekvences2 = explode('_',$this->_HEADERS[$v_second['spr']]['sequences']);
+ }
+
+ }
+ if ($spr2['tip'] == 16) {
+ foreach ($grid2['variables'] AS $_variables) {
+ $sekvences2[] = $_variables['sequence'];
+ }
+ #$sekvences2 = explode('_',$this->_HEADERS[$v_second['spr']]['sequences']);
+ }
+ } else {
+ $sekvences2[] = $sequence2;
+ }
+ # pogoji so že dodani v _CURRENT_STATUS_FILTER
+
+ # dodamo filter za loop-e
+ if (isset($this->_CURRENT_LOOP['filter']) && $this->_CURRENT_LOOP['filter'] != '') {
+ $status_filter = $this->_CURRENT_STATUS_FILTER.' && '.$this->_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+ }
+
+
+ # dodamo status filter za vse sekvence checkbox-a da so == 1
+ if ($additional_status_filter != null) {
+ $status_filter .= $additional_status_filter;
+ }
+
+ # odstranimo vse zapise, kjer katerakoli od variabel vsebuje missing
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ $_pageMissing_answers = $this->getInvalidAnswers (MISSING_TYPE_CROSSTAB);
+
+ # polovimo obe sequenci
+ $tmp_file = $folder . 'tmp_crosstab_'.$this->sid.'.TMP';
+ $file_handler = fopen($tmp_file,"w");
+ fwrite($file_handler,"<?php\n");
+ fclose($file_handler);
+ if (count($sekvences1)>0)
+ foreach ($sekvences1 AS $sequence1) {
+ if (count($sekvences2)>0)
+ foreach ($sekvences2 AS $sequence2) {
+ #skreira variable: $crosstab, $cvar1, $cvar2
+
+ $additional_filter = '';
+ if ($spr_1_checkbox == true) {
+ $_seq_1_text = ''.$sequence1;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter = ' && ($'.$sequence1.' == 1)';
+ } else {
+ $_seq_1_text = '$'.$sequence1;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key1 => $missing1) {
+ $additional_filter .= ' && ($'.$sequence1.' != '.$m_key1.')';
+ }
+ }
+
+ if ($spr_2_checkbox == true) {
+ $_seq_2_text = ''.$sequence2;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter .= ' && ($'.$sequence2.' == 1)';
+ } else {
+ $_seq_2_text = '$'.$sequence2;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key2 => $missing2) {
+ $additional_filter .= ' && ($'.$sequence2.' != '.$m_key2.')';
+ }
+ }
+
+ if (IS_WINDOWS) {
+ #$command = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$_status_filter.' { print \"$crosstab[\x27\",$'.$sequence1.',\"\x27][\x27\",$'.$sequence2.',\"\x27]++; $options1[\x27\",$'.$sequence1.',\"\x27]++; $options2[\x27\",$'.$sequence2.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ $command = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$additional_filter.' { print \"$crosstab[\x27\",'.$_seq_1_text.',\"\x27][\x27\",'.$_seq_2_text.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ #$command = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$_status_filter.' { print "$crosstab[\x27",$'.$sequence1.',"\x27][\x27",$'.$sequence2.',"\x27]++; $options1[\x27",$'.$sequence1.',"\x27]++; $options2[\x27",$'.$sequence2.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ $command = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$additional_filter.' { print "$crosstab[\x27",'.$_seq_1_text.',"\x27][\x27",'.$_seq_2_text.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out = shell_exec($command);
+ }
+
+ }
+
+ $file_handler = fopen($tmp_file,"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_file);
+ if (file_exists($tmp_file)) {
+ unlink($tmp_file);
+ }
+
+ #ker z awk ne gre nardit tolower zaradi šumnikov, nardimo ročno v loopu
+ $caseInsensitiveCrosstab = array();
+ if (count($crosstab) > 0) {
+ foreach ($crosstab as $fkey => $fvalue) {
+ $fkey = mb_strtolower($fkey,'UTF-8');
+ if (count($fvalue) > 0) {
+ foreach ($fvalue as $skey => $svalue) {
+ $skey = mb_strtolower($skey,'UTF-8');
+ $caseInsensitiveCrosstab[$fkey][$skey] += $svalue;
+ }
+ }
+ }
+ }
+ $crosstab = $caseInsensitiveCrosstab;
+ # poiščemo pripadajočo spremenljivko
+ $var_options1 = $this->_HEADERS[$v_first['spr']]['options'];
+ $var_options2 = $this->_HEADERS[$v_second['spr']]['options'];
+
+ # inicializacija
+ $_all_options1 = array();
+ $_all_options2 = array();
+ $sumaStolpec = array();
+ $sumaVrstica = array();
+ $sumaSkupna = 0;
+
+ # najprej poiščemo (združimo) vse opcije ki so definirane kot opcije spremenljivke in vse ki so v crosstabih
+ if (count($var_options1) > 0 && $spr_1_checkbox !== true ) {
+ foreach ($var_options1 as $okey => $opt) {
+ $_all_options1[$okey] = array('naslov'=>$opt, 'cnt'=>$options1[$okey], 'type'=>'o');
+ }
+ }
+ if (count($var_options2) > 0 && $spr_2_checkbox !== true) {
+ foreach ($var_options2 as $okey => $opt) {
+ $_all_options2[$okey] = array('naslov'=>$opt, 'cnt'=>$options2[$okey], 'type'=>'o');
+ }
+ }
+ # za checkboxe dodamo posebej vse opcije
+ if ($spr_1_checkbox == true ) {
+ if ($spr1['tip'] == 2 ) {
+ $grid1 =$this->_HEADERS[$v_first['spr']]['grids']['0'];
+ }
+
+ foreach ($grid1['variables'] As $vkey => $variable) {
+ if ($variable['other'] != 1) {
+ $_all_options1[$variable['sequence']] = array('naslov'=>$variable['naslov'], 'cnt'=>0, 'type'=>'o', 'vr_id'=> $variable['variable']);
+ }
+ }
+ }
+
+ if ($spr_2_checkbox == true ) {
+ if ($spr2['tip'] == 2 ) {
+ $grid2 =$this->_HEADERS[$v_second['spr']]['grids']['0'];
+ }
+
+ foreach ($grid2['variables'] As $vkey => $variable) {
+ if ($variable['other'] != 1) {
+ $_all_options2[$variable['sequence']] = array('naslov'=>$variable['naslov'], 'cnt'=>0, 'type'=>'o', 'vr_id'=> $variable['variable']);
+ }
+ }
+ }
+
+ # dodamo odgovore iz baze ki niso missingi
+ if (count($crosstab) > 0 ) {
+ foreach ($crosstab AS $_kvar1=>$_var1) {
+ # missingov ne dodajamo še zdaj, da ohranimo pravilen vrstni red
+ if (!isset($_allMissing_answers[$_kvar1]) && !isset($_all_options1[$_kvar1])) {
+ $_all_options1[$_kvar1] = array('naslov'=>$_kvar1, 'cnt'=>($_all_options1[$_kvar1]['cnt']+1), 'type'=>'t');
+ }
+
+ foreach ($_var1 AS $_kvar2=>$_var2) {
+ if (!isset($_allMissing_answers[$_kvar1]) || (isset($_allMissing_answers[$_kvar1]) && isset($_pageMissing_answers[$_kvar1]))) {
+ $sumaStolpec[$_kvar1] += $_var2;
+ }
+ if (!isset($_allMissing_answers[$_kvar2]) || (isset($_allMissing_answers[$_kvar2]) && isset($_pageMissing_answers[$_kvar2]))) {
+ $sumaVrstica[$_kvar2] += $_var2;
+ }
+ # missingov ne dodajamo še zdaj, da ohranimo pravilen vrstni red
+ if (!isset($_allMissing_answers[$_kvar2]) && !isset($_all_options2[$_kvar2])) {
+ $_all_options2[$_kvar2] = array('naslov'=>$_kvar2, 'cnt'=>($_all_options1[$_kvar2]['cnt']+1), 'type'=>'t');
+ }
+
+ }
+ }
+ }
+ /*
+ # dodamo še missinge, samo tiste ki so izbrani z profilom
+ if (count($_pageMissing_answers) > 0 ) {
+ foreach ($_pageMissing_answers as $mkey => $missing ) {
+ if ( $spr_1_checkbox !== true) {
+ $_all_options1[$mkey] = array('naslov'=>$missing['text'], 'cnt'=>(int)$options1[$mkey], 'type'=>'m');
+ }
+ if ( $spr_2_checkbox !== true ) {
+ $_all_options2[$mkey] = array('naslov'=>$missing['text'], 'cnt'=>(int)$options2[$mkey], 'type'=>'m');
+ }
+ }
+ }
+ */
+ # dodamo še missinge, samo tiste ki so izbrani z profilom
+ foreach ($_allMissing_answers AS $miskey => $_missing) {
+ if (!isset($_pageMissing_answers[$miskey])) {
+ if ( $spr_1_checkbox !== true) {
+ $_all_options1[$miskey] = array('naslov'=>$_missing, 'cnt'=>(int)$options1[$miskey], 'type'=>'m');
+ }
+ if ( $spr_2_checkbox !== true ) {
+ $_all_options2[$miskey] = array('naslov'=>$_missing, 'cnt'=>(int)$options2[$miskey], 'type'=>'m');
+ }
+ }
+ }
+ $sumaSkupna = max(array_sum($sumaStolpec), array_sum($sumaVrstica));
+
+ # če lovimo po enotah, moramo skupne enote za vsako kolono(vrstico) izračunati posebej - POPRAVLJENO KER TO MORA VERJETNO NAREDIT SAMO CE STA OBE SPR CHECKBOXA??
+ //if ($this->crossNavVsEno == 1) {
+ if ($spr_1_checkbox == true && $spr_2_checkbox == true && $this->crossNavVsEno == 1) {
+ $sumaSkupna = 0;
+ $sumaStolpec = array();
+ $sumaVrstica = array();
+
+ # sestavimo filtre za posamezno variablo da ni missing
+ if (count($sekvences1)>0) {
+ $spr1_addFilter = '';
+
+ foreach ($sekvences1 AS $sequence1) {
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key1 => $missing1) {
+ $spr1_addFilter .= ' && ($'.$sequence1.' != '.$m_key1.')';
+ }
+ }
+ }
+ if (count($sekvences2)>0) {
+ $spr2_addFilter = '';
+
+ foreach ($sekvences2 AS $sequence2) {
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key2 => $missing2) {
+ $spr2_addFilter .= ' && ($'.$sequence2.' != '.$m_key2.')';
+ }
+ }
+ }
+
+ # polovimo obe sequenci
+ $tmp_file = $folder . 'tmp_crosstab_'.$this->sid.'.TMP';
+
+
+ $file_handler = fopen($tmp_file,"w");
+ fwrite($file_handler,"<?php\n");
+
+ fclose($file_handler);
+
+ # preštejemo vse veljavne enote (nobena vrednost ne sme bit missing)
+
+
+ if (IS_WINDOWS) {
+ $command_all = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$spr1_addFilter.$spr2_addFilter.' { print \"$sumaSkupna++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command_all = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$spr1_addFilter. $spr2_addFilter.' { print "$sumaSkupna++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out_all = shell_exec($command_all);
+
+
+ #za vsako variablo polovimo število enot
+ #najprej za stolpce
+ if (count($sekvences1)>0) {
+ foreach ($sekvences1 AS $sequence1) {
+ if ($spr_1_checkbox == true) {
+ $_seq_1_text = ''.$sequence1;
+ # pri checkboxih lovimo samo tiste ki so 1
+ $chckbox_filter1 = ' && ($'.$sequence1.' == 1)';
+ } else {
+ $_seq_1_text = '$'.$sequence1;
+ }
+
+ if (IS_WINDOWS) {
+ $command_1 = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$chckbox_filter1.$spr2_addFilter.' { print \"$sumaStolpec[\x27\",'.$_seq_1_text.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command_1 = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$chckbox_filter1.$spr2_addFilter.' { print "$sumaStolpec[\x27",'.$_seq_1_text.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+ $out = shell_exec($command_1);
+ }
+ }
+ #nato še za vrstice
+ if (count($sekvences2)>0) {
+ foreach ($sekvences2 AS $sequence2) {
+ if ($spr_2_checkbox == true) {
+ $_seq_2_text = ''.$sequence2;
+ # pri checkboxih lovimo samo tiste ki so 1
+ $chckbox_filter2 = ' && ($'.$sequence2.' == 1)';
+ } else {
+ $_seq_2_text = '$'.$sequence2;
+ }
+
+ if (IS_WINDOWS) {
+ $command_2 = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$chckbox_filter2.$spr1_addFilter.' { print \"$sumaVrstica[\x27\",'.$_seq_2_text.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command_2 = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$chckbox_filter2.$spr1_addFilter.' { print "$sumaVrstica[\x27",'.$_seq_2_text.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+ $out = shell_exec($command_2);
+ }
+ }
+
+ $file_handler = fopen($tmp_file,"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_file);
+ if (file_exists($tmp_file)) {
+ unlink($tmp_file);
+ }
+ }
+
+ $CSS_COLOR0 = ' rsdl_bck0';
+ $CSS_COLOR1 = ' rsdl_bck1';
+ $CSS_COLOR2 = ' rsdl_bck2';
+ $CSS_COLOR3 = ' rsdl_bck3';
+ $CSS_COLOR4 = ' rsdl_bck4';
+ $CSS_COLOR5 = ' rsdl_bck5';
+ $CSS_COLOR6 = ' rsdl_bck6';
+
+ # izracunamo se pricakovano vrednost, in residuale
+ # exC - expected count (pricakovana vrednost)
+ $exC = array();
+ # res - residual
+ $res = array();
+ # stR - standardized residual
+ $stR = array();
+ # adR - adjusted residual
+ $adR = array();
+ #color - array kjer shranjujemo barvo celice v odvisnosti od adjusted residuala
+ $color = array();
+ #pocprečje vrstice
+ $sum_avgi = array();
+ #pocprečje stolpca
+ $sum_avgj = array();
+
+ $_w = 0;
+ $_fij = 0;
+ $_ri = 0;
+ $_cj = 0;
+ $_exC = 0;
+ $_res = 0;
+ $_stR = 0;
+ $_ri_div_w = 0;
+ $_cj_div_w = 0;
+ $_sqrt_part = 0;
+ $_adR = 0;
+ $_limit = 0;
+
+ $cnt1 = count($_all_options1);
+ $cnt2 = count($_all_options2);
+
+ # gremo skozi vsako celico
+ if ($cnt1 > 0 && $cnt2) {
+ foreach ($_all_options1 as $ckey1 => $crossVariabla1) {
+ if($sumaStolpec[$ckey1]!=null) {
+ foreach ($_all_options2 as $ckey2 => $crossVariabla2) {
+ if($sumaVrstica[$ckey2]!=null) {
+ # skupna suma
+ $_w = $sumaSkupna;
+ #frekvenca celice
+ $_fij = $crosstab[$ckey1][$ckey2];
+ #suma vrstice
+ $_ri = $sumaVrstica[$ckey2];
+ #suma stolpca
+ $_cj = $sumaStolpec[$ckey1];
+
+ # povprečje vrstice
+ $sum_avgi[$ckey2] += ((int)$_ri != 0) ? ((int)$_fij * (int)$ckey1 / (int)$_ri) : 0;
+
+ # povprečje stolpcev
+ $sum_avgj[$ckey1] += ((int)$_cj != 0) ? ((int)$_fij * (int)$ckey2 / (int)$_cj) : 0;
+
+ # exC - expected count (pricakovana vrednost
+ $_exC = ($_w > 0 ) ? (( $_ri * $_cj) / $_w) : 0;
+ $exC[$ckey1][$ckey2] = $_exC;
+ # res - residual
+ $_res = $_fij - $_exC;
+ $res[$ckey1][$ckey2] = $_res;
+ # stR - standardized residual
+ $_stR = ($_exC != 0) ? $_res / sqrt($_exC) : 0;
+ $stR[$ckey1][$ckey2] = $_stR;
+ # adR - adjusted residual
+ $_ri_div_w = ($_w != 0) ? ($_ri / $_w) : 0;
+ $_cj_div_w = ($_w != 0) ? ($_cj / $_w) : 0;
+ $_sqrt_part = $_exC * (1 - $_ri_div_w ) * (1 - $_cj_div_w );
+ $_adR = ($_sqrt_part != 0) ? $_res / sqrt($_sqrt_part ) : 0;
+
+ $adR[$ckey1][$ckey2] = $_adR;
+ #privzeto je belo
+ $color[$ckey1][$ckey2] = $CSS_COLOR0;
+ # katera vrednost nam je limit (prilagojen residual)
+ $_limit = $_adR;
+ if ($this->doColor == 'true') {
+ # če imamo barvanje residualov še pobarvamo v odvisnosti od prilagojenega residuala
+ if (abs($_limit) >= RESIDUAL_COLOR_LIMIT1)
+ $color[$ckey1][$ckey2] = $_limit > 0 ? $CSS_COLOR1 : $CSS_COLOR4;
+ if (abs($_limit) >= RESIDUAL_COLOR_LIMIT2)
+ $color[$ckey1][$ckey2] = $_limit > 0 ? $CSS_COLOR2 : $CSS_COLOR5;
+ if (abs($_limit) >= RESIDUAL_COLOR_LIMIT3)
+ $color[$ckey1][$ckey2] = $_limit > 0 ? $CSS_COLOR3 : $CSS_COLOR6;
+ }
+ } else {
+ if ($cnt2 > AUTO_HIDE_ZERRO_VALUE) {
+ unset($_all_options2[$ckey2]);
+ }
+ }
+ }
+ } else {
+ if ($cnt1 > AUTO_HIDE_ZERRO_VALUE) {
+ unset($_all_options1[$ckey1]);
+ }
+ }
+ }
+ }
+
+ # izračunamo še hi^2
+ $hi2 = 0;
+ if ($cnt1 > 0 && $cnt2)
+ foreach ($_all_options1 as $ckey1 => $crossVariabla1) {
+ foreach ($_all_options2 as $ckey2 => $crossVariabla2) {
+ $fr = (float)$crosstab[$ckey1][$ckey2];
+ $exp = (float)$exC[$ckey1][$ckey2];
+ if ($exp != 0) {
+ $hi2 += pow(($fr - $exp),2) / $exp;
+ }
+ #dejanska frekvenca
+
+ }
+ }
+ return(array(
+ 'crosstab' => $crosstab, # krostabulacije - frekvence
+ 'options1' => $_all_options1, # vse opcije za variablo 1
+ 'options2' => $_all_options2, # vse opcije za variablo 2
+ 'exC' => $exC, # pričakovana vrednost
+ 'res' => $res, # res - residual
+ 'stR' => $stR, # stR - standardized residual
+ 'adR' => $adR, # adR - adjusted residual
+ 'color' => $color, #color - array kjer shranjujemo barvo celice v odvisnosti od adjusted residuala
+ 'sumaStolpec'=> $sumaStolpec, #
+ 'sumaVrstica'=> $sumaVrstica, #
+ 'sumaSkupna' => $sumaSkupna, #
+ 'avgVrstica' => $sum_avgi, # povprečje vrstice
+ 'avgStolpec' => $sum_avgj, # povprečje stolpca
+ 'hi2' => $hi2, # hi kvadrat
+ 'isCheckbox' => array('spr1'=>(boolean)$spr_1_checkbox,'spr2'=>(boolean)$spr_2_checkbox)
+ ));
+
+ }
+
+
+ }
+
+
+
+ /** Sestavi array nepravilnih odgovorov
+ *
+ */
+ function getInvalidAnswers($type) {
+ $result = array();
+ $missingValuesForAnalysis = SurveyMissingProfiles :: GetMissingValuesForAnalysis($type);
+
+ foreach ($missingValuesForAnalysis AS $k => $answer) {
+ $result[$k] = array('text'=>$answer,'cnt'=>0);
+ }
+ return $result;
+ }
+
+ /** Naredimo formatiran izpis
+ *
+ * @param $value
+ * @param $digit
+ * @param $sufix
+ */
+
+ static function formatNumber ($value, $digit = 0, $sufix = "") {
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+ # polovimo decimalna mesta in vejice za tisočice
+
+ $decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+
+ $result = number_format($result, $digit, $decimal_point, $thousands) . $sufix;
+
+ return $result;
+ }
+
+ function getCrossTabPercentage ($sum, $value) {
+ $result = 0;
+ if ($value ) {
+ $result = (int)$sum == 0 ? 0 : $value / $sum * 100;
+ }
+
+ return $result;
+ }
+
+ function setSessionPercent() {
+
+ if (isset($_POST['crossChk1'])) {
+ $this->sessionData['crosstabs']['crossChk1'] = ($_POST['crossChk1'] == 'true');
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function setSessionColor() {
+
+ if (isset($_POST['doColor'])) {
+ $this->sessionData['crosstabs']['doColor'] = ($_POST['doColor'] == 'true');
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function setShowChart() {
+
+ if (isset($_POST['showChart'])) {
+ $this->sessionData['crosstab_charts']['showChart'] = $_POST['showChart'] == 'true';
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ public function setColor($doColor = true) {
+ if ($doColor == true) {
+ $this->doColor = true;
+ } else {
+ $this->doColor = false;
+ }
+ }
+
+ /** Funkcije ki skrbijo za ajax del
+ *
+ */
+ public function ajax() {
+ if ( isset($_POST['sequence1']) && count($_POST['sequence1']) > 0 ) {
+ $i=0;
+ if ( count($_POST['sequence1']) > 0 ){
+ foreach ($_POST['sequence1'] AS $_seq1) {
+ $this->variabla1[$i]['seq'] = $_seq1;
+ $i++;
+ }
+ }
+ }
+
+ if ( isset($_POST['spr1']) && count($_POST['spr1']) > 0 ) {
+ $i=0;
+ if ( count($_POST['spr1']) > 0 ){
+ foreach ($_POST['spr1'] AS $_spr1) {
+ $this->variabla1[$i]['spr'] = $_spr1;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['grid1']) && count($_POST['grid1']) > 0 ) {
+ $i=0;
+ if ( count($_POST['grid1']) > 0 ){
+ foreach ($_POST['grid1'] AS $_grd1) {
+ $this->variabla1[$i]['grd'] = $_grd1;
+ $i++;
+ }
+ }
+ }
+
+ if ( isset($_POST['sequence2']) && count($_POST['sequence2']) > 0 ) {
+ $i=0;
+ if ( count($_POST['sequence2']) > 0 ){
+ foreach ($_POST['sequence2'] AS $_seq2) {
+ $this->variabla2[$i]['seq'] = $_seq2;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['spr2']) && count($_POST['spr2']) > 0 ) {
+ $i=0;
+ if ( count($_POST['spr2']) > 0 ){
+ foreach ($_POST['spr2'] AS $_spr2) {
+ $this->variabla2[$i]['spr'] = $_spr2;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['grid2']) && count($_POST['grid2']) > 0 ) {
+ $i=0;
+ if ( count($_POST['grid2']) > 0 ){
+ foreach ($_POST['grid2'] AS $_grd2) {
+ $this->variabla2[$i]['grd'] = $_grd2;
+ $i++;
+ }
+ }
+ }
+
+ # variable shranimo v sejo, da jih obdržimo tudi če spreminjamo nastavitve ali razne filtre analiz
+ if (isset($this->variabla1) && count($this->variabla1) > 0) {
+ $this->sessionData['crosstabs']['crosstab_variables']['variabla1'] = $this->variabla1;
+ }
+ if (isset($this->variabla2) && count($this->variabla2) > 0) {
+ $this->sessionData['crosstabs']['crosstab_variables']['variabla2'] = $this->variabla2;
+ }
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ if (isset($_POST['crossNavVsEno']) && $_POST['crossNavVsEno'] != '' ) {
+ $this->crossNavVsEno = $_POST['crossNavVsEno'] !== 'undefined' ? $_POST['crossNavVsEno'] : 0;
+ }
+
+
+ $this->readUserSettings();
+ switch ($_GET['a']) {
+ case 'changeDropdown':
+ $this->DisplayDropdows();
+ break;
+ case 'change':
+ $this->Display();
+ break;
+ case 'change_cb':
+ $this->displayCrosstabsTables();
+ break;
+ case 'change_cb_percent':
+ $this->setSessionPercent();
+ break;
+ case 'change_cb_color':
+ $this->setSessionColor();
+ break;
+ case 'add_new_variable':
+ $this->addNewVariable();
+ break;
+ case 'prepareInspect':
+ $this->prepareInspect();
+ break;
+ case 'changeSessionInspect':
+ $this->changeSessionInspect();
+ break;
+ case 'change_show_chart':
+ $this->setShowChart();
+ break;
+ default:
+ print_r("<pre>");
+ print_r($_GET);
+ print_r($_POST);
+ print_r("</pre>");
+ break;
+ }
+
+ }
+
+ function readUserSettings() {
+ @session_start();
+ $sdsp = SurveyDataSettingProfiles :: getSetting();
+
+ $this->crossChk0 = $sdsp['crossChk0'] == '1' ? true : false;
+
+ # če smo checkbox za odstotke po vrsticah nastavili preko seje (posebej) prevzamemo vrednost
+ if (isset($this->sessionData['crosstabs']['crossChk1'])) {
+ $this->crossChk1 = $this->sessionData['crosstabs']['crossChk1'];
+ } else {
+ # če ne preberemo iz profila
+ $this->crossChk1 = $sdsp['crossChk1'] == '1' ? true : false;
+ }
+
+ # če smo checkbox za barvanje nastavili preko seje (posebej) prevzamemo vrednost
+ if (isset($this->sessionData['crosstabs']['doColor'])) {
+ $this->doColor = $this->sessionData['crosstabs']['doColor'];
+ } else {
+ # če ne preberemo iz profila
+ $this->doColor = $sdsp['doColor'] == '1' ? true : false;
+ }
+
+ # če smo radio enableInspect
+ if ($sdsp['enableInspect'] == '1' || (isset($_SESSION['enableInspect']) && $_SESSION['enableInspect'] == true)) {
+ $this->enableInspect = true;
+ } else {
+ # če ne preberemo iz profila
+ $this->enableInspect = false;
+ }
+
+ $this->doValues = $sdsp['doValues'] == '1' ? true : false;
+
+ $this->crossChk2 = $sdsp['crossChk2'] == '1' ? true : false;
+ $this->crossChk3 = $sdsp['crossChk3'] == '1' ? true : false;
+ $this->crossChkEC = $sdsp['crossChkEC'] == '1' ? true : false;
+ $this->crossChkRE = $sdsp['crossChkRE'] == '1' ? true : false;
+ $this->crossChkSR = $sdsp['crossChkSR'] == '1' ? true : false;
+ $this->crossChkAR = $sdsp['crossChkAR'] == '1' ? true : false;
+
+ $this->showChart = isset($this->sessionData['crosstab_charts']['showChart']) ? $this->sessionData['crosstab_charts']['showChart'] : false;
+ }
+
+ function isSelectedBothVariables() {
+ $selected1 = false;
+ $selected2 = false;
+ if (count($this->variabla1)) {
+ foreach ($this->variabla1 AS $var1) {
+ if ((int)$var1['seq'] > 0) {
+ $selected1 = true;
+ }
+ }
+ }
+ if (count($this->variabla2)) {
+ foreach ($this->variabla2 AS $var2) {
+ if ((int)$var2['seq'] > 0) {
+ $selected2 = true;
+ }
+ }
+ }
+
+ return ($selected1 && $selected2);
+ }
+
+ function getSelectedVariables($which = 1) {
+ $selected = array();
+ if ($which == 1) {
+ if (count($this->variabla1) > 0 ) {
+ foreach ($this->variabla1 AS $var1) {
+ if ((int)$var1['seq'] > 0) {
+ $selected[] = $var1;
+ }
+ }
+ }
+ } else {
+ if (count($this->variabla2) > 0 ) {
+ foreach ($this->variabla2 AS $var2) {
+ if ((int)$var2['seq'] > 0) {
+ $selected[] = $var2;
+ }
+ }
+ }
+ }
+
+ return count($selected) > 0 ? $selected : null;
+ }
+
+ function prepareInspect() {
+
+ global $global_user_id, $lang;
+
+ # nastavimo v sejo od kod smo prišli v inspect:
+ @session_start();
+ if ((isset($_POST['from_podstran']) && trim($_POST['from_podstran']) != '')) {
+ $_SESSION['inspectFromPodstran'][$this->sid] = $_POST['from_podstran'];
+ } else {
+ unset($_SESSION['inspectFromPodstran'][$this->sid]);
+ }
+ @session_commit();
+
+ # naredimo filter po spremenljivkah
+ $variables = $_POST['sp1'].','.$_POST['sp2'];
+ if (SurveyDataSettingProfiles :: getSetting('enableInspect')) {
+ $_add_vars = $_SESSION['dataSetting_profile'][$this->sid]['InspectListVars'];
+ if (isset($_add_vars) && is_array($_add_vars) && count($_add_vars) > 0) {
+ foreach ($_add_vars AS $add_var) {
+ $variables .= ','.$add_var.'_0';
+ }
+ }
+ }
+ $svp = new SurveyVariablesProfiles();
+ $svp -> Init($this->sid,$global_user_id);
+ $svp-> setProfileInspect($variables);
+
+ $_spr1 = $this->_HEADERS[$_POST['sp1']];
+ $_spr2 = $this->_HEADERS[$_POST['sp2']];
+
+ # nastaviti moramo dva filtra - pogojev in spremenljivk
+ $spr1 = explode('_',$_POST['sp1']);
+ $spr1 = $spr1[0];
+ $spr2 = explode('_',$_POST['sp2']);
+ $spr2 = $spr2[0];
+
+
+ # if id za inspect shranimo v nastavitev ankete SurveyUserSetting -> inspect_if_id (če ne obstaja skreiramo novega)
+ # dodamo tudi kot profil pogojev (če ne obstaja skreiramo novega)
+
+ #preverimo ali obstaja zapis v SurveyUserSetting->inspect_if_id
+ $if_id = (int)SurveyUserSetting :: getInstance()->getSettings('inspect_if_id');
+ # preverimo dejanski obstoj ifa (srv_if) če ne skreiramo novega
+ if ((int)$if_id > 0) {
+ $chks1 = "SELECT * FROM srv_if WHERE id='$if_id'";
+ $chkq1 = sisplet_query($chks1);
+ # dodamo še k profilu če ne obstaja
+ if (mysqli_num_rows($chkq1) == 0) {
+ $if_id = null;
+ SurveyUserSetting :: getInstance()->removeSettings('inspect_if_id');
+ }
+ }
+
+ if ( (int)$if_id == 0 || $if_id == null) {
+ # if še ne obstaja, skreiramo novga
+ $sql = sisplet_query("INSERT INTO srv_if (id) VALUES ('')");
+ # if (!$sql) echo '<br> -1';
+
+ $if_id = mysqli_insert_id($GLOBALS['connect_db']);
+ sisplet_query("COMMIT");
+ # shranimo pogoj kot privzet pogoj z ainspect
+ SurveyUserSetting :: getInstance()->saveSettings('inspect_if_id',(int)$if_id);
+ }
+
+
+ if ((int)$if_id > 0) {
+ # dodamo ifa za obe variabli
+
+ # ne brišemo starih pogojev, da omogočimo gnezdenje
+ #$delStr = "DELETE FROM srv_condition WHERE if_id = '$if_id'";
+ #sisplet_query($delStr);
+
+ # poiščemo vrednosti za oba vprašanja
+ $condition1 = $this->createSubCondition(1,$if_id,$spr1,$_spr1);
+ $condition2 = $this->createSubCondition(2,$if_id,$spr2,$_spr2);
+
+ sisplet_query("COMMIT");
+
+ # pogoj dodamo še v srv_condition_profile vendar ga ne nastavimo kot privzetega
+ $chk_if_str = "SELECT * FROM srv_condition_profiles WHERE sid='".$this->sid."' AND uid = '".$global_user_id."' AND type='inspect'";
+ $chk_if_qry = sisplet_query($chk_if_str);
+ $_tmp_name = $lang['srv_inspect_temp_profile'];
+ if (mysqli_num_rows($chk_if_qry) > 0) {
+ # if že obstaja popravimo morebitne podatke
+ $str = "UPDATE srv_condition_profiles SET name = '$_tmp_name', if_id='$if_id'";
+ $sql = sisplet_query($str);
+ } else {
+ #vstavimo nov profil pogojev - inspect
+ $str = "INSERT INTO srv_condition_profiles (sid, uid, name, if_id, type ) VALUES ('".$this->sid."', '".$global_user_id."', '$_tmp_name', '$if_id', 'inspect')"
+ . " ON DUPLICATE KEY UPDATE name='$_tmp_name', if_id='$if_id'";
+ $sql = sisplet_query($str);
+ }
+ sisplet_query("COMMIT");
+ }
+
+ if (isset($_SESSION['inspect_goto'])) {
+ $inspect_goto = (int)$_SESSION['inspect_goto'];
+ } else {
+ $inspect_goto = (int)0;
+ }
+ $inspect_goto_array = array( 0 => '&a=analysis&m=sumarnik',
+ 1 => '&a=data&m=quick_edit',
+ 2 => '&a=data');
+
+ echo $inspect_goto_array[$inspect_goto];
+ return ($inspect_goto_array[$inspect_goto]);
+ }
+
+ function createSubCondition($vrstn_red,$if_id,$sid,$spr) {
+ $tip = $spr['tip'];
+
+ # 1. Radio
+ # 3. Dropdown
+ # 2. Select - checkbox
+ if ($tip == '1' || $tip == '3' || $tip == '2') {
+ #radio in dropdown
+ if ($tip == '1' || $tip == '3') {
+ #s pomočjo k preberemo vrstni red
+ $sql_string = "SELECT id FROM srv_vrednost WHERE spr_id='$sid' AND variable = '".$_POST['k'.$vrstn_red]."'";
+ $sql_query = sisplet_query($sql_string);
+ if (mysqli_num_rows($sql_query) == 1 ) {
+ $sql_row = mysqli_fetch_assoc($sql_query);
+ $vred_id = $sql_row['id'];
+ }
+ }
+ #select
+ if ($tip == '2' ) {
+ $vred_id=null;
+ # če je čekbox poiščemo vred_id za sekvenco k
+ foreach ($spr[grids] as $gkey=>$grid) {
+ foreach ($grid[variables] as $vkey=>$variable) {
+ if ($variable['sequence'] == $_POST['k'.$vrstn_red]) {
+ $vred_id = $variable['vr_id'];
+ }
+ }
+ }
+ }
+ if ($vred_id != null && (int)$vred_id > 0) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red) VALUES ('$if_id', '$sid', '$vrstn_red')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red'";
+ $sql = sisplet_query($istr);
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+
+ if ((int)$vred_id > 0 || (int)$cond_id > 0) {
+ $istr = "INSERT INTO srv_condition_vre (cond_id, vre_id) VALUES ('$cond_id', '$vred_id')";
+ $sql = sisplet_query($istr);
+ if (!$sql) {
+ echo '<br>-4 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ }
+ return $cond_id;
+ }
+ }
+
+ # 7. Number
+ if ($tip == '7' ) {
+ $text=$_POST['k'.$vrstn_red];
+ $vred_id=null;
+ #pogledamo za katero vrednost iščemo s pomočjo sekvence
+ $seq = $_POST['sq'.$vrstn_red];
+ $vrstn_red = $vrstn_red-1;
+ foreach ($spr['grids'] AS $gkey=> $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['sequence'] == $seq) {
+ $grid_id = $vkey;
+ }
+ }
+ }
+ if ($grid_id !== null) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, grd_id, text) VALUES ('$if_id', '$sid', '$vrstn_red', '$grid_id', '$text')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red', grd_id='$grid_id', text='$text'";
+ $sql = sisplet_query($istr);
+
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+ return $cond_id;
+ }
+ }
+ # 21. besedilo
+ # 18. vsota
+ if ($tip == '21' || $tip == '18') {
+
+ $text=$_POST['k'.$vrstn_red];
+ $vred_id=null;
+ #pogledamo za katero vrednost iščemo s pomočjo sekvence
+ $seq = $_POST['sq'.$vrstn_red];
+
+ foreach ($spr['grids'] AS $gkey=> $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['sequence'] == $seq) {
+ $vred_id = $variable['vr_id'];
+ }
+ }
+ }
+
+ if ($vred_id !== null && (int)$vred_id > 0) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id, text) VALUES ('$if_id', '$sid', '$vrstn_red', '$vred_id', '$text')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red', vre_id='$vred_id', text='$text'";
+ $sql = sisplet_query($istr);
+
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+ return $cond_id;
+ }
+ }
+ # 16. multi checkbox
+ if ($tip == '16' ) {
+ $vred_id=null;
+
+ # sekvenca je podana pod k
+ $seq = $_POST['k'.$vrstn_red];
+
+ #pogledamo za katero vrednost iščemo s pomočjo sekvence
+ foreach ($spr['grids'] AS $gkey=> $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['sequence'] == $seq) {
+ $vred_id = $variable['vr_id'];
+ $grid_id = $variable['gr_id'];
+ }
+ }
+ }
+
+ if ($vred_id !== null && (int)$vred_id > 0) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id) VALUES ('$if_id', '$sid', '$vrstn_red', '$vred_id')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red', vre_id='$vred_id'";
+ $sql = sisplet_query($istr);
+
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+
+ #dodamo še v srv_grid
+ if ($cond_id > 0 && $grid_id > 0) {
+ $istr = "INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$cond_id', '".$grid_id."')";
+ $sql = sisplet_query($istr);
+ if (!$sql) {
+ echo '<br>-4 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ } else {
+ echo '<br>-5 :: ';
+ }
+ return $cond_id;
+ }
+ }
+ # 6. multi radio
+ if ($tip == '6' ) {
+ $vred_id=null;
+ #pogledamo za katero vrednost iščemo s pomočjo sekvence
+ $seq = $_POST['sq'.$vrstn_red];
+ foreach ($spr['grids'] AS $gkey=> $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['sequence'] == $seq) {
+ $vred_id = $variable['vr_id'];
+ }
+ }
+ }
+
+ if ($vred_id !== null && (int)$vred_id > 0) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id) VALUES ('$if_id', '$sid', '$vrstn_red', '$vred_id')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red', vre_id='$vred_id'";
+ $sql = sisplet_query($istr);
+
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+
+ #dodamo še v srv_grid
+ if ($cond_id > 0) {
+ $istr = "INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$cond_id', '".$_POST['k'.$vrstn_red]."')";
+ $sql = sisplet_query($istr);
+ if (!$sql) {
+ echo '<br>-4 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ } else {
+ echo '<br>-5 :: ';
+ }
+ return $cond_id;
+ }
+ }
+ # 17. razvrščanje ranking
+ if ($tip == '17' ) {
+
+ #pogledamo za katero vrednost iščemo s pomočjo sekvence
+ $seq = $_POST['sq'.$vrstn_red];
+
+ foreach ($spr['grids'] AS $gkey=> $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['sequence'] == $seq) {
+ $vred_id = $variable['vr_id'];
+ }
+ }
+ }
+
+ if ($vred_id !== null && (int)$vred_id > 0) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id) VALUES ('$if_id', '$sid', '$vrstn_red', '$vred_id')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red', vre_id='$vred_id'";
+ $sql = sisplet_query($istr);
+
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+ $grid_id = $_POST['k'.$vrstn_red];
+ #dodamo še v srv_grid
+ if ($cond_id > 0 && $grid_id > 0) {
+ $istr = "INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$cond_id', '".$grid_id."')";
+ $sql = sisplet_query($istr);
+ if (!$sql) {
+ echo '<br>-4 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ } else {
+ echo '<br>-5 :: ';
+ }
+ return $cond_id;
+ }
+ }
+ # 19. multi text
+ # 20. multi number
+ if ($tip == '19' || $tip == '20') {
+ $text=$_POST['k'.$vrstn_red];
+ #pogledamo za katero vrednost iščemo s pomočjo sekvence
+ $seq = $_POST['sq'.$vrstn_red];
+
+ foreach ($spr['grids'] AS $gkey=> $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['sequence'] == $seq) {
+ $vred_id = $variable['vr_id'];
+ $grid_id = $variable['gr_id'];
+ }
+ }
+ }
+
+ if ($vred_id !== null && (int)$vred_id > 0 && $grid_id > 0) {
+ $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id, grd_id, text) VALUES ('$if_id', '$sid', '$vrstn_red', '$vred_id', '$grid_id', '$text')"
+ . " ON DUPLICATE KEY UPDATE spr_id='$sid', vrstni_red = '$vrstn_red', grd_id='$grid_id', text='$text'";
+ $sql = sisplet_query($istr);
+
+ if (!$sql) {
+ echo '<br>-3 :: '.$istr;
+ echo mysqli_error($GLOBALS['connect_db']);
+ }
+ $cond_id = mysqli_insert_id($GLOBALS['connect_db']);
+ return $cond_id;
+ }
+ }
+
+ return null;
+ }
+
+ function changeSessionInspect() {
+ @session_start();
+ #Zamenjamo sejo
+ if (isset($_SESSION['enableInspect']) && $_SESSION['enableInspect'] == true) {
+ unset($_SESSION['enableInspect']);
+ } else {
+ $_SESSION['enableInspect'] = true;
+ }
+ @session_commit();
+
+ #nastavimo inspect
+ $sdsp = SurveyDataSettingProfiles :: getSetting();
+ if ($sdsp['enableInspect'] == '1' || (isset($_SESSION['enableInspect']) && $_SESSION['enableInspect'] == true)) {
+ $this->enableInspect = true;
+ } else {
+ # če ne preberemo iz profila
+ $this->enableInspect = false;
+ }
+
+ $this->displaySessionInspectCheckbox();
+ }
+ function displaySessionInspectCheckbox() {
+ global $lang;
+ echo '<input type="checkbox" id="session_inspect" '.($this->enableInspect == true ? ' checked="checekd"' : '').' onClick="changeSessionInspect();">'.$lang['srv_inspect_setting'];
+ echo Help :: display('srv_crosstab_inspect');
+ }
+
+
+ function displayLinePercent() {
+ global $lang;
+
+ echo '<input id="crossCheck1" name="crossCheck1" onchange="change_crosstab_percent();" type="checkbox" ' . ($this->crossChk1 == true ? ' checked="checked" ' : '') . ' autocomplete="off"/>';
+ echo '<label for="crossCheck1" id="spn_residual_sp1" class="ctbChck_sp1">' . $lang['srv_analiza_crosstab_odstotek_vrstice_short'].'</label>';
+ echo '<input id="crossDoColor" name="crossDoColor" onchange="change_crosstab_color();" type="checkbox" ' . ($this->doColor == true ? ' checked="checked" ' : '') . ' autocomplete="off"/>';
+ echo '<label for="crossDoColor" id="spn_residual_sp1" class="ctbChck_sp1">' . $lang['srv_analiza_crosstab_color'].'</label>';
+ }
+
+ function displayResidual(){
+ global $lang;
+
+ $selected = ($this->crossChkEC + $this->crossChkRE + $this->crossChkSR + $this->crossChkAR == 4) ? true : false;
+
+ echo '<input id="crossResiduals" name="crossResiduals" onchange="saveResidualProfileSetting(\''.SurveyDataSettingProfiles::getCurentProfileId().'\', this.checked); return false;" type="checkbox" ' . ($selected ? ' checked="checked" ' : '') . ' autocomplete="off"/>';
+ echo '<label for="crossResiduals" id="crossResiduals" class="show_residual">' . $lang['srv_analiza_crosstab_residuals'].'</label>';
+ }
+
+ function displayShowChart() {
+ global $lang;
+
+ echo '<input id="showChart" name="showChart" onchange="showTableChart(\'crosstab\');" type="checkbox" ' . ($this->showChart == true ? ' checked="checked" ' : '') . ' />';
+ echo '<label for="showChart" id="showChart" class="showChart">'.$lang['srv_show_charts'].'</label>';
+ }
+
+ function presetVariables() {
+ # preberemo prednastavljene variable iz seje, če obstajajo
+ if (isset($this->sessionData['crosstabs']['crosstab_variables']['variabla1']) && count($this->sessionData['crosstabs']['crosstab_variables']['variabla1']) > 0) {
+ $this->variabla1 = $this->sessionData['crosstabs']['crosstab_variables']['variabla1'];
+ }
+ if (isset($this->sessionData['crosstabs']['crosstab_variables']['variabla2']) && count($this->sessionData['crosstabs']['crosstab_variables']['variabla2']) > 0) {
+ $this->variabla2 = $this->sessionData['crosstabs']['crosstab_variables']['variabla2'];
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyEditsAnalysis.php b/admin/survey/classes/surveyAnalysis/class.SurveyEditsAnalysis.php
new file mode 100644
index 0000000..b1b7b5f
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyEditsAnalysis.php
@@ -0,0 +1,984 @@
+<?php
+/**
+ * Analize urejanja
+ *
+ * Author: Uroš Podkrižnik
+ * Created: 14.4.2017
+ */
+
+define('GRAPH_REDUCE', '1.22'); # količnik za koliko zmanjšamo širino grafa da ne prebije
+
+class SurveyEditsAnalysis{
+
+ private $anketa; # id ankete
+ private $db_table; # katere tabele uporabljamo
+
+
+ function __construct($anketa){
+ if ((int)$anketa > 0){
+
+ $this->anketa = $anketa;
+
+ # polovimo vrsto tabel (aktivne / neaktivne)
+ SurveyInfo :: getInstance()->SurveyInit($this->anketa);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ $this->db_table = '_active';
+ }
+ }
+ else {
+ echo 'Invalid Survey ID!';
+ exit();
+ }
+ }
+
+
+ function displayTable(){
+ global $lang;
+
+ // Legenda statusov
+ $statuses = array(
+ -1 => $lang['srv_vsi'],
+ 0 => $lang['srv_urejanje'],
+ 1 => $lang['import_data'],
+ 2 => $lang['export_analisys'],
+ 3 => $lang['srv_reporti'],
+ 4 => $lang['srv_podatki'],
+ 5 => $lang['srv_inv_nav_email'],
+ 20 => $lang['srv_hierarchy'], // Splošni podatki o hierarhiji
+ 21 => $lang['srv_hierarchy_structure'], // Grajenje hierarhije
+ 22 => $lang['srv_hierarchy_users'], // Urejanje uporabnikov
+ );
+
+ //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 = '';
+
+ echo '<form id="diagnostics_form" action="index.php" method="get">';
+
+ echo '<input type="hidden" name="a" value="edits_analysis" />';
+ echo '<input type="hidden" name="anketa" value="'.$this->anketa.'" />';
+
+ echo ''.$lang['srv_edits_analysis_seansa'].' <select name="seansa" onchange="this.form.submit();">';
+ echo '<option value="5"' . ($seansa == '5' ? ' selected' : '') . '>'.$lang['srv_edits_analysis_seansa_5min'].'</option>';
+ echo '<option value="10"' . ($seansa == '10' ? ' selected' : '') . '>'.$lang['srv_edits_analysis_seansa_10min'].'</option>';
+ echo '<option value="30"' . ($seansa == '30' ? ' selected' : '') . '>'.$lang['srv_edits_analysis_seansa_30min'].'</option>';
+ echo '<option value="60"' . ($seansa == '60' ? ' selected' : '') . '>'.$lang['srv_edits_analysis_seansa_1h'].'</option>';
+ echo '</select> ';
+
+ echo ''.$lang['status'].' <select name="status" id="edits_analysis_status" onchange="this.form.submit();">';
+ echo '<option value="-1"' . ($status == -1 ? ' selected' : '') . '>'.$statuses[-1].'</option>';
+ echo '<option value="0"' . ($status == 0 ? ' selected' : '') . '>'.$statuses[0].'</option>';
+ echo '<option value="1"' . ($status == 1 ? ' selected' : '') . '>'.$statuses[1].'</option>';
+ echo '<option value="2"' . ($status == 2 ? ' selected' : '') . '>'.$statuses[2].'</option>';
+ echo '<option value="3"' . ($status == 3 ? ' selected' : '') . '>'.$statuses[3].'</option>';
+ echo '<option value="4"' . ($status == 4 ? ' selected' : '') . '>'.$statuses[4].'</option>';
+ echo '<option value="5"' . ($status == 5 ? ' selected' : '') . '>'.$statuses[5].'</option>';
+ /*echo '<option value="20"' . ($status == 20 ? ' selected' : '') . '>'.$statuses[20].'</option>';
+ echo '<option value="21"' . ($status == 21 ? ' selected' : '') . '>'.$statuses[21].'</option>';
+ echo '<option value="22"' . ($status == 22 ? ' selected' : '') . '>'.$statuses[22].'</option>';*/
+ echo '</select> '.$lang['srv_diagnostics_in'].' ';
+
+ echo '<select id="diagnostics_date_selected" name="time" onchange="diagnosticsChooseDate();">';
+ /*echo '<option value="10 minute"' . ($time == '10 minute' ? ' selected' : '') . '>'.$lang['srv_diagnostics_10 minute'].'</option>';
+ echo '<option value="30 minute"' . ($time == '30 minute' ? ' selected' : '') . '>'.$lang['srv_diagnostics_30 minute'].'</option>';*/
+ echo '<option value="lifetime"' . ($time == 'lifetime' ? ' selected' : '') . '>'.$lang['srv_edits_analysis_period_lifetime'].'</option>';
+ echo '<option value="1 hour"' . ($time == '1 hour' ? ' selected' : '') . '>'.$lang['srv_diagnostics_1 hour'].'</option>';
+ echo '<option value="6 hour"' . ($time == '6 hour' ? ' selected' : '') . '>'.$lang['srv_diagnostics_6 hour'].'</option>';
+ echo '<option value="12 hour"' . ($time == '12 hour' ? ' selected' : '') . '>'.$lang['srv_diagnostics_12 hour'].'</option>';
+ echo '<option value="1 day"' . ($time == '1 day' ? ' selected' : '') . '>'.$lang['srv_diagnostics_1 day'].'</option>';
+ echo '<option value="2 day"' . ($time == '2 day' ? ' selected' : '') . '>'.$lang['srv_diagnostics_2 day'].'</option>';
+ echo '<option value="5 day"' . ($time == '5 day' ? ' selected' : '') . '>'.$lang['srv_diagnostics_5 day'].'</option>';
+ echo '<option value="7 day"' . ($time == '7 day' ? ' selected' : '') . '>'.$lang['srv_diagnostics_7 day'].'</option>';
+ echo '<option value="14 day"' . ($time == '14 day' ? ' selected' : '') . '>'.$lang['srv_diagnostics_14 day'].'</option>';
+ echo '<option value="1 month"' . ($time == '1 month' ? ' selected' : '') . '>'.$lang['srv_diagnostics_1 month'].'</option>';
+ echo '<option value="3 month"' . ($time == '3 month' ? ' selected' : '') . '>'.$lang['srv_diagnostics_3 month'].'</option>';
+ echo '<option value="6 month"' . ($time == '6 month' ? ' selected' : '') . '>'.$lang['srv_diagnostics_6 month'].'</option>';
+ echo '<option id="option_99date" value="99date"' . ($time == '99date' ? ' selected' : '') . '>'.$lang['srv_diagnostics_choose_date'].'</option>';
+ echo '</select> ';
+
+ // Datum - od
+ echo ''.$lang['srv_diagnostics_orfrom'].' <input type="text" id="from" name="from" value="' . $from . '" '. ($time != '99date' ? ' disabled' : '') .' />';
+ echo ' <span class="faicon calendar_icon icon-as_link" onclick="changeSelectOption()" id="from_img"></span>';
+
+ // Datum - do
+ echo ' '.$lang['srv_diagnostics_to'].' <input type="text" id="to" name="to" value="' . $to . '" '. ($time != '99date' ? ' disabled' : '') .'/>';
+ echo ' <span class="faicon calendar_icon icon-as_link" onclick="changeSelectOption()" id="to_img"></span>';
+
+ echo '<input type="submit" class="spaceLeft pointer" value="'.$lang['hour_show'].'" />';
+
+ echo '</form><div>';
+
+ //create iterval - SQL where statement
+ $interval = $this->createInterval($time, $from, $to);
+ //get object of all edits data
+ $data = $this->getData($status, $interval);
+
+ if(sizeof($data) == 0)
+ $this->echoNoData();
+ else{
+ echo '<div id="edits_analysis_time_tables">';
+ echo '<div>';
+ $sum_data = $this->drawTimeEdits($data['timeEdits'], $seansa*60, $status);
+ echo '</div>';
+ $this->GraphData($this->graphQuery($status, $interval));
+ echo '</div>';
+
+ echo '<table class="dashboard" id="edits_analysis_info">';
+ echo '<tr>';
+
+ //draw edits counter and sums of editors
+ $this->drawCountEdits($sum_data);
+
+ //draw continuous editing box
+ $continu_data = $this->continuEditsQuery($status, $interval);
+ $this->drawContinuEdits($continu_data, $sum_data);
+
+ echo '</tr>';
+ echo '</table>';
+
+ //prestavi vse tabele na konec, da bo info na vrhu
+ echo'<script>var myElement = document.getElementById("edits_analysis_time_tables");'
+ . 'myElement.parentNode.appendChild(myElement);</script>';
+
+
+ }
+ echo '</div>';
+ }
+
+ function GraphData($data){
+ global $lang, $site_url;
+
+ //error_log(json_encode($data));
+ //$DataSetJson = json_decode('{"Data":[{"Vrednosti":5,"Vrednosti2":2,"Name":0,"Variable":"0-1000"},{"Vrednosti":20,"Vrednosti2":15,"Name":1,"Variable":"1001-5000"},{"Vrednosti":20,"Vrednosti2":20,"Name":2,"Variable":"5001-10000"},{"Vrednosti":0,"Vrednosti2":8,"Name":3,"Variable":"10001-50000"}],'
+ // . '"DataDescription":{"Position":"Variable","Format":{"X":"number","Y":"number"},"Unit":{"X":null,"Y":null},"Values":["Vrednosti", "Vrednosti2"],"Description":{"Vrednosti":"prvi-prvi-prvi-prvi-prvi", "Vrednosti2":"drugi-drugi-drugi-drugi-drugi"}},"numerus":45,"average":4721,"Other":[]}');
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ $vrednosti = array();
+ $vrednostiVariable = array();
+ $avg_count = 0;
+ $avg_sum = 0;
+
+ /*foreach ($DataSetJson->Data as $value){
+ $vrednosti[] = $value->Vrednosti;
+ $vrednosti2[] = $value->Vrednosti2;
+ $avg_sum+=$value->Vrednosti;
+ $vrednostiVariable[] = $value->Variable;
+ $avg_count++;
+ }*/
+
+ $start_date = new DateTime($data['first_date']);
+ $temp_date = $start_date;
+ $end_date = new DateTime($data['last_date']);
+
+ $diff = $this->differDateTimeInDays($start_date, $end_date);
+ $DayFormat = '';
+ $DayIncrease = 'month';
+ if($diff < 32){
+ $DayFormat = '-d';
+ $DayIncrease = 'day';
+ }
+ else
+ $temp_date->setDate($start_date->format('Y'), $start_date->format('m'), 1);
+
+ while ($temp_date <= $end_date){
+ foreach($data['edits'] as $user=>$value){
+ $datestring = $temp_date->format('Y-m'.$DayFormat);
+ $cnt = isset($value[$datestring]) ? $value[$datestring] : 0;
+ $vrednosti[$user][] = $cnt;
+
+ $avg_sum+=$cnt;
+ }
+
+ $vrednostiVariable[] = $datestring;
+ $avg_count++;
+ $temp_date->modify('+1 '.$DayIncrease);
+ }
+
+ foreach($data['edits'] as $user=>$value){
+ $DataSet->AddPoint($vrednosti[$user],$user);
+ $DataSet->AddSerie($user);
+ $DataSet->SetSerieName($user,$user);
+ }
+
+ // nastavimo NUMERUS, ki se izpise pod legendo
+ $numerus = $avg_sum;
+ $DataSet->SetNumerus($numerus);
+
+ // nastavimo POVPRECJE
+ $avg = ($avg_count > 0) ? $avg_sum / $avg_count : 0;
+ $DataSet->SetAverage(round($avg, 1));
+
+
+ $DataSet->AddPoint($vrednostiVariable,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ //$DataSet->SetYAxisUnit("null");
+ $DataSet->SetYAxisFormat("number");
+
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+ $ID = self::generateChartId($DataSet->GetNumerus());
+
+ echo '<div style="margin-top:-2.5em;">';
+ echo '<div class="chart_holder" style="margin: auto !important; width: auto !important;" id="chart_edits_'.$this->anketa.'">';
+ echo '<div class="chart_title" style="width: auto !important">'. $lang['srv_edits_analysis_graph'];
+ echo '<span class="numerus">';
+ echo '(n = '.$DataSet->GetNumerus().')';
+ echo '</span>';
+ echo '</div>';
+
+ if(!$Cache->isInCache($ID, $DataSet->GetData())){
+ $graph = SurveyChart::createLine($DataSet, null, 1);
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$graph);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ $imgPath = 'pChart/Cache/'.$imgName;
+
+ $imgUrl = $site_url . 'admin/survey/' . $imgPath;
+
+ echo '<div class="chart_img" style="float: none !important" title="'.$lang['srv_edits_analysis_graph'].'">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgUrl.'?'.time().'" />';
+ echo '</div></div></div>';
+ }
+
+ /**
+ * Run querry for action times
+ * @param type $status - int of status
+ * @param type $interval - where clause for time interval
+ * @return type array of results from DB
+ */
+ function graphQuery($status, $interval){
+ $sql2 = "SELECT min(DATE_FORMAT(st.datetime, '%Y-%m-%d')) as first_date, max(DATE_FORMAT(st.datetime, '%Y-%m-%d')) as last_date"
+ . " FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ".
+ ($status != -1 ? "AND st.status=$status " : "") ."$interval ";
+ $output2=sisplet_query($sql2, 'obj');
+
+ $diff = $this->differDateTimeInDays(new DateTime($output2->first_date), new DateTime($output2->last_date));
+ $queryDayFormat = '';
+ $queryDayGroup = '';
+ if($diff < 32){
+ $queryDayFormat = '-%d';
+ $queryDayGroup = ', DAY(st.datetime)';
+ }
+
+ $sql = "SELECT count(*) as cnt, u.email, u.id, DATE_FORMAT(st.datetime, '%Y-%m$queryDayFormat') as date"
+ . " FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ".
+ ($status != -1 ? "AND st.status=$status " : "") ."$interval "
+ . "GROUP BY u.email, YEAR(st.datetime), MONTH(st.datetime)$queryDayGroup "
+ . "ORDER BY u.email, date ASC";
+ $output=sisplet_query($sql, 'array');
+
+ $data = array('edits'=>array(), 'first_date'=>$output2->first_date, 'last_date'=>$output2->last_date);
+ foreach($output as $row){
+ $data['edits'][$row['email']][$row['date']]=$row['cnt'];
+ }
+ return $data;
+ }
+
+ private function differDateTimeInDays($start_date, $end_date){
+ return $end_date->diff($start_date)->format("%a");
+ }
+
+ // Zgeneriramo ID grafa za hash
+ private function generateChartId($numerus){
+ $ID = $this->anketa.'_chart_'.$numerus.'edits_analysis';
+ return $ID;
+ }
+
+ /**
+ * Get data to show in table
+ *
+ * @param type $status - status or type of edits
+ * @param type $interval - where statement including interval for SQL
+ * @return type
+ */
+ function getData($status, $interval){
+ $data = array();
+
+ $data_temp = $this->timeEditsQuery($status, $interval);
+
+ if(sizeof($data_temp) == 0)
+ return array();
+ else
+ $data['timeEdits'] = $data_temp;
+
+ return $data;
+ }
+
+ /**
+ * Create interval for SQL query from criteria
+ *
+ * @param type $time - time selected from dropdown
+ * @param type $from - from calendat
+ * @param type $to - to calendar
+ * @return type - string WHERE statement
+ */
+ function createInterval($time, $from, $to){
+ if($time == 'lifetime' || ($time == '99date' && $from == '' && $to == ''))
+ $interval = "";
+ else if ($from == '' && $to == '')
+ $interval = "AND st.datetime > NOW() - INTERVAL $time";
+ else if ($to == '')
+ $interval = "AND '$from' <= st.datetime";
+ else if ($from == '')
+ $interval = "AND st.datetime <= '$to'";
+ else
+ $interval = "AND '$from' <= st.datetime AND st.datetime <= '$to'";
+
+ return $interval;
+ }
+
+ /**
+ * Run querry for action times
+ * @param type $status - int of status
+ * @param type $interval - where clause for time interval
+ * @return type array of results from DB
+ */
+ function timeEditsQuery($status, $interval){
+ $sql = "SELECT u.email, u.id, st.datetime". ($status == 0 ? ", st.get, st.post" : "") . ($status == -1 ? ", st.status" : "")
+ . " FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ".
+ ($status != -1 ? "AND st.status=$status " : "") ."$interval ORDER BY u.email, st.datetime DESC";
+ return sisplet_query($sql, 'array');
+ }
+
+ /**
+ * Draw box of number of edit actions
+ * @global type $lang
+ * @param type $data - object data of sums
+ */
+ function drawCountEdits($data){
+ global $lang;
+
+ echo '<td>';
+ $sum_akcij = 0;
+ $sum_time = 0;
+ $sum_seans = 0;
+
+ echo '<div class="dashboard_cell" name="div_edits_analysis_counter" id="div_edits_analysis_counter" >'."\n";
+ echo '<span class="floatLeft dashboard_title">'.$lang['srv_edits_analysis_counter'];
+ echo '</span>';
+
+ echo '<br class="clr"/><br/>';
+
+ echo '<span class="dashboard_status_span">' . $lang['srv_edits_analysis_counter_editors'] .' :</span>' . sizeof($data).'<br/><br/>';
+ echo '<table id="tbl_answ_state">';
+ echo '<tr class="anl_dash_bb "><th><strong>'.$lang['srv_edits_analysis_counter_editor'].'</strong></th>'
+ . '<td><strong>'.$lang['srv_edits_analysis_time_time'].'</strong></td>'
+ . '<td><strong>'.$lang['srv_edits_analysis_num_sessions'].'</strong></td>'
+ . '<td><strong>'.$lang['srv_edits_analysis_time_actions'].'</strong></td></tr>';
+
+ foreach ($data as $key => $value) {
+ $this->echoCountEditsRow($key, $this->calculateTimeFromSeconds($value['time_sum']), $value['st_akcij_sum'], $value['st_seans_sum'], $value['user_id']);
+ $sum_akcij += $value['st_akcij_sum'];
+ $sum_time += $value['time_sum'];
+ $sum_seans += $value['st_seans_sum'];
+ }
+
+ // vsota vlejavnih
+ $this->echoCounterEditsFootRow($sum_time, $sum_akcij, $sum_seans);
+ echo '</table>';
+ echo '</div>';
+ echo '</td>';
+ }
+
+ /**
+ * Run querry for continuous editing
+ * @param type $status - int of status
+ * @param type $interval - where clause for time interval
+ * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour'
+ * @return type array of results from DB
+ */
+ function continuEditsQuery($status, $interval, $interval_criteria = 'day', $user_criteria = 'all'){
+ $interval_criteria = ($interval_criteria == 'day') ? '' : ' %H';
+
+ $sqlString = "SELECT DATE_FORMAT(st.datetime, '%Y-%m-%d$interval_criteria') AS formatdate, count(*) as cnt FROM srv_tracking$this->db_table st WHERE ank_id = '$this->anketa' ".
+ ($status != -1 ? "AND st.status=$status " : "")."".
+ ($user_criteria != 'all' ? "AND st.user=$user_criteria " : "")."$interval GROUP BY formatdate ORDER BY formatdate desc";
+
+ return sisplet_query($sqlString, 'array');
+ }
+
+ /**
+ * Draw box of continuous editing
+ * @global type $lang
+ * @param type $data - object data of continued editing
+ * @param type $sum_data - object data of sums
+ * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour'
+ */
+ function drawContinuEdits($data, $sum_data, $interval_criteria = 'day'){
+ global $lang;
+
+ echo '<td>';
+ echo '<div class="dashboard_cell" name="div_edits_analysis_countinu" id="div_edits_analysis_countinu" >'."\n";
+ echo '<span class="floatLeft dashboard_title">'.$lang['srv_edits_analysis_countinu'];
+ echo '</span>';
+
+ echo '<br class="clr"/><br/>';
+
+ //user/s
+ echo '<span id="span_timelineDropDownType">';
+ echo $lang['srv_edits_analysis_counter_editor'].': ';
+ echo '<select id="edits_analysis_continu_user" name="edits_analysis_continu_user" onchange="editsAnalysisContinuousEditing();">';
+ echo '<option value="all" selected>'.$lang['srv_edits_analysis_counter_all'].'</option>';
+ foreach ($sum_data as $email => $row) {
+ echo '<option value="'.$row['user_id'].'">'.$email.'</option>';
+ }
+ echo '</select> ';
+ echo '</span>';
+
+ // Oblika
+ echo '<span>';
+ echo '<label>'.$lang['srv_statistic_period'].'</label>:'."\n";
+ echo '<select id="edits_analysis_continu_period" name="edits_analysis_continu_period" size="1" autocomplete="off" onchange="editsAnalysisContinuousEditing();">'."\n";
+ echo '<option value="hour" '.(($interval_criteria == "hour") ? "selected" : "").'>'.$lang['srv_statistic_period_hour_period'].'</option>';
+ echo '<option value="day" '.(($interval_criteria == "day") ? "selected" : "").'>'.$lang['srv_statistic_period_day_period'].'</option>';
+ echo '</select>'."\n";
+ echo '</span>';
+
+ //data table
+ echo '<div name="edits_analysis_continu_table" id="edits_analysis_continu_table" >'."\n";
+ //draw table
+ $this->drawContinuEditsTable($data, $interval_criteria);
+ echo '</div>';
+ }
+
+ /**
+ * Draw table with bars od continued editing
+ * @param type $data - object data of continued editing
+ * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour'
+ */
+ function drawContinuEditsTable($data, $interval_criteria = 'day'){
+ $maxValue = 0;
+
+ $interval_seconds = ($interval_criteria == 'day') ? 86400 : 3600;
+ $interval_crit = ($interval_criteria == 'day') ? '' : ' H';
+
+ echo '<table class="survey_referals_tbl">'."\n";
+ if ($data) {
+ $temp_time = null;
+ //units
+ $zapored = 0;
+ $results = array();
+
+ foreach ($data as $row) {
+ if($temp_time == null)
+ $temp_time = DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']);
+ else{
+ //calculate seconds between actions (rounded on 3600 or 86400)
+ $interval = $this->calculateTimeBetweenActions($temp_time, DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']));
+
+ //if interval between actions are 1 unit (1 hour or 1 day), add it to continued editing session
+ if($interval/$interval_seconds-$zapored < 2){
+ $zapored++;
+ //set maxValue, needed for width of bars
+ $maxValue = max($maxValue, $zapored);
+ }
+ //interval is more than 1 unit apart, not in continued editing session
+ else{
+ //if there is continued editing session until previous action, store it to array - ignore otherwise
+ if($zapored > 0)
+ array_push($results, array('time' => $temp_time, 'zapored' => $zapored));
+
+ //restart all
+ $temp_time = DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']);
+ $zapored = 0;
+ }
+ }
+ }
+ //if there is continued editing session in last actions, store it to array - ignore otherwise
+ if($zapored > 0)
+ //$this->drawContinuRow($temp_time, $zapored, $maxValue, $value);
+ array_push($results, array('time' => $temp_time, 'zapored' => $zapored));
+
+ if(!$results)
+ $this->echoNoData();
+ else{
+ //reduce bars a little
+ $maxValue *= GRAPH_REDUCE;//najvecje stevilo
+ //draw all data and bars
+ foreach ($results as $row) {
+ $this->drawContinuRow($row['time'], $row['zapored'], $maxValue, $interval_criteria);
+ }
+ }
+ } else
+ $this->echoNoData();
+
+ echo '</table>'."\n";
+ }
+
+ /**
+ * Draws a row with bar of continuous editing
+ * @param type $temp_time - the last edit
+ * @param type $zapored - hour of continuoed editing
+ * @param type $maxValue - max value of bars
+ * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour'
+ */
+ function drawContinuRow($temp_time, $zapored, $maxValue, $interval_criteria){
+ $time_last = clone $temp_time;
+ //edit DateTime get starting of continued editting session by subtracting units
+ $temp_time->modify('- '.$zapored.' '.$interval_criteria);
+
+ //if hour criteria
+ if($interval_criteria == 'hour'){
+ //add 1 hour because of from to view
+ $time_last->modify('+ 1 '.$interval_criteria);
+ $s_time = $temp_time->format('Y-m-d H:00') .' - '. $time_last->format('H:00');
+ }
+ else if($interval_criteria == 'day')
+ $s_time = $temp_time->format('Y-m-d') .' - '. $time_last->format('Y-m-d');
+
+ //echo data
+ echo '<tr>'."\n";
+ echo '<td style="width:90px;">' . $s_time . '</td>'."\n";
+ $width = ($maxValue && $zapored) ? (round($zapored / $maxValue * 100, 0)) : "0";
+ echo '<td style=""><div class="graph_db" style="text-align:right; float:left; width:'.$width.'%">&nbsp;</div><span style="display:block; margin:auto; margin-left:5px; width:20px; float:left">'.($zapored+1).'</span></td>'."\n";
+ echo '</tr>'."\n";
+ }
+
+ /**
+ * Draw box of editing times
+ * @param type $data - $data['timeEdits']
+ * @param type $seansa - cas nastavljene dolzine seanse v min
+ * @param type $status - code of status criteria
+ * @return Object - object of editors e.g. {admin:{time_sum:500, st_akcij_sum:30, st_seans_sum:5}, ...}
+ */
+ function drawTimeEdits($data, $seansa, $status){
+ global $lang;
+
+ $sum_data = array();
+
+ $datetime_last = null;
+ $datetime_start = null;
+ $st_akcij = 0;
+ $st_akcij_sum = 0;
+ $st_seans_sum = 0;
+ $time_sum = 0;
+ $user_temp = null;
+ $user_id = 0;
+ $row_id = 0;
+ $action_type = null;
+ $action_type_sum = null;
+ $statuses = null;
+
+ if($status == -1){
+ $statuses = array(
+ 0 => array("name"=>$lang['srv_urejanje'], "sum"=>0),
+ 1 => array("name"=>$lang['import_data'], "sum"=>0),
+ 2 => array("name"=>$lang['export_analisys'], "sum"=>0),
+ 3 => array("name"=>$lang['srv_reporti'], "sum"=>0),
+ 4 => array("name"=>$lang['srv_podatki'], "sum"=>0),
+ 5 => array("name"=>$lang['srv_inv_nav_email'], "sum"=>0),
+ //20 => array("name"=>$lang['srv_hierarchy'], "sum"=>0),// Splošni podatki o hierarhiji
+ //21 => array("name"=>$lang['srv_hierarchy_structure'], "sum"=>0),// Grajenje hierarhije
+ //22 => array("name"=>$lang['srv_hierarchy_users'], "sum"=>0),// Urejanje uporabnikov
+ );
+ $action_type = $statuses;
+ $action_type_sum = $statuses;
+ }
+ else if($status == 0){
+ $statuses = array();
+ $action_type = array();
+ $action_type_sum = array();
+ }
+
+ echo '<h2>'.$lang["srv_edits_analysis_editing_details"].'</h2>';
+
+ foreach ($data as $rowGrupa) {
+
+ //$post = $this->convertToJSON($rowGrupa['post']);
+ $akcija = null;
+ if($status == -1)
+ $akcija = $rowGrupa['status'];
+ else if($status == 0){
+ $get = $this->convertToJSON($rowGrupa['get']);
+ $akcija = $get['a'];
+ }
+
+ //zacetek risanja
+ if(!isset($user_temp)){
+ $user_temp = $rowGrupa['email'];
+ $user_id = $rowGrupa['id'];
+ echo '<table class="text_analysis_table floatLeft" border="1">'; //border zaradi printa - css na strani ga povozi
+ $this->echoTimeTalbeHeader($user_temp, $status, $user_id);
+ }
+
+ //naslednji editor
+ else if($user_temp != $rowGrupa['email']){
+ //izrisi se zadnjo vrstico prejsnjega urejevalca
+ $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+ $this -> echoTimeEditsFootRow($time_sum, $st_akcij_sum, $action_type_sum, $user_id.'_sum');
+ $sum_data[$user_temp]['time_sum']=$time_sum;
+ $sum_data[$user_temp]['st_akcij_sum']=$st_akcij_sum;
+ $sum_data[$user_temp]['st_seans_sum']=$st_seans_sum;
+ $sum_data[$user_temp]['user_id']=$user_id;
+ $action_type_sum = $statuses;
+
+ //nova tabela - nov urejevalec
+ $user_temp = $rowGrupa['email'];
+ $user_id = $rowGrupa['id'];
+ $this->echoTimeTalbeHeader($user_temp, $status, $user_id);
+
+ //ponastavi spremenljivke
+ $datetime_last = null;
+ $datetime_start = null;
+ $st_akcij = 0;
+ $st_akcij_sum = 0;
+ $st_seans_sum = 0;
+ $time_sum = 0;
+ }
+
+ //izpis vrstic
+ //nov start seanse
+ if(!isset($datetime_start)){
+ $datetime_start = new DateTime($rowGrupa['datetime']);
+ $st_akcij++;
+ $st_seans_sum++;
+ $action_type = $statuses;
+ }
+ //se ni druge akcije
+ else if(!isset($datetime_last)){
+ $temp_time = new DateTime($rowGrupa['datetime']);
+ $interval = $this->calculateTimeBetweenActions($datetime_start, $temp_time);
+
+ //ce je akcija od starta v kriteriju seanse, jo dodaj k seansi
+ if($interval <= $seansa){
+ $datetime_last = clone $temp_time;
+ $st_akcij++;
+ }
+ //akcija je izven kriterija seanse, izpisi samo to akcijo
+ else{
+ $datetime_last = clone $datetime_start;
+ $datetime_last->add(new DateInterval('PT5S'));
+ $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+ $st_akcij = 1;
+ $st_seans_sum++;
+ $datetime_start = clone $temp_time;
+ $datetime_last = null;
+ $action_type = $statuses;
+ }
+ }
+ //seasna ze ima vsaj dve akciji
+ else{
+ $temp_time = new DateTime($rowGrupa['datetime']);
+ $interval = $this->calculateTimeBetweenActions($datetime_last, $temp_time);
+
+ //ce je akcija od prejsnje v kriteriju seanse, jo dodaj k seansi
+ if($interval <= $seansa){
+ $datetime_last = clone $temp_time;
+ $st_akcij++;
+ }
+ //akcija je izven kriterija seanse, izpisi vse prejsnje akcije
+ else{
+ $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+ $st_akcij = 1;
+ $st_seans_sum++;
+ $datetime_start = clone $temp_time;
+ $datetime_last = null;
+ $action_type = $statuses;
+ }
+ }
+ $st_akcij_sum++;
+ $row_id++;
+ if($status == -1){
+ $action_type[$akcija]['sum'] ++;
+ $action_type_sum[$akcija]['sum'] ++;
+ }
+ else if($status == 0){
+ $action_type[$akcija] = isset($action_type[$akcija]) ? $action_type[$akcija]+1 : 1;
+ $action_type_sum[$akcija] = isset($action_type_sum[$akcija]) ? $action_type_sum[$akcija]+1 : 1;
+ }
+ }
+
+ //izrisi se zadnjo vrstico, ki jo ni foreach ter footer
+ if($datetime_last == null){
+ $datetime_last = clone $datetime_start;
+ $datetime_last->add(new DateInterval('PT5S'));
+ }
+ $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+ $this -> echoTimeEditsFootRow($time_sum, $st_akcij_sum, $action_type_sum, $user_id.'_sum');
+ $sum_data[$user_temp]['time_sum']=$time_sum;
+ $sum_data[$user_temp]['st_akcij_sum']=$st_akcij_sum;
+ $sum_data[$user_temp]['st_seans_sum']=$st_seans_sum;
+ $sum_data[$user_temp]['user_id']=$user_id;
+
+ echo '</table>';
+
+ return $sum_data;
+ }
+
+ /**
+ * Izrisi header tabele za cas urejanja vsakega urejevalca
+ * @param type $user_temp - email of user
+ * @param type $status - status from criteria
+ * @param type $user_num - int sequence nuber of user (unique, for this site, no need to be ID)
+ */
+ function echoTimeTalbeHeader($user_temp, $status, $user_num){
+ global $lang;
+
+ echo '<tr id="edits_analysis_user_'.$user_num.'"><th colspan="100"><strong>'.$user_temp.'</strong></th></tr>';
+ echo '<tr><th>'.$lang['srv_edits_analysis_time_span'].'</th><th>'.$lang['srv_edits_analysis_time_time'].
+ '</th><th>'.$lang['srv_edits_analysis_time_actions'].'</th>'.($status < 1 ? '<th>'.$lang['srv_edits_analysis_action_type'].'</th>' : '').'</tr>';
+ }
+
+ /**
+ * Nastavi in kasneje izrise vrstico urejanja
+ *
+ * @param type $datetime_start - datetime start of editing
+ * @param type $datetime_last - datetime end of editing
+ * @param type $st_akcij - num ob actions during editing
+ * @param type $action_type - string of type of action
+ * @param type $row_id - int sequence nuber of row (unique, for this site, no need to be ID)
+ * @return type int - calculated second of editing session
+ */
+ function drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type = null, $row_id = null){
+ $seconds = 0;
+
+ //create string of actions type
+ $action_type_string = ($action_type != null) ? $this -> createActionsTypeString($action_type, $row_id) : null;
+
+ if(isset($datetime_last)){
+ $seconds = $this->calculateTimeBetweenActions($datetime_start, $datetime_last);
+ $this -> echoTimeEditsRow($datetime_last->format('Y-m-d H:i:s') .' - '. $datetime_start->format('Y-m-d H:i:s'),
+ $this->calculateTimeFromSeconds($seconds), $st_akcij, $action_type_string);
+ }
+ //ce je samo ena akcija
+ else
+ $this -> echoTimeEditsRow($datetime_start->format('Y-m-d H:i:s'), 0 ,1, $action_type_string);
+
+ return $seconds;
+ }
+
+ /**
+ * Create/convert array of action types to string for table cell
+ * @param type $action_type - array of action types
+ * @param type $row_id - int sequence nuber of row (unique user int and row in table)
+ * @return string - converter array to string to put it in table cell
+ */
+ function createActionsTypeString($action_type, $row_id){
+ $action_type_string = '';
+ //urejanje - ali drug specificen status
+ if(!isset($action_type[0]['sum'])){
+ global $lang;
+ $i = 0;
+ foreach ($action_type as $key => $at){
+ if($i == 3)
+ $action_type_string .= '<div class="srv_edits_analysis_'.$row_id.' as_link" onclick="$(\'.srv_edits_analysis_'.$row_id.'\').toggle();">'.$lang['srv_more'].'</div>';
+ if($i < 3)
+ $action_type_string .= '<div>'.$key.' ('.$at.')'.'</div>';
+ else
+ $action_type_string .= '<div class="srv_edits_analysis_'.$row_id.' displayNone">'.$key.' ('.$at.')'.'</div>';
+ $i++;
+ }
+ if($i > 3)
+ $action_type_string .= '<div class="srv_edits_analysis_'.$row_id.' as_link displayNone" onclick="$(\'.srv_edits_analysis_'.$row_id.'\').toggle();">'.$lang['srv_less'].'</div>';
+ }
+ //vsi statusi
+ else{
+ foreach ($action_type as $at){
+ if($at['sum'] > 0){
+ if($action_type_string != '')
+ $action_type_string .= '</br>';
+ $action_type_string .= $at['name'].' ('.$at['sum'].')';
+ }
+ }
+ }
+ return $action_type_string;
+ }
+
+ /**
+ * Izrise vrstico urejanja
+ * @param type $datetime - string from to editing
+ * @param type $cas_seanse - editing time
+ * @param type $st_akcij - num of editing actions
+ * @param type $action_type - string of type of action
+ */
+ function echoTimeEditsRow($datetime, $cas_seanse, $st_akcij, $action_type = null){
+ //casovni razpon urejanja
+ echo '<tr><td>'.$datetime.'</td>';
+ //cas urejanja
+ echo '<td>'.$cas_seanse.'</td>';
+ //stevilo akcij
+ echo '<td>'.$st_akcij.'</td>';
+ if($action_type != null)
+ //vrsta akcij
+ echo '<td>'.$action_type.'</td>';
+ echo '</tr>';
+ }
+
+ /**
+ * Izrise vrstico editor info
+ * @param type $user - string of editor
+ * @param type $time_sum - editing time
+ * @param type $st_akcij - num of sum editing actions
+ * @param type $st_seans_sum - num of sessions
+ * @param type $user_num - int sequence nuber of user (unique user int and row in table)
+ */
+ function echoCountEditsRow($user, $time_sum, $st_akcij, $st_seans_sum, $user_num){
+ //casovni razpon urejanja
+ echo '<tr><th><a href="#edits_analysis_user_'.$user_num.'">'.$user.'</a></th>';
+ //cas urejanja
+ echo '<td>'.$time_sum.'</td>';
+ //stevilo seans
+ echo '<td>'.$st_seans_sum.'</td>';
+ //stevilo akcij
+ echo '<td>'.$st_akcij.'</td>';
+ echo '</tr>';
+ }
+
+ /**
+ * Izrise total/footer vrstico urejanja
+ * @param type $time - seconds of editing
+ * @param type $st_akcij - num of editing actions
+ * @param type $action_type - string of type of actions
+ * @param type $row_id - int sequence nuber of user (unique, for this site, no need to be ID)
+ */
+ function echoTimeEditsFootRow($time, $st_akcij, $action_type = null, $row_id = 0){
+ global $lang;
+
+ //casovni razpon urejanja
+ echo '<tr class="colored"><td>'.$lang['srv_edits_analysis_time_total'].'</td>';
+ //cas urejanja
+ echo '<td>'.$this->calculateTimeFromSeconds($time).'</td>';
+ //stevilo akcij
+ echo '<td>'.$st_akcij.'</td>';
+ if($action_type != null)
+ //vrsta akcij
+ echo '<td>'.$this->createActionsTypeString($action_type, $row_id).'</td>';
+ echo '</tr>';
+ }
+
+ /**
+ * Izrise total/footer vrstico urejanja
+ * @param type $time - seconds of editing
+ * @param type $st_akcij - num of editing actions
+ * @param type $st_seans_sum - num of sessions
+ */
+ function echoCounterEditsFootRow($time, $st_akcij, $st_seans_sum){
+ global $lang;
+
+ //casovni razpon urejanja
+ echo '<tr class="anl_dash_bt full strong"><th>'.$lang['srv_edits_analysis_time_total'].'</th>';
+ //cas urejanja
+ echo '<td>'.$this->calculateTimeFromSeconds($time).'</td>';
+ //stevilo seans
+ echo '<td>'.$st_seans_sum.'</td>';
+ //stevilo akcij
+ echo '<td>'.$st_akcij.'</td>';
+ echo '</tr>';
+ }
+
+ /**
+ * Calculate
+ * @param type $datetime_start - datetime start of editing
+ * @param type $datetime_last - datetime end of editing
+ * @return type - float in time in minutes between actions
+ */
+ function calculateTimeBetweenActions($datetime_start, $datetime_last){
+ return abs($datetime_last ->getTimestamp() - $datetime_start->getTimestamp());
+ }
+
+ /**
+ * Get readable time from seconds
+ * @param type $seconds - time in seconds
+ * @return type string - readable time
+ */
+ function calculateTimeFromSeconds($seconds){
+ $hours = floor($seconds / 3600);
+ $mins = floor($seconds / 60 % 60);
+ $secs = floor($seconds % 60);
+
+ return sprintf('%02d:%02d:%02d', $hours, $mins, $secs);
+ }
+
+ /**
+ * Convert false JSON (with keys without quotes and no stat and end braces)
+ * from DB to valid JSON
+ * @param type $toJSON string to convert to JSON (with keys without
+ * quotes and no stat and end braces)
+ * @return type valid converted JSON
+ */
+ function convertToJSON($toJSON){
+ $toJSON = preg_replace('/("(.*?)"|(\w+))(\s*:\s*(".*?"|.))/s', '"$2$3"$4', $toJSON);
+ $toJSON = '{'.$toJSON.'}';
+ return json_decode($toJSON, true);
+ }
+
+ /**
+ * Echo 'no data in DB'
+ */
+ function echoNoData(){
+ global $lang;
+ echo '<p><b>'.$lang['srv_edits_analysis_no_data'].'</b></p>'."\n";
+ }
+
+ function ajax_drawContinuEditsTable(){
+ if (isset ($_POST['user']))
+ $user = $_POST['user'];
+ else
+ $user = 'all';
+ if (isset ($_POST['period']))
+ $period = $_POST['period'];
+ else
+ $period = 'day';
+ if (isset($_POST['time']))
+ $time = $_POST['time'];
+ else
+ $time = '1 month';
+ if (isset ($_POST['status']))
+ $status = $_POST['status'];
+ else
+ $status = 0;
+ if (isset ($_POST['from']))
+ $from = $_POST['from'];
+ else
+ $from = '';
+ if (isset ($_POST['to']))
+ $to = $_POST['to'];
+ else
+ $to = '';
+
+ //create iterval - SQL where statement
+ $interval = $this->createInterval($time, $from, $to);
+
+ //get data
+ $data = $this->continuEditsQuery($status, $interval, $period, $user);
+
+ //draw table
+ $this->drawContinuEditsTable($data, $period);
+ }
+
+ function getList($status, $interval){
+ $sql = "SELECT st.datetime, u.email, st.post, st.get FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ". ($status != -1 ? "AND st.status=$status " : "") ."$interval";
+
+ // Loop cez vse vrednosti v vprasanjih na straneh v anketi
+ $sqlGrupa = sisplet_query($sql);
+
+ $vrstic = 0;
+ while($rowGrupa = mysqli_fetch_array($sqlGrupa)){
+ $vrstic++;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyMeans.php b/admin/survey/classes/surveyAnalysis/class.SurveyMeans.php
new file mode 100644
index 0000000..f2155cf
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyMeans.php
@@ -0,0 +1,1369 @@
+<?php
+/** Class ki skrbi za povprečja - meanse
+ * December 2011
+ *
+ *
+ * Enter description here ...
+ * @author Gorazd_Veselic
+ *
+ */
+
+define("EXPORT_FOLDER", "admin/survey/SurveyData");
+
+class SurveyMeans{
+
+ private $sid; # id ankete
+ private $db_table; # katere tabele uporabljamo
+ private $_HEADERS = array(); # shranimo podatke vseh variabel
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $SDF = null; # class za inkrementalno dodajanje fajlov
+
+ public $variabla1 = array('0'=> array('seq'=>'0','spr'=>'undefined', 'grd'=>'undefined')); # array drugih variable, kamor shranimo spr, grid_id, in sequenco
+ public $variabla2 = array('0'=> array('seq'=>'0','spr'=>'undefined', 'grd'=>'undefined')); # array drugih variable, kamor shranimo spr, grid_id, in sequenco
+
+ public $variablesList = null; # Seznam vseh variabel nad katerimi lahko izvajamo meanse (zakeširamo)
+
+ public $_CURRENT_STATUS_FILTER = ''; # filter po statusih, privzeto izvažamo 6 in 5
+
+ public $_HAS_TEST_DATA = false; # ali anketa vsebuje testne podatke
+
+ public $doValues = true; # checkbox Prikaži vrednosti
+
+ private $sessionData; # podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+
+ public function __construct($sid) {
+ if ((int)$sid > 0) {
+ $this->sid = $sid;
+
+ # polovimo vrsto tabel (aktivne / neaktivne)
+ SurveyInfo :: getInstance()->SurveyInit($this->sid);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ $this->db_table = '_active';
+ }
+
+ # Inicializiramo in polovimo nastavitve missing profila
+ SurveyStatusProfiles::Init($this->sid);
+ SurveyUserSetting::getInstance()->Init($this->sid, $global_user_id);
+
+ $this->_CURRENT_STATUS_FILTER = STATUS_FIELD.' ~ /6|5/';
+
+ SurveyStatusProfiles::Init($this->sid);
+ SurveyMissingProfiles :: Init($this->sid,$global_user_id);
+ SurveyConditionProfiles :: Init($this->sid, $global_user_id);
+ SurveyZankaProfiles :: Init($this->sid, $global_user_id);
+ SurveyTimeProfiles :: Init($this->sid, $global_user_id);
+ SurveyVariablesProfiles :: Init($this->sid);
+
+ SurveyDataSettingProfiles :: Init($this->sid);
+
+
+ #inicializiramo class za datoteke
+ $this->SDF = SurveyDataFile::get_instance();
+ $this->SDF->init($this->sid);
+ $this->headFileName = $this->SDF->getHeaderFileName();
+ $this->dataFileName = $this->SDF->getDataFileName();
+ $this->dataFileStatus = $this->SDF->getStatus();
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->sid);
+ $this->sessionData = SurveyUserSession::getData();
+
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA || $this->dataFileStatus == FILE_STATUS_NO_FILE || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ Common::noDataAlert();
+ exit();
+ }
+
+ if ($this->headFileName !== null && $this->headFileName != '') {
+ $this->_HEADERS = unserialize(file_get_contents($this->headFileName));
+ }
+
+ # nastavimo vse filtre
+ $this->setUpFilter();
+
+ # nastavimo uporabniške nastavitve
+ $this->readUserSettings();
+
+ } else {
+ echo 'Invalid Survey ID!';
+ exit();
+ }
+ }
+
+
+ /** Funkcija ki nastavi vse filtre
+ *
+ */
+ private function setUpFilter() {
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ return false;
+ }
+
+ # poiščemo kater profil uporablja uporabnik
+ $_currentMissingProfile = SurveyUserSetting :: getInstance()->getSettings('default_missing_profile');
+ $this->currentMissingProfile = (isset($_currentMissingProfile) ? $_currentMissingProfile : 1);
+
+ # filtriranje po statusih
+ $this->_CURRENT_STATUS_FILTER = SurveyStatusProfiles :: getStatusAsAWKString();
+
+ # filtriranje po časih
+ $_time_profile_awk = SurveyTimeProfiles :: getFilterForAWK($this->_HEADERS['unx_ins_date']['grids']['0']['variables']['0']['sequence']);
+
+ # dodamo še ife
+
+ SurveyConditionProfiles :: setHeader($this->_HEADERS);
+ $_condition_profile_AWK = SurveyConditionProfiles:: getAwkConditionString();
+
+ if (($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) || ($_time_profile_awk != "" && $_time_profile_awk != null)) {
+ $this->_CURRENT_STATUS_FILTER = '('.$this->_CURRENT_STATUS_FILTER;
+ if ($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_condition_profile_AWK;
+ }
+ if ($_time_profile_awk != "" && $_time_profile_awk != null) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_time_profile_awk;
+ }
+ $this->_CURRENT_STATUS_FILTER .= ')';
+ }
+
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+
+ if ($this->dataFileStatus == FILE_STATUS_OK || $this->dataFileStatus == FILE_STATUS_OLD) {
+
+ if (isset($this->_HEADERS['testdata'])) {
+ $this->_HAS_TEST_DATA = true;
+ }
+ }
+ }
+
+ function readUserSettings() {
+ $sdsp = SurveyDataSettingProfiles :: getSetting();
+ $this->doValues = $sdsp['doValues'] == '1' ? true : false;
+ }
+
+ /** Prikazuje filtre
+ *
+ */
+ function DisplayFilters() {
+ if ($this->dataFileStatus == FILE_STATUS_SRV_DELETED || $this->dataFileStatus == FILE_STATUS_NO_DATA){
+ return false;
+ }
+
+ global $lang;
+ if ($this->setUpJSAnaliza == true) {
+ echo '<script>
+ window.onload = function() {
+ __analiza = 1;
+ __tabele = 1;
+ }
+ </script>';
+ }
+
+ /*echo '<div id="dataOnlyValid">';
+ SurveyStatusProfiles::displayOnlyValidCheckbox();
+ echo '</div>';*/
+
+
+ # izrišemo desne linke do posameznih nastavitev
+ $SSH -> displayAnalizaRightOptions(M_ANALYSIS_MEANS);
+ }
+
+ function DisplayLinks() {
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->sid);
+ $SSH -> displayAnalizaSubNavigation();
+ }
+
+ function ajax() {
+ #nastavimo variable če so postane
+ $this->setPostVars();
+ # izvedemo akcijo
+ switch ($_GET['a']) {
+ case 'changeDropdown':
+ $this->displayDropdowns();
+ break;
+ case 'change':
+ $this->displayData();
+ break;
+ case 'add_new_variable':
+ $this->addNewVariable();
+ break;
+ case 'changeMeansSubSetting':
+ $this->changeMeansSubSetting();
+ break;
+ case 'changeMeansShowChart':
+ $this->changeMeansShowChart();
+ break;
+ default:
+ print_r("<pre>");
+ print_r($_GET);
+ print_r($_POST);
+ break;
+ }
+
+ }
+
+ function Display() {
+ global $lang;
+
+ # ali imamo testne podatke
+ if ($this->_HAS_TEST_DATA) {
+ # izrišemo bar za testne podatke
+ $SSH = new SurveyStaticHtml($this->sid);
+ $SSH -> displayTestDataBar(true);
+ }
+
+ # preberemo prednastavljene variable iz seje, če obstajajo
+ $this->presetVariables();
+
+ //$this->DisplayLinks();
+ //$this->DisplayFilters();
+
+ echo '<div id="div_means_dropdowns">';
+ $this->displayDropdowns();
+ echo '</div>'; #id="div_means_dropdowns"
+
+ echo '<div id="div_means_data">';
+ $this->displayData();
+ echo '</div>'; #id="div_means_data"
+ }
+
+ function displayDropdowns() {
+ global $lang;
+ $variables1 = $this->getVariableList(1);
+ $variables2 = $this->getVariableList(2);
+
+ echo '<div id="meansLeftDropdowns" >';
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<span class="pointer space_means_new" >&nbsp;</span>';
+ }
+ echo $lang['srv_means_label1'];
+ echo '<br />';
+ # iz header datoteke preberemo spremenljivke
+ #js: $("#means_variable_1, #means_variable_2").live('click', function() {})
+ if (count($this->variabla1) > 0) {
+ $br=null;
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<span class="pointer" id="means_add_new" onclick="means_add_new_variable(\'1\');"><span class="faicon add small icon-as_link" title=""></span></span>';
+ }
+
+ foreach($this->variabla1 AS $_key => $variabla1) {
+ echo $_br;
+ echo '<span id="v1_'.$_key.'">';
+
+ echo '<select name="means_variable_1" id="means_variable_1" onchange="change_means(); return false;" autocomplete="off">';
+
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ( $variabla1['seq'] == null || $variabla1['seq'] == 0 ) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_means_izberi_prvo'].'</option>';
+ }
+ foreach ($variables1 as $variable) {
+ echo '<option value="'.$variable['sequence'].'" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . ( ($variabla1['seq'] > 0 &&$variabla1['seq'] == $variable['sequence']) ? ' selected="selected" ' : '')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'].'</option>';
+
+ }
+
+ echo '</select>';
+ if (count($this->variabla1) > 1) {
+ echo '<span class="pointer" id="means_remove" onclick="means_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+ } else {
+ #echo '<span class="space_means_new">&nbsp;</span>';
+ }
+
+ $_br = '<br/><span class="space_means_new">&nbsp;</span>';
+ echo '</span>';
+ }
+ $_br = null;
+ }
+
+ echo '</div>';
+
+ echo '<div id="meansRightDropdowns">';
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<span class="pointer space_means_new" >&nbsp;</span>';
+ }
+ echo $lang['srv_means_label2'];
+ echo '<br />';
+
+
+ # za vsako novo spremenljivko 2 nardimo svoj select
+ if (count($this->variabla2) > 0) {
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<span class="pointer" id="means_add_new" onclick="means_add_new_variable(\'2\');"><span class="faicon add small icon-as_link" title="'.'"></span></span>';
+ }
+
+ foreach($this->variabla2 AS $_key => $variabla2) {
+ echo $_br;
+ echo '<span id="v2_'.$_key.'">';
+ echo '<select name="means_variable_2" id="means_variable_2" onchange="change_means(); return false;" autocomplete="off"'
+ . ((int)$this->variabla1['0']['seq'] > 0 ? '' : ' disabled="disabled" ')
+ .'>';
+
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ((int)$this->variabla1['0']['seq'] == 0) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_means_najprej_prvo'].'</option>';
+ } else {
+ # če druga variabla ni izbrana dodamo tekst za izbiro druge variable
+ if ($variabla2['seq'] == null || $variabla2['seq'] == 0) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_means_izberi_drugo'].'</option>';
+ }
+ }
+
+ foreach ($variables2 as $variable) {
+ echo '<option value="'.$variable['sequence'].'" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . ( $variabla2['seq'] > 0 && $variabla2['seq'] == $variable['sequence'] ? ' selected="selected" ' : '')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] .'</option>';
+
+ }
+ echo '</select>';
+ if (count($this->variabla2) > 1) {
+ echo '<span class="pointer" id="means_remove" onclick="means_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+ } else {
+ echo '<span class="space_means_new">&nbsp;</span>';
+ }
+
+ $_br = '<br/><span class="space_means_new">&nbsp;</span>';
+ echo '</span>';
+ }
+ }
+ echo '</div>';
+
+ echo '<span id="meansSubSetting" class="floatLeft spaceLeft">';
+ if (count($this->variabla2) > 1) {
+ echo '<label><input id="chkMeansSeperate" type="checkbox" onchange="changeMeansSubSetting();" '.($this->sessionData['means']['meansSeperateTables']==true?' checked="checked"':'' ).'> '.$lang['srv_means_setting_1'].'</label>';
+
+ echo '<br /><span id="spanMeansJoinPercentage"'.($this->sessionData['means']['meansSeperateTables']!=true?'':' class="displayNone"').'><label><input id="chkMeansJoinPercentage" type="checkbox" onchange="changeMeansSubSetting();" '.($this->sessionData['means']['meansJoinPercentage']==true?' checked="checked"':'' ).'> '.$lang['srv_means_setting_2'].'</label></span>';
+ }
+ echo '<br /><label><input id="showChart" type="checkbox" onchange="showTableChart(\'mean\');" '.($this->sessionData['mean_charts']['showChart']==true?' checked="checked"':'' ).'> '.$lang['srv_show_charts'].'</label>';
+ echo '</span>';
+
+ echo '<br class="clr"/>';
+
+ // Ikone za izvoz (so tukaj da se refreshajo ob ajax klicu)
+ $this->displayExport();
+ }
+
+ function displayData() {
+ global $lang;
+ global $admin_type;
+
+ $br='';
+ $means = array();
+
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyTimeProfiles :: printIsDefaultProfile(false);
+
+ # če imamo filter ifov ga izpišemo
+ SurveyConditionProfiles:: getConditionString();
+
+ # če imamo filter spremenljivk ga izpišemo
+ SurveyVariablesProfiles:: getProfileString($doNewLine , true);
+
+ # če imamo rekodiranje
+ $SR = new SurveyRecoding($this->sid);
+ $SR -> getProfileString();
+
+ if ($this->getSelectedVariables(1) !== null && $this->getSelectedVariables(2) !== null) {
+ $variables1 = $this->getSelectedVariables(2);
+ $variables2 = $this->getSelectedVariables(1);
+ $c1=0;
+ $c2=0;
+
+ # odvisno ok checkboxa prikazujemo druge variable v isti tabeli ali v svoji
+ if ($this->sessionData['means']['meansSeperateTables'] == true ) {
+ #prikazujemo ločeno
+ if (is_array($variables2) && count($variables2) > 0) {
+ foreach ($variables2 AS $v_second) {
+ if (is_array($variables1) && count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $_means = $this->createMeans($v_first, $v_second);
+ if ($_means != null) {
+ $means[$c1][0] = $_means;
+ }
+ $c1++;
+ }
+ }
+ }
+ }
+ } else {
+ #prikazujemo v isti tabeli
+ if (is_array($variables2) && count($variables2) > 0) {
+ foreach ($variables2 AS $v_second) {
+ if (is_array($variables1) && count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $_means = $this->createMeans($v_first, $v_second);
+ if ($_means != null) {
+ $means[$c1][$c2] = $_means;
+ }
+ $c2++;
+ }
+ }
+ $c1++;
+ $c2=0;
+ }
+ }
+ }
+
+ if (is_array($means) && count($means) > 0) {
+ $counter=0;
+ foreach ($means AS $mean_sub_grup) {
+ echo($br);
+ $this->displayMeansTable($mean_sub_grup);
+ $br='<br />';
+
+ // Zvezdica za vkljucitev v porocilo
+ $spr2 = $mean_sub_grup[0]['v1']['seq'].'-'.$mean_sub_grup[0]['v1']['spr'].'-'.$mean_sub_grup[0]['v1']['grd'];
+ $spr1 = $mean_sub_grup[0]['v2']['seq'].'-'.$mean_sub_grup[0]['v2']['spr'].'-'.$mean_sub_grup[0]['v2']['grd'];
+ SurveyAnalysis::Init($this->sid);
+ SurveyAnalysis::addCustomReportElement($type=6, $sub_type=0, $spr1, $spr2);
+
+ // Izrisemo graf za tabelo - zaenkrat samo admin
+ if($this->sessionData['mean_charts']['showChart'] && $_GET['m'] != 'analysis_creport'){
+ $tableChart = new SurveyTableChart($this->sid, $this, 'mean', $counter);
+ $tableChart->display();
+ }
+
+ $counter++;
+ }
+ }
+
+ } else {
+ # dropdowni niso izbrani
+ }
+ }
+
+ // Izvoz pdf in rtf
+ function displayExport () {
+
+ if ($this->isSelectedBothVariables()) {
+ $vars1 = $this->getSelectedVariables(1);
+ $vars2 = $this->getSelectedVariables(2);
+
+ $data1 = '';
+ $data2 = '';
+
+ foreach($vars1 as $var1){
+ $data1 .= implode(',', array_values($var1)).',';
+ }
+ $data1 = substr($data1, 0, -1);
+
+ foreach($vars2 as $var2){
+ $data2 .= implode(',', array_values($var2)).',';
+ }
+ $data2 = substr($data2, 0, -1);
+
+
+ $href_pdf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=mean_izpis&anketa=' . $this->sid);
+ $href_rtf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=mean_izpis_rtf&anketa=' . $this->sid);
+ $href_xls = makeEncodedIzvozUrlString('izvoz.php?b=export&m=mean_izpis_xls&anketa=' . $this->sid);
+ echo '<script>';
+ # nastavimopravilne linke
+ echo '$("#secondNavigation_links a#meansDoPdf").attr("href", "'.$href_pdf.'");';
+ echo '$("#secondNavigation_links a#meansDoRtf").attr("href", "'.$href_rtf.'");';
+ echo '$("#secondNavigation_links a#meansDoXls").attr("href", "'.$href_xls.'");';
+ # prikažemo linke
+ echo '$("#hover_export_icon").removeClass("hidden");';
+ echo '$("#secondNavigation_links a").removeClass("hidden");';
+ echo '</script>';
+ }
+ }
+
+ function setPostVars() {
+ if ( isset($_POST['sequence1']) && count($_POST['sequence1']) > 0 ) {
+ $i=0;
+ if (is_array($_POST['sequence1']) && count($_POST['sequence1']) > 0 ){
+ foreach ($_POST['sequence1'] AS $_seq1) {
+ $this->variabla1[$i]['seq'] = $_seq1;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['spr1']) && count($_POST['spr1']) > 0 ) {
+ $i=0;
+ if (is_array($_POST['spr1']) && count($_POST['spr1']) > 0 ){
+ foreach ($_POST['spr1'] AS $_spr1) {
+ $this->variabla1[$i]['spr'] = $_spr1;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['grid1']) && count($_POST['grid1']) > 0 ) {
+ $i=0;
+ if ( is_array($_POST['grid1']) &&count($_POST['grid1']) > 0 ){
+ foreach ($_POST['grid1'] AS $_grd1) {
+ $this->variabla1[$i]['grd'] = $_grd1;
+ $i++;
+ }
+ }
+ }
+
+ if ( isset($_POST['sequence2']) && count($_POST['sequence2']) > 0 ) {
+ $i=0;
+
+ if (is_array($_POST['sequence2']) && count($_POST['sequence2']) > 0 ){
+
+ foreach ($_POST['sequence2'] AS $_seq2) {
+ $this->variabla2[$i]['seq'] = $_seq2;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['spr2']) && count($_POST['spr2']) > 0 ) {
+ $i=0;
+ if ( is_array($_POST['spr2']) && count($_POST['spr2']) > 0 ){
+ foreach ($_POST['spr2'] AS $_spr2) {
+ $this->variabla2[$i]['spr'] = $_spr2;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['grid2']) && is_array($_POST['grid2']) && count($_POST['grid2']) > 0 ) {
+ $i=0;
+ if ( count($_POST['grid2']) > 0 ){
+ foreach ($_POST['grid2'] AS $_grd2) {
+ $this->variabla2[$i]['grd'] = $_grd2;
+ $i++;
+ }
+ }
+ }
+
+ # variable shranimo v sejo, da jih obdržimo tudi če spreminjamo nastavitve ali razne filtre analiz
+ if (isset($this->variabla1) && count($this->variabla1) > 0) {
+ $this->sessionData['means']['means_variables']['variabla1'] = $this->variabla1;
+ }
+ if (isset($this->variabla2) && count($this->variabla2) > 0) {
+ $this->sessionData['means']['means_variables']['variabla2'] = $this->variabla2;
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ /** funkcija vrne seznam primern variabel za meanse
+ *
+ */
+ function getVariableList($dropdown) {
+ if (isset($this->variablesList[$dropdown]) && is_array($this->variablesList[$dropdown]) && count($this->variablesList[$dropdown]) > 0) {
+ return $this->variablesList[$dropdown];
+ } else {
+ # pobrišemo array()
+ $this->variablesList = array();
+ # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence)
+ foreach ($this->_HEADERS AS $skey => $spremenljivka) {
+ if ((int)$spremenljivka['hide_system'] == 1 && in_array($spremenljivka['variable'],array('email','ime','priimek','telefon','naziv','drugo'))) {
+ continue;
+ }
+
+ $tip = $spremenljivka['tip'];
+
+
+ $skala = (int)$spremenljivka['skala'];
+ # pri drugi, analizirani variabli morajo biti numerične ali ordinalne, v ostalem pa nič)
+ # skala - 0 Ordinalna
+ # skala - 1 Nominalna
+ $_dropdown_condition = $dropdown == 1
+ || ($dropdown == 2
+ && ($skala == 0 # ordinalna
+ || $tip == 7 # number
+ || $tip == 18 # vsota
+ || $tip == 20)) # multi number
+ ? true : false;
+
+
+ if (is_numeric($tip)
+ # tekstovnih tipov ne dodajamo
+
+ && $tip != 4 #text
+ && $tip != 5 #label
+ #&& $tip != 7 #number
+ #&& $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ #&& $tip != 18 #vsota
+ #&& $tip != 19 #multitext
+ #&& $tip != 20 #multinumber
+ #&& $tip != 21 #besedilo*
+ && $tip != 22 #compute
+ && $tip != 25 #kvota
+ && $_dropdown_condition # ali ustreza pogoju za meanse
+ ) {
+
+ $cnt_all = (int)$spremenljivka['cnt_all'];
+ # radio in select in checkbox
+ if ($cnt_all == '1' || $tip == 1 || $tip == 3 || $tip == 2) {
+
+
+ # pri tipu radio ali select dodamo tisto variablo ki ni polje "drugo"
+ if (($tip == 1 || $tip == 3 )) {
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][$vid]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+
+ }
+ }
+ }
+ }
+ } else if ($skala == 1 || true) { # ta pogoj skala == 1 je malo sumljiv. ne vem več zakaj je tako
+
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+ } else if ($cnt_all > 1){
+
+ # imamo več skupin ali podskupin, zato zlopamo skozi gride in variable
+ if (count($spremenljivka['grids']) > 0 ) {
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # ali imamo en grid, ali več (tabele
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } else if($tip == 16||$tip == 18) {
+ # imamo multicheckbox
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>$gid,
+ 'sequence'=>$grid['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ } else {
+ # imamo več gridov - tabele
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>$sub);
+ }
+ if (count ($grid['variables']) > 0) {
+ $sub++;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[$dropdown][] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>$sub);
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ return $this->variablesList[$dropdown];
+ }
+ }
+
+ function isSelectedBothVariables() {
+ $selected1 = false;
+ $selected2 = false;
+ if (count($this->variabla1)) {
+ foreach ($this->variabla1 AS $var1) {
+ if ((int)$var1['seq'] > 0) {
+ $selected1 = true;
+ }
+ }
+ }
+ if (count($this->variabla2)) {
+ foreach ($this->variabla2 AS $var2) {
+ if ((int)$var2['seq'] > 0) {
+ $selected2 = true;
+ }
+ }
+ }
+
+ return ($selected1 && $selected2);
+ }
+
+
+ function getSelectedVariables($which = 1) {
+ $selected = array();
+ if ($which == 1) {
+ if (count($this->variabla1) > 0 ) {
+ foreach ($this->variabla1 AS $var1) {
+ if ((int)$var1['seq'] > 0) {
+ $selected[] = $var1;
+ }
+ }
+ }
+ } else {
+ if (count($this->variabla2) > 0 ) {
+ foreach ($this->variabla2 AS $var2) {
+ if ((int)$var2['seq'] > 0) {
+ $selected[] = $var2;
+ }
+ }
+ }
+ }
+
+ return count($selected) > 0 ? $selected : null;
+ }
+
+ public function createMeans($v_first, $v_second) {
+ global $site_path;
+ $folder = $site_path.EXPORT_FOLDER.'/';
+
+ if ($this->dataFileName != '' && file_exists($this->dataFileName)) {
+
+ $spr1 = $this->_HEADERS[$v_first['spr']];
+ $spr2 = $this->_HEADERS[$v_second['spr']];
+
+ $grid1 = $spr1['grids'][$v_first['grd']];
+ $grid2 = $spr2['grids'][$v_second['grd']];
+
+ $sequence1 = $v_first['seq'];
+ $sequence2 = $v_second['seq'];
+
+ # za checkboxe gledamo samo odgovore ki so bili 1 in za vse opcije
+ $sekvences1 = array();
+ $sekvences2 = array();
+ $spr_1_checkbox = false;
+ $spr_2_checkbox = false;
+
+ if ($spr1['tip'] == 2 || $spr1['tip'] == 16) {
+ $spr_1_checkbox = true;
+ if ($spr1['tip'] == 2) {
+ $sekvences1 = explode('_',$spr1['sequences']);
+ }
+ if ($spr1['tip'] == 16) {
+
+ foreach ($grid1['variables'] AS $_variables) {
+ $sekvences1[] = $_variables['sequence'];
+ }
+ }
+ } else {
+ $sekvences1[] = $sequence1;
+ }
+
+ if ($spr2['tip'] == 2 || $spr2['tip'] == 16) {
+ $spr_2_checkbox = true;
+ if ($spr2['tip'] == 2 ) {
+ $sekvences2 = explode('_',$this->_HEADERS[$v_second['spr']]['sequences']);
+ }
+ if ($spr2['tip'] == 16) {
+ foreach ($grid2['variables'] AS $_variables) {
+ $sekvences2[] = $_variables['sequence'];
+ }
+ }
+ } else {
+ $sekvences2[] = $sequence2;
+ }
+
+ # pogoji so že dodani v _CURRENT_STATUS_FILTER
+
+ # dodamo filter za loop-e
+ if (isset($this->_CURRENT_LOOP['filter']) && $this->_CURRENT_LOOP['filter'] != '') {
+ $status_filter = $this->_CURRENT_STATUS_FILTER.' && '.$this->_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+ }
+
+
+ # dodamo status filter za vse sekvence checkbox-a da so == 1
+ if ($additional_status_filter != null) {
+ $status_filter .= $additional_status_filter;
+ }
+
+ # odstranimo vse zapise, kjer katerakoli od variabel vsebuje missing
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ $_pageMissing_answers = $this->getInvalidAnswers (MISSING_TYPE_CROSSTAB);
+ # polovimo obe sequenci
+ $tmp_file = $folder.'tmp_means_'.$this->sid.'.tmp';
+
+ $file_handler = fopen($tmp_file,"w");
+ fwrite($file_handler,"<?php\n");
+ fclose($file_handler);
+ if (count($sekvences1)>0)
+ foreach ($sekvences1 AS $sequence1) {
+ if (count($sekvences2)>0)
+ foreach ($sekvences2 AS $sequence2) {
+ #skreira variable: $meansArray
+
+ $additional_filter = '';
+ if ($spr_1_checkbox == true) {
+ $_seq_1_text = ''.$sequence1;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter = ' && ($'.$sequence1.' == 1)';
+ } else {
+ $_seq_1_text = '$'.$sequence1;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key1 => $missing1) {
+ $additional_filter .= ' && ($'.$sequence1.' != '.$m_key1.')';
+ }
+ }
+
+ if ($spr_2_checkbox == true) {
+ $_seq_2_text = ''.$sequence2;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter .= ' && ($'.$sequence2.' == 1)';
+ } else {
+ $_seq_2_text = '$'.$sequence2;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key2 => $missing2) {
+ $additional_filter .= ' && ($'.$sequence2.' != '.$m_key2.')';
+ }
+ }
+
+ if (IS_WINDOWS) {
+ $command = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$additional_filter.' { print \"$meansArray[\x27\",'.$_seq_2_text.',\"\x27][\x27\",'.$_seq_1_text.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$additional_filter.' { print "$meansArray[\x27",'.$_seq_2_text.',"\x27][\x27",'.$_seq_1_text.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out = shell_exec($command);
+ }
+
+ }
+
+ $file_handler = fopen($tmp_file,"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_file);
+
+ if (file_exists($tmp_file)) {
+ unlink($tmp_file);
+ }
+
+ # izračunamo povprečja
+ $means = array();
+ $_tmp_sumaMeans = 0;
+ if(is_array($meansArray) && count($meansArray) > 0) {
+ foreach ($meansArray AS $f_key => $first) {
+ $tmp_sum = 0;
+ $tmp_cnt = 0;
+ foreach ($first AS $s_key => $second) {
+ # preverimo da je vse numeric
+ if (is_numeric($s_key) && is_numeric($second)) {
+ $tmp_sum = $tmp_sum + ($s_key*$second);
+ $tmp_cnt = $tmp_cnt + $second;
+
+ }
+ }
+ $_tmp_sumaMeans += $tmp_sum;
+ $key = $f_key;
+ if ($tmp_cnt != 0) {
+ $means[$key] = bcdiv($tmp_sum, $tmp_cnt, 3);
+ } else {
+ $means[$key] = bcdiv(0,1, 3);
+ }
+ }
+ }
+ # inicializacija
+ $_all_options = array();
+ $sumaVrstica = array();
+ $sumaSkupna = 0;
+ $sumaMeans = 0;
+
+ # poiščemo pripadajočo spremenljivko
+ $var_options = $this->_HEADERS[$v_second['spr']]['options'];
+
+
+ # najprej poiščemo (združimo) vse opcije ki so definirane kot opcije spremenljivke in vse ki so v meansih
+ if (count($var_options) > 0 && $spr_2_checkbox !== true) {
+ foreach ($var_options as $okey => $opt) {
+ $_all_options[$okey] = array('naslov'=>$opt, 'type'=>'o');
+ }
+ }
+
+ # za checkboxe dodamo posebej vse opcije
+ if ($spr_2_checkbox == true ) {
+ if ($spr2['tip'] == 2 ) {
+ $grid2 =$this->_HEADERS[$v_second['spr']]['grids']['0'];
+ }
+
+ foreach ($grid2['variables'] As $vkey => $variable) {
+ if ($variable['other'] != 1) {
+ $_all_options[$variable['sequence']] = array('naslov'=>$variable['naslov'], 'type'=>'o', 'vr_id'=> $variable['variable']);
+ }
+ }
+ }
+
+ # dodamo odgovore iz baze ki niso missingi
+ if (count($meansArray) > 0 ) {
+ foreach ($meansArray AS $_kvar1=>$_var1) {
+ # missingov ne dodajamo še zdaj, da ohranimo pravilen vrstni red
+ foreach ($_var1 AS $_kvar2=>$_var2) {
+ if (!isset($_allMissing_answers[$_kvar1]) || (isset($_allMissing_answers[$_kvar1]) && isset($_pageMissing_answers[$_kvar1]))) {
+ $sumaVrstica[$_kvar1] += $_var2;
+ }
+ }
+ # missingov ne dodajamo še zdaj, da ohranimo pravilen vrstni red
+ if (!isset($_allMissing_answers[$_kvar1]) && !isset($_all_options[$_kvar1])) {
+ $_all_options[$_kvar1] = array('naslov'=>$_kvar1, 'type'=>'t');
+ }
+
+ }
+ }
+ # dodamo še missinge, samo tiste ki so izbrani z profilom
+ foreach ($_allMissing_answers AS $miskey => $_missing) {
+ if (!isset($_pageMissing_answers[$miskey])) {
+ if ( $spr_2_checkbox !== true ) {
+ $_all_options[$miskey] = array('naslov'=>$_missing, 'type'=>'m');
+ }
+ }
+ }
+ $sumaSkupna = array_sum($sumaVrstica);
+ $sumaMeans = ($sumaSkupna > 0) ? $_tmp_sumaMeans / $sumaSkupna : 0;
+
+ # če lovimo po enotah, moramo skupne enote za vsako kolono(vrstico) izračunati posebej
+ if ($this->crossNavVsEno == 1) {
+ $sumaSkupna = 0;
+ $sumaVrstica = array();
+
+ # sestavimo filtre za posamezno variablo da ni missing
+ if (count($sekvences1)>0) {
+ $spr1_addFilter = '';
+
+ foreach ($sekvences1 AS $sequence1) {
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key1 => $missing1) {
+ $spr1_addFilter .= ' && ($'.$sequence1.' != '.$m_key1.')';
+ }
+ }
+ }
+ if (count($sekvences2)>0) {
+ $spr2_addFilter = '';
+
+ foreach ($sekvences2 AS $sequence2) {
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key2 => $missing2) {
+ $spr2_addFilter .= ' && ($'.$sequence2.' != '.$m_key2.')';
+ }
+ }
+ }
+
+ # polovimo obe sequenci
+ $tmp_file = $folder.'tmp_means_'.$this->sid.'.TMP';
+
+
+ $file_handler = fopen($tmp_file,"w");
+ fwrite($file_handler,"<?php\n");
+
+ fclose($file_handler);
+
+ # preštejemo vse veljavne enote (nobena vrednost ne sme bit missing)
+ if (IS_WINDOWS) {
+ $command_all = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$spr1_addFilter.$spr2_addFilter.' { print \"$sumaSkupna++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command_all = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$spr1_addFilter. $spr2_addFilter.' { print "$sumaSkupna++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out_all = shell_exec($command_all);
+
+
+ #za vsako variablo polovimo število enot
+ #najprej za stolpce
+ if (count($sekvences1)>0) {
+ foreach ($sekvences1 AS $sequence1) {
+ if ($spr_1_checkbox == true) {
+ $_seq_1_text = ''.$sequence1;
+ # pri checkboxih lovimo samo tiste ki so 1
+ $chckbox_filter1 = ' && ($'.$sequence1.' == 1)';
+ } else {
+ $_seq_1_text = '$'.$sequence1;
+ }
+
+ if (IS_WINDOWS) {
+ $command_1 = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$chckbox_filter1.$spr2_addFilter.' { print \"$sumaVrstica[\x27\",'.$_seq_1_text.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command_1 = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$chckbox_filter1.$spr2_addFilter.' { print "$sumaVrstica[\x27",'.$_seq_1_text.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+ $out = shell_exec($command_1);
+ }
+ }
+ }
+
+
+
+ $meansArr['v1'] = $v_first; # prva variabla
+ $meansArr['v2'] = $v_second; # druga variabla
+ $meansArr['result'] = $means; # povprečja
+ $meansArr['options'] = $_all_options; # vse opcije za variablo 2
+ $meansArr['sumaVrstica'] = $sumaVrstica; #
+ $meansArr['sumaSkupna'] = $sumaSkupna; #
+ $meansArr['sumaMeans'] = $sumaMeans; #
+ return $meansArr;
+ }
+ }
+
+ function displayMeansTable($_means) {
+ global $lang;
+
+ #število vratic in število kolon
+ $cols = count($_means);
+ # preberemo kr iz prvega loopa
+ $rows = count($_means[0]['options']);
+
+ # ali prikazujemo vrednosti variable pri spremenljivkah
+ $show_variables_values = $this->doValues;
+
+ $showSingleUnits = $this->sessionData['means']['meansJoinPercentage']==true && $this->sessionData['means']['meansSeperateTables'] == false;
+
+ # izrišemo tabelo
+ echo '<table class="anl_tbl_crosstab fullWidth" style="margin-top:10px;">';
+ echo '<colgroup>';
+ echo '<col style="width:auto; min-width:30px;" />';
+ echo '<col style="width:auto; min-width:30px; " />';
+ for ($i = 0; $i < $cols; $i++) {
+ echo '<col style="width:auto; min-width:30px;" />';
+ if ($showSingleUnits == false) {
+ echo '<col style="width:auto; min-width:30px;" />';
+ }
+ }
+ if ($showSingleUnits == true) {
+ echo '<col style="width:auto; min-width:30px;" />';
+ }
+ echo '</colgroup>';
+
+ echo '<tr>';
+ #echo '<td>xx&nbsp;</td>';
+ # ime variable
+ # teksti labele:
+ $label2 = $this->getSpremenljivkaTitle($_means[0]['v2']);
+ if ($showSingleUnits == false) {
+ $span = ' colspan="2"';
+ }
+ echo '<td class="anl_bt anl_bl anl_ac rsdl_bck_title ctbCll" rowspan="2">';
+ echo $label2;
+ echo '</td>';
+
+ for ($i = 0; $i < $cols; $i++) {
+ echo '<td class="anl_bt anl_bl anl_br anl_ac rsdl_bck_title ctbCll"'.$span.'>';
+ $label1 = $this->getSpremenljivkaTitle($_means[$i]['v1']);
+ echo $label1;
+ echo '</td>';
+ }
+ if ($showSingleUnits == true) {
+ echo '<td class="anl_bl ">&nbsp;</td>';
+ }
+ echo '</tr>';
+ echo '<tr>';
+
+ for ($i = 0; $i < $cols; $i++) {
+ #Povprečje
+ echo '<td class="anl_bt anl_bl anl_br anl_ac rsdl_bck_variable1 ctbCll" >';
+ echo $lang['srv_means_label'];
+ echo '</td>';
+ #enote
+ if ($showSingleUnits == false) {
+ echo '<td class="anl_bl anl_bt anl_br anl_ac red anl_ita anl_bck_text_0 rsdl_bck_variable1 ctbCll">'.$lang['srv_means_label4'].'</td>';
+ }
+ }
+ if ($showSingleUnits == true) {
+ echo '<td class="anl_bl anl_bt anl_br anl_ac red anl_ita anl_bck_text_0 rsdl_bck_variable1 ctbCll">'.$lang['srv_means_label4'].'</td>';
+ }
+
+ echo '</tr>';
+
+ if (count($_means[0]['options']) > 0) {
+
+ foreach ($_means[0]['options'] as $ckey2 =>$crossVariabla2) {
+ $units_per_row = 0;
+ echo '<tr>';
+ echo '<td class="anl_bt anl_bl anl_ac rsdl_bck_variable1 ctbCll">';
+ echo $crossVariabla2['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla2['type'] !== 't' ) {
+ if ($show_variables_values == true) {
+ if ($crossVariabla2['vr_id'] == null) {
+ echo '&nbsp;( '.$ckey2.' )';
+ } else {
+ echo '&nbsp;( '.$crossVariabla2['vr_id'].' )';
+ }
+ }
+ }
+ echo '</td>';
+ # celice z vsebino
+ for ($i = 0; $i < $cols; $i++) {
+ echo '<td class="ct_in_cell anl_br'.'" k1="'.$ckey1.'" k2="'.$ckey2.'" n1="'.$crossVariabla1['naslov'].'" n2="'.$crossVariabla2['naslov'].'" v1="'.$crossVariabla1['vr_id'].'" v2="'.$crossVariabla2['vr_id'].'">';
+ echo $this->formatNumber($_means[$i]['result'][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'));
+ echo '</td>';
+ if ($showSingleUnits == false) {
+ echo '<td class="anl_ac anl_bl anl_bt anl_br rsdl_bck0 crostabSuma">';
+ echo (int)$_means[$i]['sumaVrstica'][$ckey2];
+ echo '</td>';
+ } else {
+ $units_per_row = max($units_per_row,(int)$_means[$i]['sumaVrstica'][$ckey2]);
+ }
+ }
+ if ($showSingleUnits == true) {
+ echo '<td class="anl_ac anl_bl anl_bt anl_br rsdl_bck0 crostabSuma">';
+ echo $units_per_row;
+ echo '</tr>';
+ }
+ echo '</tr>';
+ $max_units += $units_per_row;
+ }
+ }
+ echo '<tr>';
+ echo '<td class="anl_bb anl_bt anl_bl anl_ac red anl_ita anl_bck_text_0 rsdl_bck_variable1 ctbCll">'.$lang['srv_means_label3'].'</td>';
+ for ($i = 0; $i < $cols; $i++) {
+ echo '<td class="anl_ac anl_bt anl_bl anl_br anl_bb rsdl_bck0 crostabSuma">';
+
+ echo $this->formatNumber($_means[$i]['sumaMeans'], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'));
+ echo '</td>';
+ if ($showSingleUnits == false) {
+ echo '<td class="anl_ac anl_bt anl_bl anl_br anl_bb rsdl_bck0 crostabSuma">';
+ echo (int)$_means[$i]['sumaSkupna'];
+ echo '</td>';
+ }
+ }
+ if ($showSingleUnits == true) {
+ echo '<td class="anl_ac anl_bt anl_bl anl_br anl_bb rsdl_bck0 crostabSuma">';
+ echo $max_units;
+ echo '</tr>';
+ }
+
+ echo '</tr>';
+ echo '</table>';
+ }
+
+ /** Sestavi array nepravilnih odgovorov
+ *
+ */
+ function getInvalidAnswers($type) {
+ $result = array();
+ $missingValuesForAnalysis = SurveyMissingProfiles :: GetMissingValuesForAnalysis($type);
+
+ foreach ($missingValuesForAnalysis AS $k => $answer) {
+ $result[$k] = array('text'=>$answer,'cnt'=>0);
+ }
+ return $result;
+ }
+
+
+
+ /** Naredimo formatiran izpis
+ *
+ * @param $value
+ * @param $digit
+ * @param $sufix
+ */
+
+ static function formatNumber ($value, $digit = 0, $sufix = "") {
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+ # polovimo decimalna mesta in vejice za tisočice
+
+ $decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+
+ $result = number_format($result, $digit, $decimal_point, $thousands).$sufix;
+
+ return $result;
+ }
+
+ function addNewVariable() {
+ global $lang;
+ $which = $_POST['which'];
+ $variables = $this->getVariableList($which);
+ $multiple = true;
+
+
+ if ($which == '1') {
+ echo '<br/>';
+ echo '<span class="space_means_new">&nbsp;</span>';
+ echo '<select name="means_variable_'.$which.'" id="means_variable_'.$which.'" onchange="change_means(); return false;" autocomplete="off"'
+ .'>';
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ( $variabla1['seq'] == null || $variabla1['seq'] == 0 ) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_izberi_more'].'</option>';
+ }
+
+ foreach ($variables as $variable) {
+ echo '<option value="'.$variable['sequence'].'" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] . '</option>';
+
+ }
+ echo '</select>';
+ echo '<span class="pointer" id="means_remove" onclick="means_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+
+ } else {
+ # which = 2
+ echo '<br/>';
+ echo '<span class="space_means_new">&nbsp;</span>';
+ echo '<select name="means_variable_'.$which.'" id="means_variable_'.$which.'" onchange="change_means(); return false;" autocomplete="off"'
+ .'>';
+
+ # ce prva variabla ni izbrana, dodamo tekst za izbiro prve variable
+ if ((int)$this->variabla1['0']['seq'] > 0) {
+ echo '<option value="0" selected="selected" >'. $lang['srv_analiza_crosstab_najprej_prvo'].'</option>';
+ } else {
+ # če druga variabla ni izbrana dodamo tekst za izbiro druge variable
+ echo '<option value="0" selected="selected">'. $lang['srv_analiza_crosstab_izberi_more'].'</option>';
+ }
+
+ foreach ($variables as $variable) {
+ echo '<option value="'.$variable['sequence'].'" spr_id="'.$variable['spr_id'].'" '
+ . ( isset($variable['grd_id']) ? ' grd_id="'.$variable['grd_id'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] . '</option>';
+
+ }
+ echo '</select>';
+ echo '<span class="pointer" id="means_remove" onclick="means_remove_variable(this);"><span class="faicon delete_circle icon-orange_link" title=""></span></span>';
+ }
+ }
+
+ function getSpremenljivkaTitle($v_first) {
+ global $lang;
+ # podatki spremenljivk
+ $spremenljivka_id = $v_first['spr'];
+ $grid_id = $v_first['grd'];
+ $sekvenca = $v_first['seq'];
+
+ $spremenljivka = $this->_HEADERS[$spremenljivka_id];
+ $grid = $spremenljivka['grids'][$grid_id];
+
+
+ # za multicheckboxe popravimo naslov, na podtip
+ $labela = null;
+ if ($spremenljivka['tip'] == '6' || $spremenljivka['tip'] == '7' || $spremenljivka['tip'] == '16' || $spremenljivka['tip'] == '17' || $spremenljivka['tip'] == '18' || $spremenljivka['tip'] == '19' || $spremenljivka['tip'] == '20' || $spremenljivka['tip'] == '21' ) {
+ foreach ($spremenljivka['grids'] AS $grids) {
+ foreach ($grids['variables'] AS $variable) {
+ if ($variable['sequence'] == $sekvenca) {
+ $labela .= '<span class="anl_variabla">';
+ $labela .= '<a href="/" title="'.$lang['srv_predogled_spremenljivka'].'" onclick="showspremenljivkaSingleVarPopup(\''.$spremenljivka_id.'\'); return false;">';
+ $labela .= strip_tags($spremenljivka['naslov']);
+ if ($show_variables_values == true) {
+ $labela .= '&nbsp;('.strip_tags($spremenljivka['variable']).')';
+ }
+ $labela .= '</a>';
+ $labela .= '</span>';
+
+ if ($spremenljivka['tip'] == '16') {
+ if (strip_tags($grid['naslov']) != $lang['srv_new_text']) {
+ $labela .= '<br/>'.strip_tags($grid['naslov']);
+ }
+ $labela .= '&nbsp;('.strip_tags($grid['variable']).')' ;
+ } else {
+ if (strip_tags($variable['naslov']) != $lang['srv_new_text']) {
+ $labela .= '<br/>'.strip_tags($variable['naslov']);
+ }
+ if ($show_variables_values == true) {
+ $labela .= '&nbsp;('.strip_tags($variable['variable']).')';
+ }
+ }
+
+ }
+ }
+ }
+ }
+ if ($labela == null) {
+ $labela = '<span class="anl_variabla">';
+ $labela .= '<a href="/" title="'.$lang['srv_predogled_spremenljivka'].'" onclick="showspremenljivkaSingleVarPopup(\''.$spremenljivka_id.'\'); return false;">';
+ $labela .= strip_tags($spremenljivka['naslov']);
+ if ($show_variables_values == true) {
+ $labela .= '&nbsp;('.strip_tags($spremenljivka['variable']).')';
+ }
+ $labela .= '</a>';
+ $labela .= '</span>'.NEW_LINE;
+ }
+ return $labela;
+ }
+
+ function changeMeansSubSetting() {
+ $this->sessionData['means']['meansSeperateTables'] = ($_POST['chkMeansSeperate'] == 1);
+ $this->sessionData['means']['meansJoinPercentage'] = ($_POST['chkMeansJoinPercentage'] == 1);
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function changeMeansShowChart() {
+ $this->sessionData['mean_charts']['showChart'] = ($_POST['showChart'] == 'true');
+ $this->sessionData['means']['meansSeperateTables'] = ($_POST['showChart'] == 'true') ? true : $this->sessionData['means']['meansSeperateTables'];
+ $this->sessionData['means']['meansJoinPercentage'] = ($_POST['showChart'] == 'true') ? true : $this->sessionData['means']['meansJoinPercentage'];
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function presetVariables() {
+ # preberemo prednastavljene variable iz seje, če obstajajo
+ if (isset($this->sessionData['means']['means_variables']['variabla1']) && count($this->sessionData['means']['means_variables']['variabla1']) > 0) {
+ $this->variabla1 = $this->sessionData['means']['means_variables']['variabla1'];
+ }
+ if (isset($this->sessionData['means']['means_variables']['variabla2']) && count($this->sessionData['means']['means_variables']['variabla2']) > 0) {
+ $this->variabla2 = $this->sessionData['means']['means_variables']['variabla2'];
+ }
+ }
+} \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyMultiCrosstabs.php b/admin/survey/classes/surveyAnalysis/class.SurveyMultiCrosstabs.php
new file mode 100644
index 0000000..67664da
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyMultiCrosstabs.php
@@ -0,0 +1,2489 @@
+<?php
+
+define("AUTO_HIDE_ZERRO_VALUE", 20); # nad koliko kategorij skrivamo ničelne vrednosti
+define("EXPORT_FOLDER", "admin/survey/SurveyData");
+define("R_FOLDER", "admin/survey/R");
+
+class SurveyMultiCrosstabs {
+
+ public $ank_id; # id ankete
+
+ public $table_id = 0; # id tabele, ki jo trenutno izrisujemo
+ public $table_settings = array(); # nastavitve za tabelo
+
+ public $db_table; # katere tabele uporabljamo
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+
+ public $_HEADERS = array(); # shranimo podatke vseh variabel
+
+ public $_HAS_TEST_DATA = false; # ali anketa vsebuje testne podatke
+
+ public $_CURRENT_STATUS_FILTER = ''; # filter po statusih, privzeto izvažamo 6 in 5
+ public $currentMissingProfile = 1; # Kateri Missing profil je izbran
+ public $missingProfileData = null; # Nastavitve trenutno izbranega manjkajočega profila
+
+ public $_CURRENT_LOOP = null; # trenutni loop
+
+ /* Variable so definirane v obliki:
+ * '37507_0_0_0' = x_y_z_w
+ * -> x => spr_id
+ * -> y => loop id
+ * -> z => grid_id
+ * -> y => variable id
+ *
+ */
+ public $variablesList = null; # Seznam vseh variabel nad katerimi lahko izvajamo crostabulacije (zakeširamo)
+
+ public $selectedVars = null; # Seznam izbranih variabel v tabeli
+ public $crosstabData = null; # Izracunani podatki za izbrane spremenljivke
+ public $crosstabClass = null; # Instanca crosstab razreda (za racunanje)
+
+ public $colSpan = 0; # Celoten span stolpcev (stevilo vseh childov)
+ public $rowSpan = 0; # Celoten span vrstic (stevilo vseh childov)
+ public $colLevel2 = false; # Ali imamo v stolpcih kaksen 2. nivo
+ public $rowLevel2 = false; # Ali imamo v vrsticah kaksen 2. nivo
+ public $fullColSpan = 0; # Celoten span stolpcev (stevilo vseh childov) z sumami (ce jih imamo)
+
+ public $isCheckbox = false; # Ce je kaksen checkbox v tabeli - potem imamo opcijo navedbe/enote
+
+
+ /**
+ * Inicializacija
+ *
+ * @param int $anketa
+ */
+ public function __construct( $anketa = null ) {
+ global $global_user_id, $site_path, $lang;
+
+ // če je podan ID ankete
+ if ((int)$anketa > 0) {
+
+ $this->ank_id = $anketa;
+
+ // Poskrbimo za datoteko s podatki
+ $SDF = SurveyDataFile::get_instance();
+ $SDF->init($this->ank_id);
+ $SDF->prepareFiles();
+
+ $this->headFileName = $SDF->getHeaderFileName();
+ $this->dataFileName = $SDF->getDataFileName();
+ $this->dataFileStatus = $SDF->getStatus();
+
+ # polovimo vrsto tabel (aktivne / neaktivne)
+ SurveyInfo :: getInstance()->SurveyInit($this->ank_id);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ $this->db_table = '_active';
+ }
+
+ $this->_CURRENT_STATUS_FILTER = STATUS_FIELD.' ~ /6|5/';
+
+ SurveyStatusProfiles::Init($this->ank_id);
+ SurveyMissingProfiles :: Init($this->ank_id, $global_user_id);
+
+ SurveyConditionProfiles :: Init($this->ank_id, $global_user_id);
+ SurveyZankaProfiles :: Init($this->ank_id, $global_user_id);
+ SurveyTimeProfiles :: Init($this->ank_id, $global_user_id);
+ SurveyDataSettingProfiles :: Init($this->ank_id);
+
+ # nastavimo vse filtre
+ $this->setUpFilter();
+
+ SurveyUserSetting::getInstance()->Init($this->ank_id, $global_user_id);
+
+ # Ce ne obstaja nobena tabela jo ustvarimo
+ $sql = sisplet_query("SELECT id FROM srv_mc_table WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id'");
+ if(mysqli_num_rows($sql) == 0){
+ $name = $lang['srv_table'].' 1';
+ sisplet_query("INSERT INTO srv_mc_table (ank_id, usr_id, time_created, name) VALUES('$this->ank_id', '$global_user_id', NOW(), '$name')");
+ $table_id = mysqli_insert_id($GLOBALS['connect_db']);
+
+ $this->table_id = $table_id;
+ SurveyUserSetting :: getInstance()->saveSettings('default_mc_table', $table_id);
+
+ $this->table_settings[$this->table_id] = array(
+ 'title' => '',
+ 'numerus' => 1,
+ 'percent' => 0,
+ 'sums' => 0,
+ 'navVsEno' => 1,
+ 'avgVar' => '',
+ 'delezVar' => '',
+ 'delez' => ''
+ );
+ }
+ else{
+ $this->table_id = SurveyUserSetting :: getInstance()->getSettings('default_mc_table');
+
+ // Preberemo nastavitve trenutno izbrane tabele
+ if(isset($this->table_id) && $this->table_id != ''){
+ $sql = sisplet_query("SELECT * FROM srv_mc_table WHERE id='$this->table_id' AND ank_id='$this->ank_id' AND usr_id='$global_user_id'");
+ }
+ else{
+ $sql = sisplet_query("SELECT * FROM srv_mc_table WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' ORDER BY time_created ASC");
+ }
+ $row = mysqli_fetch_array($sql);
+ $this->table_id = $row['id'];
+ $this->table_settings[$this->table_id] = array(
+ 'title' => $row['title'],
+ 'numerus' => $row['numerus'],
+ 'percent' => $row['percent'],
+ 'sums' => $row['sums'],
+ 'navVsEno' => $row['navVsEno'],
+ 'avgVar' => $row['avgVar'],
+ 'delezVar' => $row['delezVar'],
+ 'delez' => $row['delez']
+ );
+ }
+ }
+ else {
+ die("Napaka!");
+ }
+ }
+
+ /** Funkcija ki nastavi vse filtre
+ *
+ */
+ private function setUpFilter() {
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ return false;
+ }
+
+ if ($this->headFileName !== null && $this->headFileName != '') {
+ $this->_HEADERS = unserialize(file_get_contents($this->headFileName));
+ }
+
+
+ # poiščemo kater profil uporablja uporabnik
+ $_currentMissingProfile = SurveyUserSetting :: getInstance()->getSettings('default_missing_profile');
+ $this->currentMissingProfile = (isset($_currentMissingProfile) ? $_currentMissingProfile : 1);
+
+ # filtriranje po statusih
+ $this->_CURRENT_STATUS_FILTER = SurveyStatusProfiles :: getStatusAsAWKString();
+
+ # filtriranje po časih
+ $_time_profile_awk = SurveyTimeProfiles :: getFilterForAWK($this->_HEADERS['unx_ins_date']['grids']['0']['variables']['0']['sequence']);
+
+ # dodamo še ife
+
+ SurveyConditionProfiles :: setHeader($this->_HEADERS);
+ $_condition_profile_AWK = SurveyConditionProfiles:: getAwkConditionString();
+
+ if (($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) || ($_time_profile_awk != "" && $_time_profile_awk != null)) {
+ $this->_CURRENT_STATUS_FILTER = '('.$this->_CURRENT_STATUS_FILTER;
+ if ($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_condition_profile_AWK;
+ }
+ if ($_time_profile_awk != "" && $_time_profile_awk != null) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_time_profile_awk;
+ }
+ $this->_CURRENT_STATUS_FILTER .= ')';
+ }
+
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+
+ if ($this->dataFileStatus == FILE_STATUS_OK || $this->dataFileStatus == FILE_STATUS_OLD) {
+
+ if (isset($this->_HEADERS['testdata'])) {
+ $this->_HAS_TEST_DATA = true;
+ }
+ }
+ }
+
+ function display () {
+ global $lang;
+ global $global_user_id;
+
+ // Napolnimo variable s katerimi lahko operiramo
+ $this->getVariableList();
+
+ //$this->displayLinks();
+ $this->displayFilters();
+
+ $this->displayExport();
+
+
+ echo '<div id="mc_holder">';
+
+
+ // Div s spremenljivkami za drag - zaenkrat samo radio, checkbox, dropdown, multigrid, multicheckbox - ZAENKRAT BREZ CHECKBOXOV (2,16)!
+ echo '<div id="spr_list"><ul>';
+ foreach($this->variablesList AS $spr){
+ if($spr['canChoose'] && in_array($spr['tip'], array(1,3,6))){
+
+ echo '<li class="draggable mc_draggable" id="'.$spr['spr_id'].'-'.$spr['sequence'].'">';
+ echo '<span class="strong">'.$spr['variable'].'</span> - '.$this->snippet($spr['naslov'], 25);
+ echo '</li>';
+ }
+ }
+ echo '</ul></div>';
+
+
+ // Izris diva za izbiro tabele
+ $this->displayMCTablesPopups();
+
+ // Izris diva za nastavitve tabele
+ echo '<div id="mc_table_settings" class="mc_table_settings">';
+ $this->displayTableSettings();
+ echo '</div>';
+
+ // Naslov tabele
+ echo '<div id="title_'.$this->table_id.'" class="mc_table_title">';
+ $this->displayTableTitle($this->table_settings[$this->table_id]['title']);
+ echo '</div>';
+
+ // Izris tabele
+ echo '<div id="mc_table_holder_'.$this->table_id.'" class="mc_table_holder">';
+ $this->displayTable();
+ echo '</div>';
+
+ echo '</div>';
+ }
+
+ // Prikaze tabelo s podatki
+ public function displayTable(){
+ global $lang;
+ global $site_url;
+
+ // Napolnimo variable ki so ze izbrane
+ $this->getSelectedVars();
+
+ echo '<table id="'.$this->table_id.'" cellspacing="0" cellpadding="0" class="mc_table">';
+
+
+ // Imamo 2 nivoja
+ if($this->colLevel2){
+
+ // Izrisemo VERTIKALNO izbrane spremenljivkec - 1. vrstica
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<tr><td class="borderless" '.$colspan.'></td>';
+ if(count($this->selectedVars['ver'])){
+ foreach($this->selectedVars['ver'] as $var){
+
+ $rowspan = count($var['sub']) > 0 ? '':' rowspan="2"';
+ $colspan = ' colspan="'.$var['span'].'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="undefined" class="spr vertical droppable full" '.$rowspan . $colspan.'>';
+
+ echo $this->snippet($this->variablesList[$var['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+
+ echo '</td>';
+ }
+ }
+ // Izrisemo se zadnjo prazno navpicno celico vrstico
+ echo '<td id="undefined" class="spr vertical droppable empty" rowspan="4">'.$lang['srv_multicrosstabs_add'].'</td>';
+ echo '</tr>';
+
+ // Izrisemo VARIABLE za spremenljivko - 2. vrstica
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<tr><td class="borderless" '.$colspan.'></td>';
+ if(count($this->selectedVars['ver'])){
+ foreach($this->selectedVars['ver'] as $var){
+
+ if(count($var['sub']) > 0){
+ // Loop cez variable spremenljivke
+ foreach($this->variablesList[$var['spr']]['options'] as $option){
+
+ $colspan = ' colspan="'.( $var['span'] / count($this->variablesList[$var['spr']]['options']) ).'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="undefined" class="var vertical full" '.$colspan.'>';
+
+ echo $this->snippet($option, 25);
+
+ echo '</td>';
+ }
+ }
+ }
+ }
+ echo '</tr>';
+
+ // Izris vrstic za 2. nivo - 3. in 4. vrstica
+
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<tr><td class="borderless" '.$colspan.'></td>';
+ if(count($this->selectedVars['ver'])){
+ foreach($this->selectedVars['ver'] as $parentVar){
+
+ foreach($this->variablesList[$parentVar['spr']]['options'] as $option){
+ // ce imamo childe na 2. nivoju
+ if(count($parentVar['sub']) > 0){
+ foreach($parentVar['sub'] as $var){
+
+ $colspan = ' colspan="'.( count($this->variablesList[$var['spr']]['options']) ).'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="'.$parentVar['vrstni_red'].'" class="spr vertical full" '.$colspan.'>';
+
+ echo $this->snippet($this->variablesList[$var['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+
+ echo '</td>';
+ }
+ }
+ else{
+ $rowspan = ' rowspan="2"';
+ $colspan = ' colspan="'.( $parentVar['span'] / count($this->variablesList[$parentVar['spr']]['options']) ).'"';
+ echo '<td id="'.$parentVar['vrstni_red'].'" spr_id="'.$parentVar['spr'].'" parent="undefined" class="var vertical full" '.$rowspan . $colspan.'>';
+
+ echo $this->snippet($option, 25);
+
+ echo '</td>';
+ }
+ }
+ }
+ }
+ echo '</tr>';
+
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<tr><td class="borderless" '.$colspan.'></td>';
+ if(count($this->selectedVars['ver'])){
+ foreach($this->selectedVars['ver'] as $parentVar){
+
+ foreach($this->variablesList[$parentVar['spr']]['options'] as $option){
+ // ce imamo childe na 2. nivoju
+ if(count($parentVar['sub']) > 0){
+ foreach($parentVar['sub'] as $var){
+
+ foreach($this->variablesList[$var['spr']]['options'] as $suboption){
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="'.$parentVar['vrstni_red'].'" class="var vertical full">';
+
+ echo $this->snippet($suboption, 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+
+ echo '</td>';
+ }
+ }
+ }
+ }
+ }
+ }
+ echo '</tr>';
+ }
+ // Imamo samo 1 nivo
+ else{
+ // Izrisemo VERTIKALNO izbrane spremenljivkec - 1. vrstica
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<tr><td class="borderless" '.$colspan.'></td>';
+ if(count($this->selectedVars['ver'])){
+ foreach($this->selectedVars['ver'] as $var){
+
+ $colspan = ' colspan="'.($this->table_settings[$this->table_id]['sums'] == 1 && !$this->rowLevel2 ? $var['span']+1 : $var['span']).'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="undefined" class="spr vertical droppable full" '.$colspan.'>';
+
+ echo $this->snippet($this->variablesList[$var['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+
+ echo '</td>';
+ }
+ }
+ // Nimamo nobene vertikalne spremenljivke in 2 horizontalni
+ elseif($this->rowLevel2){
+ echo '<td class="borderless"></td>';
+ }
+
+ // Izrisemo se zadnjo prazno navpicno celico vrstico
+ echo '<td id="undefined" class="spr vertical droppable empty" rowspan="2">'.$lang['srv_multicrosstabs_add'].'</td>';
+ echo '</tr>';
+
+ // Izrisemo VARIABLE za spremenljivko - 2. vrstica
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<tr><td class="borderless" '.$colspan.'></td>';
+ if(count($this->selectedVars['ver'])){
+ foreach($this->selectedVars['ver'] as $var){
+
+ // Loop cez variable spremenljivke
+ foreach($this->variablesList[$var['spr']]['options'] as $option){
+
+ $colspan = ' colspan="'.( $var['span'] / count($this->variablesList[$var['spr']]['options']) ).'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="undefined" class="var vertical full" '.$colspan.'>';
+
+ echo $this->snippet($option, 25);
+
+ echo '</td>';
+ }
+
+ // Suma (ce jo imamo vklopljeno)
+ if($this->table_settings[$this->table_id]['sums'] == 1 && !$this->rowLevel2){
+ echo '<td class="var sums">';
+ echo $lang['srv_analiza_crosstab_skupaj'];
+ echo '</td>';
+ }
+ }
+ }
+ echo '</tr>';
+ }
+
+
+
+ // Izrisemo HORIZONTALNO izbrane variable
+ if(count($this->selectedVars['hor'])){
+
+ // Imamo 2 nivoja vrstic
+ if($this->rowLevel2){
+ foreach($this->selectedVars['hor'] as $parentVar){
+
+ $cnt = 0;
+ $order0 = 0;
+
+ foreach($this->variablesList[$parentVar['spr']]['options'] as $option){
+
+ $cnt2 = 0;
+
+ // ce imamo childe na 2. nivoju
+ if(count($parentVar['sub']) > 0){
+ foreach($parentVar['sub'] as $var){
+
+ $cnt3 = 0;
+
+ foreach($this->variablesList[$var['spr']]['options'] as $suboption){
+
+ echo '<tr>';
+
+ if($cnt == 0){
+ $span = $this->table_settings[$this->table_id]['sums'] == 1 && count($this->selectedVars['ver']) == 0 ? $parentVar['span']+(count($parentVar['sub'])*count($this->variablesList[$parentVar['spr']]['options'])) : $parentVar['span'];
+ $rowspan = ' rowspan="'.$span.'"';
+ echo '<td id="'.$parentVar['vrstni_red'].'" spr_id="'.$parentVar['spr'].'" parent="undefined" class="spr horizontal droppable full" '.$rowspan.'>';
+
+ echo $this->snippet($this->variablesList[$parentVar['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+ echo '</td>';
+ }
+
+ // Variabla
+ if($cnt2 == 0){
+ $span = $this->table_settings[$this->table_id]['sums'] == 1 && count($this->selectedVars['ver']) == 0 ? $parentVar['span'] / count($this->variablesList[$parentVar['spr']]['options']) + count($parentVar['sub']) : $parentVar['span'] / count($this->variablesList[$parentVar['spr']]['options']);
+ $rowspan = ' rowspan="'.$span.'"';
+ echo '<td class="var horizontal full" '.$rowspan.'>';
+ echo $this->snippet($option, 25);
+ echo '</td>';
+ }
+
+ if($cnt3 == 0){
+ $span = $this->table_settings[$this->table_id]['sums'] == 1 && count($this->selectedVars['ver']) == 0 ? count($this->variablesList[$var['spr']]['options']) + 1 : count($this->variablesList[$var['spr']]['options']);
+ $rowspan = ' rowspan="'.$span.'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="'.$parentVar['vrstni_red'].'" class="spr horizontal full" '.$rowspan.'>';
+
+ echo $this->snippet($this->variablesList[$var['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+ echo '</td>';
+ }
+
+ // Variabla 2
+ echo '<td class="var horizontal full">';
+ echo $this->snippet($suboption, 25);
+ echo '</td>';
+
+ // Celice s podatki
+ $this->displayDataCells($parentVar, $order0, $var, $cnt3);
+
+ echo '<td class="empty"></td>';
+
+ echo '</tr>';
+
+ $cnt++;
+ $cnt2++;
+ $cnt3++;
+ }
+
+ $order0++;
+
+ // Izrisemo se sumo ce je vklopljena
+ if($this->table_settings[$this->table_id]['sums'] == 1 && count($this->selectedVars['ver']) == 0){
+
+ echo '<tr>';
+
+ echo '<td class="var sums">'.$lang['srv_analiza_crosstab_skupaj'].'</td>';
+
+ $crosstabs = $this->crosstabData[$parentVar['spr'].'-'.$var['spr']];
+
+ $keys1 = array_keys($crosstabs['options2']);
+ $key = ceil($cnt / (count($this->variablesList[$var['spr']]['options'])*count($parentVar['sub']))) - 1;
+ $val = $keys1[$key];
+
+ $this->displaySumsCell($parentVar, $var, $val, $orientation=0);
+
+ echo '<td class="empty"></td>';
+
+ echo '</tr>';
+ }
+ }
+ }
+ else{
+ echo '<tr>';
+
+ if($cnt == 0){
+ $rowspan = ' rowspan="'.$parentVar['span'].'"';
+ echo '<td id="'.$parentVar['vrstni_red'].'" spr_id="'.$parentVar['spr'].'" parent="undefined" class="spr horizontal droppable full" '.$rowspan.' colspan="2">';
+
+ echo $this->snippet($this->variablesList[$parentVar['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+ echo '</td>';
+ }
+
+ // Variabla
+ $rowspan = ' rowspan="'.( $parentVar['span'] / count($this->variablesList[$parentVar['spr']]['options']) ).'"';
+ echo '<td class="var horizontal full" '.$rowspan.' colspan="2">';
+ echo $this->snippet($option, 25);
+ echo '</td>';
+
+
+ // Celice s podatki
+ $this->displayDataCells($parentVar, $cnt);
+
+ echo '<td class="empty"></td>';
+
+ echo '</tr>';
+
+ $cnt++;
+ }
+ }
+ }
+ }
+ // Imamo samo 1 nivo vrstic
+ else{
+ foreach($this->selectedVars['hor'] as $var){
+
+ $cnt = 0;
+ foreach($this->variablesList[$var['spr']]['options'] as $option){
+ echo '<tr>';
+
+ if($cnt == 0){
+ $rowspan = ' rowspan="'.($this->table_settings[$this->table_id]['sums'] == 1 && count($this->selectedVars['ver']) > 0 && !$this->colLevel2 ? $var['span']+1 : $var['span']).'"';
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="undefined" class="spr horizontal droppable full" '.$rowspan.'>';
+
+ echo $this->snippet($this->variablesList[$var['spr']]['naslov'], 25);
+
+ // Gumb za brisanje
+ echo '<div class="delete_var" onclick="deleteVariable(this);"></div>';
+ echo '</td>';
+ }
+
+ // Variabla
+ echo '<td id="'.$var['vrstni_red'].'" spr_id="'.$var['spr'].'" parent="undefined" class="var horizontal full">';
+ echo $this->snippet($option, 25);
+ echo '</td>';
+
+ // Celice s podatki
+ $this->displayDataCells($var, $cnt);
+
+
+ echo '<td class="empty"></td>';
+
+ echo '</tr>';
+
+ $cnt++;
+ }
+
+ // Vrstica za sumo (ce jo imamo vklopljeno)
+ if($this->table_settings[$this->table_id]['sums'] == 1 && count($this->selectedVars['ver']) > 0 && !$this->colLevel2){
+ echo '<tr>';
+ echo '<td class="var sums">'.$lang['srv_analiza_crosstab_skupaj'].'</td>';
+
+ // Loop cez vse stolpce
+ foreach($this->selectedVars['ver'] as $spr2){
+
+ // Loop cez variable trenutnega stolpca
+ $cnt = 0;
+ foreach($this->variablesList[$spr2['spr']]['options'] as $var2){
+
+ $crosstabs = $this->crosstabData[$var['spr'].'-'.$spr2['spr']];
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val = $keys1[$cnt];
+
+ $this->displaySumsCell($var, $spr2, $val, $orientation=1);
+
+ $cnt++;
+ }
+
+ // Krizanje navpicne in vodoravne sume
+ $this->displaySumsCell($var, $spr2, 0, $orientation=2);
+ }
+
+ echo '<td class="empty"></td>';
+
+ echo '</tr>';
+ }
+ }
+ }
+ }
+
+
+ // Izrisemo se zadnjo prazno vodoravno vrstico
+ echo '<tr class="last">';
+
+ if($this->rowSpan == 0)
+ $colspan = ' colspan="1"';
+ elseif(!$this->rowLevel2)
+ $colspan = ' colspan="2"';
+ else
+ $colspan = ' colspan="4"';
+ echo '<td id="undefined" class="spr horizontal droppable empty" '.$colspan.'>';
+ echo $lang['srv_multicrosstabs_add'];
+ echo '</td>';
+
+ for($i=0; $i<=$this->colSpan; $i++){
+ echo '<td class="empty"></td>';
+ }
+
+ // Dodatne prazne celice ce imamo sumo
+ if($this->table_settings[$this->table_id]['sums'] == 1 && ((!$this->colLevel2 && !$this->rowLevel2) || count($this->selectedVars['ver']) == 0)){
+ for($i=0; $i<count($this->selectedVars['ver']); $i++){
+ echo '<td class="empty"></td>';
+ }
+
+ if(count($this->selectedVars['ver']) == 0 && $this->rowLevel2)
+ echo '<td class="empty"></td>';
+ }
+
+ echo '</tr>';
+
+
+ echo '</table>';
+
+
+
+ echo '<div class="mc_table_bottom_settings">';
+
+ // Izrisemo legendo
+ $this->displayLegend();
+
+
+ // Ce smo v custom reportu tega ne izpisemo
+ if($_GET['m'] != 'analysis_creport'){
+
+ // Zvezdica za vkljucitev v porocilo
+ SurveyAnalysisHelper::getInstance()->addCustomReportElement($type=10, $sub_type=0, $spr1=$this->table_id);
+
+
+ echo '<script type="text/javascript">';
+
+ // Nastavimo droppable (drugace po ajaxu ne dela)
+ echo '$(function(){createDroppable();});';
+
+ // Nastavimo gumb za brisanje spremenljivke
+ echo '$(".mc_table tr td.spr").mouseover(function(){$(this).find(".delete_var").show();});';
+ echo '$(".mc_table tr td.spr").mouseout(function(){$(this).find(".delete_var").hide();});';
+
+ echo '</script>';
+ }
+
+ echo '</div>';
+ }
+
+ // Izpis celic v vrstici s podatki
+ function displayDataCells($spr1, $var1, $spr2='', $var2=''){
+
+ // Ce nimamo nobenega krizanja izpisemo prazne
+ if($spr2 == '' && $this->colSpan == 0){
+ for($i=0; $i<$this->colSpan; $i++){
+ echo '<td class="data"></td>';
+ }
+ }
+
+ // Ce nimamo stolpcev - krizanje dveh vrstic
+ elseif($spr2 != '' && $this->colSpan == 0){
+
+ $spr1_temp = explode('-', $spr1['spr']);
+ $grd = $this->variablesList[$spr1['spr']]['grd_id'];
+ $variabla1 = array('seq' => $spr1_temp[1], 'spr' => $spr1_temp[0], 'grd' => $grd);
+
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ }
+
+ //$var1 = floor(($var1) / (count($this->variablesList[$spr2['spr']]['options'])*count($spr1['sub'])));
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2])) ? $crosstabs['crosstab'][$val1][$val2] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2])) ? $crosstabs['avg'][$val1][$val2] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2])) ? $crosstabs['delez'][$val1][$val2] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+ }
+
+ // Krizanje 1 vrstice in 1 stolpca
+ elseif($spr2 == '' && !$this->colLevel2){
+
+ // Loop cez vse stolpce
+ foreach($this->selectedVars['ver'] as $spr2){
+
+ $spr1_temp = explode('-', $spr1['spr']);
+ $grd = $this->variablesList[$spr1['spr']]['grd_id'];
+ $variabla1 = array('seq' => $spr1_temp[1], 'spr' => $spr1_temp[0], 'grd' => $grd);
+
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ // Loop cez variable trenutnega stolpca
+ $cnt = 0;
+ foreach($this->variablesList[$spr2['spr']]['options'] as $var2){
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$cnt];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2])) ? $crosstabs['crosstab'][$val1][$val2] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2])) ? $crosstabs['avg'][$val1][$val2] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2])) ? $crosstabs['delez'][$val1][$val2] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+
+ $cnt++;
+ }
+
+ // Suma (ce jo imamo vklopljeno)
+ if($this->table_settings[$this->table_id]['sums'] == 1 && !$this->rowLevel2){
+ $this->displaySumsCell($spr1, $spr2, $val1, $orientation=0);
+ }
+ }
+ }
+
+ // Izpisemo vecnivojske podatke (krizanje 3 ali 4 spremenljivk)
+ else{
+
+ // Nastavimo 1. vrsticno variablo
+ $spr1_temp = explode('-', $spr1['spr']);
+ $grd = $this->variablesList[$spr1['spr']]['grd_id'];
+ $variabla1 = array('seq' => $spr1_temp[1], 'spr' => $spr1_temp[0], 'grd' => $grd);
+
+ // Krizanje 2 vrstic in 1 stolpca
+ if(!$this->colLevel2){
+
+ // Nastavimo 2. vrsticno variablo
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Loop cez vse stolpce
+ foreach($this->selectedVars['ver'] as $spr3){
+
+ $spr3_temp = explode('-', $spr3['spr']);
+ $grd = $this->variablesList[$spr3['spr']]['grd_id'];
+ $variabla3 = array('seq' => $spr3_temp[1], 'spr' => $spr3_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ // Loop cez variable trenutnega stolpca
+ $cnt = 0;
+ foreach($this->variablesList[$spr3['spr']]['options'] as $var3){
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3])) ? $crosstabs['crosstab'][$val1][$val2][$val3] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3])) ? $crosstabs['avg'][$val1][$val2][$val3] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3])) ? $crosstabs['delez'][$val1][$val2][$val3] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+
+ $cnt++;
+ }
+ }
+ }
+
+ // Krizanje 1 vrstice in 2 stolpcev
+ elseif($spr2 == ''){
+
+ // Loop cez vse stolpce 1. navpicne spremenljivke
+ foreach($this->selectedVars['ver'] as $spr2){
+
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Loop cez variable 1. navpicne spremnljivke
+ $cnt2 = 0;
+ foreach($this->variablesList[$spr2['spr']]['options'] as $var2){
+
+ // Loop cez vse navpicne spremenljivke 2. nivoja - ce obstajajo
+ if(count($spr2['sub']) > 0){
+ foreach($spr2['sub'] as $spr3){
+
+ // Nastavimo navpicno spremenljivko 2. nivoja
+ $spr3_temp = explode('-', $spr3['spr']);
+ $grd = $this->variablesList[$spr3['spr']]['grd_id'];
+ $variabla3 = array('seq' => $spr3_temp[1], 'spr' => $spr3_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$cnt2];
+
+ // Loop cez variable spremenljivke 2. nivoja
+ $cnt3 = 0;
+ foreach($this->variablesList[$spr3['spr']]['options'] as $var3){
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt3];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3])) ? $crosstabs['crosstab'][$val1][$val2][$val3] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3])) ? $crosstabs['avg'][$val1][$val2][$val3] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3])) ? $crosstabs['delez'][$val1][$val2][$val3] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+
+ $cnt3++;
+ }
+ }
+ }
+ // 1 nivojska spremenljivka v stolpcu
+ else{
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$cnt2];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2])) ? $crosstabs['crosstab'][$val1][$val2] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2])) ? $crosstabs['avg'][$val1][$val2] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2])) ? $crosstabs['delez'][$val1][$val2] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+ }
+
+ $cnt2++;
+ }
+ }
+ }
+
+
+
+ // Krizanje 2 vrstic in 2 stolpcev
+ else{
+
+ // Nastavimo 2. vrsticno variablo
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Loop cez vse stolpce 1. navpicne spremenljivke
+ foreach($this->selectedVars['ver'] as $spr3){
+
+ $spr3_temp = explode('-', $spr3['spr']);
+ $grd = $this->variablesList[$spr3['spr']]['grd_id'];
+ $variabla3 = array('seq' => $spr3_temp[1], 'spr' => $spr3_temp[0], 'grd' => $grd);
+
+ // Loop cez variable 1. navpicne spremnljivke
+ $cnt3 = 0;
+ foreach($this->variablesList[$spr3['spr']]['options'] as $var3){
+
+ // Loop cez vse navpicne spremenljivke 2. nivoja
+ if(count($spr3['sub']) > 0){
+ foreach($spr3['sub'] as $spr4){
+
+ // Nastavimo navpicno spremenljivko 2. nivoja
+ $spr4_temp = explode('-', $spr4['spr']);
+ $grd = $this->variablesList[$spr4['spr']]['grd_id'];
+ $variabla4 = array('seq' => $spr4_temp[1], 'spr' => $spr4_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+ $variables[3] = array('seq' => $variabla4['seq'], 'spr' => $variabla4['spr'], 'grd' => $variabla4['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt3];
+
+ // Loop cez variable spremenljivke 2. nivoja
+ $cnt4 = 0;
+ foreach($this->variablesList[$spr4['spr']]['options'] as $var4){
+
+ $keys4 = array_keys($crosstabs['options4']);
+ $val4 = $keys4[$cnt4];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3][$val4])) ? $crosstabs['crosstab'][$val1][$val2][$val3][$val4] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3][$val4])) ? $crosstabs['avg'][$val1][$val2][$val3][$val4] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3][$val4])) ? $crosstabs['delez'][$val1][$val2][$val3][$val4] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+
+ $cnt4++;
+ }
+ }
+ }
+ // 1 nivo navpicne spremenljivke
+ else{
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']]))
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+
+ $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']] = $this->createCrostabulation($variables);
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt3];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3])) ? $crosstabs['crosstab'][$val1][$val2][$val3] : 0;
+ $percent = ($crosstab > 0) ? $this->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3])) ? $crosstabs['avg'][$val1][$val2][$val3] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3])) ? $crosstabs['delez'][$val1][$val2][$val3] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+ }
+
+ $cnt3++;
+ }
+ }
+ }
+
+
+ // Loop cez vse stolpce
+ /*for($i=0; $i<$this->colSpan; $i++){
+ echo '<td class="data"></td>';
+ }*/
+ }
+ }
+
+ // Izpis celic v vrstici s sumami ($orientation 0->vrstica, 1->stolpec, 2->skupaj)
+ function displaySumsCell($spr1, $spr2, $val, $orientation){
+
+ $crosstabs = $this->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+
+ echo '<td class="sums data">';
+ echo '<table class="mc_inner_cell">';
+
+ // Celica s skupno sumo
+ if($orientation == 2){
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="bold white">';
+ echo $crosstabs['sumaSkupna'];
+ echo '</td></tr>';
+ }
+
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+
+
+ // Povprecje
+ if($this->table_settings[$this->table_id]['avgVar'] > 0){
+
+ // Loop cez vse in izracunamo povprecje z ustreznimi utezmi
+ $avg = 0;
+ if($crosstabs['crosstab']){
+ $tempAvg = 0;
+ foreach($crosstabs['crosstab'] as $key1 => $row){
+ foreach($row as $key2 => $count){
+ $tempAvg += $count * $crosstabs['avg'][$key1][$key2];
+ }
+ }
+ $avg = ($crosstabs['sumaSkupna'] > 0) ? $tempAvg / $crosstabs['sumaSkupna'] : 0;
+ }
+
+ echo '<tr><td class="blue">';
+ echo $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+ echo '</td></tr>';
+ }
+
+ // Delez
+ if($this->table_settings[$this->table_id]['delezVar'] > 0){
+
+ // Loop cez vrstico in izracunamo skupen delez
+ $delez = 0;
+ if($crosstabs['delez']){
+ foreach($crosstabs['delez'] as $row){
+ foreach($row as $tempDelez){
+ $delez += $tempDelez;
+ }
+ }
+ }
+
+ echo '<tr><td class="red">';
+ echo $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+
+ // Suma na koncu vrstice
+ elseif($orientation == 0){
+ // Izpisemo podatek
+ if($crosstabs['sumaVrstica'][$val]){
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="bold white">';
+ echo $crosstabs['sumaVrstica'][$val];
+ echo '</td></tr>';
+ }
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+ else{
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="bold white">';
+ echo '0';
+ echo '</td></tr>';
+ }
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+
+ }
+
+ // Povprecje
+ if($this->table_settings[$this->table_id]['avgVar'] > 0){
+
+ // Loop cez vrstico in izracunamo povprecje z ustreznimi utezmi
+ $avg = 0;
+ if($crosstabs['crosstab'][$val]){
+ $tempAvg = 0;
+ foreach($crosstabs['crosstab'][$val] as $key => $count){
+ $tempAvg += $count * $crosstabs['avg'][$val][$key];
+ }
+ $avg = ($crosstabs['sumaVrstica'][$val] > 0) ? $tempAvg / $crosstabs['sumaVrstica'][$val] : 0;
+ }
+
+ echo '<tr><td class="blue">';
+ echo $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+ echo '</td></tr>';
+ }
+
+ // Delez
+ if($this->table_settings[$this->table_id]['delezVar'] > 0){
+
+ // Loop cez vrstico in izracunamo skupen delez
+ $delez = 0;
+ if($crosstabs['delez'][$val]){
+ foreach($crosstabs['delez'][$val] as $tempDelez){
+ $delez += $tempDelez;
+ }
+ }
+
+ echo '<tr><td class="red">';
+ echo $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+
+ // Suma za stolpce
+ else{
+ // Izpisemo podatek
+ if(isset($crosstabs['sumaStolpec'][$val])){
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="bold white">';
+ echo $crosstabs['sumaStolpec'][$val];
+ echo '</td></tr>';
+ }
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber($this->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs['sumaStolpec'][$val]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+ else{
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="bold white">';
+ echo '0';
+ echo '</td></tr>';
+ }
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+
+ // Povprecje
+ if($this->table_settings[$this->table_id]['avgVar'] > 0){
+
+ // Loop cez vrstico in izracunamo povprecje z ustreznimi utezmi
+ $avg = 0;
+ if($crosstabs['crosstab']){
+ $tempAvg = 0;
+ foreach($crosstabs['crosstab'] as $key => $row){
+ if($row[$val] > 0)
+ $tempAvg += $row[$val] * $crosstabs['avg'][$key][$val];
+ }
+ $avg = ($crosstabs['sumaStolpec'][$val] > 0) ? $tempAvg / $crosstabs['sumaStolpec'][$val] : 0;
+ }
+
+ echo '<tr><td class="blue">';
+ echo $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+ echo '</td></tr>';
+ }
+
+ // Delez
+ if($this->table_settings[$this->table_id]['delezVar'] > 0){
+
+ // Loop cez vrstico in izracunamo skupen delez
+ $delez = 0;
+ if($crosstabs['delez']){
+ foreach($crosstabs['delez'] as $tempDelez){
+ $delez += $tempDelez[$val];
+ }
+ }
+
+ echo '<tr><td class="red">';
+ echo $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+
+ echo '</table>';
+ echo '</td>';
+ }
+
+ // Izpis celice z vrednostmi
+ function displayDataCell($crosstab, $percent, $avg, $delez){
+
+ echo '<td class="data">';
+ echo '<table class="mc_inner_cell">';
+
+ if($crosstab > 0){
+
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="white">';
+ echo $crosstab;
+ echo '</td></tr>';
+ }
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber($percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+ else{
+ // Numerus
+ if($this->table_settings[$this->table_id]['numerus'] == 1){
+ echo '<tr><td class="white">';
+ echo '0';
+ echo '</td></tr>';
+ }
+ // Procenti
+ if($this->table_settings[$this->table_id]['percent'] == 1){
+ echo '<tr><td class="white">';
+ echo $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+ }
+
+ // Povprecje
+ if($this->table_settings[$this->table_id]['avgVar'] > 0){
+ echo '<tr><td class="blue">';
+ echo $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+ echo '</td></tr>';
+ }
+
+ // Delez
+ if($this->table_settings[$this->table_id]['delezVar'] > 0){
+ echo '<tr><td class="red">';
+ //echo $this->formatNumber($delez, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+ echo $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ echo '</td></tr>';
+ }
+
+ echo '</table>';
+ echo '</td>';
+ }
+
+
+ function displayTableTitle($title){
+ global $lang;
+
+ $titleString = ($title == '') ? $lang['srv_table'] : $title;
+
+ echo '<div class="multicrosstab_title_inline" contenteditable="true">';
+ echo $titleString;
+ echo '</div>';
+ }
+
+ // Izpisemo nastavitve za tabelo (procenti, numerus, navedbe/enote...)
+ function displayTableSettings(){
+ global $lang;
+
+ echo '<h2>'.$lang['srv_multicrosstabs_settings'].'</h2>';
+
+ /*echo '<span class="clr"><input type="checkbox" id="numerus_'.$this->table_id.'" '.($this->table_settings[$this->table_id]['numerus'] == 1 ? ' checked="checked"':'').' onclick="changeMCSettings(\''.$this->table_id.'\', \'numerus\');" /><label for="numerus_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_numerus'].'</label></span>';
+ echo '<span class="clr"><input type="checkbox" id="percent_'.$this->table_id.'" '.($this->table_settings[$this->table_id]['percent'] == 1 ? ' checked="checked"':'').' onclick="changeMCSettings(\''.$this->table_id.'\', \'percent\');" /><label for="percent_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_percent'].'</label></span>';
+ //echo '<span class="clr"><input type="checkbox" id="avg_'.$this->table_id.'" '.($this->table_settings[$this->table_id]['avg'] == 1 ? ' checked="checked"':'').' onclick="changeMCSettings(\''.$this->table_id.'\', \'avg\');" /><label for="avg_'.$this->table_id.'"> Povprečje</label></span>';
+
+ echo '<span class="clr"><input type="checkbox" id="sums_'.$this->table_id.'" '.($this->table_settings[$this->table_id]['sums'] == 1 ? ' checked="checked"':'').' onclick="changeMCSettings(\''.$this->table_id.'\', \'sums\');" /><label for="sums_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_sum'].'</label></span>';
+
+ if($this->isCheckbox){
+ echo '<span class="clr" style="line-height: 20px;">';
+ echo '<label for="navVsEno0_'.$this->table_id.'"><input type="radio" id="navVsEno0_'.$this->table_id.'" name="navVsEno" '.($this->table_settings[$this->table_id]['navVsEno'] == 0 ? ' checked="checked"':'').' value="0" onclick="changeMCSettings(\''.$this->table_id.'\', \'navVsEno\');" />'.$lang['srv_analiza_crosstab_navedbe'].'</label>';
+ echo ' <label for="navVsEno1_'.$this->table_id.'"><input type="radio" id="navVsEno1_'.$this->table_id.'" name="navVsEno" '.($this->table_settings[$this->table_id]['navVsEno'] == 1 ? ' checked="checked"':'').' value="1" onclick="changeMCSettings(\''.$this->table_id.'\', \'navVsEno\');" />'.$lang['srv_analiza_crosstab_enote'].'</label>';
+ echo '</span>';
+ }*/
+
+ echo '<form name="mc_settings" method="post">';
+
+ echo '<input type="hidden" name="anketa" value="'.$this->ank_id.'" />';
+ echo '<input type="hidden" name="table_id" value="'.$this->table_id.'" />';
+
+
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_multicrosstabs_settings_val'].'</legend>';
+
+ // Prikaz numerusa
+ echo '<span class="clr"><input type="checkbox" id="numerus_'.$this->table_id.'" name="numerus" '.($this->table_settings[$this->table_id]['numerus'] == 1 ? ' checked="checked"':'').' value="1" /><label for="numerus_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_numerus'].'</label></span>';
+
+ // Prikaz procentov
+ echo '<span class="clr"><input type="checkbox" id="percent_'.$this->table_id.'" name="percent" '.($this->table_settings[$this->table_id]['percent'] == 1 ? ' checked="checked"':'').' value="1" /><label for="percent_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_percent'].'</label></span>';
+
+ // Prikaz vsot
+ echo '<span class="clr"><input type="checkbox" id="sums_'.$this->table_id.'" name="sums" '.($this->table_settings[$this->table_id]['sums'] == 1 ? ' checked="checked"':'').' value="1" /><label for="sums_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_sum'].'</label></span>';
+
+ // Navedbe / enote
+ /*if($this->isCheckbox){
+ echo '<span class="clr" style="line-height: 20px;">';
+ echo '<label for="navVsEno0_'.$this->table_id.'"><input type="radio" id="navVsEno0_'.$this->table_id.'" name="navVsEno" '.($this->table_settings[$this->table_id]['navVsEno'] == 0 ? ' checked="checked"':'').' value="0" />'.$lang['srv_analiza_crosstab_navedbe'].'</label>';
+ echo ' <label for="navVsEno1_'.$this->table_id.'"><input type="radio" id="navVsEno1_'.$this->table_id.'" name="navVsEno" '.($this->table_settings[$this->table_id]['navVsEno'] == 1 ? ' checked="checked"':'').' value="1" />'.$lang['srv_analiza_crosstab_enote'].'</label>';
+ echo '</span>';
+ }*/
+
+ echo '</fieldset>';
+
+
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_multicrosstabs_settings_avg'].'</legend>';
+
+ // Variabla za racunanje povprecja - numeric in ordinal (radio, dropdown, mg)
+ $checked = $this->table_settings[$this->table_id]['avgVar'] == '' ? false : true;
+ echo '<span class="clr"><input type="checkbox" id="avgSetting_'.$this->table_id.'" name="avgSetting" '.($checked ? ' checked="checked"':'').' onClick="toggleMCSetting(\'avgVar\');" /><label for="avgSetting_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_avg'].'</label>';
+ echo '<span id="avgVar" class="spaceLeft" '.($checked ? '' : ' style="display: none;"').'><select id="avgVar_'.$this->table_id.'" name="avgVar">';
+ echo '<option value="">'.$lang['srv_select_spr'].'...</option>';
+ foreach($this->variablesList AS $spr){
+ if( $spr['canChoose'] && ($spr['tip'] == 7 || (in_array($spr['tip'], array(1,3,6)) && $spr['skala'] == 0)) ){
+ echo '<option value="'.$spr['spr_id'].'-'.$spr['sequence'].'" '.($this->table_settings[$this->table_id]['avgVar'] == $spr['spr_id'].'-'.$spr['sequence'] ? ' selected="selected"' : '').'>('.$spr['variable'].') '.$this->snippet($spr['naslov'], 25).'</option>';
+ }
+ }
+ echo '</select></span>';
+ echo '</span>';
+
+ echo '</fieldset>';
+
+
+ echo '<fieldset>';
+ echo '<legend>'.$lang['srv_multicrosstabs_settings_del'].'</legend>';
+
+ // Variabla za racunanje deleza - ordinal in nominal (radio, dropdown, mg, po novem tudi checkbox, multicheckbox)
+ $checked = $this->table_settings[$this->table_id]['delezVar'] == '' ? false : true;
+ echo '<span class="clr"><input type="checkbox" id="delezSetting_'.$this->table_id.'" name="delezSetting" '.($checked ? ' checked="checked"':'').' onClick="toggleMCSetting(\'delezVar\');" /><label for="delezSetting_'.$this->table_id.'"> '.$lang['srv_multicrosstabs_delez'].'</label>';
+
+ echo '<span id="delezVar" class="spaceLeft" '.($checked ? '' : ' style="display: none;"').'><select id="delezVar_'.$this->table_id.'" name="delezVar" onChange="setDelez(this.value);">';
+ echo '<option value="">'.$lang['srv_select_spr'].'...</option>';
+ foreach($this->variablesList AS $spr){
+ if($spr['canChoose'] && in_array($spr['tip'], array(1,3,6,2,16))){
+ echo '<option value="'.$spr['spr_id'].'-'.$spr['sequence'].'" '.($this->table_settings[$this->table_id]['delezVar'] == $spr['spr_id'].'-'.$spr['sequence'] ? ' selected="selected"' : '').'>('.$spr['variable'].') '.$this->snippet($spr['naslov'], 25).'</option>';
+ }
+ }
+ echo '</select></span>';
+ echo '</span>';
+
+ echo '<div id="delez" '.($checked ? '' : ' style="display: none;"').'>';
+ $this->displayDelez($this->table_settings[$this->table_id]['delezVar']);
+ echo '</div>';
+
+ echo '</fieldset>';
+
+
+ echo '</form>';
+
+
+ // Gumbi na dnu
+ echo '<div id="mcSettingsButtons">';
+
+ echo '<span class="buttonwrapper spaceRight floatLeft">';
+ echo '<a class="ovalbutton ovalbutton_gray" onclick="closeMCSettings(\''.$this->table_id.'\');">';
+ echo '<span>'.$lang['srv_zapri'].'</span>';
+ echo '</a>';
+ echo '</span>';
+
+ echo '<span class="buttonwrapper spaceRight spaceLeft floatLeft">';
+ echo '<a class="ovalbutton ovalbutton_orange" onclick="saveMCSettings(\''.$this->table_id.'\');">';
+ echo '<span>'.$lang['srv_potrdi'].'</span>';
+ echo '</a>';
+ echo '</span>';
+
+ echo '</div>';
+ }
+
+ // Prikazemo opcije variable (checkboxe) za delez
+ function displayDelez($var){
+
+ // Ce imamo nastavljeno variablo za delez prikazemo vse njene opcije
+ if($var != ''){
+ $delez = unserialize($this->table_settings[$this->table_id]['delez']);
+
+ $cnt = 0;
+ foreach($this->variablesList[$var]['options'] as $option){
+
+ if($this->table_settings[$this->table_id]['delezVar'] == $var)
+ $val = $delez[$cnt];
+ else
+ $val = 0;
+
+ echo '<span class="clr">';
+ echo '<input type="checkbox" id="delez_'.$cnt.'" name="delez_'.$cnt.'" value="1" '.($val == 1 ? ' checked="checked"' : '').' /><label for="delez_'.$cnt.'"> '.$option.'</label>';
+ echo '</span>';
+
+ $cnt++;
+ }
+ }
+ }
+
+
+ // Prikazuje filtre
+ function displayFilters() {
+
+ if ($this->dataFileStatus == FILE_STATUS_SRV_DELETED || $this->dataFileStatus == FILE_STATUS_NO_DATA){
+ return false;
+ }
+
+ # nastavitve tabele multicrosstab
+ $SSH = new SurveyStaticHtml($this->ank_id);
+ $SSH -> displayMulticrosstabSettings();
+ }
+
+ // Prikaze dropdown z linki
+ function displayLinks() {
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->ank_id);
+ $SSH -> displayAnalizaSubNavigation();
+ }
+
+ // Prikaze izvoz za PDF/RTF
+ function displayExport () {
+
+ $href_print = makeEncodedIzvozUrlString('izvoz.php?b=export&m=multicrosstabs_izpis&anketa='.$this->ank_id);
+ $href_pdf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=multicrosstabs_izpis&anketa='.$this->ank_id);
+ $href_rtf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=multicrosstabs_izpis_rtf&anketa='.$this->ank_id);
+ $href_xls = makeEncodedIzvozUrlString('izvoz.php?b=export&m=multicrosstabs_izpis_xls&anketa='.$this->ank_id);
+
+ echo '<script>';
+ # nastavimopravilne linke
+ echo '$("#secondNavigation_links a#multicrosstabDoPdf").attr("href", "'.$href_pdf.'");';
+ echo '$("#secondNavigation_links a#multicrosstabDoRtf").attr("href", "'.$href_rtf.'");';
+ echo '$("#secondNavigation_links a#multicrosstabDoXls").attr("href", "'.$href_xls.'");';
+ # prikažemo linke
+ echo '$("#hover_export_icon a").removeClass("hidden");';
+ echo '$("#secondNavigation_links a").removeClass("hidden");';
+ echo '</script>';
+ }
+
+ // Prikazemo legendo (povprecje, delez)
+ function displayLegend(){
+ global $lang;
+
+ if($this->table_settings[$this->table_id]['avgVar'] > 0 || $this->table_settings[$this->table_id]['delezVar'] > 0){
+ echo '<div class="mc_table_legend">';
+
+ // Povprecje
+ if($this->table_settings[$this->table_id]['avgVar'] > 0){
+ echo '<span class="clr"><span class="blue">'.$lang['srv_multicrosstabs_avg'].': </span>'.$this->variablesList[$this->table_settings[$this->table_id]['avgVar']]['variable'].'</span>';
+ }
+
+ // Delez
+ if($this->table_settings[$this->table_id]['delezVar'] > 0){
+ echo '<span class="red">'.$lang['srv_multicrosstabs_delez'].': </span>'.$this->variablesList[$this->table_settings[$this->table_id]['delezVar']]['variable'];
+
+ $delez = unserialize($this->table_settings[$this->table_id]['delez']);
+ $string = '';
+ $cnt = 1;
+ foreach($delez as $val){
+ if($val == 1)
+ $string .= $cnt.', ';
+
+ $cnt++;
+ }
+ echo ' ('.substr($string, 0, -2).')';
+
+ }
+
+ echo '</div>';
+ }
+ }
+
+
+ // funkcija vrne seznam variabel za drag
+ public function getVariableList() {
+ if (isset($this->variablesList) && is_array($this->variablesList) && count($this->variablesList) > 0) {
+ return $this->variablesList;
+ } else {
+ # pobrišemo array()
+ $this->variablesList = array();
+ # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence)
+ foreach ($this->_HEADERS AS $skey => $spremenljivka) {
+ if ((int)$spremenljivka['hide_system'] == 1 && in_array($spremenljivka['variable'],array('email','ime','priimek','telefon','naziv','drugo'))) {
+ continue;
+ }
+
+ $tip = $spremenljivka['tip'];
+ if (is_numeric($tip)
+ # tekstovnih tipov ne dodajamo
+
+ && $tip != 4 #text
+ && $tip != 5 #label
+ #&& $tip != 7 #number
+ #&& $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ #&& $tip != 18 #vsota
+ #&& $tip != 19 #multitext
+ #&& $tip != 20 #multinumber
+ #&& $tip != 21 #besedilo*
+ && $tip != 22 #compute
+ && $tip != 25 #kvota
+ ) {
+ $cnt_all = (int)$spremenljivka['cnt_all'];
+ # radio in select in checkbox
+ if ($cnt_all == '1' || $tip == 1 || $tip == 3 || $tip == 2) {
+ # pri tipu radio ali select dodamo tisto variablo ki ni polje "drugo"
+ if ($tip == 1 || $tip == 3 ) {
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+
+ // Napolnimo variable
+ $options = $spremenljivka['options'];
+
+ # imamo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[$skey.'-'.$spremenljivka['grids'][0]['variables'][$vid]['sequence']] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>'undefined',
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][$vid]['sequence'],
+ 'naslov'=>strip_tags($spremenljivka['naslov']),
+ 'variable'=>$spremenljivka['variable'],
+ 'canChoose'=>true,
+ 'sub'=>0,
+ /*'cnt'=>count($spremenljivka['options']),
+ 'options'=>$spremenljivka['options']);*/
+ 'options'=>$options);
+ }
+ }
+ }
+ }
+ } else {
+
+ // Napolnimo variable
+ $options = array();
+ foreach($spremenljivka['grids'][0]['variables'] as $key => $var){
+ if(!$var['other'])
+ $options[($key+1)] = $var['naslov'];
+ }
+
+ # imamo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[$skey.'-'.$spremenljivka['grids'][0]['variables'][0]['sequence']] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>'undefined',
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'naslov'=>strip_tags($spremenljivka['naslov']),
+ 'variable'=>$spremenljivka['variable'],
+ 'canChoose'=>true,
+ 'sub'=>0,
+ /*'cnt'=>count($spremenljivka['grids'][0]));var_dump($spremenljivka['grids'][0]['variables']);*/
+ 'options'=>$options);
+ }
+ } else if ($cnt_all > 1){
+ # imamo več skupin ali podskupin, zato zlopamo skozi gride in variable
+ if (count($spremenljivka['grids']) > 0 ) {
+ $this->variablesList[$skey] = array(
+ 'tip'=>$tip,
+ 'naslov'=>strip_tags($spremenljivka['naslov']),
+ 'variable'=>$spremenljivka['variable'],
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # ali imamo en grid, ali več (ranking, vsota, text(vec kosov), number(vec kosov))
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+
+ // Napolnimo variable
+ $options = array();
+ foreach($spremenljivka['grids'][0]['variables'] as $key => $var){
+ if(!$var['other'])
+ $options[($key+1)] = $var['naslov'];
+ }
+
+ $this->variablesList[$skey.'-'.$variable['sequence']] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>'undefined',
+ 'sequence'=>$variable['sequence'],
+ 'naslov'=>strip_tags($variable['naslov']),
+ 'variable'=>$variable['variable'],
+ 'canChoose'=>true,
+ 'sub'=>1,
+ /*'cnt'=>$spremenljivka['cnt_all']);*/
+ 'options'=>$options);
+ }
+ }
+ }
+
+ }
+ # Imamo multicheckbox
+ else if($tip == 16 || $tip == 18) {
+
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+
+ // Napolnimo variable
+ $options = array();
+ foreach($spremenljivka['grids'][0]['variables'] as $key => $var){
+ if(!$var['other'])
+ $options[($key+1)] = $var['naslov'];
+ }
+
+ $sub++;
+ $this->variablesList[$skey.'-'.$grid['variables'][0]['sequence']] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>$gid,
+ 'sequence'=>$grid['variables'][0]['sequence'],
+ 'naslov'=>strip_tags($grid['naslov']),
+ 'variable'=>$grid['variable'],
+ 'canChoose'=>true,
+ 'sub'=>1,
+ /*'cnt'=>count($grid['variables']));*/
+ 'options'=>$options);
+ }
+ }
+ }
+ # imamo več gridov - multigrid, multitext, multinumber
+ else {
+
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[$skey] = array(
+ 'tip'=>$tip,
+ 'naslov'=>strip_tags($grid['naslov']),
+ 'variable'=>$grid['variable'],
+ 'canChoose'=>false,
+ 'sub'=>$sub);
+ }
+ if (count ($grid['variables']) > 0) {
+ $sub++;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+
+ // Napolnimo variable
+ $options = array();
+ if($spremenljivka['tip'] == 6){
+ $options = $spremenljivka['options'];
+ }
+ else{
+ foreach($spremenljivka['grids'][0]['variables'] as $key => $var){
+ if(!$var['other'])
+ $options[($key+1)] = $var['naslov'];
+ }
+ }
+
+ $this->variablesList[$skey.'-'.$variable['sequence']] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>'undefined',
+ 'sequence'=>$variable['sequence'],
+ 'naslov'=>strip_tags($variable['naslov']),
+ 'variable'=>$variable['variable'],
+ 'canChoose'=>true,
+ 'sub'=>$sub,
+ /*'cnt'=>count($spremenljivka['options']));*/
+ 'options'=>$options);
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ return $this->variablesList;
+ }
+ }
+
+ // funkcija vrne izbrane variable v arrayu
+ public function getSelectedVars() {
+
+ // Najprej napolnimo prvi nivo
+ $sql = sisplet_query("SELECT * FROM srv_mc_element WHERE table_id='$this->table_id' AND parent='' ORDER BY vrstni_red");
+ while($row = mysqli_fetch_array($sql)){
+
+ $colSpan = 0;
+ $rowSpan = 0;
+
+ // Horizontalne spremenljivke
+ if($row['position'] == '0'){
+
+ $this->selectedVars['hor'][$row['vrstni_red']] = $row;
+
+ $sql2 = sisplet_query("SELECT * FROM srv_mc_element WHERE table_id='$this->table_id' AND parent='$row[vrstni_red]' AND position='0'");
+ // Ce ni 2.nivoja
+ if(mysqli_num_rows($sql2) == 0){
+ $rowSpan = count($this->variablesList[$row['spr']]['options']);
+ $this->selectedVars['hor'][$row['vrstni_red']]['span'] = $rowSpan;
+
+ if($this->variablesList[$row['spr']]['tip'] == 2 || $this->variablesList[$row['spr']]['tip'] == 16)
+ $this->isCheckbox = true;
+ }
+ // Napolnimo se 2.nivo
+ else{
+ while($row2 = mysqli_fetch_array($sql2)){
+ $this->selectedVars['hor'][$row['vrstni_red']]['sub'][$row2['vrstni_red']] = $row2;
+
+ $rowSpan += count($this->variablesList[$row['spr']]['options'])*count($this->variablesList[$row2['spr']]['options']);
+ $this->selectedVars['hor'][$row['vrstni_red']]['sub'][$row2['vrstni_red']]['span'] = count($this->variablesList[$row2['spr']]['options']);
+
+ $this->rowLevel2 = true;
+
+ if($this->variablesList[$row2['spr']]['tip'] == 2 || $this->variablesList[$row2['spr']]['tip'] == 16)
+ $this->isCheckbox = true;
+ }
+
+ $this->selectedVars['hor'][$row['vrstni_red']]['span'] = $rowSpan;
+ }
+
+ $this->rowSpan += $rowSpan;
+ }
+ // Vertikalne spremenljivke
+ else{
+
+ $this->selectedVars['ver'][$row['vrstni_red']] = $row;
+
+ $sql2 = sisplet_query("SELECT * FROM srv_mc_element WHERE table_id='$this->table_id' AND parent='$row[vrstni_red]' AND position='1'");
+ // Ce ni 2.nivoja
+ if(mysqli_num_rows($sql2) == 0){
+ $colSpan = count($this->variablesList[$row['spr']]['options']);
+ $fullColSpan = $colSpan;
+ $this->selectedVars['ver'][$row['vrstni_red']]['span'] = $colSpan;
+
+ if($this->variablesList[$row['spr']]['tip'] == 2 || $this->variablesList[$row['spr']]['tip'] == 16)
+ $this->isCheckbox = true;
+
+ if($this->table_settings[$this->table_id]['sums'] == 1)
+ $fullColSpan++;
+ }
+ // Napolnimo se 2.nivo
+ else{
+ while($row2 = mysqli_fetch_array($sql2)){
+ $this->selectedVars['ver'][$row['vrstni_red']]['sub'][$row2['vrstni_red']] = $row2;
+
+ $colSpan += count($this->variablesList[$row['spr']]['options'])*count($this->variablesList[$row2['spr']]['options']);
+ $fullColSpan += count($this->variablesList[$row['spr']]['options'])*count($this->variablesList[$row2['spr']]['options']);
+ $this->selectedVars['ver'][$row['vrstni_red']]['sub'][$row2['vrstni_red']]['span'] = count($this->variablesList[$row2['spr']]['options']);
+
+ $this->colLevel2 = true;
+
+ if($this->variablesList[$row2['spr']]['tip'] == 2 || $this->variablesList[$row2['spr']]['tip'] == 16)
+ $this->isCheckbox = true;
+ }
+
+ $this->selectedVars['ver'][$row['vrstni_red']]['span'] = $colSpan;
+ }
+
+ $this->colSpan += $colSpan;
+ $this->fullColSpan += $fullColSpan;
+ }
+ }
+
+ //echo 'Cols:'.$this->colSpan.'_Rows:'.$this->rowSpan.' ';
+ //var_dump($this->selectedVars['hor']);
+ }
+
+
+ // Izvedemo izracune crosstabulacij
+ public function createCrostabulation($variables) {
+ global $site_path;
+
+ $folder = $site_path . EXPORT_FOLDER.'/';
+ $R_folder = $site_path . R_FOLDER.'/';
+
+ if ($this->dataFileName != '' && file_exists($this->dataFileName)){
+
+ $spr = array();
+ $grid = array();
+ $sekvence = array();
+ $var_options = array();
+ $_all_options = array();
+ foreach($variables as $key => $variable){
+
+ $spr[$key] = $this->_HEADERS[$variables[$key]['spr']];
+ $grid[$key] = $spr[$key]['grids'][$variables[$key]['grd']];
+ $sekvenca = $variables[$key]['seq'];
+
+ $spr_checkbox = false;
+
+
+ # za checkboxe gledamo samo odgovore ki so bili 1 in za vse opcije
+ if ($spr[$key]['tip'] == 2 || $spr[$key]['tip'] == 16) {
+
+ $spr_checkbox = true;
+
+ if ($spr[$key]['tip'] == 2) {
+ if (count($spr[$key]['grids'][0]['variables']) > 0)
+ foreach ($spr[$key]['grids'][0]['variables'] AS $_vkey =>$_variable) {
+ if ((int)$_variable['text'] != 1) {
+ $sekvence[$key][] = $_variable['sequence'];
+ }
+ } else {
+ $sekvence[$key] = explode('_',$spr[$key]['sequences']);
+ }
+ }
+ if ($spr1['tip'] == 16) {
+
+ foreach ($grid[$key]['variables'] AS $_variables) {
+
+ $sekvence[$key][] = $_variables['sequence'];
+ }
+ }
+ } else {
+ $sekvence[$key][] = $sekvenca;
+ }
+
+
+ # poiščemo pripadajočo spremenljivko
+ $var_options[$key] = $this->_HEADERS[$variable['spr']]['options'];
+
+ # najprej poiščemo (združimo) vse opcije ki so definirane kot opcije spremenljivke in vse ki so v crosstabih
+ if (count($var_options[$key]) > 0 && $spr_checkbox !== true ) {
+ foreach ($var_options[$key] as $okey => $opt) {
+ $_all_options[$key][$okey] = array('naslov'=>$opt, 'cnt'=>null, 'type'=>'o');
+ }
+ }
+
+ # za checkboxe dodamo posebej vse opcije
+ if ($spr_checkbox == true ) {
+ if ($spr[$key]['tip'] == 2 ) {
+ $grid[$key] = $this->_HEADERS[$variable['spr']]['grids']['0'];
+ }
+
+ foreach ($grid[$key]['variables'] As $vkey => $var) {
+ if ($var['other'] != 1) {
+ $_all_options[$key][$var['sequence']] = array('naslov'=>$var['naslov'], 'cnt'=>null, 'type'=>'o', 'vr_id'=> $var['variable']);
+ }
+ }
+ }
+ }
+
+
+ // Nastavimo string s katerim filtriramo datoteko za prave stolpce
+ foreach($sekvence as $sekvenca){
+ if(count($sekvenca) > 1){
+ foreach($sekvenca as $grd){
+ $crosstabVars .= '$'.$grd.',';
+ }
+ }
+ else
+ $crosstabVars .= '$'.$sekvenca[0].',';
+ }
+
+ // Ce imamo racunanje povprecja
+ $avgVar = 0;
+ if($this->table_settings[$this->table_id]['avgVar'] != ''){
+
+ $avg = explode('-',$this->table_settings[$this->table_id]['avgVar']);
+ $crosstabVars .= '$'.$avg[1].',';
+
+ $avgVar = 1;
+ }
+
+ // Ce imamo racunanje deleza
+ if($this->table_settings[$this->table_id]['delezVar'] != ''){
+
+ $delezVar = explode('-',$this->table_settings[$this->table_id]['delezVar']);
+
+ // Ce imamo delez za checkbox
+ if($this->variablesList[$this->table_settings[$this->table_id]['delezVar']]['tip'] == 2 || $this->variablesList[$this->table_settings[$this->table_id]['delezVar']]['tip'] == 16){
+ $delez = unserialize($this->table_settings[$this->table_id]['delez']);
+ $i = 0;
+ foreach($delez as $val){
+
+ if($val == 1){
+ $stolpec = (int)$delezVar[1] + $i;
+ $crosstabVars .= '$'.$stolpec.',';
+ }
+
+ $i++;
+ }
+ $delez = -1;
+ }
+ else{
+ $crosstabVars .= '$'.$delezVar[1].',';
+ $delez = unserialize($this->table_settings[$this->table_id]['delez']);
+ }
+ }
+
+ $crosstabVars = substr($crosstabVars, 0, -1);
+
+ // Ce se nimamo datoteke s pripravljenimi podatki jo ustvarimo
+ $tmp_file = $R_folder . '/TempData/crosstab_data.tmp';
+ if (!file_exists($tmp_file)) {
+ $this->prepareDataFile($crosstabVars);
+ }
+
+
+ // Inicializiramo R in pozenemo skripto za crosstabulacije
+ $R = new SurveyAnalysisR($this->ank_id);
+ $crosstabs = $R->createMultiCrosstabulation($sekvence, $avgVar, $delez);
+
+
+ $crosstabs['options1'] = $_all_options[0];
+ $crosstabs['options2'] = $_all_options[1];
+ if(isset($_all_options[2]))
+ $crosstabs['options3'] = $_all_options[2];
+ if(isset($_all_options[3]))
+ $crosstabs['options4'] = $_all_options[3];
+
+ $crosstabs['isCheckbox'] = $this->isCheckbox;
+
+
+ // Testiranje...
+ /*echo '<div style="width: 800px; position: absolute;top:0;left:0; background-color: #eeffff;">';
+ var_dump($crosstabs['sumaVrstica']);
+ var_dump($crosstabs['sumaStolpec']);
+ var_dump($crosstabs['sumaSkupna']);
+ echo '</div>';*/
+
+
+ // Na koncu pobrisemo zacasen file s podatki
+ $this->deleteDataFile();
+
+
+ return $crosstabs;
+ }
+ }
+
+
+ // Pripravimo file iz katerega preberemo podatke in izvedemo crosstabulacije
+ public function prepareDataFile($cols){
+ global $site_path;
+
+ $folder = $site_path . EXPORT_FOLDER.'/';
+ $R_folder = $site_path . R_FOLDER.'/';
+
+ # pogoji so že dodani v _CURRENT_STATUS_FILTER
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+
+ # dodamo status filter za vse sekvence checkbox-a da so == 1
+ if ($additional_status_filter != null) {
+ $status_filter .= $additional_status_filter;
+ }
+
+ # odstranimo vse zapise, kjer katerakoli od variabel vsebuje missing
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ $_pageMissing_answers = $this->getInvalidAnswers(MISSING_TYPE_CROSSTAB);
+
+
+ // File kamor zapisemo filtrirane podatke
+ $tmp_file = $R_folder . '/TempData/crosstab_data.tmp';
+
+ # polovimo obe sekvenci
+ /*if (count($sekvences1)>0)
+ foreach ($sekvences1 AS $sequence1) {
+ if (count($sekvences2)>0)
+ foreach ($sekvences2 AS $sequence2) {
+ #skreira variable: $crosstab, $cvar1, $cvar2
+
+ $additional_filter = '';
+ if ($spr_1_checkbox == true) {
+ $_seq_1_text = ''.$sequence1;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter = ' && ($'.$sequence1.' == 1)';
+ } else {
+ $_seq_1_text = '$'.$sequence1;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key1 => $missing1) {
+ $additional_filter .= ' && ($'.$sequence1.' != '.$m_key1.')';
+ }
+ }
+
+ if ($spr_2_checkbox == true) {
+ $_seq_2_text = ''.$sequence2;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter .= ' && ($'.$sequence2.' == 1)';
+ } else {
+ $_seq_2_text = '$'.$sequence2;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key2 => $missing2) {
+ $additional_filter .= ' && ($'.$sequence2.' != '.$m_key2.')';
+ }
+ }
+
+ if (IS_WINDOWS) {
+ #$command = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$_status_filter.' { print \"$crosstab[\x27\",$'.$sequence1.',\"\x27][\x27\",$'.$sequence2.',\"\x27]++; $options1[\x27\",$'.$sequence1.',\"\x27]++; $options2[\x27\",$'.$sequence2.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ $command = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$additional_filter.' { print $0 }" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ #$command = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$_status_filter.' { print "$crosstab[\x27",$'.$sequence1.',"\x27][\x27",$'.$sequence2.',"\x27]++; $options1[\x27",$'.$sequence1.',"\x27]++; $options2[\x27",$'.$sequence2.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ $command = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$additional_filter.' { print $0 }\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out = shell_exec($command);
+ }
+
+ }*/
+
+
+ // Filtriramo podatke po statusu in loopih in jih zapisemo v temp folder R-ja
+ if (IS_WINDOWS) {
+ $command = 'awk -F"|" "BEGIN {{OFS=\",\"} {ORS=\"\n\"}} '.$status_filter.' { print '.$cols.' }" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command = 'awk -F"|" \'BEGIN {{OFS=","} {ORS="\n"}} '.$status_filter.' { print '.$cols.'; }\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out = shell_exec($command);
+
+ return $out;
+ }
+
+ // Pobrisemo zacasen file s podatki
+ public function deleteDataFile(){
+ global $site_path;
+
+ $R_folder = $site_path . R_FOLDER.'/';
+ $tmp_file = $R_folder . '/TempData/crosstab_data.tmp';
+
+ // Na koncu pobrisemo zacasen file s podatki
+ if (file_exists($tmp_file)) {
+ unlink($tmp_file);
+ }
+ }
+
+
+ // Prikaze izbiro med vsemi tabelami
+ function displayMCTables(){
+ global $site_path;
+ global $global_user_id;
+ global $lang;
+
+ // Trenutna aktivna tabela
+ $sql = sisplet_query("SELECT * FROM srv_mc_table WHERE id='$this->table_id' AND ank_id='$this->ank_id' AND usr_id='$global_user_id'");
+ $current_table = mysqli_fetch_array($sql);
+
+ echo '<h2>'.$lang['srv_multicrosstabs_tables'].'</h2>';
+
+
+ echo '<div id="mc_tables_left">';
+
+ // Prednastavljen profil
+ echo '<span id="mc_tables" class="mc_tables select">';
+
+ $mc_tables = $this->getTables();
+ foreach($mc_tables as $table){
+ echo '<div class="option'.($this->table_id == $table['id'] ? ' active' : '').'" id="mc_table_'.$table['id'].'" value="'.$table['id'].'">'.$table['name'].'</div>';
+ }
+
+ echo '</span>';
+
+
+ // Na dnu imamo gumba brisi in preimenuj
+ echo '<div style="float:left;">';
+ echo '<a href="#" onclick="mc_table_action(\'show_rename\'); return false;">'.$lang['srv_multicrosstabs_tables_rename'].'</a><br/>'."\n";
+ echo '<a href="#" onclick="mc_table_action(\'show_delete\'); return false;">'.$lang['srv_multicrosstabs_tables_delete'].'</a>'."\n";
+ echo '</div>';
+
+
+ // Cas kreirranja tabele
+ echo '<div style="float:right; text-align:right;">';
+ $time_created = strtotime($current_table['time_created']);
+ echo $lang['srv_multicrosstabs_tables_time'].': <span class="bold">'.date("d.m.Y H:i", $time_created).'</span><br />';
+ echo '</div>';
+
+ echo '</div>';
+
+
+ // cover Div
+ echo '<div id="dsp_cover_div"></div>'."\n";
+
+ echo '<span class="clr"></span>';
+
+ echo '<div style="position:absolute; bottom:15px; right:15px;">';
+
+ //echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="save_creport_profile(); return false;"><span>'.$lang['save'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="use_mc_table(); return false;"><span>'.$lang['srv_multicrosstabs_tables_use'].'</span></a></div></span>';
+ echo '<span class="floatRight spaceRight" title="'.$lang['srv_multicrosstabs_tables_add'].'"><div class="buttonwrapper"><a class="ovalbutton" href="#" onclick="mc_table_action(\'show_new\'); return false;"><span>'.$lang['srv_multicrosstabs_tables_add'] . '</span></a></div></span>';
+ echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton" href="#" onclick="close_mc_tables(); return false;"><span>'.$lang['srv_zapri'].'</span></a></div></span>';
+
+ echo '</div>';
+ }
+
+ function displayMCTablesPopups(){
+ global $lang;
+
+ // div za kreacijo novega
+ echo '<div id="newMCTable">';
+
+ echo '<h2>'.$lang['srv_new_table'].'</h2>';
+
+ echo '<div style="float:left; width:400px; text-align:right;">'.$lang['srv_multicrosstabs_tables_name'].': '."\n";
+ echo '<input id="newMCTableName" name="newMCTableName" type="text" value="" size="50" /></div>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="mc_table_action(\'new\'); return false;"><span>'.$lang['save'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="mc_table_action(\'cancel_new\'); return false;"><span>'.$lang['srv_zapri'].'</span></a></span></span>'."\n";
+ echo '<div class="floatRight clr" style="padding: 15px 5px 15px 0;"><a href="#" onClick="mc_table_action(\'goto_archive\');">'.$lang['srv_analiza_arhiv'].'</a></div>';
+ echo '</div>'."\n";
+
+ // div za preimenovanje
+ echo '<div id="renameMCTable">'.$lang['srv_multicrosstabs_tables_name'].': '."\n";
+ echo '<input id="renameMCTableName" name="renameMCTableName" type="text" size="45" />'."\n";
+ echo '<input id="renameMCTableId" type="hidden" value="' . $this->table_id . '" />'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="mc_table_action(\'rename\'); return false;"><span>'.$lang['srv_multicrosstabs_tables_rename_short'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="mc_table_action(\'cancel_rename\'); return false;"><span>'.$lang['srv_zapri'].'</span></a></span></span>'."\n";
+ echo '</div>'."\n";
+
+ // div za brisanje
+ echo '<div id="deleteMCTable">'.$lang['srv_multicrosstabs_tables_delete_confirm'].': <span id="deleteMCTableName" style="font-weight:bold;"></span>?'."\n";
+ echo '<input id="deleteMCTableId" type="hidden" value="' . $this->table_id . '" />'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_orange" href="#" onclick="mc_table_action(\'delete\'); return false;"><span>'.$lang['srv_multicrosstabs_tables_delete_short'].'</span></a></span></span>'."\n";
+ echo '<span class="floatRight spaceLeft" ><span class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onclick="mc_table_action(\'cancel_delete\'); return false;"><span>'.$lang['srv_zapri'].'</span></a></span></span>'."\n";
+ echo '</div>'."\n";
+ }
+
+ // Vrnemo vse tabele uporabnika
+ public function getTables(){
+ global $global_user_id;
+
+ $mc_tables = array();
+
+ $sql = sisplet_query("SELECT * FROM srv_mc_table WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' ORDER BY time_created ASC");
+ while($row = mysqli_fetch_array($sql)){
+ $mc_tables[] = $row;
+ }
+
+ return $mc_tables;
+ }
+
+
+ function ajax(){
+ global $lang;
+ global $global_user_id;
+
+ $this->getVariableList();
+
+ if (isset ($_POST['anketa']))
+ $this->ank_id = $_POST['anketa'];
+
+ if (isset($_POST['table_id']))
+ $this->table_id = $_POST['table_id'];
+
+
+ if ($_GET['a'] == 'add_variable') {
+
+ if (isset($_POST['spr'])) $spr = $_POST['spr'];
+ if (isset($_POST['parent'])) $parent = $_POST['parent'];
+ if (isset($_POST['position'])) $position = $_POST['position'];
+
+ // Dobimo vrstni red
+ $sql = sisplet_query("SELECT COUNT(id) AS cnt FROM srv_mc_element WHERE table_id='$this->table_id' AND parent='$parent' AND position='$position'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['cnt'];
+
+ sisplet_query("INSERT INTO srv_mc_element (table_id, spr, parent, vrstni_red, position) VALUES('$this->table_id', '$spr', '$parent', '$vrstni_red', '$position')");
+
+ $this->displayTable();
+ }
+
+ if ($_GET['a'] == 'remove_variable') {
+
+ if (isset($_POST['vrstni_red'])) $vrstni_red = $_POST['vrstni_red'];
+ if (isset($_POST['position'])) $position = $_POST['position'];
+ if (isset($_POST['parent'])) $parent = $_POST['parent'];
+
+ // Ce brisemo element na 1. nivoju
+ if($parent == 'undefined'){
+ // Pobrisemo element
+ sisplet_query("DELETE FROM srv_mc_element WHERE table_id='$this->table_id' AND position='$position' AND vrstni_red='$vrstni_red' AND parent=''");
+
+ // Pobrisemo se vse childe
+ sisplet_query("DELETE FROM srv_mc_element WHERE table_id='$this->table_id' AND position='$position' AND parent='$vrstni_red'");
+
+ // Popravimo vrstni red ostalih
+ sisplet_query("UPDATE srv_mc_element SET vrstni_red=vrstni_red-1 WHERE table_id='$this->table_id' AND position='$position' AND vrstni_red>'$vrstni_red' AND parent=''");
+
+ // Popravimo parente pri childih
+ sisplet_query("UPDATE srv_mc_element SET parent=parent-1 WHERE table_id='$this->table_id' AND position='$position' AND parent>'$vrstni_red' AND parent!=''");
+ }
+ // Brisemo element na 2. nivoju
+ else{
+ // Pobrisemo element
+ sisplet_query("DELETE FROM srv_mc_element WHERE table_id='$this->table_id' AND position='$position' AND vrstni_red='$vrstni_red' AND parent='$parent'");
+
+ // Popravimo vrstni red ostalih childov
+ sisplet_query("UPDATE srv_mc_element SET vrstni_red=vrstni_red-1 WHERE table_id='$this->table_id' AND position='$position' AND vrstni_red>'$vrstni_red' AND parent='$parent'");
+ }
+
+
+ $this->displayTable();
+ }
+
+ if ($_GET['a'] == 'change_settings') {
+
+ if (isset($_POST['what'])) $what = $_POST['what'];
+ if (isset($_POST['value'])) $value = $_POST['value'];
+
+ $this->table_settings[$this->table_id][$what] = $value;
+ sisplet_query("UPDATE srv_mc_table SET $what='$value' WHERE table_id='$this->table_id'");
+
+
+ $this->displayTable();
+ }
+
+ if ($_GET['a'] == 'edit_title') {
+
+ $value = isset($_POST['value']) ? $_POST['value'] : '';
+
+ sisplet_query("UPDATE srv_mc_table SET title='$value' WHERE id='$this->table_id'");
+ }
+
+ if ($_GET['a'] == 'save_settings') {
+
+ $this->table_settings[$this->table_id]['numerus'] = (isset($_POST['numerus'])) ? $_POST['numerus'] : 0;
+ $this->table_settings[$this->table_id]['percent'] = (isset($_POST['percent'])) ? $_POST['percent'] : 0;
+ $this->table_settings[$this->table_id]['sums'] = (isset($_POST['sums'])) ? $_POST['sums'] : 0;
+
+ $this->table_settings[$this->table_id]['navVsEno'] = (isset($_POST['navVsEno'])) ? $_POST['navVsEno'] : 0;
+
+ $this->table_settings[$this->table_id]['avgVar'] = (isset($_POST['avgVar']) && isset($_POST['avgSetting'])) ? $_POST['avgVar'] : '';
+
+ $this->table_settings[$this->table_id]['delezVar'] = (isset($_POST['delezVar']) && isset($_POST['delezSetting'])) ? $_POST['delezVar'] : '';
+ // Ce imamo nastavljeno variablo za delez loopamo cez njene opcije in pogledamo katere so checkane
+ if($this->table_settings[$this->table_id]['delezVar'] != ''){
+ $delez = array();
+ $cnt = 0;
+ foreach($this->variablesList[$this->table_settings[$this->table_id]['delezVar']]['options'] as $option){
+ $val = (isset($_POST['delez_'.$cnt])) ? $_POST['delez_'.$cnt] : 0;
+ $delez[$cnt] = $val;
+ $cnt++;
+ }
+ $this->table_settings[$this->table_id]['delez'] = serialize($delez);
+ }
+ else{
+ $this->table_settings[$this->table_id]['delez'] = '';
+ }
+
+
+ $sql = sisplet_query("UPDATE srv_mc_table SET
+ numerus='".$this->table_settings[$this->table_id]['numerus']."',
+ percent='".$this->table_settings[$this->table_id]['percent']."',
+ sums='".$this->table_settings[$this->table_id]['sums']."',
+ navVsEno='".$this->table_settings[$this->table_id]['navVsEno']."',
+ avgVar='".$this->table_settings[$this->table_id]['avgVar']."',
+ delezVar='".$this->table_settings[$this->table_id]['delezVar']."',
+ delez='".$this->table_settings[$this->table_id]['delez']."'
+ WHERE id='".$this->table_id."'");
+ if(!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $this->displayTable();
+ }
+
+ if ($_GET['a'] == 'set_delez') {
+
+ //$this->table_settings[$this->table_id]['delezVar'] = (isset($_POST['delezVar'])) ? $_POST['delezVar'] : '';
+ $delezVar = (isset($_POST['delezVar'])) ? $_POST['delezVar'] : '';
+
+ $this->displayDelez($delezVar);
+ }
+
+ if ($_GET['a'] == 'mc_show_tables'){
+
+ $this->displayMCTables();
+ }
+
+ if ($_GET['a'] == 'use_mc_table'){
+
+ $value = isset($_POST['value']) ? $_POST['value'] : $this->table_id;
+ SurveyUserSetting :: getInstance()->saveSettings('default_mc_table', $value);
+ }
+
+ if ($_GET['a'] == 'rename_table'){
+
+ $id = isset($_POST['id']) ? $_POST['id'] : '';
+ $name = isset($_POST['name']) ? $_POST['name'] : '';
+ sisplet_query("UPDATE srv_mc_table SET name='$name' WHERE id='$id' AND ank_id='$this->ank_id' AND usr_id='$global_user_id'");
+
+ $this->displayMCTables();
+ }
+
+ if ($_GET['a'] == 'delete_table'){
+
+ $id = isset($_POST['id']) ? $_POST['id'] : '';
+ sisplet_query("DELETE FROM srv_mc_table WHERE id='$id' AND ank_id='$this->ank_id' AND usr_id='$global_user_id'");
+
+ // Preklopimo na prvo tabelo
+ $sql = sisplet_query("SELECT id FROM srv_mc_table WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' ORDER BY time_created ASC");
+ $row = mysqli_fetch_array($sql);
+
+ $this->table_id = $row['id'];
+ SurveyUserSetting :: getInstance()->saveSettings('default_mc_table', $row['id']);
+
+ $this->displayMCTables();
+ }
+
+ if ($_GET['a'] == 'new_table'){
+
+ $name = isset($_POST['name']) ? $_POST['name'] : '';
+ sisplet_query("INSERT INTO srv_mc_table (ank_id, usr_id, time_created, name) VALUES('$this->ank_id', '$global_user_id', NOW(), '$name')");
+ $table_id = mysqli_insert_id($GLOBALS['connect_db']);
+
+ $this->table_id = $table_id;
+ SurveyUserSetting :: getInstance()->saveSettings('default_mc_table', $table_id);
+ }
+
+ if ($_GET['a'] == 'mc_change_table'){
+
+ $id = isset($_POST['id']) ? $_POST['id'] : $this->table_id;
+ $this->table_id = $id;
+
+ $this->displayMCTables();
+ }
+ }
+
+
+ // Skrajsa tekst in doda '...' na koncu
+ function snippet($text, $length=64, $tail="..."){
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return strip_tags($text);
+ }
+
+ /** Naredimo formatiran izpis
+ *
+ * @param $value
+ * @param $digit
+ * @param $sufix
+ */
+ static function formatNumber ($value, $digit = 0, $sufix = "") {
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+ # polovimo decimalna mesta in vejice za tisočice
+
+ $decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+
+ $result = number_format($result, $digit, $decimal_point, $thousands) . $sufix;
+
+ return $result;
+ }
+
+ function getCrossTabPercentage ($sum, $value) {
+ $result = 0;
+ if ($value ) {
+ $result = (int)$sum == 0 ? 0 : $value / $sum * 100;
+ }
+
+ return $result;
+ }
+
+ /** Sestavi array nepravilnih odgovorov
+ *
+ */
+ function getInvalidAnswers($type) {
+ $result = array();
+ $missingValuesForAnalysis = SurveyMissingProfiles :: GetMissingValuesForAnalysis($type);
+
+ foreach ($missingValuesForAnalysis AS $k => $answer) {
+ $result[$k] = array('text'=>$answer,'cnt'=>0);
+ }
+ return $result;
+ }
+
+
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyTTest.php b/admin/survey/classes/surveyAnalysis/class.SurveyTTest.php
new file mode 100644
index 0000000..34819a1
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyTTest.php
@@ -0,0 +1,1207 @@
+<?php
+/** Class ki skrbi za T-test
+ * December 2011
+ *
+ *
+ * Enter description here ...
+ * @author Gorazd_Veselic
+ *
+ */
+
+define("EXPORT_FOLDER", "admin/survey/SurveyData");
+define("BC_PRECISION", 20);
+define("R_FOLDER", "admin/survey/R");
+
+class SurveyTTest
+{
+ private $sid; # id ankete
+ private $db_table; # katere tabele uporabljamo
+ public $_HEADERS = array(); # shranimo podatke vseh variabel
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $SDF = null; # class za osnovne funkcije data fajla
+
+ public $variablesList = null; # Seznam vseh variabel nad katerimi lahko izvajamo crostabulacije (zakeširamo)
+
+ public $showChart = false; # ali prikazujemo graf pod tabelo
+
+ private $sessionData; # podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+
+ function __construct($sid) {
+
+ if ((int)$sid > 0) {
+ $this->sid = $sid;
+
+ # polovimo vrsto tabel (aktivne / neaktivne)
+ SurveyInfo :: getInstance()->SurveyInit($this->sid);
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) {
+ $this->db_table = '_active';
+ }
+
+
+ # Inicializiramo in polovimo nastavitve missing profila
+ SurveyStatusProfiles::Init($this->sid);
+ SurveyUserSetting::getInstance()->Init($this->sid, $global_user_id);
+
+ SurveyStatusProfiles :: Init($this->sid);
+ SurveyMissingProfiles :: Init($this->sid,$global_user_id);
+ SurveyConditionProfiles :: Init($this->sid, $global_user_id);
+ SurveyZankaProfiles :: Init($this->sid, $global_user_id);
+ SurveyTimeProfiles :: Init($this->sid, $global_user_id);
+ SurveyVariablesProfiles :: Init($this->sid);
+
+ SurveyDataSettingProfiles :: Init($this->sid);
+
+ #inicializiramo class za datoteke
+ $this->SDF = SurveyDataFile::get_instance();
+ $this->SDF->init($this->sid);
+ $this->headFileName = $this->SDF->getHeaderFileName();
+ $this->dataFileName = $this->SDF->getDataFileName();
+ $this->dataFileStatus = $this->SDF->getStatus();
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->sid);
+ $this->sessionData = SurveyUserSession::getData();
+
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA || $this->dataFileStatus == FILE_STATUS_NO_FILE || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ Common::noDataAlert();
+ exit();
+ }
+
+ if ($this->headFileName !== null && $this->headFileName != '') {
+ $this->_HEADERS = unserialize(file_get_contents($this->headFileName));
+ }
+
+ # nastavimo vse filtre
+ $this->setUpFilter();
+
+ } else {
+ echo 'Invalid Survey ID!';
+ exit();
+ }
+ }
+
+ function ajax() {
+
+ if ( isset($_POST['spr2'])) {
+ # če imamo novo spremenljivko, pobrišemo staro sejo
+ if (isset($this->sessionData['ttest']['spr2']) && $this->sessionData['ttest']['spr2'] != $_POST['spr2']) {
+ $this->sessionData['ttest'] = null;
+ unset($this->sessionData['ttest']);
+ }
+ $this->sessionData['ttest']['spr2'] = $_POST['spr2'];
+ }
+ if ( isset($_POST['grid2'])) {
+ $this->sessionData['ttest']['grid2'] = $_POST['grid2'];
+ }
+ if ( isset($_POST['seq2'])) {
+ $this->sessionData['ttest']['seq2'] = $_POST['seq2'];
+ }
+ if ( isset($_POST['label2'])) {
+ $this->sessionData['ttest']['label2'] = $_POST['label2'];
+ }
+ if ( isset($_POST['sub_conditions'])) {
+ $this->sessionData['ttest']['sub_conditions'] = $_POST['sub_conditions'];
+ }
+
+ if ( isset($_POST['seq'])) {
+ $i=0;
+ if (count($_POST['seq']) > 0) {
+ foreach ($_POST['seq'] AS $_seq1) {
+ $this->sessionData['ttest']['variabla'][$i]['seq'] = $_seq1;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['spr'])) {
+ $i=0;
+ if (count($_POST['spr']) > 0) {
+ foreach ($_POST['spr'] AS $_spr1) {
+ $this->sessionData['ttest']['variabla'][$i]['spr'] = $_spr1;
+ $i++;
+ }
+ }
+ }
+ if ( isset($_POST['grd'])) {
+ $i=0;
+ if (count($_POST['grd']) > 0) {
+ foreach ($_POST['grd'] AS $_grd1) {
+ $this->sessionData['ttest']['variabla'][$i]['grd'] = $_grd1;
+ $i++;
+ }
+ }
+ }
+
+ if ( isset($_POST['showChart'])) {
+ $this->sessionData['ttest_charts']['showChart'] = ($_POST['showChart'] == 'true');
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ # izvedemo akcijo
+ switch ($_GET['a']) {
+ case 'spremenljivkaChange':
+ $this->spremenljivkaChange();
+ break;
+ case 'variableChange':
+ $this->variableChange();
+ break;
+ default:
+ break;
+ }
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function Display() {
+
+ # ali imamo testne podatke
+ if ($this->_HAS_TEST_DATA) {
+ # izrišemo bar za testne podatke
+ $SSH -> displayTestDataBar(true);
+ $SSH = new SurveyStaticHtml($this->sid);
+ }
+
+ /*echo '<div id="dataOnlyValid">';
+ SurveyStatusProfiles::displayOnlyValidCheckbox();
+ echo '</div>';*/
+
+ //$this->DisplayLinks();
+
+ echo '<div id="ttest_variables">';
+ $this->DisplayVariables();
+ echo '</div>'; # id="ttest_variables"
+ echo '<br class="clr">';
+ echo '<div id="ttestResults">';
+ $this->variableChange();
+ echo '</div>'; # id="ttestResults"
+ }
+
+ // Izvoz pdf in rtf
+ function displayExport () {
+
+ $variables2 = $this->getSelectedVariables() ;
+ if (is_array($variables2) && count($variables2)>0 ) {
+
+ $href_pdf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=ttest_izpis&anketa=' . $this->sid);
+ $href_rtf = makeEncodedIzvozUrlString('izvoz.php?b=export&m=ttest_izpis_rtf&anketa=' . $this->sid);
+ $href_xls = makeEncodedIzvozUrlString('izvoz.php?b=export&m=ttest_izpis_xls&anketa=' . $this->sid);
+
+ echo '<script>';
+ # nastavimopravilne linke
+ echo '$("#secondNavigation_links a#ttestDoPdf").attr("href", "'.$href_pdf.'");';
+ echo '$("#secondNavigation_links a#ttestDoRtf").attr("href", "'.$href_rtf.'");';
+ echo '$("#secondNavigation_links a#ttestDoXls").attr("href", "'.$href_xls.'");';
+ # prikažemo linke
+ echo '$("#hover_export_icon").removeClass("hidden");';
+ echo '$("#secondNavigation_links a").removeClass("hidden");';
+ echo '</script>';
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function DisplayLinks() {
+ # izrišemo navigacijo za analize
+ $SSH = new SurveyStaticHtml($this->sid);
+ //$SSH -> displayAnalizaSubNavigation();
+
+ # izrišemo desne linke do posameznih nastavitev
+ $SSH -> displayAnalizaRightOptions(M_ANALYSIS_TTEST);
+ }
+
+
+ /** Funkcija ki nastavi vse filtre
+ *
+ */
+ private function setUpFilter() {
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ return false;
+ }
+
+ # poiščemo kater profil uporablja uporabnik
+ $_currentMissingProfile = SurveyUserSetting :: getInstance()->getSettings('default_missing_profile');
+ $this->currentMissingProfile = (isset($_currentMissingProfile) ? $_currentMissingProfile : 1);
+
+ # filtriranje po statusih
+ $this->_CURRENT_STATUS_FILTER = SurveyStatusProfiles :: getStatusAsAWKString();
+
+ # filtriranje po časih
+ $_time_profile_awk = SurveyTimeProfiles :: getFilterForAWK($this->_HEADERS['unx_ins_date']['grids']['0']['variables']['0']['sequence']);
+
+ # dodamo še ife
+
+ SurveyConditionProfiles :: setHeader($this->_HEADERS);
+ $_condition_profile_AWK = SurveyConditionProfiles:: getAwkConditionString();
+
+ if (($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) || ($_time_profile_awk != "" && $_time_profile_awk != null)) {
+ $this->_CURRENT_STATUS_FILTER = '('.$this->_CURRENT_STATUS_FILTER;
+ if ($_condition_profile_AWK != "" && $_condition_profile_AWK != null ) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_condition_profile_AWK;
+ }
+ if ($_time_profile_awk != "" && $_time_profile_awk != null) {
+ $this->_CURRENT_STATUS_FILTER .= ' && '.$_time_profile_awk;
+ }
+ $this->_CURRENT_STATUS_FILTER .= ')';
+ }
+
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+
+ if ($this->dataFileStatus == FILE_STATUS_OK || $this->dataFileStatus == FILE_STATUS_OLD) {
+
+ if (isset($this->_HEADERS['testdata'])) {
+ $this->_HAS_TEST_DATA = true;
+ }
+ }
+ }
+
+ function DisplayVariables() {
+ global $lang;
+
+ $numerus = $this->getVariableList(1);
+ $selectedVar = $this->getSelectedVariables();
+
+ $variables = $this->getVariableList(2);
+
+ echo '<span id="ttestSpremenljivkaSpan" class="floatLeft">';
+ echo $lang['srv_ttest_label1'];
+ echo '<br />';
+
+ echo '<select id="ttestSpremenljivka" name="ttestSpremenljivka" onchange="ttestSpremenljivkaChange();" autocomplete="off">';
+ echo '<option value="0" selected="selected" >'. $lang['srv_ttest_select1_option'] . '</option>';
+ if (count($variables)) {
+ foreach ($variables as $variable) {
+ echo '<option value="'.$variable['spr_id'].'"'
+ . ( isset($variable['grd_id']) ? ' grid="'.$variable['grd_id'].'" ' : '')
+ . ( isset($variable['vr_id']) ? ' vred="'.$variable['vr_id'].'" ' : '')
+ . ( isset($variable['sequence']) ? ' seq2="'.$variable['sequence'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . ( $variable['spr_id'] != '' && $variable['spr_id'] == $this->sessionData['ttest']['spr2'] && $variable['sequence'] == $this->sessionData['ttest']['seq2'] ? ' selected="selected"':'')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ .$variable['variableNaslov'] . '</option>';
+ }
+ }
+ echo '</select>'; # name="ttestSpremenljivka"
+ echo '<br class="clr"/><br/>';
+ #.(count($this->sessionData['ttest']['sub_conditions']) == 2?'':'class="active"').
+ $_active = $this->checkSubConditionsActive();
+ if ($this->sessionData['ttest']['spr2'] > 0) {
+ echo '<div id="ttestVariablesSpan"'.($_active < 2 ? ' class="active"' : '').'>';
+ $this->spremenljivkaChange();
+ echo '</div>';
+ } else {
+ echo '<div id="ttestVariablesSpan" style="display:none" '.($_active < 2 ? ' class="active"' : '').'></div>';
+ }
+ echo '</span>';
+
+ $cntSubConditionsActive = $this->checkSubConditionsActive();
+ echo '<span class="floatLeft spaceRight">&nbsp;</span>';
+ echo '<span id="ttestNumerusSpan" class="floatLeft'.($cntSubConditionsActive == 2 ? '' : ' gray').'">'; #gray
+ echo $lang['srv_ttest_label2'];
+ echo '<br />';
+ echo '<select id="ttestNumerus" name="ttestNumerus" onchange="ttestVariableChange();" autocomplete="off" '.($cntSubConditionsActive == 2 ? '' : ' disabled="disabled"').'>'; #
+ echo '<option value="0" selected="selected" >'. $lang['srv_ttest_select2_option'] . '</option>';
+ if (count($numerus)) {
+ foreach ($numerus as $variable) {
+ echo '<option value="'.$variable['spr_id'].'"'
+ . ( isset($variable['grd_id']) ? ' grd="'.$variable['grd_id'].'" ' : '')
+ . ( isset($variable['vr_id']) ? ' vrd="'.$variable['vr_id'].'" ' : '')
+ . ( isset($variable['sequence']) ? ' seq="'.$variable['sequence'].'" ' : '')
+ . (( (int)$variable['canChoose'] == 1) ? '' : ' disabled="disabled" ')
+ . ( $variable['spr_id'] != '' && $variable['spr_id'] == $selectedVar[0]['spr'] && $variable['sequence'] == $selectedVar[0]['seq']?' selected="selected"':'')
+ . '> '
+ . ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' ))
+ . $variable['variableNaslov'] . '</option>';
+ }
+ }
+ echo '</select>'; # name="ttestSpremenljivka"
+ echo '</span>';
+
+ echo '<br /><span style="margin-left: 30px;">';
+ echo '<label><input id="showChart" type="checkbox" onchange="showTableChart(\'ttest\');" '.($this->sessionData['ttest_charts']['showChart']==true?' checked="checked"':'' ).'>'.$lang['srv_show_chart'].'</label>';
+ echo '</span>';
+ echo '<span style="margin-left: 30px;"><a href="https://www.1ka.si/d/sl/pomoc/prirocniki/ttest?from1ka=1" target="_blank">';
+ echo $lang['srv_ttest_interpretacija_note'];
+ echo '</a></span>';
+ echo Help::display('srv_ttest_interpretation');
+
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ /** funkcija vrne seznam primern variabel za crostabe
+ *
+ */
+ function getVariableList($witch) {
+ # pobrišemo array()
+ $this->variablesList = array();
+ # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence)
+ foreach ($this->_HEADERS AS $skey => $spremenljivka) {
+ $tip = $spremenljivka['tip'];
+ if ($witch == 1) {
+ # prvi drop down, morajo biti numerične ali ordinalne
+ # skala - 0 Ordinalna
+ # skala - 1 Nominalna
+
+ $skala = isset($spremenljivka['skala']) ? $spremenljivka['skala'] : 1;
+
+ # če radio nimajo podane skale jo damo na 0
+ $skala = ($skala == -1 && ($tip == 6 || $tip == 16) ) ? 0 : $skala ;
+
+ $_dropdown_condition = is_numeric($tip) && ((int)$skala === 0 # ordinalna
+ || $tip == 7 # number
+ || $tip == 18 # vsota
+ || $tip == 20) # multi number
+ ? true : false;
+ } else {
+ #drugi dropdown
+ # tekstovnih in numeričnih tipov ne dodajamo
+ $_dropdown_condition = is_numeric($tip) && $tip != 4 #text
+ && $tip != 5 #label
+ && $tip != 7 #number
+ && $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ && $tip != 18 #vsota
+ && $tip != 19 #multitext
+ && $tip != 20 #multinumber
+ && $tip != 21 #besedilo*
+ && $tip != 22 #compute
+ && $tip != 25 #kvota
+ ? true : false;
+ }
+ if ($_dropdown_condition) {
+ $cnt_all = (int)$spremenljivka['cnt_all'];
+ # radio in select in checkbox
+ if ($cnt_all == '1' || $tip == 1 || $tip == 3 || $tip == 2) {
+ # pri tipu radio ali select dodamo tisto variablo ki ni polje "drugo"
+ if ($tip == 1 || $tip == 3 ) {
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][$vid]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+
+ }
+ }
+ }
+ }
+ } else if ($tip == 2){
+ if ($witch == 1) {
+ #pri checkboxu ponudimo vsako podvariablo posebej
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # imampo samo eno sekvenco grids[0]
+ if (count ($spremenljivka['grids'][0]['variables']) > 0) {
+
+ foreach ($spremenljivka['grids'][0]['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'vr_id'=>$vid,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } else {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+
+ } else {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+
+ } else if ($cnt_all > 1){
+ # imamo več skupin ali podskupin, zato zlopamo skozi gride in variable
+ if (count($spremenljivka['grids']) > 0 ) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # ali imamo en grid, ali več (tabele
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } else if($tip == 16||$tip == 18) {
+ # imamo multicheckbox
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>$gid,
+ 'sequence'=>$grid['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ } else {
+ # imamo več gridov - tabele
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>$sub);
+ }
+ if (count ($grid['variables']) > 0) {
+ $sub++;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $this->variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>$sub);
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ return $this->variablesList;
+ }
+
+
+ function spremenljivkaChange() {
+ global $lang;
+
+ if (isset($this->sessionData['ttest']['spr2']) && $this->sessionData['ttest']['spr2'] != 0){
+ $_spr = explode('_',$this->sessionData['ttest']['spr2']);
+ #$spr = $_spr[0];
+ $spr = $this->sessionData['ttest']['spr2'];
+
+ if (isset($this->sessionData['ttest']['grid2'])){
+ $grid = $this->sessionData['ttest']['grid2'];
+ }
+ # poiščemo pripadajoče variable
+ $_spr_data = $this->_HEADERS[$this->sessionData['ttest']['spr2']];
+ echo $lang['srv_ttest_kategories_note'].' ('.$_spr_data['variable'].') '.$_spr_data['naslov'];
+ echo '<br/>';
+ switch ($_spr_data['tip']) {
+ case 1: #radio
+ case 3: #dropdown
+ case 17: #dropdown
+ #nardimo inpute za vse opcije
+ $sekvenca = $_spr_data['sequences'];
+ foreach ($_spr_data['options'] as $value => $option) {
+ echo '<label '.($this->checkboxSubCondition($spr.'_'.$sekvenca.'_'.$value) == ' disabled="disabled"' ? 'class="gray"' : '').'><input name="subTtest" type="checkbox" value="'.$spr.'_'.$sekvenca.'_'.$value.'" onchange="ttestVariableChange();"'.$this->checkboxSubCondition($spr.'_'.$sekvenca.'_'.$value).'/>('.$value.') - '.$option.'</label><br/>';
+ }
+ break;
+ case 2: #checkbox
+ #nardimo inpute za vse opcije
+ $option = '1';
+ foreach ($_spr_data['grids'][0]['variables'] as $vid => $variable) {
+ echo '<label '.($this->checkboxSubCondition($spr.'_'.$variable['sequence'].'_'.$option) == ' disabled="disabled"' ? 'class="gray"' : '').'><input name="subTtest" type="checkbox" value="'.$spr.'_'.$variable['sequence'].'_'.$option. '" onchange="ttestVariableChange();"'.$this->checkboxSubCondition($spr.'_'.$variable['sequence'].'_'.$option).'/>('.$variable['variable'].') - '.$variable['naslov'].'</label><br/>';
+ }
+ break;
+ case 6: #mgrid
+ #nardimo inpute za vse opcije
+ $sekvenca = $this->sessionData['ttest']['seq2'];
+ foreach ($_spr_data['options'] as $value => $option) {
+ //$sekvenca = $_spr_data['grids'][$value]['variables'][0]['sequence'];
+ echo '<label '.($this->checkboxSubCondition($spr.'_'.$sekvenca.'_'.$value) == ' disabled="disabled"' ? 'class="gray"' : '').'><input name="subTtest" type="checkbox" value="'.$spr.'_'.$sekvenca.'_'.$value.'" onchange="ttestVariableChange();"'.$this->checkboxSubCondition($spr.'_'.$sekvenca.'_'.$value).'/>('.$value.') - '.$option.'</label><br/>';
+ }
+ break;
+ case 16: #mcheck
+ #nardimo inpute za vse opcije
+ # poiščemo pripadajočo sekvenco
+ #nardimo inpute za vse opcije
+ $option = '1';
+ foreach ($_spr_data['grids'][$grid]['variables'] as $vid => $variable) {
+ echo '<label '.($this->checkboxSubCondition($spr.'_'.$variable['sequence'].'_'.$option) == ' disabled="disabled"' ? 'class="gray"' : '').'><input name="subTtest" type="checkbox" value="'.$spr.'_'.$variable['sequence'].'_'.$option.'" onchange="ttestVariableChange();"'.$this->checkboxSubCondition($spr.'_'.$variable['sequence'].'_'.$option).'/>('.$variable['variable'].') - '.$variable['naslov'].'</label><br/>';
+ }
+ break;
+
+ default:
+ if ((int)$_spr_data['tip'] > 0)
+ echo'TODO for type:'.$_spr_data['tip'];
+ break;
+ }
+ } else if ($this->sessionData['ttest']['spr2'] == 0){
+
+
+ echo $lang['srv_ttest_select1_option'].'!';
+ echo '<br/>';
+
+
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function variableChange() {
+ global $admin_type;
+
+ if (count($this->sessionData['ttest']['sub_conditions']) > 1 ) {
+ $variables1 = $this->getSelectedVariables();
+ if (count($variables1) > 0) {
+ // ikone za izvoz
+ $this->displayExport();
+ foreach ($variables1 AS $v_first) {
+
+ $ttest = null;
+ /*$ttest = $this->createTTestOld($v_first, $this->sessionData['ttest']['sub_conditions']);
+ $this->displayTtestTable($ttest);*/
+ $ttest = $this->createTTest($v_first, $this->sessionData['ttest']['sub_conditions']);
+ $this->displayTtestTable($ttest);
+
+ // Zvezdica za vkljucitev v porocilo
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+ $sub1 = $this->sessionData['ttest']['sub_conditions'][0];
+ $sub2 = $this->sessionData['ttest']['sub_conditions'][1];
+
+ $spid2 = $this->sessionData['ttest']['spr2'];
+ $seq2 = $this->sessionData['ttest']['seq2'];
+ $grid2 = $this->sessionData['ttest']['grid2'];
+
+ $spr1 = $seq2.'-'.$spid2.'-'.$grid2.'-'.$sub1.'-'.$sub2;
+ $spr2 = $seq1.'-'.$spid1.'-'.$grid1;
+ SurveyAnalysis::addCustomReportElement($type=7, $sub_type=0, $spr1, $spr2);
+
+ // Izrisemo graf za tabelo
+ if(isset($this->sessionData['ttest_charts']['showChart']) && $this->sessionData['ttest_charts']['showChart'] == true){
+ $tableChart = new SurveyTableChart($this->sid, $this, 'ttest');
+ $tableChart->display();
+ }
+ }
+ }
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ function getSelectedVariables() {
+
+ $selected = array();
+ if (count($this->sessionData['ttest']['variabla']) > 0 ) {
+ foreach ($this->sessionData['ttest']['variabla'] AS $var1) {
+ if ((int)$var1['seq'] > 0) {
+ $selected[] = $var1;
+ }
+ }
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ return count($selected) > 0 ? $selected : null;
+ }
+
+
+ function createTTest($v_first, $sub_vars) {
+ global $site_path;
+
+ $folder = $site_path . EXPORT_FOLDER.'/';
+ $R_folder = $site_path . R_FOLDER.'/';
+
+ if ($this->dataFileName != '' && file_exists($this->dataFileName)) {
+
+ // Nastavimo stolpce za katere izvajamo ttest
+ $ttestVars = '';
+ $sub_conditions = array();
+ $i=1;
+ foreach ($sub_vars as $sub_condition) {
+ if ($i < 3) {
+ $_tmp = explode('_',$sub_condition);
+ $ttestVars .= '$'.$_tmp[2].',';
+ $sub_conditions[] = $_tmp[3];
+ $i++;
+ }
+ }
+
+ $ttestVars .= '$'.$v_first['seq'].',';
+ $ttestVars = substr($ttestVars, 0, -1);
+
+ // Ce se nimamo datoteke s pripravljenimi podatki jo ustvarimo
+ $tmp_file = $R_folder . '/TempData/crosstab_data.tmp';
+ if (!file_exists($tmp_file)) {
+ $this->prepareDataFile($ttestVars);
+ }
+
+
+ // Inicializiramo R in pozenemo skripto za crosstabulacije
+ $R = new SurveyAnalysisR($this->sid);
+ $result = $R->createTTest($sub_conditions);
+
+ // Na koncu pobrisemo zacasen file s podatki
+ $this->deleteDataFile();
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ return $result;
+ }
+
+ function createTTestOld($v_first, $sub_vars) {
+ global $site_path;
+
+ $folder = $site_path . EXPORT_FOLDER.'/';
+
+ if ($this->dataFileName != '' && file_exists($this->dataFileName)) {
+
+ $spr1 = $this->_HEADERS[$v_first['spr']];
+ $grid1 = $spr1['grids'][$v_first['grd']];
+ $sequence1 = $v_first['seq'];
+
+ # za checkboxe gledamo samo odgovore ki so bili 1 in za vse opcije
+ $sekvences1 = array();
+ $spr_1_checkbox = false;
+
+ if ($spr1['tip'] == 2 || $spr1['tip'] == 16) {
+
+ $spr_1_checkbox = true;
+ if (isset($sequence1) && (int)$sequence1 > 0) {
+ $sekvences1[] = (int)$sequence1;
+ } else {
+ if ($spr1['tip'] == 2) {
+
+ $sekvences1 = explode('_',$spr1['sequences']);
+ }
+ if ($spr1['tip'] == 16) {
+
+ foreach ($grid1['variables'] AS $_variables) {
+ $sekvences1[] = $_variables['sequence'];
+ }
+ }
+ }
+ } else {
+ $sekvences1[] = $sequence1;
+ }
+ # pogoji so že dodani v _CURRENT_STATUS_FILTER
+ # dodamo filter za loop-e
+ if (isset($this->_CURRENT_LOOP['filter']) && $this->_CURRENT_LOOP['filter'] != '') {
+ $status_filter = $this->_CURRENT_STATUS_FILTER.' && '.$this->_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+ }
+
+ # nastavimo subfiltre za drugo variablo
+ $sub_conditions = array();
+ $i=1;
+ foreach ($sub_vars as $sub_condition) {
+ if ($i < 3) {
+ $_tmp = explode('_',$sub_condition);
+ $sub_conditions[$i] = ' && ($'.$_tmp[2].' == '.$_tmp[3].')';
+ $i++;
+ }
+ }
+
+
+ # dodamo status filter za vse sekvence checkbox-a da so == 1
+ if ($additional_status_filter != null) {
+ $status_filter .= $additional_status_filter;
+ }
+
+ # odstranimo vse zapise, kjer katerakoli od variabel vsebuje missing
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ $_pageMissing_answers = $this->getInvalidAnswers (MISSING_TYPE_CROSSTAB);
+
+ # polovimo obe sequenci
+ $tmp_file = $folder . 'tmp_ttest_'.$this->sid.'.TMP';
+ $file_handler = fopen($tmp_file,"w");
+ fwrite($file_handler,"<?php\n");
+ fclose($file_handler);
+ if (count($sekvences1)>0){
+ foreach ($sekvences1 AS $sequence1) {
+ if (count($sub_conditions) > 1) {
+ foreach ($sub_conditions as $subkey =>$sub_condition) {
+
+ #skreira variable: $ttest, $cvar1, $cvar2
+
+ $additional_filter = '';
+ if ($spr_1_checkbox == true) {
+ $_seq_1_text = ''.$sequence1;
+
+ # pri checkboxih gledamo samo kjer je 1 ( ne more bit missing)
+ $additional_filter = ' && ($'.$sequence1.' == 1)';
+ } else {
+ $_seq_1_text = '$'.$sequence1;
+
+ # dodamo še pogoj za missinge
+ foreach ($_pageMissing_answers AS $m_key1 => $missing1) {
+ #$additional_filter .= ' && ($'.$sequence1.' != '.$m_key1.')';
+ }
+ }
+
+ if (IS_WINDOWS) {
+ $command1 = 'awk -F"|" "BEGIN {{OFS=\"\"} {ORS=\"\n\"}} '.$status_filter.$sub_condition.$additional_filter.' { print \"$ttest[\x27\",'.$subkey.',\"\x27][\x27\",'.$_seq_1_text.',\"\x27]++;\"}" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command1 = 'awk -F"|" \'BEGIN {{OFS=""} {ORS="\n"}} '.$status_filter.$sub_condition.$additional_filter.' { print "$ttest[\x27\",'.$subkey.',\"\x27][\x27",'.$_seq_1_text.',"\x27]++;"}\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out = shell_exec($command1);
+ }
+ }
+ }
+ }
+ $file_handler = fopen($tmp_file,"a");
+ fwrite($file_handler,'?>');
+ fclose($file_handler);
+ include($tmp_file);
+ if (file_exists($tmp_file)) {
+ unlink($tmp_file);
+ }
+
+ # naredimo izračune
+ #najprej izračunamo frekvenco in povprečje
+ # zloopamo preko posamezneka pod pogoja
+ $result = array();
+
+ $cnt = 0;
+ if (count($ttest) > 0) {
+ foreach ($ttest AS $subkey => $_ttests) {
+ $cnt++;
+ # zloopamo preko frekvenc in nardimo izračune
+ $sum_all = 0;
+ $n = 0;
+ if(count($_ttests) > 0) {
+ foreach ($_ttests AS $value => $freq) {
+ #$n = bcadd($n,$freq,BC_PRECISION);
+ #$sum_all = bcadd($sum_all,bcmul($value,$freq,BC_PRECISION),BC_PRECISION);
+ $n += $freq;
+ $sum_all += $value * $freq;
+ }
+ }
+ #n = frekvenca
+ #$x = ($n <> 0)
+ # ? bcdiv($sum_all,$n,BC_PRECISION)
+ # : 0;
+
+ $x = ($n <> 0)
+ ? $sum_all / $n
+ : 0;
+
+ $result[$cnt] = array('n'=>$n, 'x'=>$x);
+
+ # izračunamo še standardno diviacijo
+ $sum_pow_xi_fi_avg = 0;
+ if(count($_ttests) > 0) {
+ foreach ($_ttests AS $value => $freq) {
+
+ $xi = $value;
+ $fi = $freq;
+ #$sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ #$sum_pow_xi_fi_avg = bcadd($sum_pow_xi_fi_avg, bcmul(bcpow(bcsub($xi,$x,BC_PRECISION),2,BC_PRECISION),$fi,BC_PRECISION));
+ $sum_pow_xi_fi_avg += pow( ($xi - $x), 2 ) * $fi ;
+ }
+ }
+ #varianca
+ #$s2 = (($n - 1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($n -1)) : 0;
+ #$s2 = (bcsub($n, 1, BC_PRECISION) <> 0)
+ # ? bcsqrt( bcdiv($sum_pow_xi_fi_avg, bcsub($n, 1, BC_PRECISION), BC_PRECISION), BC_PRECISION)
+ # : 0;
+ $s2 = ( $n - 1 <> 0 )
+ ? sqrt( $sum_pow_xi_fi_avg / ($n - 1) )
+ : 0;
+ $result[$cnt]['s2'] = $s2;
+ # standardna napaka
+ #se = s2 / sqrt(n)
+ #$se = $n > 0
+ # ? bcdiv($s2, bcsqrt($n, BC_PRECISION), BC_PRECISION)
+ # : 0;
+ $se = $n > 0
+ ? $s2 / sqrt($n)
+ : 0;
+
+ $result[$cnt]['se'] = $se;
+ #se2 = *se^2
+ #$se2 = bcpow($se, 2, BC_PRECISION);
+ $se2 = pow($se, 2);
+ $result[$cnt]['se2'] = $se2;
+
+ #margini => 1,96*ee
+ #$margin = bcmul(1.96, $se, BC_PRECISION);
+ $margin = 1.96 * $se;
+ $result[$cnt]['margin'] = $margin;
+ }
+ }
+ #razlika povprečij => $d = x1 -x2
+ #$d = bcsub($result[1]['x'], $result[2]['x'], BC_PRECISION);
+ $d = $result[1]['x'] - $result[2]['x'];
+ $result['d'] = $d;
+
+ #sed : std. error difference
+ #$sed = bcsqrt( bcadd($result[1]['se2'], $result[2]['se2'], BC_PRECISION), BC_PRECISION );
+ $sed = sqrt( $result[1]['se2'] + $result[2]['se2']);
+ $result['sed'] = $sed;
+
+ #ttest => t = d / sed
+ #$t = ($sed <> 0)
+ # ? bcdiv($d, $sed, BC_PRECISION)
+ # : 0;
+ $t = ($sed <> 0)
+ ? $d / $sed
+ : 0;
+ $result['t'] = $t;
+
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ return $result;
+ }
+
+ // Pripravimo file iz katerega preberemo podatke in izvedemo ttest
+ function prepareDataFile($cols){
+ global $site_path;
+
+ $folder = $site_path . EXPORT_FOLDER.'/';
+ $R_folder = $site_path . R_FOLDER.'/';
+
+
+ if (isset($this->_CURRENT_LOOP['filter']) && $this->_CURRENT_LOOP['filter'] != '') {
+ $status_filter = $this->_CURRENT_STATUS_FILTER.' && '.$this->_CURRENT_LOOP['filter'];
+ } else {
+ $status_filter = $this->_CURRENT_STATUS_FILTER;
+ }
+
+ # dodamo status filter za vse sekvence checkbox-a da so == 1
+ if ($additional_status_filter != null) {
+ $status_filter .= $additional_status_filter;
+ }
+
+ # odstranimo vse zapise, kjer katerakoli od variabel vsebuje missing
+ $_allMissing_answers = SurveyMissingValues::GetMissingValuesForSurvey(array(1,2,3));
+ $_pageMissing_answers = $this->getInvalidAnswers(MISSING_TYPE_CROSSTAB);
+
+
+ // File kamor zapisemo filtrirane podatke
+ $tmp_file = $R_folder . '/TempData/ttest_data.tmp';
+
+
+ // Filtriramo podatke po statusu in loopih in jih zapisemo v temp folder R-ja
+ if (IS_WINDOWS) {
+ $command = 'awk -F"|" "BEGIN {{OFS=\",\"} {ORS=\"\n\"}} '.$status_filter.' { print '.$cols.' }" '.$this->dataFileName.' >> '.$tmp_file;
+ } else {
+ $command = 'awk -F"|" \'BEGIN {{OFS=","} {ORS="\n"}} '.$status_filter.' { print '.$cols.'; }\' '.$this->dataFileName.' >> '.$tmp_file;
+ }
+
+ $out = shell_exec($command);
+
+ return $out;
+ }
+
+ // Pobrisemo zacasen file s podatki
+ function deleteDataFile(){
+ global $site_path;
+
+ $R_folder = $site_path . R_FOLDER.'/';
+ $tmp_file = $R_folder . '/TempData/ttest_data.tmp';
+
+ // Na koncu pobrisemo zacasen file s podatki
+ if (file_exists($tmp_file)) {
+ unlink($tmp_file);
+ }
+ }
+
+
+ /** Sestavi array nepravilnih odgovorov
+ *
+ */
+ function getInvalidAnswers($type) {
+ $result = array();
+ $missingValuesForAnalysis = SurveyMissingProfiles :: GetMissingValuesForAnalysis($type);
+
+ foreach ($missingValuesForAnalysis AS $k => $answer) {
+ $result[$k] = array('text'=>$answer,'cnt'=>0);
+ }
+ return $result;
+ }
+
+ function displayTtestTable($ttest) {
+ global $lang;
+
+ # preverimo ali imamo izbrano odvisno spremenljivko
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+
+ if (is_array($ttest) && count($ttest) > 0 && (int)$seq1 > 0) {
+ if ($this->isArchive == false) {
+ echo '<div id="displayFilterNotes">';
+ # če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ SurveyTimeProfiles :: printIsDefaultProfile();
+ # če imamo filter ifov ga izpišemo
+ SurveyConditionProfiles:: getConditionString($doNewLine );
+ # če imamo filter spremenljivk ga izpišemo
+ SurveyVariablesProfiles:: getProfileString($doNewLine, true);
+ SurveyDataSettingProfiles :: getVariableTypeNote($doNewLine );
+ # če rekodiranje
+ $SR = new SurveyRecoding($this->sid);
+ $SR -> getProfileString();
+ echo '</div>';
+
+ echo '<br class="clr" />';
+ }
+ $spr_data_1 = $this->_HEADERS[$spid1];
+ if ($grid1 == 'undefined') {
+
+ # imamp lahko več variabel
+ $seq = $seq1;
+ foreach ($spr_data_1['grids'] as $gkey => $grid ) {
+
+ foreach ($grid['variables'] as $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($sequence == $seq) {
+ $sprLabel1 = '('.$variable['variable'].') '. $variable['naslov'];
+ }
+ }
+ }
+ } else {
+ # imamo subgrid
+ $sprLabel1 = '('.$spr_data_1['grids'][$grid1]['variable'].') '. $spr_data_1['grids'][$grid1]['naslov'];
+ }
+
+ # polovio labele
+ $spid2 = $this->sessionData['ttest']['spr2'];
+ $sprLabel2 = trim($this->sessionData['ttest']['label2']);
+ $label1 = $this->getVariableLabels($this->sessionData['ttest']['sub_conditions'][0]);
+ $label2 = $this->getVariableLabels($this->sessionData['ttest']['sub_conditions'][1]);
+ echo '<table border="0" class="ttestTable">';
+ echo '<tr>';
+ #labele
+ echo '<td class="lightGreen" rowspan="2" >';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" onclick="showspremenljivkaSingleVarPopup(\''.$spid2.'\'); return false;">';
+ echo $sprLabel2.'</a>';
+ echo '</span>';
+ echo '</td>';
+
+ echo '<td class="lightGreen" colspan="9">';
+ echo '<span class="anl_variabla">';
+ echo '<a href="#" onclick="showspremenljivkaSingleVarPopup(\''.$spid1.'\'); return false;">';
+ echo $sprLabel1.'</a>';
+ echo '</span>';
+ echo '</td>';
+ echo '</tr>';
+ echo '<tr>';
+ #echo '<th colspan="2">&nbsp;</th>';
+ #frekvenca
+ echo '<th >n</th>';
+ #povprečje
+ echo '<th><span class="avg">x</span></th>';
+ #varianca
+ echo '<th>s&#178;</th>';
+ #standardna napaka
+ echo '<th>se(<span class="avg">x</span>)</th>';
+ #margini
+ echo '<th>&#177;1,96&#215;se(<span class="avg">x</span>)</th>';
+ #d
+ echo '<th>d</th>';
+ #sed
+ echo '<th>se(d)</th>';
+ #signifikanca
+ echo '<th>Sig.</th>';
+ #ttest
+ echo '<th>t</th>';
+ echo '</tr>';
+
+ echo '<tr>';
+
+ #labele
+
+ echo '<td class="lightGreen">'.$label1.'</td>';
+ #frekvenca
+ echo '<td>'.$this->formatNumber($ttest[1]['n'],0).'</td>';
+ #povprečje
+ echo '<td>'.$this->formatNumber($ttest[1]['x'],3).'</td>';
+ #varianca
+ echo '<td>'.$this->formatNumber($ttest[1]['s2'],3).'</td>';
+ #standardna napaka
+ echo '<td>'.$this->formatNumber($ttest[1]['se'],3).'</td>';
+ #margini
+ echo '<td>'.$this->formatNumber($ttest[1]['margin'],3).'</td>';
+ #d
+ echo '<td rowspan="2">'.$this->formatNumber($ttest['d'],3).'</td>';
+ #sed
+ echo '<td rowspan="2">'.$this->formatNumber($ttest['sed'],3).'</td>';
+ #sig
+ echo '<td rowspan="2">'.$this->formatNumber($ttest['sig'],3).'</td>';
+ #ttest
+ echo '<td rowspan="2">'.$this->formatNumber($ttest['t'],3).'</td>';
+ echo '</tr>';
+
+ echo '<tr>';
+ #labele
+ echo '<td class="lightGreen">'.$label2.'</td>';
+ #frekvenca
+ echo '<td>'.$this->formatNumber($ttest[2]['n'],0).'</td>';
+ #povprečje
+ echo '<td>'.$this->formatNumber($ttest[2]['x'],3).'</td>';
+ #varianca
+ echo '<td>'.$this->formatNumber($ttest[2]['s2'],3).'</td>';
+ #standardna napaka
+ echo '<td>'.$this->formatNumber($ttest[2]['se'],3).'</td>';
+ #margini
+ echo '<td>'.$this->formatNumber($ttest[2]['margin'],3).'</td>';
+ echo '</tr>';
+ echo '</table>';
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ /** Naredimo formatiran izpis
+ *
+ * @param $value
+ * @param $digit
+ * @param $sufix
+ */
+
+ static function formatNumber ($value, $digit = 0, $sufix = "") {
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+ # polovimo decimalna mesta in vejice za tisočice
+
+ $decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+
+ $result = number_format($result, $digit, $decimal_point, $thousands).$sufix;
+
+ return $result;
+ }
+
+ function getVariableLabels($sub_conditions) {
+ $_tmp = explode('_',$sub_conditions);
+ $spr = $this->_HEADERS[$_tmp[0].'_'.$_tmp[1]];
+ switch ($spr['tip']) {
+ case 1: #radio
+ case 3: #dropdown
+ $label = $spr['options'][$_tmp[3]];
+ break;
+ case 2: #checkbox
+ foreach ($spr['grids'][0]['variables'] as $vkey => $variable) {
+ if($variable['sequence'] == $_tmp[2]) {
+ $label = '('.$variable['variable'].') - '.$variable['naslov'];
+ }
+ }
+ break;
+ case 6: #mgrid
+ $label = $spr['options'][$_tmp[3]];
+ break;
+ case 16: #mcheck
+ $label = $spr['options'][$_tmp[3]];
+ break;
+ default:
+ $label = 'TODO: getVariableLabels for type:'.$spr['tip'];
+ break;
+ }
+ return $label;
+ }
+
+ function checkboxSubCondition($checkCondition) {
+
+ $cnt = $this->checkSubConditionsActive();
+ $sub_Conditions = $this->sessionData['ttest']['sub_conditions'];
+ if (is_array($sub_Conditions) && count($sub_Conditions) > 0) {
+ foreach ($sub_Conditions AS $sub_condition) {
+ if ($sub_condition == $checkCondition) {
+ return ' checked="checked"';
+ }
+ }
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ return $cnt == 2 ? ' disabled="disabled"' : null;
+ }
+
+ function checkSubConditionsActive() {
+
+ $cnt = 0;
+
+ $needle = $this->sessionData['ttest']['spr2'];
+ $length = strlen($needle);
+ $sub_Conditions = $this->sessionData['ttest']['sub_conditions'];
+ if (is_array($sub_Conditions) && count($sub_Conditions) > 0) {
+ foreach ($sub_Conditions AS $haystack) {
+ $cnt += (int)(substr($haystack, 0, $length) === $needle);
+ }
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ return $cnt;
+ }
+} \ No newline at end of file
diff --git a/admin/survey/classes/surveyAnalysis/class.SurveyTableChart.php b/admin/survey/classes/surveyAnalysis/class.SurveyTableChart.php
new file mode 100644
index 0000000..8b51105
--- /dev/null
+++ b/admin/survey/classes/surveyAnalysis/class.SurveyTableChart.php
@@ -0,0 +1,2853 @@
+<?php
+/**
+* @author Peter Hrvatin
+* @date April 2012
+*/
+
+define("SAA_FOLDER", "AnalysisArchive");
+
+class SurveyTableChart {
+
+ public $anketa; # id ankete
+ public $folder = ''; # pot do folderja
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $SDF = null; # class za inkrementalno dodajanje fajlov
+
+ public $uid; # id userja
+
+ private $classInstance; // instanca razreda (crosstabs, ttest...) z vsemi podatki
+ private $podstran; // podstran iz katere kreimramo graf (tip grafa -> crosstab, ttest, povprecje)
+ private $counter; // kateri graf po vrsti izrisemo (ce jih je vec)
+ private $crossCheck = false; // ce imamo odvisno spremenljivko pri crosstabu checkbox jo obravnavamo posebej
+
+ public $skin = '1ka'; # nastavitev skina za grafe
+ public $fontSize = 8; # velikost fonta v grafih
+ public $quality = 1; # kvaliteta (sirina) slike (1 -> 800px, 2 -> 1600px)
+
+ public $numerusText = ''; // dodaten text pri numerusu (veljavni, navedbe)
+
+ private $crosstabVars; // kateri graf po vrsti izrisemo (ce jih je vec)
+
+ public $break_forSpr; // break neodvisna spremenljivka
+ public $break_frequencys; // break izracunane frekvence
+ public $break_spremenljivka; // break odvisna spremenljivka
+ public $break_crosstab = 0; // break crosstab tabela
+
+ public $settings = array(); // nastavitve grafa
+ public $settings_mode=0; // zavihek nastavitev (osnovno/napredno)
+
+ public $returnChartAsHtml = false; # ali vrne rezultat analiz kot html ali ga izpiše
+ public $isArchive = false; # nastavimo na true če smo v arhivu
+ public $chartArchiveTime = ''; # unikatnost
+
+ private $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+
+ /**
+ * Konsturktor
+ *
+ * @param int $anketa
+ */
+ function __construct($anketa, $classInstance=null, $podstran='crosstab', $counter=0) {
+ global $global_user_id, $site_path;
+
+ $this->folder = $site_path . EXPORT_FOLDER.'/';
+
+ $this->anketa = $anketa;
+
+ if ((int)$this->anketa > 0) { # če je poadan anketa ID
+
+ $this->classInstance = $classInstance;
+ $this->podstran = $podstran;
+ $this->counter = $counter;
+
+ #inicializiramo SurveyAnalasys
+ SurveyAnalysis::Init($this->anketa);
+ //SurveyAnalysis::$setUpJSAnaliza = false;
+
+ #inicializiramo class za datoteke
+ $this->SDF = SurveyDataFile::get_instance();
+ $this->SDF->init($this->anketa);
+ $this->headFileName = $this->SDF->getHeaderFileName();
+ $this->dataFileName = $this->SDF->getDataFileName();
+ $this->dataFileStatus = $this->SDF->getStatus();
+
+ if ($this->dataFileStatus == FILE_STATUS_NO_DATA
+ || $this->dataFileStatus == FILE_STATUS_NO_FILE
+ || $this->dataFileStatus == FILE_STATUS_SRV_DELETED){
+ exit;
+ return false;
+ }
+ //polovimo podatke o nastavitvah trenutnega profila (missingi..)
+ SurveyAnalysis::$missingProfileData = SurveyMissingProfiles::getProfile(SurveyAnalysis::$currentMissingProfile);
+
+ #preberemo HEADERS iz datoteke
+ SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
+
+ # odstranimo sistemske variable tipa email, ime, priimek, geslo
+ SurveyAnalysis::removeSystemVariables();
+
+ # polovimo frekvence
+ SurveyAnalysis::getFrequencys();
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa);
+ $this->sessionData = SurveyUserSession::getData();
+ }
+ else {
+ //die("Napaka!");
+ }
+
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa))
+ {
+ $this->uid = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa, $this->uid);
+ }
+
+
+ $this->skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
+ $this->fontSize = SurveyDataSettingProfiles :: getSetting('chartFontSize');
+ $this->quality = (isset($this->sessionData['charts']['hq']) && $this->sessionData['charts']['hq'] == 1) ? 3 : 1;
+ }
+
+
+ function display(){
+ global $site_path;
+ global $lang;
+
+ $chartID = $this->getChartID();
+
+ switch($this->podstran){
+
+ case 'crosstab':
+ echo '<div class="crosstab_chart_holder tableChart" id="tableChart_'.$chartID.'">';
+ $this->displayCrosstabChart($chartID);
+ echo '</div>';
+
+ break;
+
+ case 'ttest':
+ echo '<div class="ttest_chart_holder tableChart" id="tableChart_'.$chartID.'">';
+ $this->displayTTestChart($chartID);
+ echo '</div>';
+
+ break;
+
+ case 'mean':
+ echo '<div class="mean_chart_holder tableChart" id="tableChart_'.$chartID.'">';
+ $this->displayMeanChart($chartID);
+ echo '</div>';
+
+ break;
+
+ case 'break':
+ echo '<div class="break_chart_holder tableChart" id="tableChart_'.$chartID.'">';
+ $this->displayBreakChart($chartID);
+ echo '</div>';
+
+ break;
+ }
+ }
+
+
+ // Izrisemo graf v crosstabih
+ function displayCrosstabChart($chartID){
+ global $site_path;
+ global $lang;
+
+ // preverimo ce imamo checkbox v odvisni spr - imamo posebne nastavitve
+ if (count($this->classInstance->variabla2) > 0) {
+ foreach ($this->classInstance->variabla2 AS $key => $var) {
+ $spr_tip = $this->classInstance->_HEADERS[$var['spr']]['tip'];
+ if ( $spr_tip == 2 || $spr_tip == 16 ) {
+ $this->crossCheck = true;
+ }
+ }
+ }
+ if (count($this->classInstance->variabla1) > 0 && $is_check == false ) { # če še ni bil checkbox
+ foreach ($this->classInstance->variabla1 AS $key => $var) {
+ $spr_tip = $this->classInstance->_HEADERS[$var['spr']]['tip'];
+ if ( $spr_tip == 2 || $spr_tip == 16 ) {
+ $this->crossCheck = true;
+ }
+ }
+ }
+ // zaenkrat ne upoastevamo
+ $this->crossCheck = false;
+
+ // defult nastavitve posameznega grafa
+ if(isset($this->sessionData['crosstab_charts'][$chartID]))
+ $this->settings = $this->sessionData['crosstab_charts'][$chartID];
+ else
+ $this->settings = $this->getDefaultSettings();
+
+
+ // Napolnimo podatke za graf
+ $DataSet = $this->getCrosstabDataSet($chartID, $this->settings);
+
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = $this->generateChartId($chartID, $this->settings, $DataSet->GetNumerus());
+
+ // Ce se nimamo zgeneriranega grafa
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+
+ switch($this->settings['type']){
+
+ // Sestavljeni stolpec - horizontalen
+ case 0:
+ $Test = $this->createHorStructBars($DataSet);
+ break;
+
+ // Sestavljeni stolpec - vertikalen
+ case 1:
+ $Test = $this->createVerStructBars($DataSet);
+ break;
+
+ // Horizontalni stolpci
+ case 3:
+ $Test = $this->createHorBars($DataSet, 1);
+ break;
+
+ // Navpicni stolpci
+ case 4:
+ $Test = $this->createVerBars($DataSet, 1);
+ break;
+
+ // Pie chart
+ case 2:
+ $Test = $this->createPie($DataSet, $this->settings['show_legend']);
+ break;
+
+ // Pie chart
+ case 5:
+ $Test = $this->create3DPie($DataSet, $this->settings['show_legend']);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+
+ if ($this->isArchive == false ) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.$this->anketa.'_'.$this->chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+
+ // zapisemo ime slike v session za izvoze
+ $this->settings['name'] = $imgName;
+ $this->sessionData['crosstab_charts'][$chartID] = $this->settings;
+
+ // Zapisemo se variable v session
+ $this->sessionData['crosstab_charts'][$chartID]['spr1'] = $this->classInstance->variabla1[0];
+ $this->sessionData['crosstab_charts'][$chartID]['spr2'] = $this->classInstance->variabla2[0];
+
+ // Naslov posameznega grafa
+ echo '<div class="chart_title">';
+
+ if($this->settings['type'] == 1 || $this->settings['type'] == 4){
+ $title = '<table><tr>';
+ $title .= '<td style="width:380px;">'.$this->crosstabVars[0] . '</td><td style="width:40px;"> / </td><td style="width:380px;">' . $this->crosstabVars[1].'</td>';
+ $title .= '</tr></table>';
+ }
+ else{
+ $title = $this->crosstabVars[0];
+ }
+ echo $title;
+
+ echo '</div>';
+
+ echo '<div class="chart_img" id="chart_img_'.$chartID.'" onclick="tableChartAdvancedSettings(\''.$chartID.'\', \'crosstab\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgPath.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ $this->displaySingleSettings($chartID, $this->settings);
+ echo '</div>';
+
+ // Zvezdica za vkljucitev v porocilo
+ $variables1 = $this->classInstance->getSelectedVariables(2);
+ $variables2 = $this->classInstance->getSelectedVariables(1);
+ $counter = 0;
+ $var1 = array();
+ $var2 = array();
+ foreach ($variables1 AS $v_first) {
+ foreach ($variables2 AS $v_second) {
+ if($counter == $this->counter){
+ $var1 = $v_first;
+ $var2 = $v_second;
+
+ break 2;
+ }
+ else
+ $counter++;
+ }
+ }
+
+ $spr2 = $var1['seq'].'-'.$var1['spr'].'-'.$var1['grd'];
+ $spr1 = $var2['seq'].'-'.$var2['spr'].'-'.$var2['grd'];
+ SurveyAnalysis::addCustomReportElement($type=5, $sub_type=1, $spr1, $spr2);
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ // Izrisemo graf v ttestu
+ function displayTTestChart($chartID){
+ global $site_path;
+ global $lang;
+
+ // defult nastavitve posameznega grafa
+ if(isset($this->sessionData['ttest_charts'][$chartID]))
+ $this->settings = $this->sessionData['ttest_charts'][$chartID];
+ else
+ $this->settings = $this->getDefaultSettings();
+
+
+ // Napolnimo podatke za graf
+ $DataSet = $this->getTTestDataSet($chartID, $this->settings);
+
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = $this->generateChartId($chartID, $this->settings, $DataSet->GetNumerus());
+
+ // Ce se nimamo zgeneriranega grafa
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+
+ switch($this->settings['type']){
+
+ // Horizontalni stolpci
+ case 0:
+ $Test = $this->createHorBars($DataSet, $legend=0);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+
+ if ($this->isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.$this->anketa.'_'.$this->chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+
+ // zapisemo ime slike v session za izvoze
+ $this->settings['name'] = $imgName;
+ $this->sessionData['ttest_charts'][$chartID] = $this->settings;
+
+ // Naslov posameznega grafa
+ echo '<div class="chart_title">';
+ $title = $lang['srv_chart_ttest_title'].':<br />';
+ $title .= '<table><tr>';
+ $title .= '<td style="width:380px; text-align: right;">'.$this->crosstabVars[0] . '</td><td style="width:40px;"> / </td><td style="width:380px; text-align: left;">' . $this->crosstabVars[1].'</td>';
+ $title .= '</tr></table>';
+ echo $title;
+ echo '</div>';
+
+ echo '<div class="chart_img" id="chart_img_'.$chartID.'" onclick="tableChartAdvancedSettings(\''.$chartID.'\', \'ttest\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgPath.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ $this->displaySingleSettings($chartID, $this->settings);
+ echo '</div>';
+
+ // Zvezdica za vkljucitev v porocilo
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+ $sub1 = $this->sessionData['ttest']['sub_conditions'][0];
+ $sub2 = $this->sessionData['ttest']['sub_conditions'][1];
+
+ $spid2 = $this->sessionData['ttest']['spr2'];
+ $seq2 = $this->sessionData['ttest']['seq2'];
+ $grid2 = $this->sessionData['ttest']['grid2'];
+
+ $spr1 = $seq2.'-'.$spid2.'-'.$grid2.'-'.$sub1.'-'.$sub2;
+ $spr2 = $seq1.'-'.$spid1.'-'.$grid1;
+ SurveyAnalysis::addCustomReportElement($type=7, $sub_type=1, $spr1, $spr2);
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ // Klicemo pri pdf/rtf izpisih da se pravilno nastavi session
+ function setTTestChartSession(){
+
+ // Zgeneriramo id vsake tabele (glede na izbrani spremenljivki za generiranje)
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+ $sub1 = $this->sessionData['ttest']['sub_conditions'][0];
+ $sub2 = $this->sessionData['ttest']['sub_conditions'][1];
+ $chartID = $sub1.'_'.$sub2.'_'.$spid1.'_'.$seq1.'_'.$grid1;
+
+ // defult nastavitve posameznega grafa
+ if(isset($this->sessionData['ttest_charts'][$chartID]))
+ $this->settings = $this->sessionData['ttest_charts'][$chartID];
+ else
+ $this->settings = $this->getDefaultSettings();
+
+ // Napolnimo podatke za graf
+ $DataSet = $this->getTTestDataSet($chartID, $this->settings);
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = $this->generateChartId($chartID, $this->settings, $DataSet->GetNumerus());
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+
+ // zapisemo ime slike v session za izvoze
+ $this->settings['name'] = $imgName;
+ $this->sessionData['ttest_charts'][$chartID] = $this->settings;
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ // Izrisemo graf v povprecjih
+ function displayMeanChart($chartID){
+ global $site_path;
+ global $lang;
+
+ // defult nastavitve posameznega grafa
+ if(isset($this->sessionData['mean_charts'][$chartID]))
+ $this->settings = $this->sessionData['mean_charts'][$chartID];
+ else
+ $this->settings = $this->getDefaultSettings();
+
+
+ // Napolnimo podatke za graf
+ $DataSet = $this->getMeanDataSet($chartID, $this->settings);
+
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = $this->generateChartId($chartID, $this->settings, $DataSet->GetNumerus());
+
+ // Ce se nimamo zgeneriranega grafa
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+
+ switch($this->settings['type']){
+
+ // Povprecja - horizontalni stolpci
+ case 0:
+ $Test = $this->createHorBars($DataSet, $legend=0, $fixedScale=1);
+ break;
+
+ // Povprecja - radar
+ case 1:
+ $Test = $this->createRadar($DataSet, 1, $fixedScale=1);
+ break;
+
+ // Povprecja - vertikalna crta
+ case 2:
+ $Test = $this->createVerLine($DataSet, $legend=0, $fixedScale=1);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+
+ if ($this->isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.$this->anketa.'_'.$this->chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+
+ // zapisemo ime slike v session za izvoze
+ $this->settings['name'] = $imgName;
+ $this->sessionData['mean_charts'][$chartID] = $this->settings;
+
+ // Naslov posameznega grafa
+ $title = '';
+ echo '<div class="chart_title">';
+ echo $title;
+ echo '</div>';
+
+ echo '<div class="chart_img" id="chart_img_'.$chartID.'" onclick="tableChartAdvancedSettings(\''.$chartID.'\', \'mean\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgPath.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ $this->displaySingleSettings($chartID, $this->settings);
+ echo '</div>';
+
+ // Zvezdica za vkljucitev v porocilo
+ $variables1 = $this->classInstance->getSelectedVariables(1);
+ $variables2 = $this->classInstance->getSelectedVariables(2);
+
+ $pos1 = floor($this->counter / count($variables2));
+ $pos2 = $this->counter % count($variables2);
+
+ $spr1 = $variables1[$pos1]['seq'].'-'.$variables1[$pos1]['spr'].'-'.$variables1[$pos1]['grd'];
+ $spr2 = $variables2[$pos2]['seq'].'-'.$variables2[$pos2]['spr'].'-'.$variables2[$pos2]['grd'];
+ SurveyAnalysis::addCustomReportElement($type=6, $sub_type=1, $spr1, $spr2);
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ // Izrisemo graf v breaku
+ function displayBreakChart($chartID){
+ global $site_path;
+ global $lang;
+
+ $tip = $this->break_spremenljivka['tip'];
+ $skala = $this->break_spremenljivka['skala'];
+
+ // Izrisemo poseben break graf (multigrid, multicheckbox, multitext, multinumber)
+ if( in_array($tip, array(7,17,18,20,)) || ($tip == 6 && $skala == 0) ){
+
+ // defult nastavitve posameznega grafa
+ if(isset($this->sessionData['break_charts'][$chartID]))
+ $this->settings = $this->sessionData['break_charts'][$chartID];
+ else
+ $this->settings = $this->getDefaultSettings();
+
+
+ // Pri number ne dovolimo radarja in ne sortiranja po kategorijah
+ if($tip == 7){
+ if($this->settings['type'] == 0)
+ $this->settings['type'] = 1;
+
+ if($this->settings['sort'] == 1)
+ $this->settings['sort'] = 0;
+ }
+
+
+ // Napolnimo podatke za graf
+ $DataSet = $this->getBreakDataSet($chartID, $this->settings);
+
+
+ // Cache
+ $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
+
+ $ID = $this->generateChartId($chartID, $this->settings, $DataSet->GetNumerus());
+
+ // Ce se nimamo zgeneriranega grafa
+ if( !$Cache->isInCache($ID, $DataSet->GetData()) ){
+
+ switch($this->settings['type']){
+
+ // Povprecja - radar
+ case 0:
+ $Test = $this->createRadar($DataSet, 1);
+ break;
+
+ // Povprecja - vertikalni stolpci
+ case 1:
+ $Test = $this->createVerBars($DataSet, 1);
+ break;
+
+ // Povprecja - horizontalni stolpci
+ case 2:
+ $Test = $this->createHorBars($DataSet, 1);
+ break;
+
+ // Povprecja - linijski graf
+ case 3:
+ $Test = $this->createLine($DataSet, 1);
+ break;
+ }
+
+ // Shranimo v cache
+ $Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
+ }
+
+ // dobimo ime slike c cache-u
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+
+ if ($this->isArchive == false) {
+ $imgPath = 'pChart/Cache/'.$imgName;
+ } else {
+ $imgPath = SAA_FOLDER.'/pChart/'.$this->anketa.'_'.$this->chartArchiveTime.'_'.$imgName;
+ copy('pChart/Cache/'.$imgName, $imgPath);
+ }
+
+ // zapisemo ime slike v session za izvoze
+ $this->settings['name'] = $imgName;
+ $this->sessionData['break_charts'][$chartID] = $this->settings;
+
+ // Zapisemo se variable v session
+ $this->sessionData['break_charts'][$chartID]['forSpr'] = $this->break_forSpr;
+ $this->sessionData['break_charts'][$chartID]['frequencys'] = $this->break_frequencys;
+ $this->sessionData['break_charts'][$chartID]['spremenljivka'] = $this->break_spremenljivka;
+
+
+ // Naslov posameznega grafa
+ echo '<div class="chart_title">';
+
+ //var_dump($this->break_spremenljivka);
+ $title = $this->break_spremenljivka['naslov'] . ' ('.$this->break_spremenljivka['variable'].')';
+
+ if($tip == 20){
+
+ $gkey = $this->break_spremenljivka['break_sub_table']['key'];
+ $grid = $this->break_spremenljivka['grids'][$gkey];
+ $subtitle = $grid['naslov'] . ' ('.$grid['variable'].')';
+
+ $title .= '<br />'.$subtitle;
+ }
+
+ echo $title;
+
+ echo '</div>';
+
+
+ echo '<div class="chart_img" id="chart_img_'.$chartID.'" onclick="tableChartAdvancedSettings(\''.$chartID.'\', \'break\');" style="cursor:pointer">';
+ // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha
+ echo '<img src="'.$imgPath.'?'.time().'" />';
+ echo '</div>';
+
+ echo '<div class="chart_settings printHide iconHide">';
+ $this->displaySingleSettings($chartID, $this->settings);
+ echo '</div>';
+
+
+ // Zvezdica za vkljucitev v porocilo - Multinumber
+ if($tip == 20){
+
+ // Preberemo za kateri grid izrisujemo tabelo
+ $gkey = $this->break_spremenljivka['break_sub_table']['key'];
+
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $this->break_spremenljivka['grids'][$gkey]['variables'][0]['sequence'].'-'.$this->break_spremenljivka['id'].'-undefined';
+ SurveyAnalysis::Init($this->anketa);
+ SurveyAnalysis::addCustomReportElement($type=9, $sub_type=1, $spr1, $spr2);
+ }
+ // Zvezdica za vkljucitev v porocilo - multigrid, number, vsota, ranking
+ else{
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $this->break_spremenljivka['grids'][0]['variables'][0]['sequence'].'-'.$this->break_spremenljivka['id'].'-undefined';
+ SurveyAnalysis::Init($this->anketa);
+ SurveyAnalysis::addCustomReportElement($type=9, $sub_type=1, $spr1, $spr2);
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ // Izrisemo crosstab graf
+ else{
+ $this->podstran = 'crosstab';
+ $this->displayCrosstabChart($chartID);
+ }
+ }
+
+
+ // Napolnimo podatke za crosstab graf
+ public function getCrosstabDataSet($chartID, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+
+ $dataArray = array();
+ $dataPercentArray = array();
+ $gridArray = array();
+ $variableArray = array();
+
+
+ if ($this->classInstance->getSelectedVariables(1) !== null && $this->classInstance->getSelectedVariables(2) !== null) {
+ $variables1 = $this->classInstance->getSelectedVariables(2);
+ $variables2 = $this->classInstance->getSelectedVariables(1);
+ $counter = 0;
+ foreach ($variables1 AS $v_first) {
+ foreach ($variables2 AS $v_second) {
+
+ // izrisemo graf ki ustreza vrstnemu redu
+ if($counter == $this->counter){
+ $crosstabs = null;
+ $crosstabs_value = null;
+
+ $crosstabs = $this->classInstance->createCrostabulation($v_first, $v_second);
+ $crosstabs_value = $crosstabs['crosstab'];
+
+ # podatki spremenljivk
+ $spr1 = $this->classInstance->_HEADERS[$v_first['spr']];
+ $spr2 = $this->classInstance->_HEADERS[$v_second['spr']];
+
+ $grid1 = $spr1['grids'][$v_first['grd']];
+ $grid2 = $spr2['grids'][$v_second['grd']];
+
+ #število vratic in število kolon
+ $cols = count($crosstabs['options1']);
+ $rows = count($crosstabs['options2']);
+
+ # ali prikazujemo vrednosti variable pri spremenljivkah
+ $show_variables_values = $this->classInstance->doValues;
+
+
+ # za multicheckboxe popravimo naslov, na podtip
+ $sub_q1 = null;
+ $sub_q2 = null;
+ if ($spr1['tip'] == '6' || $spr1['tip'] == '7' || $spr1['tip'] == '16' || $spr1['tip'] == '17' || $spr1['tip'] == '18' || $spr1['tip'] == '19' || $spr1['tip'] == '20' || $spr1['tip'] == '21' ) {
+ foreach ($spr1['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_first['seq']) {
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ if ($show_variables_values == true ) {
+ $sub_q1 .= ' ('.strip_tags($spr1['variable']).')';
+ }
+ if ($spr1['tip'] == '16') {
+ $sub_q1 .= '<br />'. strip_tags($grid1['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid1['variable']) . ')' : '');
+ } else {
+ $sub_q1 .= '<br />' . strip_tags($variable['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($variable['variable']) . ')' : '');
+ }
+ }
+ }
+ }
+ }
+ if ($sub_q1 == null) {
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ $sub_q1 .= ($show_variables_values == true ? '&nbsp;('.strip_tags($spr1['variable']).')' : '');
+ }
+ if ($spr2['tip'] == '6' || $spr2['tip'] == '7' || $spr2['tip'] == '16' || $spr2['tip'] == '17' || $spr2['tip'] == '18' || $spr2['tip'] == '19' || $spr2['tip'] == '20' || $spr2['tip'] == '21') {
+ foreach ($spr2['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_second['seq']) {
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ if ($show_variables_values == true) {
+ $sub_q2 .= ' ('.strip_tags($spr2['variable']).')';
+ }
+ if ($spr2['tip'] == '16') {
+ $sub_q2.= '<br />' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid2['variable']) . ')' : '');
+ } else {
+ $sub_q2.= '<br />' . strip_tags($variable['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($variable['variable']) . ')' : '');
+ }
+ }
+ }
+ }
+ }
+ if ($sub_q2 == null) {
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ $sub_q2 .= ($show_variables_values == true ? ' ('.strip_tags($spr2['variable']).')' : '');
+ }
+
+ // ZGORNJA LABELA - NEODVISNA
+ //$sub_q2;
+ // STRANSKA LABELA - ODVISNA
+ //$sub_q1;
+
+ $this->crosstabVars = array($sub_q1, $sub_q2);
+
+ // NASLOVI GRIDOV
+ $grid_cnt=0;
+ if (count($crosstabs['options1']) > 0 ) {
+ foreach ($crosstabs['options1'] as $ckey1 =>$crossVariabla) {
+ $grid_cnt++;
+
+ #ime variable
+ $gridArray[$grid_cnt] = $crossVariabla['naslov'];
+
+ /*echo $crossVariabla['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla['type'] != 't' && $show_variables_values == true) {
+ if ($crossVariabla['vr_id'] == null ) {
+ echo '<br/> ( '.$ckey1.' )';
+ } else {
+ echo '<br/> ( '.$crossVariabla['vr_id'].' )';
+ }
+ }*/
+ }
+ }
+
+
+ $var_cnt=0;
+ if (count($crosstabs['options2']) > 0) {
+ foreach ($crosstabs['options2'] as $ckey2 =>$crossVariabla2) {
+ $var_cnt++;
+
+ // NASLOVI VARIABEL
+ $variableArray[$var_cnt] = $crossVariabla2['naslov'];
+
+ /*echo $crossVariabla2['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla2['type'] !== 't' && $show_variables_values == true ) {
+ if ($crossVariabla2['vr_id'] == null) {
+ echo '<br/> ( '.$ckey2.' )';
+ } else {
+ echo '<br/> ( '.$crossVariabla2['vr_id'].' )';
+ }
+ }*/
+
+
+ // VREDNOSTI
+ $cnt=0;
+ foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+ $cnt++;
+
+ $dataArray[$cnt][] = ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? $crosstabs_value[$ckey1][$ckey2] : 0;
+ $dataPercentArray[$cnt][] = $this->classInstance->getCrossTabPercentage($crosstabs['sumaVrstica'][$ckey2], $crosstabs_value[$ckey1][$ckey2]);
+
+ /*
+ # celica z vebino
+ {
+ # prikazujemo eno ali več od: frekvenc, odstotkov, residualov
+ if ($this->classInstance->crossChk0) {
+ # izpišemo frekvence crostabov
+ echo ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? $crosstabs_value[$ckey1][$ckey2] : 0;
+ }
+ }*/
+ }
+ }
+ }
+
+ }
+
+ $counter++;
+ }
+ }
+ }
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ // PRAVILNO OBRNJENA - GRIDI SO SERIJE
+ for($i=1; $i<=$grid_cnt; $i++){
+
+ // procenti
+ if($settings['value_type'] == 0){
+ if(count($dataPercentArray[$i]) > 0)
+ $DataSet->AddPoint($dataPercentArray[$i],'Vrednosti_'.$i);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+ }
+ // frekvence
+ elseif($settings['value_type'] == 1){
+ if(count($dataArray[$i]) > 0)
+ $DataSet->AddPoint($dataArray[$i],'Vrednosti_'.$i);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+ }
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ $DataSet->SetSerieName($gridArray[$i],'Vrednosti_'.$i);
+ }
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($variableArray,"Variable");
+ $DataSet->SetAbsciseLabelSerie("Variable");
+
+ if($settings['value_type'] == 0){
+ $DataSet->SetYAxisUnit("%");
+ $DataSet->SetYAxisFormat("number");
+ }
+
+ // NAROBE OBRNJENA - VARIABLE SO SERIJE
+ /*for($i=1; $i<=$var_cnt; $i++){
+
+ if(count($dataArray[$i]) > 0)
+ $DataSet->AddPoint($dataArray[$i],'Vrednosti_'.$i);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti_'.$i);
+
+ $DataSet->AddSerie('Vrednosti_'.$i);
+ $DataSet->SetSerieName($variableArray[$i],'Vrednosti_'.$i);
+ }
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($gridArray,"Variable");
+ $DataSet->SetAbsciseLabelSerie("Variable");*/
+
+
+ return $DataSet;
+ }
+
+ // Napolnimo podatke za ttest graf
+ public function getTTestDataSet($chartID, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $DataSet = null;
+
+
+ $variables1 = $this->classInstance->getSelectedVariables();
+ foreach ($variables1 AS $v_first) {
+ if($this->counter == $counter){
+ $ttest = null;
+ $ttest = $this->classInstance->createTTest($v_first, $this->sessionData['ttest']['sub_conditions']);
+
+ break;
+ }
+ }
+
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+
+ if (is_array($ttest) && count($ttest) > 0 && (int)$seq1 > 0) {
+
+ $spr_data_1 = $this->classInstance->_HEADERS[$spid1];
+ if ($grid1 == 'undefined') {
+
+ # imamp lahko več variabel
+ $seq = $seq1;
+ foreach ($spr_data_1['grids'] as $gkey => $grid ) {
+
+ foreach ($grid['variables'] as $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($sequence == $seq) {
+ $sprLabel1 = '('.$variable['variable'].') '. $variable['naslov'];
+ }
+ }
+ }
+ } else {
+ # imamo subgrid
+ $sprLabel1 = '('.$spr_data_1['grids'][$grid1]['variable'].') '. $spr_data_1['grids'][$grid1]['naslov'];
+ }
+
+ $sprLabel2 = trim(str_replace('&nbsp;','',$this->sessionData['ttest']['label2']));
+
+ $this->crosstabVars = array($sprLabel1, $sprLabel2);
+
+ $label1 = $this->classInstance->getVariableLabels($this->sessionData['ttest']['sub_conditions'][0]);
+ $label2 = $this->classInstance->getVariableLabels($this->sessionData['ttest']['sub_conditions'][1]);
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ //nastavimo t, ki se izpise pod legendo
+ $t = $this->classInstance->formatNumber($ttest['t'],3);
+ $DataSet->SetNumerus($t);
+
+ $DataSet->AddPoint($this->classInstance->formatNumber($ttest[1]['x'],3),'Vrednost');
+ $DataSet->AddPoint($this->classInstance->formatNumber($ttest[2]['x'],3),'Vrednost');
+
+ $DataSet->AddSerie('Vrednost');
+
+ $DataSet->AddPoint(array(0 => $label1, 1 => $label2),"Variable");
+ $DataSet->SetAbsciseLabelSerie("Variable");
+ }
+
+ return $DataSet;
+ }
+
+ // Napolnimo podatke za mean graf
+ public function getMeanDataSet($chartID, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+
+ $dataArray = array();
+ $gridArray = array();
+ $variableArray = array();
+
+
+ $variables1 = $this->classInstance->getSelectedVariables(2);
+ $variables2 = $this->classInstance->getSelectedVariables(1);
+
+ if (is_array($variables2) && count($variables2) > 0) {
+ foreach ($variables2 AS $v_second) {
+ if (is_array($variables1) && count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $_means = $this->classInstance->createMeans($v_first, $v_second);
+ if ($_means != null) {
+ $means[$c1][0] = $_means;
+ }
+ $c1++;
+ }
+ }
+ }
+ }
+
+ // Zaenkrat prikazemo samo graf za prvo tabelo
+ if (is_array($means) && count($means) > 0) {
+ $counter=0;
+ foreach ($means AS $mean_sub_grup) {
+
+ // Izrisemo pravi graf po vrsti ki pripada tabeli
+ if($counter == $this->counter){
+ $_means = $mean_sub_grup;
+ break;
+ }
+
+ $counter++;
+ }
+ }
+
+
+ #število vratic in število kolon
+ $cols = count($_means);
+ # preberemo kr iz prvega loopa
+ $rows = count($_means[0]['options']);
+
+
+ // loop po vrsticah
+ if (count($_means[0]['options']) > 0) {
+ foreach ($_means[0]['options'] as $ckey2 =>$crossVariabla2) {
+
+ // IME VARIABLE
+ $variableArray[] = $crossVariabla2['naslov'];
+
+ // VREDNOST VARIABLE
+ $dataArray[] = $this->classInstance->formatNumber($_means[0]['result'][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'));
+ }
+ }
+
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1)
+ array_multisort($dataArray, SORT_DESC, $variableArray);
+
+
+ if(count($dataArray) > 0)
+ $DataSet->AddPoint($dataArray,'Vrednosti');
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti');
+
+ $DataSet->AddSerie('Vrednosti');
+ $DataSet->SetSerieName('Povprečja','Vrednosti');
+
+ // Pri povprecjih vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($variableArray,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie("Variable");
+
+
+ return $DataSet;
+ }
+
+ // Napolnimo podatke za break graf
+ public function getBreakDataSet($chartID, $settings, $refresh=0){
+ global $site_path;
+ global $lang;
+
+ $keysCount = count($this->break_frequencys);
+ $sequences = explode('_',$this->break_spremenljivka['sequences']);
+ $forSpremenljivka = $this->classInstance->_HEADERS[$this->break_forSpr];
+ $tip = $this->break_spremenljivka['tip'];
+
+ # izračunamo povprečja za posamezne sekvence
+ $means = array();
+ $totalMeans = array();
+ $totalFreq = array();
+ foreach ($this->break_frequencys AS $fkey => $options) {
+ foreach ($options AS $oKey => $option) {
+ foreach ($sequences AS $sequence) {
+ $means[$fkey][$oKey][$sequence] = $this->classInstance->getMeansFromKey($option[$sequence]);
+ }
+ }
+ }
+
+
+ //polnimo podatke
+ $DataSet = new pData;
+
+ $dataArray = array();
+ $variableArray = array();
+
+
+ // Polnimo podatke za multigrid dropdown, number, vsoto, ranking
+ if($this->break_spremenljivka['tip'] != 20){
+
+ $cnt=0;
+ foreach ($this->break_frequencys AS $fkey => $fkeyFrequency) {
+ $variableArray[] = $forSpremenljivka['grids'][0]['variables'][$cnt]['naslov'];
+ $cnt++;
+ foreach ($options AS $oKey => $option) {
+
+ $grid_count = 0;
+
+ foreach ($this->break_spremenljivka['grids'] AS $gkey => $grid) {
+
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+
+ $grid_count++;
+
+ #povprečja
+ $avg = $this->classInstance->formatNumber($means[$fkey][$oKey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ # enote
+ $enote = (int)$this->break_frequencys[$fkey][$oKey][$sequence]['validCnt'];
+
+ $tempArray = array();
+
+ $tempArray['avg'] = str_replace(",","",$avg);
+ $tempArray['unit'] = $enote;
+ $tempArray['key'] = $variable['variable'];
+ $tempArray['variable'] = $variable['naslov'];
+
+ $dataArray[] = $tempArray;
+
+ $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$this->break_frequencys[$fkey][$oKey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$this->break_frequencys[$fkey][$oKey][$sequence]['validCnt'];
+ }
+
+ }
+
+ }
+ }
+ }
+ }
+
+ // Polnimo podatke za multinumber
+ else{
+ // Nastavimo pravo podtabelo
+ $gkey = $this->break_spremenljivka['break_sub_table']['key'];
+ $grid = $this->break_spremenljivka['grids'][$gkey];
+
+ $cnt=0;
+ foreach ($this->break_frequencys AS $fkey => $fkeyFrequency) {
+ $variableArray[] = $forSpremenljivka['grids'][0]['variables'][$cnt]['naslov'];
+ $cnt++;
+ foreach ($forSpremenljivka['options'] AS $oKey => $option) {
+
+ # če je osnova checkbox vzamemo samo tam ko je 1
+ if(($forSpremenljivka['tip'] == 2 && $option == 1) || $forSpremenljivka['tip'] != 2 ) {
+
+ $grid_count = 0;
+
+ foreach ($grid['variables'] AS $vkey => $variable) {
+
+ $grid_count++;
+
+ $sequence = $variable['sequence'];
+
+ #povprečja
+ $avg = $this->classInstance->formatNumber($means[$fkey][$oKey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ # enote
+ $enote = (int)$this->break_frequencys[$fkey][$oKey][$sequence]['validCnt'];
+
+ $tempArray = array();
+
+ $tempArray['avg'] = str_replace(",","",$avg);
+ $tempArray['unit'] = $enote;
+ $tempArray['key'] = $variable['variable'];
+ $tempArray['variable'] = $variable['naslov'] . ' ('.$variable['variable'].')';
+
+ $dataArray[] = $tempArray;
+
+ $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$this->break_frequencys[$fkey][$oKey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$this->break_frequencys[$fkey][$oKey][$sequence]['validCnt'];
+
+ }
+ }
+ }
+ }
+ }
+
+ $variable_count = count($variableArray);
+
+ // Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
+ if($settings['rotate'] != 1){
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$grid_count; $j++){
+ $offset = $j*$grid_count;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sortiramo podaatke po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$grid_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ else{
+ for($j=0; $j<($variable_count*$grid_count); $j++){
+ $sorted_keys[] = $j;
+ }
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$variable_count; $j++){
+
+ unset($vrednosti);
+ unset($vrednostiEnote);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ // odmik glede na sortirane po prvem gridu (sort po kategorijah ali brez)
+ if($settings['sort'] < 3){
+ $offset = $sorted_keys[$j] /*$j*/ * $grid_count;
+
+ for($i=0; $i<$grid_count; $i++){
+ $vrednosti[] = $dataArray[$i+$offset]['avg'];
+ $vrednostiEnote[] = $dataArray[$i+$offset]['unit'];
+
+ $vrednostiKey[] = $dataArray[$i+$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$i+$offset]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$sorted_keys[$j]);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$sorted_keys[$j]);
+
+ $DataSet->AddSerie('Vrednosti'.$sorted_keys[$j]);
+ $DataSet->SetSerieName($variableArray[$sorted_keys[$j]],'Vrednosti'.$sorted_keys[$j]);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,'Variable'.$sorted_keys[$j]);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$sorted_keys[$j]);
+ }
+
+ // sort po prvi kategoriji
+ else{
+ for($i=0; $i<$grid_count; $i++){
+ $vrednosti[] = $dataArray[$j*$grid_count + $sorted_keys[$i]]['avg'];
+ $vrednostiEnote[] = $dataArray[$j*$grid_count + $sorted_keys[$i]]['unit'];
+
+ $vrednostiKey[] = $dataArray[$j*$grid_count + $sorted_keys[$i]]['key'];
+ $vrednostiVariable[] = $dataArray[$j*$grid_count + $sorted_keys[$i]]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$j);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$j);
+
+ $DataSet->AddSerie('Vrednosti'.$j);
+ $DataSet->SetSerieName($variableArray[$j],'Vrednosti'.$j);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($vrednostiVariable,'Variable'.$j);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$j);
+ }
+ }
+ }
+ // Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
+ else{
+
+ // Sortiramo podaatke ce je potrebno
+ if($settings['sort'] == 1){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$grid_count; $j++){
+ $offset = $j;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ // Sortiramo podaatke po prvi kategoriji
+ elseif($settings['sort'] == 3){
+
+ $tmp = Array();
+
+ // preberemo prve vrednosti iz vsakega stolpca
+ for($j=0; $j<$variable_count; $j++){
+ $offset = $j * $grid_count;
+ $tmp[] = (int)$dataArray[$offset]['avg'];
+ }
+
+ // sortiramo vrednosti in preberemo kljuce
+ arsort($tmp);
+ $sorted_keys = array_keys($tmp);
+ }
+ else{
+ for($j=0; $j<$grid_count; $j++){
+ $sorted_keys[] = $j;
+ }
+ }
+
+ // Poberemo podatke v posamezne tabele
+ for($j=0; $j<$grid_count; $j++){
+
+ // odmik glede na sortirane po prvem gridu (sort po kategorijah ali brez)
+ if($settings['sort'] < 3){
+ $offset = $sorted_keys[$j];
+
+ unset($vrednosti);
+ unset($vrednostiEnote);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ for($i=0; $i<$variable_count; $i++){
+
+ $vrednosti[] = $dataArray[$i*$grid_count+$offset]['avg'];
+ $vrednostiEnote[] = $dataArray[$i*$grid_count+$offset]['unit'];
+
+ $vrednostiKey[] = $dataArray[$i*$grid_count+$offset]['key'];
+ $vrednostiVariable[] = $dataArray[$i*$grid_count+$offset]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$vrednostiKey[0]);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$vrednostiKey[0]);
+
+ $DataSet->AddSerie('Vrednosti'.$vrednostiKey[0]);
+ $DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti'.$vrednostiKey[0]);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($variableArray,'Variable'.$vrednostiKey[0]);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$vrednostiKey[0]);
+ }
+
+ // sort po prvi kategoriji
+ else{
+ $offset = $sorted_keys[$j];
+
+ unset($vrednosti);
+ unset($vrednostiEnote);
+ unset($vrednostiKey);
+ unset($vrednostiVariable);
+
+ for($i=0; $i<$variable_count; $i++){
+
+ $vrednosti[] = $dataArray[$sorted_keys[$i]*$grid_count + $j]['avg'];
+ $vrednostiEnote[] = $dataArray[$sorted_keys[$i]*$grid_count + $j]['unit'];
+
+ $vrednostiKey[] = $dataArray[$sorted_keys[$i]*$grid_count + $j]['key'];
+ $vrednostiVariable[] = $dataArray[$sorted_keys[$i]*$grid_count + $j]['variable'];
+ }
+
+ if(count($vrednosti) > 0)
+ $DataSet->AddPoint($vrednosti,'Vrednosti'.$vrednostiKey[0]);
+ else
+ $DataSet->AddPoint(array(0),'Vrednosti'.$vrednostiKey[0]);
+
+ $DataSet->AddSerie('Vrednosti'.$vrednostiKey[0]);
+ $DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti'.$vrednostiKey[0]);
+
+ // Vedno izpisemo cela imena variabel
+ $DataSet->AddPoint($variableArray,'Variable'.$vrednostiKey[0]);
+ //$DataSet->AddPoint($vrednostiKey,"Variable");
+
+ $DataSet->SetAbsciseLabelSerie('Variable'.$vrednostiKey[0]);
+ }
+ }
+ }
+
+ return $DataSet;
+ }
+
+ public function setBreakVariables($forSpr,$frequencys,$spremenljivka){
+
+ $this->break_forSpr = $forSpr;
+ $this->break_frequencys = $frequencys;
+ $this->break_spremenljivka = $spremenljivka;
+ }
+
+
+ // Default nastavitve grafov
+ public function getDefaultSettings(){
+
+ $colors = array_fill(0, 6, '');
+
+ $settings = array(
+ 'type' => 0, // tip radarja
+ 'sort' => 0, // sortiranje po velikosti
+ 'value_type' => 0, // tip vrednosti (veljavni, frekvence, procenti...)
+ 'show_legend' => 0, // prikaz legende
+ 'scale_limit' => 0, // zacni skalo z 0 / z najmanjso vrednostjo pri numericih
+ 'interval' => 10, // stevilo intervalov pri numericih
+ 'radar_type' => 0, // tip radarj (crte / liki)
+ 'radar_scale' => 0, // skala pri radarju (na osi / diagonalno)
+ 'labelWidth' => 50, // sirina label (50% / 20%)
+ 'barLabel' => 1, // prikaz label v stolpicnih grafih
+ 'rotate' => 0, // obrnjeni gridi in variable (pri multinumber...)
+ 'hq' => 1, // visoka locljivost grafa
+ 'show_numerus' => 1, // prikaz numerusa
+ 'colors' => $colors // custom barve grafa
+ );
+
+ return $settings;
+ }
+
+ // ID grafa glede na podstran
+ public function getChartID(){
+ global $lang;
+
+ // crosstab
+ if($this->podstran == 'crosstab' || ($this->podstran == 'break' && $this->break_crosstab == 1)){
+ $variables1 = $this->classInstance->getSelectedVariables(2);
+ $variables2 = $this->classInstance->getSelectedVariables(1);
+ $counter = 0;
+ $var1 = array();
+ $var2 = array();
+ foreach ($variables1 AS $v_first) {
+ foreach ($variables2 AS $v_second) {
+ if($counter == $this->counter){
+ $var1 = $v_first;
+ $var2 = $v_second;
+
+ break 2;
+ }
+ else
+ $counter++;
+ }
+ }
+
+ // Zgeneriramo id vsake tabele (glede na izbrani spremenljivki za generiranje)
+ $chartID = implode('_', $var1).'_'.implode('_', $var2);
+ $chartID .= '_counter_'.$this->counter;
+ }
+
+ // ttest
+ elseif($this->podstran == 'ttest'){
+ // Zgeneriramo id vsake tabele (glede na izbrani spremenljivki za generiranje)
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+ $sub1 = $this->sessionData['ttest']['sub_conditions'][0];
+ $sub2 = $this->sessionData['ttest']['sub_conditions'][1];
+
+ $spid2 = $this->sessionData['ttest']['spr2'];
+ $seq2 = $this->sessionData['ttest']['seq2'];
+ $grid2 = $this->sessionData['ttest']['grid2'];
+
+ $chartID = $sub1.'_'.$sub2.'_'.$spid1.'_'.$seq1.'_'.$grid1;
+ }
+
+ // means
+ elseif($this->podstran == 'mean'){
+ // Zgeneriramo id vsake tabele (glede na izbrani spremenljivki za generiranje)
+ $variables1 = $this->classInstance->getSelectedVariables(1);
+ $variables2 = $this->classInstance->getSelectedVariables(2);
+
+ $pos1 = floor($this->counter / count($variables2));
+ $pos2 = $this->counter % count($variables2);
+
+ $chartID = implode('_', $variables1[$pos1]).'_'.implode('_', $variables2[$pos2]);
+ $chartID .= '_counter_'.$this->counter;
+ }
+
+ // break
+ else{
+ if($this->break_spremenljivka['tip'] == 20){
+ // Preberemo za kateri grid izrisujemo tabelo
+ $gkey = $this->break_spremenljivka['break_sub_table']['key'];
+
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $this->break_spremenljivka['grids'][$gkey]['variables'][0]['sequence'].'-'.$this->break_spremenljivka['id'].'-undefined';
+ }
+ else{
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $this->break_spremenljivka['grids'][0]['variables'][0]['sequence'].'-'.$this->break_spremenljivka['id'].'-undefined';
+ }
+
+ $chartID = $spr1.'_'.$spr2;
+ }
+
+ return $chartID;
+ }
+
+ // Zgeneriramo unikaten hash ID grafa
+ public function generateChartId($chartID, $settings, $numerus){
+
+ // ce posebej prizgemo legendo pri pie chartu
+ if($settings['show_legend'] == 1 && ($settings['type'] == 2 || $settings['type'] == 5))
+ $legend = '_legend';
+ else
+ $legend = '';
+
+ $ID = $this->anketa.'_chart_'.$chartID.'_counter_'.$counter.'_mv_'.SurveyAnalysis::$missingProfileData['display_mv_type'];
+
+ foreach ($settings AS $key => $val) {
+ if($key == 'colors'){
+
+ $ID .= '_colors';
+
+ foreach ($val AS $colKey => $color){
+ $ID .= '_'.$color;
+ }
+ }
+
+ elseif($key != 'name')
+ $ID .= '_'.$key.'_'.$val;
+ }
+
+ $ID .= '_skin_'.$this->skin;
+
+ $ID .= '_numerus_'.$numerus.'_numerusText_'.SurveyDataSettingProfiles :: getSetting('chartNumerusText');
+
+ $ID .= '_pieZeros_'.SurveyDataSettingProfiles :: getSetting('chartPieZeros');
+
+ $ID .= '_chartFontSize_'.SurveyDataSettingProfiles :: getSetting('chartFontSize');
+
+ //$ID .= '_hq_'.$this->quality;
+
+ return $ID;
+ }
+
+ // nastavimo prave barve ustrezne skinu
+ public function setChartColors($chart, $skin){
+
+ // Ce nimmo posebej nastavljenih barv
+ if($this->settings['colors'][0] == ''){
+ // ce je nastavljen globalen custom skin
+ if(is_numeric($skin)){
+ $skin = SurveyChart::getCustomSkin($skin);
+ $colors = explode('_', $skin['colors']);
+
+ $count = 0;
+ foreach($colors as $color){
+
+ $rgb = SurveyChart::html2rgb($color);
+ $chart->setColorPalette($count,$rgb[0],$rgb[1],$rgb[2]);
+
+ $count++;
+ }
+ }
+
+ // imamo nastavljenega enega od default skinov
+ else{
+ switch ($skin){
+
+ // 1ka skin
+ case '1ka':
+ default:
+ $chart->setColorPalette(0,30,136,229);
+ $chart->setColorPalette(1,255,166,8);
+ $chart->setColorPalette(2,72,229,194);
+ $chart->setColorPalette(3,242,87,87);
+ $chart->setColorPalette(4,117,70,68);
+ $chart->setColorPalette(5,248,202,0);
+ $chart->setColorPalette(6,255,112,166);
+ break;
+
+ // zivahen skin
+ case 'lively':
+ $chart->setColorPalette(0,224,9,13);
+ $chart->setColorPalette(1,4,23,227);
+ $chart->setColorPalette(2,0,255,8);
+ $chart->setColorPalette(3,255,247,3);
+ $chart->setColorPalette(4,255,149,0);
+ $chart->setColorPalette(5,0,251,255);
+ $chart->setColorPalette(6,166,0,255);
+ break;
+
+ // blag skin
+ case 'mild':
+ $chart->setColorPalette(0,188,224,46);
+ $chart->setColorPalette(1,224,100,46);
+ $chart->setColorPalette(2,224,214,46);
+ $chart->setColorPalette(3,46,151,224);
+ $chart->setColorPalette(4,176,46,224);
+ $chart->setColorPalette(5,224,46,117);
+ $chart->setColorPalette(6,92,224,46);
+ break;
+
+ // Office skin
+ case 'office':
+ $chart->setColorPalette(0,79,129,189);
+ $chart->setColorPalette(1,192,80,77);
+ $chart->setColorPalette(2,155,187,89);
+ $chart->setColorPalette(3,128,100,162);
+ $chart->setColorPalette(4,75,172,198);
+ $chart->setColorPalette(5,247,150,70);
+ $chart->setColorPalette(6,146,169,207);
+ break;
+
+ // Pastel skin
+ case 'pastel':
+ $chart->setColorPalette(0,121,159,11);
+ $chart->setColorPalette(1,215,161,37);
+ $chart->setColorPalette(2,146,100,190);
+ $chart->setColorPalette(3,24,132,132);
+ $chart->setColorPalette(4,76,198,139);
+ $chart->setColorPalette(5,138,136,35);
+ $chart->setColorPalette(6,108,153,210);
+ break;
+
+ // zelen skin
+ case 'green':
+ $chart->createColorGradientPalette(168,188,56,248,255,136,5);
+ $chart->setColorPalette(5,255,255,0);
+ $chart->setColorPalette(6,232,3,182);
+ break;
+
+ // moder skin
+ case 'blue':
+ $chart->createColorGradientPalette(82,124,148,174,216,240,5);
+ $chart->setColorPalette(5,255,255,0);
+ $chart->setColorPalette(6,232,3,182);
+ break;
+
+ // rdeč skin
+ case 'red':
+ $chart->createColorGradientPalette(255,0,0,80,10,10,5);
+ $chart->setColorPalette(5,255,255,0);
+ $chart->setColorPalette(6,232,3,182);
+ break;
+
+ // skin za vec kot 5 moznosti
+ case 'multi':
+ $chart->setColorPalette(0,140,0,0);
+ $chart->setColorPalette(1,240,8,0);
+ $chart->setColorPalette(2,255,138,130);
+ $chart->setColorPalette(3,242,196,200);
+ $chart->setColorPalette(4,11,3,135);
+ $chart->setColorPalette(5,4,0,252);
+ $chart->setColorPalette(6,151,148,242);
+ $chart->setColorPalette(7,0,133,31);
+ $chart->setColorPalette(8,24,217,3);
+ $chart->setColorPalette(9,139,245,157);
+ $chart->setColorPalette(10,237,202,45);
+ $chart->setColorPalette(11,253,255,120);
+ $chart->setColorPalette(12,156,0,125);
+ $chart->setColorPalette(13,255,0,246);
+ $chart->setColorPalette(14,242,3,162);
+ $chart->setColorPalette(15,237,154,216);
+ $chart->setColorPalette(16,0,123,145);
+ $chart->setColorPalette(17,0,204,250);
+ $chart->setColorPalette(18,174,238,245);
+ $chart->setColorPalette(19,0,255,200);
+ $chart->setColorPalette(20,255,111,0);
+ $chart->setColorPalette(21,255,162,0);
+ $chart->setColorPalette(22,255,201,120);
+ $chart->setColorPalette(23,161,92,133);
+ $chart->setColorPalette(24,205,159,245);
+ $chart->setColorPalette(25,179,245,103);
+ $chart->setColorPalette(26,135,171,108);
+ $chart->setColorPalette(27,73,132,145);
+ $chart->setColorPalette(28,70,96,99);
+ $chart->setColorPalette(29,156,95,103);
+ break;
+ }
+ }
+ }
+ else{
+ for($i=0; $i<7; $i++){
+
+ $color = $this->settings['colors'][$i];
+ $color = substr($color, 1);
+
+ list($r, $g, $b) = array($color[0].$color[1], $color[2].$color[3], $color[4].$color[5]);
+
+ $r = hexdec($r);
+ $g = hexdec($g);
+ $b = hexdec($b);
+
+ $chart->setColorPalette($i,$r,$g,$b);
+ }
+ }
+
+ return $chart;
+ }
+
+
+ // Funkcije za izris posameznih tipov grafov - vertikalni stolpci
+ function createVerBars($DataSet, $show_legend=0){
+ global $lang;
+
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+
+ $angle = 0;
+ $addHeight = 0;
+ $roundText = 15;
+ if($countGrids > 5){
+ $angle = 45;
+ $addHeight = 110;
+ $roundText = 30;
+ }
+
+ // Initialise the graph
+ $Test = new pChart($this->settings['hq']*800,$this->settings['hq']*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ $Test->setGraphArea($this->settings['hq']*100,$this->settings['hq']*40,$this->settings['hq']*650,$this->settings['hq']*220);
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
+ $Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Draw the bar graph
+ $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), false, 95, $this->settings['barLabel']);
+
+ if($show_legend == 1)
+ $Test->drawLegend($this->settings['hq']*680,$this->settings['hq']*30,$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ // Prikaz napisa frekvence/odstotki (samo crosstabi)
+ if($this->podstran == 'crosstab'){
+ if($this->settings['value_type'] == '0')
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*210,$this->settings['hq']*60,$this->settings['hq']*110,$lang['srv_chart_percent'],$Angle=90,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ else
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*210,$this->settings['hq']*60,$this->settings['hq']*110,$lang['srv_chart_freq'],$Angle=90,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - horizontalni stolpci
+ function createHorBars($DataSet, $show_legend=0, $fixedScale=0){
+ global $lang;
+
+ // Nastavimo visino grafa (ce imamo vec kot 7 variabel/gridov)
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+ $addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
+
+ // Initialise the graph
+ $Test = new MyHorBar($this->settings['hq']*800,$this->settings['hq']*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Dolge labele
+ $startX = ($this->settings['labelWidth'] == 20) ? 225 : 360;
+ $roundText = ($this->settings['labelWidth'] == 20) ? 35 : 65;
+
+ $Test->setGraphArea($this->settings['hq']*$startX,$this->settings['hq']*70,$this->settings['hq']*650,$this->settings['hq']*(220+$addHeight));
+
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+ // Če gre za hierarhijo, potem je fiksna skala
+ if(SurveyInfo::checkSurveyModule('hierarhija', $this->anketa))
+ $Test->setFixedScale(1,5,4);
+
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,0,0,TRUE,1,FALSE,$roundText);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Draw the bar graph
+ $Test->drawHorBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), $this->settings['barLabel']);
+
+ // Finish the graph
+ if($show_legend == 1)
+ $Test->drawLegend($this->settings['hq']*680,$this->settings['hq']*60,$DataSet->GetDataDescription(),255,255,255);
+
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ // Prikaz napisa frekvence in 1. spremenljivke na vrhu (samo crosstabi)
+ if($this->podstran == 'crosstab'){
+ if($this->settings['value_type'] == '0')
+ $Test->drawTextBox($this->settings['hq']*480,$this->settings['hq']*30,$this->settings['hq']*580,$this->settings['hq']*40,$lang['srv_chart_percent'],$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ else
+ $Test->drawTextBox($this->settings['hq']*480,$this->settings['hq']*30,$this->settings['hq']*580,$this->settings['hq']*40,$lang['srv_chart_freq'],$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+
+ $strings = explode('<br />',$this->crosstabVars[1]);
+ $substr1 = (strlen($strings[0]) > 50) ? substr($strings[0], 0, 47).'...' : $strings[0];
+ $substr2 = (strlen($strings[1]) > 50) ? substr($strings[1], 0, 47).'...' : $strings[1];
+
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*20,$this->settings['hq']*280,$this->settings['hq']*30,$substr1,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_CENTER,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*38,$this->settings['hq']*280,$this->settings['hq']*43,$substr2,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_CENTER,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+ // Prikaz t vrednosti pri ttest grafu
+ if($this->podstran == 'ttest' && $this->settings['show_numerus'] == '1'){
+ $t = 't = '.$DataSet->GetNumerus();
+ $Test->drawTextBox($this->settings['hq']*680,$this->settings['hq']*210,$this->settings['hq']*795,$this->settings['hq']*220,$t,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - vertikalni sestavljeni stolpci
+ function createVerStructBars($DataSet){
+ global $lang;
+
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+
+ $angle = 0;
+ $addHeight = 0;
+ $roundText = 15;
+ if($countGrids > 5){
+ $angle = 45;
+ $addHeight = 110;
+ $roundText = 30;
+ }
+
+ // Initialise the graph
+ $Test = new pChart($this->settings['hq']*800,$this->settings['hq']*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Pri navadnem radio in checkbox vprasanju imamo samo en stolpec - zato so dimenzije drugacne
+ /*if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
+ $Test->setGraphArea($this->settings['hq']*250,$this->settings['hq']*40,$this->settings['hq']*500,$this->settings['hq']*220);
+ else*/
+ $Test->setGraphArea($this->settings['hq']*100,$this->settings['hq']*40,$this->settings['hq']*650,$this->settings['hq']*220);
+
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
+ $Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ // Draw the bar graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ $Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), $this->settings['barLabel'], 95);
+
+ $Test->drawLegend($this->settings['hq']*680,$this->settings['hq']*30,$DataSet->GetDataDescription(),255,255,255,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=false,$reverse=true);
+
+ $Test->setFontProperties("Fonts/verdana.ttf",$this->settings['hq']*10);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ // Prikaz napisa frekvence (samo crosstabi)
+ if($this->podstran == 'crosstab'){
+ if($this->settings['value_type'] == '0')
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*210,$this->settings['hq']*60,$this->settings['hq']*110,$lang['srv_chart_percent'],$Angle=90,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ else
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*210,$this->settings['hq']*60,$this->settings['hq']*110,$lang['srv_chart_freq'],$Angle=90,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - horizontalni sestavljeni stolpci
+ function createHorStructBars($DataSet){
+ global $lang;
+
+ // Nastavimo visino graffa (ce imamo vec kot 7 variabel/gridov)
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+ $addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
+
+ // Initialise the graph
+ $Test = new MyHorBar($this->settings['hq']*800,$this->settings['hq']*(250+$addHeight+50));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Dolge labele
+ $startX = ($this->settings['labelWidth'] == 20) ? 225 : 360;
+ $roundText = ($this->settings['labelWidth'] == 20) ? 35 : 65;
+
+ // Pri navadnem radio in checkbox vprasanju imamo samo en stolpec - zato so dimenzije drugacne
+ /*if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3){
+ $Test->setGraphArea($this->settings['hq']*200,$this->settings['hq']*50,$this->settings['hq']*630,$this->settings['hq']*220);
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*243,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*295,200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,0,0,TRUE);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+ }
+ else{*/
+ $Test->setGraphArea($this->settings['hq']*$startX,$this->settings['hq']*70,$this->settings['hq']*650,$this->settings['hq']*(220+$addHeight));
+ $Test->drawFilledRoundedRectangle(7,7,793,243+$addHeight,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*(295+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,0,0,TRUE,1,FALSE,$roundText);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+ //}
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Draw the bar graph
+ $Test->drawStackedHorBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),$this->settings['barLabel'],95);
+
+
+ // pri vodoravnih strukturnih stolpcih izrisemo legendo na dnu
+ $Test->drawVerticalLegend($this->settings['hq']*400,$this->settings['hq']*(240+$addHeight),$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties("Fonts/verdana.ttf",$this->settings['hq']*10);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ // Prikaz napisa frekvence in 1. spremenljivke na vrhu (samo crosstabi)
+ if($this->podstran == 'crosstab'){
+ if($this->settings['value_type'] == '0')
+ $Test->drawTextBox($this->settings['hq']*480,$this->settings['hq']*30,$this->settings['hq']*580,$this->settings['hq']*40,$lang['srv_chart_percent'],$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ else
+ $Test->drawTextBox($this->settings['hq']*480,$this->settings['hq']*30,$this->settings['hq']*580,$this->settings['hq']*40,$lang['srv_chart_freq'],$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+ $strings = explode('<br />',$this->crosstabVars[1]);
+ $substr1 = (strlen($strings[0]) > 50) ? substr($strings[0], 0, 47).'...' : $strings[0];
+ $substr2 = (strlen($strings[1]) > 50) ? substr($strings[1], 0, 47).'...' : $strings[1];
+
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*20,$this->settings['hq']*280,$this->settings['hq']*30,$substr1,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_CENTER,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ $Test->drawTextBox($this->settings['hq']*50,$this->settings['hq']*38,$this->settings['hq']*280,$this->settings['hq']*43,$substr2,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_CENTER,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+ }
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - krozni graf
+ function createPie($DataSet, $show_legend=1){
+ global $lang;
+
+ // Initialise the graph
+ $Test = new pChart($this->settings['hq']*800,$this->settings['hq']*280);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ // Pri pie grafu uporabimo antialiasing
+ $Test->setAntialias(true, 20);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ //$Test->setGraphArea(50,40,685,220);
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*273,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*275,200,200,200);
+ //$Test->createColorGradientPalette(195,204,56,223,110,41,3);
+ //$Test->createColorGradientPalette(168,188,56,248,255,136,5);
+
+ // Draw the pie graph
+ $labels = ($this->settings['sort'] == 1) ? 'custom_percent_sort' : 'custom_percent';
+ $Test->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),$this->settings['hq']*390,$this->settings['hq']*145,$this->settings['hq']*95,$labels);
+
+ $Test->setAntialias(false, 0);
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ //$Test->drawLegend(700,30,$DataSet->GetDataDescription(),255,255,255);
+
+ if($show_legend == 1)
+ $Test->drawPieLegend($this->settings['hq']*600,$this->settings['hq']*50,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*10);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - krozni graf
+ function create3DPie($DataSet, $show_legend=1){
+ global $lang;
+
+ // Initialise the graph
+ $Test = new pChart($this->settings['hq']*800,$this->settings['hq']*280);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ // Pri pie grafu uporabimo antialiasing
+ $Test->setAntialias(true, 20);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ //$Test->setGraphArea(50,40,685,220);
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*273,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*275,200,200,200);
+ //$Test->createColorGradientPalette(195,204,56,223,110,41,3);
+ //$Test->createColorGradientPalette(168,188,56,248,255,136,5);
+
+ // Draw the pie graph
+ $labels = ($this->settings['sort'] == 1) ? 'custom_percent_sort' : 'custom_percent';
+ $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),$this->settings['hq']*390,$this->settings['hq']*130,$this->settings['hq']*95,$labels,$EnhanceColors=true,$Skew=50,$SpliceHeight=$this->settings['hq']*20,$SpliceDistance=0,$Decimals=0);
+
+ $Test->setAntialias(false, 0);
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ //$Test->drawLegend(700,30,$DataSet->GetDataDescription(),255,255,255);
+
+ if($show_legend == 1)
+ $Test->drawPieLegend($this->settings['hq']*600,$this->settings['hq']*50,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*10);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - linijski graf
+ function createVerLine($DataSet, $show_legend=0, $fixedScale=1){
+ global $lang;
+
+ // Nastavimo visino grafa (ce imamo vec kot 7 variabel/gridov)
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+ $addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
+
+ // Initialise the graph
+ $Test = new MyHorBar($this->settings['hq']*800,$this->settings['hq']*(250+$addHeight));
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ $Test->setGraphArea($this->settings['hq']*270,$this->settings['hq']*50,$this->settings['hq']*530,$this->settings['hq']*(220+$addHeight));
+
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*(243+$addHeight),5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*(245+$addHeight),200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+
+
+ /*$VMax = count($spremenljivka['options']);
+ $Divisions = $VMax-1;
+
+ $Test->setFixedScale($VMin=1, $VMax, $Divisions);*/
+
+
+ $Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,0,0,TRUE,1,$rightScale=FALSE,$roundText=40);
+ $Test->drawHorGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*6);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ // Draw the line graph
+ $Test->drawVerLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(), $insideValues=false);
+
+ // Finish the graph
+ if($show_legend == 1)
+ $Test->drawLegend($this->settings['hq']*680,$this->settings['hq']*30,$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - radar
+ function createRadar($DataSet, $show_legend=0, $fixedScale=0){
+ global $lang;
+
+ $Data = $DataSet->GetData();
+ $countGrids = count($Data);
+
+ // Initialise the graph
+ $Test = new pChart($this->settings['hq']*800,$this->settings['hq']*350);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ // Pri radar grafu uporabimo antialiasing
+ $Test->setAntialias(true, 20);
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ $Test->setGraphArea($this->settings['hq']*100,$this->settings['hq']*40,$this->settings['hq']*650,$this->settings['hq']*320);
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*343,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*345,200,200,200);
+ //$Test->drawGraphArea(255,255,255,TRUE);
+ //$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,20,20,20,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
+ //$Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ $VMax = -1;
+
+ // Draw the radar
+ $Test->drawRadarAxis($DataSet->GetData(),$DataSet->GetDataDescription(),true,5,0,0,0,160,160,160,$VMax,$this->settings['radar_scale']);
+ // Tip radarja - navaden ali samo crte
+ if($this->settings['radar_type'] == 1)
+ $Test->drawFilledRadar($DataSet->GetData(),$DataSet->GetDataDescription(),50,5,$VMax);
+ else{
+ $Test->setLineStyle($Width=(2*$this->settings['hq']),$DotSize=0);
+ $Test->drawRadar($DataSet->GetData(),$DataSet->GetDataDescription(),5,$VMax);
+ }
+
+ $Test->setAntialias(false, 0);
+
+ // Finish the graph
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ if($show_legend == 1)
+ $Test->drawLegend($this->settings['hq']*680,$this->settings['hq']*30,$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties("Fonts/verdana.ttf",$this->settings['hq']*10);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+ return $Test;
+ }
+
+ // Funkcije za izris posameznih tipov grafov - linijski graf
+ function createLine($DataSet, $show_legend=0, $fixedScale=0){
+
+ // Initialise the graph
+ $Test = new pChart($this->settings['hq']*800,$this->settings['hq']*280);
+
+ // Nastavimo barve grafu glede na skin
+ $Test = $this->setChartColors($Test, $this->skin);
+
+ $count = count($DataSet->GetData());
+
+ // Kot label na x osi
+ $angle = 0;
+ if($count > 6)
+ $angle = 45;
+
+ $Test->setLineStyle($this->settings['hq'],$DotSize=0);
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ $Test->setGraphArea($this->settings['hq']*100,$this->settings['hq']*40,$this->settings['hq']*650,$this->settings['hq']*220);
+ $Test->drawFilledRoundedRectangle($this->settings['hq']*7,$this->settings['hq']*7,$this->settings['hq']*793,$this->settings['hq']*273,5,255,255,255);
+ //$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
+ $Test->drawRectangle($this->settings['hq']*5,$this->settings['hq']*5,$this->settings['hq']*795,$this->settings['hq']*275,200,200,200);
+ $Test->drawGraphArea(255,255,255,TRUE);
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,$angle,0,TRUE);
+ if($count <= 20)
+ $Test->drawGrid(4,TRUE,230,230,230,50);
+
+ // Draw the 0 line
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+ //$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
+
+ // Draw the bar graph
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
+ if($count <= 20)
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),$this->settings['hq']*3,$this->settings['hq']*2,255,255,255);
+
+ if($show_legend == 1)
+ $Test->drawLegend($this->settings['hq']*680,$this->settings['hq']*30,$DataSet->GetDataDescription(),255,255,255);
+
+ $Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',$this->settings['hq']*$this->fontSize);
+
+
+ $Test->drawTextBox($this->settings['hq']*690,$this->settings['hq']*(210+$addHeight),$this->settings['hq']*795,$this->settings['hq']*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
+
+ return $Test;
+ }
+
+
+ // Nastavitve posameznega grafa
+ function displaySingleSettings($chartID, $settings=0){
+ global $site_path;
+ global $lang;
+
+ // Ikone izvoza na vrhu posameznih nastavitev
+ //$this->displayExportIcons($chartID);
+
+
+ echo '<div id="switch_left_'.$chartID.'_loop_0" class="switch_left '.($this->settings_mode == 1 ? ' non-active' : '').'" onClick="chartSwitchSettings(\''.$chartID.'\', \'0\', \'0\')">'.$lang['srv_chart_settings_basic'].'</div>';
+ //echo '<span id="switch_middle_'.$chartID.'_loop_0" class="'.($this->settings_mode == 1 ? 'rightHighlight' : 'leftHighlight').'"></span>';
+ echo '<div id="switch_right_'.$chartID.'_loop_0" class="switch_right '.($this->settings_mode == 0 ? ' non-active' : '').'" onClick="chartSwitchSettings(\''.$chartID.'\', \'1\', \'0\')">'.$lang['srv_chart_settings_advanced'].'</div>';
+
+
+ // OSNOVNE NASTAVITVE
+ echo '<div class="chart_settings_inner" id="chart_settings_basic_'.$chartID.'_loop_0" '.($this->settings_mode == 1 ? ' style="display:none;"' : '').'>';
+
+ //echo '<span class="title">'.$lang['srv_chart_settings'].'</span>';
+
+ switch($this->podstran){
+ case 'crosstab':
+ $this->displayCrosstabSettings($chartID, $settings);
+ break;
+
+ case 'ttest':
+ $this->displayTTestSettings($chartID, $settings);
+ break;
+
+ case 'mean':
+ $this->displayMeanSettings($chartID, $settings);
+ break;
+
+ case 'break':
+ $this->displayBreakSettings($chartID, $settings);
+ break;
+
+ default:
+ break;
+ }
+
+ echo '</div>';
+
+
+ // NAPREDNE NASTAVITVE
+ echo '<div class="chart_settings_inner" id="chart_settings_advanced_'.$chartID.'_loop_0" '.($this->settings_mode == 0 ? ' style="display:none;"' : '').'>';
+
+ switch($this->podstran){
+
+ case 'crosstab':
+ case 'mean':
+ case 'break':
+ // visoka locljivost grafa
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_hq'].': ';
+ echo '<input type="checkbox" id="tablechart_hq_'.$chartID.'" name="tablechart_hq" '.($settings['hq']=='3'?' checked="checked"':'').' onchange="changeTableChart(\''.$chartID.'\', \''.$this->podstran.'\', \'hq\');">';
+
+ echo '</div>';
+ break;
+
+ case 'ttest':
+ // prikaz numerusa
+ echo '<div class="chart_setting">';
+
+ $checked = ($settings['show_numerus']=='1') ? ' checked="checked"': '';
+
+ echo $lang['srv_chart_showNumerus'].': ';
+ echo '<input type="checkbox" id="tablechart_show_numerus_'.$chartID.'" name="tablechart_show_numerus" '.$checked.' onchange="changeTableChart(\''.$chartID.'\', \'ttest\', \'show_numerus\');">';
+
+ echo '</div>';
+
+ default:
+ break;
+ }
+
+
+ // Link na urejanje label
+ //echo '<span class="edit" style="margin-top:15px;" onclick="chartAdvancedSettings(\''.$this->counter.'\');">'.$lang['srv_chart_advancedLink_labels'].'</span>';
+ // Vprasajcek za pomoc
+ //echo Help :: display('displaychart_settings_labels');
+
+ // Link na urejanje barv
+ echo '<span class="edit" onclick="tableChartAdvancedSettings(\''.$chartID.'\', \''.$this->podstran.'\')">'.$lang['srv_chart_advancedLink_colors'].'</span>';
+ // Vprasajcek za pomoc
+ echo Help :: display('displaychart_settings_colors');
+
+ // Link na rekodiranje
+ //echo '<span class="edit" onclick="chartAdvancedSettings(\''.$this->counter.'\', \'3\');">'.$lang['srv_chart_advancedLink_recoding'].'</span>';
+ // Vprasajcek za pomoc
+ //echo Help :: display('displaychart_settings_recoding');
+
+
+ echo '</div>';
+ }
+
+ // ikone na vrhu posameznih nastavitev (izvozi)
+ function displayExportIcons($chartID){
+ global $site_path;
+ global $lang;
+
+ // linki
+ echo '<div class="chart_setting_exportLinks">';
+
+ // Ikona za print
+ echo '<a href="#" onclick="showAnalizaSingleChartPopup(\''.$chartID.'\',\''.M_ANALYSIS_CHARTS.'\'); return false;">';
+ echo '<span class="faicon print_small icon-grey_dark_link" title="' . $lang['PRN_Izpis'] . '"></span>';
+ echo '</a>';
+
+ // Izvoz posameznega grafa v PDF/RTF/PPT
+ echo '&nbsp;<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts&anketa='.$this->anketa.'&sprID='.$chartID).'" target="_blank" title="'.$lang['PDF_Izpis'].'"><span class="faicon pdf"></span>&nbsp;</a>';
+ echo '&nbsp;<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts_rtf&anketa='.$this->anketa.'&sprID='.$chartID).'" target="_blank" title="'.$lang['RTF_Izpis'].'"><span class="faicon rtf"></span>&nbsp;</a>';
+ echo '&nbsp;<a href="'.makeEncodedIzvozUrlString('izvoz.php?m=charts_ppt&anketa='.$this->anketa.'&sprID='.$chartID).'" target="_blank" title="'.$lang['PPT_Izpis'].'"><span class="faicon ppt"></span>&nbsp;</a>';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za crosstab graf
+ function displayCrosstabSettings($chartID, $settings){
+ global $site_path;
+ global $lang;
+
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="tablechart_type_'.$chartID.'" name="tablechart_type" onchange="changeTableChart(\''.$chartID.'\', \'crosstab\', \'type\');">';
+
+ if($this->crossCheck){
+ // navedbe
+ if($this->classInstance->crossNavVsEno == 0){
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_pie'].'</option>';
+ echo ' <option value="5" '.($settings['type']=='5'?' selected="selected"':'').'>'.$lang['srv_chart_3Dpie'].'</option>';
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_structure_hor'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_structure_ver'].'</option>';
+ }
+ // enote
+ else{
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_structure_hor'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_structure_ver'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ }
+ }
+ else{
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_structure_hor'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_structure_ver'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="4" '.($settings['type']=='4'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ }
+
+ echo '</select>';
+ echo '</div>';
+
+
+ // tip izpisa vrednosti
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_valtype'].': <select id="tablechart_value_type_'.$chartID.'" name="tablechart_value_type" onchange="changeTableChart(\''.$chartID.'\', \'crosstab\', \'value_type\');">';
+
+ echo ' <option value="0" '.($settings['value_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_percent'].'</option>';
+ echo ' <option value="1" '.($settings['value_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_freq'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+
+ // prikaz label v stolpcih
+ //if($settings['type'] == 0 || $settings['type'] == 1){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_barLabel'].': ';
+ echo '<input type="checkbox" id="tablechart_barLabel_'.$chartID.'" name="tablechart_barLabel" '.($settings['barLabel']=='1'?' checked="checked"':'').' onchange="changeTableChart(\''.$chartID.'\', \'crosstab\', \'barLabel\');">';
+
+ echo '</div>';
+ //}
+
+
+ // sirina label
+ /*if($settings['type'] == 0 || $settings['type'] == 3){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="tablechart_labelWidth_'.$chartID.'" name="tablechart_labelWidth" onchange="changeTableChart(\''.$chartID.'\', \'crosstab\', \'labelWidth\');">';
+
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }*/
+ }
+
+ // Nastavitve za ttest graf
+ function displayTTestSettings($chartID, $settings){
+ global $site_path;
+ global $lang;
+
+ // sirina label
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="tablechart_labelWidth_'.$chartID.'" name="tablechart_labelWidth" onchange="changeTableChart(\''.$chartID.'\', \'ttest\', \'labelWidth\');">';
+
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+
+
+ // visoka locljivost grafa
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_hq'].': ';
+ echo '<input type="checkbox" id="tablechart_hq_'.$chartID.'" name="tablechart_hq" '.($settings['hq']=='3'?' checked="checked"':'').' onchange="changeTableChart(\''.$chartID.'\', \'ttest\', \'hq\');">';
+
+ echo '</div>';
+ }
+
+ // Nastavitve za mean graf
+ function displayMeanSettings($chartID, $settings){
+ global $site_path;
+ global $lang;
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="tablechart_type_'.$chartID.'" name="tablechart_type" onchange="changeTableChart(\''.$chartID.'\', \'mean\', \'type\');">';
+
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_avg_hor'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_avg_radar'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_avg_line'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+
+ // sortiranje
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': ';
+ echo '<input type="checkbox" id="tablechart_sort_'.$chartID.'" name="tablechart_sort" '.($settings['sort']=='1'?' checked="checked"':'').' onchange="changeTableChart(\''.$chartID.'\', \'mean\', \'sort\');">';
+
+ echo '</div>';
+
+
+ // sirina label
+ if($settings['type'] == 0){
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_wide_chart'].': <select id="tablechart_labelWidth_'.$chartID.'" name="tablechart_labelWidth" onchange="changeTableChart(\''.$chartID.'\', \'mean\', \'labelWidth\');">';
+
+ echo ' <option value="50" '.($settings['labelWidth']=='50'?' selected="selected"':'').'>50%</option>';
+ echo ' <option value="20" '.($settings['labelWidth']=='20'?' selected="selected"':'').'>20%</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+ }
+
+
+ // Tip radarja
+ if($settings['type'] == 1){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="tablechart_radar_type_'.$chartID.'" name="tablechart_radar_type" onchange="changeTableChart(\''.$chartID.'\', \'mean\', \'radar_type\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == 1){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="tablechart_radar_scale_'.$chartID.'" name="tablechart_radar_scale" onchange="changeTableChart(\''.$chartID.'\', \'mean\', \'radar_scale\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+ }
+
+ // Nastavitve za crosstab graf
+ function displayBreakSettings($chartID, $settings){
+ global $site_path;
+ global $lang;
+
+ $tip = $this->break_spremenljivka['tip'];
+
+ // Tip grafa
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_type'].':<br /> <select style="width:140px;" id="tablechart_type_'.$chartID.'" name="tablechart_type" onchange="changeTableChart(\''.$chartID.'\', \'break\', \'type\');">';
+
+ if($tip != 7)
+ echo ' <option value="0" '.($settings['type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar'].'</option>';
+ echo ' <option value="1" '.($settings['type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_vertical'].'</option>';
+ echo ' <option value="2" '.($settings['type']=='2'?' selected="selected"':'').'>'.$lang['srv_chart_horizontal'].'</option>';
+ echo ' <option value="3" '.($settings['type']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_line'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+
+ // sortiranje
+ echo '<div class="chart_setting">';
+
+ echo $lang['srv_chart_sort'].': <select id="tablechart_sort_'.$chartID.'" name="tablechart_sort" onchange="changeTableChart(\''.$chartID.'\', \'break\', \'sort\');">';
+
+ echo ' <option value="0" '.($settings['sort']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_sort_no'].'</option>';
+ if($tip != 7)
+ echo ' <option value="1" '.($settings['sort']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_sort_category'].'</option>';
+ echo ' <option value="3" '.($settings['sort']=='3'?' selected="selected"':'').'>'.$lang['srv_chart_sort_first'].'</option>';
+
+ echo '</select>';
+
+ echo '</div>';
+
+ // Obrnjeni gridi in variable
+ echo '<div class="chart_setting">';
+
+ if($settings['rotate']=='1'){
+ echo $lang['srv_chart_rotate_grids'].' ';
+ echo '<span onclick="changeTableChart(\''.$chartID.'\', \'break\', \'rotate\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="tablechart_rotate_'.$chartID.'" name="tablechart_rotate" value="0">';
+ echo ' '.$lang['srv_chart_rotate_vars'].' ';
+ }
+ else{
+ echo $lang['srv_chart_rotate_vars'].' ';
+ echo '<span onclick="changeTableChart(\''.$chartID.'\', \'break\', \'rotate\');" style="cursor: pointer;"><img src="img_0/random_off.png" title="Obrni grafe/variable" /></span>';
+ echo '<input type="hidden" id="tablechart_rotate_'.$chartID.'" name="tablechart_rotate" value="1">';
+ echo ' '.$lang['srv_chart_rotate_grids'];
+ }
+ echo '</div>';
+
+ // Tip radarja
+ if($settings['type'] == '0'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_type'].': <select id="tablechart_radar_type_'.$chartID.'" name="tablechart_radar_type" onchange="changeTableChart(\''.$chartID.'\', \'break\', \'radar_type\');">';
+
+ echo ' <option value="0" '.($settings['radar_type']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_type']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_type1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+
+ // Postavitev skale pri radarju
+ if($settings['type'] == '0'){
+ echo '<div class="chart_setting">';
+ echo $lang['srv_chart_radar_scale'].': <select id="tablechart_radar_scale_'.$chartID.'" name="tablechart_radar_scale" onchange="changeTableChart(\''.$chartID.'\', \'break\', \'radar_scale\');">';
+
+ echo ' <option value="0" '.($settings['radar_scale']=='0'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale0'].'</option>';
+ echo ' <option value="1" '.($settings['radar_scale']=='1'?' selected="selected"':'').'>'.$lang['srv_chart_radar_scale1'].'</option>';
+
+ echo '</select>';
+ echo '</div>';
+ }
+ }
+
+ // Napredne nastavitve grafa
+ function displayAdvancedSettings($chartID){
+ global $site_path;
+ global $lang;
+
+ echo '<h2>'.$lang['srv_detail_settings'].'</h2>';
+
+ echo '<div class="popup_close"><a href="#" onClick="chartCloseAdvancedSettings(); return false;">✕</a></div>';
+
+ echo '<form method="post" name="table_chart_advanced_settings" onsubmit="tableChartSaveAdvancedSettings(\''.$chartID.'\'); return false;">';
+
+ echo '<input type="hidden" name="anketa" value="'.$this->anketa.'" />';
+ echo '<input type="hidden" name="podstran" value="'.$this->podstran.'" />';
+ echo '<input type="hidden" name="chartID" value="'.$chartID.'" />';
+
+ // urejanje barv
+ echo '<div id="chartSettingsArea1" class="chartSettingsArea">';
+ $this->displayAdvancedSettingsColors($chartID);
+ echo '</div>';
+
+ // urejanje label
+ echo '<div id="chartSettingsArea2" class="chartSettingsArea" style="visibility: hidden;">';
+ //$this->displayAdvancedSettingsLabels($chartID);
+ echo '</div>';
+
+ echo '</form>';
+
+ /* ZAVIHKI NA DESNI */
+ echo '<div id="chartTabs" class="chartSettingsTabs">';
+
+ echo '<ul>';
+ echo '<li id="chartTab1" class="chartTab active" onClick="chartTabAdvancedSettings(\'1\');">';
+ echo $lang['srv_chart_advanced_colors'];
+ echo '</li>';
+ echo '</ul>';
+
+ echo '</div>';
+
+
+ /* GUMBI NA DNU */
+ echo '<div id="chartSettingsButtons" class="buttons_holder">';
+
+ echo '<span class="buttonwrapper spaceRight floatLeft">';
+ echo '<a class="ovalbutton ovalbutton_gray" onclick="chartCloseAdvancedSettings(); return false;"><span>'.$lang['srv_zapri'].'</span></a>';
+ echo '</span>';
+
+ echo '<span class="buttonwrapper floatLeft">';
+ echo '<a class="ovalbutton ovalbutton_orange" onclick="tableChartSaveAdvancedSettings(\''.$chartID.'\'); return false;"><span>'.$lang['srv_potrdi'].'</span></a>';
+ echo '</span>';
+
+ echo '</div>';
+ }
+
+ // Urejanje barv posameznega grafa
+ function displayAdvancedSettingsColors($chartID){
+ global $site_path;
+ global $lang;
+
+ echo '<script type="text/javascript" charset="utf-8">
+ $(document).ready(function() {
+ var f = $.farbtastic(\'#picker\');
+ var p = $(\'#picker\').css(\'opacity\', 0.25);
+ var selected;
+ $(\'.colorwell\')
+ .each(function () { f.linkTo(this); $(this).css(\'opacity\', 0.75); })
+ .focus(function() {
+ if (selected) {
+ $(selected).css(\'opacity\', 0.75).removeClass(\'colorwell-selected\');
+ }
+ f.linkTo(this);
+ p.css(\'opacity\', 1);
+ $(selected = this).css(\'opacity\', 1).addClass(\'colorwell-selected\');
+ });
+ });
+ </script>';
+
+
+ echo ' <div id="picker" style="float: right;"></div>';
+
+ $default_colors = SurveyChart::getDefaultColors($this->skin);
+
+ for($i=0; $i<7; $i++){
+ $name = 'color'.($i+1);
+ $value = ($this->settings['colors'][$i] != '') ? $this->settings['colors'][$i] : $default_colors[$i];
+
+ echo ' <div class="form-item"><label for="'.$name.'">'.$lang['srv_color'].' '.($i+1).': </label><input type="text" id="'.$name.'" name="'.$name.'" class="colorwell" value="'.$value.'" /></div>';
+ }
+
+ // reset na default barvo
+ echo '<br /><span class="as_link clr" onClick="chartAdvancedSettingsSetColor(\''.(is_numeric($this->skin) ? implode("_",$default_colors) : $this->skin).'\')">'.$lang['srv_chart_advanced_default_color'].'</span>';
+
+ // nastavitev ene od palet
+ echo '<br /><span class="clr">'.$lang['srv_chart_advanced_skin'].': ';
+ echo '<select name="chart_advanced_color" id="chart_advanced_color" onChange="chartAdvancedSettingsSetColor(this.value)">';
+ echo ' <option' . ($this->skin == '1ka' ? ' selected="selected"' : '') . ' value="1ka">'.$lang['srv_chart_skin_1ka'].'</option>';
+ echo ' <option' . ($this->skin == 'lively' ? ' selected="selected"' : '') . ' value="lively">'.$lang['srv_chart_skin_0'].'</option>';
+ echo ' <option' . ($this->skin == 'mild' ? ' selected="selected"' : '') . ' value="mild">'.$lang['srv_chart_skin_1'].'</option>';
+ echo ' <option' . ($this->skin == 'office' ? ' selected="selected"' : '') . ' value="office">'.$lang['srv_chart_skin_6'].'</option>';
+ echo ' <option' . ($this->skin == 'pastel' ? ' selected="selected"' : '') . ' value="pastel">'.$lang['srv_chart_skin_7'].'</option>';
+ echo ' <option' . ($this->skin == 'green' ? ' selected="selected"' : '') . ' value="green">'.$lang['srv_chart_skin_2'].'</option>';
+ echo ' <option' . ($this->skin == 'blue' ? ' selected="selected"' : '') . ' value="blue">'.$lang['srv_chart_skin_3'].'</option>';
+ echo ' <option' . ($this->skin == 'red' ? ' selected="selected"' : '') . ' value="red">'.$lang['srv_chart_skin_4'].'</option>';
+ echo ' <option' . ($this->skin == 'multi' ? ' selected="selected"' : '') . ' value="multi">'.$lang['srv_chart_skin_5'].'</option>';
+
+ $customSkins = $this->getCustomSkins();
+ foreach($customSkins as $customSkin){
+ echo ' <option' . ($this->skin == $customSkin['id'] ? ' selected="selected"' : '') . ' value="'.$customSkin['colors'].'">'.$customSkin['name'].'</option>';
+ }
+ echo '</select></span>';
+ }
+
+ function getCustomSkins(){
+ global $global_user_id;
+
+ $skins = array();
+
+ $sql = sisplet_query("SELECT * FROM srv_chart_skin WHERE usr_id='$global_user_id'");
+ while($row = mysqli_fetch_array($sql)){
+ $skins[] = $row;
+ }
+
+ return $skins;
+ }
+
+
+ /** Funkcije ki skrbijo za ajax del
+ *
+ */
+ public function ajax() {
+
+ if (isset ($_POST['anketa'])) {
+ $anketa = $_POST['anketa'];
+ $this->anketa = $_POST['anketa'];
+ }
+ if (isset ($_POST['chartID']))
+ $chartID = $_POST['chartID'];
+ if (isset ($_POST['chart_type']))
+ $chart_type = $_POST['chart_type'];
+ if (isset ($_POST['podstran']))
+ $this->podstran = $_POST['podstran'];
+
+
+ // dobimo vse nastavitve iz sessiona
+ if(isset($this->sessionData[$this->podstran.'_charts'][$chartID]))
+ $this->settings = $this->sessionData[$this->podstran.'_charts'][$chartID];
+ else
+ $this->settings = $this->getDefaultSettings();
+
+
+ if (isset ($_POST['what']))
+ $what = $_POST['what'];
+ if (isset ($_POST['value']))
+ $value = $_POST['value'];
+
+ $this->settings[$what] = $value;
+ $this->sessionData[$this->podstran.'_charts'][$chartID] = $this->settings;
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ if ($_GET['a'] == 'table_chart_advanced_settings') {
+ $this->displayAdvancedSettings($chartID);
+ }
+
+ if ($_GET['a'] == 'chart_save_advanced_settings') {
+ // SHRANIMO BARVE
+ // preverimo najprej ce shranjujemo vrednosti, ki so enake kot izbran skin
+ $default = true;
+ $default_colors = SurveyChart::getDefaultColors($this->skin);
+ for($i=1; $i<8; $i++){
+ if($_POST['color'.$i] != $default_colors[$i-1]){
+ $default = false;
+ break;
+ }
+ }
+ for($i=1; $i<8; $i++){
+
+ // ce niso default vrednosti shranimo nastavljeno barvo
+ if($default == false)
+ $color = $_POST['color'.$i];
+ // ce so default vrednosti shranimo prazno
+ else
+ $color = '';
+
+ $this->settings['colors'][$i-1] = $color;
+ }
+
+ $this->sessionData[$this->podstran.'_charts'][$chartID] = $this->settings;
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+ }
+
+ // Globalne nastavitve za vse grafe
+ if ($_GET['a'] == 'change_global_settings') {
+ SurveyUserSetting :: getInstance()->saveSettings('default_chart_profile_'.$what, $value);
+ //$this->display();
+ }
+
+ if ($_GET['a'] == 'change_chart') {
+ if($this->podstran == 'break'){
+ $this->classInstance = new SurveyBreak($this->anketa);
+
+ $this->break_forSpr = $this->sessionData['break_charts'][$chartID]['forSpr'];
+ $this->break_frequencys = $this->sessionData['break_charts'][$chartID]['frequencys'];
+ $this->break_spremenljivka = $this->sessionData['break_charts'][$chartID]['spremenljivka'];
+ }
+
+ // imamo crosstab graf
+ else{
+ $this->classInstance = new SurveyCrosstabs();
+ $this->classInstance->Init($this->anketa);
+
+ // Napolnimo podatke crosstabu
+ $crossData1 = $this->sessionData['crosstab_charts'][$chartID]['spr1'];
+ $crossData2 = $this->sessionData['crosstab_charts'][$chartID]['spr2'];
+
+ $this->classInstance->setVariables($crossData1['seq'],$crossData1['spr'],$crossData1['grd'],$crossData2['seq'],$crossData2['spr'],$crossData2['grd']);
+
+ $this->break_spremenljivka['tip'] = 1;
+ $this->break_spremenljivka['skala'] = 0;
+ }
+
+ $this->displayBreakChart($chartID);
+ }
+
+ if ($_GET['a'] == 'chart_reload_advanced_settings') {
+ // SHRANIMO BARVE
+ // preverimo najprej ce shranjujemo vrednosti, ki so enake kot izbran skin
+ $default = true;
+ $default_colors = SurveyChart::getDefaultColors($this->skin);
+ for($i=1; $i<8; $i++){
+ if($_POST['color'.$i] != $default_colors[$i-1]){
+ $default = false;
+ break;
+ }
+ }
+ for($i=1; $i<8; $i++){
+
+ // ce niso default vrednosti shranimo nastavljeno barvo
+ if($default == false)
+ $color = $_POST['color'.$i];
+ // ce so default vrednosti shranimo prazno
+ else
+ $color = '';
+
+ $this->settings['colors'][$i-1] = $color;
+ }
+
+ $this->sessionData[$this->podstran.'_charts'][$chartID] = $this->settings;
+
+ if($this->podstran == 'break'){
+ $this->classInstance = new SurveyBreak($this->anketa);
+
+ $this->break_forSpr = $this->sessionData['break_charts'][$chartID]['forSpr'];
+ $this->break_frequencys = $this->sessionData['break_charts'][$chartID]['frequencys'];
+ $this->break_spremenljivka = $this->sessionData['break_charts'][$chartID]['spremenljivka'];
+ }
+
+ // imamo crosstab graf
+ else{
+ $this->classInstance = new SurveyCrosstabs();
+ $this->classInstance->Init($this->anketa);
+
+ // Napolnimo podatke crosstabu
+ $crossData1 = $this->sessionData['crosstab_charts'][$chartID]['spr1'];
+ $crossData2 = $this->sessionData['crosstab_charts'][$chartID]['spr2'];
+
+ $this->classInstance->setVariables($crossData1['seq'],$crossData1['spr'],$crossData1['grd'],$crossData2['seq'],$crossData2['spr'],$crossData2['grd']);
+
+ $this->break_spremenljivka['tip'] = 1;
+ $this->break_spremenljivka['skala'] = 0;
+ }
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::saveData($this->sessionData);
+
+ $this->displayBreakChart($chartID);
+ }
+ }
+
+}
+?> \ No newline at end of file