0) { $this->ank_id = $anketa; // polovimo vrsto tabel (aktivne / neaktivne) SurveyInfo :: getInstance()->SurveyInit($this->ank_id); $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString(); // Inicializiramo in polovimo nastavitve missing profila SurveyStatusProfiles::Init($this->ank_id); SurveyUserSetting::getInstance()->Init($this->ank_id, $global_user_id); 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); #inicializiramo class za datoteke $SDF = SurveyDataFile::get_instance(); $SDF->init($anketa); $this->headFileName = $SDF->getHeaderFileName(); $this->dataFileName = $SDF->getDataFileName(); $this->dataFileStatus = $SDF->getStatus(); SurveyAnalysis::Init($this->ank_id); //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(); $this->creportProfile = SurveyUserSetting :: getInstance()->getSettings('default_creport_profile'); $this->creportProfile = isset($this->creportProfile) && $this->creportProfile != '' ? $this->creportProfile : 0; $this->creportAuthor = SurveyUserSetting :: getInstance()->getSettings('default_creport_author'); $this->creportAuthor = isset($this->creportAuthor) && $this->creportAuthor != '' ? $this->creportAuthor : $global_user_id; $this->expanded = (isset($_GET['expanded'])) ? $_GET['expanded'] : 0; } else { echo 'Invalid Survey ID!'; exit(); } } // Izrisemo izdelano porocilo function displayReport(){ global $lang; global $global_user_id; # zakeširamo vsebino, in jo nato po potrebi zapišpemo v html if ($this->returnAsHtml != false) { ob_start(); } if ($this->isArchive == false && $this->publicCReport == false) { echo ''; $this->displayProfilePopups(); // Prva vrstica - seznam poročil echo '
'; // Seznam porocil echo '
'; // Seznam avtorjevih porocil // Prvo default porocilo $sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='creport_default_profile_name'"); if(mysqli_num_rows($sql) == 0){ echo '
'; echo $lang['srv_custom_report_default']; echo '
'; } else{ $row = mysqli_fetch_array($sql); echo '
'; echo $row['value']; echo '
'; } // Loop po ostalih lastnih porocilih $sqlReports = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id'"); while($rowReports = mysqli_fetch_array($sqlReports)){ echo '
'; echo $rowReports['name']; echo '
'; } // Loop po deljenih porocilih $sqlSharedReports = sisplet_query("SELECT s.*, u.email FROM srv_custom_report_share s, users u WHERE ank_id='$this->ank_id' AND share_usr_id='$global_user_id' AND u.id=s.author_usr_id"); while($rowSharedReports = mysqli_fetch_array($sqlSharedReports)){ // Ce gre za osnovno porocilo ki ga ne more pobrisati if($rowSharedReports['profile_id'] == 0){ // Dobimo ime osnovnega porocila $what = 'creport_default_profile_name'; $sqlN = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='".$rowSharedReports['author_usr_id']."' AND what='$what'"); if(mysqli_num_rows($sqlN) == '0'){ $default_name = $lang['srv_custom_report_default']; } else{ $rowN = mysqli_fetch_array($sqlN); $default_name = ($rowN['value'] == '') ? $lang['srv_custom_report_default'] : $rowN['value']; } echo '
'; echo $default_name . ' ('.$rowSharedReports['email'].')'; echo '
'; } // Ce gre za dodatno porocilo ga imamo normalno v bazi else{ $sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='".$rowSharedReports['author_usr_id']."'"); while($row = mysqli_fetch_array($sql)){ echo '
'; echo $row['name'] . ' ('.$rowSharedReports['email'].')'; echo '
'; } } } echo '
'; // Edit in add porocilo echo ' '; echo ' '; // Osnova porocila (prazna, vsi grafi, vse frekvence...) - prikazemo samo ce je porocilo prazno if($this->checkEmpty($this->ank_id)){ echo ''; echo $lang['srv_custom_report_base'].':'; echo ''; echo ''; } echo '
'; // Preklop na skrcen/razsirjen pogled in predogled echo '
'; if($this->expanded == 0) echo ' '.$lang['srv_custom_report_expanded_0'].''; else echo ' '.$lang['srv_custom_report_expanded_1'].''; // Preview echo ' '.$lang['srv_custom_report_preview_short'].''; echo '
'; } echo '
'; // ce arhiviramo imamo razsirjene elemente $this->expanded = ($this->isArchive == false && $this->publicCReport == false) ? $this->expanded : 1; // Naslov porocila if ($this->isArchive == false && $this->publicCReport == false) { $this->displayTitle(); } $sql = sisplet_query("SELECT * FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile' ORDER BY vrstni_red ASC"); $counter = mysqli_num_rows($sql); if($counter > 0){ echo ''; } else{ echo '
'.$lang['srv_custom_report_begin'].'
'; } if ($this->isArchive == false && $this->publicCReport == false) { // Dodajanje novega porocila echo '
'; $this->addNewElement(); echo '
'; } echo '
'; if ($this->isArchive == false && $this->publicCReport == false) { // izpisi na dnu $this->displayBottomSettings(); } if ($this->returnAsHtml != false) { $result = ob_get_clean(); ob_flush(); flush(); return $result; } } // Izrisemo posamezen element porocila function displayReportElement($element_id, $expanded){ global $lang; $sql = sisplet_query("SELECT * FROM srv_custom_report WHERE id='$element_id' AND ank_id='$this->ank_id' AND profile='$this->creportProfile'"); $reportElement = mysqli_fetch_array($sql); switch($reportElement['type']){ case '0': $this->displayReportElementHead($reportElement, $expanded, $lang['srv_custom_report_select_type']); $this->displayReportElementSettings($reportElement, $expanded); break; case '1': $this->displaySum($reportElement, $expanded); break; case '2': $this->displayFreq($reportElement, $expanded); break; case '3': $this->displayDesc($reportElement, $expanded); break; case '4': $this->displayChart($reportElement, $expanded); break; case '5': $this->displayCrosstab($reportElement, $expanded); break; case '6': $this->displayMean($reportElement, $expanded); break; case '7': $this->displayTTest($reportElement, $expanded); break; case '9': $this->displayRazbitje($reportElement, $expanded); break; case '10': $this->displayMulticrosstab($reportElement, $expanded); break; case '8': $this->displayText($reportElement, $expanded); break; default: break; } // Komentar pod elementom if($reportElement['type'] != 8) $this->displayReportElementText($reportElement, $expanded); } // Izpis nastavitev posameznega elementa (tip izpisa, izbira spremenljivk...) function displayReportElementSettings($reportElement, $expanded){ global $lang; if ($this->isArchive == false && $this->publicCReport == false) { echo ''; } } // Nastavitve na dnu function displayBottomSettings(){ global $site_path; global $lang; echo '
'; echo ''; echo ''; echo ''; echo ''; echo '
'; } function displayTTestSubVar($reportElement){ global $lang; echo '
'; $ttestData1 = explode("-", $reportElement['spr1']); $spr = $ttestData1[1]; $check1 = isset($ttestData1[3])?$ttestData1[3]:null; $check2 = isset($ttestData1[4])?$ttestData1[4]:null; # poiscemo pripadajoce variable $_spr_data = $this->classInstance->_HEADERS[$spr]; echo $lang['srv_ttest_kategories_note'].' ('.$_spr_data['variable'].') '.$_spr_data['naslov']; echo '
'; 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) { $checked = ($check1 == $spr.'_'.$sekvenca.'_'.$value || $check2 == $spr.'_'.$sekvenca.'_'.$value) ? true : false; $disabled = ($check1 != null && $check2 != null && !$checked) ? ' disabled="disabled"' : ''; echo ''; echo '
'; } break; case 2: #checkbox #nardimo inpute za vse opcije $option = '1'; foreach ($_spr_data['grids'][0]['variables'] as $vid => $variable) { $checked = ($check1 == $spr.'_'.$variable['sequence'].'_'.$option || $check2 == $spr.'_'.$variable['sequence'].'_'.$option) ? true : false; $disabled = ($check1 != null && $check2 != null && !$checked) ? ' disabled="disabled"' : ''; echo ''; echo '
'; } break; case 6: #mgrid #nardimo inpute za vse opcije foreach ($_spr_data['options'] as $value => $option) { $sekvenca = $_spr_data['grids'][$value]['variables'][0]['sequence']; $checked = ($check1 == $spr.'_'.$sekvenca.'_'.$value || $check2 == $spr.'_'.$sekvenca.'_'.$value) ? true : false; $disabled = ($check1 != null && $check2 != null && !$checked) ? ' disabled="disabled"' : ''; echo ''; echo '
'; } 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) { $checked = ($check1 == $spr.'_'.$variable['sequence'].'_'.$option || $check2 == $spr.'_'.$variable['sequence'].'_'.$option) ? true : false; $disabled = ($check1 != null && $check2 != null && !$checked) ? ' disabled="disabled"' : ''; echo ''; echo '
'; } break; default: if ((int)$_spr_data['tip'] > 0) echo'TODO for type:'.$_spr_data['tip']; break; } echo '
'; } function displayReportElementHead($reportElement, $expanded, $title=' '){ global $lang; if ($this->isArchive == false && $this->publicCReport == false) { echo '
'; // Popravimo naslov ce je textovni element if($reportElement['type'] == 8){ $title = substr(strip_tags($reportElement['text']), 0, 30); if(strlen(strip_tags($reportElement['text'])) > 30) $title .= '...'; $subtitle = '('.$lang['text'].')'; $title .= ' '.$subtitle.''; } echo '
'; echo $title; echo '
'; // Ikone za razsiritev, kopiranje, brisanje posameznega elementa echo '
'; // Kopiraj element echo ' '; // Brisi element echo ' '; echo '
'; echo '
'; } } // Urejanje naslova porocila function displayTitle(){ global $lang; global $global_user_id; echo '
'; $what = 'creport_title_profile_'.$this->creportProfile; $sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->creportAuthor' AND what='$what'"); if(mysqli_num_rows($sql) == 0){ $titleString = $lang['export_analisys_creport'].': '.SurveyInfo::getInstance()->getSurveyTitle(); } else{ $row = mysqli_fetch_array($sql); $titleString = $row['value']; } echo '
'; echo $titleString; echo '
'; echo '
'; } // Urejanje dodatnega besedila za posamezen element function displayReportElementText($reportElement, $expanded){ global $lang; echo '
'; if($expanded == 1 && $this->isArchive == false && $this->publicCReport == false){ echo ''.$lang['srv_inv_archive_comment'].':'; echo ''; echo '
'; echo $reportElement['text']; echo '
'; } elseif($reportElement['text'] != ''){ echo '
isArchive == false && $this->publicCReport == false ? ' contenteditable="true"':'').' el_id="'.$reportElement['id'].'">'; echo $reportElement['text']; echo '
'; } echo '
'; } // Izrisemo sumarnik element function displaySum($reportElement, $expanded){ global $lang; if(!isset($reportElement['spr1'])||$reportElement['spr1'] == '') $title = $lang['srv_select_spr']; else $title = SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['variable'].' - '.SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['naslov']; $subtitle = '('.$lang['srv_sumarnik'].')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } // Izrisemo sumarnik element function displayFreq($reportElement, $expanded){ global $lang; if(!isset($reportElement['spr1'])||$reportElement['spr1'] == '') $title = $lang['srv_select_spr']; else $title = SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['variable'].' - '.SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['naslov']; $subtitle = '('.$lang['srv_frequency'].')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } // Izrisemo sumarnik element function displayDesc($reportElement, $expanded){ global $lang; if(isset($reportElement['spr1']) || $reportElement['spr1'] == '') $title = $lang['srv_select_spr']; else $title = SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['variable'].' - '.SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['naslov']; $subtitle = '('.$lang['srv_descriptor'].')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } // Izrisemo sumarnik element function displayChart($reportElement, $expanded){ global $lang; if(!isset($reportElement['spr1'])||$reportElement['spr1'] == '') $title = $lang['srv_select_spr']; else $title = SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['variable'].' - '.SurveyAnalysis::$_HEADERS[$reportElement['spr1']]['naslov']; $subtitle = '('.$lang['srv_chart'].')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; echo ''; } //izrisemo crosstab element function displayCrosstab($reportElement, $expanded){ global $lang; // Ustvarimo instanco razreda $this->classInstance = new SurveyCrosstabs(); $this->classInstance->Init($this->ank_id); // Napolnimo podatke crosstabu $crossData1 = explode("-", $reportElement['spr1']); $crossData2 = explode("-", $reportElement['spr2']); $this->classInstance->setVariables($crossData1[0],(isset($crossData1[1])?$crossData1[1]:null),(isset($crossData1[2])?$crossData1[2]:null), $crossData2[0],(isset($crossData2[1])?$crossData2[1]:null),(isset($crossData2[2])?$crossData2[2]:null)); // Naslov if($reportElement['spr1'] == '' || $reportElement['spr2'] == '') $title = $lang['srv_select_spr']; else{ $show_variables_values = true; $spr1 = $this->classInstance->_HEADERS[$crossData1[1]]; $spr2 = $this->classInstance->_HEADERS[$crossData2[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 .= strip_tags($spr1['naslov']); if ($show_variables_values == true ) { $sub_q1 .= ' ('.strip_tags($spr1['variable']).')'; } if ($spr1['tip'] == '16') { $sub_q1 .= '
'. strip_tags($grid1['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid1['variable']) . ')' : ''); } else { $sub_q1 .= '
' . 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 ? ' ('.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.= '
' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid2['variable']) . ')' : ''); } else { $sub_q2.= '
' . 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']).')' : ''); } $title = $sub_q1 . ' / ' . $sub_q2; } $subtitle = '('.$lang['srv_crosstabs']. ($reportElement['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } // Izrisemo multicrosstab tabelo function displayMulticrosstab($reportElement, $expanded){ global $lang; global $global_user_id; // Ustvarimo instanco razreda $this->classInstance = new SurveyMultiCrosstabs($this->ank_id); // Naslov if($reportElement['spr1'] == '') $title = $lang['srv_select_spr']; else{ // Trenutna aktivna tabela $sql = sisplet_query("SELECT * FROM srv_mc_table WHERE id='$reportElement[spr1]' AND ank_id='$this->ank_id' AND usr_id='$this->creportAuthor'"); $current_table = mysqli_fetch_array($sql); $title = $current_table['name']; } $subtitle = '('.$lang['srv_multicrosstabs'].')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } //izrisemo crosstab element function displayMean($reportElement, $expanded){ global $lang; // Ustvarimo instanco razreda $this->classInstance = new SurveyMeans($this->ank_id); // Napolnimo podatke meansom $meanData1 = explode("-", $reportElement['spr2']); $v_first = array('seq' => $meanData1[0], 'spr' => (isset($meanData1[1])?$meanData1[1]:null), 'grd' => (isset($meanData1[2])?$meanData1[2]:null)); $meanData2 = explode("-", $reportElement['spr1']); $v_second = array('seq' => $meanData2[0], 'spr' => (isset($meanData2[1])?$meanData2[1]:null), 'grd' => (isset($meanData1[2])?$meanData2[2]:null)); $means[0] = $this->classInstance->createMeans($v_first, $v_second); // Nastavimo variable (potrebno za grafe $this->classInstance->variabla1[0] = $v_second; $this->classInstance->variabla2[0] = $v_first; // Naslov if($reportElement['spr1'] == '' || $reportElement['spr2'] == ''){ $title = $lang['srv_select_spr']; } else{ $label2 = strip_tags($this->classInstance->getSpremenljivkaTitle($means[0]['v1'])); $label1 = strip_tags($this->classInstance->getSpremenljivkaTitle($means[0]['v2'])); $title = $label1 . ' / ' . $label2; } $subtitle = '('.$lang['srv_means']. ($reportElement['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } //izrisemo ttest element function displayTTest($reportElement, $expanded){ global $lang; // Ustvarimo instanco razreda $this->classInstance = new SurveyTTest($this->ank_id); // Naslov if($reportElement['spr1'] == '' || $reportElement['spr2'] == ''){ $title = $lang['srv_select_spr']; } else{ $label2 = strip_tags($this->getTTestLabel($reportElement['spr2'])); $label1 = strip_tags($this->getTTestLabel($reportElement['spr1'])); $title = $label1 . ' / ' . $label2; } $subtitle = '('.$lang['srv_ttest']. ($reportElement['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } function getTTestLabel($spr){ $data = explode("-", $spr); $spid = $data[1]; $seq = $data[0]; $grid = $data[2]; $spr_data = $this->classInstance->_HEADERS[$spid]; if ($grid == 'undefined') { # imamp lahko ve� variabel foreach ($spr_data['grids'] as $gkey => $grid ) { foreach ($grid['variables'] as $vkey => $variable) { $sequence = $variable['sequence']; if ($sequence == $seq) { $sprLabel = '('.$variable['variable'].') '. $variable['naslov']; } } } } else { # imamo subgrid $sprLabel = '('.$spr_data['grids'][$grid]['variable'].') '. $spr_data['grids'][$grid]['naslov']; } return $sprLabel; } function displayRazbitje($reportElement, $expanded){ global $lang; // Ustvarimo instanco razreda $this->classInstance = new SurveyBreak($this->ank_id); // Naslov if($reportElement['spr1'] == '' || $reportElement['spr2'] == ''){ $title = $lang['srv_select_spr']; } else{ $breakData1 = explode("-", $reportElement['spr1']); $breakData2 = explode("-", $reportElement['spr2']); $label1 = ''; $variables = $this->classInstance->getVariableList(2); foreach ($variables as $variable) { if($breakData1[0] == $variable['sequence']){ $label1 = ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '  ' : '    ' )) . $variable['variableNaslov']; $label1 = (strlen($label1) > 60) ? substr($label1, 0, 57).'...' : $label1; break; } } $label2 = ''; $variables = $this->getBreakDependentVariableList(); foreach ($variables as $variable) { if(isset($variable['sequence'])&&$breakData2[0] == $variable['sequence']){ //$label2 = $variable['variableNaslov']; $label2 = (strlen($variable['variableNaslov']) > 60) ? substr($variable['variableNaslov'], 0, 57).'...' : $variable['variableNaslov']; break; } } $title = $label1 . ' / ' . $label2; } $subtitle = '('.$lang['srv_break']. ($reportElement['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')'; $title .= ' '.$subtitle.''; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded, $title); // Nastavitve elementa $this->displayReportElementSettings($reportElement, $expanded); // Izpis tabele ali grafa za posamezen vnos echo ''; } /** funkcija vrne seznam primern variabel za crostabe * */ function getBreakDependentVariableList() { $variablesList = array(); # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence) foreach ($this->classInstance->_HEADERS AS $skey => $spremenljivka) { $tip = isset($spremenljivka['tip'])?$spremenljivka['tip']:null; $_dropdown_condition = (is_numeric($tip) && $tip != 5 && $tip != 8 && $tip != 9) ? true : false; if ($_dropdown_condition) { $cnt_all = (int)$spremenljivka['cnt_all']; if ( $cnt_all == '1' || in_array($tip, array(1,2,3,4,7,17,18,21,22,25)) || ($tip == 6 && isset($spremenljivka['enota'])&&$spremenljivka['enota'] == 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] $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 { # imampo samo eno sekvenco grids[0]variables[0] $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 ) { $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) { $variablesList[] = array( 'tip'=>$tip, 'spr_id'=>$skey, 'sequence'=>$variable['sequence'], 'variableNaslov'=>'('.$variable['variable'].') '.strip_tags($variable['naslov']), 'canChoose'=>true, 'sub'=>1); } } } } elseif($tip == 6) { # imamo več gridov - tabele foreach($spremenljivka['grids'] AS $gid => $grid) { $sub = 0; if (isset($grid['variable'])&&$grid['variable'] != '') { $sub++; $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) { $variablesList[] = array( 'tip'=>$tip, 'spr_id'=>$skey, 'sequence'=>$variable['sequence'], 'variableNaslov'=>'('.$variable['variable'].') '.strip_tags($variable['naslov']), 'canChoose'=>true, 'sub'=>$sub); } } } } } else { foreach($spremenljivka['grids'] AS $gid => $grid) { $sub = 0; if ($grid['variable'] != '') { $sub++; $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); } } } } } } } return $variablesList; } // Izrisemo page break med elementi function displayBreak($reportElement){ global $lang; echo '
'.$lang['srv_rem_pagebreak'].'
'; echo '
'; } // Izrisemo element z besedilom function displayText($reportElement, $expanded){ global $lang; // Glava elementa (naslov, ikone...) $this->displayReportElementHead($reportElement, $expanded); echo '
'; if ($this->isArchive == false && $this->publicCReport == false) { echo ''; } echo '
isArchive == false && $this->publicCReport == false ? ' contenteditable="true"':'').' el_id="'.$reportElement['id'].'">'; echo $reportElement['text']; echo '
'; echo '
'; } // Dodajanje elementa porocila function addNewElement($id=0){ global $lang; // Dodajanje vmes in na zacetku if($id != 0){ echo ''.$lang['srv_custom_report_add'].''; echo ''.$lang['srv_custom_report_add_text'].''; if($id > 0) echo ''.$lang['srv_add_pagebreak'].''; } // Dodajanje na dnu (brez page breaka) if($id == 0){ echo ''; echo ''; } } public static function checkEmpty($ank_id){ global $global_user_id; $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; // preverimo ce je ze kaksen element v porocilu $sql = sisplet_query("SELECT id FROM srv_custom_report WHERE ank_id='$ank_id' AND usr_id='$creportAuthor' AND profile='$creportProfile' "); if(mysqli_num_rows($sql) > 0){ $empty = false; } else{ $empty = true; } return $empty; } function setUpReturnAsHtml($returnAsHtml = false) { $this->returnAsHtml = $returnAsHtml; # ali vrne rezultat analiz kot html ali ga izpiše SurveyAnalysis::setUpReturnAsHtml($returnAsHtml); } function setUpIsForArchive($isArchive = false) { $this->isArchive = $isArchive; # nastavimo da smo v arhivu SurveyAnalysis::setUpIsForArchive($isArchive); } function setUpIsForPublic($publicCReport = false) { $this->publicCReport = $publicCReport; SurveyAnalysis::$publicAnalyse = $publicCReport; SurveyAnalysis::$printPreview = $publicCReport; SurveyChart::$publicChart = $publicCReport; } function displaySettingsProfiles(){ global $site_path; global $global_user_id; global $lang; $time_created = ''; $time_edit = ''; $what = 'creport_default_profile_name'; $sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='$what'"); if(mysqli_num_rows($sql) == 0){ $default_name = $lang['srv_custom_report_default']; } else{ $row = mysqli_fetch_array($sql); $default_name = $row['value']; } $profile = $this->getProfile($this->creportProfile); //$name = $profile['name']; echo '

