false); // za shrambo parametrov in sporocil private $headFileName = null; # pot do header fajla private $dataFileName = null; # pot do data fajla private $dataFileStatus = null; # status data datoteke /** * @desc konstruktor */ function __construct ($anketa = null, $sprID = null){ global $site_path; global $global_user_id; global $output; // preverimo ali imamo stevilko ankete if ( is_numeric($anketa) ){ $this->anketa['id'] = $anketa; $this->spremenljivka = $sprID; SurveyAnalysis::Init($this->anketa['id']); SurveyAnalysis::$setUpJSAnaliza = false; // create new XLS document $this->xls = new xls(); // Poskrbimo za datoteko s podatki $SDF = SurveyDataFile::get_instance(); $SDF->init($this->anketa['id']); $SDF->prepareFiles(); $this->headFileName = $SDF->getHeaderFileName(); $this->dataFileName = $SDF->getDataFileName(); $this->dataFileStatus = $SDF->getStatus(); $_POST['podstran'] = 'usable_resp'; } else{ $this->pi['msg'] = "Anketa ni izbrana!"; $this->pi['canCreate'] = false; return false; } if (SurveyInfo::getInstance()->SurveyInit($this->anketa['id'])){ $this->anketa['uid'] = $global_user_id; SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']); } else return false; // ce smo prisli do tu je vse ok $this->pi['canCreate'] = true; return true; } function getAnketa(){ return $this->anketa['id']; } function checkCreate(){ return $this->pi['canCreate']; } function getFile($fileName){ $output = $this->createXls(); $this->xls->display($fileName, $output); } function createXls(){ global $site_path; global $lang; global $output; $convertTypes = array('charSet' => "windows-1250", 'delimit' => ";", 'newLine' => "\n", 'BOMchar' => "\xEF\xBB\xBF"); $output = $convertTypes['BOMchar']; $output .= '
'.$lang['srv_usable_respondents'].'
'; $this->displayTable(); return $output; } function displayTable(){ global $site_path; global $lang; global $output; $SUR = new SurveyUsableResp($this->anketa['id'], $generateDataFile=false); $usability = $SUR->calculateData(); # ali odstranimo stolpce kateri imajo same 0 $cols_with_value = $SUR->getColsWithValue(); $_missings = $SUR->getMissings(); $_unsets = $SUR->getUnsets(); if ($SUR->showWithZero() == false) { # odstranimo missinge brez vrednosti foreach ($SUR->getMissings() AS $_key => $_missing) { if (!isset($cols_with_value[$_key]) || $cols_with_value[$_key] == false) { unset($_missings[$_key]); } } # odstranimo neveljavne brez vrednosti foreach ($SUR->getUnsets() AS $_key => $_unset) { if (!isset($cols_with_value[$_key]) || $cols_with_value[$_key] == false) { unset($_unsets[$_key]); } } } $output .= ''; // Header rows $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; // ali odstranimo vse stolpce s podrobnimi vrednostmi (-1, -2...) if ($SUR->showDetails() == true) { foreach ($_missings AS $value => $text){ $cnt_miss++; $output .= ""; } foreach ($_unsets AS $value => $text){ $cnt_undefined++; $output .= ""; } } // ali prikazemo podrobne izracune if ($SUR->showCalculations() == true) { $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; } $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; // Data rows $output .= ''; // Izpis podatkov vsakega respondenta $userData = $usability['data']; foreach($userData as $key => $user){ // Obarvamo vrstico glede na status (belo, rumeno, rdece) if($user['status'] == 0) $css_usable = 'unusable'; elseif($user['status'] == 1) $css_usable = 'partusable'; else $css_usable = 'usable'; // Prva vrstica z vrednostmi $output .= ''; $output .= ''; // Vsi $output .= ''; // Ustrezni $output .= ''; // Non-substantive $output .= ''; // Non-response $output .= ''; // Skupaj $output .= ''; // Breakoffs $output .= ''; // Uporabni $output .= ''; $output .= ''; // ali odstranimo vse stolpce s podrobnimi vrednostmi (-1, -2...) if ($SUR->showDetails() == true) { foreach ($_missings AS $value => $text){ $output .= ''; } foreach ($_unsets AS $value => $text){ $output .= ''; } } // ali prikazemo podrobne izracune if ($SUR->showCalculations() == true) { $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; } $output .= ''; // Druga vrstica s procenti $output .= ''; // Ustrezni $output .= ''; // Non-substantive $output .= ''; // Non-response $output .= ''; // Skupaj $output .= ''; // Breakoffs $output .= ''; // Uporabni $output .= ''; // ali odstranimo vse stolpce s podrobnimi vrednostmi (-1, -2...) if ($SUR->showDetails() == true) { foreach ($_missings AS $value => $text){ $val = $user[$value]; $val = ($all > 0) ? ($val / $all * 100) : 0; $output .= ''; } foreach ($_unsets AS $value => $text){ $val = $user[$value]; $val = ($all > 0) ? ($val / $all * 100) : 0; $output .= ''; } } $output .= ''; } $output .= ''; $output .= '
Recnum'.$lang['srv_usableResp_qcount'].''.$lang['srv_usableResp_exposed'].''.$lang['srv_usableResp_breakoff'].''.$lang['srv_usableResp_usability'].'{$value}
(".$lang['srv_usableResp_'.$text].")
{$value}
(".$lang['srv_usableResp_'.$text].")
UNLUMLUCLUILUAQ
'.$lang['srv_anl_valid'].''.$lang['srv_usableResp_nonsubstantive'].''.$lang['srv_usableResp_nonresponse'].''.$lang['srv_anl_suma1'].'%Status
'.$user['recnum'].''.$user['all'].''.$user['valid'].''.$user['nonsubstantive'].''.$user['nonresponse'].''.($user['valid']+$user['nonsubstantive']+$user['nonresponse']+$user['breakoff']).''.$user['breakoff'].''.$user['usable'].''.$user['status'].''.$user[$value].''.$user[$value].''.common::formatNumber($user['UNL']*100, 0, null, '%').''.common::formatNumber($user['UML']*100, 0, null, '%').''.common::formatNumber($user['UCL']*100, 0, null, '%').''.common::formatNumber($user['UIL']*100, 0, null, '%').''.common::formatNumber($user['UAQ']*100, 0, null, '%').'
'.common::formatNumber($user['validPercent'], 0, null, '%').''.common::formatNumber($user['nonsubstantivePercent'], 0, null, '%').''.common::formatNumber($user['nonresponsePercent'], 0, null, '%').''.common::formatNumber(100, 0, null, '%').''.common::formatNumber($user['breakoffPercent'], 0, null, '%').''.common::formatNumber($user['usablePercent'], 0, null, '%').''.common::formatNumber($val, 0, null, '%').''.common::formatNumber($val, 0, null, '%').'
'; } function encodeText($text) { // popravimo sumnike ce je potrebno $stringIn = array("č","š","đ","ć","ž","Č","Š","Đ","Ć","Ž"," "); $stringOut = array("č","š","đ","ć","ž","Č","Š","Đ","Ć","Ž"," "); //$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8'); $text = str_replace($stringIn, $stringOut, $text); return $text; } function enkaEncode($text) { // popravimo sumnike ce je potrebno $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8'); return strip_tags($text); } function formatNumber ($value, $digit = 0, $sufix = "") { if ($value <> 0 && $value != null) $result = round($value, $digit); else $result = "0"; //$result = number_format($result, $digit, '.', ',') . $sufix; $result = number_format($result, $digit, ',', '') . $sufix; return $result; } } ?>