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("
");
				print_r($_GET);
				print_r($_POST);
				print_r("
"); 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 '
'; SurveyStatusProfiles::displayOnlyValidCheckbox(); echo '
';*/ # 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 '
'; $this->displayData(); echo '
'; #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 ''; } # 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 '
'; $variables = $this->getVariableList(2); echo ''; echo $lang['srv_break_label1']; echo '
'; echo ''; # name="breakSpremenljivka" echo '
'; echo '' ; $this->displayLinePercent(); $this->displayLineCharts(); // V DELU... echo ''; echo '
'; echo '
'; # 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 '
'; $this->doBreakForSpremenljivka(); echo '
'; # id="breakResults" } else { echo '
'; } } /** 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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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 '
'; echo '

'.$lang['srv_break_error_note_1'].'

'; } } /** 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 '
'; # č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 '
'; 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 '
'; # če ni multicheck in multi grid echo ''; echo ''; echo ''; echo ''; echo ''; echo $forSpremenljivka['naslov']; echo '('.$forSpremenljivka['variable'].')'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo $spremenljivka['naslov']; echo '('.$spremenljivka['variable'].')'; echo ''; if (isset ($doubleGridTitle['subtitle'])) { echo ' - '.$doubleGridTitle['subtitle']; } echo ''; echo ''; echo ''; echo ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { if ($isDoubleGrid == false || ($isDoubleGrid == true && $grid['part'] == $part)) { foreach ($grid['variables'] AS $vkey => $variable) { echo ''; } } } echo ''; echo ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { if ($isDoubleGrid == false || ($isDoubleGrid == true && $grid['part'] == $part)) { foreach ($grid['variables'] AS $vkey => $variable) { echo ''; echo ''; } } } echo ''; $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 ''; echo ''; if ($forSpremenljivka['tip'] == 2) { echo $cbxLabel; } else { echo $forSpremenljivka['options'][$oKey]; } echo ''; $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 ''; echo $this->formatNumber($means[$fkey][$oKey][$sequence],$this->num_digit_average,''); echo ''; # enote echo ''; $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$frequencys[$fkey][$oKey][$sequence]['validCnt']); $totalFreq[$sequence]+= (int)$frequencys[$fkey][$oKey][$sequence]['validCnt']; } } } } echo ''; } } } #dodamo še skupno sumo in povprečje echo ''; echo ''; 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 ''; # enote echo ''; } } } } echo ''; echo '
'; echo $variable['naslov']; echo '('.$variable['variable'].')'; echo '
Povprečje'.$lang['']; echo 'Št. enot'.$lang['']; echo '
'; echo (int)$frequencys[$fkey][$oKey][$sequence]['validCnt']; echo '
'; echo 'Skupaj'; echo ''; $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0; echo $this->formatNumber($totalMean ,$this->num_digit_average,''); echo ''; echo (int)$totalFreq[$sequence]; echo '
';//$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 '
'; } } 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 '
'; echo '
'; # 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 ''; echo ''; echo ''; echo ''; echo ''; echo $forSpremenljivka['naslov']; echo '('.$forSpremenljivka['variable'].')'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo $spremenljivka['naslov']; echo '('.$spremenljivka['variable'].')'; echo ''; echo ''; echo ''; echo ''; echo ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { foreach ($grid['variables'] AS $vkey => $variable) { echo ''; } } echo ''; echo ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { foreach ($grid['variables'] AS $vkey => $variable) { echo ''; echo ''; } } echo ''; foreach ($frequencys AS $fkey => $fkeyFrequency) { foreach ($options AS $oKey => $option) { if ($displayAll || $means[$fkey][$oKey] != null) { echo ''; echo ''; echo $forSpremenljivka['options'][$oKey]; echo ''; $css = ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { foreach ($grid['variables'] AS $vkey => $variable) { $sequence = $variable['sequence']; if ($variable['other'] != 1) { #povprečja echo ''; echo $this->formatNumber($means[$fkey][$oKey][$sequence],$this->num_digit_average,''); #echo $this->formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''); echo ''; # enote echo ''; #$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 ''; if ((int)$this->break_percent) { echo ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['other'] != 1) { $sequence = $variable['sequence']; echo ''; } } } echo ''; } } } } #dodamo še skupno sumo in povprečje echo ''; echo ''; foreach ($spremenljivka['grids'] AS $gkey => $grid) { foreach ($grid['variables'] AS $vkey => $variable) { $sequence = $variable['sequence']; if ($variable['other'] != 1) { #povprečja echo ''; # enote echo ''; } } } echo ''; echo '
'; echo $variable['naslov']; echo '('.$variable['variable'].')'; echo '
Povprečje'.$lang['']; echo 'Št. enot'.$lang['']; echo '
'; echo (int)$frequencys[$fkey][$oKey][$sequence]['validCnt']; #echo (int)$frequencys[$fkey][$sequence]['validCnt']; echo '
'; #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 '
'; echo $lang[''].'Skupaj'; echo ''; $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0; echo $this->formatNumber($totalMean ,$this->num_digit_average,''); echo ''; echo (int)$totalFreq[$sequence]; echo '
'; // 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 '
'.$lang['srv_break_table_for']; echo $spremenljivka['naslov'].' ('; echo $spremenljivka['variable'].') = '; echo $grid['naslov']; echo ' ('.$grid['variable'].')'; echo ''; } echo ''; #labele echo ''; echo ''; echo ''; echo ''; echo $forSpremenljivka['naslov']; echo '('.$forSpremenljivka['variable'].')'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo $spremenljivka['naslov']. ' - '; echo $grid['naslov']; echo '('.$grid['variable'].')'; echo ''; echo ''; echo ''; echo''; #labele echo ''; foreach ($grid['variables'] AS $vkey => $variable) { echo ''; } echo ''; echo ''; foreach ($grid['variables'] AS $vkey => $variable) { echo ''; echo ''; } echo ''; $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 ''; echo ''; if ($forSpremenljivka['tip'] == 2) { echo $cbxLabel; } else { echo $forSpremenljivka['options'][$oKey]; } #echo ' ('.$oKey.')'; echo ''; foreach ($grid['variables'] AS $vkey => $variable) { $sequence = $variable['sequence']; #povprečje echo ''; # enote echo ''; $totalMeans[$sequence] += ($means[$fkey][$oKey][$sequence]*(int)$frequencys[$fkey][$oKey][$sequence]['validCnt']); $totalFreq[$sequence]+= (int)$frequencys[$fkey][$oKey][$sequence]['validCnt']; } echo ''; } } } } #dodamo še skupno sumo in povprečje echo ''; echo ''; foreach ($grid['variables'] AS $vkey => $variable) { $sequence = $variable['sequence']; if ($variable['other'] != 1) { #povprečja echo ''; # enote echo ''; } } echo ''; echo '
'; echo $variable['naslov']; echo '('.$variable['variable'].')'; echo '
Povprečje'.$lang['']; echo 'Št. enot'.$lang['']; echo '
'; echo $this->formatNumber($means[$fkey][$oKey][$sequence],$this->num_digit_average,''); echo ''; echo (int)$frequencys[$fkey][$oKey][$sequence]['validCnt']; echo '
'; echo 'Skupaj'; echo ''; $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0; echo $this->formatNumber($totalMean ,$this->num_digit_average,''); echo ''; echo (int)$totalFreq[$sequence]; echo '
'; // 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 '
'; } } echo '
'; } } 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 '
'; echo '
'; # 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 '
'; if($tip != '21'){ echo ''; echo $lang['srv_break_table_for']; echo $spremenljivka['naslov'].' ('; echo $spremenljivka['variable'].') = '; echo $grid['naslov']; echo ' ('.$grid['variable'].')'; echo ''; } } echo ''; #labele echo ''; echo ''; echo ''; echo ''; echo $forSpremenljivka['naslov']; echo '('.$forSpremenljivka['variable'].')'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo $spremenljivka['naslov']. ' - '; echo $grid['naslov']; echo '('.$grid['variable'].')'; echo ''; echo ''; echo ''; echo''; #labele echo ''; foreach ($grid['variables'] AS $vkey => $variable) { echo ''; } echo ''; $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 ''; echo ''; if ($forSpremenljivka['tip'] == 2) { echo $cbxLabel; } else { echo $forSpremenljivka['options'][$oKey]; } echo ''; foreach ($grid['variables'] AS $vkey => $variable) { $sequence = $variable['sequence']; #povprečje echo ''; } echo ''; } } } } echo '
'; echo $variable['naslov']; echo '('.$variable['variable'].')'; echo '('.$variable['sequence'].')'; echo '
'; if (count($texts[$forSequence][$oKey][$sequence]) > 0) { $cnt=1; $count = count($texts[$forSequence][$oKey][$sequence]); foreach ($texts[$forSequence][$oKey][$sequence] AS $ky => $units) { echo '
'; echo $units['text']; echo '
'; $cnt++; } } #echo $this->formatNumber($texts[$oKey][$sequence],$this->num_digit_average,''); echo '
'; // 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 '
'; } echo '
'; } 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 '
'.$lang['srv_break_table_for']; echo $spremenljivka['naslov'].' ('; echo $spremenljivka['variable'].') = '; echo $grid['naslov']; if ($spremenljivka['tip'] != 6) { echo ' ('.$grid['variable'].')'; } echo ''; } $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 '
'; } } 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 '
  • '; echo '' . $lang['srv_break'] . ''."\n"; echo '
  • '; echo '
  •  
  • '; } } // 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 ''; } } // 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 '
    '; echo ''.$lang['srv_custom_report_comments_add'].''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
    '; // Javascript s katerim povozimo urlje za izvoze, ki niso na voljo v paketu global $app_settings; if($app_settings['commercial_packages'] == true){ echo ''; } } 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 ''; } function displayLineCharts() { global $lang; echo ''; echo ' '; echo ' '; echo ''; } }