'; echo $row['js_tracking']; echo ''; } } /** * @desc generira JavaScript za alert pri vprasanjih z reminderjem */ public function generateSubmitJS() { global $lang; global $site_url; global $secret_captcha; global $admin_type; // Dodaten text pri alertu ce smo v testnem vnosu $test_alert = (isset($_GET['testdata']) && $_GET['testdata'] == 'on') ? '\n\n' . $lang['srv_remind_preview'] : ''; // Custom texti za opozorila... SurveySetting::getInstance()->Init(get('anketa')); if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; $srv_remind_sum_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_sum_hard' . $_lang); if ($srv_remind_sum_hard == '') $srv_remind_sum_hard = $lang['srv_remind_sum_hard']; $srv_remind_sum_hard = strip_tags(addslashes(stripslashes($srv_remind_sum_hard))).$test_alert; $srv_remind_sum_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_sum_soft' . $_lang); if ($srv_remind_sum_soft == '') $srv_remind_sum_soft = $lang['srv_remind_sum_soft']; $srv_remind_sum_soft = strip_tags(addslashes(stripslashes($srv_remind_sum_soft))).$test_alert; $srv_remind_num_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_num_hard' . $_lang); if ($srv_remind_num_hard == '') $srv_remind_num_hard = $lang['srv_remind_num_hard']; $srv_remind_num_hard = strip_tags(addslashes(stripslashes($srv_remind_num_hard))).$test_alert; $srv_remind_num_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_num_soft' . $_lang); if ($srv_remind_num_soft == '') $srv_remind_num_soft = $lang['srv_remind_num_soft']; $srv_remind_num_soft = strip_tags(addslashes(stripslashes($srv_remind_num_soft))).$test_alert; $srv_remind_text_num_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_text_num_hard' . $_lang); if ($srv_remind_text_num_hard == '') $srv_remind_text_num_hard = $lang['srv_remind_text_num_hard']; $srv_remind_text_num_hard = strip_tags(addslashes(stripslashes($srv_remind_text_num_hard))).$test_alert; $srv_remind_text_num_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_text_num_soft' . $_lang); if ($srv_remind_text_num_soft == '') $srv_remind_text_num_soft = $lang['srv_remind_text_num_soft']; $srv_remind_text_num_soft = strip_tags(addslashes(stripslashes($srv_remind_text_num_soft))).$test_alert; //za minimalno stevilo izbranih checkbox-ov $srv_remind_checkbox_min_violated_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_checkbox_min_violated_hard' . $_lang); if ($srv_remind_checkbox_min_violated_hard == '') $srv_remind_checkbox_min_violated_hard = $lang['srv_remind_checkbox_min_violated_hard']; $srv_remind_checkbox_min_violated_hard = strip_tags(addslashes(stripslashes($srv_remind_checkbox_min_violated_hard))).$test_alert; $srv_remind_checkbox_min_violated_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_checkbox_min_violated_soft' . $_lang); if ($srv_remind_checkbox_min_violated_soft == '') $srv_remind_checkbox_min_violated_soft = $lang['srv_remind_checkbox_min_violated_soft']; $srv_remind_checkbox_min_violated_soft = strip_tags(addslashes(stripslashes($srv_remind_checkbox_min_violated_soft))).$test_alert; //za minimalno stevilo izbranih checkbox-ov - konec $srv_remind_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard' . $_lang); if ($srv_remind_hard == '') $srv_remind_hard = $lang['srv_remind_hard']; $srv_remind_hard = strip_tags(addslashes(stripslashes($srv_remind_hard))).$test_alert; $srv_remind_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft' . $_lang); if ($srv_remind_soft == '') $srv_remind_soft = $lang['srv_remind_soft']; $srv_remind_soft = strip_tags(addslashes(stripslashes($srv_remind_soft))).$test_alert; $srv_remind_hard_99 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-99' . $_lang); if ($srv_remind_hard_99 == '') $srv_remind_hard_99 = $lang['srv_remind_hard_-99']; $srv_remind_hard_99 = strip_tags(addslashes(stripslashes($srv_remind_hard_99))).$test_alert; $srv_remind_soft_99 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-99' . $_lang); if ($srv_remind_soft_99 == '') $srv_remind_soft_99 = $lang['srv_remind_soft_-99']; $srv_remind_soft_99 = strip_tags(addslashes(stripslashes($srv_remind_soft_99))).$test_alert; $srv_remind_hard_98 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-98' . $_lang); if ($srv_remind_hard_98 == '') $srv_remind_hard_98 = $lang['srv_remind_hard_-98']; $srv_remind_hard_98 = strip_tags(addslashes(stripslashes($srv_remind_hard_98))).$test_alert; $srv_remind_soft_98 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-98' . $_lang); if ($srv_remind_soft_98 == '') $srv_remind_soft_98 = $lang['srv_remind_soft_-98']; $srv_remind_soft_98 = strip_tags(addslashes(stripslashes($srv_remind_soft_98))).$test_alert; $srv_remind_hard_97 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-97' . $_lang); if ($srv_remind_hard_97 == '') $srv_remind_hard_97 = $lang['srv_remind_hard_-97']; $srv_remind_hard_97 = strip_tags(addslashes(stripslashes($srv_remind_hard_97))).$test_alert; $srv_remind_soft_97 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-97' . $_lang); if ($srv_remind_soft_97 == '') $srv_remind_soft_97 = $lang['srv_remind_soft_-97']; $srv_remind_soft_97 = strip_tags(addslashes(stripslashes($srv_remind_soft_97))).$test_alert; $srv_remind_hard_multi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_multi' . $_lang); if ($srv_remind_hard_multi == '') $srv_remind_hard_multi = $lang['srv_remind_hard_multi']; $srv_remind_hard_multi = strip_tags(addslashes(stripslashes($srv_remind_hard_multi))).$test_alert; $srv_remind_soft_multi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_multi' . $_lang); if ($srv_remind_soft_multi == '') $srv_remind_soft_multi = $lang['srv_remind_soft_multi']; $srv_remind_soft_multi = strip_tags(addslashes(stripslashes($srv_remind_soft_multi))).$test_alert; $srv_remind_captcha_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_captcha_soft' . $_lang); if ($srv_remind_captcha_soft == '') $srv_remind_captcha_soft = $lang['srv_remind_captcha_soft']; $srv_remind_captcha_soft = strip_tags(addslashes(stripslashes($srv_remind_captcha_soft))).$test_alert; $srv_remind_captcha_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_captcha_hard' . $_lang); if ($srv_remind_captcha_hard == '') $srv_remind_captcha_hard = $lang['srv_remind_captcha_hard']; $srv_remind_captcha_hard = strip_tags(addslashes(stripslashes($srv_remind_captcha_hard))).$test_alert; $srv_remind_email_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_email_soft' . $_lang); if ($srv_remind_email_soft == '') $srv_remind_email_soft = $lang['srv_remind_email_soft']; $srv_remind_email_soft = strip_tags(addslashes(stripslashes($srv_remind_email_soft))).$test_alert; $srv_remind_email_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_email_hard' . $_lang); if ($srv_remind_email_hard == '') $srv_remind_email_hard = $lang['srv_remind_email_hard']; $srv_remind_email_hard = strip_tags(addslashes(stripslashes($srv_remind_email_hard))).$test_alert; $srv_alert_number_toobig = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_alert_number_toobig' . $_lang); if ($srv_alert_number_toobig == '') $srv_alert_number_toobig = $lang['srv_alert_number_toobig']; $srv_alert_number_toobig = strip_tags(addslashes(stripslashes($srv_alert_number_toobig))).$test_alert; $srv_alert_number_exists = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_alert_number_exists' . $_lang); if ($srv_alert_number_exists == '') $srv_alert_number_exists = $lang['srv_alert_number_exists']; $srv_alert_number_exists = strip_tags(addslashes(stripslashes($srv_alert_number_exists))).$test_alert; $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables'); $srv_remind_checkbox_max_violated_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srv_remind_checkbox_max_violated_hard' . $_lang); if ($srv_remind_checkbox_max_violated_hard == '') $srv_remind_checkbox_max_violated_hard = $lang['srv_remind_checkbox_max_violated_hard']; $srv_remind_checkbox_max_violated_hard = strip_tags(addslashes(stripslashes($srv_remind_checkbox_max_violated_hard))).$test_alert; echo ' ' . "\n"; $sqlG = sisplet_query("SELECT spol FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'"); $rowG = mysqli_fetch_array($sqlG); $sql1 = sisplet_query("SELECT MAX(vrstni_red) AS vrstni_red FROM srv_grupa WHERE ank_id = '" . get('anketa') . "'"); $row1 = mysqli_fetch_array($sql1); $rowa = SurveyInfo::getInstance()->getSurveyRow(); //namesto naprej in nazaj se pri glasovanju izrise gumb potrdi oz. gumba moski/zenska pri izbiri spola if ($rowa['survey_type'] == 0) { if (!get('printPreview')) { if ($rowG['spol'] == 0) { $srv_potrdi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_potrdi'.$_lang); if ($srv_potrdi == '') $srv_potrdi = $lang['srv_potrdi']; echo '
' . "\n"; } else { echo ' ' . "\n"; } } //namesto naprej in nazaj izrise pri formi gumb poslji } elseif ($rowa['survey_type'] == 1) { SurveySetting::getInstance()->Init(get('anketa')); $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang); if ($srv_nextpage == '') $srv_nextpage = $lang['srv_forma_send']; if (!get('printPreview')) { echo ' ' . "\n"; } } else { SurveySetting::getInstance()->Init(get('anketa')); $row = SurveyInfo::getInstance()->getSurveyRow(); $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE ID = '" . get('grupa') . "'"); $rowg = mysqli_fetch_array($sqlg); // Smo na zadnji strani if ($row1['vrstni_red'] == $rowg['vrstni_red']) { // Dodatno preverimo ce imamo loop if(isset($_GET['loop_id']) && $_GET['loop_id'] > 0){ // Ce obstaja naslednji loop izpisemo "naslednja stran" in ne "zadnja stran" if(Find::getInstance()->findNextLoopId() > 0){ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage' . $_lang); if ($srv_nextpage == '') $srv_nextpage = $lang['srv_nextpage']; } else{ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_lastpage' . $_lang); if ($srv_nextpage == '') $srv_nextpage = $lang['srv_lastpage']; } } else{ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_lastpage' . $_lang); if ($srv_nextpage == '') $srv_nextpage = $lang['srv_lastpage']; } } else { $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage' . $_lang); if ($srv_nextpage == '') $srv_nextpage = $lang['srv_nextpage']; } $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang); if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage']; $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink'); if (!get('printPreview')) { echo ' ' . "\n"; } } } /** * @desc poklice generatorje JS kode za branching */ public function generateBranchingJS() { echo ' ' . "\n"; } /** * zgenerira koda za compute spremenljivke, ki si vrednost napolnijo samodejno iz calculation izraza * */ public function generateComputeJS() { if (get('generateComputeJS') != '') { echo 'try { ' . "\n"; echo ' ' . get('generateComputeJS') . "\n"; echo '} catch (e) {} ' . "\n"; } } /** * za podano spremenljivko zgenerira compute kodo, ki se shrani v začasno spremenljivko, da se na koncu izpiše s funkcijo generateComputeJS() * * @param mixed $spremenljivka */ public function generateCompute($spremenljivka) { // vrednost kalkulacije za ife add('generateComputeJS', "document.getElementById('vrednost_" . $spremenljivka . "').value = " . $this->generateCalculationJS(-$spremenljivka) . "; \n\r"); // vrednost se zapise v class .data-piping-SPR_ID za data-piping da se v zivo refresha add('generateComputeJS', " var val; if ( ! isNaN(document.getElementById('vrednost_" . $spremenljivka . "').value) ) val = document.getElementById('vrednost_" . $spremenljivka . "').value; else val = ''; \n\r"); add('generateComputeJS', " $('.data-piping-$spremenljivka').html( val ); \n\r"); } /** * @desc zgenerira kodo za IFe na vrednostih (podifi) */ public function generateVrednostIf() { SurveySetting::getInstance()->Init(get('anketa')); $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables'); $sql = sisplet_query("SELECT v.*, s.tip AS tip, s.id AS spr_id, s.dynamic_mg AS dynamic_mg, s.vsota_limit, s.design, s.params FROM srv_vrednost v, srv_spremenljivka s WHERE v.if_id>'0' AND v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0'"); while ($row = mysqli_fetch_array($sql)) { // Ce je odgovor skrit ga nikoli ne prikazemo in preskocimo kar celotno proceduro za to vrednost if($row['hidden'] == '1'){ continue; } //stavek za pobiranje informacij o tipu in orienataciji spremenljivke, potrebno za nadaljnje notranje pogoje za drag and drop $sqldd = sisplet_query("SELECT id, enota, orientation FROM srv_spremenljivka WHERE id = '$row[spr_id]'"); while ($rowdd = mysqli_fetch_array($sqldd)) { $spremenljivka_dd = $rowdd['id']; $orientation_dd = $rowdd['orientation']; $enota_dd = $rowdd['enota']; } // vsota - treba je se enkrat pognati racunanje if ($row['tip'] == 18) { $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[spr_id]' AND vrstni_red>0"); $max = mysqli_num_rows($sql1); $sum = ' calcSum(\'' . $row['spr_id'] . '\', \'' . $max . '\', \'' . $row['vsota_limit'] . '\'); ' . "\n"; } else $sum = ''; // dinamicni multigrid (za mobilne naprave) if ($row['tip'] == 6 && $enota_dd != 9 && $enota_dd != 3 && $row['dynamic_mg'] > 0) { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' dynamicMultigridSwitchIf(1, ' . $row['id'] . ', ' . $row['spr_id'] . '); ' . "\n"; echo ' } else { ' . "\n"; echo ' dynamicMultigridSwitchIf(0, ' . $row['id'] . ', ' . $row['spr_id'] . '); ' . "\n"; echo ' } ' . "\n"; echo ' } catch (e) {} ' . "\n"; } // Navaden multigrid else if ($row['tip'] == 6 && $enota_dd != 9 && $enota_dd != 3) { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; // Element je viden echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' var el = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; echo ' el.parentNode.removeChild( el );' . "\n"; // Element ni viden echo ' } else { ' . "\n"; // ker je element neviden, dodamo novega hidz vrednostjo -2 echo ' var el = document.getElementById(\'vrednost_if_' . $row['id'] . '\');' . "\n"; echo ' var hiddenEl = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; echo ' var parent = el.parentNode.parentNode.parentNode;' . "\n"; // V kolikor je hidden polje že postavljeno potem ga ponovno ne ustvarjamo -> se izognemo podvojenim vpisom v bazi echo ' if(!hiddenEl){' . "\n"; echo 'var newElement = document.createElement(\'input\');' . "\n"; echo ' newElement.setAttribute("id", "branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '");' . "\n"; echo ' newElement.setAttribute("name", "cond_vrednost_' . $row['id'] . '");' . "\n"; echo ' newElement.setAttribute("value", "-2");' . "\n"; echo ' newElement.setAttribute("type", "hidden");' . "\n"; echo ' parent.appendChild(newElement);' . "\n"; echo ' }' . "\n"; echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; echo ' } ' . "\n"; echo ' } catch (e) {} ' . "\n"; } // checkbox in ne drag and drop else if ($row['tip'] == 2 && ($row['orientation'] != 8 || get('mobile') == 1)) { if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' } else { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; echo ' } ' . "\n"; echo ' } catch (e) {} ' . "\n"; } else { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; // Element je viden echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' var el = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; echo ' el.parentNode.removeChild( el );' . "\n"; // Element ni viden echo ' } else { ' . "\n"; // ker je element neviden, dodamo novega hidz vrednostjo -2 echo ' var el = document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\');' . "\n"; echo ' var hiddenEl = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; echo ' var parent = el.parentNode.parentNode.parentNode;' . "\n"; // V kolikor je hidden polje že postavljeno potem ga ponovno ne ustvarjamo -> se izognemo podvojenim vpisom v bazi echo ' if(!hiddenEl){' . "\n"; echo 'var newElement = document.createElement(\'input\');' . "\n"; echo ' newElement.setAttribute("id", "branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '");' . "\n"; echo ' newElement.setAttribute("name", "cond_vrednost_' . $row['spr_id'] . '[]");' . "\n"; echo ' newElement.setAttribute("value", "' . $row['id'] . '");' . "\n"; echo ' newElement.setAttribute("type", "hidden");' . "\n"; echo ' parent.appendChild(newElement);' . "\n"; echo ' }' . "\n"; echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; echo ' } ' . "\n"; echo $sum; echo ' } catch (e) {} ' . "\n"; } } // roleta else if ($row['tip'] == 3) { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' document.getElementById(\'vrednost_' . $row['spr_id'] . '_chzn_o_' . $row['vrstni_red'] . '\').style.display = \'\'; ' . "\n"; echo ' } else { ' . "\n"; echo ' document.getElementById(\'vrednost_' . $row['spr_id'] . '_chzn_o_' . $row['vrstni_red'] . '\').style.display = \'none\'; ' . "\n"; echo ' } ' . "\n"; echo $sum; echo ' } catch (e) {} ' . "\n"; } // ranking premikanje else if ($row['tip'] == 17 && $row['design'] == 2) { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' } else { ' . "\n"; echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; echo ' $(\'#frame_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; echo ' } ' . "\n"; echo $sum; echo ' } catch (e) {} ' . "\n"; } // ranking prestavljanje else if ($row['tip'] == 17 && $row['design'] == 0) { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' } else { ' . "\n"; echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; echo ' $(\'#frame_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; echo ' } ' . "\n"; echo $sum; echo ' } catch (e) {} ' . "\n"; } else { if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' } else { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; echo ' } ' . "\n"; echo $sum; echo ' } catch (e) {} ' . "\n"; } else { echo ' try { ' . "\n"; echo ' if ( '; $this->generateCondition($row['if_id']); echo ' ) { ' . "\n"; echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; echo ' } else { ' . "\n"; echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; echo ' } ' . "\n"; echo $sum; echo ' } catch (e) {} ' . "\n"; } } // Po notranjih pogojih prikazemo ponavljanje naslovne vrstice za tabele ce je to vklopljeno if($row['tip'] == 6 || $row['tip'] == 16){ $spremenljivkaParams = new enkaParameters($row['params']); $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0); if($grid_repeat_header > 0){ echo ' gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['spr_id'].'\'); '; } } } } /** * @desc zgenerira kodo za branching */ public function generateBranching($parent = 0) { Cache::cache_all_srv_branching(get('anketa')); Cache::cache_all_srv_if(get('anketa')); foreach (Cache::srv_branching_parent(get('anketa'), $parent) AS $k => $row) { if ($row['element_if'] > 0) { $rowb = Cache::srv_if($row['element_if']); // build conditions //echo 'console.log("V generateBranching");'; echo ' try { ' . "\n"; echo ' if ('; if ($rowb['tip'] == 0) { // if if ($rowb['enabled'] == 1) echo 'true'; elseif ($rowb['enabled'] == 2) echo 'false'; else $this->generateCondition($row['element_if']); } else { // blok if ($rowb['enabled'] != 2) echo 'true'; else echo 'false'; } echo ' ) { ' . "\n"; // ko prikazujemo, prikazemo samo trenutni nivo foreach (Cache::srv_branching_parent(get('anketa'), $row['element_if']) AS $k1 => $row1) { if ($row1['element_spr'] > 0) { if (Helper::getGrupa($row1['element_spr']) == get('grupa')) { $rowc = Model::select_from_srv_spremenljivka($row1['element_spr']); if ($rowc['tip'] != 22 && $rowc['tip'] != 25) { // spremenljivka tipa compute in quota je izvzeta iz pogojev echo ' try { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $row1['element_spr'] . '\').style.display = "block"; ' . "\n"; echo ' document.getElementById(\'visible_' . $row1['element_spr'] . '\').value = \'1\'; ' . "\n"; // Dodamo class da je vprasanje v bloku echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child\'); ' . "\n"; // Dodamo class ce je vprasanje v bloku in je prikazano horizontalno if (Helper::checkParentHorizontal($row1) == 1) { echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'horizontal_block\'); ' . "\n"; } // Dodamo class ce je vprasanje v bloku in je prikazano z razpiranjem if (Helper::checkParentHorizontal($row1) == 2) { echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'expendable_block\'); ' . "\n"; } // Dodamo class z id-jem bloka echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child_'.$row['element_if'].'\'); ' . "\n"; //Uros - samo za tip 26 //ker se mapa ne kreira vredu, ce je hidden, jo je ob prikazu treba resizat ter nastavit bounds mape echo ' if('.$rowc['tip'].' == 26){ //resize map, ker je zaradi display=none postala velika 0 var map = document.getElementById("map_"+' . $row1['element_spr'] . ').gMap; google.maps.event.trigger(map, \'resize\'); //ce je 0 ali 1 marker, centriraj kot nastavi admin, drugace prilagodi markerjem if (st_markerjev[' . $row1['element_spr'] . '] == 0){ if(map.centerInMapKoordinate){ map.setCenter({lat: parseFloat(map.centerInMapKoordinate.center.lat), lng: parseFloat(map.centerInMapKoordinate.center.lng)}); } else centrirajMap(map.centerInMap, map); } else map.fitBounds(bounds[' . $row1['element_spr'] . ']); }'; echo ' } catch (e) {} ' . "\n"; } } } } $this->generateBranching($row['element_if']); // Ce imamo vklopljen modul panel moramo nastaviti status panelista glede na izpolnjen if if(SurveyInfo::checkSurveyModule('panel') == 1){ $sp = new SurveyPanel(get('anketa')); $panel_if = $sp->getPanelIf($row['element_if']); if($panel_if != ''){ echo '$(\'#panel_status\').val(\''.$panel_if.'\'); ' . "\n"; } } echo ' } else { ' . "\n"; // ko skrivamo, skrijemo vse (tudi podnivoje) (zato klic rekurzivne funkcije) foreach (Helper::getElements($row['element_if']) AS $key) { if (Helper::getGrupa($key) == get('grupa')) { $rowc = Model::select_from_srv_spremenljivka($key); if ($rowc['tip'] != 22 && $rowc['tip'] != 25) { // spremenljivka tipa compute in quota je izvzeta iz pogojev echo ' try { ' . "\n"; echo ' document.getElementById(\'spremenljivka_' . $key . '\').style.display = "none"; ' . "\n"; echo ' document.getElementById(\'visible_' . $key . '\').value = \'0\'; ' . "\n"; // Dodamo class da je vprasanje v bloku echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child\'); ' . "\n"; // Dodamo class ce je vprasanje v bloku in je prikazano horizontalno if (Helper::checkParentHorizontal($row) == 1) { echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'horizontal_block\'); ' . "\n"; } // Dodamo class ce je vprasanje v bloku in je prikazano z razpiranjem if (Helper::checkParentHorizontal($row) == 2) { echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'expendable_block\'); ' . "\n"; } // Dodamo class z id-jem bloka echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'block_child_' . $row['element_if'] . '\'); ' . "\n"; echo ' } catch (e) {} ' . "\n"; } } } echo ' } ' . "\n"; echo ' } catch (e) {} ' . "\n"; // RANDOMIZACIJA VSEBINE BLOKA // Randomiziramo vprasanja v bloku (ce imamo to vklopljeno) if ($rowb['random'] >= 0) { $questions = []; foreach (Cache::srv_branching_parent(get('anketa'), $rowb['id']) AS $key => $val) { if ($val['element_spr'] > 0) { $questions[] = $val['element_spr']; } } // Ce imamo nastavljen prikaz samo dolocenega stevila vprasanj $spr_count = ($rowb['random'] > 0) ? $rowb['random'] : count($questions); // Napolnimo seed za posameznega respondenta (da dobi vsakic isti vrstni red) mt_srand((int)get('usr_id') + (int)$rowb['id']); // Zgeneriramo random vrstni red $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($questions))); array_multisort($order, $questions); $order_in_block = json_encode($questions); echo ' blockRandomizeQuestions(\''.$rowb['id'].'\', \''.$order_in_block.'\', \''.get('usr_id').'\', \''.$spr_count.'\'); ' . "\n"; } // Randomiziramo bloke v bloku (ce imamo to vklopljeno) elseif ($rowb['random'] == -2) { $blocks = []; foreach (Cache::srv_branching_parent(get('anketa'), $rowb['id']) AS $key => $val) { if ($val['element_if'] > 0) { $if_el = Cache::srv_if($val['element_if']); // blok if ($if_el['tip'] == 1) { $blocks[] = $if_el['id']; } } } // Napolnimo seed za posameznega respondenta (da dobi vsakic isti vrstni red) mt_srand((int)get('usr_id') + (int)$rowb['id']); // Zgeneriramo random vrstni red $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($blocks))); array_multisort($order, $blocks); $order_in_block = json_encode($blocks); echo ' blockRandomizeBlocks(\'' . $rowb['id'] . '\', \'' . $order_in_block . '\', \'' . get('usr_id') . '\'); ' . "\n"; } } } // dodamo crte pri blokih, kjer so vprasanja postavljena horizontalno echo ' blockHorizontalLine(); ' . "\n"; } /** * @desc zgenerira pogoje za JS branching */ public function generateCondition($if) { $rowa = SurveyInfo::getInstance()->getSurveyRow(); $echo = ''; $sql = Cache::srv_condition($if); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $i = 0; while ($row = mysqli_fetch_array($sql)) { if ($i++ != 0) if ($row['conjunction'] == 0) $echo .= ' && '; else $echo .= ' || '; if ($row['negation'] == 1) $echo .= ' ! '; for ($i = 1; $i <= $row['left_bracket']; $i++) $echo .= ' ( '; // obicajne spremenljivke if ($row['spr_id'] > 0) { $row2 = Model::select_from_srv_spremenljivka($row['spr_id']); // obicne spremenljivke if ($row['vre_id'] == 0) { $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); // multigrid } elseif ($row['vre_id'] > 0) { $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE id = '$row[vre_id]'"); if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); $row1 = mysqli_fetch_array($sql1); } else $row1 = null; //�ud not hepen // kombinirana tabela if (in_array($row2['tip'], array(6, 16, 19, 20)) && $row2['gru_id'] == '-2') { if (in_array($row2['tip'], array(6, 16))) { $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c WHERE cond_id='$row[id]'"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; if ($rowa['mass_insert'] != 1 || $row2['tip'] != 6 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje // Ce imamo if pogoj za -1 -> neodgovor if ($row3['grd_id'] == '-1') { $condition = ''; // loop cez vse gride in preverimo ce je kaksen odkljukan $sqlG = sisplet_query("SELECT id, part, other FROM srv_grid WHERE spr_id='$row2[id]'"); while ($rowG = mysqli_fetch_array($sqlG)) { if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) { if ($rowG['other'] == 0) $condition .= '!document.getElementById(\'multi_' . $row2['id'] . '_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; else $condition .= '!document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { $condition .= '!document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $rowG['id'] . '\' '; } $condition .= ' && '; } $echo .= '(' . substr($condition, 0, -3) . ')'; } else { if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) { $sql4 = sisplet_query("SELECT part, other FROM srv_grid WHERE spr_id='$row2[id]' AND id='$row3[grd_id]'"); $row4 = mysqli_fetch_array($sql4); if ($row4['other'] == 0) $echo .= 'document.getElementById(\'multi_' . $row2['id'] . '_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; else $echo .= 'document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { $echo .= 'document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $row3['grd_id'] . '\' '; } } // masovni vnos } else { $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\').value == "' . $row3['grd_id'] . '"'; } } } elseif (in_array($row2['tip'], array(19, 20))) { $echo .= ' ( '; $echo .= ' document.getElementById(\'multi_' . $row2['id'] . '_' . $row['vre_id'] . '_grid_' . $row['grd_id'] . '\').value'; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; //if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; /*else $echo .= $row['text'];*/ $echo .= ' ) '; } // radio, checkbox, dropdown in multigrid (brez drag and drop) } elseif ((($row2['tip'] <= 3 && ($row2['orientation'] != 8 || get('mobile') == 1)) || ($row2['tip'] == 6 || $row2['tip'] == 16) && ($row2['enota'] != 9)) && ($row['spr_id'] || $row['vre_id'])) { if ($row['operator'] == 0) $echo .= ' '; else $echo .= ' ! '; $echo .= ' ( '; // obicne spremenljivke if ($row['vre_id'] == 0) { $sql3 = sisplet_query("SELECT c.vre_id, v.id, v.vrstni_red, v.other FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; if ($rowa['mass_insert'] != 1 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje // Ce imamo if pogoj za -1 -> neodgovor if ($row3['vre_id'] == '-1') { $condition = ''; // loop cez vse odgovore in preverimo ce je kaksen odkljukan $sqlV = sisplet_query("SELECT id, other FROM srv_vrednost WHERE spr_id='$row[spr_id]'"); while ($rowV = mysqli_fetch_array($sqlV)) { if ($row2['tip'] <= 2 && ($row2['orientation'] != 8 || get('mobile') == 1)) { if ($rowV['other'] >= 0) $condition .= '!document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $rowV['id'] . '\').checked '; else $condition .= '!document.getElementById(\'missing_value_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $rowV['id'] . '\').checked '; } else { $condition .= '!document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == \'' . $rowV['id'] . '\' '; } $condition .= ' && '; } $echo .= '(' . substr($condition, 0, -3) . ')'; } else { //if ($row2['tip'] <= 2) { if ($row2['tip'] <= 2 && ($row2['orientation'] != 8 || get('mobile') == 1)) { if ($row3['other'] >= 0) $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').checked '; else $echo .= 'document.getElementById(\'missing_value_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').checked '; } else { $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == \'' . $row3['id'] . '\' '; } } // masovni vnos } else { if ($row2['tip'] != 2) { // radio, dropdown $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == "' . $row3['vrstni_red'] . '"'; } else { // checkbox $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').value == "1"'; } } } // multigrid } elseif ($row['vre_id'] > 0) { $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; if ($rowa['mass_insert'] != 1 || $row2['tip'] != 6 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje // Ce imamo if pogoj za -1 -> neodgovor if ($row3['grd_id'] == '-1') { $condition = ''; // loop cez vse gride in preverimo ce je kaksen odkljukan $sqlG = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row2[id]'"); while ($rowG = mysqli_fetch_array($sqlG)) { if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) { if ($rowG['other'] == 0) $condition .= '!document.getElementById(\'vrednost_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; else $condition .= '!document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; //} elseif ($row2['enota'] == 2) { } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { $condition .= '!document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $rowG['id'] . '\' '; } $condition .= ' && '; } $echo .= '(' . substr($condition, 0, -3) . ')'; } else { if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3 || $row2['enota'] == 4 || $row2['enota'] == 8) { $sql4 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row2[id]' AND id='$row3[grd_id]'"); $row4 = mysqli_fetch_array($sql4); if ($row4['other'] == 0) $echo .= 'document.getElementById(\'vrednost_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; else $echo .= 'document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; //} elseif ($row2['enota'] == 2) { } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { $echo .= 'document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $row3['grd_id'] . '\' '; } } // masovni vnos } else { $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\').value == "' . $row3['grd_id'] . '"'; } } } $echo .= ' ) '; //drag and drop @ kategorije en odgovor } elseif ($row2['tip'] == 1 && ($row2['orientation'] == 8 && get('mobile') != 1)) { if ($row['operator'] == 0) $echo .= ' '; else $echo .= ' ! '; $echo .= ' ( '; //SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id $sql3 = sisplet_query("SELECT c.vre_id FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; //if ($row2['design'] == 0 && get('mobile') == 0) $echo .= ' $("#half2_frame_dropping_' . $row2['id'] . '").children("div").attr("value") == ' . $row3['vre_id']; //half2_frame_dropping_4271, half2_frame_dropping_1_4276 //spremenljivka_4276_vrednost_22811 } $echo .= ' ) '; //drag and drop @ kategorije vec odgovorov } elseif ($row2['tip'] == 2 && ($row2['orientation'] == 8 && get('mobile') != 1)) { $z = 0; if ($row['operator'] == 0) $echo .= ' '; else $echo .= ' ! '; $echo .= ' ( '; //SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id $sql3 = sisplet_query("SELECT c.vre_id FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; //if ($row2['design'] == 0 && get('mobile') == 0) for ($z = 1; $z <= $row2['grids']; $z++) { //preleti vse mozne odgovore in sestavi pogoj $echo .= ' $("#half2_frame_dropping_' . $row2['id'] . '").children("div :nth-child(' . $z . ')").attr("value") == ' . $row3['vre_id']; if ($z < $row2['grids']) { //ce ni zadnji mozni odgovor dodaj ali (||) $echo .= '||'; } } } $echo .= ' ) '; //drag and drop @ tabela en odgovor } elseif (($row2['tip'] == 6) && ($row2['enota'] == 9)) { if ($row['operator'] == 0) $echo .= ' '; else $echo .= ' ! '; $echo .= ' ( '; $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; //if ($row2['design'] == 0 && get('mobile') == 0) $echo .= ' $("#half2_frame_dropping_' . $row3['grd_id'] . '_' . $row2['id'] . '").children("div").attr("value") == ' . $row['vre_id']; } $echo .= ' ) '; //drag and drop @ tabela vec odgovorov } elseif (($row2['tip'] == 16) && ($row2['enota'] == 9)) { if ($row['operator'] == 0) $echo .= ' '; else $echo .= ' ! '; $echo .= ' ( '; $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; //if ($row2['design'] == 0 && get('mobile') == 0) for ($z = 1; $z <= $row2['grids']; $z++) { //preleti vse mozne odgovore in sestavi pogoj $echo .= ' $("#half2_frame_dropping_' . $row3['grd_id'] . '_' . $row2['id'] . '").children("div :nth-child(' . $z . ')").attr("value") == ' . $row['vre_id']; if ($z < $row2['grids']) { //ce ni zadnji mozni odgovor dodaj ali (||) $echo .= '||'; } } } $echo .= ' ) '; // razvrscanje } elseif ($row2['tip'] == 17) { if ($row['operator'] == 0) $echo .= ' '; else $echo .= ' ! '; $echo .= ' ( '; $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); $j = 0; while ($row3 = mysqli_fetch_array($sql3)) { if ($j++ != 0) $echo .= ' || '; if ($row2['design'] == 0 && get('mobile') == 0) // prestavljanje $echo .= ' $(\'#half2_' . $row2['id'] . '\').sortable(\'toArray\')[' . ($row3['grd_id'] - 1) . '] == \'spremenljivka_'.$row['spr_id'].'_vrednost_' . $row['vre_id'] . '\' '; elseif ($row2['design'] == 1 || get('mobile') > 0) // ostevilcevanje $echo .= ' document.getElementsByName(\'spremenljivka_' . $row2['id'] . '_vrednost_' . $row['vre_id'] . '\')[0].value == \'' . ($row3['grd_id']) . '\' '; elseif ($row2['design'] == 2 && get('mobile') == 0) // premikanje $echo .= ' $(\'#sortzone_' . $row2['id'] . '\').sortable(\'toArray\')[' . ($row3['grd_id'] - 1) . '] == \'spremenljivka_'.$row['spr_id'].'_vrednost_' . $row['vre_id'] . '\' '; } $echo .= ' ) '; // tabela text, tabela stevilo } elseif ($row2['tip'] == 19 || $row2['tip'] == 20) { $echo .= ' ( '; $echo .= ' document.getElementById(\'vrednost_' . $row['vre_id'] . '_grid_' . $row['grd_id'] . '\').value'; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; //if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; /*else $echo .= $row['text'];*/ $echo .= ' ) '; // textbox } elseif ($row2['tip'] == 21) { $echo .= ' ( '; if ($row['operator'] <= 5) $echo .= 'document.getElementsByName(\'vrednost_' . $row['spr_id'] . '_kos_' . $row['vre_id'] . '\')[0].value'; else $echo .= 'document.getElementsByName(\'vrednost_' . $row['spr_id'] . '_kos_' . $row['vre_id'] . '\')[0].value.length'; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 6) $echo .= ' == '; elseif ($row['operator'] == 7) $echo .= ' < '; elseif ($row['operator'] == 8) $echo .= ' > '; $echo .= '"' . $row['text'] . '"'; $echo .= ' ) '; // number, compute in kvota majo drugacne pogoje in opcije } elseif ($row2['tip'] == 4 || $row2['tip'] == 7 || $row2['tip'] == 22 || $row2['tip'] == 25) { $echo .= ' ( '; if ($row2['tip'] == 7) // number ma drugacen ID, ker ima lahko dva polja $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . ($row['grd_id'] + 1) . '\').value'; else $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value'; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; if ($row2['tip'] == 4 || $row['operator'] == 0 || $row['operator'] == 1) $echo .= '"' . $row['text'] . '"'; else { if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; else $echo .= $row['text']; } $echo .= ' ) '; // datum } elseif ($row2['tip'] == 8) { $echo .= ' ( '; $echo .= 'Date.parse(convertDate(document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value))'; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; else $echo .= 'Date.parse(convertDate("' . $row['text'] . '"))'; $echo .= ' ) '; // vsota } elseif ($row2['tip'] == 18) { $echo .= ' ( '; $echo .= 'document.getElementsByName(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\')[0].value'; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; else $echo .= $row['text']; $echo .= ' ) '; } // recnum } elseif ($row['spr_id'] == -1) { $echo .= ' ( _recnum % ' . $row['modul'] . ' == ' . $row['ostanek'] . ' ) '; // calculations } elseif ($row['spr_id'] == -2) { $echo .= ' ( '; $echo .= $this->generateCalculationJS($row['id']); if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; else $echo .= $row['text']; $echo .= ' ) '; // quotas } elseif ($row['spr_id'] == -3) { $quota = Check::getInstance()->checkQuota($row['id']); $echo .= ' ( '; $echo .= $quota; if ($row['operator'] == 0) $echo .= ' == '; elseif ($row['operator'] == 1) $echo .= ' !== '; elseif ($row['operator'] == 2) $echo .= ' < '; elseif ($row['operator'] == 3) $echo .= ' <= '; elseif ($row['operator'] == 4) $echo .= ' > '; elseif ($row['operator'] == 5) $echo .= ' >= '; if ($row['text'] == '') $echo .= '"' . $row['text'] . '"'; else $echo .= $row['text']; $echo .= ' ) '; // naprava } elseif ($row['spr_id'] == -4) { if (in_array($row['text'], array('0','1','2','3'))){ // Star nacin detekcije - vedno vezan na prvi prihod, po novem detektiramo vsakic posebej /*$sqlU = sisplet_query("SELECT device FROM srv_user WHERE ank_id='".get('anketa')."' AND id='".get('usr_id')."'"); $rowU = mysqli_fetch_array($sqlU); $echo .= $row['text'] . ' == ' . $rowU['device'];*/ $device = 0; $useragent = $_SERVER['HTTP_USER_AGENT']; if ($useragent != '' && get_cfg_var('browscap')) { $browser_detect = get_browser($useragent, true); $detect = New Mobile_Detect(); $detect->setUserAgent($useragent); // Detect naprave (pc, mobi, tablet, robot) if ($detect->isMobile()) { if ($detect->isTablet()) $device = 2; else $device = 1; } elseif ($browser_detect['crawler'] == 1){ $device = 3; } } $echo .= ' ( '; $echo .= $row['text'] . ' == ' . $device; $echo .= ' ) '; } } for ($i = 1; $i <= $row['right_bracket']; $i++) $echo .= ' ) '; } // failsafe, ce se poklika if, pa se ne nastavi pogoja if ($echo == '') $echo .= ' true '; echo $echo; } /** * @desc zgenerira kalkulacijo za vstavitev v JS */ public function generateCalculationJS($condition) { $calculationSpr = Cache::srv_spremenljivka(-$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']); $i = 0; $expression = ''; while ($row = mysqli_fetch_array($sql)) { if ($i++ != 0) if ($row['operator'] == 0) $expression .= ' + '; elseif ($row['operator'] == 1) $expression .= ' - '; elseif ($row['operator'] == 2) $expression .= ' * '; elseif ($row['operator'] == 3) $expression .= ' / '; for ($i = 1; $i <= $row['left_bracket']; $i++) $expression .= ' ( '; // spremenljivke if ($row['spr_id'] > 0) { // obicne spremenljivke if ($row['vre_id'] == 0) { $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); $spr = $row1['id']; $vre = 0; $grd = $row['grd_id']; $tip = $row1['tip']; } // checkbox, multigrid elseif ($row['vre_id'] > 0) { $sql1 = sisplet_query("SELECT v.spr_id, v.id, s.tip AS tip FROM srv_vrednost v, srv_spremenljivka s WHERE v.id = '$row[vre_id]' AND v.spr_id=s.id"); if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); $row1 = mysqli_fetch_array($sql1); $spr = $row1['spr_id']; $vre = $row1['id']; $tip = $row1['tip']; $grd = $row['grd_id']; } else { $spr = 0; $vre = 0; $tip = 0; $grd = 0; } // Preverimo kako obravnavamo missinge - posamezno kot 0 ali kot -88 za celo kalkulacijo $newParams = new enkaParameters($calculationSpr['params']); $calcMissing = $newParams->get('calcMissing', '0'); $expression .= " checkCalculation('{$spr}', '{$vre}', '{$grd}', '{$tip}', '{$calcMissing}') "; } // konstante elseif ($row['spr_id'] == -1) { $expression .= $row['number']; } // recnum elseif ($row['spr_id'] == -2) { $sqlu = sisplet_query("SELECT recnum FROM srv_user WHERE id='".get('usr_id')."'"); $rowu = mysqli_fetch_array($sqlu); $expression .= $rowu['recnum']; } for ($i = 1; $i <= $row['right_bracket']; $i++) $expression .= ' ) '; } // Zaokrozimo na doloceno stevilo decimalk $decimals = $calculationSpr['decimalna']; $expression = 'parseFloat((' . $expression . ').toFixed(' . $decimals . '))'; return '(' . $expression . ')'; } }