summaryrefslogtreecommitdiffstats
path: root/main/survey/app/Controllers
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /main/survey/app/Controllers
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to 'main/survey/app/Controllers')
-rw-r--r--main/survey/app/Controllers/AjaxController.php708
-rw-r--r--main/survey/app/Controllers/BodyController.php2458
-rw-r--r--main/survey/app/Controllers/CheckController.php774
-rw-r--r--main/survey/app/Controllers/Controller.php113
-rw-r--r--main/survey/app/Controllers/DisplayController.php864
-rw-r--r--main/survey/app/Controllers/FindController.php290
-rw-r--r--main/survey/app/Controllers/HeaderController.php920
-rw-r--r--main/survey/app/Controllers/HelperController.php747
-rw-r--r--main/survey/app/Controllers/InitClass.php1230
-rw-r--r--main/survey/app/Controllers/JsController.php2835
-rw-r--r--main/survey/app/Controllers/LanguageController.php196
-rw-r--r--main/survey/app/Controllers/StatisticController.php282
-rw-r--r--main/survey/app/Controllers/SurveyController.php76
-rw-r--r--main/survey/app/Controllers/VariableClass.php193
-rw-r--r--main/survey/app/Controllers/Vprasanja/ComputeController.php55
-rw-r--r--main/survey/app/Controllers/Vprasanja/DatumController.php187
-rw-r--r--main/survey/app/Controllers/Vprasanja/DoubleController.php841
-rw-r--r--main/survey/app/Controllers/Vprasanja/DragDropController.php914
-rw-r--r--main/survey/app/Controllers/Vprasanja/DynamicController.php725
-rw-r--r--main/survey/app/Controllers/Vprasanja/HeatMapController.php242
-rw-r--r--main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php856
-rw-r--r--main/survey/app/Controllers/Vprasanja/ImenaController.php160
-rw-r--r--main/survey/app/Controllers/Vprasanja/MapsController.php364
-rw-r--r--main/survey/app/Controllers/Vprasanja/MaxDiffController.php295
-rw-r--r--main/survey/app/Controllers/Vprasanja/MultigridController.php1686
-rw-r--r--main/survey/app/Controllers/Vprasanja/MultigridMobileController.php1621
-rw-r--r--main/survey/app/Controllers/Vprasanja/NumberController.php372
-rw-r--r--main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php291
-rw-r--r--main/survey/app/Controllers/Vprasanja/QuotaController.php57
-rw-r--r--main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php521
-rw-r--r--main/survey/app/Controllers/Vprasanja/RankingController.php1021
-rw-r--r--main/survey/app/Controllers/Vprasanja/SystemVariableController.php62
-rw-r--r--main/survey/app/Controllers/Vprasanja/TextController.php1022
-rw-r--r--main/survey/app/Controllers/Vprasanja/VprasanjaController.php944
-rw-r--r--main/survey/app/Controllers/Vprasanja/VsotaController.php112
35 files changed, 24034 insertions, 0 deletions
diff --git a/main/survey/app/Controllers/AjaxController.php b/main/survey/app/Controllers/AjaxController.php
new file mode 100644
index 0000000..33662e4
--- /dev/null
+++ b/main/survey/app/Controllers/AjaxController.php
@@ -0,0 +1,708 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+// Osnovni razredi
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Models\Model;
+use Common;
+use Branching;
+use SurveyAdvancedParadataLog;
+use SurveySetting;
+use MailAdapter;
+use GDPR;
+
+
+class AjaxController extends Controller
+{
+ //ajax zahteve
+ public function __construct()
+ {
+ if(empty($_GET['a'])){
+ return '';
+ }
+ if ($_GET['a'] == 'accept_droppable') {
+ $this->ajax_accept_droppable();
+ } elseif ($_GET['a'] == 'accept_ranking') {
+ $this->ajax_accept_ranking();
+ } elseif ($_GET['a'] == 'accept_dragdrop1') {
+ $this->ajax_accept_dragdrop1();
+ } elseif ($_GET['a'] == 'get_dragdrop1_data') {
+ $this->ajax_get_dragdrop1_data();
+ } elseif ($_GET['a'] == 'delete_dragdrop1_data') {
+ $this->ajax_delete_dragdrop1_data();
+ } elseif ($_GET['a'] == 'delete_dragdrop2_data') {
+ $this->ajax_delete_dragdrop2_data();
+ } elseif ($_GET['a'] == 'accept_dragdrop_grid') {
+ $this->ajax_accept_dragdrop_grid();
+ } elseif ($_GET['a'] == 'accept_sortable_ranking') {
+ $this->ajax_accept_sortable_ranking();
+ } elseif ($_GET['a'] == 'edit_size') {
+ $this->ajax_edit_size();
+ } elseif ($_GET['a'] == 'dodaj_ime') {
+ $this->ajax_dodaj_ime();
+ } elseif ($_GET['a'] == 'spol') {
+ $this->ajax_glasovanje_spol();
+ } elseif ($_GET['a'] == 'vote_spol') {
+ $this->ajax_glasovanje_vote_spol();
+ } elseif ($_GET['a'] == 'captcha') {
+ $this->ajax_captcha();
+ } elseif ($_GET['a'] == 'skin') {
+ $this->ajax_skin();
+ } elseif ($_GET['a'] == 'grupa_for_if') {
+ $this->ajax_grupa_for_if();
+ } elseif ($_GET['a'] == 'enable_comments') {
+ $this->ajax_enable_comments();
+ } elseif ($_GET['a'] == 'continue_later') {
+ $this->ajax_continue_later();
+ } elseif ($_GET['a'] == 'continue_later_send') {
+ $this->ajax_continue_later_send();
+ } elseif ($_GET['a'] == 'usr_id_data') {
+ $this->ajax_delete_signature_data();
+ }elseif ($_GET['a'] == 'get_tip_opozorila') {
+ $this->ajax_get_tip_opozorila();
+ } // genericna resitev za vse nadaljne
+ else {
+ $ajax = 'ajax_' . $_GET['a'];
+ if (method_exists($this, $ajax))
+ return $this->$ajax ();
+ else
+ echo 'method ' . $ajax . ' does not exist';
+ }
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new AjaxController();
+ }
+
+ public function ajax_delete_signature_data()
+ {
+
+ $usr_id = $_POST['usr_id'];
+ $anketa = $_POST['anketa'];
+ $spr_id = $_POST['spr_id'];
+ $vre_id = $_POST['vre_id'];
+
+
+ //$sqlsignaturefilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . $usr_id . "'");
+ $sqlsignaturefilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . $usr_id . "' AND code = '" . $spr_id . "' ");
+
+ if (mysqli_num_rows($sqlsignaturefilename) > 0) {
+ $rowSignatureFilename = mysqli_fetch_array($sqlsignaturefilename);
+ $file_2_delete = $rowSignatureFilename[0];
+ }
+
+ //echo $file_2_delete;
+
+ //$path = self::$site_url.'main/survey/uploads/'.$file_2_delete; //tale varianta ne omogoča brisanje na disku
+ $path = survey_path('uploads/' . $file_2_delete);
+
+ //echo $path;
+
+ if (is_file($path)) { //če slikovna datoteka podpisa obstaja
+ unlink($path); //zbriši datoteko
+ }
+
+ //sisplet_query("DELETE FROM srv_data_upload WHERE usr_id='" . get('usr_id') . "' AND ank_id='$anketa'");//zbriši iz baze info datoteki podpisa
+ sisplet_query("DELETE FROM srv_data_upload WHERE usr_id='" . get('usr_id') . "' AND ank_id='$anketa' AND code='$spr_id'");//zbriši iz baze info datoteki podpisa
+ sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE usr_id='" . get('usr_id') . "' AND spr_id='$spr_id' AND vre_id='$vre_id'");//zbriši iz baze info o vnesenem imenu
+ }
+
+ // sprememba skina
+ public function ajax_skin()
+ {
+ $mobile = (int)$_GET['mobile'];
+ setcookie('mobile', $mobile, 0, '/');
+ header("Location: " . $_SERVER['HTTP_REFERER']);
+ }
+
+ //za izris vprasanj pri antonucci designu 1
+ public function ajax_edit_size()
+ {
+ $spremenljivka = $_POST['spremenljivka'];
+ $size = $_POST['size'];
+
+ //sisplet_query("UPDATE srv_spremenljivka SET size='$size' WHERE id='$spremenljivka'");
+
+ for ($i = 0; $i < $size; $i++) {
+ echo ' <p><input type="text" name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="40" onkeyup="checkBranching();" value=""></p>' . "\n";
+ }
+ }
+
+ //antonucci design 2
+ public function ajax_dodaj_ime()
+ {
+ $spremenljivka = $_POST['spremenljivka'];
+ $ime = $_POST['ime'];
+
+ //sisplet_query("UPDATE srv_spremenljivka SET size='$size' WHERE id='$spremenljivka'");
+
+ echo ' <p><input type="text" value="' . $ime . '" disabled=true name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="40" onkeyup="checkBranching();" value=""></p>' . "\n";
+
+ echo ' <p><input type="text" size="40" disabled=true></p>' . "\n";
+ echo ' <p><input type="text" size="40" disabled=true></p>' . "\n";
+ echo ' <p><input type="text" size="40" disabled=true></p>' . "\n";
+
+ }
+
+ public function ajax_accept_droppable()
+ {
+
+ $child = $_POST['child'];
+ $parent = $_POST['parent'];
+
+
+ if ($parent == 'half2_1') {
+ //poiscemo usr_id
+ $sql0 = sisplet_query("SELECT usr_id FROM srv_data_imena WHERE id='$child'");
+ $row0 = mysqli_fetch_array($sql0);
+ $usr_id = $row0[0];
+
+ //poiscemo najvecji count
+ $sql = sisplet_query("SELECT MAX(countE) FROM srv_data_imena WHERE (usr_id='" . get('usr_id') . "' AND (emotion=1 AND emotionINT=0))");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $count = $row['MAX(countE)'];
+ }
+
+ $count++;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotion=1, countE='$count' WHERE id='$child'");
+ } elseif ($parent == 'half2_2') {
+ //poiscemo usr_id
+ $sql0 = sisplet_query("SELECT usr_id FROM srv_data_imena WHERE id='$child'");
+ $row0 = mysqli_fetch_array($sql0);
+ $usr_id = $row0[0];
+
+ //poiscemo najvecji count
+ $sql = sisplet_query("SELECT MAX(countS) FROM srv_data_imena WHERE (usr_id='" . get('usr_id') . "' AND (social=1 AND socialINT=0))");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $count = $row['MAX(countS)'];
+ }
+
+ $count++;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET social=1, countS='$count' WHERE id='$child'");
+ } elseif ($parent == 'half2_3') {
+ $count = 1;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotionINT=1, countE='$count' WHERE id='$child'");
+ } elseif ($parent == 'half2_4') {
+ $count = 1;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET socialINT=1, countS='$count' WHERE id='$child'");
+ } //leva stran - brisemo iz baze (emotion)
+ elseif ($parent == 'half_1') {
+ //preuredimo ostale counterje
+ $sql = sisplet_query("SELECT countE, usr_id FROM srv_data_imena WHERE id='$child'");
+ $row = mysqli_fetch_array($sql);
+
+ $counter = $row[0];
+ $usr_id = $row[1];
+
+ $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND (countE > '$counter') ORDER BY countE");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $count = $row1['countE'];
+ $count--;
+ sisplet_query("UPDATE srv_data_imena SET countE='$count' WHERE id='$row1[id]'");
+ }
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotion=0, countE=0 WHERE id='$child'");
+ } //leva stran - brisemo iz baze (druzenje)
+ elseif ($parent == 'half_2') {
+ //preuredimo ostale counterje
+ $sql = sisplet_query("SELECT countS, usr_id FROM srv_data_imena WHERE id='$child'");
+ $row = mysqli_fetch_array($sql);
+
+ $counter = $row[0];
+ $usr_id = $row[1];
+
+ $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND (countS > '$counter') ORDER BY countS");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $count = $row1['countS'];
+ $count--;
+ sisplet_query("UPDATE srv_data_imena SET countS='$count' WHERE id='$row1[id]'");
+ }
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET social=0, countS=0 WHERE id='$child'");
+ } //leva stran - brisemo iz baze (emotionINT)
+ elseif ($parent == 'half_3') {
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotionINT=0, countE=0 WHERE id='$child'");
+ } //leva stran - brisemo iz baze (druzenjeINT)
+ elseif ($parent == 'half_4') {
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET socialINT=0, countS=0 WHERE id='$child'");
+ }
+
+
+ //izpisemo ime v divu po loadu
+ $sql1 = sisplet_query("SELECT text FROM srv_data_imena WHERE id='$child'");
+ $value = mysqli_fetch_array($sql1);
+
+ echo $value[0];
+
+ }
+
+ /**
+ * @desc poskrbi za shranjevanje vrednosti 99,98,97
+ */
+
+ //zapisovanje v bazo pri ranking dropih (n>k, n=k)
+ public function ajax_accept_ranking()
+ {
+
+
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $order = $_POST['order'];
+
+ // Popravimo da se po ajax-u ohrani jezik
+ if (isset($_POST['lang_id'])) {
+ $lang_id = save('lang_id', $_POST['lang_id'], 1);
+
+ $file = lang_path($lang_id);
+ if (@include($file))
+ $_SESSION['langX'] = lang_path($lang_id, 1);
+ }
+
+ // Napredni parapodatki - za ranking je lažje če je kar tukaj
+ /*if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ SurveyAdvancedParadataLog::getInstance()->logData(0, $usr_id, 'data change', '', $spremenljivka, $order);
+ }*/
+
+ $exploded = explode('&', $order);
+
+ //najprej pobrisemo iz baze vse vnose
+ sisplet_query("DELETE FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+
+ //sortiranje (vnos v srv_data_rating)
+ $i = 1;
+ foreach ($exploded AS $key) {
+ $key = str_replace('handle_', '', $key);
+ $explode = explode('[]=', $key);
+
+ if ($explode[1] != 0)
+ sisplet_query("INSERT INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red) VALUES ('$spremenljivka', '$explode[1]', '" . get('usr_id') . "', '$i')");
+
+ $i++;
+ }
+
+ Vprasanja::getInstance()->displayVnos($spremenljivka);
+
+ echo '<div id="clr" class="clr"></div>';
+
+ }
+
+ //zapisovanje v bazo in brisanje pri drag drop
+ public function ajax_accept_dragdrop1()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $vre_id = $_POST['vre_id'];
+ $usr_id = $_POST['usr_id'];
+ $anketa = $_POST['anketa'];
+ $data_calculation = $_POST['data_calculation'];
+ $tip = $_POST['tip'];
+ $cat_right = $_POST['cat_right'];
+ $other_present = $_POST['other_present'];
+ $other = $_POST['other'];
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ //( ( (tip == 1 && other == 0 && cat_right) ) || ( (tip == 2) && (other_present != 0) ) || ( (other != 0) ) )
+ if (($tip == 1 && $cat_right && $other == 0) || (($tip == 2) && ($other_present != 0)) || (($other != 0))) {
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ }
+ sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "')");
+ }
+
+ //asinhrono pobiranje podatkov za ureditev missing
+ public function ajax_get_dragdrop1_data()
+ {
+ Model::user_not_lurker();
+ $anketa = $_GET['anketa'];
+ $spremenljivka = $_GET['spremenljivka'];
+ $vre_id = array();
+ //echo 'Spremenljivka: '.$spremenljivka;
+ //echo 'Anketa: '.$anketa;
+ //$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other!=0 ");
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka'");
+ $num = mysqli_num_rows($sql1);
+
+ /* echo '
+ <script>
+ console.log('.$num.');
+ </script>
+ '; */
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ //$vre_id[$i] = $row1['id'];
+ array_push($vre_id, $row1['id']);
+ }
+ //echo 'Podatek je: '.$num;
+ //echo $vre_id;
+ echo json_encode($vre_id);
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop
+ public function ajax_delete_dragdrop1_data()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id'");
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop, ko imamo missing-e
+ public function ajax_delete_dragdrop2_data()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ }
+
+ //zapisovanje v bazo pri drag drop v grid
+ public function ajax_accept_dragdrop_grid()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $vre_id = $_POST['vre_id'];
+ $usr_id = $_POST['usr_id'];
+ $tip = $_POST['tip'];
+ $anketa = $_POST['anketa'];
+ $indeks = $_POST['indeks'];
+ $last_vre_id = $_POST['last_vre_id'];
+ $cat_right = $_POST['cat_right'];
+ $vre_id_present = $_POST['vre_id_present'];
+
+
+ //vnesi podatke v bazo
+ if ($tip == 6) {
+ sisplet_query("INSERT INTO srv_data_grid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "', '$indeks')");
+ } else if ($tip == 16) {
+ sisplet_query("INSERT INTO srv_data_checkgrid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "', '$indeks')");
+ }
+
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop - tabela - vec odgovorov
+ public function ajax_delete_dragdrop_grid_data()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+ $indeks = $_POST['indeks'];
+ //brisi podatke iz baze
+ sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id' AND grd_id = '$indeks' ");
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop
+ public function ajax_delete_dragdrop_grid_data_1()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+ $indeks = $_POST['indeks'];
+
+ sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id' AND grd_id = '$indeks'");
+
+ }
+
+ //
+ //brisanje odgovorov iz baze pri drag drop grid, ko se klikne gumb Ponastavi
+ public function ajax_delete_dragdrop_grid_data_reset()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $anketa = $_POST['anketa'];
+ $tip = $_POST['tip'];
+
+ if($tip == 6){
+ sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' ");
+ }else if($tip == 16){
+ sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' ");
+ }
+ }
+
+ // respondent se strinja z uporabo piskotvkov - nastavimo piskotek ok
+ public function ajax_cookie_ok()
+ {
+
+ setcookie('cookie_ok', '1', time() + 2500000, '/');
+
+ }
+
+ //izpis statistike glede na spol
+ public function ajax_glasovanje_spol()
+ {
+ $spremenljivka = $_POST['spremenljivka'];
+ $spol = $_POST['spol'];
+
+ Statistic::displayStatGlasovanje($spremenljivka, $spol);
+ }
+
+ /**
+ * preveri, ce je captcha koda pravilno vnesena (preko ajaxa)
+ *
+ */
+ public function ajax_captcha(){
+ global $secret_captcha;
+
+ $text = strtoupper($_GET['text']);
+ $code = $_GET['code'];
+ $spr_id = $_GET['spr_id'];
+ $usr_id = $_GET['usr_id'];
+
+ $recaptchaResponse = $_POST['g-recaptcha-response'];
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+
+ // zdaj pa zabeleži mail (pred pošiljanjem)
+ // zdaj pa še v bazi tistih ki so se ročno dodali
+ if(strstr($request,"true")){
+ echo '1';
+ }
+ else {
+ echo '0';
+ }
+ }
+
+ /**
+ * poisce v kateri grupi/strani se pojavi if za redirect tabov
+ *
+ */
+ public function ajax_grupa_for_if($parent = 0){
+
+ $parent_if = $_POST['parent_if'];
+ if ($parent > 0) $parent_if = $parent;
+
+ ob_start();
+
+ $b = new Branching(get('anketa'));
+ $spr = $b->find_first_in_if($parent_if);
+
+ ob_clean();
+
+ $row = Model::select_from_srv_spremenljivka($spr);
+
+ if ($parent == 0)
+ echo $row['gru_id'];
+
+ return $row['gru_id'];
+ }
+
+ /**
+ * vklopi komentarje na anketo (v previewu je ta možnost)
+ *
+ */
+ public function ajax_enable_comments(){
+
+ ob_clean();
+
+ SurveySetting::getInstance()->Init((int)$_POST['anketa']);
+
+ SurveySetting::getInstance()->setSurveyMiscSetting('question_resp_comment', '1');
+ SurveySetting::getInstance()->setSurveyMiscSetting('question_resp_comment_viewadminonly', '3');
+ }
+
+
+ public function ajax_continue_later(){
+
+ save('lang_id', (int)$_GET['language']);
+
+ $url = $_POST['url'] . '&return=1';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+
+ $srv_continue_later_txt = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later_txt' . $_lang);
+ if ($srv_continue_later_txt == '') $srv_continue_later_txt = self::$lang['srv_continue_later_txt'];
+
+ $srv_continue_later_email = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later_email' . $_lang);
+ if ($srv_continue_later_email == '') $srv_continue_later_email = self::$lang['srv_continue_later_email'];
+
+ $srv_forma_send = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang);
+ if ($srv_forma_send == '') $srv_forma_send = self::$lang['srv_forma_send'];
+
+ echo '<div id="continue_later">';
+
+ echo '<p>' . $srv_continue_later_txt . ':</p><p class="url">' . $url . '</p>';
+
+ echo '<input type="hidden" name="url" id="url" value="' . $url . '">';
+
+ echo '<p>' . $srv_continue_later_email . ': <input type="email" name="email" id="email" value="" placeholder="' . self::$lang['srv_email_example2'] . '"> <button type="submit" onclick="continue_later_send(\'' . self::$site_url . '\', \'' . get('lang_id') . '\'); return false;">' . $srv_forma_send . '</button></p>';
+
+ echo '</div>';
+ }
+
+ public function ajax_continue_later_send(){
+ global $mysql_database_name;
+
+ ob_clean();
+
+ $s = self::$lang['srv_continue_later_subject'];
+
+ if($mysql_database_name == 'vprasalnikirsrssi')
+ $t = self::$lang['srv_continue_later_content_rs-rs'] . ': <a href="' . $_POST['url'] . '">' . $_POST['url'] . '</a>';
+ else
+ $t = self::$lang['srv_continue_later_content'] . ': <a href="' . $_POST['url'] . '">' . $_POST['url'] . '</a>';
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+ $t .= $signature;
+
+ $mail = $_POST['email'];
+
+ if ($mail == '') return;
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+ $result = $MA->sendMail(stripslashes($t), $s);
+ }
+ catch (Exception $e) {
+ }
+ }
+
+ public function ajax_get_tip_opozorila() {
+ $spr_id = $_POST['spr_id'];
+
+ //poberi podatke o na trenutnem obmocju
+ $sqlR = sisplet_query("SELECT reminder FROM srv_validation WHERE spr_id = $spr_id");
+ $rowR = mysqli_fetch_assoc($sqlR);
+ $tip_opozorila = $rowR['reminder'];
+
+ echo $tip_opozorila;
+ }
+
+
+ // Izpisemo seznam starih odgovorov v popup (dodatna nastavitev pri text vprasanju)
+ public function ajax_show_prevAnswers_all() {
+
+ $spremenljivka = $_POST['spremenljivka'];
+
+ echo '<h3>'.self::$lang['srv_prevAnswers'].'</h3>';
+
+ $sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."' ORDER BY id DESC");
+ while($row = mysqli_fetch_array($sql)){
+ echo '<p>';
+ echo $row['text'];
+ echo '</p>';
+ }
+
+ // Gumb zapri
+ echo '<div class="prevAnswers_button">';
+ echo '<a href="#" onClick="hide_prevAnswers_all(\''.$spremenljivka.'\'); return false;"><span>'.self::$lang['srv_zapri'].'</span></a>';
+ echo '</div>';
+
+ echo '<script>
+ $("#fade").on("click", function() {
+ hide_prevAnswers_all(\''.$spremenljivka.'\');
+ });</script>';
+ }
+
+ // Izpisemo seznam starih odgovorov v popup (dodatna nastavitev pri text vprasanju)
+ public function ajax_show_gdpr_about() {
+ global $lang;
+
+ $anketa = $_POST['anketa'];
+
+ $gdpr_settings = GDPR::getSurveySettings($anketa);
+
+ echo '<h3>'.$lang['srv_gdpr_survey_gdpr_about'].'</h3>';
+
+ if($gdpr_settings['about'] == ''){
+ $about_array = GDPR::getGDPRInfoArray($anketa);
+ $about_text = GDPR::getGDPRTextFromArray($about_array, $type='html');
+
+ echo $about_text;
+ }
+ else{
+ echo nl2br($gdpr_settings['about']);
+ }
+
+ echo '<br />';
+
+ // Gumb zapri
+ echo '<div class="prevAnswers_button">';
+ echo '<a href="#" onClick="hide_gdpr_about(); return false;"><span>'.$lang['srv_zapri'].'</span></a>';
+ echo '</div>';
+
+ echo '<script>
+ $("#fade").on("click", function() {
+ hide_gdpr_about();
+ });</script>';
+
+ echo '<br />';
+ }
+
+
+ // Shranimo vrstni red pri randomizaciji (blokov ali vprasanj)
+ public function ajax_save_randomization_order() {
+
+ $usr_id = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['usr_id']);
+ $randomization_type = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['randomization_type']);
+
+ $vrstni_red = stripcslashes($_POST['order']);
+ $vrstni_red = str_replace('"', "", substr($vrstni_red, 1, -1));
+
+ // Random vrstni red VPRASANJ oz. BLOKOV znotraj bloka
+ // ID bloka znotraj katerega so random elementi
+ $parent_block_id = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['parent_block_id']);
+
+ $sql = sisplet_query("INSERT INTO srv_data_random_blockContent
+ (usr_id, block_id, vrstni_red)
+ VALUES
+ ('".$usr_id."', '".$parent_block_id."', '".$vrstni_red."')
+ ON DUPLICATE KEY UPDATE vrstni_red='".$vrstni_red."'
+ ");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/BodyController.php b/main/survey/app/Controllers/BodyController.php
new file mode 100644
index 0000000..308b30c
--- /dev/null
+++ b/main/survey/app/Controllers/BodyController.php
@@ -0,0 +1,2458 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 08.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\DisplayController as Display;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\JsController as Js;
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Models\Model;
+use App\Models\SaveSurvey;
+use Hierarhija\Hierarhija;
+use SurveyAdvancedParadataLog;
+use SurveyInfo;
+use SurveySetting;
+use SurveyAdminSettings;
+use Common;
+use TrackingClass;
+use SurveyPanel;
+use SurveyQuiz;
+use SurveyGorenje;
+use SurveyNIJZ;
+use GDPR;
+use UserAccess;
+
+
+class BodyController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new BodyController();
+ }
+
+
+ /**
+ * @desc prikaze uvodni nagovor
+ */
+ public function displayIntroduction()
+ {
+ Header::getInstance()->displaySistemske();
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ if (!get('printPreview')) {
+ SaveSurvey::saveSistemske();
+ }
+
+ // datapiping
+ $row['introduction'] = Helper::dataPiping($row['introduction']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ // crn div za ozadje popupov
+ echo '<div id="fade"></div>';
+ echo '<div id="popup"></div>';
+
+
+ echo '<div class="outercontainer_holder ' . $class . ' intro">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . ' intro">';
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+ }
+
+ // opozorilo ce urejamo ze reseno anketo
+ if (get('quick_view') == true) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_quick_view_text'];
+ echo '</div>';
+ }
+ // opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_edit_text'];
+ echo '</div>';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE - Ce ni tega flusha, prvi klik na urejanje odpre poruseno stran (naknadni kliki so pa potem ok)
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ echo '<form method="post" action="' . SurveyInfo::getSurveyLink(false, false) . '&amp;grupa=0' . Header::getSurveyParams(true) . str_replace('&', '&amp;', get('cookie_url')) . '">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <input type="hidden" name="dummy" value="foo">' . "\n";
+ echo ' <input type="hidden" name="referer" value="' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . '">' . "\n";
+
+ $this->displayIntroductionContent();
+
+
+ if ($row['user_from_cms'] == 1 && $row['user_from_cms_email'] == 1) {
+
+ $sql1 = sisplet_query("SELECT user_id FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sqlu = Model::db_select_user($row1['user_id']);
+ $rowu = mysqli_fetch_array($sqlu);
+ if (mysqli_num_rows($sqlu) > 0) {
+ echo ' <div class="spremenljivka">' . "\n";
+ echo self::$lang['srv_recognized'] . ' <strong>' . $rowu['name'] . ' ' . $rowu['surname'] . '</strong>';
+ if ($row['user_from_cms_email'] == 1)
+ echo ' (' . $rowu['email'] . ')';
+ echo ' </div>' . "\n";
+ }
+ }
+
+ // koda za izponjevanje ankete (splosna - brez prepoznave userjev) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ $sqlp = sisplet_query("SELECT COUNT(*) AS count FROM srv_password WHERE ank_id='" . get('anketa') . "'");
+ $rowp = mysqli_fetch_array($sqlp);
+ if ($rowp['count'] > 0 && $userAccess->checkUserAccess($what='password')) {
+ echo ' <div class="spremenljivka">' . "\n";
+ echo ' <p>' . self::$lang['insert_password'] . ': <input type="text" name="password" value="' . (isset($_COOKIE['password_' . get('anketa')]) ? $_COOKIE['password_' . get('anketa')] : '') . '"></p>';
+ echo ' </div>' . "\n";
+ }
+
+ if ($row['user_base'] == 1
+ #če imamo neindividualizirana vabila - poslana preko vabil, vendar bez kode in zato brez sledenja (uporabnik se pri pošiljanju NE prenese iz srv_invitations_recipients v srv_user)
+ && $row['individual_invitation'] != 0
+ ) {
+
+ if (isset($_GET['code']))
+ $usercode = $_GET['code'];
+ else
+ $usercode = '';
+
+ if ($row['usercode_required'] == 1)
+ $usercode == '';
+
+ // �e ni nujno da vnesemo kodo usercode_skip = 1 ali 2
+ $canNotSkip = true;
+ if ($row['usercode_skip'] > 0) {
+ if ($row['usercode_skip'] == 1) { // lahko presko�imo kodo
+ $canNotSkip = false;
+ } elseif ($row['usercode_skip'] == 2) { // preverimo �e je uporabnik avtor ankete
+ $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'");
+ if (mysqli_num_rows($sqlUserAutor) > 0)
+ $canNotSkip = false;
+ }
+ }
+
+ // Ce smo v preview ali testnem vnosu in ce imamo vklopljeno da ne preverjamo kode
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on' && isset($_GET['disablecode']) && $_GET['disablecode'] == 1) {
+ $canNotSkip = false;
+ }
+
+ if ($usercode == '' && $canNotSkip || ($row['usercode_required'] == 1 /*&& $row['usercode_skip'] != 1*/)) {
+
+ $usercode_text = ($row['usercode_text'] != "") ? $row['usercode_text'] : self::$lang['srv_basecode'];
+ echo ' <div class="spremenljivka">' . "\n";
+ echo ' <p>' . $usercode_text . ': <input type="text" name="usercode" value="' . $usercode . '"></p>';
+ echo ' </div>' . "\n";
+ } else {
+ echo ' <input type="hidden" name="usercode" value="' . $usercode . '">';
+ }
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ // izbira jezika za respondenta
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $row['multilang'] == 1 && !get('printPreview')) {
+
+ $lang_resp = $row['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+
+ $file = lang_path($lang_resp);
+ include($file);
+ $lang_array[$lang['id']] = $lang['language'];
+
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ echo ' <div class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira jezika z dropdown menijem
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ echo ' <h3>' . self::$lang['lang'] . ': ';
+ echo ' <select
+ name="language"
+ id="language"
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+
+ echo ' </select>';
+ echo '</h3>' . "\n";
+ }
+ // Izbira jezika z radio gumbi (default)
+ else {
+ echo '<h3>' . self::$lang['lang'] . ': </h3>';
+ echo '<span style="font-size:13px;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<label for="language_' . $key . '">';
+ echo '<input type="radio" name="language" id="language_' . $key . '"
+ value="' . $key . '"' . ($key == $current ? '
+ checked="checked"' : '') . '
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language_' . $key . '\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+
+ echo $val;
+
+ echo '</label><br />';
+ }
+ echo '</span>';
+ }
+
+
+ echo ' </div>' . "\n";
+
+ }
+
+ echo '</div>' . "\n"; // - grupa
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ if (get('lang_id') != null)
+ $_lang = '_' . get('lang_id');
+ else
+ $_lang = '';
+
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang);
+ $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod'];
+
+ if (!get('printPreview')) {
+
+ // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija
+ $survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
+ if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){
+ $js_submit = ' onclick="';
+
+ if($survey_privacy == 2)
+ $js_submit .= 'privacy_check();';
+
+ if($row['cookie_continue'] == 0 && $row['cookie'] != -1)
+ $js_submit .= 'cookie_check();';
+
+ $js_submit .= 'return false;"';
+ }
+ else{
+ $js_submit = '';
+ }
+
+ echo ' <div class="buttons"><input class="next" type="submit" value="' . $label . '" '.$js_submit.'>' . "\n";
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1'){
+ echo '<input class="next" type="submit" value="' . self::$lang['srv_zapri'] . '" onclick="$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); return false;">' . "\n";
+ // Varianta da zapiranje iframa deluje cross domain
+ //echo '<input class="next" type="button" value="' . self::$lang['srv_zapri'] . '" onclick="parent.window.postMessage(\'closePopup\', \'http://HOST_DOMENA_TODO\');">' . "\n"
+ }
+
+ echo '</div>';
+ }
+
+ echo '</form>' . "\n";
+
+ echo '</div>' . "\n"; // - container
+
+ if (!get('printPreview')) {
+ $this->displayFooterNote();
+ }
+
+ // TAWK chat, ce je vklopljen
+ if(SurveyInfo::getInstance()->checkSurveyModule('chat')){
+ Display::getInstance()->displayChatTAWK();
+ }
+
+ echo '</div>' . "\n"; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ Js::js_tracking();
+ }
+
+ public function displayIntroductionContent()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+
+ // Ce prikazemo dodaten preduvod za gdpr ankete
+ if(GDPR::isGDPRSurveyTemplate(get('anketa'))){
+ self::displayIntroductionGDPR();
+ }
+
+
+ echo ' <div class="spremenljivka">' . "\n";
+
+ if ($row['introduction'] == '')
+ $intro = self::$lang['srv_intro'];
+ else
+ $intro = Helper::dataPiping($row['introduction']);
+
+ if (get('lang_id') != null) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='-1' AND lang_id='" . get('lang_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['naslov'] != '') $intro = $row1['naslov'];
+ }
+
+ echo '<div class="naslov">';
+
+ // ta p je mogoce prevec, ker ga verjetno vedno doda editor?
+ echo '<p>' . $intro . '</p>';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
+
+ if ($privacy == 1) {
+ echo '<p><br /></p><p style="font-weight:400;">' . self::$lang['srv_privacy_text_1'] . '</p>';
+
+ } elseif ($privacy == 2) {
+ echo '<p><br /></p>';
+
+ echo '<p style="font-weight:400;"><label for="privacy_box">';
+ echo '<input type="checkbox" name="privacy_box" id="privacy_box">';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio"></span>';
+ echo self::$lang['srv_privacy_text_2'];
+ echo '</label></p>';
+ }
+
+ // Ce imamo staticen uvod in preverjanje s captcho
+ if($row['intro_static'] == 2){
+ global $recaptcha_sitekey;
+
+ $captcha_error = (isset($_GET['captcha_error']) && $_GET['captcha_error'] == 1) ? true : false;
+
+ echo '<br />';
+
+ echo '<p>';
+ echo '<div class="g-recaptcha" data-sitekey="' .$recaptcha_sitekey .'"></div>';
+ echo '</p>';
+
+ if($captcha_error){
+ //echo '<p class="red italic">Wrong captcha!<p>';
+ }
+ }
+
+ echo '</div>' . "\n";
+
+ echo ' </div>' . "\n";
+ }
+
+ // Prikazemo dodaten uvod za GDPR
+ public function displayIntroductionGDPR()
+ {
+ $user_settings = GDPR::getSurveySettings(get('anketa'));
+
+ echo '<div class="spremenljivka '.(isset($_POST['gdpr']) ? ' required_require' : '').'">' . "\n";
+
+ echo '<div class="naslov">';
+
+ echo GDPR::getSurveyIntro(get('anketa'));
+
+ // JS za prikaz popup-a
+ echo '<script> $(".gdpr_popup_trigger").click(function(){ show_gdpr_about(\''.get('lang_id').'\'); });</script>';
+ echo '</div>' . "\n";
+
+ // Radio buttons
+ echo '<input type="hidden" name="gdpr" value="1">';
+ echo '<div class="variable_holder clr">';
+ echo ' <div class="variabla"><label for="gdpr_accept_0"><input type="radio" name="gdpr_accept" id="gdpr_accept_0" value="0"><span class="enka-checkbox-radio"></span>'.self::$lang['srv_gdpr_intro_no'].'</label></div>';
+ echo ' <div class="variabla"><label for="gdpr_accept_1"><input type="radio" name="gdpr_accept" id="gdpr_accept_1" value="1"><span class="enka-checkbox-radio"></span>'.self::$lang['srv_gdpr_intro_yes'].'</label></div>';
+ echo '</div>';
+
+ echo '</div>' . "\n";
+ }
+
+ /************************************************
+ * Izrišemo staticen uvod, ki ne shrani nicesar (user se ustvari v bazi sele na naslednji strani)
+ ************************************************/
+ public function displayStaticIntroduction()
+ {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ // datapiping
+ $row['introduction'] = Helper::dataPiping($row['introduction']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '<div class="outercontainer_holder ' . $class . ' uvod_static">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . ' uvod_static">';
+ echo '<div class="outercontainer_header"></div>';
+
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+ }
+
+ //opozorilo ce urejamo ze reseno anketo
+ if (get('quick_view') == true) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_quick_view_text'];
+ echo '</div>';
+ }
+ //opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_edit_text'];
+ echo '</div>';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ echo '<form method="post" action="' . SurveyInfo::getSurveyLink(false, false) . '&amp;grupa=0' . Header::getSurveyParams(true) . str_replace('&', '&amp;', get('cookie_url')) . '">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <input type="hidden" name="dummy" value="foo">' . "\n";
+ echo ' <input type="hidden" name="referer" value="' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . '">' . "\n";
+
+
+ $this->displayIntroductionContent();
+
+
+ // koda za izponjevanje ankete (splosna - brez prepoznave userjev) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ $sqlp = sisplet_query("SELECT COUNT(*) AS count FROM srv_password WHERE ank_id='" . get('anketa') . "'");
+ $rowp = mysqli_fetch_array($sqlp);
+ if ($rowp['count'] > 0 && $userAccess->checkUserAccess($what='password')) {
+ echo ' <div class="spremenljivka">' . "\n";
+ echo ' <p>' . self::$lang['insert_password'] . ': <input type="text" name="password" value="' . (isset($_COOKIE['password_' . get('anketa')]) ? $_COOKIE['password_' . get('anketa')] : '') . '"></p>';
+ echo ' </div>' . "\n";
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ // izbira jezika za respondenta
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $row['multilang'] == 1 && !get('printPreview')) {
+
+ $lang_resp = $row['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+
+ $file = lang_path($lang_resp);
+ include($file);
+ $lang_array[$lang['id']] = $lang['language'];
+
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ echo ' <div class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira jezika z dropdown menijem
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ echo ' <h3>' . self::$lang['lang'] . ': ';
+ echo ' <select
+ name="language"
+ id="language"
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+ echo ' </select>';
+ echo '</h3>' . "\n";
+ } // Izbira jezika z radio gumbi (default)
+ else {
+ echo '<h3>' . self::$lang['lang'] . ': </h3>';
+ echo '<span style="font-size:13px;">';
+ foreach ($lang_array AS $key => $val) {
+ echo '<label for="language_' . $key . '">';
+ echo '<input type="radio" name="language" id="language_' . $key . '"
+ value="' . $key . '"' . ($key == $current ? '
+ checked="checked"' : '') . '
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language_' . $key . '\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;"> ';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+
+ echo $val;
+
+ echo '</label><br />';
+ }
+ echo '</span>';
+ }
+
+ echo ' </div>' . "\n";
+ }
+
+ echo '</div>' . "\n"; // - grupa
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang);
+ $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod'];
+
+ if (!get('printPreview')) {
+
+ // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija
+ $survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
+ if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){
+ $js_submit = ' onclick="';
+ if($survey_privacy == 2)
+ $js_submit .= 'privacy_check();';
+ if($row['cookie_continue'] == 0 && $row['cookie'] != -1)
+ $js_submit .= 'cookie_check();';
+ $js_submit .= 'return false;"';
+ }
+ else{
+ $js_submit = '';
+ }
+
+ echo ' <div class="buttons"><input class="next" type="submit" value="' . $label . '" '.$js_submit.'>' . "\n";
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ echo '<input class="next" type="submit" value="' . self::$lang['srv_zapri'] . '" onclick="$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); return false;">' . "\n";
+
+ echo '</div>';
+ }
+
+ echo '</form>' . "\n";
+
+ echo '</div>' . "\n"; // - container
+
+ if (!get('printPreview')) {
+
+ $this->displayFooterNote();
+ }
+
+ echo '</div>' . "\n"; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+ }
+
+
+ /************************************************
+ * Izrišemo konec ankete
+ ************************************************/
+ public function displayKonec()
+ {
+ global $mysql_database_name;
+ global $lang;
+ global $admin_type;
+ global $site_url;
+ global $app_settings;
+
+ Header::getInstance()->displaySistemske();
+
+ if (!get('printPreview')) {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'AND (finish_respondent=1 OR finish_respondent_cms=1 OR finish_author=1 OR finish_other =1)");
+
+
+ // EVALVACIJA - oznacimo, da je student odgovoril
+ if (Common::checkModule('evalvacija') == '1') {
+
+ $sql1 = sisplet_query("SELECT student FROM eval_data_user WHERE ank_id='".get('anketa')."' AND usr_id='".get('usr_id')."'");
+ $sql2 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifpredm' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
+ $sql3 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='siffaks' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
+ $sql4 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifizv1' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
+ $sql5 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl'");
+ $sql6 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl2'");
+
+ // Ce imamo sifro predmeta gre za anketo za ocenjevanje predmetov
+ if (mysqli_num_rows($sql2) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+ $row2 = mysqli_fetch_array($sql2);
+
+ // Ce imamo sifro izvajalca gre za anketo PRED izpiti (eval_data_anketaPred), drugace je anketa PO izpitih (eval_data_anketaPo)
+ if (mysqli_num_rows($sql4) > 0) {
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_anketaPred (predmet, student, ank_id) VALUES ('$row2[text]', '$row1[student]', '" . get('anketa') . "')");
+ } else {
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_anketaPo (predmet, student, ank_id) VALUES ('$row2[text]', '$row1[student]', '" . get('anketa') . "')");
+ }
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ // splosna PODIPLOMSKA anketa (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql5) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_podipl (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ // splosna PODIPLOMSKA anketa 2 (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql6) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_podipl2 (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ // SPLOSNA anketa (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql1) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_splosna (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ }
+
+ // Ce je vklopljen evoli team meter zabelezimo kvoto
+ $tm_quota_increase = false;
+ $modules = SurveyInfo::getInstance()->getSurveyModules();
+ if (isset($modules['evoli_teammeter'])
+ || isset($modules['evoli_quality_climate'])
+ || isset($modules['evoli_teamship_meter'])
+ || isset($modules['evoli_organizational_employeeship_meter'])
+ ) {
+
+ // Dobimo id skupine za respondenta
+ $sqlGroupTM = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND d.usr_id='".get('usr_id')."' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ if($rowGroupTM['vre_id'] > 0){
+
+ $tm_quota = 0;
+
+ // Prestejemo vse response za doloceno skupino/podjetje (to ni vezano na departmente, ker smo lahko tudi brez departmentov!)
+ $sqlTM = sisplet_query("SELECT DISTINCT(usr_id) AS usr_id
+ FROM srv_data_vrednost_active
+ WHERE vre_id='".$rowGroupTM['vre_id']."'");
+
+ while($rowTM = mysqli_fetch_array($sqlTM)){
+
+ // Dodatno se preverimo, ce je user res koncal anketo (ima status 6 in ni lurker)
+ $sqlTMU = sisplet_query("SELECT last_status, lurker FROM srv_user where id='".$rowTM['usr_id']."'");
+ $rowTMU = mysqli_fetch_array($sqlTMU);
+
+ if($rowTMU['last_status'] == '6' && $rowTMU['lurker'] == '0')
+ $tm_quota++;
+ }
+
+ $sqlTM = sisplet_query("UPDATE srv_evoli_teammeter
+ SET kvota_val='".$tm_quota."'
+ WHERE ank_id='".get('anketa')."' AND skupina_id='".$rowGroupTM['vre_id']."'");
+ $tm_quota_increase = true;
+ }
+ }
+
+ // Popravimo url za skok po koncu ankete ce nima http://
+ if ($row['url'] != '' && substr($row['url'], 0, 4) != 'http') {
+ $finishUrl = 'http://' . $row['url'];
+ } else {
+ $finishUrl = $row['url'];
+ }
+
+ // Dodamo datapiping v url-ju
+ if($row['url'] != ''){
+ // Počistimo html tage
+ $finishUrl = strip_tags(Helper::dataPiping($finishUrl));
+ }
+
+ // Preverimo ce imamo nastavljene kaksne get parametre za dodat pri skoku na url
+ if ($row['concl_link'] == 1 && $finishUrl != '') {
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $concl_url_usr_id = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_usr_id');
+ $concl_url_status = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_status');
+ $concl_url_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_recnum');
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1')
+ $finishUrl .= '?';
+
+ if ($concl_url_usr_id == '1') {
+ $finishUrl .= 'usr_id=' . get('usr_id') . '&';
+ }
+
+ if ($concl_url_status == '1' || $concl_url_recnum == '1') {
+ $sqlU = sisplet_query("SELECT last_status, recnum FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ if($concl_url_recnum == '1')
+ $finishUrl .= 'recnum=' . $rowU['recnum'] . '&';
+
+ if($concl_url_status == '1')
+ $finishUrl .= 'status=' . $rowU['last_status'] . '&';
+ }
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1')
+ $finishUrl = substr($finishUrl, 0, -1);
+ }
+
+ // Pri Gorenje anketah posljemo id reklamacije preko njihovega api-ja
+ if (Common::checkModule('gorenje')){
+ $rek_id = SurveyGorenje::getGorenjeVariable(get('anketa'), 'rekid', get('usr_id'));
+ if($rek_id != '' && $rek_id > 0){
+
+ // Posljemo id reklamacije preko api-ja
+ SurveyGorenje::sendGorenjeRekID($rek_id);
+ }
+ }
+
+ // Preverimo ce imamo vklopljen modul za panel - potem napolnimo url z ustreznimi parametri
+ if(isset($modules['panel'])){
+
+ // Pridobimo vse nastavitve panela
+ $sp = new SurveyPanel(get('anketa'));
+ $panel_settings = $sp->getPanelSettings();
+
+ // Posebno samo za ipanel - Izraelski projekt
+ if($app_settings['app_name'] == 'www.1ka.si' && (get('anketa') == '232992' || get('anketa') == '232795' || get('anketa') == '248217' || get('anketa') == '248757' || get('anketa') == '248762')){
+
+ // Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko
+ $sqlP = sisplet_query("SELECT d.*, s.variable FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g
+ WHERE d.usr_id='".get('usr_id')."' AND s.variable IN ('id', 'i_project', 'i_user1', 'i_user4', 'i_user5', 'i_user6', 'i_user7')
+ AND d.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='".get('anketa')."'");
+ while($rowP = mysqli_fetch_array($sqlP)){
+
+ if($rowP['variable'] == 'id')
+ $panelist_id = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user1')
+ $panelist_user = $rowP['text'];
+ elseif($rowP['variable'] == 'i_project')
+ $panelist_project = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user4')
+ $user_data4 = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user5')
+ $user_data5 = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user6')
+ $user_data6 = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user7')
+ $user_data7 = $rowP['text'];
+ }
+
+ // Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default)
+ $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default'];
+
+ // Nastavimo koncen url za redirect
+ $finishUrl = 'http://survey.ipanel.co.il/mrIWeb/mrIWeb.dll?';
+ $finishUrl .= 'id='.$panelist_id.'&i.user1='.$panelist_user.'&i.project='.$panelist_project.'&i.user9='.$panel_status;
+ $finishUrl .= '&i.user4='.$user_data4.'&i.user5='.$user_data5.'&i.user6='.$user_data6.'&i.user7='.$user_data7;
+ }
+ else{
+ // Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko
+ $sqlP = sisplet_query("SELECT d.* FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g
+ WHERE d.usr_id='".get('usr_id')."' AND s.variable='".$panel_settings['user_id_name']."'
+ AND d.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='".get('anketa')."'");
+ $rowP = mysqli_fetch_array($sqlP);
+ $panelist_id = $rowP['text'];
+
+ // Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default)
+ $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default'];
+
+ // Nastavimo koncen url za redirect
+ $finishUrl = $row['url'].'?'.$panel_settings['user_id_name'].'='.$panelist_id.'&'.$panel_settings['status_name'].'='.$panel_status;
+ }
+ }
+
+ // Na koncu preverimo, če gre za hierarhijo in resevanje supersifre
+ // V kolikor gre za hierarhijo, ki uporablja superšifro potem pred redirectom poberemo vse parametre
+ if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2) {
+ $resevanje = sisplet_query("SELECT * FROM srv_hierarhija_supersifra_resevanje WHERE user_id='".get('usr_id')."'", "obj");
+
+ $kode = sisplet_query("SELECT kode FROM srv_hierarhija_supersifra WHERE koda='".$resevanje->supersifra."'", "obj");
+ $kode = unserialize($kode->kode);
+
+ sisplet_query("UPDATE srv_hierarhija_supersifra_resevanje SET status=6 WHERE user_id='".get('usr_id')."'");
+
+ // V kolikor prispemo smo ravno zaključili reševanje zadnje ankete v supersifri potem prikažemo konec oz. glede na nastavitve ankete in ne preusmerimo ponovno na začetek
+ if(end($kode) != $resevanje->koda){
+ // Glede na vrednost
+ $naslednja = array_search($resevanje->koda, $kode) + 1;
+
+ $url = sisplet_query("SELECT url FROM srv_hierarhija_koda WHERE koda='".$kode[$naslednja]."'", "obj");
+
+ $url_encode_spremenljivke = urlencode(base64_encode($url->url . '&supersifra=' . $resevanje->supersifra.'&resujem='.$naslednja));
+ $redirect = $site_url .'a/'.get('anketa').'?enc='.$url_encode_spremenljivke;
+
+ header("Location: $redirect");
+ }
+
+ }
+
+ // za posebno MJU anketo pridobimo skupino in preusmerimo nazaj na zacetek z ustreznim lepim linkom
+ if(isset($modules['mju_theme'])){
+
+ // Dobimo id skupine za respondenta
+ $sqlGroup = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND d.usr_id='".get('usr_id')."' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroup = mysqli_fetch_array($sqlGroup);
+
+ if($rowGroup['vre_id'] > 0){
+
+ $sqlGroupName = sisplet_query("SELECT naslov FROM srv_vrednost WHERE id='".$rowGroup['vre_id']."' AND spr_id='".$rowGroup['spr_id']."'");
+ $rowGroupName = mysqli_fetch_array($sqlGroupName);
+
+ $finishUrl = 'https://gov-ankete.si/'.$rowGroupName['naslov'];
+ }
+ else{
+ $finishUrl = 'https://gov-ankete.si/';
+ }
+ }
+ // za posebno MJU anketo pridobimo skupino in preusmerimo nazaj na zacetek z ustreznim lepim linkom
+ if(isset($modules['mju_redirect'])){
+
+ // Dobimo id skupine za respondenta
+ $sqlGroup = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND d.usr_id='".get('usr_id')."' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroup = mysqli_fetch_array($sqlGroup);
+
+ if($rowGroup['vre_id'] > 0){
+
+ $sqlGroupName = sisplet_query("SELECT naslov, variable FROM srv_vrednost WHERE id='".$rowGroup['vre_id']."' AND spr_id='".$rowGroup['spr_id']."'");
+ $rowGroupName = mysqli_fetch_array($sqlGroupName);
+
+ $finishUrl = 'https://gov-ankete.si/UE1_'.$rowGroupName['variable'];
+ }
+ else{
+ $finishUrl = 'https://gov-ankete.si/';
+ }
+ }
+
+
+ // URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php)
+ if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '')
+ $close_url = $app_settings['survey_finish_url'];
+ else
+ $close_url = 'https://www.1ka.si/';
+
+
+ // pri formi posebej pogledamo ce anketo zapremo ali skocimo na url - po novem je lahko vklopljen zakljucek
+ if ($row['survey_type'] == 1 && $row['show_concl'] == 0) {
+
+ if ($row['concl_link'] == 1) {
+ header("Location: $finishUrl");
+ }
+ else {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\''.$close_url.'\';' . "\n";
+ echo ' </script>' . "\n";
+ }
+ }
+ // zakljucek ankete ni prikazan in oznaceno je da zapremo anketo
+ elseif ($row['show_concl'] == 0) {
+
+ if ($row['concl_link'] == 0) {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\''.$close_url.'\';' . "\n";
+ echo ' </script>' . "\n";
+ }
+ // Rekurzivno
+ else if ($row['concl_link'] == 2) {
+ header("Location: " . SurveyInfo::getSurveyLink());
+ }
+ else {
+ header("Location: $finishUrl");
+ }
+
+ } else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '<div class="outercontainer_holder ' . $class . ' concl">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . ' concl">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1 ' . (isset($modules['uporabnost']) ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ echo '<div class="grupa">' . "\n";
+
+ Statistic::displayStatistika(true);
+
+ $this->displayKonecContent();
+
+ echo '</div>' . "\n"; //-grupa
+
+ if ($row['user_from_cms'] == 2) {
+ //echo '<p style="text-align:center"><a href="'.$site_url.'a/'.$this->anketa.'">'.$lang['srv_nextins'].'</a></p>';
+ echo '<p style="text-align:center"><a href="' . SurveyInfo::getSurveyLink() . '">' . $lang['srv_nextins'] . '</a></p>';
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ if (!get('printPreview')) {
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang);
+ if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage'];
+
+ $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink');
+
+ echo '<div class="buttons">';
+ // prejsna stran, prikazemo ce ni v zakjucku drugace nastavljeno
+ if ($row['concl_back_button'] != '0')
+ #echo '<input class="prev" type="button" value="'.$srv_prevpage.'" onclick="history.back()">'."\n";
+ if ($display_backlink != '0') {
+ // Posebej za WebSM anketo - back naredimo tako, da poiscemo prejsnjo stran
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+
+ $grupa = Find::findPrevGrupa(get('anketa'), get('grupa'));
+ $grupa = ($grupa > 0) ? '&grupa=' . $grupa : '';
+
+ $language = (isset($_GET['language'])) ? '&language=' . $_GET['language'] : '';
+
+ $link = SurveyInfo::getSurveyLink(false, false) . $grupa . $language;
+
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="location.href=\'' . $link . '\';">';
+ } else {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">' . "\n";
+ }
+ }
+ }
+ if ($finishUrl != '') {
+
+ if ($row['concl_link'] == 1) {
+ if (!isset($modules['uporabnost']))
+ $js = 'document.location.href=\'' . $finishUrl . '\';';
+ else
+ $js = 'top.location.href=\'' . $finishUrl . '\';';
+ }
+ elseif ($row['concl_link'] == 2) {
+ if (!isset($modules['uporabnost']))
+ $js = 'document.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ else
+ $js = 'top.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ }
+ elseif (!isset($modules['uporabnost'])) {
+ if (Common::checkModule('evalvacija') == '1')
+ $js = 'window.close(); document.location.href=\'https://www.uni-lj.si/\';';
+ else
+ $js = 'window.close(); document.location.href=\''.$close_url.'\';';
+ }
+ // uporabnost
+ else
+ $js = 'top.close();';
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ $js = '$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); ';
+
+
+ // Za posebno MJU anketo posebej pohendlamo kaj se zgodi po koncu
+ if(isset($modules['mju_theme'])){
+
+ // Mobitel ali tablica se po koncu zapre
+ if(get('mobile') == 1 || get('mobile') == 2){
+ $js = 'window.close(); document.location.href=\'https://http://www.mju.gov.si//\';';
+ }
+ // Drugace se preusmeri na zacetek
+ else{
+ $js = 'document.location.href=\'' . $finishUrl . '\';';
+ }
+ }
+
+
+ if (!get('printPreview')) {
+ $srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang);
+ /*if ($row['text'] != '') // besedilo koncne povezave shranimo v misc setting, da bo konsistentno z ostalimi prevodi
+ $text = $row['text'];
+ else*/
+ if ($srv_konec != '')
+ $text = $srv_konec;
+ else
+ $text = $lang['srv_konec'];
+
+ if ($row['concl_end_button'] == 1)
+ echo '<input class="next" type="submit" value="' . $text . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+ if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos
+ $sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1");
+ $rowg = mysqli_fetch_array($sqlg);
+ //echo '<p class="vnos"><a href="'.$site_url.'a/'.$this->anketa.'&grupa='.$rowg['id'].'">'.$lang['srv_nextins'].'</a> | <a href="'.$site_url.'admin/survey/index.php?anketa='.$this->anketa.'">'.$lang['srv_insend'].'</a></p>';
+ echo '<p class="vnos"><a href="' . SurveyInfo::getSurveyLink() . '&grupa=' . $rowg['id'] . '">' . $lang['srv_nextins'] . '</a> | <a href="' . $site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . $lang['srv_insend'] . '</a></p>';
+ }
+
+ echo '</div>' . "\n"; // -container
+
+ $this->displayFooterNote();
+ #$this->displayRespondetnPDF();
+
+ echo '</div>' . "\n"; // -outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+ }
+
+ //is respondent lurker?
+ $sqlur = sisplet_query("SELECT lurker FROM srv_user WHERE id = '" . get('usr_id') . "'", "obj");
+
+ // ce je tko oznacen in ce reposndent ni lurker, posljemo se alerte
+ if (mysqli_num_rows($sqlAlert) > 0 && $sqlur->lurker == 0)
+ Helper::getInstance()->alert();
+
+ // Ce je vklopljen evoli team meter, preverimo, ce posiljamo obvestilo po dosezeni kvoti
+ if( (isset($modules['evoli_teammeter']) || isset($modules['evoli_quality_climate']) || isset($modules['evoli_teamship_meter']) || isset($modules['evoli_organizational_employeeship_meter']))
+ && $tm_quota_increase
+ ){
+ Helper::getInstance()->alertTeamMeter();
+ }
+
+ Js::js_tracking();
+
+ } else { // za print preview in pdf
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ echo '<div id="container">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <div class="spremenljivka">' . "\n";
+ if ($row['conclusion'] == '') {
+ $concl = $lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ if (get('lang_id') != null) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "'AND spr_id='-2' AND lang_id='" . get('lang_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['naslov'] != '') $concl = $row1['naslov'];
+ }
+ echo ' <p>' . $concl . '</p>' . "\n";
+ echo ' </div>' . "\n";
+ echo '</div>' . "\n";
+ echo '</div>' . "\n";
+ }
+ }
+
+ public function displayKonecContent(){
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ echo ' <div class="spremenljivka">' . "\n";
+
+ // Ce gre za gdpr zakljucek (respondent ni sprejel pogojev)
+ if(GDPR::isGDPRSurveyTemplate(get('anketa')) && isset($_POST['gdpr_accept']) && $_POST['gdpr_accept'] == '0'){
+ self::displayKonecGDPR();
+ }
+ else{
+
+ if ($row['conclusion'] == '') {
+ $concl = self::$lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ if (get('lang_id') != null) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='-2' AND lang_id='" . get('lang_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['naslov'] != '') $concl = $row1['naslov'];
+ }
+
+ $concl = Helper::dataPiping($concl);
+
+ echo ' <div class="naslov"><p>' . $concl . '</p></div>' . "\n";
+
+ Display::getInstance()->displayReturnEditURL();
+ Display::getInstance()->displayRespondetnPDF();
+ }
+
+ echo ' </div>' . "\n";
+
+
+ // Prikaz pravilnih rezultatov v primeru kviza
+ if(SurveyInfo::getInstance()->checkSurveyModule('quiz')){
+
+ // Pridobimo nastavitve kviza
+ $sq = new SurveyQuiz(get('anketa'));
+ $quiz_settings = $sq->getSettings();
+
+ if($quiz_settings['results'] == '1' || $quiz_settings['results_chart'] == '1'){
+
+ echo '<div id="quiz_results">';
+
+ echo '<h2>'.self::$lang['results'].'</h2>';
+
+ // Prikaz grafa rezultatov
+ if($quiz_settings['results_chart'] == '1')
+ Display::getInstance()->displayQuizChart();
+
+ // Prikaz rezultatov
+ if($quiz_settings['results'] == '1')
+ Display::getInstance()->displayQuizAnswers();
+
+ echo '</div>';
+ }
+ }
+
+ // Prikaz Excelleration matrix grafa ce je vklopljen napredni modul
+ if(SurveyInfo::getInstance()->checkSurveyModule('excell_matrix')){
+ echo '<div id="excell_matrix">';
+ Display::getInstance()->displayExcellChart();
+ echo '</div>';
+ }
+
+ // SKAVTI - prikaz povzetka odgovorov in grafa
+ global $mysql_database_name;
+ //if($mysql_database_name == '1ka' && get('anketa') == '64'){
+ if($mysql_database_name == 'real1kasi' && (get('anketa') == '293926' || get('anketa') == '314856' || get('anketa') == '332793')){
+ echo '<div id="skavti_answers">';
+ Display::getInstance()->displaySkavtiAnswers();
+ echo '</div>';
+ }
+
+ // NIJZ - prikaz radar grafa in tabele
+ global $site_domain;
+ if( ($site_domain == 'test.1ka.si' && get('anketa') == '8892') || ($site_domain == 'anketa.nijz.si' && get('anketa') == '126738') ){
+
+ $nijz = new SurveyNIJZ(get('anketa'), get('usr_id'));
+
+ $nijz->displayRadar();
+ $nijz->displayTable();
+ }
+ }
+
+ // Prikazemo dodaten uvod za GDPR
+ public function displayKonecGDPR()
+ {
+ //$user_settings = GDPR::getSurveySettings(get('anketa'));
+
+ echo '<div class="naslov">';
+ echo '<p>'.self::$lang['srv_gdpr_concl'].'</p>';
+ echo '</div>';
+ }
+
+
+ /**
+ * @desc prikaze konec ankete
+ */
+ public function displayKonecGlasovanje(){
+ global $app_settings;
+
+ echo '<script>var srv_meta_anketa_id = ' . get('anketa') . ';</script>';
+
+ //izpis zakljucka
+ if (isset($_GET['glas_end']) && $_GET['glas_end'] == 1) {
+ if (!get('printPreview')) {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $endButton = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec');
+ $endButton = ($endButton == '') ? self::$lang['srv_konec'] : $endButton;
+ //$row['text'] == '' ? $endButton = self::$lang['srv_konec'] : $endButton = $row['text'];
+
+ //dodaten naslov gumba zakljucek
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage');
+ if ($srv_prevpage != '')
+ $text = $srv_prevpage;
+ else
+ $text = self::$lang['srv_prevpage'];
+
+
+ // URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php)
+ if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '')
+ $close_url = $app_settings['survey_finish_url'];
+ else
+ $close_url = 'https://www.1ka.si/';
+
+ // zakljucek ankete ni prikazan in oznaceno je da zapremo anketo
+ if ($row['show_concl'] < 1) {
+ if ($row['concl_link'] == 0) {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\''.$close_url.'\';' . "\n";
+ echo ' </script>' . "\n";
+ } else {
+ header("Location: $row[url]");
+ }
+ }
+
+
+ echo '<div class="outercontainer_holder concl_glasovanje">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer concl_glasovanje">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ echo '<div class="grupa">' . "\n";
+
+ echo ' <div class="spremenljivka">' . "\n";
+
+ if ($row['conclusion'] == '') {
+ $concl = self::$lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ echo ' <h3><p>' . $concl . '</p></h3>' . "\n";
+
+ echo ' </div>' . "\n";
+
+ echo '</div>' . "\n"; // -grupa
+
+ if ($_GET['preview'] == 'on') {
+ echo '<div class="buttons"><a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . self::$lang['srv_back_edit'] . '</a></div>' . "\n";
+ }
+
+ echo '<div class="buttons">';
+
+
+ if ($row['concl_back_button'] == 1) {
+ echo '<input class="prev" type="button" value="' . $text . '" onclick="javascript:history.go(-1)">';
+ }
+
+ if ($row['concl_end_button'] == 1) {
+ if ($row['concl_link'] == 1)
+ $js = 'document.location.href=\'' . $row['url'] . '\';';
+ else
+ $js = 'window.close(); document.location.href=\''.$close_url.'\';';
+
+ if (!get('printPreview')) {
+ echo '<input class="next" type="submit" value="' . $endButton . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+
+ echo '</div>' . "\n"; // -container
+
+ $this->displayFooterNote();
+
+ echo '</div>'; // -outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ // ce je tko oznacen posljemo se alerte
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "' AND (finish_respondent=1 OR finish_respondent_cms=1 OR finish_author=1 OR finish_other =1)");
+ if (mysqli_num_rows($sqlAlert) > 0)
+ Helper::getInstance()->alert();
+ }
+ else { // za print preview in pdf
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ echo '<div id="container">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <div class="spremenljivka">' . "\n";
+ if ($row['conclusion'] == '') {
+ $concl = self::$lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ echo ' <p>' . $concl . '</p>' . "\n";
+ echo ' </div>' . "\n";
+ echo '</div>' . "\n";
+ }
+ } //izpis statistike
+ else {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqls = sisplet_query("SELECT stat FROM srv_spremenljivka s, srv_glasovanje g WHERE g.ank_id = '" . get('anketa') . "' AND s.id = g.spr_id");
+ $rows = mysqli_fetch_array($sqls);
+
+ //ce statistike ne prikazujemo skocimo na zakljucek (ce imammo izklopljeno ali nastavleno na samo urednike in ni urednik)
+ if ($rows['stat'] == 0 || ($rows['stat'] == 2 && self::$admin_type != 0 && self::$admin_type != 1)) {
+ //header('Location: '.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url').'');
+ header('Location: ' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url') . '');
+ } else {
+
+ echo '<div class="outercontainer_holder concl_statistika">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer concl_statistika">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ echo '<div class="grupa">' . "\n";
+ Statistic::displayStatistika(true);
+ echo '</div>' . "\n";
+
+ echo '<div class="buttons">';
+ //$url_stat = ''.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url');
+ $url_stat = '' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url');
+ $js = 'document.location.href=\'' . $url_stat . '\';';
+
+ // Gumb nazaj
+ if ($row['concl_back_button'] == 1) {
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage');
+ if ($srv_prevpage != '')
+ $text = $srv_prevpage;
+ else
+ $text = self::$lang['srv_prevpage'];
+
+ echo '<input class="prev" type="button" value="' . $text . '" onclick="javascript:history.go(-1)">';
+ }
+
+ if ($row['show_concl'] == 1) {
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+
+ $srv_potrdi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_potrdi'.$_lang);
+ if ($srv_potrdi == '') $srv_potrdi = self::$lang['srv_potrdi'];
+
+ echo '<input class="next" type="submit" value="' . $srv_potrdi . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ elseif ($row['concl_end_button'] == 1) {
+ $endButton = self::$lang['srv_konec'];
+ echo '<input class="next" type="submit" value="' . $endButton . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+
+ echo '</div>' . "\n";
+
+ echo '</div>' . "\n"; // -container
+
+ echo '</div>' . "\n"; // -outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+ }
+ }
+ }
+
+ // Konec pri anketi evoli team meter - ce je kvota polna
+ public function displayKonecEvoliTM($date_to='')
+ {
+ global $mysql_database_name;
+ global $lang;
+ global $admin_type;
+ global $site_url;
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ // Popravimo url za skok po koncu ankete ce nima http://
+ if ($row['url'] != '' && substr($row['url'], 0, 4) != 'http') {
+ $finishUrl = 'http://' . $row['url'];
+ } else {
+ $finishUrl = $row['url'];
+ }
+
+ // Dodamo datapiping v url-ju
+ if($row['url'] != ''){
+ // Počistimo html tage
+ $finishUrl = strip_tags(Helper::dataPiping($finishUrl));
+ }
+
+ // Preverimo ce imamo nastavljene kaksne get parametre za dodat pri skoku na url
+ if ($row['concl_link'] == 1 && $finishUrl != '') {
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $concl_url_usr_id = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_usr_id');
+ $concl_url_status = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_status');
+ $concl_url_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_recnum');
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1')
+ $finishUrl .= '?';
+
+ if ($concl_url_usr_id == '1') {
+ $finishUrl .= 'usr_id=' . get('usr_id') . '&';
+ }
+
+ if ($concl_url_status == '1' || $concl_url_recnum == '1') {
+ $sqlU = sisplet_query("SELECT last_status FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ if($concl_url_recnum == '1')
+ $finishUrl .= 'recnum=' . $rowU['recnum'] . '&';
+
+ if($concl_url_status == '1')
+ $finishUrl .= 'status=' . $rowU['last_status'] . '&';
+ }
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1')
+ $finishUrl = substr($finishUrl, 0, -1);
+ }
+
+ if ($row['show_concl'] == 0) {
+
+ if ($row['concl_link'] == 0) {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\'http://www.1ka.si/\';' . "\n";
+ echo ' </script>' . "\n";
+ }
+ // Rekurzivno
+ else if ($row['concl_link'] == 2) {
+ header("Location: " . SurveyInfo::getSurveyLink());
+ }
+ else {
+ header("Location: $finishUrl");
+ }
+
+ }
+ else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+ echo '<div class="outercontainer_holder ' . $class . '">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . '">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ // Vsebina zakljucka ce je kvota polna oz je presezen datum
+ echo '<div class="grupa">' . "\n";
+ echo ' <div class="spremenljivka">' . "\n";
+
+ echo ' <div class="naslov"><p>';
+ if($date_to != '')
+ echo self::$lang['srv_evoli_survey_expired'].' '.$date_to.' '.self::$lang['srv_evoli_survey_end_help'];
+ else
+ echo self::$lang['srv_evoli_survey_quota_full'].' '.self::$lang['srv_evoli_survey_end_help'];
+ echo ' </p></div>';
+
+ echo ' </div>' . "\n";
+ echo '</div>' . "\n"; //-grupa
+
+
+ if ($row['user_from_cms'] == 2) {
+ echo '<p style="text-align:center"><a href="' . SurveyInfo::getSurveyLink() . '">' . $lang['srv_nextins'] . '</a></p>';
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ if (!get('printPreview')) {
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang);
+ if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage'];
+
+ $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink');
+
+ echo '<div class="buttons">';
+ // prejsna stran, prikazemo ce ni v zakjucku drugace nastavljeno
+ /*if ($row['concl_back_button'] != '0')
+ if ($display_backlink != '0') {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">' . "\n";
+ }*/
+ }
+ if ($finishUrl != '') {
+ if ($row['concl_link'] == 1) {
+ if (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost'))
+ $js = 'document.location.href=\'' . $finishUrl . '\';';
+ else
+ $js = 'top.location.href=\'' . $finishUrl . '\';';
+ } elseif ($row['concl_link'] == 2) {
+ if (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost'))
+ $js = 'document.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ else
+ $js = 'top.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ } elseif (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost')) {
+ if (Common::checkModule('evalvacija') == '1')
+ $js = 'window.close(); document.location.href=\'https://www.uni-lj.si/\';';
+ else
+ $js = 'window.close(); document.location.href=\'https://www.1ka.si/\';';
+ } // uporabnost
+ else
+ $js = 'top.close();';
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ $js = '$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); ';
+
+
+ if (!get('printPreview')) {
+ $srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang);
+
+ if ($srv_konec != '')
+ $text = $srv_konec;
+ else
+ $text = $lang['srv_konec'];
+
+ if ($row['concl_end_button'] == 1)
+ echo '<input class="next" type="submit" value="' . $text . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+ if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos
+ $sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1");
+ $rowg = mysqli_fetch_array($sqlg);
+ //echo '<p class="vnos"><a href="'.$site_url.'a/'.$this->anketa.'&grupa='.$rowg['id'].'">'.$lang['srv_nextins'].'</a> | <a href="'.$site_url.'admin/survey/index.php?anketa='.$this->anketa.'">'.$lang['srv_insend'].'</a></p>';
+ echo '<p class="vnos"><a href="' . SurveyInfo::getSurveyLink() . '&grupa=' . $rowg['id'] . '">' . $lang['srv_nextins'] . '</a> | <a href="' . $site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . $lang['srv_insend'] . '</a></p>';
+ }
+
+ echo '</div>' . "\n"; // -container
+
+ $this->displayFooterNote();
+
+ echo '</div>' . "\n"; // -outercontainer
+ echo '<div class="outercontainer_holder_bottom"></div></div>'; // -outercontainer_holder
+ }
+ }
+
+
+ /**
+ * @desc prikaze trenutno anketo
+ */
+ public function displayAnketa()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ if (!get('printPreview')) {
+
+ // crn div za ozadje popupov
+ echo '<div id="fade"></div>';
+ echo '<div id="popup"></div>';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '<div class="outercontainer_holder ' . $class . '">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . '">';
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ $d = new Display();
+ $d->logo();
+ $d->progress_bar();
+
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ if (get('quick_view') == true) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_quick_view_text'];
+ echo '</div>';
+ }
+
+ //opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_edit_text'];
+ echo '</div>';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ //ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ $this->displayGrupa();
+
+ echo '</div>' . "\n"; // - container
+
+ $this->displayFooterNote();
+
+ // TAWK chat, ce je vklopljen
+ if(SurveyInfo::getInstance()->checkSurveyModule('chat')){
+ Display::getInstance()->displayChatTAWK();
+ }
+
+ echo '</div>'; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ Js::js_tracking();
+
+ } else {
+
+ echo '<div id="container">' . "\n";
+ $this->displayGrupa();
+ echo '</div>' . "\n";
+ }
+ }
+
+ public function displayAllPages()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ echo '<div class="outercontainer_holder">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer">';
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+ }
+
+ echo '<div class="grupa">';
+ $this->displayIntroductionContent();
+ echo '</div>';
+
+ $this->displayGrupa();
+
+ echo '<div class="grupa">';
+ $this->displayKonecContent();
+ echo '</div>';
+
+ echo '</div>' . "\n"; // - container
+
+ echo '</div>' . "\n"; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ $this->displayFooterNote();
+ }
+
+ /**
+ * @desc prikaze trenutno grupo
+ */
+ public function displayGrupa(){
+ global $admin_type;
+
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo id-strani
+ if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ SurveyAdvancedParadataLog::getInstance()->displayGrupa(get('grupa'));
+ }
+
+ $sql = sisplet_query("SELECT naslov, vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row = mysqli_fetch_array($sql);
+ if (!get('printPreview')) {
+
+ Display::getInstance()->display_tabs();
+
+ echo '<form name="vnos" method="post" action="' . SurveyInfo::getSurveyLink(false, false) . '&amp;grupa=' . get('grupa') . (get('loop_id') != null ? '&amp;loop_id=' . get('loop_id') : '') . Header::getSurveyParams(true) . str_replace('&', '&amp;', get('cookie_url')) . '" enctype="multipart/form-data">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <input type="hidden" name="dummy" value="foo">' . "\n";
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // izbira jezika za respondenta - Ce nimamo prikazanega uvoda, prikazemo izbiro na prvi strani
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $rowa['multilang'] == 1 && $rowa['show_intro'] == 0 && $row['vrstni_red'] == 1) {
+
+ $lang_resp = $rowa['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+ $file = lang_path($lang_resp);
+ include($file);
+
+ $lang_array[$lang['id']] = $lang['language'];
+
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ echo ' <div class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira jezika z dropdown menijem
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ echo ' <h3>' . self::$lang['lang'] . ': ';
+ echo ' <select
+ name="language"
+ id="language"
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+
+ echo ' </select>';
+ echo '</h3>' . "\n";
+ }
+ // Izbira jezika z radio gumbi (default)
+ else {
+ echo '<h3>' . self::$lang['lang'] . ': </h3>';
+ echo '<span style="font-size:13px;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<label for="language_' . $key . '">';
+ echo '<input type="radio" name="language" id="language_' . $key . '"
+ value="' . $key . '"' . ($key == $current ? '
+ checked="checked"' : '') . '
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language_' . $key . '\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;"> ';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+
+ echo $val;
+
+ echo '</label><br />';
+ }
+ echo '</span>';
+ }
+
+ echo ' </div>' . "\n";
+ }
+
+ Vprasanja::getInstance()->displaySpremenljivke();
+
+ echo '</div>' . "\n"; // - grupa
+
+ Js::getInstance()->generateSubmitJS();
+
+ echo '</form>' . "\n";
+
+ Js::getInstance()->generateBranchingJS();
+
+ // Disable odgovorov, ce je ze izpolnjeval to stran in ima vklopljeno nastavitev, da ni dovoljeno naknadno vnasanje odogovorov
+ if($rowa['subsequent_answers'] == '0' && $admin_type != '0' && $admin_type != '1'){
+
+ // Preverimo, ce je uporabnik ze bil na strani
+ if(Check::getInstance()->check_subsequent_visit()){
+ echo '<script>disableSubsequentAnswers();</script>';
+ }
+ }
+
+ // nov zgornji link pri uporabnosti
+ $link = SurveySetting::getInstance()->getSurveyMiscSetting('uporabnost_link_' . get('grupa'));
+ if ($link != '' && strlen($link) > 7)
+ echo "<script> top.frames['link'].location.href = '" . $link . "'; </script>";
+ }
+ else{
+ Display::getInstance()->displaySpremenljivke();
+ }
+ }
+
+
+ public function displayFooterNote(){
+ global $mysql_database_name, $app_settings;
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ echo '<div id="footer_survey">';
+
+ // Pri mobilnem skinu (in mju skinu pri tablici) prikazemo na dnu se logo
+ if (get('mobile') == 1 || (get('mobile') == 2 && SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1')) {
+ Display::getInstance()->logo();
+ }
+
+ // Custom footer
+ if(isset($app_settings['footer_survey_custom']) && $app_settings['footer_survey_custom'] == 1){
+
+ echo '<p>'.$app_settings['footer_survey_text'].'</p>';
+ }
+ // Default footer
+ else{
+
+ $link = (self::$lang['id'] == '1') ? 'https://www.1ka.si' : 'https://www.1ka.si/d/en';
+ $link_cookie = (self::$lang['id'] == '1') ? 'https://www.1ka.si/d/sl/o-1ka/pogoji-uporabe-1ka/politika-piskotkov' : 'https://www.1ka.si/d/en/about/terms-of-use/cookie-policy';
+ $link_privacy = (self::$lang['id'] == '1') ? 'https://www.1ka.si/d/sl/o-1ka/pogoji-uporabe-storitve-1ka/politika-zasebnosti' : 'https://www.1ka.si/d/en/about/terms-of-use/privacy-policy';
+ $link_paradata = (self::$lang['id'] == '1') ? 'https://www.1ka.si/d/sl/o-1ka/pogoji-uporabe-1ka/izklop-parapodatkov' : 'https://www.1ka.si/d/en/about/terms-of-use/turn-off-paradata';
+
+ echo '<p class="footer_survey_UL">Univerza <i>v Ljubljani</i></p>';
+ echo '<p class="footer_survey_FDV"><i>Fakulteta za dru&#382;bene vede</i></p>';
+ echo '<p class="footer_survey_PoweredBy"><a href="'.$link.'" target="_blank">Powered by: 1KA</a></p>';
+ echo '<p class="footer_1ka"><a href="'.$link.'" target="_blank">1KA - ' . self::$lang['srv_footer_1ka'] . '</a></p>';
+
+ echo '<p class="privacy">';
+
+ $survey_ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip');
+ $ip_show = SurveySetting::getInstance()->getSurveyMiscSetting('survey_show_ip');
+ $survey_browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser');
+ $survey_referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal');
+ $survey_date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+
+ $privacy_text = '';
+
+ // Ce imamo vse izklopljeno je anketa brez parapodatkov
+ if(($survey_ip == 1 || $ip_show == 0) && $survey_browser == 1 && $survey_referal == 1 && $survey_date == 1){
+
+ $privacy_text = '<a href="'.$link_paradata.'" target="_blank">' . self::$lang['srv_no_paradata'] . '</a>';
+
+ echo $privacy_text;
+ }
+ else{
+ echo '<a href="'.$link.'" target="_blank">' . self::$lang['srv_no_anketa'] . ' </a>';
+
+ // Piskotki
+ if ($row['cookie'] == -1)
+ $privacy_text .= '<a href="'.$link_cookie.'" target="_blank">' . self::$lang['srv_no_cookie'] . '</a>, ';
+
+ // IP sledenje
+ if ($survey_ip == 1)
+ $privacy_text .= '<a href="'.$link_paradata.'" target="_blank">' . self::$lang['srv_no_ip'] . '</a>, ';
+
+ // Email povezovanje
+ if ($row['user_base'] == 1 && $row['show_email'] == 0)
+ $privacy_text .= '<a href="'.$link_paradata.'" target="_blank">' . self::$lang['srv_no_email'] . '</a>, ';
+
+ echo substr($privacy_text, 0, -2);
+ }
+
+ echo '</p>';
+
+ echo '<p class="privacy_link">';
+ echo '<a href="' . $link_privacy . '" target="_blank">' . self::$lang['srv_privacy_policy'] . '</a>';
+ echo '</p>';
+ }
+
+ echo '</div>';
+
+
+ // OKNO Z NASTAVITVAMI ZA PREVIEW / TEST
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on' && $_GET['no_preview'] != '1') {
+
+ echo '<div id="preview-window">';
+
+
+ // Gump za odprtje/zaprtje okna
+ echo '<div id="preview_open" '.($_GET['testdata'] == 'on' ? ' class="testdata"' : '').'>';
+
+ echo '<a href="#" onclick="preview_popup_open(); return false;" class="preview_icon_open" style="display:none;"><span class="faicon dropdown_blue"></span></a>';
+ echo '<a href="#" onclick="preview_popup_close(); return false;" class="preview_icon_close"><span class="faicon dropup_blue"></span></a>';
+
+ echo '</div>';
+
+
+ // Preklop na celostranski preview
+ echo '<div id="preview_switch">';
+
+ echo '<span class="bold">'.self::$lang['srv_mode'] . ':</span>';
+ echo '<span class="'.(get('displayAllPages') ? 'nonactive' : 'active').'"><a href="' . SurveyInfo::getSurveyLink() . Header::getSurveyParams(false, null, array('pages')) . '" title="' . self::$lang['srv_normal_x'] . '">' . self::$lang['srv_normal'] . '</a></span>';
+ echo '<span class="'.(get('displayAllPages') ? 'active' : 'nonactive').'"><a href="' . SurveyInfo::getSurveyLink() . Header::getSurveyParams(false, array('pages' => 'all', 'mobile' => '0')) . '" title="' . self::$lang['srv_scrolling_x'] . '">' . self::$lang['srv_scrolling'] . '</a></span>';
+
+ echo '</div>';
+
+
+ // Vsebina - preview-holder
+ echo '<div id="preview-holder">';
+
+ echo '<div id="preview" class="' . ($_GET['testdata'] == 'on' ? 'testdata' : '') . '">';
+
+ if ($_GET['testdata'] == 'on')
+ echo '<p>' . self::$lang['srv_testalert'] . '</p>';
+ else
+ echo '<p>' . self::$lang['srv_previewalert'] . '</p>';
+
+ if ($row['multilang'] == 1) {
+ $lang_resp = $row['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+ $file = lang_path($lang_resp);
+ include($file);
+
+ $lang_array[$lang['id']] = $lang['language'];
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ // FORM s preklopom jezika
+ echo '<form name="change_lang" action="" method="get">';
+
+ if (isset($_GET['code']))
+ echo '<input type="hidden" name="code" value="' . $_GET['code'] . '">';
+
+ if (isset($_GET['preview']))
+ echo '<input type="hidden" name="preview" value="' . $_GET['preview'] . '">';
+
+ if (isset($_GET['disableif']))
+ echo '<input type="hidden" name="disableif" value="' . $_GET['disableif'] . '">';
+
+ if (isset($_GET['displayifs']))
+ echo '<input type="hidden" name="displayifs" value="' . $_GET['displayifs'] . '">';
+
+ if (isset($_GET['displayvariables']))
+ echo '<input type="hidden" name="displayvariables" value="' . $_GET['displayvariables'] . '">';
+
+ if (isset($_GET['disablealert']))
+ echo '<input type="hidden" name="disablealert" value="' . $_GET['disablealert'] . '">';
+
+ if (isset($_GET['disablecode']))
+ echo '<input type="hidden" name="disablecode" value="' . $_GET['disablecode'] . '">';
+
+ if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0)
+ echo '<input type="hidden" name="disablecode" value="1">';
+
+ if (isset($_GET['grupa']))
+ echo '<input type="hidden" name="grupa" value="' . $_GET['grupa'] . '">';
+
+
+ echo '<p>' . self::$lang['lang'] . ': ';
+
+ echo ' <select name="language" onchange="document.change_lang.submit();">';
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+ echo ' </select></p>' . "\n";
+
+ echo '</form>';
+ }
+
+
+ // Preklop med preview-ji za mobilnik, tablico in pc
+ if(!get('displayAllPages')){
+
+ echo '<span id="preview_device"><span>' . self::$lang['srv_para_graph_device'] . ': </span>';
+
+ if (isset($_GET['mobile']) && $_GET['mobile'] == '1')
+ $device_value = 1;
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == '2')
+ $device_value = 2;
+ else
+ $device_value = 0;
+
+ echo '<a href="#" title="PC" onClick="$(\'#device_value\').val(\'0\'); document.change_diable.submit();"><span class="faicon monitor ' . ($device_value == 0 ? ' active' : '') . '"></span></a>';
+
+ // Ce imamo izklopljene mobilne prilagoditve ne pustimo preview-ja na mobile, ker itak ne prikaze scalano
+ $mobile_friendly = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_friendly');
+ if($mobile_friendly != '0'){
+ echo '<a href="#" title="' . self::$lang['srv_preview_tablet'] . '" onClick="$(\'#device_value\').val(\'2\'); document.change_diable.submit();"><span class="faicon tablet ' . ($device_value == 2 ? ' active' : '') . '"></span></a>';
+ echo '<a href="#" title="' . self::$lang['srv_preview_mobile'] . '" onClick="$(\'#device_value\').val(\'1\'); document.change_diable.submit();"><span class="faicon mobile ' . ($device_value == 1 ? ' active' : '') . '"></span></a>';
+ }
+
+ echo '</span>';
+ }
+
+
+ // FORM z dropdownom za preklop med stranmi
+ echo '<form name="go_to_page" action="#" method="get">';
+
+ if (isset($_GET['code']))
+ echo '<input type="hidden" name="code" value="' . $_GET['code'] . '">';
+
+ if (isset($_GET['preview']))
+ echo '<input type="hidden" name="preview" value="' . $_GET['preview'] . '">';
+
+ if (isset($_GET['mobile']))
+ echo '<input type="hidden" name="mobile" value="' . $_GET['mobile'] . '">';
+
+ echo '<input type="hidden" name="disableif" value="1">';
+
+ if (isset($_GET['displayifs']))
+ echo '<input type="hidden" name="displayifs" value="' . $_GET['displayifs'] . '">';
+
+ if (isset($_GET['displayvariables']))
+ echo '<input type="hidden" name="displayvariables" value="' . $_GET['displayvariables'] . '">';
+
+ if (isset($_GET['disablealert']))
+ echo '<input type="hidden" name="disablealert" value="' . $_GET['disablealert'] . '">';
+
+ if (isset($_GET['disablecode']))
+ echo '<input type="hidden" name="disablecode" value="' . $_GET['disablecode'] . '">';
+
+ if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0)
+ echo '<input type="hidden" name="disablecode" value="1">';
+
+ if ($row['multilang'] == 1 && isset($_GET['language']))
+ echo '<input type="hidden" name="language" value="' . $_GET['language'] . '">';
+
+
+ // Skok na doloceno stran - samo ce nimamo prikaza vse na eni strani
+ if(!get('displayAllPages')){
+ echo '<p>' . self::$lang['srv_jump_to'] . ': <select name="grupa" onchange="document.go_to_page.submit();">';
+
+ $sql1 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grupa WHERE ank_id = '" . get('anketa') . "' ORDER BY vrstni_red ASC");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<option value="' . $row1['id'] . '" ' . ($row1['id'] == get('grupa') ? 'selected' : '') . '>' . self::$lang['srv_stran'] . ' ' . $row1['vrstni_red'] . '</option>';
+
+ $sql2 = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='$row1[id]' ORDER BY vrstni_red ASC");
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ if ($row['multilang'] == 1) {
+ $sqlLang = sisplet_query("SELECT * FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='" . $row2['id'] . "' AND lang_id='" . get('lang_id') . "'");
+ if (mysqli_num_rows($sqlLang) > 0) {
+ $rowLang = mysqli_fetch_array($sqlLang);
+ $row2['naslov'] = $rowLang['naslov'];
+ }
+ }
+
+ echo '<option value="' . $row1['id'] . '"> - (' . $row2['variable'] . ') ' . substr($row2['naslov'], 0, 100) . '</option>';
+ }
+ }
+ echo '</select></p>';
+ }
+
+ echo '</form>';
+
+
+ // FORM s checkbox nastavitvami
+ $link = SurveyInfo::getSurveyLink(get('anketa')) . '' . Header::getSurveyParams(false, null, array('disableif', 'disablealert', 'disablecode', 'displayifs', 'displayvariables', 'hidecomment', 'mobile')) . '&survey-' . get('anketa') . '=' . $_GET['survey-' . get('anketa') . ''] . '&grupa=' . $_GET['grupa'];
+ echo '<form name="change_diable" action="' . $link . '" method="get">';
+
+ echo '<input type="hidden" name="mobile" id="device_value" value="' . $device_value . '">';
+
+ if ($row['multilang'] == 1 && isset($_GET['language']))
+ echo '<input type="hidden" name="language" value="' . $_GET['language'] . '">';
+
+ if (isset($_GET['code']))
+ echo '<input type="hidden" name="code" value="' . $_GET['code'] . '">';
+
+ echo '<p><label for="disableif"><input type="checkbox" value="1" ' . ($_GET['disableif'] == '1' ? ' checked' : '') . ' name="disableif" id="disableif" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_disableif'] . '</label></p>';
+
+ echo '<p><label for="disablealert"><input type="checkbox" value="1" ' . ($_GET['disablealert'] == '1' ? ' checked' : '') . ' name="disablealert" id="disablealert" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_disablealert'] . '</label></p>';
+
+ // Pogoj za izlapljanje kode ce imamo email vabila z zahtevano kodo
+ if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0) {
+ echo '<p><label for="disablecode"><input type="checkbox" value="1" ' . ($_GET['disablecode'] == '1' ? ' checked' : '') . ' name="disablecode" id="disablecode" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_disablecode'] . '</label></p>';
+ }
+
+ echo '<p><label for="displayifs"><input type="checkbox" value="1" ' . ($_GET['displayifs'] == '1' ? ' checked' : '') . ' name="displayifs" id="displayifs" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_displayifs'] . '</label></p>';
+
+ echo '<p><label for="displayvariables"><input type="checkbox" value="1" ' . ($_GET['displayvariables'] == '1' ? ' checked' : '') . ' name="displayvariables" id="displayvariables" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_displayvariables'] . '</label></p>';
+
+
+ // Komentarji - vidno samo ce imamo ustrezen paket
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ if($userAccess->checkUserAccess($what='komentarji')){
+
+ $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment');
+ $preview_disable_test_insert = SurveySetting::getInstance()->getSurveyMiscSetting('preview_disable_test_insert');
+
+ if ($_GET['testdata'] == 'on' || $preview_disable_test_insert == 0) {
+
+ if ($question_resp_comment == 0) {
+ echo '<p><a href="#" onclick="$.post(\'' . self::$site_url . '/main/survey/ajax.php?a=enable_comments\', {anketa: ' . get('anketa') . '}, function () { window.location = window.location + \'&testdata=on\' }); return false;">';
+
+ if ($_GET['testdata'] == 'on')
+ echo self::$lang['srv_preview_comments'];
+ else
+ echo self::$lang['srv_savedatapreview'];
+
+ echo '</a></p>';
+ }
+ else {
+ if ($_GET['testdata'] == 'on') {
+ echo '<p><label for="hidecomment"><input type="checkbox" value="1" ' . ($_GET['hidecomment'] == '1' ? ' checked' : '') . ' name="hidecomment" id="hidecomment" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_preview_comments2'] . '</label></p>';
+ } else {
+ echo '<p><a href="#" onclick="$.post(\'' . self::$site_url . '/main/survey/ajax.php?a=enable_comments\', {anketa: ' . get('anketa') . '}, function () { window.location = window.location + \'&testdata=on\' }); return false;">';
+ echo self::$lang['srv_savedatapreview'];
+ echo '</a></p>';
+ }
+ }
+ }
+ }
+
+
+
+ echo '</form>';
+
+ echo '</div>' . "\n"; // preview
+
+
+ // Komentarji - vidno samo ce imamo ustrezen paket
+ if($userAccess->checkUserAccess($what='komentarji')){
+
+ if ($question_resp_comment == 1 && $_GET['testdata'] == 'on') {
+ $question_resp_comment_inicialke = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke');
+
+ if ($question_resp_comment_inicialke == 1) {
+ echo '<p class="inicialke">' . self::$lang['srv_inicialke'] . ': <input type="text" value="" size="3" id="inicialke"></p>';
+ echo '<script> inicialke(); </script>';
+ }
+ }
+
+ $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'");
+ (mysqli_num_rows($sqlUserAutor) > 0) ? save('userAutor', true) : save('userAutor', false);
+ // Komentarji urednikov na anketo
+ if (get('userAutor')) {
+
+ echo '<div style="margin: 20px 0 15px; width: 100%;">';
+
+ $view = 1;
+ $survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment');
+ $preview_hide_survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('preview_hide_survey_comment');
+ if ((self::$admin_type <= $survey_comment && $survey_comment != '') && (/*$preview_hide_survey_comment != 1 ||*/
+ $_GET['testdata'] == 'on')
+ ) {
+
+ echo '<span class="stngs floatLeft">';
+
+ $show_survey_comment = $_GET['show_survey_comment'];
+ if ($row['forum'] == 0 || $row['thread'] == 0) {
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="0" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+ echo '</a>';
+ } else {
+
+ $sqlf = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]'");
+ $rowf = mysqli_fetch_array($sqlf);
+ $rowf['count']--; //zaradi 1. avtomatskega posta
+
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="0" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+
+ // ali prikazemo okno odprto - je dodan tak admin komentar
+ $sqlf1 = sisplet_query("SELECT * FROM post p WHERE p.tid='$row[thread]' AND p.ocena='5'");
+ while ($rowf1 = mysqli_fetch_array($sqlf1)) {
+ $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='self::$global_user_id'");
+ if (mysqli_num_rows($s) == 0)
+ $show_survey_comment = 1;
+ }
+ echo '</a>';
+ }
+
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/js-lang.php?lang='.self::$lang['lang_short'].'&amp;v=13.06.07"></script>';
+ // Ce je tole vklopljeno se js porusi?
+ //echo '<script type="text/javascript" src="'.self::$site_url.'/admin/survey/minify/g=jsnew?v=13.06.07"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/jquery/jquery.qtip-1.0.js"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/script.js"></script>';
+ echo '<script> $(function() { load_comment(\'#surveycomment_0_' . $view . '\'' . ($show_survey_comment == '1' ? ', \'2\'' : '') . '); });</script>';
+
+ echo '</span>';
+ }
+
+ // Uredniske nastavitve link
+ echo '<span class="floatRight bold"><a href="' . self::$site_url . '/admin/survey/index.php?anketa=' . get('anketa') . '&a=testiranje&popup=open" target="_blank" title="' . self::$lang['srv_uredniske_nastavitve'] . '">' . self::$lang['settings'] . ' <span class="faicon settings"></span></a></span>';
+
+ echo '</div>';
+ }
+ // Komentarji respondentov na anketo
+ elseif (self::$global_user_id > 0 || true) {
+
+ echo '<p class="stngs">';
+
+ $view = 1;
+ $survey_comment_resp = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment_resp');
+ $preview_hide_survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('preview_hide_survey_comment');
+ if (((self::$admin_type <= $survey_comment_resp && self::$admin_type != -1 && $survey_comment_resp != '') || $survey_comment_resp == 4) && ($preview_hide_survey_comment != 1 || $_GET['testdata'] == 'on')) {
+
+ $show_survey_comment = $_GET['show_survey_comment'];
+
+ if ($row['forum'] == 0 || $row['thread_resp'] == 0) {
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="4" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ //echo '<span class="sprites _comments_add" title="'.self::$lang['srv_survey_comment'].'"></span>';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+ echo '</a>';
+ }
+ else {
+
+ $sqlf = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread_resp]'");
+ $rowf = mysqli_fetch_array($sqlf);
+ $rowf['count']--; //zaradi 1. avtomatskega posta
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="4" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+
+ $sqlf1 = sisplet_query("SELECT * FROM post p WHERE p.tid='$row[thread_resp]' AND p.ocena='5'");
+ while ($rowf1 = mysqli_fetch_array($sqlf1)) {
+ $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='self::$global_user_id'");
+ if (mysqli_num_rows($s) == 0)
+ $show_survey_comment = 1;
+ }
+ echo '</a>';
+ }
+
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/js-lang.php?lang='.self::$lang['lang_short'].'&amp;v=13.06.07"></script>';
+ // Ce je tole vklopljeno se js porusi?
+ //echo '<script type="text/javascript" src="'.self::$site_url.'/admin/survey/minify/g=jsnew?v=13.06.07"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/jquery/jquery.qtip-1.0.js"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/script.js"></script>';
+ echo '<script> $(function() { load_comment(\'#surveycomment_0_' . $view . '\'' . ($show_survey_comment == '1' ? ', \'2\'' : '') . '); });</script>';
+ }
+
+ echo '</p>';
+ }
+ }
+
+ echo '</div>' . "\n"; // preview-holder
+
+ echo '</div>' . "\n"; // preview-window
+
+
+ ?><script>
+ if (localStorage.preview_popup == 1) {
+ $('#preview-holder, #preview_switch').hide();
+
+ $('.preview_icon_open').show();
+ $('.preview_icon_close').hide();
+
+ $('#preview-window').addClass('closed');
+ }
+ </script><?
+
+
+ // Komentarji - vidno samo ce imamo ustrezen paket
+ if($userAccess->checkUserAccess($what='komentarji')){
+
+ // Prikazemo okno s komentarji ce je nastavljeno da je vedno odprto
+ $preview_survey_comment_showalways = SurveySetting::getInstance()->getSurveyMiscSetting('preview_survey_comment_showalways');
+ if ($preview_survey_comment_showalways == 1) {
+
+ $view = 1;
+ $show_survey_comment = '1';//$_GET['show_survey_comment'];
+
+ ?><script>
+ $(function () {
+ <?echo 'load_comment(\'#surveycomment_0_' . $view . '\'' . ($show_survey_comment == '1' ? ', \'2\'' : '') . ');';?>
+ });
+ </script><?
+ }
+ }
+
+ }
+
+
+ save('cookie_expire', $row['cookie']);
+
+ // alert za shranjevanje cookiejev
+ if (get('cookie_expire') != -1 && !(isset($_COOKIE['cookie_ok']) && $_COOKIE['cookie_ok'] == 1) && !empty($row)) {
+
+ echo '<div id="cookie_alert">';
+ if($mysql_database_name == 'vprasalnikirsrssi')
+ echo self::$lang['srv_cookie_ok_rsrs'];
+ else
+ echo self::$lang['srv_cookie_ok'];
+ echo '</div>';
+
+ ?><script>
+ $(function () {
+ $('#cookie_alert').slideDown();
+ });
+ $('#cookie_ok').on('click', cookie_ok);
+ </script><?
+ }
+
+ // alert da je testna anketa
+ if ((get('cookie_expire') == -1 || (isset($_COOKIE['cookie_ok']) && $_COOKIE['cookie_ok'] == 1)) && isset($_GET['testdata']) && $_GET['testdata'] == 'on') {
+
+ echo '<div id="test_alert">';
+ echo self::$lang['srv_test_alert'];
+ echo '</div>';
+
+ ?><script>
+ $(function () {
+ $('#test_alert').slideDown();
+ });
+ </script><?
+ }
+ // alert da je predogled
+ elseif ((get('cookie_expire') == -1 || (isset($_COOKIE['cookie_ok']) && $_COOKIE['cookie_ok'] == 1)) && isset($_GET['preview']) && $_GET['preview'] == 'on') {
+
+ echo '<div id="test_alert">';
+ echo self::$lang['srv_preview_alert'];
+ echo '</div>';
+
+ ?><script>
+ $(function () {
+ $('#test_alert').slideDown();
+ });
+ </script><?
+ }
+
+
+ // Odgovori, ki so disable jih ustrezno skrijemo
+ ?><script>
+ $('.answer-disabled').find('td.category ').each(function () {
+ $(this).find('input, textarea').attr('disabled', 'disabled');
+ });
+ $('div.variabla.answer-disabled').find('label input').attr('disabled', 'disabled');
+ $('span.answer-disabled').on('click', function () {
+ return false;
+ });
+ </script><?
+
+
+ // Alert ce ni javascripta
+ echo '<div id="javascript_alert">';
+ echo self::$lang['srv_javascript_warning'];
+ echo '</div>';
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/CheckController.php b/main/survey/app/Controllers/CheckController.php
new file mode 100644
index 0000000..d39a6c2
--- /dev/null
+++ b/main/survey/app/Controllers/CheckController.php
@@ -0,0 +1,774 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 12.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\FindController as Find;
+use App\Models\Model;
+use Cache;
+use enkaParameters;
+use SurveyInfo;
+use SurveyMissingValues;
+use Common;
+use Mobile_Detect;
+
+
+class CheckController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ parent::getAllVariables();
+
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new CheckController();
+ }
+
+ private function refreshVariables()
+ {
+ return parent::getAllVariables();
+ }
+
+ /**
+ * @desc preveri ali so na trenutni grupi prikazana vprasanja (zaradi branchinga)
+ */
+ public function checkGrupa()
+ {
+
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id = '" . get('grupa') . "' ORDER BY vrstni_red");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($this->checkSpremenljivka($row['id']))
+ return true;
+
+ }
+
+ return false;
+ }
+
+ /**
+ * @desc preveri ali je spremenljivka vidna (zaradi branchinga) (oz. lahko je nastavljena vidnost samo administratorju)
+ */
+ public function checkSpremenljivka($spremenljivka, $isTestData=false)
+ {
+ $checkSpremenljivka = get('checkSpremenljivka');
+ if (array_key_exists($spremenljivka, $checkSpremenljivka)) {
+ return $checkSpremenljivka[$spremenljivka];
+ }
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ // ce vprasanje ni vidno ali ce uporabnik nima dostopa do vprasanja
+ if ($row['visible'] == 0 || !((self::$admin_type <= $row['dostop'] && self::$admin_type >= 0) || (self::$admin_type == -1 && $row['dostop'] == 4))) {
+ return save('checkSpremenljivka[' . $spremenljivka . ']', false, 1);
+ }
+
+ // Pri testnih podatkih ne upostevamo ifov, ker drugace nic ne napolni
+ if(!$isTestData){
+ $sql1 = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$spremenljivka'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ if (!$this->checkIf($row1['parent']))
+ return save('checkSpremenljivka[' . $spremenljivka . ']', false, 1);
+ }
+
+ return save('checkSpremenljivka[' . $spremenljivka . ']', true, 1);
+ }
+
+ /**
+ * @desc preveri ali se elementi v podanem IFu prikazejo ali ne
+ */
+ public function checkIf($if)
+ {
+ if ($if == 0) return true;
+
+ $checkIf = get('checkIf');
+ if (array_key_exists($if, $checkIf)) {
+ return $checkIf[$if];
+ }
+
+ // preverimo po strukturi navzgor
+ $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_if = '$if'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+ if (!$this->checkIf($row['parent'])) {
+ return save('checkIf[' . $if . ']', false, 1);
+ }
+
+ $sql = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ // ce je IF oznacen da se vedno prikaze
+ if ($row['enabled'] == 1)
+ return save('checkIf[' . $if . ']', true, 1);
+
+ // ce je IF oznacen da se nikoli ne prikaze
+ if ($row['enabled'] == 2)
+ return save('checkIf[' . $if . ']', false, 1);
+
+ // ce je IF oznacen kot blok, potem se vedno prikaze
+ if ($row['tip'] == 1)
+ return save('checkIf[' . $if . ']', true, 1);
+
+
+ $eval = "if (";
+
+ //$sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id = '$if' ORDER BY vrstni_red ASC");
+ $sql = Cache::srv_condition($if);
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ $i = 0;
+ // zgeneriramo pogoje z oklepaji, ki jih potem spustimo skozi eval
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($i++ != 0)
+ if ($row['conjunction'] == 0)
+ $eval .= ' && ';
+ else
+ $eval .= ' || ';
+
+ if ($row['negation'] == 1)
+ $eval .= ' ! ';
+
+ for ($i = 1; $i <= $row['left_bracket']; $i++)
+ $eval .= ' ( ';
+
+ if ($this->checkCondition($row['id']))
+ $eval .= ' true ';
+ else
+ $eval .= ' false ';
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $eval .= ' ) ';
+ }
+ $eval .= ") return true; else return false; ";
+
+ // ne glih best practice, ampak takle mamo...
+ $eval = @eval($eval);
+ if ($eval === true)
+ return save('checkIf[' . $if . ']', true, 1);
+
+ return save('checkIf[' . $if . ']', false, 1);
+ }
+
+ /**
+ * @desc preveri podani condition
+ */
+ public function checkCondition($condition)
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ // obicne spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ $row2 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // radio, checkbox, dropdown
+ if ($row2['tip'] <= 3) {
+
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_vre c, srv_data_vrednost" . get('db_table') . " v
+ WHERE c.cond_id='$condition' AND c.vre_id=v.vre_id
+ AND v.spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'");
+
+ // Dodatno preverjanje ce imamo pogoj -1
+ $sql3b = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id='$condition' AND vre_id='-1'");
+ $sql4b = sisplet_query("SELECT * FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'");
+
+ if ($row['operator'] == 0 && mysqli_num_rows($sql3) == 0 && mysqli_num_rows($sql3b) == 0)
+ return false;
+ elseif ($row['operator'] == 0 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && mysqli_num_rows($sql3) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) == 0)
+ return false;
+
+ // multigrid
+ } elseif ($row2['tip'] == 6 || $row2['tip'] == 16) {
+
+ // tabela radio (brez dvojne tabele - ki gre v checkgrid)
+ if ($row2['tip'] == 6 && $row2['enota'] != 3) {
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_grid" . get('db_table') . " d
+ WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
+ AND c.grd_id=d.grd_id AND d.usr_id='" . get('usr_id') . "' AND d.vre_id='$row[vre_id]'");
+
+ // Dodatno preverjanje ce imamo pogoj -1
+ $sql3b = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$condition' AND grd_id='-1'");
+ $sql4b = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ } // tabela checkboxov
+ else {
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_checkgrid" . get('db_table') . " d
+ WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
+ AND c.grd_id=d.grd_id AND d.usr_id='" . get('usr_id') . "' AND d.vre_id='$row[vre_id]'");
+
+ // Dodatno preverjanje ce imamo pogoj -1
+ $sql3b = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$condition' AND grd_id='-1'");
+ $sql4b = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ }
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0 && !mysqli_num_rows($sql3b) > 0)
+ return false;
+ elseif ($row['operator'] == 0 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0)
+ return false;
+ elseif ($row['operator'] == 1 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) == 0)
+ return false;
+
+ } elseif ($row2['tip'] == 19 || $row2['tip'] == 20) {
+
+ $sql3 = sisplet_query("SELECT text FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "' AND grd_id='$row[grd_id]'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
+ return false;
+
+ // textbox
+ } elseif ($row2['tip'] == 21) {
+
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] <= 5) {
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+
+ // length
+ } else {
+
+ if ($row['operator'] == 6 && !(strlen($row3['text']) == $row['text']))
+ return false;
+ elseif ($row['operator'] == 7 && !(strlen($row3['text']) < $row['text']))
+ return false;
+ elseif ($row['operator'] == 8 && !(strlen($row3['text']) > $row['text']))
+ return false;
+
+ }
+
+ // vsota
+ } elseif ($row2['tip'] == 18) {
+
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
+ return false;
+
+ // razvrscanje
+ } elseif ($row2['tip'] == 17) {
+
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_rating d
+ WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
+ AND d.vre_id='$row[vre_id]' AND d.usr_id='" . get('usr_id') . "' AND d.vrstni_red=c.grd_id");
+
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0)
+ return false;
+
+ // number
+ } else {
+
+ if ($row['grd_id'] == 0) $text = 'text';
+ else $text = 'text2';
+
+ $sql3 = sisplet_query("SELECT " . $text . " AS text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
+ return false;
+
+ }
+
+ // recnum
+ } elseif ($row['spr_id'] == -1) {
+
+ $sqlu = sisplet_query("SELECT recnum FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $rowu = mysqli_fetch_array($sqlu);
+
+ if (!($rowu['recnum'] % $row['modul'] == $row['ostanek']))
+ return false;
+
+ // calculations
+ } elseif ($row['spr_id'] == -2) {
+
+ $calculation = $this->checkCalculation($row['id']);
+
+ if ($row['operator'] == 0 && !($calculation == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($calculation != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($calculation < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($calculation <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($calculation > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($calculation >= $row['text']))
+ return false;
+
+ // kvote
+ } elseif ($row['spr_id'] == -3) {
+
+ $quota = $this->checkQuota($row['id']);
+
+ if ($row['operator'] == 0 && !($quota == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($quota != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($quota < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($quota <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($quota > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($quota >= $row['text']))
+ return false;
+
+ // 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 id='".get('usr_id')."'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ if (!($rowU['device'] == $row['text']))
+ return false;*/
+
+ $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;
+ }
+ }
+
+ if (!($device == $row['text']))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @desc izracuna kalkulacijo in vrne rezultat
+ */
+ public function checkCalculation($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']);
+
+ if ($row1['tip'] <= 3) { // radio, checkbox, dropdown
+ $sum = 0;
+ $sql2 = sisplet_query("SELECT v.variable FROM srv_data_vrednost" . get('db_table') . " d, srv_vrednost v WHERE d.vre_id=v.id AND d.spr_id='$row1[id]' AND d.usr_id='" . get('usr_id') . "'");
+ while ($row2 = mysqli_fetch_array($sql2)) { // zanka je zaradi checkboxov
+ $sum += $row2['variable'];
+ }
+ $expression .= $sum;
+
+ } elseif ($row1['tip'] == 7 || $row1['tip'] == 22 || $row1['tip'] == 25) { // number, calculation, quota
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ $row2 = mysqli_fetch_array($sql2);
+ if ($row2['text'] == '') $row2['text'] = 0;
+ $expression .= $row2['text'];
+
+ } elseif ($row1['tip'] == 8) { // datum
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ $row2 = mysqli_fetch_array($sql2);
+ if ($row2['text'] == '') $row2['text'] = 0;
+
+ $row2['text'] = ceil(strtotime($row2['text']) / (60 * 60 * 24));
+
+ $expression .= $row2['text'];
+ }
+
+ // multigrid in checkbox
+ } elseif ($row['vre_id'] > 0) {
+
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // checkbox
+ if ($row1['tip'] == 2) {
+ $sum = 0;
+ $sql2 = sisplet_query("SELECT v.variable FROM srv_data_vrednost" . get('db_table') . " d, srv_vrednost v WHERE d.vre_id=v.id AND d.spr_id='$row1[id]' AND d.usr_id='" . get('usr_id') . "'");
+ while ($row2 = mysqli_fetch_array($sql2)) { // zanka je zaradi checkboxov
+ $sum += $row2['variable'];
+ }
+ $expression .= $sum;
+ }
+ // multigrid
+ else{
+ $sql1 = sisplet_query("SELECT g.variable, g.other FROM srv_data_grid" . get('db_table') . " d, srv_grid g WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.usr_id='" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ // Pri multigridih se missingi pri kalkulacijah stejejo kot 0 (in ne -99, -98...)
+ if ($row1['other'] < 0)
+ $row1['variable'] = 0;
+
+ $expression .= $row1['variable'];
+ }
+ }
+
+ // konstante
+ } elseif ($row['spr_id'] == -1) {
+
+ $expression .= $row['number'];
+
+ }
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $expression .= ' ) ';
+
+ }
+
+ $expression = 'return ' . $expression . ';';
+
+ return eval($expression);
+
+ }
+
+ /**
+ * @desc izracuna kvoto in vrne rezultat
+ */
+ public function checkQuota($condition)
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_quota 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) {
+
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // radio, checkbox, multigrid
+ if ($row['vre_id'] > 0) {
+
+ // multigrid
+ if ($row1['tip'] == 6)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_grid" . get('db_table') . " d, srv_grid g, srv_user u
+ WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.grd_id='$row[grd_id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ // multicheckbox
+ elseif ($row1['tip'] == 16)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g, srv_user u
+ WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.grd_id='$row[grd_id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ // radio, select
+ elseif ($row1['tip'] == 1 || $row1['tip'] == 3)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_vrednost" . get('db_table') . " d, srv_user u
+ WHERE d.vre_id='$row[vre_id]' AND d.spr_id='$row1[id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ // checkbox
+ elseif ($row1['tip'] == 2)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_vrednost" . get('db_table') . " d, srv_user u
+ WHERE d.vre_id='$row[vre_id]' AND d.spr_id='$row1[id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ $row2 = mysqli_fetch_array($sql2);
+
+ $expression .= $row2['quota'];
+ }
+ } // konstante (statusi...)
+ elseif ($row['spr_id'] < 0) {
+
+ $status = '';
+
+ // Kvota ustreznih odgovorov
+ if ($row['spr_id'] == -7) {
+ $status .= ' AND (last_status=\'5\' OR last_status=\'6\') AND lurker=\'0\' ';
+ } // Kvota posameznih statusov
+ elseif ($row['spr_id'] > -7) {
+ $status .= ' AND last_status=\'' . -$row['spr_id'] . '\' ';
+ }
+
+ $sqlU = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='".get('anketa')."' ".$status." AND deleted='0'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ $expression .= $rowU['COUNT(id)'];
+ }
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $expression .= ' ) ';
+ }
+
+ $expression = 'return ' . $expression . ';';
+
+ return eval($expression);
+ }
+
+ /************************************************
+ * Preveri userja, ki se je vrnil in ga (če je tako nastavljeno) preusmeri na stran, kjer je končal
+ ************************************************/
+ public function check_cookie_return()
+ {
+
+ $row = \SurveyInfo::getInstance()->getSurveyRow();
+
+ // EVALVACIJA - nastavljeno je da ga preusmerimo na stran kjer je koncal - za studentsko evalvacijo vedno preusmerjamo z ustreznimi parametri - ZAENKRAT NI VKLOPLJENO
+ if (Common::checkModule('evalvacija') == '1' && false) {
+ $sql1 = sisplet_query("SELECT g.id FROM srv_user_grupa" . get('db_table') . " u, srv_grupa g WHERE u.gru_id=g.id AND u.usr_id='" . get('usr_id') . "' ORDER BY g.vrstni_red DESC LIMIT 1");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ save('grupa', $row1['id']);
+ $grupa = Find::getInstance()->findNextGrupa();
+
+ if ($grupa > 0) {
+ $params = $_SERVER['QUERY_STRING'];
+
+ setcookie('ref', get('anketa')); // cookie z referalom (da se ne sprozi redirect zaradi referala pri ?code= )
+ return header("Location: " . \SurveyInfo::getSurveyLink() . "&grupa=$grupa&" . $params . get('cookie_url') . "&c");
+ die();
+ }
+ }
+
+ // nastavljeno je da ga preusmerimo na stran kjer je koncal
+ if ($row['cookie_return'] == 1) {
+
+ $sql1 = sisplet_query("SELECT g.id FROM srv_user_grupa" . get('db_table') . " u, srv_grupa g WHERE u.gru_id=g.id AND u.usr_id='" . get('usr_id') . "' ORDER BY g.vrstni_red DESC LIMIT 1");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+
+ if(mysqli_num_rows($sql1) > 0){
+
+ $row1 = mysqli_fetch_array($sql1);
+
+ save('grupa', $row1['id']);
+
+ $grupa = Find::getInstance()->findNextGrupa();
+
+ if ($grupa > 0) {
+ setcookie('ref', get('anketa')); // cookie z referalom (da se ne sprozi redirect zaradi referala pri ?code= )
+ return header("Location: " . \SurveyInfo::getSurveyLink() . "&grupa=$grupa" . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . get('cookie_url') . "&c");
+ die();
+ }
+ }
+ }
+ }
+
+ /**
+ * preveri, ce je katera od spremenljivk CAPTCHA in preveri, ce je pravilno vnesena
+ * treba extra preverjat, ce je JS izklopljen
+ *
+ */
+ public function check_captcha()
+ {
+ global $secret_captcha;
+
+ // Ce urejamo podatke v admin vmesniku ne preverjamo nicesar
+ if(isset($_GET['t']) && $_GET['t'] == 'postprocess' || get('grupa') == '0' || get('grupa') == ''){
+ return;
+ }
+
+ $sql = sisplet_query("SELECT id, params FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND visible='1' AND tip='21' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0);
+
+ if ($captcha == 1) {
+ $recaptchaResponse = $_POST['g-recaptcha-response'];
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+
+ // zdaj pa zabeleži mail (pred pošiljanjem)
+ // zdaj pa še v bazi tistih ki so se ročno dodali
+ if(strstr($request,"true")){
+ //
+ }
+ else {
+ echo '<p>Wrong CAPTCHA code.</p><p><a href="#" onclick="javascript:history.go(-1)">Back</a></p>';
+ die();
+ }
+ }
+ }
+ }
+
+ /**
+ * preveri, ce preveri, ce je CAPTCHA pravilno vnesena pri uvodu (ce imamo staticen uvod s preverjanjem captche)
+ *
+ */
+ public function check_captcha_intro(){
+ global $secret_captcha;
+
+ $recaptchaResponse = $_POST['g-recaptcha-response'];
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+
+ if(strstr($request,"true")){
+ //
+ }
+ else {
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false).'?captcha_error=1');
+ die();
+ }
+ }
+
+ public function checkMissingForSpremenljivka($spremenljivka, $loop_id)
+ {
+ $missing = false;
+
+ $smv = new SurveyMissingValues(get('anketa'));
+ $missing_values = $smv->GetUnsetValuesForSurvey();
+
+ if (count($missing_values) > 0) {
+
+ $qry = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other IN ('" . implode('\',\'', array_keys($missing_values)) . "')");
+ $missing_vrednosti = array();
+ while ($row = mysqli_fetch_assoc($qry)) {
+ $missing_vrednosti[] = $row[id];
+ }
+ # pogledamo ali imamo kak zapis v srv_data_vrednost. potem je to najbrž missing
+
+ $srv_data_vrednost = array();
+ $sql2_c = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row2_c = mysqli_fetch_array($sql2_c)) {
+ #samo če je bil izbran missing -99 ne vem, -98 drugo .....
+ if (in_array($row2_c['vre_id'], $missing_vrednosti) && $missing == false) {
+ $missing = $row2_c['vre_id'];
+ }
+ }
+ }
+ return $missing;
+ }
+
+ // Preverimo, ce je uporabnik ze bil na strani
+ public function check_subsequent_visit(){
+
+ $sql = sisplet_query("SELECT g.id
+ FROM srv_user_grupa".get('db_table')." u, srv_grupa g
+ WHERE u.gru_id=g.id AND u.usr_id='".get('usr_id')."' AND g.id='".get('grupa')."'
+ ");
+
+ if(mysqli_num_rows($sql) > 0)
+ return true;
+ else
+ return false;
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Controller.php b/main/survey/app/Controllers/Controller.php
new file mode 100644
index 0000000..a9ad8fe
--- /dev/null
+++ b/main/survey/app/Controllers/Controller.php
@@ -0,0 +1,113 @@
+<?php
+/**
+ * MINI - an extremely simple naked PHP application
+ *
+ * @package mini
+ * @author Panique
+ * @link http://www.php-mini.com
+ * @link https://github.com/panique/mini/
+ * @license http://opensource.org/licenses/MIT MIT License
+ */
+
+namespace App\Controllers;
+
+use App\Controllers\VariableClass as Variable;
+use App\Models\Model as Model;
+use PDO;
+
+class Controller
+{
+ /**
+ * @var null Database Connection
+ */
+ public $db = null;
+
+ /**
+ * @var null Model
+ */
+ public $model = null;
+
+ /**
+ * Whenever controller is created, open a database connection too and load "the model".
+ */
+ public function __construct()
+ {
+ $this->openDatabaseConnection();
+ $this->loadModel();
+ $this->getGlobalVariables();
+ }
+
+ /************************************************
+ * Vse globalne spremenljivke dodamo v omenjen razred, da jih lahko potem kličemo na posameznem razredu
+ *
+ * @return $this
+ ************************************************/
+ public static $global_user_id;
+ public static $admin_type;
+ public static $site_url;
+ public static $site_path;
+ public static $lang;
+ public static $mysql_database_name;
+
+ public function getGlobalVariables()
+ {
+ // Definiramo globalne spremenljivke, ki jih kasneje uporabljamo v funkcijah
+ global $global_user_id;
+ global $admin_type;
+ global $site_url;
+ global $site_path;
+ global $lang;
+ global $mysql_database_name;
+
+ self::$global_user_id = $global_user_id;
+ self::$admin_type = $admin_type;
+ self::$site_url = $site_url;
+ self::$site_path = $site_path;
+ self::$lang = $lang;
+ self::$mysql_database_name = $mysql_database_name;
+ }
+
+ /************************************************
+ * Pridobimo vse variable, ki se uporabljajo za main/survey in jih dodamo na Controller -> $this variable
+ *
+ * @return $this
+ ************************************************/
+ public function getAllVariables()
+ {
+ // pridobimo vse spremenljivke, ki jih uporabljamo med različnimi razredi
+ $var = Variable::getAll();
+
+ // vrnemo kot $this parameter, da jih uporabljamo znotraj razreda in ni potrebno vse popravljati
+ // v obliko Variable::get('name') amap preprosto kličemo $this->name
+ foreach ($var as $key => $value) {
+ $this->$key = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Open the database connection with the credentials from application/config/config.php
+ */
+ private function openDatabaseConnection()
+ {
+ // set the (optional) options of the PDO connection. in this case, we set the fetch mode to
+ // "objects", which means all results will be objects, like this: $result->user_name !
+ // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] !
+ // @see http://www.php.net/manual/en/pdostatement.fetch.php
+ $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
+
+ // generate a database connection, using the PDO connector
+ // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/
+ $this->db = new PDO(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, $options);
+ }
+
+ /**
+ * Loads the "model".
+ * @return object model
+ */
+ public function loadModel()
+ {
+ $this->model = new Model($this->db);
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/DisplayController.php b/main/survey/app/Controllers/DisplayController.php
new file mode 100644
index 0000000..c0cbf43
--- /dev/null
+++ b/main/survey/app/Controllers/DisplayController.php
@@ -0,0 +1,864 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 05.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+// Osnovni razredi
+use App\Controllers\AjaxController as Ajax;
+use App\Controllers\BodyController as Body;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use SurveyInfo;
+use SurveySetting;
+use Common;
+use SurveyGorenje;
+
+class DisplayController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DisplayController();
+ }
+
+ public function logo()
+ {
+ // Za gorenje posebej prikazemo logo
+ if(Common::checkModule('gorenje')){
+ SurveyGorenje::logoGorenje(get('anketa'), get('usr_id'));
+ return;
+ }
+
+ $class = '';
+ $url = self::$site_url;
+
+ // Logo prikazemo angleski v vseh primerih kjer respondentov jezik ni slovenscina in ce ni custom - popravimo tudi link na angleski frontend
+ if (self::$lang['language'] != 'Slovenščina') {
+ $class = ' class="english"';
+ if (strpos(self::$site_url, 'www.1ka.si') !== false)
+ $url = self::$site_url.'d/en/';
+ }
+
+ echo '<div id="logo" ' . $class . '><a href="' . $url . '" title="' . self::$lang['srv_1cs'] . ' ' . self::$lang['srv_footer_1ka'] . '" target="_blank">' . self::$lang['srv_1cs'] . '</a><div id="logo_right"></div></div>';
+ }
+
+ /**
+ * @desc prikaze progress bar
+ */
+ public function progress_bar()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sql_count_pages = sisplet_query("SELECT COUNT( g.id ) AS count FROM srv_grupa g WHERE g.ank_id = '" . get('anketa') . "'");
+ $row_count_pages = mysqli_fetch_assoc($sql_count_pages);
+
+ // Ce prikazemo gumb za tawk chat
+ $tawk_chat = false;
+ if(SurveyInfo::getInstance()->checkSurveyModule('chat') == '1'){
+ $sql_chat = sisplet_query("SELECT chat_type FROM srv_chat_settings WHERE ank_id='".get('anketa')."'");
+ $row_chat = mysqli_fetch_assoc($sql_chat);
+
+ if($row_chat['chat_type'] == '2')
+ $tawk_chat = true;
+ }
+
+ if (($row['progressbar'] == 1 && $row_count_pages['count'] > 1) || ($row['continue_later'] == 1) || $tawk_chat) {
+ echo '<div class="header_settings_holder">';
+
+ if ($row['progressbar'] == 1 && $row_count_pages['count'] > 1) {
+
+ echo '<div class="progress_bar">';
+
+ $sql1 = sisplet_query("SELECT COUNT(s.id) AS count
+ FROM srv_grupa g, srv_spremenljivka s
+ WHERE s.gru_id=g.id AND g.ank_id = '" . get('anketa') . "' AND s.visible='1'");
+ $row1 = mysqli_fetch_array($sql1);
+ $all = $row1['count'];
+
+ $sql2 = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sql3 = sisplet_query("SELECT COUNT(s.id) AS count
+ FROM srv_grupa g, srv_spremenljivka s
+ WHERE s.gru_id=g.id AND g.ank_id = '" . get('anketa') . "' AND s.visible='1' AND g.vrstni_red<='$row2[vrstni_red]'");
+ $row3 = mysqli_fetch_array($sql3);
+ $ans = $row3['count'];
+
+ if ($all > 0) {
+
+ $p = round($ans / $all * 100, 0);
+
+ echo '<span>0%</span>';
+ echo '<div class="progress_bar_line"><span style="width:' . $p . '%"></span></div>';
+ echo '<span>100%</span>';
+ }
+
+ echo '</div>';
+ }
+
+ // Prikaz opcije "nadaljuj kasneje"
+ if ($row['continue_later'] == 1) {
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_continue_later = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later' . $_lang);
+ if ($srv_continue_later == '') $srv_continue_later = self::$lang['srv_continue_later'];
+
+ echo '<div class="continue_later_setting">';
+ echo ' <a href="#" onclick="continue_later(\'' . self::$site_url . '\', \'' . get('lang_id') . '\'); return false;">' . $srv_continue_later . '</a>';
+ echo '</div>';
+ }
+
+ // Priakz gumba za vklop tawk chata
+ if ($tawk_chat){
+ echo '<div class="tawk_chat">';
+ echo ' <span class="tawk-chat-activation">'.self::$lang['srv_chat_turn_on'].'</span>';
+ echo '</div>';
+ }
+
+ echo '</div>';
+ }
+ }
+
+ // Prikaze ikono za izvoz pdf rezultatov v zakljucku
+ public function displayRespondetnPDF()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ if ((int)$row['concl_PDF_link'] == 1) {
+
+ // Ce je vklopljen evoli ali evoli employeeship meter, prikazemo link do posebnega porocila
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli') || SurveyInfo::getInstance()->checkSurveyModule('evoli_employmeter')){
+
+ // Nastavimo ustrezen jezik za report
+ if(self::$lang['id'] == '1')
+ $report_lang = 'slo';
+ elseif(self::$lang['id'] == '29')
+ $report_lang = 'dan';
+ else
+ $report_lang = '';
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli_employmeter'))
+ $evoli_module = 'pdf_employmeter';
+ else
+ $evoli_module = 'pdf_evoli';
+
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(serialize(array('m' => $evoli_module, 'anketa' => get('anketa'), 'usr_id' => get('usr_id'), 'lang' => $report_lang)));
+
+ echo '<br class="clr"/>';
+
+ echo '<div class="concl_evoli_report naslov"><p>';
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli')){
+ echo self::$lang['srv_report_pdf_evoli'].': ';
+
+ echo '<a href="' . $pdf_url . '" class="pdfExport" target="_blank">';
+ echo '<span class="evoli_button">'.self::$lang['srv_report_pdf_evoli_button'].'</span>';
+ echo '</a>';
+ }
+ else{
+ echo self::$lang['srv_report_pdf_evoli_em'].': ';
+
+ echo '<a href="' . $pdf_url . '" class="pdfExport" target="_blank">';
+ echo '<span class="evoli_button">'.self::$lang['srv_report_pdf_evoli_em_button'].'</span>';
+ echo '</a>';
+ }
+
+ echo '</p></div>';
+ }
+ else{
+ # parametre zapakiramo v array injih serializiramo in zakodiramo z base64
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(serialize(array('a' => 'pdf_results', 'anketa' => get('anketa'), 'usr_id' => get('usr_id'), 'type' => '0')));
+
+ #echo '<div id="icon_bar">';
+ echo '<br class="clr"/><div><p>';
+ echo '<a href="' . $pdf_url . '" class="pdfExport" target="_blank"><span class="sprites pdf_white"></span> '.self::$lang['srv_report_pdf'].'</a>';
+ echo '</p></div>';
+ }
+ }
+ }
+
+ // Prikaze url za naknadno popravljanje odgovorov (od zacetka ankete) v zakljucku
+ public function displayReturnEditURL()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ if ((int)$row['concl_return_edit'] == 1) {
+
+ $return_url = $_POST['url'] . '&return=1';
+ $return_url = SurveyInfo::getSurveyLink() . get('cookie_url') . '&return=1';
+
+ echo '<br class="clr"/><div class="return_edit_url"><p>';
+ echo self::$lang['srv_concl_return_edit_URL'].':<br />';
+ echo '<a href="'.$return_url.'" title="'.self::$lang['srv_concl_return_edit_URL'].'"><span>'.$return_url.'</span></a>';
+ echo '</p></div>';
+ }
+ }
+
+ // Prikaze pravilne rezultate v primeru modula KVIZ
+ public function displayQuizAnswers()
+ {
+ // echo '<h2>'.self::$lang['results'].'</h2>';
+
+ // Loop cez vsa ustrezna vprasanja (ki imajo oznacen vsaj en pravilen odgovor)
+ $sqlS = sisplet_query("SELECT s.id, s.naslov, s.info FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.tip IN ('1', '2', '3') AND s.visible='1'
+ AND EXISTS (SELECT q.* FROM srv_quiz_vrednost q WHERE q.spr_id=s.id)
+ AND NOT EXISTS (SELECT d.* FROM srv_data_vrednost_active d WHERE d.spr_id=s.id AND usr_id='".get('usr_id')."' AND d.vre_id='-2')");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ echo '<div class="spremenljivka">';
+
+ //Vprasanja::getInstance()->displaySpremenljivka($rowS['id']);
+
+ echo '<div class="naslov">'.$rowS['naslov'];
+ if ($rowS['info'] != '')
+ echo '<p class="spremenljivka_info">' . $rowS['info'] . '</p>';
+ echo '</div>';
+
+ echo '<div class="variable_holder">';
+
+ // Loop cez vse vrednosti v vprasanju
+ $sqlV = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='".$rowS['id']."' ORDER BY vrstni_red ASC");
+ while($rowV = mysqli_fetch_array($sqlV)){
+
+ // Za vsako pogledamo ce je pravilna oz napacna
+ $answer = false;
+ $correct = false;
+
+ $sqlAnswer = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."' AND usr_id='".get('usr_id')."'");
+ if(mysqli_num_rows($sqlAnswer) == 1)
+ $answer = true;
+
+ $sqlQuiz = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."'");
+ if(mysqli_num_rows($sqlQuiz) == 1)
+ $correct = true;
+
+ if($correct && $answer){
+ echo '<div class="variabla green">';
+ echo $rowV['naslov'] . '<span class="true"></span>';
+ echo '</div>';
+ }
+ elseif($correct){
+ echo '<div class="variabla bold">';
+ //echo $rowV['naslov'] . '<span class="true2"></span>';
+ echo $rowV['naslov'];
+ echo '</div>';
+ }
+ elseif($answer){
+ echo '<div class="variabla red">';
+ echo $rowV['naslov'] . '<span class="false"></span>';
+ echo '</div>';
+ }
+ else{
+ echo '<div class="variabla">';
+ echo $rowV['naslov'];
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ echo '</div>';
+ }
+ }
+
+ // Prikaze graf rezultatov v primeru modula KVIZ
+ public function displayQuizChart()
+ {
+ //echo '<h2>'.self::$lang['results'].'</h2>';
+
+ $cnt_all = 0;
+ $cnt_answered = 0;
+ $cnt_unanswered = 0;
+ $cnt_correct = 0;
+ $cnt_incorrect = 0;
+
+ // Loop cez vsa ustrezna vprasanja (ki imajo oznacen vsaj en pravilen odgovor)
+ $sqlS = sisplet_query("SELECT s.id, s.naslov, s.info FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.tip IN ('1', '2', '3') AND s.visible='1'
+ AND EXISTS (SELECT q.* FROM srv_quiz_vrednost q WHERE q.spr_id=s.id)
+ AND NOT EXISTS (SELECT d.* FROM srv_data_vrednost_active d WHERE d.spr_id=s.id AND usr_id='".get('usr_id')."' AND d.vre_id='-2')");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ $cnt_all++;
+
+ $answer = false;
+ $correct = false;
+
+ // Loop cez vse vrednosti v vprasanju
+ $sqlV = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='".$rowS['id']."' ORDER BY vrstni_red ASC");
+ while($rowV = mysqli_fetch_array($sqlV)){
+
+ // Za vsako pogledamo ce je odgovorjena
+ $sqlAnswer = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."' AND usr_id='".get('usr_id')."'");
+ if(mysqli_num_rows($sqlAnswer) == 1){
+ $answer = true;
+
+ // Za vsako pogledamo ce je pravilna oz napacna
+ $sqlQuiz = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."'");
+
+ if(mysqli_num_rows($sqlQuiz) == 1){
+ $correct = true;
+ }
+ // Ce je oznacil napacno breakamo
+ else{
+ $correct = false;
+ break;
+ }
+ }
+ }
+
+ if($answer)
+ $cnt_answered++;
+ else
+ $cnt_unanswered++;
+
+ if($correct)
+ $cnt_correct++;
+ else
+ $cnt_incorrect++;
+ }
+
+
+ // Izrisemo graf
+ /*echo 'Vseh: '.$cnt_all;
+ echo '<br>odgovorjen: '.$cnt_answered;
+ echo '<br>neodg: '.$cnt_unanswered;
+ echo '<br>pravilen: '.$cnt_correct;
+ echo '<br>nepravilen: '.$cnt_incorrect;*/
+
+ // Include knjiznice Chart.JS
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/Chart.min.js"></script>';
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/chart_init.js?v=3"></script>';
+
+ // Izris grafa
+ echo '<div class="spremenljivka" id="quiz_results_chart_holder">';
+ echo '<canvas id="quiz_results_chart" class="chart"></canvas>';
+ echo '<script>$(document).ready(function(){ init_quiz_results_chart('.$cnt_all.', '.$cnt_correct.', '.$cnt_incorrect.', \''.self::$lang['srv_quiz_results_chart_correct'].'\', \''.self::$lang['srv_quiz_results_chart_incorrect'].'\'); })</script>';
+ echo '</div>';
+ }
+
+
+ // Prikaze graf za matriko odlicnosti (excell_matrix) v primeru modula Excelleration matrix
+ public function displayExcellChart()
+ {
+ echo '<h3 style="padding-left: 20px;">'.self::$lang['srv_excell_matrix_title'].'</h3>';
+
+ // Loop cez vsa ustrezna vprasanja in njihove vrednosti (jih zakesiramo)
+ $variables = array();
+ $variable_marza = array();
+ $variable_lp = array();
+ $spr_ids = '';
+ $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable, v.id AS vre_id, v.variable AS vre_variable, v.naslov AS vre_naslov
+ FROM srv_spremenljivka s, srv_grupa g, srv_vrednost v
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id
+ AND s.variable LIKE 'em%'
+ AND v.spr_id=s.id");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ // Marza
+ if($rowS['spr_variable'] == 'emM'){
+
+ // ID-ji vprasanj za query
+ if(!isset($variable_marza['id']))
+ $spr_ids .= $rowS['spr_id'].',';
+
+ $variable_marza['naslov'] = strip_tags($rowS['spr_naslov']);
+ $variable_marza['id'] = $rowS['spr_id'];
+
+ $variable_marza['vrednosti'][$rowS['vre_id']]['variable'] = $rowS['vre_variable'];
+ $variable_marza['vrednosti'][$rowS['vre_id']]['naslov'] = $rowS['vre_naslov'];
+ }
+ // Letni promet
+ elseif($rowS['spr_variable'] == 'emLP'){
+
+ $variable_lp['naslov'] = strip_tags($rowS['spr_naslov']);
+ $variable_lp['id'] = $rowS['spr_id'];
+ }
+ // Ostali
+ else{
+
+ // ID-ji vprasanj za query
+ if(!isset($variables[$rowS['spr_id']]['variable']))
+ $spr_ids .= $rowS['spr_id'].',';
+
+ $variables[$rowS['spr_id']]['naslov'] = strip_tags($rowS['spr_naslov']);
+ $variables[$rowS['spr_id']]['variable'] = $rowS['spr_variable'];
+
+ $variables[$rowS['spr_id']]['vrednosti'][$rowS['vre_id']]['variable'] = $rowS['vre_variable'];
+ $variables[$rowS['spr_id']]['vrednosti'][$rowS['vre_id']]['naslov'] = $rowS['vre_naslov'];
+ }
+ }
+ $spr_ids = substr($spr_ids, 0, -1);
+
+ // Loop cez vse respondente s statusom 6 - vsak je svoj bubble
+ $data = array();
+ $sum = 0;
+ $cnt = 0;
+ $sqlAnswers = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE usr_id='".get('usr_id')."' AND spr_id IN (".$spr_ids.")");
+ while($rowAnswers = mysqli_fetch_array($sqlAnswers)){
+
+ // Marzo normalno preberemo
+ if($rowAnswers['spr_id'] == $variable_marza['id']){
+ $value = $variable_marza['vrednosti'][$rowAnswers['vre_id']]['variable'];
+ $data['marza'] = $value;
+
+ $variable_marza['value'] = $rowAnswers['vre_id'];
+ }
+ // Pri ostalih racunamo povprecje
+ else{
+ $value = $variables[$rowAnswers['spr_id']]['vrednosti'][$rowAnswers['vre_id']]['variable'];
+ $sum += (int)$value;
+ $cnt++;
+
+ $variables[$rowAnswers['spr_id']]['value'] = $rowAnswers['vre_id'];
+ }
+ }
+ $data['excell'] = round($sum/$cnt, 1);
+
+ // Posebej pridobimo tudi letni promet
+ $sqlAnswers = sisplet_query("SELECT text FROM srv_data_text_active WHERE usr_id='".get('usr_id')."' AND spr_id='".$variable_lp['id']."'");
+ $rowAnswers = mysqli_fetch_array($sqlAnswers);
+ $data['letni_promet'] = $rowAnswers['text'];
+ $variable_lp['value'] = $rowAnswers['text'];
+
+ // Max radius=80 (vrednost 1000), min radius=8 (vrednost 100)
+ $radius = $data['letni_promet'];
+
+ // Include knjiznice Chart.JS
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/Chart.min.js"></script>';
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/chart_init.js?v=2"></script>';
+
+ // Izris grafa
+ echo '<div class="spremenljivka">';
+ echo '<canvas id="excell_matrix_chart" class="chart"></canvas>';
+ echo '<script>$(document).ready(function(){ init_excell_matrix('.$data['excell'].', '.$data['marza'].', '.$radius.'); })</script>';
+ echo '</div>';
+
+
+ // Izrisemo se seznam vprasanj
+ foreach($variables as $spr_id => $spremenljivka){
+
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$spremenljivka['naslov'].'</div>';
+ echo ' <div class="variable_holder">';
+ foreach($spremenljivka['vrednosti'] as $vre_id => $vrednost){
+ echo ' <div class="variabla" '.($variables[$spr_id]['value'] == $vre_id ? ' style="font-weight:bold; color:red;"' : '').'>'.$vrednost['naslov'].'</div>';
+ }
+ echo ' </div>';
+ echo '</div>';
+ }
+
+ // Marza
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$variable_marza['naslov'].'</div>';
+ echo ' <div class="variable_holder">';
+ foreach($variable_marza['vrednosti'] as $vre_id => $vrednost){
+ echo ' <div class="variabla" '.($variable_marza['value'] == $vre_id ? ' style="font-weight:bold; color:red;"' : '').'>'.$vrednost['naslov'].'</div>';
+ }
+ echo ' </div>';
+ echo '</div>';
+
+ // Letni promet
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$variable_lp['naslov'].'</div>';
+ echo ' <div class="variable_holder">';
+ echo ' <div class="variabla" style="font-weight:bold; color:red;">'.$variable_lp['value'].'</div>';
+ echo ' </div>';
+ echo '</div>';
+ }
+
+
+ // SKAVTI - prikaze povzetek in graf za njihovo anketo
+ public function displaySkavtiAnswers(){
+
+ // Stevilo top pohval in izziv, ki jih izpisemo v zakljucku
+ $max_odgovorov = 3;
+
+ $vprasanja = array();
+ $spr_ids = '';
+
+ // Loop cez vsa ustrezna vprasanja in njihove vrednosti (jih zakesiramo)
+ $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id
+ AND s.variable LIKE 'R%'
+ ");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ $vprasanje_number = substr($rowS['spr_variable'], 1);
+ $vprasanja[$rowS['spr_id']] = $vprasanje_number;
+
+ // ID-ji vprasanj za query
+ $spr_ids .= $rowS['spr_id'].',';
+ }
+
+ $spr_ids = substr($spr_ids, 0, -1);
+
+
+ // Loop cez vse response za vprasanja
+ $pohvale = array();
+ $izzivi = array();
+ $sqlAnswers = sisplet_query("SELECT vd.*, v.naslov, v.variable
+ FROM srv_data_vrednost_active vd, srv_vrednost v
+ WHERE vd.usr_id='".get('usr_id')."' AND vd.spr_id IN (".$spr_ids.")
+ AND v.id=vd.vre_id
+ ");
+ while($rowAnswers = mysqli_fetch_array($sqlAnswers)){
+
+ // Pohvala
+ if((int)$rowAnswers['variable'] >= 1 && (int)$rowAnswers['variable'] <= 199){
+ $pohvale[(int)$rowAnswers['variable']] = $rowAnswers;
+ }
+ // Izziv
+ elseif((int)$rowAnswers['variable'] >= 201 && (int)$rowAnswers['variable'] <= 399){
+ $izzivi[(int)$rowAnswers['variable']] = $rowAnswers;
+ }
+ }
+
+ // Sortiramo po velikosti
+ ksort($pohvale, SORT_NUMERIC);
+ ksort($izzivi, SORT_NUMERIC);
+
+
+ // Loop cez komentarje v nagovorih
+ $pohvale_besedilo = array();
+ $izzivi_besedilo = array();
+ $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id
+ AND (s.variable LIKE 'P%' OR s.variable LIKE 'G%')
+ ");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ $tip = substr($rowS['spr_variable'], 0, 1);
+ $vprasanje_number = substr($rowS['spr_variable'], 1);
+ $naslov = $rowS['spr_naslov'];
+
+ // Pohvala
+ if($tip == 'P'){
+ $pohvale_besedilo[$vprasanje_number] = $naslov;
+ }
+ // Izziv
+ elseif($tip == 'G'){
+ $izzivi_besedilo[$vprasanje_number] = $naslov;
+ }
+ }
+
+
+ // Izrisemo seznam vprasanj s pohvalami
+ echo '<h2 style="padding-left: 20px;">POHVALE</h2>';
+
+ // Nagovor za pohvale
+ $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='pohvale'
+ ");
+ $rowNagovor = mysqli_fetch_array($sqlNagovor);
+ echo '<div class="spremenljivka" style="border-bottom:0;"><div class="naslov">'.$rowNagovor['naslov'].'</div></div>';
+
+ $i = 1;
+ foreach($pohvale as $pohvala_vrednost => $vrednost){
+
+ if($i > $max_odgovorov)
+ break;
+
+ $spr_id = $vrednost['spr_id'];
+ $vprasanje_number = $vprasanja[$spr_id];
+
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$pohvale_besedilo[$vprasanje_number].'</div>';
+ echo '</div>';
+
+ $i++;
+ }
+
+ // Izrisemo seznam vprasanj z izzivi
+ echo '<br><h2 style="padding-left: 20px;">IZZIVI</h2>';
+
+ // Nagovor za izzive
+ $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='izzivi'
+ ");
+ $rowNagovor = mysqli_fetch_array($sqlNagovor);
+ echo '<div class="spremenljivka" style="border-bottom:0;"><div class="naslov">'.$rowNagovor['naslov'].'</div></div>';
+
+ $i = 1;
+ foreach($izzivi as $izziv_vrednost => $vrednost){
+
+ if($i > $max_odgovorov)
+ break;
+
+ $spr_id = $vrednost['spr_id'];
+ $vprasanje_number = $vprasanja[$spr_id];
+
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$izzivi_besedilo[$vprasanje_number].'</div>';
+ echo '</div>';
+
+ $i++;
+ }
+
+ $this->displaySkavtiRadar();
+ }
+
+ // SKAVTI - prikaze graf pajkovo mrezo
+ private function displaySkavtiRadar(){
+
+ // Include knjiznice Chart.JS
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/Chart.min.js"></script>';
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/chart_init.js?v=3"></script>';
+
+
+ // Priprava podatkov za radar
+ $radar_data = array();
+ $sqlB = sisplet_query("SELECT i.label, i.id
+ FROM srv_if i, srv_branching b
+ WHERE b.ank_id='".get('anketa')."' AND i.id=b.element_if
+ AND i.tip='1'
+ ");
+ if (!$sqlB) echo mysqli_error($GLOBALS['connect_db']);
+
+ // Za graf rabimo vsaj 3 ogljisca
+ if(mysqli_num_rows($sqlB) < 3)
+ return;
+
+ // Loop cez bloke (stranica radarja)
+ while($rowB = mysqli_fetch_array($sqlB)){
+
+ // Dobimo vsa ustrezna vprasanja z odgovori v tem bloku
+ $sqlQ = sisplet_query("SELECT s.id AS spr_id, s.variable AS spr_variable, v.naslov, v.variable, vd.*
+ FROM srv_branching b, srv_spremenljivka s, srv_vrednost v, srv_data_vrednost_active vd
+ WHERE b.ank_id='".get('anketa')."' AND b.parent='".$rowB['id']."' AND b.element_spr=s.id
+ AND s.variable LIKE 'R%'
+ AND vd.usr_id='".get('usr_id')."' AND vd.spr_id=s.id
+ AND v.id=vd.vre_id
+ ");
+ if (!$sqlQ) echo mysqli_error($GLOBALS['connect_db']);
+
+ // Loop cez vprasanja in odgovore v bloku
+ $count_answers_pohvale = 0;
+ $count_answers_izzivi = 0;
+ while($rowQ = mysqli_fetch_array($sqlQ)){
+
+ // Pohvala
+ if((int)$rowQ['variable'] >= 1 && (int)$rowQ['variable'] <= 200){
+ $count_answers_pohvale++;
+ }
+ // Izziv
+ elseif((int)$rowQ['variable'] >= 201 && (int)$rowQ['variable'] <= 400){
+ $count_answers_izzivi++;
+ }
+ }
+
+ $count_answers_all = (int)$count_answers_pohvale + (int)$count_answers_izzivi;
+ if($count_answers_all > 0){
+ $radar_data[$rowB['label']]['all'] = $count_answers_all;
+ $radar_data[$rowB['label']]['pohvale'] = $count_answers_pohvale;
+ $radar_data[$rowB['label']]['izzivi'] = $count_answers_izzivi;
+ }
+ }
+ //echo '<pre>' . var_export($radar_data, true) . '</pre>';
+
+ $labels = array();
+ $values = array();
+ $i = 0;
+ foreach($radar_data as $radar_label => $radar_values){
+
+ $labels[$i] = $radar_label;
+ $pohvale[$i] = round($radar_values['pohvale'] / $radar_values['all'] * 10, 2);
+ $izzivi[$i] = round($radar_values['izzivi'] / $radar_values['all'] * 10, 2);
+
+ $i++;
+ }
+
+ $json_labels = json_encode($labels);
+ $json_pohvale = json_encode($pohvale);
+ $json_izzivi = json_encode($izzivi);
+
+ echo '<br><h2 style="padding-left: 20px;">Pajkova mreža</h2>';
+
+ // Nagovor za mrezo
+ $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='mreza'
+ ");
+ $rowNagovor = mysqli_fetch_array($sqlNagovor);
+ echo '<div class="spremenljivka" style="border-bottom:0;"><div class="naslov">'.$rowNagovor['naslov'].'</div></div>';
+
+ // Izris grafa
+ echo '<div class="spremenljivka radar_chart" id="skavti_radar_chart_holder">';
+
+ echo '<canvas id="skavti_radar_chart" class="chart"></canvas>';
+ echo '<script>$(document).ready(function(){ init_skavti_radar('.$json_labels.', '.$json_pohvale.', '.$json_izzivi.'); })</script>';
+
+ echo '</div>';
+ }
+
+
+ /**
+ * prikaze lepo obvestilo o napaki (anketa je zaključena itd...)
+ *
+ * @param mixed $text
+ */
+ public function displayNapaka($text)
+ {
+ Header::getInstance()->header();
+
+ $anketa = get('anketa');
+
+ echo '<div class="outercontainer_holder"><div class="outercontainer_holder_top"></div>';
+ echo '<div id="outercontainer">';
+
+ echo ' <div class="outercontainer_header"></div>';
+
+
+ echo ' <div id="container">';
+
+ $this->logo();
+
+ echo ' <h1>' . Helper::getInstance()->displayAkronim() . '</h1>';
+
+ echo ' <div class="grupa">';
+ echo ' <div class="spremenljivka">';
+ echo ' <p>' . $text . '</p>';
+ echo ' </div>';
+ echo ' </div>'; // -grupa
+
+ echo ' </div>'; // -container
+
+ Body::getInstance()->displayFooterNote();
+
+ echo '</div>'; // -outercontainer
+ echo '<div class="outercontainer_holder_bottom"></div></div>'; // -outercontainer_holder
+ }
+
+ /**
+ * Prikaze zavihke za bloke, ce obstajajo
+ *
+ */
+ public function display_tabs()
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_if i, srv_branching b WHERE i.tab='1' AND i.tip='1' AND i.id=b.element_if AND b.ank_id='" . get('anketa') . "' ORDER BY b.parent, b.vrstni_red");
+ if (mysqli_num_rows($sql) > 0) {
+
+ echo '<div class="tabs">';
+
+ $i = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($i++ != 0) echo ' | ';
+ $label = ($row['label'] == '' ? self::$lang['srv_blok'] . ' (' . $row['number'] . ')' : $row['label']);
+ echo '<a href="#" onclick="submitForm(\'' . $row['id'] . '\'); return false;" ' . (Ajax::getInstance()->ajax_grupa_for_if($row['id']) == get('grupa') ? ' class="active"' : '') . '>' . $label . '</a> ';
+ }
+
+ echo '</div>';
+
+ }
+ }
+
+ /**
+ * @desc konstruktor
+ */
+ public function PrintSurvey()
+ {
+
+ if (isset($_GET['anketa'])) {
+ save('anketa', $_GET['anketa']);
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // uvodni nagovor
+ if ($rowa['show_intro'] != 0) {
+ Body::getInstance()->displayIntroduction();
+ }
+
+ // prikažemo ankete
+ do {
+ save('grupa', Find::getInstance()->findNextGrupa());
+
+ Body::getInstance()->displayAnketa();
+ } while (get('grupa') != Find::getInstance()->findNextGrupa() && Find::getInstance()->findNextGrupa() > 0);
+
+ // prikažemo konec
+ Body::getInstance()->displayKonec();
+ } else
+ echo 'Ni podatkov o anketi!';
+ }
+
+
+ /**
+ * @desc prikaze chat okno za tawk chat, ce je modul vklopljen (js koda)
+ */
+ public function displayChatTAWK(){
+
+ echo '<div style="display:none;">';
+
+ $sql = sisplet_query("SELECT code, chat_type FROM srv_chat_settings WHERE ank_id='".get('anketa')."'");
+ if(mysqli_num_rows($sql) > 0){
+
+ $row = mysqli_fetch_array($sql);
+
+ if($row['code'] != ''){
+
+ // JS koda za widget
+ echo $row['code'];
+
+ echo "<script type='text/javascript'>";
+
+ // Dodatno se poslje tudi recnum in usr_id
+ $sqlu = sisplet_query("SELECT id, recnum FROM srv_user WHERE id = '".get('usr_id')."'");
+ $rowu = mysqli_fetch_array($sqlu);
+ echo "Tawk_API = Tawk_API || {}; Tawk_API.visitor = {name : 'Recnum ".$rowu['recnum']." (".get('usr_id').")', email : ''}; \n";
+
+ // Nastavimo za span class="tawk-chat-activation" tage
+ if($row['chat_type'] == '1' || $row['chat_type'] == '2'){
+
+ // Na klik prikazemo chat
+ echo "$('.tawk-chat-activation').click(function() { Tawk_API.showWidget(); Tawk_API.maximize(); }); \n";
+
+ // Dodatna nastavitev, da je chat po defaultu skrit
+ echo "Tawk_API.onLoad = function(){ Tawk_API.hideWidget();
+ Tawk_API.setAttributes({
+ 'recnum' : '".$rowu['recnum']."',
+ 'user-id' : '".get('usr_id')."'}, function(error){});
+ }; \n";
+ }
+ else{
+ // Dodatno še shranimo recnum in id, ce user slucajno spremeni ime
+ echo "Tawk_API.onLoad = function(){ Tawk_API.setAttributes({
+ 'recnum' : '".$rowu['recnum']."',
+ 'user-id' : '".get('usr_id')."'}, function(error){});
+ };";
+ }
+ echo "</script>";
+ }
+ }
+
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/FindController.php b/main/survey/app/Controllers/FindController.php
new file mode 100644
index 0000000..0f60a43
--- /dev/null
+++ b/main/survey/app/Controllers/FindController.php
@@ -0,0 +1,290 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use Cache;
+
+class FindController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ parent::getAllVariables();
+
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new FindController();
+ }
+
+
+ /**
+ * poisce, ce ima podani element parenta, ki je loop
+ *
+ */
+ public static function find_parent_loop($element_spr, $element_if = 0)
+ {
+ $anketa = get('anketa');
+ $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='$anketa'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ if ($row['parent'] == 0) return 0;
+
+ $sql = sisplet_query("SELECT id FROM srv_if WHERE id = '$row[parent]' AND tip = '2'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ if (mysqli_num_rows($sql) > 0)
+ return $row['parent'];
+ else
+ return self::find_parent_loop(0, $row['parent']);
+
+ }
+
+ /**
+ * poisce naslednjo vre_id v loopu
+ *
+ */
+ public function findNextLoopId($if_id = 0)
+ {
+
+ if ($if_id == 0) {
+ $sql = sisplet_query("SELECT if_id FROM srv_loop_data WHERE id='" . get('loop_id') . "'");
+ $row = mysqli_fetch_array($sql);
+ $if_id = $row['if_id'];
+ $loop_id = get('loop_id');
+ }
+ else
+ $loop_id = 0;
+
+ $sql = sisplet_query("SELECT spr_id, max FROM srv_loop WHERE if_id = '$if_id'");
+ $row = mysqli_fetch_array($sql);
+ $spr_id = $row['spr_id'];
+ $max = $row['max'];
+
+ $spr = Cache::srv_spremenljivka($spr_id);
+
+ // Radio, checkbox, sn imena
+ if ($spr['tip'] == 2 || $spr['tip'] == 3 || $spr['tip'] == 9) {
+
+ $data_vrednost = array();
+ if ($spr['tip'] == 9)
+ $sql1 = sisplet_query("SELECT vre_id FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'");
+ else
+ $sql1 = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $data_vrednost[$row1['vre_id']] = 1;
+ }
+
+ $vre_id = '';
+ $i = 1;
+ $sql = sisplet_query("SELECT lv.vre_id, lv.tip FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($row['tip'] == 0) { // izbran
+ if (isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 1) { // ni izbran
+ if (!isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 2) { // vedno
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ } // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze
+
+ if ($i > $max && $max > 0) break;
+ }
+
+ $vre_id = substr($vre_id, 2);
+ if ($vre_id == '')
+ return null;
+
+ $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_vrednost v WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id) AND l.vre_id=v.id ORDER BY l.id ASC");
+
+
+ if (!$sql) {
+ echo 'err56545' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ $row = mysqli_fetch_array($sql);
+
+ if (mysqli_num_rows($sql) > 0)
+ return $row['id'];
+ else
+ return null;
+ }
+ // Number
+ elseif ($spr['tip'] == 7) {
+
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $num = (int)$row1['text'];
+ $sql2 = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id <= '$loop_id'");
+ if (mysqli_num_rows($sql2) >= $num || (mysqli_num_rows($sql2) >= $max && $max > 0))
+ return null;
+
+ $sql = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id'");
+ $row = mysqli_fetch_array($sql);
+
+ if (mysqli_num_rows($sql) > 0)
+ return $row['id'];
+ else
+ return null;
+
+ }
+ // Ranking
+ elseif ($spr['tip'] == 17) {
+
+ $data_vrednost = array();
+ $sql1 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "' ORDER BY vrstni_red ASC");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $data_vrednost[$row1['vre_id']] = 1;
+ }
+
+ $vre_id = '';
+ $i = 1;
+ $sql = sisplet_query("SELECT lv.vre_id, lv.tip FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($row['tip'] == 0) { // izbran
+ if (isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 1) { // ni izbran
+ if (!isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 2) { // vedno
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ } // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze
+
+ if ($i > $max && $max > 0) break;
+ }
+
+ $vre_id = substr($vre_id, 2);
+ if ($vre_id == '')
+ return null;
+
+
+ // Ce gre za prvi loop poiscemo ranking odgovor na prvem mestu
+ if($loop_id == 0){
+ $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_data_rating dr
+ WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id)
+ AND l.vre_id=dr.vre_id AND dr.usr_id='".get('usr_id')."' AND dr.vrstni_red = '1'
+ ");
+ }
+ // Ce gre za kasnejsi loop poiscemo naslednji ranking odgovor
+ else{
+ $sql2 = sisplet_query("SELECT dr.vrstni_red FROM srv_loop_data l, srv_data_rating dr WHERE l.if_id='$if_id' AND l.id='$loop_id' AND dr.vre_id=l.vre_id AND dr.usr_id='".get('usr_id')."'");
+ if(mysqli_num_rows($sql2) > 0){
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_vrednost v, srv_data_rating dr
+ WHERE l.if_id='$if_id' AND l.id != '$loop_id' AND l.vre_id IN ($vre_id)
+ AND l.vre_id=v.id
+ AND dr.vre_id=v.id AND dr.usr_id='".get('usr_id')."' AND dr.vrstni_red > '".$row2['vrstni_red']."'
+ ORDER BY dr.vrstni_red ASC
+ ");
+ }
+ else
+ return null;
+ }
+
+ if (!$sql) {
+ echo 'err56545' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ $row = mysqli_fetch_array($sql);
+
+
+ if (mysqli_num_rows($sql) > 0)
+ return $row['id'];
+ else
+ return null;
+ }
+ }
+
+ /**
+ * @desc poisce prejsnjo stran - grupo, 0 pomeni konec
+ */
+ public static function findPrevGrupa()
+ {
+ $anketa = get('anketa');
+ $grupa = get('grupa');
+
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '$grupa'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$anketa' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1");
+
+ // naslednja stran
+ if (mysqli_num_rows($sql) > 0) {
+
+ $row = mysqli_fetch_array($sql);
+ return $row['id'];
+
+ // konec
+ } else {
+
+ return 0;
+ }
+ }
+
+ /**
+ * @desc poisce naslednjo stran - grupo, 0 pomeni konec
+ */
+ public function findNextGrupa($gru_id=0)
+ {
+ //vrstni red trenutne grupe
+ if (get('grupa') > 0) {
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+ }
+ elseif ($gru_id > 0) {
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . $gru_id . "'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+ }
+ else {
+ $vrstni_red = 0;
+ }
+
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red>'$vrstni_red' ORDER BY vrstni_red ASC LIMIT 1");
+
+ // naslednja stran
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ return $row['id'];
+ }
+ // konec
+ else {
+ return 0;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/HeaderController.php b/main/survey/app/Controllers/HeaderController.php
new file mode 100644
index 0000000..1a7df13
--- /dev/null
+++ b/main/survey/app/Controllers/HeaderController.php
@@ -0,0 +1,920 @@
+<?php
+/***************************************
+ * Description: Odgovoreun za glavo, kjer poberemo tudi vse spremenljivke iz URL naslovov
+ * Autor: Robert Šmalc
+ * Created date: 28.01.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\HelperController as Helper;
+use App\Models\Model;
+use App\Controllers\FindController as Find;
+use Common;
+use SurveyAdvancedParadataLog;
+use SurveyInfo;
+use SurveyThemeEditor;
+use SurveyPanel;
+
+class HeaderController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HeaderController();
+ }
+
+ /**
+ * nastavi default parametre, ki se prenasajo preko urlja
+ *
+ */
+ public static function getSurveyParams($encode = false, $force = null, $forcenot = null)
+ {
+
+ if (!is_array($force)) $force = array();
+ if (!is_array($forcenot)) $forcenot = array();
+ $g = '';
+
+ $paramslist = array(
+ 'language',
+ 'preview',
+ 'testdata',
+ 'mobile',
+ 'urejanje',
+ 'quick_view',
+ 'disableif',
+ 'disablealert',
+ 'disablecode',
+ 'displayifs',
+ 'displayvariables',
+ 'hidecomment',
+ 'popup',
+ 'no_preview',
+ 'theme_profile',
+ 'theme',
+ 'ai',
+ 'pages'
+ );
+
+ // add params that are not forced and not notforced
+ foreach ($paramslist AS $param) {
+ if (isset($_GET[$param]) && !array_key_exists($param, $force) && !in_array($param, $forcenot))
+ $g .= '&' . $param . '=' . $_GET[$param];
+ }
+
+ // add forced params
+ foreach ($force AS $key => $val) {
+ $g .= '&' . $key . '=' . $val;
+ }
+
+ if ($encode) $g = str_replace('&', '&amp;', $g);
+
+ return $g;
+
+ }
+
+ /************************************************
+ * Funcktja pridobi vse url parametre in jih ustrezno doda v globalne spremenljivke razreda SurveyClass
+ *
+ * @param $_GET
+ * @param $var - vse spremenljivke
+ * @return (obje ct) $get
+ ************************************************/
+ public function getAllUrlParameters()
+ {
+ // Vse GET parametre damo v objekt
+ if (!empty($_GET))
+ $get = (object)$_GET;
+
+ //V kolikor gre za enkripcijo potem najprej dekriptiramo - URLDECODE SE ZE AVTOMATSKO IZVEDE NA $_GET array-u
+ if (isset($get->enc)) {
+ //$request_decoded = base64_decode(urldecode($get->enc));
+ $request_decoded = base64_decode($get->enc);
+
+ $request_array = array();
+ parse_str($request_decoded, $request_array);
+
+ foreach ($request_array as $var => $value) {
+ $get->$var = $value;
+ }
+ }
+
+ //postavimo še ID ankete, ker ga bomo največkrat potrebovali
+ if (empty($get->anketa) && !is_int($get->anketa) && empty($_POST['anketa'])) {
+ return header('Location: ' . self::$site_url);
+ die("Missing anketa id!");
+ }
+ $anketa = (($get->anketa) ? $get->anketa : $_POST['anketa']);
+
+ // Shranimo vse spremenljivke iz get parametrov v classu VariableClass
+ save('anketa', $anketa);
+ save('get', $get);
+
+ return $get;
+ }
+
+
+ /************************************************
+ * Pridobimo vse parametre iz piškotka
+ *
+ * @param $_COOKIE
+ * @return (object) $cookie
+ ************************************************/
+ public function getAllCookieParameters()
+ {
+ $cookie = null;
+ // Vse GET parametre damo v objekt
+ if (!empty($_COOKIE))
+ $cookie = (object)$_COOKIE;
+
+ // Piškot shranimo v spremenljivke VariableClass
+ save('cookie', $cookie);
+
+ return $cookie;
+ }
+
+ /**
+ * @desc zgenereira header
+ */
+ public function header(){
+ global $app_settings;
+
+
+ // preprecimo caching - tudi s klikom na gumb nazaj!
+ header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT");
+ header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
+ header("Cache-Control: post-check=0, pre-check=0", FALSE);
+ header("Pragma: no-cache"); // HTTP/1.0
+
+
+ echo '<head>' . "\n";
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqlv = sisplet_query("SELECT value FROM misc WHERE what='version'");
+ $rowv = mysqli_fetch_array($sqlv);
+
+ // Custom header title
+ if(isset($app_settings['head_title_custom']) && $app_settings['head_title_custom'] == 1){
+ echo '<title>'.strip_tags(Helper::getInstance()->displayAkronim(0)).' - '.$app_settings['head_title_text'].'</title>' . "\n";
+ }
+ // Default header title
+ else{
+ echo '<title>'.strip_tags(Helper::getInstance()->displayAkronim(0)).' - '.self::$lang['1ka_surveys'].'</title>' . "\n";
+ }
+
+ echo ' <meta charset="utf-8">' . "\n";
+
+ // Preprecimo vklop compatibility moda v IE
+ echo ' <meta http-equiv="X-UA-Compatible" content="IE=edge" />' . "\n";
+
+ // nova verzija UI 1.8.10 - includamo minificirano skupaj z script.js (uporabimo iste jQuery fajle kot v adminu)
+ echo ' <script src="' . self::$site_url . 'admin/survey/minify/g=jsfrontend?v=' . $rowv['value'] . '"></script>' . "\n";
+ echo '<script src="https://www.google.com/recaptcha/api.js" async defer></script>' . "\n";
+
+ // tukaj nalozimo CSS za jquery in template temo
+ echo ' <link href="' . self::$site_url . 'admin/survey/minify/g=cssfrontend?v=' . $rowv['value'] . '" rel="stylesheet">' . "\n";
+
+ //nalozimo stringe iz langa za JS
+ echo '<script type="text/javascript" src="' . self::$site_url . 'admin/survey/script/js-lang.php?lang=' . ($row['lang_admin'] == 1 ? 'si' : 'en') . '&amp;v=' . $rowv['value'] . '"></script>' . "\n";
+
+ // nalozimo open sans fonte za nov design
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700&subset=latin,latin-ext" rel="stylesheet" />';
+ /*echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700&subset=latin,latin-ext" rel="stylesheet">';*/
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,500,500i,600,600i,700,700i&amp;subset=latin-ext" rel="stylesheet" />';
+
+
+ // CSS mobile skin za telefone in tablice
+ if (get('mobile') == 1) {
+
+ echo ' <meta content="width=device-width; initial-scale=1.0;" name="viewport">' . "\n";
+
+ // za MJU anketo nalozimo posebej custom skin
+ if(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){
+ $this->loadCustomMadeSkin($custom_skin='MJU');
+ }
+ // CSS samo za mobilne telefone
+ else{
+ $this->themeEditorMobileCustom();
+ }
+ }
+ // CSS za tablice je po defaultu enak kot za pc
+ elseif(get('mobile') == 2){
+
+ echo ' <meta content="width=device-width" name="viewport">' . "\n";
+
+ // za MJU anketo nalozimo posebej custom skin
+ if(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){
+ $this->loadCustomMadeSkin($custom_skin='MJU');
+ }
+ // profili tem - skinov
+ else{
+ $this->themeEditor();
+ }
+ }
+ // CSS za pc
+ else{
+
+ // Custom skin za Bled
+ if($row['skin'] == 'Bled'){
+ $this->loadCustomMadeSkin($custom_skin='Bled');
+ }
+ // za MJU anketo nalozimo posebej custom skin
+ elseif(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){
+ $this->loadCustomMadeSkin($custom_skin='MJU');
+ }
+ // profili tem - skinov
+ else{
+ $this->themeEditor();
+ }
+ }
+
+
+ // še css za printer
+ // tole je ze out-of-date, po moje je zaenkrat boljs brez posebnega print skina
+ //echo ' <link rel="stylesheet" href="'.self::$site_url.'main/survey/skins/printer.css" media="print">'."\n";
+
+ // Skin za glasovanje
+ $sqlG = sisplet_query("SELECT skin FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $rowG = mysqli_fetch_array($sqlG);
+ if (mysqli_num_rows($sqlG) > 0)
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/glasovanje/' . $rowG['skin'] . '.css" media="screen">' . "\n";
+
+ // CSS za modul kviz
+ if (SurveyInfo::getInstance()->checkSurveyModule('quiz')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/quiz/quiz.css" media="screen">' . "\n";
+ }
+
+ // CSS za modul SAZU anketo
+ if (SurveyInfo::getInstance()->checkSurveyModule('sazu')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'admin/survey/modules/mod_SAZU/css/style_sazu.css" media="screen">' . "\n";
+ }
+
+ // CSS za rtl text - glede na lang datoteko (zaenkrat samo arabscina)
+ if (in_array(self::$lang['id'], array('39', '43'))) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'public/css/main_rtl.css" media="screen">' . "\n";
+ }
+
+ // JavaScript za napredne parapodatke
+ if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+
+ // Ce ne postamo oz. ce smo na zadnji strani vkljucimo js kodo
+ if(count($_POST) == 0 || Find::getInstance()->findNextGrupa($_GET['grupa']) == 0){
+ SurveyAdvancedParadataLog::getInstance()->prepareLogging();
+ SurveyAdvancedParadataLog::getInstance()->linkJavaScript();
+ }
+ }
+
+ echo '</head>' . "\n";
+
+
+ // Ce imamo vklopljen evoli na instalaciji, potem onemogocimo kopiranje
+ $evoli_copy_disable = '';
+ if (Common::checkModule('evoli') == '1' || Common::checkModule('evoli_employmeter') == '1')
+ $evoli_copy_disable = 'oncopy="return false;" oncut="return false;" oncontextmenu="return false;"';
+
+ $preview = '';
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on')
+ $preview = ' class="preview"';
+ elseif (isset($_GET['testdata']) && $_GET['testdata'] == 'on')
+ $preview = ' class="preview"';
+ echo '<body ' . $preview . ' ' . $evoli_copy_disable . '>' . "\n";
+
+ // Zamenjamo class no_js z js -> test javacsripta za userje (javascript_warning)
+ echo "<script>" . "\n";
+ $tooltips_maxwitdh = "maxWidth: '880'";
+ if ($row['skin'] == 'Embed2')
+ $tooltips_maxwitdh = "maxWidth: '340'";
+ if ($row['skin'] == 'Otroci3' || $row['skin'] == 'Otroci4')
+ $tooltips_maxwitdh = "maxWidth: '680'";
+
+ echo "$(document).ready(function(){
+ $('html').removeClass('no_js').addClass('js');
+ $('.tooltip.mouseover').tooltipster({
+ theme: 'tooltipster-shadow',";
+ echo $tooltips_maxwitdh;
+ echo "
+ });
+ $('.tooltip.mouseclick').tooltipster({
+ theme: 'tooltipster-shadow',
+ trigger: 'click',";
+ echo $tooltips_maxwitdh;
+ echo " });";
+
+ // Tega ne rabimo vec, ker urejamo okvir slik direktno s css-jem (na parenta (.variabla) damo class checked)
+ //echo "$('div.variabla input:checkbox, div.variabla input:radio').on('change', function() { activateCehckboxImages($(this)); });"."\n";
+
+ # če smo v quick_view disejblamo vse elemente frme
+ if (get('quick_view') == true) {
+ echo "$('input:[type=radio], input:[type=checkbox], input:[type=text], select, textarea').attr('disabled',true);" . "\n";
+ }
+ echo " })" . "\n";
+ echo "</script>";
+
+ if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1) { // vnos
+
+ $sql1 = sisplet_query("SELECT user_id FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sqlu = Model::db_select_user($row1['user_id']);
+ $rowu = mysqli_fetch_array($sqlu);
+
+ if (mysqli_num_rows($sqlu) > 0) {
+ echo '<div id="vnos">';
+ echo self::$lang['srv_recognized'] . ' <strong>' . $rowu['name'] . ' ' . $rowu['surname'] . '</strong><br>(' . $rowu['email'] . ')';
+ echo '</div>' . "\n";
+ }
+
+ }
+ }
+
+ /**
+ * @desc prikaze sistemske spremenljivke
+ */
+ public function displaySistemske()
+ {
+ $sql = sisplet_query("SELECT id, recnum FROM srv_user WHERE id='" . get('usr_id') . "'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ echo ' <input type="hidden" id="javascript" name="javascript" value="0">';
+ echo ' <input type="hidden" id="srv_meta_anketa_id" name="srv_meta_anketa_id" value="' . get('anketa') . '">';
+
+ // Ce imamo vklopljen modul panel sproti belezimo tudi panel_status
+ if(SurveyInfo::checkSurveyModule('panel') == 1){
+
+ // Ce gre za prvo nastavimo na default vrednost, drugace beremo iz post-a
+ $sp = new SurveyPanel(get('anketa'));
+ $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $sp->getPanelSettings('status_default');
+
+ echo ' <input type="hidden" id="panel_status" name="panel_status" value="'.$panel_status.'">';
+ }
+
+ // Spremenljivke, ki se rabijo v JS
+ echo ' <script> ' . "\n";
+
+ echo ' var _recnum = \'' . $row['recnum'] . '\'; ' . "\n";
+ echo ' var _usr_id = \'' . $row['id'] . '\'; ' . "\n";
+ echo ' var srv_meta_anketa_id = ' . get('anketa') . '; ' . "\n";
+ echo ' var srv_site_url = \'' . self::$site_url . '\'; ' . "\n";
+ echo ' var _lang = \'' . self::$lang['language'] . '\'; ' . "\n";
+
+ echo ' var is_paused_slideshow = false; ' . "\n";
+ echo ' document.getElementById(\'javascript\').value = 1; ' . "\n";
+
+ echo ' </script> ' . "\n";
+
+ // Spremenljivke, ki se rabijo v JS za drag/drop
+ echo '
+ <script>
+ var draggableOnDroppable = []; // spremenljivka, ki belezi prisotnost odgovora na ustrezni povrsini pri Drag and Drop
+ var maxDragDrop = []; // spremenljivka, ki belezi max stevilo moznih odgovorov
+
+ var draggableOverDroppable = []; // spremenljivka, ki belezi prisotnost odgovora nad ustreznim okvirjem pri Drag and Drop
+ var default_var_height_1 = []; // belezi zacetno vrednost visine celotnega vprasanja po usklajevanju visine glede na prisotne kategorije odgovorov
+ var data_after_refresh = []; // belezi, ali je uporabnik refresh-al stran oz. se vraca na stran
+ var frame_total_height_right = []; // belezi visino okvirjev desnega bloka @ drag and drop grids
+ var draggableOver = [];
+ var last_vre_id = []; // belezi vre_id zadnjega draggable, ki smo ga premikali @ Drag and drop
+ var vre_id_global = []; // belezi vre_id trenutne kategorije odgovorov @ Drag and drop
+ var last_indeks = []; // belezi indeks zadnjega okvirja, kjer je bil draggable @ Drag and drop
+ var indeks_global = []; // belezi trenutni indeks okvirja @ Drag and drop
+ var last_drop = []; // belezi indeks zadnjega okvirja, kjer je bil draggable droppan @ Drag and drop
+ var num_grids_global = []; // belezi stevilo gridov za doloceno vprasanje
+ var draggable_global = [];
+ var cat_pushed = []; // belezi, ali je kategorijo odrinila druga kategorija odgovora @ Drag and drop
+ </script>
+ ';
+ }
+
+ public function themeEditor($themePreview = false){
+
+ if (isset($_GET['theme'])) $themePreview = true; // to ne bo vec
+ if (isset($_GET['theme-preview']) && $_GET['theme-preview'] == '1') $themePreview = true; // to je pri urejanju CSSa da se refresha mimo cachea
+
+ $row = SurveyInfo::getSurveyRow();
+
+ if (isset($_GET['theme_profile'])) {
+ $row['skin_profile'] = (int)$_GET['theme_profile'];
+ }
+ if (isset($_GET['theme'])) {//to ne bo vec
+ $row['skin'] = str_replace('.css', '', $_GET['theme']);
+ $row['skin_profile'] = 0;
+ }
+
+ // ni nastavljenih profilov, nastavimo navadno temo
+ if ($row['skin_profile'] == 0) {
+
+ // Ce ne gre za obstojeco anketo nastavimo default skin
+ if($row['skin'] == '')
+ $row['skin'] = '1kaBlue';
+
+ // moznost zip skinov
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $row['skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $row['skin'] . '/' . $row['skin'] . '.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ } else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $row['skin'] . '.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ }
+ // nastavljen je profil, nastavimo temo in potem še lastne nastavitve
+ else {
+
+ $sqla = sisplet_query("SELECT skin, logo FROM srv_theme_profiles WHERE id = '$row[skin_profile]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ // moznost zip skinov
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $rowa['skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $rowa['skin'] . '/' . $rowa['skin'] . '.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ } else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $rowa['skin'] . '.css' . ($themePreview || true ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+
+ $sqlt = sisplet_query("SELECT * FROM srv_theme_editor WHERE profile_id = '" . $row['skin_profile'] . "'");
+ if (mysqli_num_rows($sqlt) > 0) {
+
+ echo '<style>';
+
+ while ($rowt = mysqli_fetch_array($sqlt)) {
+
+ switch ($rowt['id']) {
+
+ case '1':
+ echo 'h1';
+ break;
+
+ case '2':
+ echo '.spremenljivka';
+ break;
+
+ case '3':
+ echo '.variable_holder';
+ break;
+
+ case '4':
+ echo 'table.grid_table tbody tr:nth-child(2n+1)';
+ break;
+
+ case '5':
+ echo 'div.spremenljivka';
+ break;
+
+ case '7':
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio,
+ input[type="radio"]+span.enka-checkbox-radio,
+ .custom_radio_picture.obarvan > label > span.enka-custom-radio:before
+ ';
+ break;
+
+ case '6':
+ echo '#container';
+ break;
+
+ case '8':
+ echo '.tooltipster-shadow';
+ break;
+
+ case '9':
+ echo 'abbr.tooltip';
+ break;
+ }
+
+ echo ' {';
+
+ switch ($rowt['type']) {
+
+ case '1':
+ if ($rowt['value'] > 0)
+ echo 'font-family: ' . SurveyThemeEditor::getFont($rowt['value']) . ';';
+ break;
+
+ case '2':
+ case '9':
+ case '15':
+ echo 'color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '3':
+ echo 'background: ' . $rowt['value'] . ';';
+ break;
+
+ case '4':
+ echo 'font-size: ' . $rowt['value'] . '%;';
+ break;
+
+ case '5':
+ if ($rowt['value'] == '0') {
+ echo 'border: 0;';
+ } elseif ($rowt['value'] == '2') {
+ echo 'border: 1px #B9C5D9 solid;';
+ } else {
+ echo 'border: 0;';
+ echo 'border-top: 1px #B9C5D9 solid;';
+ }
+ break;
+
+ case '7':
+ if ($rowt['value'] != '0')
+ echo 'font-size: ' . $rowt['value'] . 'px;';
+ break;
+
+ case '10':
+ echo 'border-color: ' . $rowt['value'] . ';';
+ break;
+
+ case '11':
+ echo 'border-width: ' . $rowt['value'] . 'px;';
+ break;
+
+ case '12':
+ echo 'border-radius: ' . $rowt['value'] . 'px;';
+ break;
+
+ case '13':
+ echo 'background-color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '14':
+ if ($rowt['value'] == 'bold')
+ echo 'font-weight: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'italic')
+ echo 'font-style: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'underline')
+ echo 'text-decoration: ' . $rowt['value'] . ' !important;';
+ break;
+
+
+ }
+
+ echo '}';
+
+ // Accessibility
+ if($rowt['type'] == '17' && $rowt['id'] == '10'){
+ if($rowt['value'] == '1'){
+
+ // Skrijemo barvne ikone
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio, input[type="radio"]+span.enka-checkbox-radio{
+ display: none !important;
+ }';
+
+ // Prikazemo navadne ikone
+ echo 'input[type="checkbox"], input[type="radio"] {
+ display: inline-block !important;
+ }';
+ }
+ }
+ }
+
+ echo '</style>';
+ }
+
+ // Izrisemo css za custom logo
+ if ($rowa['logo'] != '') {
+ $this->customLogoCSS($rowa['logo']);
+ }
+ }
+
+ // Za office in nature skina imamo random background
+ if($row['skin'] == '1kaOffice' || $row['skin'] == '1kaNature'){
+ $bg_number = rand(1,15);
+ echo '<style> html{ background-image: url(' . self::$site_url . 'main/survey/skins/'.$row['skin'].'/bg'.$bg_number.'.jpg); } </style>';
+ }
+ }
+
+ public function themeEditorMobileCustom(){
+
+ $row = SurveyInfo::getSurveyRow();
+
+ // Najprej nalozimo mobile template skin
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'public/css/main_mobile.css" media="all">' . "\n";
+
+
+ if (isset($_GET['theme_profile'])) {
+ $row['skin_profile_mobile'] = (int)$_GET['theme_profile'];
+ }
+ if (isset($_GET['theme'])) {
+ $themePreview = true;
+ $row['mobile_skin'] = str_replace('.css', '', $_GET['theme']);
+ }
+
+
+ // Fonti za mobilne skine (vse razen prvega default)
+ if($row['mobile_skin'] != 'Mobile')
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=Bree+Serif&subset=latin,latin-ext" rel="stylesheet" />';
+
+
+ // ni nastavljenih profilov, nastavimo navadno temo
+ if ($row['skin_profile_mobile'] == 0) {
+
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $row['mobile_skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/MobileBlue.css'.($themePreview ? '?foo=' . mt_rand() : '').'" media="all">' . "\n";
+ }
+ else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $row['mobile_skin'] . '.css'.($themePreview ? '?foo='. mt_rand() : '').'" media="all">' . "\n";
+ }
+ }
+ // nastavljen je profil, nastavimo temo in potem še lastne nastavitve
+ else {
+
+ $sqla = sisplet_query("SELECT skin FROM srv_theme_profiles_mobile WHERE id = '$row[skin_profile_mobile]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $rowa['skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/MobileBlue.css'.($themePreview ? '?foo=' . mt_rand() : '').'" media="all">' . "\n";
+ } else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $rowa['skin'] . '.css'.($themePreview || true ? '?foo='. mt_rand() : '').'" media="all">' . "\n";
+ }
+
+ $sqlt = sisplet_query("SELECT * FROM srv_theme_editor_mobile WHERE profile_id = '" . $row['skin_profile_mobile'] . "'");
+ if (mysqli_num_rows($sqlt) > 0) {
+
+ echo '<style>';
+
+ while ($rowt = mysqli_fetch_array($sqlt)) {
+
+ switch ($rowt['id']) {
+
+ case '1':
+ echo 'h1';
+ break;
+
+ case '2':
+ echo '.spremenljivka .naslov';
+ break;
+
+ case '3':
+ echo '.variable_holder, .variable_holder .variabla label';
+ break;
+
+ case '4':
+ echo 'table.grid_table tbody tr:nth-child(2n+1)';
+ break;
+
+ case '5':
+ echo '.spremenljivka';
+ break;
+
+ case '7':
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio,
+ input[type="radio"]+span.enka-checkbox-radio';
+ break;
+
+ case '6':
+ echo '#container h1, #footer_survey';
+ break;
+
+ case '8':
+ echo '.tooltipster-shadow';
+ break;
+
+ case '9':
+ echo 'abbr.tooltip';
+ break;
+ }
+
+ echo ' {';
+
+ switch ($rowt['type']) {
+
+ case '1':
+ if ($rowt['value'] > 0)
+ echo 'font-family: ' . SurveyThemeEditor::getFont($rowt['value']) . ' !important;';
+ break;
+
+ case '2':
+ case '9':
+ echo 'color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '3':
+ echo 'background: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '4':
+ echo 'font-size: ' . $rowt['value'] . '% !important;';
+ break;
+
+ case '5':
+ if ($rowt['value'] == '0') {
+ echo 'border: 0;';
+ } elseif ($rowt['value'] == '2') {
+ echo 'border: 1px #B9C5D9 solid;';
+ } else {
+ echo 'border: 0;';
+ echo 'border-top: 1px #B9C5D9 solid;';
+ }
+ break;
+
+ case '8':
+ if ($rowt['value'] != '0')
+ echo 'font-size: ' . $rowt['value'] . 'px !important;';
+ break;
+
+ case '10':
+ echo 'border-color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '11':
+ echo 'border-width: ' . $rowt['value'] . 'px !important;';
+ break;
+
+ case '12':
+ echo 'border-radius: ' . $rowt['value'] . 'px !important;';
+ break;
+
+ case '13':
+ echo 'background-color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '14':
+ if ($rowt['value'] == 'bold')
+ echo 'font-weight: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'italic')
+ echo 'font-style: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'underline')
+ echo 'text-decoration: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '16':
+ echo 'color: ' . $rowt['value'] . ' !important;';
+ break;
+ }
+
+ echo '}';
+
+ // Accessibility
+ if($rowt['type'] == '17' && $rowt['id'] == '10'){
+ if($rowt['value'] == '1'){
+
+ // Skrijemo barvne ikone
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio, input[type="radio"]+span.enka-checkbox-radio{
+ display: none !important;
+ }';
+
+ // Prikazemo navadne ikone
+ echo 'input[type="checkbox"], input[type="radio"] {
+ display: inline-block !important;
+ }';
+ }
+ }
+ }
+
+ echo '</style>';
+ }
+ }
+
+ // Izrisemo css za custom logo
+ $sqla = sisplet_query("SELECT logo FROM srv_theme_profiles WHERE id = '$row[skin_profile]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ if ($rowa['logo'] != '') {
+ $this->customLogoCSS($rowa['logo']);
+ }
+ }
+
+
+ // Funkcija ki nalozi custom temo narejeno po narocilu
+ private function loadCustomMadeSkin($custom_skin){
+
+ if (isset($_GET['theme'])) $themePreview = true; // to ne bo vec
+ if (isset($_GET['theme-preview']) && $_GET['theme-preview'] == '1') $themePreview = true; // to je pri urejanju CSSa da se refresha mimo cachea
+
+
+ // Custom narejen skin za Bled
+ if($custom_skin == 'Bled'){
+
+ // Font PT sans
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,700&subset=latin,latin-ext" rel="stylesheet">';
+
+ // Imamo različne backgrounde
+ $bg_number = rand(1,9);
+ echo '<style>
+ html{
+ background-image: url(' . self::$site_url . 'main/survey/skins/___po_narocilu/Bled/bg'.$bg_number.'.jpg);
+ }
+ </style>';
+
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/Bled.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+
+ // Premaknemo footer na dno
+ echo '<script>
+ footerBled();
+
+ function footerBled(){
+ var footerResize = function() {
+ if($("#outercontainer").height() <= $(window).height()-80){
+ $(\'#footer_survey\').css(\'position\', "absolute");
+ $(\'#footer_survey\').css(\'bottom\', "0px");
+ }
+ else{
+ $(\'#footer_survey\').css(\'position\', "auto");
+ $(\'#footer_survey\').css(\'bottom\', "auto");
+ }
+ };
+ $(window).resize(footerResize).ready(footerResize);
+ }
+ </script>';
+ }
+ // Custom skin za MJU anketo
+ elseif($custom_skin == 'MJU'){
+
+ // Font PT sans
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,700&subset=latin,latin-ext" rel="stylesheet">';
+
+ // mobitel
+ if (get('mobile') == 1) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/MJU_mobile.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ // tablica
+ elseif(get('mobile') == 2){
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/MJU_tablet.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ // navaden racunalnik
+ else{
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/MJU.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ }
+ }
+
+
+ // Insertamo css za custom logo
+ private function customLogoCSS($logo){
+
+ // Najprej dobimo velikost originalne slike
+ $image_orig = self::$site_url . 'main/survey/uploads/' . $logo;
+ if (file_exists(survey_path('uploads/' . $logo))) {
+
+ $size_orig = @getimagesize($image_orig);
+
+ $css_bg_image = $image_orig;
+ $css_width = '';
+ $css_height = '';
+ $css_bg_size = 'contain !important';
+
+ // Ce gre za Gorenje prikazemo drug logo
+ if(Common::checkModule('gorenje')){
+ $css_bg_size = 'auto 50px !important';
+ }
+ // Ce slucajno ne moremo dobiti siza
+ elseif(!$size_orig){
+ $css_height = '100px';
+ $css_width = '250px';
+ }
+ // Ce je original visji kot 160 ga avtomatsko pomanjsamo
+ elseif($size_orig[1] > 160) {
+
+ $image = self::$site_url . 'function/thumb.php?src=' . self::$site_url . 'main/survey/uploads/' . $logo . '&h=100';
+ $size = @getimagesize($image);
+
+ if($size){
+ $css_bg_image = $image;
+ $css_width = $size[0].'px';
+ $css_height = '100px';
+ }
+ }
+ // Drugace pustimo default size logotipa
+ else{
+ $css_width = $size_orig[0].'px';
+ $css_height = $size_orig[1].'px';
+ }
+
+
+ // CSS za custom logo
+ echo '<style type="text/css">';
+
+ echo '#logo, #logo.english, #footer_survey #logo, #footer_survey #logo.english {';
+
+ echo ' background-image: url('.$css_bg_image.'); ';
+
+ if($css_width != '')
+ echo ' width: '.$css_width.'; ';
+
+ if($css_height != '')
+ echo ' height: '.$css_height.'; ';
+
+ if($css_bg_size != '')
+ echo ' background-size: '.$css_bg_size.'; ';
+
+ echo '}';
+
+ echo '#footer_survey #logo { max-height: 70px; max-width: 200px; }';
+
+ echo '#logo a, #footer_survey #logo a { display: none; }';
+
+ echo '</style>';
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/HelperController.php b/main/survey/app/Controllers/HelperController.php
new file mode 100644
index 0000000..58e6784
--- /dev/null
+++ b/main/survey/app/Controllers/HelperController.php
@@ -0,0 +1,747 @@
+<?php
+/***************************************
+ * Description: Notri so zbrane funkcije, ki jih večkrat lahko uporabimo v vseh razredih
+ * Autor: Robert Šmalc
+ * Created date: 29.01.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\HelperController as Helper;
+use App\Models\Model;
+use Cache;
+use Common;
+use enkaParameters;
+use Hierarhija\HierarhijaHelper;
+use MailAdapter;
+use SurveyInfo;
+use SurveySetting;
+use SurveyUnsubscribe;
+use UserAccess;
+
+class HelperController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ parent::getAllVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HelperController();
+ }
+
+ /************************************************
+ * Detekcija za katere vrste naprave gre (mobilnik, tablica ali računalnik)
+ * 0 - računalnik oz. normalni pogled
+ * 1 - mobilnik
+ * 2 - tablica
+ * @param $_SERVER ['HTTP_USER_AGENT'];
+ * @return string
+ ************************************************/
+ public static function mobile()
+ {
+ $detect = New \Mobile_Detect();
+ $mobile = 0; // 0 - klasicna, 1 - mobilna, 2 - dlancniki
+ $ismobile = 0;
+
+ // detektiramo, ce gre za mobilni aparat
+ if ($detect->isMobile())
+ $ismobile = 1;
+
+ if ($ismobile == 1) {
+ if ($detect->isTablet())
+ $mobile = 2;
+ else
+ $mobile = 1;
+ }
+
+ // prednost pa ima rocno izbrana opcija - ce je nastavljena
+ if (isset($_COOKIE['mobile'])) {
+ $c = (int)$_COOKIE['mobile'];
+ if ($c > 0)
+ $mobile = $mobile;
+ else
+ $mobile = 0;
+ }
+
+ // Ce smo slucajno v preview-ju preverimo kateri preview prikazemo
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on') {
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $mobile = 1;
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $mobile = 2;
+ };
+
+ return $mobile;
+ }
+
+ /**
+ * @desc V podanem stringu poisce spremenljivke in jih spajpa z vrednostmi
+ */
+ public static function dataPiping($text)
+ {
+ // V kolikor imamo vključen modul hierarhija potem uporabimo ustrezno pajpanje za hierarhijo
+ if (SurveyInfo::getInstance()->checkSurveyModule('hierarhija'))
+ return HierarhijaHelper::dataPiping($text, get('anketa'));
+
+
+ Common::getInstance()->Init(get('anketa'));
+
+ return Common::getInstance()->dataPiping($text, get('usr_id'), get('loop_id'), get('lang_id'));
+
+ }
+
+ /**
+ * vrne IP naslov (tudi ce gre preko proxyja)
+ *
+ */
+ public static function remote_address()
+ {
+ return GetIP();
+ }
+
+ /************************************************
+ * Vrnemo ime ankete
+ *
+ * @param $show_page = 1 - ali prikažemo omenjen naslov na spletni strani
+ * @return string
+ ************************************************/
+ public function displayAkronim($show_page = 1)
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ $srv_novaanketa_kratkoime = null;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $survey_hide_title = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hide_title');
+
+ if ($survey_hide_title == 1 /*&& $row['survey_type'] != 0*/)
+ return;
+
+ if (get('lang_id') != null) {
+ if (get('lang_id') != null)
+ $_lang = '_' . get('lang_id');
+ else
+ $_lang = '';
+
+ $srv_novaanketa_kratkoime = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime' . $_lang);
+ }
+
+ if ($show_page == 1 && get('grupa') > 0) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ $grupa = '<span> - ' . $row1['naslov'] . '</span>';
+ } else $grupa = '';
+
+ if ($srv_novaanketa_kratkoime != '')
+ return $srv_novaanketa_kratkoime . $grupa;
+ else
+ return (($row['akronim'] == null || $row['akronim'] == '') ? $row['naslov'] . $grupa : $row['akronim'] . $grupa);
+ }
+
+ /**
+ * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu
+ */
+ public static function getElements($if)
+ {
+ $elements = get('getElements');
+ $anketa = get('anketa');
+
+ if (array_key_exists($if, $elements)) {
+ return $elements[$if];
+ }
+
+ $array = array();
+
+ Cache::cache_all_srv_branching($anketa);
+
+ foreach (Cache::srv_branching_parent($anketa, $if) AS $k => $row) {
+
+ if ($row['element_spr'] > 0)
+ array_push($array, $row['element_spr']);
+ else
+ foreach (self::getElements($row['element_if']) AS $key)
+ array_push($array, $key);
+
+ }
+
+ return save('getElements[' . $if . ']', $array, 1);
+ }
+
+ /**
+ * @desc vrne ce obstaja parent z nastavitvijo horizontal pri blokih da prikazemo vprasanja vodoravno (horizontal==1) ali z razpiranjem (horizontal==2) ce je vklopljena nastavitev
+ */
+ public static function checkParentHorizontal($element){
+
+ Cache::cache_all_srv_branching(get('anketa'));
+
+ $parent = $element['parent'];
+
+ $rowb = Cache::srv_if($element['element_if']);
+ if ($rowb['horizontal'] == 1 || $rowb['horizontal'] == 2) {
+ return $rowb['horizontal'];
+ }
+ elseif ($parent == 0) {
+ return false;
+ }
+ elseif ($parent == 0) {
+ return false;
+ }
+ else {
+ $row = Cache::srv_branching(0, $parent);
+ return self::checkParentHorizontal($row);
+ }
+ }
+
+ public static function getGrupa($spremenljivka)
+ {
+ $grupa = get('getGrupa');
+
+ if (array_key_exists($spremenljivka, $grupa))
+ return $grupa[$spremenljivka];
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ return save('getGrupa[' . $spremenljivka . ']', $row['gru_id'], 1);
+ }
+
+ public static function getDatepickerRange($spremenljivka, $date_element)
+ {
+ # po potrebi pripravimo datum range
+ $row = Cache::srv_spremenljivka($spremenljivka);
+ $newParams = new enkaParameters($row['params']);
+ $min = $newParams->get('date_range_min');
+ $max = $newParams->get('date_range_max');
+ $range_string = null;
+
+ # ce imamo spodnji range
+ $range = ($min != "") ? $min : '-80';
+
+ $range .= ':';
+
+ # ce imamo zgornji range - plus je potrebno dodat posebej
+ if ($max == "")
+ $range .= '+10';
+ else if ($max < 100)
+ $range .= '+' . $max;
+ else
+ $range .= $max;
+
+ # ce imamo nastavljen spodnji ali zgornji range
+ $range_string = "$( \"{$date_element}\" ).datepicker( \"option\", \"yearRange\", \"{$range}\" );";
+
+ // Ce ni danasnji dan v rangu -> moramo posebej nastavit trenutni datum (zaradi jquery buga)
+ if (substr($max, 0, 1) == '-' || substr($min, 0, 1) == '+') {
+ $date = '1.1.' . ((int)date("Y") + (int)$min);
+ $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"defaultDate\", \"{$date}\" );";
+ } elseif ($min > date("Y") || $max < date("Y")) {
+ $date = '1.1.' . $min;
+ $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"defaultDate\", \"{$date}\" );";
+ }
+
+ // dodamo se, da je prvi dan v tednu ponedeljek
+ $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"firstDay\", 1 );";
+
+ # nastavimo datumski range
+ echo $range_string;
+ }
+
+ public static function getCustomCheckbox()
+ {
+
+ //ID skin_profile
+ $skin_id = SurveyInfo::getInstance()->getSurveyRow()['skin_profile'];
+
+ //srv_theme_editor -> velikost PC/mobilne ikone
+ $type = 7;
+
+ if (get('mobile') > 0)
+ $type = 8; //če gre za mobilnik ali tablico potem pridobimo ustrezne ikone za tole
+
+ $sql = sisplet_query("SELECT value FROM srv_theme_editor WHERE profile_id = '$skin_id' AND id='7' AND type='$type'");
+ $row = mysqli_fetch_array($sql);
+ if (!$row || empty($row) || is_null($row))
+ return 0;
+
+ return $row['value']; //vrnemo velikost custom radio/checkboxa
+ }
+
+ /**
+ * @desc poslje alerte o izpolnjeni anketi
+ */
+ public function alert()
+ {
+ global $site_path;
+
+ # kadar popravljamo obstoječe podatke ne pošiljamo več obvestil o končani anketi (Ajda)
+ if ($_GET['urejanje'] == 1) {
+ return;
+ }
+
+ // Ce smo v predogledu ali testiranju ne posiljamo obvestila
+ if ($_GET['preview'] == 'on') {
+ return;
+ }
+
+ // Preverimo ce imamo ustrezen paket kjer je na voljo obvescanje
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ if (!$userAccess->checkUserAccess($what='alert')){
+ return;
+ }
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'");
+ $rowAlert = mysqli_fetch_array($sqlAlert);
+
+ // array z emaili
+ $emails = array();
+ # TODO
+ # dodat tabelo, z emaili, za userje cms-ja če bi se želeli odjavit od obveščanja posamezne ankete
+ # ker sedaj nimamo povezave na njihov eemaile in se ne morejo odjaviti
+ # not bi blo fajn dat: anketa_id, email, code (kodo za preverjanje istovetnosti)
+ # in potem če klikne na link odjaviti in skopirati v tabelo: srv_survey_unsubscribe, da se uporabniku ne pošilja več
+
+ $ime = '';
+
+ // alert Avtorja in ostalih v dostopu
+ if ($rowAlert['finish_author'] == 1) {
+ $sqlInsertUID = Model::db_select_user($row['insert_uid']);
+ $rowInsertUID = mysqli_fetch_array($sqlInsertUID);
+
+
+ // polovimo se avtorje katerim je omogocen dostop in imajo nastavljeno da dobivajo obvestila - po novem med njimi ni nujno glavni avtor ankete
+ $sqlAlertAuthors = sisplet_query("SELECT u.email, u.id FROM users as u "
+ . " RIGHT JOIN (SELECT sd.uid, sd.alert_complete FROM srv_dostop as sd WHERE sd.ank_id='" . get('anketa') . "' AND sd.alert_complete = '1') AS dostop ON u.id = dostop.uid");
+ while ($rowAlertAuthors = mysqli_fetch_assoc($sqlAlertAuthors)) {
+
+ $sql1 = sisplet_query("SELECT alert_complete_if, uid AS id FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . $rowAlertAuthors['id'] . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ # kodo preberemo iz srv_users
+ $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND user_id = '" . $rowAlertAuthors['id'] . "'";
+ $c2q = sisplet_query($c2s);
+ list($c2) = mysqli_fetch_row($c2q);
+ # nastavimo password če še ni
+ $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND user_id = '" . $rowAlertAuthors['id'] . "' AND pass IS NULL";
+ $qrySqlUpd = sisplet_query($strSqlUpd);
+
+ // ce imamo if na posiljanje mailov
+ if ($row1['alert_complete_if'] > 0) {
+ if (Check::getInstance()->checkIf($row1['alert_complete_if'])) {
+ $emails[] = array('mail' => $rowAlertAuthors['email'], 'type' => 'author', 'uid' => $rowAlertAuthors['id']);
+ }
+ } else {
+ $emails[] = array('mail' => $rowAlertAuthors['email'], 'type' => 'author', 'uid' => $rowAlertAuthors['id']);
+ }
+ }
+ }
+ // alert respondenta (ki vpise svoj mail ob izpolnjevanju)
+ if ($rowAlert['finish_respondent'] == 1) {
+ // email
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='email' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sql11 = sisplet_query("SELECT finish_respondent_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'");
+ $row11 = mysqli_fetch_array($sql11);
+
+ # kodo preberemo iz srv_users
+ $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "'";
+ $c2q = sisplet_query($c2s);
+ list($c2) = mysqli_fetch_row($c2q);
+ # nastavimo password če še ni
+ $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "' AND pass IS NULL";
+ $qrySqlUpd = sisplet_query($strSqlUpd);
+
+ // Ce resujemo anketo v drugem jeziku pogledamo ce imamo nastavljen custom mail za tuje jezike
+ $sql_ac = sisplet_query("SELECT * FROM srv_alert_custom WHERE ank_id='" . get('anketa') . "' AND type='respondent_lang_" . get('lang_id') . "' AND uid='0'");
+ if (mysqli_num_rows($sql_ac) > 0) {
+ $row_ac = mysqli_fetch_array($sql_ac);
+ $emails[] = array('mail' => $row2['text'], 'type' => $row_ac['type'], 'uid' => '0', 'code' => $c2);
+ } // ce imamo if na posiljanje mailov
+ elseif ($row11['finish_respondent_if'] > 0) {
+ if (Check::getInstance()->checkIf($row11['finish_respondent_if'])) {
+ $emails[] = array('mail' => $row2['text'], 'type' => 'respondent', 'uid' => '0', 'code' => $c2);
+ }
+ } else {
+ $emails[] = array('mail' => $row2['text'], 'type' => 'respondent', 'uid' => '0', 'code' => $c2);
+ }
+
+ // ime
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='ime' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $ime = $row2['text'];
+
+ }
+
+ // alert respondenta prepoznanega iz sispleta
+ if ($rowAlert['finish_respondent_cms'] == 1) {
+ $sql1 = Model::db_select_user(self::$global_user_id);
+ $row1 = mysqli_fetch_array($sql1);
+
+ if ($row1['email'] != '') {
+
+ $sql11 = sisplet_query("SELECT finish_respondent_cms_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'");
+ $row11 = mysqli_fetch_array($sql11);
+
+ # kodo preberemo iz srv_users
+ $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND user_id = '" . get('usr_id') . "'";
+ $c2q = sisplet_query($c2s);
+ list($c2) = mysqli_fetch_row($c2q);
+
+ $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND user_id = '" . get('usr_id') . "' AND pass IS NULL";
+ $qrySqlUpd = sisplet_query($strSqlUpd);
+
+ // ce imamo if na posiljanje mailov
+ if ($row11['finish_respondent_cms_if'] > 0) {
+ if (Check::getInstance()->checkIf($row11['finish_respondent_cms_if'])) {
+ $emails[] = array('mail' => $row1['email'], 'type' => 'respondent_cms', 'uid' => '0', 'code' => $c2);
+ }
+ } else {
+ $emails[] = array('mail' => $row1['email'], 'type' => 'respondent_cms', 'uid' => '0', 'code' => $c2);
+ }
+
+ }
+
+ }
+
+ // alert na ostale maile
+ if ($rowAlert['finish_other'] == 1) {
+
+ $email = explode("\n", str_replace("\r", "", str_replace(",", "\r\n", str_replace(" ", "", $rowAlert['finish_other_emails']))));
+ if (count($email) > 0)
+ foreach ($email AS $mail) {
+
+ $sql11 = sisplet_query("SELECT finish_other_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'");
+ $row11 = mysqli_fetch_array($sql11);
+
+ // ce imamo if na posiljanje mailov
+ if ($row11['finish_other_if'] > 0) {
+ if (Check::getInstance()->checkIf($row11['finish_other_if'])) {
+ $emails[] = array('mail' => $mail, 'type' => 'other', 'uid' => '0');
+ }
+ } else {
+ $emails[] = array('mail' => $mail, 'type' => 'other', 'uid' => '0');
+ }
+ }
+ }
+
+ // sestavimo sporocilo
+ if ($row['finish_respondent_cms'] == 1) {
+ $sql1 = Model::db_select_user(self::$global_user_id);
+ $row1 = mysqli_fetch_array($sql1);
+ $ime = '' . $row1['name'] . ' ' . $row1['surname'];
+ }
+
+ # meta_url
+ $sql_meta_strings = "SELECT referer FROM srv_user where ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "'";
+ $sql_meta_query = sisplet_query($sql_meta_strings);
+ list($meta_url) = mysqli_fetch_row($sql_meta_query);
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+
+ $text = ($rowAlert['finish_text'] == '') ? '[NAME] ' . self::$lang['srv_alert_msg'] . ' [SURVEY] [DATE] ("[URL]")'.$signature : $rowAlert['finish_text'];
+ $subject = ($rowAlert['finish_subject'] != '') ? $rowAlert['finish_subject'] : self::$lang['srv_alert_subject'];
+
+ $sqlu = sisplet_query("SELECT email FROM users WHERE id = '$row[insert_uid]'");
+ $rowu = mysqli_fetch_array($sqlu);
+ $MailReply = $rowu['email'];
+
+ if ($rowAlert['reply_to'] != '') $MailReply = $rowAlert['reply_to'];
+
+ // preprečimo večkratno pošiljanje na iste naslove
+ array_unique($emails);
+
+ # preverimo odjavljenost od prejemanja obvestil
+ $su = new SurveyUnsubscribe(get('anketa'));
+
+ // posljemo maile
+ foreach ($emails AS $mail_list) {
+ $mail = trim($mail_list['mail']);
+ $unsubscribed = $su->isUnsubscribedEmail($mail);
+
+
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(
+ serialize(
+ array('a' => 'pdf_results',
+ 'anketa' => get('anketa'),
+ 'usr_id' => get('usr_id'),
+ 'type' => '0',
+ 'pdf_usr_type' => $mail_list['type'],
+ 'pdf_usr_id' => $mail_list['uid']
+ )));
+
+ $rtf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(
+ serialize(
+ array('a' => 'rtf_results',
+ 'anketa' => get('anketa'),
+ 'b' => 'export',
+ 'usr_id' => get('usr_id'),
+ 'pdf_usr_type' => $mail_list['type'],
+ 'pdf_usr_id' => $mail_list['uid']
+ )));
+
+
+ if ($mail != '' && $unsubscribed == false && (strlen($mail) > 1)) {
+
+ $sql_ac = sisplet_query("SELECT subject, text FROM srv_alert_custom WHERE ank_id='" . get('anketa') . "' AND type='{$mail_list['type']}' AND uid='{$mail_list['uid']}'");
+ if (mysqli_num_rows($sql_ac) > 0) {
+ $row_ac = mysqli_fetch_array($sql_ac);
+ $s = $row_ac['subject'];
+ $t = $row_ac['text'];
+ } else {
+ $s = $subject;
+ $t = $text;
+ }
+ // naredimo še data piping za odgovore
+ $t = Helper::dataPiping($t);
+
+ #zamenjamo morebitne sistemske variable
+ $t = str_replace(
+ array('[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[RTF]',
+ '[META_REFERER_URL]',
+ '[DURATION]'
+ ),
+ array($ime,
+ $row['akronim'], #$row['naslov'],
+ date("d.m.Y, H:i:s"),
+ //'<a href="'.self::$site_url.'a/'.get('anketa').'">'.self::$site_url.'a/'.get('anketa').'</a>',
+ '<a href="' . SurveyInfo::getSurveyLink() . '">' . SurveyInfo::getSurveyLink() . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '</a>',
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . $rtf_url . '">' . self::$lang['srv_alert_link_rtf'] . '</a>',
+ '<a href="' . $meta_url . '">' . $meta_url . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'
+ ),
+ $t);
+
+ $s = str_replace(
+ array('[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[RTF]',
+ '[DURATION]'),
+ array($ime,
+ $row['naslov'],
+ date("d.m.Y, H:i:s"),
+ //self::$site_url.'a/'.get('anketa'),
+ SurveyInfo::getSurveyLink(),
+ self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa'),
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . $rtf_url . '">' . self::$lang['srv_alert_link_rtf'] . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'),
+ $s);
+
+ if ($mail_list['code'] == null || trim($mail_list['code']) == '') {
+ # v tabelo srv_survey_unsubscribe_codes dodamo email in kodo za možnost odjave od obveščanja
+ $uc = $su->generateCodeForEmail($mail);
+ $unsubscribe = self::$site_url . 'admin/survey/unsubscribe.php?anketa=' . get('anketa') . '&uc=' . $uc . '&em=' . base64_encode($mail);
+ } else {
+ $unsubscribe = self::$site_url . 'admin/survey/unsubscribe.php?anketa=' . get('anketa') . '&code=' . $mail_list['code'];
+ }
+
+ $t = str_replace(
+ array('#UNSUBSCRIBE#', '[UNSUBSCRIBE]'),
+ array('<a href="' . $unsubscribe . '">' . self::$lang['user_bye_hl'] . '</a>',
+ '<a href="' . $unsubscribe . '">' . self::$lang['user_bye_hl'] . '</a>',)
+ , $t);
+
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+
+ // Shranimo email from in reply to (da ju potem nazaj nastavimo - drugace povozimo nastavitve od vabil)
+ $mailFromBCK = $MA->getMailFrom();
+ $mailReplyToBCK = $MA->getMailReplyTo();
+
+ // Nastavimo na raziskave - obvescanje je iz raziskave@1ka.si ce se ni nastavljeno posebej v smtp nastavitvah
+ $MA->setMailReplyTo($MailReply);
+ if ($mailFromBCK == '' || $mailFromBCK == 'info@1ka.si')
+ $MA->setMailFrom('raziskave@1ka.si');
+
+ // Posljemo mail
+ $result = $MA->sendMail(stripslashes($t), $s);
+
+ // Nazaj nastavimo posiljatelja (za nastavitve v vabilih)
+ $MA->setMailReplyTo($mailReplyToBCK);
+ $MA->setMailFrom($mailFromBCK);
+ } catch (Exception $e) {
+ }
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * @desc poslje alert o dosezeni kvoti za evoli - team meter
+ */
+ public function alertTeamMeter()
+ {
+ global $site_path;
+
+ # kadar popravljamo obstoječe podatke ne pošiljamo več obvestil o končani anketi (Ajda)
+ if ($_GET['urejanje'] == 1) {
+ return;
+ }
+
+ // Ce smo v predogledu ali testiranju ne posiljamo obvestila
+ if ($_GET['preview'] == 'on') {
+ return;
+ }
+
+
+ // Preverimo ce smo dosegli kvoto
+ $sqlGroupTM = sisplet_query("SELECT d.vre_id FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='" . get('anketa') . "' AND d.usr_id='" . get('usr_id') . "' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ $sqlTM = sisplet_query("SELECT tm.*, v.vrstni_red AS skupina FROM srv_evoli_teammeter tm, srv_vrednost v
+ WHERE tm.ank_id='" . get('anketa') . "' AND tm.skupina_id='" . $rowGroupTM['vre_id'] . "' AND tm.skupina_id=v.id");
+ $rowTM = mysqli_fetch_array($sqlTM);
+
+ // Preverimo ce smo slucajno ze posiljali porocilo
+ $datum_posiljanja = $rowTM['datum_posiljanja'];
+
+ // Kvota je dosezena - POSLJEMO OBVESTILO
+ if ($rowTM['kvota_max'] == $rowTM['kvota_val'] && $datum_posiljanja == '0000-00-00 00:00:00') {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'");
+ $rowAlert = mysqli_fetch_array($sqlAlert);
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+
+ $text = ($rowAlert['finish_text'] == '') ? '[NAME] ' . self::$lang['srv_alert_msg'] . ' [SURVEY] [DATE] ("[URL]")'.$signature : $rowAlert['finish_text'];
+ $subject = ($rowAlert['finish_subject'] != '') ? $rowAlert['finish_subject'] : self::$lang['srv_alert_subject'];
+
+ $MailReply = $rowTM['email'];
+
+ if ($rowAlert['reply_to'] != '') $MailReply = $rowAlert['reply_to'];
+
+ // Mail posljemo avtorju skupine (podjetja)
+ $mail = $rowTM['email'];
+
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(
+ serialize(
+ array('m' => 'pdf_teammeter',
+ 'anketa' => get('anketa'),
+ 'skupina' => $rowTM['skupina']
+ )));
+
+ if ($mail != '' && (strlen($mail) > 1)) {
+
+ $s = $subject;
+ $t = $text;
+
+ // naredimo še data piping za odgovore
+ $t = Helper::dataPiping($t);
+
+ #zamenjamo morebitne sistemske variable
+ $t = str_replace(
+ array(
+ '[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[DURATION]'
+ ),
+ array(
+ $ime,
+ $row['akronim'], #$row['naslov'],
+ date("d.m.Y, H:i:s"),
+ '<a href="' . SurveyInfo::getSurveyLink() . '">' . SurveyInfo::getSurveyLink() . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '</a>',
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'
+ ),
+ $t);
+
+ $s = str_replace(
+ array(
+ '[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[DURATION]'
+ ),
+ array(
+ $ime,
+ $row['naslov'],
+ date("d.m.Y, H:i:s"),
+ SurveyInfo::getSurveyLink(),
+ self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa'),
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'
+ ),
+ $s);
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+
+ // Shranimo email from in reply to (da ju potem nazaj nastavimo - drugace povozimo nastavitve od vabil)
+ $mailFromBCK = $MA->getMailFrom();
+ $mailReplyToBCK = $MA->getMailReplyTo();
+
+ // Nastavimo na raziskave - obvescanje je iz raziskave@1ka.si ce se ni nastavljeno posebej v smtp nastavitvah
+ $MA->setMailReplyTo($MailReply);
+ if ($mailFromBCK == '' || $mailFromBCK == 'info@1ka.si')
+ $MA->setMailFrom('raziskave@1ka.si');
+
+ // Posljemo mail
+ $result = $MA->sendMail(stripslashes($t), $s);
+
+ // Nazaj nastavimo posiljatelja (za nastavitve v vabilih)
+ $MA->setMailReplyTo($mailReplyToBCK);
+ $MA->setMailFrom($mailFromBCK);
+ }
+ catch (Exception $e) {
+ }
+
+ // Updatamo timestamp posiljanja
+ $sql = sisplet_query("UPDATE srv_evoli_teammeter SET datum_posiljanja=NOW() WHERE id='".$rowTM['id']."'");
+ }
+ }
+
+ return;
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/InitClass.php b/main/survey/app/Controllers/InitClass.php
new file mode 100644
index 0000000..f0c7dc9
--- /dev/null
+++ b/main/survey/app/Controllers/InitClass.php
@@ -0,0 +1,1230 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 04.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\BodyController as Body;
+use App\Controllers\CheckController as Check;
+use App\Controllers\DisplayController as Display;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use App\Models\SaveSurvey;
+use Common;
+use Mobile_Detect;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use GDPR;
+use MAZA;
+use UserAccess;
+
+
+class InitClass extends Controller
+{
+ protected $get;
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+
+ //inicializiramo $variable v $this, da jih lažje prikličemo
+ parent::getAllVariables();
+
+ if (!get('printPreview')) {
+ return $this->loadIfPrintPreviewFalse();
+ } else {
+ return $this->loadIfPrintPreviewTrue();
+ }
+ }
+
+ /************************************************
+ * Print preview je izključen
+ ************************************************/
+ private function loadIfPrintPreviewFalse()
+ {
+ // cist na zacetku preverimo referer. Ce je prisel od kje drugje (napacno skopiran link itd...) ga preusmerimo na prvo stran ankete
+ if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], self::$site_url) === false && !isset($_GET['code']) && !isset($_GET['return']) && !isset($_GET['params'])) {
+
+ $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!"));
+ save('anketa', $anketa);
+
+ // Pri ul evalvaciji tega ne pustimo, ker drugace narobe preusmeri
+ if (Common::checkModule('evalvacija') == '0') {
+
+ // to more bit, ker zgleda da pri redirectu browser ne nastavi novega refererja... (tudi websm anketa ne rabi tega - vedno mora skocit na ustrezno stran)
+ if ($_COOKIE['ref'] != get('anketa') && !(get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1')) {
+
+ // prenesemo sistemske spremenljivke, ki so podane preko URLja
+ $sql1 = sisplet_query("SELECT s.id, s.variable FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND s.sistem='1' AND (s.tip='4' OR s.tip='21' OR s.tip='1')");
+ $g = '';
+ while ($row1 = mysqli_fetch_array($sql1))
+ if (isset($_GET[$row1['variable']])) $g .= '&' . $row1['variable'] . '=' . $_GET[$row1['variable']];
+
+ $g .= Header::getSurveyParams();
+
+ //$redirect_url = self::$site_url."a/".get('anketa').$g;
+ $redirect_url = SurveyInfo::getSurveyLink(false, false) . $g;
+ $request_url = 'http' . ($_SERVER['HTTPS'] ? 's' : null) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+
+ if ($redirect_url != $request_url) { // to je extra check, da pridejo skozi in se ne vrtijo v neskoncni zanki tudi ljudje (paranoiki :) ) brez cookiejev
+ setcookie('ref', get('anketa')); // cookie z referalom
+
+ header("Location: " . $redirect_url);
+ die();
+ }
+ }
+ }
+ }
+
+ // ce se je vrnil na anketo preko URLja
+ if (isset($_GET['return'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ if (isset($_GET['anketa']) || isset($_POST['anketa'])) {
+
+ $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!"));
+ save('anketa', $anketa);
+
+ // Preverimo ce gre za POSEBNO webSM anketo (ki ne shranjuje nicesar - samo direktno preusmeri na ustrezno stran)
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1')
+ $this->jeWebSMSurvey();
+
+ // polovimo podatke o anketi
+ SurveyInfo::getInstance()->SurveyInit(get('anketa'));
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
+ save('db_table', '_active');
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // Ce anketa sploh ne obstaja
+ if (!$rowa) {
+ Display::getInstance()->displayNapaka(self::$lang['no_survey']);
+ die();
+ }
+
+ // Ce nima dostopa do ankete
+ if (!((self::$admin_type <= $rowa['odgovarja'] && self::$admin_type >= 0) || ($rowa['odgovarja'] == 4))) {
+ Display::getInstance()->displayNapaka(self::$lang['no_access']);
+ die();
+ }
+
+
+ // pretecena anketa, kontroliramo datum na: starts in expire
+ $stringe = "SELECT id , CURDATE(), starts, expire FROM srv_anketa WHERE id='" . get('anketa') . "' AND starts <= CURDATE() AND expire >= CURDATE()";
+ $sqle = sisplet_query($stringe);
+
+ // Tudi ce je zakljucena pustimo prikaz pri nastavljenem glas_end -> preklop arhiva statistike pri glasovanju - drugace izpisemo obvestilo o zakljucku
+ if (!(isset($_GET['preview']) && $_GET['preview'] == 'on') && ($rowa['active'] < 1 or mysqli_num_rows($sqle) == 0) && (!isset($_GET['glas_end']) && (!isset($_GET['urejanje']))))
+ $this->anketaEnd($rowa);
+
+
+ // Preverimo ce je nastavljen staticen uvod (ki ne belezi nicesar) - da se pri embeddanih anketah ne shranjujejo vsi obiskovalci ampak se user ustvari sele na prvi strani po uvodu
+ if ($rowa['intro_static'] > 0 && $rowa['show_intro'] == 1 && count($_POST) == 0 && !isset($_GET['grupa'])) {
+
+ // inicializiramo jezik za multilang anketo
+ Language::getInstance()->multilang_init();
+
+ // konec ukvarjanja s cookieji, prikazemo header
+ Header::getInstance()->header();
+
+ Body::getInstance()->displayStaticIntroduction();
+ die();
+ } // Ce imamo staticen uvod s captcho in smo kliknili na naslednjo stran, najprej preverimo captcho
+ elseif ($rowa['intro_static'] == 2 && $rowa['show_intro'] == 1 && count($_POST) != 0 && isset($_GET['grupa']) && $_GET['grupa'] == '0') {
+ Check::getInstance()->check_captcha_intro();
+ }
+
+
+ // ali je respondent avtor ankete (zaradi posebnih opcij prepoznave)
+ $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'");
+ if (mysqli_num_rows($sqlUserAutor) > 0)
+ save('userAutor', true);
+
+ // Ce imamo nastavljeno da vedno zahtevamo kodo
+ if (isset($_GET['code']) && $rowa['usercode_required'] == 1) {
+ unset($_GET['code']);
+ }
+
+ // pogledamo na kolk je nastavljen expire za cookie v nastavitvi ankete
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ save('cookie_expire', $row['cookie']);
+
+ if ($row['cookie'] == 0) {
+ $this->expire = 0;
+ } elseif ($row['cookie'] == -1) {
+ if ($rowa['user_from_cms'] == 1) {
+ $this->expire = time() - 3600;
+ } else {
+ $this->expire = 0;
+ }
+ } elseif ($row['cookie'] == 1) {
+ $this->expire = time() + 3600;
+ } else {
+ $this->expire = time() + 2500000;
+ }
+
+ // Preberimo cookie stringiii
+ $this->cookie = null;
+
+ // da delata oba načina nastavljanja piškotkov, neglede na nastavitve
+ if (isset($_GET['survey-' . get('anketa')]))
+ $this->cookie = $_GET['survey-' . get('anketa')]; // Pri nastavitvi brez cookie-ja se cookie string prenaša preko URL-ja
+ if (isset($_COOKIE['survey-' . get('anketa')]))
+ $this->cookie = $_COOKIE['survey-' . get('anketa')]; // Obicajen cookie
+
+
+ // EVALVACIJA - Ce je nov respondent preverimo ce se je vrnil (zapis v tabeli eval_data_userCookie) in mu nastavimo ustrezen cookie da ga preusmerimo na ustrezno stran
+ if (Common::checkModule('evalvacija') == '1' && $this->cookie == null)
+ $this->cookie = $this->evlavacijaNovRespondent();
+
+ // HIERARHIJA - UČITELJ, preverimo, če je učitelj ponovno prišel nazaj
+ if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2 && is_null($this->cookie))
+ $this->cookie = $this->hierarhijaPreveriCeSeJeUciteljVrnilPonovnoResevatiAnketo();
+
+ // poskrbimo za user ID
+ //
+ // tuki je kookie ze nastavljen in ga samo preberemo
+ if ($this->cookie != null)
+ $this->cookieExist($this->cookie);
+
+ // kukija se ni, ga bomo pa nastavil
+ if ($this->cookie == null)
+ $this->cookieIsNull();
+
+
+ // tukaj bomo dodatno preverjali, ce slucajno kje&kdaj pride do napake da usr_id ni postavljen
+ if (get('usr_id') == 0) {
+ $get = '';
+ foreach ($_GET AS $key => $val) {
+ if ($get != '')
+ $get .= ', ';
+ $get .= $key . ': "' . $val . '"';
+ }
+
+ $post = '';
+ foreach ($_POST AS $key => $val) {
+ if ($post != '')
+ $post .= ', ';
+ $post .= $key . ': "' . $val . '"';
+ }
+ $kuki = '';
+ foreach ($_COOKIE AS $key => $val) {
+ if ($kuki != '')
+ $kuki .= ', ';
+ $kuki .= $key . ': "' . $val . '"';
+ }
+ $text = 'GET: ' . $get . '; POST: ' . $post . '; COOKIE: ' . $kuki;
+
+ $sql_log = sisplet_query("SELECT value FROM srv_survey_misc WHERE sid = '" . get('anketa') . "' AND what = 'usr_id_error'");
+ $row_log = mysqli_fetch_array($sql_log);
+ $text = $row_log['value'] . "\n" . $text;
+
+ sisplet_query("REPLACE INTO srv_survey_misc (sid, what, value) VALUES ('" . get('anketa') . "', 'usr_id_error', '" . $text . "')");
+ }
+
+ // inicializiramo jezik za multilang anketo
+ Language::getInstance()->multilang_init();
+
+ // konec ukvarjanja s cookieji, prikazemo header
+ Header::getInstance()->header();
+
+ //prikaz konca ankete - posebej statistika pri glasovanju
+ if (isset($_GET['glas_end'])) {
+
+ Body::getInstance()->displayKonecGlasovanje();
+
+ } else {
+ if (isset($_GET['loop_id'])) save('loop_id', $_GET['loop_id']);
+
+ // nismo se poslali kaksno stran z odgovori
+ if (count($_POST) == 0) {
+
+ // Preverimo kvoto pri Evoli Team Meter
+ if (SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ ) {
+
+ // Ce imamo nastavljeno skupino
+ if (isset($_GET['skupina'])) {
+
+ $skupina_id = $_GET['skupina'];
+
+ $sqlGroupTM = sisplet_query("SELECT kvota_val, kvota_max, date_to FROM srv_evoli_teammeter WHERE ank_id='" . get('anketa') . "' AND skupina_id='" . $skupina_id . "'");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ // Ce je kvota ze dosezena
+ if ($rowGroupTM['kvota_val'] >= $rowGroupTM['kvota_max']) {
+ Body::getInstance()->displayKonecEvoliTM();
+ die();
+ }
+
+ // Ce je datum ze presezen
+ if (strtotime($rowGroupTM['date_to']) < time() - (60 * 60 * 24)) {
+ $date_to = date('d.m.Y', strtotime($rowGroupTM['date_to']));
+ Body::getInstance()->displayKonecEvoliTM($date_to);
+ die();
+ }
+ }
+ }
+
+ if (isset($_GET['grupa']))
+ save('grupa', $_GET['grupa']);
+
+ if ($rowa['show_intro'] == 0 && !isset($_GET['grupa'])) {
+ $this->set_userstatus(3);
+ SaveSurvey::saveSistemske();
+ save('grupa', Find::getInstance()->findNextGrupa());
+ }
+
+ if (get('grupa') == 'end') {
+ $this->set_userstatus(6);
+
+ Body::getInstance()->displayKonec();
+
+ }
+ elseif (get('displayAllPages')) {
+
+ Body::getInstance()->displayAllPages();
+
+
+ }
+ // prikazemo ustrezno stran / grupo
+ elseif (get('grupa') > 0) {
+
+ $preskok = false;
+
+ // pogledamo ce preskocimo kaksno stran zaradi branchinga
+ while (!Check::getInstance()->checkGrupa() && get('grupa') > 0 && $_GET['disableif'] != 1) {
+
+ SaveSurvey::getInstance()->posted(1);
+ save('grupa', Find::getInstance()->findNextGrupa());
+ $preskok = true;
+ }
+
+ if ($preskok) SaveSurvey::getInstance()->posted_commit(); // pri preskokih se ne shranjuje sproti v bazo, ampak na koncu, vse naenkrat
+
+ if (get('grupa') > 0) {
+ Body::getInstance()->displayAnketa();
+ } else {
+ $this->set_userstatus(6);
+ Body::getInstance()->displayKonec();
+ }
+
+ // prikazemo uvodni nagovor - introduction
+ } else {
+
+ // nastavimo status -- kliknil je na anketo
+ $this->set_userstatus(3);
+
+ Body::getInstance()->displayIntroduction();
+ }
+ }
+ // poslani so bili odgovori
+ else {
+
+ save('grupa', $_GET['grupa']);
+
+ // Preverimo ce gre za gdpr anketo in ce je sprejel pogoje za sodelovanje
+ if(GDPR::isGDPRSurveyTemplate(get('anketa'))){
+
+ // Ni sprejel pogojev za sodelovanje - vrzemo na zakljucek
+ if(isset($_POST['gdpr']) && $_POST['gdpr_accept'] == '0'){
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ // Ni oznacil ali sprejema pogoje
+ elseif(isset($_POST['gdpr']) && !isset($_POST['gdpr_accept'])){
+ Body::getInstance()->displayIntroduction();
+ die();
+ }
+ }
+
+ if (get('grupa') == 'end') {
+ $this->set_userstatus(6);
+
+ Body::getInstance()->displayKonec();
+
+ }
+ else {
+ // ce je nastavljena grupa (se pravi ni prva stran) in ce nismo v predogledu ankete
+ if (get('grupa') > 0 || get('displayAllPages')) {
+ // nastavimo status -- izpolnjuje anketo
+ $this->set_userstatus(5);
+
+ // shrani poslano stran v bazo
+ SaveSurvey::getInstance()->posted();
+
+ } else { // prva stran z vprasanji
+
+ $s = sisplet_query("REPLACE INTO srv_user_grupa" . get('db_table') . " (gru_id, usr_id, time_edit) VALUES ('0', '" . get('usr_id') . "', NOW())");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ $this->set_userstatus(4);
+ }
+
+ if (get('loop_AW') == 0 && get('loop_id') == null) {
+ $grupa = Find::getInstance()->findNextGrupa();
+ }
+ elseif (get('loop_AW') == 1) {
+ $grupa = get('grupa');
+ }
+ elseif (get('loop_id') != null) {
+ $grupa = get('grupa');
+ save('loop_id', Find::getInstance()->findNextLoopId(), 1);
+ if (get('loop_id') == null)
+ $grupa = Find::getInstance()->findNextGrupa();
+ }
+
+ if (get('displayAllPages')) {
+
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ if(Common::checkModule('gorenje'))
+ echo ' document.location.href=\'https://surveys.gorenje.com/\';' . "\n";
+ else
+ echo ' document.location.href=\'https://www.1ka.si/\';' . "\n";
+ echo ' </script>' . "\n";
+
+ }
+ elseif ($grupa > 0) {
+
+ save('grupa', $grupa);
+
+ if (get('loop_AW') == 0 && get('loop_id') == null)
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . Header::getSurveyParams() . get('cookie_url') . '');
+ elseif (get('loop_AW') == 1)
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&ime=' . get('ime_AW') . Header::getSurveyParams() . get('cookie_url') . '');
+ elseif (get('loop_id') != null)
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&loop_id=' . get('loop_id') . Header::getSurveyParams() . get('cookie_url') . '');
+
+ }
+ else {
+
+ // nastavimo status -- anketo je izpolnil do konca
+ $this->set_userstatus(6);
+
+ //prikaz konca ankete - pri glasovanju izpisujemo posebej zakljucek in statistiko
+ if ($rowa['survey_type'] == 0) {
+ Body::getInstance()->displayKonecGlasovanje();
+ } else {
+ Body::getInstance()->displayKonec();
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ // prisli smo cez vse silne procedure in redirecte, lahko pobrisemo cookie za referer, ker ga (upam) ne rabimo vec
+ setcookie('ref', '', time() - 5000); // pobrisemo cookie
+ }
+
+ /**
+ * Preverimo, če učitelj rešuje anketo in če že ima usr_id shranjen v bazi ali ga še ni
+ *
+ * @return mixed $cookie
+ */
+ private function hierarhijaPreveriCeSeJeUciteljVrnilPonovnoResevatiAnketo()
+ {
+ $url = base64_decode(urldecode($this->get->enc));
+
+ $cookie = sisplet_query("SELECT su.cookie AS cookie FROM srv_hierarhija_koda AS shk LEFT JOIN srv_user AS su ON (shk.srv_user_id = su.id) WHERE url='" . $url . "'", "obj")->cookie;
+ return $cookie;
+ }
+
+ /************************************************
+ * Naložimo v kolikor imamo vkloplje print preview TRUE
+ ************************************************/
+ private function loadIfPrintPreviewTrue()
+ {
+ $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!"));
+ if (get('anketa') != $anketa)
+ save('anketa', $anketa);
+
+ // polovimo podatke o anketi
+ \SurveyInfo::getInstance()->SurveyInit(get('anketa'));
+ if (\SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
+ save('db_table', '_active');
+
+ \SurveySetting::getInstance()->Init(get('anketa'));
+ save('usr_id', $_REQUEST['usr_id']);
+
+ Language::getInstance()->multilang_init();
+ }
+
+
+ /************************************************
+ * Če gre za posebno testno anketo WebSMSruvey
+ ************************************************/
+ private function jeWebSMSurvey()
+ {
+
+ // inicializiramo jezik za multilang anketo
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu)
+ $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'");
+ $rowl = mysqli_fetch_array($sqll);
+ save('lang_id', $rowl['lang_id']);
+ } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani)
+ save('lang_id', $_POST['language']);
+ }
+ if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik
+ $_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja)
+ // get('lang_id') mora se vedno ostati null !
+ } else { // zamenjamo jezik
+ $file = lang_path(get('lang_id'));
+ if (@include($file))
+ $_SESSION['langX'] = lang_path(get('lang_id'), 1);
+ }
+
+ // prikazemo header
+ Header::getInstance()->header();
+
+ if (!isset($_GET['grupa'])) {
+
+ if ($row['show_intro'] == 1) {
+ Body::getInstance()->displayIntroduction();
+ } else {
+ $grupa = save('grupa', Find::getInstance()->findNextGrupa(), 1);
+
+ if ($grupa > 0) {
+ if (isset($_GET['language']))
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&language=' . $_GET['language'] . '');
+ else
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '');
+ } else {
+ Body::getInstance()->displayKonec();
+ }
+ }
+ } else {
+ save('grupa', $_GET['grupa']);
+
+ // pogledamo ce preskocimo kaksno stran zaradi branchinga
+ while (!Check::getInstance()->checkGrupa() && get('grupa') > 0 && $_GET['disableif'] != 1) {
+ save('grupa', Find::getInstance()->findNextGrupa());
+ }
+
+ // nismo se poslali kaksno stran z odgovori
+ if (count($_POST) == 0) {
+ if (get('grupa') > 0)
+ Body::getInstance()->displayAnketa();
+ else
+ Body::getInstance()->displayKonec();
+ } // poslani so bili odgovori
+ else {
+ $grupa = Find::getInstance()->findNextGrupa();
+ save('grupa', $grupa, 1);
+
+ if ($grupa > 0) {
+ if (isset($_GET['language']))
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&language=' . $_GET['language'] . '');
+ else
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '');
+ } else {
+ Body::getInstance()->displayKonec();
+ }
+ }
+ }
+
+ die();
+ }
+
+ /************************************************
+ * Tudi ce je zakljucena pustimo prikaz pri nastavljenem glas_end -> preklop arhiva statistike pri glasovanju - drugače izpišemo obvestilo o zaključku
+ ************************************************/
+ private function anketaEnd($rowa)
+ {
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ SurveySetting::getInstance()->init(get('anketa'));
+
+ if ($rowa['active'] > 0) {
+
+ // preverimo začetek in konec
+ $sqlDates = sisplet_query("SELECT id, starts, expire, (IF(CURDATE() >= starts, true, false)) as boolStarts, (IF(CURDATE() <= expire, true, false)) as boolExpire FROM srv_anketa WHERE id='" . get('anketa') . "'");
+ $rowDates = mysqli_fetch_assoc($sqlDates);
+ if (!$rowDates['boolStarts']) {
+
+ $srv_survey_non_active_notStarted = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_notStarted' . $_lang);
+ if ($srv_survey_non_active_notStarted == '') $srv_survey_non_active_notStarted = self::$lang['srv_survey_non_active_notStarted'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active_notStarted . $rowDates['starts']);
+ }
+ if (!$rowDates['boolExpire']) {
+
+ $srv_survey_non_active_expired = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_expired' . $_lang);
+ if ($srv_survey_non_active_expired == '') $srv_survey_non_active_expired = self::$lang['srv_survey_non_active_expired'];
+
+ Display::getInstance()->displayNapaka(self::$lang['srv_survey_non_active_expired'] . $rowDates['expire']);
+ }
+ } elseif ($rowa['active'] == 0) {
+
+ # anketa ni aktivna, preverimo ali je bila sploh aktivirana
+ $str = "SELECT count(*) FROM srv_activity WHERE sid = '" . get('anketa') . "'";
+ $qry = sisplet_query($str);
+ list($count_activity) = mysqli_fetch_row($qry);
+ if ($count_activity > 0) {
+
+ $srv_survey_non_active = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active' . $_lang);
+ if ($srv_survey_non_active == '') $srv_survey_non_active = self::$lang['srv_survey_non_active'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active);
+ } else {
+
+ $srv_survey_non_active_notActivated = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_notActivated' . $_lang);
+ if ($srv_survey_non_active_notActivated == '') $srv_survey_non_active_notActivated = self::$lang['srv_survey_non_active_notActivated'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active_notActivated);
+ }
+ } else {
+
+ $srv_survey_deleted = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_deleted' . $_lang);
+ if ($srv_survey_deleted == '') $srv_survey_deleted = self::$lang['srv_survey_deleted'];
+
+ Display::getInstance()->displayNapaka($srv_survey_deleted);
+ }
+
+ die();
+ }
+
+
+ // EVALVACIJA - Ce je nov respondent preverimo ce se je vrnil (zapis v tabeli eval_data_userCookie) in mu nastavimo ustrezen cookie da ga preusmerimo na ustrezno stran
+ private function evlavacijaNovRespondent()
+ {
+ $student = (isset($_GET['sifstud'])) ? $_GET['sifstud'] : 0;
+ $predmet = (isset($_GET['sifpredm'])) ? $_GET['sifpredm'] : -1; // Ce resuje splosno anketo ni predmeta -> predmet = -1
+
+ if ($student > 0) {
+ $sqlE = sisplet_query("SELECT u.cookie AS cookie FROM eval_data_userCookie adu, srv_user u
+ WHERE adu.ank_id='" . get('anketa') . "' AND adu.student='" . $student . "' AND adu.predmet='" . $predmet . "'
+ AND u.ank_id='" . get('anketa') . "' AND u.id=adu.usr_id");
+ if (mysqli_num_rows($sqlE) > 0) {
+ $rowE = mysqli_fetch_array($sqlE);
+ $cookie = $rowE['cookie'];
+ return $cookie;
+ }
+ }
+ }
+
+
+ /************************************************
+ * Če cookie obstaja ga samo preberemo
+ ************************************************/
+ protected $cookie;
+
+ private function cookieExist($cookie)
+ {
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sql = sisplet_query("SELECT id, user_id FROM srv_user WHERE cookie='$cookie' AND deleted='0' LIMIT 1");
+ $row = mysqli_fetch_array($sql);
+
+ if ($row['id'] > 0) {
+
+ save('usr_id', $row['id']);
+
+
+ // cookie se enkrat nastavmo, ce se je kaj spreminjal nastavitve expire-ja
+ $this->set_cookie('survey-' . get('anketa'), $cookie, $this->expire);
+
+ // v primeru da je cookie ze bil postavljen, pa da se ni bilo povezave s sisplet userjem, ga 'povezemo'
+ if ($rowa['user_from_cms'] >= 1)
+ if ($row['user_id'] == 0 && self::$global_user_id > 0)
+ $sql = sisplet_query("UPDATE srv_user SET user_id = '" . self::$global_user_id . "' WHERE cookie = '$cookie'");
+
+ // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore
+ // Dodano v pogoj da se to izvede samo ce nima nastavljene grupe (drugace dela narobe klik nazaj na zakljucku, preklop med bloki...)
+ if ($rowa['return_finished'] == 0 && !isset($_GET['grupa']) && !isset($_GET['urejanje']) && !isset($_GET['return'])) {
+ $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'");
+ $rows = mysqli_fetch_array($sqls);
+ if ($rows['status'] == 6) { // Koncal anketo
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ }
+
+ // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo
+ if (!isset($_GET['grupa'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ } else { // dodatno preverjanje, ce se slucajno kaj sfizi, pa da ni tega cookieja v bazi, ga moramo se enkrat nastavit
+ $this->cookie = null;
+ }
+ }
+
+ /************************************************
+ * Cookie ni nastavljen is null
+ ************************************************/
+
+ private function cookieIsNull()
+ {
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ //preverjamo limit stevila glasov
+ if ((!isset($_GET['preview']) || $_GET['preview'] != 'on') && ($rowa['vote_limit'] == 1 || $rowa['vote_limit'] == 2)) {
+
+ // preverimo ce smo presegli limit
+ // Stetje samo ustreznih odgovorov
+ if ($rowa['vote_limit'] == 2)
+ $sqlVotes = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='" . get('anketa') . "' AND (last_status='5' OR last_status='6') AND lurker='0' AND deleted='0'");
+ // Stetje vseh odgovorov
+ else
+ $sqlVotes = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='" . get('anketa') . "' AND deleted='0'");
+
+ $rowVotes = mysqli_fetch_assoc($sqlVotes);
+
+ if ($rowa['vote_count'] <= $rowVotes['COUNT(id)']) {
+ //$this->display->displayNapaka(self::$lang['srv_survey_non_active_voteLimit'].' ('.$rowa['vote_count'].')');
+
+ $srv_survey_non_active_voteLimit = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_voteLimit' . $_lang);
+ if ($srv_survey_non_active_voteLimit == '') $srv_survey_non_active_voteLimit = self::$lang['srv_survey_non_active_voteLimit'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active_voteLimit);
+ die();
+ }
+ }
+
+ // splosna koda za dostop do ankete (brez prepoznave userja) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ $sqlp = sisplet_query("SELECT password FROM srv_password WHERE ank_id='" . get('anketa') . "'");
+ if (mysqli_num_rows($sqlp) > 0 && $userAccess->checkUserAccess($what='password')) {
+
+ $ok = false;
+
+ while ($rowp = mysqli_fetch_array($sqlp)) {
+
+ if (isset($_POST['password']) && $rowp['password'] == $_POST['password'] /*|| $_COOKIE['password_' .get('anketa')] == $rowp['password']*/) {
+ setcookie('password_' . get('anketa'), $rowp['password']);
+ $ok = true;
+ }
+ }
+
+ if (!$ok) {
+ Header::getInstance()->header();
+ Body::getInstance()->displayIntroduction();
+ die();
+ }
+ }
+
+ // preverimo, ce blokiramo IP (to nardimo, samo ce se ni kukija - drugac bi ga takoj zablokiral (ce pa je kuki se ga pa itak prepoza pa potem shendla))
+ if ($rowa['block_ip'] > 0) {
+ $sqlip = sisplet_query("SELECT id FROM srv_user WHERE ank_id='" . get('anketa') . "' AND ip='" . Helper::remote_address() . "' AND time_edit >= NOW() - INTERVAL $rowa[block_ip] MINUTE");
+ if (mysqli_num_rows($sqlip) > 0) { // je ze dostopal iz tega IPja
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ }
+
+ if (self::$global_user_id == 0) {
+ $row1['id'] = 0;
+ }
+ else {
+ $sql1 = sisplet_query("SELECT id, cookie FROM srv_user WHERE user_id = '" . self::$global_user_id . "' AND user_id > 0 AND ank_id = '" . get('anketa') . "'");
+
+ if(mysqli_num_rows($sql1) > 0)
+ $row1 = mysqli_fetch_array($sql1);
+ else
+ $row1['id'] = 0;
+ }
+
+ // ce je izbrana povezava s sisplet userjem in da smo najdl cookie za trenutnega userja, potem nastavimo ta cookie
+ if ($row1['id'] > 0 && $rowa['user_from_cms'] == 1) {
+
+ $rand = $row1['cookie'];
+
+ $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire);
+
+ save('usr_id', $row1['id']);
+
+
+ // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore
+ if ($rowa['return_finished'] == 0) {
+ $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'");
+ $rows = mysqli_fetch_array($sqls);
+ if ($rows['status'] == 6) { // Koncal anketo
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ }
+
+ // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo
+ if (!isset($_GET['grupa'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ // userji iz baze
+ } elseif (
+ ($rowa['user_base'] == 1) &&
+ #če imamo neindividualizirana vabila - poslana preko vabil, vendar bez kode in zato brez sledenja (uporabnik se pri pošiljanju NE prenese iz srv_invitations_recipients v srv_user)
+ $rowa['individual_invitation'] != 0 &&
+ ( // Omogoči anketo tudi respodentom, ki niso v bazi
+ ($rowa['usercode_skip'] == 0) // Ne (vsi grejo sem not, ker morajo nujno vnesti kodo)
+ || ($rowa['usercode_skip'] == 1 /*&& (isset($_POST['usercode']) or isset($_GET['code']))*/) // Da (sem not grejo samo, ce so vnesli kodo, da jih prepoznamo, sicer grejo na else in dobijo nov cookie)
+ || ($rowa['usercode_skip'] == 2 && (!get('userAutor') || (isset($_POST['usercode']) or isset($_GET['code'])))) // Samo avtor (ce ni avtor ankete, gre sem noter in mora vnesti kodo. Avtor ankete pa gre sem notr samo ce je podana koda, sicer gre na else in dobi nov cookie)
+
+ // Respondenti naj vedno vnesejo kodo: Da
+ || ($rowa['usercode_required'] == 1 && $rowa['usercode_skip'] != 1 &&
+ ( // Omogoči anketo tudi respodentom, ki niso v bazi
+ $rowa['usercode_skip'] == 0 // Ne (vsi grejo sem not, ker morajo nujno vnesti kodo)
+ || ($rowa['usercode_skip'] == 2 && !get('userAutor') /*&& ( !$userAutor || $userAutor || (isset($_POST['usercode']) or isset($_GET['code'])) )*/) // Samo avtor (ce ni avtor ankete, gre sem noter in mora vnesti kodo. Avtor ankete pa gre sem notr samo ce je podana koda, sicer gre na else in dobi nov cookie)
+ ) // ^ tale pogoj zgoraj se ni cist ok, ker mora tudi avtor vnesti kodo - AVTORJU NI TREBA VNEST KODE CE JE TO VKLOPLJENO - dodan && !get('userAutor')
+ )
+ )
+ ) {
+ if (isset($_POST['usercode']) or isset($_GET['code'])) {
+
+ if (isset($_POST['usercode']))
+ $usercode = strtolower($_POST['usercode']);
+ elseif (isset($_GET['code']))
+ $usercode = strtolower($_GET['code']);
+ else
+ die();
+
+ $sql2 = sisplet_query("SELECT id, recnum, cookie FROM srv_user WHERE TRIM(pass) = '$usercode' AND ank_id='".get('anketa')."' AND deleted='0'");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ $row2 = mysqli_fetch_array($sql2);
+
+ // Pravilna koda
+ if (mysqli_num_rows($sql2) > 0) {
+
+ // Ce imamo vklopljen modul za volitve preskocimo kar nekaj korakov (anonimizacija)
+ if(!SurveyInfo::checkSurveyModule('voting')){
+
+ // Dodatno preverimo ce koda se ni potekla
+ $sqlC = sisplet_query("SELECT * FROM srv_invitations_recipients WHERE ank_id='".get('anketa')."' AND TRIM(password)='".$usercode."' AND DATE(NOW())>DATE(date_expired) AND date_expired!='0000-00-00 00:00:00'");
+ if(mysqli_num_rows($sqlC) > 0){
+ Display::getInstance()->displayNapaka(self::$lang['srv_expiredcode']);
+ die();
+ }
+
+ # nastavimo še da je uporabnik odgovoril na anketo za nov način e-mail vabil
+ sisplet_query("UPDATE srv_invitations_recipients SET responded = '1', date_responded = NOW() WHERE ank_id='" . get('anketa') . "' AND TRIM(password) ='$usercode' AND responded = '0'");
+
+ sisplet_query("COMMIT");
+ }
+
+ $rand = $row2['cookie'];
+
+ $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire);
+
+ save('usr_id', $row2['id']);
+
+
+ // Preverimo ce imamo vklopljeno da uporabnik nadaljuje kjer je ostal - potem ga preusmerimo na pravo stran
+ Check::getInstance()->check_cookie_return();
+
+ if ($row2['recnum'] == 0) {
+
+ if (isset($_POST['referer']))
+ $referer = $_POST['referer'];
+ elseif (isset($_SERVER['HTTP_REFERER']))
+ $referer = $_SERVER['HTTP_REFERER'];
+ else
+ $referer = 0;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip');
+ $browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser');
+ $referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal');
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+ if ($ip == 0) $_ip = Helper::remote_address(); else $ip = "";
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+ if ($referal == 0) $_referer = $referer; else $_referer = '';
+ if ($browser == 0) $_useragent = $_SERVER['HTTP_USER_AGENT']; else $_useragent = '';
+
+ // Ce dovolimo useragent in ce je instaliran browscap
+ $_browser = '';
+ $_device = 0;
+ $_os = '';
+ if ($_useragent != '' && get_cfg_var('browscap')) {
+
+ $browser_detect = get_browser($_useragent, true);
+ $detect = New Mobile_Detect();
+ $detect->setUserAgent($_useragent);
+
+ // Detect browserja
+ if ($browser_detect['browser'] == 'Default Browser')
+ $_browser = self::$lang['srv_para_graph_other'];
+ else
+ $_browser = $browser_detect['browser'] . ' ' . $browser_detect['version'];
+
+ // Detect naprave (pc, mobi, tablet, robot)
+ if ($detect->isMobile()) {
+ if ($detect->isTablet())
+ $_device = 2;
+ else
+ $_device = 1;
+ } elseif ($browser_detect['crawler'] == 1)
+ $_device = 3;
+ else
+ $_device = 0;
+
+ // Detect operacijskega sistema
+ if ($browser_detect['platform'] == 'unknown')
+ $_os = self::$lang['srv_para_graph_other'];
+ else
+ $_os = $browser_detect['platform'];
+ }
+
+ $recnum = 0;
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ $s = sisplet_query("UPDATE srv_user SET recnum = MAX_RECNUM('" . get('anketa') . "'), time_insert=" . $_time_insert . ", language='" . get('language') . "', ip='" . $_ip . "', useragent='" . $_useragent . "', device='" . $_device . "', browser='" . $_browser . "', os='" . $_os . "' WHERE id = '" . get('usr_id') . "'");
+ if (!$s) {
+ echo 'err3432' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+
+ // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore
+ if ($rowa['return_finished'] == 0) {
+ $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'");
+ $rows = mysqli_fetch_array($sqls);
+
+ if ($rows['status'] == 6) { // Koncal anketo
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+
+ die();
+ }
+ }
+
+
+ // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo
+ if (!isset($_GET['grupa'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ }
+ else { // koda ne obstaja
+
+ //#TODO Tukaj preverimo userja iz novih e-mail vabil
+
+ if ($rowa['usercode_skip'] != 1 && !($_GET['preview'] == 'on' && isset($_GET['disablecode']) && $_GET['disablecode'] == 1)) {
+
+ // Pri Ne in Samo avtor prikazemo obvestilo, pri Da spustimo naprej in kreiramo nov cookie
+ SurveySetting::getInstance()->init(get('anketa'));
+ $srv_wrongcode = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_wrongcode' . $_lang);
+ if ($srv_wrongcode == '') $srv_wrongcode = self::$lang['srv_wrongcode'];
+
+ Display::getInstance()->displayNapaka($srv_wrongcode);
+ die();
+ }
+ }
+
+ } else {
+
+ # če imamo formo
+ if ($rowa['survey_type'] == 1) {
+ # TODO.. Mitja, tu je treba vse pravilno pohandlat.. men se niti sanja ne kak in kaj
+ # problem pri formi je da ko enkrat pošlješ email vabilo, potem vedno prikazuje header
+ // TODO: kolk casa je ze tole tukaj? :) -mitja
+ # TODO: ziher več kot leto in pol. :) tak da ni neskončno pomembno
+ }
+ else {
+
+ // baza respondentov - ce ni poslana koda
+ Language::getInstance()->multilang_init();
+ Header::getInstance()->header();
+ Body::getInstance()->displayIntroduction();
+
+ die();
+ }
+ }
+
+ }
+
+ // drugace gremo kreirat nov cookie
+ if (get('usr_id') == null) {
+
+ // izberemo random hash, ki se ni v bazi
+ do {
+ $rand = md5(mt_rand(1, mt_getrandmax()) . '@' . Helper::remote_address());
+ $sql = sisplet_query("SELECT id FROM srv_user WHERE cookie = '$rand'");
+ } while (mysqli_num_rows($sql) > 0);
+
+ $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire);
+
+ // ce je izbrana povezava s sisplet userjem, ga povezemo
+ if ($rowa['user_from_cms'] >= 1) {
+ $sqlu = Model::db_select_user(self::$global_user_id);
+ $rowu = mysqli_fetch_array($sqlu);
+ } else
+ $rowu['id'] = 0;
+
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on') {
+ $preview = 1;
+ } else {
+ $preview = 0;
+ }
+ # če smo v prezentaciji (slideshow) in ne beležimo vnosov jih označimo kot preview = 1
+ if (isset($rowa['slideshow']) && $rowa['slideshow'] == 1) {
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+ # če beležimo vnose: save_entries == 1
+ if ($ss_setings['save_entries'] == 0) {
+ $preview = 1;
+ }
+ }
+
+ $testdata = 0;
+ if (isset($_GET['testdata']) && $_GET['testdata'] == 'on') {
+ $preview = 0;
+ $testdata = 1;
+ }
+
+
+ if (isset($_POST['referer']))
+ $referer = $_POST['referer'];
+ elseif (isset($_SERVER['HTTP_REFERER']))
+ $referer = $_SERVER['HTTP_REFERER'];
+ else
+ $referer = 0;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip');
+ $browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser');
+ $referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal');
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+ if ($ip == 0) $_ip = Helper::remote_address(); else $ip = "";
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+ if ($referal == 0) $_referer = $referer; else $_referer = '';
+ if ($browser == 0) $_useragent = $_SERVER['HTTP_USER_AGENT']; else $_useragent = '';
+
+ // Ce dovolimo useragent in ce je instaliran browscap
+ $_browser = '';
+ $_device = 0;
+ $_os = '';
+ if ($_useragent != '' && get_cfg_var('browscap')) {
+
+ $browser_detect = get_browser($_useragent, true);
+ $detect = New Mobile_Detect();
+ $detect->setUserAgent($_useragent);
+
+ // Detect browserja
+ if ($browser_detect['browser'] == 'Default Browser')
+ $_browser = self::$lang['srv_para_graph_other'];
+ else
+ $_browser = $browser_detect['browser'] . ' ' . $browser_detect['version'];
+
+ // Detect naprave (pc, mobi, tablet, robot)
+ if ($detect->isMobile()) {
+ if ($detect->isTablet())
+ $_device = 2;
+ else
+ $_device = 1;
+ } elseif ($browser_detect['crawler'] == 1)
+ $_device = 3;
+ else
+ $_device = 0;
+
+ // Detect operacijskega sistema
+ if ($browser_detect['platform'] == 'unknown')
+ $_os = self::$lang['srv_para_graph_other'];
+ else
+ $_os = $browser_detect['platform'];
+ }
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ $recnum = 0;
+
+ $sql = sisplet_query("INSERT INTO srv_user (id, ank_id, preview, testdata, cookie, user_id, ip, time_insert, recnum, referer, useragent, device, browser, os, language) VALUES (0, '" . get('anketa') . "', '$preview', '$testdata', '$rand', '$rowu[id]', '" . $_ip . "', " . $_time_insert . ", MAX_RECNUM('" . get('anketa') . "'), '" . $_referer . "', '" . $_useragent . "', '" . $_device . "', '" . $_browser . "', '" . $_os . "', '" . get('language') . "')");
+ if (!$sql) {
+ echo 'err3431' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ save('usr_id', mysqli_insert_id($GLOBALS['connect_db']), 1);
+
+
+ //sisplet_query("COMMIT");
+ # če je testni vnos in če že imamo skreirano datoteko s podatki v kateri še ni označeno da imamo testem je potrebno generirati na novo
+ if ((int)$testdata > 0) {
+ $head_file_name = self::$site_path . 'admin/survey/SurveyData/export_header_' . get('anketa') . '.dat';
+ if (file_exists($head_file_name)) {
+ $header = unserialize(file_get_contents($head_file_name));
+ if ((int)$header['_settings']['hasTestData'] == 0) {
+ unlink($head_file_name);
+ }
+ }
+ }
+
+ //potrebuje se za modul MAZA - za povezavo respondenta med tebelama maza_app_users in srv_user
+ if(SurveyInfo::checkSurveyModule('maza')){
+ //error_log(json_encode($_GET));
+ $maza = new MAZA(get('anketa'));
+ //check if id and identifier match
+ if($_GET['maza_user_id'] && ($maza->maza_validate_user($_GET['maza_user_id'], $_GET['maza_identifier']))){
+ //update last_active of user
+ $maza->maza_update_user_active($_GET['maza_user_id']);
+ //insert pair of users id's in DB table
+ $maza->maza_save_srv_user($_GET['maza_user_id'], get('usr_id'), $_GET['maza_srv_version'], $_GET['maza_tgeofence_id'], $_GET['maza_tactivity_id'], $_GET['maza_mode']);
+ }
+ }
+
+ // EVALVACIJA - Ce je nov respondent se to zapise v posebno tabelo, da ga prepoznamo naslednjic brez cookija (da lahko nadaljuje kjer je ostal)
+ if (Common::checkModule('evalvacija') == '1') {
+ $student = (isset($_GET['sifstud'])) ? $_GET['sifstud'] : 0;
+ $predmet = (isset($_GET['sifpredm'])) ? $_GET['sifpredm'] : -1; // Ce resuje splosno anketo ni predmeta -> predmet = -1
+
+ if ($student > 0)
+ sisplet_query("INSERT INTO eval_data_userCookie (ank_id, usr_id, student, predmet) VALUES ('" . get('anketa') . "', '" . get('usr_id') . "', '" . $student . "', '" . $predmet . "')");
+ }
+
+ // V kolikor gre za hierarhijo in je respondent učitelj, potem usr_id shranimo, da lahko obnovimo anketo
+ if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2) {
+ $url = base64_decode(urldecode($this->get->enc));
+ $polje = sisplet_query("SELECT koda, vloga FROM srv_hierarhija_koda WHERE url='" . $url . "'", "obj");
+
+ if ($polje->vloga == 'ucitelj')
+ sisplet_query("UPDATE srv_hierarhija_koda SET srv_user_id='" . get('usr_id') . "' WHERE url='" . $url . "'");
+
+ // V kolikor gre za super šifro potem shranimo v bazo, uporabnika in katero anketo je reševal.
+ if (!empty($this->get->supersifra)) {
+ $kode = sisplet_query("SELECT kode FROM srv_hierarhija_supersifra WHERE koda='".$this->get->supersifra."'", "obj");
+ $kode = unserialize($kode->kode);
+
+ sisplet_query("INSERT INTO
+ srv_hierarhija_supersifra_resevanje
+ (user_id, supersifra, koda, status)
+ VALUES
+ ('".get('usr_id')."', '".$this->get->supersifra."', '".$kode[$this->get->resujem]."', 1)
+ ");
+
+ }
+
+ }
+ }
+ }
+
+ /**
+ * nastavi cookie, oz. v primeru ankete brez cookieja, nastavi spremenljivko za url
+ */
+ protected $anketa, $rand, $expire;
+
+ private function set_cookie($anketa, $rand, $expire)
+ {
+
+ $cookie_ok = isset($_COOKIE['cookie_ok']) ? $_COOKIE['cookie_ok'] : '';
+
+ // ce je nastavljeno na brez piskotka ali se ni potrdil shranjevanja piskotkov
+ if (get('cookie_expire') == -1 or $cookie_ok != 1) { // cookie prenasamo preko URLja
+ save('cookie_url', '&' . $anketa . '=' . $rand); // ta string se bo dodal vsem URLjem na konec
+ // &amp; dodamo naknadno samo tam, kjer se pise v html (v header() more bit samo &)
+ } else {
+ setcookie($anketa, $rand, $expire); // ce je cookie, ga obicajno nastavimo
+ }
+ }
+
+ /**
+ * @desc nastavi status za trenutnega userja
+ */
+ private function set_userstatus($status)
+ {
+ $sql_userbase = sisplet_query("SELECT MAX(tip) AS tip FROM srv_userbase WHERE usr_id = '" . get('usr_id') . "'");
+ if (!$sql_userbase) echo mysqli_error($GLOBALS['connect_db']);
+ $row_userbase = mysqli_fetch_array($sql_userbase);
+
+ if ($row_userbase['tip'] > 0) {
+ $tip = $row_userbase['tip'];
+ }
+ else {
+ $tip = 0;
+ }
+
+ $sqlu = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id = '" . get('usr_id') . "'");
+ if (!$sqlu) echo mysqli_error($GLOBALS['connect_db']);
+ $rowu = mysqli_fetch_array($sqlu);
+
+ $sqlu = sisplet_query("SELECT inv_res_id FROM srv_user WHERE id = '" . get('usr_id') . "' AND inv_res_id IS NOT NULL");
+ $inv_res_id = null;
+ if (mysqli_num_rows($sqlu) > 0) {
+ # userj je dodan preko novih vabil zato updejtamo status še tam
+ $row_inv_res_id = mysqli_fetch_assoc($sqlu);
+ $inv_res_id = (int)$row_inv_res_id['inv_res_id'];
+ }
+
+ // spremenimo tip
+ if ($status > $rowu['status'] && is_numeric(get('usr_id'))) {
+
+ $s = sisplet_query("REPLACE INTO srv_userstatus (usr_id, tip, status, datetime) VALUES ('" . get('usr_id') . "', '$tip', '$status', NOW())");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ $s = sisplet_query("UPDATE srv_user SET last_status = '$status', time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id = '" . get('usr_id') . "'");
+ if (!$s) {
+ echo mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ # updejtamo še status pri respondentih.
+ if ((int)$inv_res_id > 0) {
+ # userj je dodan preko novih vabil zato updejtamo status še tam
+ $sqlString = "UPDATE srv_invitations_recipients SET last_status='$status' WHERE ank_id='" . get('anketa') . "' AND id ='$inv_res_id' ";
+ $u = sisplet_query($sqlString);
+ }
+
+ // updatamo samo datum - tip se ni spremenil
+ } else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ # osvežimo datum spremembe
+ sisplet_query("UPDATE srv_user SET time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id='" . get('usr_id') . "'");
+
+ }
+
+ // Ce ne belezimo parapodatka za cas responsa, anonimno zabelezimo cas zadnjega responsa
+ if(SurveySetting::getInstance()->getSurveyMiscSetting('survey_date') == 1) {
+ sisplet_query("UPDATE srv_anketa SET last_response_time=NOW() WHERE id='".get('anketa')."'");
+ }
+
+ # dodamo še tracking arhivov vabil
+ if (get('user_inv_archive') > 0 && $inv_res_id > 0) {
+
+ # ignoriramo podvojene kluče
+ $s = sisplet_query("INSERT IGNORE INTO srv_invitations_tracking
+ (inv_arch_id, time_insert, res_id, status)
+ VALUES
+ ('" . (int)get('user_inv_archive') . "',NOW(),'$inv_res_id','$status')
+ ");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ }
+ else {
+ }
+
+ # potrebno bo osvežit seznam anket
+ Model::setUpdateSurveyList();
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/JsController.php b/main/survey/app/Controllers/JsController.php
new file mode 100644
index 0000000..c9699f8
--- /dev/null
+++ b/main/survey/app/Controllers/JsController.php
@@ -0,0 +1,2835 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 08.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Models\Model;
+use Cache;
+use enkaParameters;
+use Mobile_Detect;
+use SurveyAdvancedParadataLog;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use Common;
+use SurveyPanel;
+
+class JsController extends Controller
+{
+
+ public function __construct($var = null)
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new JsController();
+ }
+
+ // izpise kodo za JS sledenje, ce je nastavljena
+ public static function js_tracking()
+ {
+
+ $row = SurveyInfo::getSurveyRow();
+
+ if ($row['js_tracking'] != '') {
+ echo '<!-- JS tracking code -->';
+ echo $row['js_tracking'];
+ echo '<!-- / JS tracking code -->';
+ }
+
+ }
+
+ /**
+ * @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 ' <script> ' . "\n";
+
+ ?>
+ var lang_srv_alert_number_exists = "<?= $srv_alert_number_exists ?>";
+ var lang_srv_alert_number_toobig = "<?= $srv_alert_number_toobig ?>";
+ var lang_srv_remind_checkbox_max_violated_hard = "<?= $srv_remind_checkbox_max_violated_hard ?>";
+ <?
+
+ $survey_hint = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hint');
+ if ($survey_hint == '') $survey_hint = 1;
+
+ echo ' // generateSubmitJS() ' . "\n";
+ ?>
+ function submitAlert (id, action, type, bol, validation, txt, alert_sum, alert_num, alert_validation) {
+
+ if (validation == true) {
+
+ if (<?= $survey_hint ?> == 1) {
+
+ // pri tabelah izberemo celo spremenljivko
+ if ( ! $(id).hasClass('spremenljivka') ) {
+ id = '#' + $(id).closest('.spremenljivka')[0].id;
+ }
+
+ if (type == 'require' || type == 'require2' || type == 'require3' || type == 'require4' || type == 'require5') {
+ if ( $(id)[0].getAttribute('data-vrstni_red') >= max_vrstni_red ) return;
+ } else {
+ if ( $(id)[0].getAttribute('data-vrstni_red') > max_vrstni_red ) return;
+ }
+
+ var text;
+ if (type == 'require')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard) ?>';
+ if (type == 'require2')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_99) ?>';
+ if (type == 'require3')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_98) ?>';
+ if (type == 'require4')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_97) ?>';
+ if (type == 'require5')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_multi) ?>';
+ if (type == 'limit')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_num_hard) ?>';
+ if (type == 'text_limit')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_text_num_hard) ?>';
+ if (type == 'validation')
+ text = txt;
+ if (type == 'checkbox_min_limit')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_checkbox_min_violated_hard) ?>';
+
+ if (action == 'add') {
+ if ($(id+' div.validation_alert.'+type+'').length == 0){
+
+ $(id).append('<div class="validation_alert '+type+'">'+text+'</div>');
+
+ // Ce je opozorilo izven ekrana (ozki ekran, mobitel, tablica...) ga prikazemo na desni
+ $('div.validation_alert').each(function(){
+ if($(this).offset().left < 0){
+ $(this).addClass('alignRight');
+ }
+ });
+ }
+ showMissing(id);
+ }
+ else {
+ $(id+' div.validation_alert.'+type+'').remove();
+ }
+ }
+ }
+ else {
+ if (action == 'add') {
+ $(id).addClass('required_'+type);
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo opozorilo
+ <?if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){?>
+ dodaj_opozorilo(alert_sum, alert_num, alert_validation, bol, id);
+ <?}?>
+
+ showMissing(id);
+ }
+ else {
+ $(id).removeClass('required_'+type);
+ }
+ }
+ }
+
+ function isEmail(email) {
+ var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
+ return regex.test(email);
+ }
+
+ function showMissing(id) {
+ $(id).find('.missing').slideDown();
+ }
+ <?
+
+ echo ' function submitForm(parent_if, validation) { ' . "\n";
+ echo ' if (is_paused_slideshow == true) return false' . "\n";
+ echo ' var hard = true; ' . "\n";
+ echo ' var soft = true; ' . "\n";
+ echo ' var vsota = true; ' . "\n";
+ echo ' var num = true; ' . "\n";
+ echo ' var text_num = true; ' . "\n";
+ echo ' var checkbox_min_limit_alert = false; ' . "\n";
+
+
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND reminder > 0 ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ echo ' try { ' . "\n";
+
+ // katero spremenljivko bomo nastavili
+ if ($row['reminder'] == 1) {
+ $bol = 'soft';
+ } else {
+ $bol = 'hard';
+ }
+
+ // ce prikazujemo naknadno vec moznosti (recimo nevem in neustrezno)
+ if (($row['alert_show_99'] == 1 && $row['alert_show_98'] == 1) || ($row['alert_show_99'] == 1 && $row['alert_show_97'] == 1) || ($row['alert_show_98'] == 1 && $row['alert_show_97'] == 1)) {
+ $require = 'require5';
+ } // ce prikazujemo naknadno ne vem
+ elseif ($row['alert_show_99'] == 1) {
+ $require = 'require2';
+ } // ce prikazujemo naknadno zavrnil
+ elseif ($row['alert_show_98'] == 1) {
+ $require = 'require3';
+ } // ce prikazujemo naknadno neustrezno
+ elseif ($row['alert_show_97'] == 1) {
+ $require = 'require4';
+ } else {
+ $require = 'require';
+ }
+
+ // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
+ //echo ' if ( $(\'#spremenljivka_'.$row['id'].'\').css(\'display\') != \'none\' ) { '."\n";
+ echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+
+ // radio in checkbox
+ if ($row['tip'] <= 2 && ($row['orientation'] != 8 || get('mobile') == 1)) {
+
+ if ($row['tip'] == 1)
+ $ime = 'vrednost_' . $row['id'];
+ else
+ $ime = 'vrednost_' . $row['id'] . '[]';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+
+ echo ' var bol = false; ' . "\n";
+
+ // ce je samo 1 (spodnja procedura ne prime, je treba posebej)
+ echo ' if (len == undefined) { ' . "\n";
+
+ echo ' if (obj.checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ // sicer gremo normalno čez vse
+ //preureditev za pregled textboxa za drugo
+ echo ' } else { ' . "\n";
+
+ echo ' var bolTextBox = [] ' . "\n"; //polje, ki shranjuje info o boolean za "drugo"
+
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked){ ' . "\n"; //ce je odgovor izbran
+ echo ' bol = true; ' . "\n";
+
+ //urejanje za textbox za drugo
+ echo ' var drugo_temp = obj[i].id.replace("vrednost", "textfield"); ' . "\n";
+ echo ' if($("#"+drugo_temp).length){ ' . "\n";
+ echo ' var drugo_text_empty = true; ' . "\n";
+ echo ' if($("#"+drugo_temp).val() != ""){ ' . "\n";
+ echo ' drugo_text_empty = false; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' if (drugo_text_empty){ ' . "\n";
+ echo ' bolTextBox[i] = false; ' . "\n";
+ echo ' }else{ ' . "\n";
+ echo ' bolTextBox[i] = true; ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' } ' . "\n";
+ //urejanje za textbox za drugo - konec
+ echo ' } ' . "\n"; //konec if (obj[i].checked)
+ echo ' } ' . "\n"; //konec for
+
+ //ce polje za textbox "drugo" ni prazno, ustrezno uredi spremenljivko bol
+ echo ' if(bolTextBox.indexOf(false)>0){ ' . "\n";
+ echo ' bol = false; ' . "\n";
+ echo ' } ' . "\n";
+ //ce polje za textbox "drugo" ni prazno, ustrezno uredi spremenljivko bol - konec
+
+
+ echo ' } ' . "\n";
+ //preureditev za pregled textboxa za drugo - konec
+
+
+ // Posebna funkcionalnost za ministrstvo za obrambo, ker se mudi (q5,q6,q8,q9,q11,q14)
+ if($site_url == 'https://www.1ka.si/' && get('anketa') == '180402' && in_array($row['id'], array('10654896', '10654916', '10668668', '10677046', '10668603', '10657205'))){
+
+ // Minimalno št. checkboxov (3 oz. 5)
+ if(in_array($row['id'], array('10654896', '10654916', '10668668', '10677046'))){
+ $cnt_special = ($row['id'] == '10668668') ? 5 : 3;
+
+ echo ' var cnt_special = 0; ' . "\n";
+
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked) ' . "\n";
+ echo ' cnt_special ++; ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' if (cnt_special != '.$cnt_special.') ' . "\n";
+ echo ' bol = false; ' . "\n";
+ }
+
+ // Kliknil drugo brez vnosa v text polje
+ if(in_array($row['id'], array('10654896', '10668603', '10657205'))){
+
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked){ ' . "\n";
+ echo ' var drugo_temp = obj[i].id.replace("vrednost", "textfield"); ' . "\n";
+ echo ' if($("#"+drugo_temp).length){ ' . "\n";
+
+ echo ' var drugo_text_empty = true; ' . "\n";
+
+ echo ' if($("#"+drugo_temp).val() != "") ' . "\n";
+ echo ' drugo_text_empty = false; ' . "\n";
+
+ echo ' if (drugo_text_empty) ' . "\n";
+ echo ' bol = false; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' }' . "\n";
+
+ }
+ //drag and drop - kategorije en in vec odgovorov
+ if ($row['tip'] <= 2 && ($row['orientation'] == 8 && get('mobile') != 1)) {
+ $ime = 'vrednost_' . $row['id'];
+ echo '
+ var bol = false;
+ var prisotno = $("#half2_frame_dropping_' . $row['id'] . '").children("div").attr("value");
+ if (prisotno){
+ bol = true;
+ }
+ if (!bol) {
+ ' . $bol . ' = false;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }
+ ';
+
+
+ // dropdown
+ } elseif ($row['tip'] == 3) {
+
+ $ime = 'vrednost_' . $row['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ } //tabele @ drag and drop
+ elseif (($row['tip'] == 6 && $row['enota'] == 9) || ($row['tip'] == 16 && $row['enota'] == 9)) {
+ echo '
+ //console.log("Drag and drop Tabela en odgovorov");
+ var bol = true;
+ var prisotno = $("#half_frame_dropping_' . $row['id'] . '").children("div").attr("value");
+ if (prisotno){
+ bol = false;
+ }
+ if (!bol) {
+ ' . $bol . ' = false;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }
+
+
+ ';
+
+ // tabele
+ //} elseif ($row['tip'] == 6 || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
+ } elseif (($row['tip'] == 6 && $row['enota'] != 9) || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
+
+ echo ' var totalbol = true; ';
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' AND other!='1' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ // Pri postopnem resevanju multigrida tega nimamo, ker drugace ne dela ok (ker deluje na principu da so vse vrstice razen tekoce display:none;)
+ if ($row['dynamic_mg'] == 0) {
+ echo ' if ( document.getElementById(\'vrednost_if_' . $row1['id'] . '\').style.display != \'none\' ) { ' . "\n";
+ }
+
+ // dropdown
+ if ($row['enota'] == 2) { // zakaj je tole? pride do bugov, ce je ostala enota nastavljena na ostalih tipih
+
+ // todo
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+
+ // multi radio
+ //} elseif ($row['tip'] == 6) {
+ } elseif ($row['tip'] == 6 && $row['enota'] != 9) {
+
+ $ime = 'vrednost_' . $row1['id'];
+
+ // Pri postopnem resevanju moramo skrite z ifom posebej izlociti iz preverjanja
+ if ($row['dynamic_mg'] != 0) {
+ echo ' if( !$(\'#vrednost_if_' . $row1['id'] . '\').hasClass(\'if_hide\') ){ ' . "\n";
+ }
+
+ //echo 'console.log("Klasična tabela!"); ';
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+ echo ' var bol = false; ' . "\n";
+
+ // ce je samo 1 (spodnja procedura ne prime, je treba posebej)
+ echo ' if (len == undefined) { ' . "\n";
+
+ echo ' if (obj.checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ // sicer gremo normalno čez vse
+ echo ' } else { ' . "\n";
+
+ echo ' for (i=0; i<len; i++) ' . "\n";
+ echo ' if (obj[i].checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ // Pri dvojnih tabelah moramo posebej preverjati se desno stran
+ echo ' var bol2 = true; ' . "\n";
+ if ($row['enota'] == 3) {
+ $ime2 = 'vrednost_' . $row1['id'].'_part_2';
+
+ echo ' var obj2 = document.forms[\'vnos\'].elements[\'' . $ime2 . '\']; ' . "\n";
+ echo ' var len2 = obj2.length; ' . "\n";
+ echo ' var bol2 = false; ' . "\n";
+
+ echo ' for (i=0; i<len2; i++) ' . "\n";
+ echo ' if (obj2[i].checked) ' . "\n";
+ echo ' bol2 = true; ' . "\n";
+ }
+
+ echo ' if (!bol || !bol2) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // Pri postopnem resevanju moramo skrite z ifom posebej izlociti iz preverjanja
+ if ($row['dynamic_mg'] != 0) {
+ echo ' } ' . "\n";
+ }
+
+ // multicheck
+ //} elseif ($row['tip'] == 16) {
+ } elseif ($row['tip'] == 16 && $row['enota'] != 9) {
+
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var bol = false; ' . "\n";
+
+ echo ' for (var i=1; i<=' . $row['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.checked || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // tabela besedilo in tabela number
+ } elseif ($row['tip'] == 19 || $row['tip'] == 20) {
+
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var bol = false; ' . "\n";
+
+ echo ' for (var i=1; i<=' . $row['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.value != "" || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ }
+
+ // Pri postopnem resevanju multigrida tega nimamo, ker drugace ne dela ok
+ if ($row['dynamic_mg'] == 0) {
+ echo ' } ' . "\n";;
+ }
+ }
+
+ echo ' if (validation) { ';
+ echo ' if (!totalbol) ';
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' else ';
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ';
+
+ // besedilo *
+ } elseif ($row['tip'] == 21) {
+
+ // captcha
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0);
+
+ if ($captcha == 1) {
+ ?>
+ var response = grecaptcha.getResponse();
+
+ if (response.gelgth != 0 || validation==true) {
+ // ok
+ }
+ else {
+ <?
+ if ($bol == 'soft') {
+ ?>
+ if (!confirm('<?=$srv_remind_captcha_soft?>'))
+ return;
+ <?
+ }
+ else {
+ ?>
+ alert('<?=$srv_remind_captcha_hard?>');
+ return;
+ <?
+ }
+ ?>
+ }
+ <?
+ }
+
+ //for ($i=0; $i<$row['text_kosov']; $i++) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $ime = 'vrednost_' . $row['id'] . '_kos_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "" && obj.disabled == false) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'validation\', \'' . $bol . '\', validation); ' . "\n";
+
+ // Email validation
+ $emailVerify = ($spremenljivkaParams->get('emailVerify') ? $spremenljivkaParams->get('emailVerify') : 0);
+ if ($emailVerify == 1) {
+ echo ' } else if(isEmail(obj.value) == false) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'validation\', \'' . $bol . '\', validation, \'' . ($bol == 'soft' ? $srv_remind_email_soft : $srv_remind_email_hard) . '\'); ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation); ' . "\n";
+
+ echo ' } else if(isEmail(obj.value) == true) { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'validation\', \'' . $bol . '\', validation, \'' . ($bol == 'soft' ? $srv_remind_email_soft : $srv_remind_email_hard) . '\'); ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation); ' . "\n";
+ }
+
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // textbox, compute, quota
+ } elseif ($row['tip'] == 4 || $row['tip'] == 22 || $row['tip'] == 25 || $row['tip'] == 8) {
+
+ $ime = 'vrednost_' . $row['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "" && obj.disabled == false) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // number
+ } elseif ($row['tip'] == 7) {
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost';
+
+ echo ' var obj1 = document.getElementById(\'' . $ime . '_1\'); ' . "\n";
+ if ($row['size'] == 2)
+ echo ' var obj2 = document.getElementById(\'' . $ime . '_2\'); ' . "\n";
+ if ($row['size'] == 1)
+ echo ' if (obj1.value == "" && obj1.disabled == false) { ' . "\n";
+ elseif ($row['size'] == 2)
+ echo ' if ((obj1.value == "" && obj1.disabled == false) || (obj2.value == "" && obj2.disabled == false)) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // razvrscanje - ostevilcevanje
+ elseif ($row['tip'] == 17 && ($row['design'] == 1 || get('mobile') > 0)) {
+
+ // max stevilo vnesenih vrednosti
+ $max = $row['ranking_k'];
+
+ // nimamo omejenega stevila vnosov (morajo biti vnesena vsa stevila)
+ if ($max == 0) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+ // imamo omejeno stevilo vnosov
+ else {
+ echo ' var count = ' . $max . '; ' . "\n";
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value != "") ' . "\n";
+ echo ' count --; ' . "\n";
+ }
+
+ echo ' if (count > 0) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+ // razvrscanje - prestavljanje
+ elseif ($row['tip'] == 17 && ($row['design'] == 0)) {
+
+ //max stevilo vnesenih vrednosti
+ $max = $row['ranking_k'];
+
+ //nimamo omejenega stevila vnosov (morajo biti vnesena vsa stevila)
+ if ($max == 0) {
+ $sql1 = sisplet_query("SELECT COUNT(id) FROM srv_vrednost WHERE spr_id='$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+ $max = $row1['COUNT(id)'];
+ }
+
+ $ime = 'half2_' . $row['id'];
+ echo ' var count = $(\'#' . $ime . '\').children().size(); ' . "\n";
+
+ echo ' if (count < \'' . $max . '\') { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ // razvrscanje - heatmap
+ elseif ($row['tip'] == 17 && ($row['design'] == 3)) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]'");
+ while($row1 = mysqli_fetch_array($sql1)){
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+
+ // vsota
+ elseif ($row['tip'] == 18) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // sn
+ } elseif ($row['tip'] == 9) {
+
+ echo ' var obj = document.getElementById(\'txt1\'); ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+
+ // kombinirana tabela
+ } elseif ($row['tip'] == 24) {
+
+ $first_spr = 0;
+
+ $sqlm = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grid_multiple gm WHERE s.id=gm.spr_id AND gm.parent = '$row[id]' ORDER BY gm.vrstni_red ASC");
+ $rowm = mysqli_fetch_array($sqlm);
+ $first_spr = $rowm['id'];
+
+ $sql1 = sisplet_query("SELECT id, vrstni_red FROM srv_vrednost WHERE spr_id='$first_spr' ORDER BY vrstni_red");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ // Preverjamo ce je if na trenutni vrstici
+ $vrednost = '';
+ $sqlVrednostIf = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' AND if_id>0 AND vrstni_red='".$row1['vrstni_red']."'");
+ if(mysqli_num_rows($sqlVrednostIf) > 0){
+ $rowVrednostIf = mysqli_fetch_array($sqlVrednostIf);
+ $vrednost = 'vrednost_if_' . $rowVrednostIf['id'];
+ }
+ echo ' if ( !$(\'#'.$vrednost.'\').length || document.getElementById(\'' . $vrednost . '\').style.display != \'none\' ) { ' . "\n";
+
+ echo ' var totalBol = true; ' . "\n";
+
+ mysqli_data_seek($sqlm, 0);
+ while ($rowm = mysqli_fetch_array($sqlm)) {
+
+ $sql2 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$rowm[id]' AND vrstni_red='$row1[vrstni_red]'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ // dropdown
+ if ($rowm['tip'] == 6 && $rowm['enota'] == 2) {
+
+ // todo
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = true; ' . "\n";
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' bol = false; ' . "\n";
+ echo ' }' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+ //selectbox
+ } elseif ($rowm['tip'] == 6 && $rowm['enota'] == 6) {
+
+ // todo
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = true; ' . "\n";
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' bol = false; ' . "\n";
+ echo ' }' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ // multi radio
+ } elseif ($rowm['tip'] == 6) {
+
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = false; ' . "\n";
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+
+
+ // ce je samo 1 (spodnja procedura ne prime, je treba posebej)
+ echo ' if (len == undefined) { ' . "\n";
+
+ echo ' if (obj.checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ // sicer gremo normalno čez vse
+ echo ' } else { ' . "\n";
+
+ echo ' for (i=0; i<len; i++) ' . "\n";
+ echo ' if (obj[i].checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ // multicheck
+ } elseif ($rowm['tip'] == 16) {
+
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = false; ' . "\n";
+ echo ' for (var i=1; i<=' . $rowm['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.checked || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ // tabela besedilo in tabela number
+ } elseif ($rowm['tip'] == 19 || $rowm['tip'] == 20) {
+
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = false; ' . "\n";
+ echo ' for (var i=1; i<=' . $rowm['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.value != "" || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ }
+ }
+
+ echo ' if (!totalBol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else {' . "\n";
+ echo ' submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' }' . "\n";
+
+ echo ' } '."\n";;
+ }
+ // Lokacija - maps
+ } elseif ($row['tip'] == 26) {
+
+ $ime = 'vrednost_' . $row['id'] . '[]';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // Heatmap
+ } elseif ($row['tip'] == 27) {
+
+ $ime = 'vrednost_' . $row['id'] . '[]';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // konec pogoja, ce je vprasanje vidno
+ echo ' } //-- if display != none ' . "\n";
+
+ echo ' } catch (e) {} ' . "\n";
+
+ }
+
+
+ // Alert za EVOLI departmente
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ )
+ $evoli_teammeter = true;
+ else
+ $evoli_teammeter = false;
+
+ if($evoli_teammeter){
+ echo ' var obj = document.forms[\'vnos\'].elements[\'evoli_tm_department\']; ' . "\n";
+
+ echo ' if (typeof(obj) != "undefined" && obj != null) { ' . "\n";
+
+ echo ' if (obj.value == 0) { ' . "\n";
+ echo ' hard = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_evoli_tm_department\', \'add\', \'require\', \'hard\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_evoli_tm_department\', \'remove\', \'require\', \'hard\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' } ' . "\n";
+ }
+
+
+ // posebno testiranje za vsoto in num ce smo presegli limit
+ //$sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".get('grupa')."' AND vsota_reminder > 0 ORDER BY vrstni_red ASC");
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND (tip='18' OR tip='7' OR tip='20' OR tip='21') ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($row['vsota_reminder'] > 0) {
+
+ if ($row['vsota_reminder'] == 1) {
+ $bol_vsota = 'soft';
+ } else {
+ $bol_vsota = 'hard';
+ }
+
+ // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
+ //echo ' if ( $(\'#spremenljivka_'.$row['id'].'\').css(\'display\') != \'none\' ) { ' ."\n";
+ echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+
+ // vsota
+ if ($row['tip'] == 18) {
+ $ime = 'spremenljivka_' . $row['id'] . '_vsota';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if ( (obj.value > ' . $row['vsota_limit'] . ' && !$(obj).hasClass("def") && ' . $row['vsota_limit'] . ' != 0) || (obj.value < ' . $row['vsota_min'] . ' && !$(obj).hasClass("def") && ' . $row['vsota_min'] . ' != 0) ){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false;' . "\n";
+ echo ' vsota = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, true, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'limit\', \'' . $bol_vsota . '\', validation, false, true, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ } // multinumber
+ elseif ($row['tip'] == 20) {
+
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var bol = false; ' . "\n";
+
+ echo ' for (var i=1; i<=' . $row['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ if ($row['num_useMax'] == 1) {
+ echo ' if (obj.value > ' . $row['vsota_limit'] . ' && obj.value != \'\' && ' . $row['num_useMax'] . ' == 1){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['num_useMin'] == 1) {
+ echo ' if (obj.value < ' . $row['vsota_min'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ echo ' } ' . "\n";
+ }
+ }
+ // number in text
+ else {
+ //za text se ne gleda value amapak value.length
+ $length = $row['tip'] == 21 ? '.length' : '';
+ $num_var = $row['tip'] == 21 ? 'text_' : '';
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_1';
+
+ ///echo ' var obj = document.forms[\'vnos\'].elements[\''.$ime.'\']; ' ."\n";
+ echo ' var obj = document.getElementById(\'' . $ime . '\'); ' . "\n";
+
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+
+ if ($row['num_useMax'] == 1) {
+ echo ' if (obj.value'.$length.' > ' . $row['vsota_limit'] . ' && obj.value != \'\' && ' . $row['num_useMax'] . ' == 1){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['num_useMin'] == 1) {
+ echo ' if (obj.value'.$length.' < ' . $row['vsota_min'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['size'] > 1) {
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_2';
+
+ //echo ' var obj = document.forms[\'vnos\'].elements[\''.$ime.'\']; ' ."\n";
+ echo ' var obj = document.getElementById(\'' . $ime . '\'); ' . "\n";
+
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+
+ if ($row['num_useMax2'] == 1) {
+ echo ' if (obj.value'.$length.' > ' . $row['num_max2'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['num_useMin2'] == 1) {
+ echo ' if (obj.value'.$length.' < ' . $row['num_min2'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+ }
+
+ if($row['tip'] == 7){
+ //Alert za mobile slider *************************************
+ echo '
+ //console.log(' . $row['ranking_k'] . ');
+ //console.log(' . $row['id'] . ');
+ ';
+
+ if ($row['ranking_k'] == '1' && get('mobile') != 0) {
+ echo '
+ //console.log(' . $row['ranking_k'] . ');
+ //console.log(' . $row['id'] . ');
+ ';
+
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+ echo ' if (obj.value > ' . $slider_MaxNumLabel . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+ }
+ }
+
+ // konec pogoja, ce je vprasanje vidno
+ echo ' } //-- if display != none ' . "\n";
+
+ }
+
+ }
+
+
+ // posebno testiranje ce respondent ni izbral minimalnega stevila checkbox-ov
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND (tip='2') ORDER BY vrstni_red ASC");
+
+ while ($row = mysqli_fetch_array($sql)) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $checkbox_min_limit = ($spremenljivkaParams->get('checkbox_min_limit') ? $spremenljivkaParams->get('checkbox_min_limit') : 0);
+ $checkbox_min_limit_reminder = ($spremenljivkaParams->get('checkbox_min_limit_reminder') ? $spremenljivkaParams->get('checkbox_min_limit_reminder') : 0);
+
+ if ($checkbox_min_limit > 0) { //ce je minimalni limit nastavljen
+
+ if ($checkbox_min_limit_reminder == 1) {
+ $bol_min_limit = 'soft';
+ } else {
+ $bol_min_limit = 'hard';
+ }
+
+ // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
+ echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+
+ echo ' var checkbox_min_limit = '.$checkbox_min_limit.'; ' . "\n";
+ echo ' var checkbox_min_limit_reminder = '.$checkbox_min_limit_reminder.'; ' . "\n";
+
+ //ce je checkbox in ni drag drop, preveri, koliko je oznacenih odgovorov
+ if($row['tip'] == 2 && ($row['orientation'] != 8 || get('mobile') == 1)){
+
+ echo ' obj = document.forms[\'vnos\'].elements[\'vrednost_\'+'.$row['id'].'+\'[]\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+ echo ' var count = 0; ' . "\n";
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked){ ' . "\n";
+ echo ' count++; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' if (count < checkbox_min_limit){
+ checkbox_min_limit_alert = true;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ } ' . "\n";
+ }
+ //ce je check box in drag drop, preveri, koliko je oznacenih odgovorov
+ elseif($row['tip'] == 2 && $row['orientation'] == 8){
+ echo '
+ var prisotno = $("#half2_frame_dropping_' . $row['id'] . '").children("div").attr("value");
+ var len = $("#half2_frame_dropping_' . $row['id'] . '").children().length;
+
+ if(len < checkbox_min_limit){
+ checkbox_min_limit_alert = true;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ }
+ ';
+ }
+ // konec pogoja, ce je vprasanje vidno
+ echo '} //-- if display != none ' . "\n";
+ }
+ }
+
+
+ if (isset($_GET['disablealert']) && $_GET['disablealert'] == 1) {
+ echo ' vsota = true; ' . "\n";
+ echo ' hard = true; ' . "\n";
+ echo ' soft = true; ' . "\n";
+ }
+
+ echo ' if ( validation ) { ';
+
+ // validacija
+ $sqlv = sisplet_query("SELECT v.* FROM srv_validation v, srv_spremenljivka s WHERE v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0' AND v.reminder>'0'");
+ while ($rowv = mysqli_fetch_array($sqlv)) {
+
+ if ($rowv['reminder'] == 1) {
+ $bol = 'soft';
+ } else {
+ $bol = 'hard';
+ }
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo opozorilo
+ if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ echo 'odstrani_opozorilo(\'#spremenljivka_' . $rowv['spr_id'] . '\', false, false, true); ';
+ }
+
+ echo 'submitAlert(\'#spremenljivka_' . $rowv['spr_id'] . '\', \'remove\', \'validation\', \'' . $bol . '\', validation, false, false, false, true); ';
+ }
+
+ if (mysqli_num_rows($sqlv) > 0) mysqli_data_seek($sqlv, 0);
+
+ while ($rowv = mysqli_fetch_array($sqlv)) {
+ if ($rowv['reminder'] == 1) {
+ $bol = 'soft';
+ } else {
+ $bol = 'hard';
+ }
+
+ ?>
+ if ( <? $this->generateCondition($rowv['if_id']); ?> ) {
+
+ <?
+ // Ce imamo vklopljene napredne parapodatke zabelezimo opozorilo
+ if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ ?>
+ <?= ' dodaj_opozorilo_val(\'' . $bol . '\', \'#spremenljivka_' . $rowv['spr_id'] . '\'); ' ?>
+ <?
+ }?>
+
+ <?= ' submitAlert(\'#spremenljivka_' . $rowv['spr_id'] . '\', \'add\', \'validation\', \'' . $bol . '\', validation, \'' . $rowv['reminder_text'] . '\', false, false, true); ' ?>
+
+ }
+ <?
+ }
+
+ echo ' } else { ';
+
+ //alert za preseg limita vsote
+ echo ' if (!vsota) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_sum_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_sum_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za preseg limita stevila
+ echo ' if (!num) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_num_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_num_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za preseg limita besedila
+ echo ' if (!text_num) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_text_num_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_text_num_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za premalo izbranih checkboxov
+ echo ' if (checkbox_min_limit_alert) { ' . "\n";
+ echo ' if (checkbox_min_limit_reminder == 2) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_checkbox_min_violated_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (checkbox_min_limit_reminder == 1) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_checkbox_min_violated_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za ostale tipe
+ echo ' if(text_num && num && vsota) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' if(\'' . $require . '\' == \'require2\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_99 . '\'); ' . "\n";
+ echo ' else if(\'' . $require . '\' == \'require3\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_98 . '\'); ' . "\n";
+ echo ' else if(\'' . $require . '\' == \'require4\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_97 . '\'); ' . "\n";
+ echo ' else if(\'' . $require . '\' == \'require5\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_multi . '\'); ' . "\n";
+ echo ' else ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if(\'' . $require . '\' == \'require2\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_99 . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else if(\'' . $require . '\' == \'require3\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_98 . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else if(\'' . $require . '\' == \'require4\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_97 . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else if(\'' . $require . '\' == \'require5\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_multi . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else{ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+
+ // validacija
+ $sqlv = sisplet_query("SELECT v.* FROM srv_validation v, srv_spremenljivka s WHERE v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0'");
+ while ($rowv = mysqli_fetch_array($sqlv)) {
+
+ ?>
+ if ( <? $this->generateCondition($rowv['if_id']); ?> ) {
+
+ <? if ($rowv['reminder'] == 1) {
+
+ ?> $('#spremenljivka_<?= $rowv['spr_id'] ?>').addClass('required'); <?
+ /*?> if ( ! confirm('<?= $rowv['reminder_text'] ?>') ) return; else $('#spremenljivka_<?= $rowv['spr_id'] ?>').removeClass('required'); <?*/
+ /*?> console.log('Soft validacija se je sprozila za spremenljivko: <?= $rowv['spr_id'] ?>'); if ( ! confirm('<?= $rowv['reminder_text'] ?>') ) return; else $('#spremenljivka_<?= $rowv['spr_id'] ?>').removeClass('required'); <?*/
+ ?> if ( ! confirm('<?= $rowv['reminder_text'] ?>') ) return; else $('#spremenljivka_<?= $rowv['spr_id'] ?>').removeClass('required'); <?
+
+ } elseif ($rowv['reminder'] == 2) {
+
+ ?> $('#spremenljivka_<?= $rowv['spr_id'] ?>').addClass('required'); <?
+ /*?> alert('<?= $rowv['reminder_text'] ?>'); return; <?*/
+ /*?> console.log('Hard validacija se je sprozila za spremenljivko: <?= $rowv['spr_id'] ?>'); alert('<?= $rowv['reminder_text'] ?>'); return; <?*/
+ ?> alert('<?= $rowv['reminder_text'] ?>'); return; <?
+
+ } ?>
+
+ }
+ <?
+
+ }
+
+ // preverjanje, da vnese inicialke
+ $question_resp_comment_inicialke = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke');
+ $question_resp_comment_inicialke_alert = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke_alert');
+ if ($question_resp_comment_inicialke == 1 && $question_resp_comment_inicialke_alert == 2) {
+ ?>
+ if ( !check_inicialke() ) {
+ alert('<?= $lang['srv_enter_inicialke'] ?>');
+ preview_popup_open();
+ return;
+ }
+ <?php
+ } elseif ($question_resp_comment_inicialke == 1 && $question_resp_comment_inicialke_alert == 1) {
+ ?>
+ if ( !check_inicialke() ) {
+ if ( !confirm('<?= $lang['srv_enter_inicialke2'] ?>') ) {
+ preview_popup_open();
+ return;
+ }
+ }
+ <?php
+ }
+
+ echo ' if (parent_if == undefined) { ' . "\n";
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo cas post-a
+ if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled() && SurveyAdvancedParadataLog::getInstance()->collectPostTime()){
+ echo 'logEvent(\'page\', \'unload_page\', function(){
+ $("form[name=vnos]").submit();
+ });';
+ }
+ else{
+ echo ' $("form[name=vnos]").submit(); ' . "\n";
+ }
+
+ echo ' } else { ' . "\n";
+ echo ' $.post($(\'form[name=vnos]\').attr(\'action\'), $(\'form[name=vnos]\').serialize(), function () { ' . "\n";
+ echo ' $.post(\'' . $site_url . 'main/survey/ajax.php?a=grupa_for_if\', {anketa:' . get('anketa') . ', parent_if: parent_if}, function (data) { ' . "\n";
+ echo ' window.location.href = \'' . SurveyInfo::getSurveyLink(false, false) . '&grupa=\'+data+\'' . Header::getSurveyParams() . get('cookie_url') . '\'; ' . "\n";
+ echo ' }) ' . "\n";
+ echo ' } ) ' . "\n";
+ echo ' } ' . "\n";
+
+ // if validation else
+ echo ' } ';
+
+ echo ' } ' . "\n";
+ //echo 'spr_id_indeks = 0; ' . "\n"; //za sledenje opozoril
+ echo ' </script> ' . "\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 ' <div class="buttons">
+ <input class="next" type="submit" value="' . $srv_potrdi . '" onclick="submitForm(); return false;">
+ </div>' . "\n";
+ } else {
+ echo ' <div class="buttons">
+ <input class="next" type="submit" name="submit" value="' . $lang['glasovanja_spol_moski'] . '" onclick="submitForm(); return false;">
+ <input class="next" type="submit" name="submit" value="' . $lang['glasovanja_spol_zenska'] . '" onclick="submitForm(); return false;">
+ </div>' . "\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 ' <div class="buttons">';
+ echo ' <input class="next" type="submit" value="' . $srv_nextpage . '" onclick="submitForm(); return false;">
+ </div>' . "\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 '<div class="buttons" id="buttons_gru_' . get('grupa') . '">';
+ //echo ' <input class="prev" type="submit" value="'.$lang['srv_prevpage'].'" onclick="document.location.href=\'index.php?anketa='.get('anketa').''.($this->findPrevGrupa()>0?'&grupa='.$this->findPrevGrupa().'':'').get('cookie_url').'\'; return false;">
+ if ($row['show_intro'] == 1 || $rowg['vrstni_red'] > 1) {
+ #echo '<input class="prev" type="button" value="'.$srv_prevpage.'" onclick="history.back()">';
+
+ if (!SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+
+ // Posebej za WebSM anketo - back naredimo tako, da poiscemo prejsnjo stran
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+
+ $grupa = Find::findPrevGrupa();
+ $grupa = ($grupa > 0) ? '&grupa=' . $grupa : '';
+
+ $lang_s = (isset($_GET['language'])) ? '&language=' . $_GET['language'] : '';
+ $language = save('language', $lang_s, 1);
+
+ $link = SurveyInfo::getSurveyLink(false, false) . $grupa . $language;
+
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="location.href=\'' . $link . '\';">';
+ } elseif ($display_backlink != '0') {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">';
+ }
+ } else {
+
+ # če smo v slideshowu prikazujemo gumb nazaj ali naprej na zahtevo
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+
+ if ($ss_setings['back_btn'] == 1) {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">';
+ }
+ }
+ }
+
+ if (SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+ # če smo v prezentaciji in imamo nastavljen pause button
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+
+ if ($ss_setings['pause_btn'] == 1) {
+ echo '<input id="btn_pause_on" class="pause" type="button" value="' . $lang['srv_slideshow_btn_pause_on'] . '" onclick="slide_timer_pause_ON();">';
+ echo '<input id="btn_pause_off" class="pause display_none" type="button" value="' . $lang['srv_slideshow_btn_pause_off'] . '" onclick="slide_timer_pause_OFF();">';
+ }
+ }
+ if (!SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+ echo ' <input class="next" type="submit" value="' . $srv_nextpage . '" onclick="submitForm(); return false;">';
+ } else {
+ # če smo v slideshowu prikazujemo gumb nazaj ali naprej na zahtevo
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+ if ($ss_setings['next_btn'] == 1) {
+ echo ' <input class="next" type="submit" value="' . $srv_nextpage . '" onclick="submitForm(); return false;">';
+ }
+ }
+
+ echo '</div>' . "\n";
+ }
+ }
+ }
+
+ /**
+ * @desc poklice generatorje JS kode za branching
+ */
+ public function generateBranchingJS()
+ {
+ echo '<script> ' . "\n";
+
+ echo ' function checkBranching () { ' . "\n";
+
+ $this->generateComputeJS();
+
+ // ce je preverjanje pogojev izklopljeno
+ if ($_GET['disableif'] != 1) {
+
+ $this->generateBranching();
+
+ $this->generateVrednostIf();
+ }
+
+ // sprotna validacija v balonckih
+ echo ' submitForm(undefined, true); ';
+
+ // Popravek footerja pri temi Bled
+ $row = SurveyInfo::getSurveyRow();
+ if($row['skin'] == 'Bled'){
+ echo ' footerBled(); ' . "\n";
+ }
+
+ echo ' } //-- function checkBranching() ' . "\n";
+
+
+ echo ' checkBranching(); ' . "\n";
+
+ echo '</script> ' . "\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 . ')';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/LanguageController.php b/main/survey/app/Controllers/LanguageController.php
new file mode 100644
index 0000000..ab47a41
--- /dev/null
+++ b/main/survey/app/Controllers/LanguageController.php
@@ -0,0 +1,196 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 18.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use SurveyInfo;
+
+class LanguageController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new LanguageController();
+ }
+
+ /************************************************
+ * Osnovne jezikovne datoteke
+ *
+ * @param $anketa
+ * @return
+ ************************************************/
+ public static function getLanguageFile()
+ {
+ global $lang;
+
+ if (get('anketa') > 0) {
+ SurveyInfo::getInstance()->SurveyInit(get('anketa'));
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $jezik = $row['lang_resp'];
+
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_resp'");
+ $row = mysqli_fetch_array($sql);
+
+ $jezik = $row['value'];
+ }
+
+ $file = lang_path($jezik);
+
+ if (@include($file)) {
+ $_SESSION['langX'] = lang_path($jezik, 1);
+ }
+ }
+
+
+ /**
+ * inicializacija multilang ankete. nastavljen mora biti usr_id ali $_GET[language]
+ *
+ */
+ public function multilang_init()
+ {
+ global $lang;
+
+ // mamo prebran cookie in user id, spremenimo language ce je treba -- multilanguage podpora je vezana na usr_id
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ if ($row['multilang'] == 1) {
+ if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu)
+
+ if (!empty(get('usr_id'))) { // (v bazo se shrani v displayintroduction - z ostalimi sistemskimi) (usr_id se ni postavljen)
+ $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'");
+ $rowl = mysqli_fetch_array($sqll);
+ save('lang_id', $rowl['lang_id']);
+ } else { // v GETu, ko lahko v previewu spreminjamo jezik na strani (usr_id je ze postavljen)
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['id'] > 0)
+ $sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_GET[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ save('lang_id', $_GET['language']);
+ }
+
+ } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani)
+
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['id'] > 0)
+ $sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_POST[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ save('lang_id', $_POST['language']);
+
+ } else { // jezik je ze shranjen v bazi, ga preberemo (naslednje strani)
+
+ $sqll = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " dt, srv_spremenljivka s WHERE dt.spr_id=s.id AND s.variable='language' AND dt.usr_id='" . get('usr_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+ $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$rowl[text]'");
+ $rowl = mysqli_fetch_array($sqll);
+ save('lang_id', $rowl['lang_id']);
+
+ }
+
+ if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik
+ $_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja)
+ // get('lang_id') mora se vedno ostati null !
+
+ } else { // zamenjamo jezik
+ $file = lang_path(get('lang_id'));
+ if (@include($file))
+ $_SESSION['langX'] = lang_path(get('lang_id'), 1);
+ }
+ }
+
+ }
+
+
+ /**
+ * prevod za srv_spremenljivka
+ */
+ public static function srv_language_spremenljivka($spremenljivka)
+ {
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT * FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ return $rowl;
+ }
+
+ return false;
+ }
+
+ /**
+ * vrne prevod za srv_vrednost
+ *
+ * @param mixed $vrednost
+ */
+ public function srv_language_vrednost($vrednost, $naslov2=false)
+ {
+
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT naslov, naslov2 FROM srv_language_vrednost WHERE ank_id='" . get('anketa') . "' AND vre_id='$vrednost' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if($naslov2){
+ if ($rowl['naslov2'] != '')
+ return $rowl['naslov2'];
+ }
+ elseif ($rowl['naslov'] != ''){
+ return $rowl['naslov'];
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * vrne prevod za srv_grid
+ *
+ * @param mixed $vrednost
+ */
+ public static function srv_language_grid($spremenljivka, $grid)
+ {
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT naslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if ($rowl['naslov'] != '') return $rowl['naslov'];
+ }
+
+ return false;
+ }
+
+ /**
+ * vrne prevod podnaslova za dvojno tabelo
+ *
+ */
+ public static function srv_language_grid_podnaslov($spremenljivka, $grid)
+ {
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT podnaslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if ($rowl['podnaslov'] != '') return $rowl['podnaslov'];
+ }
+
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/StatisticController.php b/main/survey/app/Controllers/StatisticController.php
new file mode 100644
index 0000000..00b01c2
--- /dev/null
+++ b/main/survey/app/Controllers/StatisticController.php
@@ -0,0 +1,282 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 26.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Models\Model;
+use SurveyInfo;
+
+class StatisticController extends Controller
+{
+
+ /**
+ * @desc poisce vprasanja, ki imajo statistiko in jih poklice
+ */
+ public static function displayStatistika($konec = false)
+ {
+
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+
+ if ($konec) $vrstni_red = 99999999;
+
+ //preverimo ce gre za glasovanje ali navadno anketo
+ $rowA = SurveyInfo::getInstance()->getSurveyRow();
+
+ //statistika za glasovanje
+ if ($rowA['survey_type'] == 0) {
+
+ if (get('printPreview')) {
+ $sql2 = sisplet_query("SELECT ank_id, spr_id, show_title FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $spremenljivka = $row2['spr_id'];
+
+ $sqla = sisplet_query("SELECT starts, expire, statistics, db_table FROM srv_anketa WHERE id ='$row2[ank_id]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $text = $rowa['statistics'];
+
+ if ($text != '')
+ echo ' <h3>' . $text . "\n";
+ else
+ echo ' <h3>' . "\n";
+
+ if ($row2['show_title'] == 0)
+ echo ' ' . $row['naslov'] . '</h3>' . "\n";
+ else
+ echo ' </h3>' . "\n";
+ } else {
+ $sqlG = sisplet_query("SELECT spr_id FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $rowG = mysqli_fetch_array($sqlG);
+
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $prev_grupa = $row['id'];
+
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$prev_grupa' AND stat>'0' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ echo ' <div class="spremenljivka" id="spremenljivka_statistika">' . "\n";
+ self::displayStatGlasovanje($rowG['spr_id']);
+ echo ' </div>' . "\n";
+ }
+ }
+ }
+ } //navadna statistika
+ else {
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $prev_grupa = $row['id'];
+
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$prev_grupa' AND stat='1' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ echo ' <div class="spremenljivka" id="spremenljivka_statistika">' . "\n";
+ self::displayStat($row['id']);
+ echo ' </div>' . "\n";
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @desc prikaze statistike za odgovor
+ */
+ public static function displayStat($spremenljivka, $spol = 0)
+ {
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $text = $lang['results'];
+
+ echo ' <h3>' . $text . ': ' . $row['naslov'] . '</h3>' . "\n";
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_vrednost v, srv_data_vrednost" . get('db_table') . " d WHERE v.spr_id='$spremenljivka' AND v.id=d.vre_id");
+ $row = mysqli_fetch_array($sql);
+ $total = $row['count'];
+
+ $sql = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red");
+ while ($row = mysqli_fetch_array($sql)) {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " WHERE vre_id='$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+
+
+ if ($total > 0)
+ $procent = round($row1['count'] / $total, 3) * 100;
+ else
+ $procent = 0;
+
+ echo ' <p><strong>' . $row['naslov'] . ':</strong> ' . $procent . '%</p>' . "\n";
+ }
+ }
+
+ /**
+ * @desc prikaze statistiko za glasovanje
+ */
+ public function displayStatGlasovanje($spremenljivka, $spol = 0)
+ {
+ global $lang;
+ global $site_url;
+ global $global_user_id;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ //preverimo ce gre za glasovanje
+ $sql2 = sisplet_query("SELECT * FROM srv_glasovanje WHERE spr_id='$spremenljivka'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sqla = sisplet_query("SELECT starts, expire, statistics, db_table FROM srv_anketa WHERE id ='$row2[ank_id]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ if ($rowa['db_table'] == 1)
+ save('db_table', '_active');
+
+ $text = $rowa['statistics'];
+
+ if ($text != '')
+ echo ' <span class="glas_settings_title">' . $text . "\n";
+ else
+ echo ' <span class="glas_settings_title">' . "\n";
+
+ if ($row2['show_title'] == 0)
+ echo ' ' . $row['naslov'] . '</span>' . "\n";
+ else
+ echo ' </span>' . "\n";
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_vrednost v, srv_data_vrednost" . get('db_table') . " d WHERE v.spr_id='$spremenljivka' AND v.id=d.vre_id");
+ $row = mysqli_fetch_array($sql);
+ $total = $row['count'];
+
+ $sql = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ //prikaz statistike za moske(pri glasovanju)
+ if ($spol == 1) {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " v, srv_data_glasovanje g WHERE v.vre_id='$row[id]' AND v.usr_id=g.usr_id AND g.spr_id='$spremenljivka' AND g.spol='1' ");
+ $row1 = mysqli_fetch_array($sql1);
+ } //prikaz statistike za zenske(pri glasovanju)
+ elseif ($spol == 2) {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " v, srv_data_glasovanje g WHERE v.vre_id='$row[id]' AND v.usr_id=g.usr_id AND g.spr_id='$spremenljivka' AND g.spol='2' ");
+ $row1 = mysqli_fetch_array($sql1);
+ } else {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " WHERE vre_id='$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+ }
+
+ if ($total > 0)
+ $procent = round($row1['count'] / $total, 3) * 100;
+ else
+ $procent = 0;
+
+ echo ' <p style="margin-top: 10px;"><strong>' . $row['naslov'] . ':</strong>' . "\n";
+
+
+ //ce gre za glasovanje in imamo nastavljen prikaz grafa ga izrisemo
+ if ($row2['show_graph'] == 1) {
+
+ echo '</p>';
+
+ echo ' <div "style=" margin: -20px 0 0 25%; text-align: right; width: 25%; font-size: 12px;">' . "\n";
+ if ($row2['show_results'] == 1) {
+ echo $row1['count'];
+ if ($row2['show_percent'] == 1)
+ echo ' (' . $procent . '%)';
+ } elseif ($row2['show_percent'] == 1)
+ echo $procent . '%';
+ echo ' </div>' . "\n";
+
+ echo '<div id="graph"><div class="graph_fill" style="width: ' . $procent . '%;"></div></div>';
+ } else {
+ if ($row2['show_results'] == 1) {
+ echo $row1['count'];
+ if ($row2['show_percent'] == 1)
+ echo ' (' . $procent . '%)';
+ } elseif ($row2['show_percent'] == 1)
+ echo $procent . '%';
+ echo '</p>';
+ }
+ }
+
+ //stevilo vseh glasov
+ if ($row2['stat_count'] == 1) {
+ if ($spol != 0) {
+ $sql5 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_glasovanje WHERE spr_id='$spremenljivka' AND spol='1' ");
+ $row5 = mysqli_fetch_array($sql5);
+ $moskih_glasov = $row5['count'];
+
+ if ($spol == 1) {
+ $percent = round($moskih_glasov / $total, 3) * 100;
+ $total = $moskih_glasov;
+ } else {
+ $percent = round(($total - $moskih_glasov) / $total, 3) * 100;
+ $total = $total - $moskih_glasov;
+ }
+ }
+
+ echo '<p style="margin-top: 10px;">' . $lang['glasovanja_count'] . ': ' . $total;
+ if ($spol != 0)
+ echo ' (' . $percent . '%)';
+ echo '</p>';
+ }
+
+ //cas aktivnosti ankete
+ if ($row2['stat_time'] == 1) {
+ $start = strtotime($rowa['starts']);
+ $end = strtotime($rowa['expire']);
+ echo '<p>' . $lang['glasovanja_time'] . ' ' . date("m.d.Y", $start) . ' ' . $lang['glasovanja_time_end'] . ' ' . date("m.d.Y", $end) . '</p>';
+ }
+
+ //prikaz statistike po spolu (samo kjer je nastavljena opcija izbira spola) - gumbi za preklop
+ if ($row2['spol'] == 1) {
+ echo '<div class="spol_buttons">' . "\n";
+
+ if ($spol == 0) echo '<input type="button" class="active" value="' . $lang['hour_all'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'0\');">';
+ else echo '<input type="button" value="' . $lang['hour_all'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'0\');">';
+
+ if ($spol == 1) echo '<input type="button" class="active" value="' . $lang['glasovanja_spol_moski'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'1\');">';
+ else echo '<input type="button" value="' . $lang['glasovanja_spol_moski'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'1\');">';
+
+ if ($spol == 2) echo '<input type="button" class="active" value="' . $lang['glasovanja_spol_zenske'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'2\');">';
+ else echo '<input type="button" value="' . $lang['glasovanja_spol_zenske'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'2\');">';
+
+ echo '</div>' . "\n";
+ }
+
+ //prikaz arhiva statistik anket
+ if ($row2['stat_archive'] == 1) {
+
+ echo '<div id="arhiv">';
+ echo 'Ankete iz arhiva:';
+
+ $sqlArchive = sisplet_query("SELECT ank_id FROM srv_glasovanje WHERE stat_archive = '1' AND ank_id != '$row2[ank_id]'");
+
+ echo '<ul>';
+ while ($rowArchive = mysqli_fetch_array($sqlArchive)) {
+ $sql4 = sisplet_query("SELECT naslov, starts, insert_uid FROM srv_anketa WHERE id = '$rowArchive[ank_id]'");
+ $row4 = mysqli_fetch_array($sql4);
+
+ if($row4['insert_uid'] == $global_user_id){
+ echo '<li>';
+
+ echo '<a href="' . $site_url . 'a/' . $rowArchive['ank_id'] . '&glas_end=0' . get('cookie_url') . '">' . $row4['naslov'] . '</a>';
+ echo ' (' . $row4['starts'] . ')';
+
+ echo '</li>';
+ }
+ }
+ echo '</ul>';
+ echo '</div>';
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/SurveyController.php b/main/survey/app/Controllers/SurveyController.php
new file mode 100644
index 0000000..558f2ad
--- /dev/null
+++ b/main/survey/app/Controllers/SurveyController.php
@@ -0,0 +1,76 @@
+<?php
+/***************************************
+ * Description: Glavni razred pri main survey, ki skrbi za klice vseh ostalih razredov, ki nato sestavijo prikaz ankete
+ * Autor: Robert Šmalc
+ * Created date: 22.01.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\InitClass as Init;
+use App\Controllers\LanguageController as Language;
+use SurveyMissingValues;
+use SurveySetting;
+
+class SurveyController extends Controller
+{
+ private $printPreviewSet;
+
+ public function __construct($printPreviewSet = false)
+ {
+ // Pridobimo vse globalne spremenljivke
+ parent::getGlobalVariables();
+
+ // Pridobimo spremenljivke za Header
+ $this->getHeader();
+
+ // Shranimo pvrednost predogleda
+ save('printPreview', $printPreviewSet);
+
+ if (isset($this->get->pages) && $this->get->pages == 'all')
+ save('displayAllPages', true);
+
+ save('mobile', Helper::mobile());
+
+ // Pridobimo datoteko za jezike
+ Language::getLanguageFile();
+
+ // Ali imamo perdogled že rešene ankete
+ if (isset($this->get->quick_view) && $this->get->quick_view == 1)
+ save('quick_view', true);
+
+ // Če je arhivirano pošiljanje emailov
+ if (isset($this->get->ai) && (int)$this->get->ai > 0)
+ save('user_inv_archive', (int)$this->get->ai);
+
+ // Poiščemo missing vrednosti ankete smv
+ save('smv', new SurveyMissingValues(get('anketa')));
+
+ // Če imamo izklopljeno mobilno prilagajanje, potem ignoriramo mobitele in vedno prikazemo vse enako
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_friendly = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_friendly');
+ if ($mobile_friendly == 0)
+ save('mobile', 0);
+
+ // Inicializacija vsega
+ new Init();
+ }
+
+ /************************************************
+ * Poberemo spremenljivke iz get requestov in piškotkov
+ ************************************************/
+ public function getHeader()
+ {
+ $header = new Header();
+
+ // Pridobimo vse GET parametre
+ $this->get = $header->getAllUrlParameters();
+
+ //Pridobimo vse $_COOKIE paramletre
+ $this->cookie = $header->getAllCookieParameters();
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/VariableClass.php b/main/survey/app/Controllers/VariableClass.php
new file mode 100644
index 0000000..93c1c69
--- /dev/null
+++ b/main/survey/app/Controllers/VariableClass.php
@@ -0,0 +1,193 @@
+<?php
+/***************************************
+ * Description: Služi kot seznam vseh globalnih spremenljivk, ki se uporabljajo v Main Survey in jih potem tudi definiramo v Controllerju
+ * Autor: Robert Šmalc
+ * Created date: 29.01.2016
+ *****************************************/
+
+
+namespace App\Controllers;
+
+
+class VariableClass
+{
+ protected static $_configuration = array(
+ 'anketa' => null, // trenutna anketa
+ 'get' => null, // tukaj poberemo vse get parametre, ki se pošiljajo preko GET ali POST in jih dodamo v spremenljivko
+ 'grupa' => null, // trenutna grupa
+ 'spremenljivka' => null, // trenutna spremenljivka
+ 'usr_id' => null, // ID trenutnega uporabnika
+ 'cookie_expire' => null, // nastavitev kdaj expira cookie, da vemo za primer brez cookie-ja, da prenasamo preko urlja
+ 'cookie_url' => null, // kadar cookie prenasamo po URLju, se v to spremenljivko zapise koda, ki jo dodamo vsakemu linku ($_GET)
+ 'printPreview' => false, // ali kliče konstruktor
+ 'hierarhija' => null, // če gre za hierarhijo potem poberemo get parametre
+
+ /** prisilimo prikaz spremenljivke, za predogled vanalizah in mogoče še kje
+ *
+ * @public boolean
+ */
+ 'forceShowSpremenljivka' => false,
+ 'db_table' => '',
+ 'ime_AW' => null, // trenutno ime, ki se reseuje (socialna omrezja - alterwise)
+ 'loop_AW' => null,
+ 'loop_id' => null, // vrednost po kateri loopamo, ce smo v loopu
+ 'lang_id' => null,
+ 'language' => '1',
+ 'smv' => null, // misnig vrednosti od ankete
+ 'mobile' => 0, // 0 - klasicna, 1 - mobilna, 2 - dlancniki
+ 'ismobile' => 0, // detekcija, ce je mobilna naprava
+
+ 'quick_view' => false, // ali smo samo v predogledu ankete od uporabnika
+ 'user_inv_archive' => 0, // id_arhiva vabil (če smo preko vabil)
+ 'displayAllPages' => false, // ali smo v predogledu kjer izpisujemo vse strani
+ 'webSMSurvey' => '34862', // WebSM anketa, ki ne shranjuje nicesar in skoci na pravo stran (gru_id) glede na url
+ 'generateComputeJS' => '',
+
+ /**
+ * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu
+ */
+ 'getElements' => array(),
+ 'checkSpremenljivka' => array(),
+ 'checkIf' => array(),
+ 'getGrupa' => array(),
+ 'preskocena_first' => 1, // spremenljivka, da pri preskocenih straneh ne delamo vsakic vseh querijev (ampak samo prvic)
+ 'cache_srv_data_grid' => '', // ostale spremenljivke so cache, ki se v posted() polni in zapise v bazo v posted_commit()
+ 'cache_srv_data_vrednost' => '',
+ 'cache_srv_data_text' => '',
+ 'cache_srv_data_checkgrid' => '',
+ 'cache_srv_data_textgrid' => '',
+ 'cache_srv_data_rating' => '',
+ 'cache_srv_data_vrednost_cond' => '',
+ 'cache_srv_data_map' => '',
+ 'cache_srv_data_heatmap' => '',
+ 'cache_delete' => '',
+ 'lurker' => -1,
+ 'getOtherValue' => array(),
+ 'select_from_srv_spremenljivka' => array(),
+
+ // Naknadno dodane globalne spremenljivke
+ 'userAutor' => false
+ );
+
+ protected $key, $value, $return;
+
+ // Shrani novo vrednost na obstoječo spremenljivko ali doda novo spremenljivko
+ public static function save($key, $value)
+ {
+ // Ce shranjujemo anketa_id ('anketa') jo najprej dekodiramo ce je potrebno
+ if($key == 'anketa'){
+ $value = self::decryptAnketaID($value);
+ }
+
+ $polje = self::izStringaVpolje($key);
+ if ($polje){
+ self::$_configuration[ $polje['spremenljivka'][0] ][ $polje['key'][0] ] = $value;
+ } else {
+ self::$_configuration[$key] = $value;
+ };
+ }
+
+ // Popravimo id ankete ce gre za kodiranega (pri novih anketah je v url-ju kodiran id ankete da respondenti ne morejo dostopati do drugih anket)
+ private static function decryptAnketaID($anketa){
+
+ // Ce anketa ni numeric jo pretvorimo v originalen id
+ if(!is_numeric($anketa)){
+
+ $anketa_arr = str_split($anketa);
+ $anketa_id = '';
+
+ foreach($anketa_arr as $pos => $char){
+ // Na lihih mestih pretvorimo crko nazaj v stevilko
+ if($pos % 2 == 0)
+ $anketa_id .= ord($char) - 97;
+ else
+ $anketa_id .= $char;
+ }
+ }
+ else
+ $anketa_id = $anketa;
+
+ return $anketa_id;
+ }
+
+ /************************************************
+ * Funkcija iz stringa naredi polje z id vrednostjo
+ * primer (string) 'polje[id]' uredi v (arrey) polje[id]
+ * @return array()
+ ************************************************/
+ private static function izStringaVpolje($string)
+ {
+ // spremenljivka je mišljen tekst, ki je pred oklepaji
+ $spremenljivka = array();
+ // key je vrednost oz. id te spremenljivke, ki je med []
+ $key = array();
+
+ $t = "";
+ for ($i = 0; $i < strlen($string); $i++) {
+ if ($string[$i] == '[') {
+ $spremenljivka[] = $t;
+ $t = "";
+ $t1 = "";
+ $i++;
+ while ($string[$i] != ']') {
+ $t1 .= $string[$i];
+ $i++;
+ }
+ $key[] = $t1;
+
+ } else {
+ if ($string[$i] != ']')
+ $t .= $string[$i];
+ else {
+ continue;
+ }
+
+ }
+ }
+
+ // V kolikor je samo string
+ if ($t != "")
+ return false;
+
+ return [
+ 'spremenljivka' => $spremenljivka,
+ 'key' => $key
+ ];
+ }
+
+
+ // Dodamo vrednost k že obstoječi vrednosti
+ public static function add($key, $value, $return = null)
+ {
+ self::$_configuration[$key] .= $value;
+
+ if (!is_null($return))
+ return $value;
+ }
+
+ public static function get($key)
+ {
+ return self::$_configuration[$key];
+ }
+
+ public static function getAll()
+ {
+ return self::$_configuration;
+ }
+
+ /************************************************
+ * Pridobimo vse variable, ki se uporabljajo za main/survey in jih dodamo na Controller -> $this variable
+ *
+ * @return $this
+ ************************************************/
+ public function refresh()
+ {
+ foreach (self::$_configuration as $key => $value) {
+ $this->$key = $value;
+ }
+
+ return $this;
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/ComputeController.php b/main/survey/app/Controllers/Vprasanja/ComputeController.php
new file mode 100644
index 0000000..d3c9353
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/ComputeController.php
@@ -0,0 +1,55 @@
+<?php
+/***************************************
+ * Description: Compute
+ *
+ * Vprašanje je prisotno:
+ * tip 25
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\JsController as Js;
+use App\Models\Model;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+
+class ComputeController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new ComputeController();
+ }
+
+ public function display($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+ echo ' <input type="text" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" value="' . $row1['text'] . '">';
+
+ Js::getInstance()->generateCompute($spremenljivka);
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DatumController.php b/main/survey/app/Controllers/Vprasanja/DatumController.php
new file mode 100644
index 0000000..21552b5
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DatumController.php
@@ -0,0 +1,187 @@
+<?php
+/***************************************
+ * Description: Datum
+ *
+ * Vprašanje je prisotno:
+ * tip 8
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class DatumController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DatumController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ # pogledamo ali imamo kak zapis v srv_data_vrednost. potem je to najbrž missing
+ $is_missing = false;
+ $srv_data_vrednost = array();
+ # če je bilo vprašanje preskočeno se je vs srv_data_vrednost zapisalo -2, če se potem uporabnik vrne, in spremeni pogojno vprašanje
+ # se potem datum ni prikazoval. ke je bilo v bazi -2, zato sem dal da naj poišče samo če vrednost ni -2
+ $sql2_c = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id AND vre_id NOT IN ('-1','-2')");
+ while ($row2_c = mysqli_fetch_assoc($sql2_c)) {
+ $srv_data_vrednost[$row2_c['vre_id']] = true;
+ $is_missing = true;
+ }
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">' . "\n";
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+
+ echo '<input type="text" id="vrednost_' . $spremenljivka . '" name="vrednost_' . $spremenljivka . '" value="' . $row1['text'] . '"
+ onkeyup="checkBranching();" ' . ($is_missing ? ' disabled' : '') . ' readonly="true"> ';
+
+ echo '</div>' . "\n";
+
+ $array_others = array();
+ $sql_other = sisplet_query("SELECT id,naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' AND vrstni_red > 0 AND other != '0' ORDER BY vrstni_red");
+ while ($other = mysqli_fetch_array($sql_other)) {
+ # imamo polje drugo - ne vem, zavrnil...
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $other['id'];
+
+ if ($srv_data_vrednost[$other['id']]) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu
+ $_checked = ($sel ? ' checked' : '');
+
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+
+ $already_set_mv = array();
+ $sql_grid_mv = sisplet_query("SELECT naslov, other FROM srv_vrednost WHERE spr_id='" . $spremenljivka . "' AND other != 0");
+ while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) {
+ $already_set_mv[$row_grid_mv['other']] = $row_grid_mv['naslov'];
+ }
+
+ if ((($row['alert_show_99'] > 0 && isset($already_set_mv['-99']) && $already_set_mv['-99'] == $other['naslov'])
+ || ($row['alert_show_98'] > 0 && isset($already_set_mv['-98']) && $already_set_mv['-98'] == $other['naslov'])
+ || ($row['alert_show_97'] > 0 && isset($already_set_mv['-97']) && $already_set_mv['-97'] == $other['naslov']))
+ && $_checked == ''
+ )
+ $hide_missing = true;
+
+ $naslov = Language::getInstance()->srv_language_vrednost($other['id']);
+ if ($naslov != '') $other['naslov'] = $naslov;
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' missing" id="vrednost_if_' . $other['id'] . '"' . ' ' . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '">';
+ echo '<input type="checkbox" name="vrednost_mv_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $other['id'] . '"' . $_checked . ' onclick="checkBranching(); checkMissing(this);"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $other['naslov'] . '</label>';
+ echo '</div>';
+ }
+
+
+ # če smo v quick_view mode ne omogočamo
+ if (get('quick_view') == false) {
+ $date_element = "#vrednost_" . $spremenljivka;
+
+ // Ce izbiramo tudi cas - V DELU
+ $timepicker = ($spremenljivkaParams->get('date_withTime') > 0) ? 'true' : 'false';
+
+ ?>
+ <script type="text/javascript">
+ $(document).ready(function () {
+ datepicker("<?=$date_element?>", <?=($_GET['a'] != 'preview_spremenljivka' ? 'true' : 'false')?>, <?=$timepicker?>);
+
+
+ <?php
+ # dodamo date range
+ echo Helper::getDatepickerRange($spremenljivka, $date_element);
+
+ echo '$( "' . $date_element . '" ).datepicker( "option", "closeText", \'' . self::$lang['srv_clear'] . '\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showOn", \'button\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showButtonPanel", true);';
+
+ // Gumb pocisti vrednost na dnu
+ echo '$("' . $date_element . '").datepicker( "option", {
+ beforeShow: function( input ) {
+ setTimeout(function() {
+ var clearButton = $(input )
+ .datepicker( "widget" )
+ .find( ".ui-datepicker-close" );
+ clearButton.unbind("click").bind("click",function(){$.datepicker._clearDate( input );});
+ }, 1 );
+ }
+ });';
+
+ // Moznost, da so disablani specificni datumi - V DELU
+ if(false){
+
+ $disabled_dates = array('01-01-2017', '03-01-2017');
+
+ // Ce imamo kaksen datum nastavljen
+ if(!empty($disabled_dates)){
+ $disabled_dates_string = implode('","', $disabled_dates);
+ $disabled_dates_string = '"'.$disabled_dates_string.'"';
+
+ echo '$("' . $date_element . '").datepicker("option", "beforeShowDay", DisableSpecificDates);';
+
+ echo 'function DisableSpecificDates(date) {
+ var disableddates = ['.$disabled_dates_string.'];
+
+ var string = jQuery.datepicker.formatDate(\'dd-mm-yy\', date);
+ return [disableddates.indexOf(string) == -1];
+ }';
+ }
+ }
+
+ // TODO zakaj je tole? - $condition manjka in itak ne dela
+ # mogoče za missinge pr datumu ??
+ /*echo
+ '$("input#text_' . $condition . '").bind("keyup", {}, function(e) {' .
+ ' checkBranchingDate(); $(\'#vrednost_' . $spremenljivka . '\').trigger(\'change\'); return false; ' .
+ '});';*/
+ ?>
+ });
+
+ </script>
+ <?php
+
+ }
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DoubleController.php b/main/survey/app/Controllers/Vprasanja/DoubleController.php
new file mode 100644
index 0000000..b357be3
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DoubleController.php
@@ -0,0 +1,841 @@
+<?php
+/***************************************
+ * Description: Dobule grid in double checkbox
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 3
+ * tip 16 - enota 3
+ *
+ * Izris dvojnega multigrida/multicheckboxa
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+
+class DoubleController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DoubleController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za doublegrid
+ */
+ public function grid($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loop spremenljivkah, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+ // izracuni za sirino celic
+ $size = 2 * $row['grids'];
+ $colspan = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='1' ORDER BY vrstni_red");
+
+ $space = false;
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ $colspan++;
+
+ if (!$space) {
+ $colspan++;
+ $space = true;
+ }
+ }
+
+ }
+
+ //se za desni del grida
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='2' ORDER BY vrstni_red");
+
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ //$naslov = Language::srv_language_grid($row['id'], $row_grid2['id']);
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+ }
+
+ $indexLanguage++;
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table doublegrid">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '<col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ //izpis podnaslovov posameznih delov grida
+ # priredimo podnaslovov če je prevod ankete
+ $podnaslov1 = Language::srv_language_grid_podnaslov($row['id'], 1);
+ $podnaslov2 = Language::srv_language_grid_podnaslov($row['id'], 2);
+ if ($podnaslov1 != '') {
+ $row['grid_subtitle1'] = $podnaslov1;
+ }
+ if ($podnaslov2 != '') {
+ $row['grid_subtitle2'] = $podnaslov2;
+ }
+ # priredimo podnaslovov če je prevod ankete - konec
+
+ echo ' <tr>' . "\n\r";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle1'] . '</td>' . "\n";
+ echo ' <td></td>';
+ echo ' <td></td>';
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle2'] . '</td>' . "\n";
+ echo ' </tr>' . "\n\r";
+
+ echo ' <tr>' . "\n\r";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+
+ #double grid space
+ echo '<td></td>';
+ echo '<td class="double"></td>';
+
+ //se za desni del grida
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja) - za part 1
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='1' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+ # cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja) - za part 2
+ $srv_data_grid2 = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='2' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid2[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ $grid_id2 = $srv_data_grid2[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</td>' . "\n";
+ echo '<td></td>' . "\n";
+ }
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+ # izpišemo radio grida
+
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<td class="missing">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ # ni missing vrednost
+ echo '<td class="category">';
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ }
+ }
+
+ #double grid space
+ echo '<td></td>';
+ echo '<td class="double"></td>';
+
+
+ //DESNI DEL GRIDA
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids2) > 0) {
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids2[$i]['id'] == $grid_id2) {
+ $is_missing = true;
+ }
+ }
+ }
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids2[$i]['id'];
+ # izpišemo radio grida
+
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<td class="missing">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . (($grid_id2 == $value && $grid_id2 != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ # ni missing vrednost
+ echo '<td class="category">';
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . (($grid_id2 == $value && $grid_id2 != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids2[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+ /**
+ * @desc prikaze vnosno polje za doublecheckgrid - TODO!!
+ */
+ public function checkGrid($spremenljivka)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // izracuni za sirino celic
+ $size = 2 * $row['grids'];
+ $colspan = $row['grids'];
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hideLabels == false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+
+ $css = ' style = "width: ' . $gridWidth . '%;" ';
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids1 = array();
+ $srv_grids2 = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ //$sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY part, vrstni_red");
+ $sql_grid1 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part = '1' ORDER BY vrstni_red");
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part = '2' ORDER BY vrstni_red");
+
+ $space = false;
+
+ //levi del
+ while ($row_grid1 = mysqli_fetch_assoc($sql_grid1)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid1['id']);
+ if ($naslov != '') {
+ $row_grid1['naslov'] = $naslov;
+ }
+ $srv_grids1[$row_grid1['id']] = $row_grid1;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid1['other'] != 0) {
+ $mv_count++;
+
+ if ($row_grid1['part'] == 1)
+ $colspan++;
+
+ if (!$space) {
+ $colspan++;
+ $space = true;
+ }
+ }
+ }
+
+ //desni del
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+
+ if ($row_grid2['part'] == 1)
+ $colspan++;
+
+ if (!$space) {
+ $colspan++;
+ $space = true;
+ }
+ }
+ $indexLanguage++;
+ }
+
+ echo ' <table class="grid_table doublecheckgrid">' . "\n";
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '<col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ //ipis podnaslovom posameznih delv grida
+ echo ' <tr>' . "\n\r";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle1'] . '</td>' . "\n";
+ echo ' <td></td>';
+ echo ' <td></td>';
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle2'] . '</td>' . "\n";
+ echo ' </tr>' . "\n\r";
+
+ echo ' <tr>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ # če imamo enoto povečamo št. stoplcev
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30)
+ $cellsize = round(80 / $size);
+ else
+ $cellsize = 'auto';
+
+ $spacesize = round(80 / $size / 4);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1);
+ //default sirina
+ if ($taWidth == -1)
+ //$taWidth = 10;
+ $taWidth = round(50 / $size);
+
+ $bg = 1;
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids1) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids1 AS $g_id => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+
+ //vmesno polje z mejo
+ if ($count == $colspan) {
+ echo '<td></td><td class="double"></td>';
+ $first_missing_value = true;
+ }
+ $count++;
+ }
+ }
+
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids2 AS $g_id => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ $count++;
+ }
+ }
+
+
+
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $srv_data_cache = array();
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids1) > 0) {
+ foreach ($srv_grids1 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids1[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ if (count($srv_grids2) > 0) {
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids2[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' : '').'>';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ if (count($srv_grids1) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids1 AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+ # izpišemo labelo grida
+ if ($srv_grid['other'] != 0) {
+ # imamo missing polje
+ echo '<td class="missing">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+
+ //vmesno polje z mejo
+ if ($count == $colspan) {
+ echo '<td></td><td class="double"></td>';
+ $first_missing_value = true;
+ }
+ $count++;
+ }
+ }
+
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+ # izpišemo labelo grida
+ if ($srv_grid['other'] != 0) {
+ # imamo missing polje
+ echo '<td class="missing">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ $count++;
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo ' </table>' . "\n";
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DragDropController.php b/main/survey/app/Controllers/Vprasanja/DragDropController.php
new file mode 100644
index 0000000..4b4f4bc
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DragDropController.php
@@ -0,0 +1,914 @@
+<?php
+/***************************************
+ * Description: Prikaže vprašanje Drag and drop (multigrid, multicheckbox, radio, checkbox, select
+ *
+ * Vprašanje je prisotno:
+ * tip 16 - enota 9 in enota 3
+ * tip 6 - enota 9
+ * tip 1, 2, 3 - orientation 8
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+
+// Iz admin/survey
+use enkaParameters;
+use SurveySetting;
+use Common;
+
+
+// Vprašanja
+
+class DragDropController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DragDropController();
+ }
+
+ /**
+ * @desc prikaze vnos za drag-drop
+ */
+ public function display($spremenljivka)
+ {
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ // Pri WebSM anketi nimamo userja, zato ne izvajamo ajaxa
+ $ajax = 'true';
+ $usr_id = get('usr_id');
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+ $ajax = 'false';
+ $usr_id = 0;
+ }
+
+ // Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+ //n>k // prestavljanje
+ //if ($row['design'] == 0 && get('mobile') == 0){
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+
+ //izracun visine
+ $num = mysqli_num_rows($sql1); //stevilo trenutnih kategorij odgovorov v levem bloku
+ $size = $num * 37;
+
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ //echo '<div id="vrednost_if_'.$row1['id'].'">';
+ echo '<table class="ranking_table">';
+ echo '<tr>';
+ //zaslon razdelimo na dva dela - izris leve strani
+ echo '<td>';
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_ranking_avaliable_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_avaliable_categories' . $_lang);
+ if ($srv_ranking_avaliable_categories == '') $srv_ranking_avaliable_categories = self::$lang['srv_ranking_avaliable_categories'];
+
+ echo '<b>' . $srv_ranking_avaliable_categories . ':</b>';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone" style="height:' . $size . 'px">';
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ echo '<ul>';
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>';
+ }
+
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ //$this->display_DropBox($row1['naslov'], $row1['id']);
+ $value = $row1['naslov'];
+
+ // Datapiping
+ $value = Helper::dataPiping($value);
+
+ $vre_id = $row1['id'];
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row1['other']; //drugo, po navadi missing
+
+ //********* potrebno za pravilno prikazovanje predogleda
+
+ if(isset($_GET['a'])){
+ if($_GET['a'] == 'preview_spremenljivka'){
+ $preview_spremenljivka = 1;
+ echo '
+ <script>
+ var usr_id = 0;
+ </script>
+ ';
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ //********* potrebno za pravilno prikazovanje predogleda - konec
+
+ ?>
+ <script>
+ draggableOnDroppable[<?=$vre_id?>] = false; //inicializacija spremenljivke, ki belezi, ali je odgovor prisoten v ustreznem kontejnerju
+ draggableOver[<?=$spremenljivka?>] = false;
+
+ $(document).ready(function () {
+ Draggable(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$other?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ //echo '<div id="vrednost_if_'.$id.'" class="variabla">';
+ //echo '</div>'; //vrednost_if_ID
+ //div ki vsebuje vrednost
+ //if($length > 30)
+ // if($length > 90){
+ // $niz = substr($value, 0, 90);
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // }
+ // else
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ //else{
+ //echo '<div id="'.$class.'_'.$id.'" class="'.$class.' '.$c.'">'.$value.'</div>'."\n";
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ //}
+ }
+
+ echo '</li>' . "\n";
+ echo '</ul>';
+ echo '</div>'; //half_$spremenljivka
+ echo '</td>';
+
+ //srednja celica (stevilo prenesenih in spodaj puscica)
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<td class="middle">';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<td class="middle_mobile">';
+ }
+ echo '<b></b>';
+ echo '<img src="' . self::$site_url . 'main/survey/skins/Modern/arrow.png" alt="arrow">';
+ echo '</td>';
+
+ //izris desne strani
+ echo '<td>';
+
+ echo '<b>' . self::$lang['srv_drag_drop_answers'] . ':</b>';
+
+ echo '<div class="dropholder">'; // ker na td ne primer position relative za nastavit position absolute na dropzone
+
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $this->display_DropBox($row1['naslov'], $row1['id']);
+ }
+
+ //echo '<div id="vrednost_if_'.$id.'" class="variabla">';
+ //echo '<div id="vrednost_if_" class="variabla">';
+ //echo '</div>'; //vrednost_if_ID
+
+// echo '</div>'; //half2_$spremenljivka
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<ul>';
+ echo '<li>
+ <div id="half2_frame_dropping_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>
+ </li>' . "\n";
+ echo '</ul>';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<ul>';
+ echo '<li>
+ <div id="half2_frame_dropping_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>
+ </li>' . "\n";
+ echo '</ul>';
+ }
+
+ echo '</div>'; //half2_$spremenljivka
+ echo '</div>'; //dropholder
+
+ echo '</td>';
+
+
+ echo '</tr>';
+ echo '</table>';
+
+ //Gumb za resetiranje
+ echo '<div class="buttonsHeatmap">';
+ //echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="Ponastavi">';
+ echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="'.$lang['srv_drag_and_drop_reset_button'].'">'; //srv_drag_and_drop_reset_button
+ echo '</div>';
+
+ echo '</div>';
+ //}
+
+
+ ?>
+ <script>
+ $(document).ready(function () {
+ DragDropDelovanje(<?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, usr_id, <?=$num?>, <?=get('mobile')?>, <?=$checkbox_limit?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+
+ //preveri, ce je ze kaj v bazi. Pomembno, za prikazovanje ze odgovorjenih zadev, ko uporabnik gre na prejsnjo stran ali kaj podobnega
+ $sql2_PP = sisplet_query("SELECT spr_id, vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+
+ while ($row2_PP = mysqli_fetch_array($sql2_PP)) {
+
+ $spr_id_b = $row2_PP["spr_id"];
+ $vre_id_b = $row2_PP["vre_id"];
+
+ if (!empty($row2_PP)) { //ce je ze nekaj v bazi
+
+ ?>
+ <script>
+ $(document).ready(function () {
+ var other = $('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').attr('missing');
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ //console.log(other);
+ //draggableOnDroppable[<?=$spr_id_b?>] = true; //odgovor je prisoten
+ if (<?=$row['tip']?> == 1
+ )
+ { //ce je samo en mozen odgovor
+ //if( (<?=$row['tip']?> == 1) || (<?=$row['tip']?> == 2 && <?=$other?> != 0) ){ //ce je samo en mozen odgovor
+ $('#half2_frame_dropping_<?=$spr_id_b?>')
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ //.droppable( 'disable' ); //onemogoci prenos drugega odgovora
+ }
+ //else if (<?=$row['tip']?> == 2 && other != 0) {
+ else
+ if (other != 0) {
+ $('#half2_frame_dropping_<?=$spr_id_b?>')
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ //.droppable( 'disable' ); //onemogoci prenos drugega odgovora
+ //console.log('Je missing');
+ }
+ else {
+ $('#half2_frame_dropping_<?=$spr_id_b?>')
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ //console.log('Ni missing');
+ }
+ });
+ </script>
+ <?
+ }
+ }
+ }
+
+ /**
+ * @desc prikaze vnos za drag-drop v grid
+ */
+ public function grid($spremenljivka)
+ {
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ //***********za skatlasto obliko
+ $display_drag_and_drop_new_look = ($spremenljivkaParams->get('display_drag_and_drop_new_look') ? $spremenljivkaParams->get('display_drag_and_drop_new_look') : 0); //za checkbox
+ //***********za skatlasto obliko - konec
+
+ $quick_view = json_encode(get('quick_view'));
+
+ // Pri WebSM anketi nimamo userja, zato ne izvajamo ajaxa
+ $ajax = 'true';
+ $usr_id = get('usr_id');
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+ $ajax = 'false';
+ $usr_id = 0;
+ }
+
+ //n>k // prestavljanje
+ //if ($row['design'] == 0 && get('mobile') == 0){
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+
+ //izracun visine
+ $num = mysqli_num_rows($sql1); //stevilo trenutnih kategorij odgovorov v levem bloku
+ $size = $num * 37;
+
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ //echo '<div id="vrednost_if_'.$row1['id'].'">';
+ echo '<table class="ranking_table">';
+ echo '<tr>';
+ //zaslon razdelimo na dva dela - izris leve strani
+ echo '<td id="left_frame_'.$spremenljivka.'">';
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_ranking_avaliable_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_avaliable_categories' . $_lang);
+ if ($srv_ranking_avaliable_categories == '') $srv_ranking_avaliable_categories = self::$lang['srv_ranking_avaliable_categories'];
+
+ echo '<b>' . $srv_ranking_avaliable_categories . ':</b>';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone" style="height:' . $size . 'px">';
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<ul>';
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<ul>';
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>';
+
+ }
+
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ //$this->display_DropBox($row1['naslov'], $row1['id']);
+ $value = $row1['naslov'];
+
+ // Datapiping
+ $value = Helper::dataPiping($value);
+
+ $vre_id = $row1['id'];
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ //if($display_drag_and_drop_new_look != 1){
+ $class = 'ranking';
+/* }else if($display_drag_and_drop_new_look == 1){
+ $class = 'drag_and_drop_box';
+ } */
+
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+ $c = '';
+ $other = $row1['other']; //drugo, po navadi missing
+
+ //********* potrebno za pravilno prikazovanje predogleda
+ if(isset($_GET['a'])){
+ if($_GET['a'] == 'preview_spremenljivka'){
+ $preview_spremenljivka = 1;
+ echo '
+ <script>
+ var usr_id = 0;
+ </script>
+ ';
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ //********* potrebno za pravilno prikazovanje predogleda - konec
+
+
+ ?>
+ <script>
+ //spremenljvke, ce se ne uporablja polj
+ //draggableOnDroppable[<?=$vre_id?>] = false; //inicializacija spremenljivke, ki belezi, ali je trenutna kategorija odgovora prisotna kontejnerju/okvirju
+
+ skatlastOkvir[<?=$spremenljivka?>] = <?=$display_drag_and_drop_new_look?>; //belezi, ali je okvir skatlaste oblike
+ //draggableOverDroppable[<?=$vre_id?>] = false;
+ data_after_refresh[<?=$spremenljivka?>] = false;
+ frame_total_height_right[<?=$spremenljivka?>] = 0;
+ last_vre_id[<?=$spremenljivka?>] = 0;
+ vre_id_global[<?=$spremenljivka?>] = 0;
+ last_indeks[<?=$spremenljivka?>] = 0;
+ last_drop[<?=$vre_id?>] = 0;
+ //num_grids_global[<?=$spremenljivka?>] = 0;
+ indeks_global[<?=$spremenljivka?>] = 0;
+ num_grids_global[<?=$spremenljivka?>] = <?=$row['grids']?>;//stevilo okvirjev, pomembno za revert kategorije odgovora
+ cat_pushed[<?=$spremenljivka?>] = false;
+ draggable_global[<?=$vre_id?>] = 0;
+ var from_left = [];
+ from_left[<?=$vre_id?>] = true;
+ //console.log("from_left[<?=$vre_id?>]: "+from_left[<?=$vre_id?>]);
+ //spremenljvke, ce se ne uporablja polj - konec
+
+ //spremenljivke kot polja polj
+ draggableOnDroppable[<?=$vre_id?>] = new Array(2); //inicializacija spremenljivke, ki belezi, ali je trenutna kategorija odgovora prisotna kontejnerju/okvirju
+ draggableOverDroppable[<?=$vre_id?>] = new Array(2);
+ for (i = 1; i <= num_grids_global[<?=$spremenljivka?>]; i++) {
+ draggableOnDroppable[<?=$vre_id?>][i] = false;
+ draggableOverDroppable[<?=$vre_id?>][i] = false;
+ }
+ //spremenljivke kot polja polj - konec
+
+
+ $(document).ready(function () {
+ //if(<?=$display_drag_and_drop_new_look?> == 0){
+ GridDraggable(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$other?>, <?=get('mobile')?>, <?=$display_drag_and_drop_new_look?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+/* }
+ else if(<?=$display_drag_and_drop_new_look?> == 1){
+ //GridDraggableBox(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', <?=$usr_id?>, <?=$other?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ GridDraggableBox(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$other?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ } */
+ });
+ </script>
+ <?
+ //echo '<div id="vrednost_if_'.$id.'" class="variabla">';
+ //echo '</div>'; //vrednost_if_ID
+ //div ki vsebuje vrednost
+ //if($length > 30)
+ // if($length > 90){
+ // $niz = substr($value, 0, 90);
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // }
+ // else
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ //else{
+ //echo '<div id="'.$class.'_'.$id.'" class="'.$class.' '.$c.'">'.$value.'</div>'."\n";
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ //}
+ }
+
+ echo '</li>' . "\n";
+ echo '</ul>';
+ echo '</div>'; //half_$spremenljivka
+ echo '</td>';
+
+ //srednja celica (stevilo prenesenih in spodaj puscica)
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<td class="middle">';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<td class="middle_mobile">';
+ }
+ echo '<b></b>';
+ echo '<img src="' . self::$site_url . 'main/survey/skins/Modern/arrow.png" alt="arrow">';
+ echo '</td>';
+
+ //izris desne strani***********************************************************************************
+
+ echo '<td id="right_frame_'.$spremenljivka.'">';
+
+ echo '<b>' . self::$lang['srv_drag_drop_answers'] . ':</b>';
+
+ echo '<div class="dropholder">'; // ker na td ne primer position relative za nastavit position absolute na dropzone
+
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $this->display_DropBox($row1['naslov'], $row1['id']);
+ }
+
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$spremenljivka' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($spremenljivka, $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # Izpišemo TOP vrstico z labelami
+ //if (count($srv_grids) > 0) {
+ /* $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>'."\n";
+ $first_missing_value = false;
+ }
+ # izpišemo labelo grida
+ //echo ' <td class="'.($srv_grid['other']==0?'category':'missing').' '.$cssAlign.'">'.$srv_grid['naslov'].'</td>'."\n";
+ echo $srv_grid['naslov'];
+ } */
+ //}
+
+
+ //glede na število gridov, dodati ustrezno stevilo <li> oz. okvirjev
+ echo '<ul>';
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ /* if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>'."\n";
+ $first_missing_value = false;
+ } */
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ if($display_drag_and_drop_new_look == 0){
+ echo '<li>
+ <div class="frame_dropping_titles">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ }else if($display_drag_and_drop_new_look == 1){
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping_box" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ echo '<li>
+ <div class="frame_dropping_titles_box">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ }
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+
+ if($display_drag_and_drop_new_look == 0){
+ echo '<li>
+ <div class="frame_dropping_titles_mobile">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ }else if($display_drag_and_drop_new_look == 1){
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping_box_mobile" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ echo '<li>
+ <div class="frame_dropping_titles_box_mobile">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ }
+ }
+ ?>
+ <script>
+ $(document).ready(function () {
+ //ce imamo missing, je potrebno povecati stevilo grid-ov oz. okvirjev
+ if (<?=$srv_grid['other']?> !=
+ '0'
+ )
+ {
+ //console.log("Imamo missing!");
+ num_grids_global[<?=$spremenljivka?>] = num_grids_global[<?=$spremenljivka?>] + 1;
+
+ }
+ //if(<?=$display_drag_and_drop_new_look?> == 0){
+ GridDragDropDelovanje(num_grids_global[<?=$spremenljivka?>],<?=$i?>, <?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, usr_id, <?=$num?>, <?=get('mobile')?>, <?=$display_drag_and_drop_new_look?>); //poklici funkcijo za ureditev draggable in droppable
+/* }
+ else if(<?=$display_drag_and_drop_new_look?> == 1){
+ //GridDragDropDelovanjeBox(num_grids_global[<?=$spremenljivka?>],<?=$i?>, <?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, <?=$usr_id?>, <?=$num?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ GridDragDropDelovanjeBox(num_grids_global[<?=$spremenljivka?>],<?=$i?>, <?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, usr_id, <?=$num?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ } */
+ });
+ </script>
+ <?
+ }
+ ?>
+ <script>
+ $(document).ready(function () {
+ //console.log($('#spremenljivka_'+<?=$spremenljivka?>).css('height'));
+ var spremenljivka = <?=$spremenljivka?>;
+ var ajax = <?=$ajax?>;
+ var site_url = '<?=self::$site_url?>';
+ var num_grids = num_grids_global[<?=$spremenljivka?>];
+
+ //Ureditev povrnitve odgovorov (iz desne strani) v levo
+ $('#resetDragDrop_'+spremenljivka).click(function(){
+
+ var rightFrameHasChildren = ($('#half2_'+spremenljivka).find('.ranking').length ? 'Da' : 'Ne');
+ //console.log("Imamo kaj v desnem okvirju? "+rightFrameHasChildren);
+
+ if (rightFrameHasChildren == 'Da'){
+
+ //pobrisi vse iz baze
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data_reset', {spremenljivka: spremenljivka, usr_id: usr_id, anketa: srv_meta_anketa_id, tip: <?=$row['tip']?>}); //post-aj potrebne podatke
+ }
+
+ $('#half2_'+spremenljivka).find('.ranking').each(function(indeks) { //preleti vse prisotne kategorije odgovorov v desnem okvirju
+ var id = $(this).attr('id');
+ //console.log(index+1 + ": " + id);
+ var indeks = indeks+1;
+ var defaultHeight = 30; //default, povrnjena visina posameznega okvirja
+ var parent = $(this).parent().attr('id');
+ //console.log("parent:"+parent);
+ var index = parent.substring(21,22); //indeks okvirja v katerem se nahaja trenutna kategorija odgovora
+ //console.log("index:"+index);
+ //console.log("id:"+id);
+
+ $('#'+parent).outerHeight(defaultHeight); //povrni visino posameznega okvirja
+ //var parentHeight = $('#'+parent).outerHeight(true);
+ //console.log("parent:"+parent+" with height:"+parentHeight);
+
+ dynamic_question_height(spremenljivka, num_grids, <?=get('mobile')?>, <?=$display_drag_and_drop_new_look?>); //povrni visino celotnega vprasanja
+
+ ResetButtonHeight(spremenljivka);//povrni gumb na zacetno visino
+ if(<?=$display_drag_and_drop_new_look?>){
+ $(this).removeClass('drag_and_drop_box_right');
+ $(this).removeClass('drag_and_drop_box_right_after_refresh');
+ $(this).addClass('drag_and_drop_right');
+ }
+
+
+ //var vre_id = $(this).val();
+ var vre_id = $(this).attr('value');
+ //console.log("vre_id:"+vre_id);
+
+ if(<?=$row['tip']?> == 6){
+ $('#half_frame_dropping_'+spremenljivka).prepend(this); //pripopaj preneseno kategorijo na zacetek seznama kategorij na levi strani
+ //uredi parametre za nadalnje delovanje odgovarjanja
+ draggableOnDroppable[vre_id] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ draggableOverDroppable[vre_id] = false;
+ last_indeks[spremenljivka] = 0;
+ last_drop[vre_id] = 0;
+ last_vre_id[spremenljivka] = 0;
+ //uredi parametre za nadalnje delovanje odgovarjanja - konec
+ }else if(<?=$row['tip']?> == 16){
+ $(this).remove(); //odstrani kategorijo odgovora iz okvirja
+
+ //uredi parametre za nadalnje delovanje odgovarjanja
+ draggableOnDroppable[vre_id][index] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ draggableOverDroppable[vre_id][index] = false;
+ //uredi parametre za nadalnje delovanje odgovarjanja - konec
+ }
+ from_left[vre_id] = true;
+ });
+ }
+ });
+ });
+ </script>
+ <?
+
+
+ echo '</ul>';
+
+
+ echo '</div>'; //half2_$spremenljivka
+ echo '</div>'; //dropholder
+
+ echo '</td>';
+ //************************************************ konec izrisa desne strani
+
+ echo '</tr>';
+ echo '</table>';
+
+ //Gumb za resetiranje
+ echo '<div class="buttonsHeatmap">';
+ //echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="Ponastavi">';
+ echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="'.$lang['srv_drag_and_drop_reset_button'].'">'; //srv_drag_and_drop_reset_button
+ echo '</div>';
+
+
+ echo '</div>';
+ //}
+
+ //********* urejanje prikaza ob morebitnem refresh-u strani ali prehod na naslednjo oz. prejsnjo stran
+ //preveri, ce je ze kaj v bazi. Pomembno, za prikazovanje ze odgovorjenih zadev, ko uporabnik gre na prejsnjo stran ali kaj podobnega
+ if ($row['tip'] == 6) {
+ $sql2_PP = sisplet_query("SELECT spr_id, vre_id, grd_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ } elseif ($row['tip'] == 16) {
+ //$sql2_PP = sisplet_query("SELECT spr_id, vre_id, grd_id FROM srv_data_checkgrid WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql2_PP = sisplet_query("SELECT spr_id, vre_id, grd_id FROM srv_data_checkgrid_active WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ }
+
+
+ ?>
+ <script>
+
+ var cat_margin_left = 10 + 5 * 2 + 1 * 2; //hrani rob za ureditev visine levega okvirja = margin_spodnji + padding(spredi pa zadi) + border(spredi pa zadi) + neznanka
+ //var title_heigth = 26; //visina okvricka z naslovom
+ //var title_heigth = $('#spremenljivka_<?=$spremenljivka?> .naslov').height();
+ //console.log("Title height from survey: "+title_heigth);
+ var height_beside = 40; //visina od zacetka vprasanja do prvega okvirja (in malo po zadnjem okvirju)
+ var final_height_right_block_PP = 0; //hrani koncno visino desnega bloka, torej vseh prisotnih okvirjev
+ var top_cat_right = 30;
+ var left_cat = -6;
+
+ </script>
+ <?
+ $i = 0;
+ while ($row2_PP = mysqli_fetch_array($sql2_PP)) {
+
+ $spr_id_b = $row2_PP["spr_id"];
+ $vre_id_b = $row2_PP["vre_id"];
+ $grd_id_b = $row2_PP["grd_id"];
+
+ if (!empty($row2_PP)) { //ce je ze nekaj v bazi
+ ?>
+ <script>
+ $(document).ready(function () {
+
+ data_after_refresh[<?=$spremenljivka?>] = true; //oznacimo, da so prisotni podatki po refresh-u
+ draggableOnDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true; //oznacimo, da je trenutna kategorija odgovora v okvirju z dolocenim indeksom
+ draggableOverDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true;
+ last_drop[<?=$vre_id_b?>] = <?=$grd_id_b?>; //pomembno za revert kategorije odgovora in belezenje podatkov v bazo ob refreshu
+ vre_id_global[<?=$spr_id_b?>] = <?=$vre_id_b?>; //pomembno za revert kategorije odgovora ob refreshu
+ //uredi visino trenuntega okvirja glede na visino trenutne kategorije odgovora
+ frame_height(<?=$spr_id_b?>, <?=$vre_id_b?>, <?=$grd_id_b?>, false);
+
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ var desniOkvirRefresh = $('#half2_frame_dropping_<?=$grd_id_b?>_<?=$spr_id_b?>');
+ var trenutnaKategorija = $('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>');
+ if (<?=$row['tip']?> == 6)
+ { //ce je tabela - en odgovor
+ if(<?=$display_drag_and_drop_new_look?> == 0){
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ }else if(<?=$display_drag_and_drop_new_look?> == 1){ //ce so skatle
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').css({left: left_cat})); //prenesi ustrezni odgovor
+ trenutnaKategorija.removeClass('drag_and_drop');
+ trenutnaKategorija.addClass('drag_and_drop_box_right_after_refresh');
+ //var pravaVisina = calcPravaVisina(desniOkvirRefresh, 0); //visina/pozicija prenesene kategorije v desnem okvirju
+ /* desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').css({top: pravaVisina})); //prenesi ustrezni odgovor */
+ }
+ }
+ else
+ if (<?=$row['tip']?> == 16)
+ {
+ if(<?=$display_drag_and_drop_new_look?> == 0){
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone()) //kloniraj ustrezni odgovor
+ }else if(<?=$display_drag_and_drop_new_look?> == 1){
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone().css({left:left_cat})) //kloniraj ustrezni odgovor
+
+ desniOkvirRefresh.children(trenutnaKategorija).removeClass('drag_and_drop');
+ desniOkvirRefresh.children(trenutnaKategorija).addClass('drag_and_drop_box_right_after_refresh');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+
+ }
+/* if(<?=$display_drag_and_drop_new_look?> == 0){
+ $('#half2_frame_dropping_<?=$grd_id_b?>_<?=$spr_id_b?>') //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone()) //kloniraj ustrezni odgovor
+ }else if(<?=$display_drag_and_drop_new_look?> == 1){
+ $('#half2_frame_dropping_<?=$grd_id_b?>_<?=$spr_id_b?>') //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone().css({top: (top_cat_right), left:-6})) //kloniraj ustrezni odgovor
+ } */
+ }
+
+/* //console.log('Nekaj je v bazi!');
+ data_after_refresh[<?=$spremenljivka?>] = true; //oznacimo, da so prisotni podatki po refresh-u
+ draggableOnDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true; //oznacimo, da je trenutna kategorija odgovora v okvirju z dolocenim indeksom
+ draggableOverDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true;
+ last_drop[<?=$vre_id_b?>] = <?=$grd_id_b?>; //pomembno za revert kategorije odgovora in belezenje podatkov v bazo ob refreshu
+ vre_id_global[<?=$spr_id_b?>] = <?=$vre_id_b?>; //pomembno za revert kategorije odgovora ob refreshu
+ //uredi visino trenuntega okvirja glede na visino trenutne kategorije odgovora
+ frame_height(<?=$spr_id_b?>, <?=$vre_id_b?>, <?=$grd_id_b?>, false);
+
+ checkBranching(); */
+ });
+ </script>
+ <?
+ }
+ }
+
+ //if(!empty($row2_PP)){
+ if (mysqli_num_rows($sql2_PP) != 0) {
+ ?>
+ <script>
+ $(document).ready(function () {
+ data_after_refresh[<?=mysqli_num_rows($sql2_PP)?>] = <?=mysqli_num_rows($sql2_PP)?>;
+ refresh[<?=$spremenljivka?>] = 1;
+ //console.log(<?=$vre_id?>);
+ //console.log(last_drop[<?=$vre_id?>]);
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ //question_height(<?=$spr_id_b?>, <?=$row['grids']?>);
+ //question_height(<?=$spr_id_b?>, num_grids_global[<?=$spremenljivka?>]);
+ //dynamic_question_height(<?=$spr_id_b?>, num_grids_global[<?=$spremenljivka?>]);
+ num_grids_global[<?=$spremenljivka?>] = <?=$row['grids']?>;//stevilo okvirjev, pomembno za revert kategorije odgovora ob refreshu
+ });
+ </script>
+ <?
+ //}
+ }
+ //********* konec - urejanje prikaza ob morebitnem refresh-u strani ali prehod na naslednjo oz. prejsnjo stran
+ }
+
+ /**
+ * @desc izrisemo drop okno
+ */
+ public function display_DropBox($value, $id)
+ {
+
+ $length = strlen($value);
+ $style = '';
+ $class = 'ranking';
+ $c = '';
+
+ //div ki vsebuje vrednost
+ if ($length > 30)
+ if ($length > 90) {
+ $niz = substr($value, 0, 90);
+ echo '<div title="' . strip_tags($value) . '" id="' . $class . '_' . $id . '" class="' . $class . '_long ' . $c . '">' . $niz . '...</div>' . "\n";
+ } else
+ echo '<div title="' . strip_tags($value) . '" id="' . $class . '_' . $id . '" class="' . $class . '_long ' . $c . '">' . $value . '</div>' . "\n";
+ else
+ echo '<div id="' . $class . '_' . $id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n";
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DynamicController.php b/main/survey/app/Controllers/Vprasanja/DynamicController.php
new file mode 100644
index 0000000..57e0127
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DynamicController.php
@@ -0,0 +1,725 @@
+<?php
+/***************************************
+ * Description: Prikaže vsa polja iz dinamičnega multigrida/multicheckbox horizontalni/vertikalni
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 3 - dynamic_mg 1, 3, 5
+ * tip 16 - enota 3 - dynamic_mg 1, 3, 5
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class DynamicController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DynamicController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za dinamicen multigrid
+ */
+ public function multigrid($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+
+ //************************ za izris traku
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox trak
+ $trak_num_of_titles = ($spremenljivkaParams->get('trak_num_of_titles') ? $spremenljivkaParams->get('trak_num_of_titles') : 0); //belezi stevilo nadnaslovov
+
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen @ diferencial ali klasicna tabela
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ $trak_class = 'trak_class';
+ $trak_class_input = 'trak_class_input';
+ $question = 'question_trak';
+ if ($row['enota'] == 1){ //ce je diferencial
+ $gridWidth = 15; //za sirino celic skrajno levo pa desno od traku
+ }
+ if($trak_num_of_titles != 0){
+ $display_trak_num_of_titles = 'style="display:none;"';
+ $trak_nadnaslov_table_td_width = 100 / $trak_num_of_titles; //spremenljivka za razporeditev sirine nadnaslovov @ traku
+ }
+ $display_trak_num_of_titles = '';
+
+/* ?>
+ <script>
+ $(document).ready(function(){
+ trak_edit_num_titles(<?=$row['grids']?>, <?=$spremenljivka?>, <?=$trak_num_of_titles?>, <?=json_encode($trak_nadnaslov)?>);
+ });
+ </script>
+ <? */
+ }else{
+ $trak_class = '';
+ $trak_class_input = '';
+ $question = 'question';
+ $display_trak_num_of_titles = 'style="display:none;"';
+ }
+
+ for($i = 1; $i <= $trak_num_of_titles; $i++){
+ $trak_nadnaslov[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.$i.'') ? $spremenljivkaParams->get('trak_nadnaslov_'.$i.'') : $lang['srv_new_text']);
+ }
+ //********************** za izris traku - konec
+
+
+
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ $size += 1;
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table dynamicmultigrid">' . "\n";
+
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+ if ($row['enota'] > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="differential">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ }
+ if (!$row['dynamic_mg'] == 3) {
+ echo '<colgroup>';
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ //vrstica z nadnaslovi
+ echo '<tr '.$display_trak_num_of_titles.' class="display_trak_num_of_titles_respondent_'.$row['id'].'">';
+ echo ' <td></td>';
+ echo ' <td></td>';
+ //for($j = 1; $j <= $trak_num_of_titles; $j++){
+ for ($j = 1; $j <= $row['grids']; $j++) {
+ //echo '<td>'.$j.'</td>';
+ if($j == 1){
+ $nadnaslov_floating = 'left';
+ }else if($j == $row['grids']){
+ $nadnaslov_floating = 'right';
+ }else{
+ $nadnaslov_floating = 'none';
+ }
+ echo '<td class="trak_inline_nadnaslov" grd="gr_'.$j.'"><div id="trak_nadnaslov_'.$j.'_'.$spremenljivka.'" name="trak_nadnaslov_'.$j.'" class="trak_inline_nadnaslov" style="float:'.$nadnaslov_floating.'; display:inline" '.(strpos($trak_nadnaslov[$j], $lang['srv_new_text'])!==false || $this->lang_id!=null ?' default="1"':'').'>' . $trak_nadnaslov[$j] . '</div></td>';
+
+ }
+ echo '</tr>';
+ //vrstica z nadnaslovi - konec
+
+ echo ' <tr>' . "\n";
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+
+ if($diferencial_trak != 1){ //ce ni traku
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }elseif($diferencial_trak == 1){ //ce je trak
+ # izpišemo ustrezno labelo grida
+ if($srv_grid['other'] == 0){ //ce je labela za kategorijo odgovora, naj bo prazno
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '"></td>' . "\n";
+ }else { //drugace, ce je labela za missing, izpisi labelo
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ }
+ }
+
+ if (!$row['dynamic_mg'] == 3) {
+ echo ' <td></td>' . "\n";
+ }
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $gridRow = 1;
+ $hide = false;
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $countVar = mysqli_num_rows($sql1);
+
+ // Stevilo vseh vrednosti
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '" value="' . $countVar . '" />';
+ // Indikator da v js vemo ali smo ravnokar naloudali stran ali pa smo samo premaknili vrstico (potrebno zaradi prikazovanja glede na ife v dolocenih primerih)
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '_load" value="1" />';
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $ifDisplay = ($row1['if_id'] > 0 ? ' if_hide' : '');
+ // Ce lahko prikazemo vrstico (se ni nobena izrisana in ni skrita z ifom) -> naslednjih ne izrisujemo vec
+ if ($hide == false && $row1['hidden'] == 0 && $row1['if_id'] == 0) {
+ $gridRowDisplay = '';
+ $hide = true;
+ } else
+ $gridRowDisplay = ' style="display:none;"';
+
+ $colspan = 0;
+
+ echo ' <tr id="vrednost_if_'. $row1['id'].'" seq="'.$gridRow.'" class="'.$spremenljivka.'_gridRow '.$spremenljivka.'_gridRow_'.$gridRow.' '.$ifDisplay.'" '.$gridRowDisplay.'>' . "\n";
+ echo ' <td class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</td>' . "\n";
+ echo '<td></td>' . "\n";
+
+ $colspan += 2;
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+
+ $colspan++;
+ }
+
+ $value = $srv_grids[$i]['id'];
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<td class="missing">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\'); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0) ){ //ce je trak
+ if ($gridRow < $countVar){
+ echo '<td onClick="checkBranching(); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 0); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');" id="trak_tbl_' . $row1['id'] . '_'.$srv_grid['vrstni_red'].'" class="category' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' '.$trak_class.' '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? 'trak_container_bg' : '').'">';
+ }else{
+ echo '<td onClick="checkBranching(); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 0); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '" id="trak_tbl_' . $row1['id'] . '_'.$srv_grid['vrstni_red'].'" class="category' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' '.$trak_class.' '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? 'trak_container_bg' : '').'">';
+ }
+ # ni missing vrednost
+ echo '<input vre_id = '.$row1['id'].' class="'.$trak_class_input.'" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '">';
+ echo '<label class="radio-button-label">'.$srv_grid['variable'];
+ //echo '<span ' . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '></span>'; //custom radio button
+ echo '</label>';
+ echo '</td>' . "\n";
+ }else{
+ # ni missing vrednost
+ echo '<td class="category">';
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\'); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ }
+
+ $colspan++;
+ }
+ }
+
+ # dodamo še enoto
+ if ($row['enota'] == 1) {
+ echo ' <td></td>' . "\n";
+ echo ' <td>' . $row1['naslov2'] . '</td>' . "\n";
+ $colspan += 2;
+ }
+
+ // puscice levo/desno
+ if ($row['dynamic_mg'] == 3) {
+
+ //echo ' <td style="height: 80px;">'."\n";
+ echo '</tr><tr class="gridRowArrows ' . $spremenljivka . '_gridRowArrows_' . $gridRow . ' ' . $ifDisplay . '" ' . $gridRowDisplay . '><td colspan="' . $colspan . '">';
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ if ($gridRow > 1)
+ echo ' <td><div title="' . self::$lang['back'] . '" id="arrow_left" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' <td><div id="dynamic_count" style="text-align: center;">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div></td>';
+ if ($gridRow < $countVar)
+ echo ' <td><div title="' . self::$lang['forward'] . '" id="arrow_right" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' </tr></table>' . "\n";
+ echo '</td>';
+ //echo ' </td>'."\n";
+
+ // paginacija
+ } elseif ($row['dynamic_mg'] == 5 || (get('mobile') == 1 && $mobile_tables > 0)) {
+
+ echo '</tr><tr class="gridRowArrows ' . $spremenljivka . '_gridRowArrows_' . $gridRow . ' ' . $ifDisplay . '" ' . $gridRowDisplay . '><td colspan="' . $colspan . '">';
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ for ($i = 1; $i <= $countVar; $i++) {
+ echo ' <td><div title="' . $i . '" id="sequence_number_' . $i . '" class="sequence_number sequence_number_'.$i.' ' . ($i == $gridRow ? ' active' : '') . '" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . $i . '\');">' . $i . '</div></td>';
+ }
+ echo ' </tr></table>' . "\n";
+ echo '</td>';
+
+ // puscice za naprej/nazaj
+ } else {
+
+ echo ' <td style="height: 80px;">' . "\n";
+ if ($gridRow > 1)
+ echo ' <div title="' . self::$lang['back'] . '" id="arrow_up" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' <div id="dynamic_count">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div>';
+ if ($gridRow < $countVar)
+ echo ' <div title="' . self::$lang['forward'] . '" id="arrow_down" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' </td>' . "\n";
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ $gridRow++;
+ }
+
+ echo '</table>' . "\n";
+
+ //************* za ureditev prilagajanja label stolpcev @TRAK
+ //prilagajanje trem opisnim nadnaslovom
+ $custom_column_label_option = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1);
+ echo '
+ <script>
+ change_custom_column_label_respondent(\'' . $row['grids'] . '\', \'' . $row['id'] . '\', \'' . $custom_column_label_option . '\');
+ </script>
+ ';
+ if($trak_num_of_titles != 0){
+ //prilagajanje stevilu izbranih nadnaslovov
+ ?>
+ <script>
+ $(document).ready(function(){
+ trak_edit_num_titles_respondent(<?=$row['grids']?>, <?=$spremenljivka?>, <?=$trak_num_of_titles?>, <?=json_encode($trak_nadnaslov)?>);
+ });
+ </script>
+ <?
+ }
+ //************* za ureditev prilagajanja label stolpcev @TRAK - konec
+ }
+
+ /**
+ * @desc prikaze vnosno polje za vertikalen dinamicen multigrid
+ */
+ public function verticalMultigrid($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox trak
+ //echo '<script>console.log("diferencial_trak: "+'.$diferencial_trak.'); </script>';
+ //echo '<script>console.log("dynamic_mg vertikal: "+'.$row['dynamic_mg'].'); </script>';
+
+ //CE JE TRAK - POJDI NA IZRIS VODORAVNE RAZLICICE
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen @ diferencial ali klasicna tabela
+ $this->multigrid($spremenljivka); //pojdi na zgornjo funkcijo za izris vodoravne različice
+ }else{ //CE NI TRAK, NADALJUJ Z IZRISOM NAVPICNE RAZLICICE
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ $size += 1;
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $gridRow = 1;
+ $hide = false;
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $countVar = mysqli_num_rows($sql1);
+
+ // Stevilo vseh vrednosti
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '" value="' . $countVar . '" />';
+ // Indikator da v js vemo ali smo ravnokar naloudali stran ali pa smo samo premaknili vrstico (potrebno zaradi prikazovanja glede na ife v dolocenih primerih)
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '_load" value="1" />';
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $ifDisplay = ($row1['if_id'] > 0 ? ' if_hide' : '');
+ // Ce lahko prikazemo vrstico (se ni nobena izrisana in ni skrita z ifom) -> naslednjih ne izrisujemo vec
+ if ($hide == false && $row1['hidden'] == 0 && $row1['if_id'] == 0) {
+ $gridRowDisplay = '';
+ $hide = true;
+ } else
+ $gridRowDisplay = ' style="display:none;"';
+
+ echo ' <div id="vrednost_if_'.$row1['id'].'" seq="'.$gridRow.'" class="'.$spremenljivka.'_gridRow '.$spremenljivka.'_gridRow_'.$gridRow.' '.$ifDisplay.'" '.$gridRowDisplay.'>' . "\n";
+
+ echo '<div ' . ($row['dynamic_mg'] == 4 ? ' style="float: left; width: 70%;"' : '') . '>';
+
+ echo '<div class="dynamic_mg_vrednost">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</div>';
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ $first_missing_value = false;
+ }
+ $value = $srv_grids[$i]['id'];
+ $grid_title = $srv_grids[$i]['naslov'];
+
+ // Datapiping
+ $grid_title = Helper::dataPiping($grid_title);
+
+ $smeski ='';
+ if(in_array($row['enota'], [11,12])){
+ $smeski = 'visual-radio-scale visual-radio-block';
+ }
+
+ # izpišemo radio grida
+ echo '<div class="variabla '.$smeski.'">';
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . '); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . ');' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo ' ' . $grid_title . '</label>';
+ } else {
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . '); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . '); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ if($row['enota'] == 11){
+ echo '<span class="enka-vizualna-skala siv-'.$row['grids'].$value.'"></span>';
+ }elseif($row['enota'] == 12){
+ echo '<span class="enka-custom-radio '.$spremenljivkaParams->get('customRadio').'"></span>';
+ }else {
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ }
+
+ echo ' ' . $grid_title . '</label>';
+ }
+ echo '</div>';
+ }
+ }
+
+ // Dodamo se drug naslov ce imamo semanticni diferencial
+ if ($row['enota'] == 1) {
+
+ // Datapiping
+ $row1['naslov2'] = Helper::dataPiping($row1['naslov2']);
+
+ echo '<div class="dynamic_mg_vrednost">';
+ echo $row1['naslov2'];
+ echo '</div>';
+ }
+
+ echo '</div>';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // puscice za naprej/nazaj
+ if ($row['dynamic_mg'] == 4) {
+ $position = ($size - 2) * 10;
+ echo ' <div style="margin-top:' . $position . 'px; float: right; text-align: center;">' . "\n";
+ if ($gridRow > 1)
+ echo ' <div title="' . self::$lang['back'] . '" id="arrow_up" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' <div id="dynamic_count">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div>';
+ if ($gridRow < $countVar)
+ echo ' <div title="' . self::$lang['forward'] . '" id="arrow_down" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' </div>' . "\n";
+
+ // Paginacija
+ } elseif ($row['dynamic_mg'] == 6 || (get('mobile') == 1 && $mobile_tables > 0)) {
+
+ echo '</tr><tr class="gridRowArrows ' . $spremenljivka . '_gridRowArrows_' . $gridRow . ' ' . $ifDisplay . '" ' . $gridRowDisplay . '><td colspan="' . $colspan . '">';
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ for ($i = 1; $i <= $countVar; $i++) {
+ echo ' <td><div title="' . $i . '" id="sequence_number_' . $i . '" class="sequence_number sequence_number_'.$i.' ' . ($i == $gridRow ? ' active' : '') . '" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . $i . '\');">' . $i . '</div></td>';
+ }
+ echo ' </tr></table>' . "\n";
+ echo '</td>';
+
+ // puscice levo/desno
+ } else {
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ if ($gridRow > 1)
+ echo ' <td><div title="' . self::$lang['back'] . '" id="arrow_left" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' <td><div id="dynamic_count" style="text-align: center;">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div></td>';
+ if ($gridRow < $countVar)
+ echo ' <td><div title="' . self::$lang['forward'] . '" id="arrow_right" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' </tr></table>' . "\n";
+ }
+
+ echo ' </div>' . "\n";
+
+ $bg++;
+ $gridRow++;
+ }
+ } //KONEC IZRISA NAVPICNE / VERTICAL RAZLICICE
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/HeatMapController.php b/main/survey/app/Controllers/Vprasanja/HeatMapController.php
new file mode 100644
index 0000000..4a255dd
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/HeatMapController.php
@@ -0,0 +1,242 @@
+<?php
+/***************************************
+ * Description: Prikaže vprašanje Heatmap
+ *
+ * Vprašanje je prisotno:
+ * tip 27
+ *
+ * Autor: Patrik Pucer
+ * Created date: 06.10.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class HeatMapController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HeatMapController();
+ }
+
+ /**
+ * @desc prikaze vnos za image hotspot za radio
+ */
+ public function display($spremenljivka){
+
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0);
+
+ //$hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 1); //po default-u skrij namig
+ $hotspot_tooltips_option = 1; //naj bo 1 tako, da je skrito, saj trenutno tega v heatmap ne rabimo
+
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+
+ $heatmap_num_clicks = ($spremenljivkaParams->get('heatmap_num_clicks') ? $spremenljivkaParams->get('heatmap_num_clicks') : 1);
+ $heatmap_show_clicks = ($spremenljivkaParams->get('heatmap_show_clicks') ? $spremenljivkaParams->get('heatmap_show_clicks') : 0); //za checkbox
+ $disable_heatmap_show_clicks_hidden = ($heatmap_show_clicks == 1) ? 'disabled' : '';
+
+ $heatmap_click_color = ($spremenljivkaParams->get('heatmap_click_color') ? $spremenljivkaParams->get('heatmap_click_color') : "");
+ $heatmap_click_size = ($spremenljivkaParams->get('heatmap_click_size') ? $spremenljivkaParams->get('heatmap_click_size') : 5);
+ $heatmap_click_shape = ($spremenljivkaParams->get('heatmap_click_shape') ? $spremenljivkaParams->get('heatmap_click_shape') : 1);
+
+ $heatmap_show_counter_clicks = ($spremenljivkaParams->get('heatmap_show_counter_clicks') ? $spremenljivkaParams->get('heatmap_show_counter_clicks') : 0); //za prikazovanje/skrivanje stevca klikov
+
+ // Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+
+
+
+ echo '<div id="heatmap_'.$spremenljivka.'" class="hotspot" style="width: 40%; float: left;">';
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ //ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
+ //$sql1a = sisplet_query("SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql1a = sisplet_query("SELECT lat, lng, address, text FROM srv_data_heatmap WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $heatmap_data = array();
+ while ($row1a = mysqli_fetch_array($sql1a)) {
+ $heatmap_data[] = $row1a;
+ }
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
+ //echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'">';
+ //echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //canvas
+ echo '<canvas id="heatmapCanvas_'.$row['id'].'">';
+
+ echo '</canvas>';
+
+ //Za obmocja
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ }
+ echo '</map>';
+
+ //************************************************************************************************
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki
+ echo '<div id="heatmapCheckbox_'.$row['id'].'">';
+ RadioCheckboxSelect::getInstance()->display($spremenljivka); //prikaze radio button in checkbox z odgovori
+ echo '</div>';
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+ //Za obmocja - konec
+
+ //GUMBA
+ echo '<div class="buttonsHeatmap">';
+
+ //gumb za resetiranje vseh tock
+ echo '<input id="resetHeatMapCanvas_'.$row['id'].'" type="button" value="'.$lang['srv_vprasanje_heatmap_reset_canvas'].'">';
+
+ echo '&emsp;';
+
+ //gumb za resetiranje zadnje tocke
+ echo '<input id="resetHeatMapLastPoint_'.$row['id'].'" type="button" value="'.$lang['srv_vprasanje_heatmap_reset_last_point'].'">';
+
+ echo '</div>';
+ //GUMBA - konec
+
+ //canvas - konec
+
+ //div za stevec klikov
+ if($heatmap_show_counter_clicks){
+ echo '</br><div id="heatmapClickCounter_'.$spremenljivka.'">';
+ echo '<div>'.$lang['srv_vprasanje_heatmap_num_clicks'].':</div>';
+ echo '<div id="heatmapClickNumber_'.$spremenljivka.'" style="float:left">0</div>/'.$heatmap_num_clicks;
+ echo '</div>';
+ }
+ //div za stevec klikov - konec
+
+ //div za inpute tock
+ echo '<div id="heatmapInputs_'.$spremenljivka.'" style="display:none">';
+ echo '</div>';
+ //div za inpute tock - konec
+
+ ?>
+ <script>
+
+ mousePos[<?=$spremenljivka?>] = new Array(2);
+ indeksMousePos[<?=$spremenljivka?>] = 0;
+ heatmap_num_clicksGlobal[<?=$spremenljivka?>] = <?=$heatmap_num_clicks?>;
+ var heatmapDataLength = [];
+ var refreshed = [];
+ for(i = 1; i <= <?=$heatmap_num_clicks?>; i++){
+ mousePos[<?=$spremenljivka?>][i] = 0;
+ //console.log("mousePos[<?=$spremenljivka?>]["+i+"]: "+mousePos[<?=$spremenljivka?>][i]);
+ }
+
+ $(document).ready(function () {
+
+ InitHeatMapCanvas(<?=$spremenljivka?>, <?=$quick_view?>);
+ //Ta spremenljivka ze vsebuje podatke? primer, ce gre uporabnik na prejsnjo stran ali refresh-a stran
+ var heatmap_data = JSON.parse('<?php echo json_encode($heatmap_data); ?>');
+ heatmapDataLength[<?=$spremenljivka?>] = heatmap_data.length; //belezi zacetno dolzino polja
+ //ce ze obstajajo tocke, jih dodaj na canvas
+ if (heatmap_data.length > 0){
+ heatmap_data_add(<?=$spremenljivka?>, heatmap_data, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, <?=$heatmap_show_clicks?>, <?=$heatmap_num_clicks?>);
+ refreshed[<?=$spremenljivka?>] = 1;
+ }
+ });
+ $('#heatmapCanvas_<?=$spremenljivka?>').click(function (e) {
+ HeatMapCanvasDelovanje(e, <?=$spremenljivka?>, <?=$heatmap_show_clicks?>, <?=$heatmap_num_clicks?>, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, <?=$quick_view?>);
+ });
+ $('#heatmapCanvas_<?=$spremenljivka?>').mouseover(function (e) {
+ if (heatmap_num_clicksGlobal[<?=$spremenljivka?>] != 0){ //ce je se mozno klikati
+ $(this).css( 'cursor', 'pointer' ); //ko je se miška nahaja na canvas-u, naj se spremeni v rokico
+ }
+ });
+ //klicanje funkcije za brisanje vseh tock na canvasu
+ $('#resetHeatMapCanvas_<?=$spremenljivka?>').click(function (e) {
+ resetHeatMapCanvas(<?=$spremenljivka?>, <?=$heatmap_num_clicks?>, <?=$quick_view?>);
+ });
+
+ //klicanje funkcije za brisanje zadnje izbrane tocke na canvasu
+ $('#resetHeatMapLastPoint_<?=$spremenljivka?>').click(function (e) {
+ var heatmap_data = JSON.parse('<?php echo json_encode($heatmap_data); ?>');
+ resetHeatMapLastPoint(<?=$spremenljivka?>, <?=$heatmap_num_clicks?>, <?=$heatmap_show_clicks?>, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, heatmap_data, <?=$quick_view?>);
+ });
+
+ $('#heatmapCheckbox_<?=$spremenljivka?> .variabla').css("display", "none"); //skrij radio/checkbox button odgovore, kjer se bodo beležili odgovori
+
+ </script>
+ <?
+
+ echo '</div>';
+
+ echo ' </div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php b/main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php
new file mode 100644
index 0000000..3e0b953
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php
@@ -0,0 +1,856 @@
+<?php
+/***************************************
+ * Description: Prikaže vprašanje Image HotSpot
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 10
+ *
+ * Autor: Patrik Pucer
+ * Created date: 26.04.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+use App\Controllers\Vprasanja\RankingController as Ranking;
+
+// Iz admin/survey
+use SurveyInfo;
+
+
+class ImageHotSpotController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new ImageHotSpotController();
+ }
+
+ /**
+ * @desc prikaze vnos za image hotspot za radio
+ */
+ public function display($spremenljivka){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0);
+ $hotspot_region_visibility = ($spremenljivkaParams->get('hotspot_region_visibility') ? $spremenljivkaParams->get('hotspot_region_visibility') : 1); //za radio "vedno" in "ob mouseover"
+ $hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 0);
+
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+ $hotspot_visibility_color = ($spremenljivkaParams->get('hotspot_visibility_color') ? $spremenljivkaParams->get('hotspot_visibility_color') : "");
+
+ // Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+ if($hotspot_region_visibility_option){
+ $hotspot_region_visibility_option = $hotspot_region_visibility;
+ }
+
+ //zaslon razdelimo na dva dela - izris leve strani***************************************
+ echo '<div id="half_hot_spot_1" class="hotspot" style="width: 40%; float: left;">';
+
+
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ //$sqlR = sisplet_query("SELECT * FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }
+ else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //prikaz obmocij na sliki*********************************************************************************
+ $options[$row['id']] = '{areas: ['; //belezi kodo za settings-e za prikazovanje tooltip v imagemapster
+
+ //HTML ZA TOOLTIP
+ //$htmltootip[$row['id']] = '';
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ //$sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sql_grid = sisplet_query("SELECT id, naslov, other FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ }
+ }
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ //$sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql_grid = sisplet_query("SELECT vre_id, grd_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $sql1 = sisplet_query("SELECT id, naslov, hidden FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $htmltootip[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = $htmltootip1[$row1['id']].''.$row1['id'].'<br />';
+ //echo $htmltootip1[$row1['id']];
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<div class=\"grid_table multigrid\">';
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ //echo ' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div id=\"im_vrednost_if_' . $row1['id'] . '\"' . (($row1['hidden'] == 1) ? 'style=\"display:none\"' : '') . (($row1['hidden'] == 2) ? 'class=\"answer-disabled\"' : '') . '\">';
+
+
+ //echo ' <td class="question">';
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td class="question">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div class=\"question\">';
+
+ //echo $row1['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$row1['naslov'];
+
+ //echo '</td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'</td>' . "\n";
+ $htmltootip[$row['id']] = $htmltootip[$row['id']].'</div>';
+
+ //echo ' <td></td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td></td>' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div></div>';
+
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' </div>';
+
+ //uredi options za imagemapster in prikazovanja obmocij
+ //$options[$row['id']] = $options[$row['id']] .'{key: "'.$row1['naslov'].'", toolTip: "'.$htmltootip[$row['id']].' "} ,';
+
+ //$bg++;
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</table>' . "\n";
+ }
+ //echo '</table>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'</table>' . "\n";
+
+ //echo $htmltootip[$row1['id']];
+ //HTML ZA TOOLTIP - KONEC
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ //uredi options za imagemapster in prikazovanja obmocij
+ $options[$row['id']] = $options[$row['id']] .'{key: "'.$rowR['vre_id'].'", toolTip: "'.$htmltootip[$rowR['vre_id']].' "} ,';
+ }
+ echo '</map>';
+
+ $options[$row['id']] = rtrim($options[$row['id']], ","); //odstrani zadnjo vejico pri options
+ $options[$row['id']] = $options[$row['id']].']}'; //zapri areas z ]}
+ //echo $options[$row['id']];
+
+ //************************************************************************************************
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki
+ RadioCheckboxSelect::getInstance()->display($spremenljivka); //prikaze radio button in checkbox z odgovori
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+
+
+ ?>
+
+ <script>
+ $(document).ready(function () {
+ mapinitRadio(<?=$row['id']?>, <?=$options[$row['id']]?>, <?=$row['tip']?>, <?=$hotspot_region_visibility_option?>, <?=$hotspot_tooltips_option?>, '<?=$hotspot_region_color?>', '<?=$hotspot_visibility_color?>', <?=$quick_view?>); //uredi delovanje imagemapster in prikazovanja/skrivanje obmocij ter tooltip-ov
+ });
+ </script>
+ <?
+ echo '</div>';
+ //prikaz obmocij na sliki - konec**************************************************************************
+
+
+ echo ' </div>';
+ //************************* Izris leve strani - konec
+ }
+
+ /**
+ * @desc prikaze vnos za image hotspot za radio grid
+ */
+ public function grid($spremenljivka){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0); //za checkbox
+ $hotspot_region_visibility = ($spremenljivkaParams->get('hotspot_region_visibility') ? $spremenljivkaParams->get('hotspot_region_visibility') : 1); //za radio "vedno" in "ob mouseover"
+ $hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 0);
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+ $hotspot_visibility_color = ($spremenljivkaParams->get('hotspot_visibility_color') ? $spremenljivkaParams->get('hotspot_visibility_color') : "");
+
+ if($hotspot_region_visibility_option){
+ $hotspot_region_visibility_option = $hotspot_region_visibility;
+ }
+
+ // Pri vpogledu moramo deaktivirati radio button-e (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+
+
+ //zaslon razdelimo na dva dela - izris leve strani***************************************
+ echo '<div id="half_hot_spot_1" class="hotspot" style="width: 40%; float: left;">';
+
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row['id'].'" style="display:none; ">';
+
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }
+ else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //prikaz obmocij na sliki*********************************************************************************
+ $options[$row['id']] = '{areas: ['; //belezi kodo za settings-e za prikazovanje tooltip v imagemapster
+
+ //HTML ZA TOOLTIP
+ //$htmltootip[$row['id']] = '';
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ //$sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sql_grid = sisplet_query("SELECT id, naslov, other FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ }
+ }
+
+ //echo '<table class="grid_table multigrid">' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'<table class=\"grid_table multigrid\">';
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ //$sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql_grid = sisplet_query("SELECT vre_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $sql1 = sisplet_query("SELECT id, naslov, hidden FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $htmltootip[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = $htmltootip1[$row1['id']].''.$row1['id'].'<br />';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ // preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ // ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ //echo ' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div id=\"im_vrednost_if_' . $row1['id'] . '\"' . (($row1['hidden'] == 1) ? 'style=\"display:none\"' : '') . (($row1['hidden'] == 2) ? 'class=\"answer-disabled\"' : '') . '\">';
+
+
+ //echo ' <td class="question">';
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td class="question">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div class=\"question\">';
+
+ //echo $row1['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$row1['naslov'];
+
+
+ //echo '</td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'</td>' . "\n";
+ $htmltootip[$row['id']] = $htmltootip[$row['id']].'</div>';
+
+ //echo ' <td></td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td></td>' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div></div>';
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+
+ //echo ' <td></td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td></td>' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div></div>';
+
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<div class=\"missing ' . $cssAlign . '\">';
+ # imamo missing vrednost
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<label for=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation=\"0\" onclick=\"checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation=\"0\" onclick=\"checkChecked(this); checkTableMissing(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$srv_grid['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</label>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ } else {
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<div class=\"category ' . $cssAlign . '\">';
+ # ni missing vrednost
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<label for=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation=\"' . $srv_grids[$i]['variable'] . '\" onclick=\"checkChecked(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$srv_grid['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</label>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ }
+ }
+ }
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' </div>';
+
+
+ //uredi options za imagemapster in prikazovanja obmocij
+ //$options[$row['id']] = $options[$row['id']] .'{key: "'.$row1['naslov'].'", toolTip: "'.$htmltootip[$row['id']].' "} ,';
+
+ //$bg++;
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</table>' . "\n";
+ }
+ //HTML ZA TOOLTIP - KONEC
+
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ //uredi options za imagemapster in prikazovanja obmocij
+ $options[$row['id']] = $options[$row['id']] .'{key: "'.$rowR['vre_id'].'", toolTip: "'.$htmltootip[$rowR['vre_id']].' "} ,';
+ }
+ echo '</map>';
+
+ $options[$row['id']] = rtrim($options[$row['id']], ","); //odstrani zadnjo vejico pri options
+ $options[$row['id']] = $options[$row['id']].']}'; //zapri areas z ]}
+ //echo $options[$row['id']];
+
+ //************************************************************************************************
+ //izris tabele z radio button, ki bo skrita in beležila odgovore na sliki
+ Multigrid::getInstance()->display($spremenljivka); //prikaze tabelo z radio button odgovori
+
+ //izris tabele z radio button, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+
+ ?>
+
+ <script>
+ $(document).ready(function () {
+ mapinitRadioGrid(<?=$row['id']?>, <?=$options[$row['id']]?>, <?=$hotspot_region_visibility_option?>, <?=$hotspot_tooltips_option?>, '<?=$hotspot_region_color?>', '<?=$hotspot_visibility_color?>', <?=$quick_view?>); //uredi delovanje imagemapster in prikazovanja obmocij ter tooltip-ov
+ });
+ </script>
+ <?
+ echo '</div>';
+ //prikaz obmocij na sliki - konec**************************************************************************
+
+
+ echo ' </div>';
+
+ //************************* Izris leve strani - konec
+ }
+
+ public function ranking($spremenljivka, $oblika){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0); //za checkbox
+ $hotspot_region_visibility = ($spremenljivkaParams->get('hotspot_region_visibility') ? $spremenljivkaParams->get('hotspot_region_visibility') : 1); //za radio "vedno" in "ob mouseover"
+ $hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 0);
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+ $hotspot_visibility_color = ($spremenljivkaParams->get('hotspot_visibility_color') ? $spremenljivkaParams->get('hotspot_visibility_color') : "");
+
+ if($hotspot_region_visibility_option){
+ $hotspot_region_visibility_option = $hotspot_region_visibility;
+ }
+
+ // Pri vpogledu moramo deaktivirati radio button-e (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+
+ //zaslon razdelimo na dva dela - izris leve strani***************************************
+ echo '<div id="half_hot_spot_1" class="hotspot" style="width: 40%; float: left;">';
+
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
+
+ // Ali gre za sazu anketo
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu'))
+ echo '<input type="hidden" id="hotspot_image_'.$row[id].'_sazu" value="1">';
+
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }
+ else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //prikaz obmocij na sliki*********************************************************************************
+ $options[$row['id']] = '{areas: ['; //belezi kodo za settings-e za prikazovanje tooltip v imagemapster
+
+ //HTML ZA TOOLTIP
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_hotspot_regions WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ //$row_grid['naslov'] = $naslov;
+ $row_grid['vrstni_red'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ }
+ }
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT vre_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, vrstni_red FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $htmltootip[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = $htmltootip1[$row1['id']].''.$row1['id'].'<br />';
+
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $htmltootip[$row1['id']] .= '<div id=\"im_vrednost_if_' . $row1['id'] . '\"' . (($row1['hidden'] == 1) ? 'style=\"display:none\"' : '') . (($row1['hidden'] == 2) ? 'class=\"answer-disabled\"' : '') . '\">';
+
+ $htmltootip[$row1['id']] .= '<div class=\"question\">';
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu'))
+ $htmltootip[$row1['id']] .= '<div class=\"title\">Razvrsti območje od 1 do 6 glede na privlačnost:</div>';
+ else
+ $htmltootip[$row1['id']] .= '<div class=\"title\">'.$row1['naslov'].'</div>';
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ $htmltootip[$row1['id']] .= '<div class=\"missing ' . $cssAlign . '\">';
+ # imamo missing vrednost
+ $htmltootip[$row1['id']] .= '<label for=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ $htmltootip[$row1['id']] .= '<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation=\"0\" onclick=\"checkChecked(this); checkTableMissing(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+
+ $htmltootip[$row1['id']] .= '<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ $htmltootip[$row1['id']] .= $srv_grid['naslov'];
+ $htmltootip[$row1['id']] .= '</label>';
+ $htmltootip[$row1['id']] .= '</div>';
+ }
+ else {
+ $htmltootip[$row1['id']] .= '<div class=\"category ' . $cssAlign . '\">';
+
+
+ // Za SAZU moramo posebej obarvati
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+ # ni missing vrednost
+ $htmltootip[$row1['id']] .= '<label for=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ $htmltootip[$row1['id']] .= '<input vrstni_red='.$srv_grid['vrstni_red'].' type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation=\"' . $srv_grids[$i]['variable'] . '\" onclick=\"checkChecked(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRankingSazu(this, ' . $row1['id'] . ');\">';
+ $htmltootip[$row1['id']] .= '<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ //besedilo ob radio buttonu
+ $htmltootip[$row1['id']] .= $srv_grid['vrstni_red'];
+
+ //besedilo ob radio buttonu - konec
+ $htmltootip[$row1['id']] .= '</label>';
+ }
+ else{
+ # ni missing vrednost
+ $htmltootip[$row1['id']] .= '<label for=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ $htmltootip[$row1['id']] .= '<input vrstni_red='.$srv_grid['vrstni_red'].' type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation=\"' . $srv_grids[$i]['variable'] . '\" onclick=\"checkChecked(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRanking(this, ' . $row1['id'] . ');\">';
+ $htmltootip[$row1['id']] .= '<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ //besedilo ob radio buttonu
+ $htmltootip[$row1['id']] .= $srv_grid['vrstni_red'];
+ //besedilo ob radio buttonu - konec
+ $htmltootip[$row1['id']] .= '</label>';
+ }
+ $htmltootip[$row1['id']] .= '</div>';
+ }
+ }
+ }
+
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' </div>'; //konec elementa question
+
+
+ //KOMENTAR v popupu******************************************************************************************************
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+
+ $sqlComment = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ // Najdemo naslednje textgrid vprasanje na isti strani, kamor zapisemo komentarje
+ $sqlComment = sisplet_query("SELECT v1.id, v1.naslov, v1.vrstni_red, s1.id as spr_id
+ FROM srv_vrednost v1, srv_spremenljivka s1
+ WHERE s1.gru_id='".$row[gru_id]."' AND s1.variable='regcom'
+ AND v1.spr_id=s1.id AND v1.vrstni_red='".$row1[vrstni_red]."'
+ ");
+ $rowComment = mysqli_fetch_array($sqlComment);
+
+ // Pridobimo ze mogoce vnesen text
+ $sqlCommentData = sisplet_query("SELECT text FROM srv_data_textgrid".get('db_table')."
+ WHERE spr_id='".$rowComment['spr_id']."' AND usr_id='".get('usr_id')."' AND vre_id='".$rowComment['id']."'
+ ");
+ $rowCommentData = mysqli_fetch_array($sqlCommentData);
+
+ // Izrisemo input box, ki je sinhroniziran z inputi naslednjega skritega textgrid vprasanja
+ $textarea_id = 'vrednost_'.$rowComment['id'].'_grid_1';
+
+ $komentar = '<textarea onkeyup=\"mapdelovanjeRankingKomentar(\''.$textarea_id.'\', this.value);\" id=\"im_vrednost_komentar_' . $row1['id'] . '\" name=\"vrednost_komentar_' . $row1['id'] . '\" >';
+ $komentar .= $rowCommentData['text'];
+ $komentar .= '</textarea>';
+
+ $htmltootip[$row1['id']] .= ' <div class=\"komentar\">Opišite s ključno besedo:'.$komentar.'</div>';
+ }
+ //KOMENTAR - KONEC **********************************************************************************************
+
+
+ $htmltootip[$row1['id']] .= '<span class=\"close_button\" onClick=\"removeMapsterTooltip();\" style=\"margin:\">Zapri</span>';
+
+ //uredi options za imagemapster in prikazovanja obmocij
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>'; //konec elementa z radio buttoni
+ }
+
+ //echo $htmltootip[$row1['id']];
+ //HTML ZA TOOLTIP - KONEC
+
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ //uredi options za imagemapster in prikazovanja obmocij
+ $options[$row['id']] = $options[$row['id']] .'{key: "'.$rowR['vre_id'].'", toolTip: "'.$htmltootip[$rowR['vre_id']].' "} ,';
+ }
+ echo '</map>';
+
+ $options[$row['id']] = rtrim($options[$row['id']], ","); //odstrani zadnjo vejico pri options
+ $options[$row['id']] = $options[$row['id']].']}'; //zapri areas z ]}
+ //echo $options[$row['id']];
+
+ //************************************************************************************************
+ //izris ranking z oštevilčevanjem, ki bo skrita in beležila odgovore na sliki
+ Ranking::getInstance()->display($spremenljivka, $oblika); //prikaze tabelo z radio button odgovori
+ //izris ranking z oštevilčevanjem, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+
+
+ ?>
+ <script>
+ $(document).ready(function () {
+
+ //uredi delovanje imagemapster in prikazovanja obmocij ter tooltip-ov
+ mapinitRanking(<?=$row['id']?>, <?=$options[$row['id']]?>, <?=$hotspot_region_visibility_option?>, <?=$hotspot_tooltips_option?>, '<?=$hotspot_region_color?>', '<?=$hotspot_visibility_color?>', <?=$quick_view?>);
+
+ // Remove tooltip if clicked outside
+ $(window).click(function(e) {
+ if(e.target.class != "hotspot"
+ && e.target.class != "mapster_tooltip"
+ && !$(".hotspot").has(e.target).length
+ && !$(".mapster_tooltip").has(e.target).length){
+ removeMapsterTooltip();
+ }
+ });
+ });
+ </script>
+ <?
+ echo '</div>';
+ //prikaz obmocij na sliki - konec**************************************************************************
+
+
+ echo ' </div>';
+
+ //************************* Izris leve strani - konec
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/ImenaController.php b/main/survey/app/Controllers/Vprasanja/ImenaController.php
new file mode 100644
index 0000000..a2ae73b
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/ImenaController.php
@@ -0,0 +1,160 @@
+<?php
+/***************************************
+ * Description: SN imena
+ *
+ * Vprašanje je prisotno:
+ * tip 9
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Models\Model;
+
+// Iz admin/survey
+use enkaParameters;
+use Common;
+
+// Vprašanja
+
+class ImenaController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new ImenaController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ if ($spremenljivkaParams->get('NG_cancelButton') == '1') {
+ $cancelText = $spremenljivkaParams->get('NG_cancelText');
+ $cancelButton = 1;
+ } else {
+ $cancelText = self::$lang['srv_NG_cancelText'];
+ $cancelButton = 0;
+ }
+
+ // Dodajanje polj za vnos ime z gumbom (+)
+ if ($row['design'] == 0 || $_GET['m'] == 'quick_edit') {
+ $addText = ($spremenljivkaParams->get('NG_addText') ? $spremenljivkaParams->get('NG_addText') : self::$lang['srv_NG_addText']);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ $first = true;
+ $id = 1;
+
+ // WebSM anketa ima fiksno napolnjena polja ker gre samo za primer in se nic ne shranjuje
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" readonly name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="John">';
+ echo ' </div>';
+
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" readonly name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="Sarah">';
+ echo ' <img src="' . self::$site_url . 'main/survey/skins/Modern/blue_delete.png" style="cursor:pointer;" border="0">';
+ echo ' </div>';
+
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" readonly name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="Kevin">';
+ echo ' <img src="' . self::$site_url . 'main/survey/skins/Modern/blue_delete.png" style="cursor:pointer;" border="0">';
+ echo ' </div>';
+
+ //gumb za dodajanje polj
+ echo ' <div id="divTxt' . $spremenljivka . '">';
+ echo ' </div>';
+ echo ' <p style="cursor:pointer;"><img src="' . self::$site_url . 'main/survey/skins/Modern/add.png" border="0"> ' . $addText . '</p>';
+ } else {
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="' . $row2['text'] . '">';
+ if ($first || $_GET['m'] == 'quick_edit')
+ $first = false;
+ else
+ echo ' <a href="#" onClick="removeFormField(\'#row' . $id . '\'); return false;"><span class="faicon delete"></span></a>';
+
+ echo ' </div>';
+
+ $id++;
+ }
+
+ if ($_GET['m'] != 'quick_edit') {
+
+ //vedno imamo eno prazno vnosno polje
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" value="" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" onblur="checkName(\'' . $spremenljivka . '\', this); checkBranching();">';
+ if ($first)
+ $first = false;
+ else
+ echo ' <a href="#" onClick="removeFormField(\'#row' . $id . '\'); return false;"><span class="faicon delete"></span></a>';
+ echo ' </div>';
+ $id++;
+
+ // gumb za dodajanje polj
+ echo ' <input type="hidden" id="counter" value="' . $id . '">';
+
+ echo ' <div id="divTxt' . $spremenljivka . '">';
+ echo ' </div>';
+
+ echo ' <div class="sn_add_field"><a href="#" onClick="addFormField(' . $spremenljivka . '); return false;"><span class="faicon add"></span> ' . $addText . '</a></div>';
+ }
+ }
+ } // Fiksno stevilo polj za imena
+ elseif ($row['design'] == 1) {
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ $first = true;
+ $id = 1;
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="' . $row2['text'] . '"></div>';
+ $id++;
+ }
+
+ // dodamo prazna vnosna polja
+ for ($i = $id; $i <= $row['size']; $i++)
+ echo ' <div id="row' . $i . '" class="sn_name"><input type="text" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $i . '" size="40" onblur="checkName(\'' . $spremenljivka . '\', this); checkBranching();"></div>';
+ } // 1 textbox - loceni z entri
+ elseif ($row['design'] == 2) {
+ $values = '';
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $values .= $row2['text'] . "\n";
+ }
+
+ echo '<textarea name="spremenljivka_' . $spremenljivka . '" style="width: 250px; height: 150px;">' . $values . '</textarea>';
+ } // Vnos stevila polj
+ elseif ($row['design'] == 3) {
+ $countText = ($spremenljivkaParams->get('NG_countText') ? $spremenljivkaParams->get('NG_countText') : self::$lang['srv_design_count']);
+ echo $countText . ': <input type="text" size="5" name="stImen_' . $spremenljivka . '" id="stImen_' . $spremenljivka . '" value="" onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); edit_size(' . $spremenljivka . ', stImen_' . $spremenljivka . '.value)">' . "\n";
+
+ echo '<div id="imena_' . $spremenljivka . '">';
+ echo '</div>';
+ }
+
+
+ //gumb za preskok (ce je vklopljen)
+ if ($cancelButton == 1)
+ echo ' <br><p><input class="prev" type="button" value="' . $cancelText . '" onclick="submitForm()"></p>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/MapsController.php b/main/survey/app/Controllers/Vprasanja/MapsController.php
new file mode 100644
index 0000000..a188a7b
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MapsController.php
@@ -0,0 +1,364 @@
+<?php
+/* * *************************************
+ * Description: Maps (google maps lokacija)
+ *
+ * Vprašanje je prisotno:
+ * tip 26 - lokacija
+ * podtip 2 - multi lokacija
+ * podtip 1 - moja lokacija
+ *
+ * Autor: Uros Podkriznik
+ * Created date: 22.04.2016
+ * *************************************** */
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+/**
+ * Description of MapsController
+ *
+ * @author uros p.
+ */
+class MapsController extends Controller {
+
+ public function __construct() {
+ parent::getGlobalVariables();
+ }
+
+ /* * **********************************************
+ * Get instance
+ * ********************************************** */
+
+ private static $_instance;
+
+ public static function getInstance() {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MapsController();
+ }
+
+ public function display($spremenljivka, $oblika) {
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $podtip = $row['enota'];
+ //$selected = Model::getOtherValue($spremenljivka);
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_variabla" class="variabla ' . $oblika['cssFloat'] . '">' . "\n";
+
+ //get input type - marker, polyline, polygon
+ $multi_input_type = $spremenljivkaParams->get('multi_input_type');
+
+ $map_data = array();
+ $map_data_info_shapes = array();
+
+ //ce je choose location
+ if($podtip == 3){
+
+ $loop_id_3 = "";
+ //force text to be null from sql
+ $force_text_null = 'false';
+
+ //do we have loop
+ if(get('loop_id') != null){
+ //does data for this loop already exist?
+ $sql1 = sisplet_query("SELECT id FROM srv_data_map WHERE usr_id='" . get('usr_id') .
+ "' AND spr_id='$spremenljivka' AND loop_id $loop_id", 'array');
+
+ //data does not exist, force null on text
+ if(count($sql1) == 0)
+ $force_text_null = 'true';
+ else
+ $loop_id_3 = " AND dm.loop_id = '" . get('loop_id') . "'";
+ }
+
+
+ $sql1 = sisplet_query("SELECT vm.vre_id, vm.lat, vm.lng, vm.address, v.naslov, IF($force_text_null, NULL, dm.text) as text FROM srv_vrednost AS v
+ LEFT JOIN srv_vrednost_map AS vm ON v.id = vm.vre_id
+ LEFT JOIN srv_data_map AS dm ON v.id = dm.vre_id AND dm.usr_id='" . get('usr_id') . "'
+ WHERE v.spr_id='$spremenljivka' $loop_id_3", 'array');
+
+ //je vec vrednosti
+ if(!isset($sql1['lat']))
+ $map_data = $sql1;
+ //je ena vrednost
+ else
+ $map_data[] = $sql1;
+
+
+ //get info shapes
+ $sql2 = sisplet_query("SELECT lat, lng, address, overlay_id FROM srv_vrednost_map
+ WHERE spr_id='$spremenljivka' AND overlay_type='polyline' ORDER BY overlay_id, vrstni_red", 'array');
+
+ //create json data for info shapes
+ $st_linij=0;
+ $last_id=0;
+ foreach ($sql2 as $line_row) {
+ if($line_row['overlay_id'] != $last_id){
+ $st_linij++;
+ $last_id = $line_row['overlay_id'];
+ $map_data_info_shapes[$st_linij-1]['overlay_id']=$line_row['overlay_id'];
+ $map_data_info_shapes[$st_linij-1]['address']=$line_row['address'];
+ $map_data_info_shapes[$st_linij-1]['path']= array();
+ }
+
+ $path = array();
+ $path['lat']=floatval($line_row['lat']);
+ $path['lng']=floatval($line_row['lng']);
+
+ array_push($map_data_info_shapes[$st_linij-1]['path'], $path);
+ }
+ }
+ //ce je polygon ali polyline
+ else if($podtip == 2 && $multi_input_type != '' && $multi_input_type != 'marker'){
+ //ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
+ $sql1 = sisplet_query("SELECT lat, lng FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id "
+ . "ORDER BY vrstni_red", 'array');
+
+ //if not empty
+ if(count($sql1)>0){
+ $map_data = $sql1;
+
+ //iterate and convert all coordinates to float - needed for JS
+ for($i=0; $i<count($map_data); $i++){
+ $map_data[$i]['lat'] = floatval($map_data[$i]['lat']);
+ $map_data[$i]['lng'] = floatval($map_data[$i]['lng']);
+ }
+ }
+ }
+ //ce so markerji
+ else{
+ //ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
+ $sql1 = sisplet_query("SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id "
+ . "ORDER BY vrstni_red", 'array');
+
+ //je vec vrednosti
+ if(!isset($sql1['lat']))
+ $map_data = $sql1;
+ //je ena vrednost
+ else
+ $map_data[] = $sql1;
+ }
+
+ //dobi fokus mape
+ $fokus = $spremenljivkaParams->get('fokus_mape');
+
+ //pridobi parametre za centriranje mape in jo nastavi za kasnejso uporabo v js
+ $fokus_koordinate = $spremenljivkaParams->get('fokus_koordinate'); //dobi fokus koordinat mape
+ if(!isset(json_decode($fokus_koordinate)->center->lat))
+ $fokus_koordinate = false;
+
+ //dobi max odgovore
+ $maxmark = $spremenljivkaParams->get('max_markers');
+ //staro, kasneje sem dodal max_markers - to je zaradi vasjinega workshopa
+ if($maxmark == '')
+ $maxmark = $spremenljivkaParams->get('date_range_max');
+
+ //dobi user location
+ $spremenljivkaParams->get('user_location') == 1 ? $userLocation = json_encode(true) :
+ $userLocation = json_encode(false);
+
+ //dobi podvprasanje za marker
+ $spremenljivkaParams->get('marker_podvprasanje') == 1 ? $podvprasanje = json_encode(true) :
+ $podvprasanje = json_encode(false);
+
+ //dobi naslov podvprasanje za marker
+ $podvprasanje_naslov = $spremenljivkaParams->get('naslov_podvprasanja_map');
+ if(!$spremenljivkaParams->get('naslov_podvprasanja_map'))
+ $podvprasanje_naslov = '';
+
+ //ali se prikaze searchbox
+ $spremenljivkaParams->get('dodaj_searchbox') == 1 ? $dodaj_searchbox = json_encode(true) :
+ $dodaj_searchbox = json_encode(false);
+
+ //ce je tip moja lokacija
+ if($podtip == 1){
+ //vkljucijo se funkcije za klik na mapi
+ $klikNaMapo = json_encode(true);
+ //vkljuci se iskanje lokacije uporabnika
+ //$userLocation = json_encode(True);
+ $mojaLokacija = json_encode(True);
+ if(!$fokus)
+ $fokus = "Slovenia";
+ }
+ //ce je tip multi lokacija
+ elseif($podtip == 2){
+ //vkljuci se iskanje lokacije uporabnika
+ //$userLocation = json_encode(false);
+ $mojaLokacija = json_encode(false);
+ if(!$fokus)
+ $fokus = "Slovenia";
+
+ if($multi_input_type != 'marker'){
+ $klikNaMapo = json_encode(false);
+ //izrisi opozorilo o max odgovorov
+ echo '<div id="end_shape_info_'.$spremenljivka.'" style="display: inline-block; color:red; font-size:0.8em;">'.$lang['srv_resevanje_info_end_shpe_map'].'</div>';
+ }
+ else{
+ //izrisi opozorilo o max odgovorov
+ echo '<div id="max_marker_'.$spremenljivka.'" style="display: none; color:red; font-size:0.8em;">'.$lang['srv_resevanje_max_marker_opozorilo_map'].'</div>';
+ //vkljucijo se funkcije za klik na mapi
+ $klikNaMapo = json_encode(true);
+ }
+ }
+ //ce je podtip izberi lokacijo
+ elseif($podtip == 3){
+ //izkljucijo se funkcije za klik na mapi
+ $klikNaMapo = json_encode(false);
+ $mojaLokacija = json_encode(false);
+ }
+
+ //ali smo v pregledu izpolnjene ankete? ce da, se v JS nastavi na viewMode=true
+ $quick_view = json_encode(get('quick_view'));
+ //disablaj klik na mapo, ce je v quick_view
+ if(get('quick_view'))
+ $klikNaMapo = json_encode(false);
+
+ //warningi za geolokacijo
+ echo '<div id="warning_geo_'.$spremenljivka.'" style="display: none; color:orange; font-size:0.8em;"></div>';
+
+ //izrisi search box za v mapo
+ echo '<input id="pac-input_'.$spremenljivka.'" class="pac-input" type="text" onkeypress="return event.keyCode != 13;" style="display: none;">';
+ //izrisi mapo
+ echo '<div id="map_'.$spremenljivka.'" style="width:100%;height:300px;border-style: solid;border-width: 1px;border-color: #b4b3b3;"></div>';
+
+ ?>
+ <script type="text/javascript">
+ //zaradi resevanja preko mobilnikov, dodaj ta class, da se iznici top padding (mobile.css)
+ document.getElementById("spremenljivka_<?php echo $spremenljivka; ?>")
+ .getElementsByClassName("variable_holder")[0].className += " map_spremenljivka";
+
+ //preveri, ce je google API ze loadan (ce se je vedno na novo naloadal, je prislo do errorjev)
+ if((typeof google === 'object' && typeof google.maps === 'object'))
+ MapDeclaration();
+ else{
+ mapsAPIseNi(MapDeclaration);
+ }
+
+ function MapDeclaration(){
+ //spremenljivke
+ var spremenljivka = "<?php echo $spremenljivka; ?>";
+ //podtip
+ var podtip = "<?php echo $podtip; ?>";
+ max_mark[spremenljivka] = "<?php echo $maxmark; ?>";
+ //je ta spremenljivka tipa moja lokacija?
+ var mojaLokacija = <?php echo $mojaLokacija; ?>;
+ //ze ta spremenljivka vsebuje podatke? primer, ce gre uporabnik na prejsnjo stran
+ var map_data = JSON.parse('<?php echo addslashes(json_encode($map_data)); ?>');
+ //vsebuje ta spremenljivka F user location (trenutna lokacija)
+ var doUserLocation = <?php echo $userLocation; ?>;
+ //ali se izrise podvprasanje v infowindow
+ podvprasanje[spremenljivka] = <?php echo $podvprasanje; ?>;
+ //naslov podvprasanja v infowindow
+ podvprasanje_naslov[spremenljivka] = '<?php echo $podvprasanje_naslov; ?>';
+ //se naj izvede F klik na mapo (najbrz bo to vedno true)
+ var doKlikNaMapo = <?php echo $klikNaMapo; ?>;
+ //smo v pregledu izpolnjene ankete?
+ viewMode = <?php echo $quick_view; ?>;
+ //centerInMap = string naslova, kaj bo zajel zemljevid. Rec. Slovenija / ali Ljubljana
+ var centerInMap = "<?php echo $fokus; ?>";
+ //get input type - marker, polyline, polygon
+ var multi_input_type = "<?php echo $multi_input_type; ?>";
+ //steje markerje (int id spremenljivke: int st markerjev)
+ st_markerjev[spremenljivka] = 0;
+ //array of all marksers
+ allMarkers['<?php echo $spremenljivka; ?>'] = [];
+
+ //pridobi parametre za centriranje mape in jo nastavi za kasnejso uporabo
+ var centerInMapKoordinate = <?php echo json_encode($fokus_koordinate)?>;
+ if(centerInMapKoordinate)
+ centerInMapKoordinate = JSON.parse(centerInMapKoordinate);
+
+ //ce je spremenljivka tipa moj lokacija, jo shrani v array
+ if(mojaLokacija)
+ ml_sprem.push(spremenljivka);
+
+ //mapType = tip zemljevida, ki bo prikazan. Recimo za satelitsko sliko google.maps.MapTypeId.SATELLITE (možno še .ROADMAP)
+ var mapType = google.maps.MapTypeId.ROADMAP;
+
+ //Deklaracija potrebnih stvari za delovanje in upravljanje google maps JS API
+ var mapOptions = {
+ streetViewControl: false,
+ navigationControl: false,
+ mapTypeId: mapType
+ };
+
+ //ce je v bazi naslov enak vpisanemu v nastavitvah, nastavi po parametrih
+ if(centerInMapKoordinate){
+ mapOptions.center = {lat: parseFloat(centerInMapKoordinate.center.lat),
+ lng: parseFloat(centerInMapKoordinate.center.lng)};
+ mapOptions.zoom = parseInt(centerInMapKoordinate.zoom);
+ }
+
+ //deklaracija geocoderja (API)
+ if(!geocoder)
+ geocoder = new google.maps.Geocoder();
+ //infowindow iz API-ja, za prikaz markerja in informacije o markerju
+ if(!infowindow)
+ infowindow = new google.maps.InfoWindow();
+ //deklaracija zemljevida
+ var mapdiv = document.getElementById("map_"+spremenljivka);
+ var map = new google.maps.Map(mapdiv, mapOptions);
+ //shrani podatke za center v mapo v primeru, ce je spremenljivka hidden
+ //zaradi loopa, da se lahko ob prikayu ponovno nastavi
+ map.centerInMap = centerInMap;
+ map.centerInMapKoordinate = centerInMapKoordinate;
+ //to se kasneje uporabi za pridobitev mape z id-em spremenljivke
+ mapdiv.gMap = map;
+ //deklaracija mej/okvira prikaza na zemljevidu
+ bounds[spremenljivka] = new google.maps.LatLngBounds();
+
+ //ce ze obstajajo markerji ali podatki za mapo, jo nafilaj
+ if (multi_input_type && multi_input_type != 'marker'){
+ if(map_data.length > 0)
+ map_data_fill_shape(spremenljivka, map_data, multi_input_type);
+ else
+ drawShape(spremenljivka, null, multi_input_type);
+ }
+ else if (map_data.length > 0)
+ map_data_fill(spremenljivka, map_data, podtip);
+ //ce ne obstajajo podatki, centriraj mapo na nastavljeno obmocje
+ else if(!centerInMapKoordinate)
+ centrirajMap(centerInMap, map);
+
+ if(podtip == 3){
+ //fill info shapes in map if exists
+ var map_data_info_shapes = JSON.parse('<?php echo addslashes(json_encode($map_data_info_shapes)); ?>');
+ if (map_data_info_shapes.length > 0)
+ map_data_fill_info_shapes('<?php echo $spremenljivka; ?>', map_data_info_shapes);
+ }
+
+ //izvedi, ce je nastavljena trenutna lokacija respodenta
+ if (doUserLocation && map_data.length === 0){
+ usrLoc_sprem.push(spremenljivka);
+ userLocation(spremenljivka);
+ }
+
+ //izvedi, ce je nastavljen klik na mapo
+ if (doKlikNaMapo)
+ klikNaMapo(spremenljivka);
+
+ //izrisi in nastavi search box na zemljevidu
+ if(<?php echo $dodaj_searchbox; ?>)
+ searchBox(spremenljivka, function doAfterPlaceFromSearchBox(pos, address){
+ if(max_mark[spremenljivka]-st_markerjev[spremenljivka] > 0)
+ createMarker(spremenljivka, address, pos, true);
+ });
+ }
+
+ </script>
+ <?php
+ echo '</div>';
+ }
+
+}
diff --git a/main/survey/app/Controllers/Vprasanja/MaxDiffController.php b/main/survey/app/Controllers/Vprasanja/MaxDiffController.php
new file mode 100644
index 0000000..e1807b9
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MaxDiffController.php
@@ -0,0 +1,295 @@
+<?php
+/***************************************
+ * Description: Multigrid maxdiff
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 5
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+class MaxDiffController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MaxDiffController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za maxdiff
+ */
+ public function display($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ // diferencial
+ $size += 2;
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ //$cellsize = round(80/$size);
+ $cellsize = round(160 / $size);
+ } else {
+ //$cellsize = 'auto';
+ $cellsize = round(160 / $size);
+ }
+
+ //$spacesize = round(80/$size/4);
+ $spacesize = round(240 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table maxdiff">' . "\n";
+
+
+ echo '<thead>';
+ echo ' <tr>' . "\n";
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ //echo ' <td></td>'."\n";
+
+ if ($i == 1) {
+ echo ' <td></td>' . "\n";
+ }
+
+
+ }
+ }
+
+ echo ' </tr>' . "\n";
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing ' . $cssAlign . '">';
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input data-col="' . $i . $row[0] . '" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ if ($i == 1) {
+ echo ' <td style="text-align: center;" class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+ echo '</td>' . "\n";
+ }
+
+
+ } else {
+ echo '<td class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input data-col="' . $i . $row[0] . '" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ //urejanje navpicnega dela grupiranja radio button - vodoravni je urejen po defaultu s pomočjo atributa name
+ echo '
+ <script>
+
+ $(document).ready(
+ function(){
+ var col, elem, ime;
+ ime = "vrednost_' . $row1['id'] . '";
+
+ $("input[name=" + ime + "]").click(function() {
+ elem = $(this);
+ col = elem.data("col");
+ $("input[data-col=" + col + "]").prop("checked", false);
+ elem.prop("checked", true);
+ });
+ }
+ );
+ </script>
+ ';
+
+ if ($i == 1) {
+ echo ' <td style="text-align: center;" class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo '</td>';
+ }
+ }
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/MultigridController.php b/main/survey/app/Controllers/Vprasanja/MultigridController.php
new file mode 100644
index 0000000..85fd49d
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MultigridController.php
@@ -0,0 +1,1686 @@
+<?php
+/***************************************
+ * Description: Multigrid: dropdown, select box, checkbox, multiple
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 2, enota 6
+ * tip 16 - enota 3, enota 6, enota 0
+ * tip 19
+ * tip 20
+ * tip 24
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+
+class MultigridController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MultigridController();
+ }
+
+ protected $spremenljivka;
+
+ /**
+ * @desc prikaze vnosno polje za navadno tabelo in tabelo diferencial
+ * Stara funkcija $this->displayMultigrid($spremenljivka);
+ */
+ public function display($spremenljivka)
+ {
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // prej:
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+
+ // Za izris traku
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox trak
+ $trak_num_of_titles = ($spremenljivkaParams->get('trak_num_of_titles') ? $spremenljivkaParams->get('trak_num_of_titles') : 0); //belezi stevilo nadnaslovov
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen @ diferencial ali klasicna tabela
+ $trak_class = 'trak_class';
+ $trak_class_input = 'trak_class_input';
+ $question = 'question_trak';
+
+ if ($row['enota'] == 1){ //ce je diferencial
+ $gridWidth = 15; //za sirino celic skrajno levo pa desno od traku
+ }
+
+ if($trak_num_of_titles != 0){
+ $display_trak_num_of_titles = 'style="display:none;"';
+ $trak_nadnaslov_table_td_width = 100 / $trak_num_of_titles; //spremenljivka za razporeditev sirine nadnaslovov @ traku
+ }
+
+ $display_trak_num_of_titles = '';
+ }
+ else{
+ $trak_class = '';
+ $trak_class_input = '';
+ $question = 'question';
+ $display_trak_num_of_titles = 'style="display:none;"';
+ }
+
+ for($i = 1; $i <= $trak_num_of_titles; $i++){
+ $trak_nadnaslov[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.$i.'') ? $spremenljivkaParams->get('trak_nadnaslov_'.$i.'') : $lang['srv_new_text']);
+ }
+ // Za izris traku - konec
+
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ // diferencial
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+
+ // IZRIS TABELE
+ echo '<table class="grid_table multigrid">' . "\n";
+
+
+ // Colgroup
+ // ce je gridWidth enak nula, imamo skrito labelo.
+ // hideLabels bom posredoval naprej v funkcije
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo ' <col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+ }
+
+
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++) {
+ echo '<col>';
+ }
+ echo '</colgroup>';
+
+
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+ if ($row['enota'] > 0 && !in_array($row['enota'], [11,12])) {
+ // desnih label ne bom skrival, ker je neumno dati dvojne labele + skrite labele!
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="differential">';
+ echo ' <col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ }
+ // Colgroup - konec
+
+
+ // Header vrstica
+ echo '<thead>';
+ $this->displayMultigridHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $diferencial_trak, $trak_nadnaslov, $display_trak_num_of_titles, $middle_row=false, $hideLabels);
+ echo '</thead>';
+
+
+ // Body tabele
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+
+ # po potrebi prevedemo naslov2 za semanticni diferencial
+ if($row['enota'] == 1){
+ $naslov2 = Language::getInstance()->srv_language_vrednost($row1['id'], true);
+ if ($naslov2 != '') {
+ $row1['naslov2'] = $naslov2;
+ }
+ }
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">' . "\n";
+
+ if ($hideLabels == false) {
+
+ echo ' <td class="'.$question.'">';
+
+ echo $row1['naslov'];
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo '</td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ if (count($srv_grids) > 0) {
+
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 1);">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo '</label>';
+
+ echo '</td>' . "\n";
+ }
+ else {
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0) ){
+ echo '<td onClick="checkBranching(); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 0);" id="trak_tbl_' . $row1['id'] . '_'.$srv_grid['vrstni_red'].'" class="category' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' '.$trak_class.' '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? 'trak_container_bg' : '').'">';
+
+ # ni missing vrednost
+ echo '<input vre_id = '.$row1['id'].' class="'.$trak_class_input.'" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '">';
+ echo '<label class="radio-button-label">'.$srv_grid['variable'].'</label>';
+
+ echo '</td>' . "\n";
+ }
+ else{
+ // Pri VAS in slikovnem tiput mora biti 'checked' označen tudi pri TD elementu
+ $_checked = (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '');
+
+ // V kolikor imamo vizalno skalo in smeške
+ if($row['enota'] == 11){
+ $tabelaSmeski = 'visual-radio-scale visual-radio-table';
+ }
+ elseif($row['enota'] == 12){
+ $tabelaSmeski = 'custom_radio_picture custom-radio-table';
+ }
+ else{
+ $tabelaSmeski ='';
+ }
+
+ echo '<td class="category '.$tabelaSmeski. $_checked.' ' . $cssAlign . '">';
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . $_checked . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); customRadioTableSelect(' . $row1['id'] . ', ' . $value. ');">';
+
+ if($row['enota'] == 11){
+ echo '<span class="enka-vizualna-skala siv-'.$row['grids'].$value.'"></span>';
+ }elseif($row['enota'] == 12){
+ echo '<span class="enka-custom-radio '.$spremenljivkaParams->get('customRadio').'"></span>';
+ }else {
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ }
+ echo '</label>';
+
+ //Pri smeških moramo pognati JS, da doda ustrezen razred 'obarvan'
+ if($row['enota'] == 12 && ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing)){
+ echo '<script>
+ $(document).ready( function(){ customRadioTableSelect(\''.$row1['id'].'\', \''.$value.'\'); } );
+ </script>';
+ }
+
+ echo '</td>' . "\n";
+ }
+ }
+ }
+ }
+ # dodamo še enoto
+ if ($row['enota'] == 1) {
+ // Datapiping
+ $row1['naslov2'] = Helper::dataPiping($row1['naslov2']);
+
+ echo ' <td></td>' . "\n";
+ echo ' <td class="differential question_trak">' . $row1['naslov2'] . '</td>' . "\n";
+ }
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+
+
+ // za ureditev prilagajanja label stolpcev - prilagajanje trem opisnim nadnaslovom
+ $custom_column_label_option = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1);
+ echo '<script>
+ change_custom_column_label_respondent(\'' . $row['grids'] . '\', \'' . $row['id'] . '\', \'' . $custom_column_label_option . '\');
+ </script>';
+
+ // prilagajanje stevilu izbranih nadnaslovov
+ if($trak_num_of_titles != 0){
+ ?>
+ <script>
+ $(document).ready(function(){
+ trak_edit_num_titles_respondent(<?=$row['grids']?>, <?=$spremenljivka?>, <?=$trak_num_of_titles?>, <?=json_encode($trak_nadnaslov)?>);
+ });
+ </script>
+ <?
+ }
+ // za ureditev prilagajanja label stolpcev - konec
+
+
+ // JS za ponvaljanje naslovne vrstice
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+ if($grid_repeat_header > 0){
+ echo '<script> gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['id'].'\'); </script>';
+ }
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayMultigridDropdown($spremenljivka);
+ ************************************************/
+ public function dropdown($spremenljivka)
+ {
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $_otherStatusFields = array(99 => 'undecided', 98 => 'rejected', 97 => 'inappropriate');
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ if ($gridAlign == 0)
+ $cssAlign = ' class="alignCenter"';
+ elseif ($gridAlign == 1)
+ $cssAlign = ' class="alignLeft"';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' class="alignRight"';
+
+ echo ' <table class="grid_table multigriddropdown">' . "\n";
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ echo '<col>';
+ echo '</colgroup>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // cache tabele srv_grid, da se ne bere vsakic znova
+ $srv_grids = array();
+
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') $row_grid['naslov'] = $naslov;
+
+ $srv_grids[$row_grid['vrstni_red']] = $row_grid;
+ }
+
+ // cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo '<tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.$row3['text'].'">';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ echo '<td ' . $cssAlign . '>';
+
+
+ if ($row['enota'] == 2) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $prvaVrstica_roleta = ($spremenljivkaParams->get('prvaVrstica_roleta') ? $spremenljivkaParams->get('prvaVrstica_roleta') : 1);
+
+ //echo '<select multiple name="vrednost_'.$row1['id'].'" id="vrednost_'.$spremenljivka.'_'.$row1['id'].'" size="'.$sbSize.'" onchange="checkBranching(); omejiSelectBoxMulti('.$spremenljivka.','.$row1['id'].'); clickSelectBox('.$spremenljivka.');" multiple = " ">'."\n";
+ echo '<select name="vrednost_' . $row1['id'] . '" id="vrednost_' . $spremenljivka . '_' . $row1['id'] . '" size="1" onclick="checkBranching(); omejiSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . '); clickSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . ');" >' . "\n";
+ switch ($prvaVrstica_roleta) {
+ case "1":
+ echo ' <option value=""></option>';
+ break;
+ case "2":
+
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+ }
+
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $row5 = $srv_grid;
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ echo '<option name="vrednost_' . $row1['id'] . '_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ }
+ }
+
+
+ echo '</select>' . "\n";
+ echo '</td>' . "\n";
+
+ echo '</tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayMultigridSelectBox($spremenljivka);d
+ ************************************************/
+ public function selectBox($spremenljivka)
+ {
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $_otherStatusFields = array(99 => 'undecided', 98 => 'rejected', 97 => 'inappropriate');
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ if ($gridAlign == 0)
+ $cssAlign = ' class="alignCenter"';
+ elseif ($gridAlign == 1)
+ $cssAlign = ' class="alignLeft"';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' class="alignRight"';
+
+ echo ' <table class="grid_table multigriddropdown">' . "\n";
+
+ if ($hideLabels ==false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ echo '<col>';
+ echo '</colgroup>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $missingi = array();
+
+ // cache tabele srv_grid, da se ne bere vsakic znova
+ $srv_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') $row_grid['naslov'] = $naslov;
+
+ $srv_grid[$row_grid['vrstni_red']] = $row_grid;
+
+ //belezenje missingov
+ if($row_grid['other']!=0){
+ array_push($missingi, $row_grid['naslov']);
+ }
+ }
+
+ // cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo '<tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.$row3['text'].'">';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ echo '<td ' . $cssAlign . '>';
+
+ // todo id se podvaja - popravljeno
+ //echo '<select name="vrednost_'.$row1['id'].'" id="vrednost_'.$spremenljivka.'_'.$row1['id'].'" size="1" onchange="checkBranching();" >'."\n";
+
+ if ($row['tip'] == 6) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+ //echo '<select multiple name="vrednost_'.$row1['id'].'" id="vrednost_'.$spremenljivka.'_'.$row1['id'].'" size="'.$sbSize.'" onchange="checkBranching(); omejiSelectBoxMulti('.$spremenljivka.','.$row1['id'].'); clickSelectBox('.$spremenljivka.');" multiple = " ">'."\n";
+ echo '<select multiple name="vrednost_' . $row1['id'] . '" id="vrednost_' . $spremenljivka . '_' . $row1['id'] . '" size="' . $sbSize . '" onclick="checkBranching(); omejiSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . '); clickSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . ');" multiple = " ">' . "\n";
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo ' <option value=""></option>';
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+
+ } elseif ($row['tip'] == 16) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+
+ echo '<select name="vrednost_' . $row1['id'] . '[]" id="vrednost_' . $spremenljivka . '_' . $row1['id'] . '" size="' . $sbSize . '" onclick="checkBranching(); clickSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . ');" multiple = " ">' . "\n";
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo ' <option value=""></option>';
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+ }
+
+ //echo '<option value=""></option>'."\n";
+
+ //for ($i = 1; $i <= $row['grids']; $i++) {
+ for ($i = 1; $i <= count($srv_grid); $i++) {
+
+ $row5 = $srv_grid[$i];
+ $value1 = $value2 = $row5['id'];
+
+ if($row5['other']!=0){ //ce so missingi
+ $value2 = $row5['other'];
+ }
+
+ // todo name je obsolete - popravljeno
+ if ($row['tip'] == 16) {
+ //echo '<option name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ echo '<option name="vrednost_' . $row1['id'] . '_grid_' . $value1 . '" id="vrednost_' . $row1['id'] . '_grid_' . $valu1e . '" value="' . $value2 . '"' . (($grid_id == $value1 && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ //echo '<option name="vrednost_' . $row1['id'] . '_grid_' . $value1 . '" id="vrednost_' . $row1['id'] . '_grid_' . $valu1e . '" value="' . $value2 . '"' . (($grid_id == $value1 && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="0" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ } else {
+ //echo '<option name="vrednost_' . $row1['id'] . '_' . $i . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ echo '<option name="vrednost_' . $row1['id'] . '_' . $i . '" id="vrednost_' . $row1['id'] . '_grid_' . $value1 . '" value="' . $value2 . '"' . (($grid_id == $value1 && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ }
+ }
+
+ echo '</select>' . "\n";
+ echo '</td>' . "\n";
+
+ echo '</tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayMultigridSelectBox($spremenljivka);
+ ************************************************/
+ public function checkbox($spremenljivka)
+ {
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // za združljivost za nazaj dodam tudi v "staro funkcijo" opcijo prikaza brez labele :)
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ // polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ // če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ echo ' <table class="grid_table multigridcheckbox">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo ' <col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ # če imamo enoto povečamo št. stoplcev
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30)
+ $cellsize = round(80 / $size);
+ else
+ $cellsize = 'auto';
+
+ $spacesize = round(80 / $size / 4);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1);
+ //default sirina
+ if ($taWidth == -1)
+ //$taWidth = 10;
+ $taWidth = round(50 / $size);
+
+ $bg = 1;
+
+
+ // Header tabele
+ echo '<thead>';
+ $this->displayMulticheckboxHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $middle_row=false, $hideLabels);
+ echo '</thead>';
+
+
+ // Body tabele
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $srv_data_cache = array();
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+
+ # izpišemo labelo grida
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing ' . $cssAlign . '">';
+ # imamo missing polje
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, 16, ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {# ni missing vrednost
+ echo '<td class="category ' . $cssAlign . '">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="1" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, 16, ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+ echo '</tbody>';
+
+ echo ' </table>' . "\n";
+
+ // JS za ponvaljanje naslovne vrstice
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+ if($grid_repeat_header > 0){
+ echo '<script> gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['id'].'\'); </script>';
+ }
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za multiple (kombinirano) tabelo, ki je sestavljena iz večih tabel
+ * Stara funkcija $this->displayMultigridMultiple($spremenljivka);
+ */
+ public function multiple($spremenljivka)
+ {
+ global $admin_type;
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+
+ $sql1 = sisplet_query("SELECT spr_id FROM srv_grid_multiple WHERE parent='$spremenljivka' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $multiple[] = $row1['spr_id'];
+ }
+ if (count($multiple) == 0)
+ return;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT g.*, s.tip, s.enota, s.dostop, s.params FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id=m.spr_id AND m.spr_id IN (" . implode(',', $multiple) . ") ORDER BY m.vrstni_red, g.vrstni_red");
+ if (!$sql_grid) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row_grid['spr_id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+
+ // Sirina posamezne podtabele v % (lahko jo posebej nastavimo)
+ $subtabelaParams = new enkaParameters($row_grid['params']);
+ $gridmultiple_width = (($subtabelaParams->get('gridmultiple_width') > 0) ? $subtabelaParams->get('gridmultiple_width') : 0);
+ if($gridmultiple_width > 0){
+
+ $sql_grid_size = sisplet_query("SELECT COUNT(*) as cnt_grids FROM srv_grid WHERE spr_id='".$row_grid['spr_id']."'");
+ $row_grid_size = mysqli_fetch_assoc($sql_grid_size);
+
+ if((int)$row_grid_size['cnt_grids'] > 1){
+ $row_grid['gridmultiple_width'] = floor($gridmultiple_width / $row_grid_size['cnt_grids']);
+ }
+ else{
+ $row_grid['gridmultiple_width'] = $gridmultiple_width;
+ }
+ }
+
+ if ($row_grid['tip'] == 6 && ($row_grid['enota'] == 2 || $row_grid['enota'] == 6)) {
+ $srv_grids[$row_grid['spr_id'] . '-0'] = $row_grid;
+ }
+ elseif ($row_grid['tip'] == 16 && $row_grid['enota'] == 6) {
+ $srv_grids[$row_grid['spr_id'] . '-0'] = $row_grid;
+ }
+ else {
+ $srv_grids[$row_grid['spr_id'] . '-' . $row_grid['id']] = $row_grid;
+
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+ }
+
+ $size = count($srv_grids);
+
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ }
+ else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table multigrid">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup class="category">';
+ /*for ($i = 1; $i <= $size; $i++)
+ echo '<col>';*/
+ foreach ($srv_grids as $grid){
+ if($grid['gridmultiple_width'] > 0)
+ echo '<col style="width:'.$grid['gridmultiple_width'].'%;">';
+ else
+ echo '<col>';
+ }
+ echo '</colgroup>';
+
+ echo '<thead>';
+
+ // podnaslovi gridov
+ if ($row['grid_subtitle1'] == '1') {
+ echo ' <tr>';
+ if ($hideLabels == false) {
+ echo ' <td></td>';
+ //echo ' <td style="width:' . $spacesize . '%"></td>';
+ echo ' <td></td>';
+ }
+ $sql2 = sisplet_query("SELECT s.id, s.naslov, s.tip, s.dostop, s.enota, s.grids FROM srv_spremenljivka s, srv_grid_multiple m WHERE s.id = m.spr_id AND parent = '" . $row['id'] . "' ORDER BY m.vrstni_red");
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ // Datapiping
+ $row2['naslov'] = Helper::dataPiping($row2['naslov']);
+
+ if (($admin_type <= $row2['dostop'] && $admin_type >= 0) || ($admin_type == -1 && $row2['dostop'] == 4) || get('forceShowSpremenljivka')){
+ if (get('lang_id') != null) {
+ $rowl = \App\Controllers\LanguageController::srv_language_spremenljivka($row2['id']);
+ if (strip_tags($rowl['naslov']) != '') $row2['naslov'] = $rowl['naslov'];
+ }
+
+ echo ' <td colspan="' . ($row2['tip'] == 6 && ($row2['enota'] == 2 || $row2['enota'] == 6) ? '1' : $row2['grids']) . '" class="grid_header" grd="g_' . $row2['id'] . '">' . $row2['naslov'] . '</td>';
+ }
+ }
+
+ echo ' </tr>';
+ }
+
+ echo ' <tr>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ $jj = 0;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ $jj++;
+ if (($admin_type <= $srv_grid['dostop'] && $admin_type >= 0) || ($admin_type == -1 && $srv_grid['dostop'] == 4) || get('forceShowSpremenljivka')) {
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ # izpišemo labelo grida
+ if ($srv_grid['tip'] == 6 && ($srv_grid['enota'] == 2 || $srv_grid['enota'] == 6)) {
+ echo '<td></td>';
+ }
+ elseif ($srv_grid['tip'] == 16 && $srv_grid['enota'] == 6) {
+ echo '<td></td>';
+ }
+ else {
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ }
+ }
+ if ($row['enota'] > 0) echo '<td></td><td></td>'; // differencial
+ echo ' </tr>' . "\n";
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($multiple[0], get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id IN (" . implode(',', $multiple) . ") AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['spr_id']][$row_grid['vre_id']] = $row_grid;
+ }
+
+ $srv_data_checkgrid = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id IN (" . implode(',', $multiple) . ") AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_checkgrid[$row2['spr_id']][$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id IN (" . implode(',', $multiple) . ") AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['spr_id']][$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, vrstni_red, hidden, other FROM srv_vrednost WHERE spr_id='" . $multiple[0] . "' ORDER BY FIELD(vrstni_red, $orderby)");
+ $sql_if_variabla = sisplet_query("SELECT id, other FROM srv_vrednost WHERE spr_id='" . $row['id'] . "' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $row_if_variabla = mysqli_fetch_array($sql_if_variabla);
+
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row_if_variabla['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $is_missing = false;
+
+ echo ' <tr id="vrednost_if_' . $row_if_variabla['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ //echo ' <tr id="vrednost_if_'.$row1['id'].'">'."\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">';
+ echo $row1['naslov'];
+ if ($row_if_variabla['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='" . $multiple[0] . "' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+
+ $jj = 0;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+ $jj++;
+
+ if (($admin_type <= $srv_grid['dostop'] && $admin_type >= 0) || ($admin_type == -1 && $srv_grid['dostop'] == 4) || get('forceShowSpremenljivka')) {
+
+ $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='" . $srv_grid['spr_id'] . "' AND vrstni_red = '" . $row1['vrstni_red'] . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $row_spr = Model::select_from_srv_spremenljivka($srv_grid['spr_id']);
+ $spr_Params = new enkaParameters($row_spr['params']);
+
+ $value = $srv_grids[$i]['id'];
+
+ // multigrid
+ if ($row_spr['tip'] == 6) {
+
+ // dropdown in selectbox
+ if (($row_spr['enota'] == 2) || ($row_spr['enota'] == 6)) {
+ $sbSize = ($spr_Params->get('sbSize') ? $spr_Params->get('sbSize') : 3);
+ $prvaVrstica = ($spr_Params->get('prvaVrstica') ? $spr_Params->get('prvaVrstica') : 1);
+ $prvaVrstica_roleta = ($spr_Params->get('prvaVrstica_roleta') ? $spr_Params->get('prvaVrstica_roleta') : 1);
+ $grid_id = $srv_data_grid[$row_spr['id']][$row2['id']]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ if ($row_spr['enota'] == 2) {//roleta
+ echo '<select id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" onchange="checkBranching();" size="1" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '">';
+ //echo '<option value=""></option>';
+ switch ($prvaVrstica_roleta) {
+ case "1":
+ echo ' <option value=""></option>' . "\n";
+ break;
+ case "2":
+
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>' . "\n";
+ break;
+ }
+ } elseif ($row_spr['enota'] == 6) {//selectbox
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+ echo '<select id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" onclick="checkBranching(); clickSelectBoxMultiCombo(' . $row_spr['id'] . ',' . $row2['id'] . ', ' . $value . ');" size="' . $sbSize . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '">';
+
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo '<option value=""></option>';
+ break;
+ case "3":
+ echo '<option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+
+ //echo '<option value=""></option>';
+ }
+
+
+ $sql_grid = sisplet_query("SELECT id, naslov, variable FROM srv_grid WHERE spr_id='$row_spr[id]' ORDER BY vrstni_red");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ echo '<option id="vrednost_' . $row_spr['id'] . '_grid_' . $row_grid['id'] . '" value="' . $row_grid['id'] . '" onclick="checkBranching();" data-calculation="' . $row_grid['variable'] . '" name="vrednost_' . $row_spr['id'] . '" ' . ($row_grid['id'] == $grid_id ? ' selected' : '') . '>' . $row_grid['naslov'] . '</option>';
+ }
+ echo '</select>';
+ echo '</td>';
+ } else {
+
+ $grid_id = $srv_data_grid[$row_spr['id']][$row2['id']]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ # ni missing vrednost
+ echo '<label for="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '"' : '') . ' id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio "' .((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ }
+
+ // multi
+ } elseif ($row_spr['tip'] == 16) {
+
+ //multi selectbox
+ if ($row_spr['enota'] == 6) {
+ $spremenljivkaParams = new enkaParameters($row_spr['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 3);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+ $grid_id = $srv_data_grid[$row_spr['id']][$row2['id']]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+
+ //echo '<select multiple="" id="multi_'.$row_spr['id'].'_'.$row2['id'].'_grid_'.$value.'" onchange="checkBranching();" size="'.$sbSize.'" name="multi_'.$row_spr['id'].'_'.$row2['id'].'">';
+ echo '<select multiple="" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" onclick="checkBranching(); clickSelectBoxMultiCombo(' . $row_spr['id'] . ',' . $row2['id'] . ', ' . $value . ');" size="' . $sbSize . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '[]">';
+
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo '<option value=""></option>';
+ break;
+ case "3":
+ echo '<option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+
+ //echo '<option value=""></option>';
+
+ $sql_grid = sisplet_query("SELECT id, naslov, variable FROM srv_grid WHERE spr_id='$row_spr[id]' ORDER BY vrstni_red");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ echo '<option id="vrednost_' . $row_spr['id'] . '_grid_' . $row_grid['id'] . '" value="' . $row_grid['id'] . '" onclick="checkBranching();" data-calculation="' . $row_grid['variable'] . '" name="vrednost_' . $row_spr['id'] . '" ' . ($row_grid['id'] == $grid_id ? ' selected' : '') . '>' . $row_grid['naslov'] . '</option>';
+ //echo '<option id="vrednost_'.$row_spr['id'].'_grid_'.$row_grid['id'].'" value="'.$row_grid['id'].'" onclick="checkBranching();" data-calculation="'.$row_grid['variable'].'" name="vrednost_'.$row_spr['id'].'[]" '.($row_grid['id']==$grid_id?' selected':'').'>'.$row_grid['naslov'].'</option>';
+ }
+ echo '</select>';
+ echo '</td>';
+ }//multi checkbox
+ elseif ($row_spr['enota'] != 6) {
+ $grid_id = $srv_data_checkgrid[$row_spr['id']][$row2['id']][$value]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ echo '<label for="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="1" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio "' .((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ // multitext
+ } elseif ($row_spr['tip'] == 19) {
+
+ $taWidth = ($spr_Params->get('taWidth') ? $spr_Params->get('taWidth') : -1);
+ $taHeight = ($spr_Params->get('taHeight') ? $spr_Params->get('taHeight') : 1);
+
+ //default sirina
+ if ($taWidth == -1) {
+ $taWidth = 80;
+ }
+ else {
+ $taWidth = $taWidth * 10; // da dobimo % (opcije se od 1 - 9)
+ }
+
+ $vsebina = $srv_data_cache[$row_spr['id']][$row2['id']][$srv_grid['id']]['text'];
+
+ // datum
+ if ($spr_Params->get('multigrid-datum') == '1') {
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' datepicker ' . $cssAlign . '">';
+ echo '<input type="text" class="width_' . $taWidth . ' height_' . $taHeight . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();" value="' . ($is_missing ? '' : $vsebina) . '" readonly="true">' . '';
+
+ $date_element = "#multi_" . $row_spr['id'] . "_" . $row2['id'] . "_grid_" . $value;
+ ?>
+ <script>
+ datepicker("<?=$date_element?>", <?=($_GET['a'] != 'preview_spremenljivka' ? 'true' : 'false')?>);
+ <?php
+ # dodamo date range
+ echo Helper::getDatepickerRange($row_spr['id'], $date_element);
+
+ echo '$( "' . $date_element . '" ).datepicker( "option", "closeText", \'' . $lang['srv_clear'] . '\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showOn", \'button\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showButtonPanel", true);';
+
+ // Gumb pocisti vrednost na dnu
+ echo '$("' . $date_element . '").datepicker( "option", {
+ beforeShow: function( input ) {
+ setTimeout(function() {
+ var clearButton = $(input )
+ .datepicker( "widget" )
+ .find( ".ui-datepicker-close" );
+ clearButton.unbind("click").bind("click",function(){$.datepicker._clearDate( input );});
+ }, 1 );
+ }
+ });';
+
+ ?>
+ </script>
+ <?
+
+ echo '</td>' . "\n";
+ }
+ // navaden text
+ else {
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ echo '<textarea class="width_' . $taWidth . ' height_' . $taHeight . '" rows="' . $taHeight . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();">' . ($is_missing ? '' : $vsebina) . '</textarea>';
+ echo '</td>' . "\n";
+ }
+
+ // multinumber
+ } elseif ($row_spr['tip'] == 20) {
+
+ $taWidth = ($spr_Params->get('taWidth') ? $spr_Params->get('taWidth') : -1);
+ $taHeight = ($spr_Params->get('taHeight') ? $spr_Params->get('taHeight') : 1);
+
+ //default sirina
+ if ($taWidth == -1) {
+ $taWidth = 80;
+ }
+ else {
+ $taWidth = $taWidth * 10; // da dobimo % (opcije se od 1 - 9)
+ }
+
+ $vsebina = $srv_data_cache[$row_spr['id']][$row2['id']][$srv_grid['id']]['text'];
+
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ //echo '<textarea class="width_'.$taWidth.' height_'.$taHeight.'" rows="'.$taHeight.'" name="multi_'.$row_spr['id'].'_'.$row2['id'].'_grid_'.$value.'" id="multi_'.$row_spr['id'].'_'.$row2['id'].'_grid_'.$value.'" data-calculation="'.$srv_grid['variable'].'" '.($is_missing ? ' disabled' : '').' onkeyup="checkBranching();">'.($is_missing ? '' : $vsebina).'</textarea>';
+ echo '<input type="text" class="width_' . $taWidth . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" value="' . ($is_missing ? '' : $vsebina) . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeypress="checkNumber(this, ' . $row_spr['cela'] . ', ' . $row_spr['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row_spr['cela'] . ', ' . $row_spr['decimalna'] . '); checkBranching();">';
+
+ echo '</td>' . "\n";
+
+ }
+ }
+ }
+ }
+ # dodamo še enoto
+ if ($row['enota'] == 1) {
+ echo ' <td></td>' . "\n";
+ echo ' <td class="differential">' . $row1['naslov2'] . '</td>' . "\n";
+ }
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+
+ // Izris naslovne vrstice tabele za radio tabelo
+ private function displayMultigridHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $diferencial_trak, $trak_nadnaslov, $display_trak_num_of_titles, $middle_row=false, $hideLabels=false){
+ global $lang;
+
+ // Vrstica z nadnaslovi
+ echo '<tr '.$display_trak_num_of_titles.' class="display_trak_num_of_titles_respondent_'.$row['id'].'">';
+
+ if ($hideLabels == false) {
+ echo ' <td></td>';
+ echo ' <td></td>';
+ }
+
+ for ($j = 1; $j <= $row['grids']; $j++) {
+
+ if($j == 1){
+ $nadnaslov_floating = 'left';
+ }
+ else if($j == $row['grids']){
+ $nadnaslov_floating = 'right';
+ }
+ else{
+ $nadnaslov_floating = 'none';
+ }
+
+ echo '<td class="trak_inline_nadnaslov" grd="gr_'.$j.'"><div id="trak_nadnaslov_'.$j.'_'.$spremenljivka.'" name="trak_nadnaslov_'.$j.'" class="trak_inline_nadnaslov" style="float:'.$nadnaslov_floating.'; display:inline" '.(strpos($trak_nadnaslov[$j], $lang['srv_new_text'])!==false || $this->lang_id!=null ?' default="1"':'').'>' . $trak_nadnaslov[$j] . '</div></td>';
+ }
+
+ // Ce je diferencial
+ if ($row['enota'] == 1) {
+
+ echo '<td></td><td></td>';
+
+ if($mv_count > 0 && $diferencial_trak == 1){
+ for($z=0; $z<=$mv_count; $z++){
+ echo '<td></td>';
+ }
+ }
+ }
+ echo '</tr>';
+ // Vrstica z nadnaslovi - konec
+
+
+ // Preverimo, ce ponavljamo glavo - potem ji dodamo class in jo z JS ponovimo
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+
+ // Zacetek TR
+ if (($mv_count > 0 && $diferencial_trak == 1) || $diferencial_trak != 1) {
+ echo ' <tr class="table-header '.($middle_row ? 'middle_row"' : ''). ' ' .($grid_repeat_header > 0 ? 'repeat_header' : '').'">' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>';
+ echo ' <td></td>';
+ }
+ }
+
+ if (count($srv_grids) > 0) {
+
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ # dodamo spejs pred manjkajočimi vrednostmi
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Ce ni traku izpišemo labelo grida
+ if($diferencial_trak != 1){
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ // Ce je trak
+ elseif($diferencial_trak == 1 && $mv_count > 0){
+
+ // Izpišemo ustrezno labelo grida
+ if($srv_grid['other'] == 0){ //ce je labela za kategorijo odgovora, naj bo prazno
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '"></td>' . "\n";
+ }
+ // Drugace, ce je labela za missing, izpisi labelo
+ else {
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ }
+ }
+
+ // Differencial in ni traku
+ if ($row['enota'] > 0 && $diferencial_trak != 1 && !in_array($row['enota'], [11,12]))
+ echo '<td></td><td></td>';
+
+
+ // Konec TR
+ if (($mv_count > 0 && $diferencial_trak == 1) || $diferencial_trak != 1)
+ echo ' </tr>' . "\n";
+ }
+
+ // Izris naslovne vrstice tabele za checkbox tabelo
+ private function displayMulticheckboxHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $middle_row=false, $hideLabels){
+ global $lang;
+
+ // Preverimo, ce ponavljamo glavo - potem ji dodamo class in jo z JS ponovimo
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+
+ // Zacetek TR
+ echo ' <tr class="table-header '.($middle_row ? 'middle_row"' : ''). ' ' .($grid_repeat_header > 0 ? 'repeat_header' : '').'">' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ if (count($srv_grids) > 0) {
+
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $g_id => $srv_grid) {
+
+ # dodamo spejs pred manjkajočimi vrednostmi
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+
+
+ // Konec TR
+ echo ' </tr>' . "\n";
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/MultigridMobileController.php b/main/survey/app/Controllers/Vprasanja/MultigridMobileController.php
new file mode 100644
index 0000000..eaf7eb2
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MultigridMobileController.php
@@ -0,0 +1,1621 @@
+<?php
+/***************************************
+ * Description: Multigrid - na mobilnikih
+ *
+ * Vprašanje je prisotno:
+ * tip 6
+ * tip 16
+ * tip 19
+ * tip 20
+ *
+ * Autor: Peter Hrvatin
+ * Created date: 9.05.2019
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+
+
+class MultigridMobileController extends Controller{
+
+ protected $spremenljivka;
+
+ public function __construct(){
+ parent::getGlobalVariables();
+ }
+
+ // Get instance
+ private static $_instance;
+
+ public static function getInstance(){
+
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MultigridMobileController();
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za tabelo radio
+ */
+ public function radioMultigrid($spremenljivka){
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+
+ # koliko je stolpcev z manjkajočimi vrednostmi
+ $mv_count = 0;
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobietl
+ echo '<div class="grid_mobile radio '.($row['enota'] == 11 ? 'visual_scale' : '').' '.($row['enota'] == 12 ? 'smiley_scale' : '').' '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $first = true;
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '').(($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '')
+ $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ // preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ // Ugotovimo ali je na katerem gridu predhodno izbran missing oz. pridobimo text. vrednost izpolnjenega odg.
+ $is_missing = false;
+ $grid_data_value = '';
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ // Ugotovimo ali je na katerem gridu predhodno izbran missing
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+
+ // Pridobimo text. vrednost izpolnjenega odg.
+ if($srv_grids[$i]['id'] == $grid_id){
+ $grid_data_value = $srv_grids[$i]['naslov'];
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';
+
+ echo '</div>';
+
+
+ // IZPOLNJENA VREDNOST, ce obstaja in ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2){
+ echo '<div class="grid_mobile_result">'.($grid_id != '' ? $grid_data_value : '').'</div>';
+ }
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ $cnt = 0;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids[$i]['id'];
+
+ $is_checked = (($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? true : false;
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids[$i]['id'];
+
+ $is_checked = ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? true : false;
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+
+ // Vizualna skala
+ if($row['enota'] == 11){
+ echo '<span class="category visual-radio-scale visual-radio-table '.$cssAlign.' '.($is_checked ? ' checked' : '').'"><label>';
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<span class="enka-vizualna-skala siv-'.$row['grids'].$value.'"></span>';
+
+ echo '</label></span>' . "\n";
+ }
+ // Smile-iji
+ elseif($row['enota'] == 12){
+ echo '<span class="category custom_radio_picture custom-radio-table '.$cssAlign.' '.($is_checked ? ' obarvan' : '').'"><label>';
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . '); customRadioTableSelectMobile(' . $row1['id'] . ', ' . $value. ');">';
+ echo '<span class="enka-custom-radio '.$spremenljivkaParams->get('customRadio').'"></span>';
+
+ echo '</label></span>' . "\n";
+ }
+ // Max Diff
+ elseif($row['enota'] == 5){
+ echo '<span class="category ' . $cssAlign . '">';
+
+ echo '<input data-col="'.$i.$row[0].'" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+ }
+ else {
+ echo '<span class="category ' . $cssAlign . '">';
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+ }
+
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti) - pri one against another tega ni
+ if($row['enota'] != 4)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+
+ // Vizualna skala - pobarvamo zvezdice
+ if($row['enota'] == 12 && $is_checked){
+ echo '<script>
+ $(document).ready( function(){ customRadioTableSelectMobile(\''.$row1['id'].'\', \''.$value.'\'); } );
+ </script>';
+ }
+ }
+
+ // Max Diff - urejanje navpicnega dela grupiranja radio button - vodoravni je urejen po defaultu s pomočjo atributa name
+ if($row['enota'] == 5){
+ echo '<script>
+ $(document).ready(
+ function(){
+ var col, elem, ime;
+ ime = "vrednost_' . $row1['id'] . '";
+
+ $("input[name=" + ime + "]").click(function() {
+ elem = $(this);
+ col = elem.data("col");
+
+ $("input[data-col=" + col + "]").prop("checked", false);
+ $("input[data-col=" + col + "]").parent().parent().removeClass("checked");
+
+ elem.prop("checked", true);
+ elem.parent().parent().addClass("checked");
+ });
+ }
+ );
+ </script>';
+ }
+
+ // One against another - beseda "ali"
+ if($row['enota'] == 4 && $cnt == 0){
+
+ echo '<div class="grid_mobile_title">';
+ echo self::$lang['srv_tip_sample_t6_4_vmes'];
+ echo '</div>';
+ }
+
+ $cnt++;
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+ // Semanticni diferencial in one against another - desna labela
+ if($row['enota'] == 1 || $row['enota'] == 4){
+
+ echo '<div class="grid_mobile_title">';
+
+ # po potrebi prevedemo naslov2 za semanticni diferencial
+ $naslov2 = Language::getInstance()->srv_language_vrednost($row1['id'], true);
+ if ($naslov2 != '') {
+ $row1['naslov2'] = $naslov2;
+ }
+
+ // Datapiping
+ $row1['naslov2'] = Helper::dataPiping($row1['naslov2']);
+
+ echo $row1['naslov2'];
+
+ echo '</div>';
+ }
+
+ // END grid_mobile_question
+ echo '</div>';
+
+ $first = false;
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+ /**
+ * @desc prikaze vnosno polje za dvojno tabelo radio
+ */
+ public function radioDoubleMultigrid($spremenljivka){
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+
+ # koliko je stolpcev z manjkajočimi vrednostmi
+ $mv_count = 0;
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='1' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ // se za desni del grida
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='2' ORDER BY vrstni_red");
+
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+ }
+
+ $indexLanguage++;
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobietl
+ echo '<div class="grid_mobile radio double '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='1' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+ // Cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja) - za part 2
+ $srv_data_grid2 = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='2' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid2[$row_grid['vre_id']] = $row_grid;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $first = true;
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '').(($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '')
+ $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ // preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ $grid_id2 = $srv_data_grid2[$row1['id']]['grd_id'];
+
+ // ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ /*if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';*/
+
+ echo '</div>';
+
+
+ // Podnaslov prve podtabele
+ if($row['grid_subtitle1'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle1'].'</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_1">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // Vmesna crta med prvim in drugim delom dvojne tabele
+ echo '<div class="grid_mobile_double_separator"></div>';
+
+
+ // Podnaslov druge podtabele
+ if($row['grid_subtitle2'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle2'].'</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_2">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids2) > 0) {
+
+ foreach ($srv_grids2 AS $j => $srv_grid) {
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<div class="grid_mobile_variable '.((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . ((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . (((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids2[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables part2
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+
+ $first = false;
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za tabelo checkbox
+ */
+ public function checkboxMultigrid($spremenljivka){
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobitel
+ echo '<div class="grid_mobile checkbox '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache izpolnjenih podatkov
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '').'>';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo '</div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';
+
+ echo '</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables">';
+
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $is_checked = ($grid_id == $value && $grid_id != '') ? true : false;
+
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing polje
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $is_checked = ($grid_id == $value && $grid_id != '' && !$is_missing) ? true : false;
+
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="1" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+ /**
+ * @desc prikaze vnosno polje za dvojno tabelo checkbox
+ */
+ public function checkboxDoubleMultigrid($spremenljivka){
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $srv_grids2 = array();
+
+ # koliko je stolpcev z manjkajočimi vrednostmi
+ $mv_count = 0;
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='1' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ // se za desni del grida
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='2' ORDER BY vrstni_red");
+
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+ }
+
+ $indexLanguage++;
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobietl
+ echo '<div class="grid_mobile checkbox double '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_cache = array();
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_cache)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $first = true;
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '').(($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '')
+ $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+ if (count($srv_grids2) > 0) {
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids2[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ /*if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';*/
+
+ echo '</div>';
+
+ // Podnaslov prve podtabele
+ if($row['grid_subtitle1'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle1'].'</div>';
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_1">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+
+ echo '<div class="grid_mobile_variable '.((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost 0
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // Vmesna crta med prvim in drugim delom dvojne tabele
+ echo '<div class="grid_mobile_double_separator"></div>';
+
+ // Podnaslov druge podtabele
+ if($row['grid_subtitle2'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle2'].'</div>';
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_2">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids2) > 0) {
+
+ foreach ($srv_grids2 AS $j => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$j]['grd_id'];
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids2[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables part2
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+
+ $first = false;
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za tabelo text in number
+ */
+ public function textMultigrid($spremenljivka){
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+
+ if ($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['num_useMin'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMax'] == 1)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ else
+ $limit = '';
+
+ //************Params za omejitev sliderjev
+ //tvorjenje omejitve********************************************************************************
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+ $limit_slider_mobile = '(min ' . $slider_MinNumLabel . ', max ' . $slider_MaxNumLabel . ')';
+ //************
+
+ // omejitev vnosa
+ if ($row['vsota_show'] == 1 && $row['ranking_k'] != '1' && $row['tip'] == 20) {
+ echo ' <label class="limit">' . $limit . '</label>';
+ }
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+
+
+ // Izrisemo celotno vsebino tabele za mobitel
+ echo '<div class="grid_mobile text '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache textovnih odgovorov
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Cache missingov
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '').'>';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';
+
+ echo '</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables">';
+
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ if ($srv_grid['other'] != 0)
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ else
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ if ($grid_id == $value) {
+ $vsebina = $srv_data_cache[$row1['id']][$i]['text'];
+ }
+
+
+ // Missing
+ if ($srv_grid['other'] != 0) {
+
+ $is_checked = ($grid_id == $value && $grid_id != '') ? true : false;
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ # imamo missing nardimo radio
+ echo '<span class="missing ' . $cssAlign . '">';
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>';
+
+ // izpišemo labelo grida
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ echo '<span class=" grid_mobile_variable_title ' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // multitext
+ elseif ($row['tip'] == 19) {
+
+ echo '<div class="grid_mobile_variable">';
+
+ // izpišemo labelo grida
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ echo '<span class="grid_mobile_variable_title ' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</span>';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ echo '<textarea class="width_' . $taWidth . '" rows="' . $taHeight . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();">' . ($is_missing ? '' : $vsebina) . '</textarea>';
+ echo '</span>' . "\n";
+
+ // END grid_mobile_variable
+ echo '</div>';
+ }
+ // multinumber - rabimo JS checkNumber
+ else {
+
+ echo '<div class="grid_mobile_variable">';
+
+ // izpišemo labelo grida
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ echo '<span class="grid_mobile_variable_title ' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</span>';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ echo '<input type="text" class="width_' . $taWidth . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . ($is_missing ? '' : $vsebina) . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); checkBranching();">';
+
+ // multislider
+ //slider na PC, tablici in mobilniku
+ if ($row['ranking_k'] == 1) {
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0);
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0);
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0);
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0);
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0);
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0);
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1);
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+ //$slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ //$slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5);
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0);
+ $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : '';
+
+
+ if(get('lang_id') != null){
+ $lang_id = get('lang_id');
+ $ank_id = get('anketa');
+
+ $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$ank_id' AND spr_id='$spremenljivka' AND lang_id='$lang_id' ORDER BY label_id";
+ $sqlSlider = sisplet_query($sqlString);
+
+ while ($rowsqlSlider = mysqli_fetch_array($sqlSlider)) {
+ if($rowsqlSlider['label_id'] == 1){
+ $MinLabel = $rowsqlSlider['label'];
+ }
+ elseif($rowsqlSlider['label_id'] == 2){
+ $MaxLabel = $rowsqlSlider['label'];
+ }elseif($row['label_id'] == 0){
+ $custom = $rowsqlSlider['label'];
+ }
+ }
+
+ if($slider_DescriptiveLabel_defaults && $custom==''){ //ce so prednalozene opisne labele drsnika in nimamo se prevoda
+ $custom_ar = explode(';', $slider_DescriptiveLabel_defaults_naslov1);
+ }else{ //ce so custom opisne labele drsnika
+ $custom_ar = explode('; ', $custom);
+ }
+
+ // Ce slucajno nimamo prevedeno uporabimo original
+ $MinLabel = ($MinLabel == '') ? ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']) : $MinLabel;
+ $MaxLabel = ($MaxLabel == '') ? ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']) : $MaxLabel;
+ }
+ else{
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']);
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']);
+ }
+
+ echo '<div style="width:100%; height:150px">';
+
+ //$default_value = round(($row['vsota_limit']-$row['vsota_min']) / 2) + $row['vsota_min'];
+ $default_value = round(($slider_MaxNumLabel - $slider_MinNumLabel) / 2) + $slider_MinNumLabel;
+ $vrednost = ($vsebina == '') ? $default_value : $vsebina;
+
+ //labeli nad min in max drsnikov ############################################################
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel">';
+ } else if (get('mobile') == 1) { //ce mobilnik
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel_mobile">';
+ }
+ echo '<tbody>';
+ echo '<tr>';
+ echo '<td align="left">' . $MinLabel . '</td>';
+ echo '<td align="right">' . $MaxLabel . '</td>';
+ echo '</tr>';
+ echo '</tbody>';
+ echo '</table>';
+ //labeli nad min in max drsnikov - konec ####################################################
+
+ echo '<div class="sliderText" id="sliderText_' . $spremenljivka . '_' . $row1['id'] . '">' . $vrednost . '</div>';
+
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider"></div>';
+ }
+ else if (get('mobile') == 1) { //ce mobilnik
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider_grid_mobile"></div>';
+ }
+
+ echo '</div>';
+
+ // za custom opisne labele
+ // moznosti urejanja opisnih label drsnika
+ if($slider_VmesneDescrLabel){
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ if($custom == ''){ //ce nimamo prevoda opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ }else{ //ce mamo prevod opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1];
+ }
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ }
+ //za custom opisne labele - konec
+
+ ?>
+ <script>
+ $(function () {
+ slider_grid_init(<?=get('mobile')?>, <?=$spremenljivka?>, <?=$row1['id']?>, <?=$slider_MinNumLabel?>, <?=$slider_MaxNumLabel?>, <?=$vrednost?>, <?=$slider_handle?>, <?=$slider_handle_step?>, <?=$slider_VmesneNumLabel?>, <?=$slider_VmesneCrtice?>, <?=$slider_MinMaxNumLabelNew?>, <?=$slider_window_number?>, '<?=$slider_DescriptiveLabel_defaults_naslov1?>', <?=$slider_DescriptiveLabel_defaults?>, <?=$default_value?>, <?=$slider_nakazi_odgovore?>, <?=$slider_VmesneDescrLabel?>, '<?=$slider_CustomDescriptiveLabels?>');
+ });
+ </script>
+ <?
+ }
+
+ echo '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/NumberController.php b/main/survey/app/Controllers/Vprasanja/NumberController.php
new file mode 100644
index 0000000..13f312c
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/NumberController.php
@@ -0,0 +1,372 @@
+<?php
+/***************************************
+ * Description: Number
+ *
+ * Vprašanje je prisotno:
+ * tip 7
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Models\Model;
+use enkaParameters;
+
+class NumberController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new NumberController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ //tvorjenje omejitve za sliderje v mobile razlicici********************************************************************************
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+
+ $limit_slider_mobile = '(min ' . $slider_MinNumLabel . ', max ' . $slider_MaxNumLabel . ')';
+ //**************************************************************************************************
+ //***************************
+
+
+ if ($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['num_useMin'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMax'] == 1)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ else
+ $limit = '';
+
+ if ($row['size'] == 2) {
+ if ($row['num_useMin2'] == 1 && $row['num_useMax2'] == 1 && $row['num_min2'] == $row['num_max2'])
+ $limit2 = '(' . $row['num_min2'] . ')';
+ elseif ($row['num_useMin2'] == 1 && $row['num_useMax2'] == 1)
+ $limit2 = '(min ' . $row['num_min2'] . ', max ' . $row['num_max2'] . ')';
+ elseif ($row['num_useMin2'] == 1)
+ $limit2 = '(min ' . $row['num_min2'] . ')';
+ elseif ($row['num_useMax2'] == 1)
+ $limit2 = '(max ' . $row['num_max2'] . ')';
+ else
+ $limit2 = '';
+ }
+
+ # preverimo ali je vrednost v bazi missing
+ $missing = Check::getInstance()->checkMissingForSpremenljivka($spremenljivka, $loop_id);
+
+ if ((int)$missing > 0) {
+ $srv_data_vrednost[$missing] = true;
+ }
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+ $sql1 = sisplet_query("SELECT text, text2 FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ //default sirina
+ if ($taWidth == -1)
+ $taWidth = 10;
+
+ //preverjanje praznega vnosa (-1)
+ $row1['text'] != -1 ? $text = $row1['text'] : $text = '';
+ $row1['text2'] != -1 ? $text2 = $row1['text2'] : $text2 = '';
+
+ $row1['text'] != -1 ? $value[1] = $row1['text'] : $value[1] = '';
+ $row1['text2'] != -1 ? $value[2] = $row1['text2'] : $value[2] = '';
+
+ $sql2 = sisplet_query("SELECT id, naslov, vrstni_red, other FROM srv_vrednost WHERE spr_id='$spremenljivka' order BY vrstni_red");
+ $array_others = array();
+
+ # zloopamo skozi vrednosti in ločeno pohandlamo veljavne in neveljavnej
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row2['id']);
+ if ($naslov == null || $naslov == '') {
+ $naslov = $row2['naslov'];
+ }
+
+ // Datapiping
+ $naslov = Helper::dataPiping($naslov);
+
+ if ((int)$row2['other'] == 0) {
+ # normalna vrednost
+
+ # po potrebi dodamo prelom
+ if ($taWidth > 40 && $row2['vrstni_red'] > 1) {
+ echo '<br>';
+ }
+
+ echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $row2['vrstni_red'] . '" ' . ($row['ranking_k'] == '1' && get('mobile') == 0 ? ' style="display:none;"' : '') . '>';
+
+ # če imamo enoto na levi jo izpišemo
+ if ($row['enota'] == 1) {
+ echo $naslov;
+ }
+
+ echo ' <input type="text" class="width_' . $taWidth . '" name="vrednost_' . $spremenljivka . '[]"'
+ #. ' id="vrednost_'.$spremenljivka.'_'.$row2['vrstni_red'].'" value="'.$value[$row2['vrstni_red']].'"'
+ . ' id="spremenljivka_' . $spremenljivka . '_vrednost_' . $row2['vrstni_red'] . '" value="' . (!$missing ? $value[$row2['vrstni_red']] : '') . '"'
+ . ' onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');"'
+ . ' onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); checkBranching();"'
+ . (!$missing ? '' : ' disabled') . '> ' . "\n";
+ # če imamo enoto na desni jo izpišemo
+ if ($row['enota'] == 2) {
+ echo $naslov;
+ }
+
+ echo '</label>';
+
+ } else {
+ # imamo polje drugo - ne vem, zavrnil...
+ $array_others[$row2['id']] = array(
+ 'naslov' => $naslov,
+ 'vrstni_red' => $row2['vrstni_red'],
+ 'value' => $text[$row2['vrstni_red']],
+ );
+
+ }
+
+ //omejitev vnosa
+ if ($row['vsota_show'] == 1 && ($row['ranking_k'] != '1' /*|| get('mobile') != 0*/)) {
+ if ($row2['vrstni_red'] > 1)
+ echo ' <label class="limit">' . $limit2 . '</label>';
+ else
+ echo ' <label class="limit">' . $limit . '</label>';
+ }
+ }
+
+ // slider na PC, no mobile
+ if ($row['ranking_k'] == '1') { //slider na PC, tablici in mobilniku
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0);
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0);
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0);
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0);
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0);
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0);
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1);
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+
+
+
+ if(get('lang_id') != null){
+ $lang_id = get('lang_id');
+ $ank_id = get('anketa');
+
+ $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$ank_id' AND spr_id='$spremenljivka' AND lang_id='$lang_id' ORDER BY label_id";
+ $sqlSlider = sisplet_query($sqlString);
+
+ while ($row = mysqli_fetch_array($sqlSlider)) {
+ if($row['label_id'] == 1){
+ $MinLabel = $row['label'];
+ }
+ elseif($row['label_id'] == 2){
+ $MaxLabel = $row['label'];
+ }elseif($row['label_id'] == 0){
+ $custom = $row['label'];
+ }
+ }
+
+ if($custom!=''){
+ $custom_ar = explode('; ', $custom); //polje za prevedene opisne labele drsnika
+ }
+
+ // Ce slucajno nimamo prevedeno uporabimo original
+ $MinLabel = ($MinLabel == '') ? ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']) : $MinLabel;
+ $MaxLabel = ($MaxLabel == '') ? ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']) : $MaxLabel;
+ }
+ else{
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']);
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']);
+ }
+
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5);
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0);
+ $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : '';
+
+ //za custom opisne labele
+ //moznosti urejanja opisnih label drsnika
+ if($slider_VmesneDescrLabel){
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ if($custom == ''){ //ce nimamo prevoda opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ }else{ //ce mamo prevod opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1];
+ }
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ }
+ //za custom opisne labele - konec
+
+
+ //spremenljivke za labele podrocij
+ $slider_labele_podrocij = ($spremenljivkaParams->get('slider_labele_podrocij') ? $spremenljivkaParams->get('slider_labele_podrocij') : 0); //za checkbox
+ $display_labele_podrocij = ($slider_labele_podrocij == 0) ? ' style="display:none;"' : '';
+ $slider_StevLabelPodrocij = ($spremenljivkaParams->get('slider_StevLabelPodrocij') ? $spremenljivkaParams->get('slider_StevLabelPodrocij') : 3);
+ $slider_table_td_width = 100 / $slider_StevLabelPodrocij; //spremenljivka za razporeditev sirine sliderja po podrocjih
+
+ for ($i = 1; $i <= $slider_StevLabelPodrocij; $i++) {
+ $slider_Labela_podrocja[$i] = ($spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') ? $spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') : self::$lang['srv_new_text']);
+ }
+
+
+ echo '<div style="width:95%">';
+
+
+ $default_value = round(($slider_MaxNumLabel - $slider_MinNumLabel) / 2) + $slider_MinNumLabel;
+ $vrednost = ($value[1] == '') ? $default_value : $value[1];
+
+
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_minmaxlabel">';
+ }
+ else if (get('mobile') == 1) { //ce mobilnik
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_minmaxlabel_mobile">';
+ }
+ echo '<tr>';
+ echo '<td align="left">' . $MinLabel . '</td>';
+ echo '<td align="right">' . $MaxLabel . '</td>';
+ echo '</tr>';
+ echo '</table>';
+
+
+ echo '<div class="sliderText" id="sliderText_' . $spremenljivka . '">' . $vrednost . '</div>';
+
+ // ce PC ali tablica
+ if (get('mobile') == 0 || get('mobile') == 2) {
+ echo '<div id="slider_' . $spremenljivka . '" class="slider"></div>';
+ $slider_podrocja_table_width = 85;
+ }
+ // ce mobilnik
+ else if (get('mobile') == 1) {
+ echo '<div id="slider_' . $spremenljivka . '" class="slider_mobile"></div>';
+ $slider_podrocja_table_width = 100;
+ }
+
+
+ echo '</div>';
+
+ ?>
+ <script>
+ $(function () {
+ slider_init(<?=get('mobile')?>, <?=$spremenljivka?>, <?=$slider_MinNumLabel?>, <?=$slider_MaxNumLabel?>, <?=$vrednost?>, <?=$slider_handle?>, <?=$slider_handle_step?>, <?=$slider_VmesneNumLabel?>, <?=$slider_VmesneCrtice?>, <?=$slider_MinMaxNumLabelNew?>, <?=$slider_window_number?>, '<?=$slider_DescriptiveLabel_defaults_naslov1?>', <?=$slider_DescriptiveLabel_defaults?>, <?=$default_value?>, <?=$slider_nakazi_odgovore?>, <?=$slider_VmesneDescrLabel?>, '<?=$slider_CustomDescriptiveLabels?>', '<?=$custom?>');
+ });
+ </script>
+ <?
+
+ echo '<br /><br />';
+
+ //tabela za labele podrocij in podrocja
+ echo '<table ' . $display_labele_podrocij . ' style="width:' . $slider_podrocja_table_width . '%; left: 5px;">';
+
+ //vrstica z graficnim prikazom podrocja
+ echo '<tr>';
+ for ($i = 1; $i <= $slider_StevLabelPodrocij; $i++) {
+ echo '<td width="' . $slider_table_td_width . '%" class="label_podrocje_prikaz"><div ></div></td>';
+ }
+ echo '</tr>';
+
+ //vrstica z labelami podrocji
+ echo '<tr>';
+ for ($j = 1; $j <= $slider_StevLabelPodrocij; $j++) {
+ echo '<td class="inline_labele_podrocij"><div id="slider_Labela_podrocja_' . $j . '_' . $spremenljivka . '" name="slider_Labela_podrocja_' . $j . '" class="inline_labele_podrocij" style="float:none; display:inline" ' . (strpos($slider_Labela_podrocja[$j], self::$lang['srv_new_text']) !== false || get('lang_id') != null ? ' default="1"' : '') . '>' . $slider_Labela_podrocja[$j] . '</div></td>';
+ }
+ echo '</tr>';
+ echo '</table>';
+ }
+
+ echo '</div>';
+ if (count($array_others) > 0) {
+ $missing = 1;
+ foreach ($array_others AS $oKey => $other) {
+ # missing vrednost
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $oKey;
+
+ if ($srv_data_vrednost[$oKey]) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu
+ $_checked = ($sel ? ' checked' : '');
+ // Tole ni definirano in ne more delat?? zakaj bi sploh kadarkoli bil missing disabled??
+ //$_disabled = ($is_missing && ($row1['other'] == 0 || $row1['other'] == 1) ? true : false);
+ $_disabled = false;
+
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+
+ $already_set_mv = array();
+ $sql_grid_mv = sisplet_query("SELECT naslov, other FROM srv_vrednost WHERE spr_id='" . $spremenljivka . "' AND other != 0");
+ while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) {
+ $already_set_mv[$row_grid_mv['other']] = $row_grid_mv['naslov'];
+ }
+
+ if ((($row['alert_show_99'] > 0 && isset($already_set_mv['-99']) && $already_set_mv['-99'] == $other['naslov'])
+ || ($row['alert_show_98'] > 0 && isset($already_set_mv['-98']) && $already_set_mv['-98'] == $other['naslov'])
+ || ($row['alert_show_97'] > 0 && isset($already_set_mv['-97']) && $already_set_mv['-97'] == $other['naslov']))
+ && $_checked == ''
+ )
+
+ $hide_missing = true;
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' missing" id="vrednost_if_' . $oKey . '"' . ' ' . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '">';
+ echo '<input type="checkbox" name="vrednost_mv_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $oKey . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="0" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $oKey . '\', \'' . $checkbox_limit . '\');' : '') . ' checkMissing(this);"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $other['naslov'] . '</label>';
+ echo '</div>';
+ }
+ }
+
+ SystemVariable::display($spremenljivka, $oblika);
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php b/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php
new file mode 100644
index 0000000..de5581d
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php
@@ -0,0 +1,291 @@
+<?php
+/***************************************
+ * Description: One against another
+ *
+ * Vprašanje je prisotno:
+ * tip 6
+ * tip 4
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+class OneAgainstAnotherController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new OneAgainstAnotherController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za one against another
+ */
+ function display($spremenljivka)
+ {
+
+ //echo "One against another!";
+
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ //$gridAlign = 1;
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ // diferencial
+ //if ($row['enota'] == 1) {
+ $size += 2;
+ //}
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table multigrid" >' . "\n";
+
+
+ // echo '<colgroup class="question">';
+ // //echo '<col class="width_'.$gridWidth.'">';
+ // echo '<col class="width_15">';
+ // echo '</colgroup>';
+ // echo '<colgroup>';
+ // //echo '<col class="space">';
+ // echo '<col class="width_20">';
+ // echo '</colgroup>';
+ // echo '<colgroup class="category">';
+ // for ($i=1; $i<=$row['grids']; $i++)
+ // echo '<col>';
+ // echo '</colgroup>';
+ // if ($mv_count > 0) {
+ // echo '<colgroup>';
+ // echo '<col class="space">';
+ // echo '</colgroup>';
+ // echo '<colgroup class="missing">';
+ // for ($i=1; $i<=$mv_count; $i++)
+ // echo '<col>';
+ // echo '</colgroup>';
+ // }
+ // if ($row['enota'] > 0) {
+ // echo '<colgroup>';
+ // //echo '<col class="space">';
+ // echo '<col class="width_20">';
+ // echo '</colgroup>';
+ // //echo '<colgroup class="differential">';
+ // //echo '<col class="width_'.$gridWidth.'">';
+
+ // //echo '</colgroup>';
+ // }
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ echo $srv_grids[5]['id'];
+
+ //levi stolpec naslovov
+ echo ' <td class="question" style="text-align: right;">';
+ echo $row1['naslov'];
+ echo '</td>';
+
+
+ //radio buttoni
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+/* if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ } */
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+/* echo '<td class="missing' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' ' . $cssAlign . '">';
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+ echo '<span ' . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '></span>';
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ if ($i == 1) { //ce je to prvi radio button, dodaj ali
+ //echo '<td style="text-align: center;"> ali </td>';
+ echo '<td style="text-align: center;"> ' . self::$lang['srv_tip_sample_t6_4_vmes'] . ' </td>';
+ }
+
+ */
+ }else {
+ //echo '<td class="category ' . $cssAlign . '">';
+ echo '<td class="category style="text-align: center;">';
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ if ($i == 1) { //ce je to prvi radio button, dodaj "ali"
+ echo '<td style="text-align: center;"> ' . self::$lang['srv_tip_sample_t6_4_vmes'] . ' </td>';
+ }
+ }
+
+ }
+ }
+
+ //desni stolpec naslovov
+ echo ' <td class="differential" style="text-align: left;">' . $row1['naslov2'] . '</td>' . "\n";
+
+ //missingi po desnem stolpcu
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ //echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' ' . $cssAlign . '">';
+ //echo '<td class="missing' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' style="text-align: center;">';
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo $srv_grid['naslov'];
+ echo '</label>';
+
+ echo '</td>' . "\n";
+ }
+ }
+ }
+
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/QuotaController.php b/main/survey/app/Controllers/Vprasanja/QuotaController.php
new file mode 100644
index 0000000..777a333
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/QuotaController.php
@@ -0,0 +1,57 @@
+<?php
+/***************************************
+ * Description: Quota
+ *
+ * Vprašanje je prisotno:
+ * tip 25
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use App\Models\Model;
+
+
+class QuotaController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new QuotaController();
+ }
+
+ public function display($spremenljivka)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Izračunamo kvoto
+ $quota = Check::getInstance()->checkQuota(-$spremenljivka);
+
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (mysqli_num_rows($sql1) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+ $quota = $row1['text'];
+ }
+
+ echo ' <input type="text" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" value="' . $quota . '">';
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php b/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php
new file mode 100644
index 0000000..9de8d5f
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php
@@ -0,0 +1,521 @@
+<?php
+/***************************************
+ * Description: Izpis sledečih tipov vprašanj: radio, checkbox in select
+ *
+ * Vprašanje je prisotno:
+ * tip 1
+ * tip 2
+ * tip 3
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+
+class RadioCheckboxSelectController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new RadioCheckboxSelectController();
+ }
+
+
+ public function display($spremenljivka, $oblika = null)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $stolpci = ($spremenljivkaParams->get('stolpci') ? $spremenljivkaParams->get('stolpci') : 1);
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ // Ce imamo slucajno vklopljeno nastavitev da so odgovori disabled
+ $disabled_vprasanje = ($spremenljivkaParams->get('disabled_vprasanje') == '1') ? true : false;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_dropdown_select = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_dropdown_select' . $_lang);
+ if ($srv_dropdown_select == '') $srv_dropdown_select = self::$lang['srv_dropdown_select'];
+
+ // DROPDOWN
+ if ($row['tip'] == 3) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $prvaVrstica_roleta = ($spremenljivkaParams->get('prvaVrstica_roleta') ? $spremenljivkaParams->get('prvaVrstica_roleta') : 1);
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+
+ if (!$row['info']) {
+ echo ' <select name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' size="' . ($row['orientation'] == '6' ? (mysqli_num_rows($sql1) + 1) . '" multiple' : '1"') . ' onchange="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.'); omejiSelectBox(' . $spremenljivka . ');">' . "\n";
+ }
+ elseif ($row['info']) {
+ echo ' <select name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' size="' . ($row['orientation'] == '6' ? (mysqli_num_rows($sql1) + 1) . '" multiple' : '1"') . ' onchange="drugo_' . $spremenljivka . '(); checkBranching(); ">' . "\n";
+ }
+
+ switch ($prvaVrstica_roleta) {
+
+ case "1":
+ echo ' <option value=""></option>' . "\n";
+ break;
+
+ case "2":
+ break;
+
+ case "3":
+ echo ' <option value="">' . $srv_dropdown_select . '...</option>' . "\n";
+ break;
+ }
+ }
+
+ // CHECKBOX
+ if ($row['tip'] == 2) {
+
+ if ($row['orientation'] != 6) {
+ $selected = Model::getOtherValue($spremenljivka);
+ echo '<input name="other_selected_vrednost_' . $spremenljivka . '" id="other_selected_vrednost_' . $spremenljivka . '" value="' . $selected . '" type="hidden">';
+ }
+ // Izberite s seznama
+ elseif ($row['orientation'] == 6) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+
+ if ($sbSize == 2) { //potrebno dodati predefinirano visino min 36px, ce sta samo dve moznosti v selectu, ker v FF, ni videti scrollbar-a
+ echo ' <select multiple style="height: 36px;" name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.'); ">' . "\n";
+ }
+ else {
+ echo ' <select multiple name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.'); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . '">' . "\n";
+ }
+
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo ' <option value=""></option>' . "\n";
+ break;
+ case "3":
+ echo ' <option value="">' . $srv_dropdown_select . '...</option>' . "\n";
+ break;
+ }
+ }
+ }
+
+ // RADIO
+ if ($row['tip'] == 1) {
+
+ if ($row['orientation'] == 6) {
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+
+ if ($sbSize == 2) { //potrebno dodati predefinirano visino min 36px, ce sta samo dve moznosti v selectu, ker v FF, ni videti scrollbar-a
+ echo ' <select style="height: 36px;" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.');">' . "\n";
+ }
+ else {
+ echo ' <select name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ','.$checkbox_limit.');">' . "\n";
+ }
+
+ switch ($prvaVrstica) {
+ case "1":
+ break;
+ case "2":
+ echo ' <option value=""></option>' . "\n";
+ break;
+ case "3":
+ echo ' <option value="">' . $srv_dropdown_select . '...</option>' . "\n";
+ break;
+ }
+ }
+ }
+
+ // cache, da vse preberemo naenkrat
+ $srv_data_vrednost = array();
+ $sql2_c = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row2_c = mysqli_fetch_array($sql2_c)) {
+ $srv_data_vrednost[$row2_c['vre_id']] = true;
+ }
+ # preverimo ali imamo izbran kak missing
+ $is_missing = false;
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ if ($row1['other'] == 0 || $row1['other'] == 1) {
+ } else {
+ if ($srv_data_vrednost[$row1['id']]) {
+ $is_missing = true;
+ }
+ }
+ }
+ if (mysqli_num_rows($sql1))
+ mysqli_data_seek($sql1, 0);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $stolpci = ($spremenljivkaParams->get('stolpci') ? $spremenljivkaParams->get('stolpci') : 1);
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+ $checkbox_min_limit = ($spremenljivkaParams->get('checkbox_min_limit') ? $spremenljivkaParams->get('checkbox_min_limit') : 0);
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $hideRadio = ($spremenljivkaParams->get('hideRadio') == 1) ? ' hideRadio' : '';
+
+ // Ali imamo prednastavljen radio ali checkbox (ce se nimamo odgovora)
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_vrednost)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ if ($stolpci > 1 && $row['orientation'] == 1 && get('mobile') != 1) {
+ echo '<div class="floatLeft width_' . round(100 / $stolpci, 0) . '">';
+ $kategorij = mysqli_num_rows($sql1);
+ $v_stolpcu = ceil($kategorij / $stolpci);
+ }
+
+ $i = 0;
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ if ($row1['other'] == 0 || $row1['other'] == 1) {
+ # normalna vrednost
+ $_id = 'spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'];
+ $missing = 0;
+ } else {
+ # missing vrednost
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'];
+ $missing = 1;
+ }
+
+ if (isset($srv_data_vrednost[$row1['id']])) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu (pri radio buttonih ne rabimo disablat polj)
+ $_checked = (($sel && !$is_missing) || ($sel && ($row1['other'] !== 0 && $row1['other'] != 1)) ? ' checked' : '');
+ $_disabled = ($is_missing && ($row1['other'] == 0 || $row1['other'] == 1) && $row['tip'] != 1 ? true : false);
+
+ // posebej za radio button opcijo da ne prikaže vprašanja in izpolni prvi odgovor
+ if ($row['tip'] == 1 && $row['hidden_default'] == 1 && $i == 0)
+ $_checked = ' checked';
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+ if ((($row['alert_show_99'] > 0 && $row1['variable'] == '-99')
+ || ($row['alert_show_98'] > 0 && $row1['variable'] == '-98')
+ || ($row['alert_show_97'] > 0 && $row1['variable'] == '-97'))
+ && $missing == 1 && $_checked == ''
+ )
+ $hide_missing = true;
+
+ //v kolikor je bil odgovor skrit, ga uporabniku ne prikažemo
+ if ($row1['hidden'] == 1)
+ $hide_missing = true;
+
+ // Ce imamo slucajno prednastavljeno vrednost
+ if ($presetValue > 0 && $presetValue == $row1['id'])
+ $_checked = ' checked';
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ // RADIO
+ if ($row['tip'] == 1) {
+
+ // Radio - izberite s seznama
+ if ($row['orientation'] == 6) {
+ echo '<option value="' . $row1['id'] . '"' . ($sel ? ' selected' : '') . ' id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" ' . (($row1['hidden'] == 1) ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>' . $row1['naslov'] . '</option>' . "\n";
+
+ }
+ // Radio - navpicno - text levo
+ elseif ($row['orientation'] == 7) {
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<table class="width_30">';
+
+ echo '<tr>';
+ echo '<td><label for="' . $_id . '">' . $row1['naslov'] . ' </label>';
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" id="spremenljivka_'.$spremenljivka.'_textfield_'.$row1['id'].'" value="'.$row3['text'].'" '.($_disabled ? ' disabled' : '').' onclick="$(\'#spremenljivka_'.$spremenljivka.'_vrednost_'.$row1['id'].'\').attr(\'checked\',true); checkBranching();">';
+ }
+ echo '</td>';
+
+ echo '<td align="right">';
+ echo '<label>';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\', \'' . $_id . '\');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '') .
+ '></span>';
+
+ echo '</label></td>';
+ echo '</tr>';
+ echo '</table>';
+ }
+ // Radio - custom checkobox??
+ elseif ($row['orientation'] == 9) {
+ echo '<div class="variabla custom_radio_picture ' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '"><input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\'); customRadioSelect(' . $row1['id'] . ', ' . $row1['variable'] . ');"> ';
+
+ echo '<span class="enka-custom-radio ' .
+ ($spremenljivkaParams->get('customRadio') ? $spremenljivkaParams->get('customRadio') : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"': '').
+ '></span>';
+
+ echo '<div class="custom_radio_answer">(' . $row1['naslov'] . ')</div>';
+ echo '</label>';
+
+ //Pri smeških moramo pognati JS, da doda ustrezen razred 'obarvan'
+ if($_checked == ' checked'){
+ echo '<script>
+ $(document).ready( function(){ customRadioSelect(\'' . $row1['id'] . '\', \'' . $row1['variable'] . '\'); } );
+ </script>';
+ }
+ }
+ // Vizualna analogna skala
+ elseif ($row['orientation'] == 11) {
+ $stOdgovorov = mysqli_num_rows($sql1);
+
+ echo '<div class="variabla custom_radio visual-radio-scale ' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '"><input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\');"> ';
+ echo '<span class="enka-vizualna-skala siv-'.$stOdgovorov.$row1['naslov'].' '.((Helper::getCustomCheckbox() != 0) ? 'size-' . Helper::getCustomCheckbox(): '').'"></span>';
+ echo '<div class="custom_radio_answer '.((Helper::getCustomCheckbox() != 0) ? 'size-' . Helper::getCustomCheckbox(): '').'">(' . $row1['naslov'] . ')</div>';
+ echo '</label>';
+ }
+ // Radio - standard
+ else {
+ echo '<div class="variabla' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '"><input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled || $disabled_vprasanje ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\');"> ';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '') .
+ '></span>';
+ echo '' . $row1['naslov'] . '</label>';
+
+ // Ce je vprasanje disabled moramo vseeno postati vrednost
+ if($disabled_vprasanje){
+ echo '<input type="hidden" name="vrednost_'. $spremenljivka.'" value="'.key($srv_data_vrednost).'">';
+ }
+ }
+ }
+ // CHECKBOX
+ elseif ($row['tip'] == 2 || $row['tip'] == 27) {
+
+ // Checkbox - standard
+ if ($row['orientation'] != 6 && $row['orientation'] != 7) {
+ echo '<div class="variabla' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+
+ if($row['tip'] == 2){
+ echo '<label for="' . $_id . '"><input type="checkbox" name="vrednost_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : '1') . '" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . ' ' . ($missing == 1 ? ' checkMissing(this);' : '') . ' setCheckedClass(this, \'2\');"> ';
+ }
+ elseif($row['tip'] == 27){ //ce je heatmap, kjer je v uporabi checkbox za belezenje klikov na obmocja, je potrebno spremeniti "name"
+ echo '<label for="' . $_id . '"><input type="checkbox" name="vrednostHeatmap_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : '1') . '" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . ' ' . ($missing == 1 ? ' checkMissing(this);' : '') . ' setCheckedClass(this, \'2\');"> ';
+ }
+
+
+ // Font awesom checkbox custom
+ echo '<span class="enka-checkbox-radio' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '" ' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '' . $row1['naslov'] . '</label>';
+ //v kolikor je odgovor skrit(1) ali disable(2), mu damo vrednost -2
+ if ($row1['hidden'] == 1 || $row1['hidden'] == 2)
+ echo '<input id="branch_' . $_id . '" name="cond_vrednost_' . $spremenljivka . '[]" value="' . $row1['id'] . '" type="hidden">';
+
+ }
+ // Checkbox - izberite s seznama
+ elseif ($row['orientation'] == 6) {
+ echo '<option value="' . $row1['id'] . '"' . ($sel ? ' selected' : '') . ' id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" ' . ($hide_missing ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>' . $row1['naslov'] . '</option>' . "\n";
+ }
+ // Checkbox - navpicno - text levo
+ elseif ($row['orientation'] == 7) {
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>';
+ echo '<table class="width_30">';
+ //echo '<table style="width:30%">';
+ echo '<tr>';
+ //echo '<td><label for="'.$_id.'">'.$row1['naslov'].' </label></td>';
+ echo '<td><label for="' . $_id . '">' . $row1['naslov'] . ' </label>';
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" id="spremenljivka_'.$spremenljivka.'_textfield_'.$row1['id'].'" value="'.$row3['text'].'" '.($_disabled ? ' disabled' : '').' onclick="$(\'#spremenljivka_'.$spremenljivka.'_vrednost_'.$row1['id'].'\').attr(\'checked\',true); checkBranching();">';
+ }
+ echo '</td>';
+ echo '<td align="right">';
+ echo '<label>';
+ echo '<input type="checkbox" name="vrednost_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : '1') . '" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . ' ' . ($missing == 1 ? ' checkMissing(this);' : '') . ' setCheckedClass(this, \'2\',' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>';
+ echo '</tr>';
+ echo '</table>';
+ }
+
+ }
+ // DROPDOWN
+ elseif ($row['tip'] == 3) {
+ # imamo dropdown
+ echo '<option value="' . $row1['id'] . '"' . ($sel ? ' selected' : '') . ' id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" ' . ($hide_missing ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>' . $row1['naslov'] . '</option>' . "\n";
+ }
+
+
+ if ($row['tip'] != 3 && $row['orientation'] != 6) {//ce ni vprasanje tipa 3 (roleta) in ni orientacija 6 (select box)
+ //if ($row['tip'] != 3 && $row['orientation']!=6) {
+ if ($row['orientation'] != 7) { //ce ni orientacija 7 (postavitev: navpicno - tekst levo)
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching(); '.($checkbox_limit > 0 ? 'checkboxLimitTextbox(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '').'" >' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching(); '.($checkbox_limit > 0 ? 'checkboxLimitTextbox(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '').'" />';
+ }
+ }
+ echo '</div>' . "\n";
+ }
+
+ $i++;
+ if ($stolpci > 1 && $row['orientation'] == 1 && get('mobile') != 1) {
+ if ($i >= $v_stolpcu) {
+ echo '</div><div class="floatLeft width_' . round(100 / $stolpci, 0) . '">';
+ $i = 0;
+ }
+ }
+ }
+
+ if ($stolpci > 1 && $row['orientation'] == 1 && get('mobile') != 1)
+ echo '</div>';
+
+ // koncamo select
+ if ($row['tip'] == 3 || $row['orientation'] == 6) {
+ echo ' </select>' . "\n";
+
+ if ($row['tip'] == 2 && $row['orientation'] == 6) {
+ if (mysqli_num_rows($sql1) > 0) mysqli_data_seek($sql1, 0);
+ while ($row1 = mysqli_fetch_assoc($sql1)) {
+ if ($row1['hidden'] == 1 || $row1['hidden'] == 2)
+ echo '<input id="branch_' . $_id . '" name="cond_vrednost_' . $spremenljivka . '[]" value="' . $row1['id'] . '" type="hidden">';
+ }
+ }
+ // Ce je vprasanje disabled moramo vseeno postati vrednost
+ elseif($disabled_vprasanje){
+ echo '<input type="hidden" name="vrednost_'. $spremenljivka.'" value="'.key($srv_data_vrednost).'">';
+ }
+
+ if (mysqli_num_rows($sql1) > 0) mysqli_data_seek($sql1, 0);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo '<br /><textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" class="drugo_' . $spremenljivka . '" rows="' . $otherHeight . '" style="display:none; ' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="checkBranching();">' . $row3['text'] . '</textarea>';
+ else
+ echo '<br /><input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" class="drugo_' . $spremenljivka . '" value="' . $row3['text'] . '" style="display:none; ' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="checkBranching();" />';
+ }
+ }
+
+ ?>
+ <script>
+ function drugo_<?=$spremenljivka?> () {
+ $('.drugo_<?=$spremenljivka?>').hide();
+ $('#spremenljivka_<?=$spremenljivka?>_textfield_' + $('#vrednost_<?=$spremenljivka?>').val()).show();
+ }
+
+ </script><?
+
+ echo '</div>';
+
+ // vedno prikazujemo novo roleto
+ // text rolete ni pri multiple selectu in pri mobilni (pri tablici jo pustimo)
+ if (
+ $row['orientation'] != 6 && get('mobile') != 1 && get('forceShowSpremenljivka') !== true
+ ) {
+ ?>
+ <script>
+ $('select#vrednost_<?=$spremenljivka?>').chosen({search_contains: true});
+ </script>
+ <?
+ }
+ }
+
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/RankingController.php b/main/survey/app/Controllers/Vprasanja/RankingController.php
new file mode 100644
index 0000000..014bb37
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/RankingController.php
@@ -0,0 +1,1021 @@
+<?php
+/***************************************
+ * Description: Ranking
+ *
+ * Vprašanje je prisotno:
+ * tip 17
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+
+// Iz admin/survey
+use enkaParameters;
+use SurveySetting;
+use Common;
+use SurveyInfo;
+
+class RankingController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new RankingController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ // Pri WebSM anketi nimamo userja, zato ne izvajamo ajaxa
+ $ajax = 'true';
+ $usr_id = get('usr_id');
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+ $ajax = 'false';
+ $usr_id = 0;
+ }
+
+ //********* potrebno za pravilno prikazovanje predogleda in vpogled v posamezen podatek
+ $quick_view = json_encode(get('quick_view'));
+
+ if(isset($_GET['a'])){
+ if($_GET['a'] == 'preview_spremenljivka'){
+ $preview_spremenljivka = 1;
+ echo '
+ <script>
+ var usr_id = 0;
+ </script>
+ ';
+ }
+ else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ }
+ else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ //********* potrebno za pravilno prikazovanje predogleda in vpogled v posamezen podatek - konec
+
+
+ // premikanje - n==k
+ if ($row['design'] == 2 && get('mobile') == 0)
+ $this->displayPremikanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax);
+
+ // prestavljanje za SAZU - n>k
+ else if ($row['design'] == 0 && get('mobile') == 0
+ && SurveyInfo::getInstance()->checkSurveyModule('sazu')
+ && in_array($spremenljivka, array('11092569','11092563'))
+ )
+ $this->displayPrestavljanjeSAZU($spremenljivka, $preview_spremenljivka, $quick_view, $ajax);
+
+ // prestavljanje - n>k
+ else if ($row['design'] == 0 && get('mobile') == 0)
+ $this->displayPrestavljanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax);
+
+ // ostevilcevanje - mobile
+ else if ($row['design'] == 1 || $row['design'] == 3 || get('mobile') > 0)
+ $this->displayOstevilcevanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax, $oblika);
+ }
+
+
+ // Izrisemo podtip premikanje (n == k)
+ private function displayPremikanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ # če smo v quick_view mode ne omogočamo
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ //javascript za sortable (drag in drop)
+ echo "<script>
+ $(document).ready(
+ function(){
+ $('#sortzone_$spremenljivka').sortable({
+
+ items: '.handle, .handle_long',
+
+ opacity: '0.7',
+ //stop: function () {
+ stop: function (event, ui) {
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ frame_height_ranking_premikanje_dyn (ui, $spremenljivka);
+ if(" . $ajax . "){
+
+ var sortable_filtered_items = $('#sortzone_$spremenljivka').sortable({
+ items: 'div:visible'
+ });
+
+ $.post('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {
+ /*order: $('#sortzone_$spremenljivka:visible').sortable('serialize'), */
+ order: sortable_filtered_items.sortable('serialize'),
+ spremenljivka: $spremenljivka,
+ usr_id: usr_id,
+ anketa: srv_meta_anketa_id
+ });
+ }
+ },
+ over: function( event, ui ) {
+ //frame_height_ranking_premikanje_dyn (ui, $spremenljivka);
+ }
+ });
+ //checkBranching(); // dokler ne premakne elementa je -1, zato naj bo tudi v JS tako
+ // checkBranching() sprozimo samo, ce je spremenljivka skrita, ker je vkljucena v enem od pogojev na prejsnji strani
+ if ( $('div#spremenljivke_hidden div#spremenljivka_{$spremenljivka}').length > 0){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ }
+ );
+ </script>";
+ }
+
+
+ //ce je bil vrstni red popravljen ze prej (so ze vnosi v bazi)
+ $sql1 = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red");
+
+ $vre_idCache1 = array();
+ $otherCache1 = array();
+ $vre_idCache2 = array();
+ $otherCache2 = array();
+ $vre_idCacheN = array();
+ $vrstni_redCacheN = array();
+
+ if (($num = mysqli_num_rows($sql1)) != 0) {
+ //izracun visine
+ $size = $num * 50;
+
+ echo '<div class="sortholder">';
+
+ echo '<div id="sortzone_' . $spremenljivka . '" class="sortzone">';
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $sql2 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE id='$row1[vre_id]' ");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row2['id']);
+ if ($naslov != '') $row2['naslov'] = $naslov;
+
+ // Datapiping
+ $row2['naslov'] = Helper::dataPiping($row2['naslov']);
+
+ $value = $row2['naslov'];
+ $vre_id = $row2['id'];
+ array_push($vre_idCache1, $vre_id);
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'handle moving';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row2['other']; //drugo, po navadi missing
+ array_push($otherCache1, $other);
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+
+ }
+ echo '</div>';
+
+ //$sqlN = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0");
+ $sqlN = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red");
+ //izris stevilk pred vrednostmi
+ echo '<ul class="sorting">';
+ $stevec = 0;
+ //for ($i = 0; $i < mysqli_num_rows($sqlN); $i++) {
+ while ($rowN = mysqli_fetch_array($sqlN)) {
+ $spr_id = $rowN["spr_id"];
+ $vre_id = $rowN["vre_id"];
+ array_push($vre_idCacheN, $vre_id);
+ $vrstni_red = $rowN["vrstni_red"];
+ array_push($vrstni_redCacheN, $vrstni_red);
+ //$stevec = $i + 1;
+ //$stevec = $stevec + 1;
+ echo '<li id="frame_spremenljivka_'.$spremenljivka.'_vrednost_'.$vre_id.'" class="frame_spremenljivka_'.$spremenljivka.'">
+ <div class="frame_moving" data="'.$vrstni_red.'">' . $vrstni_red . '.</div>
+ </li>' . "\n";
+ }
+ echo '</ul>';
+
+ echo '</div>';
+
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCache1 = 0;
+ foreach($vre_idCache1 as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCache1[$indeksVre_idCache1]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCache1++;
+ }
+ $indeksvre_idCacheN = 0;
+ foreach($vre_idCacheN as $vre_id){
+ //**************
+ ?>
+ <script>
+ $(document).ready(function () {
+ frame_height_ranking_premikanje(<?=$spremenljivka?>, <?=$vre_id?>, <?=$vrstni_redCacheN[$indeksvre_idCacheN]?>);
+ });
+ </script>
+ <?
+ //********
+ $indeksvre_idCacheN++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+
+ } //ce gre za prvo popravljanje vrstnega reda (se ni vnosov v srv_data_rating)
+ else {
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql2 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ //izracun visine
+ $num = mysqli_num_rows($sql2);
+ $size = $num * 50;
+
+ echo '<div class="sortholder">';
+
+ echo '<div id="sortzone_' . $spremenljivka . '" class="sortzone">';
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row2['id']);
+ if ($naslov != '') $row2['naslov'] = $naslov;
+
+ // Datapiping
+ $row2['naslov'] = Helper::dataPiping($row2['naslov']);
+
+ $value = $row2['naslov'];
+ $vre_id = $row2['id'];
+ array_push($vre_idCache2, $vre_id);
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'handle moving';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row2['other']; //drugo, po navadi missing
+ array_push($otherCache2, $other);
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+
+ }
+ echo '</div>';
+
+ $sqlN = sisplet_query("SELECT id, spr_id, vrstni_red FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0");
+ //izris stevilk pred vrednostmi
+ $stevec = 0;
+ echo '<ul class="sorting">';
+ //for ($i = 0; $i < mysqli_num_rows($sqlN); $i++) {
+ while ($rowN = mysqli_fetch_array($sqlN)) {
+ $spr_id = $rowN["spr_id"];
+ $vre_id = $rowN["id"];
+ $vrstni_red = $rowN["vrstni_red"];
+ array_push($vre_idCacheN, $vre_id);
+ array_push($vrstni_redCacheN, $vrstni_red);
+ //$stevec = $i + 1;
+ $stevec = $stevec + 1;
+ echo '<li id="frame_spremenljivka_'.$spremenljivka.'_vrednost_'.$vre_id.'" class="frame_spremenljivka_'.$spremenljivka.'">
+ <div class="frame_moving" data="'.$stevec.'">' . $stevec . '.</div>
+ </li>' . "\n";
+ }
+ echo '</ul>';
+
+ echo '</div>';
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCache2 = 0;
+ foreach($vre_idCache2 as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCache2[$indeksVre_idCache2]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCache2++;
+ }
+ $indeksvre_idCacheN = 0;
+ foreach($vre_idCacheN as $vre_id){
+ //**************
+ ?>
+ <script>
+ $(document).ready(function () {
+ frame_height_ranking_premikanje(<?=$spremenljivka?>, <?=$vre_id?>, <?=$vrstni_redCacheN[$indeksvre_idCacheN]?>);
+ });
+ </script>
+ <?
+ //********
+ $indeksvre_idCacheN++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+ }
+ }
+
+ // Izrisemo podtip prestavljanje (n >= k)
+ private function displayPrestavljanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ //izracun visine
+ $num = mysqli_num_rows($sql1);
+ $size = $num * 37;
+
+ //nastavimo $max (maximum prenesenih vrednosti) -> ce lahko nosimo vse vrednosti ($row['ranking_k'] == 0) je $max stevilo vseh vrednotsti
+ if ($row['ranking_k'] == 0)
+ $max = mysqli_num_rows($sql1);
+ else
+ $max = $row['ranking_k'];
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ save('lang_id', (get('lang_id') == null) ? self::$lang['id'] : get('lang_id'));
+
+ //nismo presegli limita ranking_k
+ if ($count < $max) {
+ # če smo v quick_view mode ne omogočamo
+ //if (get('quick_view') == false) {
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ //javascript za drag in drop
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half2_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka, #half2_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ //stop: function (){
+ stop: function (event, ui){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ if(" . $ajax . "){
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ frame_height_ranking (ui, $spremenljivka);
+ },
+ over: function( event, ui ) {
+ frame_height_ranking (ui, $spremenljivka);
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ } //preneseno je bilo max stevilo vrednosti
+ else {
+ # če smo v quick_view mode ne omogočamo
+ //if (get('quick_view') == false) {
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ stop: function (){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ }
+
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ echo '<table class="ranking_table">';
+ echo '<tr>';
+ //zaslon razdelimo na dva dela - izris leve strani
+ echo '<td>';
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_ranking_avaliable_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_avaliable_categories' . $_lang);
+ if ($srv_ranking_avaliable_categories == '') $srv_ranking_avaliable_categories = self::$lang['srv_ranking_avaliable_categories'];
+
+ echo '<b>' . $srv_ranking_avaliable_categories . ':</b>';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone" style="height:' . $size . 'px">';
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ $vre_idCacheL = array();
+ $otherCacheL = array();
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+ array_push($vre_idCacheL, $vre_id);
+ $other = $row1['other']; //drugo, po navadi missing
+ array_push($otherCacheL, $other);
+
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+ $c = '';
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ }
+
+ echo '</div>';
+ echo '</td>';
+
+
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCacheL = 0;
+ foreach($vre_idCacheL as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCacheL[$indeksVre_idCacheL]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCacheL++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+
+ //srednja celica (stevilo prenesenih in spodaj puscica)
+ echo '<td class="middle">';
+ echo '<b>' . $count . '/' . $max . '</b>';
+ echo '<img src="' . self::$site_url . 'main/survey/skins/Modern/arrow.png" alt="arrow">';
+ echo '</td>';
+
+ //izris desne strani
+ echo '<td>';
+
+
+ $srv_ranking_ranked_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_ranked_categories' . $_lang);
+ if ($srv_ranking_ranked_categories == '') $srv_ranking_ranked_categories = self::$lang['srv_ranking_ranked_categories'];
+
+ echo '<b>' . $srv_ranking_ranked_categories . ':</b>';
+
+ echo '<div class="dropholder">'; // ker na td ne primer position relative za nastavit position absolute na dropzone
+
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ $vre_idCacheD = array();
+ $otherCacheD = array();
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+ array_push($vre_idCacheD, $vre_id);
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row1['other']; //drugo, po navadi missing
+ array_push($otherCacheD, $other);
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ }
+ echo '</div>';
+
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCacheD = 0;
+ foreach($vre_idCacheD as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCacheD[$indeksVre_idCacheD]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCacheD++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+
+
+ ?>
+ <script>
+ $(document).ready(function () {
+ question_height_ranking(<?=$spremenljivka?>);
+ });
+ </script>
+ <?
+
+
+ //izris osencenih polj (ranking_k)
+
+ echo '<ul>';
+ for ($i = 0; $i < $max; $i++) {
+ $stevec = $i + 1;
+ echo '<li>
+ <div class="frame_ranking" onHover="">' . $stevec . '.</div>
+ </li>' . "\n";
+ }
+ echo '</ul>';
+
+
+ echo '</div>'; //dropholder
+
+ echo '</td>';
+
+
+ echo '</tr>';
+ echo '</table>';
+ echo '</div>';
+
+ $sql2_Refresh = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' ");
+ while ($row2_Refresh = mysqli_fetch_array($sql2_Refresh)) {
+ $spr_id = $row2_Refresh["spr_id"];
+ $vre_id = $row2_Refresh["vre_id"];
+ $vrstni_red = $row2_Refresh["vrstni_red"];
+ if (!empty($row2_Refresh)) { //ce je ze kaj v bazi
+ ?>
+ <script>
+ $(document).ready(function () {
+ var trenutna_visina_prenesenega = $('#spremenljivka_<?=$spr_id?>_vrednost_<?=$vre_id?>').height()
+ //console.log(trenutna_visina_prenesenega);
+ var i = 0;
+ $('#half2_<?=$spr_id?>').siblings().children('li').children('div').each(function(){ //preleti prazne okvirje
+ i = i + 1;
+ if(<?=$vrstni_red?> == i){
+ $(this).height(trenutna_visina_prenesenega);
+ //console.log(i);
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ });
+ </script>
+ <?
+ }
+ }
+ }
+
+ // Izrisemo podtip prestavljanje za sazu (vodoravno postavljene slike)
+ private function displayPrestavljanjeSAZU($spremenljivka, $preview_spremenljivka, $quick_view, $ajax){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ //izracun visine
+ $size = 3 * 37;
+ $max = 3;
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ save('lang_id', (get('lang_id') == null) ? self::$lang['id'] : get('lang_id'));
+
+ // nismo presegli limita ranking_k
+ if ($count < $max) {
+
+ # če smo v quick_view mode ne omogočamo
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+
+ //javascript za drag in drop
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half2_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka, #half2_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ //stop: function (){
+ stop: function (event, ui){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ if(" . $ajax . "){
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ } //preneseno je bilo max stevilo vrednosti
+ else {
+ # če smo v quick_view mode ne omogočamo
+ //if (get('quick_view') == false) {
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ stop: function (){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ }
+
+
+ // Izris drag in drop slik
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ echo '<div class="ranking_table">';
+
+
+ // izris zgornje vrstice iz kjer jemljemo slike
+ echo '<div class="grab_row">';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone">';
+
+ $sql1 = sisplet_query("SELECT id, naslov, other, if_id FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY RAND()");
+ //$sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ }
+ else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+ $sql1V = sisplet_query("SELECT * FROM srv_data_rating WHERE vre_id = '$row1[id]' AND spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ if(mysqli_num_rows($sql1V) == 0){
+ // '#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . '">' . $value . '</div>' . "\n";
+ //echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . '" '.($row1['if_id'] > 0 ? ' style="display:none"' : '').'>' . $value . '</div>' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+ // End grab_row
+ echo '</div>';
+
+
+ // izris spodnje vrstice kamor spustimo slike
+ echo '<div class="drop_row">';
+
+ // izris osencenih polj (ranking_k)
+ echo '<div class="drop_frames">';
+ for ($i = 1; $i <= 3; $i++) {
+ echo '<div class="frame_ranking">' . $i . '</div>' . "\n";
+ }
+ echo '</div>';
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ }
+ else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+ //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . '">' . $value . '</div>' . "\n";
+ }
+ echo '</div>';
+
+
+ // END drop_row
+ echo '</div>';
+
+
+ // END ranking_table
+ echo '</div>';
+ echo '</div>';
+
+
+ // Large image on hover
+ echo '<script>
+ $(".ranking").hover(
+ function enter(el){
+ var content = $(this).html();
+
+ $(this).append( $("<div class=\"sazu_holder2\">" + content + "</div>") );
+ $(this).css("z-index", 3000);
+ },
+ function exit(){
+ $("div.sazu_holder2").remove();
+ $(".ranking").css("z-index", 20);
+ }
+ );
+ $(".ranking img").mousedown(
+ function(){
+ $("div.sazu_holder2").remove();
+ $(".ranking").css("z-index", 20);
+ }
+ );
+ </script>';
+ }
+
+ // Izrisemo podtip ostevilcevanje (mobile)
+ private function displayOstevilcevanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax, $oblika){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql1 = sisplet_query("SELECT id, naslov, if_id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ //nastavimo $max (maximum prenesenih vrednosti) -> ce lahko nosimo vse vrednosti ($row['ranking_k'] == 0) je $max stevilo vseh vrednotsti
+ if ($row['ranking_k'] == 0)
+ $max = mysqli_num_rows($sql1);
+ else
+ $max = $row['ranking_k'];
+
+ $count = mysqli_num_rows($sql1);
+
+ $counter = 0;
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_rating WHERE vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row2 = mysqli_fetch_array($sql2);
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . '>';
+
+ // Poseben input za SAZU
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+ echo ' <input
+ vred_id='.$row1['id'].'
+ type="hidden"
+ name="spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '"
+ id="spremenljivka_' . $spremenljivka . '_ranking_cifre_' . $counter . '"
+ value="' . $row2['vrstni_red'] . '"
+ > ';
+
+ echo '<br />';
+
+ echo '<select class="sazu_select" id="sazu_select_'.$counter.'" onChange="sazuSelect(this.value, \''.$spremenljivka.'\', \''.$counter.'\');">
+ <option></option>
+ <option value="1" '.($row2['vrstni_red'] == "1" ? ' selected="selected"' : '').'>1</option>
+ <option value="2" '.($row2['vrstni_red'] == "2" ? ' selected="selected"' : '').'>2</option>
+ <option value="3" '.($row2['vrstni_red'] == "3" ? ' selected="selected"' : '').'>3</option>
+ </select>';
+
+ echo $row1['naslov'];
+ }
+ else{
+ echo ' <input
+ vred_id='.$row1['id'].'
+ type="hidden"
+ name="spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '"
+ id="spremenljivka_' . $spremenljivka . '_ranking_cifre_' . $counter . '"
+ value="' . $row2['vrstni_red'] . '"
+ > ';
+
+ echo '<br />';
+
+ echo '<select class="ranking_select" id="ranking_select_'.$counter.'" onChange="rankingSelect(this.value, \''.$spremenljivka.'\', \''.$counter.'\');">';
+ echo ' <option></option>';
+
+ // Ce imamo omejitev stevila izbir
+ for($i=1; $i<=$max; $i++){
+ echo ' <option value="'.$i.'" '.($row2['vrstni_red'] == $i ? ' selected="selected"' : '').'>'.$i.'</option>';
+ }
+
+ echo '</select>';
+
+ echo $row1['naslov'];
+ }
+
+ echo '</div>' . "\n";
+ $counter++;
+ }
+
+ // Preverimo in omogocimo/onemogocimo vrednosti pri loadu, ce imamo slucajno ze izpolnjene
+ echo '<script> $(document).ready(rankingSelectCheckAll()); </script>';
+
+ // Script za SAZU
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+ echo '<script> $(document).ready(sazuSelectCheck()); </script>';
+ }
+
+ if ($row['ranking_k'] != 0)
+ echo '<span class="limit">(' . self::$lang['srv_max_answers'] . ': ' . $max . ')</span>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/SystemVariableController.php b/main/survey/app/Controllers/Vprasanja/SystemVariableController.php
new file mode 100644
index 0000000..f0551df
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/SystemVariableController.php
@@ -0,0 +1,62 @@
+<?php
+/***************************************
+ * Description: Special system variables
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Models\Model;
+
+class SystemVariableController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new SystemVariableController();
+ }
+
+ /**
+ * @desc Prikaže checkboxe za vrednosti 99,98,97
+ */
+ public static function display($spremenljivka, $oblika)
+ {
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND other IN (99,98,97) ORDER BY vrstni_red ");
+ $selected = Model::getOtherValue($spremenljivka);
+ echo '<input name="other_selected_vrednost_' . $spremenljivka . '" id="other_selected_vrednost_' . $spremenljivka . '" value="' . $selected . '" type="hidden">';
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if ($selected == $row1['id'])
+ $sel = true;
+ else
+ $sel = false;
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+ echo '<label for="missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '">';
+ echo '<input type="checkbox" name="vrednost_' . $spremenljivka . '[]" id="missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '" value="' . $row1['id'] . '"' . ($sel ? ' checked' : '') . ' spremenljivka="' . $spremenljivka . '" onclick=" checkBranching();"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $row1['naslov'] . '</label>';
+ echo '</div>' . "\n";
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/TextController.php b/main/survey/app/Controllers/Vprasanja/TextController.php
new file mode 100644
index 0000000..03c3fd3
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/TextController.php
@@ -0,0 +1,1022 @@
+<?php
+/***************************************
+ * Description: Textbox, Multitext
+ *
+ * Vprašanje je prisotno:
+ * tip 21
+ * tip 19
+ * tip 20
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Models\Model;
+use enkaParameters;
+
+class TextController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new TextController();
+ }
+
+
+ /************************************************
+ * Stara funkcija $this->displayMultitext($spremenljivka)
+ ************************************************/
+ public function multitext($spremenljivka)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+ if ($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['num_useMin'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMax'] == 1)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ else
+ $limit = '';
+
+ //************Params za omejitev sliderjev
+ //tvorjenje omejitve********************************************************************************
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+ $limit_slider_mobile = '(min ' . $slider_MinNumLabel . ', max ' . $slider_MaxNumLabel . ')';
+ //************
+
+ // omejitev vnosa
+ if ($row['vsota_show'] == 1 && $row['ranking_k'] != '1' && $row['tip'] == 20) {
+ echo ' <label class="limit">' . $limit . '</label>';
+ }
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ echo ' <table class="grid_table multitext">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ echo ' <tr>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ # če imamo enoto povečamo št. stoplcev
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30)
+ $cellsize = round(80 / $size);
+ else
+ $cellsize = 'auto';
+
+ $spacesize = round(80 / $size / 4);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1);
+ //default sirina
+ if ($taWidth == -1) {
+ $taWidth = 80;
+ } else {
+ //$taWidth = $taWidth * 10 * 2; // da dobimo % (opcije se od 1 - 5)
+ $taWidth = $taWidth * 10; // da dobimo % (opcije se od 1 - 9)
+ }
+
+ $bg = 1;
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $g_id => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache textovnih odgovorov
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Cache missingov
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '"'/*.($row1['if_id']>0?' style="display:none"':'')*/ . '' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' : '').'>';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ if ($srv_grid['other'] != 0)
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ else
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ if ($grid_id == $value) {
+
+ $vsebina = $srv_data_cache[$row1['id']][$i]['text'];
+
+ //$row2 = mysqli_fetch_array($sql2);
+ }
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+ # izpišemo labelo grida
+ //multitext
+ if ($row['tip'] == 19) {
+ if ($srv_grid['other'] != 0) {
+ # imamo missing nardimo radio
+ echo '<td class="missing ' . $cssAlign . '">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category ' . $cssAlign . '">';
+ //echo '<input type="text" style="width:'.$taWidth.'em;" name="vrednost_'.$row1['id'].'_grid_'.$value.'" id="vrednost_'.$row1['id'].'_grid_'.$value.'" value="'.($is_missing ? '' : $vsebina).'" calculation="'.$srv_grid['variable'].'" '.($is_missing ? ' disabled class="disabled"' : '').'>';
+ echo '<textarea class="width_' . $taWidth . '" rows="' . $taHeight . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();">' . ($is_missing ? '' : $vsebina) . '</textarea>';
+ echo '</td>' . "\n";
+ }
+
+ //multinumber - rabimo JS checkNumber
+ } else {
+ if ($srv_grid['other'] != 0) {
+ # imamo missing nardimo radio
+ echo '<td class="missing ' . $cssAlign . '">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category ' . $cssAlign . '">';
+ echo '<input type="text" class="width_' . $taWidth . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . ($is_missing ? '' : $vsebina) . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); checkBranching();">';
+
+ //multislider
+ //if ($row['ranking_k'] == 1 && get('mobile') == 0) {
+ if ($row['ranking_k'] == 1) { //slider na PC, tablici in mobilniku
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0);
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0);
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0);
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0);
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0);
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0);
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1);
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+ //$slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ //$slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5);
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0);
+ $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : '';
+
+
+ if(get('lang_id') != null){
+ $lang_id = get('lang_id');
+ $ank_id = get('anketa');
+
+ $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$ank_id' AND spr_id='$spremenljivka' AND lang_id='$lang_id' ORDER BY label_id";
+ $sqlSlider = sisplet_query($sqlString);
+
+ while ($rowsqlSlider = mysqli_fetch_array($sqlSlider)) {
+ if($rowsqlSlider['label_id'] == 1){
+ $MinLabel = $rowsqlSlider['label'];
+ }
+ elseif($rowsqlSlider['label_id'] == 2){
+ $MaxLabel = $rowsqlSlider['label'];
+ }elseif($row['label_id'] == 0){
+ $custom = $rowsqlSlider['label'];
+ }
+ }
+
+ if($slider_DescriptiveLabel_defaults && $custom==''){ //ce so prednalozene opisne labele drsnika in nimamo se prevoda
+ $custom_ar = explode(';', $slider_DescriptiveLabel_defaults_naslov1);
+ }else{ //ce so custom opisne labele drsnika
+ $custom_ar = explode('; ', $custom);
+ }
+
+ // Ce slucajno nimamo prevedeno uporabimo original
+ $MinLabel = ($MinLabel == '') ? ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']) : $MinLabel;
+ $MaxLabel = ($MaxLabel == '') ? ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']) : $MaxLabel;
+ }
+ else{
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']);
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']);
+ }
+
+ //echo '<div style="width:100%">';
+ echo '<div style="width:100%; height:150px">';
+
+ //$default_value = round(($row['vsota_limit']-$row['vsota_min']) / 2) + $row['vsota_min'];
+ $default_value = round(($slider_MaxNumLabel - $slider_MinNumLabel) / 2) + $slider_MinNumLabel;
+ $vrednost = ($vsebina == '') ? $default_value : $vsebina;
+
+ //labeli nad min in max drsnikov ############################################################
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel">';
+ } else if (get('mobile') == 1) { //ce mobilnik
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel_mobile">';
+ }
+ echo '<tbody>';
+ echo '<tr>';
+ echo '<td align="left">' . $MinLabel . '</td>';
+ echo '<td align="right">' . $MaxLabel . '</td>';
+ echo '</tr>';
+ echo '</tbody>';
+ echo '</table>';
+ //labeli nad min in max drsnikov - konec ####################################################
+
+ echo '<div class="sliderText" id="sliderText_' . $spremenljivka . '_' . $row1['id'] . '">' . $vrednost . '</div>';
+
+ //echo '<div style="display:inline-block;">'.$row['vsota_min'].'</div>';
+ //echo '<div id="slider_'.$spremenljivka.'_'.$row1['id'].'" class="slider"></div>';
+ //echo '<div style="display:inline-block;">'.$row['vsota_limit'].'</div>';
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider"></div>';
+ } else if (get('mobile') == 1) { //ce mobilnik
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider_grid_mobile"></div>';
+ }
+
+ echo '</div>';
+
+ //za custom opisne labele
+ //moznosti urejanja opisnih label drsnika
+ if($slider_VmesneDescrLabel){
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ if($custom == ''){ //ce nimamo prevoda opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ }else{ //ce mamo prevod opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1];
+ }
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ }
+ //za custom opisne labele - konec
+
+ ?>
+ <script>
+ $(function () {
+ slider_grid_init(<?=get('mobile')?>, <?=$spremenljivka?>, <?=$row1['id']?>, <?=$slider_MinNumLabel?>, <?=$slider_MaxNumLabel?>, <?=$vrednost?>, <?=$slider_handle?>, <?=$slider_handle_step?>, <?=$slider_VmesneNumLabel?>, <?=$slider_VmesneCrtice?>, <?=$slider_MinMaxNumLabelNew?>, <?=$slider_window_number?>, '<?=$slider_DescriptiveLabel_defaults_naslov1?>', <?=$slider_DescriptiveLabel_defaults?>, <?=$default_value?>, <?=$slider_nakazi_odgovore?>, <?=$slider_VmesneDescrLabel?>, '<?=$slider_CustomDescriptiveLabels?>', '<?=$custom?>');
+ });
+ </script>
+ <?
+ }
+
+ echo '</td>' . "\n";
+
+ }
+ }
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo ' </table>' . "\n";
+
+ // Izpis prejsnjih odgovorov (ce imamo vklopljeno nastavitev)
+ $prevAnswers = ($spremenljivkaParams->get('prevAnswers') ? $spremenljivkaParams->get('prevAnswers') : 0);
+ if($prevAnswers == 1)
+ self::display_prevAnswers($spremenljivka);
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayTextbox($spremenljivka)
+ ************************************************/
+ public function textbox($spremenljivka, $oblika)
+ {
+ global $recaptcha_sitekey;
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ if($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '('.$lang['srv_text_length_char_num'].$row['vsota_min'].')';
+ elseif($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '('.$lang['srv_text_length_char_num'].'min '.$row['vsota_min'].', max '.$row['vsota_limit'].')';
+ elseif($row['num_useMin'] == 1)
+ $limit = '('.$lang['srv_text_length_char_num'].'min '.$row['vsota_min'].')';
+ elseif($row['num_useMax'] == 1)
+ $limit = '('.$lang['srv_text_length_char_num'].'max '.$row['vsota_limit'].')';
+ else
+ $limit = '';
+
+ $taSize = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1);
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $max_text_length = ($row['vsota_limit'] > 0 ? ' maxlength="'.$row['vsota_limit'].'"' : '');
+ $email_verify = ($spremenljivkaParams->get('emailVerify') ? $spremenljivkaParams->get('emailVerify') : 0);
+
+ //default sirina
+ if ($taWidth == -1)
+ $taWidth = 30;
+
+ # preverimo ali je vrednost v bazi missing
+ $missing = Check::getInstance()->checkMissingForSpremenljivka($spremenljivka, $loop_id);
+
+ if ((int)$missing > 0) {
+ $srv_data_vrednost[$missing] = true;
+ }
+
+ // Ce imamo slucajno vklopljeno nastavitev da so odgovori disabled
+ $disabled_vprasanje = ($spremenljivkaParams->get('disabled_vprasanje') == '1') ? true : false;
+
+ if ($row['upload'] == 1 || $row['upload'] == 2 ) // max size
+ echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . (1024 * 1024 * 100) . '">';
+
+ echo '<table class="text_vrednost"><tbody>' . "\n";
+ if ($row['orientation'] != 3)
+ echo '<tr>';
+
+ # za polja drugo
+ $array_others = array();
+
+ $sql1 = sisplet_query("SELECT id, naslov, vrstni_red, other, size, naslov2 FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red > 0 ORDER BY vrstni_red");
+
+ $i = 1;
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ # če ni polje drugo
+ if ((int)$row1['other'] == 0) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$row1[id]' AND loop_id $loop_id");
+ $row2 = mysqli_fetch_array($sql2);
+
+
+ // sirina celice td
+ $cell = $row['text_kosov'] == 1 ? 100 : $row1['size'];
+ $width = round(100 / $row['text_kosov'], 0);
+ // sirina vnosnega polja
+ $input = $taWidth;
+
+ if ($row['orientation'] == 3)
+ echo '<tr>';
+ echo '<td class="variabla">' . "\n";
+
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ //izpisi
+ if ($row['text_orientation'] == 1 || $row['text_orientation'] == 3) {
+ echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '">' . $row1['naslov'] . '</label>' . "\n";
+
+ if ($row['text_orientation'] == 3)
+ echo '<br>';
+ }
+
+
+ // Ni signature ali upload
+ if ($row['upload'] == 0 && $row['signature'] == 0) {
+
+ // if captcha == 1
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0);
+
+ if ($captcha == 1) {
+ echo '<div class="g-recaptcha" data-sitekey="' .$recaptcha_sitekey .'"></div>';
+ }
+ else {
+ $char_counter_events = $limit ? 'charCounter(this);' : '';
+
+ // Ce gre za email preverjamo pravilnost na blur in ne na keyup
+ $js_trigger = ($email_verify == 1) ? 'onBlur' : 'onKeyUp';
+
+ echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '">';
+
+ if ($taSize > 1) {
+ echo '<textarea name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' rows="' . $taSize . '" class="width_' . $input . '" onkeyup="checkBranching();'.$char_counter_events.'"' . (!$missing && !$disabled_vprasanje ? '' : ' disabled') . $max_text_length. '>' . (!$missing ? $row2['text'] : '') . '</textarea>';
+ } else {
+ echo '<input type="text" name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '" class="width_' . $input . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' '.$js_trigger.'="checkBranching();'.$char_counter_events.'" value="' . (!$missing ? $row2['text'] : '') . '" ' . (!$missing && !$disabled_vprasanje ? '' : ' disabled') . $max_text_length. '>';
+ }
+
+ // Ce je vprasanje disabled moramo vseeno postati vrednost
+ if($disabled_vprasanje && !$missing){
+ echo '<input type="hidden" name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" value="'.$row2['text'].'">';
+ }
+
+ // prikazi counter znakov
+ if ($limit && !get('printPreview')) {
+ echo '<span id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '_counter" class="char_counter"></span>';
+ echo '<script>set_charCounter(\'spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '\');</script>';
+ }
+
+ echo '</label>';
+ }
+
+ } // Signature
+ elseif ($row['signature'] != 0 && $row['upload'] == 0) {
+ //***novo
+ echo ' <script src="' . self::$site_url . 'main/survey/js/signature/jquery.signaturepad.js"></script>' . "\n";
+ echo ' <!--[if lt IE 9]><script src="' . self::$site_url . 'main/survey/js/signature/flashcanvas.js"></script><![endif]-->' . "\n";
+
+ //za ureditev vpogleda v posamezno enoto
+ $quick_view = json_encode(get('quick_view'));
+
+ // options za risanje signature in ostale spremenljivke
+ echo '<script>
+ if('.$quick_view.'==1){
+ $("#clear_spremenljivka_' . $spremenljivka . '").attr("disabled", true);
+ //console.log("Izklopi gumb");
+ }
+ optionsPodpis[' . $spremenljivka . '] = { //options za signature knjižnico, ki niso default vrednosti
+ drawOnly : true //samo risanje podpisa
+ , clear: "#clear_spremenljivka_' . $spremenljivka . '" //gumb oz. polje za brisanje ima id
+ , output: "#signature-data_spremenljivka_' . $spremenljivka . '" //polje, kjer se prikaže output oz. podpis v json obliki
+ , validateFields: false //preverjanje vnosa podpisa in imena se ne izvaja
+ };
+
+ </script>
+ ';
+
+ //***novo
+
+ //$sqlSignature = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . get('usr_id') . "'");
+ $sqlSignature = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . get('usr_id') . "' AND code='" . $spremenljivka . "' ");
+ if (mysqli_num_rows($sqlSignature) > 0) {
+ $rowSignature = mysqli_fetch_array($sqlSignature);
+ $signaturefile = $rowSignature[0];
+
+
+ echo '
+ <script>
+ var polje_imena ="#spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
+ $(document).ready(
+ function(){
+
+ $("#canvas_' . $spremenljivka . '").hide();
+ $("#podpis_slika_' . $spremenljivka . '").show();
+ if(' . sizeof($row2['text']) . ' > 0){
+ $("#spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '").val("' . $row2['text'] . '");
+ }
+ //$("#clear_spremenljivka_' . $spremenljivka . '").mousedown(function(){ //ob kliku na gumb miške dol
+ $("#clear_spremenljivka_' . $spremenljivka . '").click(function(){ //ob kliku
+ $("#canvas_' . $spremenljivka . '").show(); //pokazi canvas za podpis
+ $("#canvas_' . $spremenljivka . ' .sigWrapper").addClass("current");
+ podpisposlan[' . $spremenljivka . '] = 0;
+ $("#podpis_slika_' . $spremenljivka . '").remove(); //odstrani sliko podpisa
+ $.post("' . self::$site_url . 'main/survey/ajax.php?a=usr_id_data", //poslji podatke za brisanje podatkov o sliki iz baze in brisanje datoteke iz diska
+ {usr_id: ' . get('usr_id') . ', anketa: ' . srv_meta_anketa_id . ', spr_id: ' . $spremenljivka . ', vre_id: ' . $row1[id] . '});
+ });
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']); //omogoci risanje na canvas
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").mouseout(function(){ //ob izhodu miške iz površine za podpisovanje
+ if(!$("#signature-data_spremenljivka_' . $spremenljivka . '").val()){ //če ni nobenega podpisa
+ //console.log("Prazno!");
+ }else{ //drugače, če je podpisa prisoten
+ if(podpisposlan[' . $spremenljivka . '] == 0){
+ podpisposlan[' . $spremenljivka . '] = 1;
+
+ var signaturedata = $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']).getSignatureImage();
+ //console.log(signaturedata);
+ var signaturename = $("#signature-name_spremenljivka_' . $spremenljivka . '").val();
+ $("#signature-data_spremenljivka_' . $spremenljivka . '").val(signaturedata);
+ $("#signature-name_spremenljivka_' . $spremenljivka . '").val(signaturename);
+ }
+ }
+ });
+ }
+ );
+
+ </script>
+ ';
+ //echo $rowSignature[0];
+ } else {
+
+ //predelano - začetek urejanja javascript kode za delovanje podpisa
+ echo '
+ <script>
+ $(document).ready(
+ function(){
+
+ podpisposlan[' . $spremenljivka . '] = 0;
+
+ if('.$quick_view.'){
+ $("#clear_spremenljivka_' . $spremenljivka . '").attr("disabled", true);
+ }else{
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']); //omogoci risanje na canvas
+ }
+
+
+
+ $("#clear_spremenljivka_' . $spremenljivka . '").click(function(){ //ob kliku na gumb Clear
+ //console.log("Brišem");
+ podpisposlan[' . $spremenljivka . '] = 0;
+ $("#spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '").val("");//počisti polje z imenom
+ });
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").mouseout(function(){ //ob izhodu miške iz površine za podpisovanje
+
+ if(!$("#signature-data_spremenljivka_' . $spremenljivka . '").val()){ //če ni nobenega podpisa
+ //console.log("Prazno!");
+ }else{ //drugače, če je podpisa prisoten
+ //console.log("Nekaj je");
+ if(podpisposlan[' . $spremenljivka . '] == 0){
+ podpisposlan[' . $spremenljivka . '] = 1;
+
+ var signaturedata = $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']).getSignatureImage();
+ //console.log(signaturedata);
+ var signaturename = $("#signature-name_spremenljivka_' . $spremenljivka . '").val();
+ $("#signature-data_spremenljivka_' . $spremenljivka . '").val(signaturedata);
+ $("#signature-name_spremenljivka_' . $spremenljivka . '").val(signaturename);
+ }
+ }
+ });
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").click(function(){ //ob kliku na gumb površino za podpisovanje
+ podpisposlan[' . $spremenljivka . '] = 0;
+ });
+ }
+ );
+ </script>
+ ';
+
+
+ //predelano - konec
+ }
+
+ // Dobimo sirino polja - ce je mobile ga pomanjsamo
+ if(get('mobile') == 1){
+ $width = 300;
+ $height = 150;
+ }
+ else{
+ $width = 600;
+ $height = 200;
+ }
+
+ echo '
+ <div id="signature-pad_spremenljivka_' . $spremenljivka . '">
+ <div id="canvas_' . $spremenljivka . '">
+
+ <div class="sig sigWrapper">
+ <canvas width="'.$width.'" height="'.$height.'" style="border:1px solid black"></canvas>
+ </div>
+ </div>
+ <div id="podpis_slika_' . $spremenljivka . '" hidden>
+ <img src="' . self::$site_url . 'main/survey/uploads/' . $signaturefile . '" style="width: '.$width.'px; height: '.$height.'px; border:1px solid black">
+ </div>
+ <div>
+
+ <input id="clear_spremenljivka_' . $spremenljivka . '" type="button" value="' . self::$lang['srv_signature_clear'] . '" class="sig_clear_button" style="width: '.$width.'px;">
+
+ <input id="signature-data_spremenljivka_' . $spremenljivka . '" type="text" value="" name="signature-data_spremenljivka_' . $spremenljivka . '" hidden><br />
+ ';
+
+
+ echo '
+ ' . self::$lang['srv_signature_name'] . ' ' . '<input type="text" name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '" ' . (!$missing ? '' : ' disabled') . '><br />
+
+ </div>
+ </div>
+ ';
+ }
+
+ // Smo v admin podatkih in uplodamo datoteko ali fotografijo
+ elseif( ($row['upload'] == 1 || $row['upload'] == 2) && ($_GET['t'] == 'postprocess' || $_GET['m'] == 'quick_edit') ){
+
+ $sqlUpload = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id='".get('usr_id')."' AND code='".$row2['text']."'");
+
+ // Ze imamo datoteko - moznost brisanja v adminu
+ if(mysqli_num_rows($sqlUpload) > 0){
+
+ $rowUpload = mysqli_fetch_array($sqlUpload);
+ $file = $rowUpload[0];
+
+ global $site_url;
+ echo '<div style="font-size:14px;"><a href="'.$site_url.'/main/survey/download.php?anketa='.get('anketa').'&code='.$row2['text'].'">'.$file.'</a></div>';
+
+ // Remove file button
+ if($_GET['quick_view'] != '1'){
+ echo '<div class="buttonwrapper floatLeft">
+ <a
+ class="ovalbutton ovalbutton_orange btn_savesettings"
+ href="#"
+ style="margin: 10px 0 0 0;"
+ id="remove_file_'.$spremenljivka.'_vrednost_'.$i.'"
+ onClick="removeUploadFromData(\''.get('usr_id').'\', \''.$spremenljivka.'\', \''.$row2['text'].'\')"
+ >';
+ echo self::$lang['srv_alert_upload_remove'];
+ echo '</div>';
+ }
+ }
+ // Uploadamo datoteko preko admina - TODO
+ else{
+
+ echo '<input name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '"
+ type="file"
+ id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
+ class="pointer"
+ >';
+ }
+ }
+
+ // Upload
+ elseif ($row['upload'] == 1) {
+
+ echo '<input name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '"
+ type="file"
+ id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
+ ' . (!$missing ? '' : ' disabled') . '
+ class="pointer"
+ onChange="checkUpload(this, \''.$spremenljivka.'_vrednost_'.$i.'\');"
+ >';
+
+ // Remove file button
+ echo '<div class="remove_file pointer"
+ id="remove_file_'.$spremenljivka.'_vrednost_'.$i.'"
+ style="display:none;"
+ onClick="removeUpload(\'spremenljivka_'.$spremenljivka.'_vrednost_'.$i.'\')"
+ >';
+ echo self::$lang['srv_alert_upload_remove'];
+ echo '</div>';
+ }
+
+ // Fotografiranje
+ elseif ($row['upload'] == 2) {
+
+ $inpname = 'vrednost_' . $spremenljivka . '_kos_' . $row1['id'];
+ $inpid = 'spremenljivka_' . $spremenljivka . '_vrednost_' . $i;
+
+ echo '<label class="custom-foto-upload" for="'.$inpid. '"></label>';
+ echo '<input class="upload_foto_file" name="'.$inpname . '" type="file" accept="image/*" id="'.$inpid. '" capture="camera">';
+ echo '<div class="fotoresults_delete upload_fotoresults_delete pointer" id="upload_fotoresults_delete_'.$inpid.'" onClick="delete_upload_foto(\''.$inpid.'\');">'.$lang['srv_alert_foto_remove'].'</div>';
+
+ echo '<div id="upload_foto_result_'.$inpid.'_holder">
+ <img id="upload_foto_result_'.$inpid. '" class="upload_foto_result" src="#">
+ </div>';
+
+ echo '<div class="fotoparent" id="fotoparent_'.$inpid.'" style="visibility: hidden; display : none;">
+ <div class="fotoresults_div">
+ <p style="padding: 4px;"><i>'.self::$lang['srv_resevanje_foto_result_title'].'</i></p>
+
+ <div class="fotoresults" id="fotoresults_'.$inpid.'">
+ <p>'.self::$lang['srv_resevanje_foto_pre_result'].'</p>
+ </div>
+ <div class="fotoresults_delete pointer" id="fotoresults_delete_'.$inpid.'" onClick="delete_snapshot(\''.$inpid.'\');">'.$lang['srv_alert_foto_remove'].'</div>
+ </div>
+ <input id="foto_'.$inpid.'" type="hidden" name="foto_'.$inpname.'" value=""/>
+
+ <div class="my_camera_div">
+ <p style="padding: 4px;"><i>'.self::$lang['srv_resevanje_foto_snap_title'].'</i></p>
+
+ <div class="my_camera" id="my_camera_'.$inpid.'"></div>
+
+ <!-- A button for taking snaps -->
+ <button type="button" class="record_foto" onClick="take_snapshot(\''.$inpid.'\');"></button>
+ </div>
+ </div>';
+ ?>
+
+ <!-- Configure a few settings and attach camera -->
+ <script language="JavaScript">
+ //dobi osnovni id iputa spremenljivke
+ var inpid = '<?php echo $inpid; ?>';
+
+ //deklarira vse potrebno za funkcionalnost fotografiranja
+ FotoDeclaration(inpid, '<?php echo self::$site_url; ?>');
+
+ //prikazi uploadano datoteko v primeru navadnega uploada ali prek mobilnika
+ function readURL(input) {
+ if (input.files && input.files[0]) {
+ var reader = new FileReader();
+
+ reader.onload = function (e) {
+ $('#upload_foto_result_'+inpid).css("display", "inline");
+ $('#upload_foto_result_'+inpid).attr('src', e.target.result);
+ $('#upload_fotoresults_delete_'+inpid).show();
+ };
+
+ reader.readAsDataURL(input.files[0]);
+ }
+ }
+
+ //ko se navadni upload spremeni, zazeni F za prikaz slike
+ $("#"+inpid).change(function(){
+ readURL(this);
+ });
+ </script>
+ <?php
+ }
+
+
+ if ($row['text_orientation'] == 2) {
+ echo '<br><label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '">' . $row1['naslov'] . '</label>' . "\n";
+ }
+
+ // omejitev vnosa
+ if ($row['vsota_show'] == 1) {
+ echo '<label class="limit">' . $limit . '</label>';
+ }
+
+ echo '</td>' . "\n";
+ if ($row['orientation'] == 3)
+ echo '</tr>';
+ }
+ else {
+ # imamo polje drugo - ne vem, zavrnil...
+ $array_others[$row1['id']] = array(
+ 'naslov' => $row1['naslov'],
+ 'vrstni_red' => $row1['vrstni_red']
+ );
+ }
+
+ $i++;
+ }
+
+ if ($row['orientation'] != 3)
+ echo '</tr>';
+
+ echo '</tbody></table>' . "\n";
+
+ if (count($array_others) > 0) {
+ $missing = 1;
+ foreach ($array_others AS $oKey => $other) {
+ # missing vrednost
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $oKey;
+
+ if ($srv_data_vrednost[$oKey]) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu
+ $_checked = ($sel ? ' checked' : '');
+ // Tole ni definirano in ne more delat?? zakaj bi sploh kadarkoli bil missing disabled??
+ //$_disabled = ($is_missing && ($row1['other'] == 0 || $row1['other'] == 1) ? true : false);
+ $_disabled = false;
+
+ $naslov = Language::getInstance()->srv_language_vrednost($oKey);
+ if ($naslov != '') $other['naslov'] = $naslov;
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+
+ $already_set_mv = array();
+ $sql_grid_mv = sisplet_query("SELECT naslov, other FROM srv_vrednost WHERE spr_id='" . $spremenljivka . "' AND other != 0");
+ while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) {
+ $already_set_mv[$row_grid_mv['other']] = $row_grid_mv['naslov'];
+ }
+
+ if ((($row['alert_show_99'] > 0 && isset($already_set_mv['-99']) && $already_set_mv['-99'] == $other['naslov'])
+ || ($row['alert_show_98'] > 0 && isset($already_set_mv['-98']) && $already_set_mv['-98'] == $other['naslov'])
+ || ($row['alert_show_97'] > 0 && isset($already_set_mv['-97']) && $already_set_mv['-97'] == $other['naslov']))
+ && $_checked == ''
+ )
+ $hide_missing = true;
+
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' missing" id="vrednost_if_' . $oKey . '"' . ' ' . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '">';
+ echo '<input type="checkbox" name="vrednost_mv_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $oKey . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="1" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $oKey . '\', \'' . $checkbox_limit . '\');' : '') . ' checkMissing(this);"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $other['naslov'] . '</label>';
+ echo '</div>';
+ }
+ }
+
+ SystemVariable::display($spremenljivka, $oblika);
+
+ // Izpis prejsnjih odgovorov (ce imamo vklopljeno nastavitev)
+ $prevAnswers = ($spremenljivkaParams->get('prevAnswers') ? $spremenljivkaParams->get('prevAnswers') : 0);
+ if($prevAnswers == 1)
+ self::display_prevAnswers($spremenljivka);
+ }
+
+
+ // Prikazemo stare odgovore pod vprasanjem (nastavitev prevAnswers)
+ private function display_prevAnswers($spremenljivka){
+
+ echo '<div class="text_prevAnswers">';
+ echo self::$lang['srv_prevAnswers'].':';
+
+ echo '<div class="text_prevAnswers_list">';
+
+ //$sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id!='" . get('usr_id') . "' AND vre_id='$row1[id]' AND loop_id $loop_id");
+ $sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."' ORDER BY id DESC limit 30");
+ while($row = mysqli_fetch_array($sql)){
+ echo '<p>';
+ echo $row['text'];
+ echo '</p>';
+ }
+
+ $sqlC = sisplet_query("SELECT count(*) FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."'");
+ $rowC = mysqli_fetch_array($sqlC);
+ if($rowC['count(*)'] > 30){
+ // gumb "vec" da prikazemo vse
+ echo '<span class="more" onClick="show_prevAnswers_all(\''.$spremenljivka.'\');">('.self::$lang['srv_more'].'...)</span>';
+
+ // div za izris vseh
+ echo '<div id="text_prevAnswers_popup_'.$spremenljivka.'" class="text_prevAnswers_popup"></div>';
+ }
+
+ echo '</div>';
+
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/VprasanjaController.php b/main/survey/app/Controllers/Vprasanja/VprasanjaController.php
new file mode 100644
index 0000000..c34b1c3
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/VprasanjaController.php
@@ -0,0 +1,944 @@
+<?php
+/***************************************
+ * Description: Tukaj kličemo vse tipe vprašanj, ki so nato v posameznih razredih
+ * Autor: Robert Šmalc
+ * Created date: 29.02.2016
+ **************************************
+ * TIPI VPRAŠANJ:
+ * radio -> tip = 1
+ * checkbox -> tip = 2
+ * select -> tip = 3
+ * text -> tip = 4 // ni vec v uporabi
+ * besedilo* -> tip = 21
+ * label -> tip = 5
+ * multigrid -> tip = 6
+ * multicheckbox -> tip = 16
+ * multitext -> tip = 19
+ * multinumber -> tip = 20
+ * number -> tip = 7
+ * compute -> tip = 22 // samo v naprednejših anketah (ifi ali test anketa)
+ * quota -> tip = 25 // samo v naprednejših anketah (ifi ali test anketa)
+ * datum -> tip = 8
+ * ranking -> tip = 17
+ * vsota -> tip = 18
+ * grid - multiple -> tip = 24
+ * iz knjiznice -> tip = 23 // podtip nam pove za tip vprasanja, ki ga poiscemo glede na variablo
+ * SN-imena -> tip = 9
+ * Map-lokacija -> tip = 26
+ * HeatMap -> tip = 27
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+use App\Controllers\Controller;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\Vprasanja\ComputeController as Compute;
+use App\Controllers\Vprasanja\DatumController as Datum;
+use App\Controllers\Vprasanja\DoubleController as Double;
+use App\Controllers\Vprasanja\DragDropController as DragDrop;
+use App\Controllers\Vprasanja\DynamicController as Dynamic;
+use App\Controllers\Vprasanja\ImenaController as Imena;
+use App\Controllers\Vprasanja\MaxDiffController as MaxDiff;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+use App\Controllers\Vprasanja\MultigridMobileController as MultigridMobile;
+use App\Controllers\Vprasanja\NumberController as Number;
+use App\Controllers\Vprasanja\OneAgainstAnotherController as OneAgainstAnother;
+use App\Controllers\Vprasanja\QuotaController as Quota;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\RankingController as Ranking;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Controllers\Vprasanja\TextController as Text;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Controllers\Vprasanja\VsotaController as Vsota;
+use App\Controllers\Vprasanja\MapsController as Maps;
+use App\Controllers\Vprasanja\ImageHotSpotController as HotSpot;
+use App\Controllers\Vprasanja\HeatMapController as HeatMap;
+use App\Models\Model;
+use Branching;
+use enkaParameters;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use UserAccess;
+
+
+class VprasanjaController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance) {
+ self::refreshVariables();
+ return self::$_instance;
+ }
+
+ return new VprasanjaController();
+ }
+
+ private function refreshVariables()
+ {
+ return parent::getAllVariables();
+ }
+
+ /**
+ * @desc prikaze spremenljivke v trenutni grupi
+ */
+ public function displaySpremenljivke(){
+
+ if (!get('printPreview')) {
+ // poiscemo vprasanja s prejsnje strani, ki imajo vklopljeno statistiko
+ Statistic::displayStatistika();
+
+ // zgeneriramo sistemske spremenljivke
+ Header::getInstance()->displaySistemske();
+
+ // prikazemo skrita ze odgovorjena vprasanja
+ Vprasanja::getInstance()->displaySpremenljivkeHidden();
+ }
+
+ $offset = 0;
+ $zaporedna = 1;
+
+ if (SurveyInfo::getInstance()->getSurveyCountType() > 0) {
+ // Preštejemo koliko vprašanj je bilo do sedaj
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='" . get('grupa') . "'");
+ $rowg = mysqli_fetch_assoc($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+
+ $sqlCountPast = sisplet_query("SELECT count(*) as cnt FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND g.vrstni_red < '$vrstni_red' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
+ $rowCount = mysqli_fetch_assoc($sqlCountPast);
+ $offset = $rowCount['cnt'];
+ }
+
+ // poiscemo vprasanja / spremenljivke
+ // če imamo pri posamezni spremenljivki nastavljeno da jo prikazujemo na začetku vsake strani
+ if (get('displayAllPages')) {
+ $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka AS s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='" . get('anketa') . "' ORDER BY g.vrstni_red, s.vrstni_red ASC");
+ }
+ else {
+ // Optimizirano
+ $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka AS s, srv_grupa g WHERE ((s.gru_id='" . get('grupa') . "' AND s.visible='1' AND g.ank_id='" . get('anketa') . "') OR (s.showOnAllPages = '1' AND s.visible='1' AND g.ank_id='" . get('anketa') . "')) AND s.gru_id=g.id ORDER BY g.vrstni_red, s.vrstni_red ASC");
+ }
+
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ )
+ $evoli_teammeter = true;
+ else
+ $evoli_teammeter = false;
+
+ while ($row = mysqli_fetch_array($sql)) {
+
+ // Izbira departmenta za modul EVOLI TEAMMETER / evoli_quality_climate / evoli_teamship_meter / evoli_organizational_employeeship_meter na prvi strani
+ if($evoli_teammeter){
+
+ // Ce smo na prvi strani in izpisujemo drugo vprasanje
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='" . get('grupa') . "'");
+ $rowg = mysqli_fetch_assoc($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+ if($zaporedna == 2 && $rowg['vrstni_red'] == 1){
+ // Dobimo id skupine (podjetja) za respondenta
+ $sqlGroupTM = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='" . get('anketa') . "' AND d.usr_id='" . get('usr_id') . "' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ // Loop cez vse oddelke (departments) za izbrano skupino (podjetje)
+ $sqlTM = sisplet_query("SELECT d.* FROM srv_evoli_teammeter_department d, srv_evoli_teammeter tm WHERE d.tm_id=tm.id AND tm.skupina_id='".$rowGroupTM['vre_id']."'");
+ if(mysqli_num_rows($sqlTM) > 0){
+
+ echo ' <div id="spremenljivka_evoli_tm_department" class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira oddelka z dropdown menijem
+ if(isset($_GET['language']) && $_GET['language'] == '1'){
+ echo ' <p><div class="naslov"><span class="reminder">*</span>Prosimo izberite vašo ekipo, oddelek ali delovno skupino v vaši organizaciji:</div>';
+ echo ' <div class="variable_holder clr"><div class="variabla"><select name="evoli_tm_department" id="evoli_tm_department">';
+
+ echo '<option value="0">Izberite s seznama</option>';
+ while($rowTM = mysqli_fetch_array($sqlTM)){
+ echo '<option value="' . $rowTM['id'] . '">' . $rowTM['department'] . '</option>';
+ }
+
+ echo ' </select></div></div>';
+ echo '</p>' . "\n";
+ }
+ else{
+ echo ' <p><div class="naslov"><span class="reminder">*</span>Please indicate your team, department or working group in your organisation:</div>';
+ echo ' <div class="variable_holder clr"><div class="variabla"><select name="evoli_tm_department" id="evoli_tm_department">';
+
+ echo '<option value="0">Select from dropdown</option>';
+ while($rowTM = mysqli_fetch_array($sqlTM)){
+ echo '<option value="' . $rowTM['id'] . '">' . $rowTM['department'] . '</option>';
+ }
+
+ echo ' </select></div></div>';
+ echo '</p>' . "\n";
+ }
+
+ echo ' </div>' . "\n";
+ }
+ }
+ }
+
+ if ($zaporedna == 1 && get('loop_id') == null) { // preverimo, ce je na tej strani LOOP in redirectamo na prvo vrednost
+
+ $if_id = Find::find_parent_loop($row['id']);
+ if ($if_id > 0) {
+ $sql1 = sisplet_query("SELECT if_id FROM srv_loop WHERE if_id = '$if_id'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ save('loop_id', Find::getInstance()->findNextLoopId($row1['if_id']));
+
+ if (get('loop_id') != null) {
+ $loop_id = '&loop_id=' . get('loop_id');
+ }
+ else {
+ $loop_id = '';
+ save('grupa', Find::getInstance()->findNextGrupa());
+ if (get('grupa') == 0) save('grupa', 'end');
+ }
+
+ header('Location: ' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . $loop_id . Header::getSurveyParams() . get('cookie_url') . '');
+ return;
+ }
+ }
+
+ //ce gre za glasovanje in smo eno vprasanje ze prikazali, ostalih ne prikazemo
+ if ((SurveyInfo::getInstance()->getSurveyType() != 0) || ($zaporedna == 1))
+ Vprasanja::getInstance()->displaySpremenljivka($row['id'], $offset, $zaporedna);
+
+ $zaporedna++;
+ }
+
+
+ // JS za mobilno razpiranje tabel
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+ if($mobile_tables == 2){
+
+ echo '<script>
+ $(document).ready(
+ function(){
+ mobileMultigridExpandable();
+ }
+ );
+ </script>';
+ }
+
+ // JS za razpiranje tabel znotraj bloka s to nastavitvijo
+ echo '<script>
+ $(document).ready(
+ function(){
+ questionsExpandable();
+ }
+ );
+ </script>';
+
+
+ echo '<script>
+ var comments = init_comments_save();
+
+ // GDPR popup
+ $(".gdpr_popup_trigger").click(function(){ show_gdpr_about(\''.get('lang_id').'\'); });
+ </script>';
+ }
+
+ /**
+ * @desc prikazemo skrita ze odgovorjena vprasanja
+ */
+ public function displaySpremenljivkeHidden()
+ {
+
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='" . get('grupa') . "'");
+ $rowg = mysqli_fetch_array($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+
+ echo "\n";
+ echo '<!-- hidden -->' . "\n";
+ echo '<div id="spremenljivke_hidden" style="display:none">' . "\n";
+
+ // pri skritih gledamo za nazaj, in ce smo v loopu ne smemo upostevat trenutnega loopa
+ $loop_id = get('loop_id');
+ save('loop_id', null, 1);
+
+ // Izpisemo vprasanja ki so uporabljena v pogoju in so bila resena na prejsnjih straneh oz. tudi na isti strani ce gre za skupine ali jezike
+ $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND (g.vrstni_red<'$vrstni_red' OR (g.vrstni_red='$vrstni_red' AND s.skupine>'0')) ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($this->inCondition($row['id'])) {
+ $this->displaySpremenljivka($row['id']);
+ }
+ }
+
+ save('loop_id', $loop_id, 1);
+
+ echo '</div>' . "\n";
+ echo '<!-- /hidden -->' . "\n\r\n\r";
+
+ }
+
+ /**
+ * @desc prikaze komentar spremenljivke
+ * shrani se v srv_Data_text, kjer je spr_id=0 in vre_id=$spremenljivka
+ */
+ public function displaySpremenljivkaComment($spremenljivka){
+
+ // Preverimo, ce so komentarji v placljivem paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ if(!$userAccess->checkUserAccess($what='komentarji'))
+ return;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $srv_qct = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_text');
+ $question_resp_comment_show_open = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_show_open');
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_comment = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_question_respondent_comment' . $_lang);
+ $comment = $srv_comment != '' ? $srv_comment : self::$lang['srv_question_respondent_comment'];
+
+ if (get('lang_id') != null) {
+ $qct = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_question_comment_text_' . get('lang_id'));
+ if ($qct != '') $srv_qct = $qct;
+ }
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='0' AND vre_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row = mysqli_fetch_array($sql);
+
+ echo '<div class="comment red" onclick="$(\'#question_resp_comment_' . $spremenljivka . '\').toggle();" >' . $comment . '</div>
+ <div class="variable_holder ' . ($question_resp_comment_show_open == 1 ? 'display_none' : '') . '" id="question_resp_comment_' . $spremenljivka . '">
+ <div class="variabla question_comment">
+ <textarea name="question_comment_' . $spremenljivka . '" id="question_comment_' . $spremenljivka . '">' . $row['text'] . '</textarea>
+ </div>
+ </div>';
+ }
+
+ /**
+ * @desc prikaze spremenljivko
+ */
+ public function displaySpremenljivka($spremenljivka, $offset = 0, $zaporedna = null)
+ {
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $rowl = Language::srv_language_spremenljivka($spremenljivka);
+ if (strip_tags($rowl['naslov']) != '') $row['naslov'] = $rowl['naslov'];
+ if (strip_tags($rowl['info']) != '') $row['info'] = $rowl['info'];
+ if ($rowl['vsota'] != '') $row['vsota'] = $rowl['vsota'];
+
+
+ // da dela tudi userjem brez JS, po defaultu vedno prikazemo vsa vprasanja, ki jih potem skrivamo z JS
+ $display = '';
+
+ // smo v vpogledu in izpisujemo spremenljivko iz loopa
+ $loop_style = (get('loop_id') != null && $_GET['m'] == 'quick_edit') ? ' quick_edit_loop' : '';
+
+ // hidden_default je pri radio buttnu opcija, da je vprasanje skrito, shrani pa se po defaultu prvi odgovor
+
+ if ($row['tip'] == 22 || $row['tip'] == 25 /*|| ($row['tip']==1 && $row['hidden_default']==1)*/) {
+ $display = 'display_none'; // compute ali kvota vprašanje je vedno skrito
+ }
+
+ // Class za tipe ki jih v hitrem urejanju izpisemo v eni vrstici
+ $simple = (!in_array($row['tip'], array(5, 6, 16, 19, 20, 17))) ? ' simple' : '';
+
+ // Class za nagovor - ce ima crto ali ne
+ $nagovor_line = '';
+ if ($row['tip'] == 5) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $nagovorLine = ($spremenljivkaParams->get('nagovorLine') ? $spremenljivkaParams->get('nagovorLine') : 0);
+
+ // Brez crte
+ if ($nagovorLine == 1)
+ $nagovor_line = 'hide_border';
+ // S crto
+ elseif ($nagovorLine == 2)
+ $nagovor_line = 'show_border';
+ }
+
+ /*
+ * V kolikor sistemsk spremenljivka je uporabljena v pogoju, potem preverimo, vrednost odgovora sistemske spremenljivke in omenjen odgovor v našem primeru samo nagovor prikažemo
+ */
+ $display_sistemske = '';
+ $sql_if = sisplet_query("SELECT * FROM srv_branching WHERE element_spr='$spremenljivka'");
+ $row_if = mysqli_fetch_object($sql_if);
+ if (!empty($row_if->parent)) {
+ $sql_condition = sisplet_query("SELECT * FROM srv_condition WHERE if_id='$row_if->parent'");
+ $row_condition = mysqli_fetch_object($sql_condition);
+
+ # V kolikor imamo pogoj, potem preverimo, če je pogoj vezan na sistemske in skrite spremenljivke
+ if (!empty($row_condition)) {
+ $sql_spr_sistem = sisplet_query("SELECT id FROM srv_spremenljivka WHERE id='$row_condition->spr_id' AND sistem=1 AND visible=0");
+ if ($sql_spr_sistem->num_rows > 0)
+ $display_sistemske = 'display_none';
+ }
+
+ $sql_condition_vred = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id='$row_condition->id'");
+ $row_condition_vred = mysqli_fetch_object($sql_condition_vred);
+
+ //preverimo, še če je bilo to vprašanje odgovorjeno in izbrana vrednost odgovora enaka našemu pogoji pri IF stavku
+ $sql_data_cond = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE usr_id='" . get('usr_id') . "' AND spr_id='$row_condition->spr_id'");
+ $row_data_cond = mysqli_fetch_object($sql_data_cond);
+
+ if (!empty($row_data_cond->vre_id) && !empty($row_condition_vred->vre_id) && ($row_data_cond->vre_id == $row_condition_vred->vre_id)) {
+ $display_sistemske = '';
+ }
+ }
+
+
+ if ((self::$admin_type <= $row['dostop'] && self::$admin_type >= 0) || (self::$admin_type == -1 && $row['dostop'] == 4)) {
+ // ok
+ } else {
+ $display = 'display_none'; // user iz sispleta nima dostopa do vprasanja
+ return; // ce damo samo display na none, se npr. v IFih spet pokaze vprasanje...
+ }
+
+
+ if (get('forceShowSpremenljivka')) { // za prikaz spremenljivke v analizi in mogoče še kje
+ $display = '';
+ }
+ echo "\n\r\n\r";
+ echo ' <!-- spremenljivka -->' . "\n";
+ echo ' <div id="spremenljivka_' . $spremenljivka . '" class="spremenljivka ' . $simple . ' ' . $nagovor_line . ' tip_' . $row['tip'] . ' ' . $loop_style . ' ' . $display . $display_sistemske . ($row['dostop'] < 4 ? ' limited' : '') . '" data-vrstni_red="' . $row['vrstni_red'] . '">' . "\n";
+
+ // izpis tekstovnega pogoja
+ if (isset($_GET['displayifs']) && $_GET['displayifs'] == '1') {
+ $b = new Branching(get('anketa'));
+ $parents = $b->get_parents($row['id']);
+
+ $parents = explode('p_', $parents);
+ foreach ($parents AS $key => $val) {
+ if (is_numeric(trim($val))) {
+ $parents[$key] = (int)$val;
+ } else {
+ unset($parents[$key]);
+ }
+ }
+
+ echo '<div>';
+ foreach ($parents AS $if) {
+ echo '<p>';
+ $b->conditions_display($if);
+ $b->blocks_display($if);
+ echo '</p>';
+ }
+ echo '</div>';
+ }
+
+ echo ' <input type="hidden" name="visible_' . $spremenljivka . '" id="visible_' . $spremenljivka . '" value="' . ($display == '' || $row['hidden_default'] == 1 ? '1' : '0') . '">' . "\n";
+
+ $oblika = array();
+
+ $oblika['orientation'] = $row['orientation'];
+
+ // pri multigridu ne pustimo spremembe orientacije - spremembe ne pustimo tudi ce je resevalec mobitl
+ if (($row['orientation'] == 0 || $row['orientation'] == 2)
+ && $row['tip'] != 6 && $row['tip'] != 16 && $row['tip'] != 19 && $row['tip'] != 20
+ && get('mobile') == 0
+ ) {
+
+ // ce ni besedilo
+ if($row['tip'] != 21){
+ $oblika['cssFloat'] = ' floatLeft';
+ }
+ // ce je besedilo in postavitev vodoravno ob vprasanju
+ else{
+ $oblika['cssFloat'] = ' besediloObVprasanju';
+ }
+
+ // ce je vodoravno ob vprasanju
+ if ($row['orientation'] == 0) {
+ $oblika['divClear'] = '';
+ }
+ // ce je vodoravno pod vprasanjem
+ else {
+ $oblika['divClear'] = 'clr';
+ $oblika['cssLineBreak'] = '<br>';
+ }
+ }
+ else {
+ $oblika['cssFloat'] = '';
+ $oblika['divClear'] = 'clr';
+ }
+
+ // datapiping
+ $row['naslov'] = Helper::dataPiping($row['naslov']);
+
+ // izpisemo statistiko za radio, checkbox, dropdown in multigrid
+ if ($row['stat'] == 1 && ($row['tip'] <= 3 || $row['tip'] == 6)) {
+ echo ' <div id="stat_' . $spremenljivka . '" class="stat">' . "\n";
+ echo ' </div>' . "\n";
+ }
+
+ // stevilcenje
+ if ((SurveyInfo::getInstance()->getSurveyCountType() > 0 || isset($_GET['displayvariables']) && $_GET['displayvariables'] > 0) && get('forceShowSpremenljivka') == false) {
+ echo '<div class="counter">';
+ if (SurveyInfo::getInstance()->getSurveyCountType() == 1) {
+ echo $zaporedna + $offset . ")&nbsp;";
+ }
+ if (SurveyInfo::getInstance()->getSurveyCountType() == 2 || isset($_GET['displayvariables']) && $_GET['displayvariables'] == 1) {
+ echo strip_tags($row['variable']) . '&nbsp;-&nbsp;';
+ }
+ if (SurveyInfo::getInstance()->getSurveyCountType() == 3) {
+ echo $zaporedna + $offset . ")&nbsp;" . strip_tags($row['variable']) . '&nbsp;-&nbsp;';
+ }
+ echo '</div>';
+ }
+
+
+ echo '<div class="naslov ' . $oblika['cssFloat'] . '">';
+
+ if ($row['reminder'] > 0) // statusi: reminder, in še kaj
+ echo '<span class="reminder">*</span>';
+
+ echo $row['naslov'];
+ if ($row['info'] != '')
+ echo '<p class="spremenljivka_info">' . $row['info'] . '</p>';
+
+ echo '</div>';
+
+ // nagovor nima nicesar
+ if ($row['tip'] != 5) {
+
+ // ce je besedilo in postavitev vodoravno ob vprasanju
+ if($row['tip'] == 21 && $row['orientation'] == 0){
+ echo '<div class="variable_holder besediloObVprasanju ' . $oblika['divClear'] . '" ' . ($row['hidden_default'] == 1 ? 'style="display:none"' : '') . '>';
+ }
+ else{
+ // ce je postavitev vodoravno pod vprasanjem
+ if($row['orientation'] == 2){
+ echo '<div class="variable_holder vodoravno_pod_vprasanjem '.$oblika['divClear'].'" '.($row['hidden_default'] == 1 ? 'style="display:none"' : '').'>';
+ }
+ // ce je postavitev vodoravno ob vprasanju
+ elseif($row['orientation'] == 0){
+ echo '<div class="variable_holder vodoravno_ob_vprasanju '.$oblika['divClear'].'" '.($row['hidden_default'] == 1 ? 'style="display:none"' : '').'>';
+ }
+ else{
+ //echo '<div class="variable_holder '.$oblika['divClear'].'" ' . ($row['hidden_default'] == 1 ? 'style="display:none"' : 'style="display:inline"').'>';
+ echo '<div class="variable_holder '.$oblika['divClear'].'" ' . ($row['hidden_default'] == 1 ? 'style="display:none"' : '').'>';
+ }
+ }
+
+ if ($rowa['mass_insert'] == '1' && $_GET['m'] != 'quick_edit')
+ $this->displayMassVnos($spremenljivka, $oblika);
+ else
+ $this->displayVnos($spremenljivka, $oblika);
+
+ echo '</div>';
+ }
+
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment') == 1 &&
+ get('forceShowSpremenljivka') == false &&
+ !$_GET['hidecomment'] == 1 &&
+ ($_GET['preview'] == 'on' && $_GET['testdata'] == 'on')
+ ) {
+ $this->displaySpremenljivkaComment($spremenljivka);
+ }
+
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+
+ // timer na spremenljivki
+ if ($row['timer'] > 0 && $row['gru_id'] == $_GET['grupa']) {
+ echo '<script>' . "\n";
+ echo 'setTimeout(\'submitForm()\', ' . ($row['timer'] * 1000) . ');' . "\n";
+ echo '</script>' . "\n";
+ }
+ else if ((int)$row['timer'] > 0 && SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+ echo '<script>' . "\n";
+ # če smo v prezentaciji in imamo nastavljen autostart
+
+ # če smo na prvi strani in mamo nastavljen autostart z timerjem
+ if (!isset($_GET['grupa']) && ($ss_setings['autostart'] == 1 || $ss_setings['autostart'] == 3)) {
+ echo 'setTimeout(\'submitForm()\', ' . ($row['timer'] * 1000) . ');' . "\n";
+ }
+ if (!isset($_GET['grupa']) && ((int)$ss_setings['autostart'] == 2 || (int)$ss_setings['autostart'] == 3)) {
+ echo '$(".spremenljivka").addClass("pointer");' . "\n";
+ # autostart z klikom
+ echo '$(".spremenljivka").live("click", function(event) {submitForm()});' . "\n";
+ }
+ echo ' </script>' . "\n";
+ }
+
+ echo '</div>'; // spremenljivka
+ }
+
+ /**
+ * preveri, ce se spremenljivka pojavi v katerem izmed pogojev, da jo je potrebno izpisati
+ *
+ * @param mixed $spremenljivka
+ */
+ private function inCondition($spremenljivka)
+ {
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_condition WHERE spr_id='$spremenljivka'");
+ $row = mysqli_fetch_array($sql);
+ if ($row['count'] > 0)
+ return true;
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_calculation WHERE spr_id='$spremenljivka'");
+ $row = mysqli_fetch_array($sql);
+ if ($row['count'] > 0)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * prikaze vnos spremenljivke za masovno vnasanje vprasalnika
+ *
+ * @param mixed $spremenljivka
+ * @param mixed $oblika
+ */
+ function displayMassVnos($spremenljivka, $oblika)
+ {
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ switch ($row['tip']) {
+ case 1:
+ case 3:
+ $sql = sisplet_query("SELECT id, vrstni_red FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other='1' ORDER BY vrstni_red ASC");
+ $input = '';
+ $js = '';
+ while ($row = mysqli_fetch_array($sql)) {
+ $input .= ' <input type="text" name="textfield_' . $row['id'] . '" style="display:none" id="textfield_' . $row['id'] . '">';
+ $js .= ' if (this.value == \'' . $row['vrstni_red'] . '\') document.getElementById(\'textfield_' . $row['id'] . '\').style.display = \'inline\'; else document.getElementById(\'textfield_' . $row['id'] . '\').style.display = \'none\'; ';
+ }
+ echo '<input type="text" name="vrednost_' . $spremenljivka . '" onkeyup="checkBranching(); ' . $js . '" id="vrednost_' . $spremenljivka . '">';
+ echo $input;
+ break;
+
+ case 2:
+ $sql = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red ASC");
+ echo '<table>';
+ while ($row = mysqli_fetch_array($sql)) {
+ echo '<tr><td>' . $row['naslov'] . '</td><td><input type="text" name="vrednost_' . $spremenljivka . '[]" onkeyup="checkBranching();" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $row['id'] . '"></td>';
+ if ($row['other'] == 1) echo '<td><input type="text" name="textfield_' . $row['id'] . '"></td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+ break;
+
+ case 6:
+ $sql = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red ASC");
+ echo '<table>';
+ while ($row = mysqli_fetch_array($sql)) {
+ echo '<tr><td>' . $row['naslov'] . '</td><td><input type="text" name="vrednost_' . $row['id'] . '" onkeyup="checkBranching();" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $row['id'] . '"></td>';
+ if ($row['other'] == 1) echo '<td><input type="text" name="textfield_' . $row['id'] . '"></td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+ break;
+
+ default:
+ $this->displayVnos($spremenljivka, $oblika);
+ break;
+ }
+ }
+
+ /**
+ * @desc prikaze polja za vnos
+ */
+ function displayVnos($spremenljivka, $oblika = null)
+ {
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ // Pridobimo parametre
+ // nalozimo parametre spremenljivke
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ // Izrisemo ustrezno vsebino vprasanja glede na tip
+ switch($row['tip']){
+
+ // Radio, checkbox, dropdown
+ case 1:
+ case 2:
+ case 3:
+
+ if ($row['orientation'] != 8 && $row['orientation'] != 10) {
+ RadioCheckboxSelect::getInstance()->display($spremenljivka, $oblika);
+ }
+ elseif ($row['orientation'] == 8) {
+ if(get('mobile') == 1)
+ RadioCheckboxSelect::getInstance()->display($spremenljivka, $oblika);
+ else
+ DragDrop::getInstance()->display($spremenljivka);
+ }
+ elseif($row['orientation'] == 10){
+ HotSpot::getInstance()->display($spremenljivka);
+ }
+
+ break;
+
+
+ // Tabela - radio
+ case 6:
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // Izris multigrida s postopnim resevanjem
+ if($row['dynamic_mg'] > 0 && !get('printPreview')){
+
+ if ($row['dynamic_mg'] == 1 || $row['dynamic_mg'] == 3 || $row['dynamic_mg'] == 5)
+ Dynamic::getInstance()->multigrid($spremenljivka);
+ else
+ Dynamic::getInstance()->verticalMultigrid($spremenljivka);
+ }
+ // Izris radio multigrida na mobitelu
+ elseif (get('mobile') == 1 && $mobile_tables > 0) {
+
+ // Dvojni multigrid
+ if($row['enota'] == 3)
+ MultigridMobile::getInstance()->radioDoubleMultigrid($spremenljivka);
+ else
+ MultigridMobile::getInstance()->radioMultigrid($spremenljivka);
+ }
+ // Ostali podtipi tabel
+ else{
+
+ // Izris glede na podtip
+ switch($row['enota']){
+
+ // Multigrid z dropdownom
+ case 2:
+ Multigrid::getInstance()->dropdown($spremenljivka);
+ break;
+
+ // Dvojni multigrid
+ case 3:
+ Double::getInstance()->grid($spremenljivka);
+ break;
+
+ // OneAgainstAnother
+ case 4:
+ OneAgainstAnother::getInstance()->display($spremenljivka);
+ break;
+
+ // MaxDiff
+ case 5:
+ MaxDiff::getInstance()->display($spremenljivka);
+ break;
+
+ // SelectBox
+ case 6:
+ Multigrid::getInstance()->selectBox($spremenljivka);
+ break;
+
+ // Grid drag and drop
+ case 9:
+ DragDrop::getInstance()->grid($spremenljivka);
+ break;
+
+ // Image hotspot za radio grid
+ case 10:
+ HotSpot::getInstance()->grid($spremenljivka);
+ break;
+
+ // Navaden multigrid
+ default:
+ Multigrid::getInstance()->display($spremenljivka);
+ break;
+ }
+ }
+
+ break;
+
+
+ // Tabela - checkbox
+ case 16:
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // Izris checkbox multigrida na mobitelu
+ if (get('mobile') == 1 && $mobile_tables > 0) {
+
+ // Dvojni multigrid
+ if($row['enota'] == 3)
+ MultigridMobile::getInstance()->checkboxDoubleMultigrid($spremenljivka);
+ else
+ MultigridMobile::getInstance()->checkboxMultigrid($spremenljivka);
+ }
+ // Izris glede na podtip
+ else{
+ switch($row['enota']){
+
+ // Dvojni multicheckboxa
+ case 3:
+ Double::getInstance()->checkGrid($spremenljivka);
+ break;
+
+ // SelectBox
+ case 6:
+ Multigrid::getInstance()->selectBox($spremenljivka);
+ break;
+
+ // Navaden checkbox
+ case 0:
+ Multigrid::getInstance()->checkbox($spremenljivka);
+ break;
+
+ // Grid drag and drop
+ case 9:
+ DragDrop::getInstance()->grid($spremenljivka);
+ break;
+ }
+ }
+
+ break;
+
+
+ // Tabela - multitext in multinumber
+ case 19:
+ case 20:
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // Izris text in number multigrida na mobitelu
+ if (get('mobile') == 1 && $mobile_tables > 0) {
+ MultigridMobile::getInstance()->textMultigrid($spremenljivka);
+ }
+ // Izris navadnega text in number multigrida
+ else{
+ Text::getInstance()->multitext($spremenljivka);
+ }
+
+ break;
+
+
+ // Multi Tabela
+ case 24:
+ Multigrid::getInstance()->multiple($spremenljivka);
+ break;
+
+
+ // Textbox - tega ni vec... naj zaenkrat se ostane za kaksno staro anketo...
+ case 4:
+
+ echo '<div class="variabla ' . $oblika['cssFloat'] . '">';
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $taSize = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1);
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ //default sirina
+ if ($taWidth == -1)
+ $taWidth = 30;
+
+ if ($taSize > 1)
+ echo ' <textarea name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" rows="' . $taSize . '" style="width: ' . $taWidth . 'em;" onkeyup="checkBranching();"' . ($selected ? ' disabled' : '') . '>' . $row1['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" style="width: ' . $taWidth . 'em;" onkeyup="checkBranching();" value="' . $row1['text'] . '" ' . ($selected ? ' disabled' : '') . '>';
+ echo '</div>';
+
+ SystemVariable::getInstance()->display($spremenljivka, $oblika);
+
+ break;
+
+
+ // Textbox
+ case 21:
+ Text::getInstance()->textbox($spremenljivka, $oblika);
+ break;
+
+
+ // Number
+ case 7:
+ Number::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Datum
+ case 8:
+ Datum::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Generator imen (SN)
+ case 9:
+ Imena::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Ranking
+ case 17:
+
+ // Image hotspot ranking
+ if($row['design'] == 3){
+ HotSpot::getInstance()->ranking($spremenljivka, $oblika);
+ }
+ else{
+ Ranking::getInstance()->display($spremenljivka, $oblika);
+ }
+
+ break;
+
+
+ // Vsota
+ case 18:
+ Vsota::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Compute
+ case 22:
+ Compute::getInstance()->display($spremenljivka);
+ break;
+
+
+ // Kvota
+ case 25:
+ Quota::getInstance()->display($spremenljivka);
+ break;
+
+
+ // Maps / lokacija
+ case 26:
+ Maps::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // HeatMap
+ case 27:
+ HeatMap::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Nagovor - prazno
+ case 5:
+ default:
+ break;
+ }
+ }
+
+}
diff --git a/main/survey/app/Controllers/Vprasanja/VsotaController.php b/main/survey/app/Controllers/Vprasanja/VsotaController.php
new file mode 100644
index 0000000..ad79de7
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/VsotaController.php
@@ -0,0 +1,112 @@
+<?php
+/***************************************
+ * Description: Vsota
+ *
+ * Vprašanje je prisotno:
+ * tip 18
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+class VsotaController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new VsotaController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql1 = sisplet_query("SELECT id, naslov, if_id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ $max = mysqli_num_rows($sql1);
+ $counter = 0;
+ $sum = 0;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row2 = mysqli_fetch_array($sql2);
+
+ //preverjanje skritega vprasanja(-2)
+ $row2['text'] != -2 ? $text = $row2['text'] : $text = '';
+
+
+ echo '<div class="variabla_sum width_' . $gridWidth . '" id="vrednost_if_' . $row1['id'] . '" ' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . '>';
+ //echo ' <label for="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '">' . $row1['naslov'] . '</label>';
+ //echo ' <label style="width:200px;display: inline-block;" for="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '">' . $row1['naslov'] . '</label>';
+ echo ' <label class="vsota_besedilo" for="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '">' . $row1['naslov'] . '</label>';
+ echo ' <input type="text" name="spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '" value="' . $text . '" onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); calcSum(' . $spremenljivka . ', ' . $max . ', ' . $row['vsota_limit'] . ');" onBlur="checkBranching();" ' . ($selected ? ' disabled' : '') . '>';
+
+ echo '</div>' . "\n";
+ $counter++;
+ $sum += (double)$text;
+ }
+
+ if ($row['vsota_limit'] != 0 && $row['vsota_limit'] == $row['vsota_min'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['vsota_limit'] != 0 && $row['vsota_min'] != 0)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['vsota_limit'] != 0)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ elseif ($row['vsota_min'] != 0)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+
+ $rowl = Language::srv_language_spremenljivka($spremenljivka);
+ if ($rowl['vsota'] != '') $row['vsota'] = $rowl['vsota'];
+ if ($row['vsota'] == '') $row['vsota'] = self::$lang['srv_vsota_text'];
+
+ echo '<div class="variabla_sum width_' . $gridWidth . ' sum" id="vsota_' . $row['id'] . '">';
+ //echo ' <label for="spremenljivka_' . $spremenljivka . '_vsota">' . $row['vsota'] . '</label>';
+ //echo ' <label style="width:200px;display: inline-block;" for="spremenljivka_' . $spremenljivka . '_vsota">' . $row['vsota'] . '</label>';
+ echo ' <label class="vsota_besedilo" for="spremenljivka_' . $spremenljivka . '_vsota">' . $row['vsota'] . '</label>';
+ echo ' <input type="text" name="spremenljivka_' . $spremenljivka . '_vsota_' . $row['id'] . '" id="spremenljivka_' . $spremenljivka . '_vsota" value="' . $sum . '" disabled class="def">';
+ echo '</div>' . "\n";
+
+ if ($row['vsota_show'] == 1)
+ echo ' <label class="limit_vsota">' . $limit . '</label>';
+
+ }
+} \ No newline at end of file