From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- .../Controllers/Vprasanja/MaxDiffController.php | 295 +++++++++++++++++++++ 1 file changed, 295 insertions(+) create mode 100644 main/survey/app/Controllers/Vprasanja/MaxDiffController.php (limited to 'main/survey/app/Controllers/Vprasanja/MaxDiffController.php') 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 @@ +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 '' . "\n"; + + + echo ''; + echo ' ' . "\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 ' ' . "\n"; + $first_missing_value = false; + } + + // Datapiping + $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']); + + # izpišemo labelo grida + echo ' ' . "\n"; + //echo ' '."\n"; + + if ($i == 1) { + echo ' ' . "\n"; + } + + + } + } + + echo ' ' . "\n"; + echo ''; + + echo ''; + + $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 ' ' . "\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 ' ' . "\n"; + $first_missing_value = false; + } + + $value = $srv_grids[$i]['id']; + + # izpišemo radio grida + if ($srv_grid['other'] != 0) { + echo '' . "\n"; + + if ($i == 1) { + echo ' ' . "\n"; + } + + + } else { + echo '' . "\n"; + + //urejanje navpicnega dela grupiranja radio button - vodoravni je urejen po defaultu s pomočjo atributa name + echo ' + + '; + + if ($i == 1) { + echo ' '; + } + } + } + } + + echo ' ' . "\n"; + + $bg++; + } + + echo ''; + + echo '
' . $srv_grid['naslov'] . '
'; + # imamo missing vrednost + echo ''; + echo ''; + 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 ' '; + else + echo ' '; + } + echo ''; + # ni missing vrednost + echo ''; + echo ''; + 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 ' '; + else + echo ' '; + } + + echo '
' . "\n"; + } + +} \ No newline at end of file -- cgit v1.2.3