'.$lang['srv_custom_report_profile_title'].'

'; echo ''; echo '
'; // Prednastavljen profil echo ''; echo '
'.$default_name.'
'; // Loop po lastnih porocilih $sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id'"); while($row = mysqli_fetch_array($sql)){ echo '
'.$row['name'].'
'; // Preberemo cas kreiranja porocila if($this->creportProfile == $row['id']) $time_created = $row['time_created']; } // Loop po deljenih porocilih drugih urednikov ankete $sqlA = sisplet_query("SELECT s.*, u.email FROM srv_custom_report_share s, users u WHERE ank_id='$this->ank_id' AND share_usr_id='$global_user_id' AND u.id=s.author_usr_id"); while($rowA = mysqli_fetch_array($sqlA)){ // Ce gre za osnovno porocilo ki ga ne more pobrisati if($rowA['profile_id'] == 0){ // Dobimo ime osnovnega porocila $what = 'creport_default_profile_name'; $sqlN = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='".$rowA['author_usr_id']."' AND what='$what'"); if(mysqli_num_rows($sqlN) == '0'){ $default_name = $lang['srv_custom_report_default']; } else{ $rowN = mysqli_fetch_array($sqlN); $default_name = ($rowN['value'] == '') ? $lang['srv_custom_report_default'] : $rowN['value']; } echo '
'; echo $default_name . ' ('.$rowA['email'].')'; echo '
'; } // Ce gre za dodatno porocilo ga imamo normalno v bazi else{ $sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='".$rowA['author_usr_id']."'"); while($row = mysqli_fetch_array($sql)){ echo '
'; echo $row['name'] . ' ('.$rowA['email'].')'; echo '
'; // Preberemo cas kreiranja porocila if($this->creportProfile == $row['id']) $time_created = $row['time_created']; } } } echo '
'; // Ce je izbran custom profil imamo na dnu gumba brisi in preimenuj, pri default pa samo preimenuj // Preimenuje, brise in share lahko samo za lastna porocila if($this->creportAuthor == $global_user_id){ echo '

