summaryrefslogtreecommitdiffstats
path: root/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php
diff options
context:
space:
mode:
Diffstat (limited to 'main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php')
-rw-r--r--main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php291
1 files changed, 291 insertions, 0 deletions
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