anketa = $anketa; if (isset($surveySkin)) $this->skin = $surveySkin; SurveyInfo::getInstance()->SurveyInit($this->anketa); } /** * @desc pohendla ajax zahteve */ function ajax () { if (isset($_POST['anketa'])) $this->anketa = $_POST['anketa']; if (isset($_POST['spremenljivka'])) $this->spremenljivka = $_POST['spremenljivka']; if (strpos($_SERVER['HTTP_REFERER'], 'parent_if') !== false) { $_GET['parent_if'] = substr( $_SERVER['HTTP_REFERER'], strpos($_SERVER['HTTP_REFERER'], 'parent_if')+10 ); } // genericna resitev $ajax = 'ajax_' . $_GET['a']; if ( method_exists('BranchingAjax', $ajax) ) $this->$ajax(); else echo 'method '.$ajax.' does not exist'; } function ajax_follow_up_condition($ank_id = null, $if_id = null, $odg_id = null, $spr_id = null) { if ($ank_id == null) $ank_id = $_POST['ank_id']; if ($if_id == null) $if_id = $_POST['if_id']; if ($odg_id == null) $odg_id = $_POST['odg_id']; if ($spr_id == null) $spr_id = $_POST['spr_id']; $sql = sisplet_query("SELECT naslov FROM srv_vrednost WHERE id = '$odg_id'"); $naslov = mysqli_fetch_array($sql); sisplet_query("UPDATE srv_if SET label='$naslov[0]' WHERE id='$if_id'"); $sql_id = sisplet_query("SELECT id FROM srv_condition WHERE if_id='$if_id'"); $id_condition = mysqli_fetch_array($sql_id); sisplet_query("UPDATE srv_condition SET spr_id='$spr_id' WHERE id='$id_condition[0]'"); sisplet_query("INSERT INTO srv_condition_vre (cond_id, vre_id) VALUES ('$id_condition[0]', '$odg_id')"); } //generira blok (dropdown in menu) za missinge za kategorije function ajax_get_missing_block () { global $lang; $b = new Branching($this->anketa); $b->missings_menu($this->spremenljivka); } function ajax_if_new ($spremenljivka = null, $if = null, $endif = null, $tip = null) { global $lang; Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); $spremenljivka = (isset($_POST['spremenljivka']) && $spremenljivka == null) ? $_POST['spremenljivka'] : $spremenljivka; $if = (isset($_POST['if']) && $if == null) ? $_POST['if'] : $if; $endif = (isset($_POST['endif']) && $endif == null) ? $_POST['endif'] : $endif; $tip = (isset($_POST['tip']) && $tip == null) ? $_POST['tip'] : $tip; $copy = isset($_POST['copy']) ? $_POST['copy'] : 0; $no_content = isset($_POST['no_content']) ? $_POST['no_content'] : 0; $include_element = false; $b = new Branching($this->anketa); if ($spremenljivka >= 0 || $if >= 0) { $sqln = sisplet_query("SELECT MAX(i.number) AS number FROM srv_if i, srv_branching b WHERE b.ank_id='$this->anketa' AND b.element_if=i.id"); if (!$sqln) echo mysqli_error($GLOBALS['connect_db']); $rown = mysqli_fetch_array($sqln); $number = $rown['number'] + 1; $sql = sisplet_query("INSERT INTO srv_if (id, number, tip) VALUES ('', '$number', '$tip')"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $if_id = mysqli_insert_id($GLOBALS['connect_db']); if ($spremenljivka > 0 || ($if > 0 && $endif == 1)) { $sql = sisplet_query("SELECT parent, vrstni_red, element_spr, element_if FROM srv_branching WHERE element_spr = '$spremenljivka' AND element_if='$if'"); $row = mysqli_fetch_array($sql); } if ($spremenljivka == 0 && $if == 0) { if ($endif == 0) { // dodajanje na zacetek $row['parent'] = 0; $row['vrstni_red'] = 0; } else { // dodajanje na konec $row['parent'] = 0; $row['vrstni_red'] = 99999999; // ce je blok Demografija na zadnjem mestu v anketi, potem pri "dodajanju na konec" dodamo pred demografijo --da je demografija vedno na koncu $sqld = sisplet_query("SELECT b.element_if, b.vrstni_red FROM srv_if i, srv_branching b WHERE i.label = '$lang[srv_demografija]' AND i.tip='1' AND b.ank_id='$this->anketa' AND b.element_if=i.id AND parent='0' AND b.vrstni_red = (SELECT MAX(vrstni_red) FROM srv_branching WHERE ank_id='$this->anketa' AND parent = '0') "); if (mysqli_num_rows($sqld) > 0) { $rowd = mysqli_fetch_array($sqld); sisplet_query("UPDATE srv_branching SET vrstni_red = vrstni_red+1 WHERE element_if = $rowd[element_if] AND element_spr = '0' AND ank_id='$this->anketa'"); $row['vrstni_red'] = $rowd['vrstni_red']; } } } if ($if > 0 && $endif != 1) { $row['parent'] = $if; $row['vrstni_red'] = 0; } // dodajanje ifa na trenutno spremenljivko if ($spremenljivka > 0 && $endif == 1) { $next_element = $row; $include_element = true; // v if vkljucimo tudi trenutno spremenljivko // dodajanje ifa na naslednji element } else { $next_element = $b->find_next_element($row['parent'], $row['vrstni_red']); } if ($next_element == null) { // next_element je prazen na koncu ifa, takrat je tudi nov if prazen $next_element['parent'] = $row['parent']; $next_element['vrstni_red'] = $row['vrstni_red'] + 1; $next_element['element_spr'] = 0; $next_element['element_if'] = 0; } $add = true; // dodajamo loop - preverimo da ga ne zelimo vgnezditi v drug loop if ($tip == 2) { // preverimo, da ga ne dodamo v ze obstojec loop if ($b->find_loop_parent($next_element['parent']) > 0) $add = false; // preverimo, da ge ne dodamo direktno pred obstojec loop (ker potem objame obstojec loop in dobimo vgnezdenje) if ($next_element['element_if'] > 0) if ($b->find_loop_child($next_element['element_if']) > 0) $add = false; } if ($add) { $b->if_new($endif, $next_element['parent'], $if_id, $next_element['vrstni_red'], $next_element['element_spr'], $next_element['element_if'], $copy, $no_content, $include_element); sisplet_query("UPDATE srv_anketa SET branching='1' WHERE id = '$this->anketa'"); } else { $b->dropped_alert($lang['srv_loop_no_nesting']); } } $this->check_loop(); $b->repare_vrstni_red(); Common::getInstance()->prestevilci($spremenljivka, $all=true); // Zacasno shranimo zadnji ustvarjen if, da vemo katerega odpreti echo ''; $b->branching_struktura(); return $if_id; } function ajax_spremenljivka_new ($spremenljivka = null, $if = null, $endif = null, $copy=null, $tip=null, $podtip=null, $drop=null) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); if ($spremenljivka == null && isset($_POST['spremenljivka'])) $spremenljivka = $_POST['spremenljivka']; if ($if == null && isset($_POST['if'])) $if = $_POST['if']; if ($endif == null && isset($_POST['endif'])) $endif = $_POST['endif']; if ($copy == null && isset($_POST['copy'])) $copy = $_POST['copy']; if ($drop == null && isset($_POST['drop'])) $drop = $_POST['drop']; if ($tip == null && isset($_POST['tip'])) $tip = $_POST['tip']; if ($podtip == null && isset($_POST['podtip'])) $podtip = $_POST['podtip']; if ($tip == 23) { $copy = $podtip; $tip = 0; $podtip = 0; } elseif ($tip == 26) { $podtip = 1; } $b = new Branching($this->anketa); $this->spremenljivka_new($spremenljivka, $if, $endif, $copy, $drop); if ($tip > 0) { Vprasanje::change_tip($this->spremenljivka, $tip, $podtip); } if ($podtip > 0) { $v = new Vprasanje($this->anketa); $v->spremenljivka = $this->spremenljivka; ob_start(); if ($tip == 6) { // tabela en odgovor $v->ajax_change_diferencial($podtip); } elseif ($tip == 21) { // besedilo* if ($podtip == 1) { // captcha $v->set_captcha(); } elseif ($podtip == 2) { // email $v->set_email(); } elseif ($podtip == 3) { // url $v->set_url(); } elseif ($podtip == 4) { // upload $v->set_upload(); } elseif ($podtip == 5) { // text box $v->set_box(); } elseif ($podtip == 6) { // podpis $v->set_signature(); } elseif ($podtip == 7) { // fotografija $v->set_fotografija(); } } elseif ($tip == 19) { if ($podtip == 1) { $v->set_datum(); // multigrid datum } } elseif($tip == 26){ $v->set_map ($podtip); } elseif($tip == 5 && $podtip == 2){ $v->set_chat(); } elseif($tip == 7 && $podtip == 2){ $v->set_slider(); } elseif($tip == 1 && $podtip == 10) { // GDPR $v->set_GDPR(); } ob_clean(); } $b->repare_vrstni_red(); Common::getInstance()->prestevilci(); //$b->branching_struktura(); Cache::clear_cache(); $data = array(); $data['nova_spremenljivka_id'] = $this->spremenljivka; ob_start(); $b = new Branching($this->anketa); $b->spremenljivka = $this->spremenljivka; $b->branching_struktura(); $branching_struktura_text = ob_get_clean(); if(!mb_detect_encoding($branching_struktura_text, 'UTF-8', true)) $data['branching_struktura'] = utf8_encode($branching_struktura_text); else $data['branching_struktura'] = $branching_struktura_text; $this->check_loop(); ob_start(); $v = new Vprasanje($this->anketa); $v->spremenljivka = $this->spremenljivka; $v->ajax_vprasanje_fullscreen(); $vprasanje_fullscreen_text = ob_get_clean(); if(!mb_detect_encoding($vprasanje_fullscreen_text, 'UTF-8', true)) $data['vprasanje_fullscreen'] = utf8_encode($vprasanje_fullscreen_text); else $data['vprasanje_fullscreen'] = $vprasanje_fullscreen_text; echo json_encode($data); } /** * @desc kreira novo spremeniljvko v branchingu -- doda zapis tudi v srv_branching */ function spremenljivka_new ($spremenljivka, $if=0, $endif=0, $copy=0, $drop=0, $toStart=false) { Common::updateEditStamp(); global $lang; $b = new Branching($this->anketa); if ($spremenljivka >= 0 || $if > 0) { if ($if > 0) { if ($endif != 1) $spr_id = $b->find_first_in_if($if); else $spr_id = $b->find_next_spr($b->find_last_in_if($if)); } elseif ($spremenljivka > 0) { $spr_id = $spremenljivka; } elseif ($spremenljivka == 0 && $toStart==false) { $spr_id = $b->find_first_spr(); } elseif ($spremenljivka == 0 && $toStart==true) { $spr_id = $b->find_last_spr(); } $sqlS = sisplet_query("SELECT gru_id, vrstni_red FROM srv_spremenljivka WHERE id='$spr_id'"); $rowS = mysqli_fetch_array($sqlS); // Mogoce ni se nobenega vprasanja v anketi if ($rowS['gru_id'] == '0'){ $sqlG = sisplet_query("SELECT id, vrstni_red FROM srv_grupa WHERE ank_id='$this->anketa'"); $rowG = mysqli_fetch_array($sqlG); // Dodaten pogoj da nikoli tega ne pustimo, ce je gru_id==0 if($rowG['id'] == '0') die('group id error'); $spr_id = $b->nova_spremenljivka($rowG['id'], $rowG['vrstni_red'], 1, $copy); } elseif($rowS['gru_id'] < 0){ die('group id < 0 error'); } else{ // Povecamo vrstni red vsem kasnejsim vprasanjem v isti grupi sisplet_query("UPDATE srv_spremenljivka SET vrstni_red=vrstni_red+1 WHERE gru_id='$rowS[gru_id]' AND vrstni_red>'$rowS[vrstni_red]'"); $sqlG = sisplet_query("SELECT id, vrstni_red FROM srv_grupa WHERE ank_id='$this->anketa' AND id='$rowS[gru_id]'"); $rowG = mysqli_fetch_array($sqlG); $spr_id = $b->nova_spremenljivka($rowS['gru_id'], $rowG['vrstni_red'], $rowS['vrstni_red']+1, $copy); } $this->spremenljivka = $spr_id; if ( $this->spremenljivka == $spremenljivka ) die('copy error'); // 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 ($this->spremenljivka == 0 && $if == 0) die('copy error2'); if ($if > 0) { if ($endif != 1) { $sql = sisplet_query("INSERT INTO srv_branching (ank_id, parent, element_spr, element_if, vrstni_red) VALUES ('$this->anketa', '$if', '$spr_id', '0', '0')"); $b->repare_branching($if); } else { $sqlb = sisplet_query("SELECT parent, vrstni_red FROM srv_branching WHERE element_spr='$spremenljivka' AND element_if='$if'"); $rowb = mysqli_fetch_array($sqlb); sisplet_query("UPDATE srv_branching SET vrstni_red=vrstni_red+1 WHERE parent='$rowb[parent]' AND vrstni_red>'$rowb[vrstni_red]' AND ank_id='$this->anketa'"); $rowb['vrstni_red']++; $sql = sisplet_query("INSERT INTO srv_branching (ank_id, parent, element_spr, element_if, vrstni_red) VALUES ('$this->anketa', '$rowb[parent]', '$spr_id', '0', '$rowb[vrstni_red]')"); $b->repare_branching($rowb['parent']); } } else { if ($spremenljivka > 0) { $sqlb = sisplet_query("SELECT parent, vrstni_red FROM srv_branching WHERE element_spr='$spremenljivka' AND element_if='$if'"); $rowb = mysqli_fetch_array($sqlb); sisplet_query("UPDATE srv_branching SET vrstni_red=vrstni_red+1 WHERE parent='$rowb[parent]' AND vrstni_red>'$rowb[vrstni_red]' AND ank_id='$this->anketa'"); $rowb['vrstni_red']++; } elseif ($spremenljivka == 0) { if ($endif == 0) { // dodajanje na zacetek $rowb['parent'] = 0; $rowb['vrstni_red'] = 0; } else { // dodajanje na konec $rowb['parent'] = 0; $rowb['vrstni_red'] = 99999999; // ce je blok Demografija na zadnjem mestu v anketi, potem pri "dodajanju na konec" dodamo pred demografijo --da je demografija vedno na koncu $sqld = sisplet_query("SELECT b.element_if, b.vrstni_red FROM srv_if i, srv_branching b WHERE i.label = '$lang[srv_demografija]' AND i.tip='1' AND b.ank_id='$this->anketa' AND b.element_if=i.id AND parent='0' AND b.vrstni_red = ( SELECT MAX(vrstni_red) FROM srv_branching WHERE ank_id='$this->anketa' AND parent = '0' )"); if (mysqli_num_rows($sqld) > 0) { $rowd = mysqli_fetch_array($sqld); sisplet_query("UPDATE srv_branching SET vrstni_red = vrstni_red+1 WHERE element_if = $rowd[element_if] AND element_spr = '0' AND ank_id='$this->anketa'"); $rowb['vrstni_red'] = $rowd['vrstni_red']; } } } $sql = sisplet_query("INSERT INTO srv_branching (ank_id, parent, element_spr, element_if, vrstni_red) VALUES ('$this->anketa', '$rowb[parent]', '$spr_id', '0', '$rowb[vrstni_red]')"); $b->repare_branching($rowb['parent']); // ++ nastavljanje pagebreakov // if ($drop == 2) { $s = sisplet_query("SELECT pagebreak FROM srv_branching WHERE element_spr='$spremenljivka' AND ank_id='$this->anketa'"); $r = mysqli_fetch_array($s); // preverimo se, ce imamo res pagebreak if ($r['pagebreak'] == 1) { $s = sisplet_query("UPDATE srv_branching SET pagebreak='1' WHERE element_spr='$this->spremenljivka' AND ank_id='$this->anketa'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $s = sisplet_query("UPDATE srv_branching SET pagebreak='0' WHERE element_spr='$spremenljivka' AND ank_id='$this->anketa'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); Cache::clear_branching_cache(); // drugace se polje pagebreak zakesira pri prikazu } } // -- nastavljanje pagebreakov // } } //return id nove spremenljivke za API return $spr_id; } /** * Uporablja se tudi v API, ampak zaenkrat samo za mobile app, zato sem ignoriral vse alerte in droppanje ifa * V kolikor se bo to uporabljalo tudi v API za sirso uporabo, je funkcijo potrebno ustrezno prilagoditi */ function ajax_accept_droppable ($child = 0, $vrstni_red = 0, $page_break = 0, $API_call = false, $parent = 0) { global $lang; Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); if(!$API_call){ $parent = $_POST['parent']; $tmp_p = str_replace('droppable_', '', $parent); $tmp_p = explode('-', $tmp_p); $parent = isset($tmp_p[0]) ? $tmp_p[0] : $parent; $vrstni_red = isset($tmp_p[1]) ? $tmp_p[1] : $vrstni_red; $page_break = isset($tmp_p[2]) ? $tmp_p[2] : $page_break; $child = $_POST['child']; $child = str_replace('branching_', '', $child); } $b = new Branching($this->anketa); // droppal smo spremenljivko if (is_numeric($parent) && is_numeric($child) && $child > 0) { if ($b->check_dropped_spremenljivka($child, $parent, $vrstni_red)) { $sql = sisplet_query("SELECT pagebreak FROM srv_branching WHERE element_spr = '$child'"); $row = mysqli_fetch_array($sql); $prev = $b->find_prev_spr($child); // preden zacnemo premikati, poiscemo predhodno spremenljivko, ki jo rabimo pri PB $s = sisplet_query("UPDATE srv_branching SET vrstni_red = (vrstni_red+1) WHERE parent='$parent' AND vrstni_red > '$vrstni_red' AND ank_id='$this->anketa'"); if (!$s && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$s && $API_call) return mysqli_error($GLOBALS['connect_db']); $sql = sisplet_query("UPDATE srv_branching SET parent='$parent', vrstni_red=('$vrstni_red'+1) WHERE element_spr='$child' AND ank_id='$this->anketa'"); if (!$sql && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$sql && $API_call) return mysqli_error($GLOBALS['connect_db']); // ++ nastavljanje pagebreakov // // spremenljivko smo spustili pred page break, zato zamenjamo pagebreak polja (to oznacuje $page_break == 2) if ($page_break == 2) { /*echo '$page_break == 2';*/ $s = sisplet_query("SELECT pagebreak FROM srv_branching WHERE parent='$parent' AND vrstni_red='$vrstni_red' AND ank_id='$this->anketa'"); $r = mysqli_fetch_array($s); // preverimo se, ce imamo res pagebreak - npr. ce spustimo cisto na konec, ga ni if ($r['pagebreak'] == 1) { /*echo '$r[pb] == 1';*/ $s = sisplet_query("UPDATE srv_branching SET pagebreak='1' WHERE element_spr='$child' AND ank_id='$this->anketa'"); if (!$s && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$s && $API_call) return mysqli_error($GLOBALS['connect_db']); $s = sisplet_query("UPDATE srv_branching SET pagebreak='0' WHERE parent='$parent' AND vrstni_red='$vrstni_red' AND ank_id='$this->anketa'"); if (!$s && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$s && $API_call) return mysqli_error($GLOBALS['connect_db']); Cache::clear_branching_cache(); // drugace se polje pagebreak zakesira pri prikazu } // ce je za spremenljivko page break, ga moramo ohraniti tam, kjer je } elseif ($row['pagebreak'] == 1) { /*echo '$row[pb] == 1';*/ $s = sisplet_query("SELECT element_spr FROM srv_branching WHERE parent='$parent' AND vrstni_red>='$vrstni_red' AND ank_id='$this->anketa' ORDER BY vrstni_red ASC LIMIT 1"); $r = mysqli_fetch_array($s); /*echo ' r: '.$r['element_spr'].' c:'. $child. ' prev:'.$prev.' previous:'. $b->find_prev_spr_branching($child);*/ // ce spremenljivko s PB spustimo na isto mesto, ne smemo popravljati PB if ($b->find_prev_spr_branching($child) != $prev /*|| $r['element_spr']==$child*/) { /*echo ' yes ';*/ if ($prev == 0 && $page_break != 2) { /*echo '$prev==0';*/ // ce premikamo prvo spremenljivko spustimo nekam za PB, ga zbrisemo (ker na prvem mestu ostane prazna stran) $s = sisplet_query("UPDATE srv_branching SET pagebreak='0' WHERE element_spr='$child' AND ank_id='$this->anketa'"); if (!$s && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$s && $API_call) return mysqli_error($GLOBALS['connect_db']); } elseif ($prev > 0) { /*echo '$prev>0';*/ // normalno - zamenjamo pagebreak-a $s = sisplet_query("UPDATE srv_branching SET pagebreak='0' WHERE element_spr='$child' AND ank_id='$this->anketa'"); if (!$s && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$s && $API_call) return mysqli_error($GLOBALS['connect_db']); $s = sisplet_query("UPDATE srv_branching SET pagebreak='1' WHERE element_spr='$prev' AND ank_id='$this->anketa'"); if (!$s && !$API_call) echo mysqli_error($GLOBALS['connect_db']); else if (!$s && $API_call) return mysqli_error($GLOBALS['connect_db']); } } /*else echo ' no';*/ Cache::clear_branching_cache(); // drugace se polje pagebreak zakesira pri prikazu } // na zadnjem mestu vedno popravimo, da ni pagebreaka (ker je nepotreben in lahko kasneje ko se premika kaj pokvari) $last = $b->find_last_spr_branching(); sisplet_query("UPDATE srv_branching SET pagebreak='0' WHERE element_spr='$last' AND ank_id='$this->anketa'"); // -- nastavljanje pagebreakov // $b->repare_branching(); } else $b->dropped_alert(); } // droppal smo if ali endif else { $child = str_replace('if', '', $child); // droppal smo if if (is_numeric($child)) { if (is_numeric($parent) && $child > 0 && $child != $parent) { $loop = false; // premikamo loop ali blok/if ki vsebuje loop if ($b->find_loop_child($child) > 0) { if ($parent > 0) { if ($b->find_loop_parent($parent) > 0) $loop = true; } } if ($b->check_dropped_if($child, $parent, $vrstni_red) && !$loop) { sisplet_query("UPDATE srv_branching SET vrstni_red = (vrstni_red+1) WHERE parent='$parent' AND vrstni_red > '$vrstni_red' AND ank_id='$this->anketa'"); $sql = sisplet_query("UPDATE srv_branching SET parent='$parent', vrstni_red=('$vrstni_red'+1) WHERE element_if='$child' AND ank_id='$this->anketa'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); // ++ nastavljanje pagebreakov // // ce if premaknemo na zgornjo stran pagebreaka, potem PB premaknemo na zadnjo spremenljivko v IFu if ($page_break == 2) { $s = sisplet_query("SELECT pagebreak FROM srv_branching WHERE parent='$parent' AND vrstni_red='$vrstni_red' AND ank_id='$this->anketa'"); $r = mysqli_fetch_array($s); if ($r['pagebreak'] == 1) { $s = sisplet_query("UPDATE srv_branching SET pagebreak='0' WHERE parent='$parent' AND vrstni_red='$vrstni_red' AND ank_id='$this->anketa'"); $s = sisplet_query("UPDATE srv_branching SET pagebreak='1' WHERE element_spr='{$b->find_last_spr_branching($child)}' AND ank_id='$this->anketa'"); Cache::clear_branching_cache(); // drugace se polje pagebreak zakesira pri prikazu } } // -- nastavljanje pagebreakov // $b->repare_branching(); } else { if ($loop) $b->dropped_alert($lang['srv_loop_no_nesting']); else $b->dropped_alert(); } } // droppal smo endif } else { $child = str_replace('end', '', $child); if (is_numeric($parent) && is_numeric($child)) { $sql = sisplet_query("SELECT parent, vrstni_red FROM srv_branching WHERE element_if = '$child'"); $row = mysqli_fetch_array($sql); $sql1 = sisplet_query("SELECT * FROM srv_branching WHERE parent='$child'"); $elements = mysqli_num_rows($sql1); // podaljsamo IF if ($row['parent'] == $parent && $row['vrstni_red'] <= $vrstni_red) { $loop = false; // preverjanje, ce premikamo ENDLOOP, da ne potegnemo cez kaksen drug loop $sqli = sisplet_query("SELECT tip FROM srv_if WHERE id = '$child'"); $rowi = mysqli_fetch_array($sqli); if ($rowi['tip'] == '2') { for ($i=$row['vrstni_red']+1; $i<=$vrstni_red; $i++) { $sqli = sisplet_query("SELECT element_if FROM srv_branching WHERE parent='$parent' AND vrstni_red='$i' AND ank_id='$this->anketa'"); $rowi = mysqli_fetch_array($sqli); if ($rowi['element_if'] > 0) if ($b->find_loop_child($rowi['element_if']) > 0) $loop = true; } } if (!$loop) { $vr = $elements+1; for ($i=$row['vrstni_red']+1; $i<=$vrstni_red; $i++) { sisplet_query("UPDATE srv_branching SET parent='$child', vrstni_red='$vr' WHERE parent='$parent' AND vrstni_red='$i' AND ank_id='$this->anketa'"); $vr++; } } else $b->dropped_alert($lang['srv_loop_no_nesting']); // krajsamo IF } elseif ($parent == $child) { $vr = $row['vrstni_red']+1; sisplet_query("UPDATE srv_branching SET vrstni_red=(vrstni_red+'$elements'-'$vrstni_red') WHERE parent='$row[parent]' AND vrstni_red>'$row[vrstni_red]' AND ank_id='$this->anketa'"); for ($i=$vrstni_red+1; $i<=$elements; $i++) { sisplet_query("UPDATE srv_branching SET parent='$row[parent]', vrstni_red='$vr' WHERE parent='$child' AND vrstni_red='$i' AND ank_id='$this->anketa'"); $vr++; } } else $b->dropped_alert(); $b->repare_branching(); } } } $this->check_loop(); $b->repare_vrstni_red(); Common::getInstance()->prestevilci(); if(!$API_call) $b->branching_struktura(); } function ajax_if_remove ($if=0, $first=1) { global $lang; Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); $if = ($if == 0 && isset($_POST['if'])) ? $_POST['if'] : $if; // ali brisemo tudi celotno vsebino pogoja/bloka $all = (isset($_POST['all']) && $_POST['all'] == 1) ? 1 : 0; $b = new Branching($this->anketa); if ($if > 0) { // preverimo, ce obstajajo ze podatki za spremenljivko - v tem primeru damo dodaten error $confirmed = $_POST['confirmed']; if ($all == 1 && $confirmed != '1') { $sql = sisplet_query("SELECT count(*) AS count FROM srv_user WHERE ank_id='$this->anketa' AND deleted='0' AND preview='0'"); $row = mysqli_fetch_array($sql); if ($row['count'] > 0) { echo '
'.$lang['if_delete_data'].'
'; echo ''.$lang['srv_brisiifconfirm_all'].'
'; echo ' '; return; } } $sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id = '$if'"); while ($row = mysqli_fetch_array($sql)) sisplet_query("DELETE FROM srv_condition_vre WHERE cond_id='$row[id]'"); sisplet_query("DELETE FROM srv_condition WHERE if_id = '$if'"); sisplet_query("DELETE FROM srv_if WHERE id = '$if'"); sisplet_query("DELETE FROM srv_validation WHERE if_id='$if'"); $sql = sisplet_query("SELECT parent, vrstni_red FROM srv_branching WHERE element_if = '$if'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); if ($all == 0) { $sql1 = sisplet_query("SELECT * FROM srv_branching WHERE parent = '$if'"); $childs = mysqli_num_rows($sql1); sisplet_query("UPDATE srv_branching SET vrstni_red=(vrstni_red+'$childs'-1) WHERE parent='$row[parent]' AND vrstni_red > '$row[vrstni_red]' AND ank_id='$this->anketa'"); sisplet_query("UPDATE srv_branching SET parent='$row[parent]', vrstni_red=(vrstni_red+'$row[vrstni_red]'-1) WHERE parent='$if' AND ank_id='$this->anketa'"); } else { $sa = null; $sql1 = sisplet_query("SELECT element_spr, element_if FROM srv_branching WHERE parent = '$if'"); while ($row1 = mysqli_fetch_array($sql1)) { if ($row1['element_spr'] > 0) { if ($sa == null) $sa = new SurveyAdmin(-1, $this->anketa); $sa->brisi_spremenljivko($row1['element_spr']); } else { $this->ajax_if_remove($row1['element_if'], 0); } } } sisplet_query("DELETE FROM srv_branching WHERE element_if = '$if'"); $b->repare_branching($row['parent']); $b->repare_vrstni_red(); $sql = sisplet_query("SELECT * FROM srv_branching WHERE ank_id='$this->anketa' AND element_if > 0"); if (mysqli_num_rows($sql) == 0) { sisplet_query("UPDATE srv_anketa SET branching='0' WHERE id='$this->anketa'"); } } // izpisemo samo pri prvem klicu, pri rekurzivnih pa ne if ($first == 1) $b->branching_struktura(); } function ajax_vrednost_if_remove ($if=0) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); if ($if == 0) $if = $_POST['if']; $vrednost = $_POST['vrednost']; if ($if > 0) { $sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id = '$if'"); while ($row = mysqli_fetch_array($sql)) sisplet_query("DELETE FROM srv_condition_vre WHERE cond_id='$row[id]'"); sisplet_query("DELETE FROM srv_condition WHERE if_id = '$if'"); sisplet_query("DELETE FROM srv_if WHERE id = '$if'"); sisplet_query("UPDATE srv_vrednost SET if_id='0' WHERE if_id='$if'"); } } function ajax_if_tip() { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); $if = $_POST['if']; $tip = $_POST['tip']; sisplet_query("UPDATE srv_if SET tip = '$tip' WHERE id = '$if'"); $b = new Branching($this->anketa); $b->condition_editing($if); } function ajax_vrednost_condition_editing () { Common::updateEditStamp(); $vrednost = $_POST['vrednost']; $sql = sisplet_query("SELECT if_id FROM srv_vrednost WHERE id = '$vrednost'"); $row = mysqli_fetch_array($sql); if ($row['if_id'] > 0) { $if = $row['if_id']; } else { sisplet_query("INSERT INTO srv_if (id) VALUES ('')"); $if = mysqli_insert_id($GLOBALS['connect_db']); sisplet_query("INSERT INTO srv_condition (id, if_id, vrstni_red) VALUES ('', '$if', '1')"); sisplet_query("UPDATE srv_vrednost SET if_id='$if' WHERE id = '$vrednost'"); } $b = new Branching($this->anketa); $b->condition_editing($if, $vrednost); } function ajax_condition_editing () { $if = $_POST['if']; if ($if == 0) { $sql = sisplet_query("SELECT id FROM srv_if ORDER BY id DESC LIMIT 1"); $row = mysqli_fetch_array($sql); $if = $row['id']; } $b = new Branching($this->anketa); $b->condition_editing($if); } function ajax_data_condition_editing () { $if = $_POST['if']; if ($if == 0) { $sql = sisplet_query("SELECT id FROM srv_if ORDER BY id DESC LIMIT 1"); $row = mysqli_fetch_array($sql); $if = $row['id']; } $b = new Branching($this->anketa); $b->condition_editing($if,-1); } function ajax_condition_add () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $if = $_POST['if']; $conjunction = $_POST['conjunction']; $negation = $_POST['negation']; $sql = sisplet_query("SELECT MAX(vrstni_red) AS max FROM srv_condition WHERE if_id = '$if'"); $row = mysqli_fetch_array($sql); $vrstni_red = $row['max'] + 1; sisplet_query("INSERT INTO srv_condition (if_id, conjunction, negation, vrstni_red) VALUES ('$if', '$conjunction', '$negation', '$vrstni_red')"); $b = new Branching($this->anketa); $b->condition_editing_inner($if, $_POST['vrednost']); } function ajax_condition_edit () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $text = isset($_POST['text']) ? strip_tags($_POST['text']) : ''; $operator = isset($_POST['operator']) ? $_POST['operator'] : ''; $negation = isset($_POST['negation']) ? $_POST['negation'] : ''; $conjunction = isset($_POST['conjunction']) ? $_POST['conjunction'] : ''; $vrednost = isset($_POST['vrednost']) ? $_POST['vrednost'] : ''; $condition = isset($_POST['condition']) ? $_POST['condition'] : ''; $spremenljivka = isset($_POST['spremenljivka']) ? $_POST['spremenljivka'] : ''; $ostanek = isset($_POST['ostanek']) ? $_POST['ostanek'] : ''; //$vrednost = explode(',', $vrednost); sisplet_query("DELETE FROM srv_condition_vre WHERE cond_id='$condition'"); sisplet_query("DELETE FROM srv_condition_grid WHERE cond_id='$condition'"); // obicna spremenljivka if (is_numeric($spremenljivka)) { $spremenljivka = $spremenljivka; $vre_id = 0; if ($vrednost != null) foreach ($vrednost AS $val) if ($val > 0 || $val == -1) sisplet_query("INSERT INTO srv_condition_vre (cond_id, vre_id) VALUES ('$condition', '$val')"); // multigrid } elseif ( is_numeric(str_replace('vre_', '', $spremenljivka)) ) { $vre_id = str_replace('vre_', '', $spremenljivka); $sql2 = sisplet_query("SELECT spr_id FROM srv_vrednost WHERE id = '$vre_id'"); $row2 = mysqli_fetch_array($sql2); $spremenljivka = $row2['spr_id']; if ($vrednost != null) foreach ($vrednost AS $val) { if ($val > 0 || $val < 0) // neustrezni so minus sisplet_query("INSERT INTO srv_condition_grid (cond_id, grd_id) VALUES ('$condition', '$val')"); } // tabela besedilo, tabela stevilo } elseif (substr($spremenljivka,0,4) == 'grd_') { $e = explode('_', $spremenljivka); $vre_id = $e[1]; $grid = $e[2]; $sql2 = sisplet_query("SELECT spr_id FROM srv_vrednost WHERE id = '$vre_id'"); $row2 = mysqli_fetch_array($sql2); $spremenljivka = $row2['spr_id']; // number } elseif (substr($spremenljivka,0,4) == 'num_') { $e = explode('_', $spremenljivka); $spremenljivka = $e[1]; $grid = $e[2]; $vre_id = 0; } // calculation if ($spremenljivka == -2) { $sqlc = sisplet_query("SELECT vre_id FROM srv_condition WHERE id = '$condition'"); $rowc = mysqli_fetch_array($sqlc); $vre_id = $rowc['vre_id']; } sisplet_query("UPDATE srv_condition SET spr_id='$spremenljivka', vre_id='$vre_id', text='$text', conjunction='$conjunction', negation='$negation', operator='$operator', ostanek='$ostanek' WHERE id = '$condition'"); $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->conditions_display($row['if_id'], 1, 1); } function ajax_bracket_edit () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $right_bracket = $_POST['right_bracket']; $left_bracket = $_POST['left_bracket']; $condition = $_POST['condition']; sisplet_query("UPDATE srv_condition SET left_bracket='$left_bracket', right_bracket='$right_bracket' WHERE id = '$condition'"); $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->condition_editing($row['if_id'], $_POST['vrednost']); } function ajax_bracket_edit_new () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $who = $_POST['who']; $what = $_POST['what']; $left_bracket = $_POST['left_bracket']; $condition = $_POST['condition']; if ($who == 'left') if ($what == 'plus') $bracket = 'left_bracket=left_bracket+1'; else $bracket = 'left_bracket=left_bracket-1'; else if ($what == 'plus') $bracket = 'right_bracket=right_bracket+1'; else $bracket = 'right_bracket=right_bracket-1'; sisplet_query("UPDATE srv_condition SET $bracket WHERE id = '$condition'"); $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->condition_editing_inner($row['if_id'], $_POST['vrednost']); } function ajax_conjunction_edit () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $conjunction = $_POST['conjunction']; $negation = $_POST['negation']; $condition = $_POST['condition']; sisplet_query("UPDATE srv_condition SET conjunction='$conjunction', negation='$negation' WHERE id = '$condition'"); $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->condition_editing_inner($row['if_id'], $_POST['vrednost']); } function ajax_fill_value () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $condition = $_POST['condition']; $spremenljivka = $_POST['spremenljivka']; // obicna spremenljivka if (is_numeric($spremenljivka)) { $spremenljivka = $spremenljivka; $vrednost = 0; $grid = 0; // multigrid } elseif ( is_numeric( str_replace('vre_', '', $spremenljivka) ) ) { $vrednost = str_replace('vre_', '', $spremenljivka); $sql2 = sisplet_query("SELECT spr_id FROM srv_vrednost WHERE id = '$vrednost'"); $row2 = mysqli_fetch_array($sql2); $spremenljivka = $row2['spr_id']; $grid = 0; // tabela besedilo, tabela stevilo } elseif (substr($spremenljivka,0,4) == 'grd_') { $e = explode('_', $spremenljivka); $vrednost = $e[1]; $grid = $e[2]; $sql2 = sisplet_query("SELECT spr_id FROM srv_vrednost WHERE id = '$vrednost'"); $row2 = mysqli_fetch_array($sql2); $spremenljivka = $row2['spr_id']; // number } elseif (substr($spremenljivka,0,4) == 'num_') { $e = explode('_', $spremenljivka); $spremenljivka = $e[1]; $grid = $e[2]; $vrednost = 0; } sisplet_query("DELETE FROM srv_condition_vre WHERE cond_id='$condition'"); sisplet_query("DELETE FROM srv_condition_grid WHERE cond_id='$condition'"); sisplet_query("UPDATE srv_condition SET spr_id='$spremenljivka', vre_id='$vrednost', grd_id='$grid' WHERE id = '$condition'"); $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->condition_editing_inner($row['if_id'], $_POST['vrednost'], $_POST['condition']); } function ajax_fill_ostanek () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $condition = $_POST['condition']; $modul = $_POST['modul']; sisplet_query("UPDATE srv_condition SET modul='$modul' WHERE id = '$condition'"); $b = new Branching($this->anketa); $b->fill_ostanek($condition); } function ajax_edit_label() { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $if = $_POST['if']; $label = strip_tags($_POST['label']); sisplet_query("UPDATE srv_if SET label='$label' WHERE id = '$if'"); } function ajax_edit_panel_status() { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $if = $_POST['if']; $panel_status = $_POST['panel_status']; // Ce je prazen ga pobrisemo iz baze if($panel_status == ''){ $sqlP = sisplet_query("DELETE FROM srv_panel_if WHERE ank_id='".$this->anketa."' AND if_id='".$if."'"); } else{ $sqlP = sisplet_query("INSERT INTO srv_panel_if (ank_id, if_id, value) VALUES ('".$this->anketa."', '".$if."', '".$panel_status."') ON DUPLICATE KEY UPDATE value='".$panel_status."'"); } } function ajax_condition_remove () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $condition = $_POST['condition']; sisplet_query("DELETE FROM srv_condition WHERE id='$condition'"); $b = new Branching($this->anketa); $b->repare_condition($_POST['if']); $b->condition_editing_inner($_POST['if'], $_POST['vrednost']); } function ajax_calculation_editing () { if ($_POST['noupdate'] != 1) { Common::updateEditStamp(); } $condition = $_POST['condition']; $vrednost = $_POST['vrednost']; $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $calculation = $b->calculation_editing($condition, $vrednost); if ($row['vre_id'] == 0) { $s = sisplet_query("UPDATE srv_condition SET vre_id='$calculation' WHERE id='$condition'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } } function ajax_calculation_editing_close () { $condition = $_POST['condition']; $vrednost = $_POST['vrednost']; $sql = sisplet_query("SELECT if_id FROM srv_condition WHERE id = '$condition'"); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); if ($condition >= 0) $b->condition_editing($row['if_id'], $vrednost); else { $row = SurveyInfo::getInstance()->getSurveyRow(); if ($row['expanded'] == 1) { $b->vprasanje(-$condition); } else { $b->spremenljivka_name(-$condition); } } } function ajax_calculation_save () { if ($_POST['noupdate'] != 1) { Common::updateEditStamp(); } $calculation = $_POST['calculation']; $expression = $_POST['expression']; sisplet_query("UPDATE srv_calculation SET expression='$expression' WHERE id = '$calculation'"); } function ajax_calculation_add () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $condition = $_POST['condition']; $operator = $_POST['operator']; $vrednost = $_POST['vrednost']; $sql = sisplet_query("SELECT MAX(vrstni_red) AS max FROM srv_calculation WHERE cnd_id = '$condition'"); $row = mysqli_fetch_array($sql); $vrstni_red = $row['max'] + 1; $s = sisplet_query("INSERT INTO srv_calculation (id, cnd_id, operator, vrstni_red) VALUES ('', '$condition', '$operator', '$vrstni_red')"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $b = new Branching($this->anketa); $b->calculation_editing_inner($condition, $vrednost); } function ajax_calculation_operator_edit () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $calculation = $_POST['calculation']; $operator = $_POST['operator']; sisplet_query("UPDATE srv_calculation SET operator='$operator' WHERE id = '$calculation'"); $sql = sisplet_query("SELECT * FROM srv_calculation WHERE id = '$calculation'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->calculation_editing_inner($row['cnd_id'], $_POST['vrednost']); } function ajax_calculation_edit () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $spremenljivka = $_POST['spremenljivka']; $calculation = $_POST['calculation']; $number = $_POST['number']; $vrednost = $_POST['vrednost']; $grd_id = 0; // obicna spremenljivka if (is_numeric($spremenljivka)) { $spr_id = $spremenljivka; $vre_id = 0; // checkbox, multigrid } elseif ( strpos($spremenljivka, 'vre_') !== false ) { $e = explode('_', $spremenljivka); list( , $vre_id, $grd_id) = $e; $sql2 = sisplet_query("SELECT spr_id FROM srv_vrednost WHERE id = '$vre_id'"); $row2 = mysqli_fetch_array($sql2); $spr_id = $row2['spr_id']; // number } elseif ( strpos($spremenljivka, 'num_') !== false ) { $e = explode('_', $spremenljivka); list( , $spr_id, $grd_id) = $e; $vre_id = 0; // multicheckbox, multinumber } else { $e = explode('_', $spremenljivka); list( , $spr_id, $vre_id, $grd_id) = $e; } if (!is_numeric($number)) $number = 0; $s = sisplet_query("UPDATE srv_calculation SET spr_id='$spr_id', vre_id='$vre_id', grd_id='$grd_id', number='$number' WHERE id = '$calculation'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); $sql = sisplet_query("SELECT * FROM srv_calculation WHERE id = '$calculation'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->calculation_editing_inner($row['cnd_id'], $vrednost); } function ajax_calculation_remove () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $calculation = $_POST['calculation']; $vrednost = $_POST['vrednost']; sisplet_query("DELETE FROM srv_calculation WHERE id='$calculation'"); $b = new Branching($this->anketa); $b->repare_calculation($_POST['condition']); $b->calculation_editing_inner($_POST['condition'], $vrednost); } function ajax_calculation_bracket_edit_new () { if ($_POST['noupdate'] != 1) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); } $who = $_POST['who']; $what = $_POST['what']; $left_bracket = $_POST['left_bracket']; $calculation = $_POST['calculation']; if ($who == 'left') if ($what == 'plus') $bracket = 'left_bracket=left_bracket+1'; else $bracket = 'left_bracket=left_bracket-1'; else if ($what == 'plus') $bracket = 'right_bracket=right_bracket+1'; else $bracket = 'right_bracket=right_bracket-1'; sisplet_query("UPDATE srv_calculation SET $bracket WHERE id = '$calculation'"); $sql = sisplet_query("SELECT * FROM srv_calculation WHERE id = '$calculation'"); if (!$sql) echo mysqli_error($GLOBALS['connect_db']); $row = mysqli_fetch_array($sql); $b = new Branching($this->anketa); $b->calculation_editing_inner($row['cnd_id'], $_POST['vrednost']); } function ajax_condition_editing_close () { $if = $_POST['if']; $b = new Branching($this->anketa); $b->display_if_label($if); } function ajax_vrednost_condition_editing_close () { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); $vrednost = $_POST['vrednost']; $if = $_POST['if']; $grid = $_POST['grid']; $b = new Branching($this->anketa); if($grid == 1) { echo '*'; }else{ $b->conditions_display($if, 0, 1); } //dodamo trikotnik error na koncu if ($b->condition_check($if) != 0) echo ''; } function ajax_pagebreak ($spr = 0, $force_on = 0) { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); $spremenljivka = $_POST['spremenljivka']; if ($spr > 0) $spremenljivka = $spr; $sql = sisplet_query("SELECT pagebreak FROM srv_branching WHERE element_spr = '$spremenljivka'"); $row = mysqli_fetch_array($sql); if ($row['pagebreak'] == 0 || $force_on == 1) $pagebreak = 1; else $pagebreak = 0; sisplet_query("UPDATE srv_branching SET pagebreak = '$pagebreak' WHERE element_spr = '".$spremenljivka."' AND ank_id='".$this->anketa."'"); $this->check_loop(); $b = new Branching($this->anketa); $b->repare_vrstni_red(); $b->trim_grupe(); //$this->pagebreak_display($spremenljivka); $this->spremenljivka = 0; $b->branching_struktura(); } function ajax_pagebreak_all () { Common::getInstance()->Init($this->anketa); Common::getInstance()->updateEditStamp(); sisplet_query("UPDATE srv_branching SET pagebreak = '1' WHERE element_spr > '0' AND ank_id='".$this->anketa."'"); $b = new Branching($this->anketa); $b->repare_vrstni_red(); $b->trim_grupe(); //$this->pagebreak_display($spremenljivka); $this->spremenljivka = 0; $b->branching_struktura(); } function ajax_vprasanje_edit () { $spremenljivka = $_POST['spremenljivka']; $this->spremenljivka = $spremenljivka; $b = new Branching($this->anketa); $b->display_vprasanja(); } function ajax_refresh_left () { $b = new Branching($this->anketa); $b->spremenljivka = $this->spremenljivka; $b->branching_struktura(); } function ajax_refresh_right () { $b = new Branching($this->anketa); $b->display_vprasanja(); $b->showVprasalnikBottom(); } function ajax_get_new_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 s.id DESC LIMIT 1"); $row = mysqli_fetch_array($sql); echo $row['id']; } function ajax_if_collapsed () { Common::updateEditStamp(); $if = $_POST['if']; $collapsed = $_POST['collapsed']; sisplet_query("UPDATE srv_if SET collapsed='$collapsed' WHERE id = '$if'"); } function ajax_if_display_collapsed () { $if = $_POST['if']; $b = new Branching($this->anketa); $b->display_if_content($if); } function ajax_editmode_introconcl () { $id = $_POST['id']; $b = new Branching($this->anketa); $b->introduction_conclusion($id, 1); } function ajax_normalmode_introconcl () { $id = $_POST['id']; $b = new Branching($this->anketa); $b->introduction_conclusion($id); } function ajax_edit_introconcl () { Common::updateEditStamp(); $id = $_POST['id']; $text = $_POST['text']; $opomba = strip_tags($_POST['opomba']); if ($id == -1) { sisplet_query("UPDATE srv_anketa SET introduction='$text', intro_opomba='$opomba' WHERE id='$this->anketa'"); } elseif ($id == -2) { sisplet_query("UPDATE srv_anketa SET conclusion='$text', concl_opomba='$opomba' WHERE id='$this->anketa'"); } else{ sisplet_query("UPDATE srv_anketa SET statistics='$text' WHERE id='$this->anketa'"); } } function ajax_introconcl_visible () { Common::updateEditStamp(); $id = $_POST['id']; $row = SurveyInfo::getInstance()->getSurveyRow(); if ($id == -1) { $name = 'show_intro'; } else { $name = 'show_concl'; } $show = $row[$name]; if ($show == 1) $newshow = 0; else $newshow = 1; sisplet_query("UPDATE srv_anketa SET $name = '$newshow' WHERE id ='$this->anketa'"); SurveyInfo :: getInstance()->resetSurveyData(); $b = new Branching($this->anketa); $b->introduction_conclusion($id); } function ajax_concl_settings () { Common::updateEditStamp(); $text = $_POST['text']; $url = $_POST['url']; if ($_POST['concl_link'] == 'true') $concl_link = 0; else $concl_link = 1; if ($_POST['concl_back_button'] == 'true') $concl_back_button = 1; else $concl_back_button = 0; sisplet_query("UPDATE srv_anketa SET text='$text', url='$url', concl_link='$concl_link', concl_back_button='$concl_back_button' WHERE id = '$this->anketa'"); } function ajax_scale_ordnom () { Common::updateEditStamp(); $spremenljivka = $_POST['spremenljivka']; $value = $_POST['value']; sisplet_query("UPDATE srv_spremenljivka SET skala='$value' WHERE id='$spremenljivka'"); $b = new Branching($this->anketa); $b->vprasanje($spremenljivka); } function ajax_expand () { $mode = $_POST['mode']; $b = new Branching($this->anketa); $b->display_vprasanja($mode); } function ajax_refresh_spremenljivka_name () { $spremenljivka = $_POST['spremenljivka']; $b = new Branching($this->anketa); $b->spremenljivka_name($spremenljivka); } function ajax_prestevilci () { global $site_url; Common::updateEditStamp(); Common::getInstance()->Init($this->anketa); Common::getInstance()->prestevilci(0, true); echo $site_url.'admin/survey/index.php?anketa='.$this->anketa.'&a=branching'; } function ajax_dodaj_blok_interpretacije () { global $site_url; global $lang; Common::updateEditStamp(); // blok $this->ajax_if_new(0, 0, 0, 1); $sql = sisplet_query("SELECT element_if FROM srv_branching WHERE ank_id='$this->anketa' AND parent='0' AND element_if>0 ORDER BY vrstni_red DESC LIMIT 1"); $row = mysqli_fetch_array($sql); $if_id = $row['element_if']; // bloku nastavimo labelo sisplet_query("UPDATE srv_if SET label = '".$lang['srv_zakljucek_vprasalnika']."' WHERE id = '$if_id'"); // spremenljivka compute $this->ajax_spremenljivka_new(0, $if_id, 1); // spremenljivko nastavimo tip na compute sisplet_query("UPDATE srv_spremenljivka SET tip='22', size='1', naslov='$lang[srv_vprasanje_tip_22]', variable='sum', variable_custom='1' WHERE id = '$this->spremenljivka'"); // nastavimo page break sisplet_query("UPDATE srv_branching SET pagebreak = '1' WHERE element_spr = '".$this->spremenljivka."' AND ank_id='".$this->anketa."'"); $b = new Branching($this->anketa); $b->repare_vrstni_red(); $b->trim_grupe(); // spremenljivka label $this->ajax_spremenljivka_new(0, $if_id, 1); // spremenljivko nastavimo tip label sisplet_query("UPDATE srv_spremenljivka SET tip='5', naslov='Rezultat: #sum#' WHERE id = '$this->spremenljivka'"); } function ajax_check_pogoji() { global $lang; $b = new Branching($this->anketa); $code = $b->check_pogoji(); // ce je vse ok, preverimo se loope if ($code === true) $code = $b->check_loops(); // ce je vse ok, preverimo se validacije if ($code === true) $code = $b->check_validation(); // ce je vse ok, preverimo se imena variabel (vprasanj in variabel znotraj vprasanj) if ($code === true) $code = $b->check_variable(); // ce je vse ok, preverimo se vrednosti stolpcev v gridu (ce je slucajno kaksna prazna) if ($code === true) $code = $b->check_grid_value(); // pogoji so ok if ($code === true) { if ($_GET['izpis'] == 'long') { echo ''.$lang['srv_check_pogoji_ok'].'!
'; echo ' '; } else { echo '1'; } // pogoji niso ok } else { if ($_GET['izpis'] == 'long') { if ($code['type'] == 'if' || $code['type'] == 'podif') echo ''.$lang['srv_check_pogoji_if'].' '.$row['number'].'.
'; } // napaka v podifih, ki so nastavljeni na vrednosti spremenljivk elseif ($code['type'] == 'podif') { $sql = sisplet_query("SELECT id, naslov, variable FROM srv_spremenljivka WHERE id = '$code[id]'"); $row = mysqli_fetch_array($sql); echo ''.$lang['srv_check_pogoji_spremenljivka'].': '.$row['variable'].' - '.strip_tags($row['naslov']).'
'; } // napaka z gnezdenjem loopov elseif ($code['type'] == 'loop') { $sql = sisplet_query("SELECT id, number FROM srv_if WHERE id = '$code[id]'"); $row = mysqli_fetch_array($sql); echo ''.$lang['srv_check_pogoji_loop'].' '.$row['number'].'
'; } elseif ($code['type'] == 'validation') { $sql = sisplet_query("SELECT id, naslov, variable FROM srv_spremenljivka WHERE id = '$code[id]'"); $row = mysqli_fetch_array($sql); echo ''.$lang['srv_check_validacija'].': '.$row['variable'].' - '.strip_tags($row['naslov']).'
'; } // napaka z imeni variabel elseif ($code['type'] == 'variable') { foreach ($code['vars'] AS $var) { echo ''.$var.''; if ($code['code'] == 1) { echo ' '.$lang['srv_error_oklepaji'].''; } elseif ($code['code'] == 2) { echo ' '.$lang['srv_error_spremenljivka'].''; } elseif ($code['code'] == 3) { echo ' '.$lang['srv_error_vrednost'].''; } elseif ($code['code'] == 4) { echo ' '.$lang['srv_error_numericno'].''; } elseif ($code['code'] == 5) { echo ' '.$lang['srv_error_calculation'].''; } elseif ($code['code'] == 6) { echo ' '.$lang['srv_error_loop'].''; } echo '
'; echo ' '; } else { echo ''.$lang['srv_check_pogoji_not_ok_txt'].'
'; echo ' '; } } } /** * alert, da se naj zapira bloke (shranimo da se ne prikazuje vec) * */ function ajax_alert_close_block () { global $lang; SurveySetting::getInstance()->Init($this->anketa); $show_alert = SurveySetting::getInstance()->getSurveyMiscSetting('alert_close_block'); if($show_alert != '2'){ echo ''.$lang['srv_find_text'].'
'; echo ''.$lang['srv_find'].':
'; echo ''.$lang['srv_replace_with'].':
'; echo ''; echo '