'.$lang['srv_rename_profile'].'

'; if($this->creportProfile > 0) echo '

'.$lang['srv_delete_profile'].'

'; echo '

'.$lang['srv_custom_report_share'].'

'; } /*/ Preberemo najkasneje editiran element (cas spreminjanja) $sqlt = sisplet_query("SELECT MAX(time_edit) FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'"); if(mysqli_num_rows($sqlt) > 0){ $rowt = mysqli_fetch_array($sqlt); $time_edit = $rowt['MAX(time_edit)']; } else $time_edit = $time_created; // Cas kreirranja in urejanja profila echo '
'; if($time_created != '' && $time_created != '0000-00-00 00:00:00'){ $time_created = strtotime($time_created); echo '

'.$lang['srv_custom_report_time_created'].': '.date("d.m.Y H:i", $time_created).'

'; } if($time_edit != '' && $time_edit != '0000-00-00 00:00:00'){ $time_edit = strtotime($time_edit); echo '

'.$lang['srv_custom_report_time_edited'].': '.date("d.m.Y H:i", $time_edit).'

'; }*/ echo '
'; echo '
'; // Komentar profila echo '
'; $what = 'creport_comment_profile_'.$this->creportProfile; $sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->creportAuthor' AND what='$what'"); if(mysqli_num_rows($sql) == 0){ $comment = ''; } else{ $row = mysqli_fetch_array($sql); $comment = $row['value']; } echo '

