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 --- main/.htaccess | 1 + main/survey/ajax.php | 33 + main/survey/app/.htaccess | 3 + main/survey/app/Controllers/AjaxController.php | 708 + main/survey/app/Controllers/BodyController.php | 2458 +++ main/survey/app/Controllers/CheckController.php | 774 + main/survey/app/Controllers/Controller.php | 113 + main/survey/app/Controllers/DisplayController.php | 864 + main/survey/app/Controllers/FindController.php | 290 + main/survey/app/Controllers/HeaderController.php | 920 + main/survey/app/Controllers/HelperController.php | 747 + main/survey/app/Controllers/InitClass.php | 1230 ++ main/survey/app/Controllers/JsController.php | 2835 +++ main/survey/app/Controllers/LanguageController.php | 196 + .../survey/app/Controllers/StatisticController.php | 282 + main/survey/app/Controllers/SurveyController.php | 76 + main/survey/app/Controllers/VariableClass.php | 193 + .../Controllers/Vprasanja/ComputeController.php | 55 + .../app/Controllers/Vprasanja/DatumController.php | 187 + .../app/Controllers/Vprasanja/DoubleController.php | 841 + .../Controllers/Vprasanja/DragDropController.php | 914 + .../Controllers/Vprasanja/DynamicController.php | 725 + .../Controllers/Vprasanja/HeatMapController.php | 242 + .../Vprasanja/ImageHotSpotController.php | 856 + .../app/Controllers/Vprasanja/ImenaController.php | 160 + .../app/Controllers/Vprasanja/MapsController.php | 364 + .../Controllers/Vprasanja/MaxDiffController.php | 295 + .../Controllers/Vprasanja/MultigridController.php | 1686 ++ .../Vprasanja/MultigridMobileController.php | 1621 ++ .../app/Controllers/Vprasanja/NumberController.php | 372 + .../Vprasanja/OneAgainstAnotherController.php | 291 + .../app/Controllers/Vprasanja/QuotaController.php | 57 + .../Vprasanja/RadioCheckboxSelectController.php | 521 + .../Controllers/Vprasanja/RankingController.php | 1021 + .../Vprasanja/SystemVariableController.php | 62 + .../app/Controllers/Vprasanja/TextController.php | 1022 + .../Controllers/Vprasanja/VprasanjaController.php | 944 + .../app/Controllers/Vprasanja/VsotaController.php | 112 + main/survey/app/Models/Model.php | 308 + main/survey/app/Models/SaveSurvey.php | 1628 ++ main/survey/app/Models/User.php | 58 + main/survey/app/bootstrap.php | 104 + main/survey/app/config.php | 49 + main/survey/app/global_function.php | 70 + main/survey/app/use_classes.php | 59 + main/survey/download.php | 48 + main/survey/edit_anketa.php | 29 + main/survey/embed_out.php | 9 + main/survey/image.php | 410 + main/survey/index.php | 41 + main/survey/js/ChartJS/Chart.bundle.js | 18608 +++++++++++++++++++ main/survey/js/ChartJS/Chart.bundle.min.js | 10 + main/survey/js/ChartJS/Chart.js | 14145 ++++++++++++++ main/survey/js/ChartJS/Chart.min.js | 10 + main/survey/js/ChartJS/chart_init.js | 260 + main/survey/js/DragDrop/dragdrop.js | 1550 ++ main/survey/js/DragDrop/dragdropbox.js | 951 + main/survey/js/Fotografiranje/FotoDeclaration.js | 82 + main/survey/js/Fotografiranje/webcam.js | 833 + main/survey/js/Fotografiranje/webcam.swf | Bin 0 -> 7090 bytes main/survey/js/HeatMap/HeatMapCanvas.js | 285 + main/survey/js/HeatMap/heatmap4Respondents.js | 13 + main/survey/js/ImageHotSpot/imagemapRespondent.js | 859 + main/survey/js/Maps/Geocoding.js | 92 + main/survey/js/Maps/KlikNaMapo.js | 43 + main/survey/js/Maps/MapDeclaration.js | 323 + main/survey/js/Maps/Markers.js | 317 + main/survey/js/Maps/SearchBox.js | 78 + main/survey/js/Maps/ShapeDrawing.js | 397 + main/survey/js/Maps/UserLocation.js | 94 + main/survey/js/custom_column_label_respondent.js | 98 + main/survey/js/customizeImageView4Respondent.js | 355 + main/survey/js/dhtmlgoodies_calendar.js | 1518 ++ main/survey/js/script.js | 1971 ++ main/survey/js/signature/LICENSE.txt | 27 + main/survey/js/signature/flashcanvas.js | 28 + main/survey/js/signature/flashcanvas.swf | Bin 0 -> 21235 bytes main/survey/js/signature/jquery.signaturepad.js | 895 + main/survey/js/signature_pad.js | 323 + main/survey/js/tooltipster.min.js | 1 + main/survey/js/trak_respondent.js | 67 + main/survey/mobile-detect/Mobile_Detect.php | 767 + main/survey/sa_koda.php | 45 + main/survey/skins/1ka.css | 256 + main/survey/skins/1ka/close.png | Bin 0 -> 275 bytes main/survey/skins/1ka/header.png | Bin 0 -> 87 bytes main/survey/skins/1ka/header_new.png | Bin 0 -> 89 bytes main/survey/skins/1ka/header_new2.png | Bin 0 -> 3574 bytes main/survey/skins/1ka/logo.png | Bin 0 -> 758 bytes main/survey/skins/1ka/logo_full.png | Bin 0 -> 3178 bytes main/survey/skins/1ka/logo_full_ang.png | Bin 0 -> 3041 bytes main/survey/skins/1ka/logo_full_old.png | Bin 0 -> 2522 bytes main/survey/skins/1ka/plus.png | Bin 0 -> 290 bytes main/survey/skins/1kaBlack.css | 529 + main/survey/skins/1kaBlue.css | 529 + main/survey/skins/1kaGreen.css | 529 + main/survey/skins/1kaGrey.css | 442 + main/survey/skins/1kaNature.css | 564 + main/survey/skins/1kaNature/bg1.jpg | Bin 0 -> 139961 bytes main/survey/skins/1kaNature/bg10.jpg | Bin 0 -> 446729 bytes main/survey/skins/1kaNature/bg11.jpg | Bin 0 -> 356184 bytes main/survey/skins/1kaNature/bg12.jpg | Bin 0 -> 114309 bytes main/survey/skins/1kaNature/bg13.jpg | Bin 0 -> 256582 bytes main/survey/skins/1kaNature/bg14.jpg | Bin 0 -> 191577 bytes main/survey/skins/1kaNature/bg15.jpg | Bin 0 -> 207375 bytes main/survey/skins/1kaNature/bg2.jpg | Bin 0 -> 206042 bytes main/survey/skins/1kaNature/bg3.jpg | Bin 0 -> 238650 bytes main/survey/skins/1kaNature/bg4.jpg | Bin 0 -> 347652 bytes main/survey/skins/1kaNature/bg5.jpg | Bin 0 -> 455253 bytes main/survey/skins/1kaNature/bg6.jpg | Bin 0 -> 490365 bytes main/survey/skins/1kaNature/bg7.jpg | Bin 0 -> 247379 bytes main/survey/skins/1kaNature/bg8.jpg | Bin 0 -> 275981 bytes main/survey/skins/1kaNature/bg9.jpg | Bin 0 -> 434561 bytes main/survey/skins/1kaOffice.css | 564 + main/survey/skins/1kaOffice/bg1.jpg | Bin 0 -> 143807 bytes main/survey/skins/1kaOffice/bg10.jpg | Bin 0 -> 223837 bytes main/survey/skins/1kaOffice/bg11.jpg | Bin 0 -> 98822 bytes main/survey/skins/1kaOffice/bg12.jpg | Bin 0 -> 246860 bytes main/survey/skins/1kaOffice/bg13.jpg | Bin 0 -> 259740 bytes main/survey/skins/1kaOffice/bg14.jpg | Bin 0 -> 264281 bytes main/survey/skins/1kaOffice/bg15.jpg | Bin 0 -> 109271 bytes main/survey/skins/1kaOffice/bg2.jpg | Bin 0 -> 127853 bytes main/survey/skins/1kaOffice/bg3.jpg | Bin 0 -> 85775 bytes main/survey/skins/1kaOffice/bg4.jpg | Bin 0 -> 142542 bytes main/survey/skins/1kaOffice/bg5.jpg | Bin 0 -> 226242 bytes main/survey/skins/1kaOffice/bg6.jpg | Bin 0 -> 110841 bytes main/survey/skins/1kaOffice/bg7.jpg | Bin 0 -> 110699 bytes main/survey/skins/1kaOffice/bg8.jpg | Bin 0 -> 64086 bytes main/survey/skins/1kaOffice/bg9.jpg | Bin 0 -> 111881 bytes main/survey/skins/1kaOrange.css | 529 + main/survey/skins/1kaPurple.css | 529 + main/survey/skins/1kaRed.css | 529 + main/survey/skins/1ka_customsortables.css | 286 + main/survey/skins/1ka_customsortables/close.png | Bin 0 -> 275 bytes main/survey/skins/1ka_customsortables/header.png | Bin 0 -> 87 bytes .../skins/1ka_customsortables/header_new.png | Bin 0 -> 89 bytes .../skins/1ka_customsortables/header_new2.png | Bin 0 -> 3574 bytes main/survey/skins/1ka_customsortables/logo.png | Bin 0 -> 758 bytes .../survey/skins/1ka_customsortables/logo_full.png | Bin 0 -> 3178 bytes .../skins/1ka_customsortables/logo_full_ang.png | Bin 0 -> 3041 bytes .../skins/1ka_customsortables/logo_full_old.png | Bin 0 -> 2522 bytes main/survey/skins/1ka_customsortables/plus.png | Bin 0 -> 290 bytes main/survey/skins/Classic.css | 243 + main/survey/skins/Classic2.css | 244 + main/survey/skins/Classic3.css | 239 + main/survey/skins/Classic4.css | 240 + main/survey/skins/Classic5.css | 242 + main/survey/skins/Colorful.css | 127 + main/survey/skins/Default.css | 92 + main/survey/skins/Embed.css | 64 + main/survey/skins/Embed2.css | 72 + main/survey/skins/Fdv.css | 534 + main/survey/skins/Mobile.css | 220 + main/survey/skins/Mobile2.css | 219 + main/survey/skins/Mobile3.css | 219 + main/survey/skins/Mobile4.css | 219 + main/survey/skins/Mobile5.css | 219 + main/survey/skins/MobileBlack.css | 228 + main/survey/skins/MobileBlue.css | 227 + main/survey/skins/MobileCdi.css | 237 + main/survey/skins/MobileFdv.css | 233 + main/survey/skins/MobileGreen.css | 227 + main/survey/skins/MobileOrange.css | 227 + main/survey/skins/MobilePurple.css | 228 + main/survey/skins/MobileRed.css | 228 + main/survey/skins/MobileUni.css | 233 + main/survey/skins/Modern.css | 105 + main/survey/skins/Modern/add.png | Bin 0 -> 733 bytes main/survey/skins/Modern/arrow.png | Bin 0 -> 967 bytes main/survey/skins/Modern/arrowD.png | Bin 0 -> 964 bytes main/survey/skins/Modern/arrowD2.png | Bin 0 -> 3823 bytes main/survey/skins/Modern/arrowL.png | Bin 0 -> 995 bytes main/survey/skins/Modern/arrowL2.png | Bin 0 -> 3782 bytes main/survey/skins/Modern/arrowR.png | Bin 0 -> 991 bytes main/survey/skins/Modern/arrowR2.png | Bin 0 -> 3798 bytes main/survey/skins/Modern/arrowU.png | Bin 0 -> 878 bytes main/survey/skins/Modern/arrowU2.png | Bin 0 -> 3733 bytes main/survey/skins/Modern/background.jpg | Bin 0 -> 366 bytes main/survey/skins/Modern/blue_delete.png | Bin 0 -> 715 bytes main/survey/skins/Oko.css | 328 + main/survey/skins/Oko2.css | 328 + main/survey/skins/Otroci.css | 329 + main/survey/skins/Otroci/nadaljuj-kasneje.png | Bin 0 -> 3814 bytes main/survey/skins/Otroci/otroci-3-desno.png | Bin 0 -> 17420 bytes main/survey/skins/Otroci/otroci-3-footer.png | Bin 0 -> 2127 bytes main/survey/skins/Otroci/otroci-3-levo.png | Bin 0 -> 27907 bytes main/survey/skins/Otroci/otroci-3-top.png | Bin 0 -> 13715 bytes main/survey/skins/Otroci/otroci-4-desno.png | Bin 0 -> 17420 bytes main/survey/skins/Otroci/otroci-4-footer.png | Bin 0 -> 41434 bytes main/survey/skins/Otroci/otroci-4-top.png | Bin 0 -> 13260 bytes main/survey/skins/Otroci/otroci-logo.png | Bin 0 -> 6315 bytes main/survey/skins/Otroci2.css | 329 + main/survey/skins/Otroci3.css | 309 + main/survey/skins/Otroci4.css | 293 + main/survey/skins/Otroci_Safe/nadaljuj-kasneje.png | Bin 0 -> 648 bytes main/survey/skins/Otroci_Safe/otroci-1.png | Bin 0 -> 137 bytes main/survey/skins/Otroci_Safe/otroci-2-figure.png | Bin 0 -> 4127 bytes main/survey/skins/Otroci_Safe/otroci-2.png | Bin 0 -> 137 bytes main/survey/skins/Otroci_Safe/otroci-figure.png | Bin 0 -> 4031 bytes main/survey/skins/Otroci_Safe/otroci-logo.png | Bin 0 -> 6315 bytes main/survey/skins/Slideshow.css | 111 + main/survey/skins/Uni.css | 534 + main/survey/skins/check-radio/box_checked_blue.png | Bin 0 -> 2124 bytes main/survey/skins/check-radio/box_checked_grey.png | Bin 0 -> 1823 bytes main/survey/skins/check-radio/box_empty_blue.png | Bin 0 -> 549 bytes main/survey/skins/check-radio/box_empty_grey.png | Bin 0 -> 619 bytes main/survey/skins/check-radio/icons.png | Bin 0 -> 135673 bytes main/survey/skins/check-radio/icons.psd | Bin 0 -> 623426 bytes .../skins/check-radio/radio_checked_blue.png | Bin 0 -> 2633 bytes .../skins/check-radio/radio_checked_grey.png | Bin 0 -> 2628 bytes .../skins/check-radio/radio_unchecked_blue.png | Bin 0 -> 1506 bytes .../skins/check-radio/radio_unchecked_grey.png | Bin 0 -> 1886 bytes .../survey/skins/check-radio/smiley_happy_blue.png | Bin 0 -> 2487 bytes .../survey/skins/check-radio/smiley_happy_grey.png | Bin 0 -> 2691 bytes main/survey/skins/check-radio/star_blue.png | Bin 0 -> 1970 bytes main/survey/skins/check-radio/star_empty_blue.png | Bin 0 -> 2718 bytes main/survey/skins/check-radio/thumbs_up.png | Bin 0 -> 2171 bytes main/survey/skins/check-radio/thumbs_up_blue.png | Bin 0 -> 2548 bytes main/survey/skins/fdv/fdv.png | Bin 0 -> 7263 bytes main/survey/skins/glasovanje/Classic.css | 58 + main/survey/skins/glasovanje/Modern.css | 45 + main/survey/skins/quiz/false.png | Bin 0 -> 15987 bytes main/survey/skins/quiz/quiz.css | 62 + main/survey/skins/quiz/true.png | Bin 0 -> 16065 bytes main/survey/skins/quiz/true2.png | Bin 0 -> 16128 bytes main/survey/skins/tooltipster/tooltipster.css | 288 + main/survey/skins/uni/uni.png | Bin 0 -> 2831 bytes main/survey/uporabnost.php | 44 + main/survey/view_count.php | 16 + 229 files changed, 85655 insertions(+) create mode 100644 main/.htaccess create mode 100644 main/survey/ajax.php create mode 100644 main/survey/app/.htaccess create mode 100644 main/survey/app/Controllers/AjaxController.php create mode 100644 main/survey/app/Controllers/BodyController.php create mode 100644 main/survey/app/Controllers/CheckController.php create mode 100644 main/survey/app/Controllers/Controller.php create mode 100644 main/survey/app/Controllers/DisplayController.php create mode 100644 main/survey/app/Controllers/FindController.php create mode 100644 main/survey/app/Controllers/HeaderController.php create mode 100644 main/survey/app/Controllers/HelperController.php create mode 100644 main/survey/app/Controllers/InitClass.php create mode 100644 main/survey/app/Controllers/JsController.php create mode 100644 main/survey/app/Controllers/LanguageController.php create mode 100644 main/survey/app/Controllers/StatisticController.php create mode 100644 main/survey/app/Controllers/SurveyController.php create mode 100644 main/survey/app/Controllers/VariableClass.php create mode 100644 main/survey/app/Controllers/Vprasanja/ComputeController.php create mode 100644 main/survey/app/Controllers/Vprasanja/DatumController.php create mode 100644 main/survey/app/Controllers/Vprasanja/DoubleController.php create mode 100644 main/survey/app/Controllers/Vprasanja/DragDropController.php create mode 100644 main/survey/app/Controllers/Vprasanja/DynamicController.php create mode 100644 main/survey/app/Controllers/Vprasanja/HeatMapController.php create mode 100644 main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php create mode 100644 main/survey/app/Controllers/Vprasanja/ImenaController.php create mode 100644 main/survey/app/Controllers/Vprasanja/MapsController.php create mode 100644 main/survey/app/Controllers/Vprasanja/MaxDiffController.php create mode 100644 main/survey/app/Controllers/Vprasanja/MultigridController.php create mode 100644 main/survey/app/Controllers/Vprasanja/MultigridMobileController.php create mode 100644 main/survey/app/Controllers/Vprasanja/NumberController.php create mode 100644 main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php create mode 100644 main/survey/app/Controllers/Vprasanja/QuotaController.php create mode 100644 main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php create mode 100644 main/survey/app/Controllers/Vprasanja/RankingController.php create mode 100644 main/survey/app/Controllers/Vprasanja/SystemVariableController.php create mode 100644 main/survey/app/Controllers/Vprasanja/TextController.php create mode 100644 main/survey/app/Controllers/Vprasanja/VprasanjaController.php create mode 100644 main/survey/app/Controllers/Vprasanja/VsotaController.php create mode 100644 main/survey/app/Models/Model.php create mode 100644 main/survey/app/Models/SaveSurvey.php create mode 100644 main/survey/app/Models/User.php create mode 100644 main/survey/app/bootstrap.php create mode 100644 main/survey/app/config.php create mode 100644 main/survey/app/global_function.php create mode 100644 main/survey/app/use_classes.php create mode 100644 main/survey/download.php create mode 100644 main/survey/edit_anketa.php create mode 100644 main/survey/embed_out.php create mode 100644 main/survey/image.php create mode 100644 main/survey/index.php create mode 100644 main/survey/js/ChartJS/Chart.bundle.js create mode 100644 main/survey/js/ChartJS/Chart.bundle.min.js create mode 100644 main/survey/js/ChartJS/Chart.js create mode 100644 main/survey/js/ChartJS/Chart.min.js create mode 100644 main/survey/js/ChartJS/chart_init.js create mode 100644 main/survey/js/DragDrop/dragdrop.js create mode 100644 main/survey/js/DragDrop/dragdropbox.js create mode 100644 main/survey/js/Fotografiranje/FotoDeclaration.js create mode 100644 main/survey/js/Fotografiranje/webcam.js create mode 100644 main/survey/js/Fotografiranje/webcam.swf create mode 100644 main/survey/js/HeatMap/HeatMapCanvas.js create mode 100644 main/survey/js/HeatMap/heatmap4Respondents.js create mode 100644 main/survey/js/ImageHotSpot/imagemapRespondent.js create mode 100644 main/survey/js/Maps/Geocoding.js create mode 100644 main/survey/js/Maps/KlikNaMapo.js create mode 100644 main/survey/js/Maps/MapDeclaration.js create mode 100644 main/survey/js/Maps/Markers.js create mode 100644 main/survey/js/Maps/SearchBox.js create mode 100644 main/survey/js/Maps/ShapeDrawing.js create mode 100644 main/survey/js/Maps/UserLocation.js create mode 100644 main/survey/js/custom_column_label_respondent.js create mode 100644 main/survey/js/customizeImageView4Respondent.js create mode 100644 main/survey/js/dhtmlgoodies_calendar.js create mode 100644 main/survey/js/script.js create mode 100644 main/survey/js/signature/LICENSE.txt create mode 100644 main/survey/js/signature/flashcanvas.js create mode 100644 main/survey/js/signature/flashcanvas.swf create mode 100644 main/survey/js/signature/jquery.signaturepad.js create mode 100644 main/survey/js/signature_pad.js create mode 100644 main/survey/js/tooltipster.min.js create mode 100644 main/survey/js/trak_respondent.js create mode 100644 main/survey/mobile-detect/Mobile_Detect.php create mode 100644 main/survey/sa_koda.php create mode 100644 main/survey/skins/1ka.css create mode 100644 main/survey/skins/1ka/close.png create mode 100644 main/survey/skins/1ka/header.png create mode 100644 main/survey/skins/1ka/header_new.png create mode 100644 main/survey/skins/1ka/header_new2.png create mode 100644 main/survey/skins/1ka/logo.png create mode 100644 main/survey/skins/1ka/logo_full.png create mode 100644 main/survey/skins/1ka/logo_full_ang.png create mode 100644 main/survey/skins/1ka/logo_full_old.png create mode 100644 main/survey/skins/1ka/plus.png create mode 100644 main/survey/skins/1kaBlack.css create mode 100644 main/survey/skins/1kaBlue.css create mode 100644 main/survey/skins/1kaGreen.css create mode 100644 main/survey/skins/1kaGrey.css create mode 100644 main/survey/skins/1kaNature.css create mode 100644 main/survey/skins/1kaNature/bg1.jpg create mode 100644 main/survey/skins/1kaNature/bg10.jpg create mode 100644 main/survey/skins/1kaNature/bg11.jpg create mode 100644 main/survey/skins/1kaNature/bg12.jpg create mode 100644 main/survey/skins/1kaNature/bg13.jpg create mode 100644 main/survey/skins/1kaNature/bg14.jpg create mode 100644 main/survey/skins/1kaNature/bg15.jpg create mode 100644 main/survey/skins/1kaNature/bg2.jpg create mode 100644 main/survey/skins/1kaNature/bg3.jpg create mode 100644 main/survey/skins/1kaNature/bg4.jpg create mode 100644 main/survey/skins/1kaNature/bg5.jpg create mode 100644 main/survey/skins/1kaNature/bg6.jpg create mode 100644 main/survey/skins/1kaNature/bg7.jpg create mode 100644 main/survey/skins/1kaNature/bg8.jpg create mode 100644 main/survey/skins/1kaNature/bg9.jpg create mode 100644 main/survey/skins/1kaOffice.css create mode 100644 main/survey/skins/1kaOffice/bg1.jpg create mode 100644 main/survey/skins/1kaOffice/bg10.jpg create mode 100644 main/survey/skins/1kaOffice/bg11.jpg create mode 100644 main/survey/skins/1kaOffice/bg12.jpg create mode 100644 main/survey/skins/1kaOffice/bg13.jpg create mode 100644 main/survey/skins/1kaOffice/bg14.jpg create mode 100644 main/survey/skins/1kaOffice/bg15.jpg create mode 100644 main/survey/skins/1kaOffice/bg2.jpg create mode 100644 main/survey/skins/1kaOffice/bg3.jpg create mode 100644 main/survey/skins/1kaOffice/bg4.jpg create mode 100644 main/survey/skins/1kaOffice/bg5.jpg create mode 100644 main/survey/skins/1kaOffice/bg6.jpg create mode 100644 main/survey/skins/1kaOffice/bg7.jpg create mode 100644 main/survey/skins/1kaOffice/bg8.jpg create mode 100644 main/survey/skins/1kaOffice/bg9.jpg create mode 100644 main/survey/skins/1kaOrange.css create mode 100644 main/survey/skins/1kaPurple.css create mode 100644 main/survey/skins/1kaRed.css create mode 100644 main/survey/skins/1ka_customsortables.css create mode 100644 main/survey/skins/1ka_customsortables/close.png create mode 100644 main/survey/skins/1ka_customsortables/header.png create mode 100644 main/survey/skins/1ka_customsortables/header_new.png create mode 100644 main/survey/skins/1ka_customsortables/header_new2.png create mode 100644 main/survey/skins/1ka_customsortables/logo.png create mode 100644 main/survey/skins/1ka_customsortables/logo_full.png create mode 100644 main/survey/skins/1ka_customsortables/logo_full_ang.png create mode 100644 main/survey/skins/1ka_customsortables/logo_full_old.png create mode 100644 main/survey/skins/1ka_customsortables/plus.png create mode 100644 main/survey/skins/Classic.css create mode 100644 main/survey/skins/Classic2.css create mode 100644 main/survey/skins/Classic3.css create mode 100644 main/survey/skins/Classic4.css create mode 100644 main/survey/skins/Classic5.css create mode 100644 main/survey/skins/Colorful.css create mode 100644 main/survey/skins/Default.css create mode 100644 main/survey/skins/Embed.css create mode 100644 main/survey/skins/Embed2.css create mode 100644 main/survey/skins/Fdv.css create mode 100644 main/survey/skins/Mobile.css create mode 100644 main/survey/skins/Mobile2.css create mode 100644 main/survey/skins/Mobile3.css create mode 100644 main/survey/skins/Mobile4.css create mode 100644 main/survey/skins/Mobile5.css create mode 100644 main/survey/skins/MobileBlack.css create mode 100644 main/survey/skins/MobileBlue.css create mode 100644 main/survey/skins/MobileCdi.css create mode 100644 main/survey/skins/MobileFdv.css create mode 100644 main/survey/skins/MobileGreen.css create mode 100644 main/survey/skins/MobileOrange.css create mode 100644 main/survey/skins/MobilePurple.css create mode 100644 main/survey/skins/MobileRed.css create mode 100644 main/survey/skins/MobileUni.css create mode 100644 main/survey/skins/Modern.css create mode 100644 main/survey/skins/Modern/add.png create mode 100644 main/survey/skins/Modern/arrow.png create mode 100644 main/survey/skins/Modern/arrowD.png create mode 100644 main/survey/skins/Modern/arrowD2.png create mode 100644 main/survey/skins/Modern/arrowL.png create mode 100644 main/survey/skins/Modern/arrowL2.png create mode 100644 main/survey/skins/Modern/arrowR.png create mode 100644 main/survey/skins/Modern/arrowR2.png create mode 100644 main/survey/skins/Modern/arrowU.png create mode 100644 main/survey/skins/Modern/arrowU2.png create mode 100644 main/survey/skins/Modern/background.jpg create mode 100644 main/survey/skins/Modern/blue_delete.png create mode 100644 main/survey/skins/Oko.css create mode 100644 main/survey/skins/Oko2.css create mode 100644 main/survey/skins/Otroci.css create mode 100644 main/survey/skins/Otroci/nadaljuj-kasneje.png create mode 100644 main/survey/skins/Otroci/otroci-3-desno.png create mode 100644 main/survey/skins/Otroci/otroci-3-footer.png create mode 100644 main/survey/skins/Otroci/otroci-3-levo.png create mode 100644 main/survey/skins/Otroci/otroci-3-top.png create mode 100644 main/survey/skins/Otroci/otroci-4-desno.png create mode 100644 main/survey/skins/Otroci/otroci-4-footer.png create mode 100644 main/survey/skins/Otroci/otroci-4-top.png create mode 100644 main/survey/skins/Otroci/otroci-logo.png create mode 100644 main/survey/skins/Otroci2.css create mode 100644 main/survey/skins/Otroci3.css create mode 100644 main/survey/skins/Otroci4.css create mode 100644 main/survey/skins/Otroci_Safe/nadaljuj-kasneje.png create mode 100644 main/survey/skins/Otroci_Safe/otroci-1.png create mode 100644 main/survey/skins/Otroci_Safe/otroci-2-figure.png create mode 100644 main/survey/skins/Otroci_Safe/otroci-2.png create mode 100644 main/survey/skins/Otroci_Safe/otroci-figure.png create mode 100644 main/survey/skins/Otroci_Safe/otroci-logo.png create mode 100644 main/survey/skins/Slideshow.css create mode 100644 main/survey/skins/Uni.css create mode 100644 main/survey/skins/check-radio/box_checked_blue.png create mode 100644 main/survey/skins/check-radio/box_checked_grey.png create mode 100644 main/survey/skins/check-radio/box_empty_blue.png create mode 100644 main/survey/skins/check-radio/box_empty_grey.png create mode 100644 main/survey/skins/check-radio/icons.png create mode 100644 main/survey/skins/check-radio/icons.psd create mode 100644 main/survey/skins/check-radio/radio_checked_blue.png create mode 100644 main/survey/skins/check-radio/radio_checked_grey.png create mode 100644 main/survey/skins/check-radio/radio_unchecked_blue.png create mode 100644 main/survey/skins/check-radio/radio_unchecked_grey.png create mode 100644 main/survey/skins/check-radio/smiley_happy_blue.png create mode 100644 main/survey/skins/check-radio/smiley_happy_grey.png create mode 100644 main/survey/skins/check-radio/star_blue.png create mode 100644 main/survey/skins/check-radio/star_empty_blue.png create mode 100644 main/survey/skins/check-radio/thumbs_up.png create mode 100644 main/survey/skins/check-radio/thumbs_up_blue.png create mode 100644 main/survey/skins/fdv/fdv.png create mode 100644 main/survey/skins/glasovanje/Classic.css create mode 100644 main/survey/skins/glasovanje/Modern.css create mode 100644 main/survey/skins/quiz/false.png create mode 100644 main/survey/skins/quiz/quiz.css create mode 100644 main/survey/skins/quiz/true.png create mode 100644 main/survey/skins/quiz/true2.png create mode 100644 main/survey/skins/tooltipster/tooltipster.css create mode 100644 main/survey/skins/uni/uni.png create mode 100644 main/survey/uporabnost.php create mode 100644 main/survey/view_count.php (limited to 'main') diff --git a/main/.htaccess b/main/.htaccess new file mode 100644 index 0000000..b0e37d7 --- /dev/null +++ b/main/.htaccess @@ -0,0 +1 @@ +RewriteEngine Off \ No newline at end of file diff --git a/main/survey/ajax.php b/main/survey/ajax.php new file mode 100644 index 0000000..4027393 --- /dev/null +++ b/main/survey/ajax.php @@ -0,0 +1,33 @@ +ajax(); +} +else { + new \App\Controllers\AjaxController(); +} + +?> \ No newline at end of file diff --git a/main/survey/app/.htaccess b/main/survey/app/.htaccess new file mode 100644 index 0000000..05cd49a --- /dev/null +++ b/main/survey/app/.htaccess @@ -0,0 +1,3 @@ +# Ne dovolimo direktnega dostopa do tega direktorija + +deny from al diff --git a/main/survey/app/Controllers/AjaxController.php b/main/survey/app/Controllers/AjaxController.php new file mode 100644 index 0000000..33662e4 --- /dev/null +++ b/main/survey/app/Controllers/AjaxController.php @@ -0,0 +1,708 @@ +ajax_accept_droppable(); + } elseif ($_GET['a'] == 'accept_ranking') { + $this->ajax_accept_ranking(); + } elseif ($_GET['a'] == 'accept_dragdrop1') { + $this->ajax_accept_dragdrop1(); + } elseif ($_GET['a'] == 'get_dragdrop1_data') { + $this->ajax_get_dragdrop1_data(); + } elseif ($_GET['a'] == 'delete_dragdrop1_data') { + $this->ajax_delete_dragdrop1_data(); + } elseif ($_GET['a'] == 'delete_dragdrop2_data') { + $this->ajax_delete_dragdrop2_data(); + } elseif ($_GET['a'] == 'accept_dragdrop_grid') { + $this->ajax_accept_dragdrop_grid(); + } elseif ($_GET['a'] == 'accept_sortable_ranking') { + $this->ajax_accept_sortable_ranking(); + } elseif ($_GET['a'] == 'edit_size') { + $this->ajax_edit_size(); + } elseif ($_GET['a'] == 'dodaj_ime') { + $this->ajax_dodaj_ime(); + } elseif ($_GET['a'] == 'spol') { + $this->ajax_glasovanje_spol(); + } elseif ($_GET['a'] == 'vote_spol') { + $this->ajax_glasovanje_vote_spol(); + } elseif ($_GET['a'] == 'captcha') { + $this->ajax_captcha(); + } elseif ($_GET['a'] == 'skin') { + $this->ajax_skin(); + } elseif ($_GET['a'] == 'grupa_for_if') { + $this->ajax_grupa_for_if(); + } elseif ($_GET['a'] == 'enable_comments') { + $this->ajax_enable_comments(); + } elseif ($_GET['a'] == 'continue_later') { + $this->ajax_continue_later(); + } elseif ($_GET['a'] == 'continue_later_send') { + $this->ajax_continue_later_send(); + } elseif ($_GET['a'] == 'usr_id_data') { + $this->ajax_delete_signature_data(); + }elseif ($_GET['a'] == 'get_tip_opozorila') { + $this->ajax_get_tip_opozorila(); + } // genericna resitev za vse nadaljne + else { + $ajax = 'ajax_' . $_GET['a']; + if (method_exists($this, $ajax)) + return $this->$ajax (); + else + echo 'method ' . $ajax . ' does not exist'; + } + } + + /************************************************ + * Get instance + ************************************************/ + private static $_instance; + + public static function getInstance() + { + if (self::$_instance) + return self::$_instance; + + return new AjaxController(); + } + + public function ajax_delete_signature_data() + { + + $usr_id = $_POST['usr_id']; + $anketa = $_POST['anketa']; + $spr_id = $_POST['spr_id']; + $vre_id = $_POST['vre_id']; + + + //$sqlsignaturefilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . $usr_id . "'"); + $sqlsignaturefilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . $usr_id . "' AND code = '" . $spr_id . "' "); + + if (mysqli_num_rows($sqlsignaturefilename) > 0) { + $rowSignatureFilename = mysqli_fetch_array($sqlsignaturefilename); + $file_2_delete = $rowSignatureFilename[0]; + } + + //echo $file_2_delete; + + //$path = self::$site_url.'main/survey/uploads/'.$file_2_delete; //tale varianta ne omogoča brisanje na disku + $path = survey_path('uploads/' . $file_2_delete); + + //echo $path; + + if (is_file($path)) { //če slikovna datoteka podpisa obstaja + unlink($path); //zbriši datoteko + } + + //sisplet_query("DELETE FROM srv_data_upload WHERE usr_id='" . get('usr_id') . "' AND ank_id='$anketa'");//zbriši iz baze info datoteki podpisa + sisplet_query("DELETE FROM srv_data_upload WHERE usr_id='" . get('usr_id') . "' AND ank_id='$anketa' AND code='$spr_id'");//zbriši iz baze info datoteki podpisa + sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE usr_id='" . get('usr_id') . "' AND spr_id='$spr_id' AND vre_id='$vre_id'");//zbriši iz baze info o vnesenem imenu + } + + // sprememba skina + public function ajax_skin() + { + $mobile = (int)$_GET['mobile']; + setcookie('mobile', $mobile, 0, '/'); + header("Location: " . $_SERVER['HTTP_REFERER']); + } + + //za izris vprasanj pri antonucci designu 1 + public function ajax_edit_size() + { + $spremenljivka = $_POST['spremenljivka']; + $size = $_POST['size']; + + //sisplet_query("UPDATE srv_spremenljivka SET size='$size' WHERE id='$spremenljivka'"); + + for ($i = 0; $i < $size; $i++) { + echo '

' . "\n"; + } + } + + //antonucci design 2 + public function ajax_dodaj_ime() + { + $spremenljivka = $_POST['spremenljivka']; + $ime = $_POST['ime']; + + //sisplet_query("UPDATE srv_spremenljivka SET size='$size' WHERE id='$spremenljivka'"); + + echo '

' . "\n"; + + echo '

' . "\n"; + echo '

' . "\n"; + echo '

' . "\n"; + + } + + public function ajax_accept_droppable() + { + + $child = $_POST['child']; + $parent = $_POST['parent']; + + + if ($parent == 'half2_1') { + //poiscemo usr_id + $sql0 = sisplet_query("SELECT usr_id FROM srv_data_imena WHERE id='$child'"); + $row0 = mysqli_fetch_array($sql0); + $usr_id = $row0[0]; + + //poiscemo najvecji count + $sql = sisplet_query("SELECT MAX(countE) FROM srv_data_imena WHERE (usr_id='" . get('usr_id') . "' AND (emotion=1 AND emotionINT=0))"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + $count = $row['MAX(countE)']; + } + + $count++; + + //update baze + sisplet_query("UPDATE srv_data_imena SET emotion=1, countE='$count' WHERE id='$child'"); + } elseif ($parent == 'half2_2') { + //poiscemo usr_id + $sql0 = sisplet_query("SELECT usr_id FROM srv_data_imena WHERE id='$child'"); + $row0 = mysqli_fetch_array($sql0); + $usr_id = $row0[0]; + + //poiscemo najvecji count + $sql = sisplet_query("SELECT MAX(countS) FROM srv_data_imena WHERE (usr_id='" . get('usr_id') . "' AND (social=1 AND socialINT=0))"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + $count = $row['MAX(countS)']; + } + + $count++; + + //update baze + sisplet_query("UPDATE srv_data_imena SET social=1, countS='$count' WHERE id='$child'"); + } elseif ($parent == 'half2_3') { + $count = 1; + + //update baze + sisplet_query("UPDATE srv_data_imena SET emotionINT=1, countE='$count' WHERE id='$child'"); + } elseif ($parent == 'half2_4') { + $count = 1; + + //update baze + sisplet_query("UPDATE srv_data_imena SET socialINT=1, countS='$count' WHERE id='$child'"); + } //leva stran - brisemo iz baze (emotion) + elseif ($parent == 'half_1') { + //preuredimo ostale counterje + $sql = sisplet_query("SELECT countE, usr_id FROM srv_data_imena WHERE id='$child'"); + $row = mysqli_fetch_array($sql); + + $counter = $row[0]; + $usr_id = $row[1]; + + $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND (countE > '$counter') ORDER BY countE"); + while ($row1 = mysqli_fetch_array($sql1)) { + $count = $row1['countE']; + $count--; + sisplet_query("UPDATE srv_data_imena SET countE='$count' WHERE id='$row1[id]'"); + } + + //update baze + sisplet_query("UPDATE srv_data_imena SET emotion=0, countE=0 WHERE id='$child'"); + } //leva stran - brisemo iz baze (druzenje) + elseif ($parent == 'half_2') { + //preuredimo ostale counterje + $sql = sisplet_query("SELECT countS, usr_id FROM srv_data_imena WHERE id='$child'"); + $row = mysqli_fetch_array($sql); + + $counter = $row[0]; + $usr_id = $row[1]; + + $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND (countS > '$counter') ORDER BY countS"); + while ($row1 = mysqli_fetch_array($sql1)) { + $count = $row1['countS']; + $count--; + sisplet_query("UPDATE srv_data_imena SET countS='$count' WHERE id='$row1[id]'"); + } + + //update baze + sisplet_query("UPDATE srv_data_imena SET social=0, countS=0 WHERE id='$child'"); + } //leva stran - brisemo iz baze (emotionINT) + elseif ($parent == 'half_3') { + //update baze + sisplet_query("UPDATE srv_data_imena SET emotionINT=0, countE=0 WHERE id='$child'"); + } //leva stran - brisemo iz baze (druzenjeINT) + elseif ($parent == 'half_4') { + //update baze + sisplet_query("UPDATE srv_data_imena SET socialINT=0, countS=0 WHERE id='$child'"); + } + + + //izpisemo ime v divu po loadu + $sql1 = sisplet_query("SELECT text FROM srv_data_imena WHERE id='$child'"); + $value = mysqli_fetch_array($sql1); + + echo $value[0]; + + } + + /** + * @desc poskrbi za shranjevanje vrednosti 99,98,97 + */ + + //zapisovanje v bazo pri ranking dropih (n>k, n=k) + public function ajax_accept_ranking() + { + + + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $usr_id = $_POST['usr_id']; + $order = $_POST['order']; + + // Popravimo da se po ajax-u ohrani jezik + if (isset($_POST['lang_id'])) { + $lang_id = save('lang_id', $_POST['lang_id'], 1); + + $file = lang_path($lang_id); + if (@include($file)) + $_SESSION['langX'] = lang_path($lang_id, 1); + } + + // Napredni parapodatki - za ranking je lažje če je kar tukaj + /*if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){ + SurveyAdvancedParadataLog::getInstance()->logData(0, $usr_id, 'data change', '', $spremenljivka, $order); + }*/ + + $exploded = explode('&', $order); + + //najprej pobrisemo iz baze vse vnose + sisplet_query("DELETE FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'"); + + //sortiranje (vnos v srv_data_rating) + $i = 1; + foreach ($exploded AS $key) { + $key = str_replace('handle_', '', $key); + $explode = explode('[]=', $key); + + if ($explode[1] != 0) + sisplet_query("INSERT INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red) VALUES ('$spremenljivka', '$explode[1]', '" . get('usr_id') . "', '$i')"); + + $i++; + } + + Vprasanja::getInstance()->displayVnos($spremenljivka); + + echo '
'; + + } + + //zapisovanje v bazo in brisanje pri drag drop + public function ajax_accept_dragdrop1() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $vre_id = $_POST['vre_id']; + $usr_id = $_POST['usr_id']; + $anketa = $_POST['anketa']; + $data_calculation = $_POST['data_calculation']; + $tip = $_POST['tip']; + $cat_right = $_POST['cat_right']; + $other_present = $_POST['other_present']; + $other = $_POST['other']; + + $row = Model::select_from_srv_spremenljivka($spremenljivka); + + //( ( (tip == 1 && other == 0 && cat_right) ) || ( (tip == 2) && (other_present != 0) ) || ( (other != 0) ) ) + if (($tip == 1 && $cat_right && $other == 0) || (($tip == 2) && ($other_present != 0)) || (($other != 0))) { + sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'"); + } + sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "')"); + } + + //asinhrono pobiranje podatkov za ureditev missing + public function ajax_get_dragdrop1_data() + { + Model::user_not_lurker(); + $anketa = $_GET['anketa']; + $spremenljivka = $_GET['spremenljivka']; + $vre_id = array(); + //echo 'Spremenljivka: '.$spremenljivka; + //echo 'Anketa: '.$anketa; + //$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other!=0 "); + $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka'"); + $num = mysqli_num_rows($sql1); + + /* echo ' + + '; */ + + while ($row1 = mysqli_fetch_array($sql1)) { + //$vre_id[$i] = $row1['id']; + array_push($vre_id, $row1['id']); + } + //echo 'Podatek je: '.$num; + //echo $vre_id; + echo json_encode($vre_id); + + } + + //brisanje odgovorov iz baze pri drag drop + public function ajax_delete_dragdrop1_data() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $usr_id = $_POST['usr_id']; + $vre_id = $_POST['vre_id']; + $anketa = $_POST['anketa']; + + sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id'"); + + } + + //brisanje odgovorov iz baze pri drag drop, ko imamo missing-e + public function ajax_delete_dragdrop2_data() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $usr_id = $_POST['usr_id']; + $vre_id = $_POST['vre_id']; + $anketa = $_POST['anketa']; + + sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'"); + } + + //zapisovanje v bazo pri drag drop v grid + public function ajax_accept_dragdrop_grid() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $vre_id = $_POST['vre_id']; + $usr_id = $_POST['usr_id']; + $tip = $_POST['tip']; + $anketa = $_POST['anketa']; + $indeks = $_POST['indeks']; + $last_vre_id = $_POST['last_vre_id']; + $cat_right = $_POST['cat_right']; + $vre_id_present = $_POST['vre_id_present']; + + + //vnesi podatke v bazo + if ($tip == 6) { + sisplet_query("INSERT INTO srv_data_grid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "', '$indeks')"); + } else if ($tip == 16) { + sisplet_query("INSERT INTO srv_data_checkgrid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "', '$indeks')"); + } + + + } + + //brisanje odgovorov iz baze pri drag drop - tabela - vec odgovorov + public function ajax_delete_dragdrop_grid_data() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $usr_id = $_POST['usr_id']; + $vre_id = $_POST['vre_id']; + $anketa = $_POST['anketa']; + $indeks = $_POST['indeks']; + //brisi podatke iz baze + sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id' AND grd_id = '$indeks' "); + + } + + //brisanje odgovorov iz baze pri drag drop + public function ajax_delete_dragdrop_grid_data_1() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $usr_id = $_POST['usr_id']; + $vre_id = $_POST['vre_id']; + $anketa = $_POST['anketa']; + $indeks = $_POST['indeks']; + + sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id' AND grd_id = '$indeks'"); + + } + + // + //brisanje odgovorov iz baze pri drag drop grid, ko se klikne gumb Ponastavi + public function ajax_delete_dragdrop_grid_data_reset() + { + Model::user_not_lurker(); + + $spremenljivka = $_POST['spremenljivka']; + $usr_id = $_POST['usr_id']; + $anketa = $_POST['anketa']; + $tip = $_POST['tip']; + + if($tip == 6){ + sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' "); + }else if($tip == 16){ + sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' "); + } + } + + // respondent se strinja z uporabo piskotvkov - nastavimo piskotek ok + public function ajax_cookie_ok() + { + + setcookie('cookie_ok', '1', time() + 2500000, '/'); + + } + + //izpis statistike glede na spol + public function ajax_glasovanje_spol() + { + $spremenljivka = $_POST['spremenljivka']; + $spol = $_POST['spol']; + + Statistic::displayStatGlasovanje($spremenljivka, $spol); + } + + /** + * preveri, ce je captcha koda pravilno vnesena (preko ajaxa) + * + */ + public function ajax_captcha(){ + global $secret_captcha; + + $text = strtoupper($_GET['text']); + $code = $_GET['code']; + $spr_id = $_GET['spr_id']; + $usr_id = $_GET['usr_id']; + + $recaptchaResponse = $_POST['g-recaptcha-response']; + $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse); + + // zdaj pa zabeleži mail (pred pošiljanjem) + // zdaj pa še v bazi tistih ki so se ročno dodali + if(strstr($request,"true")){ + echo '1'; + } + else { + echo '0'; + } + } + + /** + * poisce v kateri grupi/strani se pojavi if za redirect tabov + * + */ + public function ajax_grupa_for_if($parent = 0){ + + $parent_if = $_POST['parent_if']; + if ($parent > 0) $parent_if = $parent; + + ob_start(); + + $b = new Branching(get('anketa')); + $spr = $b->find_first_in_if($parent_if); + + ob_clean(); + + $row = Model::select_from_srv_spremenljivka($spr); + + if ($parent == 0) + echo $row['gru_id']; + + return $row['gru_id']; + } + + /** + * vklopi komentarje na anketo (v previewu je ta možnost) + * + */ + public function ajax_enable_comments(){ + + ob_clean(); + + SurveySetting::getInstance()->Init((int)$_POST['anketa']); + + SurveySetting::getInstance()->setSurveyMiscSetting('question_resp_comment', '1'); + SurveySetting::getInstance()->setSurveyMiscSetting('question_resp_comment_viewadminonly', '3'); + } + + + public function ajax_continue_later(){ + + save('lang_id', (int)$_GET['language']); + + $url = $_POST['url'] . '&return=1'; + + SurveySetting::getInstance()->Init(get('anketa')); + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + + $srv_continue_later_txt = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later_txt' . $_lang); + if ($srv_continue_later_txt == '') $srv_continue_later_txt = self::$lang['srv_continue_later_txt']; + + $srv_continue_later_email = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later_email' . $_lang); + if ($srv_continue_later_email == '') $srv_continue_later_email = self::$lang['srv_continue_later_email']; + + $srv_forma_send = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang); + if ($srv_forma_send == '') $srv_forma_send = self::$lang['srv_forma_send']; + + echo '
'; + + echo '

' . $srv_continue_later_txt . ':

' . $url . '

'; + + echo ''; + + echo '

' . $srv_continue_later_email . ':

'; + + echo '
'; + } + + public function ajax_continue_later_send(){ + global $mysql_database_name; + + ob_clean(); + + $s = self::$lang['srv_continue_later_subject']; + + if($mysql_database_name == 'vprasalnikirsrssi') + $t = self::$lang['srv_continue_later_content_rs-rs'] . ': ' . $_POST['url'] . ''; + else + $t = self::$lang['srv_continue_later_content'] . ': ' . $_POST['url'] . ''; + + // Podpis + $signature = Common::getEmailSignature(); + $t .= $signature; + + $mail = $_POST['email']; + + if ($mail == '') return; + + try { + $MA = new MailAdapter(get('anketa'), $type='alert'); + $MA->addRecipients($mail); + $result = $MA->sendMail(stripslashes($t), $s); + } + catch (Exception $e) { + } + } + + public function ajax_get_tip_opozorila() { + $spr_id = $_POST['spr_id']; + + //poberi podatke o na trenutnem obmocju + $sqlR = sisplet_query("SELECT reminder FROM srv_validation WHERE spr_id = $spr_id"); + $rowR = mysqli_fetch_assoc($sqlR); + $tip_opozorila = $rowR['reminder']; + + echo $tip_opozorila; + } + + + // Izpisemo seznam starih odgovorov v popup (dodatna nastavitev pri text vprasanju) + public function ajax_show_prevAnswers_all() { + + $spremenljivka = $_POST['spremenljivka']; + + echo '

'.self::$lang['srv_prevAnswers'].'

'; + + $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"); + while($row = mysqli_fetch_array($sql)){ + echo '

'; + echo $row['text']; + echo '

'; + } + + // Gumb zapri + echo '
'; + echo ''.self::$lang['srv_zapri'].''; + echo '
'; + + echo ''; + } + + // Izpisemo seznam starih odgovorov v popup (dodatna nastavitev pri text vprasanju) + public function ajax_show_gdpr_about() { + global $lang; + + $anketa = $_POST['anketa']; + + $gdpr_settings = GDPR::getSurveySettings($anketa); + + echo '

'.$lang['srv_gdpr_survey_gdpr_about'].'

'; + + if($gdpr_settings['about'] == ''){ + $about_array = GDPR::getGDPRInfoArray($anketa); + $about_text = GDPR::getGDPRTextFromArray($about_array, $type='html'); + + echo $about_text; + } + else{ + echo nl2br($gdpr_settings['about']); + } + + echo '
'; + + // Gumb zapri + echo '
'; + echo ''.$lang['srv_zapri'].''; + echo '
'; + + echo ''; + + echo '
'; + } + + + // Shranimo vrstni red pri randomizaciji (blokov ali vprasanj) + public function ajax_save_randomization_order() { + + $usr_id = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['usr_id']); + $randomization_type = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['randomization_type']); + + $vrstni_red = stripcslashes($_POST['order']); + $vrstni_red = str_replace('"', "", substr($vrstni_red, 1, -1)); + + // Random vrstni red VPRASANJ oz. BLOKOV znotraj bloka + // ID bloka znotraj katerega so random elementi + $parent_block_id = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['parent_block_id']); + + $sql = sisplet_query("INSERT INTO srv_data_random_blockContent + (usr_id, block_id, vrstni_red) + VALUES + ('".$usr_id."', '".$parent_block_id."', '".$vrstni_red."') + ON DUPLICATE KEY UPDATE vrstni_red='".$vrstni_red."' + "); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + } +} \ No newline at end of file diff --git a/main/survey/app/Controllers/BodyController.php b/main/survey/app/Controllers/BodyController.php new file mode 100644 index 0000000..308b30c --- /dev/null +++ b/main/survey/app/Controllers/BodyController.php @@ -0,0 +1,2458 @@ +displaySistemske(); + + $row = SurveyInfo::getInstance()->getSurveyRow(); + if (!get('printPreview')) { + SaveSurvey::saveSistemske(); + } + + // datapiping + $row['introduction'] = Helper::dataPiping($row['introduction']); + + SurveySetting::getInstance()->Init(get('anketa')); + $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img'); + $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : ''; + if (isset($_GET['mobile']) && $_GET['mobile'] == 1) + $class .= ' mobile_preview'; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2) + $class .= ' tablet_preview'; + + + // crn div za ozadje popupov + echo '
'; + echo ''; + + + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + + echo '
' . "\n"; + + Display::getInstance()->logo(); + + Display::getInstance()->progress_bar(); + + if (!get('printPreview')) { + echo '

checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + } + + // opozorilo ce urejamo ze reseno anketo + if (get('quick_view') == true) { + echo '
'; + echo self::$lang['srv_quick_view_text']; + echo '
'; + } + // opozorilo ce urejamo ze reseno anketo + if (isset($_GET['urejanje'])) { + echo '
'; + echo self::$lang['srv_edit_text']; + echo '
'; + + // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno + ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE - Ce ni tega flusha, prvi klik na urejanje odpre poruseno stran (naknadni kliki so pa potem ok) + $sas = new SurveyAdminSettings(); + $sas->checkFirstDataChange(); + + // Updatamo tracking (ker gre za editiranje odgovorov) + TrackingClass::update(get('anketa'), 4); + } + + echo '
' . "\n"; + echo '
' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; + + $this->displayIntroductionContent(); + + + if ($row['user_from_cms'] == 1 && $row['user_from_cms_email'] == 1) { + + $sql1 = sisplet_query("SELECT user_id FROM srv_user WHERE id = '" . get('usr_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + + $sqlu = Model::db_select_user($row1['user_id']); + $rowu = mysqli_fetch_array($sqlu); + if (mysqli_num_rows($sqlu) > 0) { + echo '
' . "\n"; + echo self::$lang['srv_recognized'] . ' ' . $rowu['name'] . ' ' . $rowu['surname'] . ''; + if ($row['user_from_cms_email'] == 1) + echo ' (' . $rowu['email'] . ')'; + echo '
' . "\n"; + } + } + + // koda za izponjevanje ankete (splosna - brez prepoznave userjev) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu + $userAccess = UserAccess::getInstance(self::$global_user_id); + $sqlp = sisplet_query("SELECT COUNT(*) AS count FROM srv_password WHERE ank_id='" . get('anketa') . "'"); + $rowp = mysqli_fetch_array($sqlp); + if ($rowp['count'] > 0 && $userAccess->checkUserAccess($what='password')) { + echo '
' . "\n"; + echo '

' . self::$lang['insert_password'] . ':

'; + echo '
' . "\n"; + } + + if ($row['user_base'] == 1 + #če imamo neindividualizirana vabila - poslana preko vabil, vendar bez kode in zato brez sledenja (uporabnik se pri pošiljanju NE prenese iz srv_invitations_recipients v srv_user) + && $row['individual_invitation'] != 0 + ) { + + if (isset($_GET['code'])) + $usercode = $_GET['code']; + else + $usercode = ''; + + if ($row['usercode_required'] == 1) + $usercode == ''; + + // �e ni nujno da vnesemo kodo usercode_skip = 1 ali 2 + $canNotSkip = true; + if ($row['usercode_skip'] > 0) { + if ($row['usercode_skip'] == 1) { // lahko presko�imo kodo + $canNotSkip = false; + } elseif ($row['usercode_skip'] == 2) { // preverimo �e je uporabnik avtor ankete + $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'"); + if (mysqli_num_rows($sqlUserAutor) > 0) + $canNotSkip = false; + } + } + + // Ce smo v preview ali testnem vnosu in ce imamo vklopljeno da ne preverjamo kode + if (isset($_GET['preview']) && $_GET['preview'] == 'on' && isset($_GET['disablecode']) && $_GET['disablecode'] == 1) { + $canNotSkip = false; + } + + if ($usercode == '' && $canNotSkip || ($row['usercode_required'] == 1 /*&& $row['usercode_skip'] != 1*/)) { + + $usercode_text = ($row['usercode_text'] != "") ? $row['usercode_text'] : self::$lang['srv_basecode']; + echo '
' . "\n"; + echo '

' . $usercode_text . ':

'; + echo '
' . "\n"; + } else { + echo ' '; + } + } + + SurveySetting::getInstance()->Init(get('anketa')); + + // izbira jezika za respondenta + if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $row['multilang'] == 1 && !get('printPreview')) { + + $lang_resp = $row['lang_resp']; + $lang_array = array(); + + $current = self::$lang['id']; + + $file = lang_path($lang_resp); + include($file); + $lang_array[$lang['id']] = $lang['language']; + + $file = lang_path($current); + include($file); + + $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language"); + while ($rowl = mysqli_fetch_array($sqll)) { + $lang_array[$rowl['lang_id']] = $rowl['language']; + } + + echo '
' . "\n"; + + // Izbira jezika z dropdown menijem + if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) { + echo '

' . self::$lang['lang'] . ': '; + echo ' '; + echo '

' . "\n"; + } + // Izbira jezika z radio gumbi (default) + else { + echo '

' . self::$lang['lang'] . ':

'; + echo ''; + + foreach ($lang_array AS $key => $val) { + echo '
'; + } + echo '
'; + } + + + echo '
' . "\n"; + + } + + echo '
' . "\n"; // - grupa + + SurveySetting::getInstance()->Init(get('anketa')); + + if (get('lang_id') != null) + $_lang = '_' . get('lang_id'); + else + $_lang = ''; + + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang); + $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod']; + + if (!get('printPreview')) { + + // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija + $survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy'); + if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){ + $js_submit = ' onclick="'; + + if($survey_privacy == 2) + $js_submit .= 'privacy_check();'; + + if($row['cookie_continue'] == 0 && $row['cookie'] != -1) + $js_submit .= 'cookie_check();'; + + $js_submit .= 'return false;"'; + } + else{ + $js_submit = ''; + } + + echo '
' . "\n"; + + if (isset($_GET['popup']) && $_GET['popup'] == '1'){ + echo '' . "\n"; + // Varianta da zapiranje iframa deluje cross domain + //echo '' . "\n" + } + + echo '
'; + } + + echo '
' . "\n"; + + echo '
' . "\n"; // - container + + if (!get('printPreview')) { + $this->displayFooterNote(); + } + + // TAWK chat, ce je vklopljen + if(SurveyInfo::getInstance()->checkSurveyModule('chat')){ + Display::getInstance()->displayChatTAWK(); + } + + echo '
' . "\n"; // - outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + + Js::js_tracking(); + } + + public function displayIntroductionContent() + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + + // Ce prikazemo dodaten preduvod za gdpr ankete + if(GDPR::isGDPRSurveyTemplate(get('anketa'))){ + self::displayIntroductionGDPR(); + } + + + echo '
' . "\n"; + + if ($row['introduction'] == '') + $intro = self::$lang['srv_intro']; + else + $intro = Helper::dataPiping($row['introduction']); + + if (get('lang_id') != null) { + $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='-1' AND lang_id='" . get('lang_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + if ($row1['naslov'] != '') $intro = $row1['naslov']; + } + + echo '
'; + + // ta p je mogoce prevec, ker ga verjetno vedno doda editor? + echo '

' . $intro . '

'; + + SurveySetting::getInstance()->Init(get('anketa')); + $privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy'); + + if ($privacy == 1) { + echo '


' . self::$lang['srv_privacy_text_1'] . '

'; + + } elseif ($privacy == 2) { + echo '


'; + + echo '

'; + } + + // Ce imamo staticen uvod in preverjanje s captcho + if($row['intro_static'] == 2){ + global $recaptcha_sitekey; + + $captcha_error = (isset($_GET['captcha_error']) && $_GET['captcha_error'] == 1) ? true : false; + + echo '
'; + + echo '

'; + echo '

'; + echo '

'; + + if($captcha_error){ + //echo '

Wrong captcha!

'; + } + } + + echo '

' . "\n"; + + echo '
' . "\n"; + } + + // Prikazemo dodaten uvod za GDPR + public function displayIntroductionGDPR() + { + $user_settings = GDPR::getSurveySettings(get('anketa')); + + echo '
' . "\n"; + + echo '
'; + + echo GDPR::getSurveyIntro(get('anketa')); + + // JS za prikaz popup-a + echo ''; + echo '
' . "\n"; + + // Radio buttons + echo ''; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + + echo '
' . "\n"; + } + + /************************************************ + * Izrišemo staticen uvod, ki ne shrani nicesar (user se ustvari v bazi sele na naslednji strani) + ************************************************/ + public function displayStaticIntroduction() + { + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + // datapiping + $row['introduction'] = Helper::dataPiping($row['introduction']); + + SurveySetting::getInstance()->Init(get('anketa')); + $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img'); + $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : ''; + if (isset($_GET['mobile']) && $_GET['mobile'] == 1) + $class .= ' mobile_preview'; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2) + $class .= ' tablet_preview'; + + + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + + + echo '
' . "\n"; + + Display::getInstance()->logo(); + + Display::getInstance()->progress_bar(); + + if (!get('printPreview')) { + echo '

checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + } + + //opozorilo ce urejamo ze reseno anketo + if (get('quick_view') == true) { + echo '
'; + echo self::$lang['srv_quick_view_text']; + echo '
'; + } + //opozorilo ce urejamo ze reseno anketo + if (isset($_GET['urejanje'])) { + echo '
'; + echo self::$lang['srv_edit_text']; + echo '
'; + + // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno + ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE + $sas = new SurveyAdminSettings(); + $sas->checkFirstDataChange(); + + // Updatamo tracking (ker gre za editiranje odgovorov) + TrackingClass::update(get('anketa'), 4); + } + + echo '
' . "\n"; + echo '
' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; + + + $this->displayIntroductionContent(); + + + // koda za izponjevanje ankete (splosna - brez prepoznave userjev) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu + $userAccess = UserAccess::getInstance(self::$global_user_id); + $sqlp = sisplet_query("SELECT COUNT(*) AS count FROM srv_password WHERE ank_id='" . get('anketa') . "'"); + $rowp = mysqli_fetch_array($sqlp); + if ($rowp['count'] > 0 && $userAccess->checkUserAccess($what='password')) { + echo '
' . "\n"; + echo '

' . self::$lang['insert_password'] . ':

'; + echo '
' . "\n"; + } + + SurveySetting::getInstance()->Init(get('anketa')); + + // izbira jezika za respondenta + if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $row['multilang'] == 1 && !get('printPreview')) { + + $lang_resp = $row['lang_resp']; + $lang_array = array(); + + $current = self::$lang['id']; + + $file = lang_path($lang_resp); + include($file); + $lang_array[$lang['id']] = $lang['language']; + + $file = lang_path($current); + include($file); + + $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language"); + while ($rowl = mysqli_fetch_array($sqll)) { + $lang_array[$rowl['lang_id']] = $rowl['language']; + } + + echo '
' . "\n"; + + // Izbira jezika z dropdown menijem + if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) { + echo '

' . self::$lang['lang'] . ': '; + echo ' '; + echo '

' . "\n"; + } // Izbira jezika z radio gumbi (default) + else { + echo '

' . self::$lang['lang'] . ':

'; + echo ''; + foreach ($lang_array AS $key => $val) { + echo '
'; + } + echo '
'; + } + + echo '
' . "\n"; + } + + echo '
' . "\n"; // - grupa + + SurveySetting::getInstance()->Init(get('anketa')); + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang); + $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod']; + + if (!get('printPreview')) { + + // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija + $survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy'); + if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){ + $js_submit = ' onclick="'; + if($survey_privacy == 2) + $js_submit .= 'privacy_check();'; + if($row['cookie_continue'] == 0 && $row['cookie'] != -1) + $js_submit .= 'cookie_check();'; + $js_submit .= 'return false;"'; + } + else{ + $js_submit = ''; + } + + echo '
' . "\n"; + + if (isset($_GET['popup']) && $_GET['popup'] == '1') + echo '' . "\n"; + + echo '
'; + } + + echo '
' . "\n"; + + echo '
' . "\n"; // - container + + if (!get('printPreview')) { + + $this->displayFooterNote(); + } + + echo '
' . "\n"; // - outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + } + + + /************************************************ + * Izrišemo konec ankete + ************************************************/ + public function displayKonec() + { + global $mysql_database_name; + global $lang; + global $admin_type; + global $site_url; + global $app_settings; + + Header::getInstance()->displaySistemske(); + + if (!get('printPreview')) { + + $row = SurveyInfo::getInstance()->getSurveyRow(); + $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'AND (finish_respondent=1 OR finish_respondent_cms=1 OR finish_author=1 OR finish_other =1)"); + + + // EVALVACIJA - oznacimo, da je student odgovoril + if (Common::checkModule('evalvacija') == '1') { + + $sql1 = sisplet_query("SELECT student FROM eval_data_user WHERE ank_id='".get('anketa')."' AND usr_id='".get('usr_id')."'"); + $sql2 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifpredm' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'"); + $sql3 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='siffaks' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'"); + $sql4 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifizv1' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'"); + $sql5 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl'"); + $sql6 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl2'"); + + // Ce imamo sifro predmeta gre za anketo za ocenjevanje predmetov + if (mysqli_num_rows($sql2) > 0) { + $row1 = mysqli_fetch_array($sql1); + $row2 = mysqli_fetch_array($sql2); + + // Ce imamo sifro izvajalca gre za anketo PRED izpiti (eval_data_anketaPred), drugace je anketa PO izpitih (eval_data_anketaPo) + if (mysqli_num_rows($sql4) > 0) { + // student je v celoti odgovoril na anketo + sisplet_query("INSERT INTO eval_data_anketaPred (predmet, student, ank_id) VALUES ('$row2[text]', '$row1[student]', '" . get('anketa') . "')"); + } else { + // student je v celoti odgovoril na anketo + sisplet_query("INSERT INTO eval_data_anketaPo (predmet, student, ank_id) VALUES ('$row2[text]', '$row1[student]', '" . get('anketa') . "')"); + } + + // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti + sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'"); + } + // splosna PODIPLOMSKA anketa (ena na studenta, brez predmetov) + elseif (mysqli_num_rows($sql5) > 0) { + $row1 = mysqli_fetch_array($sql1); + + // student je v celoti odgovoril na anketo + sisplet_query("INSERT INTO eval_data_podipl (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')"); + + // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti + sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'"); + } + // splosna PODIPLOMSKA anketa 2 (ena na studenta, brez predmetov) + elseif (mysqli_num_rows($sql6) > 0) { + $row1 = mysqli_fetch_array($sql1); + + // student je v celoti odgovoril na anketo + sisplet_query("INSERT INTO eval_data_podipl2 (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')"); + + // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti + sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'"); + } + // SPLOSNA anketa (ena na studenta, brez predmetov) + elseif (mysqli_num_rows($sql1) > 0) { + $row1 = mysqli_fetch_array($sql1); + + // student je v celoti odgovoril na anketo + sisplet_query("INSERT INTO eval_data_splosna (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')"); + + // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti + sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'"); + } + } + + // Ce je vklopljen evoli team meter zabelezimo kvoto + $tm_quota_increase = false; + $modules = SurveyInfo::getInstance()->getSurveyModules(); + if (isset($modules['evoli_teammeter']) + || isset($modules['evoli_quality_climate']) + || isset($modules['evoli_teamship_meter']) + || isset($modules['evoli_organizational_employeeship_meter']) + ) { + + // Dobimo id skupine 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); + + if($rowGroupTM['vre_id'] > 0){ + + $tm_quota = 0; + + // Prestejemo vse response za doloceno skupino/podjetje (to ni vezano na departmente, ker smo lahko tudi brez departmentov!) + $sqlTM = sisplet_query("SELECT DISTINCT(usr_id) AS usr_id + FROM srv_data_vrednost_active + WHERE vre_id='".$rowGroupTM['vre_id']."'"); + + while($rowTM = mysqli_fetch_array($sqlTM)){ + + // Dodatno se preverimo, ce je user res koncal anketo (ima status 6 in ni lurker) + $sqlTMU = sisplet_query("SELECT last_status, lurker FROM srv_user where id='".$rowTM['usr_id']."'"); + $rowTMU = mysqli_fetch_array($sqlTMU); + + if($rowTMU['last_status'] == '6' && $rowTMU['lurker'] == '0') + $tm_quota++; + } + + $sqlTM = sisplet_query("UPDATE srv_evoli_teammeter + SET kvota_val='".$tm_quota."' + WHERE ank_id='".get('anketa')."' AND skupina_id='".$rowGroupTM['vre_id']."'"); + $tm_quota_increase = true; + } + } + + // Popravimo url za skok po koncu ankete ce nima http:// + if ($row['url'] != '' && substr($row['url'], 0, 4) != 'http') { + $finishUrl = 'http://' . $row['url']; + } else { + $finishUrl = $row['url']; + } + + // Dodamo datapiping v url-ju + if($row['url'] != ''){ + // Počistimo html tage + $finishUrl = strip_tags(Helper::dataPiping($finishUrl)); + } + + // Preverimo ce imamo nastavljene kaksne get parametre za dodat pri skoku na url + if ($row['concl_link'] == 1 && $finishUrl != '') { + SurveySetting::getInstance()->Init(get('anketa')); + $concl_url_usr_id = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_usr_id'); + $concl_url_status = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_status'); + $concl_url_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_recnum'); + + if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1') + $finishUrl .= '?'; + + if ($concl_url_usr_id == '1') { + $finishUrl .= 'usr_id=' . get('usr_id') . '&'; + } + + if ($concl_url_status == '1' || $concl_url_recnum == '1') { + $sqlU = sisplet_query("SELECT last_status, recnum FROM srv_user WHERE id = '" . get('usr_id') . "'"); + $rowU = mysqli_fetch_array($sqlU); + + if($concl_url_recnum == '1') + $finishUrl .= 'recnum=' . $rowU['recnum'] . '&'; + + if($concl_url_status == '1') + $finishUrl .= 'status=' . $rowU['last_status'] . '&'; + } + + if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1') + $finishUrl = substr($finishUrl, 0, -1); + } + + // Pri Gorenje anketah posljemo id reklamacije preko njihovega api-ja + if (Common::checkModule('gorenje')){ + $rek_id = SurveyGorenje::getGorenjeVariable(get('anketa'), 'rekid', get('usr_id')); + if($rek_id != '' && $rek_id > 0){ + + // Posljemo id reklamacije preko api-ja + SurveyGorenje::sendGorenjeRekID($rek_id); + } + } + + // Preverimo ce imamo vklopljen modul za panel - potem napolnimo url z ustreznimi parametri + if(isset($modules['panel'])){ + + // Pridobimo vse nastavitve panela + $sp = new SurveyPanel(get('anketa')); + $panel_settings = $sp->getPanelSettings(); + + // Posebno samo za ipanel - Izraelski projekt + if($app_settings['app_name'] == 'www.1ka.si' && (get('anketa') == '232992' || get('anketa') == '232795' || get('anketa') == '248217' || get('anketa') == '248757' || get('anketa') == '248762')){ + + // Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko + $sqlP = sisplet_query("SELECT d.*, s.variable FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g + WHERE d.usr_id='".get('usr_id')."' AND s.variable IN ('id', 'i_project', 'i_user1', 'i_user4', 'i_user5', 'i_user6', 'i_user7') + AND d.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='".get('anketa')."'"); + while($rowP = mysqli_fetch_array($sqlP)){ + + if($rowP['variable'] == 'id') + $panelist_id = $rowP['text']; + elseif($rowP['variable'] == 'i_user1') + $panelist_user = $rowP['text']; + elseif($rowP['variable'] == 'i_project') + $panelist_project = $rowP['text']; + elseif($rowP['variable'] == 'i_user4') + $user_data4 = $rowP['text']; + elseif($rowP['variable'] == 'i_user5') + $user_data5 = $rowP['text']; + elseif($rowP['variable'] == 'i_user6') + $user_data6 = $rowP['text']; + elseif($rowP['variable'] == 'i_user7') + $user_data7 = $rowP['text']; + } + + // Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default) + $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default']; + + // Nastavimo koncen url za redirect + $finishUrl = 'http://survey.ipanel.co.il/mrIWeb/mrIWeb.dll?'; + $finishUrl .= 'id='.$panelist_id.'&i.user1='.$panelist_user.'&i.project='.$panelist_project.'&i.user9='.$panel_status; + $finishUrl .= '&i.user4='.$user_data4.'&i.user5='.$user_data5.'&i.user6='.$user_data6.'&i.user7='.$user_data7; + } + else{ + // Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko + $sqlP = sisplet_query("SELECT d.* FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g + WHERE d.usr_id='".get('usr_id')."' AND s.variable='".$panel_settings['user_id_name']."' + AND d.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='".get('anketa')."'"); + $rowP = mysqli_fetch_array($sqlP); + $panelist_id = $rowP['text']; + + // Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default) + $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default']; + + // Nastavimo koncen url za redirect + $finishUrl = $row['url'].'?'.$panel_settings['user_id_name'].'='.$panelist_id.'&'.$panel_settings['status_name'].'='.$panel_status; + } + } + + // Na koncu preverimo, če gre za hierarhijo in resevanje supersifre + // V kolikor gre za hierarhijo, ki uporablja superšifro potem pred redirectom poberemo vse parametre + if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2) { + $resevanje = sisplet_query("SELECT * FROM srv_hierarhija_supersifra_resevanje WHERE user_id='".get('usr_id')."'", "obj"); + + $kode = sisplet_query("SELECT kode FROM srv_hierarhija_supersifra WHERE koda='".$resevanje->supersifra."'", "obj"); + $kode = unserialize($kode->kode); + + sisplet_query("UPDATE srv_hierarhija_supersifra_resevanje SET status=6 WHERE user_id='".get('usr_id')."'"); + + // V kolikor prispemo smo ravno zaključili reševanje zadnje ankete v supersifri potem prikažemo konec oz. glede na nastavitve ankete in ne preusmerimo ponovno na začetek + if(end($kode) != $resevanje->koda){ + // Glede na vrednost + $naslednja = array_search($resevanje->koda, $kode) + 1; + + $url = sisplet_query("SELECT url FROM srv_hierarhija_koda WHERE koda='".$kode[$naslednja]."'", "obj"); + + $url_encode_spremenljivke = urlencode(base64_encode($url->url . '&supersifra=' . $resevanje->supersifra.'&resujem='.$naslednja)); + $redirect = $site_url .'a/'.get('anketa').'?enc='.$url_encode_spremenljivke; + + header("Location: $redirect"); + } + + } + + // za posebno MJU anketo pridobimo skupino in preusmerimo nazaj na zacetek z ustreznim lepim linkom + if(isset($modules['mju_theme'])){ + + // Dobimo id skupine za respondenta + $sqlGroup = 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"); + $rowGroup = mysqli_fetch_array($sqlGroup); + + if($rowGroup['vre_id'] > 0){ + + $sqlGroupName = sisplet_query("SELECT naslov FROM srv_vrednost WHERE id='".$rowGroup['vre_id']."' AND spr_id='".$rowGroup['spr_id']."'"); + $rowGroupName = mysqli_fetch_array($sqlGroupName); + + $finishUrl = 'https://gov-ankete.si/'.$rowGroupName['naslov']; + } + else{ + $finishUrl = 'https://gov-ankete.si/'; + } + } + // za posebno MJU anketo pridobimo skupino in preusmerimo nazaj na zacetek z ustreznim lepim linkom + if(isset($modules['mju_redirect'])){ + + // Dobimo id skupine za respondenta + $sqlGroup = 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"); + $rowGroup = mysqli_fetch_array($sqlGroup); + + if($rowGroup['vre_id'] > 0){ + + $sqlGroupName = sisplet_query("SELECT naslov, variable FROM srv_vrednost WHERE id='".$rowGroup['vre_id']."' AND spr_id='".$rowGroup['spr_id']."'"); + $rowGroupName = mysqli_fetch_array($sqlGroupName); + + $finishUrl = 'https://gov-ankete.si/UE1_'.$rowGroupName['variable']; + } + else{ + $finishUrl = 'https://gov-ankete.si/'; + } + } + + + // URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php) + if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '') + $close_url = $app_settings['survey_finish_url']; + else + $close_url = 'https://www.1ka.si/'; + + + // pri formi posebej pogledamo ce anketo zapremo ali skocimo na url - po novem je lahko vklopljen zakljucek + if ($row['survey_type'] == 1 && $row['show_concl'] == 0) { + + if ($row['concl_link'] == 1) { + header("Location: $finishUrl"); + } + else { + echo ' ' . "\n"; + } + } + // zakljucek ankete ni prikazan in oznaceno je da zapremo anketo + elseif ($row['show_concl'] == 0) { + + if ($row['concl_link'] == 0) { + echo ' ' . "\n"; + } + // Rekurzivno + else if ($row['concl_link'] == 2) { + header("Location: " . SurveyInfo::getSurveyLink()); + } + else { + header("Location: $finishUrl"); + } + + } else { + + SurveySetting::getInstance()->Init(get('anketa')); + $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img'); + $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : ''; + if (isset($_GET['mobile']) && $_GET['mobile'] == 1) + $class .= ' mobile_preview'; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2) + $class .= ' tablet_preview'; + + + echo '
'; + echo '
'; + + echo '
' . "\n"; + echo '
'; + + echo '
' . "\n"; + + Display::getInstance()->logo(); + + Display::getInstance()->progress_bar(); + + echo '

' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + + echo '
' . "\n"; + + Statistic::displayStatistika(true); + + $this->displayKonecContent(); + + echo '
' . "\n"; //-grupa + + if ($row['user_from_cms'] == 2) { + //echo '

'.$lang['srv_nextins'].'

'; + echo '

' . $lang['srv_nextins'] . '

'; + } + + SurveySetting::getInstance()->Init(get('anketa')); + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + if (!get('printPreview')) { + $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang); + if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage']; + + $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink'); + + echo '
'; + // prejsna stran, prikazemo ce ni v zakjucku drugace nastavljeno + if ($row['concl_back_button'] != '0') + #echo ''."\n"; + if ($display_backlink != '0') { + // Posebej za WebSM anketo - back naredimo tako, da poiscemo prejsnjo stran + if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') { + + $grupa = Find::findPrevGrupa(get('anketa'), get('grupa')); + $grupa = ($grupa > 0) ? '&grupa=' . $grupa : ''; + + $language = (isset($_GET['language'])) ? '&language=' . $_GET['language'] : ''; + + $link = SurveyInfo::getSurveyLink(false, false) . $grupa . $language; + + echo ''; + } else { + echo '' . "\n"; + } + } + } + if ($finishUrl != '') { + + if ($row['concl_link'] == 1) { + if (!isset($modules['uporabnost'])) + $js = 'document.location.href=\'' . $finishUrl . '\';'; + else + $js = 'top.location.href=\'' . $finishUrl . '\';'; + } + elseif ($row['concl_link'] == 2) { + if (!isset($modules['uporabnost'])) + $js = 'document.location.href=\'' . SurveyInfo::getSurveyLink() . '\';'; + else + $js = 'top.location.href=\'' . SurveyInfo::getSurveyLink() . '\';'; + } + elseif (!isset($modules['uporabnost'])) { + if (Common::checkModule('evalvacija') == '1') + $js = 'window.close(); document.location.href=\'https://www.uni-lj.si/\';'; + else + $js = 'window.close(); document.location.href=\''.$close_url.'\';'; + } + // uporabnost + else + $js = 'top.close();'; + + if (isset($_GET['popup']) && $_GET['popup'] == '1') + $js = '$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); '; + + + // Za posebno MJU anketo posebej pohendlamo kaj se zgodi po koncu + if(isset($modules['mju_theme'])){ + + // Mobitel ali tablica se po koncu zapre + if(get('mobile') == 1 || get('mobile') == 2){ + $js = 'window.close(); document.location.href=\'https://http://www.mju.gov.si//\';'; + } + // Drugace se preusmeri na zacetek + else{ + $js = 'document.location.href=\'' . $finishUrl . '\';'; + } + } + + + if (!get('printPreview')) { + $srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang); + /*if ($row['text'] != '') // besedilo koncne povezave shranimo v misc setting, da bo konsistentno z ostalimi prevodi + $text = $row['text']; + else*/ + if ($srv_konec != '') + $text = $srv_konec; + else + $text = $lang['srv_konec']; + + if ($row['concl_end_button'] == 1) + echo '' . "\n"; + } + } + + echo '
'; + + if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos + $sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1"); + $rowg = mysqli_fetch_array($sqlg); + //echo '

'.$lang['srv_nextins'].' | '.$lang['srv_insend'].'

'; + echo '

' . $lang['srv_nextins'] . ' | ' . $lang['srv_insend'] . '

'; + } + + echo '
' . "\n"; // -container + + $this->displayFooterNote(); + #$this->displayRespondetnPDF(); + + echo '
' . "\n"; // -outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + } + + //is respondent lurker? + $sqlur = sisplet_query("SELECT lurker FROM srv_user WHERE id = '" . get('usr_id') . "'", "obj"); + + // ce je tko oznacen in ce reposndent ni lurker, posljemo se alerte + if (mysqli_num_rows($sqlAlert) > 0 && $sqlur->lurker == 0) + Helper::getInstance()->alert(); + + // Ce je vklopljen evoli team meter, preverimo, ce posiljamo obvestilo po dosezeni kvoti + if( (isset($modules['evoli_teammeter']) || isset($modules['evoli_quality_climate']) || isset($modules['evoli_teamship_meter']) || isset($modules['evoli_organizational_employeeship_meter'])) + && $tm_quota_increase + ){ + Helper::getInstance()->alertTeamMeter(); + } + + Js::js_tracking(); + + } else { // za print preview in pdf + + $row = SurveyInfo::getInstance()->getSurveyRow(); + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + if ($row['conclusion'] == '') { + $concl = $lang['srv_end']; + } else { + $concl = $row['conclusion']; + } + if (get('lang_id') != null) { + $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "'AND spr_id='-2' AND lang_id='" . get('lang_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + if ($row1['naslov'] != '') $concl = $row1['naslov']; + } + echo '

' . $concl . '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + } + } + + public function displayKonecContent(){ + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + echo '
' . "\n"; + + // Ce gre za gdpr zakljucek (respondent ni sprejel pogojev) + if(GDPR::isGDPRSurveyTemplate(get('anketa')) && isset($_POST['gdpr_accept']) && $_POST['gdpr_accept'] == '0'){ + self::displayKonecGDPR(); + } + else{ + + if ($row['conclusion'] == '') { + $concl = self::$lang['srv_end']; + } else { + $concl = $row['conclusion']; + } + if (get('lang_id') != null) { + $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='-2' AND lang_id='" . get('lang_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + if ($row1['naslov'] != '') $concl = $row1['naslov']; + } + + $concl = Helper::dataPiping($concl); + + echo '

' . $concl . '

' . "\n"; + + Display::getInstance()->displayReturnEditURL(); + Display::getInstance()->displayRespondetnPDF(); + } + + echo '
' . "\n"; + + + // Prikaz pravilnih rezultatov v primeru kviza + if(SurveyInfo::getInstance()->checkSurveyModule('quiz')){ + + // Pridobimo nastavitve kviza + $sq = new SurveyQuiz(get('anketa')); + $quiz_settings = $sq->getSettings(); + + if($quiz_settings['results'] == '1' || $quiz_settings['results_chart'] == '1'){ + + echo '
'; + + echo '

'.self::$lang['results'].'

'; + + // Prikaz grafa rezultatov + if($quiz_settings['results_chart'] == '1') + Display::getInstance()->displayQuizChart(); + + // Prikaz rezultatov + if($quiz_settings['results'] == '1') + Display::getInstance()->displayQuizAnswers(); + + echo '
'; + } + } + + // Prikaz Excelleration matrix grafa ce je vklopljen napredni modul + if(SurveyInfo::getInstance()->checkSurveyModule('excell_matrix')){ + echo '
'; + Display::getInstance()->displayExcellChart(); + echo '
'; + } + + // SKAVTI - prikaz povzetka odgovorov in grafa + global $mysql_database_name; + //if($mysql_database_name == '1ka' && get('anketa') == '64'){ + if($mysql_database_name == 'real1kasi' && (get('anketa') == '293926' || get('anketa') == '314856' || get('anketa') == '332793')){ + echo '
'; + Display::getInstance()->displaySkavtiAnswers(); + echo '
'; + } + + // NIJZ - prikaz radar grafa in tabele + global $site_domain; + if( ($site_domain == 'test.1ka.si' && get('anketa') == '8892') || ($site_domain == 'anketa.nijz.si' && get('anketa') == '126738') ){ + + $nijz = new SurveyNIJZ(get('anketa'), get('usr_id')); + + $nijz->displayRadar(); + $nijz->displayTable(); + } + } + + // Prikazemo dodaten uvod za GDPR + public function displayKonecGDPR() + { + //$user_settings = GDPR::getSurveySettings(get('anketa')); + + echo '
'; + echo '

'.self::$lang['srv_gdpr_concl'].'

'; + echo '
'; + } + + + /** + * @desc prikaze konec ankete + */ + public function displayKonecGlasovanje(){ + global $app_settings; + + echo ''; + + //izpis zakljucka + if (isset($_GET['glas_end']) && $_GET['glas_end'] == 1) { + if (!get('printPreview')) { + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + SurveySetting::getInstance()->Init(get('anketa')); + $endButton = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec'); + $endButton = ($endButton == '') ? self::$lang['srv_konec'] : $endButton; + //$row['text'] == '' ? $endButton = self::$lang['srv_konec'] : $endButton = $row['text']; + + //dodaten naslov gumba zakljucek + $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage'); + if ($srv_prevpage != '') + $text = $srv_prevpage; + else + $text = self::$lang['srv_prevpage']; + + + // URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php) + if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '') + $close_url = $app_settings['survey_finish_url']; + else + $close_url = 'https://www.1ka.si/'; + + // zakljucek ankete ni prikazan in oznaceno je da zapremo anketo + if ($row['show_concl'] < 1) { + if ($row['concl_link'] == 0) { + echo ' ' . "\n"; + } else { + header("Location: $row[url]"); + } + } + + + echo '
'; + echo '
'; + + echo '
' . "\n"; + echo '
'; + + echo '
' . "\n"; + + Display::getInstance()->logo(); + + Display::getInstance()->progress_bar(); + + echo '

' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + + echo '
' . "\n"; + + echo '
' . "\n"; + + if ($row['conclusion'] == '') { + $concl = self::$lang['srv_end']; + } else { + $concl = $row['conclusion']; + } + echo '

' . $concl . '

' . "\n"; + + echo '
' . "\n"; + + echo '
' . "\n"; // -grupa + + if ($_GET['preview'] == 'on') { + echo '' . "\n"; + } + + echo '
'; + + + if ($row['concl_back_button'] == 1) { + echo ''; + } + + if ($row['concl_end_button'] == 1) { + if ($row['concl_link'] == 1) + $js = 'document.location.href=\'' . $row['url'] . '\';'; + else + $js = 'window.close(); document.location.href=\''.$close_url.'\';'; + + if (!get('printPreview')) { + echo '' . "\n"; + } + } + + echo '
'; + + + echo '
' . "\n"; // -container + + $this->displayFooterNote(); + + echo '
'; // -outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + + // ce je tko oznacen posljemo se alerte + $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "' AND (finish_respondent=1 OR finish_respondent_cms=1 OR finish_author=1 OR finish_other =1)"); + if (mysqli_num_rows($sqlAlert) > 0) + Helper::getInstance()->alert(); + } + else { // za print preview in pdf + + $row = SurveyInfo::getInstance()->getSurveyRow(); + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + if ($row['conclusion'] == '') { + $concl = self::$lang['srv_end']; + } else { + $concl = $row['conclusion']; + } + echo '

' . $concl . '

' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + } + } //izpis statistike + else { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $sqls = sisplet_query("SELECT stat FROM srv_spremenljivka s, srv_glasovanje g WHERE g.ank_id = '" . get('anketa') . "' AND s.id = g.spr_id"); + $rows = mysqli_fetch_array($sqls); + + //ce statistike ne prikazujemo skocimo na zakljucek (ce imammo izklopljeno ali nastavleno na samo urednike in ni urednik) + if ($rows['stat'] == 0 || ($rows['stat'] == 2 && self::$admin_type != 0 && self::$admin_type != 1)) { + //header('Location: '.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url').''); + header('Location: ' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url') . ''); + } else { + + echo '
'; + echo '
'; + + echo '
' . "\n"; + echo '
'; + + echo '
' . "\n"; + + Display::getInstance()->logo(); + + Display::getInstance()->progress_bar(); + + echo '

' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + + echo '
' . "\n"; + Statistic::displayStatistika(true); + echo '
' . "\n"; + + echo '
'; + //$url_stat = ''.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url'); + $url_stat = '' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url'); + $js = 'document.location.href=\'' . $url_stat . '\';'; + + // Gumb nazaj + if ($row['concl_back_button'] == 1) { + $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage'); + if ($srv_prevpage != '') + $text = $srv_prevpage; + else + $text = self::$lang['srv_prevpage']; + + echo ''; + } + + if ($row['show_concl'] == 1) { + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + + $srv_potrdi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_potrdi'.$_lang); + if ($srv_potrdi == '') $srv_potrdi = self::$lang['srv_potrdi']; + + echo '' . "\n"; + } + elseif ($row['concl_end_button'] == 1) { + $endButton = self::$lang['srv_konec']; + echo '' . "\n"; + } + + echo '
' . "\n"; + + echo '
' . "\n"; // -container + + echo '
' . "\n"; // -outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + } + } + } + + // Konec pri anketi evoli team meter - ce je kvota polna + public function displayKonecEvoliTM($date_to='') + { + global $mysql_database_name; + global $lang; + global $admin_type; + global $site_url; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + // Popravimo url za skok po koncu ankete ce nima http:// + if ($row['url'] != '' && substr($row['url'], 0, 4) != 'http') { + $finishUrl = 'http://' . $row['url']; + } else { + $finishUrl = $row['url']; + } + + // Dodamo datapiping v url-ju + if($row['url'] != ''){ + // Počistimo html tage + $finishUrl = strip_tags(Helper::dataPiping($finishUrl)); + } + + // Preverimo ce imamo nastavljene kaksne get parametre za dodat pri skoku na url + if ($row['concl_link'] == 1 && $finishUrl != '') { + SurveySetting::getInstance()->Init(get('anketa')); + $concl_url_usr_id = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_usr_id'); + $concl_url_status = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_status'); + $concl_url_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_recnum'); + + if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1') + $finishUrl .= '?'; + + if ($concl_url_usr_id == '1') { + $finishUrl .= 'usr_id=' . get('usr_id') . '&'; + } + + if ($concl_url_status == '1' || $concl_url_recnum == '1') { + $sqlU = sisplet_query("SELECT last_status FROM srv_user WHERE id = '" . get('usr_id') . "'"); + $rowU = mysqli_fetch_array($sqlU); + + if($concl_url_recnum == '1') + $finishUrl .= 'recnum=' . $rowU['recnum'] . '&'; + + if($concl_url_status == '1') + $finishUrl .= 'status=' . $rowU['last_status'] . '&'; + } + + if ($concl_url_usr_id == '1' || $concl_url_status == '1') + $finishUrl = substr($finishUrl, 0, -1); + } + + if ($row['show_concl'] == 0) { + + if ($row['concl_link'] == 0) { + echo ' ' . "\n"; + } + // Rekurzivno + else if ($row['concl_link'] == 2) { + header("Location: " . SurveyInfo::getSurveyLink()); + } + else { + header("Location: $finishUrl"); + } + + } + else { + + SurveySetting::getInstance()->Init(get('anketa')); + $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img'); + $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : ''; + if (isset($_GET['mobile']) && $_GET['mobile'] == 1) + $class .= ' mobile_preview'; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2) + $class .= ' tablet_preview'; + + echo '
'; + echo '
'; + + echo '
' . "\n"; + echo '
'; + + echo '
' . "\n"; + + Display::getInstance()->logo(); + + Display::getInstance()->progress_bar(); + + echo '

checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + + // Vsebina zakljucka ce je kvota polna oz je presezen datum + echo '
' . "\n"; + echo '
' . "\n"; + + echo '

'; + if($date_to != '') + echo self::$lang['srv_evoli_survey_expired'].' '.$date_to.' '.self::$lang['srv_evoli_survey_end_help']; + else + echo self::$lang['srv_evoli_survey_quota_full'].' '.self::$lang['srv_evoli_survey_end_help']; + echo '

'; + + echo '
' . "\n"; + echo '
' . "\n"; //-grupa + + + if ($row['user_from_cms'] == 2) { + echo '

' . $lang['srv_nextins'] . '

'; + } + + SurveySetting::getInstance()->Init(get('anketa')); + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + if (!get('printPreview')) { + $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang); + if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage']; + + $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink'); + + echo '
'; + // prejsna stran, prikazemo ce ni v zakjucku drugace nastavljeno + /*if ($row['concl_back_button'] != '0') + if ($display_backlink != '0') { + echo '' . "\n"; + }*/ + } + if ($finishUrl != '') { + if ($row['concl_link'] == 1) { + if (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost')) + $js = 'document.location.href=\'' . $finishUrl . '\';'; + else + $js = 'top.location.href=\'' . $finishUrl . '\';'; + } elseif ($row['concl_link'] == 2) { + if (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost')) + $js = 'document.location.href=\'' . SurveyInfo::getSurveyLink() . '\';'; + else + $js = 'top.location.href=\'' . SurveyInfo::getSurveyLink() . '\';'; + } elseif (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost')) { + if (Common::checkModule('evalvacija') == '1') + $js = 'window.close(); document.location.href=\'https://www.uni-lj.si/\';'; + else + $js = 'window.close(); document.location.href=\'https://www.1ka.si/\';'; + } // uporabnost + else + $js = 'top.close();'; + + if (isset($_GET['popup']) && $_GET['popup'] == '1') + $js = '$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); '; + + + if (!get('printPreview')) { + $srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang); + + if ($srv_konec != '') + $text = $srv_konec; + else + $text = $lang['srv_konec']; + + if ($row['concl_end_button'] == 1) + echo '' . "\n"; + } + } + + echo '
'; + + if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos + $sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1"); + $rowg = mysqli_fetch_array($sqlg); + //echo '

'.$lang['srv_nextins'].' | '.$lang['srv_insend'].'

'; + echo '

' . $lang['srv_nextins'] . ' | ' . $lang['srv_insend'] . '

'; + } + + echo '
' . "\n"; // -container + + $this->displayFooterNote(); + + echo '
' . "\n"; // -outercontainer + echo '
'; // -outercontainer_holder + } + } + + + /** + * @desc prikaze trenutno anketo + */ + public function displayAnketa() + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + if (!get('printPreview')) { + + // crn div za ozadje popupov + echo '
'; + echo ''; + + SurveySetting::getInstance()->Init(get('anketa')); + $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img'); + $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : ''; + if (isset($_GET['mobile']) && $_GET['mobile'] == 1) + $class .= ' mobile_preview'; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2) + $class .= ' tablet_preview'; + + + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + + echo '
' . "\n"; + + $d = new Display(); + $d->logo(); + $d->progress_bar(); + + echo '

checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + + if (get('quick_view') == true) { + echo '
'; + echo self::$lang['srv_quick_view_text']; + echo '
'; + } + + //opozorilo ce urejamo ze reseno anketo + if (isset($_GET['urejanje'])) { + echo '
'; + echo self::$lang['srv_edit_text']; + echo '
'; + + // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno + //ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE + $sas = new SurveyAdminSettings(); + $sas->checkFirstDataChange(); + + // Updatamo tracking (ker gre za editiranje odgovorov) + TrackingClass::update(get('anketa'), 4); + } + + $this->displayGrupa(); + + echo '
' . "\n"; // - container + + $this->displayFooterNote(); + + // TAWK chat, ce je vklopljen + if(SurveyInfo::getInstance()->checkSurveyModule('chat')){ + Display::getInstance()->displayChatTAWK(); + } + + echo '
'; // - outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + + Js::js_tracking(); + + } else { + + echo '
' . "\n"; + $this->displayGrupa(); + echo '
' . "\n"; + } + } + + public function displayAllPages() + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + + echo '
' . "\n"; + + Display::getInstance()->logo(); + Display::getInstance()->progress_bar(); + + if (!get('printPreview')) { + echo '

checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '

' . "\n"; + } + + echo '
'; + $this->displayIntroductionContent(); + echo '
'; + + $this->displayGrupa(); + + echo '
'; + $this->displayKonecContent(); + echo '
'; + + echo '
' . "\n"; // - container + + echo '
' . "\n"; // - outercontainer + + echo '
'; + echo '
'; // -outercontainer_holder + + $this->displayFooterNote(); + } + + /** + * @desc prikaze trenutno grupo + */ + public function displayGrupa(){ + global $admin_type; + + + // Ce imamo vklopljene napredne parapodatke zabelezimo id-strani + if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){ + SurveyAdvancedParadataLog::getInstance()->displayGrupa(get('grupa')); + } + + $sql = sisplet_query("SELECT naslov, vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'"); + $row = mysqli_fetch_array($sql); + if (!get('printPreview')) { + + Display::getInstance()->display_tabs(); + + echo '
' . "\n"; + echo '
' . "\n"; + echo ' ' . "\n"; + + SurveySetting::getInstance()->Init(get('anketa')); + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + // izbira jezika za respondenta - Ce nimamo prikazanega uvoda, prikazemo izbiro na prvi strani + if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $rowa['multilang'] == 1 && $rowa['show_intro'] == 0 && $row['vrstni_red'] == 1) { + + $lang_resp = $rowa['lang_resp']; + $lang_array = array(); + + $current = self::$lang['id']; + $file = lang_path($lang_resp); + include($file); + + $lang_array[$lang['id']] = $lang['language']; + + $file = lang_path($current); + include($file); + + $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language"); + while ($rowl = mysqli_fetch_array($sqll)) { + $lang_array[$rowl['lang_id']] = $rowl['language']; + } + + echo '
' . "\n"; + + // Izbira jezika z dropdown menijem + if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) { + echo '

' . self::$lang['lang'] . ': '; + echo ' '; + echo '

' . "\n"; + } + // Izbira jezika z radio gumbi (default) + else { + echo '

' . self::$lang['lang'] . ':

'; + echo ''; + + foreach ($lang_array AS $key => $val) { + echo '
'; + } + echo '
'; + } + + echo '
' . "\n"; + } + + Vprasanja::getInstance()->displaySpremenljivke(); + + echo '
' . "\n"; // - grupa + + Js::getInstance()->generateSubmitJS(); + + echo '
' . "\n"; + + Js::getInstance()->generateBranchingJS(); + + // Disable odgovorov, ce je ze izpolnjeval to stran in ima vklopljeno nastavitev, da ni dovoljeno naknadno vnasanje odogovorov + if($rowa['subsequent_answers'] == '0' && $admin_type != '0' && $admin_type != '1'){ + + // Preverimo, ce je uporabnik ze bil na strani + if(Check::getInstance()->check_subsequent_visit()){ + echo ''; + } + } + + // nov zgornji link pri uporabnosti + $link = SurveySetting::getInstance()->getSurveyMiscSetting('uporabnost_link_' . get('grupa')); + if ($link != '' && strlen($link) > 7) + echo ""; + } + else{ + Display::getInstance()->displaySpremenljivke(); + } + } + + + public function displayFooterNote(){ + global $mysql_database_name, $app_settings; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + echo ''; + + + // OKNO Z NASTAVITVAMI ZA PREVIEW / TEST + if (isset($_GET['preview']) && $_GET['preview'] == 'on' && $_GET['no_preview'] != '1') { + + echo '
'; + + + // Gump za odprtje/zaprtje okna + echo '
'; + + echo ''; + echo ''; + + echo '
'; + + + // Preklop na celostranski preview + echo '
'; + + echo ''.self::$lang['srv_mode'] . ':'; + echo '' . self::$lang['srv_normal'] . ''; + echo '' . self::$lang['srv_scrolling'] . ''; + + echo '
'; + + + // Vsebina - preview-holder + echo '
'; + + echo '
'; + + if ($_GET['testdata'] == 'on') + echo '

' . self::$lang['srv_testalert'] . '

'; + else + echo '

' . self::$lang['srv_previewalert'] . '

'; + + if ($row['multilang'] == 1) { + $lang_resp = $row['lang_resp']; + $lang_array = array(); + + $current = self::$lang['id']; + $file = lang_path($lang_resp); + include($file); + + $lang_array[$lang['id']] = $lang['language']; + $file = lang_path($current); + include($file); + + $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language"); + while ($rowl = mysqli_fetch_array($sqll)) { + $lang_array[$rowl['lang_id']] = $rowl['language']; + } + + // FORM s preklopom jezika + echo '
'; + + if (isset($_GET['code'])) + echo ''; + + if (isset($_GET['preview'])) + echo ''; + + if (isset($_GET['disableif'])) + echo ''; + + if (isset($_GET['displayifs'])) + echo ''; + + if (isset($_GET['displayvariables'])) + echo ''; + + if (isset($_GET['disablealert'])) + echo ''; + + if (isset($_GET['disablecode'])) + echo ''; + + if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0) + echo ''; + + if (isset($_GET['grupa'])) + echo ''; + + + echo '

' . self::$lang['lang'] . ': '; + + echo '

' . "\n"; + + echo '
'; + } + + + // Preklop med preview-ji za mobilnik, tablico in pc + if(!get('displayAllPages')){ + + echo '' . self::$lang['srv_para_graph_device'] . ': '; + + if (isset($_GET['mobile']) && $_GET['mobile'] == '1') + $device_value = 1; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == '2') + $device_value = 2; + else + $device_value = 0; + + echo ''; + + // Ce imamo izklopljene mobilne prilagoditve ne pustimo preview-ja na mobile, ker itak ne prikaze scalano + $mobile_friendly = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_friendly'); + if($mobile_friendly != '0'){ + echo ''; + echo ''; + } + + echo ''; + } + + + // FORM z dropdownom za preklop med stranmi + echo '
'; + + if (isset($_GET['code'])) + echo ''; + + if (isset($_GET['preview'])) + echo ''; + + if (isset($_GET['mobile'])) + echo ''; + + echo ''; + + if (isset($_GET['displayifs'])) + echo ''; + + if (isset($_GET['displayvariables'])) + echo ''; + + if (isset($_GET['disablealert'])) + echo ''; + + if (isset($_GET['disablecode'])) + echo ''; + + if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0) + echo ''; + + if ($row['multilang'] == 1 && isset($_GET['language'])) + echo ''; + + + // Skok na doloceno stran - samo ce nimamo prikaza vse na eni strani + if(!get('displayAllPages')){ + echo '

' . self::$lang['srv_jump_to'] . ':

'; + } + + echo '
'; + + + // FORM s checkbox nastavitvami + $link = SurveyInfo::getSurveyLink(get('anketa')) . '' . Header::getSurveyParams(false, null, array('disableif', 'disablealert', 'disablecode', 'displayifs', 'displayvariables', 'hidecomment', 'mobile')) . '&survey-' . get('anketa') . '=' . $_GET['survey-' . get('anketa') . ''] . '&grupa=' . $_GET['grupa']; + echo '
'; + + echo ''; + + if ($row['multilang'] == 1 && isset($_GET['language'])) + echo ''; + + if (isset($_GET['code'])) + echo ''; + + echo '

'; + + echo '

'; + + // Pogoj za izlapljanje kode ce imamo email vabila z zahtevano kodo + if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0) { + echo '

'; + } + + echo '

'; + + echo '

'; + + + // Komentarji - vidno samo ce imamo ustrezen paket + $userAccess = UserAccess::getInstance(self::$global_user_id); + if($userAccess->checkUserAccess($what='komentarji')){ + + $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment'); + $preview_disable_test_insert = SurveySetting::getInstance()->getSurveyMiscSetting('preview_disable_test_insert'); + + if ($_GET['testdata'] == 'on' || $preview_disable_test_insert == 0) { + + if ($question_resp_comment == 0) { + echo '

'; + + if ($_GET['testdata'] == 'on') + echo self::$lang['srv_preview_comments']; + else + echo self::$lang['srv_savedatapreview']; + + echo '

'; + } + else { + if ($_GET['testdata'] == 'on') { + echo '

'; + } else { + echo '

'; + echo self::$lang['srv_savedatapreview']; + echo '

'; + } + } + } + } + + + + echo '
'; + + echo '
' . "\n"; // preview + + + // Komentarji - vidno samo ce imamo ustrezen paket + if($userAccess->checkUserAccess($what='komentarji')){ + + if ($question_resp_comment == 1 && $_GET['testdata'] == 'on') { + $question_resp_comment_inicialke = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke'); + + if ($question_resp_comment_inicialke == 1) { + echo '

' . self::$lang['srv_inicialke'] . ':

'; + echo ''; + } + } + + $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'"); + (mysqli_num_rows($sqlUserAutor) > 0) ? save('userAutor', true) : save('userAutor', false); + // Komentarji urednikov na anketo + if (get('userAutor')) { + + echo '
'; + + $view = 1; + $survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment'); + $preview_hide_survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('preview_hide_survey_comment'); + if ((self::$admin_type <= $survey_comment && $survey_comment != '') && (/*$preview_hide_survey_comment != 1 ||*/ + $_GET['testdata'] == 'on') + ) { + + echo ''; + + $show_survey_comment = $_GET['show_survey_comment']; + if ($row['forum'] == 0 || $row['thread'] == 0) { + echo ''; + echo self::$lang['srv_comment_splosen'] . ' '; + echo ''; + echo ''; + } else { + + $sqlf = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]'"); + $rowf = mysqli_fetch_array($sqlf); + $rowf['count']--; //zaradi 1. avtomatskega posta + + echo ''; + echo self::$lang['srv_comment_splosen'] . ' '; + echo ''; + + // ali prikazemo okno odprto - je dodan tak admin komentar + $sqlf1 = sisplet_query("SELECT * FROM post p WHERE p.tid='$row[thread]' AND p.ocena='5'"); + while ($rowf1 = mysqli_fetch_array($sqlf1)) { + $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='self::$global_user_id'"); + if (mysqli_num_rows($s) == 0) + $show_survey_comment = 1; + } + echo ''; + } + + echo ''; + // Ce je tole vklopljeno se js porusi? + //echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + } + + // Uredniske nastavitve link + echo '' . self::$lang['settings'] . ' '; + + echo '
'; + } + // Komentarji respondentov na anketo + elseif (self::$global_user_id > 0 || true) { + + echo '

'; + + $view = 1; + $survey_comment_resp = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment_resp'); + $preview_hide_survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('preview_hide_survey_comment'); + if (((self::$admin_type <= $survey_comment_resp && self::$admin_type != -1 && $survey_comment_resp != '') || $survey_comment_resp == 4) && ($preview_hide_survey_comment != 1 || $_GET['testdata'] == 'on')) { + + $show_survey_comment = $_GET['show_survey_comment']; + + if ($row['forum'] == 0 || $row['thread_resp'] == 0) { + echo ''; + echo self::$lang['srv_comment_splosen'] . ' '; + //echo ''; + echo ''; + echo ''; + } + else { + + $sqlf = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread_resp]'"); + $rowf = mysqli_fetch_array($sqlf); + $rowf['count']--; //zaradi 1. avtomatskega posta + echo ''; + echo self::$lang['srv_comment_splosen'] . ' '; + echo ''; + + $sqlf1 = sisplet_query("SELECT * FROM post p WHERE p.tid='$row[thread_resp]' AND p.ocena='5'"); + while ($rowf1 = mysqli_fetch_array($sqlf1)) { + $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='self::$global_user_id'"); + if (mysqli_num_rows($s) == 0) + $show_survey_comment = 1; + } + echo ''; + } + + echo ''; + // Ce je tole vklopljeno se js porusi? + //echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '

'; + } + } + + echo '
' . "\n"; // preview-holder + + echo '
' . "\n"; // preview-window + + + ?>checkUserAccess($what='komentarji')){ + + // Prikazemo okno s komentarji ce je nastavljeno da je vedno odprto + $preview_survey_comment_showalways = SurveySetting::getInstance()->getSurveyMiscSetting('preview_survey_comment_showalways'); + if ($preview_survey_comment_showalways == 1) { + + $view = 1; + $show_survey_comment = '1';//$_GET['show_survey_comment']; + + ?>'; + if($mysql_database_name == 'vprasalnikirsrssi') + echo self::$lang['srv_cookie_ok_rsrs']; + else + echo self::$lang['srv_cookie_ok']; + echo '
'; + + ?>'; + echo self::$lang['srv_test_alert']; + echo ''; + + ?>'; + echo self::$lang['srv_preview_alert']; + echo ''; + + ?>'; + echo self::$lang['srv_javascript_warning']; + echo ''; + } + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/CheckController.php b/main/survey/app/Controllers/CheckController.php new file mode 100644 index 0000000..d39a6c2 --- /dev/null +++ b/main/survey/app/Controllers/CheckController.php @@ -0,0 +1,774 @@ +checkSpremenljivka($row['id'])) + return true; + + } + + return false; + } + + /** + * @desc preveri ali je spremenljivka vidna (zaradi branchinga) (oz. lahko je nastavljena vidnost samo administratorju) + */ + public function checkSpremenljivka($spremenljivka, $isTestData=false) + { + $checkSpremenljivka = get('checkSpremenljivka'); + if (array_key_exists($spremenljivka, $checkSpremenljivka)) { + return $checkSpremenljivka[$spremenljivka]; + } + + $row = Model::select_from_srv_spremenljivka($spremenljivka); + + // ce vprasanje ni vidno ali ce uporabnik nima dostopa do vprasanja + if ($row['visible'] == 0 || !((self::$admin_type <= $row['dostop'] && self::$admin_type >= 0) || (self::$admin_type == -1 && $row['dostop'] == 4))) { + return save('checkSpremenljivka[' . $spremenljivka . ']', false, 1); + } + + // Pri testnih podatkih ne upostevamo ifov, ker drugace nic ne napolni + if(!$isTestData){ + $sql1 = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$spremenljivka'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + if (!$this->checkIf($row1['parent'])) + return save('checkSpremenljivka[' . $spremenljivka . ']', false, 1); + } + + return save('checkSpremenljivka[' . $spremenljivka . ']', true, 1); + } + + /** + * @desc preveri ali se elementi v podanem IFu prikazejo ali ne + */ + public function checkIf($if) + { + if ($if == 0) return true; + + $checkIf = get('checkIf'); + if (array_key_exists($if, $checkIf)) { + return $checkIf[$if]; + } + + // preverimo po strukturi navzgor + $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_if = '$if'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + if (!$this->checkIf($row['parent'])) { + return save('checkIf[' . $if . ']', false, 1); + } + + $sql = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + // ce je IF oznacen da se vedno prikaze + if ($row['enabled'] == 1) + return save('checkIf[' . $if . ']', true, 1); + + // ce je IF oznacen da se nikoli ne prikaze + if ($row['enabled'] == 2) + return save('checkIf[' . $if . ']', false, 1); + + // ce je IF oznacen kot blok, potem se vedno prikaze + if ($row['tip'] == 1) + return save('checkIf[' . $if . ']', true, 1); + + + $eval = "if ("; + + //$sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id = '$if' ORDER BY vrstni_red ASC"); + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $i = 0; + // zgeneriramo pogoje z oklepaji, ki jih potem spustimo skozi eval + while ($row = mysqli_fetch_array($sql)) { + if ($i++ != 0) + if ($row['conjunction'] == 0) + $eval .= ' && '; + else + $eval .= ' || '; + + if ($row['negation'] == 1) + $eval .= ' ! '; + + for ($i = 1; $i <= $row['left_bracket']; $i++) + $eval .= ' ( '; + + if ($this->checkCondition($row['id'])) + $eval .= ' true '; + else + $eval .= ' false '; + + for ($i = 1; $i <= $row['right_bracket']; $i++) + $eval .= ' ) '; + } + $eval .= ") return true; else return false; "; + + // ne glih best practice, ampak takle mamo... + $eval = @eval($eval); + if ($eval === true) + return save('checkIf[' . $if . ']', true, 1); + + return save('checkIf[' . $if . ']', false, 1); + } + + /** + * @desc preveri podani condition + */ + public function checkCondition($condition) + { + + $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + // obicne spremenljivke + if ($row['spr_id'] > 0) { + + $row2 = Model::select_from_srv_spremenljivka($row['spr_id']); + + // radio, checkbox, dropdown + if ($row2['tip'] <= 3) { + + $sql3 = sisplet_query("SELECT * FROM srv_condition_vre c, srv_data_vrednost" . get('db_table') . " v + WHERE c.cond_id='$condition' AND c.vre_id=v.vre_id + AND v.spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'"); + + // Dodatno preverjanje ce imamo pogoj -1 + $sql3b = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id='$condition' AND vre_id='-1'"); + $sql4b = sisplet_query("SELECT * FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'"); + + if ($row['operator'] == 0 && mysqli_num_rows($sql3) == 0 && mysqli_num_rows($sql3b) == 0) + return false; + elseif ($row['operator'] == 0 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) > 0) + return false; + elseif ($row['operator'] == 1 && mysqli_num_rows($sql3) > 0) + return false; + elseif ($row['operator'] == 1 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) == 0) + return false; + + // multigrid + } elseif ($row2['tip'] == 6 || $row2['tip'] == 16) { + + // tabela radio (brez dvojne tabele - ki gre v checkgrid) + if ($row2['tip'] == 6 && $row2['enota'] != 3) { + $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_grid" . get('db_table') . " d + WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]' + AND c.grd_id=d.grd_id AND d.usr_id='" . get('usr_id') . "' AND d.vre_id='$row[vre_id]'"); + + // Dodatno preverjanje ce imamo pogoj -1 + $sql3b = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$condition' AND grd_id='-1'"); + $sql4b = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'"); + } // tabela checkboxov + else { + $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_checkgrid" . get('db_table') . " d + WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]' + AND c.grd_id=d.grd_id AND d.usr_id='" . get('usr_id') . "' AND d.vre_id='$row[vre_id]'"); + + // Dodatno preverjanje ce imamo pogoj -1 + $sql3b = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$condition' AND grd_id='-1'"); + $sql4b = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'"); + } + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0 && !mysqli_num_rows($sql3b) > 0) + return false; + elseif ($row['operator'] == 0 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) > 0) + return false; + elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0) + return false; + elseif ($row['operator'] == 1 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) == 0) + return false; + + } elseif ($row2['tip'] == 19 || $row2['tip'] == 20) { + + $sql3 = sisplet_query("SELECT text FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "' AND grd_id='$row[grd_id]'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + $row3 = mysqli_fetch_array($sql3); + + if ($row['operator'] == 0 && !($row3['text'] == $row['text'])) + return false; + elseif ($row['operator'] == 1 && !($row3['text'] != $row['text'])) + return false; + elseif ($row['operator'] == 2 && !($row3['text'] < $row['text'])) + return false; + elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text'])) + return false; + elseif ($row['operator'] == 4 && !($row3['text'] > $row['text'])) + return false; + elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text'])) + return false; + + // textbox + } elseif ($row2['tip'] == 21) { + + $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + $row3 = mysqli_fetch_array($sql3); + + if ($row['operator'] <= 5) { + + if ($row['operator'] == 0 && !($row3['text'] == $row['text'])) + return false; + elseif ($row['operator'] == 1 && !($row3['text'] != $row['text'])) + return false; + + // length + } else { + + if ($row['operator'] == 6 && !(strlen($row3['text']) == $row['text'])) + return false; + elseif ($row['operator'] == 7 && !(strlen($row3['text']) < $row['text'])) + return false; + elseif ($row['operator'] == 8 && !(strlen($row3['text']) > $row['text'])) + return false; + + } + + // vsota + } elseif ($row2['tip'] == 18) { + + $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + $row3 = mysqli_fetch_array($sql3); + + if ($row['operator'] == 0 && !($row3['text'] == $row['text'])) + return false; + elseif ($row['operator'] == 1 && !($row3['text'] != $row['text'])) + return false; + elseif ($row['operator'] == 2 && !($row3['text'] < $row['text'])) + return false; + elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text'])) + return false; + elseif ($row['operator'] == 4 && !($row3['text'] > $row['text'])) + return false; + elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text'])) + return false; + + // razvrscanje + } elseif ($row2['tip'] == 17) { + + $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_rating d + WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]' + AND d.vre_id='$row[vre_id]' AND d.usr_id='" . get('usr_id') . "' AND d.vrstni_red=c.grd_id"); + + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0) + return false; + elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0) + return false; + + // number + } else { + + if ($row['grd_id'] == 0) $text = 'text'; + else $text = 'text2'; + + $sql3 = sisplet_query("SELECT " . $text . " AS text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + $row3 = mysqli_fetch_array($sql3); + + if ($row['operator'] == 0 && !($row3['text'] == $row['text'])) + return false; + elseif ($row['operator'] == 1 && !($row3['text'] != $row['text'])) + return false; + elseif ($row['operator'] == 2 && !($row3['text'] < $row['text'])) + return false; + elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text'])) + return false; + elseif ($row['operator'] == 4 && !($row3['text'] > $row['text'])) + return false; + elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text'])) + return false; + + } + + // recnum + } elseif ($row['spr_id'] == -1) { + + $sqlu = sisplet_query("SELECT recnum FROM srv_user WHERE id = '" . get('usr_id') . "'"); + $rowu = mysqli_fetch_array($sqlu); + + if (!($rowu['recnum'] % $row['modul'] == $row['ostanek'])) + return false; + + // calculations + } elseif ($row['spr_id'] == -2) { + + $calculation = $this->checkCalculation($row['id']); + + if ($row['operator'] == 0 && !($calculation == $row['text'])) + return false; + elseif ($row['operator'] == 1 && !($calculation != $row['text'])) + return false; + elseif ($row['operator'] == 2 && !($calculation < $row['text'])) + return false; + elseif ($row['operator'] == 3 && !($calculation <= $row['text'])) + return false; + elseif ($row['operator'] == 4 && !($calculation > $row['text'])) + return false; + elseif ($row['operator'] == 5 && !($calculation >= $row['text'])) + return false; + + // kvote + } elseif ($row['spr_id'] == -3) { + + $quota = $this->checkQuota($row['id']); + + if ($row['operator'] == 0 && !($quota == $row['text'])) + return false; + elseif ($row['operator'] == 1 && !($quota != $row['text'])) + return false; + elseif ($row['operator'] == 2 && !($quota < $row['text'])) + return false; + elseif ($row['operator'] == 3 && !($quota <= $row['text'])) + return false; + elseif ($row['operator'] == 4 && !($quota > $row['text'])) + return false; + elseif ($row['operator'] == 5 && !($quota >= $row['text'])) + return false; + + // naprava + } elseif ($row['spr_id'] == -4) { + + if (in_array($row['text'], array('0','1','2','3'))){ + + // Star nacin detekcije - vedno vezan na prvi prihod, po novem detektiramo vsakic posebej + /*$sqlU = sisplet_query("SELECT device FROM srv_user WHERE id='".get('usr_id')."'"); + $rowU = mysqli_fetch_array($sqlU); + + if (!($rowU['device'] == $row['text'])) + return false;*/ + + $device = 0; + $useragent = $_SERVER['HTTP_USER_AGENT']; + + if ($useragent != '' && get_cfg_var('browscap')) { + + $browser_detect = get_browser($useragent, true); + + $detect = New Mobile_Detect(); + $detect->setUserAgent($useragent); + + // Detect naprave (pc, mobi, tablet, robot) + if ($detect->isMobile()) { + if ($detect->isTablet()) + $device = 2; + else + $device = 1; + } + elseif ($browser_detect['crawler'] == 1){ + $device = 3; + } + } + + if (!($device == $row['text'])) + return false; + } + } + + return true; + } + + /** + * @desc izracuna kalkulacijo in vrne rezultat + */ + public function checkCalculation($condition) + { + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + + $i = 0; + $expression = ''; + while ($row = mysqli_fetch_array($sql)) { + + if ($i++ != 0) + if ($row['operator'] == 0) + $expression .= ' + '; + elseif ($row['operator'] == 1) + $expression .= ' - '; + elseif ($row['operator'] == 2) + $expression .= ' * '; + elseif ($row['operator'] == 3) + $expression .= ' / '; + + for ($i = 1; $i <= $row['left_bracket']; $i++) + $expression .= ' ( '; + + // spremenljivke + if ($row['spr_id'] > 0) { + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + + $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); + + if ($row1['tip'] <= 3) { // radio, checkbox, dropdown + $sum = 0; + $sql2 = sisplet_query("SELECT v.variable FROM srv_data_vrednost" . get('db_table') . " d, srv_vrednost v WHERE d.vre_id=v.id AND d.spr_id='$row1[id]' AND d.usr_id='" . get('usr_id') . "'"); + while ($row2 = mysqli_fetch_array($sql2)) { // zanka je zaradi checkboxov + $sum += $row2['variable']; + } + $expression .= $sum; + + } elseif ($row1['tip'] == 7 || $row1['tip'] == 22 || $row1['tip'] == 25) { // number, calculation, quota + + $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + $row2 = mysqli_fetch_array($sql2); + if ($row2['text'] == '') $row2['text'] = 0; + $expression .= $row2['text']; + + } elseif ($row1['tip'] == 8) { // datum + + $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + $row2 = mysqli_fetch_array($sql2); + if ($row2['text'] == '') $row2['text'] = 0; + + $row2['text'] = ceil(strtotime($row2['text']) / (60 * 60 * 24)); + + $expression .= $row2['text']; + } + + // multigrid in checkbox + } elseif ($row['vre_id'] > 0) { + + $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); + + // checkbox + if ($row1['tip'] == 2) { + $sum = 0; + $sql2 = sisplet_query("SELECT v.variable FROM srv_data_vrednost" . get('db_table') . " d, srv_vrednost v WHERE d.vre_id=v.id AND d.spr_id='$row1[id]' AND d.usr_id='" . get('usr_id') . "'"); + while ($row2 = mysqli_fetch_array($sql2)) { // zanka je zaradi checkboxov + $sum += $row2['variable']; + } + $expression .= $sum; + } + // multigrid + else{ + $sql1 = sisplet_query("SELECT g.variable, g.other FROM srv_data_grid" . get('db_table') . " d, srv_grid g WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.usr_id='" . get('usr_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + + // Pri multigridih se missingi pri kalkulacijah stejejo kot 0 (in ne -99, -98...) + if ($row1['other'] < 0) + $row1['variable'] = 0; + + $expression .= $row1['variable']; + } + } + + // konstante + } elseif ($row['spr_id'] == -1) { + + $expression .= $row['number']; + + } + + for ($i = 1; $i <= $row['right_bracket']; $i++) + $expression .= ' ) '; + + } + + $expression = 'return ' . $expression . ';'; + + return eval($expression); + + } + + /** + * @desc izracuna kvoto in vrne rezultat + */ + public function checkQuota($condition) + { + + $sql = sisplet_query("SELECT * FROM srv_quota WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $i = 0; + $expression = ''; + while ($row = mysqli_fetch_array($sql)) { + + if ($i++ != 0) + if ($row['operator'] == 0) + $expression .= ' + '; + elseif ($row['operator'] == 1) + $expression .= ' - '; + elseif ($row['operator'] == 2) + $expression .= ' * '; + elseif ($row['operator'] == 3) + $expression .= ' / '; + + for ($i = 1; $i <= $row['left_bracket']; $i++) + $expression .= ' ( '; + + // spremenljivke + if ($row['spr_id'] > 0) { + + $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); + + // radio, checkbox, multigrid + if ($row['vre_id'] > 0) { + + // multigrid + if ($row1['tip'] == 6) + $sql2 = sisplet_query("SELECT COUNT(*) AS quota + FROM srv_data_grid" . get('db_table') . " d, srv_grid g, srv_user u + WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.grd_id='$row[grd_id]' AND d.usr_id=u.id AND u.deleted='0'"); + + // multicheckbox + elseif ($row1['tip'] == 16) + $sql2 = sisplet_query("SELECT COUNT(*) AS quota + FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g, srv_user u + WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.grd_id='$row[grd_id]' AND d.usr_id=u.id AND u.deleted='0'"); + + // radio, select + elseif ($row1['tip'] == 1 || $row1['tip'] == 3) + $sql2 = sisplet_query("SELECT COUNT(*) AS quota + FROM srv_data_vrednost" . get('db_table') . " d, srv_user u + WHERE d.vre_id='$row[vre_id]' AND d.spr_id='$row1[id]' AND d.usr_id=u.id AND u.deleted='0'"); + + // checkbox + elseif ($row1['tip'] == 2) + $sql2 = sisplet_query("SELECT COUNT(*) AS quota + FROM srv_data_vrednost" . get('db_table') . " d, srv_user u + WHERE d.vre_id='$row[vre_id]' AND d.spr_id='$row1[id]' AND d.usr_id=u.id AND u.deleted='0'"); + + $row2 = mysqli_fetch_array($sql2); + + $expression .= $row2['quota']; + } + } // konstante (statusi...) + elseif ($row['spr_id'] < 0) { + + $status = ''; + + // Kvota ustreznih odgovorov + if ($row['spr_id'] == -7) { + $status .= ' AND (last_status=\'5\' OR last_status=\'6\') AND lurker=\'0\' '; + } // Kvota posameznih statusov + elseif ($row['spr_id'] > -7) { + $status .= ' AND last_status=\'' . -$row['spr_id'] . '\' '; + } + + $sqlU = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='".get('anketa')."' ".$status." AND deleted='0'"); + $rowU = mysqli_fetch_array($sqlU); + + $expression .= $rowU['COUNT(id)']; + } + + for ($i = 1; $i <= $row['right_bracket']; $i++) + $expression .= ' ) '; + } + + $expression = 'return ' . $expression . ';'; + + return eval($expression); + } + + /************************************************ + * Preveri userja, ki se je vrnil in ga (če je tako nastavljeno) preusmeri na stran, kjer je končal + ************************************************/ + public function check_cookie_return() + { + + $row = \SurveyInfo::getInstance()->getSurveyRow(); + + // EVALVACIJA - nastavljeno je da ga preusmerimo na stran kjer je koncal - za studentsko evalvacijo vedno preusmerjamo z ustreznimi parametri - ZAENKRAT NI VKLOPLJENO + if (Common::checkModule('evalvacija') == '1' && false) { + $sql1 = sisplet_query("SELECT g.id FROM srv_user_grupa" . get('db_table') . " u, srv_grupa g WHERE u.gru_id=g.id AND u.usr_id='" . get('usr_id') . "' ORDER BY g.vrstni_red DESC LIMIT 1"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + save('grupa', $row1['id']); + $grupa = Find::getInstance()->findNextGrupa(); + + if ($grupa > 0) { + $params = $_SERVER['QUERY_STRING']; + + setcookie('ref', get('anketa')); // cookie z referalom (da se ne sprozi redirect zaradi referala pri ?code= ) + return header("Location: " . \SurveyInfo::getSurveyLink() . "&grupa=$grupa&" . $params . get('cookie_url') . "&c"); + die(); + } + } + + // nastavljeno je da ga preusmerimo na stran kjer je koncal + if ($row['cookie_return'] == 1) { + + $sql1 = sisplet_query("SELECT g.id FROM srv_user_grupa" . get('db_table') . " u, srv_grupa g WHERE u.gru_id=g.id AND u.usr_id='" . get('usr_id') . "' ORDER BY g.vrstni_red DESC LIMIT 1"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + + if(mysqli_num_rows($sql1) > 0){ + + $row1 = mysqli_fetch_array($sql1); + + save('grupa', $row1['id']); + + $grupa = Find::getInstance()->findNextGrupa(); + + if ($grupa > 0) { + setcookie('ref', get('anketa')); // cookie z referalom (da se ne sprozi redirect zaradi referala pri ?code= ) + return header("Location: " . \SurveyInfo::getSurveyLink() . "&grupa=$grupa" . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . get('cookie_url') . "&c"); + die(); + } + } + } + } + + /** + * preveri, ce je katera od spremenljivk CAPTCHA in preveri, ce je pravilno vnesena + * treba extra preverjat, ce je JS izklopljen + * + */ + public function check_captcha() + { + global $secret_captcha; + + // Ce urejamo podatke v admin vmesniku ne preverjamo nicesar + if(isset($_GET['t']) && $_GET['t'] == 'postprocess' || get('grupa') == '0' || get('grupa') == ''){ + return; + } + + $sql = sisplet_query("SELECT id, params FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND visible='1' AND tip='21' ORDER BY vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + + $spremenljivkaParams = new enkaParameters($row['params']); + $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0); + + if ($captcha == 1) { + $recaptchaResponse = $_POST['g-recaptcha-response']; + $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse); + + // zdaj pa zabeleži mail (pred pošiljanjem) + // zdaj pa še v bazi tistih ki so se ročno dodali + if(strstr($request,"true")){ + // + } + else { + echo '

Wrong CAPTCHA code.

Back

'; + die(); + } + } + } + } + + /** + * preveri, ce preveri, ce je CAPTCHA pravilno vnesena pri uvodu (ce imamo staticen uvod s preverjanjem captche) + * + */ + public function check_captcha_intro(){ + global $secret_captcha; + + $recaptchaResponse = $_POST['g-recaptcha-response']; + $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse); + + if(strstr($request,"true")){ + // + } + else { + header('Location: ' . SurveyInfo::getSurveyLink(false, false).'?captcha_error=1'); + die(); + } + } + + public function checkMissingForSpremenljivka($spremenljivka, $loop_id) + { + $missing = false; + + $smv = new SurveyMissingValues(get('anketa')); + $missing_values = $smv->GetUnsetValuesForSurvey(); + + if (count($missing_values) > 0) { + + $qry = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other IN ('" . implode('\',\'', array_keys($missing_values)) . "')"); + $missing_vrednosti = array(); + while ($row = mysqli_fetch_assoc($qry)) { + $missing_vrednosti[] = $row[id]; + } + # pogledamo ali imamo kak zapis v srv_data_vrednost. potem je to najbrž missing + + $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)) { + #samo če je bil izbran missing -99 ne vem, -98 drugo ..... + if (in_array($row2_c['vre_id'], $missing_vrednosti) && $missing == false) { + $missing = $row2_c['vre_id']; + } + } + } + return $missing; + } + + // Preverimo, ce je uporabnik ze bil na strani + public function check_subsequent_visit(){ + + $sql = sisplet_query("SELECT g.id + FROM srv_user_grupa".get('db_table')." u, srv_grupa g + WHERE u.gru_id=g.id AND u.usr_id='".get('usr_id')."' AND g.id='".get('grupa')."' + "); + + if(mysqli_num_rows($sql) > 0) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/main/survey/app/Controllers/Controller.php b/main/survey/app/Controllers/Controller.php new file mode 100644 index 0000000..a9ad8fe --- /dev/null +++ b/main/survey/app/Controllers/Controller.php @@ -0,0 +1,113 @@ +openDatabaseConnection(); + $this->loadModel(); + $this->getGlobalVariables(); + } + + /************************************************ + * Vse globalne spremenljivke dodamo v omenjen razred, da jih lahko potem kličemo na posameznem razredu + * + * @return $this + ************************************************/ + public static $global_user_id; + public static $admin_type; + public static $site_url; + public static $site_path; + public static $lang; + public static $mysql_database_name; + + public function getGlobalVariables() + { + // Definiramo globalne spremenljivke, ki jih kasneje uporabljamo v funkcijah + global $global_user_id; + global $admin_type; + global $site_url; + global $site_path; + global $lang; + global $mysql_database_name; + + self::$global_user_id = $global_user_id; + self::$admin_type = $admin_type; + self::$site_url = $site_url; + self::$site_path = $site_path; + self::$lang = $lang; + self::$mysql_database_name = $mysql_database_name; + } + + /************************************************ + * Pridobimo vse variable, ki se uporabljajo za main/survey in jih dodamo na Controller -> $this variable + * + * @return $this + ************************************************/ + public function getAllVariables() + { + // pridobimo vse spremenljivke, ki jih uporabljamo med različnimi razredi + $var = Variable::getAll(); + + // vrnemo kot $this parameter, da jih uporabljamo znotraj razreda in ni potrebno vse popravljati + // v obliko Variable::get('name') amap preprosto kličemo $this->name + foreach ($var as $key => $value) { + $this->$key = $value; + } + + return $this; + } + + /** + * Open the database connection with the credentials from application/config/config.php + */ + private function openDatabaseConnection() + { + // set the (optional) options of the PDO connection. in this case, we set the fetch mode to + // "objects", which means all results will be objects, like this: $result->user_name ! + // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] ! + // @see http://www.php.net/manual/en/pdostatement.fetch.php + $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING); + + // generate a database connection, using the PDO connector + // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ + $this->db = new PDO(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, $options); + } + + /** + * Loads the "model". + * @return object model + */ + public function loadModel() + { + $this->model = new Model($this->db); + } +} \ No newline at end of file diff --git a/main/survey/app/Controllers/DisplayController.php b/main/survey/app/Controllers/DisplayController.php new file mode 100644 index 0000000..c0cbf43 --- /dev/null +++ b/main/survey/app/Controllers/DisplayController.php @@ -0,0 +1,864 @@ +' . self::$lang['srv_1cs'] . '
'; + } + + /** + * @desc prikaze progress bar + */ + public function progress_bar() + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $sql_count_pages = sisplet_query("SELECT COUNT( g.id ) AS count FROM srv_grupa g WHERE g.ank_id = '" . get('anketa') . "'"); + $row_count_pages = mysqli_fetch_assoc($sql_count_pages); + + // Ce prikazemo gumb za tawk chat + $tawk_chat = false; + if(SurveyInfo::getInstance()->checkSurveyModule('chat') == '1'){ + $sql_chat = sisplet_query("SELECT chat_type FROM srv_chat_settings WHERE ank_id='".get('anketa')."'"); + $row_chat = mysqli_fetch_assoc($sql_chat); + + if($row_chat['chat_type'] == '2') + $tawk_chat = true; + } + + if (($row['progressbar'] == 1 && $row_count_pages['count'] > 1) || ($row['continue_later'] == 1) || $tawk_chat) { + echo '
'; + + if ($row['progressbar'] == 1 && $row_count_pages['count'] > 1) { + + echo '
'; + + $sql1 = sisplet_query("SELECT COUNT(s.id) AS count + FROM srv_grupa g, srv_spremenljivka s + WHERE s.gru_id=g.id AND g.ank_id = '" . get('anketa') . "' AND s.visible='1'"); + $row1 = mysqli_fetch_array($sql1); + $all = $row1['count']; + + $sql2 = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'"); + $row2 = mysqli_fetch_array($sql2); + + $sql3 = sisplet_query("SELECT COUNT(s.id) AS count + FROM srv_grupa g, srv_spremenljivka s + WHERE s.gru_id=g.id AND g.ank_id = '" . get('anketa') . "' AND s.visible='1' AND g.vrstni_red<='$row2[vrstni_red]'"); + $row3 = mysqli_fetch_array($sql3); + $ans = $row3['count']; + + if ($all > 0) { + + $p = round($ans / $all * 100, 0); + + echo '0%'; + echo '
'; + echo '100%'; + } + + echo '
'; + } + + // Prikaz opcije "nadaljuj kasneje" + if ($row['continue_later'] == 1) { + SurveySetting::getInstance()->Init(get('anketa')); + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + $srv_continue_later = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later' . $_lang); + if ($srv_continue_later == '') $srv_continue_later = self::$lang['srv_continue_later']; + + echo '
'; + echo ' ' . $srv_continue_later . ''; + echo '
'; + } + + // Priakz gumba za vklop tawk chata + if ($tawk_chat){ + echo '
'; + echo ' '.self::$lang['srv_chat_turn_on'].''; + echo '
'; + } + + echo '
'; + } + } + + // Prikaze ikono za izvoz pdf rezultatov v zakljucku + public function displayRespondetnPDF() + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + if ((int)$row['concl_PDF_link'] == 1) { + + // Ce je vklopljen evoli ali evoli employeeship meter, prikazemo link do posebnega porocila + if(SurveyInfo::getInstance()->checkSurveyModule('evoli') || SurveyInfo::getInstance()->checkSurveyModule('evoli_employmeter')){ + + // Nastavimo ustrezen jezik za report + if(self::$lang['id'] == '1') + $report_lang = 'slo'; + elseif(self::$lang['id'] == '29') + $report_lang = 'dan'; + else + $report_lang = ''; + + if(SurveyInfo::getInstance()->checkSurveyModule('evoli_employmeter')) + $evoli_module = 'pdf_employmeter'; + else + $evoli_module = 'pdf_evoli'; + + $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(serialize(array('m' => $evoli_module, 'anketa' => get('anketa'), 'usr_id' => get('usr_id'), 'lang' => $report_lang))); + + echo '
'; + + echo '

'; + + if(SurveyInfo::getInstance()->checkSurveyModule('evoli')){ + echo self::$lang['srv_report_pdf_evoli'].': '; + + echo ''; + echo ''.self::$lang['srv_report_pdf_evoli_button'].''; + echo ''; + } + else{ + echo self::$lang['srv_report_pdf_evoli_em'].': '; + + echo ''; + echo ''.self::$lang['srv_report_pdf_evoli_em_button'].''; + echo ''; + } + + echo '

'; + } + else{ + # parametre zapakiramo v array injih serializiramo in zakodiramo z base64 + $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(serialize(array('a' => 'pdf_results', 'anketa' => get('anketa'), 'usr_id' => get('usr_id'), 'type' => '0'))); + + #echo '
'; + echo '

'; + echo ' '.self::$lang['srv_report_pdf'].''; + echo '

'; + } + } + } + + // Prikaze url za naknadno popravljanje odgovorov (od zacetka ankete) v zakljucku + public function displayReturnEditURL() + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + + if ((int)$row['concl_return_edit'] == 1) { + + $return_url = $_POST['url'] . '&return=1'; + $return_url = SurveyInfo::getSurveyLink() . get('cookie_url') . '&return=1'; + + echo '

'; + echo self::$lang['srv_concl_return_edit_URL'].':
'; + echo ''.$return_url.''; + echo '

'; + } + } + + // Prikaze pravilne rezultate v primeru modula KVIZ + public function displayQuizAnswers() + { + // echo '

'.self::$lang['results'].'

'; + + // Loop cez vsa ustrezna vprasanja (ki imajo oznacen vsaj en pravilen odgovor) + $sqlS = sisplet_query("SELECT s.id, s.naslov, s.info FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.tip IN ('1', '2', '3') AND s.visible='1' + AND EXISTS (SELECT q.* FROM srv_quiz_vrednost q WHERE q.spr_id=s.id) + AND NOT EXISTS (SELECT d.* FROM srv_data_vrednost_active d WHERE d.spr_id=s.id AND usr_id='".get('usr_id')."' AND d.vre_id='-2')"); + if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']); + while($rowS = mysqli_fetch_array($sqlS)){ + + echo '
'; + + //Vprasanja::getInstance()->displaySpremenljivka($rowS['id']); + + echo '
'.$rowS['naslov']; + if ($rowS['info'] != '') + echo '

' . $rowS['info'] . '

'; + echo '
'; + + echo '
'; + + // Loop cez vse vrednosti v vprasanju + $sqlV = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='".$rowS['id']."' ORDER BY vrstni_red ASC"); + while($rowV = mysqli_fetch_array($sqlV)){ + + // Za vsako pogledamo ce je pravilna oz napacna + $answer = false; + $correct = false; + + $sqlAnswer = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."' AND usr_id='".get('usr_id')."'"); + if(mysqli_num_rows($sqlAnswer) == 1) + $answer = true; + + $sqlQuiz = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."'"); + if(mysqli_num_rows($sqlQuiz) == 1) + $correct = true; + + if($correct && $answer){ + echo '
'; + echo $rowV['naslov'] . ''; + echo '
'; + } + elseif($correct){ + echo '
'; + //echo $rowV['naslov'] . ''; + echo $rowV['naslov']; + echo '
'; + } + elseif($answer){ + echo '
'; + echo $rowV['naslov'] . ''; + echo '
'; + } + else{ + echo '
'; + echo $rowV['naslov']; + echo '
'; + } + } + + echo '
'; + + echo '
'; + } + } + + // Prikaze graf rezultatov v primeru modula KVIZ + public function displayQuizChart() + { + //echo '

'.self::$lang['results'].'

'; + + $cnt_all = 0; + $cnt_answered = 0; + $cnt_unanswered = 0; + $cnt_correct = 0; + $cnt_incorrect = 0; + + // Loop cez vsa ustrezna vprasanja (ki imajo oznacen vsaj en pravilen odgovor) + $sqlS = sisplet_query("SELECT s.id, s.naslov, s.info FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.tip IN ('1', '2', '3') AND s.visible='1' + AND EXISTS (SELECT q.* FROM srv_quiz_vrednost q WHERE q.spr_id=s.id) + AND NOT EXISTS (SELECT d.* FROM srv_data_vrednost_active d WHERE d.spr_id=s.id AND usr_id='".get('usr_id')."' AND d.vre_id='-2')"); + if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']); + while($rowS = mysqli_fetch_array($sqlS)){ + + $cnt_all++; + + $answer = false; + $correct = false; + + // Loop cez vse vrednosti v vprasanju + $sqlV = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='".$rowS['id']."' ORDER BY vrstni_red ASC"); + while($rowV = mysqli_fetch_array($sqlV)){ + + // Za vsako pogledamo ce je odgovorjena + $sqlAnswer = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."' AND usr_id='".get('usr_id')."'"); + if(mysqli_num_rows($sqlAnswer) == 1){ + $answer = true; + + // Za vsako pogledamo ce je pravilna oz napacna + $sqlQuiz = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."'"); + + if(mysqli_num_rows($sqlQuiz) == 1){ + $correct = true; + } + // Ce je oznacil napacno breakamo + else{ + $correct = false; + break; + } + } + } + + if($answer) + $cnt_answered++; + else + $cnt_unanswered++; + + if($correct) + $cnt_correct++; + else + $cnt_incorrect++; + } + + + // Izrisemo graf + /*echo 'Vseh: '.$cnt_all; + echo '
odgovorjen: '.$cnt_answered; + echo '
neodg: '.$cnt_unanswered; + echo '
pravilen: '.$cnt_correct; + echo '
nepravilen: '.$cnt_incorrect;*/ + + // Include knjiznice Chart.JS + echo ''; + echo ''; + + // Izris grafa + echo '
'; + echo ''; + echo ''; + echo '
'; + } + + + // Prikaze graf za matriko odlicnosti (excell_matrix) v primeru modula Excelleration matrix + public function displayExcellChart() + { + echo '

'.self::$lang['srv_excell_matrix_title'].'

'; + + // Loop cez vsa ustrezna vprasanja in njihove vrednosti (jih zakesiramo) + $variables = array(); + $variable_marza = array(); + $variable_lp = array(); + $spr_ids = ''; + $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable, v.id AS vre_id, v.variable AS vre_variable, v.naslov AS vre_naslov + FROM srv_spremenljivka s, srv_grupa g, srv_vrednost v + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id + AND s.variable LIKE 'em%' + AND v.spr_id=s.id"); + if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']); + while($rowS = mysqli_fetch_array($sqlS)){ + + // Marza + if($rowS['spr_variable'] == 'emM'){ + + // ID-ji vprasanj za query + if(!isset($variable_marza['id'])) + $spr_ids .= $rowS['spr_id'].','; + + $variable_marza['naslov'] = strip_tags($rowS['spr_naslov']); + $variable_marza['id'] = $rowS['spr_id']; + + $variable_marza['vrednosti'][$rowS['vre_id']]['variable'] = $rowS['vre_variable']; + $variable_marza['vrednosti'][$rowS['vre_id']]['naslov'] = $rowS['vre_naslov']; + } + // Letni promet + elseif($rowS['spr_variable'] == 'emLP'){ + + $variable_lp['naslov'] = strip_tags($rowS['spr_naslov']); + $variable_lp['id'] = $rowS['spr_id']; + } + // Ostali + else{ + + // ID-ji vprasanj za query + if(!isset($variables[$rowS['spr_id']]['variable'])) + $spr_ids .= $rowS['spr_id'].','; + + $variables[$rowS['spr_id']]['naslov'] = strip_tags($rowS['spr_naslov']); + $variables[$rowS['spr_id']]['variable'] = $rowS['spr_variable']; + + $variables[$rowS['spr_id']]['vrednosti'][$rowS['vre_id']]['variable'] = $rowS['vre_variable']; + $variables[$rowS['spr_id']]['vrednosti'][$rowS['vre_id']]['naslov'] = $rowS['vre_naslov']; + } + } + $spr_ids = substr($spr_ids, 0, -1); + + // Loop cez vse respondente s statusom 6 - vsak je svoj bubble + $data = array(); + $sum = 0; + $cnt = 0; + $sqlAnswers = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE usr_id='".get('usr_id')."' AND spr_id IN (".$spr_ids.")"); + while($rowAnswers = mysqli_fetch_array($sqlAnswers)){ + + // Marzo normalno preberemo + if($rowAnswers['spr_id'] == $variable_marza['id']){ + $value = $variable_marza['vrednosti'][$rowAnswers['vre_id']]['variable']; + $data['marza'] = $value; + + $variable_marza['value'] = $rowAnswers['vre_id']; + } + // Pri ostalih racunamo povprecje + else{ + $value = $variables[$rowAnswers['spr_id']]['vrednosti'][$rowAnswers['vre_id']]['variable']; + $sum += (int)$value; + $cnt++; + + $variables[$rowAnswers['spr_id']]['value'] = $rowAnswers['vre_id']; + } + } + $data['excell'] = round($sum/$cnt, 1); + + // Posebej pridobimo tudi letni promet + $sqlAnswers = sisplet_query("SELECT text FROM srv_data_text_active WHERE usr_id='".get('usr_id')."' AND spr_id='".$variable_lp['id']."'"); + $rowAnswers = mysqli_fetch_array($sqlAnswers); + $data['letni_promet'] = $rowAnswers['text']; + $variable_lp['value'] = $rowAnswers['text']; + + // Max radius=80 (vrednost 1000), min radius=8 (vrednost 100) + $radius = $data['letni_promet']; + + // Include knjiznice Chart.JS + echo ''; + echo ''; + + // Izris grafa + echo '
'; + echo ''; + echo ''; + echo '
'; + + + // Izrisemo se seznam vprasanj + foreach($variables as $spr_id => $spremenljivka){ + + echo '
'; + echo '
'.$spremenljivka['naslov'].'
'; + echo '
'; + foreach($spremenljivka['vrednosti'] as $vre_id => $vrednost){ + echo '
'.$vrednost['naslov'].'
'; + } + echo '
'; + echo '
'; + } + + // Marza + echo '
'; + echo '
'.$variable_marza['naslov'].'
'; + echo '
'; + foreach($variable_marza['vrednosti'] as $vre_id => $vrednost){ + echo '
'.$vrednost['naslov'].'
'; + } + echo '
'; + echo '
'; + + // Letni promet + echo '
'; + echo '
'.$variable_lp['naslov'].'
'; + echo '
'; + echo '
'.$variable_lp['value'].'
'; + echo '
'; + echo '
'; + } + + + // SKAVTI - prikaze povzetek in graf za njihovo anketo + public function displaySkavtiAnswers(){ + + // Stevilo top pohval in izziv, ki jih izpisemo v zakljucku + $max_odgovorov = 3; + + $vprasanja = array(); + $spr_ids = ''; + + // Loop cez vsa ustrezna vprasanja in njihove vrednosti (jih zakesiramo) + $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable + FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id + AND s.variable LIKE 'R%' + "); + if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']); + while($rowS = mysqli_fetch_array($sqlS)){ + + $vprasanje_number = substr($rowS['spr_variable'], 1); + $vprasanja[$rowS['spr_id']] = $vprasanje_number; + + // ID-ji vprasanj za query + $spr_ids .= $rowS['spr_id'].','; + } + + $spr_ids = substr($spr_ids, 0, -1); + + + // Loop cez vse response za vprasanja + $pohvale = array(); + $izzivi = array(); + $sqlAnswers = sisplet_query("SELECT vd.*, v.naslov, v.variable + FROM srv_data_vrednost_active vd, srv_vrednost v + WHERE vd.usr_id='".get('usr_id')."' AND vd.spr_id IN (".$spr_ids.") + AND v.id=vd.vre_id + "); + while($rowAnswers = mysqli_fetch_array($sqlAnswers)){ + + // Pohvala + if((int)$rowAnswers['variable'] >= 1 && (int)$rowAnswers['variable'] <= 199){ + $pohvale[(int)$rowAnswers['variable']] = $rowAnswers; + } + // Izziv + elseif((int)$rowAnswers['variable'] >= 201 && (int)$rowAnswers['variable'] <= 399){ + $izzivi[(int)$rowAnswers['variable']] = $rowAnswers; + } + } + + // Sortiramo po velikosti + ksort($pohvale, SORT_NUMERIC); + ksort($izzivi, SORT_NUMERIC); + + + // Loop cez komentarje v nagovorih + $pohvale_besedilo = array(); + $izzivi_besedilo = array(); + $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable + FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id + AND (s.variable LIKE 'P%' OR s.variable LIKE 'G%') + "); + if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']); + while($rowS = mysqli_fetch_array($sqlS)){ + + $tip = substr($rowS['spr_variable'], 0, 1); + $vprasanje_number = substr($rowS['spr_variable'], 1); + $naslov = $rowS['spr_naslov']; + + // Pohvala + if($tip == 'P'){ + $pohvale_besedilo[$vprasanje_number] = $naslov; + } + // Izziv + elseif($tip == 'G'){ + $izzivi_besedilo[$vprasanje_number] = $naslov; + } + } + + + // Izrisemo seznam vprasanj s pohvalami + echo '

POHVALE

'; + + // Nagovor za pohvale + $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable + FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='pohvale' + "); + $rowNagovor = mysqli_fetch_array($sqlNagovor); + echo '
'.$rowNagovor['naslov'].'
'; + + $i = 1; + foreach($pohvale as $pohvala_vrednost => $vrednost){ + + if($i > $max_odgovorov) + break; + + $spr_id = $vrednost['spr_id']; + $vprasanje_number = $vprasanja[$spr_id]; + + echo '
'; + echo '
'.$pohvale_besedilo[$vprasanje_number].'
'; + echo '
'; + + $i++; + } + + // Izrisemo seznam vprasanj z izzivi + echo '

IZZIVI

'; + + // Nagovor za izzive + $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable + FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='izzivi' + "); + $rowNagovor = mysqli_fetch_array($sqlNagovor); + echo '
'.$rowNagovor['naslov'].'
'; + + $i = 1; + foreach($izzivi as $izziv_vrednost => $vrednost){ + + if($i > $max_odgovorov) + break; + + $spr_id = $vrednost['spr_id']; + $vprasanje_number = $vprasanja[$spr_id]; + + echo '
'; + echo '
'.$izzivi_besedilo[$vprasanje_number].'
'; + echo '
'; + + $i++; + } + + $this->displaySkavtiRadar(); + } + + // SKAVTI - prikaze graf pajkovo mrezo + private function displaySkavtiRadar(){ + + // Include knjiznice Chart.JS + echo ''; + echo ''; + + + // Priprava podatkov za radar + $radar_data = array(); + $sqlB = sisplet_query("SELECT i.label, i.id + FROM srv_if i, srv_branching b + WHERE b.ank_id='".get('anketa')."' AND i.id=b.element_if + AND i.tip='1' + "); + if (!$sqlB) echo mysqli_error($GLOBALS['connect_db']); + + // Za graf rabimo vsaj 3 ogljisca + if(mysqli_num_rows($sqlB) < 3) + return; + + // Loop cez bloke (stranica radarja) + while($rowB = mysqli_fetch_array($sqlB)){ + + // Dobimo vsa ustrezna vprasanja z odgovori v tem bloku + $sqlQ = sisplet_query("SELECT s.id AS spr_id, s.variable AS spr_variable, v.naslov, v.variable, vd.* + FROM srv_branching b, srv_spremenljivka s, srv_vrednost v, srv_data_vrednost_active vd + WHERE b.ank_id='".get('anketa')."' AND b.parent='".$rowB['id']."' AND b.element_spr=s.id + AND s.variable LIKE 'R%' + AND vd.usr_id='".get('usr_id')."' AND vd.spr_id=s.id + AND v.id=vd.vre_id + "); + if (!$sqlQ) echo mysqli_error($GLOBALS['connect_db']); + + // Loop cez vprasanja in odgovore v bloku + $count_answers_pohvale = 0; + $count_answers_izzivi = 0; + while($rowQ = mysqli_fetch_array($sqlQ)){ + + // Pohvala + if((int)$rowQ['variable'] >= 1 && (int)$rowQ['variable'] <= 200){ + $count_answers_pohvale++; + } + // Izziv + elseif((int)$rowQ['variable'] >= 201 && (int)$rowQ['variable'] <= 400){ + $count_answers_izzivi++; + } + } + + $count_answers_all = (int)$count_answers_pohvale + (int)$count_answers_izzivi; + if($count_answers_all > 0){ + $radar_data[$rowB['label']]['all'] = $count_answers_all; + $radar_data[$rowB['label']]['pohvale'] = $count_answers_pohvale; + $radar_data[$rowB['label']]['izzivi'] = $count_answers_izzivi; + } + } + //echo '
' . var_export($radar_data, true) . '
'; + + $labels = array(); + $values = array(); + $i = 0; + foreach($radar_data as $radar_label => $radar_values){ + + $labels[$i] = $radar_label; + $pohvale[$i] = round($radar_values['pohvale'] / $radar_values['all'] * 10, 2); + $izzivi[$i] = round($radar_values['izzivi'] / $radar_values['all'] * 10, 2); + + $i++; + } + + $json_labels = json_encode($labels); + $json_pohvale = json_encode($pohvale); + $json_izzivi = json_encode($izzivi); + + echo '

Pajkova mreža

'; + + // Nagovor za mrezo + $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable + FROM srv_spremenljivka s, srv_grupa g + WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='mreza' + "); + $rowNagovor = mysqli_fetch_array($sqlNagovor); + echo '
'.$rowNagovor['naslov'].'
'; + + // Izris grafa + echo '
'; + + echo ''; + echo ''; + + echo '
'; + } + + + /** + * prikaze lepo obvestilo o napaki (anketa je zaključena itd...) + * + * @param mixed $text + */ + public function displayNapaka($text) + { + Header::getInstance()->header(); + + $anketa = get('anketa'); + + echo '
'; + echo '
'; + + echo '
'; + + + echo '
'; + + $this->logo(); + + echo '

' . Helper::getInstance()->displayAkronim() . '

'; + + echo '
'; + echo '
'; + echo '

' . $text . '

'; + echo '
'; + echo '
'; // -grupa + + echo '
'; // -container + + Body::getInstance()->displayFooterNote(); + + echo '
'; // -outercontainer + echo '
'; // -outercontainer_holder + } + + /** + * Prikaze zavihke za bloke, ce obstajajo + * + */ + public function display_tabs() + { + + $sql = sisplet_query("SELECT * FROM srv_if i, srv_branching b WHERE i.tab='1' AND i.tip='1' AND i.id=b.element_if AND b.ank_id='" . get('anketa') . "' ORDER BY b.parent, b.vrstni_red"); + if (mysqli_num_rows($sql) > 0) { + + echo '
'; + + $i = 0; + while ($row = mysqli_fetch_array($sql)) { + if ($i++ != 0) echo ' | '; + $label = ($row['label'] == '' ? self::$lang['srv_blok'] . ' (' . $row['number'] . ')' : $row['label']); + echo 'ajax_grupa_for_if($row['id']) == get('grupa') ? ' class="active"' : '') . '>' . $label . ' '; + } + + echo '
'; + + } + } + + /** + * @desc konstruktor + */ + public function PrintSurvey() + { + + if (isset($_GET['anketa'])) { + save('anketa', $_GET['anketa']); + + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + // uvodni nagovor + if ($rowa['show_intro'] != 0) { + Body::getInstance()->displayIntroduction(); + } + + // prikažemo ankete + do { + save('grupa', Find::getInstance()->findNextGrupa()); + + Body::getInstance()->displayAnketa(); + } while (get('grupa') != Find::getInstance()->findNextGrupa() && Find::getInstance()->findNextGrupa() > 0); + + // prikažemo konec + Body::getInstance()->displayKonec(); + } else + echo 'Ni podatkov o anketi!'; + } + + + /** + * @desc prikaze chat okno za tawk chat, ce je modul vklopljen (js koda) + */ + public function displayChatTAWK(){ + + echo '
'; + + $sql = sisplet_query("SELECT code, chat_type FROM srv_chat_settings WHERE ank_id='".get('anketa')."'"); + if(mysqli_num_rows($sql) > 0){ + + $row = mysqli_fetch_array($sql); + + if($row['code'] != ''){ + + // JS koda za widget + echo $row['code']; + + echo ""; + } + } + + echo '
'; + } +} \ No newline at end of file diff --git a/main/survey/app/Controllers/FindController.php b/main/survey/app/Controllers/FindController.php new file mode 100644 index 0000000..0f60a43 --- /dev/null +++ b/main/survey/app/Controllers/FindController.php @@ -0,0 +1,290 @@ + 0) + return $row['parent']; + else + return self::find_parent_loop(0, $row['parent']); + + } + + /** + * poisce naslednjo vre_id v loopu + * + */ + public function findNextLoopId($if_id = 0) + { + + if ($if_id == 0) { + $sql = sisplet_query("SELECT if_id FROM srv_loop_data WHERE id='" . get('loop_id') . "'"); + $row = mysqli_fetch_array($sql); + $if_id = $row['if_id']; + $loop_id = get('loop_id'); + } + else + $loop_id = 0; + + $sql = sisplet_query("SELECT spr_id, max FROM srv_loop WHERE if_id = '$if_id'"); + $row = mysqli_fetch_array($sql); + $spr_id = $row['spr_id']; + $max = $row['max']; + + $spr = Cache::srv_spremenljivka($spr_id); + + // Radio, checkbox, sn imena + if ($spr['tip'] == 2 || $spr['tip'] == 3 || $spr['tip'] == 9) { + + $data_vrednost = array(); + if ($spr['tip'] == 9) + $sql1 = sisplet_query("SELECT vre_id FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'"); + else + $sql1 = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'"); + + while ($row1 = mysqli_fetch_array($sql1)) { + $data_vrednost[$row1['vre_id']] = 1; + } + + $vre_id = ''; + $i = 1; + $sql = sisplet_query("SELECT lv.vre_id, lv.tip FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['tip'] == 0) { // izbran + if (isset($data_vrednost[$row['vre_id']])) { + $vre_id .= ', ' . $row['vre_id']; + $i++; + } + } elseif ($row['tip'] == 1) { // ni izbran + if (!isset($data_vrednost[$row['vre_id']])) { + $vre_id .= ', ' . $row['vre_id']; + $i++; + } + } elseif ($row['tip'] == 2) { // vedno + $vre_id .= ', ' . $row['vre_id']; + $i++; + } // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze + + if ($i > $max && $max > 0) break; + } + + $vre_id = substr($vre_id, 2); + if ($vre_id == '') + return null; + + $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_vrednost v WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id) AND l.vre_id=v.id ORDER BY l.id ASC"); + + + if (!$sql) { + echo 'err56545' . mysqli_error($GLOBALS['connect_db']); + die(); + } + $row = mysqli_fetch_array($sql); + + if (mysqli_num_rows($sql) > 0) + return $row['id']; + else + return null; + } + // Number + elseif ($spr['tip'] == 7) { + + $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + + $num = (int)$row1['text']; + $sql2 = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id <= '$loop_id'"); + if (mysqli_num_rows($sql2) >= $num || (mysqli_num_rows($sql2) >= $max && $max > 0)) + return null; + + $sql = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id'"); + $row = mysqli_fetch_array($sql); + + if (mysqli_num_rows($sql) > 0) + return $row['id']; + else + return null; + + } + // Ranking + elseif ($spr['tip'] == 17) { + + $data_vrednost = array(); + $sql1 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "' ORDER BY vrstni_red ASC"); + + while ($row1 = mysqli_fetch_array($sql1)) { + $data_vrednost[$row1['vre_id']] = 1; + } + + $vre_id = ''; + $i = 1; + $sql = sisplet_query("SELECT lv.vre_id, lv.tip FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + + if ($row['tip'] == 0) { // izbran + if (isset($data_vrednost[$row['vre_id']])) { + $vre_id .= ', ' . $row['vre_id']; + $i++; + } + } elseif ($row['tip'] == 1) { // ni izbran + if (!isset($data_vrednost[$row['vre_id']])) { + $vre_id .= ', ' . $row['vre_id']; + $i++; + } + } elseif ($row['tip'] == 2) { // vedno + $vre_id .= ', ' . $row['vre_id']; + $i++; + } // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze + + if ($i > $max && $max > 0) break; + } + + $vre_id = substr($vre_id, 2); + if ($vre_id == '') + return null; + + + // Ce gre za prvi loop poiscemo ranking odgovor na prvem mestu + if($loop_id == 0){ + $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_data_rating dr + WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id) + AND l.vre_id=dr.vre_id AND dr.usr_id='".get('usr_id')."' AND dr.vrstni_red = '1' + "); + } + // Ce gre za kasnejsi loop poiscemo naslednji ranking odgovor + else{ + $sql2 = sisplet_query("SELECT dr.vrstni_red FROM srv_loop_data l, srv_data_rating dr WHERE l.if_id='$if_id' AND l.id='$loop_id' AND dr.vre_id=l.vre_id AND dr.usr_id='".get('usr_id')."'"); + if(mysqli_num_rows($sql2) > 0){ + $row2 = mysqli_fetch_array($sql2); + + $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_vrednost v, srv_data_rating dr + WHERE l.if_id='$if_id' AND l.id != '$loop_id' AND l.vre_id IN ($vre_id) + AND l.vre_id=v.id + AND dr.vre_id=v.id AND dr.usr_id='".get('usr_id')."' AND dr.vrstni_red > '".$row2['vrstni_red']."' + ORDER BY dr.vrstni_red ASC + "); + } + else + return null; + } + + if (!$sql) { + echo 'err56545' . mysqli_error($GLOBALS['connect_db']); + die(); + } + $row = mysqli_fetch_array($sql); + + + if (mysqli_num_rows($sql) > 0) + return $row['id']; + else + return null; + } + } + + /** + * @desc poisce prejsnjo stran - grupo, 0 pomeni konec + */ + public static function findPrevGrupa() + { + $anketa = get('anketa'); + $grupa = get('grupa'); + + $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '$grupa'"); + $row = mysqli_fetch_array($sql); + $vrstni_red = $row['vrstni_red']; + + $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$anketa' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1"); + + // naslednja stran + if (mysqli_num_rows($sql) > 0) { + + $row = mysqli_fetch_array($sql); + return $row['id']; + + // konec + } else { + + return 0; + } + } + + /** + * @desc poisce naslednjo stran - grupo, 0 pomeni konec + */ + public function findNextGrupa($gru_id=0) + { + //vrstni red trenutne grupe + if (get('grupa') > 0) { + $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'"); + $row = mysqli_fetch_array($sql); + $vrstni_red = $row['vrstni_red']; + } + elseif ($gru_id > 0) { + $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . $gru_id . "'"); + $row = mysqli_fetch_array($sql); + $vrstni_red = $row['vrstni_red']; + } + else { + $vrstni_red = 0; + } + + $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red>'$vrstni_red' ORDER BY vrstni_red ASC LIMIT 1"); + + // naslednja stran + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + return $row['id']; + } + // konec + else { + return 0; + } + } + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/HeaderController.php b/main/survey/app/Controllers/HeaderController.php new file mode 100644 index 0000000..1a7df13 --- /dev/null +++ b/main/survey/app/Controllers/HeaderController.php @@ -0,0 +1,920 @@ + $val) { + $g .= '&' . $key . '=' . $val; + } + + if ($encode) $g = str_replace('&', '&', $g); + + return $g; + + } + + /************************************************ + * Funcktja pridobi vse url parametre in jih ustrezno doda v globalne spremenljivke razreda SurveyClass + * + * @param $_GET + * @param $var - vse spremenljivke + * @return (obje ct) $get + ************************************************/ + public function getAllUrlParameters() + { + // Vse GET parametre damo v objekt + if (!empty($_GET)) + $get = (object)$_GET; + + //V kolikor gre za enkripcijo potem najprej dekriptiramo - URLDECODE SE ZE AVTOMATSKO IZVEDE NA $_GET array-u + if (isset($get->enc)) { + //$request_decoded = base64_decode(urldecode($get->enc)); + $request_decoded = base64_decode($get->enc); + + $request_array = array(); + parse_str($request_decoded, $request_array); + + foreach ($request_array as $var => $value) { + $get->$var = $value; + } + } + + //postavimo še ID ankete, ker ga bomo največkrat potrebovali + if (empty($get->anketa) && !is_int($get->anketa) && empty($_POST['anketa'])) { + return header('Location: ' . self::$site_url); + die("Missing anketa id!"); + } + $anketa = (($get->anketa) ? $get->anketa : $_POST['anketa']); + + // Shranimo vse spremenljivke iz get parametrov v classu VariableClass + save('anketa', $anketa); + save('get', $get); + + return $get; + } + + + /************************************************ + * Pridobimo vse parametre iz piškotka + * + * @param $_COOKIE + * @return (object) $cookie + ************************************************/ + public function getAllCookieParameters() + { + $cookie = null; + // Vse GET parametre damo v objekt + if (!empty($_COOKIE)) + $cookie = (object)$_COOKIE; + + // Piškot shranimo v spremenljivke VariableClass + save('cookie', $cookie); + + return $cookie; + } + + /** + * @desc zgenereira header + */ + public function header(){ + global $app_settings; + + + // preprecimo caching - tudi s klikom na gumb nazaj! + header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT"); + header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT"); + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 + header("Cache-Control: post-check=0, pre-check=0", FALSE); + header("Pragma: no-cache"); // HTTP/1.0 + + + echo '' . "\n"; + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $sqlv = sisplet_query("SELECT value FROM misc WHERE what='version'"); + $rowv = mysqli_fetch_array($sqlv); + + // Custom header title + if(isset($app_settings['head_title_custom']) && $app_settings['head_title_custom'] == 1){ + echo ''.strip_tags(Helper::getInstance()->displayAkronim(0)).' - '.$app_settings['head_title_text'].'' . "\n"; + } + // Default header title + else{ + echo ''.strip_tags(Helper::getInstance()->displayAkronim(0)).' - '.self::$lang['1ka_surveys'].'' . "\n"; + } + + echo ' ' . "\n"; + + // Preprecimo vklop compatibility moda v IE + echo ' ' . "\n"; + + // nova verzija UI 1.8.10 - includamo minificirano skupaj z script.js (uporabimo iste jQuery fajle kot v adminu) + echo ' ' . "\n"; + echo '' . "\n"; + + // tukaj nalozimo CSS za jquery in template temo + echo ' ' . "\n"; + + //nalozimo stringe iz langa za JS + echo '' . "\n"; + + // nalozimo open sans fonte za nov design + echo ''; + /*echo '';*/ + echo ''; + + + // CSS mobile skin za telefone in tablice + if (get('mobile') == 1) { + + echo ' ' . "\n"; + + // za MJU anketo nalozimo posebej custom skin + if(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){ + $this->loadCustomMadeSkin($custom_skin='MJU'); + } + // CSS samo za mobilne telefone + else{ + $this->themeEditorMobileCustom(); + } + } + // CSS za tablice je po defaultu enak kot za pc + elseif(get('mobile') == 2){ + + echo ' ' . "\n"; + + // za MJU anketo nalozimo posebej custom skin + if(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){ + $this->loadCustomMadeSkin($custom_skin='MJU'); + } + // profili tem - skinov + else{ + $this->themeEditor(); + } + } + // CSS za pc + else{ + + // Custom skin za Bled + if($row['skin'] == 'Bled'){ + $this->loadCustomMadeSkin($custom_skin='Bled'); + } + // za MJU anketo nalozimo posebej custom skin + elseif(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){ + $this->loadCustomMadeSkin($custom_skin='MJU'); + } + // profili tem - skinov + else{ + $this->themeEditor(); + } + } + + + // še css za printer + // tole je ze out-of-date, po moje je zaenkrat boljs brez posebnega print skina + //echo ' '."\n"; + + // Skin za glasovanje + $sqlG = sisplet_query("SELECT skin FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'"); + $rowG = mysqli_fetch_array($sqlG); + if (mysqli_num_rows($sqlG) > 0) + echo ' ' . "\n"; + + // CSS za modul kviz + if (SurveyInfo::getInstance()->checkSurveyModule('quiz')) { + echo ' ' . "\n"; + } + + // CSS za modul SAZU anketo + if (SurveyInfo::getInstance()->checkSurveyModule('sazu')) { + echo ' ' . "\n"; + } + + // CSS za rtl text - glede na lang datoteko (zaenkrat samo arabscina) + if (in_array(self::$lang['id'], array('39', '43'))) { + echo ' ' . "\n"; + } + + // JavaScript za napredne parapodatke + if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){ + + // Ce ne postamo oz. ce smo na zadnji strani vkljucimo js kodo + if(count($_POST) == 0 || Find::getInstance()->findNextGrupa($_GET['grupa']) == 0){ + SurveyAdvancedParadataLog::getInstance()->prepareLogging(); + SurveyAdvancedParadataLog::getInstance()->linkJavaScript(); + } + } + + echo '' . "\n"; + + + // Ce imamo vklopljen evoli na instalaciji, potem onemogocimo kopiranje + $evoli_copy_disable = ''; + if (Common::checkModule('evoli') == '1' || Common::checkModule('evoli_employmeter') == '1') + $evoli_copy_disable = 'oncopy="return false;" oncut="return false;" oncontextmenu="return false;"'; + + $preview = ''; + if (isset($_GET['preview']) && $_GET['preview'] == 'on') + $preview = ' class="preview"'; + elseif (isset($_GET['testdata']) && $_GET['testdata'] == 'on') + $preview = ' class="preview"'; + echo '' . "\n"; + + // Zamenjamo class no_js z js -> test javacsripta za userje (javascript_warning) + echo ""; + + if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1) { // vnos + + $sql1 = sisplet_query("SELECT user_id FROM srv_user WHERE id = '" . get('usr_id') . "'"); + $row1 = mysqli_fetch_array($sql1); + + $sqlu = Model::db_select_user($row1['user_id']); + $rowu = mysqli_fetch_array($sqlu); + + if (mysqli_num_rows($sqlu) > 0) { + echo '
'; + echo self::$lang['srv_recognized'] . ' ' . $rowu['name'] . ' ' . $rowu['surname'] . '
(' . $rowu['email'] . ')'; + echo '
' . "\n"; + } + + } + } + + /** + * @desc prikaze sistemske spremenljivke + */ + public function displaySistemske() + { + $sql = sisplet_query("SELECT id, recnum FROM srv_user WHERE id='" . get('usr_id') . "'"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + $row = mysqli_fetch_array($sql); + + echo ' '; + echo ' '; + + // Ce imamo vklopljen modul panel sproti belezimo tudi panel_status + if(SurveyInfo::checkSurveyModule('panel') == 1){ + + // Ce gre za prvo nastavimo na default vrednost, drugace beremo iz post-a + $sp = new SurveyPanel(get('anketa')); + $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $sp->getPanelSettings('status_default'); + + echo ' '; + } + + // Spremenljivke, ki se rabijo v JS + echo ' ' . "\n"; + + // Spremenljivke, ki se rabijo v JS za drag/drop + echo ' + + '; + } + + public function themeEditor($themePreview = false){ + + if (isset($_GET['theme'])) $themePreview = true; // to ne bo vec + if (isset($_GET['theme-preview']) && $_GET['theme-preview'] == '1') $themePreview = true; // to je pri urejanju CSSa da se refresha mimo cachea + + $row = SurveyInfo::getSurveyRow(); + + if (isset($_GET['theme_profile'])) { + $row['skin_profile'] = (int)$_GET['theme_profile']; + } + if (isset($_GET['theme'])) {//to ne bo vec + $row['skin'] = str_replace('.css', '', $_GET['theme']); + $row['skin_profile'] = 0; + } + + // ni nastavljenih profilov, nastavimo navadno temo + if ($row['skin_profile'] == 0) { + + // Ce ne gre za obstojeco anketo nastavimo default skin + if($row['skin'] == '') + $row['skin'] = '1kaBlue'; + + // moznost zip skinov + if (!is_file(self::$site_path . 'main/survey/skins/' . $row['skin'] . '.css')) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } + } + // nastavljen je profil, nastavimo temo in potem še lastne nastavitve + else { + + $sqla = sisplet_query("SELECT skin, logo FROM srv_theme_profiles WHERE id = '$row[skin_profile]'"); + $rowa = mysqli_fetch_array($sqla); + + // moznost zip skinov + if (!is_file(self::$site_path . 'main/survey/skins/' . $rowa['skin'] . '.css')) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } + + $sqlt = sisplet_query("SELECT * FROM srv_theme_editor WHERE profile_id = '" . $row['skin_profile'] . "'"); + if (mysqli_num_rows($sqlt) > 0) { + + echo ''; + } + + // Izrisemo css za custom logo + if ($rowa['logo'] != '') { + $this->customLogoCSS($rowa['logo']); + } + } + + // Za office in nature skina imamo random background + if($row['skin'] == '1kaOffice' || $row['skin'] == '1kaNature'){ + $bg_number = rand(1,15); + echo ''; + } + } + + public function themeEditorMobileCustom(){ + + $row = SurveyInfo::getSurveyRow(); + + // Najprej nalozimo mobile template skin + echo ' ' . "\n"; + + + if (isset($_GET['theme_profile'])) { + $row['skin_profile_mobile'] = (int)$_GET['theme_profile']; + } + if (isset($_GET['theme'])) { + $themePreview = true; + $row['mobile_skin'] = str_replace('.css', '', $_GET['theme']); + } + + + // Fonti za mobilne skine (vse razen prvega default) + if($row['mobile_skin'] != 'Mobile') + echo ''; + + + // ni nastavljenih profilov, nastavimo navadno temo + if ($row['skin_profile_mobile'] == 0) { + + if (!is_file(self::$site_path . 'main/survey/skins/' . $row['mobile_skin'] . '.css')) { + echo ' ' . "\n"; + } + else { + echo ' ' . "\n"; + } + } + // nastavljen je profil, nastavimo temo in potem še lastne nastavitve + else { + + $sqla = sisplet_query("SELECT skin FROM srv_theme_profiles_mobile WHERE id = '$row[skin_profile_mobile]'"); + $rowa = mysqli_fetch_array($sqla); + + if (!is_file(self::$site_path . 'main/survey/skins/' . $rowa['skin'] . '.css')) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } + + $sqlt = sisplet_query("SELECT * FROM srv_theme_editor_mobile WHERE profile_id = '" . $row['skin_profile_mobile'] . "'"); + if (mysqli_num_rows($sqlt) > 0) { + + echo ''; + } + } + + // Izrisemo css za custom logo + $sqla = sisplet_query("SELECT logo FROM srv_theme_profiles WHERE id = '$row[skin_profile]'"); + $rowa = mysqli_fetch_array($sqla); + + if ($rowa['logo'] != '') { + $this->customLogoCSS($rowa['logo']); + } + } + + + // Funkcija ki nalozi custom temo narejeno po narocilu + private function loadCustomMadeSkin($custom_skin){ + + if (isset($_GET['theme'])) $themePreview = true; // to ne bo vec + if (isset($_GET['theme-preview']) && $_GET['theme-preview'] == '1') $themePreview = true; // to je pri urejanju CSSa da se refresha mimo cachea + + + // Custom narejen skin za Bled + if($custom_skin == 'Bled'){ + + // Font PT sans + echo ''; + + // Imamo različne backgrounde + $bg_number = rand(1,9); + echo ''; + + echo ' ' . "\n"; + + // Premaknemo footer na dno + echo ''; + } + // Custom skin za MJU anketo + elseif($custom_skin == 'MJU'){ + + // Font PT sans + echo ''; + + // mobitel + if (get('mobile') == 1) { + echo ' ' . "\n"; + } + // tablica + elseif(get('mobile') == 2){ + echo ' ' . "\n"; + } + // navaden racunalnik + else{ + echo ' ' . "\n"; + } + } + } + + + // Insertamo css za custom logo + private function customLogoCSS($logo){ + + // Najprej dobimo velikost originalne slike + $image_orig = self::$site_url . 'main/survey/uploads/' . $logo; + if (file_exists(survey_path('uploads/' . $logo))) { + + $size_orig = @getimagesize($image_orig); + + $css_bg_image = $image_orig; + $css_width = ''; + $css_height = ''; + $css_bg_size = 'contain !important'; + + // Ce gre za Gorenje prikazemo drug logo + if(Common::checkModule('gorenje')){ + $css_bg_size = 'auto 50px !important'; + } + // Ce slucajno ne moremo dobiti siza + elseif(!$size_orig){ + $css_height = '100px'; + $css_width = '250px'; + } + // Ce je original visji kot 160 ga avtomatsko pomanjsamo + elseif($size_orig[1] > 160) { + + $image = self::$site_url . 'function/thumb.php?src=' . self::$site_url . 'main/survey/uploads/' . $logo . '&h=100'; + $size = @getimagesize($image); + + if($size){ + $css_bg_image = $image; + $css_width = $size[0].'px'; + $css_height = '100px'; + } + } + // Drugace pustimo default size logotipa + else{ + $css_width = $size_orig[0].'px'; + $css_height = $size_orig[1].'px'; + } + + + // CSS za custom logo + echo ''; + } + } + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/HelperController.php b/main/survey/app/Controllers/HelperController.php new file mode 100644 index 0000000..58e6784 --- /dev/null +++ b/main/survey/app/Controllers/HelperController.php @@ -0,0 +1,747 @@ +isMobile()) + $ismobile = 1; + + if ($ismobile == 1) { + if ($detect->isTablet()) + $mobile = 2; + else + $mobile = 1; + } + + // prednost pa ima rocno izbrana opcija - ce je nastavljena + if (isset($_COOKIE['mobile'])) { + $c = (int)$_COOKIE['mobile']; + if ($c > 0) + $mobile = $mobile; + else + $mobile = 0; + } + + // Ce smo slucajno v preview-ju preverimo kateri preview prikazemo + if (isset($_GET['preview']) && $_GET['preview'] == 'on') { + if (isset($_GET['mobile']) && $_GET['mobile'] == 1) + $mobile = 1; + elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2) + $mobile = 2; + }; + + return $mobile; + } + + /** + * @desc V podanem stringu poisce spremenljivke in jih spajpa z vrednostmi + */ + public static function dataPiping($text) + { + // V kolikor imamo vključen modul hierarhija potem uporabimo ustrezno pajpanje za hierarhijo + if (SurveyInfo::getInstance()->checkSurveyModule('hierarhija')) + return HierarhijaHelper::dataPiping($text, get('anketa')); + + + Common::getInstance()->Init(get('anketa')); + + return Common::getInstance()->dataPiping($text, get('usr_id'), get('loop_id'), get('lang_id')); + + } + + /** + * vrne IP naslov (tudi ce gre preko proxyja) + * + */ + public static function remote_address() + { + return GetIP(); + } + + /************************************************ + * Vrnemo ime ankete + * + * @param $show_page = 1 - ali prikažemo omenjen naslov na spletni strani + * @return string + ************************************************/ + public function displayAkronim($show_page = 1) + { + $row = SurveyInfo::getInstance()->getSurveyRow(); + $srv_novaanketa_kratkoime = null; + + SurveySetting::getInstance()->Init(get('anketa')); + $survey_hide_title = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hide_title'); + + if ($survey_hide_title == 1 /*&& $row['survey_type'] != 0*/) + return; + + if (get('lang_id') != null) { + if (get('lang_id') != null) + $_lang = '_' . get('lang_id'); + else + $_lang = ''; + + $srv_novaanketa_kratkoime = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime' . $_lang); + } + + if ($show_page == 1 && get('grupa') > 0) { + $sql1 = sisplet_query("SELECT naslov FROM srv_grupa WHERE id = '" . get('grupa') . "'"); + $row1 = mysqli_fetch_array($sql1); + $grupa = ' - ' . $row1['naslov'] . ''; + } else $grupa = ''; + + if ($srv_novaanketa_kratkoime != '') + return $srv_novaanketa_kratkoime . $grupa; + else + return (($row['akronim'] == null || $row['akronim'] == '') ? $row['naslov'] . $grupa : $row['akronim'] . $grupa); + } + + /** + * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu + */ + public static function getElements($if) + { + $elements = get('getElements'); + $anketa = get('anketa'); + + if (array_key_exists($if, $elements)) { + return $elements[$if]; + } + + $array = array(); + + Cache::cache_all_srv_branching($anketa); + + foreach (Cache::srv_branching_parent($anketa, $if) AS $k => $row) { + + if ($row['element_spr'] > 0) + array_push($array, $row['element_spr']); + else + foreach (self::getElements($row['element_if']) AS $key) + array_push($array, $key); + + } + + return save('getElements[' . $if . ']', $array, 1); + } + + /** + * @desc vrne ce obstaja parent z nastavitvijo horizontal pri blokih da prikazemo vprasanja vodoravno (horizontal==1) ali z razpiranjem (horizontal==2) ce je vklopljena nastavitev + */ + public static function checkParentHorizontal($element){ + + Cache::cache_all_srv_branching(get('anketa')); + + $parent = $element['parent']; + + $rowb = Cache::srv_if($element['element_if']); + if ($rowb['horizontal'] == 1 || $rowb['horizontal'] == 2) { + return $rowb['horizontal']; + } + elseif ($parent == 0) { + return false; + } + elseif ($parent == 0) { + return false; + } + else { + $row = Cache::srv_branching(0, $parent); + return self::checkParentHorizontal($row); + } + } + + public static function getGrupa($spremenljivka) + { + $grupa = get('getGrupa'); + + if (array_key_exists($spremenljivka, $grupa)) + return $grupa[$spremenljivka]; + + $row = Model::select_from_srv_spremenljivka($spremenljivka); + + return save('getGrupa[' . $spremenljivka . ']', $row['gru_id'], 1); + } + + public static function getDatepickerRange($spremenljivka, $date_element) + { + # po potrebi pripravimo datum range + $row = Cache::srv_spremenljivka($spremenljivka); + $newParams = new enkaParameters($row['params']); + $min = $newParams->get('date_range_min'); + $max = $newParams->get('date_range_max'); + $range_string = null; + + # ce imamo spodnji range + $range = ($min != "") ? $min : '-80'; + + $range .= ':'; + + # ce imamo zgornji range - plus je potrebno dodat posebej + if ($max == "") + $range .= '+10'; + else if ($max < 100) + $range .= '+' . $max; + else + $range .= $max; + + # ce imamo nastavljen spodnji ali zgornji range + $range_string = "$( \"{$date_element}\" ).datepicker( \"option\", \"yearRange\", \"{$range}\" );"; + + // Ce ni danasnji dan v rangu -> moramo posebej nastavit trenutni datum (zaradi jquery buga) + if (substr($max, 0, 1) == '-' || substr($min, 0, 1) == '+') { + $date = '1.1.' . ((int)date("Y") + (int)$min); + $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"defaultDate\", \"{$date}\" );"; + } elseif ($min > date("Y") || $max < date("Y")) { + $date = '1.1.' . $min; + $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"defaultDate\", \"{$date}\" );"; + } + + // dodamo se, da je prvi dan v tednu ponedeljek + $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"firstDay\", 1 );"; + + # nastavimo datumski range + echo $range_string; + } + + public static function getCustomCheckbox() + { + + //ID skin_profile + $skin_id = SurveyInfo::getInstance()->getSurveyRow()['skin_profile']; + + //srv_theme_editor -> velikost PC/mobilne ikone + $type = 7; + + if (get('mobile') > 0) + $type = 8; //če gre za mobilnik ali tablico potem pridobimo ustrezne ikone za tole + + $sql = sisplet_query("SELECT value FROM srv_theme_editor WHERE profile_id = '$skin_id' AND id='7' AND type='$type'"); + $row = mysqli_fetch_array($sql); + if (!$row || empty($row) || is_null($row)) + return 0; + + return $row['value']; //vrnemo velikost custom radio/checkboxa + } + + /** + * @desc poslje alerte o izpolnjeni anketi + */ + public function alert() + { + global $site_path; + + # kadar popravljamo obstoječe podatke ne pošiljamo več obvestil o končani anketi (Ajda) + if ($_GET['urejanje'] == 1) { + return; + } + + // Ce smo v predogledu ali testiranju ne posiljamo obvestila + if ($_GET['preview'] == 'on') { + return; + } + + // Preverimo ce imamo ustrezen paket kjer je na voljo obvescanje + $userAccess = UserAccess::getInstance(self::$global_user_id); + if (!$userAccess->checkUserAccess($what='alert')){ + return; + } + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'"); + $rowAlert = mysqli_fetch_array($sqlAlert); + + // array z emaili + $emails = array(); + # TODO + # dodat tabelo, z emaili, za userje cms-ja če bi se želeli odjavit od obveščanja posamezne ankete + # ker sedaj nimamo povezave na njihov eemaile in se ne morejo odjaviti + # not bi blo fajn dat: anketa_id, email, code (kodo za preverjanje istovetnosti) + # in potem če klikne na link odjaviti in skopirati v tabelo: srv_survey_unsubscribe, da se uporabniku ne pošilja več + + $ime = ''; + + // alert Avtorja in ostalih v dostopu + if ($rowAlert['finish_author'] == 1) { + $sqlInsertUID = Model::db_select_user($row['insert_uid']); + $rowInsertUID = mysqli_fetch_array($sqlInsertUID); + + + // polovimo se avtorje katerim je omogocen dostop in imajo nastavljeno da dobivajo obvestila - po novem med njimi ni nujno glavni avtor ankete + $sqlAlertAuthors = sisplet_query("SELECT u.email, u.id FROM users as u " + . " RIGHT JOIN (SELECT sd.uid, sd.alert_complete FROM srv_dostop as sd WHERE sd.ank_id='" . get('anketa') . "' AND sd.alert_complete = '1') AS dostop ON u.id = dostop.uid"); + while ($rowAlertAuthors = mysqli_fetch_assoc($sqlAlertAuthors)) { + + $sql1 = sisplet_query("SELECT alert_complete_if, uid AS id FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . $rowAlertAuthors['id'] . "'"); + $row1 = mysqli_fetch_array($sql1); + + # kodo preberemo iz srv_users + $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND user_id = '" . $rowAlertAuthors['id'] . "'"; + $c2q = sisplet_query($c2s); + list($c2) = mysqli_fetch_row($c2q); + # nastavimo password če še ni + $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND user_id = '" . $rowAlertAuthors['id'] . "' AND pass IS NULL"; + $qrySqlUpd = sisplet_query($strSqlUpd); + + // ce imamo if na posiljanje mailov + if ($row1['alert_complete_if'] > 0) { + if (Check::getInstance()->checkIf($row1['alert_complete_if'])) { + $emails[] = array('mail' => $rowAlertAuthors['email'], 'type' => 'author', 'uid' => $rowAlertAuthors['id']); + } + } else { + $emails[] = array('mail' => $rowAlertAuthors['email'], 'type' => 'author', 'uid' => $rowAlertAuthors['id']); + } + } + } + // alert respondenta (ki vpise svoj mail ob izpolnjevanju) + if ($rowAlert['finish_respondent'] == 1) { + // email + $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='email' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'"); + $row2 = mysqli_fetch_array($sql2); + + $sql11 = sisplet_query("SELECT finish_respondent_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'"); + $row11 = mysqli_fetch_array($sql11); + + # kodo preberemo iz srv_users + $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "'"; + $c2q = sisplet_query($c2s); + list($c2) = mysqli_fetch_row($c2q); + # nastavimo password če še ni + $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "' AND pass IS NULL"; + $qrySqlUpd = sisplet_query($strSqlUpd); + + // Ce resujemo anketo v drugem jeziku pogledamo ce imamo nastavljen custom mail za tuje jezike + $sql_ac = sisplet_query("SELECT * FROM srv_alert_custom WHERE ank_id='" . get('anketa') . "' AND type='respondent_lang_" . get('lang_id') . "' AND uid='0'"); + if (mysqli_num_rows($sql_ac) > 0) { + $row_ac = mysqli_fetch_array($sql_ac); + $emails[] = array('mail' => $row2['text'], 'type' => $row_ac['type'], 'uid' => '0', 'code' => $c2); + } // ce imamo if na posiljanje mailov + elseif ($row11['finish_respondent_if'] > 0) { + if (Check::getInstance()->checkIf($row11['finish_respondent_if'])) { + $emails[] = array('mail' => $row2['text'], 'type' => 'respondent', 'uid' => '0', 'code' => $c2); + } + } else { + $emails[] = array('mail' => $row2['text'], 'type' => 'respondent', 'uid' => '0', 'code' => $c2); + } + + // ime + $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='ime' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + + $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'"); + $row2 = mysqli_fetch_array($sql2); + + $ime = $row2['text']; + + } + + // alert respondenta prepoznanega iz sispleta + if ($rowAlert['finish_respondent_cms'] == 1) { + $sql1 = Model::db_select_user(self::$global_user_id); + $row1 = mysqli_fetch_array($sql1); + + if ($row1['email'] != '') { + + $sql11 = sisplet_query("SELECT finish_respondent_cms_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'"); + $row11 = mysqli_fetch_array($sql11); + + # kodo preberemo iz srv_users + $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND user_id = '" . get('usr_id') . "'"; + $c2q = sisplet_query($c2s); + list($c2) = mysqli_fetch_row($c2q); + + $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND user_id = '" . get('usr_id') . "' AND pass IS NULL"; + $qrySqlUpd = sisplet_query($strSqlUpd); + + // ce imamo if na posiljanje mailov + if ($row11['finish_respondent_cms_if'] > 0) { + if (Check::getInstance()->checkIf($row11['finish_respondent_cms_if'])) { + $emails[] = array('mail' => $row1['email'], 'type' => 'respondent_cms', 'uid' => '0', 'code' => $c2); + } + } else { + $emails[] = array('mail' => $row1['email'], 'type' => 'respondent_cms', 'uid' => '0', 'code' => $c2); + } + + } + + } + + // alert na ostale maile + if ($rowAlert['finish_other'] == 1) { + + $email = explode("\n", str_replace("\r", "", str_replace(",", "\r\n", str_replace(" ", "", $rowAlert['finish_other_emails'])))); + if (count($email) > 0) + foreach ($email AS $mail) { + + $sql11 = sisplet_query("SELECT finish_other_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'"); + $row11 = mysqli_fetch_array($sql11); + + // ce imamo if na posiljanje mailov + if ($row11['finish_other_if'] > 0) { + if (Check::getInstance()->checkIf($row11['finish_other_if'])) { + $emails[] = array('mail' => $mail, 'type' => 'other', 'uid' => '0'); + } + } else { + $emails[] = array('mail' => $mail, 'type' => 'other', 'uid' => '0'); + } + } + } + + // sestavimo sporocilo + if ($row['finish_respondent_cms'] == 1) { + $sql1 = Model::db_select_user(self::$global_user_id); + $row1 = mysqli_fetch_array($sql1); + $ime = '' . $row1['name'] . ' ' . $row1['surname']; + } + + # meta_url + $sql_meta_strings = "SELECT referer FROM srv_user where ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "'"; + $sql_meta_query = sisplet_query($sql_meta_strings); + list($meta_url) = mysqli_fetch_row($sql_meta_query); + + // Podpis + $signature = Common::getEmailSignature(); + + $text = ($rowAlert['finish_text'] == '') ? '[NAME] ' . self::$lang['srv_alert_msg'] . ' [SURVEY] [DATE] ("[URL]")'.$signature : $rowAlert['finish_text']; + $subject = ($rowAlert['finish_subject'] != '') ? $rowAlert['finish_subject'] : self::$lang['srv_alert_subject']; + + $sqlu = sisplet_query("SELECT email FROM users WHERE id = '$row[insert_uid]'"); + $rowu = mysqli_fetch_array($sqlu); + $MailReply = $rowu['email']; + + if ($rowAlert['reply_to'] != '') $MailReply = $rowAlert['reply_to']; + + // preprečimo večkratno pošiljanje na iste naslove + array_unique($emails); + + # preverimo odjavljenost od prejemanja obvestil + $su = new SurveyUnsubscribe(get('anketa')); + + // posljemo maile + foreach ($emails AS $mail_list) { + $mail = trim($mail_list['mail']); + $unsubscribed = $su->isUnsubscribedEmail($mail); + + + $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode( + serialize( + array('a' => 'pdf_results', + 'anketa' => get('anketa'), + 'usr_id' => get('usr_id'), + 'type' => '0', + 'pdf_usr_type' => $mail_list['type'], + 'pdf_usr_id' => $mail_list['uid'] + ))); + + $rtf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode( + serialize( + array('a' => 'rtf_results', + 'anketa' => get('anketa'), + 'b' => 'export', + 'usr_id' => get('usr_id'), + 'pdf_usr_type' => $mail_list['type'], + 'pdf_usr_id' => $mail_list['uid'] + ))); + + + if ($mail != '' && $unsubscribed == false && (strlen($mail) > 1)) { + + $sql_ac = sisplet_query("SELECT subject, text FROM srv_alert_custom WHERE ank_id='" . get('anketa') . "' AND type='{$mail_list['type']}' AND uid='{$mail_list['uid']}'"); + if (mysqli_num_rows($sql_ac) > 0) { + $row_ac = mysqli_fetch_array($sql_ac); + $s = $row_ac['subject']; + $t = $row_ac['text']; + } else { + $s = $subject; + $t = $text; + } + // naredimo še data piping za odgovore + $t = Helper::dataPiping($t); + + #zamenjamo morebitne sistemske variable + $t = str_replace( + array('[NAME]', + '[SURVEY]', + '[DATE]', + '[SITE]', + '[URL]', + '[PDF]', + '[RTF]', + '[META_REFERER_URL]', + '[DURATION]' + ), + array($ime, + $row['akronim'], #$row['naslov'], + date("d.m.Y, H:i:s"), + //''.self::$site_url.'a/'.get('anketa').'', + '' . SurveyInfo::getSurveyLink() . '', + '' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '', + '' . self::$lang['srv_alert_link_pdf'] . '', + '' . self::$lang['srv_alert_link_rtf'] . '', + '' . $meta_url . '', + '' . self::$lang['srv_activate_duration'] . '' + ), + $t); + + $s = str_replace( + array('[NAME]', + '[SURVEY]', + '[DATE]', + '[SITE]', + '[URL]', + '[PDF]', + '[RTF]', + '[DURATION]'), + array($ime, + $row['naslov'], + date("d.m.Y, H:i:s"), + //self::$site_url.'a/'.get('anketa'), + SurveyInfo::getSurveyLink(), + self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa'), + '' . self::$lang['srv_alert_link_pdf'] . '', + '' . self::$lang['srv_alert_link_rtf'] . '', + '' . self::$lang['srv_activate_duration'] . ''), + $s); + + if ($mail_list['code'] == null || trim($mail_list['code']) == '') { + # v tabelo srv_survey_unsubscribe_codes dodamo email in kodo za možnost odjave od obveščanja + $uc = $su->generateCodeForEmail($mail); + $unsubscribe = self::$site_url . 'admin/survey/unsubscribe.php?anketa=' . get('anketa') . '&uc=' . $uc . '&em=' . base64_encode($mail); + } else { + $unsubscribe = self::$site_url . 'admin/survey/unsubscribe.php?anketa=' . get('anketa') . '&code=' . $mail_list['code']; + } + + $t = str_replace( + array('#UNSUBSCRIBE#', '[UNSUBSCRIBE]'), + array('' . self::$lang['user_bye_hl'] . '', + '' . self::$lang['user_bye_hl'] . '',) + , $t); + + + try { + $MA = new MailAdapter(get('anketa'), $type='alert'); + $MA->addRecipients($mail); + + // Shranimo email from in reply to (da ju potem nazaj nastavimo - drugace povozimo nastavitve od vabil) + $mailFromBCK = $MA->getMailFrom(); + $mailReplyToBCK = $MA->getMailReplyTo(); + + // Nastavimo na raziskave - obvescanje je iz raziskave@1ka.si ce se ni nastavljeno posebej v smtp nastavitvah + $MA->setMailReplyTo($MailReply); + if ($mailFromBCK == '' || $mailFromBCK == 'info@1ka.si') + $MA->setMailFrom('raziskave@1ka.si'); + + // Posljemo mail + $result = $MA->sendMail(stripslashes($t), $s); + + // Nazaj nastavimo posiljatelja (za nastavitve v vabilih) + $MA->setMailReplyTo($mailReplyToBCK); + $MA->setMailFrom($mailFromBCK); + } catch (Exception $e) { + } + } + } + + return; + } + + /** + * @desc poslje alert o dosezeni kvoti za evoli - team meter + */ + public function alertTeamMeter() + { + global $site_path; + + # kadar popravljamo obstoječe podatke ne pošiljamo več obvestil o končani anketi (Ajda) + if ($_GET['urejanje'] == 1) { + return; + } + + // Ce smo v predogledu ali testiranju ne posiljamo obvestila + if ($_GET['preview'] == 'on') { + return; + } + + + // Preverimo ce smo dosegli kvoto + $sqlGroupTM = sisplet_query("SELECT d.vre_id 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); + + $sqlTM = sisplet_query("SELECT tm.*, v.vrstni_red AS skupina FROM srv_evoli_teammeter tm, srv_vrednost v + WHERE tm.ank_id='" . get('anketa') . "' AND tm.skupina_id='" . $rowGroupTM['vre_id'] . "' AND tm.skupina_id=v.id"); + $rowTM = mysqli_fetch_array($sqlTM); + + // Preverimo ce smo slucajno ze posiljali porocilo + $datum_posiljanja = $rowTM['datum_posiljanja']; + + // Kvota je dosezena - POSLJEMO OBVESTILO + if ($rowTM['kvota_max'] == $rowTM['kvota_val'] && $datum_posiljanja == '0000-00-00 00:00:00') { + + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'"); + $rowAlert = mysqli_fetch_array($sqlAlert); + + // Podpis + $signature = Common::getEmailSignature(); + + $text = ($rowAlert['finish_text'] == '') ? '[NAME] ' . self::$lang['srv_alert_msg'] . ' [SURVEY] [DATE] ("[URL]")'.$signature : $rowAlert['finish_text']; + $subject = ($rowAlert['finish_subject'] != '') ? $rowAlert['finish_subject'] : self::$lang['srv_alert_subject']; + + $MailReply = $rowTM['email']; + + if ($rowAlert['reply_to'] != '') $MailReply = $rowAlert['reply_to']; + + // Mail posljemo avtorju skupine (podjetja) + $mail = $rowTM['email']; + + $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode( + serialize( + array('m' => 'pdf_teammeter', + 'anketa' => get('anketa'), + 'skupina' => $rowTM['skupina'] + ))); + + if ($mail != '' && (strlen($mail) > 1)) { + + $s = $subject; + $t = $text; + + // naredimo še data piping za odgovore + $t = Helper::dataPiping($t); + + #zamenjamo morebitne sistemske variable + $t = str_replace( + array( + '[NAME]', + '[SURVEY]', + '[DATE]', + '[SITE]', + '[URL]', + '[PDF]', + '[DURATION]' + ), + array( + $ime, + $row['akronim'], #$row['naslov'], + date("d.m.Y, H:i:s"), + '' . SurveyInfo::getSurveyLink() . '', + '' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '', + '' . self::$lang['srv_alert_link_pdf'] . '', + '' . self::$lang['srv_activate_duration'] . '' + ), + $t); + + $s = str_replace( + array( + '[NAME]', + '[SURVEY]', + '[DATE]', + '[SITE]', + '[URL]', + '[PDF]', + '[DURATION]' + ), + array( + $ime, + $row['naslov'], + date("d.m.Y, H:i:s"), + SurveyInfo::getSurveyLink(), + self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa'), + '' . self::$lang['srv_alert_link_pdf'] . '', + '' . self::$lang['srv_activate_duration'] . '' + ), + $s); + + try { + $MA = new MailAdapter(get('anketa'), $type='alert'); + $MA->addRecipients($mail); + + // Shranimo email from in reply to (da ju potem nazaj nastavimo - drugace povozimo nastavitve od vabil) + $mailFromBCK = $MA->getMailFrom(); + $mailReplyToBCK = $MA->getMailReplyTo(); + + // Nastavimo na raziskave - obvescanje je iz raziskave@1ka.si ce se ni nastavljeno posebej v smtp nastavitvah + $MA->setMailReplyTo($MailReply); + if ($mailFromBCK == '' || $mailFromBCK == 'info@1ka.si') + $MA->setMailFrom('raziskave@1ka.si'); + + // Posljemo mail + $result = $MA->sendMail(stripslashes($t), $s); + + // Nazaj nastavimo posiljatelja (za nastavitve v vabilih) + $MA->setMailReplyTo($mailReplyToBCK); + $MA->setMailFrom($mailFromBCK); + } + catch (Exception $e) { + } + + // Updatamo timestamp posiljanja + $sql = sisplet_query("UPDATE srv_evoli_teammeter SET datum_posiljanja=NOW() WHERE id='".$rowTM['id']."'"); + } + } + + return; + } +} \ No newline at end of file diff --git a/main/survey/app/Controllers/InitClass.php b/main/survey/app/Controllers/InitClass.php new file mode 100644 index 0000000..f0c7dc9 --- /dev/null +++ b/main/survey/app/Controllers/InitClass.php @@ -0,0 +1,1230 @@ +loadIfPrintPreviewFalse(); + } else { + return $this->loadIfPrintPreviewTrue(); + } + } + + /************************************************ + * Print preview je izključen + ************************************************/ + private function loadIfPrintPreviewFalse() + { + // cist na zacetku preverimo referer. Ce je prisel od kje drugje (napacno skopiran link itd...) ga preusmerimo na prvo stran ankete + if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], self::$site_url) === false && !isset($_GET['code']) && !isset($_GET['return']) && !isset($_GET['params'])) { + + $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!")); + save('anketa', $anketa); + + // Pri ul evalvaciji tega ne pustimo, ker drugace narobe preusmeri + if (Common::checkModule('evalvacija') == '0') { + + // to more bit, ker zgleda da pri redirectu browser ne nastavi novega refererja... (tudi websm anketa ne rabi tega - vedno mora skocit na ustrezno stran) + if ($_COOKIE['ref'] != get('anketa') && !(get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1')) { + + // prenesemo sistemske spremenljivke, ki so podane preko URLja + $sql1 = sisplet_query("SELECT s.id, s.variable FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND s.sistem='1' AND (s.tip='4' OR s.tip='21' OR s.tip='1')"); + $g = ''; + while ($row1 = mysqli_fetch_array($sql1)) + if (isset($_GET[$row1['variable']])) $g .= '&' . $row1['variable'] . '=' . $_GET[$row1['variable']]; + + $g .= Header::getSurveyParams(); + + //$redirect_url = self::$site_url."a/".get('anketa').$g; + $redirect_url = SurveyInfo::getSurveyLink(false, false) . $g; + $request_url = 'http' . ($_SERVER['HTTPS'] ? 's' : null) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + + if ($redirect_url != $request_url) { // to je extra check, da pridejo skozi in se ne vrtijo v neskoncni zanki tudi ljudje (paranoiki :) ) brez cookiejev + setcookie('ref', get('anketa')); // cookie z referalom + + header("Location: " . $redirect_url); + die(); + } + } + } + } + + // ce se je vrnil na anketo preko URLja + if (isset($_GET['return'])) { + Check::getInstance()->check_cookie_return(); + } + + if (isset($_GET['anketa']) || isset($_POST['anketa'])) { + + $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!")); + save('anketa', $anketa); + + // Preverimo ce gre za POSEBNO webSM anketo (ki ne shranjuje nicesar - samo direktno preusmeri na ustrezno stran) + if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') + $this->jeWebSMSurvey(); + + // polovimo podatke o anketi + SurveyInfo::getInstance()->SurveyInit(get('anketa')); + if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) + save('db_table', '_active'); + + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + // Ce anketa sploh ne obstaja + if (!$rowa) { + Display::getInstance()->displayNapaka(self::$lang['no_survey']); + die(); + } + + // Ce nima dostopa do ankete + if (!((self::$admin_type <= $rowa['odgovarja'] && self::$admin_type >= 0) || ($rowa['odgovarja'] == 4))) { + Display::getInstance()->displayNapaka(self::$lang['no_access']); + die(); + } + + + // pretecena anketa, kontroliramo datum na: starts in expire + $stringe = "SELECT id , CURDATE(), starts, expire FROM srv_anketa WHERE id='" . get('anketa') . "' AND starts <= CURDATE() AND expire >= CURDATE()"; + $sqle = sisplet_query($stringe); + + // Tudi ce je zakljucena pustimo prikaz pri nastavljenem glas_end -> preklop arhiva statistike pri glasovanju - drugace izpisemo obvestilo o zakljucku + if (!(isset($_GET['preview']) && $_GET['preview'] == 'on') && ($rowa['active'] < 1 or mysqli_num_rows($sqle) == 0) && (!isset($_GET['glas_end']) && (!isset($_GET['urejanje'])))) + $this->anketaEnd($rowa); + + + // Preverimo ce je nastavljen staticen uvod (ki ne belezi nicesar) - da se pri embeddanih anketah ne shranjujejo vsi obiskovalci ampak se user ustvari sele na prvi strani po uvodu + if ($rowa['intro_static'] > 0 && $rowa['show_intro'] == 1 && count($_POST) == 0 && !isset($_GET['grupa'])) { + + // inicializiramo jezik za multilang anketo + Language::getInstance()->multilang_init(); + + // konec ukvarjanja s cookieji, prikazemo header + Header::getInstance()->header(); + + Body::getInstance()->displayStaticIntroduction(); + die(); + } // Ce imamo staticen uvod s captcho in smo kliknili na naslednjo stran, najprej preverimo captcho + elseif ($rowa['intro_static'] == 2 && $rowa['show_intro'] == 1 && count($_POST) != 0 && isset($_GET['grupa']) && $_GET['grupa'] == '0') { + Check::getInstance()->check_captcha_intro(); + } + + + // ali je respondent avtor ankete (zaradi posebnih opcij prepoznave) + $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'"); + if (mysqli_num_rows($sqlUserAutor) > 0) + save('userAutor', true); + + // Ce imamo nastavljeno da vedno zahtevamo kodo + if (isset($_GET['code']) && $rowa['usercode_required'] == 1) { + unset($_GET['code']); + } + + // pogledamo na kolk je nastavljen expire za cookie v nastavitvi ankete + $row = SurveyInfo::getInstance()->getSurveyRow(); + save('cookie_expire', $row['cookie']); + + if ($row['cookie'] == 0) { + $this->expire = 0; + } elseif ($row['cookie'] == -1) { + if ($rowa['user_from_cms'] == 1) { + $this->expire = time() - 3600; + } else { + $this->expire = 0; + } + } elseif ($row['cookie'] == 1) { + $this->expire = time() + 3600; + } else { + $this->expire = time() + 2500000; + } + + // Preberimo cookie stringiii + $this->cookie = null; + + // da delata oba načina nastavljanja piškotkov, neglede na nastavitve + if (isset($_GET['survey-' . get('anketa')])) + $this->cookie = $_GET['survey-' . get('anketa')]; // Pri nastavitvi brez cookie-ja se cookie string prenaša preko URL-ja + if (isset($_COOKIE['survey-' . get('anketa')])) + $this->cookie = $_COOKIE['survey-' . get('anketa')]; // Obicajen cookie + + + // EVALVACIJA - Ce je nov respondent preverimo ce se je vrnil (zapis v tabeli eval_data_userCookie) in mu nastavimo ustrezen cookie da ga preusmerimo na ustrezno stran + if (Common::checkModule('evalvacija') == '1' && $this->cookie == null) + $this->cookie = $this->evlavacijaNovRespondent(); + + // HIERARHIJA - UČITELJ, preverimo, če je učitelj ponovno prišel nazaj + if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2 && is_null($this->cookie)) + $this->cookie = $this->hierarhijaPreveriCeSeJeUciteljVrnilPonovnoResevatiAnketo(); + + // poskrbimo za user ID + // + // tuki je kookie ze nastavljen in ga samo preberemo + if ($this->cookie != null) + $this->cookieExist($this->cookie); + + // kukija se ni, ga bomo pa nastavil + if ($this->cookie == null) + $this->cookieIsNull(); + + + // tukaj bomo dodatno preverjali, ce slucajno kje&kdaj pride do napake da usr_id ni postavljen + if (get('usr_id') == 0) { + $get = ''; + foreach ($_GET AS $key => $val) { + if ($get != '') + $get .= ', '; + $get .= $key . ': "' . $val . '"'; + } + + $post = ''; + foreach ($_POST AS $key => $val) { + if ($post != '') + $post .= ', '; + $post .= $key . ': "' . $val . '"'; + } + $kuki = ''; + foreach ($_COOKIE AS $key => $val) { + if ($kuki != '') + $kuki .= ', '; + $kuki .= $key . ': "' . $val . '"'; + } + $text = 'GET: ' . $get . '; POST: ' . $post . '; COOKIE: ' . $kuki; + + $sql_log = sisplet_query("SELECT value FROM srv_survey_misc WHERE sid = '" . get('anketa') . "' AND what = 'usr_id_error'"); + $row_log = mysqli_fetch_array($sql_log); + $text = $row_log['value'] . "\n" . $text; + + sisplet_query("REPLACE INTO srv_survey_misc (sid, what, value) VALUES ('" . get('anketa') . "', 'usr_id_error', '" . $text . "')"); + } + + // inicializiramo jezik za multilang anketo + Language::getInstance()->multilang_init(); + + // konec ukvarjanja s cookieji, prikazemo header + Header::getInstance()->header(); + + //prikaz konca ankete - posebej statistika pri glasovanju + if (isset($_GET['glas_end'])) { + + Body::getInstance()->displayKonecGlasovanje(); + + } else { + if (isset($_GET['loop_id'])) save('loop_id', $_GET['loop_id']); + + // nismo se poslali kaksno stran z odgovori + if (count($_POST) == 0) { + + // Preverimo kvoto pri Evoli Team Meter + 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') + ) { + + // Ce imamo nastavljeno skupino + if (isset($_GET['skupina'])) { + + $skupina_id = $_GET['skupina']; + + $sqlGroupTM = sisplet_query("SELECT kvota_val, kvota_max, date_to FROM srv_evoli_teammeter WHERE ank_id='" . get('anketa') . "' AND skupina_id='" . $skupina_id . "'"); + $rowGroupTM = mysqli_fetch_array($sqlGroupTM); + + // Ce je kvota ze dosezena + if ($rowGroupTM['kvota_val'] >= $rowGroupTM['kvota_max']) { + Body::getInstance()->displayKonecEvoliTM(); + die(); + } + + // Ce je datum ze presezen + if (strtotime($rowGroupTM['date_to']) < time() - (60 * 60 * 24)) { + $date_to = date('d.m.Y', strtotime($rowGroupTM['date_to'])); + Body::getInstance()->displayKonecEvoliTM($date_to); + die(); + } + } + } + + if (isset($_GET['grupa'])) + save('grupa', $_GET['grupa']); + + if ($rowa['show_intro'] == 0 && !isset($_GET['grupa'])) { + $this->set_userstatus(3); + SaveSurvey::saveSistemske(); + save('grupa', Find::getInstance()->findNextGrupa()); + } + + if (get('grupa') == 'end') { + $this->set_userstatus(6); + + Body::getInstance()->displayKonec(); + + } + elseif (get('displayAllPages')) { + + Body::getInstance()->displayAllPages(); + + + } + // prikazemo ustrezno stran / grupo + elseif (get('grupa') > 0) { + + $preskok = false; + + // pogledamo ce preskocimo kaksno stran zaradi branchinga + while (!Check::getInstance()->checkGrupa() && get('grupa') > 0 && $_GET['disableif'] != 1) { + + SaveSurvey::getInstance()->posted(1); + save('grupa', Find::getInstance()->findNextGrupa()); + $preskok = true; + } + + if ($preskok) SaveSurvey::getInstance()->posted_commit(); // pri preskokih se ne shranjuje sproti v bazo, ampak na koncu, vse naenkrat + + if (get('grupa') > 0) { + Body::getInstance()->displayAnketa(); + } else { + $this->set_userstatus(6); + Body::getInstance()->displayKonec(); + } + + // prikazemo uvodni nagovor - introduction + } else { + + // nastavimo status -- kliknil je na anketo + $this->set_userstatus(3); + + Body::getInstance()->displayIntroduction(); + } + } + // poslani so bili odgovori + else { + + save('grupa', $_GET['grupa']); + + // Preverimo ce gre za gdpr anketo in ce je sprejel pogoje za sodelovanje + if(GDPR::isGDPRSurveyTemplate(get('anketa'))){ + + // Ni sprejel pogojev za sodelovanje - vrzemo na zakljucek + if(isset($_POST['gdpr']) && $_POST['gdpr_accept'] == '0'){ + Body::getInstance()->displayKonec(); + die(); + } + // Ni oznacil ali sprejema pogoje + elseif(isset($_POST['gdpr']) && !isset($_POST['gdpr_accept'])){ + Body::getInstance()->displayIntroduction(); + die(); + } + } + + if (get('grupa') == 'end') { + $this->set_userstatus(6); + + Body::getInstance()->displayKonec(); + + } + else { + // ce je nastavljena grupa (se pravi ni prva stran) in ce nismo v predogledu ankete + if (get('grupa') > 0 || get('displayAllPages')) { + // nastavimo status -- izpolnjuje anketo + $this->set_userstatus(5); + + // shrani poslano stran v bazo + SaveSurvey::getInstance()->posted(); + + } else { // prva stran z vprasanji + + $s = sisplet_query("REPLACE INTO srv_user_grupa" . get('db_table') . " (gru_id, usr_id, time_edit) VALUES ('0', '" . get('usr_id') . "', NOW())"); + if (!$s) echo mysqli_error($GLOBALS['connect_db']); + $this->set_userstatus(4); + } + + if (get('loop_AW') == 0 && get('loop_id') == null) { + $grupa = Find::getInstance()->findNextGrupa(); + } + elseif (get('loop_AW') == 1) { + $grupa = get('grupa'); + } + elseif (get('loop_id') != null) { + $grupa = get('grupa'); + save('loop_id', Find::getInstance()->findNextLoopId(), 1); + if (get('loop_id') == null) + $grupa = Find::getInstance()->findNextGrupa(); + } + + if (get('displayAllPages')) { + + echo ' ' . "\n"; + + } + elseif ($grupa > 0) { + + save('grupa', $grupa); + + if (get('loop_AW') == 0 && get('loop_id') == null) + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . Header::getSurveyParams() . get('cookie_url') . ''); + elseif (get('loop_AW') == 1) + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&ime=' . get('ime_AW') . Header::getSurveyParams() . get('cookie_url') . ''); + elseif (get('loop_id') != null) + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&loop_id=' . get('loop_id') . Header::getSurveyParams() . get('cookie_url') . ''); + + } + else { + + // nastavimo status -- anketo je izpolnil do konca + $this->set_userstatus(6); + + //prikaz konca ankete - pri glasovanju izpisujemo posebej zakljucek in statistiko + if ($rowa['survey_type'] == 0) { + Body::getInstance()->displayKonecGlasovanje(); + } else { + Body::getInstance()->displayKonec(); + } + + } + } + } + } + } + + // prisli smo cez vse silne procedure in redirecte, lahko pobrisemo cookie za referer, ker ga (upam) ne rabimo vec + setcookie('ref', '', time() - 5000); // pobrisemo cookie + } + + /** + * Preverimo, če učitelj rešuje anketo in če že ima usr_id shranjen v bazi ali ga še ni + * + * @return mixed $cookie + */ + private function hierarhijaPreveriCeSeJeUciteljVrnilPonovnoResevatiAnketo() + { + $url = base64_decode(urldecode($this->get->enc)); + + $cookie = sisplet_query("SELECT su.cookie AS cookie FROM srv_hierarhija_koda AS shk LEFT JOIN srv_user AS su ON (shk.srv_user_id = su.id) WHERE url='" . $url . "'", "obj")->cookie; + return $cookie; + } + + /************************************************ + * Naložimo v kolikor imamo vkloplje print preview TRUE + ************************************************/ + private function loadIfPrintPreviewTrue() + { + $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!")); + if (get('anketa') != $anketa) + save('anketa', $anketa); + + // polovimo podatke o anketi + \SurveyInfo::getInstance()->SurveyInit(get('anketa')); + if (\SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) + save('db_table', '_active'); + + \SurveySetting::getInstance()->Init(get('anketa')); + save('usr_id', $_REQUEST['usr_id']); + + Language::getInstance()->multilang_init(); + } + + + /************************************************ + * Če gre za posebno testno anketo WebSMSruvey + ************************************************/ + private function jeWebSMSurvey() + { + + // inicializiramo jezik za multilang anketo + $row = SurveyInfo::getInstance()->getSurveyRow(); + if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu) + $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'"); + $rowl = mysqli_fetch_array($sqll); + save('lang_id', $rowl['lang_id']); + } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani) + save('lang_id', $_POST['language']); + } + if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik + $_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja) + // get('lang_id') mora se vedno ostati null ! + } else { // zamenjamo jezik + $file = lang_path(get('lang_id')); + if (@include($file)) + $_SESSION['langX'] = lang_path(get('lang_id'), 1); + } + + // prikazemo header + Header::getInstance()->header(); + + if (!isset($_GET['grupa'])) { + + if ($row['show_intro'] == 1) { + Body::getInstance()->displayIntroduction(); + } else { + $grupa = save('grupa', Find::getInstance()->findNextGrupa(), 1); + + if ($grupa > 0) { + if (isset($_GET['language'])) + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&language=' . $_GET['language'] . ''); + else + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . ''); + } else { + Body::getInstance()->displayKonec(); + } + } + } else { + save('grupa', $_GET['grupa']); + + // pogledamo ce preskocimo kaksno stran zaradi branchinga + while (!Check::getInstance()->checkGrupa() && get('grupa') > 0 && $_GET['disableif'] != 1) { + save('grupa', Find::getInstance()->findNextGrupa()); + } + + // nismo se poslali kaksno stran z odgovori + if (count($_POST) == 0) { + if (get('grupa') > 0) + Body::getInstance()->displayAnketa(); + else + Body::getInstance()->displayKonec(); + } // poslani so bili odgovori + else { + $grupa = Find::getInstance()->findNextGrupa(); + save('grupa', $grupa, 1); + + if ($grupa > 0) { + if (isset($_GET['language'])) + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&language=' . $_GET['language'] . ''); + else + header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . ''); + } else { + Body::getInstance()->displayKonec(); + } + } + } + + die(); + } + + /************************************************ + * Tudi ce je zakljucena pustimo prikaz pri nastavljenem glas_end -> preklop arhiva statistike pri glasovanju - drugače izpišemo obvestilo o zaključku + ************************************************/ + private function anketaEnd($rowa) + { + + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + SurveySetting::getInstance()->init(get('anketa')); + + if ($rowa['active'] > 0) { + + // preverimo začetek in konec + $sqlDates = sisplet_query("SELECT id, starts, expire, (IF(CURDATE() >= starts, true, false)) as boolStarts, (IF(CURDATE() <= expire, true, false)) as boolExpire FROM srv_anketa WHERE id='" . get('anketa') . "'"); + $rowDates = mysqli_fetch_assoc($sqlDates); + if (!$rowDates['boolStarts']) { + + $srv_survey_non_active_notStarted = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_notStarted' . $_lang); + if ($srv_survey_non_active_notStarted == '') $srv_survey_non_active_notStarted = self::$lang['srv_survey_non_active_notStarted']; + + Display::getInstance()->displayNapaka($srv_survey_non_active_notStarted . $rowDates['starts']); + } + if (!$rowDates['boolExpire']) { + + $srv_survey_non_active_expired = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_expired' . $_lang); + if ($srv_survey_non_active_expired == '') $srv_survey_non_active_expired = self::$lang['srv_survey_non_active_expired']; + + Display::getInstance()->displayNapaka(self::$lang['srv_survey_non_active_expired'] . $rowDates['expire']); + } + } elseif ($rowa['active'] == 0) { + + # anketa ni aktivna, preverimo ali je bila sploh aktivirana + $str = "SELECT count(*) FROM srv_activity WHERE sid = '" . get('anketa') . "'"; + $qry = sisplet_query($str); + list($count_activity) = mysqli_fetch_row($qry); + if ($count_activity > 0) { + + $srv_survey_non_active = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active' . $_lang); + if ($srv_survey_non_active == '') $srv_survey_non_active = self::$lang['srv_survey_non_active']; + + Display::getInstance()->displayNapaka($srv_survey_non_active); + } else { + + $srv_survey_non_active_notActivated = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_notActivated' . $_lang); + if ($srv_survey_non_active_notActivated == '') $srv_survey_non_active_notActivated = self::$lang['srv_survey_non_active_notActivated']; + + Display::getInstance()->displayNapaka($srv_survey_non_active_notActivated); + } + } else { + + $srv_survey_deleted = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_deleted' . $_lang); + if ($srv_survey_deleted == '') $srv_survey_deleted = self::$lang['srv_survey_deleted']; + + Display::getInstance()->displayNapaka($srv_survey_deleted); + } + + die(); + } + + + // EVALVACIJA - Ce je nov respondent preverimo ce se je vrnil (zapis v tabeli eval_data_userCookie) in mu nastavimo ustrezen cookie da ga preusmerimo na ustrezno stran + private function evlavacijaNovRespondent() + { + $student = (isset($_GET['sifstud'])) ? $_GET['sifstud'] : 0; + $predmet = (isset($_GET['sifpredm'])) ? $_GET['sifpredm'] : -1; // Ce resuje splosno anketo ni predmeta -> predmet = -1 + + if ($student > 0) { + $sqlE = sisplet_query("SELECT u.cookie AS cookie FROM eval_data_userCookie adu, srv_user u + WHERE adu.ank_id='" . get('anketa') . "' AND adu.student='" . $student . "' AND adu.predmet='" . $predmet . "' + AND u.ank_id='" . get('anketa') . "' AND u.id=adu.usr_id"); + if (mysqli_num_rows($sqlE) > 0) { + $rowE = mysqli_fetch_array($sqlE); + $cookie = $rowE['cookie']; + return $cookie; + } + } + } + + + /************************************************ + * Če cookie obstaja ga samo preberemo + ************************************************/ + protected $cookie; + + private function cookieExist($cookie) + { + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + $sql = sisplet_query("SELECT id, user_id FROM srv_user WHERE cookie='$cookie' AND deleted='0' LIMIT 1"); + $row = mysqli_fetch_array($sql); + + if ($row['id'] > 0) { + + save('usr_id', $row['id']); + + + // cookie se enkrat nastavmo, ce se je kaj spreminjal nastavitve expire-ja + $this->set_cookie('survey-' . get('anketa'), $cookie, $this->expire); + + // v primeru da je cookie ze bil postavljen, pa da se ni bilo povezave s sisplet userjem, ga 'povezemo' + if ($rowa['user_from_cms'] >= 1) + if ($row['user_id'] == 0 && self::$global_user_id > 0) + $sql = sisplet_query("UPDATE srv_user SET user_id = '" . self::$global_user_id . "' WHERE cookie = '$cookie'"); + + // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore + // Dodano v pogoj da se to izvede samo ce nima nastavljene grupe (drugace dela narobe klik nazaj na zakljucku, preklop med bloki...) + if ($rowa['return_finished'] == 0 && !isset($_GET['grupa']) && !isset($_GET['urejanje']) && !isset($_GET['return'])) { + $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'"); + $rows = mysqli_fetch_array($sqls); + if ($rows['status'] == 6) { // Koncal anketo + Header::getInstance()->header(); + Body::getInstance()->displayKonec(); + die(); + } + } + + // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo + if (!isset($_GET['grupa'])) { + Check::getInstance()->check_cookie_return(); + } + + } else { // dodatno preverjanje, ce se slucajno kaj sfizi, pa da ni tega cookieja v bazi, ga moramo se enkrat nastavit + $this->cookie = null; + } + } + + /************************************************ + * Cookie ni nastavljen is null + ************************************************/ + + private function cookieIsNull() + { + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + //preverjamo limit stevila glasov + if ((!isset($_GET['preview']) || $_GET['preview'] != 'on') && ($rowa['vote_limit'] == 1 || $rowa['vote_limit'] == 2)) { + + // preverimo ce smo presegli limit + // Stetje samo ustreznih odgovorov + if ($rowa['vote_limit'] == 2) + $sqlVotes = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='" . get('anketa') . "' AND (last_status='5' OR last_status='6') AND lurker='0' AND deleted='0'"); + // Stetje vseh odgovorov + else + $sqlVotes = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='" . get('anketa') . "' AND deleted='0'"); + + $rowVotes = mysqli_fetch_assoc($sqlVotes); + + if ($rowa['vote_count'] <= $rowVotes['COUNT(id)']) { + //$this->display->displayNapaka(self::$lang['srv_survey_non_active_voteLimit'].' ('.$rowa['vote_count'].')'); + + $srv_survey_non_active_voteLimit = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_voteLimit' . $_lang); + if ($srv_survey_non_active_voteLimit == '') $srv_survey_non_active_voteLimit = self::$lang['srv_survey_non_active_voteLimit']; + + Display::getInstance()->displayNapaka($srv_survey_non_active_voteLimit); + die(); + } + } + + // splosna koda za dostop do ankete (brez prepoznave userja) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu + $userAccess = UserAccess::getInstance(self::$global_user_id); + $sqlp = sisplet_query("SELECT password FROM srv_password WHERE ank_id='" . get('anketa') . "'"); + if (mysqli_num_rows($sqlp) > 0 && $userAccess->checkUserAccess($what='password')) { + + $ok = false; + + while ($rowp = mysqli_fetch_array($sqlp)) { + + if (isset($_POST['password']) && $rowp['password'] == $_POST['password'] /*|| $_COOKIE['password_' .get('anketa')] == $rowp['password']*/) { + setcookie('password_' . get('anketa'), $rowp['password']); + $ok = true; + } + } + + if (!$ok) { + Header::getInstance()->header(); + Body::getInstance()->displayIntroduction(); + die(); + } + } + + // preverimo, ce blokiramo IP (to nardimo, samo ce se ni kukija - drugac bi ga takoj zablokiral (ce pa je kuki se ga pa itak prepoza pa potem shendla)) + if ($rowa['block_ip'] > 0) { + $sqlip = sisplet_query("SELECT id FROM srv_user WHERE ank_id='" . get('anketa') . "' AND ip='" . Helper::remote_address() . "' AND time_edit >= NOW() - INTERVAL $rowa[block_ip] MINUTE"); + if (mysqli_num_rows($sqlip) > 0) { // je ze dostopal iz tega IPja + Header::getInstance()->header(); + Body::getInstance()->displayKonec(); + die(); + } + } + + if (self::$global_user_id == 0) { + $row1['id'] = 0; + } + else { + $sql1 = sisplet_query("SELECT id, cookie FROM srv_user WHERE user_id = '" . self::$global_user_id . "' AND user_id > 0 AND ank_id = '" . get('anketa') . "'"); + + if(mysqli_num_rows($sql1) > 0) + $row1 = mysqli_fetch_array($sql1); + else + $row1['id'] = 0; + } + + // ce je izbrana povezava s sisplet userjem in da smo najdl cookie za trenutnega userja, potem nastavimo ta cookie + if ($row1['id'] > 0 && $rowa['user_from_cms'] == 1) { + + $rand = $row1['cookie']; + + $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire); + + save('usr_id', $row1['id']); + + + // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore + if ($rowa['return_finished'] == 0) { + $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'"); + $rows = mysqli_fetch_array($sqls); + if ($rows['status'] == 6) { // Koncal anketo + Header::getInstance()->header(); + Body::getInstance()->displayKonec(); + die(); + } + } + + // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo + if (!isset($_GET['grupa'])) { + Check::getInstance()->check_cookie_return(); + } + + // userji iz baze + } elseif ( + ($rowa['user_base'] == 1) && + #če imamo neindividualizirana vabila - poslana preko vabil, vendar bez kode in zato brez sledenja (uporabnik se pri pošiljanju NE prenese iz srv_invitations_recipients v srv_user) + $rowa['individual_invitation'] != 0 && + ( // Omogoči anketo tudi respodentom, ki niso v bazi + ($rowa['usercode_skip'] == 0) // Ne (vsi grejo sem not, ker morajo nujno vnesti kodo) + || ($rowa['usercode_skip'] == 1 /*&& (isset($_POST['usercode']) or isset($_GET['code']))*/) // Da (sem not grejo samo, ce so vnesli kodo, da jih prepoznamo, sicer grejo na else in dobijo nov cookie) + || ($rowa['usercode_skip'] == 2 && (!get('userAutor') || (isset($_POST['usercode']) or isset($_GET['code'])))) // Samo avtor (ce ni avtor ankete, gre sem noter in mora vnesti kodo. Avtor ankete pa gre sem notr samo ce je podana koda, sicer gre na else in dobi nov cookie) + + // Respondenti naj vedno vnesejo kodo: Da + || ($rowa['usercode_required'] == 1 && $rowa['usercode_skip'] != 1 && + ( // Omogoči anketo tudi respodentom, ki niso v bazi + $rowa['usercode_skip'] == 0 // Ne (vsi grejo sem not, ker morajo nujno vnesti kodo) + || ($rowa['usercode_skip'] == 2 && !get('userAutor') /*&& ( !$userAutor || $userAutor || (isset($_POST['usercode']) or isset($_GET['code'])) )*/) // Samo avtor (ce ni avtor ankete, gre sem noter in mora vnesti kodo. Avtor ankete pa gre sem notr samo ce je podana koda, sicer gre na else in dobi nov cookie) + ) // ^ tale pogoj zgoraj se ni cist ok, ker mora tudi avtor vnesti kodo - AVTORJU NI TREBA VNEST KODE CE JE TO VKLOPLJENO - dodan && !get('userAutor') + ) + ) + ) { + if (isset($_POST['usercode']) or isset($_GET['code'])) { + + if (isset($_POST['usercode'])) + $usercode = strtolower($_POST['usercode']); + elseif (isset($_GET['code'])) + $usercode = strtolower($_GET['code']); + else + die(); + + $sql2 = sisplet_query("SELECT id, recnum, cookie FROM srv_user WHERE TRIM(pass) = '$usercode' AND ank_id='".get('anketa')."' AND deleted='0'"); + if (!$sql2) echo mysqli_error($GLOBALS['connect_db']); + $row2 = mysqli_fetch_array($sql2); + + // Pravilna koda + if (mysqli_num_rows($sql2) > 0) { + + // Ce imamo vklopljen modul za volitve preskocimo kar nekaj korakov (anonimizacija) + if(!SurveyInfo::checkSurveyModule('voting')){ + + // Dodatno preverimo ce koda se ni potekla + $sqlC = sisplet_query("SELECT * FROM srv_invitations_recipients WHERE ank_id='".get('anketa')."' AND TRIM(password)='".$usercode."' AND DATE(NOW())>DATE(date_expired) AND date_expired!='0000-00-00 00:00:00'"); + if(mysqli_num_rows($sqlC) > 0){ + Display::getInstance()->displayNapaka(self::$lang['srv_expiredcode']); + die(); + } + + # nastavimo še da je uporabnik odgovoril na anketo za nov način e-mail vabil + sisplet_query("UPDATE srv_invitations_recipients SET responded = '1', date_responded = NOW() WHERE ank_id='" . get('anketa') . "' AND TRIM(password) ='$usercode' AND responded = '0'"); + + sisplet_query("COMMIT"); + } + + $rand = $row2['cookie']; + + $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire); + + save('usr_id', $row2['id']); + + + // Preverimo ce imamo vklopljeno da uporabnik nadaljuje kjer je ostal - potem ga preusmerimo na pravo stran + Check::getInstance()->check_cookie_return(); + + if ($row2['recnum'] == 0) { + + if (isset($_POST['referer'])) + $referer = $_POST['referer']; + elseif (isset($_SERVER['HTTP_REFERER'])) + $referer = $_SERVER['HTTP_REFERER']; + else + $referer = 0; + + SurveySetting::getInstance()->Init(get('anketa')); + $ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip'); + $browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser'); + $referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal'); + $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date'); + + if ($ip == 0) $_ip = Helper::remote_address(); else $ip = ""; + if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''"; + if ($referal == 0) $_referer = $referer; else $_referer = ''; + if ($browser == 0) $_useragent = $_SERVER['HTTP_USER_AGENT']; else $_useragent = ''; + + // Ce dovolimo useragent in ce je instaliran browscap + $_browser = ''; + $_device = 0; + $_os = ''; + if ($_useragent != '' && get_cfg_var('browscap')) { + + $browser_detect = get_browser($_useragent, true); + $detect = New Mobile_Detect(); + $detect->setUserAgent($_useragent); + + // Detect browserja + if ($browser_detect['browser'] == 'Default Browser') + $_browser = self::$lang['srv_para_graph_other']; + else + $_browser = $browser_detect['browser'] . ' ' . $browser_detect['version']; + + // Detect naprave (pc, mobi, tablet, robot) + if ($detect->isMobile()) { + if ($detect->isTablet()) + $_device = 2; + else + $_device = 1; + } elseif ($browser_detect['crawler'] == 1) + $_device = 3; + else + $_device = 0; + + // Detect operacijskega sistema + if ($browser_detect['platform'] == 'unknown') + $_os = self::$lang['srv_para_graph_other']; + else + $_os = $browser_detect['platform']; + } + + $recnum = 0; + + if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']); + + $s = sisplet_query("UPDATE srv_user SET recnum = MAX_RECNUM('" . get('anketa') . "'), time_insert=" . $_time_insert . ", language='" . get('language') . "', ip='" . $_ip . "', useragent='" . $_useragent . "', device='" . $_device . "', browser='" . $_browser . "', os='" . $_os . "' WHERE id = '" . get('usr_id') . "'"); + if (!$s) { + echo 'err3432' . mysqli_error($GLOBALS['connect_db']); + die(); + } + } + + // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore + if ($rowa['return_finished'] == 0) { + $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'"); + $rows = mysqli_fetch_array($sqls); + + if ($rows['status'] == 6) { // Koncal anketo + Header::getInstance()->header(); + Body::getInstance()->displayKonec(); + + die(); + } + } + + + // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo + if (!isset($_GET['grupa'])) { + Check::getInstance()->check_cookie_return(); + } + + } + else { // koda ne obstaja + + //#TODO Tukaj preverimo userja iz novih e-mail vabil + + if ($rowa['usercode_skip'] != 1 && !($_GET['preview'] == 'on' && isset($_GET['disablecode']) && $_GET['disablecode'] == 1)) { + + // Pri Ne in Samo avtor prikazemo obvestilo, pri Da spustimo naprej in kreiramo nov cookie + SurveySetting::getInstance()->init(get('anketa')); + $srv_wrongcode = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_wrongcode' . $_lang); + if ($srv_wrongcode == '') $srv_wrongcode = self::$lang['srv_wrongcode']; + + Display::getInstance()->displayNapaka($srv_wrongcode); + die(); + } + } + + } else { + + # če imamo formo + if ($rowa['survey_type'] == 1) { + # TODO.. Mitja, tu je treba vse pravilno pohandlat.. men se niti sanja ne kak in kaj + # problem pri formi je da ko enkrat pošlješ email vabilo, potem vedno prikazuje header + // TODO: kolk casa je ze tole tukaj? :) -mitja + # TODO: ziher več kot leto in pol. :) tak da ni neskončno pomembno + } + else { + + // baza respondentov - ce ni poslana koda + Language::getInstance()->multilang_init(); + Header::getInstance()->header(); + Body::getInstance()->displayIntroduction(); + + die(); + } + } + + } + + // drugace gremo kreirat nov cookie + if (get('usr_id') == null) { + + // izberemo random hash, ki se ni v bazi + do { + $rand = md5(mt_rand(1, mt_getrandmax()) . '@' . Helper::remote_address()); + $sql = sisplet_query("SELECT id FROM srv_user WHERE cookie = '$rand'"); + } while (mysqli_num_rows($sql) > 0); + + $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire); + + // ce je izbrana povezava s sisplet userjem, ga povezemo + if ($rowa['user_from_cms'] >= 1) { + $sqlu = Model::db_select_user(self::$global_user_id); + $rowu = mysqli_fetch_array($sqlu); + } else + $rowu['id'] = 0; + + if (isset($_GET['preview']) && $_GET['preview'] == 'on') { + $preview = 1; + } else { + $preview = 0; + } + # če smo v prezentaciji (slideshow) in ne beležimo vnosov jih označimo kot preview = 1 + if (isset($rowa['slideshow']) && $rowa['slideshow'] == 1) { + $ss = new SurveySlideshow(get('anketa')); + $ss_setings = $ss->getSettings(); + # če beležimo vnose: save_entries == 1 + if ($ss_setings['save_entries'] == 0) { + $preview = 1; + } + } + + $testdata = 0; + if (isset($_GET['testdata']) && $_GET['testdata'] == 'on') { + $preview = 0; + $testdata = 1; + } + + + if (isset($_POST['referer'])) + $referer = $_POST['referer']; + elseif (isset($_SERVER['HTTP_REFERER'])) + $referer = $_SERVER['HTTP_REFERER']; + else + $referer = 0; + + SurveySetting::getInstance()->Init(get('anketa')); + $ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip'); + $browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser'); + $referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal'); + $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date'); + + if ($ip == 0) $_ip = Helper::remote_address(); else $ip = ""; + if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''"; + if ($referal == 0) $_referer = $referer; else $_referer = ''; + if ($browser == 0) $_useragent = $_SERVER['HTTP_USER_AGENT']; else $_useragent = ''; + + // Ce dovolimo useragent in ce je instaliran browscap + $_browser = ''; + $_device = 0; + $_os = ''; + if ($_useragent != '' && get_cfg_var('browscap')) { + + $browser_detect = get_browser($_useragent, true); + $detect = New Mobile_Detect(); + $detect->setUserAgent($_useragent); + + // Detect browserja + if ($browser_detect['browser'] == 'Default Browser') + $_browser = self::$lang['srv_para_graph_other']; + else + $_browser = $browser_detect['browser'] . ' ' . $browser_detect['version']; + + // Detect naprave (pc, mobi, tablet, robot) + if ($detect->isMobile()) { + if ($detect->isTablet()) + $_device = 2; + else + $_device = 1; + } elseif ($browser_detect['crawler'] == 1) + $_device = 3; + else + $_device = 0; + + // Detect operacijskega sistema + if ($browser_detect['platform'] == 'unknown') + $_os = self::$lang['srv_para_graph_other']; + else + $_os = $browser_detect['platform']; + } + + if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']); + + $recnum = 0; + + $sql = sisplet_query("INSERT INTO srv_user (id, ank_id, preview, testdata, cookie, user_id, ip, time_insert, recnum, referer, useragent, device, browser, os, language) VALUES (0, '" . get('anketa') . "', '$preview', '$testdata', '$rand', '$rowu[id]', '" . $_ip . "', " . $_time_insert . ", MAX_RECNUM('" . get('anketa') . "'), '" . $_referer . "', '" . $_useragent . "', '" . $_device . "', '" . $_browser . "', '" . $_os . "', '" . get('language') . "')"); + if (!$sql) { + echo 'err3431' . mysqli_error($GLOBALS['connect_db']); + die(); + } + save('usr_id', mysqli_insert_id($GLOBALS['connect_db']), 1); + + + //sisplet_query("COMMIT"); + # če je testni vnos in če že imamo skreirano datoteko s podatki v kateri še ni označeno da imamo testem je potrebno generirati na novo + if ((int)$testdata > 0) { + $head_file_name = self::$site_path . 'admin/survey/SurveyData/export_header_' . get('anketa') . '.dat'; + if (file_exists($head_file_name)) { + $header = unserialize(file_get_contents($head_file_name)); + if ((int)$header['_settings']['hasTestData'] == 0) { + unlink($head_file_name); + } + } + } + + //potrebuje se za modul MAZA - za povezavo respondenta med tebelama maza_app_users in srv_user + if(SurveyInfo::checkSurveyModule('maza')){ + //error_log(json_encode($_GET)); + $maza = new MAZA(get('anketa')); + //check if id and identifier match + if($_GET['maza_user_id'] && ($maza->maza_validate_user($_GET['maza_user_id'], $_GET['maza_identifier']))){ + //update last_active of user + $maza->maza_update_user_active($_GET['maza_user_id']); + //insert pair of users id's in DB table + $maza->maza_save_srv_user($_GET['maza_user_id'], get('usr_id'), $_GET['maza_srv_version'], $_GET['maza_tgeofence_id'], $_GET['maza_tactivity_id'], $_GET['maza_mode']); + } + } + + // EVALVACIJA - Ce je nov respondent se to zapise v posebno tabelo, da ga prepoznamo naslednjic brez cookija (da lahko nadaljuje kjer je ostal) + if (Common::checkModule('evalvacija') == '1') { + $student = (isset($_GET['sifstud'])) ? $_GET['sifstud'] : 0; + $predmet = (isset($_GET['sifpredm'])) ? $_GET['sifpredm'] : -1; // Ce resuje splosno anketo ni predmeta -> predmet = -1 + + if ($student > 0) + sisplet_query("INSERT INTO eval_data_userCookie (ank_id, usr_id, student, predmet) VALUES ('" . get('anketa') . "', '" . get('usr_id') . "', '" . $student . "', '" . $predmet . "')"); + } + + // V kolikor gre za hierarhijo in je respondent učitelj, potem usr_id shranimo, da lahko obnovimo anketo + if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2) { + $url = base64_decode(urldecode($this->get->enc)); + $polje = sisplet_query("SELECT koda, vloga FROM srv_hierarhija_koda WHERE url='" . $url . "'", "obj"); + + if ($polje->vloga == 'ucitelj') + sisplet_query("UPDATE srv_hierarhija_koda SET srv_user_id='" . get('usr_id') . "' WHERE url='" . $url . "'"); + + // V kolikor gre za super šifro potem shranimo v bazo, uporabnika in katero anketo je reševal. + if (!empty($this->get->supersifra)) { + $kode = sisplet_query("SELECT kode FROM srv_hierarhija_supersifra WHERE koda='".$this->get->supersifra."'", "obj"); + $kode = unserialize($kode->kode); + + sisplet_query("INSERT INTO + srv_hierarhija_supersifra_resevanje + (user_id, supersifra, koda, status) + VALUES + ('".get('usr_id')."', '".$this->get->supersifra."', '".$kode[$this->get->resujem]."', 1) + "); + + } + + } + } + } + + /** + * nastavi cookie, oz. v primeru ankete brez cookieja, nastavi spremenljivko za url + */ + protected $anketa, $rand, $expire; + + private function set_cookie($anketa, $rand, $expire) + { + + $cookie_ok = isset($_COOKIE['cookie_ok']) ? $_COOKIE['cookie_ok'] : ''; + + // ce je nastavljeno na brez piskotka ali se ni potrdil shranjevanja piskotkov + if (get('cookie_expire') == -1 or $cookie_ok != 1) { // cookie prenasamo preko URLja + save('cookie_url', '&' . $anketa . '=' . $rand); // ta string se bo dodal vsem URLjem na konec + // & dodamo naknadno samo tam, kjer se pise v html (v header() more bit samo &) + } else { + setcookie($anketa, $rand, $expire); // ce je cookie, ga obicajno nastavimo + } + } + + /** + * @desc nastavi status za trenutnega userja + */ + private function set_userstatus($status) + { + $sql_userbase = sisplet_query("SELECT MAX(tip) AS tip FROM srv_userbase WHERE usr_id = '" . get('usr_id') . "'"); + if (!$sql_userbase) echo mysqli_error($GLOBALS['connect_db']); + $row_userbase = mysqli_fetch_array($sql_userbase); + + if ($row_userbase['tip'] > 0) { + $tip = $row_userbase['tip']; + } + else { + $tip = 0; + } + + $sqlu = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id = '" . get('usr_id') . "'"); + if (!$sqlu) echo mysqli_error($GLOBALS['connect_db']); + $rowu = mysqli_fetch_array($sqlu); + + $sqlu = sisplet_query("SELECT inv_res_id FROM srv_user WHERE id = '" . get('usr_id') . "' AND inv_res_id IS NOT NULL"); + $inv_res_id = null; + if (mysqli_num_rows($sqlu) > 0) { + # userj je dodan preko novih vabil zato updejtamo status še tam + $row_inv_res_id = mysqli_fetch_assoc($sqlu); + $inv_res_id = (int)$row_inv_res_id['inv_res_id']; + } + + // spremenimo tip + if ($status > $rowu['status'] && is_numeric(get('usr_id'))) { + + $s = sisplet_query("REPLACE INTO srv_userstatus (usr_id, tip, status, datetime) VALUES ('" . get('usr_id') . "', '$tip', '$status', NOW())"); + if (!$s) echo mysqli_error($GLOBALS['connect_db']); + + SurveySetting::getInstance()->Init(get('anketa')); + $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date'); + if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''"; + + + if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']); + + $s = sisplet_query("UPDATE srv_user SET last_status = '$status', time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id = '" . get('usr_id') . "'"); + if (!$s) { + echo mysqli_error($GLOBALS['connect_db']); + die(); + } + # updejtamo še status pri respondentih. + if ((int)$inv_res_id > 0) { + # userj je dodan preko novih vabil zato updejtamo status še tam + $sqlString = "UPDATE srv_invitations_recipients SET last_status='$status' WHERE ank_id='" . get('anketa') . "' AND id ='$inv_res_id' "; + $u = sisplet_query($sqlString); + } + + // updatamo samo datum - tip se ni spremenil + } else { + + SurveySetting::getInstance()->Init(get('anketa')); + $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date'); + if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''"; + + + if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']); + + # osvežimo datum spremembe + sisplet_query("UPDATE srv_user SET time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id='" . get('usr_id') . "'"); + + } + + // Ce ne belezimo parapodatka za cas responsa, anonimno zabelezimo cas zadnjega responsa + if(SurveySetting::getInstance()->getSurveyMiscSetting('survey_date') == 1) { + sisplet_query("UPDATE srv_anketa SET last_response_time=NOW() WHERE id='".get('anketa')."'"); + } + + # dodamo še tracking arhivov vabil + if (get('user_inv_archive') > 0 && $inv_res_id > 0) { + + # ignoriramo podvojene kluče + $s = sisplet_query("INSERT IGNORE INTO srv_invitations_tracking + (inv_arch_id, time_insert, res_id, status) + VALUES + ('" . (int)get('user_inv_archive') . "',NOW(),'$inv_res_id','$status') + "); + if (!$s) echo mysqli_error($GLOBALS['connect_db']); + } + else { + } + + # potrebno bo osvežit seznam anket + Model::setUpdateSurveyList(); + } + + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/JsController.php b/main/survey/app/Controllers/JsController.php new file mode 100644 index 0000000..c9699f8 --- /dev/null +++ b/main/survey/app/Controllers/JsController.php @@ -0,0 +1,2835 @@ +'; + echo $row['js_tracking']; + echo ''; + } + + } + + /** + * @desc generira JavaScript za alert pri vprasanjih z reminderjem + */ + public function generateSubmitJS() + { + global $lang; + global $site_url; + global $secret_captcha; + global $admin_type; + + // Dodaten text pri alertu ce smo v testnem vnosu + $test_alert = (isset($_GET['testdata']) && $_GET['testdata'] == 'on') ? '\n\n' . $lang['srv_remind_preview'] : ''; + + // Custom texti za opozorila... + SurveySetting::getInstance()->Init(get('anketa')); + if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = ''; + $srv_remind_sum_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_sum_hard' . $_lang); + if ($srv_remind_sum_hard == '') $srv_remind_sum_hard = $lang['srv_remind_sum_hard']; + $srv_remind_sum_hard = strip_tags(addslashes(stripslashes($srv_remind_sum_hard))).$test_alert; + $srv_remind_sum_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_sum_soft' . $_lang); + if ($srv_remind_sum_soft == '') $srv_remind_sum_soft = $lang['srv_remind_sum_soft']; + $srv_remind_sum_soft = strip_tags(addslashes(stripslashes($srv_remind_sum_soft))).$test_alert; + $srv_remind_num_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_num_hard' . $_lang); + if ($srv_remind_num_hard == '') $srv_remind_num_hard = $lang['srv_remind_num_hard']; + $srv_remind_num_hard = strip_tags(addslashes(stripslashes($srv_remind_num_hard))).$test_alert; + $srv_remind_num_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_num_soft' . $_lang); + if ($srv_remind_num_soft == '') $srv_remind_num_soft = $lang['srv_remind_num_soft']; + $srv_remind_num_soft = strip_tags(addslashes(stripslashes($srv_remind_num_soft))).$test_alert; + + $srv_remind_text_num_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_text_num_hard' . $_lang); + if ($srv_remind_text_num_hard == '') $srv_remind_text_num_hard = $lang['srv_remind_text_num_hard']; + $srv_remind_text_num_hard = strip_tags(addslashes(stripslashes($srv_remind_text_num_hard))).$test_alert; + $srv_remind_text_num_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_text_num_soft' . $_lang); + if ($srv_remind_text_num_soft == '') $srv_remind_text_num_soft = $lang['srv_remind_text_num_soft']; + $srv_remind_text_num_soft = strip_tags(addslashes(stripslashes($srv_remind_text_num_soft))).$test_alert; + + //za minimalno stevilo izbranih checkbox-ov + $srv_remind_checkbox_min_violated_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_checkbox_min_violated_hard' . $_lang); + if ($srv_remind_checkbox_min_violated_hard == '') $srv_remind_checkbox_min_violated_hard = $lang['srv_remind_checkbox_min_violated_hard']; + $srv_remind_checkbox_min_violated_hard = strip_tags(addslashes(stripslashes($srv_remind_checkbox_min_violated_hard))).$test_alert; + + $srv_remind_checkbox_min_violated_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_checkbox_min_violated_soft' . $_lang); + if ($srv_remind_checkbox_min_violated_soft == '') $srv_remind_checkbox_min_violated_soft = $lang['srv_remind_checkbox_min_violated_soft']; + $srv_remind_checkbox_min_violated_soft = strip_tags(addslashes(stripslashes($srv_remind_checkbox_min_violated_soft))).$test_alert; + //za minimalno stevilo izbranih checkbox-ov - konec + + $srv_remind_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard' . $_lang); + if ($srv_remind_hard == '') $srv_remind_hard = $lang['srv_remind_hard']; + $srv_remind_hard = strip_tags(addslashes(stripslashes($srv_remind_hard))).$test_alert; + $srv_remind_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft' . $_lang); + if ($srv_remind_soft == '') $srv_remind_soft = $lang['srv_remind_soft']; + $srv_remind_soft = strip_tags(addslashes(stripslashes($srv_remind_soft))).$test_alert; + + $srv_remind_hard_99 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-99' . $_lang); + if ($srv_remind_hard_99 == '') $srv_remind_hard_99 = $lang['srv_remind_hard_-99']; + $srv_remind_hard_99 = strip_tags(addslashes(stripslashes($srv_remind_hard_99))).$test_alert; + $srv_remind_soft_99 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-99' . $_lang); + if ($srv_remind_soft_99 == '') $srv_remind_soft_99 = $lang['srv_remind_soft_-99']; + $srv_remind_soft_99 = strip_tags(addslashes(stripslashes($srv_remind_soft_99))).$test_alert; + $srv_remind_hard_98 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-98' . $_lang); + if ($srv_remind_hard_98 == '') $srv_remind_hard_98 = $lang['srv_remind_hard_-98']; + $srv_remind_hard_98 = strip_tags(addslashes(stripslashes($srv_remind_hard_98))).$test_alert; + $srv_remind_soft_98 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-98' . $_lang); + if ($srv_remind_soft_98 == '') $srv_remind_soft_98 = $lang['srv_remind_soft_-98']; + $srv_remind_soft_98 = strip_tags(addslashes(stripslashes($srv_remind_soft_98))).$test_alert; + $srv_remind_hard_97 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-97' . $_lang); + if ($srv_remind_hard_97 == '') $srv_remind_hard_97 = $lang['srv_remind_hard_-97']; + $srv_remind_hard_97 = strip_tags(addslashes(stripslashes($srv_remind_hard_97))).$test_alert; + $srv_remind_soft_97 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-97' . $_lang); + if ($srv_remind_soft_97 == '') $srv_remind_soft_97 = $lang['srv_remind_soft_-97']; + $srv_remind_soft_97 = strip_tags(addslashes(stripslashes($srv_remind_soft_97))).$test_alert; + $srv_remind_hard_multi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_multi' . $_lang); + if ($srv_remind_hard_multi == '') $srv_remind_hard_multi = $lang['srv_remind_hard_multi']; + $srv_remind_hard_multi = strip_tags(addslashes(stripslashes($srv_remind_hard_multi))).$test_alert; + $srv_remind_soft_multi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_multi' . $_lang); + if ($srv_remind_soft_multi == '') $srv_remind_soft_multi = $lang['srv_remind_soft_multi']; + $srv_remind_soft_multi = strip_tags(addslashes(stripslashes($srv_remind_soft_multi))).$test_alert; + + $srv_remind_captcha_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_captcha_soft' . $_lang); + if ($srv_remind_captcha_soft == '') $srv_remind_captcha_soft = $lang['srv_remind_captcha_soft']; + $srv_remind_captcha_soft = strip_tags(addslashes(stripslashes($srv_remind_captcha_soft))).$test_alert; + $srv_remind_captcha_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_captcha_hard' . $_lang); + if ($srv_remind_captcha_hard == '') $srv_remind_captcha_hard = $lang['srv_remind_captcha_hard']; + $srv_remind_captcha_hard = strip_tags(addslashes(stripslashes($srv_remind_captcha_hard))).$test_alert; + + $srv_remind_email_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_email_soft' . $_lang); + if ($srv_remind_email_soft == '') $srv_remind_email_soft = $lang['srv_remind_email_soft']; + $srv_remind_email_soft = strip_tags(addslashes(stripslashes($srv_remind_email_soft))).$test_alert; + $srv_remind_email_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_email_hard' . $_lang); + if ($srv_remind_email_hard == '') $srv_remind_email_hard = $lang['srv_remind_email_hard']; + $srv_remind_email_hard = strip_tags(addslashes(stripslashes($srv_remind_email_hard))).$test_alert; + + $srv_alert_number_toobig = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_alert_number_toobig' . $_lang); + if ($srv_alert_number_toobig == '') $srv_alert_number_toobig = $lang['srv_alert_number_toobig']; + $srv_alert_number_toobig = strip_tags(addslashes(stripslashes($srv_alert_number_toobig))).$test_alert; + $srv_alert_number_exists = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_alert_number_exists' . $_lang); + if ($srv_alert_number_exists == '') $srv_alert_number_exists = $lang['srv_alert_number_exists']; + $srv_alert_number_exists = strip_tags(addslashes(stripslashes($srv_alert_number_exists))).$test_alert; + + $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables'); + + $srv_remind_checkbox_max_violated_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srv_remind_checkbox_max_violated_hard' . $_lang); + if ($srv_remind_checkbox_max_violated_hard == '') $srv_remind_checkbox_max_violated_hard = $lang['srv_remind_checkbox_max_violated_hard']; + $srv_remind_checkbox_max_violated_hard = strip_tags(addslashes(stripslashes($srv_remind_checkbox_max_violated_hard))).$test_alert; + + + echo ' ' . "\n"; + + + $sqlG = sisplet_query("SELECT spol FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'"); + $rowG = mysqli_fetch_array($sqlG); + + $sql1 = sisplet_query("SELECT MAX(vrstni_red) AS vrstni_red FROM srv_grupa WHERE ank_id = '" . get('anketa') . "'"); + $row1 = mysqli_fetch_array($sql1); + + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + //namesto naprej in nazaj se pri glasovanju izrise gumb potrdi oz. gumba moski/zenska pri izbiri spola + if ($rowa['survey_type'] == 0) { + + if (!get('printPreview')) { + if ($rowG['spol'] == 0) { + + $srv_potrdi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_potrdi'.$_lang); + if ($srv_potrdi == '') $srv_potrdi = $lang['srv_potrdi']; + + echo '
+ +
' . "\n"; + } else { + echo '
+ + +
' . "\n"; + } + } + + //namesto naprej in nazaj izrise pri formi gumb poslji + } elseif ($rowa['survey_type'] == 1) { + + SurveySetting::getInstance()->Init(get('anketa')); + + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang); + if ($srv_nextpage == '') $srv_nextpage = $lang['srv_forma_send']; + + if (!get('printPreview')) { + echo '
'; + echo ' +
' . "\n"; + } + + } else { + + SurveySetting::getInstance()->Init(get('anketa')); + + $row = SurveyInfo::getInstance()->getSurveyRow(); + $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE ID = '" . get('grupa') . "'"); + $rowg = mysqli_fetch_array($sqlg); + + // Smo na zadnji strani + if ($row1['vrstni_red'] == $rowg['vrstni_red']) { + + // Dodatno preverimo ce imamo loop + if(isset($_GET['loop_id']) && $_GET['loop_id'] > 0){ + + // Ce obstaja naslednji loop izpisemo "naslednja stran" in ne "zadnja stran" + if(Find::getInstance()->findNextLoopId() > 0){ + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage' . $_lang); + if ($srv_nextpage == '') $srv_nextpage = $lang['srv_nextpage']; + } + else{ + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_lastpage' . $_lang); + if ($srv_nextpage == '') $srv_nextpage = $lang['srv_lastpage']; + } + } + else{ + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_lastpage' . $_lang); + if ($srv_nextpage == '') $srv_nextpage = $lang['srv_lastpage']; + } + } + else { + $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage' . $_lang); + if ($srv_nextpage == '') $srv_nextpage = $lang['srv_nextpage']; + } + + $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang); + if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage']; + + $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink'); + + if (!get('printPreview')) { + echo '
'; + //echo ' + if ($row['show_intro'] == 1 || $rowg['vrstni_red'] > 1) { + #echo ''; + + if (!SurveyInfo::getInstance()->checkSurveyModule('slideshow')) { + + // Posebej za WebSM anketo - back naredimo tako, da poiscemo prejsnjo stran + if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') { + + $grupa = Find::findPrevGrupa(); + $grupa = ($grupa > 0) ? '&grupa=' . $grupa : ''; + + $lang_s = (isset($_GET['language'])) ? '&language=' . $_GET['language'] : ''; + $language = save('language', $lang_s, 1); + + $link = SurveyInfo::getSurveyLink(false, false) . $grupa . $language; + + echo ''; + } elseif ($display_backlink != '0') { + echo ''; + } + } else { + + # če smo v slideshowu prikazujemo gumb nazaj ali naprej na zahtevo + $ss = new SurveySlideshow(get('anketa')); + $ss_setings = $ss->getSettings(); + + if ($ss_setings['back_btn'] == 1) { + echo ''; + } + } + } + + if (SurveyInfo::getInstance()->checkSurveyModule('slideshow')) { + # če smo v prezentaciji in imamo nastavljen pause button + $ss = new SurveySlideshow(get('anketa')); + $ss_setings = $ss->getSettings(); + + if ($ss_setings['pause_btn'] == 1) { + echo ''; + echo ''; + } + } + if (!SurveyInfo::getInstance()->checkSurveyModule('slideshow')) { + echo ' '; + } else { + # če smo v slideshowu prikazujemo gumb nazaj ali naprej na zahtevo + $ss = new SurveySlideshow(get('anketa')); + $ss_setings = $ss->getSettings(); + if ($ss_setings['next_btn'] == 1) { + echo ' '; + } + } + + echo '
' . "\n"; + } + } + } + + /** + * @desc poklice generatorje JS kode za branching + */ + public function generateBranchingJS() + { + echo ' ' . "\n"; + } + + /** + * zgenerira koda za compute spremenljivke, ki si vrednost napolnijo samodejno iz calculation izraza + * + */ + public function generateComputeJS() + { + + if (get('generateComputeJS') != '') { + + echo 'try { ' . "\n"; + echo ' ' . get('generateComputeJS') . "\n"; + echo '} catch (e) {} ' . "\n"; + } + + } + + /** + * za podano spremenljivko zgenerira compute kodo, ki se shrani v začasno spremenljivko, da se na koncu izpiše s funkcijo generateComputeJS() + * + * @param mixed $spremenljivka + */ + public function generateCompute($spremenljivka) + { + + // vrednost kalkulacije za ife + add('generateComputeJS', "document.getElementById('vrednost_" . $spremenljivka . "').value = " . $this->generateCalculationJS(-$spremenljivka) . "; \n\r"); + + // vrednost se zapise v class .data-piping-SPR_ID za data-piping da se v zivo refresha + add('generateComputeJS', " var val; if ( ! isNaN(document.getElementById('vrednost_" . $spremenljivka . "').value) ) val = document.getElementById('vrednost_" . $spremenljivka . "').value; else val = ''; \n\r"); + add('generateComputeJS', " $('.data-piping-$spremenljivka').html( val ); \n\r"); + } + + /** + * @desc zgenerira kodo za IFe na vrednostih (podifi) + */ + public function generateVrednostIf() + { + + SurveySetting::getInstance()->Init(get('anketa')); + $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables'); + + $sql = sisplet_query("SELECT v.*, s.tip AS tip, s.id AS spr_id, s.dynamic_mg AS dynamic_mg, s.vsota_limit, s.design, s.params FROM srv_vrednost v, srv_spremenljivka s WHERE v.if_id>'0' AND v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0'"); + while ($row = mysqli_fetch_array($sql)) { + + // Ce je odgovor skrit ga nikoli ne prikazemo in preskocimo kar celotno proceduro za to vrednost + if($row['hidden'] == '1'){ + continue; + } + + //stavek za pobiranje informacij o tipu in orienataciji spremenljivke, potrebno za nadaljnje notranje pogoje za drag and drop + $sqldd = sisplet_query("SELECT id, enota, orientation FROM srv_spremenljivka WHERE id = '$row[spr_id]'"); + while ($rowdd = mysqli_fetch_array($sqldd)) { + $spremenljivka_dd = $rowdd['id']; + $orientation_dd = $rowdd['orientation']; + $enota_dd = $rowdd['enota']; + } + + // vsota - treba je se enkrat pognati racunanje + if ($row['tip'] == 18) { + $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[spr_id]' AND vrstni_red>0"); + $max = mysqli_num_rows($sql1); + $sum = ' calcSum(\'' . $row['spr_id'] . '\', \'' . $max . '\', \'' . $row['vsota_limit'] . '\'); ' . "\n"; + } + else + $sum = ''; + + + // dinamicni multigrid (za mobilne naprave) + if ($row['tip'] == 6 && $enota_dd != 9 && $enota_dd != 3 && $row['dynamic_mg'] > 0) { + + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' dynamicMultigridSwitchIf(1, ' . $row['id'] . ', ' . $row['spr_id'] . '); ' . "\n"; + + echo ' } else { ' . "\n"; + + echo ' dynamicMultigridSwitchIf(0, ' . $row['id'] . ', ' . $row['spr_id'] . '); ' . "\n"; + + echo ' } ' . "\n"; + + echo ' } catch (e) {} ' . "\n"; + } + // Navaden multigrid + else if ($row['tip'] == 6 && $enota_dd != 9 && $enota_dd != 3) { + + echo ' try { ' . "\n"; + + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + // Element je viden + echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' var el = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; + echo ' el.parentNode.removeChild( el );' . "\n"; + + // Element ni viden + echo ' } else { ' . "\n"; + + // ker je element neviden, dodamo novega hidz vrednostjo -2 + echo ' var el = document.getElementById(\'vrednost_if_' . $row['id'] . '\');' . "\n"; + echo ' var hiddenEl = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; + echo ' var parent = el.parentNode.parentNode.parentNode;' . "\n"; + + // V kolikor je hidden polje že postavljeno potem ga ponovno ne ustvarjamo -> se izognemo podvojenim vpisom v bazi + echo ' if(!hiddenEl){' . "\n"; + echo 'var newElement = document.createElement(\'input\');' . "\n"; + echo ' newElement.setAttribute("id", "branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '");' . "\n"; + echo ' newElement.setAttribute("name", "cond_vrednost_' . $row['id'] . '");' . "\n"; + echo ' newElement.setAttribute("value", "-2");' . "\n"; + echo ' newElement.setAttribute("type", "hidden");' . "\n"; + echo ' parent.appendChild(newElement);' . "\n"; + echo ' }' . "\n"; + + echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; + + echo ' } ' . "\n"; + + echo ' } catch (e) {} ' . "\n"; + } + // checkbox in ne drag and drop + else if ($row['tip'] == 2 && ($row['orientation'] != 8 || get('mobile') == 1)) { + + if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' } else { ' . "\n"; + echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; + + echo ' } ' . "\n"; + + echo ' } catch (e) {} ' . "\n"; + } + else { + echo ' try { ' . "\n"; + + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + // Element je viden + echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' var el = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; + echo ' el.parentNode.removeChild( el );' . "\n"; + + // Element ni viden + echo ' } else { ' . "\n"; + + // ker je element neviden, dodamo novega hidz vrednostjo -2 + echo ' var el = document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\');' . "\n"; + echo ' var hiddenEl = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n"; + echo ' var parent = el.parentNode.parentNode.parentNode;' . "\n"; + + // V kolikor je hidden polje že postavljeno potem ga ponovno ne ustvarjamo -> se izognemo podvojenim vpisom v bazi + echo ' if(!hiddenEl){' . "\n"; + echo 'var newElement = document.createElement(\'input\');' . "\n"; + echo ' newElement.setAttribute("id", "branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '");' . "\n"; + echo ' newElement.setAttribute("name", "cond_vrednost_' . $row['spr_id'] . '[]");' . "\n"; + echo ' newElement.setAttribute("value", "' . $row['id'] . '");' . "\n"; + echo ' newElement.setAttribute("type", "hidden");' . "\n"; + echo ' parent.appendChild(newElement);' . "\n"; + echo ' }' . "\n"; + + echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; + + echo ' } ' . "\n"; + + echo $sum; + + echo ' } catch (e) {} ' . "\n"; + } + + } + // roleta + else if ($row['tip'] == 3) { + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' document.getElementById(\'vrednost_' . $row['spr_id'] . '_chzn_o_' . $row['vrstni_red'] . '\').style.display = \'\'; ' . "\n"; + + echo ' } else { ' . "\n"; + echo ' document.getElementById(\'vrednost_' . $row['spr_id'] . '_chzn_o_' . $row['vrstni_red'] . '\').style.display = \'none\'; ' . "\n"; + + echo ' } ' . "\n"; + + echo $sum; + + echo ' } catch (e) {} ' . "\n"; + } + // ranking premikanje + else if ($row['tip'] == 17 && $row['design'] == 2) { + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' } else { ' . "\n"; + + echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; + echo ' $(\'#frame_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; + + echo ' } ' . "\n"; + + echo $sum; + + echo ' } catch (e) {} ' . "\n"; + } + // ranking prestavljanje + else if ($row['tip'] == 17 && $row['design'] == 0) { + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' } else { ' . "\n"; + + echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; + echo ' $(\'#frame_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n"; + + echo ' } ' . "\n"; + + echo $sum; + + echo ' } catch (e) {} ' . "\n"; + } + else { + if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' } else { ' . "\n"; + echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; + + echo ' } ' . "\n"; + + echo $sum; + + echo ' } catch (e) {} ' . "\n"; + } + else { + echo ' try { ' . "\n"; + echo ' if ( '; + $this->generateCondition($row['if_id']); + echo ' ) { ' . "\n"; + + echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n"; + + echo ' } else { ' . "\n"; + echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n"; + + echo ' } ' . "\n"; + + echo $sum; + + echo ' } catch (e) {} ' . "\n"; + } + } + + // Po notranjih pogojih prikazemo ponavljanje naslovne vrstice za tabele ce je to vklopljeno + if($row['tip'] == 6 || $row['tip'] == 16){ + + $spremenljivkaParams = new enkaParameters($row['params']); + $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0); + + if($grid_repeat_header > 0){ + echo ' gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['spr_id'].'\'); '; + } + } + } + } + + /** + * @desc zgenerira kodo za branching + */ + public function generateBranching($parent = 0) + { + Cache::cache_all_srv_branching(get('anketa')); + Cache::cache_all_srv_if(get('anketa')); + + foreach (Cache::srv_branching_parent(get('anketa'), $parent) AS $k => $row) { + + if ($row['element_if'] > 0) { + + $rowb = Cache::srv_if($row['element_if']); + + // build conditions + //echo 'console.log("V generateBranching");'; + echo ' try { ' . "\n"; + + echo ' if ('; + + if ($rowb['tip'] == 0) { // if + + if ($rowb['enabled'] == 1) + echo 'true'; + elseif ($rowb['enabled'] == 2) + echo 'false'; + else + $this->generateCondition($row['element_if']); + + } else { // blok + + if ($rowb['enabled'] != 2) + echo 'true'; + else + echo 'false'; + + } + echo ' ) { ' . "\n"; + + // ko prikazujemo, prikazemo samo trenutni nivo + foreach (Cache::srv_branching_parent(get('anketa'), $row['element_if']) AS $k1 => $row1) { + + if ($row1['element_spr'] > 0) { + + if (Helper::getGrupa($row1['element_spr']) == get('grupa')) { + + $rowc = Model::select_from_srv_spremenljivka($row1['element_spr']); + if ($rowc['tip'] != 22 && $rowc['tip'] != 25) { // spremenljivka tipa compute in quota je izvzeta iz pogojev + + echo ' try { ' . "\n"; + echo ' document.getElementById(\'spremenljivka_' . $row1['element_spr'] . '\').style.display = "block"; ' . "\n"; + echo ' document.getElementById(\'visible_' . $row1['element_spr'] . '\').value = \'1\'; ' . "\n"; + + // Dodamo class da je vprasanje v bloku + echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child\'); ' . "\n"; + + // Dodamo class ce je vprasanje v bloku in je prikazano horizontalno + if (Helper::checkParentHorizontal($row1) == 1) { + echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'horizontal_block\'); ' . "\n"; + } + // Dodamo class ce je vprasanje v bloku in je prikazano z razpiranjem + if (Helper::checkParentHorizontal($row1) == 2) { + echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'expendable_block\'); ' . "\n"; + } + + // Dodamo class z id-jem bloka + echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child_'.$row['element_if'].'\'); ' . "\n"; + + + //Uros - samo za tip 26 + //ker se mapa ne kreira vredu, ce je hidden, jo je ob prikazu treba resizat ter nastavit bounds mape + echo ' + if('.$rowc['tip'].' == 26){ + //resize map, ker je zaradi display=none postala velika 0 + var map = document.getElementById("map_"+' . $row1['element_spr'] . ').gMap; + google.maps.event.trigger(map, \'resize\'); + //ce je 0 ali 1 marker, centriraj kot nastavi admin, drugace prilagodi markerjem + if (st_markerjev[' . $row1['element_spr'] . '] == 0){ + if(map.centerInMapKoordinate){ + map.setCenter({lat: parseFloat(map.centerInMapKoordinate.center.lat), + lng: parseFloat(map.centerInMapKoordinate.center.lng)}); + } + else + centrirajMap(map.centerInMap, map); + } + else + map.fitBounds(bounds[' . $row1['element_spr'] . ']); + }'; + + echo ' } catch (e) {} ' . "\n"; + + } + } + + } + } + + $this->generateBranching($row['element_if']); + + // Ce imamo vklopljen modul panel moramo nastaviti status panelista glede na izpolnjen if + if(SurveyInfo::checkSurveyModule('panel') == 1){ + + $sp = new SurveyPanel(get('anketa')); + $panel_if = $sp->getPanelIf($row['element_if']); + + if($panel_if != ''){ + echo '$(\'#panel_status\').val(\''.$panel_if.'\'); ' . "\n"; + } + } + + echo ' } else { ' . "\n"; + + // ko skrivamo, skrijemo vse (tudi podnivoje) (zato klic rekurzivne funkcije) + foreach (Helper::getElements($row['element_if']) AS $key) { + + if (Helper::getGrupa($key) == get('grupa')) { + + $rowc = Model::select_from_srv_spremenljivka($key); + if ($rowc['tip'] != 22 && $rowc['tip'] != 25) { // spremenljivka tipa compute in quota je izvzeta iz pogojev + + echo ' try { ' . "\n"; + echo ' document.getElementById(\'spremenljivka_' . $key . '\').style.display = "none"; ' . "\n"; + echo ' document.getElementById(\'visible_' . $key . '\').value = \'0\'; ' . "\n"; + + // Dodamo class da je vprasanje v bloku + echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child\'); ' . "\n"; + + // Dodamo class ce je vprasanje v bloku in je prikazano horizontalno + if (Helper::checkParentHorizontal($row) == 1) { + echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'horizontal_block\'); ' . "\n"; + } + // Dodamo class ce je vprasanje v bloku in je prikazano z razpiranjem + if (Helper::checkParentHorizontal($row) == 2) { + echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'expendable_block\'); ' . "\n"; + } + + // Dodamo class z id-jem bloka + echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'block_child_' . $row['element_if'] . '\'); ' . "\n"; + echo ' } catch (e) {} ' . "\n"; + + } + } + } + + echo ' } ' . "\n"; + + echo ' } catch (e) {} ' . "\n"; + + + // RANDOMIZACIJA VSEBINE BLOKA + // Randomiziramo vprasanja v bloku (ce imamo to vklopljeno) + if ($rowb['random'] >= 0) { + + $questions = []; + + foreach (Cache::srv_branching_parent(get('anketa'), $rowb['id']) AS $key => $val) { + if ($val['element_spr'] > 0) { + $questions[] = $val['element_spr']; + } + } + + // Ce imamo nastavljen prikaz samo dolocenega stevila vprasanj + $spr_count = ($rowb['random'] > 0) ? $rowb['random'] : count($questions); + + // Napolnimo seed za posameznega respondenta (da dobi vsakic isti vrstni red) + mt_srand((int)get('usr_id') + (int)$rowb['id']); + + // Zgeneriramo random vrstni red + $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($questions))); + array_multisort($order, $questions); + + $order_in_block = json_encode($questions); + + echo ' blockRandomizeQuestions(\''.$rowb['id'].'\', \''.$order_in_block.'\', \''.get('usr_id').'\', \''.$spr_count.'\'); ' . "\n"; + } + // Randomiziramo bloke v bloku (ce imamo to vklopljeno) + elseif ($rowb['random'] == -2) { + + $blocks = []; + + foreach (Cache::srv_branching_parent(get('anketa'), $rowb['id']) AS $key => $val) { + if ($val['element_if'] > 0) { + + $if_el = Cache::srv_if($val['element_if']); + + // blok + if ($if_el['tip'] == 1) { + $blocks[] = $if_el['id']; + } + } + } + + // Napolnimo seed za posameznega respondenta (da dobi vsakic isti vrstni red) + mt_srand((int)get('usr_id') + (int)$rowb['id']); + + // Zgeneriramo random vrstni red + $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($blocks))); + array_multisort($order, $blocks); + + $order_in_block = json_encode($blocks); + + echo ' blockRandomizeBlocks(\'' . $rowb['id'] . '\', \'' . $order_in_block . '\', \'' . get('usr_id') . '\'); ' . "\n"; + } + } + } + + // dodamo crte pri blokih, kjer so vprasanja postavljena horizontalno + echo ' blockHorizontalLine(); ' . "\n"; + } + + /** + * @desc zgenerira pogoje za JS branching + */ + public function generateCondition($if) + { + $rowa = SurveyInfo::getInstance()->getSurveyRow(); + + $echo = ''; + $sql = Cache::srv_condition($if); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $i = 0; + while ($row = mysqli_fetch_array($sql)) { + + if ($i++ != 0) + if ($row['conjunction'] == 0) + $echo .= ' && '; + else + $echo .= ' || '; + + if ($row['negation'] == 1) + $echo .= ' ! '; + + for ($i = 1; $i <= $row['left_bracket']; $i++) + $echo .= ' ( '; + + // obicajne spremenljivke + if ($row['spr_id'] > 0) { + + $row2 = Model::select_from_srv_spremenljivka($row['spr_id']); + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); + // multigrid + } elseif ($row['vre_id'] > 0) { + $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE id = '$row[vre_id]'"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + $row1 = mysqli_fetch_array($sql1); + } else + $row1 = null; //�ud not hepen + + + // kombinirana tabela + if (in_array($row2['tip'], array(6, 16, 19, 20)) && $row2['gru_id'] == '-2') { + + if (in_array($row2['tip'], array(6, 16))) { + $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c WHERE cond_id='$row[id]'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + if ($rowa['mass_insert'] != 1 || $row2['tip'] != 6 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje + + // Ce imamo if pogoj za -1 -> neodgovor + if ($row3['grd_id'] == '-1') { + $condition = ''; + + // loop cez vse gride in preverimo ce je kaksen odkljukan + $sqlG = sisplet_query("SELECT id, part, other FROM srv_grid WHERE spr_id='$row2[id]'"); + while ($rowG = mysqli_fetch_array($sqlG)) { + if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) { + if ($rowG['other'] == 0) + $condition .= '!document.getElementById(\'multi_' . $row2['id'] . '_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; + else + $condition .= '!document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; + + } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { + $condition .= '!document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $rowG['id'] . '\' '; + } + $condition .= ' && '; + } + $echo .= '(' . substr($condition, 0, -3) . ')'; + } else { + if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) { + + $sql4 = sisplet_query("SELECT part, other FROM srv_grid WHERE spr_id='$row2[id]' AND id='$row3[grd_id]'"); + $row4 = mysqli_fetch_array($sql4); + + if ($row4['other'] == 0) + $echo .= 'document.getElementById(\'multi_' . $row2['id'] . '_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; + else + $echo .= 'document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; + + } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { + $echo .= 'document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $row3['grd_id'] . '\' '; + } + } + + // masovni vnos + } else { + $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\').value == "' . $row3['grd_id'] . '"'; + } + + } + } elseif (in_array($row2['tip'], array(19, 20))) { + $echo .= ' ( '; + + $echo .= ' document.getElementById(\'multi_' . $row2['id'] . '_' . $row['vre_id'] . '_grid_' . $row['grd_id'] . '\').value'; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + + //if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + /*else + $echo .= $row['text'];*/ + + $echo .= ' ) '; + } + + // radio, checkbox, dropdown in multigrid (brez drag and drop) + } elseif ((($row2['tip'] <= 3 && ($row2['orientation'] != 8 || get('mobile') == 1)) || ($row2['tip'] == 6 || $row2['tip'] == 16) && ($row2['enota'] != 9)) && ($row['spr_id'] || $row['vre_id'])) { + + if ($row['operator'] == 0) + $echo .= ' '; + else + $echo .= ' ! '; + + $echo .= ' ( '; + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + + $sql3 = sisplet_query("SELECT c.vre_id, v.id, v.vrstni_red, v.other FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + if ($rowa['mass_insert'] != 1 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje + + // Ce imamo if pogoj za -1 -> neodgovor + if ($row3['vre_id'] == '-1') { + $condition = ''; + + // loop cez vse odgovore in preverimo ce je kaksen odkljukan + $sqlV = sisplet_query("SELECT id, other FROM srv_vrednost WHERE spr_id='$row[spr_id]'"); + while ($rowV = mysqli_fetch_array($sqlV)) { + if ($row2['tip'] <= 2 && ($row2['orientation'] != 8 || get('mobile') == 1)) { + if ($rowV['other'] >= 0) + $condition .= '!document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $rowV['id'] . '\').checked '; + else + $condition .= '!document.getElementById(\'missing_value_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $rowV['id'] . '\').checked '; + } else { + $condition .= '!document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == \'' . $rowV['id'] . '\' '; + } + $condition .= ' && '; + } + $echo .= '(' . substr($condition, 0, -3) . ')'; + } else { + //if ($row2['tip'] <= 2) { + if ($row2['tip'] <= 2 && ($row2['orientation'] != 8 || get('mobile') == 1)) { + if ($row3['other'] >= 0) + $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').checked '; + else + $echo .= 'document.getElementById(\'missing_value_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').checked '; + } else { + $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == \'' . $row3['id'] . '\' '; + } + } + + // masovni vnos + } else { + if ($row2['tip'] != 2) { // radio, dropdown + $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == "' . $row3['vrstni_red'] . '"'; + } else { // checkbox + $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').value == "1"'; + } + } + } + + // multigrid + } elseif ($row['vre_id'] > 0) { + $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + if ($rowa['mass_insert'] != 1 || $row2['tip'] != 6 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje + + // Ce imamo if pogoj za -1 -> neodgovor + if ($row3['grd_id'] == '-1') { + $condition = ''; + + // loop cez vse gride in preverimo ce je kaksen odkljukan + $sqlG = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row2[id]'"); + while ($rowG = mysqli_fetch_array($sqlG)) { + if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) { + if ($rowG['other'] == 0) + $condition .= '!document.getElementById(\'vrednost_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; + else + $condition .= '!document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked '; + + //} elseif ($row2['enota'] == 2) { + } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { + $condition .= '!document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $rowG['id'] . '\' '; + } + $condition .= ' && '; + } + $echo .= '(' . substr($condition, 0, -3) . ')'; + } else { + if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3 || $row2['enota'] == 4 || $row2['enota'] == 8) { + + $sql4 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row2[id]' AND id='$row3[grd_id]'"); + $row4 = mysqli_fetch_array($sql4); + + if ($row4['other'] == 0) + $echo .= 'document.getElementById(\'vrednost_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; + else + $echo .= 'document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked '; + + //} elseif ($row2['enota'] == 2) { + } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) { + $echo .= 'document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $row3['grd_id'] . '\' '; + } + } + + // masovni vnos + } else { + $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\').value == "' . $row3['grd_id'] . '"'; + } + + } + } + + $echo .= ' ) '; + //drag and drop @ kategorije en odgovor + } elseif ($row2['tip'] == 1 && ($row2['orientation'] == 8 && get('mobile') != 1)) { + + if ($row['operator'] == 0) + $echo .= ' '; + else + $echo .= ' ! '; + + $echo .= ' ( '; + //SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id + $sql3 = sisplet_query("SELECT c.vre_id FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + //if ($row2['design'] == 0 && get('mobile') == 0) + $echo .= ' $("#half2_frame_dropping_' . $row2['id'] . '").children("div").attr("value") == ' . $row3['vre_id']; + + //half2_frame_dropping_4271, half2_frame_dropping_1_4276 //spremenljivka_4276_vrednost_22811 + + } + + $echo .= ' ) '; + //drag and drop @ kategorije vec odgovorov + } elseif ($row2['tip'] == 2 && ($row2['orientation'] == 8 && get('mobile') != 1)) { + $z = 0; + if ($row['operator'] == 0) + $echo .= ' '; + else + $echo .= ' ! '; + + $echo .= ' ( '; + //SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id + $sql3 = sisplet_query("SELECT c.vre_id FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + //if ($row2['design'] == 0 && get('mobile') == 0) + for ($z = 1; $z <= $row2['grids']; $z++) { //preleti vse mozne odgovore in sestavi pogoj + $echo .= ' $("#half2_frame_dropping_' . $row2['id'] . '").children("div :nth-child(' . $z . ')").attr("value") == ' . $row3['vre_id']; + if ($z < $row2['grids']) { //ce ni zadnji mozni odgovor dodaj ali (||) + $echo .= '||'; + } + } + } + + $echo .= ' ) '; + + //drag and drop @ tabela en odgovor + } elseif (($row2['tip'] == 6) && ($row2['enota'] == 9)) { + if ($row['operator'] == 0) + $echo .= ' '; + else + $echo .= ' ! '; + + $echo .= ' ( '; + + $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); + + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + //if ($row2['design'] == 0 && get('mobile') == 0) + $echo .= ' $("#half2_frame_dropping_' . $row3['grd_id'] . '_' . $row2['id'] . '").children("div").attr("value") == ' . $row['vre_id']; + } + + $echo .= ' ) '; + //drag and drop @ tabela vec odgovorov + } elseif (($row2['tip'] == 16) && ($row2['enota'] == 9)) { + if ($row['operator'] == 0) + $echo .= ' '; + else + $echo .= ' ! '; + + $echo .= ' ( '; + + $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); + + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + //if ($row2['design'] == 0 && get('mobile') == 0) + for ($z = 1; $z <= $row2['grids']; $z++) { //preleti vse mozne odgovore in sestavi pogoj + $echo .= ' $("#half2_frame_dropping_' . $row3['grd_id'] . '_' . $row2['id'] . '").children("div :nth-child(' . $z . ')").attr("value") == ' . $row['vre_id']; + if ($z < $row2['grids']) { //ce ni zadnji mozni odgovor dodaj ali (||) + $echo .= '||'; + } + } + } + + $echo .= ' ) '; + + + // razvrscanje + } elseif ($row2['tip'] == 17) { + + if ($row['operator'] == 0) + $echo .= ' '; + else + $echo .= ' ! '; + + $echo .= ' ( '; + + $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'"); + if (!$sql3) echo mysqli_error($GLOBALS['connect_db']); + + $j = 0; + while ($row3 = mysqli_fetch_array($sql3)) { + if ($j++ != 0) $echo .= ' || '; + + if ($row2['design'] == 0 && get('mobile') == 0) // prestavljanje + $echo .= ' $(\'#half2_' . $row2['id'] . '\').sortable(\'toArray\')[' . ($row3['grd_id'] - 1) . '] == \'spremenljivka_'.$row['spr_id'].'_vrednost_' . $row['vre_id'] . '\' '; + elseif ($row2['design'] == 1 || get('mobile') > 0) // ostevilcevanje + $echo .= ' document.getElementsByName(\'spremenljivka_' . $row2['id'] . '_vrednost_' . $row['vre_id'] . '\')[0].value == \'' . ($row3['grd_id']) . '\' '; + elseif ($row2['design'] == 2 && get('mobile') == 0) // premikanje + $echo .= ' $(\'#sortzone_' . $row2['id'] . '\').sortable(\'toArray\')[' . ($row3['grd_id'] - 1) . '] == \'spremenljivka_'.$row['spr_id'].'_vrednost_' . $row['vre_id'] . '\' '; + + } + + $echo .= ' ) '; + + + // tabela text, tabela stevilo + } elseif ($row2['tip'] == 19 || $row2['tip'] == 20) { + + $echo .= ' ( '; + + $echo .= ' document.getElementById(\'vrednost_' . $row['vre_id'] . '_grid_' . $row['grd_id'] . '\').value'; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + + //if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + /*else + $echo .= $row['text'];*/ + + $echo .= ' ) '; + + // textbox + } elseif ($row2['tip'] == 21) { + + $echo .= ' ( '; + + if ($row['operator'] <= 5) + $echo .= 'document.getElementsByName(\'vrednost_' . $row['spr_id'] . '_kos_' . $row['vre_id'] . '\')[0].value'; + else + $echo .= 'document.getElementsByName(\'vrednost_' . $row['spr_id'] . '_kos_' . $row['vre_id'] . '\')[0].value.length'; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 6) + $echo .= ' == '; + elseif ($row['operator'] == 7) + $echo .= ' < '; + elseif ($row['operator'] == 8) + $echo .= ' > '; + + $echo .= '"' . $row['text'] . '"'; + + $echo .= ' ) '; + + // number, compute in kvota majo drugacne pogoje in opcije + } elseif ($row2['tip'] == 4 || $row2['tip'] == 7 || $row2['tip'] == 22 || $row2['tip'] == 25) { + + $echo .= ' ( '; + + if ($row2['tip'] == 7) // number ma drugacen ID, ker ima lahko dva polja + $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . ($row['grd_id'] + 1) . '\').value'; + else + $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value'; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + if ($row2['tip'] == 4 || $row['operator'] == 0 || $row['operator'] == 1) + $echo .= '"' . $row['text'] . '"'; + else { + if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + else + $echo .= $row['text']; + } + + $echo .= ' ) '; + + // datum + } elseif ($row2['tip'] == 8) { + + $echo .= ' ( '; + + $echo .= 'Date.parse(convertDate(document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value))'; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + else + $echo .= 'Date.parse(convertDate("' . $row['text'] . '"))'; + + $echo .= ' ) '; + + // vsota + } elseif ($row2['tip'] == 18) { + + $echo .= ' ( '; + + $echo .= 'document.getElementsByName(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\')[0].value'; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + else + $echo .= $row['text']; + + $echo .= ' ) '; + + } + + // recnum + } elseif ($row['spr_id'] == -1) { + + $echo .= ' ( _recnum % ' . $row['modul'] . ' == ' . $row['ostanek'] . ' ) '; + + // calculations + } elseif ($row['spr_id'] == -2) { + + $echo .= ' ( '; + + $echo .= $this->generateCalculationJS($row['id']); + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + else + $echo .= $row['text']; + + $echo .= ' ) '; + + // quotas + } elseif ($row['spr_id'] == -3) { + + $quota = Check::getInstance()->checkQuota($row['id']); + + $echo .= ' ( '; + + $echo .= $quota; + + if ($row['operator'] == 0) + $echo .= ' == '; + elseif ($row['operator'] == 1) + $echo .= ' !== '; + elseif ($row['operator'] == 2) + $echo .= ' < '; + elseif ($row['operator'] == 3) + $echo .= ' <= '; + elseif ($row['operator'] == 4) + $echo .= ' > '; + elseif ($row['operator'] == 5) + $echo .= ' >= '; + + if ($row['text'] == '') + $echo .= '"' . $row['text'] . '"'; + else + $echo .= $row['text']; + + $echo .= ' ) '; + + // naprava + } elseif ($row['spr_id'] == -4) { + + if (in_array($row['text'], array('0','1','2','3'))){ + + // Star nacin detekcije - vedno vezan na prvi prihod, po novem detektiramo vsakic posebej + /*$sqlU = sisplet_query("SELECT device FROM srv_user WHERE ank_id='".get('anketa')."' AND id='".get('usr_id')."'"); + $rowU = mysqli_fetch_array($sqlU); + + $echo .= $row['text'] . ' == ' . $rowU['device'];*/ + + $device = 0; + $useragent = $_SERVER['HTTP_USER_AGENT']; + + if ($useragent != '' && get_cfg_var('browscap')) { + + $browser_detect = get_browser($useragent, true); + + $detect = New Mobile_Detect(); + $detect->setUserAgent($useragent); + + // Detect naprave (pc, mobi, tablet, robot) + if ($detect->isMobile()) { + if ($detect->isTablet()) + $device = 2; + else + $device = 1; + } + elseif ($browser_detect['crawler'] == 1){ + $device = 3; + } + } + + $echo .= ' ( '; + $echo .= $row['text'] . ' == ' . $device; + $echo .= ' ) '; + } + } + + for ($i = 1; $i <= $row['right_bracket']; $i++) + $echo .= ' ) '; + } + + // failsafe, ce se poklika if, pa se ne nastavi pogoja + if ($echo == '') + $echo .= ' true '; + + echo $echo; + } + + /** + * @desc zgenerira kalkulacijo za vstavitev v JS + */ + public function generateCalculationJS($condition) + { + $calculationSpr = Cache::srv_spremenljivka(-$condition); + + $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC"); + if (!$sql) echo mysqli_error($GLOBALS['connect_db']); + + $i = 0; + $expression = ''; + while ($row = mysqli_fetch_array($sql)) { + + if ($i++ != 0) + if ($row['operator'] == 0) + $expression .= ' + '; + elseif ($row['operator'] == 1) + $expression .= ' - '; + elseif ($row['operator'] == 2) + $expression .= ' * '; + elseif ($row['operator'] == 3) + $expression .= ' / '; + + for ($i = 1; $i <= $row['left_bracket']; $i++) + $expression .= ' ( '; + + // spremenljivke + if ($row['spr_id'] > 0) { + + // obicne spremenljivke + if ($row['vre_id'] == 0) { + $row1 = Model::select_from_srv_spremenljivka($row['spr_id']); + + $spr = $row1['id']; + $vre = 0; + $grd = $row['grd_id']; + $tip = $row1['tip']; + } // checkbox, multigrid + elseif ($row['vre_id'] > 0) { + $sql1 = sisplet_query("SELECT v.spr_id, v.id, s.tip AS tip FROM srv_vrednost v, srv_spremenljivka s WHERE v.id = '$row[vre_id]' AND v.spr_id=s.id"); + if (!$sql1) echo mysqli_error($GLOBALS['connect_db']); + + $row1 = mysqli_fetch_array($sql1); + + $spr = $row1['spr_id']; + $vre = $row1['id']; + $tip = $row1['tip']; + $grd = $row['grd_id']; + } else { + $spr = 0; + $vre = 0; + $tip = 0; + $grd = 0; + } + + // Preverimo kako obravnavamo missinge - posamezno kot 0 ali kot -88 za celo kalkulacijo + $newParams = new enkaParameters($calculationSpr['params']); + $calcMissing = $newParams->get('calcMissing', '0'); + + $expression .= " checkCalculation('{$spr}', '{$vre}', '{$grd}', '{$tip}', '{$calcMissing}') "; + } + // konstante + elseif ($row['spr_id'] == -1) { + $expression .= $row['number']; + } + // recnum + elseif ($row['spr_id'] == -2) { + $sqlu = sisplet_query("SELECT recnum FROM srv_user WHERE id='".get('usr_id')."'"); + $rowu = mysqli_fetch_array($sqlu); + + $expression .= $rowu['recnum']; + } + + for ($i = 1; $i <= $row['right_bracket']; $i++) + $expression .= ' ) '; + } + + // Zaokrozimo na doloceno stevilo decimalk + $decimals = $calculationSpr['decimalna']; + $expression = 'parseFloat((' . $expression . ').toFixed(' . $decimals . '))'; + + return '(' . $expression . ')'; + } +} \ No newline at end of file diff --git a/main/survey/app/Controllers/LanguageController.php b/main/survey/app/Controllers/LanguageController.php new file mode 100644 index 0000000..ab47a41 --- /dev/null +++ b/main/survey/app/Controllers/LanguageController.php @@ -0,0 +1,196 @@ + 0) { + SurveyInfo::getInstance()->SurveyInit(get('anketa')); + $row = SurveyInfo::getInstance()->getSurveyRow(); + + $jezik = $row['lang_resp']; + + } else { + $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_resp'"); + $row = mysqli_fetch_array($sql); + + $jezik = $row['value']; + } + + $file = lang_path($jezik); + + if (@include($file)) { + $_SESSION['langX'] = lang_path($jezik, 1); + } + } + + + /** + * inicializacija multilang ankete. nastavljen mora biti usr_id ali $_GET[language] + * + */ + public function multilang_init() + { + global $lang; + + // mamo prebran cookie in user id, spremenimo language ce je treba -- multilanguage podpora je vezana na usr_id + $row = SurveyInfo::getInstance()->getSurveyRow(); + if ($row['multilang'] == 1) { + if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu) + + if (!empty(get('usr_id'))) { // (v bazo se shrani v displayintroduction - z ostalimi sistemskimi) (usr_id se ni postavljen) + $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'"); + $rowl = mysqli_fetch_array($sqll); + save('lang_id', $rowl['lang_id']); + } else { // v GETu, ko lahko v previewu spreminjamo jezik na strani (usr_id je ze postavljen) + $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'"); + $row1 = mysqli_fetch_array($sql1); + if ($row1['id'] > 0) + $sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_GET[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'"); + save('lang_id', $_GET['language']); + } + + } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani) + + $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'"); + $row1 = mysqli_fetch_array($sql1); + if ($row1['id'] > 0) + $sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_POST[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'"); + save('lang_id', $_POST['language']); + + } else { // jezik je ze shranjen v bazi, ga preberemo (naslednje strani) + + $sqll = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " dt, srv_spremenljivka s WHERE dt.spr_id=s.id AND s.variable='language' AND dt.usr_id='" . get('usr_id') . "'"); + $rowl = mysqli_fetch_array($sqll); + $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$rowl[text]'"); + $rowl = mysqli_fetch_array($sqll); + save('lang_id', $rowl['lang_id']); + + } + + if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik + $_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja) + // get('lang_id') mora se vedno ostati null ! + + } else { // zamenjamo jezik + $file = lang_path(get('lang_id')); + if (@include($file)) + $_SESSION['langX'] = lang_path(get('lang_id'), 1); + } + } + + } + + + /** + * prevod za srv_spremenljivka + */ + public static function srv_language_spremenljivka($spremenljivka) + { + if (get('lang_id') != null) { + + $sqll = sisplet_query("SELECT * FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND lang_id='" . get('lang_id') . "'"); + $rowl = mysqli_fetch_array($sqll); + + return $rowl; + } + + return false; + } + + /** + * vrne prevod za srv_vrednost + * + * @param mixed $vrednost + */ + public function srv_language_vrednost($vrednost, $naslov2=false) + { + + if (get('lang_id') != null) { + + $sqll = sisplet_query("SELECT naslov, naslov2 FROM srv_language_vrednost WHERE ank_id='" . get('anketa') . "' AND vre_id='$vrednost' AND lang_id='" . get('lang_id') . "'"); + $rowl = mysqli_fetch_array($sqll); + + if($naslov2){ + if ($rowl['naslov2'] != '') + return $rowl['naslov2']; + } + elseif ($rowl['naslov'] != ''){ + return $rowl['naslov']; + } + } + + return false; + } + + /** + * vrne prevod za srv_grid + * + * @param mixed $vrednost + */ + public static function srv_language_grid($spremenljivka, $grid) + { + if (get('lang_id') != null) { + + $sqll = sisplet_query("SELECT naslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'"); + $rowl = mysqli_fetch_array($sqll); + + if ($rowl['naslov'] != '') return $rowl['naslov']; + } + + return false; + } + + /** + * vrne prevod podnaslova za dvojno tabelo + * + */ + public static function srv_language_grid_podnaslov($spremenljivka, $grid) + { + if (get('lang_id') != null) { + + $sqll = sisplet_query("SELECT podnaslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'"); + $rowl = mysqli_fetch_array($sqll); + + if ($rowl['podnaslov'] != '') return $rowl['podnaslov']; + } + + return false; + } + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/StatisticController.php b/main/survey/app/Controllers/StatisticController.php new file mode 100644 index 0000000..00b01c2 --- /dev/null +++ b/main/survey/app/Controllers/StatisticController.php @@ -0,0 +1,282 @@ +getSurveyRow(); + + //statistika za glasovanje + if ($rowA['survey_type'] == 0) { + + if (get('printPreview')) { + $sql2 = sisplet_query("SELECT ank_id, spr_id, show_title FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'"); + $row2 = mysqli_fetch_array($sql2); + + $spremenljivka = $row2['spr_id']; + + $sqla = sisplet_query("SELECT starts, expire, statistics, db_table FROM srv_anketa WHERE id ='$row2[ank_id]'"); + $rowa = mysqli_fetch_array($sqla); + + $row = Model::select_from_srv_spremenljivka($spremenljivka); + + $text = $rowa['statistics']; + + if ($text != '') + echo '

' . $text . "\n"; + else + echo '

' . "\n"; + + if ($row2['show_title'] == 0) + echo ' ' . $row['naslov'] . '

' . "\n"; + else + echo ' ' . "\n"; + } else { + $sqlG = sisplet_query("SELECT spr_id FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'"); + $rowG = mysqli_fetch_array($sqlG); + + $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + $prev_grupa = $row['id']; + + $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$prev_grupa' AND stat>'0' ORDER BY vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + echo '
' . "\n"; + self::displayStatGlasovanje($rowG['spr_id']); + echo '
' . "\n"; + } + } + } + } //navadna statistika + else { + $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1"); + if (mysqli_num_rows($sql) > 0) { + $row = mysqli_fetch_array($sql); + $prev_grupa = $row['id']; + + $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$prev_grupa' AND stat='1' ORDER BY vrstni_red ASC"); + while ($row = mysqli_fetch_array($sql)) { + echo '
' . "\n"; + self::displayStat($row['id']); + echo '
' . "\n"; + } + } + } + + } + + /** + * @desc prikaze statistike za odgovor + */ + public static function displayStat($spremenljivka, $spol = 0) + { + global $lang; + + $row = Model::select_from_srv_spremenljivka($spremenljivka); + + $text = $lang['results']; + + echo '

' . $text . ': ' . $row['naslov'] . '

' . "\n"; + + $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_vrednost v, srv_data_vrednost" . get('db_table') . " d WHERE v.spr_id='$spremenljivka' AND v.id=d.vre_id"); + $row = mysqli_fetch_array($sql); + $total = $row['count']; + + $sql = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red"); + while ($row = mysqli_fetch_array($sql)) { + $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " WHERE vre_id='$row[id]'"); + $row1 = mysqli_fetch_array($sql1); + + + if ($total > 0) + $procent = round($row1['count'] / $total, 3) * 100; + else + $procent = 0; + + echo '

' . $row['naslov'] . ': ' . $procent . '%

' . "\n"; + } + } + + /** + * @desc prikaze statistiko za glasovanje + */ + public function displayStatGlasovanje($spremenljivka, $spol = 0) + { + global $lang; + global $site_url; + global $global_user_id; + + $row = Model::select_from_srv_spremenljivka($spremenljivka); + + //preverimo ce gre za glasovanje + $sql2 = sisplet_query("SELECT * FROM srv_glasovanje WHERE spr_id='$spremenljivka'"); + $row2 = mysqli_fetch_array($sql2); + + $sqla = sisplet_query("SELECT starts, expire, statistics, db_table FROM srv_anketa WHERE id ='$row2[ank_id]'"); + $rowa = mysqli_fetch_array($sqla); + + if ($rowa['db_table'] == 1) + save('db_table', '_active'); + + $text = $rowa['statistics']; + + if ($text != '') + echo ' ' . $text . "\n"; + else + echo ' ' . "\n"; + + if ($row2['show_title'] == 0) + echo ' ' . $row['naslov'] . '' . "\n"; + else + echo ' ' . "\n"; + + $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_vrednost v, srv_data_vrednost" . get('db_table') . " d WHERE v.spr_id='$spremenljivka' AND v.id=d.vre_id"); + $row = mysqli_fetch_array($sql); + $total = $row['count']; + + $sql = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red"); + while ($row = mysqli_fetch_array($sql)) { + + //prikaz statistike za moske(pri glasovanju) + if ($spol == 1) { + $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " v, srv_data_glasovanje g WHERE v.vre_id='$row[id]' AND v.usr_id=g.usr_id AND g.spr_id='$spremenljivka' AND g.spol='1' "); + $row1 = mysqli_fetch_array($sql1); + } //prikaz statistike za zenske(pri glasovanju) + elseif ($spol == 2) { + $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " v, srv_data_glasovanje g WHERE v.vre_id='$row[id]' AND v.usr_id=g.usr_id AND g.spr_id='$spremenljivka' AND g.spol='2' "); + $row1 = mysqli_fetch_array($sql1); + } else { + $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " WHERE vre_id='$row[id]'"); + $row1 = mysqli_fetch_array($sql1); + } + + if ($total > 0) + $procent = round($row1['count'] / $total, 3) * 100; + else + $procent = 0; + + echo '

' . $row['naslov'] . ':' . "\n"; + + + //ce gre za glasovanje in imamo nastavljen prikaz grafa ga izrisemo + if ($row2['show_graph'] == 1) { + + echo '

'; + + echo '
' . "\n"; + if ($row2['show_results'] == 1) { + echo $row1['count']; + if ($row2['show_percent'] == 1) + echo ' (' . $procent . '%)'; + } elseif ($row2['show_percent'] == 1) + echo $procent . '%'; + echo '
' . "\n"; + + echo '
'; + } else { + if ($row2['show_results'] == 1) { + echo $row1['count']; + if ($row2['show_percent'] == 1) + echo ' (' . $procent . '%)'; + } elseif ($row2['show_percent'] == 1) + echo $procent . '%'; + echo '

'; + } + } + + //stevilo vseh glasov + if ($row2['stat_count'] == 1) { + if ($spol != 0) { + $sql5 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_glasovanje WHERE spr_id='$spremenljivka' AND spol='1' "); + $row5 = mysqli_fetch_array($sql5); + $moskih_glasov = $row5['count']; + + if ($spol == 1) { + $percent = round($moskih_glasov / $total, 3) * 100; + $total = $moskih_glasov; + } else { + $percent = round(($total - $moskih_glasov) / $total, 3) * 100; + $total = $total - $moskih_glasov; + } + } + + echo '

' . $lang['glasovanja_count'] . ': ' . $total; + if ($spol != 0) + echo ' (' . $percent . '%)'; + echo '

'; + } + + //cas aktivnosti ankete + if ($row2['stat_time'] == 1) { + $start = strtotime($rowa['starts']); + $end = strtotime($rowa['expire']); + echo '

' . $lang['glasovanja_time'] . ' ' . date("m.d.Y", $start) . ' ' . $lang['glasovanja_time_end'] . ' ' . date("m.d.Y", $end) . '

'; + } + + //prikaz statistike po spolu (samo kjer je nastavljena opcija izbira spola) - gumbi za preklop + if ($row2['spol'] == 1) { + echo '
' . "\n"; + + if ($spol == 0) echo ''; + else echo ''; + + if ($spol == 1) echo ''; + else echo ''; + + if ($spol == 2) echo ''; + else echo ''; + + echo '
' . "\n"; + } + + //prikaz arhiva statistik anket + if ($row2['stat_archive'] == 1) { + + echo '
'; + echo 'Ankete iz arhiva:'; + + $sqlArchive = sisplet_query("SELECT ank_id FROM srv_glasovanje WHERE stat_archive = '1' AND ank_id != '$row2[ank_id]'"); + + echo '
    '; + while ($rowArchive = mysqli_fetch_array($sqlArchive)) { + $sql4 = sisplet_query("SELECT naslov, starts, insert_uid FROM srv_anketa WHERE id = '$rowArchive[ank_id]'"); + $row4 = mysqli_fetch_array($sql4); + + if($row4['insert_uid'] == $global_user_id){ + echo '
  • '; + + echo '' . $row4['naslov'] . ''; + echo ' (' . $row4['starts'] . ')'; + + echo '
  • '; + } + } + echo '
'; + echo '
'; + } + } + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/SurveyController.php b/main/survey/app/Controllers/SurveyController.php new file mode 100644 index 0000000..558f2ad --- /dev/null +++ b/main/survey/app/Controllers/SurveyController.php @@ -0,0 +1,76 @@ +getHeader(); + + // Shranimo pvrednost predogleda + save('printPreview', $printPreviewSet); + + if (isset($this->get->pages) && $this->get->pages == 'all') + save('displayAllPages', true); + + save('mobile', Helper::mobile()); + + // Pridobimo datoteko za jezike + Language::getLanguageFile(); + + // Ali imamo perdogled že rešene ankete + if (isset($this->get->quick_view) && $this->get->quick_view == 1) + save('quick_view', true); + + // Če je arhivirano pošiljanje emailov + if (isset($this->get->ai) && (int)$this->get->ai > 0) + save('user_inv_archive', (int)$this->get->ai); + + // Poiščemo missing vrednosti ankete smv + save('smv', new SurveyMissingValues(get('anketa'))); + + // Če imamo izklopljeno mobilno prilagajanje, potem ignoriramo mobitele in vedno prikazemo vse enako + SurveySetting::getInstance()->Init(get('anketa')); + $mobile_friendly = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_friendly'); + if ($mobile_friendly == 0) + save('mobile', 0); + + // Inicializacija vsega + new Init(); + } + + /************************************************ + * Poberemo spremenljivke iz get requestov in piškotkov + ************************************************/ + public function getHeader() + { + $header = new Header(); + + // Pridobimo vse GET parametre + $this->get = $header->getAllUrlParameters(); + + //Pridobimo vse $_COOKIE paramletre + $this->cookie = $header->getAllCookieParameters(); + } + + +} \ No newline at end of file diff --git a/main/survey/app/Controllers/VariableClass.php b/main/survey/app/Controllers/VariableClass.php new file mode 100644 index 0000000..93c1c69 --- /dev/null +++ b/main/survey/app/Controllers/VariableClass.php @@ -0,0 +1,193 @@ + null, // trenutna anketa + 'get' => null, // tukaj poberemo vse get parametre, ki se pošiljajo preko GET ali POST in jih dodamo v spremenljivko + 'grupa' => null, // trenutna grupa + 'spremenljivka' => null, // trenutna spremenljivka + 'usr_id' => null, // ID trenutnega uporabnika + 'cookie_expire' => null, // nastavitev kdaj expira cookie, da vemo za primer brez cookie-ja, da prenasamo preko urlja + 'cookie_url' => null, // kadar cookie prenasamo po URLju, se v to spremenljivko zapise koda, ki jo dodamo vsakemu linku ($_GET) + 'printPreview' => false, // ali kliče konstruktor + 'hierarhija' => null, // če gre za hierarhijo potem poberemo get parametre + + /** prisilimo prikaz spremenljivke, za predogled vanalizah in mogoče še kje + * + * @public boolean + */ + 'forceShowSpremenljivka' => false, + 'db_table' => '', + 'ime_AW' => null, // trenutno ime, ki se reseuje (socialna omrezja - alterwise) + 'loop_AW' => null, + 'loop_id' => null, // vrednost po kateri loopamo, ce smo v loopu + 'lang_id' => null, + 'language' => '1', + 'smv' => null, // misnig vrednosti od ankete + 'mobile' => 0, // 0 - klasicna, 1 - mobilna, 2 - dlancniki + 'ismobile' => 0, // detekcija, ce je mobilna naprava + + 'quick_view' => false, // ali smo samo v predogledu ankete od uporabnika + 'user_inv_archive' => 0, // id_arhiva vabil (če smo preko vabil) + 'displayAllPages' => false, // ali smo v predogledu kjer izpisujemo vse strani + 'webSMSurvey' => '34862', // WebSM anketa, ki ne shranjuje nicesar in skoci na pravo stran (gru_id) glede na url + 'generateComputeJS' => '', + + /** + * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu + */ + 'getElements' => array(), + 'checkSpremenljivka' => array(), + 'checkIf' => array(), + 'getGrupa' => array(), + 'preskocena_first' => 1, // spremenljivka, da pri preskocenih straneh ne delamo vsakic vseh querijev (ampak samo prvic) + 'cache_srv_data_grid' => '', // ostale spremenljivke so cache, ki se v posted() polni in zapise v bazo v posted_commit() + 'cache_srv_data_vrednost' => '', + 'cache_srv_data_text' => '', + 'cache_srv_data_checkgrid' => '', + 'cache_srv_data_textgrid' => '', + 'cache_srv_data_rating' => '', + 'cache_srv_data_vrednost_cond' => '', + 'cache_srv_data_map' => '', + 'cache_srv_data_heatmap' => '', + 'cache_delete' => '', + 'lurker' => -1, + 'getOtherValue' => array(), + 'select_from_srv_spremenljivka' => array(), + + // Naknadno dodane globalne spremenljivke + 'userAutor' => false + ); + + protected $key, $value, $return; + + // Shrani novo vrednost na obstoječo spremenljivko ali doda novo spremenljivko + public static function save($key, $value) + { + // Ce shranjujemo anketa_id ('anketa') jo najprej dekodiramo ce je potrebno + if($key == 'anketa'){ + $value = self::decryptAnketaID($value); + } + + $polje = self::izStringaVpolje($key); + if ($polje){ + self::$_configuration[ $polje['spremenljivka'][0] ][ $polje['key'][0] ] = $value; + } else { + self::$_configuration[$key] = $value; + }; + } + + // Popravimo id ankete ce gre za kodiranega (pri novih anketah je v url-ju kodiran id ankete da respondenti ne morejo dostopati do drugih anket) + private static function decryptAnketaID($anketa){ + + // Ce anketa ni numeric jo pretvorimo v originalen id + if(!is_numeric($anketa)){ + + $anketa_arr = str_split($anketa); + $anketa_id = ''; + + foreach($anketa_arr as $pos => $char){ + // Na lihih mestih pretvorimo crko nazaj v stevilko + if($pos % 2 == 0) + $anketa_id .= ord($char) - 97; + else + $anketa_id .= $char; + } + } + else + $anketa_id = $anketa; + + return $anketa_id; + } + + /************************************************ + * Funkcija iz stringa naredi polje z id vrednostjo + * primer (string) 'polje[id]' uredi v (arrey) polje[id] + * @return array() + ************************************************/ + private static function izStringaVpolje($string) + { + // spremenljivka je mišljen tekst, ki je pred oklepaji + $spremenljivka = array(); + // key je vrednost oz. id te spremenljivke, ki je med [] + $key = array(); + + $t = ""; + for ($i = 0; $i < strlen($string); $i++) { + if ($string[$i] == '[') { + $spremenljivka[] = $t; + $t = ""; + $t1 = ""; + $i++; + while ($string[$i] != ']') { + $t1 .= $string[$i]; + $i++; + } + $key[] = $t1; + + } else { + if ($string[$i] != ']') + $t .= $string[$i]; + else { + continue; + } + + } + } + + // V kolikor je samo string + if ($t != "") + return false; + + return [ + 'spremenljivka' => $spremenljivka, + 'key' => $key + ]; + } + + + // Dodamo vrednost k že obstoječi vrednosti + public static function add($key, $value, $return = null) + { + self::$_configuration[$key] .= $value; + + if (!is_null($return)) + return $value; + } + + public static function get($key) + { + return self::$_configuration[$key]; + } + + public static function getAll() + { + return self::$_configuration; + } + + /************************************************ + * Pridobimo vse variable, ki se uporabljajo za main/survey in jih dodamo na Controller -> $this variable + * + * @return $this + ************************************************/ + public function refresh() + { + foreach (self::$_configuration as $key => $value) { + $this->$key = $value; + } + + return $this; + } + + +} \ No newline at end of file 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 @@ +'; + + 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 @@ +' . "\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 ' '; + + echo '
' . "\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 ''; + } + + + # č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'; + + ?> + + 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 '' . "\n"; + + if ($hideLabels == false) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + for ($i = 1; $i <= $row['grids']; $i++) + echo ''; + echo ''; + + if ($mv_count > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + for ($i = 1; $i <= $mv_count / 2; $i++) + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + for ($i = 1; $i <= $row['grids']; $i++) + echo ''; + echo ''; + if ($mv_count > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + for ($i = 1; $i <= $mv_count / 2; $i++) + echo ''; + echo ''; + } + + echo ''; + + //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 ' ' . "\n\r"; + if ($hideLabels == false) { + echo ' ' . "\n"; + echo ' ' . "\n"; + } + echo ' ' . "\n"; + echo ' '; + echo ' '; + echo ' ' . "\n"; + echo ' ' . "\n\r"; + + echo ' ' . "\n\r"; + if ($hideLabels == false) { + echo ' ' . "\n"; + 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"; + } + } + + #double grid space + echo ''; + echo ''; + + //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 ' ' . "\n"; + $first_missing_value = false; + } + + // Datapiping + $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']); + + # izpišemo labelo grida + echo ' ' . "\n"; + } + } + echo ' ' . "\n"; + + echo ''; + + echo ''; + + $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 ' ' . "\n"; + if ($hideLabels == false) { + echo ' ' . "\n"; + 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) { + # imamo missing vrednost + echo '' . "\n"; + } else { + # ni missing vrednost + echo '' . "\n"; + } + } + } + + #double grid space + echo ''; + echo ''; + + + //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 ' ' . "\n"; + $first_missing_value = false; + } + + $value = $srv_grids2[$i]['id']; + # izpišemo radio grida + + if ($srv_grid['other'] != 0) { + # imamo missing vrednost + echo '' . "\n"; + } else { + # ni missing vrednost + echo '' . "\n"; + } + } + } + + echo ' ' . "\n"; + + $bg++; + } + + echo ''; + + echo '
' . $row['grid_subtitle1'] . '' . $row['grid_subtitle2'] . '
' . $srv_grid['naslov'] . '' . $srv_grid['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 ' '; + else + echo ' '; + + //echo ' '; + } + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
' . "\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 ' ' . "\n"; + if ($hideLabels == false) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + for ($i = 1; $i <= $row['grids']; $i++) + echo ''; + echo ''; + if ($mv_count > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + for ($i = 1; $i <= $mv_count / 2; $i++) + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo ''; + echo ''; + + echo ''; + for ($i = 1; $i <= $row['grids']; $i++) + echo ''; + echo ''; + if ($mv_count > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + for ($i = 1; $i <= $mv_count / 2; $i++) + echo ''; + echo ''; + } + + echo ''; + + //ipis podnaslovom posameznih delv grida + echo ' ' . "\n\r"; + if ($hideLabels == false) { + echo ' ' . "\n"; + echo ' ' . "\n"; + } + echo ' ' . "\n"; + echo ' '; + echo ' '; + echo ' ' . "\n"; + echo ' ' . "\n\r"; + + echo ' ' . "\n"; + if ($hideLabels == false) { + echo ' ' . "\n"; + echo ' ' . "\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 ''; + $first_missing_value = false; + + $count++; + } + + // Datapiping + $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']); + + # izpišemo labelo grida + echo '' . "\n"; + + //vmesno polje z mejo + if ($count == $colspan) { + echo ''; + $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 ''; + $first_missing_value = false; + + $count++; + } + + // Datapiping + $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']); + + # izpišemo labelo grida + echo '' . "\n"; + $count++; + } + } + + + + echo ' ' . "\n"; + + echo ''; + + echo ''; + + $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 ' ' . "\n"; + + if ($hideLabels == false) { + echo ' ' . "\n"; + echo ' ' . "\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 ''; + $first_missing_value = false; + + $count++; + } + # izpišemo labelo grida + if ($srv_grid['other'] != 0) { + # imamo missing polje + echo '' . "\n"; + } else { + echo '' . "\n"; + } + + //vmesno polje z mejo + if ($count == $colspan) { + echo ''; + $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 ''; + $first_missing_value = false; + + $count++; + } + # izpišemo labelo grida + if ($srv_grid['other'] != 0) { + # imamo missing polje + echo '' . "\n"; + } else { + echo '' . "\n"; + } + $count++; + } + } + + echo ' ' . "\n"; + + $bg++; + } + + echo ''; + + echo '
' . $row['grid_subtitle1'] . '' . $row['grid_subtitle2'] . '
' . $srv_grid['naslov'] . '' . $srv_grid['naslov'] . '
' . $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 ' '; + } + echo ' '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
' . "\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 @@ +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 '
'; + //echo '
'; + echo ''; + echo ''; + //zaslon razdelimo na dva dela - izris leve strani + echo ''; + + //srednja celica (stevilo prenesenih in spodaj puscica) + if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico + echo ''; + + //izris desne strani + echo ''; + + + echo ''; + echo '
'; + + 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 '' . $srv_ranking_avaliable_categories . ':'; + + echo '
'; + $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 '
    '; + + if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico + echo '
  • +
    '; + } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik + echo '
  • +
    '; + } + + + 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 ' + + '; + }else{ + $preview_spremenljivka = 0; + echo ' + + '; + } + }else{ + $preview_spremenljivka = 0; + echo ' + + '; + } + //********* potrebno za pravilno prikazovanje predogleda - konec + + ?> + + '; + //echo '
'; //vrednost_if_ID + //div ki vsebuje vrednost + //if($length > 30) + // if($length > 90){ + // $niz = substr($value, 0, 90); + //echo '
'.$niz.'...
'."\n"; + // echo '
'.$niz.'...
'."\n"; + // } + // else + //echo '
'.$value.'
'."\n"; + // echo '
'.$value.'
'."\n"; + //else{ + //echo '
'.$value.'
'."\n"; + echo '
' . $value . '
' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id + //} + } + + echo '' . "\n"; + echo ''; + echo ''; //half_$spremenljivka + echo '
'; + } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik + echo ''; + } + echo ''; + echo 'arrow'; + echo ''; + + echo '' . self::$lang['srv_drag_drop_answers'] . ':'; + + echo '
'; // ker na td ne primer position relative za nastavit position absolute na dropzone + + + echo '
'; + $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 '
'; + //echo '
'; + //echo '
'; //vrednost_if_ID + +// echo '
'; //half2_$spremenljivka + if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico + echo '
    '; + echo '
  • +
    +
  • ' . "\n"; + echo '
'; + } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik + echo '
    '; + echo '
  • +
    +
  • ' . "\n"; + echo '
'; + } + + echo '
'; //half2_$spremenljivka + echo '
'; //dropholder + + echo '
'; + + //Gumb za resetiranje + echo '
'; + //echo ''; + echo ''; //srv_drag_and_drop_reset_button + echo '
'; + + echo '
'; + //} + + + ?> + + + + 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 '
'; + //echo '
'; + echo ''; + echo ''; + //zaslon razdelimo na dva dela - izris leve strani + echo ''; + + //srednja celica (stevilo prenesenih in spodaj puscica) + if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico + echo ''; + + //izris desne strani*********************************************************************************** + + echo ''."\n"; + $first_missing_value = false; + } + # izpišemo labelo grida + //echo ' '."\n"; + echo $srv_grid['naslov']; + } */ + //} + + + //glede na število gridov, dodati ustrezno stevilo
  • oz. okvirjev + echo '
      '; + $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']); + if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico + if($display_drag_and_drop_new_look == 0){ + echo '
  • +
    ' . $srv_grid['naslov'] . '
    +
  • ' . "\n"; //izpis "naslova" okvirja + echo '
  • +
    +
  • ' . "\n"; //izpis okvirja + }else if($display_drag_and_drop_new_look == 1){ + echo '
  • +
    +
  • ' . "\n"; //izpis okvirja + echo '
  • +
    ' . $srv_grid['naslov'] . '
    +
  • ' . "\n"; //izpis "naslova" okvirja + } + } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik + + if($display_drag_and_drop_new_look == 0){ + echo '
  • +
    ' . $srv_grid['naslov'] . '
    +
  • ' . "\n"; //izpis "naslova" okvirja + echo '
  • +
    +
  • ' . "\n"; //izpis okvirja + }else if($display_drag_and_drop_new_look == 1){ + echo '
  • +
    +
  • ' . "\n"; //izpis okvirja + echo '
  • +
    ' . $srv_grid['naslov'] . '
    +
  • ' . "\n"; //izpis "naslova" okvirja + } + } + ?> + + + + '; + + + echo ''; //half2_$spremenljivka + echo ''; //dropholder + + echo ''; + //************************************************ konec izrisa desne strani + + echo ''; + echo '
    '; + + 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 '' . $srv_ranking_avaliable_categories . ':'; + + echo '
    '; + $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 '
      '; + echo '
    • +
      '; + } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik + echo '
        '; + echo '
      • +
        '; + + } + + + 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 ' + + '; + }else{ + $preview_spremenljivka = 0; + echo ' + + '; + } + }else{ + $preview_spremenljivka = 0; + echo ' + + '; + } + //********* potrebno za pravilno prikazovanje predogleda - konec + + + ?> + + '; + //echo '
    '; //vrednost_if_ID + //div ki vsebuje vrednost + //if($length > 30) + // if($length > 90){ + // $niz = substr($value, 0, 90); + //echo '
    '.$niz.'...
    '."\n"; + // echo '
    '.$niz.'...
    '."\n"; + // } + // else + //echo '
    '.$value.'
    '."\n"; + // echo '
    '.$value.'
    '."\n"; + //else{ + //echo '
    '.$value.'
    '."\n"; + echo '
    ' . $value . '
    ' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id + //} + } + + echo '' . "\n"; + echo ''; + echo ''; //half_$spremenljivka + echo '
    '; + } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik + echo ''; + } + echo ''; + echo 'arrow'; + echo ''; + + echo '' . self::$lang['srv_drag_drop_answers'] . ':'; + + echo '
    '; // ker na td ne primer position relative za nastavit position absolute na dropzone + + + echo '
    '; + $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 '
    '.$srv_grid['naslov'].'
    '; + + //Gumb za resetiranje + echo '
    '; + //echo ''; + echo ''; //srv_drag_and_drop_reset_button + echo '
    '; + + + echo '
    '; + //} + + //********* 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"); + } + + + ?> + + + + + + 30) + if ($length > 90) { + $niz = substr($value, 0, 90); + echo '
    ' . $niz . '...
    ' . "\n"; + } else + echo '
    ' . $value . '
    ' . "\n"; + else + echo '
    ' . $value . '
    ' . "\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 @@ +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 = ''; + +/* ?> + + 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 '' . "\n"; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + for ($i = 1; $i <= $row['grids']; $i++) + echo ''; + echo ''; + if ($mv_count > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + for ($i = 1; $i <= $mv_count; $i++) + echo ''; + echo ''; + } + if ($row['enota'] > 0) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + if (!$row['dynamic_mg'] == 3) { + echo ''; + echo ''; + echo ''; + } + + echo ''; + + //vrstica z nadnaslovi + echo ''; + echo ' '; + echo ' '; + //for($j = 1; $j <= $trak_num_of_titles; $j++){ + for ($j = 1; $j <= $row['grids']; $j++) { + //echo ''; + if($j == 1){ + $nadnaslov_floating = 'left'; + }else if($j == $row['grids']){ + $nadnaslov_floating = 'right'; + }else{ + $nadnaslov_floating = 'none'; + } + echo ''; + + } + echo ''; + //vrstica z nadnaslovi - konec + + echo ' ' . "\n"; + echo ' ' . "\n"; + 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']); + + + if($diferencial_trak != 1){ //ce ni traku + # izpišemo labelo grida + echo ' ' . "\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 ' ' . "\n"; + }else { //drugace, ce je labela za missing, izpisi labelo + echo ' ' . "\n"; + } + } + } + } + + if (!$row['dynamic_mg'] == 3) { + 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 + $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 ''; + // 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 ''; + + 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 ' ' . "\n"; + echo ' ' . "\n"; + echo '' . "\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 ' ' . "\n"; + $first_missing_value = false; + + $colspan++; + } + + $value = $srv_grids[$i]['id']; + # izpišemo radio grida + if ($srv_grid['other'] != 0) { + # imamo missing vrednost + echo '' . "\n"; + } else { + if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0) ){ //ce je trak + if ($gridRow < $countVar){ + echo '' . "\n"; + }else{ + # ni missing vrednost + echo '' . "\n"; + } + } + + $colspan++; + } + } + + # dodamo še enoto + if ($row['enota'] == 1) { + echo ' ' . "\n"; + echo ' ' . "\n"; + $colspan += 2; + } + + // puscice levo/desno + if ($row['dynamic_mg'] == 3) { + + //echo ' '; + //echo ' '."\n"; + + // paginacija + } elseif ($row['dynamic_mg'] == 5 || (get('mobile') == 1 && $mobile_tables > 0)) { + + echo ''; + + // puscice za naprej/nazaj + } else { + + echo ' ' . "\n"; + } + + echo ' ' . "\n"; + + $bg++; + $gridRow++; + } + + echo '
    '.$j.'
    lang_id!=null ?' default="1"':'').'>' . $trak_nadnaslov[$j] . '
    ' . $srv_grid['naslov'] . '' . $srv_grid['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 ' '; + else + echo ' '; + + //echo ' '; + } + echo ''; + echo ''; + echo ''; + }else{ + echo ''; + } + # ni missing vrednost + echo ''; + echo ''; + echo ''; + echo ''; + echo '' . $row1['naslov2'] . ''."\n"; + echo '
    '; + echo ' ' . "\n"; + if ($gridRow > 1) + echo ' '; + else + echo ' '; + echo ' '; + if ($gridRow < $countVar) + echo ' '; + else + echo ' '; + echo '
    '.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'
    ' . "\n"; + echo '
    '; + echo ' ' . "\n"; + for ($i = 1; $i <= $countVar; $i++) { + echo ' '; + } + echo '
    ' . $i . '
    ' . "\n"; + echo '
    ' . "\n"; + if ($gridRow > 1) + echo '
    '; + else + echo '
    '; + echo '
    '.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'
    '; + if ($gridRow < $countVar) + echo '
    '; + else + echo '
    '; + echo '
    ' . "\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 ' + + '; + if($trak_num_of_titles != 0){ + //prilagajanje stevilu izbranih nadnaslovov + ?> + + 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 ''; + //echo ''; + + //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 ''; + // 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 ''; + + 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 '
    ' . "\n"; + + 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 ' '; + } + echo '
    '; + + 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 '
    '; + if ($srv_grid['other'] != 0) { + # imamo missing vrednost + echo ''; + } else { + # ni missing vrednost + echo ''; + } + echo '
    '; + } + } + + // Dodamo se drug naslov ce imamo semanticni diferencial + if ($row['enota'] == 1) { + + // Datapiping + $row1['naslov2'] = Helper::dataPiping($row1['naslov2']); + + echo '
    '; + echo $row1['naslov2']; + echo '
    '; + } + + echo '
    '; + + 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 '
    ' . "\n"; + if ($gridRow > 1) + echo '
    '; + else + echo '
    '; + echo '
    '.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'
    '; + if ($gridRow < $countVar) + echo '
    '; + else + echo '
    '; + echo '
    ' . "\n"; + + // Paginacija + } elseif ($row['dynamic_mg'] == 6 || (get('mobile') == 1 && $mobile_tables > 0)) { + + echo ''; + echo ' ' . "\n"; + for ($i = 1; $i <= $countVar; $i++) { + echo ' '; + } + echo '
    ' . $i . '
    ' . "\n"; + echo ''; + + // puscice levo/desno + } else { + echo ' ' . "\n"; + if ($gridRow > 1) + echo ' '; + else + echo ' '; + echo ' '; + if ($gridRow < $countVar) + echo ' '; + else + echo ' '; + echo '
    '.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'
    ' . "\n"; + } + + echo '
    ' . "\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 @@ +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 '
    '; + //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 '