summaryrefslogtreecommitdiffstats
path: root/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php
blob: 5c93cf73336bfdb1277d47ee5858f168395ed195 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
<?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 (isset($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 . '"><span class="variabla_text">' . $row1['naslov'] . '</span></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'] . '" class="input_other" 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'] . '" class="input_other" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_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);
                    //ali so smeskoti pobarvani ali samo sivi
					$colored = ($spremenljivkaParams->get('visual_type') == 1 ? 'colored' : '');

                    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(): '').' '.$colored.'"></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 '<span class="variabla_text">' . $row1['naslov'] . '</span></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 '<span class="variabla_text">' . $row1['naslov'] . '</span></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 '<tr>';
                    echo '<td><label for="' . $_id . '"><span class="variabla_text">' . $row1['naslov'] . '</span></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'] . '" class="input_other" 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'] . '" class="input_other" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_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'] . '" class="input_other" 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'] . '" class="input_other" 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="input_other 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="input_other 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>
                <?
            }
        }

    }


}