'.$lang['srv_inv_archive_comment'].':

'; // Komentar lahko popravlja samo avtor porocila if($this->creportAuthor == $global_user_id) echo ''; else echo ''.$comment.''; echo '
'; // cover Div echo '
'."\n"; echo '
'; echo ''; echo ''; echo ''; echo '
'; } function displayProfilePopups(){ global $lang; //global $global_user_id; $profile = $this->getProfile($this->creportProfile); //$name = $profile['name']; // div za kreacijo novega echo '
'; echo '

'.$lang['srv_custom_report_create2'].'

'; echo ''; echo '

'.$lang['srv_custom_report_name'].':

'; echo ''; echo '

'.$lang['srv_inv_archive_comment'].':

'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '
'; // div za preimenovanje echo '
'; echo '

'.$lang['srv_custom_report_name'].':

'; echo ''; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '
'; // div za brisanje echo '
'; echo '

'.$lang['srv_custom_report_delete_confirm'].': ?

'; echo ''."\n"; echo '
'; echo ''; echo ''; echo '
'; echo '
'; // div za deljenje z drugimi uredniki echo '
'; echo '
'."\n"; } public function getProfile($profile_id){ global $global_user_id; $sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$profile_id'"); $profile = mysqli_fetch_array($sql); return $profile; } public function getTitle(){ global $global_user_id; global $lang; $what = 'creport_title_profile_'.$this->creportProfile; $sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->creportAuthor' AND what='$what'"); if(mysqli_num_rows($sql) == 0){ $titleString = $lang['export_analisys_creport'].': '.SurveyInfo::getInstance()->getSurveyTitle(); } else{ $row = mysqli_fetch_array($sql); $titleString = $row['value']; } return $titleString; } public function displayPublicCReport($properties) { global $lang; global $site_url; header('Cache-Control: no-cache'); header('Pragma: no-cache'); $anketa = $this->ank_id; $this->creportProfile = $properties['creportProfile']; $this->creportAuthor = $properties['creportAuthor']; 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 ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $what = 'creport_title_profile_'.$this->creportProfile; $sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$anketa' AND uid='$this->creportAuthor' AND what='$what'"); if(mysqli_num_rows($sql) == 0){ $titleString = $lang['srv_publc_creport_title_for'].SurveyInfo::getInstance()->getSurveyTitle(); } else{ $row = mysqli_fetch_array($sql); $titleString = $row['value']; } echo '

'.$titleString.'

'; echo ''; echo ''; echo '
'; # ponastavimo nastavitve- filter self::displayReport(); echo '
'; echo ''; echo ''; echo ''; } // Funkcije ajaxa public function ajax() { global $lang; global $global_user_id; global $site_url; $_GET['m'] = 'analysis_creport'; if (isset ($_POST['anketa'])) $this->ank_id = $_POST['anketa']; if (isset ($_POST['element_id'])) $element_id = $_POST['element_id']; if (isset ($_POST['what'])) $what = $_POST['what']; if (isset ($_POST['value'])) $value = $_POST['value']; // Nastavimo se nacin (skrcen/razsirjen) $this->expanded = (isset($_POST['expanded']) ? $_POST['expanded'] : 0); // Dodajanje praznega elementa v report if($_GET['a'] == 'add_empty_element'){ // dodajanje vmes if($element_id > 0){ $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'"); $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['vrstni_red'] + 1; // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>='$vrstni_red' AND profile='$this->creportProfile'"); $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $el_id = mysqli_insert_id($GLOBALS['connect_db']); } //dodajanje na zacetku elseif($element_id == -1){ // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'"); $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '1', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $el_id = mysqli_insert_id($GLOBALS['connect_db']); } // dodajanje na koncu else{ $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile' ORDER BY vrstni_red DESC"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['vrstni_red'] + 1; } else $vrstni_red = 1; $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $el_id = mysqli_insert_id($GLOBALS['connect_db']); } $this->displayReport(); echo ''; } // Dodajanje ze nastavljenega elementa v report (klik na zvezdico) if($_GET['a'] == 'add_element'){ if (isset ($_POST['type'])) $type = $_POST['type']; if (isset ($_POST['sub_type'])) $sub_type = $_POST['sub_type']; if (isset ($_POST['spr1'])) $spr1 = $_POST['spr1']; if (isset ($_POST['spr2'])) $spr2 = $_POST['spr2']; if (isset ($_POST['insert'])) $insert = $_POST['insert']; // Vstavljanje if($insert == 1){ // Razberemo vrstni red $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile' ORDER BY vrstni_red DESC"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['vrstni_red'] + 1; } else $vrstni_red = 1; $sql = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, sub_type, spr1, spr2, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$type', '$sub_type', '$spr1', '$spr2', '$this->creportProfile', NOW())"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); echo $vrstni_red; } // brisanje else{ // Preberemo vrstni red elementa, ki ga brisemo $sql = sisplet_query("SELECT id, vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND type='$type' AND sub_type='$sub_type' AND spr1='$spr1' AND spr2='$spr2' AND profile='$this->creportProfile'"); $row = mysqli_fetch_array($sql); $vrstni_red = $row['vrstni_red']; $element_id = $row['id']; $sql = sisplet_query("DELETE FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red-1, time_edit=NOW() WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>'$vrstni_red' AND profile='$this->creportProfile'"); echo -1; } } // Brisanje elementa if($_GET['a'] == 'delete_element'){ $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'"); $row = mysqli_fetch_array($sql); $vrstni_red = $row['vrstni_red']; $sql = sisplet_query("DELETE FROM srv_custom_report WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red-1, time_edit=NOW() WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>'$vrstni_red' AND profile='$this->creportProfile'"); $this->displayReport(); } // Editiranje elementa v reportu if($_GET['a'] == 'edit_element'){ // Preklop na navaden tip (freq, sums, graf, desc) if($what == 'type' && $value < 5){ $sql = sisplet_query("SELECT type FROM srv_custom_report WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'"); $row = mysqli_fetch_array($sql); // Ce preklapljamo iz crosstabov, meansov ali ttesta - resetiramo spremenljivke if($row['type'] > 4){ $s = sisplet_query("UPDATE srv_custom_report SET $what='$value', spr1='', spr2='', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'"); } else{ $s = sisplet_query("UPDATE srv_custom_report SET $what='$value', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } } // Ce preklopimo na crosstabe, means ali ttest resetiramo vse spremenljivke elseif($what == 'type' && $value > 4){ $s = sisplet_query("UPDATE srv_custom_report SET $what='$value', spr1='', spr2='', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } // Ostali preklopi else{ $s = sisplet_query("UPDATE srv_custom_report SET $what='$value', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } $expanded = isset($_POST['expanded']) ? $_POST['expanded'] : 1; $this->displayReportElement($element_id, $expanded); } if($_GET['a'] == 'copy_element'){ $sql = sisplet_query("SELECT * FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'"); $row = mysqli_fetch_array($sql); // najprej prestevilcimo elemente ki so za kopiranim $sql2 = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>'$row[vrstni_red]' AND profile='$this->creportProfile'"); $vrstni_red = $row['vrstni_red'] + 1; $sqlInsert = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, sub_type, spr1, spr2, text, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$row[type]', '$row[sub_type]', '$row[spr1]', '$row[spr2]', '$row[text]', '$row[profile]', NOW())"); if (!$sqlInsert) echo mysqli_error($GLOBALS['connect_db']); $this->displayReport(); } // Sortiranje elementov if($_GET['a'] == 'change_order'){ $sortable = $_POST['sortable']; $exploded = explode('&', $sortable); $i = 1; foreach ($exploded AS $key) { $key = str_replace('variabla_', '', $key); $explode = explode('[]=', $key); $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red = '$i', time_edit = NOW() WHERE id = '$explode[1]' AND profile='$this->creportProfile'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $i++; } } // Alert pri dodajanju prvega if($_GET['a'] == 'first_alert'){ echo '

