From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- admin/survey/Branching.php | 10442 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 10442 insertions(+) create mode 100644 admin/survey/Branching.php (limited to 'admin/survey/Branching.php') diff --git a/admin/survey/Branching.php b/admin/survey/Branching.php new file mode 100644 index 0000000..08ff025 --- /dev/null +++ b/admin/survey/Branching.php @@ -0,0 +1,10442 @@ + 0) { + + $this->anketa = $anketa; + + }elseif (!empty($_POST['anketa']) && is_numeric($_POST['anketa'])){ + + $this->anketa = $_POST['anketa']; + + }elseif ( !empty($_GET['anketa']) && is_numeric($_GET['anketa'])) { + + $this->anketa = $_GET['anketa']; + + } + + // Vrnemo in zapišemo v log, kdaj je anketa=0 + if(empty($this->anketa) || $this->anketa <= 0) { + if($this->anketa == 0) + return 'Missing ID ankete v branchingu!'; + } + + // spremeni nastavitve pogleda urejanja + if (isset($_GET['change_mode']) && $_GET['change_mode'] == 1) { + $ba = new BranchingAjax($this->anketa); + $ba->ajax_change_mode(); + } + + # clear E_NOTICE + if (!isset($_POST['spr'])) { $_POST['spr'] = null; } + if (!isset($_POST['if'])) { $_POST['if'] = null; } + if (!isset($_POST['endif'])) { $_POST['endif'] = null; } + if (!isset($_POST['parent_if'])) { $_POST['parent_if'] = null; } + if (!isset($_GET['parent_if'])) { $_GET['parent_if'] = null; } + if (!isset($_POST['info'])) { $_POST['info'] = null; } + + if (isset($surveySkin)) + $this->skin = $surveySkin; + + SurveyInfo::getInstance()->SurveyInit($this->anketa); + + if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) + $this->db_table = '_active'; + + UserSetting :: getInstance()->Init($global_user_id); + + // v novem nacinu se vsem anketam nastavi branching na 1 (popravi se pri starih - brez ifov, da dobiji srv_branching tabelo) + $row = SurveyInfo::getInstance()->getSurveyRow(); + if ($row['branching'] == 0) { + $this->init_branching(); + } + if ($row['expanded'] == 1) + $this->expanded = true; + + if ($row['locked'] == 1) + $this->locked = 1; + } + + /** + * @desc inicializacija branchinga (samo prvi�, na za�etku), prepi�e vrstni red iz normalenga urejanja + */ + function init_branching () { + + // nastavimo na branching, da ne sinhroniza + sisplet_query("UPDATE srv_anketa SET branching='1' WHERE id = '$this->anketa'"); + + // vsilimo refresh podatkov + SurveyInfo :: getInstance()->resetSurveyData(); + + sisplet_query("DELETE FROM srv_branching WHERE ank_id='$this->anketa'"); + + $sql = sisplet_query("SELECT s.id, s.gru_id, s.vrstni_red + FROM srv_grupa g, srv_spremenljivka s + WHERE g.ank_id='$this->anketa' AND g.id=s.gru_id AND s.id + ORDER BY g.vrstni_red ASC, s.vrstni_red ASC + "); + $vrstni_red = 1; + while ($row = mysqli_fetch_array($sql)) { + + $sql1 = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id = '$row[gru_id]' AND vrstni_red = ('$row[vrstni_red]'+1)"); + if (mysqli_num_rows($sql1) == 0 && $this->find_last_spr() != $row['id']) + $pb = 1; + else + $pb = 0; + + sisplet_query("INSERT INTO srv_branching (ank_id, parent, element_spr, element_if, vrstni_red, pagebreak) VALUES ('$this->anketa', '0', '$row[id]', '0', '$vrstni_red', '$pb')"); + + $vrstni_red ++; + } + + } + + function display_new () { + global $lang; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + #$this->survey_type = SurveyAdmin::getSurvey_type($this->anketa); + $this->survey_type = SurveyInfo::getInstance()->getSurveyColumn("survey_type"); + + // Glasovanje + if($this->survey_type == 0){ + + $gl = new Glasovanje($this->anketa); + + //div z nastavitvami za glasovanje + echo '
'; + //$this->display_glasovanje_settings(); + $gl->display_glasovanje_settings(); + echo '
'; + + + echo '
'; + + echo '
'; + + //$this->branching_struktura(); + $gl = new Glasovanje($this->anketa); + $gl->vprasanja(); + + echo '
'; // #branching + + //$this->vprasanje_float_editing(); + echo '
'; + + echo '
'; // #placeholder + + $this->toolbox(); + } + + // Navadna anketa ali forma + else{ + echo '
'; + + echo '
'; + + Common::Init($this->anketa); + echo Common::checkStruktura(); + $this->branching_struktura(); + + echo '
'; // #branching + + $this->vprasanje_float_editing(); + + echo '
'; // #placeholder + + $this->toolbox(); + } + + // forma in glasovanje - hitre nastavitve na desni - ce imamo odprto knjiznico ne prikazemo zaradi prekrivanja + if ( ($this->survey_type == 1 || $this->survey_type == 0) && ($row['toolbox'] < 3) ) { + echo '
survey_type==0 ? ' class="glas_quick_settings"':'').'>'; + echo '
survey_type==0 ? ' class="glas_quick_settings"':'').'>'; + $this->toolbox_settings(); + echo '
'; + echo '
'; + } + + if ($row['popup'] == 0) { // default je true + ?>'; + echo 'alert(document.getElementsByTagName("*").length);'; + echo '';*/ + + } + + + function vprasanje_float_editing () { + + echo '
'; + + } + + /** + * prikaze zgornji toolbox z nastavitvami + * + */ + /*function toolbox_nastavitve () { + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + echo '
=3?' class="library"':'').'>'; + $this->display_toolbox_nastavitve(); + echo '
'; + }*/ + + /** + * prikaze zgornji toolbox z nastavitvami + * + */ + function display_toolbox_nastavitve() { + global $lang; + global $admin_type; + global $site_url; + global $global_user_id; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + # preverimo ali imamo ife. Če so, izpisujemo vse ikonce + $sql_select = "SELECT count(*) AS if_count FROM srv_branching WHERE element_if > 0 AND ank_id = '".$this->anketa."'"; + $sql_query = sisplet_query($sql_select); + $row_query = mysqli_fetch_array($sql_query); + $has_if = (int)$row_query['if_count'] > 0 ? true : false; + + # ali prikazujemo vse ikonice ali samo "simpl" ikonice + $sql_select_fv = "SELECT count(*) AS full_view FROM srv_user_setting_for_survey WHERE sid='".$this->anketa."' AND uid='".$global_user_id."' AND what='display_full_toolbox' AND value='1'"; + $sql_query_fv = sisplet_query($sql_select_fv); + $row_query_fv = mysqli_fetch_array($sql_query_fv); + $full_view = (int)$row_query_fv['full_view'] == 1 ? true : false; + $full_view = true; + + echo '
'; + # skrčen / razširjen + if ($this->expanded) { + echo ''.$lang['srv_expanded_0_short'].' '; + $sqle = sisplet_query("SELECT count(*) AS c FROM srv_branching WHERE ank_id='$this->anketa'"); + $rowe = mysqli_fetch_array($sqle); + if ($rowe['c'] > 15 && !isset($_COOKIE['expanded'])) + echo ''.$lang['srv_expaned_text'].' '.$lang['srv_zapri'].''; + } else { + echo ''.$lang['srv_expanded_0_short'].' '; + } + echo Help::display('srv_branching_expanded'); + + echo '
'; + + + echo '
'; + + # find & replace + if ($row['locked'] == 0) { + echo ''; + } + + if ($row['locked'] == 0 && $full_view == true) { + echo ' '."\n"; + } + + # Hrošč je viden samo če imamo ife in razširjen pogled + if ($row['locked'] == 0 && $full_view == true) { // if ($row['flat'] == 0) + echo ' '."\n"; + } + + if ($row['locked'] == 0 && $full_view == true) { + echo '' . Help :: display('srv_grupe_recount_branching') ."\n"; + } + + if ($has_if == true && $full_view == true || ($has_if == true && $this->expanded == false)) { + echo ''."\n"; + echo ''."\n"; + } + + echo '
'; + + // prikaz blokov kot zavihke + echo '
'; + $sql = sisplet_query("SELECT i.* FROM srv_if i, srv_branching b WHERE i.tab='1' AND i.tip='1' AND i.id=b.element_if AND b.ank_id='$this->anketa' ORDER BY b.parent, b.vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $i = 0; + while ($row = mysqli_fetch_array($sql)) { + if ($i++ != 0) echo ' | '; + $label = ($row['label'] == ''?$lang['srv_blok'].' ('.$row['number'].')':$row['label']); + echo ''.$label.' '; + } + echo '
'; + + echo '
'; + } + + /** + * zamenja full_view = 1/0 za toolbox + * + */ + function toogle_toolbox_nastavitve() { + global $global_user_id; + + # ali prikazujemo vse ikonice ali samo "simpl" ikonice + + $sql_update_fv = "INSERT INTO srv_user_setting_for_survey (sid,uid,what,value) VALUES ('$this->anketa', '$global_user_id', 'display_full_toolbox', '1') ON DUPLICATE KEY UPDATE value = !value"; + $sql_query_fv = sisplet_query($sql_update_fv); + $this->display_toolbox_nastavitve(); + } + + /** + * prikaze izbrani toolbox + * + */ + function toolbox () { + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + if($this->survey_type != 0) + $this->toolbox_basic2(); + + if ($row['toolbox'] >= 3) + $this->toolbox_library(); + + ?>anketa); + } + + /** + * novi toolbox s tipi vprašanj + */ + function toolbox_basic2 () { + global $lang; + global $admin_type; + global $global_user_id; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + $this->survey_type = SurveyInfo::getInstance()->getSurveyColumn("survey_type"); + $hierarhija = SurveyInfo::getInstance()->checkSurveyModule('hierarhija'); + + // Toolbox napredne nastavitve (prestevilci, dodaj prelome, debug...) + if($this->survey_type > 1 && !SurveyInfo::getInstance()->checkSurveyModule('hierarhija') ){ + + echo '
'; + + echo ''; + + $this->toolbox_add_advanced_settings(); + + echo '
'; + } + + + echo '
survey_type==1?' class="forma"':'').($hierarhija ? ' class="toolbox-hierarhija"' : '').'>'; + + if ($row['locked'] == 1) { + + // Ce ima uporabnik prepreceno moznost odklepanja ankete + $d = new Dostop(); + if(($hierarhija && SurveyInfo::getSurveyModules('hierarhija') == 2) || $d->checkDostopSub('lock') && ($admin_type != 0 && $admin_type != 1)){ + echo '
'; + echo ''; + echo '
'; + } + else{ + //echo '

'; + echo '
'; + echo ''; + echo '
'; + } + + if(!$hierarhija) { + echo '

'; + echo '

'; + } + + echo '

'; + echo '

'; + + if(!$hierarhija) + echo '

'; + + echo '

'; + + if(!$hierarhija) { + echo '
'; + $this->toolbox_add_advanced(); + echo '
'; + } + + // normalna anketa + if ($this->survey_type != 1){ + + // Preverimo, ce je funkcionalnost v paketu, ki ga ima uporabnik + $userAccess = UserAccess::getInstance($global_user_id); + + echo '

'; + echo '

'; + } + } + else { + + if(!$hierarhija) { + echo '

'; + echo '

'; + } + + echo '

'; + echo '

'; + + if(!$hierarhija) + echo '

'; + + echo '

'; + + if(!$hierarhija) { + echo '
'; + $this->toolbox_add_advanced(); + echo '
'; + } + + // normalna anketa + if ($this->survey_type != 1){ + + // Preverimo, ce je funkcionalnost v paketu, ki ga ima uporabnik + $userAccess = UserAccess::getInstance($global_user_id); + + echo '

'; + echo '

'; + } + } + + echo '
'; + } + + /** + * prikaze popup z vsemi tipi vprasanj + * + */ + function toolbox_add_advanced() { + global $lang; + global $site_url; + global $admin_type; + global $global_user_id; + + $spr = $_POST['spr']; + $if = $_POST['if']; + $endif = $_POST['endif']; + + // Preverimo, ce je funkcionalnost v paketu, ki ga ima uporabnik + $userAccess = UserAccess::getInstance($global_user_id); + + echo '
'; + + echo '

'.$lang['srv_add_question_type'].' '.Help::display('srv_toolbox_add_advanced').'

'; + echo '

'.$lang['srv_new_question_text'].'

'; + + echo ''; + echo ''; + echo ''; + + echo '
'; + + echo '

'.$lang['srv_sklop_osnovna2'].'

'; + echo '
'; + + echo '

'.$lang['srv_vprasanje_tip_1'].'

'; + echo '

'.$lang['srv_vprasanje_tip_1'].' - '.$lang['srv_dropdown'].'

'; + echo '

'.$lang['srv_vprasanje_tip_2'].'

'; + + echo '
'; + echo '

'.$lang['srv_vprasanje_tables'].'

'; + echo '
'; + + echo '

'.$lang['srv_classic'].'

'; + echo '

'.$lang['srv_diferencial2'].'

'; + echo '

'.$lang['srv_table_dropdown'].'

'; + echo '

'.$lang['srv_double_grid'].'

'; + + echo '
'; + echo '

'.$lang['srv_sklop_posebna'].'

'; + echo '
'; + + echo '

'.$lang['srv_vprasanje_tip_5'].'

'; + + echo '

'.$lang['srv_vprasanje_tip_26'].'

'; + + echo '

'.$lang['srv_vprasanje_heatmap'].'

'; + + echo '

'.$lang['srv_vprasanje_tip_8'].'

'; + echo '

'.$lang['srv_vprasanje_tip_17'].'

'; + echo '

'.$lang['srv_vprasanje_tip_18'].'

'; + + echo '
'; + echo '
'; + + echo '

'.$lang['srv_sklop_osnovna_vnos2'].'

'; + echo '
'; + + echo '

'.$lang['srv_vprasanje_tip_7'].'

'; + echo '

'.$lang['srv_vprasanje_tip_21'].'

'; + echo '

'.$lang['srv_number_insert_1'].'

'; + + echo '
'; + echo '

'.$lang['srv_sklop_tabele_ostale'].'

'; + echo '
'; + + echo '

'.$lang['srv_vprasanje_tip_16'].'

'; + echo '

'.$lang['srv_vprasanje_tip_20'].'

'; + echo '

'.$lang['srv_vprasanje_tip_19'].'

'; + echo '

'.$lang['srv_survey_table_multiple'].'

'; + + echo '
'; + echo '

'.$lang['srv_standardni_vnosi'].'

'; + echo '
'; + + echo '

'.$lang['email'].'

'; + echo '

'.$lang['url'].'

'; + echo '

'.$lang['srv_tip_standard_993'].'

'; + echo '

'.$lang['srv_vprasanje_tip_long_21_7'].'

'; + echo '

'.$lang['srv_captcha_edit'].'

'; + echo '

'.$lang['srv_gdpr'].'

'; + + echo '
'; + + echo '
'; + + if (($lang['id'] == '1' || $lang['id'] == '2') && ($site_url == 'https://www.1ka.si/' || strpos($site_url, 'localhost') !== false ) ) { + + echo '

'.$lang['srv_demografija'].'

'; + echo '
'; + + if ($lang['id'] == '1') { + echo '

'.$lang['srv_demografija_spol'].'

'; + echo '

'.$lang['srv_demografija_starost'].'

'; + echo '

'.$lang['srv_demografija_zakonski_stan'].'

'; + echo '

'.$lang['srv_demografija_status'].'

'; + echo '

'.$lang['srv_demografija_izobrazba'].'

'; + echo '

'.$lang['srv_demografija_lokacija'].'

'; + } + + if ($lang['id'] == '2') { + echo '

'.$lang['srv_demografija_spol'].'

'; + echo '

'.$lang['srv_demografija_starost'].'

'; + echo '

'.$lang['srv_demografija_zakonski_stan'].'

'; + echo '

'.$lang['srv_demografija_status'].'

'; + echo '

'.$lang['srv_demografija_izobrazba'].'

'; + echo '

'.$lang['srv_demografija_lokacija'].'

'; + } + } + + echo '

'; + echo '

'; + + echo '
'; + echo '

'.$lang['srv_advanced_features'].'

'; + echo '
'; + + // Kalkulacija + echo '

'.$lang['srv_vprasanje_tip_22'].'

'; + + // Kvota + echo '

'.$lang['srv_vprasanje_tip_25'].'

'; + + // Loop + echo '

'.$lang['srv_zanka'].'

'; + + // Signature + echo '

'.$lang['srv_signature_edit'].'

'; + + // Chat (nagovor z gumbom za vklop chata) - ce je vklopljen modul chat + if (SurveyInfo::getInstance()->checkSurveyModule('chat')){ + echo '

'.$lang['srv_vprasanje_tip_5_2'].'

'; + } + + // Socialna omrezja + if (SurveyInfo::getInstance()->checkSurveyModule('social_network')){ + echo '

'.$lang['srv_vprasanje_tip_9'].'

'; + } + elseif(!$userAccess->checkUserAccess($what='question_type_signature')){ + echo '

'.$lang['srv_vprasanje_tip_9'].'

'; + } + else{ + echo '

checkUserAccess($what='question_type_signature') ? 'class="user_access_locked"' : '').'"> '.$lang['srv_vprasanje_tip_9'].'

'; + } + + echo '
'; + + //echo ''.$lang['srv_zapri'].''; + + echo '
'; + } + + /** + * prikaze popup z vsemi tipi vprasanj + * + */ + function toolbox_add_advanced_settings() { + global $lang; + global $admin_type; + global $site_url; + global $global_user_id; + + echo '
'; + + echo ''.$lang['srv_advanced_settings_title'].''; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + # preverimo ali imamo ife. Če so, izpisujemo vse ikonce + $sql_select = "SELECT count(*) AS if_count FROM srv_branching WHERE element_if > 0 AND ank_id = '".$this->anketa."'"; + $sql_query = sisplet_query($sql_select); + $row_query = mysqli_fetch_array($sql_query); + $has_if = (int)$row_query['if_count'] > 0 ? true : false; + + # ali prikazujemo vse ikonice ali samo "simpl" ikonice + $sql_select_fv = "SELECT count(*) AS full_view FROM srv_user_setting_for_survey WHERE sid='".$this->anketa."' AND uid='".$global_user_id."' AND what='display_full_toolbox' AND value='1'"; + $sql_query_fv = sisplet_query($sql_select_fv); + $row_query_fv = mysqli_fetch_array($sql_query_fv); + $full_view = (int)$row_query_fv['full_view'] == 1 ? true : false; + $full_view = true; + + // Razsiri / skrci + if($this->survey_type > 1){ + if($this->expanded) { + echo '

'; + echo ''; + echo ''; + echo $lang['srv_expand_0']; + echo ''; + echo '

'; + } + else { + echo '

'; + echo ''; + echo ''; + echo $lang['srv_expand_1']; + echo ''; + echo '

'; + } + } + + if ($has_if == true/* && $full_view == true || ($has_if == true && $this->expanded == false)*/) { + echo '

'; + echo ''.$lang['srv_expand'].''."\n"; + echo ''.$lang['srv_collapse'].''."\n"; + echo '

'; + } + + # find & replace + if ($row['locked'] == 0) { + echo '

'; + echo ''.$lang['srv_find_replace_words'].''; + echo '

'; + } + + if ($row['locked'] == 0 && $full_view == true) { + echo '

'; + echo ''.$lang['srv_pagebreak_all'].' '."\n"; + echo '

'; + } + + # Hrošč je viden samo če imamo ife in razširjen pogled + if ($row['locked'] == 0 && $full_view == true) { // if ($row['flat'] == 0) + echo '

'; + echo ''.$lang['srv_check_pogoji'].' '."\n"; + echo '

'; + } + + if ($row['locked'] == 0 && $full_view == true) { + echo '

'; + echo ''.$lang['srv_grupe_recount_branching'].'' . Help :: display('srv_grupe_recount_branching') ."\n"; + echo '

'; + } + + // Knjiznica na desni + if ($row['locked'] == 0) { + if($row['toolbox'] >= 3){ + echo '

'; + echo ''.$lang['srv_library_hide'].''; + echo '

'; + } + else{ + echo '

'; + echo ''.$lang['srv_library_show'].''; + echo '

'; + } + } + + echo '
'; + + // prikaz blokov kot zavihke + /*echo '
'; + $sql = sisplet_query("SELECT i.* FROM srv_if i, srv_branching b WHERE i.tab='1' AND i.tip='1' AND i.id=b.element_if AND b.ank_id='$this->anketa' ORDER BY b.parent, b.vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $i = 0; + while ($row = mysqli_fetch_array($sql)) { + if ($i++ != 0) echo ' | '; + $label = ($row['label'] == ''?$lang['srv_blok'].' ('.$row['number'].')':$row['label']); + echo '

'; + echo ''.$label.' '; + echo '

'; + } + echo '
';*/ + } + + /** + * prikaz knjiznice v toolboxu na levi strani + * + */ + function toolbox_library () { + global $lang; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + //glede na to kje smo se nahajali se vrnemo (na osnovne oz napredne moznosti) + //$row['toolbox'] == 3 ? $preklop = 1 : $preklop = 2; + + echo '
'; + + //echo '

'.$lang['srv_nazajnavprasanja'].'

'; + + + //zgornja navigacija toolboxa + /*echo ''; + echo ''; + //echo ''; + echo ''; + echo '
'.$lang['srv_novaspremenljivka'].''.$lang['srv_advanced'].''.$lang['srv_library'].'
';*/ + + if ($row['locked'] == 1) { + + //echo '

'.$lang['srv_anketa_locked_1'].'

'; + echo '

'; + echo ' '.$lang['srv_anketa_locked_1']; + echo '

'; + + } else { + + echo '
'; + $l = new Library(); + $l->display(); + echo '
'; + } + + echo '
'; + } + + /** + * hitre nastavitve - na dnu pri formi + * + */ + function toolbox_settings ($status1='none', $status2='none') { + global $lang; + global $admin_type; + + $row = Cache::srv_spremenljivka($row2['spr_id']); + $rowA = SurveyInfo::getInstance()->getSurveyRow(); + + SurveySetting::getInstance()->Init($this->anketa); + $alertDiv = SurveySetting::getInstance()->getSurveyMiscSetting('srvtoolbox_form_alert'); + $emailDiv = SurveySetting::getInstance()->getSurveyMiscSetting('srvtoolbox_form_email'); + + + //OBVESCANJE + $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '$this->anketa'"); + if (!$sqlAlert) + echo mysqli_error($GLOBALS['connect_db']); + $rowAlert = mysqli_fetch_array($sqlAlert); + + $rowAlert['finish_other'] == 1 || ($rowAlert['finish_other_emails'] && $rowAlert['finish_other'] != 0) ? $checked = true : $checked = false; + + echo '

'; + $alertDiv == 1 ? $obvescanje = 0 : $obvescanje = 1; + echo ''; + + $img = ($status1 == 'none') ? ' class="faicon icon-blue plus"' : ' class="faicon icon-blue minus"'; + echo ' '; + + echo '' . $lang['srv_alert_link_form'] . ''; + echo '

'; + + //echo '
'; + $sas = new SurveyAdminSettings(); + + echo '
'; + + // avtor ankete oz osebe z dostopom + echo '

'; + echo ''; + $sas->display_alert_label('finish_author',($rowAlert['finish_author'] == 1), true); + echo '

'; + + // posebej navedeni maili + echo '

'; + + echo '

'; + echo ''; + echo ''; + echo '

'; + + //respondent iz cms + /*echo '

'; + echo ''; + $sas->display_alert_label('finish_respondent_cms',($rowAlert['finish_respondent_cms'] == 1), true); + echo '

';*/ + + //respondent + echo '

'; + echo ''; + echo ''; + $sas->display_alert_label('finish_respondent',($rowAlert['finish_respondent'] == 1), true); + echo '

'; + + echo ''.$lang['srv_detail_settings'].''; + echo '
'; + + echo '
'; + } + + /** + * izrise linke za dodajanje demografskih vprasanj pri novi prazni anketi + * + */ + function demografija () { + global $lang; + + echo '
'; + echo '
'; + + echo '

'.$lang['srv_head_demografska_vprasanja'].'

'; + + echo '
'; + + if ($lang['id'] == '1') { + echo '

check_demografija_exists('XSPOL')?'checked':'').' value="XSPOL" id="XSPOL">

'; + echo '

check_demografija_exists('XSTAR2a4')?'checked':'').' value="XSTAR2a4" id="XSTAR2a4">

'; + echo '

check_demografija_exists('XZST1surs4')?'checked':'').' value="XZST1surs4" id="XZST1surs4">

'; + + echo '
'; + + echo '

check_demografija_exists('XDS2a4')?'checked':'').' value="XDS2a4" id="XDS2a4">

'; + echo '

check_demografija_exists('XIZ1a2')?'checked':'').' value="XIZ1a2" id="XIZ1a2">

'; + echo '

check_demografija_exists('XLOKACREGk')?'checked':'').' value="XLOKACREGk" id="XLOKACREGk">

'; + //echo '

'; + } + + if ($lang['id'] == '2') { + echo '

check_demografija_exists('XSEX')?'checked':'').' value="XSEX" id="XSEX">

'; + echo '

check_demografija_exists('XAGE')?'checked':'').' value="XAGE" id="XAGE">

'; + echo '

check_demografija_exists('XMRSTS')?'checked':'').' value="XMRSTS" id="XMRSTS">

'; + + echo '
'; + + echo '

check_demografija_exists('XSTS')?'checked':'').' value="XSTS" id="XSTS">

'; + echo '

check_demografija_exists('XEDU')?'checked':'').' value="XEDU" id="XEDU">

'; + echo '

check_demografija_exists('XLOC')?'checked':'').' value="XLOC" id="XLOC">

'; //echo '

