summaryrefslogtreecommitdiffstats
path: root/main/survey/app/Controllers/Vprasanja
diff options
context:
space:
mode:
Diffstat (limited to 'main/survey/app/Controllers/Vprasanja')
-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
21 files changed, 12348 insertions, 0 deletions
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