'.$lang['srv_custom_report_insert'].'

'; echo ''; echo $lang['srv_custom_report_first']; echo '
'; echo ''; echo ''; echo '
'; } // razsiritev / skrcenje elementa if($_GET['a'] == 'expand_element'){ if (isset ($_POST['expanded'])) $expanded = $_POST['expanded']; $this->displayReportElement($element_id, $expanded); } // Dodajanje text elementa v report if($_GET['a'] == 'add_text_element'){ // dodajanje vmes if($element_id > 0){ $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'"); $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['vrstni_red'] + 1; // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>='$vrstni_red' AND profile='$this->creportProfile'"); $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, type, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '8', '$vrstni_red', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $el_id = mysqli_insert_id($GLOBALS['connect_db']); } //dodajanje na zacetku elseif($element_id == -1){ // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'"); $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, type, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '8', '1', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $el_id = mysqli_insert_id($GLOBALS['connect_db']); } // dodajanje na koncu else{ $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile' ORDER BY vrstni_red DESC"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['vrstni_red'] + 1; } else $vrstni_red = 1; $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, type, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '8', '$vrstni_red', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $el_id = mysqli_insert_id($GLOBALS['connect_db']); } $this->displayReport(); echo ''; } // Dodajanje page breaka v report if($_GET['a'] == 'add_pb_element'){ $sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'"); $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['vrstni_red'] + 1; // Prestevilcimo elemente $sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>='$vrstni_red' AND profile='$this->creportProfile'"); $s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, type, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '-1', '$vrstni_red', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $this->displayReport(); } // Urejanje naslova porocila if($_GET['a'] == 'edit_title'){ $what = 'creport_title_profile_'.$this->creportProfile; if($value != ''){ $s = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$this->creportAuthor', '$what', '$value') ON DUPLICATE KEY UPDATE value='$value'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } else{ $s = sisplet_query("DELETE FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->creportAuthor' AND what='$what'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } } // prikaz previewja if($_GET['a'] == 'report_preview'){ echo '

