false); // za shrambo parametrov in sporocil var $rtf; 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; // 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 RTF document $this->rtf = new enka_RTF(); // 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(); // Nastavimo da izpisujemo samo prvih 5 spremenljivk $_GET['spr_limit'] = 5; // Nastavimo da nikoli ne izpisemo vabila $_GET['email'] = 0; SurveyDataDisplay::Init($this->anketa['id']); } else{ $this->pi['msg'] = "Anketa ni izbrana!"; $this->pi['canCreate'] = false; return false; } if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init()){ $this->anketa['uid'] = $global_user_id; SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']); } else return false; // ce smo prisli do tu je vse ok $this->pi['canCreate'] = true; return true; } function getAnketa() { return $this->anketa['id']; } function checkCreate() { return $this->pi['canCreate']; } function getFile($fileName) { //Close and output rtf document // $this->rtf->Output($fileName, 'I'); $this->rtf->display($fileName = "analiza.rtf",true); } function init() { global $lang; // dodamo avtorja in naslov $this->rtf->WriteTitle(); $this->rtf->WriteHeader($this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()), 'left'); $this->rtf->WriteHeader($this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()), 'right'); $this->rtf->WriteFooter($lang['page']." {PAGE} / {NUMPAGES}", 'right'); $this->rtf->set_default_font(FNT_TIMES, FNT_MAIN_SIZE); return true; } function createRtf() { global $site_path; global $lang; // izpisemo prvo stran //$this->createFrontPage(); $this->rtf->draw_title($lang['export_list']); $this->rtf->MyRTF .= $this->rtf->_font_size(16); $this->displayTable(); } function displayTable(){ global $site_path; global $lang; $folder = $site_path . EXPORT_FOLDER.'/'; //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 SurveyAnalysis::removeSystemVariables(); SurveyDataDisplay::$_VARS[VAR_DATA] = 1; SurveyDataDisplay::$_VARS[VAR_SPR_LIMIT] = 5; SurveyDataDisplay::$_VARS[VAR_META] = 0; SurveyDataDisplay::$_VARS[VAR_EMAIL] = 0; SurveyDataDisplay::$_VARS[VAR_RELEVANCE] = 0; SurveyDataDisplay::$_VARS[VAR_STATUS] = 0; SurveyDataDisplay::$_VARS[VAR_EDIT] = 0; SurveyDataDisplay::$_VARS[VAR_PRINT] = 0; SurveyDataDisplay::$_VARS[VAR_MONITORING] = 0; if(SurveyDataDisplay::$_VARS['view_date']) SurveyDataDisplay::$_VARS[VAR_SPR_LIMIT]++; # ponastavimo nastavitve- filter SurveyDataDisplay::setUpFilter(); // Prestejemo stevilo stolpcev za vsako spremenljivko $spr_cont = 0; $rowArray = array(); $row_count = 0; // visine naslovnih vrstic $first_height = 0; $second_height = 0; $third_height = 0; if(SurveyDataDisplay::$_VARS['view_date']){ $row_count ++; } foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) { # preverjamo ali je meta if ($spremenljivka['tip'] != 'm' && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES)){ # ali imamo sfiltrirano spremenljivko if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid])) && count($spremenljivka['grids']) > 0) { // prikazemo samo prvih 5 spremenljivk if($spr_cont < 5) { $rowArray[$spr_cont]['cnt_grd'] = count($spremenljivka['grids']); $rowArray[$spr_cont]['cnt_var'] = count($spremenljivka['grids'][0]['variables']); $row_count += count($spremenljivka['grids'][0]['variables']) * count($spremenljivka['grids']); } $spr_cont++; } } } $this->rtf->MyRTF .= "{\par"; $max_width = 10300; $single_width = floor($max_width / $row_count); $single_width = ($single_width < 200) ? 200 : $single_width; // PRVA VRSTICA (naslovi spremenljivk) $tableHeader = '\trowd\trql\trrh400'; $table = ''; $tableEnd = ''; $spr_cont = 0; $width = 0; if(SurveyDataDisplay::$_VARS['view_date']){ $width += $single_width; $table .= '\clvertalc\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\cellx'.( $width ); $tableEnd .= '\pard\intbl\b '.$this->snippet($this->enkaEncode($lang['srv_data_date']),20,'...') . '\ql\cell'; } foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) { # preverjamo ali je meta if ($spremenljivka['tip'] != 'm' && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES)){ # ali imamo sfiltrirano spremenljivko if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]))) { // prikazemo samo prvih 5 spremenljivk if ($spr_cont < 5) { $width += $single_width * $rowArray[$spr_cont]['cnt_var'] * $rowArray[$spr_cont]['cnt_grd']; $table .= '\clvertalc\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\cellx'.( $width ); $tableEnd .= '\pard\intbl\b '.$this->snippet($this->enkaEncode($spremenljivka['naslov']),20,'...') . '\ql\cell'; } $spr_cont++; } } } $tableEnd .= '\pard\intbl\row'; $this->rtf->MyRTF .= $this->rtf->enkaEncode($tableHeader.$table.$tableEnd); // DRUGA VRSTICA (imena gridov) $tableHeader = '\trowd\trql\trrh400'; $table = ''; $tableEnd = ''; $spr_cont = 0; $width = 0; if(SurveyDataDisplay::$_VARS['view_date']){ $width += $single_width; $table .= '\clvertalc\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\cellx'.( $width ); $tableEnd .= '\pard\intbl\b '.$this->snippet($this->enkaEncode($lang['srv_data_date']),20,'...') . '\ql\cell'; } foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) { # preverjamo ali je meta if ($spremenljivka['tip'] != 'm' && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES)){ # ali imamo sfiltrirano spremenljivko if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid])) && count($spremenljivka['grids']) > 0) { // prikazemo samo prvih 5 spremenljivk if ($spr_cont < 5) { foreach ($spremenljivka['grids'] AS $gid => $grid) { $width += $single_width * $rowArray[$spr_cont]['cnt_var']; $table .= '\clvertalc\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\cellx'.( $width ); $tableEnd .= '\pard\intbl\b '.$this->snippet($this->enkaEncode($grid['naslov']),20,'...') . '\qc\cell'; } } $spr_cont++; } } } $tableEnd .= '\pard\intbl\row'; $this->rtf->MyRTF .= $this->rtf->enkaEncode($tableHeader.$table.$tableEnd); // TRETJA VRSTICA (imena variabel) $tableHeader = '\trowd\trql\trrh400'; $table = ''; $tableEnd = ''; $spr_cont = 0; $width = 0; if(SurveyDataDisplay::$_VARS['view_date']){ $width += $single_width; $table .= '\clvertalc\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\cellx'.( $width ); $tableEnd .= '\pard\intbl\b '.$this->snippet($this->enkaEncode($lang['srv_data_date']),20,'...') . '\ql\cell'; } foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) { # preverjamo ali je meta if ($spremenljivka['tip'] != 'm' && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES)){ # ali imamo sfiltrirano spremenljivko if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid])) && count($spremenljivka['grids']) > 0) { // prikazemo samo prvih 5 spremenljivk if($spr_cont < 5) { foreach ($spremenljivka['grids'] AS $gid => $grid) { if (count ($grid['variables']) > 0) { foreach ($grid['variables'] AS $vid => $variable ){ $text = $variable['naslov']; if ($variable['other'] == 1) $text .= ' (text)'; $width += $single_width; $table .= '\clvertalc\clbrdrt\brdrs\brdrw10\clbrdrl\brdrs\brdrw10\clbrdrb\brdrs\brdrw10\clbrdrr\brdrs\brdrw10\cellx'.( $width ); $tableEnd .= '\pard\intbl\b '.$this->snippet($this->enkaEncode($text),20,'...') . '\qc\cell'; } } } } $spr_cont++; } } } $tableEnd .= '\pard\intbl\row'; $this->rtf->MyRTF .= $this->rtf->enkaEncode($tableHeader.$table.$tableEnd); // Nastavimo stevilo izpisov - prikazemo vse $_REC_LIMIT = ''; //$_REC_LIMIT = ' NR==1,NR==50'; $_command = ''; #preberemo podatke // polovimo vrstice z statusom 5,6 in jih damo v začasno datoteko if (IS_WINDOWS) { $_command = 'gawk -F"'.STR_DLMT.'" "BEGIN {OFS=\"\x7C\"} '.SurveyDataDisplay::$_CURRENT_STATUS_FILTER.' { print $0 }" '.$this->dataFileName; } else { $_command = 'awk -F"'.STR_DLMT.'" \'BEGIN {OFS="\x7C"} '.SurveyDataDisplay::$_CURRENT_STATUS_FILTER.' { print $0 }\' '.$this->dataFileName; } // paginacija po stolpcih (spremenljivkah) if (IS_WINDOWS) { $_command .= ' | cut -d "|" -f 1,'.SurveyDataDisplay::$_VARIABLE_FILTER; } else { $_command .= ' | cut -d \'|\' -f 1,'.SurveyDataDisplay::$_VARIABLE_FILTER; } if ($_REC_LIMIT != '') { #paginating if (IS_WINDOWS) { $_command .= ' | awk '.$_REC_LIMIT; } else { $_command .= ' | awk '.$_REC_LIMIT; } } else { #$file_sufix = 'filtred_spr_pagination'; } // zamenjamo | z