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
|
<?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 . ')';
//**************************************************************************************************
//***************************
$limit = ''; $limit2 = '';
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'] . ')';
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'] . ')';
}
# 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)
$text = (isset($row1['text']) && $row1['text'] != -1) ? $row1['text'] : '';
$text2 = (isset($row1['text2']) && $row1['text2'] != -1) ? $row1['text2'] : '';
$value[1] = (isset($row1['text']) && $row1['text'] != -1) ? $row1['text']: '';
$value[2] = (isset($row1['text2']) && $row1['text2'] != -1) ? $row1['text2']: '';
$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>';
}
# če imamo enoto na levi jo izpišemo
if ($row['enota'] == 1) {
echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $row2['vrstni_red'] . '" ' . ($row['ranking_k'] == '1' && get('mobile') == 0 ? ' style="display:none;"' : '') . '>';
echo $naslov;
echo '</label>';
}
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 '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $row2['vrstni_red'] . '" ' . ($row['ranking_k'] == '1' && get('mobile') == 0 ? ' style="display:none;"' : '') . '>';
echo $naslov;
echo '</label>';
}
} else {
# imamo polje drugo - ne vem, zavrnil...
$array_others[$row2['id']] = array(
'naslov' => $naslov,
'vrstni_red' => $row2['vrstni_red'],
'value' => (isset($text[$row2['vrstni_red']]) ? $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){
$slider_CustomDescriptiveLabels = '';
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| /",' ',$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 (isset($srv_data_vrednost[$oKey]) && $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'];
echo ' </label>';
echo '</div>';
}
}
SystemVariable::display($spremenljivka, $oblika);
}
}
|