'.$lang['export_analisys_creport'].': '.SurveyInfo::getInstance()->getSurveyTitle().'

'; $this->setUpReturnAsHtml(false); $this->setUpIsForArchive(true); $this->expanded = 1; $this->displayReport(); echo ''; } // Alert pri dodajanju vseh elementov istega tipa v report if($_GET['a'] == 'all_elements_alert'){ $type = (isset($_POST['type'])) ? $_POST['type'] : 0; echo '

'.$lang['srv_custom_report_comments_add'].'

'; echo ''; echo '

'.$lang['srv_custom_report_comments_alert'.$type].'

'; echo '
'; echo ''; echo ''; echo '
'; } // Dodajanje vseh elementov istega tipa v report if($_GET['a'] == 'all_elements_add'){ $type = (isset($_POST['type'])) ? $_POST['type'] : 0; $sql = sisplet_query("SELECT MAX(vrstni_red) FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_assoc($sql); $vrstni_red = $row['MAX(vrstni_red)'] + 1; } else $vrstni_red = 1; // Vstavljamo BREAK if($type == 9){ // Ustvarimo instanco breaka $this->classInstance = new SurveyBreak($this->ank_id); $spr1 = (isset($_POST['spr1'])) ? $_POST['spr1'] : 0; $spremenljivka = explode("-", $spr1); $sub_type = (isset($_POST['sub_type'])) ? $_POST['sub_type'] : 0; // Loop po odvisnih spremenljivkah in variablah $variables = $this->getBreakDependentVariableList(); foreach ($variables as $variable) { // Ce ne gre za disablan element in ne gre za isto spremenljivko kot spr1 if((int)$variable['canChoose'] == 1 && $variable['spr_id'] != $spremenljivka[1]){ $spr2 = $variable['sequence'].'-'.$variable['spr_id'].'-undefined'; // Vstavimo element v bazo $sqlInsert = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, sub_type, spr1, spr2, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '9', '$sub_type', '$spr1', '$spr2', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $vrstni_red++; } } } // Vstavljamo ostale osnove (sums, grafi, freq, desc) else{ # preberemo header foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) { # preverjamo ali je meta if ($spremenljivka['tip'] != 'm' && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES )){ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore $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)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']; } } } // Ce ja kaksen veljaven oz ce prikazujemo tudi prazne if(SurveyDataSettingProfiles :: getSetting('hideEmpty') != 1 || $only_valid > 0){ $sqlInsert = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, spr1, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$type', '$spid', '$this->creportProfile', NOW())"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $vrstni_red++; } } } } //$this->displayReport(); } // Odpremo okno za izbiro/save profila if($_GET['a'] == 'creport_show_profiles') { $this->displaySettingsProfiles(); } // Spreminjamo profil if($_GET['a'] == 'creport_change_profile') { if (isset ($_POST['id'])) $id = $_POST['id']; if (isset ($_POST['author'])) $author = $_POST['author']; $this->creportProfile = $id; $this->creportAuthor = $author; $this->displaySettingsProfiles(); } // preimenujemo profil if($_GET['a'] == 'renameProfile') { if (isset ($_POST['id'])) $id = $_POST['id']; if (isset ($_POST['name'])) $name = $_POST['name']; // Default profil shranimo drugam ker ga ni v bazi (prevec komplikacij ker je bilo to naknadno delano) if($id == 0){ $what = 'creport_default_profile_name'; $sql = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$global_user_id', '$what', '$name') ON DUPLICATE KEY UPDATE value='$name'"); } else $sql = sisplet_query("UPDATE srv_custom_report_profiles SET name='$name' WHERE id='$id'"); $this->displaySettingsProfiles(); } // pobrisemo profil if($_GET['a'] == 'deleteProfile') { if (isset ($_POST['id'])) $id = $_POST['id']; $sql = sisplet_query("DELETE FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' AND id='$id'"); $sql = sisplet_query("DELETE FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' AND profile='$id'"); $this->displaySettingsProfiles(); } // shranimo kot nov profil if($_GET['a'] == 'newProfile') { if (isset ($_POST['name'])) $name = $_POST['name']; if (isset ($_POST['comment'])) $comment = $_POST['comment']; $sql = sisplet_query("INSERT INTO srv_custom_report_profiles (ank_id, usr_id, name, time_created) VALUES('$this->ank_id', '$global_user_id', '$name', NOW())"); $profile_id = mysqli_insert_id($GLOBALS['connect_db']); SurveyUserSetting :: getInstance()->saveSettings('default_creport_profile', $profile_id); $this->creportProfile = $profile_id; SurveyUserSetting :: getInstance()->saveSettings('default_creport_author', $global_user_id); $this->creportAuthor = $global_user_id; // Dodamo se komentar porocila $what = 'creport_comment_profile_'.$this->creportProfile; if($comment != ''){ $s = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$global_user_id', '$what', '$comment') ON DUPLICATE KEY UPDATE value='$comment'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } else{ $s = sisplet_query("DELETE FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='$what'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } //$this->displaySettingsProfiles(); } // pozenemo izbran profil if($_GET['a'] == 'use_creport_profile') { if (isset ($_POST['id'])) $id = $_POST['id']; if (isset ($_POST['author'])) $author = $_POST['author']; SurveyUserSetting :: getInstance()->saveSettings('default_creport_profile', $id); SurveyUserSetting :: getInstance()->saveSettings('default_creport_author', $author); } // urejanje komentarja profila if($_GET['a'] == 'edit_profile_comment') { $what = 'creport_comment_profile_'.$this->creportProfile; if($value != ''){ $s = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$global_user_id', '$what', '$value') ON DUPLICATE KEY UPDATE value='$value'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } else{ $s = sisplet_query("DELETE FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='$what'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } } // prikazemo deljenje profila z drugimi uredniki if($_GET['a'] == 'shareProfileShow') { echo '
'; echo ''.$lang['srv_custom_report_share_long'].':'; if (isset ($_POST['id'])){ $id = $_POST['id']; // Loop cez vse urednike ankete z dostopom do analiz $d = new Dostop(); $users = $d->getUsersDostop(); foreach($users as $user){ if($user['id'] != $global_user_id){ $sql = sisplet_query("SELECT * FROM srv_custom_report_share WHERE ank_id='".$this->ank_id."' AND profile_id='".$id."' AND author_usr_id='".$global_user_id."' AND share_usr_id='".$user['id']."' LIMIT 1"); $checked = (mysqli_num_rows($sql) > 0) ? ' checked="checked"' : ''; echo '
'; echo ' '; echo ''; echo '
'; } } } echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; } // delimo profil z drugimi uredniki if($_GET['a'] == 'shareProfile') { if (isset ($_POST['id']) && isset ($_POST['users'])){ $id = $_POST['id']; $users = $_POST['users']; // Dodamo dostop ostalim urednikom za to porocilo foreach($users as $user_id){ $sql = sisplet_query("INSERT INTO srv_custom_report_share (ank_id, profile_id, author_usr_id, share_usr_id) VALUES ('".$this->ank_id."', '".$id."', '".$global_user_id."', '".$user_id."')"); } // Pobrisemo dostop neoznacenim urednikom do tega porocila $sql = sisplet_query("DELETE FROM srv_custom_report_share WHERE ank_id='".$this->ank_id."' AND profile_id='".$id."' AND author_usr_id='".$global_user_id."' AND share_usr_id NOT IN (".implode(',', $users).")"); } elseif(isset($_POST['id'])){ $id = $_POST['id']; // Pobrisemo dostop vsem urednikom do tega porocila $sql = sisplet_query("DELETE FROM srv_custom_report_share WHERE ank_id='".$this->ank_id."' AND profile_id='".$id."' AND author_usr_id='".$global_user_id."'"); } $this->displaySettingsProfiles(); } } } ?>