'; + } + + echo '
'; + echo '
'; + + echo '
'; + + } + + /** + * Vrne ID bloka z demografijo + * + */ + function get_demografija_id () { + global $lang; + + $sql = sisplet_query("SELECT i.* FROM srv_branching b, srv_if i WHERE b.ank_id = '$this->anketa' AND b.parent='0' AND i.id=b.element_if AND i.tip='1'"); + if (mysqli_num_rows($sql) == 1) { + $row = mysqli_fetch_array($sql); + if ($row['label'] == $lang['srv_demografija']) { + return $row['id']; + } + } + + return 0; + + } + + /** + * preveri, ce so v bloku z demografijo samo demografska vprasanja + * + */ + function check_only_demografija($id) { + + $sql = sisplet_query("SELECT element_spr FROM srv_branching WHERE parent = '$id'"); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_spr'] > 0) { + + $sql1 = sisplet_query("SELECT sistem FROM srv_spremenljivka WHERE id = '$row[element_spr]'"); + $row1 = mysqli_fetch_array($sql1); + if ( ! $row1['sistem']==1 ) // bomo rekl, da kr ce ni sistemska + return false; + + } else { + return false; + } + + } + + return true; + + } + + /** + * preveri, ce je izbrana variabla ze dodana kot demografija + * + * @param mixed $variable + */ + function check_demografija_exists($variable) { + + $if_id = $this->get_demografija_id(); + + $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_branching b, srv_spremenljivka s WHERE b.ank_id='$this->anketa' AND b.element_spr=s.id AND b.parent='$if_id' AND s.variable='$variable'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + if ($row['count'] > 0) + return true; + + return false; + } + + + /** + * nova branching struktura + * + */ + function branching_struktura () { + global $lang; + + // naenkrat preberemo vse spremenljivke, da ne delamo queryja vsakic posebej + Cache::cache_all_srv_spremenljivka($this->anketa, true); + // enako za srv_branching + Cache::cache_all_srv_branching($this->anketa, true); + // cachiramo tudi srv_if + Cache::cache_all_srv_if($this->anketa); + // cache vseh spremenljivk + //$this->find_all_spremenljivka(); + + #$this->survey_type = SurveyAdmin::getSurvey_type($this->anketa); + $this->survey_type = SurveyInfo::getInstance()->getSurveyColumn("survey_type"); + + //$this->toolbox_nastavitve(); + + + // prikaz blokov kot zavihke + $sqlB = sisplet_query("SELECT i.* FROM srv_if i, srv_branching b WHERE i.tab='1' AND i.tip='1' AND i.id=b.element_if AND b.ank_id='$this->anketa' ORDER BY b.parent, b.vrstni_red"); + if (!$sqlB) echo mysqli_error($GLOBALS['connect_db']); + + if(mysqli_num_rows($sqlB) > 0){ + + echo '
'; + + // Zavihek VSI + echo '

'; + echo ''.$lang['srv_vsi'].' '; + echo '

'; + + // Ostali zavihki + while ($rowB = mysqli_fetch_array($sqlB)) { + echo ' | '; + $label = ($rowB['label'] == '' ? $lang['srv_blok'].' ('.$rowB['number'].')' : $rowB['label']); + echo '

'; + echo ''.$label.' '; + echo '

'; + } + + echo '
'; + } + + + echo ''; + + + // Pri formi na dnu izpisemo dodaten text + $this->showVprasalnikBottom(); + + + if (isset($_GET['spr_id']) && $_GET['spr_id'] > 0) { + ?> + + + + 0) + $this->display_spremenljivka($element_spr); + else + $this->display_if($element_if); + } + + function display_spremenljivka ($spremenljivka) { + global $lang; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + #$this->survey_type = SurveyAdmin::getSurvey_type($this->anketa); + $this->survey_type = SurveyInfo::getInstance()->getSurveyColumn("survey_type"); + + if ($row['flat'] == 0) + $zamik = ( $this->level($spremenljivka,0) > 0 ? ' style="padding-left:'.(10+$this->level($spremenljivka,0)*20).'px"' : '' ); + else + $zamik = ''; + + $row = Cache::srv_spremenljivka($spremenljivka); + $row1 = Cache::srv_branching($spremenljivka, 0); + + echo '
  • '; + if ($this->expanded) { + $this->vprasanje($spremenljivka); + } else { + $this->spremenljivka_name($row['id'], $row['naslov'], $row['variable'], $row['visible'], $row['sistem']); + } + echo '
  • '; + + //echo '
  • '; + + if ($this->pagebreak($spremenljivka)) { + $gr = $this->getGrupa4Spremenljivka($this->find_next_spr($spremenljivka)); + if ($gr['id'] > 0) { + echo '
  • '; + echo ''; + echo '
  • '; + + // ++ zadnji pagebreak prikazan izven ifa // + // ce je spremenljivka zadnja v IFu, ne prikazemo PB, ker ga bomo za ENDIFom + $rows = Cache::srv_branching($spremenljivka, 0); + if ( $this->find_last_in_if($rows['parent']) != $spremenljivka ) { + echo '
  • '; + //echo ''.$gr['naslov'].''; + echo ''.$lang['srv_stran'].' '.$gr['vrstni_red'].''; + echo '
  • '; + echo '
  • '; + echo ''; + echo '
  • '; + } + // -- zadnji pagebreak prikazan izven ifa // + } elseif($this->survey_type != 1) { + echo '
  • '; + echo ''; + echo '
  • '; + + /*echo '
  • '; + echo ''.$lang['srv_end_label'].''; + echo '
  • '; + + echo '
  • '; + echo ''; + echo '
  • ';*/ + } + + } elseif ($spremenljivka == $this->find_last_spr() && $this->survey_type != 1) { // zadnja spremenljivka - zakljucek + echo '
  • '; + echo ''; + echo '
  • '; + + /*echo '
  • '; + echo ''.$lang['srv_end_label'].''; + echo '
  • '; + + echo '
  • '; + echo ''; + echo '
  • ';*/ + + } elseif ($this->survey_type != 1) { //pri formi ne dovolimo dodajanja page-breakov + + // tuki pustimo, da se PB lahko dodaja za spremenljivko in za ifom (pol se prikaze za ifom) + // -- v zadnji spremenljivki za ifom ne prikazemo dodajanja + $rows = Cache::srv_branching($spremenljivka, 0); + if ( $this->find_last_in_if($rows['parent']) != $spremenljivka ) { + echo '
  • '; + echo ''; + echo '
  • '; + } else { // zadnji spremenljivki v ifu izpisemo PB izven ifa (da je bolj pregledno in lepse) + echo '
  • '; + echo ''; + echo '
  • '; + } + } elseif ($this->survey_type == 1) { // forma + echo '
  • '; + echo '
  • '; + } + + //echo ''; + + } + + function display_if_label($if) { + global $lang; + + $rowb = Cache::srv_if($if); + + echo '
    '; + echo ''; + + if ($rowb['tip'] == 0) { + $this->conditions_display($if); + } elseif ($rowb['tip'] == 1) { + echo 'BLOCK ('.$rowb['number'].')'.($rowb['enabled']==2?' FALSE ':'').($rowb['label']!=''?' ( '.$rowb['label'].' )':'').''; + } elseif ($rowb['tip'] == 2) { + $this->loop_display($if); + } + + echo ''; + echo '
    '; + + } + + function display_if ($if) { + global $lang; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + $rowb = Cache::srv_if($if); + + if ($row['flat'] == 0) + $zamik = ( $this->level(0,$if) > 0 ? ' style="padding-left:'.(10+$this->level(0,$if)*20).'px"' : '' ); + else + $zamik = ''; + + + echo '
  • '; + + // plusminus + if ($row['flat'] == 0) + echo ''; + + $this->display_if_label($if); + + echo '
  • '; + + + echo ''; + + + $row1 = Cache::srv_branching(0, $if); + + // ++ zadnji pagebreak prikazan izven ifa // + $spr = $this->find_last_in_if($if); + if($spr > 0) + $rows = Cache::srv_branching($spr, 0); + + $rowi = cache::srv_branching(0, $if); + + // preverimo, da ni na zadnjem mestu ifa se en if (ker potem se 2x izpise PB) + $sqle = sisplet_query("SELECT ank_id, parent, element_spr, element_if FROM srv_branching WHERE parent='{$rowi['parent']}' AND vrstni_red>'{$rowi['vrstni_red']}' AND ank_id='$this->anketa'"); + + + if ($rows['pagebreak'] == 1 AND (mysqli_num_rows($sqle)>0 || $rowi['parent']==0) ) { + + $gr = $this->getGrupa4Spremenljivka($this->find_next_spr($spr)); + + if ($gr['id'] > 0) { + + echo '
  • '; + echo ''; + echo '
  • '; + echo '
  • '; + echo ''.$lang['srv_stran'].' '.$gr['vrstni_red'].''; + echo '
  • '; + } + + } + + // zadnji spremenljivki v ifu, tudi dodamo PB izven pagebreaka (da se doda, tam kjer se potem prikaže) + if ($rows['pagebreak'] == 0 AND (mysqli_num_rows($sqle)>0 || $rowi['parent']==0) ) { + echo '
  • '; + echo ''; + echo '
  • '; + } else { + echo '
  • '; + echo '
  • '; + } + + // -- zadnji pagebreak prikazan izven ifa // + } + + function display_if_content ($if) { + global $lang; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $rowb = Cache::srv_if($if); + + if ($row['flat'] == 0) { + $zamik = ($this->level(0, $if) > 0 ? ' style="padding-left:' . (10 + $this->level(0, $if) * 20) . 'px"' : ''); + $zaklepaj = ($this->level(0, $if) > 0 ? 'margin-left:-' . (10 + $this->level(0, $if) * 20) . 'px;width:' . (15 + $this->level(0, $if) * 20) . 'px;' : ''); + } + else { + $zamik = ''; + $zaklepaj = ''; + } + + echo '
  • '; + echo '
  • '; + + foreach (Cache::srv_branching_parent($this->anketa, $if) AS $k => $row1) { + $this->display_element($row1['element_spr'], $row1['element_if']); + } + + echo '
  • '; + echo ''.($rowb['tip']==0?'ENDIF':($rowb['tip']==1?'ENDBLOCK':'ENDLOOP')).' ('.$rowb['number'].')'."\n\r"; + + // Dodajanje komentarjev na if/blok + if ($this->displayKomentarji !== false) { + $this->if_komentarji($if, $rowb['tip']); + } + + echo '
  • '; + } + + /** + * prikaze spremenljivko pri skrcenem nacinu + * + * @param mixed $spremenljivka + * @param mixed $naslov + * @param mixed $variable + * @param mixed $visible + * @param mixed $sistem + */ + function spremenljivka_name ($spremenljivka, $naslov=null, $variable=null, $visible=1, $sistem=0) { + global $lang; + + $row = Cache::srv_spremenljivka($spremenljivka); + + $tip = $row['tip']; + $naslov = $row['naslov']; + $variable = $row['variable']; + $visible = $row['visible']; + $sistem = $row['sistem']; + $dostop = $row['dostop']; + + // Barva vprašanja je privzeto modra, če pa je sistemsko ali skrito pa je rdeča + $spanred = ($visible == 0 || $sistem == 1 || $dostop != 4 ) ? ' ' : ''; + + // Kvota + if($tip == 25){ + $SQ = new SurveyQuotas($this->anketa); + echo '('.$variable.') '.$SQ->quota_display(-$spremenljivka).' ( '.$lang['srv_vprasanje_tip_long_'.$row['tip']].' )'; + } + // Kalkulacija + else if($tip == 22){ + echo '('.$variable.') '.$this->calculations_display(-$spremenljivka).' ( '.$lang['srv_vprasanje_tip_long_'.$row['tip']].' )'; + } + // Navadne spremenljivke + else{ + echo '('.$variable.') '.$spanred.skrajsaj(strip_tags($naslov), 80).($spanred!=''?'':'').' ( '.$lang['srv_vprasanje_tip_long_'.$row['tip']].' )'; + } + } + + private $Survey = null; + + /** + * @desc prikaze vprasanje pri razsirjenem nacinu + * dodal nov argument, zaradi pravilnega prikazovanja prevoda sliderjev + */ + function vprasanje($spremenljivka, $prevajanje = false) { + global $lang; + global $lang1; + global $site_path; + global $admin_type; + global $global_user_id; + global $site_url; + + $row = Cache::srv_spremenljivka($spremenljivka); + + $this->prevajanje = $prevajanje; + + if ( $this->lang_id != null ) { + include_once('../../main/survey/app/global_function.php'); + if (empty($this->Survey->get)) + $this->Survey = new \App\Controllers\SurveyController(true); + + save('lang_id', $this->lang_id); + + $rowl = \App\Controllers\LanguageController::srv_language_spremenljivka($spremenljivka); + if (strip_tags($rowl['naslov']) != '') $row['naslov'] = $rowl['naslov']; + if (strip_tags($rowl['info']) != '') $row['info'] = $rowl['info']; + if ($rowl['vsota'] != '') $row['vsota'] = $rowl['vsota']; + } + + $this->survey_type = SurveyInfo::getInstance()->getSurveyColumn("survey_type"); + + // Ce je vprasanje ali anketa zaklenjena (vprasanje ni nikoli zaklenjeno za admine, managerje in avtorja ankete) + $author = SurveyInfo::getInstance()->getSurveyColumn("insert_uid"); + $question_locked = ($row['locked'] == 1 && $admin_type != 0 && $admin_type != 1 && $global_user_id != $author) ? true : false; + $locked = ($this->locked || $question_locked) ? true : false; + + // v atribut + echo '
    '; + + // nalozimo parametre spremenljivke + $spremenljivkaParams = new enkaParameters($row['params']); + + // Ce prikazujemo urejanje variable + $show_variable_inline = $spremenljivkaParams->get('grid_var') == '1' ? ' style="display:block;"' : ' style="display:none;"'; + $show_variable_row = $spremenljivkaParams->get('grid_var') == '1' ? ' style="display:auto;"' : ' style="display:none;"'; + + if ($this->branching == 0 ) + $movable = ' movable'; + else + $movable = ''; + + // <-- Zgornja vrstica pri editiranju vprasanj --- + echo '
    '; + echo '
    ' . $row['variable'] . ($row['label']!=''?' - '.$row['label'].'':'') .'
    '; + + + echo '
    '; + $string = ''; + // statusi: reminder, timer, in še kaj + if ($row['sistem'] == 1) + $string = $string . $lang['srv_system_text'] . ' | '; + + if ($row['visible'] == 0) + $string .= $lang['srv_hidden_text'] . ' | '; + + if ($row['dostop'] != 4) { + $string = $string . $lang['srv_visible_dostop'].' '; + switch ($row['dostop']) { + case 3: $string .= strtolower($lang['see_registered']); + break; + case 2: $string .= strtolower($lang['see_member']); + break; + case 1: $string .= strtolower($lang['see_manager']); + break; + case 0; $string .= strtolower($lang['see_admin']); + break; + } + $string .= ' | '; + } + + if ($row['reminder'] > 0) { + if ($row['reminder'] == 1) { + // echo ''.$lang['srv_reminder_soft'].''; + $string = $string . $lang['srv_reminder_soft']; + } else { + // echo ''.$lang['srv_reminder_hard'].''; + $string = $string . $lang['srv_reminder_hard']; + } + $string = $string . ' | '; + } + + $sqlv = sisplet_query("SELECT spr_id, if_id FROM srv_validation WHERE spr_id = '$spremenljivka'"); + if (mysqli_num_rows($sqlv) > 0) { + $string = $string . $lang['srv_validation']; + $string = $string . ' | '; + } + + if ($row['timer'] > 0) { + $string = $string . $lang['srv_timer_on_time']; + $string = $string . (substr(bcdiv($row['timer'], 60), 0, 4)) . '' . $lang['srv_minutes'] . ' '; + $string = $string . (bcmod($row['timer'], 60)) . '' . $lang['srv_seconds'] . ''; + $string = $string . ' | '; + } + //izrišemo še ostale statuse: statistika, orientacija, sortiranje + if ($row['tip'] <= 3 && $row['stat'] && $this->survey_type != 0) { + $string = $string . $lang['srv_stat_on'] . ' | '; + } + + + // Status orentacije - navadna vprasanja + if((in_array($row['tip'], array('1', '2', '21', '7', '8')) && $row['orientation'] != '1') || ($row['tip'] == '3' && $row['orientation'] == '1')){ + $string .= $this->getVprasanjeOrientationString($row['tip'], $row['orientation']) . ' | '; + } + // Status orentacije - tabele + elseif(in_array($row['tip'], array('6', '16')) && $row['enota'] != '0'){ + $string .= $this->getVprasanjeOrientationString($row['tip'], $row['enota']) . ' | '; + } + + + if ($row['tip'] == 1 && $row['hidden_default'] == 1) { + $string = $string . $lang['srv_potrditev'] . ' | '; + } + + if ($row['random']) { + $arrayRandomText = array ( + 0 => $lang['srv_random_off'], + 1 => $lang['srv_random_on'], + 2 => $lang['srv_sort_asc'], + 3 => $lang['srv_sort_desc'] + ); + + $string = $string . $arrayRandomText[$row['random']] . ' | '; + } + //skriti checkboxi + if ($row['checkboxhide'] != 0) + $string = $string . $lang['srv_checkboxhide_disabled'] . ' | '; + + // Kljucavnica ce je vprasanje zaklenjeno + if($question_locked){ + echo '
    '; + } + // Ce je zaklenjeno ampak ga lahko ureja ker je admin ali avtor + elseif($row['locked']){ + $string = $string . $lang['srv_locked_text'] . ' | '; + } + + // Ce je onemogoceno vprasanje + $disabled_vprasanje = $spremenljivkaParams->get('disabled_vprasanje') ? $spremenljivkaParams->get('disabled_vprasanje') : 0; + if($disabled_vprasanje){ + $string = $string . $lang['srv_disabled_text'] . ' | '; + } + + //zbrisemo zadnji "|" iz niza + $string = substr($string, 0, -7); + $string = '' . $string . ''; + echo $string; + + echo '
    '; + + echo '
    '; // - spremenljivka_settings + // --- Zgornja vrstica pri editiranju vprasanj --> + + // pri multigridu ne pustimo spremembe orientacije + if ( ($row['orientation'] == 0 || $row['orientation'] == 2) && $row['tip'] != '6') { + $cssFloat = ' floatLeft'; + $divClear = ''; + if ($row['orientation'] == 2) { + # pri vodoravni orientaciji z prelomom vrstice + $line_break = "
    "; + } + } else { + $cssFloat = ''; + $divClear = '
    '; + } + + // kalkulacija + if ($row['tip'] == 22) { + $row['naslov'] = ''.$this->calculations_display(-$spremenljivka).' ( '.$lang['srv_vprasanje_tip_long_'.$row['tip']].' )'; + } + // Kvota + else if($row['tip'] == 25){ + $SQ = new SurveyQuotas($this->anketa); + $row['naslov'] = ''.$SQ->quota_display(-$spremenljivka).' ( '.$lang['srv_vprasanje_tip_long_'.$row['tip']].' )'; + } + + // Inline ifi so disablani ce nimamo ustreznega paketa + $userAccess = UserAccess::getInstance($global_user_id); + + echo '
    '; + + if ( in_array($row['tip'], array(1,2,6,16,19,20)) ) { + if ($row['enota'] != 10 && $row['orientation'] != 10){ + echo ''; + + MobileSurveyAdmin::displayAddQuestionCategory($this->anketa, $spremenljivka, $row['tip']); + } + } + + // kalkulacija + if ($row['tip'] == 22) { + echo '
    '; + echo $row['naslov']; + echo '
    '; + } + // Kvota + elseif($row['tip'] == 25){ + echo '
    '; + echo $row['naslov']; + echo '
    '; + } + // GDPR vprasanje in prevajanje - prevedemo v anglescino + elseif($prevajanje && $row['variable'] == 'gdpr'){ + + // nastavimo na jezik za respondentov vmesnik + $language_id_bck = $lang['id']; + $file = ($this->lang_id == '1') ? '../../lang/1.php' : '../../lang/2.php'; + @include($file); + + $gdpr_naslov = GDPR::getSurveyIntro($this->anketa); + + echo '
    lang_id!=null ? ' default="1"':'').'>'; + echo $gdpr_naslov; + echo '
    '; + + // nastavimo nazaj na admin jezik + $file = '../../lang/'.$language_id_bck.'.php'; + @include($file); + } + else{ + echo '
    lang_id!=null ? ' default="1"':'').'>'; + echo $row['naslov']; + echo '
    '; + } + + if ($row['info'] != '') + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row['info'] . '
    '; + + echo ''; + + if ($_POST['info'] == $lang['note']) { //ce v opombi je default besedilo ("Opomba") + ?> + $("#spremenljivka_content_'.$spremenljivka.' div.spremenljivka_info.info_inline").html("'.$lang['srv_info_selectbox'].'"); + + '; + } + else{ + echo' + + '; + } + ?> + $("#spremenljivka_content_'.$spremenljivka.' div.spremenljivka_info.info_inline").html("'.$lang['srv_info_checkbox'].'"); + + '; + } + else{ + echo' + + '; + } + ?> + $("#spremenljivka_content_'.$spremenljivka.' div.spremenljivka_info.info_inline").html("'.$lang['srv_info_selectbox'].'"); + + '; + } + else{ + echo' + + '; + } + ?> + $("#spremenljivka_content_'.$spremenljivka.' div.spremenljivka_info.info_inline").html("'.$lang['srv_info_checkbox'].'"); + + '; + } + else{ + echo' + + '; + } + ?>lang_id==null?'allow_new':'').'">'; + + // radio, checkbox, select + if ($row['tip'] <= 3) { + + if ($row['tip'] == 3 || $row['orientation'] == 6) + echo '
    '; + + $orderby = "ORDER BY vrstni_red" ; + + $sql1 = sisplet_query("SELECT id, naslov, variable, other, if_id, hidden FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red>0 $orderby"); + + + $spremenljivkaParams = new enkaParameters($row['params']); + $stolpci = ($spremenljivkaParams->get('stolpci') ? $spremenljivkaParams->get('stolpci') : 1); + + //if($row['tip'] == 1 && $row['orientation'] == 6){ + if(($row['tip'] == 1 && $row['orientation'] == 6) || ($row['tip'] == 2 && $row['orientation'] == 6)){ + ?> + + + + + + 0 ORDER BY vrstni_red"); + + //izracun visine + $num = mysqli_num_rows($sql1); + $size = $num * 50; + + //zaslon razdelimo na dva dela - izris leve strani + echo '
    '; + + while ($row1 = mysqli_fetch_array($sql1)) { + + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + //preverimo dolzino niza -> max == 20 + $length = strlen($row1['naslov']); + ?> + + get('quickImage') ? $spremenljivkaParams->get('quickImage') : 0); + if($quickImage == -1){ //onesposobil za enkrat + + if ($length > 30) $class = 'ranking_long'; $class = 'ranking'; + //echo '
    '; + echo '
    '; + // Ikona za upload slike + echo ' '; + + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + //koda za notranji IF + if ($row1['if_id'] > 0) { + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + } + else{ + if ($length > 30) $class = 'ranking_long'; $class = 'ranking'; + //echo '
    '; + echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + //koda za notranji IF + if ($row1['if_id'] > 0) { + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + } + + + //******************// Slika kot odgovor - konec + + + echo '
    '; + + } + echo '
    '; + + // izris desne strani + echo '
    '; + + echo '
    '; + + echo '
    '; + + echo '
    '; + + } + + //Image hot spot @ radio ******************************************************************************************************** + if( ($row['tip'] == 1) && $row['orientation'] == 10){ //image hot spot + $this->vprasanje_hotspot($row['id'], $row['tip'], $row['orientation']); + } + + //Image hot spot @ checkbox ******************************************************************************************************** + if( ($row['tip'] == 2) && $row['orientation'] == 10){ //image hot spot + $this->vprasanje_hotspot($row['id'], $row['tip'], $row['orientation']); + } + + + $stolpec = 1; + $i = 0; + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + + // Prevajanje in gdpr + if($prevajanje && $row['variable'] == 'gdpr'){ + + $gdpr_answer = ''; + + if($row1['variable'] == '2') + $gdpr_answer = 'yes'; + + if($row1['variable'] == '1') + $gdpr_answer = 'no'; + + // Prevedemo gdpr odgovore + if($gdpr_answer != ''){ + $row1['naslov'] = $lang['srv_gdpr_intro_'.$gdpr_answer]; + } + } + } + + // Ce je variabla ne vem in imamo vklopljen prikaz ob opozorilu -> rdec + $missing_warning = ''; + if(($row1['other'] == '-97' && $row['alert_show_97'] > 0) + || ($row1['other'] == '-98' && $row['alert_show_98'] > 0) + || ($row1['other'] == '-99' && $row['alert_show_99'] > 0)){ + $missing_warning = ' red'; + } + + if ($row['tip'] == 1 && $row['orientation'] != 8 && $row['orientation'] != 10) { + //echo '
    '; + if($row['orientation'] == 6){ + echo '
    '.$row1['variable'].'
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + elseif($row['orientation'] == 7){ + //echo '
    '.$row1['variable'].'
    ' . $row1['naslov'] . '
    '; + echo '
    '.$row1['variable'].'
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + if ($row1['if_id'] > 0) { + + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + echo ' '; + echo ' '; + if($row['tip'] == 1) + echo ' '; + echo ' '; + echo ' '; + + + echo ''; + echo ''; + echo'
    '; + } + elseif($row['orientation'] == 9){ + echo '
    + +
    '; + + } + elseif( $row['orientation'] == 11){ + + $stVsehEnot = mysqli_num_rows($sql1); + // + echo '
    + +
    '; + } + else{ + // Slika kot odgovor + $quickImage = ($spremenljivkaParams->get('quickImage') ? $spremenljivkaParams->get('quickImage') : 0); + if($quickImage == 1 && $row['orientation'] == 1){ + echo '
    '; + echo ' '; + echo '
    '.$row1['variable'].'
    '; + + // Ikona za upload slike + echo ' '; + + // Slika oz. text (brez moznosti editiranja) - samo če je vnesen kaksen text ali slika + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + else{ + echo '
    '; + echo ' '; + echo '
    '.$row1['variable'].'
    '; + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + } + } + elseif ($row['tip'] == 2 && $row['orientation'] != 10) { + if($row['orientation'] == 6){ + echo '
    '.$row1['variable'].'
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + elseif($row['orientation'] == 7){ + //echo '
    '.$row1['variable'].'
    ' . $row1['naslov'] . '
    '; + echo '
    '.$row1['variable'].'
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + if ($row1['if_id'] > 0) { + + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + echo ' '; + echo ' '; + if($row['tip'] == 1) + echo ' '; + echo ' '; + echo ' '; + + + echo''; + echo ''; + echo'
    '; + } + else{ + // Slika kot odgovor + $quickImage = ($spremenljivkaParams->get('quickImage') ? $spremenljivkaParams->get('quickImage') : 0); + if($quickImage == 1 && $row['orientation'] == 1){ + echo '
    '; + echo ' '; + echo '
    '.$row1['variable'].'
    '; + + // Ikona za upload slike + echo ' '; + + // Slika oz. text (brez moznosti editiranja) - samo če je vnesen kaksen text ali slika + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + else{ + echo '
    '.$row1['variable'].'
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + } + } + elseif ($row['tip'] == 3) { + //echo ' '; + echo '
    '.$row1['variable'].'
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'] . '
    '; + } + + + if (!in_array($row['orientation'], [7, 9, 10, 11])) { + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + if ($row1['if_id'] > 0) { + + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + echo ' '; + + // Kljukica za kviz + if(SurveyInfo::getInstance()->checkSurveyModule('quiz')){ + $sqlQ = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$row['id']."' AND vre_id='".$row1['id']."'"); + echo ' '; + } + + echo ' '; + + if($row['tip'] == 1 || $row['tip'] == 2 || $row['tip'] == 3) + echo ' '; + + echo ' '; + echo ' '; + + echo '
    '; + + } + + $i++; + } + + if ($row['tip'] == 3 || $row['orientation'] == 6) {//ce je tip vprasanja roleta ali je orientacija "Izbrite iz seznama" + echo '
    '; + echo '
    '.$lang['edit3'].'
    '; + echo '
    '; + } + } + // multigrid, multicheckbox, multitext, multinumber prikaz + elseif ($row['tip'] == 6 || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20 || $row['tip'] == 24) { + + $spremenljivkaParams = new enkaParameters($row['params']); + $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30); + $css = ' style = "width: '.$gridWidth.'%;" '; + + // izracuni za sirino celic + $size = $row['grids']; + + # če imamo missinge size povečamo za 1 + številomissingov + $sql_grid_mv = sisplet_query("SELECT id, spr_id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + $missing_count = mysqli_num_rows($sql_grid_mv); + if ($missing_count > 0) { + $size += $missing_count + 1; + } + + if($row['tip'] == 6 && $row['enota'] == 1){ + $size += 2; + } + if(($row['tip'] == 6 || $row['tip'] == 16) && $row['enota'] == 3){ + $size *= 2; + } + + $size +=1; + + //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo + if($gridWidth == 30) + $cellsize = round(70/$size); + else + $cellsize = 'auto'; + + $spacesize = round(70 / $size / 4); + + $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1); + $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1); + //default sirina + if($taWidth == -1) + //$taWidth = 10; + $taWidth = round(50 / $size); + + + + $sizebox = '$("#grids_count option:selected").val()'; + $display = ($row['tip'] == 6 && $row['enota'] == 8) ? ' style="display:none;"' : ''; + $grid_plus_minus = '
    '; + + //izrisemo multigride z dropdowni in select box + if($row['tip'] == 6 && ($row['enota'] == 2 || $row['enota'] == 6)) { + + echo ''; + + echo ' '; + + // urejanje vrednosti + echo ' '; + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red, variable FROM srv_grid WHERE spr_id='$row[id]' AND vrstni_red>0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + echo ''; + + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + + echo ' '; + + $row2 = mysqli_fetch_array($sql2); + } + else { + echo ' '; + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + echo ''; + } + } + echo ' '; + + echo ''; + + echo ''; + + $bg = 1; + + + $sql1 = sisplet_query("SELECT id, naslov, other, hidden, if_id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo ''; + echo ''; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + echo ''; + + + echo ''; + $bg++; + } + + + echo ''; + echo '
    ' . $row2['variable'] . '
    '.$grid_plus_minus.'
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ? ' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + echo '
    '; + + if ($row['enota'] == 6){ + echo ''; + } + + if($row['enota'] == 6){ + //echo ''; + $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1); + switch ($prvaVrstica) { + case "1": + + break; + case "2": + echo ''; + break; + case "3": + echo ''; + break; + } + } + elseif($row['enota'] == 2){ + //echo ''; + $prvaVrstica_roleta = ($spremenljivkaParams->get('prvaVrstica_roleta') ? $spremenljivkaParams->get('prvaVrstica_roleta') : 1); + switch ($prvaVrstica_roleta) { + case "1": + echo ''; + break; + case "2": + + break; + case "3": + echo ''; + break; + } + } + + + + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + + echo ''; + $row2 = mysqli_fetch_array($sql2); + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 ORDER BY vrstni_red"); + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + echo ''; + } + echo ''; + echo ' '.$lang['edit3'].''; + echo '
    '; + } + + //izrisemo multigride s select box namesto checkbox + elseif($row['tip'] == 16 && $row['enota'] == 6) { + + echo ''; + + echo ' '; + + // urejanje vrednosti + echo ' '; + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red, variable FROM srv_grid WHERE spr_id='$row[id]' AND vrstni_red>0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + echo ''; + + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + echo ''; + } + } + echo ' '; + + echo ''; + + echo ''; + + $bg = 1; + + + $sql1 = sisplet_query("SELECT id, naslov, hidden, other, if_id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo ''; + echo ''; + + $sql2 = sisplet_query("SELECT naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + echo ''; + + + echo ''; + $bg++; + } + + + echo ''; + echo '
    ' . $row2['variable'] . '
    '.$grid_plus_minus.'
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ? ' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + echo '
    '; + + if ($row['enota'] == 6){ + echo ''; + } + + //echo ''; + $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1); + switch ($prvaVrstica) { + case "1": + + break; + case "2": + echo ''; + break; + case "3": + echo ''; + break; + } + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + echo ''; + $row2 = mysqli_fetch_array($sql2); + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 ORDER BY vrstni_red"); + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + echo ''; + } + echo ''; + echo ' '.$lang['edit3'].''; + echo '
    '; + } + + //izrisemo double multigride + elseif(($row['tip'] == 6 || $row['tip'] == 16) && $row['enota'] == 3){ + + $colspan = $row['grids']; + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 AND part='1'"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + $colspan += mysqli_num_rows($sql_grid_mv) + 1; + } + + echo ''; + + echo ' '; + + echo ' '; + echo ' '; + echo ' '; + + // Prevod podnaslovov + if ($this->lang_id != null) { + + $podnaslov1 = \App\Controllers\LanguageController::srv_language_grid_podnaslov($row['id'], 1); + $podnaslov2 = \App\Controllers\LanguageController::srv_language_grid_podnaslov($row['id'], 2); + + if ($podnaslov1 != '') { + $row['grid_subtitle1'] = $podnaslov1; + } + if ($podnaslov2 != '') { + $row['grid_subtitle2'] = $podnaslov2; + } + } + + // Urejanje podnaslova 1. grida + echo ' '; + + echo ' '; + + // Urejanje podnaslova 2. grida + echo ' '; + + echo ''; + + echo ' '; + + + // urejanje vrednosti + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red, variable FROM srv_grid WHERE spr_id='$row[id]' AND vrstni_red>0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + + echo ''; + + echo ''; + + echo ' '; + echo ' '; + echo ' '; + + $bg = 1; + + //PRVI DEL GRIDA + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 AND part='1' ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 AND part='1'"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + echo ''; + } + } + + echo ''; + + //DRUGI DEL GRIDA + //$sql2 = sisplet_query("SELECT naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 AND part='2' ORDER BY vrstni_red"); + $sql2String = "SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 AND part='2' ORDER BY vrstni_red"; + $sql2 = sisplet_query($sql2String); + //$sql2 = sisplet_query("SELECT naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 AND part='1' ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + //$naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['idrow2['id']); + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $i); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i+$row['grids']+mysqli_num_rows($sql_grid_mv)) { + //echo ' '; + if($this->prevajanje == true){ + $oznaka = 'vprlang'; + }elseif($this->prevajanje == false){ + $oznaka = 'branching'; + } + + //echo ' '; + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 AND part='2'"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + echo ''; + } + } + + echo ' '; + + echo ' '; + echo ' '; + + $bg++; + + //$orderby = Survey::generate_order_by_field($spremenljivka); + + //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)"); + $sql1 = sisplet_query("SELECT id, naslov, hidden, if_id, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo ' '; + echo ' '; + echo ''; + + //PRVI DEL GRIDA + //razlicni vnosi glede na tip multigrida + for ($i = 1; $i <= $row['grids']; $i++) { + + if($row['tip'] == 6) + echo ' '; + + elseif($row['tip'] == 16) + echo ' '; + } + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 AND part='1'"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if($row['tip'] == 6) { + echo ' '; + } elseif($row['tip'] == 16) { + echo ' '; + } else { + echo ' '; + + } + + } + } + + echo ''; + + //DRUGI DEL GRIDA + //razlicni vnosi glede na tip multigrida + for ($i = 1; $i <= $row['grids']; $i++) { + + if($row['tip'] == 6) + echo ' '; + + elseif($row['tip'] == 16) + echo ' '; + } + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0 AND part='2'"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if($row['tip'] == 6) { + echo ' '; + } elseif($row['tip'] == 16) { + echo ' '; + } else { + echo ' '; + } + + } + } + + // Zadnja bela celica kjer se nahajajo ikone za mouseover + echo ''; + + echo ' '; + + $bg++; + } + + echo ' '; + echo '
    '; + echo '
    ' . $row['grid_subtitle1'] . '
    '; + echo '
    '; + echo '
    ' . $row['grid_subtitle2'] . '
    '; + echo '
    ' . $row2['variable'] . '
    '.$grid_plus_minus.'
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    ' . $row2['naslov'] . '' . $row2['naslov'] . '' . $row2['naslov'] . '' . $row_grid_mv['naslov'] . '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + + } + + echo '
    '; + + + // multiple gridi + } elseif ($row['tip'] == 24) { + + $this->vprasanje_grid_multiple($row['id']); + } + + //one against another + elseif($row['tip'] == 6 && $row['enota'] == 4){ + + echo ' '; + + // urejanje vrednosti + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, variable FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + echo ' '; + echo ' '; + $row2 = mysqli_fetch_array($sql2); + echo ' '; + echo ''; + + + echo ''; + + $bg++; + + + $sql1 = sisplet_query("SELECT id, naslov, naslov2, if_id, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + + $naslov2 = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id'], true); + if ($naslov2 != '') $row1['naslov2'] = $naslov2; + } + + echo ' '; + echo ' '; + + + //radio buttons in "ali" + echo ' '; + + echo ' '; + + echo ' '; + + //ali + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + //echo ''; + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + + if($row['tip'] == 6) { + echo ' '; + } else { + echo ' '; + } + + } + } + + + // desni stolpec možnosti, predelani bivši diferencial + echo ' '; + + // Zadnja bela celica kjer se nahajajo ikone za mouseover + echo ''; + + echo ' '; + + $bg++; + } + + echo ' '; + echo '
    ' . $row2['variable'] . '
    ' . $row2['variable'] . '
    '; + echo ''; + + echo ' '; + + //levi stolpec možnosti + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + echo '
    '.$lang['srv_tip_sample_t6_4_vmes'].'
    lang_id!=null ?' default="1"':'').'>' . $row1['naslov2'] . '
    '; + } + + //MaxDiff + elseif($row['tip'] == 6 && $row['enota'] == 5){ + //echo "MaxDiff"; + echo ' '; + echo ' '; //začetek glave oz. naslovne vrstice tabele + + // urejanje vrednosti + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, variable FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + echo ' '; + $row2 = mysqli_fetch_array($sql2); + echo ' '; + echo ' '; + echo ''; + + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + //risanje naslovov stolpcev + for ($i = 1; $i <= $row['grids']; $i++) { + + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + + if ($row2['vrstni_red'] == $i) { + //echo ' '; + $label_text = ($row2['id'] % 2 == 0 ? $lang['srv_maxdiff_label1'] : $lang['srv_maxdiff_label2']); + + //ce je default besedilo "Vpišite besedilo" spremeni labelo v "Najmanj pomemben" in "Najbolj pomemben", drugace pokazi v labelah, kar je v bazi + echo ' '; + + $row2 = mysqli_fetch_array($sql2); + echo ''; + } else { + echo ' '; + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + //echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + echo ''; + } + } + echo ' '; + + echo ''; //konec glave oz. naslovne vrstice tabele + + echo ''; //zacetek telesa tabele + + $bg++; + + $sql1 = sisplet_query("SELECT id, naslov, hidden, if_id, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo ' '; //začetek vrstice + + + // levi del radio button + //echo ' '; + echo ' '; + + //sredinski del z besedilom + echo ' '; + + + // desni del radio button + echo ' '; + + //urejanje navpicnega dela grupiranja radio button - vodoravni je urejen po defaultu s pomočjo atributa name + echo' + + '; + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + //echo ''; + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if($row['tip'] == 6) { + echo ' '; + } else { + echo ' '; + } + + } + } + + // diferencial + + echo ' '; //konec vrstice + + $bg++; + } + + echo ' '; + echo '
    ' . $row2['variable'] . '
    ' . $row2['variable'] . '
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ? ' default="1"':'').'>' . ($row2['naslov'] == $lang['srv_new_grid'] ? $label_text : $row2['naslov']) . '
    lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + echo '
    '; + } + + //Drag and drop grids******************************************************************************************************** + //elseif($row['tip'] == 6 && $row['enota'] == 9){ //Drag and drop grids + elseif( ($row['tip'] == 6 || $row['tip'] == 16) && $row['enota'] == 9){ //Drag and drop grids + + $sql1 = sisplet_query("SELECT id, naslov, hidden, other, if_id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY vrstni_red"); + + //izracun visine + $num = mysqli_num_rows($sql1); + $size = $num * 50; + + //zaslon razdelimo na dva dela - izris leve strani + echo '
    '; + + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + //preverimo dolzino niza -> max == 20 + $length = strlen($row1['naslov']); + ?> + + 30) $class = 'ranking_long'; $class = 'ranking'; + //echo '
    '; + echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + //koda za notranji IF + if ($row1['if_id'] > 0) { + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + echo '
    '; + + } + echo '
    '; + + //izris desne strani************************************************************************************** + + //***********za skatlasto obliko + $display_drag_and_drop_new_look = ($spremenljivkaParams->get('display_drag_and_drop_new_look') ? $spremenljivkaParams->get('display_drag_and_drop_new_look') : 0); //za checkbox + //***********za skatlasto obliko - konec + + echo '
    '; + + $sql2 = sisplet_query("SELECT id, naslov, variable, vrstni_red FROM srv_grid WHERE spr_id='$spremenljivka' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + echo '
      '; + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + + + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + + echo '
    • +
      ' . $row2['variable'] . '
      +
    • '."\n"; //izpis "oznake" okvirja + if($display_drag_and_drop_new_look == 0){ + echo '
    • +
      lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
      +
    • '."\n"; //izpis "naslova" okvirja + echo '
    • +
      +
    • '."\n"; //izpis okvirja + }else if($display_drag_and_drop_new_look == 1){ + echo '
    • +
      +
    • '."\n"; //izpis okvirja + echo '
    • +
      lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
      +
    • '."\n"; //izpis "naslova" okvirja + } + + $row2 = mysqli_fetch_array($sql2); + } + } + //***************************** missing-i + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + if($display_drag_and_drop_new_look == 0){ + echo '
    • +
      lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
      +
    • '."\n"; //izpis "naslova" okvirja za missing + echo '
    • +
      +
    • '."\n"; //izpis okvirja za missing + }else if($display_drag_and_drop_new_look == 1){ + echo '
    • +
      +
    • '."\n"; //izpis okvirja za missing + echo '
    • +
      lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
      +
    • '."\n"; //izpis "naslova" okvirja za missing + } + } + + } + //********************************** konec missing-i + + echo '
    '; + + + echo '
    '; //half2_$spremenljivka + + echo '
    '; + + //***********************Drag and drop grid konec************************************************************* + + } + //Image hot spot******************************************************************************************************** + elseif( ($row['tip'] == 6) && $row['enota'] == 10){ //image hot spot + $this->vprasanje_hotspot($row['id'], $row['tip'], $row['orientation']); + } + // navadni gridi + else{ + + // Ce imamo vklopljeno omejitev pri multinumber + if ($row['tip'] == 20) { + if($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit']) + $limit = '('.$row['vsota_min'].')'; + elseif($row['num_useMin'] == 1 && $row['num_useMax'] == 1) + $limit = '(min '.$row['vsota_min'].', max '.$row['vsota_limit'].')'; + elseif($row['num_useMin'] == 1) + $limit = '(min '.$row['vsota_min'].')'; + elseif($row['num_useMax'] == 1) + $limit = '(max '.$row['vsota_limit'].')'; + else + $limit = ''; + + if ($row['vsota_show'] == 1 && $limit != '') { + echo ''.$limit.''; + } + } + + //************************ za izris traku + $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox + $trak_num_of_titles = ($spremenljivkaParams->get('trak_num_of_titles') ? $spremenljivkaParams->get('trak_num_of_titles') : 0); + + //if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen in je diferencial ali klasicna tabela + if($row['tip'] == 6 && $diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen in je diferencial ali klasicna tabela + $trak_class = 'trak_class'; + $trak_class_input = 'trak_class_input'; + if($trak_num_of_titles != 0){ + $display_trak_num_of_titles = 'style="display:none;"'; + $trak_nadnaslov_table_td_width = 100 / $trak_num_of_titles; //spremenljivka za razporeditev sirine nadnaslovov @ traku + } + $display_trak_num_of_titles = ''; + }else{ + $trak_class = ''; + $trak_class_input = ''; + $display_trak_num_of_titles = 'style="display:none;"'; + } + + + for($i = 1; $i <= $trak_num_of_titles; $i++){ + $trak_nadnaslov[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.$i.'') ? $spremenljivkaParams->get('trak_nadnaslov_'.$i.'') : $lang['srv_new_text']); + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $i); + if ($naslov != '') $trak_nadnaslov[$i] = $naslov; + } + } + + //********************** za izris traku - konec + + + if ($row['tip'] == 20) { //ce je tabela s stevili + if ($row['ranking_k'] == 1){ //ce so stevila v obliki drsnikov + $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0); + $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0); + $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox + $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0); + $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0); + $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0); + $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0); + $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0); + $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 5); + $slider_MinLabel= ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum"); + $slider_MaxLabel= ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum"); + $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0); + $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100); + $slider_MinNumLabelTemp = ($spremenljivkaParams->get('slider_MinNumLabelTemp') ? $spremenljivkaParams->get('slider_MinNumLabelTemp') : 0); + $slider_MaxNumLabelTemp = ($spremenljivkaParams->get('slider_MaxNumLabelTemp') ? $spremenljivkaParams->get('slider_MaxNumLabelTemp') : 100); + $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : $lang['srv_new_text']); + $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : $lang['srv_new_text']); + + $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0); + $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0); + + if($prevajanje == true){ + $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND lang_id='$this->lang_id' ORDER BY label_id"; + $sqlSlider = sisplet_query($sqlString); + //$custom = "1; 2; 3; 4"; + while ($rowPrevajanje = mysqli_fetch_array($sqlSlider)) { + if($rowPrevajanje['label_id'] == 1){ + $MinLabel = $rowPrevajanje['label']; + }elseif($rowPrevajanje['label_id'] == 2){ + $MaxLabel = $rowPrevajanje['label']; + }elseif($rowPrevajanje['label_id'] == 0){ + $custom = $rowPrevajanje['label']; + } + } + $prevod = "prevajanje"; + + if($slider_DescriptiveLabel_defaults && $custom==''){ //ce so prednalozene opisne labele drsnika in nimamo se prevoda + $custom_ar = explode(';', $slider_DescriptiveLabel_defaults_naslov1); + }else{ //ce so custom opisne labele drsnika + $custom_ar = explode('; ', $custom); + } + }else if ($prevajanje == false){ + $prevod = ""; + } + + $slider_CalculatedNumofDescrLabels = $slider_MaxNumLabel - $slider_MinNumLabel; + if($slider_CalculatedNumofDescrLabels>11){ + $slider_CalculatedNumofDescrLabels = 11; + } + $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : $slider_CalculatedNumofDescrLabels); + + if($slider_VmesneDescrLabel){ //ce se ureja opisne labele drsnika + $slider_NumofColspans = $slider_NumofDescrLabels + 1; + $sliderTableStyle = 'style="table-layout: fixed; width: 100%"'; + $sliderTableColspan = "colspan=".$slider_NumofColspans." "; + }else{ + $slider_NumofColspans = $slider_NumofDescrLabels; + } + + } + }else{ + $sliderTableStyle = ""; + $sliderTableColspan = ""; + } + + echo ' '; + echo ' '; + + + //vrstica z nadnaslovi ################################################################################### + echo ' '; + + + //vrstica z nadnaslovi + echo ''; + + + + echo ' '; + echo ' '; + + + for ($j = 1; $j <= $row['grids']; $j++) { + + //echo ''; + if($j == 1){ + $nadnaslov_floating = 'left'; + } + else if($j == $row['grids']){ + $nadnaslov_floating = 'right'; + } + else{ + $nadnaslov_floating = 'none'; + } + + echo ''; + } + echo ''; + + //vrstica z nadnaslovi - konec ################################################################################### + + // urejanje vrednosti + echo ' '; + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, variable, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + echo ''; + + //echo ' '; + echo ' '; + if ($row['ranking_k'] != 1){ //ce ni slider + echo ' '; + }else{ + echo ' '; + } + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + + //************* za ureditev prilagajanja label stolpcev + $custom_column_label_option = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1); + echo ' + + '; + //************* za ureditev prilagajanja label stolpcev - konec + //*********** trak - nadnaslovi + if($row['tip'] == 6 && $diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen in je diferencial ali klasicna tabela + //$trak_num_of_titles + + ?> + + 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + //echo ''; + echo ''; + } + + } + + // diferencial + if ($row['enota'] == 1 && $row['tip'] == 6) { + echo ' '; + echo ' '; + echo ''; + } + else{ + if ($row['ranking_k'] != 1){ //ce ni slider + echo ''; + } + } + + echo ' '; + + echo ''; + if ($row['ranking_k'] == 1) { //ce je slider + //min max labele nad drsnikom ################################################################## + $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : ''; + echo ''; + echo ''; + echo ''; + + $bg++; + + $varIndex = 0; //belezi, katera je trenuta vrstica podvprasanja + + //parameter, ki belezi, ali se je izris droppables izvedel + $izris_droppable_grid = ($spremenljivkaParams->get('izris_droppable_grid') ? $spremenljivkaParams->get('izris_droppable_grid') : 0); + + + $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other, if_id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + + $naslov2 = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id'], true); + if ($naslov2 != '') $row1['naslov2'] = $naslov2; + } + + if ($row['ranking_k'] == 1) { //ce je slider + $style = 'style="height:150px;"'; + }else{ + $style = ''; + } + + echo ' '; + echo ' '; + + //echo ''; + echo ''; + + + + //razlicni vnosi glede na tip multigrida + for ($i = 1; $i <= $row['grids']; $i++) { + + if($row['tip'] == 6) { + if($row['enota'] != 9){ //ce ni postavitev drag and drop, pokazi radio buttone + + $sqlTrak = sisplet_query("SELECT spr_id, variable, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 AND id='$i'"); + $rowTrak = mysqli_fetch_array($sqlTrak); + + echo ''; + } + + } elseif($row['tip'] == 16) { + echo ' '; + + } elseif ($row['tip'] == 19) { + echo ' '; + + } elseif ($row['tip'] == 20) { + + //echo ' '; + //echo ' '; + //Zadnja bela celica kjer se nahajajo ikone za mouseover, ko je slider - konec + + }else{ + echo ' '; + } + } + + $izris_droppable_grid = 1; //izris ene vrstice droppables se je izvedel + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + //echo ''; + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if($row['tip'] == 6) { + echo ' '; + } elseif($row['tip'] == 16) { + echo ' '; + } else { + echo ' '; + } + + } + } + + // diferencial + if ($row['enota'] == 1 && $row['tip'] == 6) { + echo ' '; + echo ' '; + } + + if ($row['ranking_k'] != 1) { //ce ni slider + // Zadnja bela celica kjer se nahajajo ikone za mouseover + echo ''; + + echo ' '; + } + + $bg++; + + $varIndex++; + if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0) ){ // ce je diferencial ali klasicna tabela s trakom, dodaj se prazno vrstico med razlicnimi odgovori + echo '' . "\n"; + } + } + + echo ' '; + echo '
    '.$j.'
    lang_id!=null ?' default="1"':'').'>' . $trak_nadnaslov[$j] . '
    ' . $row2['variable'] . '
    '.$grid_plus_minus.'
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    '.$lang['slider_admin_minmax_label_desc'].''; + + echo ''; + echo ''; + //echo ''; + echo ''; + //echo ''; + echo ''; + echo ''; + echo '
    lang_id!=null ?' default="1"':'').'>' . $MinLabel . '
    lang_id!=null ?' default="1"':'').'>' . $MinLabel . '
    lang_id!=null ?' default="1"':'').'>' . $MaxLabel . '
    lang_id!=null ?' default="1"':'').'>' . $MaxLabel . '
    '; + + //min max labele nad drsnikom - konec ################################################################## + } + //echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + if($row['enota'] != 9){ + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + } + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + echo '
    + '; + if($row['enota'] == 11){ + echo ''; + }elseif($row['enota'] == 12){ + echo ''; + }else { + echo ''; + } + + if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen in je diferencial ali klasicna tabela, dodaj se label z ustreznimi stevilkami za trak + echo ''; + } + + echo ''; + + if ($row['ranking_k'] == 1) { //ce je slider + + echo ' '; + + echo '
    '; + + + $default_value = round( ($slider_MaxNumLabel-$slider_MinNumLabel) / 2) + $slider_MinNumLabel; + + + echo '
    '.$default_value.'
    '; + + echo '
    '; + + echo '
    '; + + + //za custom opisne labele + //moznosti urejanja opisnih label drsnika + if($slider_VmesneDescrLabel){ + for($i=1; $i<=$slider_NumofDescrLabels; $i++){ + if($prevajanje == false){ + $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : ''); + }else if ($prevajanje == true){ + $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1]; + } + + $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s| /",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik + if($i == 1){ + $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp; + }else{ + $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp; + } + } + } + //za custom opisne labele - konec + + if($prevajanje == false){ + ?> + + + +
    '; + } + + echo '
    lang_id!=null ?' default="1"':'').'>' . $row1['naslov2'] . '
    '; + + //ce je drsnik in moramo urediti opisne labele ######################################################### + if ($row['ranking_k'] == 1 && $slider_VmesneDescrLabel){ //ce je slider in se ureja opisne labele + + echo '
    '; //za urediti prostor med zadnjimi opisnimi labelami in njihovim urejanjem + + if($slider_DescriptiveLabel_defaults&&$prevajanje==false){ + $tabelaOpisneStyle = 'display:none;'; + }else{ + $tabelaOpisneStyle = ''; + } + + echo ''; + echo ''; + + //moznosti urejanja opisnih label drsnika + echo ''; + echo ''; + echo ''; //gumb za posodobitev custom opisnih label + echo ''; + echo ''; + $sirinaStolpcev = 100/$slider_NumofDescrLabels; + for($j = 1; $j <= $slider_NumofDescrLabels; $j++){ //ostali stolpci + if($prevajanje == false){ + $slider_Labela_opisna[$j] = ($spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') ? $spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') : $lang['srv_new_text']); + }else if ($prevajanje == true){ + $slider_Labela_opisna[$j] = $custom_ar[$j-1]; + } + + echo ''; + } + echo ''; + echo ''; + //moznosti urejanja ureditev opisnih label drsnika - konec + + //moznosti brez urejanja opisnih label drsnika + echo ''; + echo ''; + echo ''; //gumb za vklop posodabljanja custom opisnih label + echo ''; + echo ''; + $sirinaStolpcev = 100/$slider_NumofDescrLabels; + for($j = 1; $j <= $slider_NumofDescrLabels; $j++){ //ostali stolpci + if($prevajanje == false){ + $slider_Labela_opisna[$j] = ($spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') ? $spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') : $lang['srv_new_text']); + }else if ($prevajanje == true){ + $slider_Labela_opisna[$j] = $custom_ar[$j-1]; + } + + echo ''; + } + echo ''; + echo ''; + //moznosti brez urejanja ureditev opisnih label drsnika - konec + + //js koda za ustrezno skrivanje in prikazovanje delov za urejanje custom opisnih label + ?> + + '; + } + //ce je drsnik in moramo urediti opisne labele - konec ################################################## + } + + // textbox -- not any more + } elseif ($row['tip'] == 4) { + + $taSize = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1); + $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1); + //default sirina + if($taWidth == -1) + $taWidth = 30; + + if ($taSize > 1) + echo ''; + else + echo ''; + + // dodamo checkboxe za druga polja + $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' AND other>0"); + while ($row1 = mysqli_fetch_array($sql1)) { + echo '
    '; + echo ''; + echo ''; + echo ''; + echo '
    '; + } + } + + // textbox* + elseif ($row['tip'] == 21) { + + if($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit']) + $limit = '('.$lang['srv_text_length_char_num'].$row['vsota_min'].')'; + elseif($row['num_useMin'] == 1 && $row['num_useMax'] == 1) + $limit = '('.$lang['srv_text_length_char_num'].'min '.$row['vsota_min'].', max '.$row['vsota_limit'].')'; + elseif($row['num_useMin'] == 1) + $limit = '('.$lang['srv_text_length_char_num'].'min '.$row['vsota_min'].')'; + elseif($row['num_useMax'] == 1) + $limit = '('.$lang['srv_text_length_char_num'].'max '.$row['vsota_limit'].')'; + else + $limit = ''; + + $taSize = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1); + $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1); + //default sirina + if($taWidth == -1) + $taWidth = 30; + + echo '
    '.$lang['slider_custom_labels_msg'].'
    lang_id!=null ?' default="1"':'').'>' . $slider_Labela_opisna[$j] . '
    '; + if($row['orientation'] != 3) + echo ''; + + $_others = array(); + $sql1 = sisplet_query("SELECT id, naslov, variable, size, other, hidden, naslov2 FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red > 0 ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ((int)$row1['other'] == 0) { + + // sirina celice td + $cell = $row['text_kosov'] == 1 ? 100 : $row1['size'] ; + // sirina vnosnega polja + $input = $taWidth; + + if($row['orientation'] == 3) + echo ''; + echo ''; + if($row['orientation'] == 3) + echo ''; + } + else { + # imamo opcijo drugo prikažemo kot checkbox + $_others[] = $row1; + } + } + if($row['orientation'] != 3) + echo ''; + echo '
    '; + + if($row['text_orientation'] == 1 || $row['text_orientation'] == 3){ + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + if ($row['text_orientation'] == 3) + echo '
    '; + } + if ($taSize > 1) + echo ''; + else + echo ''; + + if($row['text_orientation'] == 2){ + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + } + echo '
    '; + + if ($row['vsota_show'] == 1 && $limit != '') + echo ''.$limit.''; + + if (count($_others)> 0 ) { + foreach ($_others AS $oKey => $_other) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($_other['id']); + if ($naslov != '') $_other['naslov'] = $naslov; + } + + // Ce je variabla ne vem in imamo vklopljen prikaz ob opozorilu -> rdec + $missing_warning = ''; + if(($_other['variable'] == '-97' && $row['alert_show_97'] > 0) + || ($_other['variable'] == '-98' && $row['alert_show_98'] > 0) + || ($_other['variable'] == '-99' && $row['alert_show_99'] > 0)){ + $missing_warning = ' red'; + } + + echo '
    '; + echo ' '; + echo '
    ' . $_other['naslov'] . '
    '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    '; + + } + } + } + + // number + elseif ($row['tip'] == 7) { + + if($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit']) + $limit = '('.$row['vsota_min'].')'; + elseif($row['num_useMin'] == 1 && $row['num_useMax'] == 1) + $limit = '(min '.$row['vsota_min'].', max '.$row['vsota_limit'].')'; + elseif($row['num_useMin'] == 1) + $limit = '(min '.$row['vsota_min'].')'; + elseif($row['num_useMax'] == 1) + $limit = '(max '.$row['vsota_limit'].')'; + else + $limit = ''; + + if($row['size'] == 2){ + if($row['num_useMin2'] == 1 && $row['num_useMax2'] == 1 && $row['num_min2'] == $row['num_max2']) + $limit2 = '('.$row['num_min2'].')'; + elseif($row['num_useMin2'] == 1 && $row['num_useMax2'] == 1) + $limit2 = '(min '.$row['num_min2'].', max '.$row['num_max2'].')'; + elseif($row['num_useMin2'] == 1) + $limit2 = '(min '.$row['num_min2'].')'; + elseif($row['num_useMax2'] == 1) + $limit2 = '(max '.$row['num_max2'].')'; + else + $limit2 = ''; + } + + $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1); + //default sirina + if($taWidth == -1) + $taWidth = 10; + + $cssFloat = ' floatLeft'; + + + $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' AND other = 0 "); + $row1 = mysqli_fetch_array($sql1); + $sqlOther = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red>0 AND other != 0"); + $num_other = mysqli_num_rows($sqlOther); + $num_all = $num_other+$row['size']; + + $cell_width = 'width:'.(80/$num_all).'% '; + + if ( $row['ranking_k'] == '0' ) { + + echo '
    '; + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + if($row['enota'] == 1) + echo '
    lang_id!=null ?' default="1"':'').'>' . $row1['naslov'] . '
    + '; + elseif($row['enota'] == 2) + echo '
    lang_id!=null?' default="1"':'').'>' . $row1['naslov'].'
    '; + else + echo ' '; + echo '
    '; + + // Omejitev vnosa + if ($row['orientacija'] == 1) { + echo '
    ccc
    '; + $cssFloat = ''; + }else { + $cssFloat = ' floatLeft'; + } + if ($row['vsota_show'] == 1 && $limit != '') { + echo ''.$limit.''; + } elseif($row['size'] != 2 && $limit == '') { + echo ''.$lang['srv_number_text'].''; + } + + $cssFloat = ' floatLeft'; + + if ($row['size'] == 2) { + + $row1 = mysqli_fetch_array($sql1); + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo '
    '; + if($row['enota'] == 1){ + if($taWidth > 40) + echo '
    '; + echo '
    lang_id!=null ?' default="1"':'').'>' . $row1['naslov'] . '
    + '; + } + elseif($row['enota'] == 2) + echo '
    lang_id!=null ?' default="1"':'').'>' . $row1['naslov'].'
    '; + else + echo ' '; + echo '
    '; + + //Omejitev vnosa + if ($row['orientacija'] == 1) { + echo '
    ccc
    '; + $cssFloat = ''; + }else { + $cssFloat = ' floatLeft'; + } + if ($row['vsota_show'] == 1 && $limit2 != '') { + echo ''.$limit2.''; + } elseif($limit == '' && $limit2 == '') { + echo ''.$lang['srv_number_text'].''; + } + } + + }//ranking_k == 0 + + if ( $row['ranking_k'] == '1' ) { + + echo '
    '; + + $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0); + $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0); + $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox + $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0); + $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0); + $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0); + $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0); + $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0); + $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 5); + $slider_MinLabel= ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum"); + $slider_MaxLabel= ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum"); + $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0); + $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100); + $slider_MinNumLabelTemp = ($spremenljivkaParams->get('slider_MinNumLabelTemp') ? $spremenljivkaParams->get('slider_MinNumLabelTemp') : 0); + $slider_MaxNumLabelTemp = ($spremenljivkaParams->get('slider_MaxNumLabelTemp') ? $spremenljivkaParams->get('slider_MaxNumLabelTemp') : 100); + + $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : $lang['srv_new_text']); + $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : $lang['srv_new_text']); + + if ($prevajanje == true){ + $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND lang_id='$this->lang_id' ORDER BY label_id"; + $sqlSlider = sisplet_query($sqlString); + + while ($rowPrevajanje = mysqli_fetch_array($sqlSlider)) { + if($rowPrevajanje['label_id'] == 1){ + $MinLabel = $rowPrevajanje['label']; + }elseif($rowPrevajanje['label_id'] == 2){ + $MaxLabel = $rowPrevajanje['label']; + }elseif($rowPrevajanje['label_id'] == 0){ + $custom = $rowPrevajanje['label']; + } + } + } + + $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5); + $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0); + $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0); + $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : ''; + $slider_labele_podrocij = ($spremenljivkaParams->get('slider_labele_podrocij') ? $spremenljivkaParams->get('slider_labele_podrocij') : 0); //za checkbox + $display_labele_podrocij = ($slider_labele_podrocij == 0) ? ' style="display:none;"' : ''; + $slider_StevLabelPodrocij = ($spremenljivkaParams->get('slider_StevLabelPodrocij') ? $spremenljivkaParams->get('slider_StevLabelPodrocij') : 3); + + $slider_table_td_width = 100 / $slider_StevLabelPodrocij; //spremenljivka za razporeditev sirine sliderja po podrocjih + + for($i = 1; $i <= $slider_StevLabelPodrocij; $i++){ + $slider_Labela_podrocja[$i] = ($spremenljivkaParams->get('slider_Labela_podrocja_'.$i.'') ? $spremenljivkaParams->get('slider_Labela_podrocja_'.$i.'') : $lang['srv_new_text']); + } + + echo '
    '; + + $default_value = round( ($slider_MaxNumLabel-$slider_MinNumLabel) / 2) + $slider_MinNumLabel; + + //tabela za labeli nad min in max + echo ''; + echo ''; + + echo ''; + + echo ''; + + echo ''; + echo '
    lang_id!=null ?' default="1"':'').'>' . $MinLabel . '
    lang_id!=null ?' default="1"':'').'>' . $MaxLabel . '
    '; + //tabela za labeli nad min in max - konec + + echo '
    '.$default_value.'
    '; + if($prevajanje == false){ + //echo '
    '; + $prevod = ""; + } + else if ($prevajanje == true){ + $prevod = "prevajanje"; + if($slider_DescriptiveLabel_defaults && $custom==''){ //ce so prednalozene opisne labele drsnika in nimamo se prevoda + $custom_ar = explode(';', $slider_DescriptiveLabel_defaults_naslov1); + }else{ //ce so custom opisne labele drsnika + $custom_ar = explode('; ', $custom); + } + } + echo '
    '; + echo '
    '; + + //za custom opisne labele + //moznosti urejanja opisnih label drsnika + if($slider_VmesneDescrLabel){ + for($i=1; $i<=$slider_NumofDescrLabels; $i++){ + if($prevajanje == false){ + $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : ''); + }else if ($prevajanje == true){ + $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1]; + } + + $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s| /",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik + if($i == 1){ + $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp; + }else{ + $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp; + } + } + } + //za custom opisne labele - konec + + //echo $slider_DescriptiveLabel_defaults_naslov1; + if ($prevajanje == false){ + ?> + + + + '; + echo '
    '; + echo '
    '; + + //tabela za labele podrocij in podrocja + echo ''; + + //vrstica z graficnim prikazom podrocja + echo ''; + for($i = 1; $i <= $slider_StevLabelPodrocij; $i++){ + echo ''; + } + echo ''; + + //vrstica z labelami podrocij + echo ''; + for($j = 1; $j <= $slider_StevLabelPodrocij; $j++){ + echo ''; + } + echo ''; + + echo '
    lang_id!=null ?' default="1"':'').'>' . $slider_Labela_podrocja[$j] . '
    '; + + //tabela za labele podrocij in podrocja + echo '
    '; + + //ce je drsnik in moramo urediti opisne labele ######################################################### + if ($slider_VmesneDescrLabel){ //ce se ureja custom opisne labele + + echo '
    '; //za urediti prostor med zadnjimi opisnimi labelami in njihovim urejanjem + + if($slider_DescriptiveLabel_defaults&&$prevajanje==false){ + $tabelaOpisneStyle = 'display:none;'; + }else{ + $tabelaOpisneStyle = ''; + } + + echo ''; + echo ''; + + //moznosti urejanja opisnih label drsnika + echo ''; + //echo ''; + echo ''; + echo ''; //gumb za posodobitev custom opisnih label + echo ''; + echo ''; + $sirinaStolpcev = 100/$slider_NumofDescrLabels; + for($j = 1; $j <= $slider_NumofDescrLabels; $j++){ //ostali stolpci + if($prevajanje == false){ + $slider_Labela_opisna[$j] = ($spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') ? $spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') : $lang['srv_new_text']); + }else if ($prevajanje == true){ + $slider_Labela_opisna[$j] = $custom_ar[$j-1]; + } + + echo ''; + } + echo ''; + echo ''; + //moznosti urejanja ureditev opisnih label drsnika - konec + + //moznosti brez urejanja opisnih label drsnika + echo ''; + echo ''; + echo ''; //gumb za vklop posodabljanja custom opisnih label + echo ''; + echo ''; + $sirinaStolpcev = 100/$slider_NumofDescrLabels; + for($j = 1; $j <= $slider_NumofDescrLabels; $j++){ //ostali stolpci + if($prevajanje == false){ + $slider_Labela_opisna[$j] = ($spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') ? $spremenljivkaParams->get('slider_Labela_opisna_'.$j.'') : $lang['srv_new_text']); + }else if ($prevajanje == true){ + $slider_Labela_opisna[$j] = $custom_ar[$j-1]; + } + + echo ''; + } + echo ''; + echo ''; + //moznosti brez urejanja ureditev opisnih label drsnika - konec + + //js koda za ustrezno skrivanje in prikazovanje delov za urejanje custom opisnih label + ?> + + '; + } + //ce je drsnik in moramo urediti opisne labele - konec ################################################## + } + + + // dodamo checkboxe za druga polja + while ($row1 = mysqli_fetch_array($sqlOther)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + // Ce je variabla ne vem in imamo vklopljen prikaz ob opozorilu -> rdec + $missing_warning = ''; + if(($row1['other'] == '-97' && $row['alert_show_97'] > 0) + || ($row1['other'] == '-98' && $row['alert_show_98'] > 0) + || ($row1['other'] == '-99' && $row['alert_show_99'] > 0)){ + $missing_warning = ' red'; + } + + echo '
    '; + echo ''; + echo '
    ' . $row1['naslov'] . '
    '; + + echo ' '; + echo ' '; + echo '
    '; + } + } + + // label + elseif ($row['tip'] == 5) { + + } + + // 8_datum + elseif ($row['tip'] == 8) { + + #XXXXXXXXX MV + echo '
    '; + echo ' '; + echo ' '; + echo '
    '; + + // dodamo checkboxe za druga polja + $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red>0 AND other != 0"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + // Ce je variabla ne vem in imamo vklopljen prikaz ob opozorilu -> rdec + $missing_warning = ''; + if(($row1['other'] == '-97' && $row['alert_show_97'] > 0) + || ($row1['other'] == '-98' && $row['alert_show_98'] > 0) + || ($row1['other'] == '-99' && $row['alert_show_99'] > 0)){ + $missing_warning = ' red'; + } + + echo '
    '; + echo ''; + echo '
    ' . $row1['naslov'] . '
    '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
    '; + } + + } + + // ranking + elseif ($row['tip'] == 17) { + + $sql1 = sisplet_query("SELECT id, naslov, hidden, if_id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY vrstni_red"); + + // izracun visine + $num = mysqli_num_rows($sql1); + $size = $num * 50; + + // n=k + if ($row['design'] == 2) { + echo '
    '; + + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + //preverimo dolzino niza -> max == 20 + $length = strlen($row1['naslov']); + ?> + + 30) $class = 'ranking_long'; $class = 'ranking'; + + echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + + //koda za notranji IF + if ($row1['if_id'] > 0) { + + echo '
    '; + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + + echo '
    '; + } + + echo '
    '; + } + echo '
    '; + } + + //n>k + elseif ($row['design'] == 0) { + + //zaslon razdelimo na dva dela - izris leve strani + echo '
    '; + + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + //preverimo dolzino niza -> max == 20 + $length = strlen($row1['naslov']); + ?> + + 30) $class = 'ranking_long'; $class = 'ranking'; + + echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + + //koda za notranji IF + if ($row1['if_id'] > 0) { + echo '
    '; + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0){ + echo ' '; + } + + echo '
    '; + } + + echo '
    '; + } + echo '
    '; + + // izris desne strani + echo '
    '; + + if($row['ranking_k'] == 0) + $max = mysqli_num_rows($sql1); + else + $max = $row['ranking_k']; + + for($i=1; $i<=$max; $i++){ + echo '
    '.$i.'
    '; + } + + echo '
    '; + + echo '
    '; + } + + // cifre - dropdown + elseif ($row['design'] == 1) { + + $max = mysqli_num_rows($sql1); + + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + //echo ' '; + echo ''; + + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + + //koda za notranji IF + if ($row1['if_id'] > 0) { + + echo ' *'; + + echo ' '; + $this->conditions_display($row1['if_id']); + echo ''; + + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + echo '
    '; + } + } + + //image hotspot za razvrscanje + elseif ($row['design'] == 3) { + + //izris hotspot nastavitev za dodajanje slike + $this->vprasanje_hotspot($row['id'], $row['tip'], $row['design']); + } + } + + // vsota + elseif ($row['tip'] == 18) { + + $spremenljivkaParams = new enkaParameters($row['params']); + $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30); + + echo '
    '; + + $sql1 = sisplet_query("SELECT id, naslov, hidden, if_id FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red > '0' ORDER BY vrstni_red ASC"); + while($row1 = mysqli_fetch_array($sql1)){ + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo '
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ?' default="1"':'').'>'.$row1['naslov'].'
    '; + + echo ' '; + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + echo '
    '; + + } + echo '
    '; + + $row1 = Cache::srv_spremenljivka($row['id']); + + if($row['vsota_limit'] != 0 && $row['vsota_limit'] == $row['vsota_min']) + $limit = '('.$row['vsota_min'].')'; + elseif($row['vsota_limit'] != 0 && $row['vsota_min'] != 0) + $limit = '(min '.$row['vsota_min'].', max '.$row['vsota_limit'].')'; + elseif($row['vsota_limit'] != 0) + $limit = '(max '.$row['vsota_limit'].')'; + elseif($row['vsota_min'] != 0) + $limit = '(min '.$row['vsota_min'].')'; + + $vsota = ($row1['vsota'] != '') ? $row1['vsota'] : $lang['srv_vsota_text']; + + + echo '
    '.$lang['slider_custom_labels_msg'].'
    lang_id!=null ?' default="1"':'').'>' . $slider_Labela_opisna[$j] . '
    lang_id!=null ?' default="1"':'').'>' . $slider_Labela_opisna[$j] . '
    '; + + echo ' '; + + echo ' '; + + echo '
    '; + echo '
    '; + echo '
    lang_id!=null ?' default="1"':'').'>' . $vsota . '
    '; + echo '
    '; + echo '
    '; + echo ' '; + if ($row['vsota_show'] == 1) + echo ' '; + echo '
    '; + } + + // SN - imena + elseif ($row['tip'] == 9) { + + } + + // SN - social + elseif ($row['tip'] == 10) { + + } + + // SN - podvprasanje + elseif ($row['tip'] == 11) { + + } + + // SN - number + elseif ($row['tip'] == 12) { + + $sql1 = sisplet_query("SELECT naslov FROM srv_vrednost WHERE spr_id='$row[id]'"); + + for ($t = 0; $t < $row['size']; $t++) { + $row1 = mysqli_fetch_array($sql1); + + if ($row['enota'] > 0) { + echo '

    ' . $row1['naslov'] . '

    '; + } else + echo '

    '; + } + } + + // SN - povezave + elseif ($row['tip'] == 13) { + + } + + // AW - podvprasanje + elseif ($row['tip'] == 14) { + + if ($row['random'] == 1) + $orderby = 'RAND()'; + else + $orderby = 'vrstni_red'; + + $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY $orderby"); + while ($row1 = mysqli_fetch_array($sql1)) { + echo '

    '; + } + + if ($row['textfield'] == 1) { + echo '

    '; + } + } + + // AW - number + elseif ($row['tip'] == 15) { + + } + + // 26 - Lokacija - maps + elseif ($row['tip'] == 26) { + + //podtip 2 - multilokacija; 1 - moja lokacija; 3 - choose lokacija + + $default_centerInMap = "Slovenija"; + + //pridobi parametre za centriranje mape in jo nastavi za kasnejso uporabo v js + $fokus_koordinate = $spremenljivkaParams->get('fokus_koordinate'); //dobi fokus koordinat mape + if(!isset(json_decode($fokus_koordinate)->center->lat)) + $fokus_koordinate = false; + + $fokus = $spremenljivkaParams->get('fokus_mape'); //dobi fokus mape + $podvprasanje_naslov = $spremenljivkaParams->get('naslov_podvprasanja_map');//dobi naslov podvprasanja + + if($fokus || $fokus_koordinate) + $centerInMap = $fokus; + else + $centerInMap = $default_centerInMap; + + $map_data = array(); + $map_data_info_shapes = array(); + + //ce je podtip choose location + if($row['enota'] == 3){ + //ce so podatki ze v bazi + $sql1 = sisplet_query("SELECT vm.vre_id as id, v.naslov, vm.lat, vm.lng, vm.address FROM srv_vrednost AS v + LEFT JOIN srv_vrednost_map AS vm ON v.id = vm.vre_id + WHERE v.spr_id='$spremenljivka'", 'array'); + + //je vec vrednosti + if(!isset($sql1['lat'])) + $map_data = $sql1; + //je ena vrednost + else + $map_data[] = $sql1; + + echo ''.$lang['srv_branching_no_value_map'].''; + + //get info shapes + $sql2 = sisplet_query("SELECT lat, lng, address, overlay_id FROM srv_vrednost_map + WHERE spr_id='$spremenljivka' AND overlay_type='polyline' ORDER BY overlay_id, vrstni_red", 'array'); + + //create json data for info shapes + $st_linij=0; + $last_id=0; + foreach ($sql2 as $line_row) { + if($line_row['overlay_id'] != $last_id){ + $st_linij++; + $last_id = $line_row['overlay_id']; + $map_data_info_shapes[$st_linij-1]['overlay_id']=$line_row['overlay_id']; + $map_data_info_shapes[$st_linij-1]['address']=$line_row['address']; + $map_data_info_shapes[$st_linij-1]['path']= array(); + } + + $path = array(); + $path['lat']=floatval($line_row['lat']); + $path['lng']=floatval($line_row['lng']); + + array_push($map_data_info_shapes[$st_linij-1]['path'], $path); + } + } + + //izrisi search box za v mapo + echo ''; + + echo '
    '; + ?> + + vprasanje_heatmap($row['id'], $row['tip']); + } + + + + //echo '
    '; + echo '
    '; + + if ($row['orientation']==0 || $row['orientation']==2 || $row['tip'] == 17) echo '
    '; // kjer so vsi divi floatani, da se raztegne okvir vprasanja + + echo '
    '; + + //echo '
    '; + if ($this->displayKomentarji !== false) { + $this->vprasanje_komentarji($spremenljivka); + } + + echo '
    '; + } + + function vprasanje_grid_multiple ($spremenljivka) { + global $lang; + + $row = Cache::srv_spremenljivka($spremenljivka); + + $spremenljivkaParams = new enkaParameters($row['params']); + + // Ce je vprasanje ali anketa zaklenjena + $locked = ($this->locked) ? true : false; + + // Inline ifi so disablani ce nimamo ustreznega paketa + $userAccess = UserAccess::getInstance($global_user_id); + + echo ' '; + echo ' '; + + // podnaslovi gridov + if ($row['grid_subtitle1'] == '1') { + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $sql2 = sisplet_query("SELECT s.id, s.naslov, s.grids FROM srv_spremenljivka s, srv_grid_multiple m WHERE s.id = m.spr_id AND parent = '".$row['id']."' ORDER BY m.vrstni_red"); + while ($row2 = mysqli_fetch_array($sql2)) { + + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $rowl = \App\Controllers\LanguageController::srv_language_spremenljivka($row2['id']); + if (strip_tags($rowl['naslov']) != '') $row2['naslov'] = $rowl['naslov']; + } + + + echo ' '; + + } + + echo ' '; + } + + // urejanje vrednosti + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT id, variable, vrstni_red FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + echo ''; + + $grid_plus_minus = ''; + + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $bg = 1; + + //$sql2 = sisplet_query("SELECT g.* FROM srv_grid g, srv_grid_multiple m WHERE g.spr_id = m.spr_id AND parent = '".$row['id']."' ORDER BY m.vrstni_red, g.vrstni_red"); + + $sqlM = sisplet_query("SELECT spr_id FROM srv_grid_multiple WHERE parent='$spremenljivka' ORDER BY vrstni_red"); + if(mysqli_num_rows($sqlM) > 0){ + $multiple = array(); + while ($rowM = mysqli_fetch_array($sqlM)) { + $multiple[] = $rowM['spr_id']; + } + $sql2 = sisplet_query("SELECT g.*, s.tip, s.enota, s.dostop FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id=m.spr_id AND m.spr_id IN (".implode(',', $multiple).") ORDER BY m.vrstni_red, g.vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= mysqli_num_rows($sql2); $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row2['spr_id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + + if (true) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + echo ''; + + } + } + echo ' '; + + + // linki za urejanje pod-spremenljivk tabele + echo ' '; + echo ' '; + //echo ' '; + echo ' '; + + $bg = 1; + $col = 1; + $tip_prev = 0; + $id_prev = 0; + + $sql2 = sisplet_query("SELECT s.grids, s.id, s.tip FROM srv_grid_multiple m, srv_spremenljivka s WHERE s.id = m.spr_id AND m.parent = '".$row['id']."' ORDER BY m.vrstni_red"); + while ($row2 = mysqli_fetch_array($sql2)) { + + if ($id_prev == 0) $id_prev = $row2['id']; + + if ($tip_prev != $row2['tip']) $col++; + $tip_prev = $row2['tip']; + + echo ' '; + + $id_prev = $row2['id']; + } + echo ' '; + + echo ''; + echo ''; + + $bg++; + + $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other, if_id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + echo ' '; + echo ' '; + + //echo ''; + echo ''; + + //razlicni vnosi glede na tip multigrida + //for ($i = 1; $i <= $row['grids']; $i++) { + $sql2 = sisplet_query("SELECT s.id, s.tip, s.enota FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id = m.spr_id AND parent = '".$row['id']."' ORDER BY m.vrstni_red, g.vrstni_red"); + if (mysqli_num_rows($sql2) > 0) + $cellsize = 80/mysqli_num_rows($sql2); + else + $cellsize = 0; + + $col = 1; + $tip_prev = 0; + $id_prev = 0; + + while ($row2 = mysqli_fetch_array($sql2)) { + + if ($id_prev == 0) $id_prev = $row2['id']; + + if ($tip_prev != $row2['tip']) $col++; + $tip_prev = $row2['tip']; + + if($row2['tip'] == 6) { + //echo ' '; + echo ' '; + + } elseif($row2['tip'] == 16) { + //echo ' '; + echo ' '; + + } elseif ($row2['tip'] == 19) { + echo ' '; + + } elseif ($row2['tip'] == 20) { + + echo ' '; + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if($row['tip'] == 6) { + echo ' '; + } elseif($row['tip'] == 16) { + echo ' '; + } else { + echo ' '; +// echo ' '; + } + + } + } + + // diferencial + if ($row['enota'] == 1 && $row['tip'] == 6) { + //echo ' '; + echo ' '; + echo ' '; + } + echo ' '; + + $bg++; + } + + echo ' '; + echo '
    lang_id!=null ?' default="1"':'').'>' . $row2['naslov'] . '
    ' . $row2['variable'] . '
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    '.$grid_plus_minus.''.$lang['edit3'].'
    '; + echo ''; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'
    '; + + if ($row1['if_id'] > 0) { + echo ' *'; + if ($this->condition_check($row1['if_id']) != 0) + echo ' '; + } + + if ($row1['other'] == 1){ + $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1); + $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1); + + if ($otherHeight > 1) + echo ''; + else + echo ''; + } + + + echo '
    '.($row2['enota']!=2?'':'').''.(($row2['enota']!=2 && $row2['enota']!=6)?'':'').''.(($row2['enota']!=2 && $row2['enota']!=6)?'':'').''; + + if ($row['ranking_k'] == 1) { + echo '
    '; + + $default_value = round(($row['vsota_limit']-$row['vsota_min']) / 2) + $row['vsota_min']; + echo '
    '.$default_value.'
    '; + + echo '
    '.$row['vsota_min'].'
    '; + echo '
    '; + echo '
    '.$row['vsota_limit'].'
    '; + + echo '
    '; + + // + ?> + + '; + } + + $id_prev = $row2['id']; + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + //echo '
    lang_id!=null ?' default="1"':'').'>' . $row1['naslov2'] . '
    '; + + } + + + /** + * komentarji na vprasanje - vrstica se izpise na dnu prikaza vprasanja + * + * @param mixed $spremenljivka + */ + function vprasanje_komentarji ($spremenljivka) { + global $lang; + global $admin_type; + global $global_user_id; + + SurveySetting::getInstance()->Init($this->anketa); + $question_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment'); + $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment'); + $question_resp_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_viewadminonly'); + + $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly'); + $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor'); + + if (!($admin_type <= $question_comment && $question_comment!='') && !($question_resp_comment==1)) return; + if ($_GET['a'] == 'komentarji') return; // v komentarjih tut ne izpisujemo te vrstice + + echo '
    '; + + // komentarji na vprasanje + if ($admin_type <= $question_comment && $question_comment != '') { + + // Dodaj komentar + echo ' '; + //echo ''.$lang['srv_question_comment'].' '; + echo ' '; + echo $lang['srv_add_comment']; + echo ''; + echo ' '; + + $row = Cache::srv_spremenljivka($spremenljivka); + if ($row['thread'] == 0) { + $row['count'] = 0; + } else { + if ($admin_type <= $question_comment_viewadminonly) { + $sql = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]'"); + } elseif ($question_comment_viewauthor==1) { + $sql = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]' AND uid='$global_user_id'"); + } else { + $sql = sisplet_query("SELECT * FROM post WHERE 1 = 0"); + } + $row = mysqli_fetch_array($sql); + $row['count']--;//1. je default comment + } + + // Poglej komentarje + if ($admin_type <= $question_comment_viewadminonly || $question_comment_viewauthor==1) { + echo '   '; + echo ' '; + } + } + + // komentarji respondentov + if (($question_resp_comment==1) AND ($admin_type <= $question_resp_comment_viewadminonly)) { + + echo ' '; + $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_text".$this->db_table." WHERE spr_id='0' AND vre_id='$spremenljivka'"); + $row = mysqli_fetch_array($sql); + + if ($row['count'] > 0) { + echo ''; + echo ' '; + echo $lang['srv_repondent_comment'].' ('.$row['count'].')'; + echo ''; + echo ' '; + } + echo ''; + } + + echo '
    '; + } + + /** + * komentarji na if oz. blok - vrstica se izpise na dnu prikaza ifa oz. bloka + * + * @param mixed $if_id (id ifa ali bloka) + * @param mixed $block (ali gre za if ali blok) + */ + function if_komentarji ($if_id, $block=0) { + global $lang; + global $admin_type; + global $global_user_id; + + SurveySetting::getInstance()->Init($this->anketa); + $question_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment'); + + $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly'); + $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor'); + + if (!($admin_type <= $question_comment && $question_comment!='')) return; + if ($_GET['a'] == 'komentarji') return; // v komentarjih tut ne izpisujemo te vrstice + + // komentarji na if ali blok + if ($admin_type <= $question_comment && $question_comment != '') { + + // Dodaj komentar + echo ' '; + //echo ''.$lang['srv_question_comment'].' '; + echo ' '; + echo $lang['srv_add_comment']; + echo ''; + echo ' '; + + $row = Cache::srv_if($if_id); + if ($row['thread'] == 0) { + $row['count'] = 0; + } else { + if ($admin_type <= $question_comment_viewadminonly) { + $sql = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]'"); + } elseif ($question_comment_viewauthor==1) { + $sql = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]' AND uid='$global_user_id'"); + } else { + $sql = sisplet_query("SELECT * FROM post WHERE 1 = 0"); + } + $row = mysqli_fetch_array($sql); + $row['count']--;//1. je default comment + } + + // Poglej komentarje + if ($admin_type <= $question_comment_viewadminonly || $question_comment_viewauthor==1) { + echo '   '; + echo ' '; + } + } + } + + /** + * @desc prikaze uvod ali zakljucek (pri razsirjenem nacinu) + */ + function introduction_conclusion ($id, $editmode = 0) { + global $lang; + global $site_path, $site_url; + + SurveyInfo :: getInstance()->resetSurveyData(); + $row = SurveyInfo::getInstance()->getSurveyRow(); + + if ( $this->lang_id != null ) { + $l = $lang; // survey nam povozi lang.. + + include_once('../../main/survey/app/global_function.php'); + if (empty($this->Survey->get)) + $this->Survey = new \App\Controllers\SurveyController(true); + + $lang = $l; + save('lang_id', $this->lang_id); + $rowl = \App\Controllers\LanguageController::srv_language_spremenljivka($id); + if ($id == -1) { + if (strip_tags($rowl['naslov']) != '') $row['introduction'] = $rowl['naslov']; + } else { + if (strip_tags($rowl['naslov']) != '') $row['conclusion'] = $rowl['naslov']; + } + } + + //uvod + if ($id == -1) { + if ($row['introduction'] == '') { + SurveyInfo::getInstance()->SurveyInit($this->anketa); + $lang_admin = SurveyInfo::getInstance()->getSurveyColumn('lang_admin'); + $lang_resp = SurveyInfo::getInstance()->getSurveyColumn('lang_resp'); + + // nastavimo na jezik za respondentov vmesnik + if ($this->lang_id == null) { + if ($lang_resp > 0) { + $file = '../../lang/'.$lang_resp.'.php'; + @include($file); + } + } + + $text = '

    '.$lang['srv_intro'].'

    '; + + // nastavimo nazaj na admin jezik + if ($this->lang_id == null) { + if ($lang_admin > 0) { + $file = '../../lang/'.$lang_admin.'.php'; + @include($file); + } + } + + } else { + $text = $row['introduction']; + } + $show = $row['show_intro']; + $opomba = $row['intro_opomba']; + $selectall = $lang['srv_intro']; + } + //statistika + elseif($id == -3) { + $gl = new Glasovanje($this->anketa); + $gl->edit_statistika($editmode); + return 0; + } + //zakljucek + else{ + if ($row['conclusion'] == '') { + SurveyInfo::getInstance()->SurveyInit($this->anketa); + $lang_admin = SurveyInfo::getInstance()->getSurveyColumn('lang_admin'); + $lang_resp = SurveyInfo::getInstance()->getSurveyColumn('lang_resp'); + + // nastavimo na jezik za respondentov vmesnik + if ($this->lang_id == null) { + if ($lang_resp > 0) { + $file = '../../lang/'.$lang_resp.'.php'; + @include($file); + } + } + + $text = '

    '.$lang['srv_end'].'

    '; + + // nastavimo nazaj na admin jezik + if ($this->lang_id == null) { + if ($lang_admin > 0) { + $file = '../../lang/'.$lang_admin.'.php'; + @include($file); + } + } + } else { + $text = $row['conclusion']; + } + $show = $row['show_concl']; + $opomba = $row['concl_opomba']; + $selectall = $lang['srv_end']; + } + + echo '
    '."\n\r"; + if ($editmode == 0) { + // <-- Zgornja vrstica pri editiranju vprasanj --- + echo '
    '; + echo '
    '; + // variabla + echo '
    '; + echo ($id == -1) ? $lang['srv_intro_label'] : $lang['srv_end_label']; + echo '
    '."\n\r"; + echo '
    '; + + // prikažemo nastavitve vprasanja + $fullscreen = ( isset($_POST['fullscreen']) && $_POST['fullscreen'] != 'undefined') ? (int)$_POST['fullscreen'] : false; + echo '
    '."\n\r"; + + if ($id == -1) { + $show = $row['show_intro']; + } else { + $show = $row['show_concl']; + } + + if ($show != 1) { + echo '
    ' . $lang['srv_visible_off'] .'
    '; + } + + echo '
    '; + + echo '
    '; + echo '
    '; + // --- Zgornja vrstica pri editiranju vprasanj --> + + // <-- Editor teksta vprasanja --- + echo '
    '; + echo '
    '.$text.'
    '; + echo '
    '; + + echo ''; + + // opomba + if ($opomba != '' && $this->lang_id == null) { + echo ''; + echo ''; + echo ''; + echo '
    '.$lang['note'].' ('.$lang['srv_internal'].'):'; + echo ''.$opomba.''; + echo '
    '; + } + echo '
    '; + // --- Editor teksta vprasanja --> + + echo '
    '; + + } else { // urejanje uvoda,zakljucka + + // <-- Zgornja vrstica pri editiranju vprasanj --- + echo '
    '; + echo '
    '; + // variabla + echo '
    '; + echo ($id == -1) ? $lang['srv_intro_label'] : $lang['srv_end_label']; + echo '
    '."\n\r"; + echo '
    '; + + // prikažemo nastavitve vprasanja + $fullscreen = ( isset($_POST['fullscreen']) && $_POST['fullscreen'] != 'undefined') ? (int)$_POST['fullscreen'] : false; + echo '
    '."\n\r"; + echo ' '; + //$this->introconcl_visible($id); + echo ' '."\n\r"; + echo '
    '; + + if (!$fullscreen) { + // right spremenljivka icon menu + echo '
    '."\n\r"; + echo ' '.$lang['srv_preglejspremenljivko'].''."\n\r"; + echo ' '.$lang['srv_editirajspremenljivko_fs'].''."\n\r"; + echo ' '.$lang['srv_predogled_spremenljivka'].''."\n\r"; + echo '
    '."\n\r"; + } + echo '
    '; + echo '
    '; + // --- Zgornja vrstica pri editiranju vprasanj --> + + echo '
    '."\n\r"; + // <-- Editor teksta vprasanja --- + + echo '
    '; + + echo '
    '; + echo ''; + echo '
    '; + echo ''; + echo '
    '; + + // opomba + echo ''; + echo ''; + echo ''; + echo '
    '.$lang['note'].' ('.$lang['srv_internal'].'):'; + echo ''; + echo '
    '; + + echo ''; + + echo '
    '; + + echo '
    '; + // --- Editor teksta vprasanja --> + + if ($id == -2) { + $text = $row['text']; + if ($row['url'] != '') + $url = $row['url']; + else + $url = $site_url; + + echo '
    '; + + echo '

    '.$lang['srv_concl_link'].'

    '; + + echo '
    '; + //echo '


    '."\n\r"; + echo '

    '."\n\r"; + echo '
    '; + + echo '

    '.$lang['srv_concl_back_button_show'].'

    '; + + echo ''; + echo '
    '; + } + + //pri formi in glasovanju gumb potrdi refresha stran + if($row['survey_type'] == 1 || $row['survey_type'] == 0){ + echo '
    '; + echo ' '; + echo '
    '; + echo '
    '; + } + else{ + echo '
    '; + echo ' '; + echo '
    '; + echo '
    '; + } + } + echo '
    '."\n\r"; + } + + /** + * @desc prikaze uvod ali zakljucek (pri razsirjenem nacinu) + */ + function gdpr_introduction () { + global $lang; + global $site_path, $site_url; + + $text = GDPR::getSurveyIntro($this->anketa); + $text = str_replace('h3', 'b', $text); + + echo '
    '."\n\r"; + + + // <-- Zgornja vrstica pri editiranju vprasanj --- + echo '
    '; + echo '
    '; + // variabla + echo '
    '; + echo $lang['srv_gdpr_survey_gdpr_1ka_template_title']; + echo '
    '."\n\r"; + echo '
    '; + + echo '
    '; + + echo '
    '; + // --- Zgornja vrstica pri editiranju vprasanj --> + + + // <-- Editor teksta vprasanja --- + echo '
    '; + echo '
    '.$text.'
    '; + echo '
    '; + + echo '
    '; + // --- Editor teksta vprasanja --> + + + echo '
    '; + + + // Da/ne variable + echo '
    '; + + echo '
    '; + echo ' '; + echo ' '; + echo ' '; + echo '
    '.$lang['srv_gdpr_intro_no'].'
    '; + echo '
    '; + + echo '
    '; + echo ' '; + echo ' '; + echo ' '; + echo '
    '.$lang['srv_gdpr_intro_yes'].'
    '; + echo '
    '; + + echo '
    '; + + echo '
    '; + + + echo '
    '."\n\r"; + } + + + /** + * vrne parente elementa + * + * @param mixed $spr + * @param mixed $if + */ + var $get_parents = array(); + function get_parents ($spr=0, $if=0) { + + if (isset($this->get_parents[$spr][$if])) + return $this->get_parents[$spr][$if]; + + $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr='$spr' AND element_if='$if'"); + $row = mysqli_fetch_array($sql); + + if ($row['parent'] == 0) { + $this->get_parents[$spr][$if] = ''; + + } else { + $this->get_parents[$spr][$if] = $this->get_parents(0, $row['parent']); // rekurzija + + if ($this->get_parents[$spr][$if] != '') $this->get_parents[$spr][$if] .= ' '; // presledek + + $this->get_parents[$spr][$if] .= 'p_'.$row['parent']; // trenutni element + } + + return $this->get_parents[$spr][$if]; + } + + /** + * @desc prikaze link za page breake + */ + function pagebreak_display ($spremenljivka) { + global $lang; + + if ($this->pagebreak($spremenljivka)) + echo ''; + else + echo ''; + } + + + /** + * @desc prikaze pogoje v IFu + */ + function conditions_display($if, $long_alert=0, $notranji_pogoj=0) { + global $lang; + + $row_if = Cache::srv_if($if); + + if ($row_if['tip'] != 0) return; + + // če gre za notranji pogoj prikažemo zvezdico + echo ''.(($notranji_pogoj == 1)?'*' : '').'IF'; + + if (true || $long_alert == 0) { + echo ' ('.$row_if['number'].') '; + } + + if ($long_alert == 0) { + + if ($row_if['enabled'] == 1) { + echo 'TRUE'; + echo ' ( '; + } + elseif ($row_if['enabled'] == 2) { + echo 'FALSE'; + echo ' ( '; + } + } + + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $spr_id=0; + $bracket = 0; + $c = 0; + while ($row = mysqli_fetch_array($sql)) { + + if ($row['spr_id'] != 0) $spr_id = $row['spr_id']; + + echo ''; + if ($c++ != 0) + if ($row['conjunction'] == 0) + echo ' AND '; + else + echo ' OR '; + + if ($row['negation'] == 1) + echo ' NOT '; + echo ''; + + for ($i=1; $i<=$row['left_bracket']; $i++) + if ($long_alert == 1) + echo ' ( '; + else + echo ' ( '; + + // obicajne spremenljivke + if ($row['spr_id'] > 0) { + + $row2 = Cache::srv_spremenljivka($row['spr_id']); + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + $row1 = Cache::srv_spremenljivka($row['spr_id']); + // multigrid + } elseif ($row['vre_id'] > 0) { + $sql1 = sisplet_query("SELECT variable FROM srv_vrednost WHERE id = '$row[vre_id]'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + } else + $row1 = null; + + if (true || $long_alert) echo ''; + echo $row1['variable']; + if (true || $long_alert) echo ''; + + // radio, checkbox, dropdown in multigrid + if (($row2['tip'] <= 3 || $row2['tip'] == 6 || $row2['tip'] == 16) && ($row['spr_id'] || $row['vre_id'])) { + + if ($row['operator'] == 0) + echo ' = '; + else + echo ' ≠ '; + + echo '['; + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + $sql2 = sisplet_query("SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id ORDER BY v.vrstni_red"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row2 = mysqli_fetch_array($sql2)) { + if ($j++ != 0) echo ', '; + + if($row2['vre_id'] == '-1') + echo '-1'; + else + echo $row2['variable']; + } + // multigrid + } elseif ($row['vre_id'] > 0) { + + $j = 0; + + // Preverimo pogoj -1 + $sqlX = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$row[id]' AND grd_id='-1'"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + if(mysqli_num_rows($sqlX) > 0){ + echo '-1'; + $j++; + } + + $sql2 = sisplet_query("SELECT g.* FROM srv_condition_grid c, srv_grid g WHERE c.cond_id='$row[id]' AND c.grd_id=g.id AND g.spr_id='$row[spr_id]' ORDER BY g.part, g.vrstni_red"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + while ($row2 = mysqli_fetch_array($sql2)) { + if ($j++ != 0) echo ', '; + + echo $row2['variable']; + } + } + + echo ']'; + + // razvrscanje + } elseif ($row2['tip'] == 17) { + + if ($row['operator'] == 0) + echo ' = '; + else + echo ' ≠ '; + + echo '['; + + $sql2 = sisplet_query("SELECT * FROM srv_condition_grid c WHERE c.cond_id='$row[id]'"); + + $j = 0; + while ($row2 = mysqli_fetch_array($sql2)) { + if ($j++ != 0) echo ', '; + echo $row2['grd_id']; + } + + echo ']'; + + // textbox in number mata drugacne pogoje in opcije + } elseif ( in_array($row2['tip'], array(4, 21, 7, 8, 22, 19, 20, 18)) ) { + + if ($row2['tip'] == 19 || $row2['tip'] == 20) { + echo '['.$row['grd_id'].']'; + } elseif ($row2['tip'] == 7) { + echo '['.($row['grd_id']+1).']'; + } elseif ($row2['tip'] == 8) { + echo '['.($row['grd_id']+1).']'; + } + + if ($row['operator'] == 0) + echo ' = '; + elseif ($row['operator'] == 1) + echo ' ≠ '; // echo ' != '; + elseif ($row['operator'] == 2) + echo ' < '; + elseif ($row['operator'] == 3) + echo ' <= '; + elseif ($row['operator'] == 4) + echo ' > '; + elseif ($row['operator'] == 5) + echo ' >= '; + elseif ($row['operator'] == 6) + echo ' length = '; + elseif ($row['operator'] == 7) + echo ' length < '; + elseif ($row['operator'] == 8) + echo ' length > '; + + #vrednost pogoja + echo '\''.$row['text'].'\''; + } + + // recnum + } elseif ($row['spr_id'] == -1) { + + //echo 'mod(recnum, '.$row['modul'].') = '.$row['ostanek']; + echo ''.$lang['group'].' ('.$row['modul'].') = '.($row['ostanek'] + 1); + + // calculation + } elseif ($row['spr_id'] == -2) { + + echo ' ( '.$this->calculations_display($row['id']).' ) '; + + if ($row['operator'] == 0) + echo ' = '; + elseif ($row['operator'] == 1) + echo ' ≠ '; //echo ' != '; + elseif ($row['operator'] == 2) + echo ' < '; + elseif ($row['operator'] == 3) + echo ' <= '; + elseif ($row['operator'] == 4) + echo ' > '; + elseif ($row['operator'] == 5) + echo ' >= '; + + echo ''.$row['text'].''; + + // kvote + } elseif ($row['spr_id'] == -3) { + + $SQ = new SurveyQuotas($this->anketa); + echo ' ( '.$SQ->quota_display($row['id']).' ) '; + + if ($row['operator'] == 0) + echo ' = '; + elseif ($row['operator'] == 1) + echo ' ≠ '; //echo ' != '; + elseif ($row['operator'] == 2) + echo ' < '; + elseif ($row['operator'] == 3) + echo ' <= '; + elseif ($row['operator'] == 4) + echo ' > '; + elseif ($row['operator'] == 5) + echo ' >= '; + + echo ''.$row['text'].''; + + // naprava + } elseif ($row['spr_id'] == -4) { + + if(in_array($row['text'], array('0','1','2','3'))) + echo ''.$lang['srv_device'].' = '.$lang['srv_para_graph_device'.$row['text']]; + else + echo ''.$lang['srv_device'].' = '.$lang['srv_device_type_select']; + } + + for ($i=1; $i<=$row['right_bracket']; $i++) + if ($long_alert == 1) + echo ' ) '; + else + echo ' ) '; + + } + //echo ''; + + if ($row_if['label'] != '') { + echo ' ('; + echo ' '.$row_if['label'].' '; + echo ') '; + + } + + $condition_check = $this->condition_check($if); + + if ($long_alert) { + if ($c == 1 && $spr_id == 0) + if ($this->count_spr_in_if($if) > 1) { + echo ''.$lang['srv_edit_condition_question'].''; + } else { + $spr = $this->find_first_in_if($if); + $r = Cache::srv_spremenljivka($spr); + if (!$spr > 0) $r['variable'] = ''; + echo ''.sprintf($lang['srv_edit_condition_question1'], ''.$r['variable'].'').''; + } + //if ($condition_check >= 1 && $condition_check <= 5 ) { + echo ''; + if ($condition_check == 1) + echo ' '.$lang['srv_error_oklepaji'].''; + if ($condition_check == 2) { + if (mysqli_num_rows($sql) > 1) // ko nardimo nov if, ne prikazemo takoj errorja + echo ' '.$lang['srv_error_spremenljivka'].''; + } elseif ($condition_check == 3) + echo ' '.$lang['srv_error_vrednost'].''; + if ($condition_check == 4) + echo ' '.$lang['srv_error_numericno'].''; + if ($condition_check == 5) + echo ' '.$lang['srv_error_calculation'].''; + if ($condition_check == 6) + echo ' '.$lang['srv_error_date'].''; + echo ''; + //} + + } else { + if ($condition_check != 0) + echo ' '.$lang['srv_if_error'].''; + + } + + if ($long_alert == 0) { + if ($row_if['enabled'] == 1) { + echo ' )'; // span class="if_comment" + } elseif ($row_if['enabled'] == 2) { + echo ' )'; // span class="if_comment" + } + } + + + } + + function loop_display ($if) { + global $lang; + + if ($if == 0) return; + $rowb = Cache::srv_if($if); + //začetek oklepaja za ZANKO + + echo 'LOOP ('.$rowb['number'].')'; + + $sql = sisplet_query("SELECT l.spr_id, s.variable FROM srv_loop l, srv_spremenljivka s WHERE l.if_id='$if' AND l.spr_id=s.id"); + $row = mysqli_fetch_array($sql); + + if ($row['spr_id'] == 0) return; + + $spr = Cache::srv_spremenljivka($row['spr_id']); + + echo ' '.$row['variable'].' for ['; + + if ($spr['tip'] == 7) { + + echo 'value'; + + } else { + + $i = 0; + $sql1 = sisplet_query("SELECT v.variable FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($i++ != 0) echo ', '; + echo strip_tags($row1['variable']); + } + + } + + echo ']'; + + echo ($rowb['label']!=''?' ( '.$rowb['label'].' )':'').''; + + if ( $this->find_parent_loop(0, $if) > 0 ) { + echo ''; + echo ' '; + echo ''; + } + } + + function blocks_display ($if) { + global $lang; + + if ($if == 0) return; + + $rowb = Cache::srv_if($if); + + if ($rowb['tip'] != 1) return; + + echo 'BLOK ('.$rowb['number'].')'; + + if($rowb['label'] != '') + echo ' '.$rowb['label'].''; + } + + /** + * preveri za celo anketo, če so vsi pogoji OK + * + */ + //public $check_pogoji_id; + function check_pogoji () { + + // najprej gremo cez vse ife + $sql = sisplet_query("SELECT element_if FROM srv_branching WHERE ank_id = '$this->anketa' AND element_if > 0 ORDER BY vrstni_red"); + while ($row = mysqli_fetch_array($sql)) { + $condition_check = $this->condition_check($row['element_if']); + if ($condition_check != 0) { + //$this->check_pogoji_id = $row['element_if']; + //return $condition_check; + return array('type' => 'if', 'code' => $condition_check, 'id' => $row['element_if']); + } + } + + // potem moramo it se cez vse podife na vrednostih spremenljivk + $sql = sisplet_query("SELECT v.if_id, s.id FROM srv_vrednost v, srv_spremenljivka s, srv_grupa g WHERE v.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='$this->anketa' AND v.if_id > '0' ORDER BY g.vrstni_red, s.vrstni_red, v.vrstni_red"); + while ($row = mysqli_fetch_array($sql)) { + $condition_check = $this->condition_check($row['if_id']); + if ($condition_check != 0) { + //$this->check_pogoji_id = $row['id']; + //return $condition_check + 10; + return array('type' => 'podif', 'code' => $condition_check, 'id' => $row['id']); + } + } + + // in pa mogoce se cez spremenljivke tipa kalkulacija ? + // TODO maybe + + return true; + } + + /** + * preveri celo anketo, ce so loopi pravilno postavljeni + * gleda pa to, da loopi niso vgnezdeni en znotraj drugega + * za PB ne rabimo preverjat, ker se delajo ze sproti v check_loop() + * + */ + function check_loops () { + + // vseeno se enkrat popravimo pagebreake... + $this->check_loop(); + + $sql = sisplet_query("SELECT b.element_spr, b.element_if FROM srv_branching b, srv_if i WHERE b.ank_id='$this->anketa' AND b.element_if > '0' AND b.element_if=i.id AND i.tip='2' ORDER BY b.vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + + // trenutni loop ima nekega parenta ki je tudi loop + if ( $this->find_parent_loop($row['element_spr'], $row['element_if']) > 0 ) { + + return array('type' => 'loop', 'code' => '6', 'id' => $row['element_if']); + + } + + } + + return true; + } + + /** + * preveri za celo anketo, če so vse validacije OK + * + */ + function check_validation () { + + // najprej gremo cez vse ife + $sql = sisplet_query("SELECT if_id, spr_id FROM srv_validation v, srv_branching b WHERE v.spr_id=b.element_spr AND b.ank_id='$this->anketa' AND b.element_spr > 0 ORDER BY b.vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + $condition_check = $this->condition_check($row['if_id']); + if ($condition_check != 0) { + //$this->check_pogoji_id = $row['element_if']; + //return $condition_check; + return array('type' => 'validation', 'code' => $condition_check, 'id' => $row['spr_id']); + } + } + + return true; + } + + /** + * preveri, da se imena spremenljivk (vprašanj) v anketi in imena variabel znotraj vprasanja ne ponavljajo + * + */ + function check_variable () { + + $spremenljivke = array(); + $vrednosti = array(); + $spr_errors = array(); + $var_errors = array(); + + // Napolnimo array z vprasanji + $sql = sisplet_query("SELECT s.id, s.variable FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa'"); + while ($row = mysqli_fetch_array($sql)) { + $spremenljivke[$row['id']] = $row['variable']; + + // Napolnimo array z variablami znotraj vprasanj + $sqlV = sisplet_query("SELECT id, variable FROM srv_vrednost WHERE spr_id='".$row['id']."'"); + while ($rowV = mysqli_fetch_array($sqlV)) { + $vrednosti[$row['id']][$rowV['id']] = $rowV['variable']; + } + } + + $vars = array(); + + // Preverimo in izpišemo napake za imena vprasanj (spremenljivk) + if ( count($spremenljivke) != count(array_unique($spremenljivke)) ) { + $sql = sisplet_query("SELECT variable FROM srv_spremenljivka s, srv_grupa g WHERE gru_id=g.id and g.ank_id='$this->anketa' GROUP BY variable HAVING COUNT(variable) > 1"); + + while ($row = mysqli_fetch_array($sql)) { + $vars[] = $row['variable']; + } + + $spr_errors['type'] = 'question_variable'; + $spr_errors['code'] = '7'; + $spr_errors['vars'] = $vars; + } + + // Preverimo in izpišemo napake se za imena variabel znotraj vprasanj - ce je vklopljen modul kviz, dovolimo iste vrednosti + if(!SurveyInfo::getInstance()->checkSurveyModule('quiz')){ + foreach($vrednosti as $spr_id => $vrednost){ + + if ( count($vrednost) != count(array_unique($vrednost)) ) { + $sql = sisplet_query("SELECT variable FROM srv_vrednost WHERE spr_id='".$spr_id."' GROUP BY variable HAVING COUNT(variable) > 1"); + + while ($row = mysqli_fetch_array($sql)) { + $vars[] = $spremenljivke[$spr_id] . ' - ' . $row['variable']; + } + + $var_errors['type'] = 'variable'; + $var_errors['code'] = '7'; + $var_errors['vars'] = $vars; + } + } + } + + /*if(count($spr_errors)) + return $spr_errors;*/ + + if(count($var_errors)) + return $var_errors; + + return true; + } + + + /** + * @desc preveri ali je IF pravilno nastavljen + * error code: 0 - ok + * 1 - oklepaji so narobe + * 2 - spremenljivka ni postavljena + * 3 - spremenljivka nima vrednosti nastavljene + * 4 - number vrednost ni nastavljena + * 5 - kalkulacija ni v redu postavljena + * 6 - datum ni v pravilni obliki + */ + function condition_check ($if) { + + $row = Cache::srv_if($if); + + if ($row['tip'] == 1 || $row['tip'] == 2) return 0; // ce je blok je vse ok, ker ne more biti narobe nastavljen + + if ( !$this->condition_check_bracket($if)) + return 1; + + if (!$this->condition_check_spremenljivka($if)) + return 2; + + if (!$this->condition_check_spremenljivka_vre($if)) + return 3; + + if (!$this->condition_check_number($if)) + return 4; + + if (!$this->condition_check_calculation($if)) + return 5; + + if (!$this->condition_check_date($if)) + return 6; + + if (!$this->condition_check_device($if)) + return 7; + + return 0; + + } + + /** + * za podani IF preveri, ce ima pravilno nastavljene vse kalkulacije + * + * @param int $if + */ + function condition_check_calculation ($if) { + + $sql1 = Cache::srv_condition($if); + while($row1 = mysqli_fetch_array($sql1)) { + if ($row1['spr_id'] == '-2') { + if ( $this->calculation_check($row1['id']) != 0 ) + return false; + } + } + return true; + } + + /** + * @desc preveri ali so oklepaji pravilno postavljeni (presteje predoklepaje in zaklepaje) + */ + function condition_check_bracket ($if) { + + //$sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id='$if' ORDER BY vrstni_red"); + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $bracket = 0; + while ($row = mysqli_fetch_array($sql)) { + $bracket = $bracket + $row['left_bracket'] - $row['right_bracket']; + if ($bracket < 0) + return false; + } + + if ($bracket == 0) + return true; + else + return false; + } + + /** + * @desc preveri ali imajo vsi pogoji izbrane spremenljivke + */ + function condition_check_spremenljivka ($if) { + + //$sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id='$if'"); + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + if (!($row['spr_id'] > 0 || $row['spr_id'] == -1 || $row['spr_id'] == -2 || $row['spr_id'] == -3 || $row['spr_id'] == -4)) + return false; + } + + return true; + } + + /** + * @desc preveri ali imajo vse spremenljivke izbrane vrednosti + */ + function condition_check_spremenljivka_vre ($if) { + + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + if ($row['spr_id'] > 0) { + + $row1 = Cache::srv_spremenljivka($row['spr_id']); + + if ($row['vre_id'] == 0) { + + if ($row1['tip'] <= 3) { + + $sql2 = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id='$row[id]'"); + if (mysqli_num_rows($sql2) == 0) + return false; + + } + + } elseif ($row['vre_id'] > 0) { + // tabela radio, tabela checkbox + if ($row1['tip'] == 6 || $row1['tip'] == 16 || $row1['tip'] == 17) { + $sql2 = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$row[id]'"); + if (mysqli_num_rows($sql2) == 0) + return false; + + // textbox + } else { + // ok... besedilo ima samo polje za vnos, ki pa je lahko prazno + } + + } + } + } + + return true; + } + + /** + * @desc preveri ali imajo datumi pravilno obliko + */ + function condition_check_date ($if) { + + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) + { + if ($row['spr_id'] > 0) + { + $row1 = Cache::srv_spremenljivka($row['spr_id']); + if ($row1['tip'] == 8) { + if (empty($row['text']) || trim($row['text']) == '') + { + return false; + } + else if ((int)$row['text'] <= 0) + { + return false; + } + else + { + #preverimo obliko datuma + $fields = explode('.',$row['text']); + if (!is_numeric($fields[0]) || (int)$fields[0] == 0 + || !is_numeric($fields[1]) || (int)$fields[1] == 0 + || !is_numeric($fields[2]) || (int)$fields[2] == 0) + { + return false; + } + return checkdate((int)$fields[1],(int)$fields[0],(int)$fields[2]); + } + + } + } + } + + return true; + } + + /** + * @desc preveri ali je naprava ustrezno nastavljena + */ + function condition_check_device ($if) { + + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + if ($row['spr_id'] == -4 && !in_array($row['text'], array('0','1','2','3'))){ + return false; + } + } + + return true; + } + + /** + * @desc preveri ali imajo number polja z numeri�nim operatorjem vpisano �tevilko + */ + function condition_check_number ($if) { + + // number + $sql = sisplet_query("SELECT c.* FROM srv_condition c, srv_spremenljivka s WHERE s.id=c.spr_id AND s.tip IN (7, 18, 20) AND c.if_id='$if'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + + if ( ! (is_numeric($row['text']) || $row['text'] == '') ) + return false; + } + + // calculation + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + if ($row['spr_id'] == -2) { + if (!is_numeric($row['text'])) + return false; + } + } + + return true; + + } + + /** + * @desc preveri ali so oklepaji pravilno postavljeni v kalkulacijah (presteje predoklepaje in zaklepaje) + * in pa ce je izbrana spremenljivka + */ + function calculation_check ($condition) { + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id='$condition' ORDER BY vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + if (mysqli_num_rows($sql) == 0) return 1; // ni sploh se izbrana spremenljivka (ker ni calculation sploh se inicializiran z default vrstico) + + $bracket = 0; + while ($row = mysqli_fetch_array($sql)) { + if ($row['spr_id'] == 0) // ce ni izbrana spremenljivka v eni od vrstic + return 2; + + $bracket = $bracket + $row['left_bracket'] - $row['right_bracket']; + if ($bracket < 0) + return 3; // oklepaj + } + + if ($bracket == 0) + return 0; // vse ok + else + return 3; // zaklepaj + } + + /** + * @desc izpise form za urejanje pogojev + * @param int ID ifa, ki mu urejamo pogoje + * @param int Pri urejanju podifov (na multigridih, radio,..) podamo tudi ID vrednosti na katero se if navezuje + */ + function condition_editing ($if, $vrednost=0, $edit_fill_value=0) { + global $lang; + + // Pogoj na vrednost + if($vrednost > 0){ + echo '

    '.$lang['urejanje_pogoj_popup_vrednost'].'

    '; + echo ''; + + echo ''.$lang['urejanje_podif_alert'].''; + + echo '

    '; + + $sql = sisplet_query("SELECT naslov FROM srv_vrednost WHERE id='$vrednost'"); + $row = mysqli_fetch_assoc($sql); + echo '
    '.$row['naslov'].'
    '; + } + // Pogoj pri npr. obvescanju + elseif($vrednost == -3){ + echo '

    '.$lang['urejanje_pogoj_popup'].'

    '; + echo ''; + } + // Validacija + elseif($vrednost == -4){ + echo '

    '.$lang['urejanje_pogoj_popup_validacija'].'

    '; + echo ''; + } + + $row = Cache::srv_if($if); + + // osnovni okvir vsebine, ce prebije visino dobi scroolbar + echo '
    '; + echo '
    '; + + $this->condition_editing_inner($if, $vrednost, $edit_fill_value); + + echo '
    '; + echo '
    '; + + echo '
    '; + //echo '
    '; + echo '
    '; + + + // gumbi na desni v novem oknu + if ($vrednost==0) { + + // floating box + echo '
    '; + + if ($row['tip'] == 0) + echo '

    '.$lang['oblikovanje_if'].'

    '; + elseif ($row['tip'] == 1) + echo '

    '.$lang['oblikovanje_blok'].'

    '; + elseif ($row['tip'] == 2) + echo '

    '.$lang['srv_loop_urejanje'].'

    '; + + if ($row['tip'] == 0) + echo '

    '.$lang['srv_edit_condition_question'].'

    '; + elseif ($row['tip'] == 1) + echo '

    '.$lang['srv_block_desc'].'

    '; + + if ($vrednost != -1 && $vrednost != -2) { + echo '

    '; + echo ($row['tip']==0?$lang['srv_if_label']:($row['tip']==1?$lang['srv_block_label']:$lang['srv_loop_label'])).':'; + echo ''; + echo '

    '; + + echo ''; + + } + + if ($row['tip'] == 0 || $row['tip'] == 1) { + + echo '
    '; + + echo '

    '.($row['tip'] == 1 ? $lang['srv_block_enabled'] : $lang['srv_if_enabled']).':'; + + echo''; + echo ''; + if ($row['tip'] == 0) + echo ''; + echo ''; + echo ''; + + echo '

    '; + + echo '
    '; + } + + // Posebna nastavitev vrednosti statusa panelista ce je vklopljen modul "panel" + if ($row['tip'] == 0 && SurveyInfo::getInstance()->checkSurveyModule('panel')) { + + echo '
    '; + echo '

    '.$lang['srv_panel_if'].':'; + + $sp = new SurveyPanel($this->anketa); + $panel_if = $sp->getPanelIf($if); + + echo''; + echo ''; + echo ''; + + echo ''; + + echo '

    '; + echo '
    '; + } + + if ($row['tip'] == 1) { + + echo '
    '; + + // Blok ki prikaze nakljucno razvrscena vprasanja (in samo doloceno stevilo) + echo '

    '; + echo ' '.$lang['srv_block_random'].': '.Help::display('srv_block_random'); + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '

    '; + + // Stevilo vprasanj ki jih nakljucno izberemo (ce je zgornja "da") + echo '

    = 0) ? '' : ' style="display:none;"').'>'.$lang['srv_block_random_cnt'].':'; + echo ''; + + // Blok ki vsebuje horizontalno urejena vprasanja + echo '

    '.$lang['srv_orientacija_vprasanja'].':'; + echo ''; + echo '

    '; + + // Blok kot zavihek + echo '

    '.$lang['srv_block_tab'].':'; + echo ''; + echo '

    '; + + // Opozorilo, da mora biti blok na svoji strani (ce je vklopljena katera od zgornjih nastavitev) + echo '

    =0 ? '' : ' style="display:none;"').'>'.$lang['srv_block_pbWarning'].'

    '; + + echo '
    '; + } + + + echo ''; + + echo ''; + echo ''.($row['tip'] == 0 ? $lang['srv_if_rem_all'] : ($row['tip']==1?$lang['srv_block_rem_all']:$lang['srv_loop_rem_all']) ).''."\n\r"; + echo ''; + + echo '
    '; + + echo ''; + echo ''.$lang['srv_zapri'].''; + echo ''; + + echo ''; + echo ''.($row['tip'] == 0 ? $lang['srv_if_rem'] : ($row['tip']==1?$lang['srv_block_rem']:$lang['srv_loop_rem']) ).''."\n\r"; + echo ''; + + echo '
    '; // -- div_condition_editing_float + + } + // filter v DisplayData + elseif ($vrednost == -1) { + // tega niti ni vec... + } + // profili filtrov + elseif ($vrednost == -2) { + + } + // klasicen popup v #div_condition_editing, uporablja se npr pri ifih za obvescanje + elseif ($vrednost == -3) { + echo ''; + echo ''.$lang['srv_potrdi'].''; + echo ''; + echo ''; + echo ''.$lang['srv_zapri'].''; + echo ''; + echo ''; + echo ''.$lang['srv_if_rem'].''."\n\r"; + echo ''; + + } + // validacija + elseif ($vrednost == -4) { + echo ''; + echo ''.$lang['srv_potrdi'].''; + echo ''; + echo ''; + echo ''.$lang['srv_zapri'].''; + echo ''; + echo ''; + echo ''.$lang['srv_if_rem'].''."\n\r"; + echo ''; + + } + // filter na vrednosti + else { + echo ''; + echo ''.$lang['srv_potrdi'].''; + echo ''; + echo ''; + echo ''.$lang['srv_zapri'].''; + echo ''; + echo ''; + echo ''.$lang['srv_if_rem'].''."\n\r"; + echo ''; + } + + echo '
    '; + + ?>'; + + //echo '
    '.$lang['sintaksa_if'].'
    '; + + echo '
    '; + echo '
    '; + //zacetni oklepaj za if +// echo ''; + $this->conditions_display($if, 1, 1); + echo '
    '; + echo '
    '; + echo '
    '; + + + echo '
    '; + + $sql1 = Cache::srv_condition($if); + if (!$sql1) { echo mysqli_error($GLOBALS['connect_db']); die('1'); } + + while ($row1 = mysqli_fetch_array($sql1)) { + $this->condition_edit($row1['id'], $vrednost, $edit_fill_value); + $spr_id = $row1['spr_id']; + } + + if ( ! ( mysqli_num_rows($sql1)==1 && $spr_id==0 ) ) { + echo '
    '.$lang['srv_add_cond'].' '.Help::display('srv_if_operator').': + +  AND , +  AND NOT , +  OR , +  OR NOT 
    '; + } + + echo '
    '; + + // blok + } elseif ($row['tip'] == 1) { + + //ko imamo BLOCK prikažemo začetek oklepaja + echo 'BLOCK ('.$row['number'].')'.($row['enabled']==2?' FALSE ':'').($row['label']!=''?' ( '.$row['label'].' )':'').''; + + // zanka + } elseif ($row['tip'] == 2) { + //začetni oklepaj za zanko + + $this->loop_display($if); + + echo ''; + echo '
    '; + + echo '

    '.$lang['srv_loop_desc'].' '.Help::display('DataPiping').'

    '; + + if ( $this->find_parent_loop(0, $if) > 0 ) { + echo '

    '.$lang['srv_loop_no_nesting'].'

    '; + } else { + echo '

    '.$lang['srv_loop_no_nesting'].'

    '; + } + + $this->loop_edit($if); + + echo '
    '; + + if (true) { + $sql = sisplet_query("SELECT count(*) AS count FROM srv_user WHERE ank_id='$this->anketa' AND deleted='0'"); + $row = mysqli_fetch_array($sql); + if ($row['count'] > 10) { + ?>vrstni_red($this->find_before_if($row['if_id'])); + } elseif ($vrednost == -1 or $vrednost == -2 or $vrednost == -3) { // filter v DisplayData.php (prikazemo vse spremenljivke) + $vrstni_red = PHP_INT_MAX; + } elseif ($vrednost == -4) { // validacija + if (!$this->spremenljivka > 0) { + $sqlv = sisplet_query("SELECT spr_id FROM srv_validation WHERE if_id = '$row[if_id]'"); + $rowv = mysqli_fetch_array($sqlv); + $this->spremenljivka = $rowv['spr_id']; + } + $vrstni_red = $this->vrstni_red($this->spremenljivka); + } else { // ce imamo podif na vrednosti + $sqlv = sisplet_query("SELECT spr_id FROM srv_vrednost WHERE if_id='$row[if_id]'"); + $rowv = mysqli_fetch_array($sqlv); + $vrstni_red = $this->vrstni_red($rowv['spr_id']); + } + + $sql_count = sisplet_query("SELECT COUNT(*) AS count FROM srv_condition WHERE if_id='$row[if_id]'"); + if (!$sql_count) die(); + $row_count = mysqli_fetch_array($sql_count); + + if ($row['vrstni_red'] == 1 && $row_count['count'] > 1) { + echo ''; + echo ''; + echo ''; // gumbi oklepaji + echo ''; // logicni operatorji + echo ''; // oklepaji + echo ''; + echo ''; // gumbi zaklepaji + echo ''; // move + echo ''; + echo '
    '.$lang['srv_oklepaji'].'   '.$lang['srv_zaklepaji'].''.$lang['edit2'].'
    '; + + } elseif ($row['vrstni_red'] == 1) { + echo '
     
    '; + } + + // form + echo '
    '."\n\r"; + + echo ''; + echo ''; + + // left_bracket + if ($row_count['count'] != 1 || $row['left_bracket']>0 || $row['right_bracket']>0) { + echo ''; + + + // conjunction + echo ''; + + // display bracket + echo ''; + + // spremenljivka + echo ''; + + + // span, ki se updata ob spremembi spremenljivke + echo ''; + + // display right bracket + echo ''; + + // right_bracket buttons + if ($row_count['count'] != 1 || $row['right_bracket']>0 || $row['left_bracket']>0) { + echo ''; + + + // move + echo ''; + + // remove + echo ''; + + + echo ''; + echo '
    '; + echo ''; + if ($row['left_bracket'] > 0) + echo ''; + else + echo ''; + } else { + echo ''; + } + echo ''; + if ($row['vrstni_red'] == 1) { + echo ''; + + // prikazujemo samo ce je ze izbran not + if ($row['negation']==1) + echo '  not  '; + + } else { + + echo ''; + + if ($row['conjunction']==0 && $row['negation']==0) + echo '  AND  '; + if ($row['conjunction']==1 && $row['negation']==0) + echo '  OR  '; + if ($row['conjunction']==0 && $row['negation']==1) + echo ' AND NOT '; + if ($row['conjunction']==1 && $row['negation']==1) + echo ' OR NOT '; + + } + echo ''; + for ($i=1; $i<=$row['left_bracket']; $i++) echo ' ( '; + echo ''.($row['spr_id']=='0'?''.$lang['srv_select_spr'].'!':'').'
    '; + echo '
     '."\n\r"; + echo '
    '; + + echo ''."\n\r"; + + if ($edit_fill_value == $condition) + $edit_value = true; + else + $edit_value = false; + + // to je zato, da pri kalkulaciji prenesemo naprej nastavitev, a smo v navadnih ifih, profilih ifov ipd, zaradi tistih gumbov spodaj + if ($vrednost < 0 && $row['vre_id'] <= 0 || ($row['spr_id'] == -2 || $row['spr_id'] == -3)) + $row['vre_id'] = $vrednost; + + $this->fill_value($condition, $row['spr_id'], $row['vre_id'], $row['grd_id'], $edit_value); + + echo ''."\n\r"; + echo ''; + if ($row_count['count'] != 1 || $row['right_bracket']>0 || $row['left_bracket']>0) { + for ($i=1; $i<=$row['right_bracket']; $i++) echo ' ) '; + } + echo ''; + + if ($row['right_bracket'] > 0) + echo ''; + else + echo ''; + + echo ''; + } + else { + echo ''; + } + echo ''; + if ($row_count['count'] != 1 ) + echo ''; + echo ''; + if ($row_count['count'] != 1 ) + echo ''."\n"; + echo '
    '; + + echo '
    '."\n\r"; + } + + /** + * @desc napolni select z vrednostmi izbrane spremenljivke -- $vrednost je pa za multigrid + */ + function fill_value($condition, $spremenljivka, $vrednost, $grid=0, $edit_value = false) { + global $lang; + + $sql = sisplet_query("SELECT * FROM srv_condition WHERE id='$condition'"); + $row = mysqli_fetch_array($sql); + + $row1 = Cache::srv_spremenljivka($spremenljivka); + + // navadne spremenljivke (vkljucno z multigrid) + if ($spremenljivka > 0) { + + // zato, da z JS vemo kaj poslat po AJAXu, ID vrednosti ali text + echo ''; + + // operator + echo ' '."\n\r"; + + echo ''; + + // number in textbox, vsota imajo textovni input (ter compute in kvota) + if ($row1['tip'] == 4 || $row1['tip'] == 21 || $row1['tip'] == 7 || $row1['tip'] == 22 || $row1['tip'] == 25 || $row1['tip'] == 18) + { + echo ''; + + echo ''; + + // select input za datum + } else if ( $row1['tip'] == 8){ + + echo ''; + + echo ''; + + // select input za spremenljivke + } else { + // obicajna spremenljivka + if ($vrednost <= 0) { + + echo ''; + echo ''; + + + // multigrid (tuki mamo poleg spremenljivke vrednost, ki oznacuje element) + } elseif ($vrednost > 0) { + + // tabela radio, tabela checkbox + if ($grid == 0) { + + echo ''; + echo ''; + + + // tabela text, tabela stevilo + } else { + + echo ''; + + echo ''; + } + } + } + + // mod recnum + } elseif ($spremenljivka == -1) { + + // zato, da z JS vemo kaj poslat po AJAXu, ID vrednosti ali text + echo ''."\n\r"; + + echo $lang['srv_groups'].': '."\n\r"; + + echo ''; + $this->fill_ostanek($condition); + echo ''."\n\r"; + + // calculation + } elseif ($spremenljivka == -2) { + + // zato, da z JS vemo kaj poslat po AJAXu, ID vrednosti ali text + echo ''."\n\r"; + + $text = $this->calculations_display($condition); + if ($text == '') $text = $lang['srv_editcalculation']; + + echo ' '.$text.' '; + + // operator + echo ' '."\n\r"; + + echo ''; + + echo ''; + + // kvote + } elseif ($spremenljivka == -3) { + + // zato, da z JS vemo kaj poslat po AJAXu, ID vrednosti ali text + echo ''."\n\r"; + + $SQ = new SurveyQuotas($this->anketa); + $text = $SQ->quota_display($condition); + if ($text == '') $text = $lang['srv_edit_quota']; + + echo ' '.$text.' '; + + // operator + echo ' '."\n\r"; + + echo ''; + + echo ''; + + // Naprava + } elseif ($spremenljivka == -4) { + + // zato, da z JS vemo kaj poslat po AJAXu, ID vrednosti ali text + echo ''."\n\r"; + + echo $lang['srv_device_type'].': '."\n\r"; + } + } + + /** + * @desc izpise dropdown za ostanek + */ + function fill_ostanek ($condition) { + global $lang; + + $sql = sisplet_query("SELECT * FROM srv_condition WHERE id='$condition'"); + $row = mysqli_fetch_array($sql); + + echo $lang['srv_group'].': '."\n\r"; + + } + + /** + * prikaze urejanje loopa + * + * @param int $if + */ + function loop_edit ($if) { + global $lang; + + $advanced = false; + + $sqll = sisplet_query("SELECT * FROM srv_loop_vre WHERE if_id='$if' AND tip!='0'"); + if (mysqli_num_rows($sqll) > 0) + $advanced = true; + + if ($_POST['advanced'] == 1) + $advanced = true; + + $sql = sisplet_query("SELECT * FROM srv_loop WHERE if_id='$if'"); + $row = mysqli_fetch_array($sql); + $spremenljivka = $row['spr_id']; + $max = $row['max']; + + $spr = Cache::srv_spremenljivka($spremenljivka); + $tip = $spr['tip']; + + $vrstni_red = $this->vrstni_red($this->find_before_if($if)); + $prev_grupa = 0; + + + echo ''; + + echo ''; + + if (!$advanced && $spremenljivka>0 && ($tip==2 || $tip==3)) { + echo ''; + } + + echo '
    '; + + echo $lang['srv_loop_for'].' '; + + if ($spremenljivka > 0 && ($tip==2 || $tip==3)) + echo $lang['srv_loop_for_when'].(!$advanced?' '.$lang['srv_loop_when_checked']:''); + + echo ''; + + if ($spremenljivka > 0 && ($tip==2 ||$tip==3)) { // spremenljivka je izbrana in ne gre za sn-imena + + if ($advanced) { + echo ''; + } + + $sql2 = sisplet_query("SELECT id, naslov, variable, vrstni_red FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red ASC"); + while ($row2 = mysqli_fetch_array($sql2)) { + + $sql3 = sisplet_query("SELECT * FROM srv_loop_vre WHERE if_id='$if' AND vre_id='$row2[id]'"); + $row3 = mysqli_fetch_array($sql3); + + if ($advanced) { + + if (mysqli_num_rows($sql3) == 0) $row3['tip'] = 3; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + } else { + if (mysqli_num_rows($sql3) > 0) $selected = ' checked'; else $selected = ''; + + echo ''; + echo ''; + echo'
    '; + } + } + + if ($advanced) + echo '
    '.$lang['srv_loop_checked'].''.$lang['srv_loop_notchecked'].''.$lang['srv_loop_always'].''.$lang['srv_loop_never'].'
    ('.$row2['variable'].') '.strip_tags($row2['naslov']).'
    '; + + } elseif ($tip == 7) { // number nima dodatnih nastavitev + } elseif ($tip == 8) { // datum nima dodatnih nastavitev + } elseif ($tip == 9) { //SN-imena - uporabimo vedno vseh 20 vrednosti + } + + echo '
    '.$lang['srv_advanced_options'].'
    '; + + if ($spremenljivka > 0) { + $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka'"); + $count = mysqli_num_rows($sql2); + + if ($tip == 7) { + $count = 20; + if ($max == 0) $max = 20; + } + + echo '

    '.$lang['srv_loop_max'].':

    '; + } + } + + function calculations_display($condition, $long_alert=0) { + global $lang; + + $echo = ''; + $echo .= ''; + + if ($condition < 0) { + $rowC = Cache::srv_spremenljivka($condition < 0 ? -$condition : $condition); + $echo .= $rowC['variable'].' = '; + } + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $bracket = 0; + $i = 0; + while ($row = mysqli_fetch_array($sql)) { + + + if ($i++ != 0) + if ($row['operator'] == 0) + $echo .= ' + '; + elseif ($row['operator'] == 1) + $echo .= ' - '; + elseif ($row['operator'] == 2) + $echo .= ' * '; + elseif ($row['operator'] == 3) + $echo .= ' / '; + + for ($i=1; $i<=$row['left_bracket']; $i++) + if ($long_alert == 1) + $echo .= ' ( '; + else + $echo .= ' ( '; + + // spremenljivke + if ($row['spr_id'] > 0) { + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + $row1 = Cache::srv_spremenljivka($row['spr_id']); + if ($row1['tip'] != 7) { + $variable = $row1['variable']; + // number + } else { + $variable = $row1['variable'].'['.($row['grd_id']+1).']'; + } + // multigrid + } elseif ($row['grd_id'] == 0) { + $sql1 = sisplet_query("SELECT variable FROM srv_vrednost WHERE id = '$row[vre_id]'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + $variable = $row1['variable']; + // multichecckbox, multinumber + } elseif ($row['grd_id'] > 0) { + $sql1 = sisplet_query("SELECT variable FROM srv_vrednost WHERE id = '$row[vre_id]'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + $sql1g = sisplet_query("SELECT * FROM srv_grid WHERE id = '$row[grd_id]'"); + if (!$sql1g) echo mysqli_error($GLOBALS['connect_db']); + $row1g = mysqli_fetch_array($sql1g); + + $variable = $row1['variable'].'['.$row1g['variable'].']'; + } + + if ($long_alert) $echo .= ''; + $echo .= $variable; + if ($long_alert) $echo .= ''; + + // konstante + } elseif ($row['spr_id'] == -1) { + + $echo .= $row['number']; + + // recnum + } elseif ($row['spr_id'] == -2) { + + $echo .= 'Recnum'; + + } + + for ($i=1; $i<=$row['right_bracket']; $i++) + if ($long_alert == 1) + $echo .= ' ) '; + else + $echo .= ' ) '; + + } + + $echo .= ''; + + if ($long_alert) { + $calculation_check = $this->calculation_check($condition); + + if ( $calculation_check != 0) { + + if ($calculation_check == 1) + $echo .= '
    '.$lang['srv_error_spremenljivka'].''; + elseif ($calculation_check == 2) + $echo .= '
    '.$lang['srv_error_spremenljivka'].''; + elseif ($calculation_check == 3) + $echo .= '
    '.$lang['srv_error_oklepaji'].''; + + } + } + + return $echo; + } + + /** + * @desc izpise urejanje kalkulacije + */ + function calculation_editing ($condition, $vrednost=0) { + global $lang; + + echo ''; + + echo '
    '; + $this->calculation_editing_inner($condition, $vrednost); + echo '
    '; + + echo '
    '; + + $row = Cache::srv_spremenljivka(-$condition); + if ($condition < 0) { + echo '

    '.$lang['srv_variable'].':

    '; + } + + // Nastavitev števila decimalk + echo '

    '.$lang['srv_results_num_digits'].':'; + echo ' '; + echo '

    '; + + // Nastavitev kako se obravnava missing v kalkulaciji (kot 0 ali za celo kalkulacijo kot -88) + $newParams = new enkaParameters($row['params']); + $calcMissing = $newParams->get('calcMissing', '0'); + echo '

    '; + echo ' '; + echo ''; + echo ' '.Help::display('srv_calculation_missing'); + echo '

    '; + + echo '
    '; + + // kalkulacija kot spremenljivka (lahko jo zbrisemo) + if ($condition < 0) { + echo ''; + echo ''.$lang['srv_anketadelete_txt'].''; + echo ''; + } + + echo ''; + echo ''.$lang['srv_zapri'].''; + echo ''; + + echo ''; + echo ''.$lang['srv_potrdi'].''; + echo ''; + + echo '
    '; + echo '
    '; + + echo '
    '.$lang['srv_more'].'
    '; + + ?>'; + + echo '

    '.$lang['srv_calc'].'

    '; + echo '
    '; + echo $this->calculations_display($condition, 1); + echo '
    '; + echo '
    '; + + echo '
    '; + echo '

    '.$lang['srv_editcalculation'].'

    '; + echo '
    '; + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red"); + if (mysqli_num_rows($sql) == 0) { + sisplet_query("INSERT INTO srv_calculation (id, cnd_id, vrstni_red) VALUES ('', '$condition', '1')"); + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red"); + } + while ($row = mysqli_fetch_array($sql)) { + + $this->calculation_edit($row['id'], $vrednost); + } + + echo '

    '.$lang['srv_add_cond'].': +  + , +  - , +  * , +  /  +



    '; + + } + + /** + * @desc vrstica v urejanju kalkulacij + */ + function calculation_edit ($calculation, $vrednost=0) { + global $lang; + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE id = '$calculation'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + $sql1 = sisplet_query("SELECT * FROM srv_condition WHERE id = '{$row['cnd_id']}'"); + $row1 = mysqli_fetch_array($sql1); + + if ($row['cnd_id'] > 0) { // kalkulacija znotraj pogoja + $vrstni_red = $this->vrstni_red($this->find_before_if($row1['if_id'])); + } else { // kalkulacija kot spremenljivka + $vrstni_red = $this->vrstni_red(-$row['cnd_id']) - 1; // -1 je da ne prikaze se trenutne kalkulacije + } + + $sql_count = sisplet_query("SELECT COUNT(*) AS count FROM srv_calculation WHERE cnd_id='$row[cnd_id]'"); + if (!$sql_count) die(); + $row_count = mysqli_fetch_array($sql_count); + + if ($row['vrstni_red'] == 1 && $row_count['count'] > 1) { + echo ''; + echo ''; + echo ''; // gumbi oklepaji + echo ''; // logicni operatorji + echo ''; // oklepaji + echo ''; + echo ''; // gumbi zaklepaji + echo ''; // move + echo ''; + echo '
    '.$lang['srv_oklepaji'].'   '.$lang['srv_zaklepaji'].''.$lang['edit2'].'
    '; + + } elseif ($row['vrstni_red'] == 1) { + echo '
     
    '; + } + + // form + echo '
    '."\n\r"; + + echo ''; + echo ''; + + + // left_bracket + if ($row_count['count'] != 1 || $row['left_bracket']>0 || $row['right_bracket']>0) { + + echo ''; + + // operator + echo ''; + + + // left_bracket + echo ''; + + // spremenljivka + echo ''; + + + // right_bracket + echo ''; + + + // right_bracket buttons + if ($row_count['count'] != 1 || $row['right_bracket']>0 || $row['left_bracket']>0) { + echo ''; + + // move + echo ''; + + // remove + echo ''; + + + echo ''; + echo '
    '; + echo ''; + + if ($row['left_bracket'] > 0) + echo ''; + else + echo ''; + } + else { + echo ''; + } + echo ''; + + if ($row['vrstni_red'] == 1) { + // nimamo nic.. + } else { + + if ($row['operator']==0) + echo ' + '; + if ($row['operator']==1) + echo ' - '; + if ($row['operator']==2) + echo ' * '; + if ($row['operator']==3) + echo ' / '; + } + + echo ''; + for ($i=$row['left_bracket']; $i>0; $i--) { + echo ' ( '; } + echo ''; + if ($row['spr_id']==0) echo ''.$lang['srv_select_spr'].'!'; + echo '
    '; + echo ''; + + // number vnos + if ($row['spr_id'] == -1) { + //if ($row['number'] == 0) $row['number'] = ''; + echo ' '; + + echo ''; + + } + + echo '
     '."\n\r"; + echo '
    '; + for ($i=$row['right_bracket']; $i>0; $i--) { + echo ' ) '; + } + echo ''; + if ($row['right_bracket'] > 0) + echo ''; + else + echo ''; + + echo ''; + } else { + echo ''; +// echo ''; +// echo ''; + } + echo ''; + if ($row_count['count'] != 1 ) + echo ''; + echo ''; + $sql3 = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id='$row[cnd_id]'"); + if (mysqli_num_rows($sql3) != 1 ) + echo ' '."\n\r"; + echo '
    '; + + echo '
    '."\n\r"; + + } + + /** + * @desc generira ime variable za novo spremenljivko + */ + function generate_variable ($preset = null) { + + $variable_array = array(); + + + // Dodaten loop po spremenljivkah, ki so znotraj kombinirane tabele (gru_id == -2) + $sql = sisplet_query("SELECT s.id AS id FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.tip='24' ORDER BY g.vrstni_red, s.vrstni_red"); + if(mysqli_num_rows($sql)){ + while ($row = mysqli_fetch_array($sql)) { + $sqlM = sisplet_query("SELECT s.id, s.variable, s.variable_custom FROM srv_spremenljivka s, srv_grid_multiple m + WHERE m.parent='".$row['id']."' AND m.ank_id='$this->anketa' AND s.id=m.spr_id + ORDER BY m.vrstni_red"); + while ($rowM = mysqli_fetch_array($sqlM)) { + $variable_array[$rowM['id']] = $rowM['variable']; + } + } + } + + + $sql = sisplet_query("SELECT s.id, variable, variable_custom FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.tip!='9' ORDER BY g.vrstni_red, s.vrstni_red"); + while ($row = mysqli_fetch_array($sql)) { + $variable_array[$row['id']] = $row['variable']; + } + $i = 1; + do { + if ($preset === null) $preset = 'Q'; + $variable = $preset . $i++; + + $variable_ok = true; + foreach ($variable_array AS $spr => $var) { + if ($spr != $row['id'] && $var == $variable) { + $variable_ok = false; + } + } + } while ( ! $variable_ok ); + + + return $variable; + } + + /** + * @desc preveri ime variable za novo spremenljivko in doda številko če je potrebno + */ + function append_variable ($variable) { + + $variable_array = array(); + + $sql = sisplet_query("SELECT s.id, variable, variable_custom FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.tip!='9' ORDER BY g.vrstni_red, s.vrstni_red"); + + while ($row = mysqli_fetch_array($sql)) { + $variable_array[$row['id']] = $row['variable']; + } + + if ( ! in_array($variable, $variable_array) ) + return $variable; + + $i = 1; + do { + + $variable_new = $variable . $i++; + if ( ! in_array($variable_new, $variable_array) ) + return $variable_new; + + } while ( true ); + + } + + /** + * @desc vpise novo spremenljivko v bazo (lahko je skopirana) + * + * kopiranje je urejeno, da deluje z bazo ver 10.11.24, za nadaljne spremembe je potrebno dodati samo nove tabele, ker se celotna vsebina obstojecih tabel kopira avtomatsko cela + */ + function nova_spremenljivka($grupa, $grupa_vrstni_red, $vrstni_red, $kuki = 0) { + global $lang; + + if ($kuki == 0) + $kuki = $_COOKIE['srv_clipboard_' . $this->anketa]; + + $variable = $this->generate_variable(); + $variable_custom = 0; + + // skopirali bomo spremenljivko + if ($kuki > 0) { + + $spr = $kuki; + + $row = Cache::srv_spremenljivka($spr); + if ($row['id'] != $spr) return; + + // zakaj je bilo to ?? + //$variable = $row['variable'] . '_' . $variable; + + // pri sistemskih se variable ohrani, ker jih nekje identificiramo po variable-i + // in pri kopiranju iz in v knjiznico tudi + if ($row['sistem'] == 1) { + $variable = $row['variable']; + $variable_custom = $row['variable_custom']; + if ($grupa > 0) { + $variable = $this->append_variable($variable); + } + } + + // kalkulacija ima svoj custom tip + if ($row['tip'] == 22) { + $sql1 = sisplet_query("SELECT s.variable FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.tip='22'"); + if (!$sql1) echo 'err453'.mysqli_error($GLOBALS['connect_db']); + $c = 0; + while ($row1 = mysqli_fetch_array($sql1)) { + $row1['variable'] = (int)str_replace('C', '', $row1['variable']); + if ($row1['variable'] > $c) + $c = $row1['variable']; + } + $c++; + $variable = 'C'.$c; + } + // name generator + if ($row['tip'] == 9) { + $sql1 = sisplet_query("SELECT s.variable FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.tip='9'"); + if (!$sql1) echo 'err453'.mysqli_error($GLOBALS['connect_db']); + $c = 0; + while ($row1 = mysqli_fetch_array($sql1)) { + $row1['variable'] = (int)str_replace('G', '', $row1['variable']); + if ($row1['variable'] > $c) + $c = $row1['variable']; + } + $c++; + $variable = 'G'.$c; + } + + global $connect_db; + + SurveyCopy::setSrcSurvey($this->anketa); + SurveyCopy::setSrcConectDb($connect_db); + SurveyCopy::setDestSite(0); + + // spremenljivka + $qry_src_spremenljivka = sisplet_query("SELECT * FROM srv_spremenljivka WHERE id = '$row[id]'"); + $pre_set = array( 'id' => "NULL", + 'gru_id' => "'$grupa'", + 'naslov' => "'".mysqli_real_escape_string($GLOBALS['connect_db'], $row['naslov'])."'", + 'variable' => "'".mysqli_real_escape_string($GLOBALS['connect_db'], $variable)."'", + 'variable_custom' => "'$variable_custom'", + 'thread' => "'0'", + 'edit_graf' => "'0'", // naknadno popravimo editiranje grafov - po kopiranju je onemogoceno + ); + $spr_array = SurveyCopy::preformCopyTable('srv_spremenljivka', 'id', SurveyCopy::sql2array($qry_src_spremenljivka), $pre_set); + $spremenljivka = $spr_array[$row['id']]; // vrne v obliki arraya [star_id] => [nov_id] + + // if - podifi na vrednostih + $new_if_ids = array (); + $qry_src_vre_if = sisplet_query("SELECT * FROM srv_vrednost v WHERE v.if_id>0 AND v.spr_id='$spr'"); + while ($row_vre_if = mysqli_fetch_array($qry_src_vre_if)) { + // IF-i, tabela srv_if + $qry_src_if_ = sisplet_query("SELECT * FROM srv_if WHERE id = '".$row_vre_if['if_id']."'"); + //$qry_src_if = self::arrayfilter($arr_src['srv_if'], 'id', $row['id']); + $pre_set = array('id' => "NULL"); + $tmp_if_ids = SurveyCopy::preformCopyTable('srv_if', 'id', SurveyCopy::sql2array($qry_src_if_), $pre_set); + + $new_if_ids += $tmp_if_ids; + } + + // vrednost + $qry_src_vrednost = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$spr' ORDER BY vrstni_red"); + $pre_set = array( 'id' => "NULL", + 'spr_id' => "'$spremenljivka'", + 'if_id' => array('field'=>'if_id', 'from'=>$new_if_ids) + ); + $tmp_vrednosti_ids = SurveyCopy::preformCopyTable('srv_vrednost', 'id', SurveyCopy::sql2array($qry_src_vrednost), $pre_set); + + + // maps - choose + if ($row['tip'] == 26 && $row['enota'] == 3){ + $new_vrednosti_ids = array(); + // shranimo stare in nove id-je spremenljivk + if ( count($tmp_vrednosti_ids) > 0 ) + foreach ($tmp_vrednosti_ids as $key => $value) + $new_vrednosti_ids[$key] = $value; + + $qry_src_vrednost_map = sisplet_query("SELECT * FROM srv_vrednost_map WHERE spr_id='$spr' ORDER BY vrstni_red"); + $pre_set = array('id' => "NULL", + 'spr_id' => "'$spremenljivka'", + 'vre_id' => array('field'=>'vre_id', 'from'=>$new_vrednosti_ids)); + SurveyCopy::preformCopyTable('srv_vrednost_map', 'id', SurveyCopy::sql2array($qry_src_vrednost_map), $pre_set); + } + + // grid + $qry_src_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$spr' ORDER BY id"); + $pre_set = array( 'spr_id' => "'$spremenljivka'", + ); + SurveyCopy::preformCopyTable('srv_grid', null, SurveyCopy::sql2array($qry_src_grid), $pre_set); + + + // srv_grid_multiple + $new_sub = array(); + $sqlm = sisplet_query("SELECT * FROM srv_grid_multiple WHERE parent = '$spr'"); + while ($rowm = mysqli_fetch_assoc($sqlm)) { + $new_sub[$rowm['spr_id']] = $this->nova_spremenljivka(-2, 0, 0, $rowm['spr_id']); + } + + $qry_src_grid_multiple = sisplet_query("SELECT * FROM srv_grid_multiple WHERE parent='$spr' ORDER BY vrstni_red"); + + // Ce dodajamo kombinirano tabelo v knjiznico nastavimo ank_id v srv_grid_multiple na -1 + $multiple_ank_id = ($grupa == -1) ? '-1' : $this->anketa; + + $pre_set = array( + 'ank_id' => $multiple_ank_id, + 'parent' => "'$spremenljivka'", + 'spr_id' => array('field'=>'spr_id','from'=>$new_sub), + ); + SurveyCopy::preformCopyTable('srv_grid_multiple', null, SurveyCopy::sql2array($qry_src_grid_multiple), $pre_set); + + + // srv_condition + $qry_src_condition = sisplet_query("SELECT * FROM srv_condition WHERE if_id IN (".SurveyCopy::prepareSubquery(sisplet_query("SELECT v.if_id FROM srv_vrednost v WHERE v.spr_id='$spr' AND v.if_id>0")).")"); + if (!$qry_src_condition) echo mysqli_error($GLOBALS['connect_db']); + $pre_set = array('id' => "NULL", + 'if_id' => array('field'=>'if_id', 'from'=>$new_if_ids)/*, + 'spr_id' => array('field'=>'spr_id', 'from'=>$new_spremenljivke_ids), + 'vre_id' => array('field'=>'vre_id', 'from'=>$new_vrednosti_ids)*/); + $condition = SurveyCopy::preformCopyTable('srv_condition', 'id', SurveyCopy::sql2array($qry_src_condition), $pre_set); + + // condtition grid, tabela srv_condition_grid + if (count($condition) > 0) { + foreach ($condition AS $orig => $bckp) { + // condtition grid, tabela srv_condition_grid + $qry_src_condition_grid = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id = '".$orig."'"); + //$src_srv_condition_grid = SurveyCopy::arrayfilter($arr_src['srv_condition_grid'], 'cond_id', $orig); + $pre_set = array('id'=>"NULL", + 'cond_id' => "'".$bckp."'"); + $new_condition_grid_ids = SurveyCopy :: preformCopyTable('srv_condition_grid', 'id', SurveyCopy::sql2array($qry_src_condition_grid), $pre_set); + } + } + + // condtition vrednost, tabela srv_condition_vre + if (count($condition) > 0) { + foreach ($condition AS $orig => $bckp) { + $qry_src_condition_vre = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id = '$orig'"); + //$src_srv_condition_vre = SurveyCopy::arrayfilter($arr_src['srv_condition_vre'], 'cond_id', $orig); + $pre_set = array('cond_id' => $bckp/*, + 'vre_id' => array('field'=>'vre_id', 'from'=>$new_vrednosti_ids)*/); + SurveyCopy::preformCopyTable('srv_condition_vre', null, SurveyCopy::sql2array($qry_src_condition_vre), $pre_set); + } + } + + // kopiranje kalkulacije + $sql2 = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '-$spr'"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + while ($row2 = mysqli_fetch_array($sql2)) { + $qry_src_calculation = sisplet_query("SELECT * FROM srv_calculation WHERE id = '$row2[id]'"); + $pre_set = array( 'id' => "NULL", + 'cnd_id' => "'-$spremenljivka'", + 'spr_id' => "'".$this->if_copy_spremenljivka($row2['spr_id'])."'", + 'vre_id' => "'".$this->if_copy_vrednost($row2['vre_id'])."'" + ); + SurveyCopy::preformCopyTable('srv_calculation', null, SurveyCopy::sql2array($qry_src_calculation), $pre_set); + + } + + // kopiranje kalkulacije v podifu + $sql2 = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id IN (".SurveyCopy::prepareSubquery(sisplet_query("SELECT c.id FROM srv_vrednost v, srv_condition c WHERE c.if_id=v.if_id AND v.if_id >0 AND v.spr_id='$spr'")).")"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + while ($row2 = mysqli_fetch_array($sql2)) { + $qry_src_calculation = sisplet_query("SELECT * FROM srv_calculation WHERE id = '$row2[id]'"); + $pre_set = array( 'id' => "NULL", + 'cnd_id' => array('field'=>'cnd_id', 'from'=>$condition)/*, + 'spr_id' => "'".$this->if_copy_spremenljivka($row2['spr_id'])."'", + 'vre_id' => "'".$this->if_copy_vrednost($row2['vre_id'])."'"*/ + ); + SurveyCopy::preformCopyTable('srv_calculation', null, SurveyCopy::sql2array($qry_src_calculation), $pre_set); + + } + + // nova (prazna) spremenljivka + } else { + + // pri glasovanju ustvarimo samo prvic novo spr. z default 2 variablami + if(isset($_POST['survey_type']) && $_POST['survey_type'] == 0) + $size = 2; + else + $size = 3; + + if($type < 990) + $sql = sisplet_query("INSERT INTO srv_spremenljivka (id, gru_id, naslov, variable, size, tip, vrstni_red) VALUES ('', '$grupa', '

    $lang[srv_new_vprasanje]

    ', '$variable', '$size', '$type', '$vrstni_red')"); + //standardna vprasanja -> email, url, file upload, ime priimek + else{ + if($type == 991) //email + $sql = sisplet_query("INSERT INTO srv_spremenljivka (id, gru_id, naslov, variable, size, tip, vrstni_red) VALUES ('', '$grupa', '

    Vnesite vaš email naslov

    ', 'email', '1', '4', '$vrstni_red')"); + elseif($type == 992) //url + $sql = sisplet_query("INSERT INTO srv_spremenljivka (id, gru_id, naslov, variable, size, tip, vrstni_red) VALUES ('', '$grupa', '

    Vnesite URL

    ', 'url', '1', '4', '$vrstni_red')"); + elseif($type == 993) //file upload + $sql = sisplet_query("INSERT INTO srv_spremenljivka (id, gru_id, naslov, variable, size, tip, vrstni_red) VALUES ('', '$grupa', '

    Naložite datoteko

    ', 'upload', '1', '4', '$vrstni_red')"); + elseif($type == 994) //ime priimek + $sql = sisplet_query("INSERT INTO srv_spremenljivka (id, gru_id, naslov, variable, size, tip, vrstni_red, text_kosov, text_orientation) VALUES ('', '$grupa', '

    Vnesite ime in priimek

    ', 'name', '1', '21', '$vrstni_red', '2', '2')"); + } + + if (!$sql) + echo mysqli_error($GLOBALS['connect_db']); + + $spremenljivka = mysqli_insert_id($GLOBALS['connect_db']); + } + + // vnesemo -4 tag v podatke, ki oznacuje novo spremenljivko + $sql = sisplet_query("SELECT id FROM srv_user WHERE ank_id = '$this->anketa'"); + $query_values = ""; + while ($row = mysqli_fetch_array($sql)) { + if($query_values != "") $query_values .= ", "; + $query_values .= " ('$spremenljivka', '-4', '$row[id]') "; + } + if (mysqli_num_rows($sql) > 0) + sisplet_query("INSERT INTO srv_data_vrednost".$this->db_table." (spr_id, vre_id, usr_id) VALUES $query_values"); + + return $spremenljivka; + } + + + + /** + * @desc ustvari nov IF (lahko je skopiran) + */ + function if_new ($endif, $parent, $if_id, $vrstni_red, $spremenljivka, $if, $copy=0, $no_content=0, $include_element=true) { + + if ($copy > 0) + $cookie = $copy; + else + $cookie = substr($_COOKIE['srv_clipboard_'.$this->anketa], 3); + + // Dodaten pogoj da nikoli ne vstavimo v srv_branching elementa ki ima element_spr=0 in element_if=0 (potem lahko pride do neskoncnega loopa kjer se dodajajo grupe v anketo) + if ($if_id == 0) die('copy error2'); + + // skopiran if + if ($cookie > 0 && $this->if_copy_check($parent, $cookie)) { + + sisplet_query("UPDATE srv_branching SET vrstni_red=vrstni_red+1 WHERE parent='$parent' AND vrstni_red>='$vrstni_red' AND ank_id='$this->anketa'"); + + sisplet_query("INSERT INTO srv_branching (ank_id, parent, element_spr, element_if, vrstni_red) VALUES ('$this->anketa', '$parent', '0', '$if_id', '$vrstni_red')"); + + $this->if_copy($if_id, $cookie, false, $no_content); + + // ob pastanju zbrisemo clipboard + setcookie('srv_clipboard_'.$this->anketa, '', time()-3600); + + // navaden nov if (pri ENDIFu je nov if prazen, zato ne dodamo nicesar) + } else { + + $s = sisplet_query("INSERT INTO srv_condition (id, if_id, vrstni_red) VALUES ('', '$if_id', '1')"); + if (!$s) echo mysqli_error($GLOBALS['connect_db']); + + if (!$include_element) { // ce vstavimo if, moramo vrstne rede ostalih povecati (sicer pa ne, ker 1 element postavimo v IF) + sisplet_query("UPDATE srv_branching SET vrstni_red=vrstni_red+1 WHERE parent='$parent' AND vrstni_red >= '$vrstni_red' AND ank_id='$this->anketa'"); + } + + sisplet_query("INSERT INTO srv_branching (ank_id, parent, element_spr, element_if, vrstni_red) VALUES ('$this->anketa', '$parent', '0', '$if_id', '$vrstni_red')"); + + if ( $include_element && ($spremenljivka > 0 || $if > 0) ) { + // v if dodamo se spremenljivko oz if (karkoli je bilo pod crto) + sisplet_query("UPDATE srv_branching SET parent='$if_id', vrstni_red='1' WHERE element_spr='$spremenljivka' AND element_if='$if' AND ank_id='$this->anketa'"); + } + } + $this->repare_branching($parent); + } + + /** + * @desc preverimo da ne kopiramo v isti IF (ker se rekurzivno kopira naprej zarad algoritma) + * @param parent od elementa kamor kopiramo + * @param if iz katerega bomo kopiral (v kukiju) + */ + function if_copy_check($parent, $kuki) { + + if ($parent == $kuki) + return false; + + if ($parent == 0) + return true; + + $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_if='$parent' AND ank_id='$this->anketa'"); + $row = mysqli_fetch_array($sql); + + if ($row['parent'] > 0) + if (!$this->if_copy_check($row['parent'], $kuki)) + return false; + + return true; + } + + + /** + * @desc skopira vsebino enega ifa v drugega + * + * kopiranje je urejeno, da deluje z bazo ver 10.11.24, za nadaljne spremembe je potrebno dodati samo nove tabele, ker se celotna vsebina obstojecih tabel kopira avtomatsko cela + * + * @param if v katerega bomo kopiral + * @param if iz katerega bomo kopiral + * @param library pove, ce kopiramo v knjiznico, da ima ank_id -1 + */ + function if_copy($if, $if_copied, $library=false, $no_content=0) { + + // ce kopiramo v knjiznico, tukaj nardimo nov if + if ($if == 0) { + $sql = sisplet_query("INSERT INTO srv_if (id) VALUES ('')"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $if = mysqli_insert_id($GLOBALS['connect_db']); + } + + // popravimo if, ki je bil skreiran ze v funkciji ajax + $sql = sisplet_query("SELECT * FROM srv_if WHERE id = '$if_copied'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + $s = sisplet_query("SHOW columns FROM srv_if"); + $update = ''; + while ($r = mysqli_fetch_array($s)) { + if ($r['Field'] != 'id' && $r['Field'] != 'folder') { + if ($update != '') $update .= ','; + $update .= $r['Field']." = '".$row[$r['Field']]."' "; + } + } + sisplet_query("UPDATE srv_if SET $update WHERE id = '$if'"); + + + global $connect_db; + + SurveyCopy::setSrcSurvey($this->anketa); + SurveyCopy::setSrcConectDb($connect_db); + SurveyCopy::setDestSite(0); + + + // skopiramo pogoje + $sql = Cache::srv_condition($if_copied); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + $qry_src_condition = sisplet_query("SELECT * FROM srv_condition WHERE id = '$row[id]'"); + $pre_set = array( 'id' => "NULL", + 'if_id' => "'$if'", + 'spr_id' => "'".$this->if_copy_spremenljivka($row['spr_id'])."'" + ); + $cond_array = SurveyCopy::preformCopyTable('srv_condition', 'id', SurveyCopy::sql2array($qry_src_condition), $pre_set); + $cond_id = $cond_array[$row['id']]; + + $vre_id = array(); + $sql2 = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id = '$row[id]'"); + while ($row2 = mysqli_fetch_array($sql2)) { + $vre_id[$row2['vre_id']] = $this->if_copy_vrednost($row2['vre_id']); + } + if (mysqli_num_rows($sql2) > 0) mysqli_data_seek($sql2, 0); + $pre_set = array( 'cond_id' => "'$cond_id'", + 'vre_id' => array('field'=>'vre_id', 'from'=>$vre_id) + ); + SurveyCopy::preformCopyTable('srv_condition_vre', null, SurveyCopy::sql2array($sql2), $pre_set); + + $sql2 = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id = '$row[id]'"); + $pre_set = array( 'cond_id' => "'$cond_id'", + ); + SurveyCopy::preformCopyTable('srv_condition_grid', null, SurveyCopy::sql2array($sql2), $pre_set); + + $sql2 = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$row[id]'"); + while ($row2 = mysqli_fetch_array($sql2)) { + $vre_id[$row2['vre_id']] = $this->if_copy_vrednost($row2['vre_id']); + } + if (mysqli_num_rows($sql2) > 0) mysqli_data_seek($sql2, 0); + $pre_set = array( 'id' => "NULL", + 'cnd_id' => "'$cond_id'", + 'spr_id' => array('field'=>'spr_id', 'from'=>$this->if_copy_spremenljivke), + 'vre_id' => array('field'=>'vre_id', 'from'=>$vre_id) + ); + SurveyCopy::preformCopyTable('srv_calculation', null, SurveyCopy::sql2array($sql2), $pre_set); + } + + // zanka + // srv_loop + $qry_src_loop = sisplet_query("SELECT * FROM srv_loop WHERE if_id = '$if_copied'"); + $pre_set = array( 'if_id' => "'$if'", + 'spr_id' => array('field'=>'spr_id','from'=>$this->if_copy_spremenljivke) + ); + SurveyCopy::preformCopyTable('srv_loop', null, SurveyCopy::sql2array($qry_src_loop), $pre_set); + + // srv_loop_vre + $qry_src_loop_vre = sisplet_query("SELECT * FROM srv_loop_vre WHERE if_id = '$if_copied'"); + while ($row2 = mysqli_fetch_array($qry_src_loop_vre)) { + $vre_id[$row2['vre_id']] = $this->if_copy_vrednost($row2['vre_id']); + } + if (mysqli_num_rows($qry_src_loop_vre) > 0) mysqli_data_seek($qry_src_loop_vre, 0); + $pre_set = array( 'if_id' => "'$if'", + 'vre_id' => array('field'=>'vre_id','from'=>$vre_id) + ); + SurveyCopy::preformCopyTable('srv_loop_vre', null, SurveyCopy::sql2array($qry_src_loop_vre), $pre_set); + + // srv_loop_data + $qry_src_loop_data = sisplet_query("SELECT * FROM srv_loop_data WHERE if_id = '$if_copied'"); + while ($row2 = mysqli_fetch_array($qry_src_loop_data)) { + $vre_id[$row2['vre_id']] = $this->if_copy_vrednost($row2['vre_id']); + } + if (mysqli_num_rows($qry_src_loop_data) > 0) mysqli_data_seek($qry_src_loop_data, 0); + $pre_set = array( 'id' => "NULL", + 'if_id' => "'$if'", + 'vre_id' => array('field'=>'vre_id','from'=>$vre_id) + ); + SurveyCopy::preformCopyTable('srv_loop_data', 'id', SurveyCopy::sql2array($qry_src_loop_data), $pre_set); + + // ali kopiramo tudi vsebino ifa + if ($no_content != 1) { + + // gremo cez njegove childe in jih kopiramo + $sql = sisplet_query("SELECT * FROM srv_branching WHERE parent = '$if_copied' ORDER BY vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $values = ''; + while ($row = mysqli_fetch_array($sql)) { + + if ($library) // ce kopiramo v library + $anketa = -1; + elseif ($row['ank_id'] == -1) // ce kopiramo iz librarija v anketo + $anketa = $this->anketa; + else + $anketa = $row['ank_id']; + + // element je spremenljivka -- kreiramo novo spremenljivko + if ($row['element_spr'] > 0) { + + // Dobimo id strani + $sqlGrupa = sisplet_query("SELECT g.id, g.vrstni_red FROM srv_grupa g, srv_spremenljivka s WHERE s.id='".$row['element_if']."' AND s.gru_id=g.id"); + if (!$sqlGrupa) echo mysqli_error($GLOBALS['connect_db']); + $rowGrupa = mysqli_fetch_array($sqlGrupa); + + //$element_spr = $this->nova_spremenljivka($anketa, 0, $row['vrstni_red'], $row['element_spr']); + $element_spr = $this->nova_spremenljivka($rowGrupa['id'], $rowGrupa['vrstni_red'], $row['vrstni_red'], $row['element_spr']); + $element_if = 0; + + $this->if_copy_spremenljivke[$row['element_spr']] = $element_spr; + + // element je if -- + } elseif ($row['element_if'] > 0) { + + $sql1 = sisplet_query("SELECT * FROM srv_if WHERE id = '".$row['element_if']."'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + $sql2 = sisplet_query("INSERT INTO srv_if (id, label) VALUES ('', '".$row1['label']."')"); + $element_spr = 0; + $element_if = mysqli_insert_id($GLOBALS['connect_db']); + + // skopiramo rekurzivno se podif + $this->if_copy($element_if, $row['element_if'], $library); + } + + $sql3 = sisplet_query("SELECT * FROM srv_branching WHERE ank_id='".$row['ank_id']."' AND parent='".$row['parent']."' AND element_spr='".$row['element_spr']."' AND element_if='".$row['element_if']."'"); + $pre_set = array( 'ank_id' => "'$anketa'", + 'parent' => "'$if'", + 'element_spr' => "'$element_spr'", + 'element_if' => "'$element_if'" + ); + SurveyCopy::preformCopyTable('srv_branching', null, SurveyCopy::sql2array($sql3), $pre_set); + } + + } + + return $if; // to je ko kopiramo v library, da dobimo ID ifa + } + + private $if_copy_spremenljivke = array(); // povezave originalnih spremenljivk s skopiranimi (da lahko spremenimo pogoje) + + /** + * @desc za podano spremenljivko vrne skopirano spremenljivko, ce smo jo skopiral. ce ne, vrne original + */ + function if_copy_spremenljivka ($spr) { + + if ($spr < 0) + return $spr; + + if ($this->if_copy_spremenljivke[$spr] > 0) + return $this->if_copy_spremenljivke[$spr]; + + $sql = sisplet_query("SELECT g.ank_id FROM srv_spremenljivka s, srv_grupa g WHERE s.id = '$spr' AND s.gru_id=g.id"); + $row = mysqli_fetch_array($sql); + if ($row['ank_id'] == $this->anketa) + return $spr; + + return 0; + } + + /** + * @desc za podano vrednost v (podani) spremenljivki vrne skopirano vrednost (skopirane spremenljivke) + * ce ni bila skopirana v tej rundi vrne original (to pomeni, da se if nanasa na spremenljivko izven bloka ki se kopira) + */ + function if_copy_vrednost ($vre) { + + $sql = sisplet_query("SELECT spr_id, vrstni_red FROM srv_vrednost WHERE id = '$vre'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + $spr_copy = $this->if_copy_spremenljivke[$row['spr_id']]; + if ($spr_copy > 0) { + + $vrstni_red = $row['vrstni_red']; + + $sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spr_copy' AND vrstni_red = '$vrstni_red'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + return $row['id']; + + } else { + + $sql = sisplet_query("SELECT g.ank_id FROM srv_vrednost v, srv_spremenljivka s, srv_grupa g WHERE v.id='$vre' AND v.spr_id=s.id AND s.gru_id=g.id"); + $row = mysqli_fetch_array($sql); + + if ($row['ank_id'] == $this->anketa) + return $vre; + else + return 0; + + } + } + + /** + * @desc preveri ali lahko droppamo spremenljivko na to mesto (da se ne unicijo pogoji) + * @param spremenljivka ki jo droppamo + * @param parent kamor smo droppal spremenljivko + * @param vrstni_red znotraj parenta kamor smo droppal + * Pogledamo kam bo padla spremenljivka in potem za vse pogoje pred novo pozicijo spremenljivke + * preverimo, da nimajo v condition-u te spremenljivke + */ + function check_dropped_spremenljivka ($spremenljivka, $parent, $vrstni_red) { + + // vrstni red kam bo prisla spremenljivka + $vrstni_red = $this->check_vrstni_red($parent, $vrstni_red); + + $sql = sisplet_query("SELECT i.id, i.tip FROM srv_branching b, srv_if i WHERE i.id=b.element_if AND b.element_if > '0' AND b.ank_id='$this->anketa' ORDER BY b.vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + // ce je pogoj pred novo pozicijo spremenljivke + if ($this->vrstni_red_branching($row['id']) <= $vrstni_red) + if ($row['tip'] == 0) { // if + if (!$this->check_if($row['id'], $spremenljivka)) + return false; + } elseif ($row['tip'] == 2) { // zanka + if (!$this->check_loop_spremenljivka($row['id'], $spremenljivka)) + return false; + } + + } + + return true; + } + + /** + * @desc preveri ali lahko droppamo if na to mesto (da se ne unicijo pogoji) + * Najprej poiscemo novo pozicijo IFa in potem za vse spremenljivke za novo pozicijo pogoja (in pred staro) + * preverimo da ni spremenljivka v katerem od pogojev IFa (in tudi podifov tega IFa) + * Potem pa se za vse IFe pred droppanim IFom preverimo, da nimajo v pogoju kaksne spremenljivke + * iz droppanga IFa + */ + function check_dropped_if ($if, $parent, $vrstni_red) { + + // vrstni red kam bo prsu if + $vrstni_red = $this->check_vrstni_red($parent, $vrstni_red); + + // spremenljivke za IFom + foreach ($this->get_subifs($if) AS $ifs) { + //echo $ifs.': '; + + $sql = sisplet_query("SELECT tip FROM srv_if WHERE id = '$ifs'"); + $row = mysqli_fetch_array($sql); + $tip = $row['tip']; + + $sql = sisplet_query("SELECT element_spr FROM srv_branching WHERE element_spr > '0' AND ank_id='$this->anketa' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + // ce je spremenljivka za novo pozicijo ifa (in pred staro) + if ($this->vrstni_red_branching(0, $row['element_spr']) > $vrstni_red && + $this->vrstni_red_branching(0, $row['element_spr']) < $this->vrstni_red_branching($if)) + if ($tip == 0) { // if + if (!$this->check_if($ifs, $row['element_spr'])) + return false; + } elseif ($tip == 2) { // zanka + if (!$this->check_loop_spremenljivka($ifs, $row['element_spr'])) + return false; + } + + } + } + + + // IFi pred droppanim IFom + $sql = sisplet_query("SELECT element_if FROM srv_branching WHERE element_if > '0' AND ank_id='$this->anketa' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + // gledamo samo za tiste IFe, ki niso vgnezdeni v droppanem IFu + if (!in_array($row['element_if'], $this->get_subifs($if))) + // ce je pogoj pred novo pozicijo droppanga ifa + if ($this->vrstni_red_branching($row['element_if']) <= $vrstni_red) + foreach ($this->get_subspr($if) AS $spr) + if (!$this->check_if($row['element_if'], $spr)) + return false; + + } + + return true; + } + + /** + * @desc poisce vrstni red kamor bo paddel dropped element + */ + function check_vrstni_red ($parent, $vrstni_red) { + + // spustil smo na prvi element v IFu (ki ima vrstni red 0) + if ($vrstni_red == 0) { + return $this->vrstni_red_branching($parent); + + } else { + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$parent' AND ank_id='$this->anketa' AND vrstni_red='$vrstni_red'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + // spustil smo pod spremenljivko + if ($row['element_spr'] > 0) { + return $this->vrstni_red_branching(0, $row['element_spr']); + + // spustil smo pod ENDIF, zato poiscemo zadnji element v ifu (ker je isti globalni vrstni red -- endif nima vpliva) + // oz. ce je ta IF prazen poiscemo kar vrstni red tega IFa + } else { + return $this->find_last_elm_in_if($row['element_if']); + } + } + } + + /** + * @desc preveri, da ni spremenljivka v pogoju IFa. Vrne true, ce spremenljivke ni med pogoji + */ + function check_if ($if, $spremenljivka) { + + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + if ($row['spr_id'] == $spremenljivka) + return false; + } + + return true; + } + + /** + * preveri, da spremenljivka ni nastavljena, da se loopa po njej v zanki + * + * @param mixed $if + * @param mixed $spremenljivka + */ + function check_loop_spremenljivka ($if, $spremenljivka) { + + $sql = sisplet_query("SELECT if_id, spr_id FROM srv_loop WHERE if_id = '$if'"); + $row = mysqli_fetch_array($sql); + if ($row['spr_id'] == $spremenljivka) return false; + + return true; + } + + /** + * @desc vrne vse podife podanega ifa (vkljucno s podanim ifom) + */ + function get_subifs ($if) { + + $array = array(); + array_push($array, $if); + + $sql = sisplet_query("SELECT element_if FROM srv_branching WHERE parent = '$if' AND ank_id='$this->anketa' ORDER BY vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_if'] > 0) { + foreach ($this->get_subifs($row['element_if']) AS $key) + array_push($array, $key); + } + } + + return $array; + } + + /** + * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu + */ + function get_subspr ($if) { + + $array = array(); + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent = '$if' AND ank_id='$this->anketa' ORDER BY vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_spr'] > 0) + array_push($array, $row['element_spr']); + else + foreach ($this->get_subspr($row['element_if']) AS $key) + array_push($array, $key); + } + + return $array; + } + + /** + * @desc popravi vrstne rede v obicajnem urejanju (srv_spremenljivka) ob premikanju v branchingu (srv_branching) + */ + var $spremenljivka_grupa = null; // cache trenutnih vrednosti, da izvedemo query, samo pri tistih, kjer je razlika + var $repare_vrstni_red_values = ''; // kesiramo update query, da se tudi pri rekurzivnih klicih te funkcije, izvede samo 1x + function repare_vrstni_red ($parent=0, $spr_vr=1, $gru_vr=1) { + + if ($parent == 0) sisplet_query("BEGIN"); + + // preberemo cel branching, ker dostopamo iz $this->pagebreak(); + if ($parent == 0) + Cache::cache_all_srv_branching($this->anketa); + + if ($this->spremenljivka_grupa == null) { + $sql = sisplet_query("SELECT s.id, s.gru_id, s.vrstni_red FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa'"); + while ($row = mysqli_fetch_array($sql)) { + $a = array('vrstni_red' => $row['vrstni_red'], 'gru_id' => $row['gru_id']); + $this->spremenljivka_grupa[$row['id']] = $a; + } + } + + // gremo cez vse v srv_branching + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE ank_id='$this->anketa' AND parent='$parent' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $values = ""; + while ($row = mysqli_fetch_array($sql)) { + if ($row['element_spr'] > 0) { + + $gru_id = $this->find_grupa($gru_vr); + + if ($this->spremenljivka_grupa[$row['element_spr']]['vrstni_red'] != $spr_vr OR $this->spremenljivka_grupa[$row['element_spr']]['gru_id'] != $gru_id) { + if ( $gru_id > 0 ) { + sisplet_query("UPDATE srv_spremenljivka SET vrstni_red = '$spr_vr', gru_id='$gru_id' WHERE id = '$row[element_spr]'"); + + if ($values != "") $values .= ", "; + $values .= "('$row[element_spr]', '$gru_id', '$spr_vr')"; + } + } + + // ce je za njim pagebreak, poiscemo novo grupo + if ($this->pagebreak($row['element_spr'])) { + $gru_vr++; + $spr_vr = 1; + // naslednja spremenljivka je na isti strani + } else { + $spr_vr++; + } + + } else if ($row['element_if'] > 0){ + + // rekurzivni klic iste funckije, ki gre cez ife + $arr = $this->repare_vrstni_red($row['element_if'], $spr_vr, $gru_vr); + + $spr_vr = $arr[0]; + $gru_vr = $arr[1]; + } + } + + if ($this->repare_vrstni_red_values != "" && $values != "") $this->repare_vrstni_red_values .= ","; + $this->repare_vrstni_red_values .= $values; + + if ($this->repare_vrstni_red_values != "" && $parent == 0) { + //$s = sisplet_query("INSERT INTO srv_spremenljivka (id, gru_id, vrstni_red) VALUES ".$this->repare_vrstni_red_values." ON DUPLICATE KEY UPDATE gru_id=VALUES(gru_id), vrstni_red=VALUES(vrstni_red)"); + //if (!$s) echo 'e007'.mysqli_error($GLOBALS['connect_db']); + } + + if ($parent == 0) sisplet_query("COMMIT"); + + $a = Array($spr_vr, $gru_vr); + return $a; + } + + /** + * @desc poisce grupo s podanim vrstnim redom + */ + var $find_grupa = array(); + function find_grupa ($gru_vr) { + global $lang; + + if (isset($this->find_grupa[$gru_vr])) { + return $this->find_grupa[$gru_vr]; + } + + $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' AND vrstni_red = '$gru_vr'"); + $row = mysqli_fetch_array($sql); + + if ($row['id'] > 0) { + $this->find_grupa[$gru_vr] = $row['id']; + return $this->find_grupa[$gru_vr]; + } + + $sql = sisplet_query("INSERT INTO srv_grupa (ank_id, naslov, vrstni_red) VALUES ('$this->anketa', '$lang[srv_stran] $gru_vr', '$gru_vr')"); + $this->find_grupa[$gru_vr] = mysqli_insert_id($GLOBALS['connect_db']); + + // Ce dodamo 4. stran vklopimo progress indicator (pri 3 straneh ali manj je po default izklopljen) + $sql2 = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa'"); + $vrstni_red = mysqli_num_rows($sql2); + if($vrstni_red == 4){ + $sqlP = sisplet_query("UPDATE srv_anketa SET progressbar='1' WHERE id='$this->anketa'"); + } + + return $this->find_grupa[$gru_vr]; + } + + /** + * @desc odstrani prazne grupe (strani) na koncu ankete + */ + function trim_grupe () { + + // pogledamo, ce je zadnja grupa prazna in nato rekurzivno klicemo funkcijo dokler so prazne + $sqlG = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' ORDER BY vrstni_red DESC"); + + // Ce imamo samo se 1 grupo je ne smemo pobrisati - izstopni pogoj + if(mysqli_num_rows($sqlG) > 1){ + $rowG = mysqli_fetch_array($sqlG); + + $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id = '$rowG[id]'"); + if (mysqli_num_rows($sql) == 0) { + sisplet_query("DELETE FROM srv_grupa WHERE id = '$rowG[id]'"); + $this->trim_grupe(); + } + } + } + + /** + * zgenerira strukturo za hitrejse delovanje find_next_spr() in find_prev_spr() + * TODO - ni v uporabi... + */ + private $find_all_spr = null; + function find_all_spremenljivka () { + + $sql = sisplet_query("SELECT s.id AS id, g.naslov AS grupa_naslov FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' ORDER BY g.vrstni_red, s.vrstni_red"); + while ($row = mysqli_fetch_assoc($sql)) { + $this->find_all_spr[$row['id']] = $row; + } + } + + /** + * @desc poisce naslednjo spremenljivko za podano spremenljivko + */ + function find_next_spr ($spremenljivka) { + + $sql = sisplet_query("SELECT vrstni_red, gru_id FROM srv_spremenljivka WHERE id = '$spremenljivka'"); + $row = mysqli_fetch_array($sql); + $vrstni_red = $row['vrstni_red']; + + // naslednij je na isti strani + $next = $vrstni_red + 1; + $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE vrstni_red='$next' AND gru_id='$row[gru_id]'"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + return $row['id']; + } + + // naslednik je na naslednji strani + $sql = sisplet_query("SELECT g.vrstni_red FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND s.id='$spremenljivka'"); + $row = mysqli_fetch_array($sql); + $grupa_red = $row['vrstni_red']; + $next = $grupa_red + 1; + $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND g.vrstni_red = '$next' ORDER BY s.vrstni_red ASC LIMIT 1"); + $row = mysqli_fetch_array($sql); + return $row['id']; + + } + + /** + * @desc poisce predhodnjo spremenljivko za podano spremenljivko + */ + var $find_prev_spr = array(); + function find_prev_spr ($spremenljivka) { + + if (array_key_exists($spremenljivka, $this->find_prev_spr)) { + return $this->find_prev_spr[$spremenljivka]; + } + + $sql = sisplet_query("SELECT vrstni_red, gru_id FROM srv_spremenljivka WHERE id = '$spremenljivka'"); + $row = mysqli_fetch_array($sql); + $vrstni_red = $row['vrstni_red']; + + // predhodnik je na isti strani + $prev = $vrstni_red - 1; + $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE vrstni_red='$prev' AND gru_id='$row[gru_id]'"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + + $this->find_prev_spr[$spremenljivka] = $row['id']; + return $row['id']; + } + + // predhodnik je na prejsnji strani + $sql = sisplet_query("SELECT g.vrstni_red FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND s.id='$spremenljivka'"); + $row = mysqli_fetch_array($sql); + $grupa_red = $row['vrstni_red']; + $prev = $grupa_red - 1; + $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND g.vrstni_red = '$prev' ORDER BY s.vrstni_red DESC LIMIT 1"); + $row = mysqli_fetch_array($sql); + + $this->find_prev_spr[$spremenljivka] = $row['id']; + return $row['id']; + + } + + var $prev_srv_branching = 0; // zacasna spremenljivka + /** + * poisce predhodnjo spremenljivko v srv_branching tabeli + * + * @param mixed $spremenljivka + */ + function find_prev_spr_branching ($spremenljivka, $parent=0) { + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE ank_id='$this->anketa' AND parent='$parent' ORDER BY vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_spr'] > 0) { + if ($row['element_spr'] == $spremenljivka) return $this->prev_srv_branching; + $this->prev_srv_branching = $row['element_spr']; + + } else { + $r = $this->find_prev_spr_branching($spremenljivka, $row['element_if']); + if ($r > 0) return $r; + } + } + + return 0; + } + + /** + * @desc Poisce zadnjo spremenljivko v anketi + */ + var $find_last_spr = 0; + function find_last_spr () { + + if ($this->find_last_spr > 0) + return $this->find_last_spr; + + $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' ORDER BY g.vrstni_red DESC, s.vrstni_red DESC LIMIT 1"); + $row = mysqli_fetch_array($sql); + + $this->find_last_spr = $row['id']; + return $row['id']; + + } + + /** + * poisce zadnjo spremenljivko v tabeli srv_branching + * + */ + function find_last_spr_branching ($parent = 0) { + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE ank_id='$this->anketa' AND parent='$parent' ORDER BY vrstni_red DESC LIMIT 1"); + $row = mysqli_fetch_array($sql); + + if ($row['element_spr'] > 0) return $row['element_spr']; + + if ( mysqli_num_rows($sql) > 0 ) + return $this->find_last_spr_branching($row['element_if']); + + return 0; + } + + /** + * vrne array grupe za podano spremenljivko + * + * @param mixed $spremenljivka + * @return array + */ + function getGrupa4Spremenljivka($spremenljivka) { + + $sql = sisplet_query("SELECT g.* FROM srv_grupa AS g WHERE g.id = (SELECT s.gru_id FROM srv_spremenljivka as s WHERE s.id = '$spremenljivka')"); + $row = mysqli_fetch_assoc($sql); + + return $row; + } + + /** + * vrne array grupe za podan if + * + * @param mixed $if_id + * @return array + */ + function getGrupa4If($if_id) { + + $sqlBr = sisplet_query("SELECT vrstni_red FROM srv_branching WHERE ank_id='$this->anketa' AND element_if='$if_id'"); + $rowBr = mysqli_fetch_assoc($sqlBr); + $vrstni_red_if = $rowBr['vrstni_red']; + + if($vrstni_red_if == 1){ + $sql = sisplet_query("SELECT * FROM srv_grupa WHERE ank_id='$this->anketa' AND vrstni_red='1'"); + $row = mysqli_fetch_assoc($sql); + } + else{ + $sqlB = sisplet_query("SELECT element_spr, pagebreak FROM srv_branching WHERE ank_id='$this->anketa' AND vrstni_red<'$vrstni_red_if' AND element_spr>'0' ORDER BY vrstni_red DESC"); + $rowB = mysqli_fetch_assoc($sqlB); + + if($rowB['pagebreak'] == 0){ + $row = $this->getGrupa4Spremenljivka($rowB['element_spr']); + } + else{ + $prev_grupa = $this->getGrupa4Spremenljivka($rowB['element_spr']); + $row['id'] = $this->find_grupa($prev_grupa['vrstni_red']+1); + $row['vrstni_red'] = $prev_grupa['vrstni_red']+1; + } + } + + return $row; + } + + /** + * @desc Poisce prvo spremenljivko v anketi + */ + var $find_first_spr = 0; + function find_first_spr () { + + if ($this->find_first_spr > 0) + return $this->find_first_spr; + + $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC LIMIT 1"); + $row = mysqli_fetch_array($sql); + + $this->find_first_spr = $row['id']; + return $row['id']; + + } + + /** + * @desc vrne (globalni) vrstni red spremenljivke, uposteva tudi stran + */ + var $vrstni_red = array(); + function vrstni_red($spremenljivka) { + + if ($spremenljivka == 0) return 0; + //$this->repareAnketa(); + + if (array_key_exists($spremenljivka, $this->vrstni_red)) { + return $this->vrstni_red[$spremenljivka]; + } + + $sql = sisplet_query("SELECT id, gru_id, vrstni_red FROM srv_spremenljivka WHERE id = '$spremenljivka'"); + $row = mysqli_fetch_array($sql); + $vrstni_red = $row['vrstni_red']; + + $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '$row[gru_id]'"); + $rowg = mysqli_fetch_array($sqlg); + + $sql1 = sisplet_query("SELECT id FROM srv_grupa WHERE vrstni_red < '$rowg[vrstni_red]' AND ank_id='$this->anketa'"); + while ($row1 = mysqli_fetch_array($sql1)) { + + $vrstni_red += $this->prestej_grupo($row1['id']); + } + + $this->vrstni_red[$spremenljivka] = $vrstni_red; + return $this->vrstni_red[$spremenljivka]; + } + + /** + * @desc presteje spremenljivke v grupi + */ + var $prestej_grupo = array(); + function prestej_grupo ($grupa) { + + if (array_key_exists($grupa, $this->prestej_grupo)) { + return $this->prestej_grupo[$grupa]; + } + + $sql2 = sisplet_query("SELECT COUNT(*) AS count FROM srv_spremenljivka WHERE gru_id = '$grupa'"); + $row2 = mysqli_fetch_array($sql2); + + $this->prestej_grupo[$grupa] = $row2['count']; + return $row2['count']; + } + + /** + * poisce naslednji element (spremenljivko, if, blok) in vrne njegov row (parent, vrstni_red, element_spr, element_if) + * v primeru ENDIFA, vrne prazno + * + * @param mixed $spr + * @param mixed $if + */ + var $find_next_element = array(); + function find_next_element($parent, $vrstni_red) { + + if (isset($this->find_next_element[$spr][$if])) + return $this->find_next_element[$spr][$if]; + + $sql = sisplet_query("SELECT parent, vrstni_red, element_spr, element_if FROM srv_branching WHERE parent='$parent' AND vrstni_red>'$vrstni_red' AND ank_id='$this->anketa' ORDER BY vrstni_red ASC LIMIT 1"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + $this->find_next_element[$spr][$if] = $row; + } else { + $this->find_next_element[$spr][$if] = null; + } + + return $this->find_next_element[$spr][$if]; + } + + /** + * @desc poklice funkcijo za poiskat spremenljivko pred podanim ifom + */ + function find_before_if ($if) { + $a = $this->find_before_if_fun($if); + return $a[1]; + } + + /** + * @desc poisce spremenljivko pred podanim ifom + */ + function find_before_if_fun ($if, $parent=0, $prev=0) { + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE ank_id='$this->anketa' AND parent='$parent' ORDER BY vrstni_red"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_if'] > 0) { + + if ($row['element_if'] == $if) { + $a[0] = 1; + $a[1] = $prev; + return $a; + } + + $a = $this->find_before_if_fun($if, $row['element_if'], $prev); + if ($a[0] == 1) { + return $a; + } + $prev = $a[1]; + + } else { + + $prev = $row['element_spr']; + } + } + + $a[0] = 0; + $a[1] = $prev; + return $a; + } + + /** + * @desc vrne vrstni red zadnjega elementa v ifu (spremenljivka ali if -- ce je prazen, drugace je zadnja v vsakem primeru spremenljivka) + */ + function find_last_elm_in_if ($if) { + + $sql1 = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$if' AND ank_id='$this->anketa' ORDER BY vrstni_red DESC LIMIT 1"); + + // if ni prazen, gremo dalje + if (mysqli_num_rows($sql1) > 0) { + + $row1 = mysqli_fetch_array($sql1); + + // zadnja je spremenljivka -- vrnemo jo + if ($row1['element_spr'] > 0) { + return $this->vrstni_red_branching(0, $row1['element_spr']); + + // na zadnjem mestu je if -- gremo rekurzivno naprej + } else { + return $this->find_last_elm_in_if($row1['element_if']); + } + + // if je prazen, vrnemo kar vrstni red ifa + } else { + return $this->vrstni_red_branching($if); + } + + } + + /** + * @desc poisce zadnjo spremenljivko v IFu + */ + function find_last_in_if ($if) { + + if ($if == null) return null; + + if (!$this->find_spr_in_if($if)) return null; + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$if' AND ank_id='$this->anketa' ORDER BY vrstni_red DESC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_spr'] > 0) + return $row['element_spr']; + else { + $r = $this->find_last_in_if($row['element_if']); + if ($r != null) + return $r; + } + } + } + + /** + * @desc poisce prvo spremenljivko v IFu + */ + function find_first_in_if ($if) { + + if ($if == null) return null; + + if (!$this->find_spr_in_if($if)) return null; + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$if' AND ank_id='$this->anketa' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['element_spr'] > 0) + return $row['element_spr']; + else { + $r = $this->find_first_in_if($row['element_if']); + if ($r != null) + return $r; + } + } + } + + /** + * @desc preveri ali so kaksne spremenljivke v IFu + */ + function find_spr_in_if ($if) { + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$if' AND ank_id='$this->anketa'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + if ($row['element_spr'] > 0) + return true; + elseif ($row['element_if'] > 0) + if ($this->find_spr_in_if($row['element_if'])) + return true; + } + + return false; + } + + /** + * @desc presteje koliko spremenljiv je v IFu + */ + function count_spr_in_if ($if) { + $count = 0; + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$if' AND ank_id='$this->anketa'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + if ($row['element_spr'] > 0) + $count++; + elseif ($row['element_if'] > 0) + $count += $this->count_spr_in_if($row['element_if']); + + } + + return $count; + } + + private $vrstni_red_branching = null; + /** + * vrne vrstni red elementa v branching strukturi (uposteva tudi ife itd..) + * + * @param mixed $if + * @param mixed $spremenljivka + */ + function vrstni_red_branching ($if, $spremenljivka=0) { + + if ($this->vrstni_red_branching === null) { + + Cache::cache_all_srv_branching($this->anketa); + $vrstni_red = 1; + $this->vrstni_red_branching_fun(0, $vrstni_red); + } + + return $this->vrstni_red_branching[$if][$spremenljivka]; + } + + /** + * zgenerira array z vrstnimi redi elementov (rekurzivno) + * + * @param mixed $parent + * @param mixed $vrstni_red + */ + function vrstni_red_branching_fun ($parent, &$vrstni_red) { + + foreach (Cache::srv_branching_parent($this->anketa, $parent) AS $k => $row) { + + $this->vrstni_red_branching[$row['element_if']][$row['element_spr']] = $vrstni_red; + $vrstni_red++; + + if ($row['element_if'] > 0) { + $this->vrstni_red_branching_fun($row['element_if'], $vrstni_red); + } + } + } + + /** + * @desc poklice repareAnketa, ki popravi celotno anketo + */ + function repareAnketa () { + + Common::repareAnketa($this->anketa); + } + + /** + * pri repare branching bomo šli zdej vedno čez celo strukturo, ker drugace zgleda da nekaj ni ok + * + * @param mixed $parent + */ + function repare_branching ($parent=0) { + + $this->repare_branching_do(); + } + + /** + * @desc rekurzivno popravi vrstne rede v branchingu + */ + function repare_branching_do ($parent=0) { + + $vrstni_red = 1; + + $sql = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent='$parent' AND ank_id='$this->anketa' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + while ($row = mysqli_fetch_array($sql)) { + + if ($row['vrstni_red'] != $vrstni_red) { + sisplet_query("UPDATE srv_branching SET vrstni_red='$vrstni_red' WHERE element_spr='$row[element_spr]' AND element_if='$row[element_if]' AND ank_id='$this->anketa'"); + } + + $vrstni_red++; + + if ($row['element_if'] > 0) + $this->repare_branching_do($row['element_if']); + } + } + + /** + * @desc preveri ali je spremenljivka zadnja na strani (pagebreak) + */ + var $pagebreak = array(); + function pagebreak ($spremenljivka) { + + if (array_key_exists($spremenljivka, $this->pagebreak)) { + return $this->pagebreak[$spremenljivka]; + } + + $row = Cache::srv_branching($spremenljivka, 0); + + if ($row['pagebreak'] == 1) { + $this->pagebreak[$spremenljivka] = true; + return true; + } else { + $this->pagebreak[$spremenljivka] = false; + return false; + } + } + + /** + * @desc vrne nivo (level) spremenljivke v strukturi branchinga + */ + var $level = array(); + function level ($element_spr, $element_if=0) { + + if (isset($this->level[$element_spr][$element_if])) { + return $this->level[$element_spr][$element_if]; + } + + $row = Cache::srv_branching($element_spr, $element_if); + + if ($row['parent'] == 0) { + + $this->level[$element_spr][$element_if] = 0; + return 0; + + } else { + + $value = $this->level(0, $row['parent']) + 1; + $this->level[$element_spr][$element_if] = $value; + + return $value; + } + } + + /** + * @desc popravi vrstne rede v conditionu + */ + function repare_condition ($if) { + + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $vrstni_red=1; + + while ($row = mysqli_fetch_array($sql)) { + if ($row['vrstni_red'] != $vrstni_red) + sisplet_query("UPDATE srv_condition SET vrstni_red='$vrstni_red' WHERE id = '$row[id]'"); + $vrstni_red++; + } + } + + /** + * @desc popravi vrstne rede v calculationu + */ + function repare_calculation ($condition) { + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id='$condition' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $vrstni_red=1; + + while ($row = mysqli_fetch_array($sql)) { + if ($row['vrstni_red'] != $vrstni_red) + $s = sisplet_query("UPDATE srv_calculation SET vrstni_red='$vrstni_red' WHERE id = '$row[id]'"); + $vrstni_red++; + } + } + + /** + * @desc + */ + function dropped_alert($text = null) { + global $lang; + + if ($text === null) + $text = $lang['srv_dropped_alert']; + + echo ''; + + echo ' '."\n\r"; + } + + function showVprasalnikBottom() { + + echo '
    ' . "\n\r"; + $this->showVprasalnikBottomContent(); + echo '
    ' . "\n\r"; + } + + /** + * + * @param mixed $color + */ + function showVprasalnikBottomContent($color = 'orange') { + global $lang, $site_url; + + $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_branching WHERE ank_id='$this->anketa'"); + $row = mysqli_fetch_array($sql); + + if ($row['count'] > 0) { + + $d = new Dostop(); + + echo '
    '; + + + // Vprasalnik se shranjuje avt. + echo '
    '; + echo ''; + echo '
    '.$lang['srv_vprasalnik_autosave'].'
    '; + echo '
    '; + + echo ''; + + + echo '
    '; + } + } + + /** + * @desc Če je anketa aktivna, preverimo da ni slučajno potekel čas aktivnosti, + * če je, jo deaktiviramo + */ + function checkSurveyActive($anketa = null) { + // pretecena anketa, kontroliramo datum na: starts in expire + sisplet_query("UPDATE srv_anketa SET active = '0' WHERE id='" . ($anketa ? $anketa : $this->anketa) . "' AND active = '1' AND expire < CURDATE()"); + + SurveyInfo :: getInstance()->SurveyInit($this->anketa); + // vsilimo refresh podatkov + SurveyInfo :: getInstance()->resetSurveyData(); + + $sqls = sisplet_query("SELECT active FROM srv_anketa WHERE id='" . ($anketa ? $anketa : $this->anketa) . "'"); + $rows = mysqli_fetch_assoc($sqls); + return $rows['active']; + } + + /** + * vrne array vseh spremenljivk, ki se pojavljajo v loopu + * + * @param mixed $ank_id + */ + function spremenljivke_in_loop ($anketa = null) { + + if ($anketa == null) { + $ank_id = $this->anketa; + } else { + $ank_id = $anketa; + } + $a = array(); + + $sql = sisplet_query("SELECT b.element_if FROM srv_branching b, srv_if i WHERE b.ank_id='$ank_id' AND b.element_if=i.id AND i.tip='2'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + + $a[$row['element_if']] = $this->get_subspr($row['element_if']); + } + + return $a; + } + + /** + * preveri, ce obstajajo loopi in ce so PB na loopih pravilno postavljeni ter jih popravi + * - pagebreak mora biti pred in za loopom, ter nobenega pb v loopu -- se pravi: loop je na svoji strani + */ + function check_loop () { + + $change = false; + + $a = $this->spremenljivke_in_loop(); + + // loop cez vse loope :) + foreach ($a AS $loop => $spremenljivke) { + + // spremenljivka pred loopom - mora imet pb + $pred = $this->find_before_if($loop); + $row = Cache::srv_branching($pred, 0); + if ($row['pagebreak'] == 0) { + sisplet_query("UPDATE srv_branching SET pagebreak = '1' WHERE element_spr = '$pred' AND ank_id='".$this->anketa."'"); + $change = true; + } + + // zadnja spremenljivka v loopu + $za = $this->find_last_in_if($loop); + + // loop cez spremenljivke v loopu + foreach ($spremenljivke AS $spr) { + + if ($spr != $za) { + // spremenljivke v loopu nimajo pb (razen zadnje) + $row = Cache::srv_branching($spr, 0); + if ($row['pagebreak'] == 1) { + sisplet_query("UPDATE srv_branching SET pagebreak = '0' WHERE element_spr = '$spr' AND ank_id='".$this->anketa."'"); + $change = true; + } + } + + } + + // zadnja spremenljivka v loopu - mora imet pb + $row = Cache::srv_branching($za, 0); + if ($row['pagebreak'] == 0) { + sisplet_query("UPDATE srv_branching SET pagebreak = '1' WHERE element_spr = '$za' AND ank_id='".$this->anketa."'"); + $change = true; + } + + } + + if ($change) { + $this->repare_vrstni_red(); + $this->trim_grupe(); + $this->pagebreak = array(); + Cache::clear_branching_cache(); + } + + } + + /** + * preveri, ce je podani element loop, ali pa ima parenta, ki je loop + * + */ + function find_loop_parent ($parent) { + + if ($parent == 0) return 0; + + $sql = sisplet_query("SELECT id FROM srv_if WHERE id = '$parent' AND tip = '2'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + if (mysqli_num_rows($sql) > 0) + return $parent; + + $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '0' AND element_if = '$parent' AND ank_id='$this->anketa'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + return $this->find_loop_parent($row['parent']); + + } + + /** + * preveri, ce je podani element loop, ali pa ima childa, ki je loop + * + */ + function find_loop_child ($if) { + + $sql = sisplet_query("SELECT id FROM srv_if WHERE id = '$if' AND tip = '2'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + if (mysqli_num_rows($sql) > 0) + return $if; + + $sql = sisplet_query("SELECT element_if FROM srv_branching WHERE parent = '$if' AND element_if > '0' AND ank_id='$this->anketa'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + while ($row = mysqli_fetch_array($sql)) { + return $this->find_loop_child($row['element_if']); + } + + return 0; + } + + /** + * poisce, ce ima podani element parenta, ki je loop + * + */ + function find_parent_loop ($element_spr, $element_if=0) { + + $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='$this->anketa'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + if ($row['parent'] == 0) return 0; + + $sql = sisplet_query("SELECT id FROM srv_if WHERE id = '$row[parent]' AND tip = '2'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + if (mysqli_num_rows($sql) > 0) + return $row['parent']; + else + return $this->find_parent_loop(0, $row['parent']); + + } + + function displayKomentarji($displayKomentarji = true) { + $this->displayKomentarji = $displayKomentarji; + } + + //funkcija za izris hotspot + //radio grid + function vprasanje_hotspot($spremenljivka, $tip, $enota_orientation){ + global $lang; + + $row = Cache::srv_spremenljivka($spremenljivka); + $spremenljivkaParams = new enkaParameters($row['params']); + $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : ""); + + //zaslon razdelimo na dva dela - izris leve strani*************************************** + //echo '
    lang_id==null?'allow_new':'').'">'; + echo '
    '; + + + //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' AND other = 0 ORDER BY vrstni_red"); + $sql1_missing = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' AND other != 0 ORDER BY vrstni_red"); + + $sqlR = sisplet_query("SELECT * FROM srv_hotspot_regions WHERE spr_id='$row[id]' "); + + if($_GET['a'] == 'prevajanje'){ //ce se izvaja prevajanje + if (mysqli_num_rows($sqlR) != 0){ //ce so obmocja + + //pokazi shranjena obmocja + while ($rowR = mysqli_fetch_array($sqlR)) { + + //ureditev izbire imena obmocja glede na jezik ankete + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslovObmocja = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($rowR['vre_id']); + if ($naslovObmocja == ''){ + $naslovObmocja = $rowR['region_name']; + } + //echo "naslovObmocja: ".$naslovObmocja; + } + + echo '
    '.$naslovObmocja.'

    '; + } + } + } + else{ //ce ni prevajanje pokazi: + //GUMB za nalaganje in urejanje slike + if ( ($hotspot_image == '') || substr($hotspot_image, 0, 4) != '

    '; + echo '

    '; + + //Slika + echo '
    '.$hotspot_image.'
    '; + } + + + //skrita varianta od koder poberem height in width za urejanje obmocij + //izbira ustreznega radio ali checkbox za prikazovanje ob missingu + if ($tip == 1){ + $input = "radio"; + } + else if ($tip == 2){ + $input = "checkbox"; + } + + echo ''; + + echo '
    '; + + if (mysqli_num_rows($sql1) == 0){ + echo '
    '; + echo '
    '; + } + else{ + while ($row1 = mysqli_fetch_array($sql1)) { + + echo ' '; + } + while ($row1_missing = mysqli_fetch_array($sql1_missing)) { + + echo '
    '; + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1_missing['naslov'].'
    '; + echo '
    '; + } + } + + echo '
    '; + + + ?> + + '; + //************************* Izris leve strani - konec + + //************** Izris desne strani za grid + if($tip == 6){ //ce je radio grid izrisi desno stran + + echo '
    '; + echo ' '; + echo ' '; + + // urejanje vrednosti + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + echo ''; + + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND other=0 ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for ($i = 1; $i <= $row['grids']; $i++) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row2['id']); + if ($naslov != '') $row2['naslov'] = $naslov; + } + if ($row2['vrstni_red'] == $i) { + echo ' '; + $row2 = mysqli_fetch_array($sql2); + } else { + echo ' '; + } + } + + #kateri missingi so nastavljeni + $sql_grid_mv = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='".$spremenljivka."' AND other != 0"); + if (mysqli_num_rows($sql_grid_mv) > 0 ) { + echo ''; + while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) { + if ($this->lang_id != null) { + $naslov = \App\Controllers\LanguageController::srv_language_grid($row['id'], $row_grid_mv['id']); + if ($naslov != '') $row_grid_mv['naslov'] = $naslov; + } + + echo ''; + + } + + } + echo ''; + echo ' '; + + echo ''; + echo ''; + + $bg++; + + + //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)"); + $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + while ($row1 = mysqli_fetch_array($sql1)) { + + if ($this->lang_id != null) { + save('lang_id', $this->lang_id); + $naslov = \App\Controllers\LanguageController::getInstance()->srv_language_vrednost($row1['id']); + if ($naslov != '') $row1['naslov'] = $naslov; + } + + $bg++; + } + + echo ' '; + + echo '
    ' . $row2['variable'] . '
    '.$grid_plus_minus.'
    lang_id!=null ? ' default="1"':'').'>' . $row2['naslov'] . '
    lang_id!=null ?' default="1"':'').'>' . $row_grid_mv['naslov'] . '
    '; + echo '
    '; + + } + //************** Izris desne strani za grid - konec + + + //************** Izris desne strani za image hotspot razvrscanje + if($tip == 17 || $row['design'] == 3){ //ce je razvrscanje z image hotspot izrisi desno stran + echo '
    '; + echo ' '; + echo ' '; + + // urejanje vrednosti + echo ' '; + echo ' '; + + $bg = 1; + + $sql2 = sisplet_query("SELECT * FROM srv_hotspot_regions WHERE spr_id='$row[id]' ORDER BY vrstni_red"); + $row2 = mysqli_fetch_array($sql2); + + for($indeks=1;$indeks <= mysqli_num_rows($sql2);$indeks++){ + echo ''; + $row2 = mysqli_fetch_array($sql2); + } + echo ''; + + echo ' '; + echo ' '; + + $bg = 1; + + echo ''; + echo ' '; + + echo ''; + + echo '
    ' . $row2['vrstni_red'] . '
    '.$grid_plus_minus.'
    '; + echo '
    '; + + } + //************** Izris desne strani za image hotspot razvrscanje - konec + + + //***********************Image hot spot konec************************************************************* + } + + //funkcija za izris heatmap + //radio grid + function vprasanje_heatmap($spremenljivka, $tip){ + global $lang; + + $row = Cache::srv_spremenljivka($spremenljivka); + $spremenljivkaParams = new enkaParameters($row['params']); + $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : ""); + $spremenljivkaParams->set('multi_input_type', 'marker'); + + echo '
    '; + + $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$row[id]' AND other = 0 ORDER BY vrstni_red"); + $sql1_missing = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$row[id]' AND other != 0 ORDER BY vrstni_red"); + + //GUMB za nalaganje in urejanje slike + if ( ($hotspot_image == '') || substr($hotspot_image, 0, 4) != '

    '; + + echo '
    '.$hotspot_image.'
    '; + + + //skrita varianta od koder poberem height in width za urejanje obmocij + //izbira ustreznega radio ali checkbox za prikazovanje ob missingu + $input = "checkbox"; + + echo ''; + + echo '
    '; + + if (mysqli_num_rows($sql1) == 0){ + echo '
    '; + echo '
    '; + } + else{ + while ($row1 = mysqli_fetch_array($sql1)) { + + echo ''; + } + while ($row1_missing = mysqli_fetch_array($sql1_missing)) { + echo '
    '; + echo '
    lang_id!=null ? ' default="1"':'').'>' . $row1_missing['naslov'].'
    '; + echo '
    '; + } + } + echo '
    '; + + ?> + + '; + //***********************Heatmap konec************************************************************* + } + + + // Vrnemo string orientacije za vprasanje + private function getVprasanjeOrientationString($type, $orientation){ + global $lang; + + // Prva stevilka je tip vprasanja, druga tip orientacije + switch($type.'-'.$orientation){ + + case '1-0': + case '2-0': + case '21-0': + case '7-0': + case '8-0': + $orientation_string = $lang['srv_orientacija_horizontalna']; + break; + + case '1-2': + case '2-2': + case '21-2': + $orientation_string = $lang['srv_orientacija_horizontalna_2']; + break; + + case '21-3': + $orientation_string = $lang['srv_orientacija_vertikalna']; + break; + + case '1-4': + case '3-1': + case '6-2': + $orientation_string = $lang['srv_dropdown']; + break; + + case '1-6': + case '2-6': + $orientation_string = $lang['srv_select-box_radio']; + break; + + case '1-7': + case '2-7': + $orientation_string = $lang['srv_orientacija_vertikalna_2']; + break; + + case '1-8': + case '2-8': + $orientation_string = $lang['srv_drag_drop']; + break; + + case '1-9': + case '6-12': + $orientation_string = $lang['srv_custom-picture_radio']; + break; + + case '1-10': + case '2-10': + case '6-10': + $orientation_string = $lang['srv_hot_spot']; + break; + + case '1-11': + case '6-11': + $orientation_string = $lang['srv_visual_analog_scale']; + break; + + + case '6-1': + $orientation_string = $lang['srv_diferencial2']; + break; + + case '6-3': + case '16-3': + $orientation_string = $lang['srv_double_grid']; + break; + + case '6-4': + $orientation_string = $lang['srv_one_against_another']; + break; + + case '6-5': + $orientation_string = $lang['srv_max_diff']; + break; + + case '6-6': + case '16-6': + $orientation_string = $lang['srv_select-box_radio']; + break; + + case '6-8': + $orientation_string = $lang['srv_orientacija_tabela_da_ne']; + break; + + case '6-9': + case '16-9': + $orientation_string = $lang['srv_drag_drop']; + break; + + default: + $orientation_string = ''; + break; + } + + return $orientation_string; + } +} + +?> -- cgit v1.2.3