sid = $anketa; # Inicializiramo in polovimo nastavitve missing profila SurveyStatusProfiles::Init($this->sid); SurveyUserSetting::getInstance()->Init($anketa, $global_user_id); #inicializiramo class za datoteke SurveyDataFile::get_instance(); SurveyDataFile::get_instance()->init($anketa); $headFileName = SurveyDataFile::get_instance()->getHeaderFileName(); $dataFileStatus = SurveyDataFile::get_instance()->getStatus(); # polovimo header datoteko if ($dataFileStatus == FILE_STATUS_NO_DATA || $dataFileStatus == FILE_STATUS_NO_FILE || $dataFileStatus == FILE_STATUS_SRV_DELETED){ return false; } if ($headFileName !== null && $headFileName != '') { $this->_HEADERS = unserialize(file_get_contents($headFileName)); } session_start(); #nastavimo inspect if (isset($_SESSION['enableInspect']) && $_SESSION['enableInspect'] == true) { $this->enableInspect = true; } else { $this->enableInspect = false; } #nastavimo GOTO (analize,vpogled,podatki) if (isset($_SESSION['inspect_goto'])) { $this->inspect_goto = (int)$_SESSION['inspect_goto']; } else { $this->inspect_goto = 0; } } public function isInspectEnabled() { return $this->enableInspect; } public function whereToGo() { $inspect_goto_array = array( SI_GOTO_ANALIZE => '&a=analysis&m=sumarnik', SI_GOTO_VPOGLED => '&a=data&m=quick_edit', SI_GOTO_PODATKI => '&a=data'); return ($inspect_goto_array[$this->inspect_goto]); } public function ajax() { switch ($_GET['a']) { case 'analizaPrepareInspect': $this->PrepareInspectAnaliza(); break; case 'changeSessionInspect': $this->changeSessionInspect(); break; case 'showInspectSettings': $this->showInspectSettings(); break; case 'show_inspectListSpr': $this->showInspectListSpr(); break; case 'saveInspectListVars': $this->saveInspectListVars(); break; case 'saveSettings': $this->saveSettings(); break; case 'displayInspectVars': $this->displayInspectVars(); break; case 'removeInspect': $this->removeInspect(); break; default: print_r("
"); print_r($_POST); print_r($_GET); print_r(""); break; } } function PrepareInspectAnaliza() { global $global_user_id, $lang; # nastavimo filter variable #izluščimo spr_id $spr_data = explode('_',$_POST['spr_data']); $spr = $spr_data[0]; $sequence = $spr_data[2]; $counter = $spr_data[3]; $_spr = $this->_HEADERS[$spr.'_0']; # nastavimo v sejo od kod smo prišli v inspect: session_start(); if ((isset($_POST['from_podstran']) && trim($_POST['from_podstran']) != '')) { $_SESSION['inspectFromPodstran'][$this->sid] = $_POST['from_podstran']; } else { unset($_SESSION['inspectFromPodstran'][$this->sid]); } session_commit(); # naredimo inspect profil za variable $variables = $spr.'_0'; $var_array[] = $variables; if ($this->isInspectEnabled()) { $_add_vars = $_SESSION['dataSetting_profile'][$this->sid]['InspectListVars']; if (isset($_add_vars) && is_array($_add_vars) && count($_add_vars) > 0) { foreach ($_add_vars AS $add_var) { $variables .= ','.$add_var.'_0'; $var_array[] = $add_var.'_0'; } } } $svp = new SurveyVariablesProfiles(); $svp -> Init($this->sid); $svp-> setProfileInspect($var_array); # if id za inspect shranimo v nastavitev ankete SurveyUserSetting -> inspect_if_id (če ne obstaja skreiramo novega) # dodamo tudi kot profil pogojev (če ne obstaja skreiramo novega) #preverimo ali obstaja zapis v SurveyUserSetting->inspect_if_id $if_id = (int)SurveyUserSetting :: getInstance()->getSettings('inspect_if_id'); # preverimo dejanski obstoj ifa (srv_if) če ne skreiramo novega if ((int)$if_id > 0) { $chks1 = "SELECT id FROM srv_if WHERE id='$if_id'"; $chkq1 = sisplet_query($chks1); # dodamo še k profilu če ne obstaja if (mysqli_num_rows($chkq1) == 0) { $if_id = null; SurveyUserSetting :: getInstance()->removeSettings('inspect_if_id'); } } if ( (int)$if_id == 0 || $if_id == null) { # if še ne obstaja, skreiramo novga $newIfString = "INSERT INTO srv_if (id) VALUES ('')"; $sql = sisplet_query($newIfString); # if (!$sql) echo '
-1'; $if_id = mysqli_insert_id($GLOBALS['connect_db']); sisplet_query("COMMIT"); # shranimo pogoj kot privzet pogoj z ainspect SurveyUserSetting :: getInstance()->saveSettings('inspect_if_id',(int)$if_id); } if ((int)$if_id > 0) { # dodamo ifa za obe variabli # ne brišemo starih pogojev, da omogočimo gnezdenje #$delStr = "DELETE FROM srv_condition WHERE if_id = '$if_id'"; #sisplet_query($delStr); # poiščemo vrednosti za oba vprašanja $condition = $this->createSubCondition($_POST['vkey'],$if_id,$spr,$_spr,$sequence); sisplet_query("COMMIT"); # pogoj dodamo še v srv_condition_profile vendar ga ne nastavimo kot privzetega $chk_if_str = "SELECT id FROM srv_condition_profiles WHERE sid='".$this->sid."' AND uid = '".$global_user_id."' AND type='inspect'"; $chk_if_qry = sisplet_query($chk_if_str); $_tmp_name = $lang['srv_inspect_temp_profile']; if (mysqli_num_rows($chk_if_qry) > 0) { # if že obstaja popravimo morebitne podatke $str = "UPDATE srv_condition_profiles SET name = '$_tmp_name', if_id='$if_id'"; $sql = sisplet_query($str); } else { #vstavimo nov profil pogojev - inspect $str = "INSERT INTO srv_condition_profiles (sid, uid, name, if_id, type ) VALUES ('".$this->sid."', '".$global_user_id."', '$_tmp_name', '$if_id', 'inspect')" . " ON DUPLICATE KEY UPDATE name='$_tmp_name', if_id='$if_id'"; $sql = sisplet_query($str); } sisplet_query("COMMIT"); } echo $this->whereToGo(); return $this->whereToGo(); } function createSubCondition($vrednost,$if_id,$spr,$_spr,$sequence) { $tip = $_spr['tip']; # 1. Radio # 3. Dropdown # 2. Select - checkbox if ($tip == '1' || $tip == '3' || $tip == '2') { #radio in dropdown if ($tip == '1' || $tip == '3') { #s pomočjo k preberemo stni red $sql_string = "SELECT id FROM srv_vrednost WHERE spr_id='$spr' AND variable = '".$vrednost."'"; $sql_query = sisplet_query($sql_string); if (mysqli_num_rows($sql_query) == 1 ) { $sql_row = mysqli_fetch_assoc($sql_query); $vred_id = $sql_row['id']; } } #select if ($tip == '2' ) { $vred_id=null; # če je čekbox poiščemo vred_id za sekvenco k foreach ($_spr['grids'] as $gkey=>$grid) { foreach ($grid['variables'] as $vkey=>$variable) { if ($variable['sequence'] == $sequence) { $vred_id = $variable['vr_id']; } } } } if ($vred_id != null && (int)$vred_id > 0) { if ($tip == '2' && $vrednost == 0) { $_operator_str = ', operator'; $_operator_val = ", '1'"; $_operator_repl = ", operator = '1'"; } $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red".$_operator_str.") VALUES ('$if_id', '$spr', '1'".$_operator_val.")" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1'".$_operator_repl; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); if ((int)$vred_id > 0 || (int)$cond_id > 0) { $istr = "INSERT INTO srv_condition_vre (cond_id, vre_id) VALUES ('$cond_id', '$vred_id')"; $sql = sisplet_query($istr); if (!$sql) { echo '
-4 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } } return $cond_id; } } # 6. multi radio if ($tip == '6' ) { # če je dvojni grid potem posebej polovimo vrednosti list($enota) = mysqli_fetch_row(sisplet_query("SELECT enota FROM srv_spremenljivka WHERE id='$spr'")); if($enota != 3) { $vred_id=null; #pogledamo za katero vrednost iščemo s pomočjo sekvence foreach ($_spr['grids'] AS $gkey=> $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['sequence'] == $sequence) { $vred_id = $variable['vr_id']; } } } $sql_string = "SELECT id FROM srv_grid WHERE spr_id='$spr' AND (variable = '".$vrednost."' OR other = '".$vrednost."')"; $sql_query = sisplet_query($sql_string); if (mysqli_num_rows($sql_query) == 1 ) { $sql_row = mysqli_fetch_assoc($sql_query); $vrednost_id = $sql_row['id']; } } else { $vred_id = $sequence; # za dvojni grid moramo id polovit s pomočjo part $_tmp = explode('_',$vrednost); $vrednost = $_tmp[0]; $part = $_tmp[1]; $sql_string = "SELECT id FROM srv_grid WHERE spr_id='$spr' AND (variable = '".$vrednost."' OR other = '".$vrednost."') AND part = '$part'"; $sql_query = sisplet_query($sql_string); if (mysqli_num_rows($sql_query) == 1 ) { $sql_row = mysqli_fetch_assoc($sql_query); $vrednost_id = $sql_row['id']; } } if ($vred_id !== null && (int)$vred_id > 0) { $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id) VALUES ('$if_id', '$spr', '1', '$vred_id')" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1', vre_id='$vred_id'"; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); #dodamo še v srv_grid if ($cond_id > 0) { $istr = "INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$cond_id', '".$vrednost_id."')"; $sql = sisplet_query($istr); if (!$sql) { echo '
-4 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } } else { echo '
-5 :: '; } return $cond_id; } } # 7. Number if ($tip == '7' ) { $vred_id=null; #pogledamo za katero vrednost iščemo s pomočjo sekvence foreach ($_spr['grids'] AS $gkey=> $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['sequence'] == $sequence) { $grid_id = $vkey; } } } if ($grid_id !== null) { $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, grd_id, text) VALUES ('$if_id', '$spr', '1', '$grid_id', '$vrednost')" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1', grd_id='$grid_id', text='$vrednost'"; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); return $cond_id; } } # 16. multi checkbox if ($tip == '16' ) { $vred_id=null; #pogledamo za katero vrednost iščemo s pomočjo sekvence foreach ($_spr['grids'] AS $gkey=> $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['sequence'] == $sequence) { $vred_id = $variable['vr_id']; $grid_id = $variable['gr_id']; } } } if ($vrednost == 0) { $_operator_str = ', operator'; $_operator_val = ", '1'"; $_operator_repl = ", operator = '1'"; } if ($vred_id !== null && (int)$vred_id > 0) { $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id".$_operator_str.") VALUES ('$if_id', '$spr', '1', '$vred_id'".$_operator_val.")" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1', vre_id='$vred_id'".$_operator_repl; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); #dodamo še v srv_grid if ($cond_id > 0 && $grid_id > 0) { $istr = "INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$cond_id', '".$grid_id."')"; $sql = sisplet_query($istr); if (!$sql) { echo '
-4 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } } else { echo '
-5 :: '; } return $cond_id; } } # 17. razvrščanje ranking if ($tip == '17' ) { #pogledamo za katero vrednost iščemo s pomočjo sekvence foreach ($_spr['grids'] AS $gkey=> $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['sequence'] == $sequence) { $vred_id = $variable['vr_id']; } } } if ($vred_id !== null && (int)$vred_id > 0) { $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id) VALUES ('$if_id', '$spr', '1', '$vred_id')" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1', vre_id='$vred_id'"; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); $grid_id = $_spr['options'][$vrednost]; #dodamo še v srv_grid if ($cond_id > 0 && $grid_id > 0) { $istr = "INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$cond_id', '".$grid_id."')"; $sql = sisplet_query($istr); if (!$sql) { echo '
-4 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } } else { echo '
-5 :: '; } return $cond_id; } } # 21. besedilo # 18. vsota if ($tip == '21' || $tip == '18') { $vred_id=null; #pogledamo za katero vrednost iščemo s pomočjo sekvence foreach ($_spr['grids'] AS $gkey=> $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['sequence'] == $sequence) { $vred_id = $variable['vr_id']; } } } if ($vred_id !== null && (int)$vred_id > 0) { $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id, text) VALUES ('$if_id', '$spr', '1', '$vred_id', '$vrednost')" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1', vre_id='$vred_id', text='$vrednost'"; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); return $cond_id; } } # 19. multi text # 20. multi number if ($tip == '19' || $tip == '20') { #pogledamo za katero vrednost iščemo s pomočjo sekvence foreach ($_spr['grids'] AS $gkey=> $grid) { foreach ($grid['variables'] AS $vkey => $variable) { if ($variable['sequence'] == $sequence) { $vred_id = $variable['vr_id']; $grid_id = $variable['gr_id']; } } } if ($vred_id !== null && (int)$vred_id > 0 && $grid_id > 0) { $istr = "INSERT INTO srv_condition (if_id, spr_id, vrstni_red, vre_id, grd_id, text) VALUES ('$if_id', '$spr', '1', '$vred_id', '$grid_id', '$vrednost')" . " ON DUPLICATE KEY UPDATE spr_id='$spr', vrstni_red = '1', grd_id='$grid_id', text='$vrednost'"; $sql = sisplet_query($istr); if (!$sql) { echo '
-3 :: '.$istr; echo mysqli_error($GLOBALS['connect_db']); } $cond_id = mysqli_insert_id($GLOBALS['connect_db']); return $cond_id; } } return null; } function changeSessionInspect() { session_start(); #Zamenjamo sejo if (isset($_SESSION['enableInspect']) && $_SESSION['enableInspect'] == true) { unset($_SESSION['enableInspect']); } else { $_SESSION['enableInspect'] = true; } session_commit(); #nastavimo inspect if (isset($_SESSION['enableInspect']) && $_SESSION['enableInspect'] == true) { $this->enableInspect = true; } else { # če ne preberemo iz profila $this->enableInspect = false; } $this->displaySessionInspectCheckbox((isset($_POST['isAnaliza']) && (int)$_POST['isAnaliza'] == 1) ? true : false); } function DisplayLink($hideAdvanced = true) { global $lang; $css = ($this->enableInspect == SI_DEFAULT_PROFILE ? ' gray' : ''); if ($hideAdvanced == false || $this->enableInspect != SI_DEFAULT_PROFILE) { echo '
'.$lang['srv_inspect_setting_link'].'
'; echo ''; echo ''; echo ' enableInspect == false) ? ' checked="checked" ' : '') . ' autocomplete="off"/>'; echo ''; echo ' enableInspect == true) ? ' checked="checked" ' : '') . ' autocomplete="off"/>'; echo ''; echo Help :: display('srv_crosstab_inspect'); echo '
'; echo ''; echo '
'; echo '