summaryrefslogtreecommitdiffstats
path: root/admin/survey/export/latexclasses
diff options
context:
space:
mode:
Diffstat (limited to 'admin/survey/export/latexclasses')
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaBreak.php1343
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaCReport.php1337
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaCharts.php293
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaCrosstab.php1320
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaDesc.php319
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaFreq.php384
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaMean.php371
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaMultiCrosstab.php1909
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaSums.php2984
-rw-r--r--admin/survey/export/latexclasses/Analize/AnalizaTTest.php413
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/BesediloLatex.php475
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/DatumLatex.php140
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/GridMultipleLatex.php559
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/HeatmapLatex.php337
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/KalkulacijaLatex.php121
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/KvotaLatex.php145
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/LokacijaLatex.php142
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/MultiGridLatex.php1768
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/NagovorLatex.php73
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/RadioCheckboxSelectLatex.php488
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/RazvrscanjeLatex.php397
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/SNImena.php94
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/SteviloLatex.php702
-rw-r--r--admin/survey/export/latexclasses/Vprasanja/VsotaLatex.php167
-rw-r--r--admin/survey/export/latexclasses/class.LatexAnalysis.php287
-rw-r--r--admin/survey/export/latexclasses/class.LatexAnalysisElement.php2022
-rw-r--r--admin/survey/export/latexclasses/class.LatexDocument.php1423
-rw-r--r--admin/survey/export/latexclasses/class.LatexEditsAnalysis.php1305
-rw-r--r--admin/survey/export/latexclasses/class.LatexGDPR.php115
-rw-r--r--admin/survey/export/latexclasses/class.LatexStatus.php1517
-rw-r--r--admin/survey/export/latexclasses/class.LatexSurvey.php1342
-rw-r--r--admin/survey/export/latexclasses/class.LatexSurveyElement.php2372
-rw-r--r--admin/survey/export/latexclasses/textemp/.gitignore4
-rw-r--r--admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisAndOtherLandscape.cls100
-rw-r--r--admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisPortrait.cls98
-rw-r--r--admin/survey/export/latexclasses/textemp/latexTemplatePdfSurvey.cls226
36 files changed, 27092 insertions, 0 deletions
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaBreak.php b/admin/survey/export/latexclasses/Analize/AnalizaBreak.php
new file mode 100644
index 0000000..3317de4
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaBreak.php
@@ -0,0 +1,1343 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+
+/** Class za generacijo latex
+ *
+ *
+ *
+ */
+class AnalizaBreak extends LatexAnalysisElement {
+
+ var $anketa;// = array(); // trenutna anketa
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+ var $db_table = '';
+
+ public $breakClass = null; // break class
+ public $crosstabClass = null; // crosstab class
+
+ var $spr = 0; // spremenljivka za katero delamo razbitje
+ var $seq; // sekvenca
+
+ var $break_percent; // opcija za odstotke
+
+ public $break_charts = 0; // ali prikazujemo graf ali tabelo
+
+ var $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+ protected $texBigSkip = '\bigskip';
+ protected $spaceBetweenTables = ' \newline \vspace*{1 cm} \newline';
+
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $podstran = 'break'){
+ global $site_path;
+ global $global_user_id;
+ // preverimo ali imamo stevilko ankete
+ //if ( is_numeric($anketa) ){
+ if ( is_numeric($anketa['id']) ){
+ //$this->anketa['id'] = $anketa;
+ $this->anketa = $anketa;
+ $this->anketa['podstran'] = $podstran;
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+ $_GET['a'] = A_ANALYSIS;
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData();
+
+ #############################################
+/* // ustvarimo break objekt
+ $this->breakClass = new SurveyBreak($this->anketa['id']);
+ $this->spr = $this->sessionData['break']['spr'];
+ # poiščemo sekvenco
+ $this->seq = $this->sessionData['break']['seq'];
+
+ $this->break_percent = (isset($this->sessionData['break']['break_percent']) && $this->sessionData['break']['break_percent'] == false) ? false : true; */
+ #############################################
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init()){
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) ){
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+
+/* function encodeText($text)
+ { // popravimo sumnike ce je potrebno
+ $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
+ $text = str_replace(array("&scaron;","&#353;","&#269;"),array("š","š","č"),$text);
+ return strip_tags($text);
+ } */
+
+
+ function displayBreak($forSpr=null, $forSeq=null, $frequencys=null, $breakClass=null, $break_charts=null, $export_format='') {
+
+ $this->breakClass = $breakClass;
+ $this->break_charts = $break_charts;
+ $this->seq = $forSeq;
+ $this->spr = $forSpr;
+ $this->export_format = $export_format;
+
+ $tabela = '';
+
+ // če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
+ //SurveyTimeProfiles :: printIsDefaultProfile(false);
+
+ // če imamo filter ifov ga izpišemo
+ //SurveyConditionProfiles:: getConditionString();
+
+ // če imamo filter spremenljivk ga izpišemo
+ //SurveyVariablesProfiles:: getProfileString(true);
+ //SurveyDataSettingProfiles :: getVariableTypeNote();
+
+ // če rekodiranje
+ //$SR = new SurveyRecoding($this->anketa);
+ //$SR -> getProfileString();
+
+ // filtriranje po spremenljivkah
+ $_FILTRED_VARIABLES = SurveyVariablesProfiles::getProfileVariables(SurveyVariablesProfiles::checkDefaultProfile(), true);
+
+ foreach ($this->breakClass->_HEADERS AS $skey => $spremenljivka) {
+ $spremenljivka['id'] = $skey;
+ $tip = $spremenljivka['tip'];
+
+ if ( is_numeric($tip)
+ && $tip != 4 #text
+ && $tip != 5 #label
+ && $tip != 8 #datum
+ && $tip != 9 #SN-imena
+ && $tip != 19 #multitext
+ && $tip != 21 #besedilo*
+ && ( count($_FILTRED_VARIABLES) == 0 || (count($_FILTRED_VARIABLES) > 0 && isset($_FILTRED_VARIABLES[$skey]) ))
+ ) {
+
+ $tabela .= $this->displayBreakSpremenljivka($forSpr,$frequencys,$spremenljivka);
+ } else if ( is_numeric($tip)
+ && (
+ $tip == 4 #text
+ || $tip == 19 #multitext
+ || $tip == 21 #besedilo*
+ || $tip == 20 #multi numer*
+ ) && ( count($_FILTRED_VARIABLES) == 0 || (count($_FILTRED_VARIABLES) > 0 && isset($_FILTRED_VARIABLES[$skey]) ) )
+ ) {
+ $tabela .= $this->displayBreakSpremenljivka($forSpr,$frequencys,$spremenljivka);
+ }
+ }
+ return $tabela;
+ }
+
+ function displayBreakSpremenljivka($forSpr=null,$frequencys=null,$spremenljivka=null) {
+ $tip = $spremenljivka['tip'];
+ $skala = $spremenljivka['skala'];
+ $tabela = '';
+
+ if ($forSpr != $spremenljivka['id']) {
+ switch ($tip) {
+ # radio, dropdown
+ case 1:
+ case 3:
+ $tabela .= $this->displayCrosstabs($forSpr,$frequencys,$spremenljivka);
+ break;
+ #multigrid
+ case 6:
+ if ($skala == 0) {
+ $tabela .= $this->displayBreakTableMgrid($forSpr,$frequencys,$spremenljivka);
+ } else {
+ $tabela .= $this->displayCrosstabs($forSpr,$frequencys,$spremenljivka);
+ }
+ break;
+ # checkbox
+ case 2:
+ $tabela .= $this->displayCrosstabs($forSpr,$frequencys,$spremenljivka);
+ break;
+ #number
+ case 7:
+ #ranking
+ case 17:
+ #vsota
+ case 18:
+ #multinumber
+ case 20:
+ $tabela .= $this->displayBreakTableNumber($forSpr,$frequencys,$spremenljivka);
+ break ;
+ case 19:
+ $tabela .= $this->displayBreakTableText($forSpr,$frequencys,$spremenljivka);
+ break ;
+ #multicheck
+ case 16:
+ $tabela .= $this->displayCrosstabs($forSpr,$frequencys,$spremenljivka);
+ break;
+ case 4:
+ case 21:
+ # po novem besedilo izpisujemo v klasični tabeli
+ $tabela .= $this->displayBreakTableText($forSpr,$frequencys,$spremenljivka);
+ break;
+ default:
+ $tabela .= $this->displayCrosstabs($forSpr,$frequencys,$spremenljivka);
+ break;
+ }
+ }
+ return $tabela;
+ }
+
+ function displayBreakTableMgrid($forSpr=null,$frequencys=null,$spremenljivka=null, $creport=false, $ank_id=null, $export_format=null) {
+ global $lang;
+ $tabela = '';
+ $brezHline = $this->getBrezHline($this->export_format);
+ if($creport){
+ $breakClass = new SurveyBreak($ank_id);
+ $this->breakClass = $breakClass;
+ $this->export_format = $export_format;
+ }
+ //echo "displayBreakTableMgrid funckija</br>";
+ //echo "tip vprašanja: ".$spremenljivka['tip']."</br>";
+ // Ce izrisujemo graf//
+ if($this->break_charts == 1){
+ $tabela .= $this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'mgrid');
+ }
+ // Ce izrisujemo tabelo
+ else{
+
+ $keysCount = count($frequencys);
+ $sequences = explode('_',$spremenljivka['sequences']);
+ $forSpremenljivka = $this->breakClass->_HEADERS[$forSpr];
+ $tip = $spremenljivka['tip'];
+
+ # izračunamo povprečja za posamezne sekvence
+ $means = array();
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ foreach ($sequences AS $sequence) {
+ $means[$fkey][$sequence] = $this->breakClass->getMeansFromKey($frequencys[$fkey][$sequence]);
+ }
+ }
+
+ if ($tip != 16 && $tip != 20) {
+ if ($tip == 1 || $tip == 3) {
+ if (count($spremenljivka['options']) < 15) {
+ $rowspan = 2;
+ $colspan = count($spremenljivka['options'])+1;
+ } else {
+ $rowspan = 1;
+ $colspan = 1;
+ }
+ } else {
+ $rowspan = 2;
+ $colspan = count($sequences);
+ }
+
+ $singleWidth = floor(200 / $colspan);
+
+ $steviloPodstolpcev = $colspan;
+
+ #preverjanje velikosti tabele
+ $mejaZaVelikeTabele = 5;
+ $velikostTabele = $steviloPodstolpcev;
+ if($velikostTabele > $mejaZaVelikeTabele){ //ce imamo veliko tabelo, jo je potrebno razbiti na vec tabel, ker drugace je presiroka
+ //echo "tabela je prevelika, ima ".($velikostTabele)." stolpcev</br>";
+ $presirokaTabela = 1;
+ $steviloTabelCelih = intval($velikostTabele / $mejaZaVelikeTabele);
+ $steviloTabelMod = $velikostTabele % $mejaZaVelikeTabele;
+ $delnaTabela = 0;
+ if($steviloTabelMod != 0){
+ $delnaTabela = 1;
+ }
+ $steviloTabel = $steviloTabelCelih + $delnaTabela;
+
+/* echo "stevilo podtabel celih ".($steviloTabelCelih)." </br>";
+ echo "stevilo podtabel mod ".($steviloTabelMod)." </br>";
+ echo "stevilo podtabel ".($steviloTabel)." </br>"; */
+ }else{
+ $presirokaTabela = 0;
+ }
+ #preverjanje velikosti tabele - konec
+
+ if($presirokaTabela == 0){ //ce tabela ni presiroka
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = $steviloPodstolpcev+1;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ //echo "steviloOstalihStolpcev v funkciji: ".$steviloOstalihStolpcev."</br>";
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ //echo "tukaj";
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($this->export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'C|' : 'c|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($this->export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($this->export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ // PRVA VRSTICA
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($forSpremenljivka['naslov'].' ('.$forSpremenljivka['variable'].')');
+ //$prvaVrstica[] = $this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')');
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')').'}';
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).')').'}';
+ if($this->export_format == 'pdf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).')').'}';
+ }elseif($this->export_format == 'rtf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')').'}';
+ }
+
+
+ // DRUGA IN TRETJA VRSTICA
+ $drugaVrstica = array();
+ $drugaVrstica[]='';
+ $tretjaVrstica = array();
+ $tretjaVrstica[] = '';
+ //echo "tip: ".$tip."</br>";
+
+ if ($tip != 1 && $tip != 3) {
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $text = $this->encodeText($variable['naslov'].' ('.$variable['variable'].')');
+ $drugaVrstica[]=$text;
+ $tretjaVrstica[] = $this->encodeText($lang['srv_analiza_crosstab_average']);
+ }
+ }
+ }
+ else if (count($spremenljivka['options']) < 15) {
+ //echo "options :".count($spremenljivka['options'])."</br>";
+ foreach ($spremenljivka['options'] AS $okey => $option) {
+ //$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($option.' ('.$okey.')'), 1, 'C', 0, 0, 0 ,0, true);
+ $text = $this->encodeText($option.' ('.$okey.')');
+ $drugaVrstica[]=$text;
+ $tretjaVrstica[] = $this->encodeText($lang['srv_analiza_crosstab_average']);
+ }
+ //$this->pdf->MultiCell($singleWidth, $height, 'povprečje', 1, 'C', 0, 1, 0 ,0, true);
+ }
+
+ //Izpis vrstic tabele ##################
+ $tabela .= $this->tableRow($prvaVrstica,1); //izpis prve vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($drugaVrstica,1); //izpis druge vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($tretjaVrstica, $brezHline); //izpis tretje vrstice
+
+ // VRSTICE S PODATKI
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ $podatkiVrstica = array();
+ $podatkiVrstica[]=$this->encodeText($forSpremenljivka['options'][$fkey]); //naslov horizontalne vrstice
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['other'] != 1) {
+ $sequence = $variable['sequence'];
+ if (($tip == 1 || $tip == 3) && count($spremenljivka['options']) < 15) {
+ foreach ($spremenljivka['options'] AS $okey => $option) {
+ //$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($frequencys[$fkey][$sequence]['valid'][$okey]['cnt']), 1, 'C', 0, 0, 0 ,0, true);
+ $podatkiVrstica[]=$this->encodeText($frequencys[$fkey][$sequence]['valid'][$okey]['cnt']);
+ //echo "podatkiVrstica 1 :".$this->encodeText($frequencys[$fkey][$sequence]['valid'][$okey]['cnt'])."</br>";
+ }
+ }
+ $podatkiVrstica[]=$this->formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ //echo "podatki v vrstici: ".$this->formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'')."</br>";
+ }
+ }
+ }
+ $tabela .= $this->tableRow($podatkiVrstica, $brezHline); //izpis vrstice s podatki
+ }
+ //Izpis vrstic tabele - konec ##################
+
+ /*zakljucek latex tabele*/
+ $tabela .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ //echo "tabela :".$tabela."</br>";
+ }elseif($presirokaTabela == 1){ //ce tabela je presiroka
+ $izpisaneCeleTabele = 0;
+ $indeksPodatkov = 0;
+ $indeksPodatkovOld = 0;
+ $indeksPodatkov1 = 0;
+ $indeksPodatkovOld1 = 0;
+ for($p=0; $p<$steviloTabel; $p++){ //ustvarjanje podtabel
+ $indeksPodatkov1 = $indeksPodatkov;
+ $indeksPodatkovOld1 = $indeksPodatkovOld;
+ //Priprava parametrov za tabelo
+ if($izpisaneCeleTabele < $steviloTabelCelih){
+ $steviloStolpcevParameterTabular = $mejaZaVelikeTabele+1;
+ $steviloPodstolpcev = $steviloStolpcevParameterTabular;
+ }else{
+ $steviloStolpcevParameterTabular = $steviloTabelMod+1;
+ $steviloPodstolpcev = $steviloStolpcevParameterTabular;
+ }
+ $izpisaneCeleTabele++; //vecanje indeksa za belezenja stevila izpisaih celih tabel, takih, ki so velike 5 + 1 stolpcev
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ //echo "steviloOstalihStolpcev v funkciji: ".$steviloOstalihStolpcev."</br>";
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ //echo "tukaj";
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($this->export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'C|' : 'c|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }
+ }
+ //echo "parametri za tabelo: ".$parameterTabular."</br>";
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($this->export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($this->export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ // PRVA VRSTICA
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($forSpremenljivka['naslov'].' ('.$forSpremenljivka['variable'].')');
+ if($this->export_format == 'pdf'){
+ $prvaVrstica[] = '\multicolumn{'.($steviloPodstolpcev-1).'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).')').'}';
+ }elseif($this->export_format == 'rtf'){
+ $prvaVrstica[] = '\multicolumn{'.($steviloPodstolpcev-1).'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')').'}';
+ }
+
+ // DRUGA IN TRETJA VRSTICA
+ $drugaVrstica = array();
+ $drugaVrstica[]='';
+ $tretjaVrstica = array();
+ $tretjaVrstica[] = '';
+ //echo "tip: ".$tip."</br>";
+ //echo "indeks podatkov prej: ".$indeksPodatkov."</br>";
+
+ if ($tip != 1 && $tip != 3) {
+ for($s=$indeksPodatkov; $s<($steviloPodstolpcev-1+$indeksPodatkovOld); $s++){
+ $grid = $spremenljivka['grids'][$s];
+ $text = $this->encodeText($grid['variables'][0]['naslov'].' ('.$grid['variables'][0]['variable'].')');
+ //echo "grid podatek: ".$text."</br>";
+ $drugaVrstica[] = $text;
+ $tretjaVrstica[] = $this->encodeText($lang['srv_analiza_crosstab_average']);
+ $indeksPodatkov = $s;
+ }
+ $indeksPodatkov = $indeksPodatkov + 1;
+ $indeksPodatkovOld = $indeksPodatkov;
+ }
+ else if (count($spremenljivka['options']) < 15) { //TO-DO: preureditev foreach v for, sem naredil isto kot v starih izvozih, vendar ne razumem, kdaj se to sprozi
+ //echo "options :".count($spremenljivka['options'])."</br>";
+ //echo "znotraj </br>";
+ foreach ($spremenljivka['options'] AS $okey => $option) {
+ //$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($option.' ('.$okey.')'), 1, 'C', 0, 0, 0 ,0, true);
+ $text = $this->encodeText($option.' ('.$okey.')');
+ $drugaVrstica[]=$text;
+ $tretjaVrstica[] = $this->encodeText($lang['srv_analiza_crosstab_average']);
+ }
+ //$this->pdf->MultiCell($singleWidth, $height, 'povprečje', 1, 'C', 0, 1, 0 ,0, true);
+ }
+
+ //Izpis vrstic tabele ##################
+ $tabela .= $this->tableRow($prvaVrstica,1); //izpis prve vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($drugaVrstica,1); //izpis druge vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($tretjaVrstica, $brezHline); //izpis tretje vrstice
+ //echo "tabela: ".$tabela."</br>";
+
+ // VRSTICE S PODATKI
+ //print_r($frequencys);
+ //echo "vrstice: ".count($frequencys)."</br>";
+ //foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ $steviloVrsticSPodatki = count($frequencys);
+
+ for($fkey=1; $fkey<=($steviloVrsticSPodatki); $fkey++){ //izpis vsake vrstice posebej
+ //echo "indeks freq: ".$fkey."</br>";
+ $podatkiVrstica = array();
+ $podatkiVrstica[] = $this->encodeText($forSpremenljivka['options'][$fkey]); //naslov horizontalne vrstice
+ //echo "debug text: ".$this->encodeText($forSpremenljivka['options'][$fkey])."</br>";
+
+ //foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ for($s1=$indeksPodatkov1; $s1<($steviloPodstolpcev-1+$indeksPodatkovOld1); $s1++){
+ $grid = $spremenljivka['grids'][$s1];
+ $variable = $grid['variables'][0];
+ if ($variable['other'] != 1) {
+ $sequence = $variable['sequence'];
+ //echo "sdvsdv </br>";
+ /* if (($tip == 1 || $tip == 3) && count($spremenljivka['options']) < 15) {
+ foreach ($spremenljivka['options'] AS $okey => $option) {
+ $podatkiVrstica[] = $this->encodeText($frequencys[$fkey][$sequence]['valid'][$okey]['cnt']);
+ //echo "podatki Vrstica 1 :".$this->encodeText($frequencys[$fkey][$sequence]['valid'][$okey]['cnt'])."</br>";
+ }
+ } */
+ $podatkiVrstica[] = $this->formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+
+ //echo "podatki v vrstici: ".$this->formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'')."</br>";
+ }
+ }
+ //print_r($podatkiVrstica);
+ $tabela .= $this->tableRow($podatkiVrstica, $brezHline); //izpis vrstice s podatki
+ //echo "indeks podatkov: ".$indeksPodatkov1."</br>";
+ //echo "limit for zanke ".(5+$indeksPodatkovOld)." </br>";
+ //echo "konec vrstice </br>";
+ }
+ //Izpis vrstic tabele - konec ##################
+
+ /*zakljucek latex tabele*/
+ $tabela .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ //echo "tabela :".$tabela."</br>";
+
+ }
+
+
+ }
+ }else
+ {
+ $rowspan = 2;
+ $colspan = $spremenljivka['grids'][0]['cnt_vars'];
+ $singleWidth = floor(200 / $colspan);
+ //echo "colspan spodaj: ".$colspan."</br>";
+
+ # za multicheck razdelimo na grupe - skupine
+ foreach ($frequencys AS $fkey => $frequency) {
+
+/* $this->pdf->setFont('','B','6');
+ $this->pdf->MultiCell(200, 5, $this->encodeText('Tabela za: ('.$forSpremenljivka['variable'].') = '.$forSpremenljivka['options'][$fkey]), 0, 'L', 0, 1, 0 ,0, true); */
+
+
+ $text = $spremenljivka['naslov'].' ('.$spremenljivka['variable'].')';
+ $height = $this->getCellHeight($text, 260);
+ //$this->pdf->MultiCell(260, $height, $this->encodeText($text), 1, 'C', 0, 1, 0 ,0, true);
+
+ //$this->pdf->setFont('','','6');
+
+
+ foreach ($spremenljivka['grids'][0]['variables'] AS $vkey => $variable) {
+ //$height = ($this->getCellHeight($variable['naslov'], $singleWidth) > $height) ? $this->getCellHeight($variable['naslov'], $singleWidth) : $height;
+ }
+
+ //$this->pdf->MultiCell(60, $height, '', 1, 'C', 0, 0, 0 ,0, true);
+ foreach ($spremenljivka['grids'][0]['variables'] AS $vkey => $variable) {
+ //$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($variable['naslov']), 1, 'C', 0, 0, 0 ,0, true);
+ }
+ //$this->pdf->MultiCell(1, $height,'', 0, 'C', 0, 1, 0 ,0, true);
+
+
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ $text = '('.$grid['variable'].') '.$grid['naslov'];
+/* $height = $this->getCellHeight($text, 60);
+ $this->pdf->MultiCell(60, $height, $this->encodeText($text), 1, 'C', 0, 0, 0 ,0, true); */
+
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+
+ //$this->pdf->MultiCell($singleWidth, $height, self::formatNumber($means[$fkey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''), 1, 'C', 0, 0, 0 ,0, true);
+ }
+ //$this->pdf->MultiCell(1, $height,'', 0, 'C', 0, 1, 0 ,0, true);
+ }
+ //$this->pdf->ln(10);
+ }
+ }
+ }
+ return $tabela;
+ }
+
+ function displayBreakTableNumber($forSpr=null,$frequencys=null,$spremenljivka=null, $creport=false, $ank_id=null, $export_format=null) {
+ global $lang;
+ $tabela = '';
+ $brezHline = $this->getBrezHline($this->export_format);
+
+ if($creport){
+ $breakClass = new SurveyBreak($ank_id);
+ $this->breakClass = $breakClass;
+ }
+ $keysCount = count($frequencys);
+ $sequences = explode('_',$spremenljivka['sequences']);
+ $forSpremenljivka = $this->breakClass->_HEADERS[$forSpr];
+ $tip = $spremenljivka['tip'];
+
+ # izračunamo povprečja za posamezne sekvence
+ $means = array();
+ $totalMeans = array();
+ $totalFreq = array();
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ foreach ($sequences AS $sequence) {
+ $means[$fkey][$sequence] = $this->breakClass->getMeansFromKey($frequencys[$fkey][$sequence]);
+ }
+ }
+
+ // Ce izrisujemo graf
+ if($this->break_charts == 1){
+
+ // Number, vsota, ranking graf
+ if($tip != 20 ){
+ //$this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'number');
+ $tabela .= $this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'number');
+ }
+
+ // Multinumber graf
+ else{
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ // Izrisujemo samo 1 graf v creportu
+ if($_GET['m'] == 'analysis_creport'){
+
+ if($spremenljivka['break_sub_table']['key'] == $gkey){
+ //$this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'number');
+ $tabela .= $this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'number');
+ }
+ }
+
+ // Izrisujemo vse zaporedne grafe
+ else{
+ $spremenljivka['break_sub_table']['key'] = $gkey;
+ $spremenljivka['break_sub_table']['sequence'] = $grid['variables'][0]['sequence'];
+ $tabela .= $this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'number');
+ }
+ }
+ }
+ }
+
+ // Izrisujemo tabelo
+ else{
+ # za multi number naredimo po skupinah
+ if ($tip != 20) {
+
+ $rowspan = 3;
+ $colspan = count($sequences);
+ $singleWidth = floor(200 / $colspan);
+
+ //Priprava podatkov za prve 3 vrstice tabele
+ // DRUGA VRSTICA prva, ker potrebujemo stevilo elementov v drugi vrstici, da pripravimo izpis prve vrstice in tabele
+ $drugaVrstica = array();
+ $drugaVrstica[] = '';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $drugaVrstica[] = $this->encodeText($variable['naslov'].' ('.$variable['variable'].')');
+ }
+ }
+
+ // PRVA VRSTICA
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($forSpremenljivka['naslov'].' ('.$forSpremenljivka['variable'].')');
+ //$prvaVrstica[] = $this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')'); //\multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}
+ $steviloPodstolpcev = count($drugaVrstica) - 1;
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')').'}';
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}
+ //{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}
+ //{'.$this->encodeText($this->snippet($spremenljivka['naslov']).'('.$this->snippet($spremenljivka['variable']).')').'}';
+ if($this->export_format == 'pdf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}
+ {>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}
+ {'.$this->encodeText($this->snippet($spremenljivka['naslov']).'('.$this->snippet($spremenljivka['variable']).')').'}';
+ }elseif($this->export_format == 'rtf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].')').'}';
+ }
+
+ // TRETJA VRSTICA
+ $tretjaVrstica = array();
+ $tretjaVrstica[] = '';
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $tretjaVrstica[] = $this->encodeText($lang['srv_analiza_crosstab_average']);
+ }
+ }
+
+ //Priprava podatkov za prve 3 vrstice tabele - konec
+
+ //Priprava parametrov za tabelo
+ //$steviloStolpcevParameterTabular = 2;
+ $steviloStolpcevParameterTabular = count($drugaVrstica);
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($this->export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'C|' : 'c|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($this->export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($this->export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+
+ //Izpis vrstic tabele
+ $tabela .= $this->tableRow($prvaVrstica,1); //izpis prve vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($drugaVrstica,1); //izpis druge vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($tretjaVrstica, $brezHline); //izpis tretje vrstice
+
+ //VRSTICE S PODATKI - priprava in izpis podatkov
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ $podatkiVrstica = array();
+ $podatkiVrstica[]=$this->encodeText($forSpremenljivka['options'][$fkey]);
+
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ if ($variable['other'] != 1) {
+ $sequence = $variable['sequence'];
+ $podatkiVrstica[]=$this->formatNumber($means[$fkey][$sequence]);
+ $totalMeans[$sequence] += ($this->breakClass->getMeansFromKey($fkeyFrequency[$sequence])*(int)$frequencys[$fkey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$frequencys[$fkey][$sequence]['validCnt'];
+ }
+ }
+ }
+
+ $tabela .= $this->tableRow($podatkiVrstica, $brezHline); //izpis vrstice s podatki
+ }
+ //VRSTICE S PODATKI - priprava in izpis podatkov - konec
+
+ // dodamo še skupno sumo in povprečje
+ $sumaVrstica = array();
+ $sumaVrstica[]=$this->encodeText($lang['srv_analiza_crosstab_skupaj']);
+
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ foreach ($grid['variables'] AS $vkey => $variable) {
+
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0;
+ $sumaVrstica[]=$this->formatNumber($totalMean ,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ }
+ }
+ }
+
+ $tabela .= $this->tableRow($sumaVrstica, $brezHline); //izpis vrstice s sumo
+
+ //Izpis vrstic tabele - konec
+
+ /*zakljucek latex tabele*/
+ $tabela .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ }
+
+ else {
+ $rowspan = 3;
+ $colspan = count($spremenljivka['grids'][0]['variables']);
+ $steviloPodstolpcev = $colspan;
+ $singleWidth = floor(200 / $colspan);
+ # za multinumber razdelimo na grupe - skupine
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ //izpis opisnega besedila pred tabelo
+ $tabela .= $this->encodeText('Tabela za: '.$spremenljivka['naslov'].' ('.$spremenljivka['variable'].') = '.$grid['naslov'].' ('.$grid['variable'].')');
+ //$tabela .= $this->texNewLine;
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = $steviloPodstolpcev+1;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($this->export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($this->export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($this->export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ // PRVA VRSTICA
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($forSpremenljivka['naslov'].' ('.$forSpremenljivka['variable'].')');
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].') - '.$grid['naslov'].' ('.$grid['variable'].')').'}';
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).') - '.$grid['naslov'].' ('.$grid['variable'].')').'}';
+ if($this->export_format == 'pdf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).') - '.$grid['naslov'].' ('.$grid['variable'].')').'}';
+ }elseif($this->export_format == 'rtf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].') - '.$grid['naslov'].' ('.$grid['variable'].')').'}';
+ }
+
+ // DRUGA VRSTICA
+ $drugaVrstica = array();
+ $drugaVrstica[]='';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $text = $this->encodeText($variable['naslov'].' ('.$variable['variable'].')');
+ $drugaVrstica[]=$text;
+ }
+
+ // TRETJA VRSTICA
+ $tretjaVrstica = array();
+ $tretjaVrstica[] = '';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $tretjaVrstica[] = $this->encodeText($lang['srv_analiza_crosstab_average']);
+ }
+
+ //Izpis vrstic tabele
+ $tabela .= $this->tableRow($prvaVrstica,1); //izpis prve vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($drugaVrstica,1); //izpis druge vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($tretjaVrstica, $brezHline); //izpis tretje vrstice
+
+ // VRSTICE Z VSEBINO
+ foreach ($forSpremenljivka['options'] AS $okey => $option) {
+ $podatkiVrstica = array();
+ $podatkiVrstica[]=$this->encodeText($option);
+ //$height = $this->getCellHeight($option, 60);
+ //$this->pdf->MultiCell(60, $height, $this->encodeText($option), 1, 'C', 0, 0, 0 ,0, true);
+
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ #povprečje
+ //$this->pdf->MultiCell($singleWidth, $height, self::formatNumber($means[$okey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''), 1, 'C', 0, 0, 0 ,0, true);
+ $podatkiVrstica[]=$this->formatNumber($means[$okey][$sequence],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+
+ $totalMeans[$sequence] += ($means[$okey][$sequence]*(int)$frequencys[$okey][$sequence]['validCnt']);
+ $totalFreq[$sequence]+= (int)$frequencys[$okey][$sequence]['validCnt'];
+ }
+
+ $tabela .= $this->tableRow($podatkiVrstica, $brezHline); //izpis vrstice s podatki
+ }
+
+ // dodamo še skupno sumo in povprečje
+ $sumaVrstica = array();
+ $sumaVrstica[]=$this->encodeText($lang['srv_analiza_crosstab_skupaj']);
+
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($variable['other'] != 1) {
+ #povprečja
+ $totalMean = $totalFreq[$sequence] > 0 ? $totalMeans[$sequence] / $totalFreq[$sequence] : 0;
+ $sumaVrstica[]=$this->formatNumber($totalMean ,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+
+ }
+ }
+ $tabela .= $this->tableRow($sumaVrstica, $brezHline); //izpis vrstice s sumo
+
+ //Izpis vrstic tabele - konec
+
+ /*zakljucek latex tabele*/
+ $tabela .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ }
+ }
+ }
+ return $tabela;
+ }
+
+ function displayBreakTableText($forSpr=null,$frequencys=null,$spremenljivka=null, $creport=false, $ank_id=null, $export_format=null) {
+ global $lang;
+ $tabela = '';
+ $brezHline = $this->getBrezHline($this->export_format);
+ if($creport){
+ $breakClass = new SurveyBreak($ank_id);
+ $this->breakClass = $breakClass;
+ }
+ $keysCount = count($frequencys);
+ $sequences = explode('_',$spremenljivka['sequences']);
+ $forSpremenljivka = $this->breakClass->_HEADERS[$forSpr];
+ $tip = $spremenljivka['tip'];
+
+ # izračunamo povprečja za posamezne sekvence
+ $texts = array();
+ $forSequences = array();
+ foreach ($frequencys AS $fkey => $fkeyFrequency) {
+ foreach ($sequences AS $sequence) {
+ $texts[$fkey][$sequence] = $this->breakClass->getTextFromKey($fkeyFrequency[$sequence]);
+ }
+ }
+
+ $rowspan = 2;
+ $colspan = count($spremenljivka['grids'][0]['variables']);
+
+ $steviloPodstolpcev = $colspan;
+
+ $singleWidth = floor(200 / $colspan);
+
+
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+
+ //izpis opisnega besedila pred tabelo
+ $tabela .= $this->encodeText('Tabela za: '.$spremenljivka['naslov'].' ('.$spremenljivka['variable'].') = '.$grid['naslov'].' ('.$grid['variable'].')');
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = $steviloPodstolpcev+1;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($this->export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($this->export_format == 'pdf' ? 'C|' : 'c|');
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'X|' : 'l|');
+
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($this->export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($this->export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ // PRVA VRSTICA
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($forSpremenljivka['naslov'].' ('.$forSpremenljivka['variable'].')');
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].') - '.$grid['naslov'].' ('.$grid['variable'].')').'}';
+ //$prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).') - '.$this->snippet($grid['naslov']).' ('.$this->snippet($grid['variable']).')').'}';
+ if($this->export_format == 'pdf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{>{\hsize=\dimexpr '.($steviloPodstolpcev).'\hsize + '.($steviloPodstolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($this->snippet($spremenljivka['naslov']).' ('.$this->snippet($spremenljivka['variable']).') - '.$this->snippet($grid['naslov']).' ('.$this->snippet($grid['variable']).')').'}';
+ }elseif($this->export_format == 'rtf'){
+ $prvaVrstica[] = '\multicolumn{'.$steviloPodstolpcev.'}{c|}{'.$this->encodeText($spremenljivka['naslov'].' ('.$spremenljivka['variable'].') - '.$grid['naslov'].' ('.$grid['variable'].')').'}';
+ }
+
+ // DRUGA VRSTICA
+ $drugaVrstica = array();
+ $drugaVrstica[]='';
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $text = $this->encodeText($variable['naslov'].' ('.$variable['variable'].')');
+ $drugaVrstica[]=$text;
+ }
+
+ //Izpis vrstic tabele
+ $tabela .= $this->tableRow($prvaVrstica,1); //izpis prve vrstice
+ if($this->export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."}"; //izpis prekinjene horizontalne crte
+ }
+
+ $tabela .= $this->tableRow($drugaVrstica, $brezHline); //izpis druge vrstice
+
+
+ // VRSTICE Z VSEBINO
+ foreach ($forSpremenljivka['options'] AS $okey => $option) {
+ $podatkiVrstica = array();
+ $podatkiVrstica[]=$this->encodeText($option);
+
+ // Izrisemo vrstico
+ //$this->pdf->MultiCell(60, $height, $this->encodeText($option), 1, 'C', 0, 0, 0 ,0, true);
+ foreach ($grid['variables'] AS $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if (count($texts[$okey][$sequence]) > 0) {
+ $text = "";
+ foreach ($texts[$okey][$sequence] AS $ky => $units) {
+ //$text .= $units['text']."\n";
+ $text .= $units['text']."; ";
+ }
+ $text = substr($text,0,-2);
+ $podatkiVrstica[]=$this->encodeText($text);
+ //$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($text), 1, 'C', 0, 0, 0 ,0, true);
+ }
+ else{
+ //$this->pdf->MultiCell($singleWidth, $height, '', 1, 'C', 0, 0, 0 ,0, true);
+ $podatkiVrstica[]='';
+ }
+ }
+ $tabela .= $this->tableRow($podatkiVrstica, $brezHline); //izpis vrstice s podatki
+ }
+ //Izpis vrstic tabele - konec
+
+ /*zakljucek latex tabele*/
+ $tabela .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ }
+ return $tabela;
+ }
+
+ function displayCrosstabs($forSpr=null,$frequencys=null,$spremenljivka=null) {
+ global $lang;
+ $tabela = '';
+ //echo "funkcija displayCrosstabs </br>";
+ //print_r($spremenljivka['grids'] );
+ //ustvarimo crosstab objekt
+ $this->crosstabClass = new SurveyCrosstabs();
+ $this->crosstabClass->Init($this->anketa['id']);
+
+ $spr1 = $this->spr;
+ $seq1 = $this->seq;
+ $grd1 = 'undefined';
+
+ foreach ($this->breakClass->_HEADERS[$spr1]['grids'] AS $gid => $grid) {
+ foreach ($grid['variables'] AS $vkey => $vrednost) {
+ if ($vrednost['sequence'] == $seq1) {
+ $grd1 = $gid;
+ }
+ }
+ }
+
+ $spr2 = $spremenljivka['id'];
+ //echo "spremenljivka, ki jo gledam: ".$spremenljivka['tip']." </br>";
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (($spremenljivka['tip'] == 16 || $spremenljivka['tip'] == 6) && $this->break_charts != 1) {
+
+ $text = 'Tabela za: '.$spremenljivka['naslov'].' ('.$spremenljivka['variable'].') = '.$grid['naslov'];
+
+ if ($spremenljivka['tip'] != 6) {
+ $text .= ' ('.$grid['variable'].')';
+ }
+ $tabela .= $this->encodeText($text);
+ }
+
+ $seq2 = $grid['variables'][0]['sequence'];
+ $grd2 = $gid;
+
+ $this->crosstabClass->setVariables($seq2,$spr2,$grd2,$seq1,$spr1,$grd1);
+
+ if($this->break_charts == 1){
+ $this->crosstabClass->fromBreak = false;
+ $tabela .= $this->displayChart($forSpr,$frequencys,$spremenljivka,$type = 'crosstab');
+ }
+ else{
+ $tabela .= $this->displayCrosstabsTable();
+ }
+ }
+ return $tabela;
+ }
+
+
+ function displayCrosstabsTable() {
+ global $lang;
+ $tabela = '';
+ $crosstab = new AnalizaCrosstab($this->anketa);
+ $tabela .= $crosstab->showCrosstabsTable($this->crosstabClass, $this->export_format);
+ return $tabela;
+ }
+
+ function displayChart($forSpr=null,$frequencys=null,$spremenljivka=null,$type=null){
+ global $lang;
+ $texImg = '';
+ // Zgeneriramo id vsake tabele (glede na izbrani spremenljivki za generiranje)
+ if($type == 'crosstab'){
+ $chartID = implode('_', $this->crosstabClass->variabla1[0]);
+ $chartID .= '_'.$this->crosstabClass->variabla2[0]['seq'].'_'.$this->crosstabClass->variabla2[0]['spr'].'_undefined';
+ $chartID .= '_counter_0'/*.$this->crosstabClass->counter*/;
+
+ $settings = $this->sessionData['crosstab_charts'][$chartID];
+ }
+ else{
+ if($spremenljivka['tip'] == 20){
+ // Preberemo za kateri grid izrisujemo tabelo
+ $gkey = $spremenljivka['break_sub_table']['key'];
+
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $spremenljivka['grids'][$gkey]['variables'][0]['sequence'].'-'.$spremenljivka['id'].'-undefined';
+ }
+ else{
+ $spr1 = $this->sessionData['break']['seq'].'-'. $this->sessionData['break']['spr'].'-undefined';
+ $spr2 = $spremenljivka['grids'][0]['variables'][0]['sequence'].'-'.$spremenljivka['id'].'-undefined';
+ }
+
+ $chartID = $spr1.'_'.$spr2;
+
+ $settings = $this->sessionData['break_charts'][$chartID];
+ }
+
+ $imgName = $settings['name'];
+ if($imgName){
+ copy('pChart/Cache/'.$imgName,'pChart/Cache/'.$imgName.'.png');
+ }
+
+ // Naslov posameznega grafa
+ $title = $spremenljivka['naslov'] . ' ('.$spremenljivka['variable'].')';
+ if($spremenljivka['tip'] == 20){
+ $grid = $spremenljivka['grids'][$gkey];
+ $subtitle = $grid['naslov'] . ' ('.$grid['variable'].')';
+ }
+ elseif($spremenljivka['tip'] == 16 || $spremenljivka['tip'] == 6){
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if($this->crosstabClass->variabla1[0]['seq'] == $grid['variables'][0]['sequence']){
+ $subtitle = $grid['naslov'];
+ if ($spremenljivka['tip'] != 6) {
+ $subtitle .= ' ('.$grid['variable'].')';
+ }
+ break;
+ }
+ }
+ }
+
+ $boldedTitle = $this->returnBold($this->encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+ $boldedSubTitle = '';
+ if($spremenljivka['tip'] == 20 || $spremenljivka['tip'] == 16 || $spremenljivka['tip'] == 6){
+ $boldedSubTitle = $this->returnBold($this->encodeText($subtitle)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+ }
+
+ if($imgName){
+ $texImageOnly = " \\includegraphics[scale=0.75]{".$imgName."} "; //latex za sliko
+ }else{
+ $texImageOnly = $lang['srv_export_no_chart'];
+ }
+
+ $texImage .= $this->returnCentered($boldedTitle.$boldedSubTitle.$texImageOnly); //vrni sredinsko poravnana naslov in slika
+
+ return $texImage;
+ }
+
+
+ /*
+ prikazemo posamezno celico s podatki
+ $data - vsebina (array)
+ $width - sirina celice
+ $numRows - stevilo vrstic (1, 2 ali 3)
+ frekvence - da ali ne
+ $numColumnPercent - stevilo stolpcev pri procentih (1, 2 ali 3)
+ $numColumnResidual - stevilo stolpcev pri procentih (1, 2, 3 ali 4)
+ */
+ function displayCell($data=null, $width=null, $numRows=null, $frekvence=null, $numColumnPercent=null, $numColumnResidual=null){
+
+ $height = ($numRows == 1 ? 8 : 5);
+ $fullHeight = ($height == 8 ? $height : $numRows*$height);
+ $i=0;
+
+ //preberemo pozicijo - zacetek celice
+ $y = $this->pdf->GetY();
+ $x = $this->pdf->GetX();
+
+ $this->pdf->setDrawColor(170, 170, 170);
+
+ //izrisemo frekvence
+ if($frekvence == 1){
+ $this->pdf->MultiCell($width, $height, $this->encodeText($data[$i]), 1, 'C', 0, 1, 0 ,0, true);
+ $i++;
+ }
+
+ if($numColumnPercent > 0){
+
+ $this->pdf->setX($x);
+ $singleWidth = round($width/$numColumnPercent);
+
+ for($j=1; $j<$numColumnPercent; $j++){
+ $this->pdf->MultiCell($singleWidth, $height, $this->encodeText($data[$i]), 1, 'C', 0, 0, 0 ,0, true);
+ $i++;
+ }
+ $this->pdf->MultiCell($width - (($numColumnPercent-1)*$singleWidth), $height, $this->encodeText($data[$i]), 1, 'C', 0, 1, 0 ,0, true);
+ $i++;
+ }
+
+ if($numColumnResidual > 0){
+
+ $this->pdf->setX($x);
+ $singleWidth = round($width/$numColumnResidual);
+
+ for($j=1; $j<$numColumnResidual; $j++){
+ $this->pdf->MultiCell($singleWidth, $height, $this->encodeText($data[$i]), 1, 'C', 0, 0, 0 ,0, true);
+ $i++;
+ }
+ $this->pdf->MultiCell($width - (($numColumnResidual-1)*$singleWidth), $height, $this->encodeText($data[$i]), 1, 'C', 0, 1, 0 ,0, true);
+ $i++;
+ }
+
+ //zaradi preglednosti narisemo okvir celotne celice
+ $this->pdf->setDrawColor(0, 0, 0, 255);
+ $this->pdf->SetXY($x, $y);
+ $this->pdf->MultiCell($width, $fullHeight, '', 1, 'C', 0, 1, 0 ,0, true);
+
+ //na koncu nastavimo pozicijo na pravo mesto
+ $this->pdf->SetXY($x+$width, $y);
+ }
+
+
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text=null,$length=64,$tail="...")
+ {
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function drawLine()
+ {
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+/* function formatNumber($value,$digit=0,$sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ } */
+
+ function getCellHeight($string=null, $width=null){
+
+ $this->pdf->startTransaction();
+ // get the number of lines calling you method
+ $linecount = $this->pdf->MultiCell($width, 0, $string, 0, 'L', 0, 0, '', '', true, 0, false, true, 0);
+ // restore previous object
+ $this->pdf = $this->pdf->rollbackTransaction();
+
+ $height = ($linecount <= 1) ? 4.7 : $linecount * ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio()) + 2;
+
+ return $height;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaCReport.php b/admin/survey/export/latexclasses/Analize/AnalizaCReport.php
new file mode 100644
index 0000000..03291c7
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaCReport.php
@@ -0,0 +1,1337 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+
+/** Class za generacijo pdf-a
+ *
+ * @desc: po novem je potrebno form elemente generirati ro�no kot slike
+ *
+ */
+class AnalizaCReport extends LatexAnalysisElement{
+
+ protected $ank_id; // trenuten id ankete
+ protected $ank; //trenutna anketa
+ protected $usr_id; // user
+
+ protected $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ protected $pdf;
+ protected $currentStyle;
+ protected $db_table = '';
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ protected $dataFileStatus = null; # status data datoteke
+ private $CID = null; # class za inkrementalno dodajanje fajlov
+
+ public $crosstabVars = array();
+ public $meanData1;
+ public $meanData2;
+
+ protected $creportProfile = 0; // Izbran profil porocila
+
+ protected $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ protected $export_format;
+
+ protected $texNewLine = '\\\\ ';
+ protected $horizontalLineTex = "\\hline ";
+
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $export_format='')
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa['id']) ){
+ $this->ank_id = $anketa['id'];
+ $this->ank = $anketa;
+ $this->export_format = $export_format;
+
+
+ // Nastavimo pravi profil porocila
+ $this->creportProfile = SurveyUserSetting :: getInstance()->getSettings('default_creport_profile');
+ $this->creportProfile = isset($this->creportProfile) ? $this->creportProfile : 0;
+
+ // Testiramo kako je obrnjen dokument (ce vsebuje crosstabe, means ali ttest je lanscape)
+ $orientation = ($this->landscapeTest()) ? 'L' : 'P';
+
+ // TODO: Če jih bomo mogoče potrebovali
+ //SurveyConditionProfiles :: Init($this->ank_id, $global_user_id);
+ //SurveyTimeProfiles :: Init($this->ank_id, $global_user_id);
+ //SurveyDataSettingProfiles :: Init($this->ank_id);
+
+
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->ank_id);
+ $this->sessionData = SurveyUserSession::getData();
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+ $_GET['a'] = A_ANALYSIS;
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->ank_id) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->ank_id) )
+ {
+ $this->usr_id = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->ank_id, $this->usr_id);
+ }
+ else
+ return false;
+
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+
+ public function getDataFileStatus() {
+ return $this->dataFileStatus;
+ }
+
+ public function getCreportProfile() {
+ return $this->creportProfile;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+
+
+ // Izpisemo sumarnik element
+ function displaySum($element=null){
+ $sumLatex = '';
+ $spid = $element['spr1'];
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm')
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ && (($global_user_id === 0 || $global_user_id === null) || in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ) )) {
+
+ # ali imamo sfiltrirano spremenljivko
+ //if (isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid])) {
+
+ //pdfIzvozAnalizaFunctions::init($this->ank_id, $this, $from='sums');
+ $sums = new AnalizaSums($this->ank);
+
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1:
+ # radio - prikaže navpično
+ //pdfIzvozAnalizaFunctions::sumVertical($spid,'sums');
+ $sumLatex .= $sums->sumVertical($spid, 'sums', $this->export_format);
+ break;
+
+ case 2:
+ #checkbox če je dihotomna:
+ //pdfIzvozAnalizaFunctions::sumVerticalCheckbox($spid,'sums');
+ $sumLatex .= $sums->sumVerticalCheckbox($spid, 'sums', $this->export_format);
+ break;
+
+ case 3:
+ # dropdown - prikjaže navpično
+ //pdfIzvozAnalizaFunctions::sumVertical($spid,'sums');
+ $sumLatex .= $sums->sumVertical($spid, 'sums', $this->export_format);
+ break;
+
+ case 6:
+ # multigrid
+ //pdfIzvozAnalizaFunctions::sumHorizontal($spid,'sums');
+ $sumLatex .= $sums->sumHorizontal($spid, 'sums', $this->export_format);
+ break;
+
+ case 16:
+ #multicheckbox če je dihotomna:
+ //pdfIzvozAnalizaFunctions::sumMultiHorizontalCheckbox($spid,'sums');
+ $sumLatex .= $sums->sumMultiHorizontalCheckbox($spid, 'sums', $this->export_format);
+ break;
+
+ case 17:
+ #razvrščanje če je ordinalna
+ //pdfIzvozAnalizaFunctions::sumHorizontal($spid,'sums');
+ $sumLatex .= $sums->sumHorizontal($spid, 'sums', $this->export_format);
+ break;
+
+ case 4: # text
+ case 8: # datum
+ //pdfIzvozAnalizaFunctions::sumTextVertical($spid,'sums');
+ $sumLatex .= $sums->sumTextVertical($spid, 'sums', $this->export_format);
+ break;
+
+ case 21: # besedilo*
+ # varabla tipa »besedilo« je v sumarniku IDENTIČNA kot v FREKVENCAH.
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ //pdfIzvozAnalizaFunctions::sumTextVertical($spid,'sums');
+ $sumLatex .= $sums->sumTextVertical($spid, 'sums', $this->export_format);
+ } else {
+ //pdfIzvozAnalizaFunctions::sumMultiText($spid,'sums');
+ $sumLatex .= $sums->sumMultiText($spid, 'sums', $this->export_format);
+ }
+ break;
+
+ case 19: # multitext
+ //pdfIzvozAnalizaFunctions::sumMultiText($spid,'sums');
+ $sumLatex .= $sums->sumMultiText($spid, 'sums', $this->export_format);
+ break;
+
+ case 7:
+ case 18:
+ case 22:
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ //pdfIzvozAnalizaFunctions::sumNumberVertical($spid,'sums');
+ $sumLatex .= $sums->sumNumberVertical($spid, 'sums', $this->export_format);
+ break;
+
+ case 20:
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ //pdfIzvozAnalizaFunctions::sumMultiNumber($spid,'sums');
+ $sumLatex .= $sums->sumMultiNumber($spid, 'sums', $this->export_format);
+ break;
+
+ case 5:
+ # nagovor
+ //pdfIzvozAnalizaFunctions::sumNagovor($spid,'sums');
+ $sumLatex .= $sums->sumNagovor($spid, 'sums', $this->export_format);
+ break;
+ }
+
+ //}
+
+ } // end if $spremenljivka['tip'] != 'm'
+ return $sumLatex;
+ }
+
+ // Izpisemo frekvence element
+ function displayFreq($element=null){
+ $freqLatex = '';
+ $spid = $element['spr1'];
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm')
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ && (($global_user_id === 0 || $global_user_id === null) || in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ) )) {
+
+ # ali imamo sfiltrirano spremenljivko
+ //if (isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid])) {
+
+ //pdfIzvozAnalizaFunctions::init($this->ank_id, $this, $from='freq');
+
+ # prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ case 2: #checkbox če je dihotomna:
+ case 3: # dropdown - prikjaže navpično
+ case 6: # multigrid
+ case 4: # text
+ case 7:# variabla tipa »število«
+ case 8: # datum
+ case 16: #multicheckbox če je dihotomna:
+ case 17: #razvrščanje če je ordinalna
+ case 18: # vsota
+ case 19: # multitext
+ case 20: # multi number
+ case 21: # besedilo*
+ case 22: # kalkulacija
+ $freq = new AnalizaFreq($this->ank);
+ $freqLatex .= $freq->frequencyVertical($spid, $this->export_format);
+ break;
+ case 5:
+ # nagovor
+ $sums = new AnalizaSums($this->ank);
+ $freqLatex .= $sums->sumNagovor($spid, 'sums', $this->export_format);
+ break;
+ }
+ //}
+
+ } // end if $spremenljivka['tip'] != 'm'
+ return $freqLatex;
+ }
+
+ // Izpisemo opisne stat element
+ function displayDesc($element=null){
+ global $lang;
+ $descLatex = '';
+
+ # polovimo frekvence
+ SurveyAnalysis::getDescriptives();
+
+ $spid = $element['spr1'];
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 8;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($this->export_format == 'pdf' ? 'P|' : 'l|');
+ }else{
+ $parameterTabular .= ($this->export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $descLatex .= $this->StartLatexTable($this->export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($this->export_format != 'xls'){
+ $descLatex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*prva vrstica tabele*/
+
+ /*priprava polja z naslovi stolpcev*/
+ $text = array();
+
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_variable']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_variable_text1']);
+
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_m']);
+ $text[] = $this->encodeText($lang['srv_analiza_num_units']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_povprecje1']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_odklon']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_min']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_max']);
+ /*priprava polja z naslovi stolpcev - konec*/
+
+ $descLatex .= $this->tableRow($text);
+ /*prva vrstica tabele - konec*/
+
+
+ /* preverjamo ali je meta*/
+ if ($spremenljivka['tip'] != 'm'
+ && ( count(SurveyAnalysis::$_FILTRED_VARIABLES) == 0 || (count(SurveyAnalysis::$_FILTRED_VARIABLES) > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ))
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES)
+ && ($this->spremenljivka == $spid || $this->spremenljivka == null) ) {
+
+ $show_enota = false;
+ /* preverimo ali imamo samo eno variablo in če iammo enoto*/
+ if ((int)$spremenljivka['enota'] != 0 || $spremenljivka['cnt_all'] > 1 ) {
+ $show_enota = true;
+ }
+
+ /* izpišemo glavno vrstico z podatki*/
+ $_sequence = null;
+ /* za enodimenzijske tipe izpišemo podatke kar v osnovni vrstici*/
+ if (!$show_enota) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $descLatex .= $this->displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ } else {
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $show_enota = false;
+ }
+ $descLatex .= $this->displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ /*zloopamo skozi variable*/
+ $_sequence = null;
+ $grd_cnt=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ if (count($spremenljivka['grids']) > 1 && $grd_cnt !== 0 && $spremenljivka['tip'] != 6) {
+ $grid['new_grid'] = true;
+ }
+ $grd_cnt++;
+ /* dodamo dodatne vrstice z albelami grida*/
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ /* dodamo ostale vrstice*/
+ $do_show = ($variable['other'] !=1 && ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3 || $spremenljivka['tip'] == 5 || $spremenljivka['tip'] == 8 ))
+ ? false
+ : true;
+ if ($do_show) {
+ $descLatex .= $this->displayDescriptivesVariablaRow($spremenljivka,$grid,$variable,$_css);
+
+ }
+ $grid['new_grid'] = false;
+ }
+ }
+ } //else: if (!$show_enota)
+ } // end if $spremenljivka['tip'] != 'm'
+
+ /*zakljucek latex tabele*/
+ $descLatex .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ //echo "</br> Tex celotne tabele: ".$descLatex."</br>";
+ return $descLatex;
+ }
+
+ // Izpisemo graf element
+ function displayChart($element=null){
+
+ $chart = '';
+ $spid = $element['spr1'];
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))) {
+ # ali imamo sfiltrirano spremenljivko
+ //if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ) ) {
+
+ //$this->pdf->SetFillColor(250, 250, 250);
+
+ // Ce imamo radio tip in manj kot 5 variabel po defaultu prikazemo piechart
+ $vars = count($spremenljivka['options']);
+ $type = 0;
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $vars < 5 )
+ $type = 2;
+
+ //ce imamo nominalno spremenljivko ali ce je samo 1 variabla nimamo povprecij
+ if($spremenljivka['tip'] == 6 && ($spremenljivka['cnt_all'] == 1 || $spremenljivka['skala'] == 1) && $type == 0 )
+ $type = 2;
+
+ //pdfIzvozAnalizaFunctions::init($this->ank_id, $this, $from='charts');
+
+ if($spremenljivka['tip'] == 4 || $spremenljivka['tip'] == 19 || $spremenljivka['tip'] == 21 || $spremenljivka['tip'] == 22){
+ // ce imamo vklopljeno nastavitev prikaz tabel med grafi (default)
+/* if($spremenljivka['tip'] == 19)
+ //pdfIzvozAnalizaFunctions::sumMultiText($spid, 'sums');
+ else
+ //pdfIzvozAnalizaFunctions::frequencyVertical($spid); */
+ }
+ elseif( in_array($spremenljivka['tip'],array(1,2,3,6,7,8,16,17,18,20)) ){
+ // Prikazemo posamezen graf
+ //pdfIzvozAnalizaFunctions::displayChart($spid, $type);
+ $chart .= $this->displayChartsInLatex($spid, $type, $fromCharts=false, $this->ank, $from='charts', $this, $this->export_format);
+
+ }
+ //}
+
+ } // end if $spremenljivka['tip'] != 'm'
+ return $chart;
+ }
+
+ // Izpisemo crosstab tabelo
+ function displayCrosstab($element=null){
+ global $lang;
+ $crosstabTex = '';
+ // Napolnimo podatke crosstabu
+ $crossData1 = explode("-", $element['spr1']);
+ $crossData2 = explode("-", $element['spr2']);
+
+ $crosstabClass = new SurveyCrosstabs();
+ $crosstabClass->Init($this->ank_id);
+ $crosstabClass->setVariables($crossData1[0],$crossData1[1],$crossData1[2],$crossData2[0],$crossData2[1],$crossData2[2]);
+
+ $crosstab = new AnalizaCrosstab($this->ank);
+ $crosstabTex .= $crosstab->showCrosstabsTable($crosstabClass, $this->export_format, $creport=true);
+
+ return $crosstabTex;
+ }
+
+ // Izpisemo crosstab graf
+ function displayCrosstabChart($element=null){
+
+ $crosstabChartTex = '';
+ // Napolnimo podatke crosstabu
+ //$crossData1 = explode("-", $element['spr2']);
+ $crossData1 = explode("-", $element['spr1']);
+ //$crossData2 = explode("-", $element['spr1']);
+ $crossData2 = explode("-", $element['spr2']);
+
+ //ustvarimo crosstab objekt in mu napolnimo variable (var1, var2, checkboxi)
+ $this->crosstabClass = new SurveyCrosstabs();
+ $this->crosstabClass->Init($this->ank_id);
+
+
+ for($i=0; $i<sizeof($crossData1)/3; $i++){
+ $index = $i * 3;
+ $this->crossData1[$i] = array($crossData1[$index],$crossData1[$index+1],$crossData1[$index+2]);
+ }
+ for($i=0; $i<sizeof($crossData2)/3; $i++){
+ $index = $i * 3;
+ $this->crossData2[$i] = array($crossData2[$index],$crossData2[$index+1],$crossData2[$index+2]);
+ }
+
+ $this->crosstabClass->_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ if (count($this->crosstabClass->_LOOPS) > 0) {
+ # če mamo zanke
+ foreach ( $this->crosstabClass->_LOOPS AS $loop) {
+ $this->crosstabClass->_CURRENT_LOOP = $loop;
+ }
+ } else {
+ // loopamo cez vse izbrane variable in izrisemo vse tabele
+ $this->counter = 0;
+ for($j=0; $j<sizeof($this->crossData2); $j++){
+ for($i=0; $i<sizeof($this->crossData1); $i++){
+ $this->crosstabClass->setVariables($this->crossData2[$j][0],$this->crossData2[$j][1],$this->crossData2[$j][2],$this->crossData1[$i][0],$this->crossData1[$i][1],$this->crossData1[$i][2]);
+ //$this->counter++;
+ }
+ }
+ }
+
+ $crossTabChart = new AnalizaCrosstab($this->ank, $this->crosstabClass, $this->counter);
+
+ $crosstabChartTex .= $crossTabChart->displayCrosstabChart();
+
+ return $crosstabChartTex;
+ }
+
+ // Izpisemo mean tabelo
+ function displayMean($element=null){
+ $meanTex = '';
+ // ustvarimo means objekt
+ $meansClass = new SurveyMeans($this->ank_id);
+
+ // Napolnimo podatke crosstabu
+ $meanData1 = explode("-", $element['spr2']);
+ $meanData2 = explode("-", $element['spr1']);
+
+ $v_first = array('seq' => $meanData1[0], 'spr' => $meanData1[1], 'grd' => $meanData1[2]);
+ $v_second = array('seq' => $meanData2[0], 'spr' => $meanData2[1], 'grd' => $meanData2[2]);
+
+ $_means[0] = $meansClass->createMeans($v_first, $v_second);
+
+ $mean = new AnalizaMean($this->ank);
+
+ $meanTex .= $mean->displayMeansTable($_means, $meansClass, $this->export_format);
+
+ return $meanTex;
+ }
+
+ // Izpisemo mean graf
+ function displayMeanChart($element=null){
+ $meanChartTex = '';
+ // ustvarimo means objekt
+ $meansClass = new SurveyMeans($this->ank_id);
+
+ // Napolnimo podatke crosstabu
+ $meanData1 = explode("-", $element['spr2']);
+ $meanData2 = explode("-", $element['spr1']);
+
+ $v_first = array('seq' => $meanData1[0], 'spr' => $meanData1[1], 'grd' => $meanData1[2]);
+ $v_second = array('seq' => $meanData2[0], 'spr' => $meanData2[1], 'grd' => $meanData2[2]);
+
+ $this->meanData2[0] = $v_first;
+ $this->meanData1[0] = $v_second;
+
+ $_means[0] = $meansClass->createMeans($v_first, $v_second);
+
+ $mean = new AnalizaMean($this->ank);
+ $meanChartTex .= $mean->displayChart(0, $this->meanData1, $this->meanData2, $this->sessionData);
+
+ return $meanChartTex;
+
+ }
+
+ // Izpisemo ttest tabelo
+ function displayTTest($element=null){
+ $tTestTex = '';
+ // ustvarimo ttest objekt
+ $ttestClass = new SurveyTTest($this->ank_id);
+
+ // Nastavimo session da lahko pravilno izrisemo tabelo/graf
+ $ttestData1 = explode("-", $element['spr1']);
+ $ttestData2 = explode("-", $element['spr2']);
+
+ $dataArray = array();
+
+ $dataArray['spr2'] = $ttestData1[1];
+ $dataArray['grid2'] = $ttestData1[2];
+ $dataArray['seq2'] = $ttestData1[0];
+ $dataArray['label2'] = strip_tags($this->getTTestLabel($element['spr1'], $ttestClass));
+
+ $dataArray['sub_conditions'][0] = $ttestData1[3];
+ $dataArray['sub_conditions'][1] = $ttestData1[4];
+
+ $dataArray['variabla'][0]['seq'] = $ttestData2[0];
+ $dataArray['variabla'][0]['spr'] = $ttestData2[1];
+ $dataArray['variabla'][0]['grd'] = $ttestData2[2];
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::Init($this->ank_id);
+ $sessionData = SurveyUserSession::getData('ttest');
+ $sessionData = $dataArray;
+ SurveyUserSession::saveData($sessionData, 'ttest');
+ //print_r($sessionData);
+ // ustvarimo ttest objekt
+ $ttestClass = new SurveyTTest($this->ank_id);
+
+ if (count($this->sessionData['ttest']['sub_conditions']) > 1 ) {
+ $tTest = new AnalizaTTest($this->ank);
+ $variables1 = $ttestClass->getSelectedVariables();
+ if (count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $ttest = null;
+ $ttest = $ttestClass->createTTest($v_first, $this->sessionData['ttest']['sub_conditions']);
+ $tTestTex .= $tTest->displayTTestTable($ttest, $ttestClass, $this->export_format, $this->sessionData);
+ }
+ }
+ }
+
+ return $tTestTex;
+ }
+
+ // Izpisemo ttest graf
+ function displayTTestChart($element=null){
+ $tTestChartTex = '';
+
+ // ustvarimo ttest objekt
+ $ttestClass = new SurveyTTest($this->ank_id);
+
+ // Nastavimo session da lahko pravilno izrisemo tabelo/graf
+ $ttestData1 = explode("-", $element['spr1']);
+ $ttestData2 = explode("-", $element['spr2']);
+
+ $dataArray = array();
+
+ $dataArray['spr2'] = $ttestData1[1];
+ $dataArray['grid2'] = $ttestData1[2];
+ $dataArray['seq2'] = $ttestData1[0];
+ $dataArray['label2'] = strip_tags($this->getTTestLabel($element['spr1'], $ttestClass));
+
+ $dataArray['sub_conditions'][0] = $ttestData1[3];
+ $dataArray['sub_conditions'][1] = $ttestData1[4];
+
+ $dataArray['variabla'][0]['seq'] = $ttestData2[0];
+ $dataArray['variabla'][0]['spr'] = $ttestData2[1];
+ $dataArray['variabla'][0]['grd'] = $ttestData2[2];
+
+ // Shranimo spremenjene nastavitve v bazo
+ SurveyUserSession::Init($this->ank_id);
+ $sessionData = SurveyUserSession::getData('ttest');
+ $sessionData = $dataArray;
+ SurveyUserSession::saveData($sessionData, 'ttest');
+
+ // ustvarimo ttest objekt
+ $ttestClass = new SurveyTTest($this->ank_id);
+
+ if (count($this->sessionData['ttest']['sub_conditions']) > 1 ) {
+ $tTest = new AnalizaTTest($this->ank);
+ $variables1 = $ttestClass->getSelectedVariables();
+ if (count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $tTestChartTex .= $tTest->displayChart($this->sessionData, $ttestClass, $this->ank, $creport=true);
+ }
+ }
+ }
+ return $tTestChartTex;
+ }
+
+ // Izpisemo break tabelo
+ function displayBreak($element=null){
+ global $lang;
+ $breakTex = '';
+
+ // Napolnimo podatke breaku
+ $breakData1 = explode("-", $element['spr1']);
+ $breakData2 = explode("-", $element['spr2']);
+
+ $breakClass = new SurveyBreak($this->ank_id);
+
+ $forSpr = $breakData1[1];
+ $_spr_data = $breakClass->_HEADERS[$forSpr];
+
+ # poiščemo sekvenco
+ $sekvenca = $breakData1[0];
+
+ # poiščemo opcije
+ $opcije = $_spr_data['options'];
+
+ if ((int)$_spr_data['tip'] != 2) {
+ $seqences[] = $sekvenca;
+ $options = $opcije;
+ } else {
+ # za checkboxe imamo več sekvenc
+ $seqences = explode('_',$_spr_data['sequences']);
+ $options[1] = $opcije[1];
+ }
+
+ # za vsako opcijo posebej izračunamo povprečja za vse spremenljivke
+ /*$frequencys = array();
+ if (count($seqences) > 0) {
+ foreach ($seqences as $seq) {
+
+ if (count($options) > 0) {
+ foreach ($options as $oKey => $option) {
+ # zloopamo skozi variable
+ $oKeyfrequencys = $breakClass->getAllFrequencys($oKey, $seq, $forSpr);
+ if ($oKeyfrequencys != null) {
+ $frequencys[$seq][$oKey] = $oKeyfrequencys;
+ }
+ }
+ }
+ }
+ }*/
+ $frequencys = null;
+ if (count($options) > 0) {
+ foreach ($options as $okey => $option) {
+
+ # zloopamo skozi variable
+ $okeyfrequencys = $breakClass->getAllFrequencys($okey, $sekvenca, $forSpr);
+ if ($okeyfrequencys != null) {
+ if ($frequencys == null) {
+ $frequencys = array();
+ }
+ $frequencys[$okey] = $okeyfrequencys;
+ }
+ }
+ }
+
+ $spremenljivka = $breakClass->_HEADERS[$breakData2[1]];
+ $spremenljivka['id'] = $breakData2[1];
+
+ $tip = $spremenljivka['tip'];
+ $skala = $spremenljivka['skala'];
+
+ // Izrisujemo tabelo ki ni crosstab
+ if( ($tip == 6 && $skala == 0) || in_array($tip, array(4,7,17,18,19,20,21)) ){
+ $break = new AnalizaBreak($this->ank);
+
+ if($tip == 6 && $skala == 0){
+ $breakTex .= $break->displayBreakTableMgrid($forSpr,$frequencys, $spremenljivka, $creport=true, $this->ank_id, $this->export_format);
+ }
+ elseif($tip == 4 || $tip == 19 || $tip == 21){
+ // Nastavimo se katero podtabelo izrisemo (sekvenca odvisne spr)
+ $spremenljivka['break_sub_table']['sequence'] = $breakData2[0];
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if($spremenljivka['break_sub_table']['sequence'] == $grid['variables'][0]['sequence']){
+ $spremenljivka['break_sub_table']['key'] = $gkey;
+ break;
+ }
+ }
+
+ $breakTex .= $break->displayBreakTableText($forSpr,$frequencys,$spremenljivka, $creport=true, $this->ank_id, $this->export_format);
+ }
+ else{
+ // Nastavimo se katero podtabelo izrisemo (sekvenca odvisne spr)
+ $spremenljivka['break_sub_table']['sequence'] = $breakData2[0];
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if($spremenljivka['break_sub_table']['sequence'] == $grid['variables'][0]['sequence']){
+ $spremenljivka['break_sub_table']['key'] = $gkey;
+ break;
+ }
+ }
+ $breakTex .= $break->displayBreakTableNumber($forSpr,$frequencys,$spremenljivka, $creport=true, $this->ank_id, $this->export_format);
+ }
+ }
+
+ // Izrisujemo crosstab
+ else{
+ $breakTex .= $this->displayCrosstab($element);
+ }
+ return $breakTex;
+ }
+
+ // Izpisemo break graf
+ function displayBreakChart($element=null){
+ $breakChartTex = '';
+ // Napolnimo podatke breaku
+ $breakData1 = explode("-", $element['spr1']);
+ $breakData2 = explode("-", $element['spr2']);
+
+ $breakClass = new SurveyBreak($this->ank_id);
+
+ $forSpr = $breakData1[1];
+ $_spr_data = $breakClass->_HEADERS[$forSpr];
+
+ # poiščemo sekvenco
+ $sekvenca = $breakData1[0];
+
+ # poiščemo opcije
+ $opcije = $_spr_data['options'];
+
+ if ((int)$_spr_data['tip'] != 2) {
+ $seqences[] = $sekvenca;
+ $options = $opcije;
+ } else {
+ # za checkboxe imamo več sekvenc
+ $seqences = explode('_',$_spr_data['sequences']);
+ $options[1] = $opcije[1];
+ }
+
+ $frequencys = null;
+ if (count($options) > 0) {
+ foreach ($options as $okey => $option) {
+
+ # zloopamo skozi variable
+ $okeyfrequencys = $breakClass->getAllFrequencys($okey, $sekvenca, $forSpr);
+ if ($okeyfrequencys != null) {
+ if ($frequencys == null) {
+ $frequencys = array();
+ }
+ $frequencys[$okey] = $okeyfrequencys;
+ }
+ }
+ }
+
+ $spremenljivka = $breakClass->_HEADERS[$breakData2[1]];
+ $spremenljivka['id'] = $breakData2[1];
+
+ $tip = $spremenljivka['tip'];
+ $skala = $spremenljivka['skala'];
+
+ $break = new AnalizaBreak($this->ank); //definiranje razreda AnalizaBreak
+
+ // Pri textovnih tipih vedno izrisemo tabelo
+ if($tip == 4 || $tip == 21 || $tip == 19){
+ // Nastavimo se katero podtabelo izrisemo (sekvenca odvisne spr)
+ $spremenljivka['break_sub_table']['sequence'] = $breakData2[0];
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if($spremenljivka['break_sub_table']['sequence'] == $grid['variables'][0]['sequence']){
+ $spremenljivka['break_sub_table']['key'] = $gkey;
+ break;
+ }
+ }
+
+ //pdfIzvozAnalizaFunctions::init($this->ank_id, $this, $from='break', $breakClass);
+ //pdfIzvozAnalizaFunctions::displayBreakTableText($forSpr,$frequencys,$spremenljivka);
+ $breakChartTex .= $break->displayBreakTableText($forSpr,$frequencys,$spremenljivka, $creport=true, $this->ank_id, $this->export_format);
+ }
+
+ // Izrisujemo graf ki ni crosstab
+ elseif( ($tip == 6 && $skala == 0) || in_array($tip, array(7,17,18,20)) ){
+
+ //pdfIzvozAnalizaFunctions::init($this->ank_id, $this, $from='break', $breakClass);
+
+ if($tip == 6 && $skala == 0){
+ //pdfIzvozAnalizaFunctions::displayBreakChart($forSpr,$frequencys,$spremenljivka);
+ $breakChartTex .= $break->displayChart($forSpr,$frequencys,$spremenljivka, $type='creport');
+ }
+ else{
+ // Nastavimo se katero podtabelo izrisemo (sekvenca odvisne spr)
+ $spremenljivka['break_sub_table']['sequence'] = $breakData2[0];
+ foreach ($spremenljivka['grids'] AS $gkey => $grid) {
+ if($spremenljivka['break_sub_table']['sequence'] == $grid['variables'][0]['sequence']){
+ $spremenljivka['break_sub_table']['key'] = $gkey;
+ break;
+ }
+ }
+ //pdfIzvozAnalizaFunctions::displayBreakChart($forSpr,$frequencys,$spremenljivka);
+ $breakChartTex .= $break->displayChart($forSpr,$frequencys,$spremenljivka, $type='creport');
+ }
+ }
+ // Izrisujemo crosstab
+ else{
+ $breakChartTex .= $this->displayCrosstabChart($element);
+ }
+
+ return $breakChartTex;
+ }
+
+ // Izpisemo element z besedilom
+ function displayText($text=''){
+ global $lang;
+ $texTitle = '';
+ $texTitle .= $this->encodeText($text).$this->texNewLine;
+ return $texTitle;
+ }
+
+
+ // Izpisemo naslov elementa
+ function displayTitle($element=null){
+ global $lang;
+ $texTitle = '';
+ // sumarnik
+ if($element['type'] == '1'){
+ $spr = SurveyAnalysis::$_HEADERS[$element['spr1']];
+
+ if($element['spr1'] == '')
+ $title = $lang['srv_select_spr'];
+ else
+ $title = $spr['variable'].' - '.$spr['naslov'];
+
+ $subtitle = ' ('.$lang['srv_sumarnik'].')';
+ }
+
+ // freq
+ elseif($element['type'] == '2'){
+ $spr = SurveyAnalysis::$_HEADERS[$element['spr1']];
+
+ if($element['spr1'] == '')
+ $title = $lang['srv_select_spr'];
+ else
+ $title = $spr['variable'].' - '.$spr['naslov'];
+
+ $subtitle = ' ('.$lang['srv_frequency'].')';
+ }
+
+ // desc
+ elseif($element['type'] == '3'){
+ $spr = SurveyAnalysis::$_HEADERS[$element['spr1']];
+
+ if($element['spr1'] == '')
+ $title = $lang['srv_select_spr'];
+ else
+ $title = $spr['variable'].' - '.$spr['naslov'];
+
+ $subtitle = ' ('.$lang['srv_descriptor'].')';
+ }
+
+ // chart
+ elseif($element['type'] == '4'){
+ $spr = SurveyAnalysis::$_HEADERS[$element['spr1']];
+
+ if($element['spr1'] == '')
+ $title = $lang['srv_select_spr'];
+ else
+ $title = $spr['variable'].' - '.$spr['naslov'];
+
+ $subtitle = ' ('.$lang['srv_chart'].')';
+ }
+
+ // crosstab
+ elseif($element['type'] == '5'){
+
+ // Napolnimo podatke crosstabu
+ $crossData1 = explode("-", $element['spr1']);
+ $crossData2 = explode("-", $element['spr2']);
+
+ $crosstabClass = new SurveyCrosstabs();
+ $crosstabClass->Init($this->ank_id);
+
+ $crosstabClass->setVariables($crossData1[0],$crossData1[1],$crossData1[2],$crossData2[0],$crossData2[1],$crossData2[2]);
+
+ // Naslov
+ if($element['spr1'] == '' || $element['spr2'] == '')
+ $title = $lang['srv_select_spr'];
+ else{
+ $show_variables_values = true;
+
+ $spr1 = $crosstabClass->_HEADERS[$crossData1[1]];
+ $spr2 = $crosstabClass->_HEADERS[$crossData2[1]];
+
+ # za multicheckboxe popravimo naslov, na podtip
+ $sub_q1 = null;
+ $sub_q2 = null;
+ if ($spr1['tip'] == '6' || $spr1['tip'] == '7' || $spr1['tip'] == '16' || $spr1['tip'] == '17' || $spr1['tip'] == '18' || $spr1['tip'] == '19' || $spr1['tip'] == '20' || $spr1['tip'] == '21' ) {
+ foreach ($spr1['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_first['seq']) {
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ if ($show_variables_values == true ) {
+ $sub_q1 .= ' ('.strip_tags($spr1['variable']).')';
+ }
+ if ($spr1['tip'] == '16') {
+ $sub_q1 .= '<br />'. strip_tags($grid1['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid1['variable']) . ')' : '');
+ } else {
+ $sub_q1 .= '<br />' . strip_tags($variable['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($variable['variable']) . ')' : '');
+ }
+ }
+ }
+ }
+ }
+ if ($sub_q1 == null) {
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ $sub_q1 .= ($show_variables_values == true ? '&nbsp;('.strip_tags($spr1['variable']).')' : '');
+ }
+ if ($spr2['tip'] == '6' || $spr2['tip'] == '7' || $spr2['tip'] == '16' || $spr2['tip'] == '17' || $spr2['tip'] == '18' || $spr2['tip'] == '19' || $spr2['tip'] == '20' || $spr2['tip'] == '21') {
+ foreach ($spr2['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_second['seq']) {
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ if ($show_variables_values == true) {
+ $sub_q2 .= ' ('.strip_tags($spr2['variable']).')';
+ }
+ if ($spr2['tip'] == '16') {
+ $sub_q2.= '<br />' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid2['variable']) . ')' : '');
+ } else {
+ $sub_q2.= '<br />' . strip_tags($variable['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($variable['variable']) . ')' : '');
+ }
+ }
+ }
+ }
+ }
+ if ($sub_q2 == null) {
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ $sub_q2 .= ($show_variables_values == true ? ' ('.strip_tags($spr2['variable']).')' : '');
+ }
+
+ $title = $sub_q1 . ' / ' . $sub_q2;
+ }
+
+ $subtitle = ' ('.$lang['srv_crosstabs']. ($element['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')';
+ }
+
+ // mean
+ elseif($element['type'] == '6'){
+
+ // ustvarimo means objekt
+ $meansClass = new SurveyMeans($this->ank_id);
+
+ // Napolnimo podatke crosstabu
+ $meanData1 = explode("-", $element['spr2']);
+ $meanData2 = explode("-", $element['spr1']);
+
+ $v_first = array('seq' => $meanData1[0], 'spr' => $meanData1[1], 'grd' => $meanData1[2]);
+ $v_second = array('seq' => $meanData2[0], 'spr' => $meanData2[1], 'grd' => $meanData2[2]);
+
+ $means[0] = $meansClass->createMeans($v_first, $v_second);
+
+ // Nastavimo variable (potrebno za grafe
+ $meansClass->variabla1[0] = $v_second;
+ $meansClass->variabla2[0] = $v_first;
+
+ // Naslov
+ if($element['spr1'] == '' || $element['spr2'] == ''){
+ $title = $lang['srv_select_spr'];
+ }
+ else{
+ $label2 = strip_tags($meansClass->getSpremenljivkaTitle($means[0]['v1']));
+ $label1 = strip_tags($meansClass->getSpremenljivkaTitle($means[0]['v2']));
+
+ $title = $label1 . ' / ' . $label2;
+ }
+
+ $subtitle = ' ('.$lang['srv_means']. ($element['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')';
+ }
+
+ // ttest
+ elseif($element['type'] == '7'){
+
+ // ustvarimo ttest objekt
+ $ttestClass = new SurveyTTest($this->ank_id);
+
+ // Naslov
+ if($element['spr1'] == '' || $element['spr2'] == ''){
+ $title = $lang['srv_select_spr'];
+ }
+ else{
+ $label2 = strip_tags($this->getTTestLabel($element['spr2'], $ttestClass));
+ $label1 = strip_tags($this->getTTestLabel($element['spr1'], $ttestClass));
+
+ $title = $label1 . ' / ' . $label2;
+ }
+
+ $subtitle = ' ('.$lang['srv_ttest']. ($element['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')';
+ }
+
+ // break
+ elseif($element['type'] == '9'){
+
+ // ustvarimo ttest objekt
+ $breakClass = new SurveyBreak($this->ank_id);
+
+ $breakData1 = explode("-", $element['spr1']);
+ $breakData2 = explode("-", $element['spr2']);
+
+
+ $label1 = '';
+ $variables = $breakClass->getVariableList(2);
+ foreach ($variables as $variable) {
+
+ if($breakData1[0] == $variable['sequence']){
+ $label1 = ( (int)$variable['sub'] == 0 ? '' : ( (int)$variable['sub'] == 1 ? '&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;' )) . $variable['variableNaslov'];
+ $label1 = (strlen($label1) > 60) ? substr($label1, 0, 57).'...' : $label1;
+
+ break;
+ }
+ }
+
+ $label2 = '';
+ $variables = $this->getBreakDependentVariableList($breakClass);
+ foreach ($variables as $variable) {
+
+ if($breakData2[0] == $variable['sequence']){
+ //$label2 = $variable['variableNaslov'];
+ $label2 = (strlen($variable['variableNaslov']) > 60) ? substr($variable['variableNaslov'], 0, 57).'...' : $variable['variableNaslov'];
+
+ break;
+ }
+ }
+
+ $title = $label1 . ' / ' . $label2;
+ $subtitle = '('.$lang['srv_break']. ($element['sub_type'] == 1 ? ' - '.$lang['srv_chart'] : '') .')';
+ }
+
+
+ //TODO: Potrebno je v LATEX določiti ali je stran obrnjena landscape
+ $width = $this->landscapeTest() ? 270 : 165;
+
+ $boldedTitle = $this->returnBold($this->encodeText($this->encodeText($title . $subtitle)));
+ $texTitle .= $this->returnCentered($boldedTitle);
+
+ return $texTitle;
+ }
+
+ function getTTestLabel($spr=null, $ttestClass=null){
+
+ $data = explode("-", $spr);
+
+ $spid = $data[1];
+ $seq = $data[0];
+ $grid = $data[2];
+
+ $spr_data = $ttestClass->_HEADERS[$spid];
+ if ($grid == 'undefined') {
+
+ # imamp lahko več variabel
+ foreach ($spr_data['grids'] as $gkey => $grid ) {
+
+ foreach ($grid['variables'] as $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($sequence == $seq) {
+ $sprLabel = '('.$variable['variable'].') '. $variable['naslov'];
+ }
+ }
+ }
+ } else {
+ # imamo subgrid
+ $sprLabel = '('.$spr_data['grids'][$grid]['variable'].') '. $spr_data['grids'][$grid]['naslov'];
+ }
+
+ return $sprLabel;
+ }
+
+ /** funkcija vrne seznam primern variabel za break
+ *
+ */
+ function getBreakDependentVariableList($breakClass=null) {
+
+ $variablesList = array();
+
+ # zloopamo skozi header in dodamo variable (potrebujemo posamezne sekvence)
+ foreach ($breakClass->_HEADERS AS $skey => $spremenljivka) {
+
+ $tip = $spremenljivka['tip'];
+
+ $_dropdown_condition = (is_numeric($tip) && $tip != 5 && $tip != 8 && $tip != 9) ? true : false;
+ if ($_dropdown_condition) {
+
+ $cnt_all = (int)$spremenljivka['cnt_all'];
+ if ( $cnt_all == '1' || in_array($tip, array(1,2,3,4,7,17,18,21,22)) || ($tip == 6 && $spremenljivka['enota'] == 2) ) {
+
+ # pri tipu radio ali select dodamo tisto variablo ki ni polje "drugo"
+ if ($tip == 1 || $tip == 3 ) {
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][$vid]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+
+ }
+ }
+ }
+ }
+ }
+
+ else {
+ # imampo samo eno sekvenco grids[0]variables[0]
+ $variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$spremenljivka['grids'][0]['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>0);
+ }
+ }
+ else if ($cnt_all > 1){
+ # imamo več skupin ali podskupin, zato zlopamo skozi gride in variable
+ if (count($spremenljivka['grids']) > 0 ) {
+ $variablesList[] = array(
+ 'tip'=>$tip,
+
+ 'variableNaslov'=>'('.$spremenljivka['variable'].')&nbsp;'.strip_tags($spremenljivka['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>0);
+ # ali imamo en grid, ali več (tabele
+ if (count($spremenljivka['grids']) == 1 ) {
+ # če imamo samo en grid ( lahko je več variabel zaradi polja drugo.
+ $grid = $spremenljivka['grids'][0];
+ if (count ($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+
+ } elseif($tip == 6) {
+ # imamo več gridov - tabele
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $variablesList[] = array(
+ 'tip'=>$tip,
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>false,
+ 'sub'=>$sub);
+ }
+ if (count ($grid['variables']) > 0) {
+ $sub++;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ if ($variable['other'] != 1) {
+ $variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'sequence'=>$variable['sequence'],
+ 'variableNaslov'=>'('.$variable['variable'].')&nbsp;'.strip_tags($variable['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>$sub);
+ }
+ }
+ }
+ }
+ } else {
+ foreach($spremenljivka['grids'] AS $gid => $grid) {
+ $sub = 0;
+ if ($grid['variable'] != '') {
+ $sub++;
+ $variablesList[] = array(
+ 'tip'=>$tip,
+ 'spr_id'=>$skey,
+ 'grd_id'=>$gid,
+ 'sequence'=>$grid['variables'][0]['sequence'],
+ 'variableNaslov'=>'('.$grid['variable'].')&nbsp;'.strip_tags($grid['naslov']),
+ 'canChoose'=>true,
+ 'sub'=>1);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $variablesList;
+ }
+
+
+ // Izpisemo komentar elementa
+ function displayComment($text=''){
+ global $lang;
+ $texTitle = '';
+
+ if($text != ''){
+ $texTitle .= $this->encodeText($text).$this->texNewLine;
+ }
+ return $texTitle;
+ }
+
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="...")
+ {
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function drawLine()
+ {
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+
+ // Ce imamo v porocilu tabelo crosstab ali ttest ali means imamo landscape orientacijo
+ function landscapeTest(){
+ global $global_user_id;
+
+ $sql = sisplet_query("SELECT * FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' AND profile='$this->creportProfile' AND sub_type='0' AND (type='5' OR type='6' OR type='7' OR type='9')");
+
+ if(mysqli_num_rows($sql) > 0)
+ return true;
+ else
+ return false;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaCharts.php b/admin/survey/export/latexclasses/Analize/AnalizaCharts.php
new file mode 100644
index 0000000..bd632fa
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaCharts.php
@@ -0,0 +1,293 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaSums.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFrekvenca.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+/**
+ * @desc Class za generacijo latex
+ */
+class AnalizaCharts extends LatexAnalysisElement {
+
+ var $anketa; // trenutna anketa
+ var $spremenljivka; // trenutna spremenljivka
+
+ var $headFileName = null; // pot do header fajla
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+
+ var $skin;
+ var $numbering;
+ var $frontpage;
+
+ var $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ var $current_loop = 'undefined';
+
+ protected $export_format;
+
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $export_format='', $sprID = null, $loop = null){
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa['id']) ){
+
+ $this->anketa = $anketa;
+ $this->spremenljivka = $sprID;
+ $this->export_format = $export_format;
+
+ SurveyChart::Init($this->anketa['id']);
+
+ // Poskrbimo za datoteko s podatki
+ $SDF = SurveyDataFile::get_instance();
+ $SDF->init($this->anketa['id']);
+ $SDF->prepareFiles();
+
+ $this->headFileName = $SDF->getHeaderFileName();
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData('charts');
+ }
+ else{
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) ){
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $global_user_id);
+
+ $this->skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
+ $this->numbering = SurveyDataSettingProfiles :: getSetting('chartNumbering');
+ $this->frontpage = SurveyDataSettingProfiles :: getSetting('chartFP');
+ }
+ else
+ return false;
+
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+ function displayCharts(){
+ global $site_path;
+ global $lang;
+
+ $chart = '';
+ #preberemo HEADERS iz datoteke
+ SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
+
+ # polovimo frekvence
+ SurveyAnalysis::getFrequencys();
+
+ #odstranimo sistemske variable
+ SurveyAnalysis::removeSystemVariables();
+
+ $vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+
+ foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
+ // preverjamo ali je meta
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ && ($this->spremenljivka == $spid || $this->spremenljivka == null) ) {
+
+ // ali imamo sfiltrirano spremenljivko
+ if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ) ) {
+
+ // Ce imamo radio tip in manj kot 5 variabel po defaultu prikazemo piechart
+ $vars = count($spremenljivka['options']);
+ $type = 0;
+ if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $vars < 5 )
+ $type = 2;
+
+ //ce imamo nominalno spremenljivko ali ce je samo 1 variabla nimamo povprecij
+ if($spremenljivka['tip'] == 6 && ($spremenljivka['cnt_all'] == 1 || $spremenljivka['skala'] == 1) && $type == 0 )
+ $type = 2;
+
+
+ if($spremenljivka['tip'] == 4 || $spremenljivka['tip'] == 19 || $spremenljivka['tip'] == 21 || $spremenljivka['tip'] == 22){
+
+ $hideEmpty = SurveyDataSettingProfiles :: getSetting('hideEmpty');
+
+ // ce imamo vklopljeno nastavitev prikaz tabel med grafi (default)
+ if($spremenljivka['tip'] == 19){
+
+ $_answers = SurveyAnalysis::getAnswers($spremenljivka,10);
+
+ // Preverimo ce je prazna in ne izpisujemo praznih
+ if($_answers['validCnt'] != 0 || $hideEmpty != 1){
+ //izpis naslova/podnaslova tabele
+ $stevilcenje = ($exportClass->numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $stevilcenje . $spremenljivka['naslov'];
+ $boldedTitle = $this->returnBold($this->encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+ if($spremenljivka['tip'] == 2){
+ $boldedSubTitle = $lang['srv_info_checkbox'];
+ }
+
+ $chart .= $this->returnCentered($boldedTitle.$boldedSubTitle, $this->export_format); //vrni sredinsko poravnana naslov in podnaslova
+ //izpis naslova/podnaslova tabele - konec
+
+ $sums = new AnalizaSums($this->anketa);
+ $chart .= $sums->sumMultiText($spid, 'sums', $this->export_format);
+ }
+ }
+ else{
+ $emptyData = false;
+ if($hideEmpty == 1){
+
+ $emptyData = true;
+ if (count($spremenljivka['grids']) > 0){
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $_variables_count = count($grid['variables']);
+
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+
+ if(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0)
+ $emptyData = false;
+ }
+ }
+ }
+ }
+
+ // Preverimo ce je prazna in ne izpisujemo praznih
+ if($emptyData == false || $hideEmpty != 1){
+ //pdfIzvozAnalizaFunctions::frequencyVertical($spid, $displayTitle=true);
+ //izpis naslova/podnaslova tabele
+ $stevilcenje = ($exportClass->numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $stevilcenje . $spremenljivka['naslov'];
+ $boldedTitle = $this->returnBold($this->encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+ if($spremenljivka['tip'] == 2){
+ $boldedSubTitle = $lang['srv_info_checkbox'];
+ }
+ $chart .= $this->returnCentered($boldedTitle.$boldedSubTitle, $this->export_format); //vrni sredinsko poravnana naslov in podnaslova
+ //izpis naslova/podnaslova tabele - konec
+
+ $freq = new AnalizaFreq($this->anketa);
+ $chart .= $freq->frequencyVertical($spid, $this->export_format);
+ }
+ }
+ }
+ elseif( in_array($spremenljivka['tip'],array(1,2,3,6,7,8,16,17,18,20)) ){
+ // Prikazemo posamezen graf
+ $chart .= $this->displayChartsInLatex($spid, $type, $fromCharts=true, $this->anketa, $from='charts', $this, $this->export_format);
+ }
+ }
+
+ } // end if $spremenljivka['tip'] != 'm'
+
+ } // end foreach self::$_HEADERS
+ return $chart;
+ }
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ // vrnemo string za prvi in zadnji vnos
+ function getEntryDates(){
+ global $lang;
+
+ $prvi_vnos_date = SurveyInfo::getSurveyFirstEntryDate();
+ $prvi_vnos_time = SurveyInfo::getSurveyFirstEntryTime();
+ $zadnji_vnos_date = SurveyInfo::getSurveyLastEntryDate();
+ $zadnji_vnos_time = SurveyInfo::getSurveyLastEntryTime();
+
+ if ($prvi_vnos_date != null) {
+ $first = $this->dateFormat($prvi_vnos_date,'j.n.y');
+ $first .= $prvi_vnos_time != null ? (SurveyInfo::$dateTimeSeperator .$this->dateFormat($prvi_vnos_time,'G:i')) : '';
+ }
+ if ($zadnji_vnos_date != null) {
+ $last = $this->dateFormat($zadnji_vnos_date,'j.n.y');
+ $last .= $zadnji_vnos_time != null ? (SurveyInfo::$dateTimeSeperator .$this->dateFormat($zadnji_vnos_time,'G:i')) : '';
+ }
+
+ $text = $lang['srv_setting_collectdata_datetime'].$first.' '.$lang['s_to'].' '.$last;
+
+ return $text;
+ }
+
+ function dateFormat($input=null, $format=null) {
+ if ($input != '..') {
+ return date($format,strtotime($input));
+ } else {
+ return '';
+ }
+ }
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaCrosstab.php b/admin/survey/export/latexclasses/Analize/AnalizaCrosstab.php
new file mode 100644
index 0000000..7defd7f
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaCrosstab.php
@@ -0,0 +1,1320 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaFrekvenca.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+/**
+ * @desc Class za generacijo izvoza v Latex
+ */
+
+class AnalizaCrosstab extends LatexAnalysisElement{
+
+ var $anketa; // trenutna anketa (array)
+ var $spremenljivka; // trenutna spremenljivka
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $CID = null; # class za inkrementalno dodajanje fajlov
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ protected $tex;
+ var $currentStyle;
+
+ var $current_loop = 'undefined';
+
+ static public $_FILTRED_OTHER = array(); # filter za polja drugo
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+ protected $show_valid_percent;
+ protected $texBigSkip = '\bigskip';
+ protected $spaceBetweenTables = ' \newline \vspace*{1 cm} \newline';
+
+ public $crosstabClass = null; //crosstab class
+
+ protected $sessionData;
+ protected $counter;
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $crosstabClass=null, $counter=null, $sprID = null, $loop = null)
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ //if ( is_numeric($anketa) )
+ if ( is_numeric($anketa['id']) )
+ {
+ $this->anketa = $anketa;
+ $this->spremenljivka = $sprID;
+ $this->counter = $counter;
+ $this->crosstabClass = $crosstabClass;
+
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData('crosstab_charts');
+ //print_r($this->sessionData);
+ //echo "sessionData: ".$this->sessionData[name]."</br>";
+ //$hideAllSystem = SurveyDataSettingProfiles :: getSetting('hideAllSystem');
+ /* $hideAllSystem = SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT');
+ echo "hideAllSystem: ".$hideAllSystem."</br>"; */
+ //SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT')
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']))
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+
+ function init()
+ {
+ global $lang;
+
+ // array used to define the language and charset of the pdf file to be generated
+ $language_meta = Array();
+ $language_meta['a_meta_charset'] = 'UTF-8';
+ $language_meta['a_meta_dir'] = 'ltr';
+ $language_meta['a_meta_language'] = 'sl';
+ $language_meta['w_page'] = $lang['page'];
+
+ //set some language-dependent strings
+ $this->pdf->setLanguageArray($language_meta);
+
+ //set margins
+ $this->pdf->setPrintHeaderFirstPage(true);
+ $this->pdf->setPrintFooterFirstPage(true);
+ $this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
+ $this->pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
+ $this->pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
+
+ // set header and footer fonts
+ $this->pdf->setHeaderFont(Array(FNT_HEADER_TEXT, "I", FNT_HEADER_SIZE));
+ $this->pdf->setFooterFont(Array(FNT_HEADER_TEXT, 'I', FNT_HEADER_SIZE));
+
+
+ // set document information
+ $this->pdf->SetAuthor('An Order Form');
+ $this->pdf->SetTitle('An Order');
+ $this->pdf->SetSubject('An Order');
+
+ // set default header data
+ $this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()));
+
+ //set auto page breaks
+ $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
+
+ $this->pdf->SetFont(FNT_MAIN_TEXT, '', FNT_MAIN_SIZE);
+ //set image scale factor
+ $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
+ return true;
+ }
+
+ public function showCrosstabsTable($crosstabClass=null, $export_format='', $creport=false) {
+ global $lang;
+ $tabela = '';
+ $this->crosstabClass = $crosstabClass;
+
+ if ($this->crosstabClass->getSelectedVariables(1) !== null && $this->crosstabClass->getSelectedVariables(2) !== null) {
+ if($creport){
+ $variables2 = $this->crosstabClass->getSelectedVariables(1);
+ $variables1 = $this->crosstabClass->getSelectedVariables(2);
+ }else{
+ $variables1 = $this->crosstabClass->getSelectedVariables(1);
+ $variables2 = $this->crosstabClass->getSelectedVariables(2);
+ }
+
+ $stevec = 0;
+
+ foreach ($variables1 AS $v_first) {
+ foreach ($variables2 AS $v_second) {
+
+ $crosstabs = null;
+ $crosstabs_value = null;
+
+ $crosstabs = $this->crosstabClass->createCrostabulation($v_first, $v_second);
+ $crosstabs_value = $crosstabs['crosstab'];
+
+ # podatki spremenljivk
+ $spr1 = $this->crosstabClass->_HEADERS[$v_first['spr']];
+ $spr2 = $this->crosstabClass->_HEADERS[$v_second['spr']];
+
+ /* print_r($crosstabClass);
+ echo "</br>"; */
+
+ $grid1 = $spr1['grids'][$v_first['grd']];
+ $grid2 = $spr2['grids'][$v_second['grd']];
+
+ #število vrstic in število kolon
+ $cols = count($crosstabs['options1']);
+ $rows = count($crosstabs['options2']);
+
+ # ali prikazujemo vrednosti variable pri spremenljivkah
+ $show_variables_values = $this->crosstabClass->doValues;
+
+ # nastavitve oblike
+ if (($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) && ($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR)) {
+ # dodamo procente in residuale
+ $rowSpan = 3;
+ $numColumnPercent = $this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3;
+ $numColumnResidual = $this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR;
+ $tblColumn = max($numColumnPercent,$numColumnResidual);
+ } else if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ # imamo samo procente
+ $rowSpan = 2;
+ $numColumnPercent = $this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3;
+ $numColumnResidual = 0;
+ $tblColumn = $numColumnPercent;
+ } else if ($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR) {
+ # imamo samo residuale
+ $rowSpan = 2;
+ $numColumnPercent = 0;
+ $numColumnResidual = $this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR;
+ $tblColumn = $numColumnResidual;
+ } else {
+ #prikazujemo samo podatke
+ $rowSpan = 1;
+ $numColumnPercent = 0;
+ $numColumnResidual = 0;
+ $tblColumn = 1;
+ }
+
+
+ # izrišemo tabelo
+
+ # najprej izrišemo naslovne vrstice
+ # za multicheckboxe popravimo naslov, na podtip
+ $sub_q1 = null;
+ if ($spr1['tip'] == '6' || $spr1['tip'] == '16' || $spr1['tip'] == '17' || $spr1['tip'] == '19' || $spr1['tip'] == '20') {
+ foreach ($spr1['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_first['seq']) {
+ $sub_q1 = strip_tags($spr1['naslov']);
+ if ($show_variables_values == true ) {
+ $sub_q1 .= '&nbsp;('.strip_tags($spr1['variable']).')';
+ }
+ if ($spr1['tip'] == '16') {
+ $sub_q1 .= ', ' . strip_tags($grid1['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($grid1['variable']) . ')' : '');
+ } else {
+ $sub_q1 .= ', ' . strip_tags($variable['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($variable['variable']) . ')' : '');
+ }
+ }
+ }
+ }
+ }
+ if ($sub_q1 == null) {
+ $sub_q1 .= strip_tags($spr1['naslov']);
+ $sub_q1 .= ($show_variables_values == true ? '&nbsp;('.strip_tags($spr1['variable']).')' : '');
+ }
+
+ $sub_q2 = null;
+ if ($spr2['tip'] == '6' || $spr2['tip'] == '16' || $spr2['tip'] == '17' || $spr2['tip'] == '19' || $spr2['tip'] == '20') {
+ foreach ($spr2['grids'] AS $grid) {
+ foreach ($grid['variables'] AS $variable) {
+ if ($variable['sequence'] == $v_second['seq']) {
+ $sub_q2 = strip_tags($spr2['naslov']);
+ if ($show_variables_values == true) {
+ $sub_q2 .= '&nbsp;('.strip_tags($spr2['variable']).')';
+ }
+ if ($spr2['tip'] == '16') {
+ $sub_q2.= ', ' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($grid2['variable']) . ')' : '');
+ } else {
+ $sub_q2.= ', ' . strip_tags($variable['naslov']) . ($show_variables_values == true ? '&nbsp;(' . strip_tags($variable['variable']) . ')' : '');
+ }
+ }
+ }
+ }
+ }
+ if ($sub_q2 == null) {
+ $sub_q2 .= strip_tags($spr2['naslov']);
+ $sub_q2 .= ($show_variables_values == true ? '&nbsp;('.strip_tags($spr2['variable']).')' : '');
+ }
+
+ $this->crosstabVars = array($sub_q1, $sub_q2);
+
+ //pridobitev stevila dodatnih podatkov v vsaki vmesni vrstici oz. stolpcu
+ $steviloVmesnihVrstic = $this->crosstabClass->crossChk0 +
+ ($this->crosstabClass->crossChk1||$this->crosstabClass->crossChk2||$this->crosstabClass->crossChk3) +
+ ($this->crosstabClass->crossChkEC||$this->crosstabClass->crossChkRE||$this->crosstabClass->crossChkSR||$this->crosstabClass->crossChkAR);
+
+ $steviloVmesnihStolpcevPodvrstica2 = $this->crosstabClass->crossChk1 +
+ $this->crosstabClass->crossChk2 +
+ $this->crosstabClass->crossChk3;
+
+ $steviloVmesnihStolpcevPodvrstica3 = $this->crosstabClass->crossChkEC +
+ $this->crosstabClass->crossChkRE +
+ $this->crosstabClass->crossChkSR +
+ $this->crosstabClass->crossChkAR;
+
+ //echo "steviloVmesnihVrstic: ".$steviloVmesnihVrstic."</br>";
+ //echo "steviloVmesnihStolpcevPodvrstica2: ".$steviloVmesnihStolpcevPodvrstica2."</br>";
+ //echo "steviloVmesnihStolpcevPodvrstica3: ".$steviloVmesnihStolpcevPodvrstica3."</br>";
+
+ $podVrstice = 0;
+
+ //if($steviloVmesnihStolpcevPodvrstica2||$steviloVmesnihStolpcevPodvrstica3){
+ if($steviloVmesnihStolpcevPodvrstica2&&$steviloVmesnihStolpcevPodvrstica3){
+ //echo "1 </br>";
+ if($steviloVmesnihStolpcevPodvrstica2 >= $steviloVmesnihStolpcevPodvrstica3){
+ $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica2;
+ //}else{
+ }elseif(0 < $steviloVmesnihStolpcevPodvrstica2 && $steviloVmesnihStolpcevPodvrstica2 < $steviloVmesnihStolpcevPodvrstica3){
+ $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica3;
+ }
+ //eksperiment
+ $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica2*$steviloVmesnihStolpcevPodvrstica3;
+ $podVrstice = 1;
+ }elseif($steviloVmesnihStolpcevPodvrstica2){
+ //echo "2 </br>";
+ $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica2;
+ $podVrstice = 1;
+ }elseif($steviloVmesnihStolpcevPodvrstica3){
+ //echo "3 </br>";
+ $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica3;
+ $podVrstice = 1;
+ }else{
+ //echo "4 </br>";
+ $steviloVmesnihStolpcevPodvrstic = 1;
+ }
+ //echo "steviloVmesnihStolpcevPodvrstic: ".$steviloVmesnihStolpcevPodvrstic."</br>";
+ //echo "Podvrstice: ".$podVrstice."</br>";
+ //pridobitev stevila dodatnih podatkov v vsaki vmesni vrstici oz. stolpcu - konec
+
+ //za ureditev prepoznavanja presirokih tabele
+ $mejaZaVelikeTabele = 8;
+ $velikostTabele = $cols*$steviloVmesnihStolpcevPodvrstic + 1 + $steviloVmesnihStolpcevPodvrstic; //surova velikost tabele, da prepoznamo, ce je presiroka ali ne
+ //echo "<b>velikost tabele: </b>".($velikostTabele)." podatkov je : $cols </br>";
+
+ if($velikostTabele > $mejaZaVelikeTabele){ //ce imamo veliko tabelo, jo je potrebno razbiti na vec tabel, ker drugace je presiroka
+ //echo "tabela je presiroka, ima ".($velikostTabele)." stolpcev</br>";
+ $presirokaTabela = 1;
+
+ $steviloTabelCelih = intval($velikostTabele / $mejaZaVelikeTabele);
+ $steviloTabelMod = $velikostTabele % $mejaZaVelikeTabele;
+ $delnaTabela = 0;
+ if($steviloTabelMod != 0){
+ $delnaTabela = 1;
+ }
+ $steviloTabel = $steviloTabelCelih + $delnaTabela;
+
+ if($delnaTabela){ //ce je delna tabela, manjsa od velikosti mejnih stolpcev (8)
+ $steviloStolpcevDelnaTabela = $velikostTabele - $steviloTabelCelih*$mejaZaVelikeTabele;
+ }
+
+ /* echo "stevilo podtabel celih ".($steviloTabelCelih)." </br>";
+ echo "stevilo podtabel mod ".($steviloTabelMod)." </br>";
+ echo "stevilo stolpcev delna podtabela ".($steviloStolpcevDelnaTabela)." </br>";
+ echo "stevilo podtabel za izpis: ".($steviloTabel)." </br>"; */
+
+
+
+ $cols = array();
+ $crosstabsOptions1All = array();
+ //$crosstabsOptions1 = array();
+
+ //$crosstabs['options1']
+ //print_r($crosstabs['options1']);
+ //print_r(array_chunk($crosstabs['options1'], $mejaZaVelikeTabele, true));
+
+ //priprava polja s stevilom stolpcev za vsako podtabelo
+ //echo "stevilo vseh podatkov: ".count($crosstabs['options1'])."</br>";
+ $crosstabsOptions1All = array_chunk($crosstabs['options1'], $mejaZaVelikeTabele, true);
+ //print_r($crosstabsOptions1All);
+
+ for($tab=0; $tab<$steviloTabel; $tab++){
+ if($tab != ($steviloTabel-1)){ //ce ni zadnja podtabela
+ $cols[$tab] = $mejaZaVelikeTabele;
+ }else{
+ if($delnaTabela){
+ $cols[$tab] = $steviloStolpcevDelnaTabela - 1;
+ }else{
+ $cols[$tab] = $mejaZaVelikeTabele;
+ }
+ }
+ }
+
+ /* foreach($crosstabsOptions1All as $crosstabsOptions1Index => $crosstabsOptions1){
+ if($crosstabsOptions1Index != (count($crosstabsOptions1All)-1)){ //ce ni zadnja podtabela
+ $cols[$crosstabsOptions1Index] = $mejaZaVelikeTabele;
+ }else{
+ if($delnaTabela){
+ $cols[$crosstabsOptions1Index] = $steviloStolpcevDelnaTabela;
+ }else{
+ $cols[$crosstabsOptions1Index] = $mejaZaVelikeTabele;
+ }
+ }
+ } */
+ //priprava polja s stevilom stolpcev za vsako podtabelo - konec
+
+ //priprava polja s stevilom stolpcev za vsako podtabelo
+ //echo "stevilo vseh podatkov: ".count($crosstabs['options1'])."</br>";
+ /* $crosstabsOptions1All = array_chunk($crosstabs['options1'], $mejaZaVelikeTabele, true);
+ //print_r($crosstabsOptions1All);
+
+ $steviloVsehStolpcev = 0;
+
+ foreach($crosstabsOptions1All as $crosstabsOptions1Index => $crosstabsOptions1){ //TOLE JE POTREBNO PREUREDITI, SAJ SE POJAVI TEŽAVA, KO PODATKA NI IN JE STOLPEC S SUMAMI (recimo)
+ if($crosstabsOptions1Index != (count($crosstabsOptions1All)-1)){ //ce ni zadnja podtabela
+ $cols[$crosstabsOptions1Index] = count($crosstabsOptions1All[$crosstabsOptions1Index]);
+ $steviloVsehStolpcev = $steviloVsehStolpcev + (count($crosstabsOptions1All[$crosstabsOptions1Index]) + 1);
+ }else{
+ if($delnaTabela){
+ //$cols[$crosstabsOptions1Index] = count($crosstabsOptions1All[$crosstabsOptions1Index]) + 1;
+ $cols[$crosstabsOptions1Index] = count($crosstabsOptions1All[$crosstabsOptions1Index]);
+ }else{
+ //$cols[$crosstabsOptions1Index] = count($crosstabsOptions1All[$crosstabsOptions1Index]) + 1;
+ $cols[$crosstabsOptions1Index] = count($crosstabsOptions1All[$crosstabsOptions1Index]);
+ }
+ $steviloVsehStolpcev = $steviloVsehStolpcev + (count($crosstabsOptions1All[$crosstabsOptions1Index]) + 2);
+ }
+ } */
+ //priprava polja s stevilom stolpcev za vsako podtabelo - konec
+ //echo "steviloVsehStolpcev: $steviloVsehStolpcev </br>";
+
+ }else{
+ $presirokaTabela = 0;
+ }
+ //za ureditev prepoznavanja presirokih tabele - konec
+
+
+ if($presirokaTabela == 0){ //ce ni presiroka tabela
+
+ if($stevec == 0){
+ //Priprava parametrov za tabelo
+
+ $steviloStolpcevParameterTabular = $cols*$steviloVmesnihStolpcevPodvrstic + 1 + $steviloVmesnihStolpcevPodvrstic;
+
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($export_format == 'pdf' ? ' >{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ $parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'c|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/ //pred spremembo je bilo to
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+ //echo "Parametri tabele: $parameterTabular </br>";
+ $tabela .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+ }
+
+ //prva vrstica ######################################################################################
+ /*prvi in zadnji stolpec prve vrstice prazna, ostali pa z ustreznim besedilom*/
+ $steviloMultiCol1 = $cols * $steviloVmesnihStolpcevPodvrstic;
+
+ ##########
+ $steviloTabColSep = ($steviloMultiCol1-1)*2;
+ $steviloArrayrulewidth = ($steviloMultiCol1-1);
+
+ if($export_format=='pdf'){
+ //$tabela .= " & \multicolumn{".$steviloMultiCol1."}{>{\hsize=\dimexpr".$steviloMultiCol1."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{".$this->encodeText($sub_q1)."} "; //prvi (prazen) in stolpec z besedilom
+ $tabela .= " & \multicolumn{".$steviloMultiCol1."}{>{\hsize=\dimexpr".$steviloMultiCol1."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}c|}{".$this->encodeText($sub_q1)."} "; //prvi (prazen) in stolpec z besedilom
+ }elseif($export_format=='rtf'){
+ $tabela .= " & \multicolumn{".$steviloMultiCol1."}{c|}{".$this->encodeText($sub_q1)."} "; //prvi (prazen) in stolpec z besedilom
+ }
+
+ ###########
+
+ if($cols!=0){
+ if($steviloVmesnihStolpcevPodvrstic==1){
+ $tabela .= " & "; //zadnji stolpec
+ }else{
+ if($export_format=='xls'){
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{c|}{}"; //zadnji stolpec
+ }else{
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}{}"; //zadnji stolpec
+ //$tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{C|}{}"; //zadnji stolpec
+ }
+ }
+ }
+
+
+
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //prva vrstica - konec ##############################################################################
+
+ // druga vrstica ####################################################################################
+ $tabela .= $this->encodeText($sub_q2); //prvi stolpec 2. vrstice
+ //echo "testiram, kjer ssem: ".$this->encodeText($sub_q2)."</br>";
+ //echo "testiram, kjer ssem: ".$steviloTabColSep."</br>";
+ $drugaVrstica = array();
+ if (count($crosstabs['options1']) > 0 ) { //stolpci (izkljucno) med prvim in zadnjim
+ foreach ($crosstabs['options1'] as $ckey1 =>$crossVariabla) {
+ #ime variable
+ $text = $crossVariabla['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla['type'] != 't') {
+ $text .= ' ( '.$ckey1.' )';
+ }
+ $tabela .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, $this->encodeText($text));
+ }
+ }
+ //echo "test: ".$podVrstice."</br>";
+ if($podVrstice){ //ce je potrebno multicol prikazovanje
+ //spremenljivke za pravilno sirino
+ $colNum = $steviloVmesnihStolpcevPodvrstic;
+ $colNum2 = $steviloVmesnihStolpcevPodvrstic/$steviloVmesnihStolpcevPodvrstica2; //stevilo podstolpcev za 2. podvrstico
+ $colNum3 = $steviloVmesnihStolpcevPodvrstic/$steviloVmesnihStolpcevPodvrstica3; //stevilo podstolpcev za 3. podvrstico
+ //spremenljivke za pravilno sirino - konec
+
+ $tabela .= $this->MultiColCellLatex($colNum, $this->encodeText($lang['srv_analiza_crosstab_skupaj'])); //izpis naslova zadnjega stolpca 2. vestice
+ }else{
+ $tabela .= " & ";
+ $tabela .= $this->encodeText($lang['srv_analiza_crosstab_skupaj']); //izpis naslova zadnjega stolpca 2. vestice
+ }
+
+ $tabela .= $this->texNewLine; /*nova vrstica*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ // druga vrstica - konec #########################################################################
+
+ //izpis vmesnih vrstic tabele ####################################################################
+ if (count($crosstabs['options2']) > 0) {
+
+ //POSAMEZNA VMESNA VRSTICA
+ foreach ($crosstabs['options2'] as $ckey2 =>$crossVariabla2) {
+ //priprava besedila za prvo celico 1. stolpca
+ $text = $crossVariabla2['naslov'];
+ if($export_format != 'xls'){
+ $text = $this->snippet($this->encodeText($text), 25);
+ }
+ if ($crossVariabla2['type'] !== 't') {
+ $text .= ' ('.$ckey2.')';
+ }
+ //priprava besedila za prvo celico 1. stolpca - konec
+
+ //izpis prve celice 1. stolpca
+ if($export_format != 'xls'){
+ $tabela .= $this->MultiRowCellLatex($steviloVmesnihVrstic, $this->encodeText($text));
+ }else{
+ $tabela .= $text;
+ }
+
+ $tabela1 = ''; //za belezenje 1. vrstice s frekvencami
+ $tabela2 = ''; //za belezenje 2. vrstice z odstotki
+ $tabela3 = ''; //za belezenje 3. vrstice z residuali
+
+ foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+
+ if ($this->crosstabClass->crossChk0) {
+ # frekvence crostabov
+ $crossChk0 = ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? $crosstabs_value[$ckey1][$ckey2] : 0;
+ $tabela1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum);
+ }
+ if ($this->crosstabClass->crossChk1) {
+ #procent vrstica
+ $crossChk1 = $this->encodeText($this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$ckey2], $crosstabs_value[$ckey1][$ckey2]), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ #procent stolpec
+ $crossChk2 = $this->encodeText($this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaStolpec'][$ckey1], $crosstabs_value[$ckey1][$ckey2]), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2);
+ }
+ if ($this->crosstabClass->crossChk3) {
+ #procent skupni
+ $crossChk3 = $this->encodeText($this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs_value[$ckey1][$ckey2]), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2);
+ }
+
+ # residuali
+ if ($this->crosstabClass->crossChkEC) {
+ $crossChkEC = $this->encodeText($this->formatNumber($crosstabs['exC'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkEC, $podVrstice, $colNum3);
+ }
+ if ($this->crosstabClass->crossChkRE) {
+ $crossChkRE = $this->encodeText($this->formatNumber($crosstabs['res'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkRE, $podVrstice, $colNum3);
+ }
+ if ($this->crosstabClass->crossChkSR) {
+ $crossChkSR = $this->encodeText($this->formatNumber($crosstabs['stR'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkSR, $podVrstice, $colNum3);
+ }
+ if ($this->crosstabClass->crossChkAR) {
+ $crossChkAR = $this->encodeText($this->formatNumber($crosstabs['adR'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkAR, $podVrstice, $colNum3);
+ }
+ }
+
+ //se zadnji stolpec - vedno risemo
+ if ($this->crosstabClass->crossChk0) {
+ # suma po vrsticah
+ $crossChk0 = (int)$crosstabs['sumaVrstica'][$ckey2];
+ $tabela1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ # suma po vrsticah v procentih
+ if ($this->crosstabClass->crossChk1) {
+ $crossChk1 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ $crossChk2 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk3) {
+ $crossChk3 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ }
+
+ $tabela .= $tabela1; //izpis 1. vrstice s freq
+ $tabela .= $this->texNewLine;
+
+ if($steviloVmesnihVrstic > 1){ //ce je potrebno multirow prikazovanje
+ if($tabela2!=''){ //ce je 2. podvrstica
+ if($export_format != 'xls'){
+ $tabela .= ' \cline{2-'.$steviloStolpcevParameterTabular.'}'; //je potrebno urediti prvi stolpec tako, da ni crt med celicami
+ }
+ $tabela .= $tabela2; //izpis 2. vrstice z odstotki
+ $tabela .= $this->texNewLine;
+
+ }
+ if($tabela3!=''){ //ce je 3. podvrstica
+ if($export_format != 'xls'){
+ $tabela .= ' \cline{2-'.$steviloStolpcevParameterTabular.'}'; //je potrebno urediti prvi stolpec tako, da ni crt med celicami
+ }
+ $tabela .= $tabela3; //izpis 3. vrstice z residuali
+ $tabela .= $this->MultiColCellLatex($colNum, ''); //pri residualih je zadnja celica v zadnjem stolpcu prazna
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }else{
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ }else{
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ }
+ }
+ //izpis vmesnih vrstic tabele - konec ##################################################################################
+
+
+ // skupni sestevki po stolpcih - ZADNJA VRSTICA ########################################################################
+
+ //izpis celice v prvem stolpcu
+ if($export_format != 'xls'){
+ $tabela .= $this->MultiRowCellLatex($steviloVmesnihVrstic, $this->encodeText($lang['srv_analiza_crosstab_skupaj']), $tabela2, $tabela3, $cols);
+ }else{
+ $tabela .= $this->encodeText($lang['srv_analiza_crosstab_skupaj']);
+ }
+ //izpis celice v prvem stolpcu - konec
+
+ if (count($crosstabs['options1']) > 0){
+ $tabelaZadnja1 = ''; //belezi kodo za 1. podvrstico zadnje vrstice
+ $tabelaZadnja2 = ''; //belezi kodo za 2. podvrstico zadnje vrstice
+ foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+
+ # prikazujemo eno od treh možnosti
+ if ($this->crosstabClass->crossChk0) {
+ # suma po stolpcih
+ $crossChk0 = (int)$crosstabs['sumaStolpec'][$ckey1];
+ $tabelaZadnja1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ # suma po stolpcih v procentih
+ if ($this->crosstabClass->crossChk1) {
+ $crossChk1 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ $crossChk2 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk3){
+ $crossChk3 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ }
+ }
+
+ # zadnja celica z skupno sumo
+ if ($this->crosstabClass->crossChk0) {
+ # skupna suma
+ $crossChk0 = (int)$crosstabs['sumaSkupna'];
+ $tabelaZadnja1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ # suma po stolpcih v procentih
+ if ($this->crosstabClass->crossChk1) {
+ $crossChk1 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ $crossChk2 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk3) {
+ $crossChk3 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ }
+ }
+
+ $tabela .= $tabelaZadnja1; //izpis 1. podvrstice s freq
+ $tabela .= $this->texNewLine;
+
+ if($steviloVmesnihVrstic > 1 && $tabela2!=''){ //ce je potrebno multicol prikazovanje
+ if($export_format != 'xls'){
+ $tabela .= ' \cline{2-'.$steviloStolpcevParameterTabular.'}'; //je potrebno urediti prvi stolpec tako, da ni crt med celicami
+ }
+ }else{
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+
+ if($steviloVmesnihVrstic > 1 && $tabela2!=''){ //ce je potrebno multirow prikazovanje
+ $tabela .= $tabelaZadnja2; //izpis 2. vrstice z odstotki
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ // skupni sestevki po stolpcih - ZADNJA VRSTICA - konec #############################################################################
+
+ $stevec++;
+ }elseif($presirokaTabela == 1){ //ce je tabela presiroka
+ //print_r($cols);
+
+ //echo "<b>velikost tabele: </b>".($velikostTabele)." podatkov je : $cols </br>";
+ //echo $velikostTabele % 2;
+ //potrebno za ureditev zadnje podtabele s Skupaj
+ if($velikostTabele % 2){
+ $niSodo = 1;
+ //$steviloTabel = $steviloTabel - 1;
+ }else{
+ $niSodo = 0;
+ }
+ //echo "stevilo podtabel za izpis, če ni sodo: ".($steviloTabel)." </br>";
+ //potrebno za ureditev predzadnje podtabele - konec
+
+ if($steviloVmesnihStolpcevPodvrstic>1){
+ $crosstabsOptions1All = array_chunk($crosstabs['options1'], 2, true);
+ }
+
+
+ //izpis vsake podtabele posebej
+ for($t=0; $t<$steviloTabel; $t++){
+ $stevec = 0;
+ if($stevec == 0){
+
+ //Priprava parametrov za tabelo
+
+ //$steviloStolpcevParameterTabular = $cols[$t]*$steviloVmesnihStolpcevPodvrstic + 1 + $steviloVmesnihStolpcevPodvrstic;
+ //$steviloStolpcevParameterTabular = $cols[$t]*$steviloVmesnihStolpcevPodvrstic + $steviloVmesnihStolpcevPodvrstic;
+ //$steviloStolpcevParameterTabular = $cols[$t]*$steviloVmesnihStolpcevPodvrstic + 1;
+
+ if($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR){ //ce je potrebno izpisati tudi reziduale
+ $reziduali = 1;
+ }
+
+ if($t != ($steviloTabel-1)){ //ce ni zadnja podtabela
+ $steviloStolpcevParameterTabular = $mejaZaVelikeTabele + 1;
+ }else{
+ if($delnaTabela){
+ //echo "residuali: ".$this->crosstabClass->crossChkEC." ".$this->crosstabClass->crossChkRE." ".$this->crosstabClass->crossChkSR." ".$this->crosstabClass->crossChkAR."</br>";
+ if($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR){ //ce je potrebno izpisati tudi reziduale
+ //$reziduali = 1;
+ $steviloStolpcevParameterTabular = $steviloStolpcevDelnaTabela + 1;
+ }else{
+ $steviloStolpcevParameterTabular = $steviloStolpcevDelnaTabela;
+ }
+ /* echo "steviloStolpcevDelnaTabela: $steviloStolpcevDelnaTabela </br>";
+ echo "steviloStolpcevParameterTabular1: $steviloStolpcevParameterTabular </br>"; */
+ //$steviloStolpcevParameterTabular++;
+ }else{
+ $steviloStolpcevParameterTabular = $mejaZaVelikeTabele + 1;
+ }
+ }
+
+ if($steviloStolpcevParameterTabular <= 2){
+ $steviloStolpcevParameterTabular++;
+ }
+ //echo "steviloStolpcevParameterTabular2: $steviloStolpcevParameterTabular </br>";
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ if($t != ($steviloTabel-1)){//ce ni zadnja podtabela
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ $parameterTabular .= ($export_format == 'pdf' ? 'Y|' : 'l|');
+ }else{
+ //$parameterTabular .= ($export_format == 'pdf' ? ' >{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ $parameterTabular .= ($export_format == 'pdf' ? 'Y|' : 'c|');
+ }
+ }else{ //ce je zadnja podtabela
+ $parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+ //echo "Parametri tabele $t: $parameterTabular s številom stolpcev $cols[$t] </br>";
+ $tabela .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+ }
+
+ //prva vrstica ######################################################################################
+ /*prvi in zadnji stolpec prve vrstice prazna, ostali pa z ustreznim besedilom*/
+
+ //$steviloMultiCol1 = $cols[$t] * $steviloVmesnihStolpcevPodvrstic;
+ if($t == ($steviloTabel-1)){ //ce je zadnja podtabela
+ //$steviloMultiCol1 = ($cols[$t]-1) * $steviloVmesnihStolpcevPodvrstic;
+ $steviloMultiCol1 = ($steviloStolpcevParameterTabular - 2);
+ }else{
+ //$steviloMultiCol1 = $cols[$t] * $steviloVmesnihStolpcevPodvrstic;
+ $steviloMultiCol1 = $steviloStolpcevParameterTabular - 1;
+ }
+
+
+ if($reziduali &&($t == ($steviloTabel-1))){ //ce so reziduali in je zadnja podtabela
+ $steviloMultiCol1 = 0;
+ $steviloVmesnihStolpcevPodvrstic=1;
+ }
+ //echo "steviloMultiCol1: ".$steviloMultiCol1." $reziduali</br>";
+ ##########
+
+ if($steviloMultiCol1){
+ $steviloTabColSep = ($steviloMultiCol1-1)*2;
+ $steviloArrayrulewidth = ($steviloMultiCol1-1);
+ if($export_format=='pdf'){
+ //$tabela .= " & \multicolumn{".$steviloMultiCol1."}{>{\hsize=\dimexpr".$steviloMultiCol1."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{".$this->encodeText($sub_q1)."} "; //prvi (prazen) in stolpec z besedilom
+ $tabela .= " & \multicolumn{".$steviloMultiCol1."}{>{\hsize=\dimexpr".$steviloMultiCol1."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}c|}{".$this->encodeText($sub_q1)."} "; //prvi (prazen) in stolpec z besedilom
+ }elseif($export_format=='rtf'){
+ $tabela .= " & \multicolumn{".$steviloMultiCol1."}{c|}{".$this->encodeText($sub_q1)."} "; //prvi (prazen) in stolpec z besedilom
+ }
+ }else{
+ $tabela .= " & ".$this->encodeText($sub_q1)." ";
+ }
+ ###########
+ //echo "testiram, kjer ssem: ".$this->encodeText($sub_q1)."</br>";
+
+ if($cols[$t]!=0 &&($t == ($steviloTabel-1))){
+ if($steviloVmesnihStolpcevPodvrstic==1){
+ $tabela .= " & "; //zadnji stolpec
+ }else{
+ if($export_format=='xls'){
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{c|}{}"; //zadnji stolpec
+ }else{
+ //$tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}{}"; //zadnji stolpec
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{Y|}{}"; //zadnji stolpec
+ }
+ }
+ }
+
+ if($reziduali &&($t == ($steviloTabel-1))){ //ce so reziduali in je zadnja podtabela
+ $tabela .= " & "; //zadnji stolpec
+ }
+
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //prva vrstica - konec ##############################################################################
+ //echo "$tabela</br>";
+
+ // druga vrstica ####################################################################################
+ $tabela .= $this->encodeText($sub_q2); //prvi stolpec 2. vrstice
+ //echo "testiram, kjer ssem: ".$this->encodeText($sub_q2)."</br>";
+ //echo "testiram, kjer ssem: ".$steviloTabColSep."</br>";
+ $drugaVrstica = array();
+
+ //echo count($crosstabsOptions1All[$t])."</br>";
+ //if (count($crosstabs['options1']) > 0 ) { //stolpci (izkljucno) med prvim in zadnjim
+ if (count($crosstabsOptions1All[$t]) > 0 ) { //stolpci (izkljucno) med prvim in zadnjim
+ foreach ($crosstabsOptions1All[$t] as $ckey1 =>$crossVariabla) {
+ #ime variable
+ $text = $crossVariabla['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla['type'] != 't') {
+ $text .= ' ( '.$ckey1.' )';
+ }
+ $tabela .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, $this->encodeText($text));
+ //echo "steviloVmesnihStolpcevPodvrstic $t: $steviloVmesnihStolpcevPodvrstic</br>";
+ //echo $this->encodeText($text)."</br>";
+ }
+ if($niSodo && $t == ($steviloTabel-2) && $reziduali){ //ce ni sodo in je predzadnja podtabela in so reziduali, dodaj se vse potrebno za prazen stolpec
+ //if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ $tabela .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+ }else{
+ $tabela .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+ //echo "test: ".$podVrstice."</br>";
+ if($podVrstice){ //ce je potrebno multicol prikazovanje
+ //spremenljivke za pravilno sirino
+ $colNum = $steviloVmesnihStolpcevPodvrstic;
+ $colNum2 = $steviloVmesnihStolpcevPodvrstic/$steviloVmesnihStolpcevPodvrstica2; //stevilo podstolpcev za 2. podvrstico
+ $colNum3 = $steviloVmesnihStolpcevPodvrstic/$steviloVmesnihStolpcevPodvrstica3; //stevilo podstolpcev za 3. podvrstico
+ //spremenljivke za pravilno sirino - konec
+ if($t == ($steviloTabel-1)){ //ce je zadnji stolpec v podtabeli
+ $tabela .= $this->MultiColCellLatex($colNum, $this->encodeText($lang['srv_analiza_crosstab_skupaj'])); //izpis naslova zadnjega stolpca 2. vrstice
+ }
+
+ //}else{
+ }elseif(($t == ($steviloTabel-1))){ //ce je zadnja podtabela
+ //}elseif(($t == ($steviloTabel-1)) && $niSodo == 1){
+ $tabela .= " & ";
+ $tabela .= $this->encodeText($lang['srv_analiza_crosstab_skupaj']); //izpis naslova zadnjega stolpca 2. vrstice
+ }
+
+ $tabela .= $this->texNewLine; /*nova vrstica*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ // druga vrstica - konec #########################################################################
+
+
+ //izpis vmesnih vrstic tabele ####################################################################
+ //echo count($crosstabs['options2'])."</br>";
+ //if (count($crosstabs['options2']) > 0) {
+ if (count($crosstabs['options2']) > 0) {
+
+ //POSAMEZNA VMESNA VRSTICA
+ foreach ($crosstabs['options2'] as $ckey2 =>$crossVariabla2) {
+ //priprava besedila za prvo celico 1. stolpca
+ $text = $crossVariabla2['naslov'];
+ if($export_format != 'xls'){
+ $text = $this->snippet($this->encodeText($text), 25);
+ }
+ if ($crossVariabla2['type'] !== 't') {
+ $text .= ' ('.$ckey2.')';
+ }
+ //priprava besedila za prvo celico 1. stolpca - konec
+
+ //izpis prve celice 1. stolpca
+ if($export_format != 'xls'){
+ $tabela .= $this->MultiRowCellLatex($steviloVmesnihVrstic, $this->encodeText($text));
+ }else{
+ $tabela .= $text;
+ }
+
+ $tabela1 = ''; //za belezenje 1. vrstice s frekvencami
+ $tabela2 = ''; //za belezenje 2. vrstice z odstotki
+ $tabela3 = ''; //za belezenje 3. vrstice z residuali
+
+ //foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+ foreach ($crosstabsOptions1All[$t] as $ckey1 => $crossVariabla1) {
+
+ if ($this->crosstabClass->crossChk0) {
+ # frekvence crostabov
+ $crossChk0 = ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? $crosstabs_value[$ckey1][$ckey2] : 0;
+ $tabela1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum);
+ /* if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ $tabela1 .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ } */
+
+ }
+ if ($this->crosstabClass->crossChk1) {
+ #procent vrstica
+ $crossChk1 = $this->encodeText($this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$ckey2], $crosstabs_value[$ckey1][$ckey2]), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ #procent stolpec
+ $crossChk2 = $this->encodeText($this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaStolpec'][$ckey1], $crosstabs_value[$ckey1][$ckey2]), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2);
+ }
+ if ($this->crosstabClass->crossChk3) {
+ #procent skupni
+ $crossChk3 = $this->encodeText($this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs_value[$ckey1][$ckey2]), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2);
+ }
+
+ # residuali
+ if ($this->crosstabClass->crossChkEC) {
+ $crossChkEC = $this->encodeText($this->formatNumber($crosstabs['exC'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkEC, $podVrstice, $colNum3);
+ }
+ if ($this->crosstabClass->crossChkRE) {
+ $crossChkRE = $this->encodeText($this->formatNumber($crosstabs['res'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkRE, $podVrstice, $colNum3);
+ }
+ if ($this->crosstabClass->crossChkSR) {
+ $crossChkSR = $this->encodeText($this->formatNumber($crosstabs['stR'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkSR, $podVrstice, $colNum3);
+ }
+ if ($this->crosstabClass->crossChkAR) {
+ $crossChkAR = $this->encodeText($this->formatNumber($crosstabs['adR'][$ckey1][$ckey2], 3, ''));
+ $tabela3 .= $this->DisplayLatexCells($crossChkAR, $podVrstice, $colNum3);
+ }
+ //echo "tabela 3: $tabela3 </br>";
+ }
+
+ //if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ if($niSodo && $t == ($steviloTabel-2) && $reziduali){ //ce ni sodo in je predzadnja podtabela in je potrebno izpisati reziduale, dodaj se vse potrebno za prazen stolpec
+ $tabela1 .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+
+ if(!$crosstabsOptions1All[$t]){
+ if($tabela1){
+ //$tabela1 .= ' & ';
+ }
+ if($tabela2!=''){
+ //$tabela2 .= ' & ';
+ }
+ if($tabela3!=''){
+ //$tabela3 .= ' & ';
+ }
+ }
+
+
+ //se zadnji stolpec - risemo, ko je zadnja tabela
+ if($t == ($steviloTabel-1)){
+ if ($this->crosstabClass->crossChk0) {
+ # suma po vrsticah
+ $crossChk0 = (int)$crosstabs['sumaVrstica'][$ckey2];
+ if(!$crosstabsOptions1All[$t]){
+ $tabela1 .= ' & ';
+ }
+ $tabela1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum, $steviloVmesnihStolpcevPodvrstic, $niSodo);
+ }
+ if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ if(!$crosstabsOptions1All[$t]){
+ $tabela2 .= ' & ';
+ }
+ # suma po vrsticah v procentih
+ if ($this->crosstabClass->crossChk1) {
+ $crossChk1 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic, $niSodo);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ $crossChk2 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic, $niSodo);
+ }
+ if ($this->crosstabClass->crossChk3) {
+ $crossChk3 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabela2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic, $niSodo);
+ }
+ }
+ }
+
+ $tabela .= $tabela1; //izpis 1. vrstice s freq
+
+ $tabela .= $this->texNewLine;
+ //echo "steviloStolpcevParameterTabular: $steviloStolpcevParameterTabular </br>";
+ if($steviloVmesnihVrstic > 1){ //ce je potrebno multirow prikazovanje
+ if($tabela2!=''){ //ce je 2. podvrstica
+ if($export_format != 'xls'){
+ $tabela .= ' \cline{2-'.$steviloStolpcevParameterTabular.'}'; //je potrebno urediti prvi stolpec tako, da ni crt med celicami
+ }
+
+
+ if($niSodo && $t == ($steviloTabel-2) && $reziduali){ //ce ni sodo in je predzadnja podtabela in so reziduali, dodaj se vse potrebno za prazen stolpec
+ //if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ $tabela2 .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+
+ $tabela .= $tabela2; //izpis 2. vrstice z odstotki
+
+ $tabela .= $this->texNewLine;
+
+ }
+ if($tabela3!=''){ //ce je 3. podvrstica
+ if($export_format != 'xls'){
+ $tabela .= ' \cline{2-'.$steviloStolpcevParameterTabular.'}'; //je potrebno urediti prvi stolpec tako, da ni crt med celicami
+ }
+
+ if($niSodo && $t == ($steviloTabel-2) && $reziduali){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ //if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ $tabela3 .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+
+ $tabela .= $tabela3; //izpis 3. vrstice z residuali
+
+ if($t == ($steviloTabel-1)){ //ce je zadnja podtabela
+ $tabela .= $this->MultiColCellLatex($colNum, ''); //pri residualih je zadnja celica v zadnjem stolpcu prazna
+ }
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }else{
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ }else{
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ }
+ }
+ //izpis vmesnih vrstic tabele - konec ##################################################################################
+
+ //echo "tabela 2: $tabela2 </br>";
+ //echo "tabela 3: $tabela3 </br>";
+
+ // skupni sestevki po stolpcih - ZADNJA VRSTICA ########################################################################
+
+ //izpis celice v prvem stolpcu
+ if($export_format != 'xls'){
+ $tabela .= $this->MultiRowCellLatex($steviloVmesnihVrstic, $this->encodeText($lang['srv_analiza_crosstab_skupaj']), $tabela2, $tabela3, $cols[$t]);
+ }else{
+ $tabela .= $this->encodeText($lang['srv_analiza_crosstab_skupaj']);
+ }
+ //izpis celice v prvem stolpcu - konec
+
+ //if (count($crosstabs['options1']) > 0){
+ //if (count($crosstabsOptions1All[$t]) > 0){
+ //
+ $tabelaZadnja1 = ''; //belezi kodo za 1. podvrstico zadnje vrstice
+ $tabelaZadnja2 = ''; //belezi kodo za 2. podvrstico zadnje vrstice
+ //foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
+ foreach ($crosstabsOptions1All[$t] as $ckey1 => $crossVariabla1) {
+
+ # prikazujemo eno od treh možnosti
+ if ($this->crosstabClass->crossChk0) {
+ # suma po stolpcih
+ $crossChk0 = (int)$crosstabs['sumaStolpec'][$ckey1];
+ $tabelaZadnja1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ # suma po stolpcih v procentih
+ if ($this->crosstabClass->crossChk1) {
+ $crossChk1 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ $crossChk2 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk3){
+ $crossChk3 = $this->encodeText($this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ }
+ }
+
+ # zadnja celica z skupno sumo
+ if($t == ($steviloTabel-1)){
+ if ($this->crosstabClass->crossChk0) {
+ # skupna suma
+ $crossChk0 = (int)$crosstabs['sumaSkupna'];
+
+ //echo "numr: ".$crosstabsOptions1All[$t]."</br>";
+ //if (!$crosstabsOptions1All[$t]){
+ /* if (!$crosstabsOptions1All[$t] && $reziduali == 0){
+ $tabelaZadnja1 .= " & ";
+ } */
+ $tabelaZadnja1 .= $this->DisplayLatexCells($crossChk0, $podVrstice, $colNum, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
+ # suma po stolpcih v procentih
+ if (!$crosstabsOptions1All[$t]){
+ $tabelaZadnja2 .= " & ";
+ }
+ if ($this->crosstabClass->crossChk1) {
+ $crossChk1 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk1, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk2) {
+ $crossChk2 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk2, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ if ($this->crosstabClass->crossChk3) {
+ $crossChk3 = $this->encodeText($this->formatNumber(100, 2, '%'));
+ $tabelaZadnja2 .= $this->DisplayLatexCells($crossChk3, $podVrstice, $colNum2, $steviloVmesnihStolpcevPodvrstic);
+ }
+ }
+ }
+ //}
+ /* echo "tabelaZadnja1: $tabelaZadnja1</br>";
+ echo "tabelaZadnja2: $tabelaZadnja2</br>"; */
+
+ $tabela .= $tabelaZadnja1; //izpis 1. podvrstice s freq
+ if($niSodo && $t == ($steviloTabel-2) && $reziduali){ //ce ni sodo in je predzadnja podtabela in reziduali, dodaj se vse potrebno za prazen stolpec
+ //if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ $tabela .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+ $tabela .= $this->texNewLine;
+
+ if($steviloVmesnihVrstic > 1 && $tabela2!=''){ //ce je potrebno multicol prikazovanje
+ if($export_format != 'xls'){
+ $tabela .= ' \cline{2-'.$steviloStolpcevParameterTabular.'}'; //je potrebno urediti prvi stolpec tako, da ni crt med celicami
+ }
+ }else{
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ //echo "ni sodo $niSodo </br>";
+ if($steviloVmesnihVrstic > 1 && $tabela2!=''){ //ce je potrebno multirow prikazovanje
+ $tabela .= $tabelaZadnja2; //izpis 2. vrstice z odstotki
+ if($niSodo && $t == ($steviloTabel-2) && $reziduali){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ //if($niSodo && $t == ($steviloTabel-2)){ //ce ni sodo in je predzadnja podtabela, dodaj se vse potrebno za prazen stolpec
+ $tabela .= $this->MultiColCellLatex($steviloVmesnihStolpcevPodvrstic, '');
+ }
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex;
+ }
+ }
+ // skupni sestevki po stolpcih - ZADNJA VRSTICA - konec #############################################################################
+
+ $stevec++;
+ $tabela .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ }
+ }
+ }
+ }
+
+ /*zakljucek latex tabele*/
+ if($presirokaTabela == 0){ //ce ni presiroka tabela
+ $tabela .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ }
+ /*zaljucek latex tabele - konec */
+
+ //echo "showChart: ".$this->sessionData['showChart']."</br>";
+ // Izris grafa (ce je vklopljena nastavitev)
+ if($this->sessionData['showChart'] == '1' && $creport == false){
+ $tabela .= $this->displayCrosstabChart();
+ }
+ }
+ //echo "</br> Tex celotne tabele: ".$tabela."</br>";
+ return $tabela;
+ }
+
+ function displayCrosstabChart(){
+ global $lang;
+ $chart = '';
+
+ // Zgeneriramo id vsake tabele (glede na izbrani spremenljivki za generiranje)
+ $chartID = implode('_', $this->crosstabClass->variabla1[0]).'_'.implode('_', $this->crosstabClass->variabla2[0]);
+ $chartID .= '_counter_'.$this->counter;
+
+ $settings = $this->sessionData[$chartID];
+ $imgName = $settings['name'];
+
+ // Naslov posameznega grafa
+ if($settings['type'] == 1 || $settings['type'] == 4){
+ $title = $this->crosstabVars[0].'/'.$this->crosstabVars[1];
+ }
+ else{
+ $title = $this->crosstabVars[0];
+ }
+
+ $boldedTitle = $this->returnBold($this->encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+
+ copy('pChart/Cache/'.$imgName,'pChart/Cache/'.$imgName.'.png');
+ $texImageOnly = " \\includegraphics[scale=0.75]{".$imgName."} "; //latex za sliko
+
+ $chart .= $this->returnCentered($boldedTitle.$texImageOnly); //vrni sredinsko poravnana naslov in slika
+
+ return $chart;
+ }
+
+
+}
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaDesc.php b/admin/survey/export/latexclasses/Analize/AnalizaDesc.php
new file mode 100644
index 0000000..8433e9b
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaDesc.php
@@ -0,0 +1,319 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaFrekvenca.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+/**
+ * @desc Class za generacijo izvoza v Latex
+ */
+
+class AnalizaDesc extends LatexAnalysisElement{
+
+ var $anketa; // trenutna anketa (array)
+ var $spremenljivka; // trenutna spremenljivka
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $CID = null; # class za inkrementalno dodajanje fajlov
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ protected $tex;
+ var $currentStyle;
+
+ var $current_loop = 'undefined';
+
+ static public $_FILTRED_OTHER = array(); # filter za polja drugo
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+ protected $show_valid_percent;
+ protected $texBigSkip = '\bigskip';
+ protected $spaceBetweenTables = ' \newline \vspace*{1 cm} \newline';
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $sprID = null, $loop = null)
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ //if ( is_numeric($anketa) )
+ if ( is_numeric($anketa['id']) )
+ {
+ //$this->anketa['id'] = $anketa;
+ //$this->anketa['id'] = $anketa['id'];
+ $this->anketa = $anketa;
+ $this->spremenljivka = $sprID;
+
+
+ $loop = SurveyZankaProfiles :: Init($this->anketa['id'], $global_user_id);
+ $this->current_loop = ($loop != null) ? $loop : $this->current_loop;
+
+ //$hideAllSystem = SurveyDataSettingProfiles :: getSetting('hideAllSystem');
+ /* $hideAllSystem = SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT');
+ echo "hideAllSystem: ".$hideAllSystem."</br>"; */
+ //SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT')
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']))
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+
+ function init()
+ {
+ global $lang;
+
+ // array used to define the language and charset of the pdf file to be generated
+ $language_meta = Array();
+ $language_meta['a_meta_charset'] = 'UTF-8';
+ $language_meta['a_meta_dir'] = 'ltr';
+ $language_meta['a_meta_language'] = 'sl';
+ $language_meta['w_page'] = $lang['page'];
+
+ //set some language-dependent strings
+ $this->pdf->setLanguageArray($language_meta);
+
+ //set margins
+ $this->pdf->setPrintHeaderFirstPage(true);
+ $this->pdf->setPrintFooterFirstPage(true);
+ $this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
+ $this->pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
+ $this->pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
+
+ // set header and footer fonts
+ $this->pdf->setHeaderFont(Array(FNT_HEADER_TEXT, "I", FNT_HEADER_SIZE));
+ $this->pdf->setFooterFont(Array(FNT_HEADER_TEXT, 'I', FNT_HEADER_SIZE));
+
+
+ // set document information
+ $this->pdf->SetAuthor('An Order Form');
+ $this->pdf->SetTitle('An Order');
+ $this->pdf->SetSubject('An Order');
+
+ // set default header data
+ $this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()));
+
+ //set auto page breaks
+ $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
+
+ $this->pdf->SetFont(FNT_MAIN_TEXT, '', FNT_MAIN_SIZE);
+ //set image scale factor
+ $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
+ return true;
+ }
+
+
+ //function displayTableLatex($headFileName, $spremenljivka, $spid, $export_format, $hideEmpty){
+ function displayTableLatex($headFileName=null, $spremenljivka=null, $export_format='', $hideEmpty=null){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ //echo 'funkcija displayTableLatex</br>';
+ $this->export_format = $export_format;
+ $this->hideEmpty = $hideEmpty;
+ $tabela = '';
+
+ $this->headFileName = $headFileName;
+
+ #preberemo HEADERS iz datoteke
+ //SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
+
+ # polovimo opisne podatke
+ SurveyAnalysis::getDescriptives();
+
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 8;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*prva vrstica tabele*/
+ /*priprava polja z naslovi stolpcev*/
+ $text = array();
+
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_variable']).'}';
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_variable_text1']).'}';
+
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_m']).'}';
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_num_units']).'}';
+ //$text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_povprecje1']).'}';
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_povprecje_odstotek1']).'}';
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_odklon']).'}';
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_min']).'}';
+ $text[] = '\textbf{'.$this->encodeText($lang['srv_analiza_opisne_max']).'}';
+ /*priprava polja z naslovi stolpcev - konec*/
+
+ $tabela .= $this->tableRow($text);
+ /*prva vrstica tabele - konec*/
+
+ # dodamo še kontrolo če kličemo iz displaySingleVar
+ if (isset($_spid) && $_spid !== null) {
+ SurveyAnalysis::$_HEADERS = array($_spid => SurveyAnalysis::$_HEADERS[$_spid]);
+ }
+
+ /*izpis ostalih vrstic*/
+ foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
+ /* preverjamo ali je meta*/
+ if ($spremenljivka['tip'] != 'm'
+ && ( count(SurveyAnalysis::$_FILTRED_VARIABLES) == 0 || (count(SurveyAnalysis::$_FILTRED_VARIABLES) > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ))
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES)
+ && ($this->spremenljivka == $spid || $this->spremenljivka == null) ) {
+
+ $show_enota = false;
+ /* preverimo ali imamo samo eno variablo in če iammo enoto*/
+ if ((int)$spremenljivka['enota'] != 0 || $spremenljivka['cnt_all'] > 1 ) {
+ $show_enota = true;
+ }
+
+ /* izpišemo glavno vrstico z podatki*/
+ $_sequence = null;
+ /* za enodimenzijske tipe izpišemo podatke kar v osnovni vrstici*/
+ if (!$show_enota) {
+// if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3
+// || $spremenljivka['tip'] == 4 || $spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 8) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ //self::displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ $tabela .= $this->displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ } else {
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ $variable = $spremenljivka['grids'][0]['variables'][0];
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $show_enota = false;
+ }
+ //self::displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ $tabela .= $this->displayDescriptivesSpremenljivkaRow($spid, $spremenljivka,$show_enota,$_sequence);
+ /*zloopamo skozi variable*/
+ $_sequence = null;
+ $grd_cnt=0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ if (count($spremenljivka['grids']) > 1 && $grd_cnt !== 0 && $spremenljivka['tip'] != 6) {
+ $grid['new_grid'] = true;
+ }
+ $grd_cnt++;
+ /* dodamo dodatne vrstice z albelami grida*/
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ /* dodamo ostale vrstice*/
+ $do_show = ($variable['other'] !=1 && ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3 || $spremenljivka['tip'] == 5 || $spremenljivka['tip'] == 8 ))
+ ? false
+ : true;
+ if ($do_show) {
+ //self::displayDescriptivesVariablaRow($spremenljivka,$grid,$variable,$_css);
+ $tabela .= $this->displayDescriptivesVariablaRow($spremenljivka,$grid,$variable,$_css);
+
+ }
+ $grid['new_grid'] = false;
+
+ }
+ }
+ } //else: if (!$show_enota)
+ } // end if $spremenljivka['tip'] != 'm'
+ } // end foreach SurveyAnalysis::$_HEADERS
+
+
+ /*zakljucek latex tabele*/
+ $tabela .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele - konec */
+ //echo "</br> Tex celotne tabele: ".$tabela."</br>";
+ return $tabela;
+ }
+}
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaFreq.php b/admin/survey/export/latexclasses/Analize/AnalizaFreq.php
new file mode 100644
index 0000000..8945266
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaFreq.php
@@ -0,0 +1,384 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaFrekvenca.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+ define ('MEJA_DOLZINA_VPRASANJA', 132);
+
+/**
+ * @desc Class za generacijo izvoza v Latex
+ */
+
+class AnalizaFreq extends LatexAnalysisElement{
+
+ var $anketa; // trenutna anketa (array)
+ var $spremenljivka; // trenutna spremenljivka
+
+ private $headFileName = null; # pot do header fajla
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ protected $tex;
+ var $currentStyle;
+
+ var $current_loop = 'undefined';
+
+ static public $_FILTRED_OTHER = array(); # filter za polja drugo
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+ protected $show_valid_percent;
+ protected $texBigSkip = '\bigskip';
+ protected $spaceBetweenTables = ' \newline \vspace*{1 cm} \newline';
+
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $sprID = null, $loop = null){
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa['id']) ){
+ $this->anketa = $anketa;
+ $this->spremenljivka = $sprID;
+ }
+ else{
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+
+ return false;
+ }
+
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id'])){
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+
+
+ function displayTableLatex($headFileName=null, $spremenljivka=null, $spid=null, $export_format='', $hideEmpty=null){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+
+ $this->export_format = $export_format;
+ $this->hideEmpty = $hideEmpty;
+ $tabela = '';
+
+ $this->headFileName = $headFileName;
+
+ //TODO: Omenjene datoteke že generiramo v LatexAnalysis in tukaj za vsako vrstico res ni potrebe še enkrat to generirat
+ /*
+ #preberemo HEADERS iz datoteke
+ SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
+
+ # polovimo frekvence
+ SurveyAnalysis::getFrequencys();
+
+ #odstranimo sistemske variable
+ SurveyAnalysis::removeSystemVariables();
+
+
+ ###
+ //SurveyMissingProfiles :: Init($spremenljivka['id'], $global_user_id);
+ */
+
+
+ ####
+
+ //TODO: Spremenljivki se nikjer ne kliče
+ //$vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+ //$line_break = '';
+
+ //echo "Spr tip v Sums: ".$spremenljivka['tip']."</br>";
+
+ #prikazujemo v odvisnosti od kategorije spremenljivke
+ switch ($spremenljivka['tip']) {
+ case 1: # radio - prikjaže navpično
+ case 2: #checkbox če je dihotomna:
+ case 3: # dropdown - prikjaže navpično
+ case 6: # multigrid
+ case 4: # text
+ case 7:# variabla tipa »število«
+ case 8: # datum
+ case 16: #multicheckbox če je dihotomna:
+ case 17: #razvrščanje če je ordinalna
+ case 18: # vsota
+ case 19: # multitext
+ case 20: # multi number
+ case 21: # besedilo*
+ case 22: # kalkulacija
+ //self::frequencyVertical($spid);
+ $tabela .= self::frequencyVertical($spid, $export_format);
+ //$tabela .= $this->spaceBetweenTables;
+ break;
+ case 5:
+ # nagovor
+ //pdfIzvozAnalizaSums::sumNagovor($spid,'freq');
+ $tabela .= $this->sumNagovor($spid,'freq');
+ //$tabela .= $this->spaceBetweenTables;
+ break;
+ }
+ //echo "</br> Tex celotne tabele: ".$tabela."</br>";
+ return $tabela;
+ }
+
+
+ /** Izriše frekvence v vertikalni obliki z Latex
+ *
+ * @param unknown_type $spid
+ */
+ function frequencyVertical($spid=null, $export_format='') {
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (SurveyAnalysis::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = SurveyAnalysis::getNumRecords();
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 6;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ //$tex .= '\keepXColumns'; //potrebno dodati pred tabelo, da se obdrzi sirina stolpca
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloOstalihStolpcev."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloOstalihStolpcev."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloOstalihStolpcev.'}{>{\hsize=\dimexpr '.($steviloOstalihStolpcev+1).'\hsize + '.($steviloOstalihStolpcev+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloOstalihStolpcev."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloOstalihStolpcev."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica
+ $tex .= self::tableHeader();
+ /*Konec naslovnih vrstic*/
+
+ $_answersOther = array();
+
+ /* dodamo opcijo kje izrisujemo legendo*/
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false);
+
+ /* izpis veljavnih odgovorov*/
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+
+ # dodamo dodatne vrstice z albelami grida
+ if ($_variables_count > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if (($variable['text'] != true && $variable['other'] != true)
+ || (in_array($spremenljivka['tip'],array(4,8,21,22)))){
+ # dodamo ime podvariable
+ //if ($_variables_count > 1 && in_array($spremenljivka['tip'],array(2,6,7,16,17,18,19,20,21))) {
+ if ($inline_legenda) {
+ $tex .= self::outputSubVariablaVertical($spremenljivka,$variable,$grid,$spid,$options);
+ }
+
+ $maxAnswer = (SurveyDataSettingProfiles :: getSetting('numOpenAnswers') > 0) ? SurveyDataSettingProfiles :: getSetting('numOpenAnswers') : 30;
+ $counter = 0;
+ $_kumulativa = 0;
+ //SurveyAnalysis::$_FREQUENCYS[$_sequence]
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 /*&& $counter < $maxAnswer*/ || true) { # izpisujemo samo tiste ki nisno 0
+ if (in_array($spremenljivka['tip'],array(4,7,8,19,20,21))) { // text, number, datum, mtext, mnumber, text*
+ $options['isTextAnswer'] = true;
+ # ali prikažemo vse odgovore ali pa samo toliko koliko je nastavljeno v TEXT_ANSWER_LIMIT
+ $options['textAnswerExceed'] = ($counter >= TEXT_ANSWER_LIMIT && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > TEXT_ANSWER_LIMIT+2) ? true : false; # ali začnemo skrivati tekstovne odgovore
+ } else {
+ $options['isTextAnswer'] = false;
+ $options['textAnswerExceed'] = false;
+ }
+ //$counter = pdfIzvozAnalizaSums::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ $tex .= $this->outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ //$counter = pdfIzvozAnalizaSums::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ //$tex .= $this->outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ $tex .= self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ $_Z_MV = !$this->hideEmpty;
+ if($_Z_MV){ //ce je potrebno izpisati tudi manjkajoce
+ $tex .= $this->encodeText($lang['srv_anl_missing1']);
+ }
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ //$counter = pdfIzvozAnalizaSums::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ $tex .= $this->outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ //$counter = pdfIzvozAnalizaSums::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ $tex .= $this->outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ //$counter = pdfIzvozAnalizaSums::outputSumaVertical($counter,$_sequence,$spid,$options);
+ $tex .= $this->outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+ //echo "tex: ".$tex;
+ return $tex;
+ }
+
+ function outputSubVariablaVertical($spremenljivka=null,$variable=null,$grid=null,$spid=null,$_options = array()) {
+ global $lang;
+ $texOutputSubVariablaVertical='';
+ $text = array();
+
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'textAnswerExceed'=>false # ali presegamo število tekstovnih odgovorov za prikaz
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $text[] = $this->encodeText($variable['variable']);
+
+ $text[] = $this->encodeText($variable['naslov']);
+
+ $text[] = '';
+ $text[] = '';
+ $text[] = '';
+ $text[] = '';
+
+ $texOutputSubVariablaVertical .= self::tableRow($text);
+
+ return $texOutputSubVariablaVertical;
+ }
+
+
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ function formatNumber($value=null, $digit=0, $sufix=""){
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+ function drawLine(){
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+}
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaMean.php b/admin/survey/export/latexclasses/Analize/AnalizaMean.php
new file mode 100644
index 0000000..e2bceba
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaMean.php
@@ -0,0 +1,371 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+
+/** Class za generacijo izvoza v Latex
+ *
+ * @desc: po novem je potrebno form elemente generirati rocno kot slike
+ *
+ */
+class AnalizaMean extends LatexAnalysisElement{
+
+ var $anketa;// = array(); // trenutna anketa
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+ var $db_table = '';
+
+ public $meansClass = null; //means class
+
+ var $meanData1;
+ var $meanData2;
+
+ var $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $podstran = 'mean')
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa['id']) )
+ {
+ $this->anketa['id'] = $anketa;
+ $this->anketa['podstran'] = $podstran;
+ // create new PDF document
+ //$this->pdf = new enka_TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']))
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+
+ public function displayMeansTable($_means=null, $meansClass=null, $export_format='') {
+ global $lang;
+ $tabela = '';
+ $this->meansClass = $meansClass;
+
+ #število vratic in število kolon
+ $cols = count($_means);
+
+ # preberemo kr iz prvega loopa
+ $rows = count($_means[0]['options']);
+
+ // sirina ene celice
+ $singleWidth = round( 180 / $cols / 2 );
+
+ // visina prve vrstice
+/* $firstHeight = 0;
+ for ($i = 0; $i < $cols; $i++) {
+ $label1 = $this->meansClass->getSpremenljivkaTitle($_means[$i]['v1']);
+ $firstHeight = ($firstHeight > $this->getCellHeight($this->encodeText($label1), $singleWidth*2)) ? $firstHeight : $this->getCellHeight($this->encodeText($label1), $singleWidth*2);
+ } */
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 3;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+
+ //prva vrstica tabele
+ $label2 = $this->meansClass->getSpremenljivkaTitle($_means[0]['v2']);
+
+ //$this->pdf->MultiCell(80, $firstHeight, $this->encodeText($label2), 'TLR', 'C', 0, 0, 0 ,0, true);
+ $prva = '';
+ for ($i = 0; $i < $cols; $i++) {
+ $label1 = $this->meansClass->getSpremenljivkaTitle($_means[$i]['v1']);
+ //$this->pdf->MultiCell($singleWidth*2, $firstHeight, $this->encodeText($label1), 1, 'C', 0, 0, 0 ,0, true);
+ $prva .= $label1.' ';
+ }
+
+ $steviloPodStolpcev1 = $cols+1;
+
+ if($export_format != 'xls'){
+ $poravnava = "C";
+ }else{
+ $poravnava = "c";
+ }
+
+ ############
+ $steviloTabColSep = ($steviloPodStolpcev1-1)*2;
+ $steviloArrayrulewidth = ($steviloPodStolpcev1-1);
+
+ if($export_format=='pdf'){
+ $tabela .= $this->encodeText($label2)." & \multicolumn{".$steviloPodStolpcev1."}{>{\hsize=\dimexpr".$steviloPodStolpcev1."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}".$poravnava."|}{".$this->encodeText($prva)."} ".$this->texNewLine;
+ }elseif($export_format=='rtf'){
+ $tabela .= $this->encodeText($label2)." & \multicolumn{".$steviloPodStolpcev1."}{".$poravnava."|}{".$this->encodeText($prva)."} ".$this->texNewLine;
+ }
+ ############
+
+ //$tabela .= $this->encodeText($label2)." & \multicolumn{".$steviloPodStolpcev1."}{>{\hsize=\dimexpr".$steviloPodStolpcev1."\hsize+".$steviloPodStolpcev1."\\tabcolsep+\arrayrulewidth\\relax}".$poravnava."|}{".$this->encodeText($prva)."} ".$this->texNewLine;
+ //$tabela .= $this->encodeText($label2)." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($prva)."} ".$this->texNewLine;
+ //$tabela .= $this->encodeText($label2)." & \multicolumn{".$steviloPodStolpcev1."}{".$poravnava."|}{".$this->encodeText($prva)."} ".$this->texNewLine;
+ //$tabela .= $this->encodeText($label2)." & \multicolumn{".$steviloPodStolpcev1."}{C|}{".$this->encodeText($prva)."} ".$this->texNewLine;
+ //$tabela .= $this->encodeText($label2).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1).'\hsize + '.($steviloPodStolpcev1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($prva).'} '.$this->texNewLine;
+
+ //prva vrstica tabele - konec
+
+ //druga vrstica tabele
+ //$this->pdf->MultiCell(80, 7, $this->encodeText(''), 'BLR', 'C', 0, 0, 0 ,0, true);
+ //echo "stolpci: ".$cols."</br>";
+ //echo "vrstice: ".$rows."</br>";
+
+ $druga = array();
+ $steviloPodStolpcev = $steviloPodStolpcev1 + 1;
+ //$tabela .= "\\cline{2-".$steviloPodStolpcev."} & "; //horizontalna vrstica od 2 do zadnje celice
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloPodStolpcev."} "; //horizontalna vrstica od 2 do zadnje celice
+ }
+
+ $tabela .= " & ";
+
+ $brezHline = $this->getBrezHline($export_format);
+
+ for ($i = 0; $i < $cols; $i++) {
+ $druga[] = $this->encodeText($lang['srv_means_label']);
+ $druga[] = $this->encodeText($lang['srv_means_label4']);
+ //$this->pdf->MultiCell($singleWidth, 7, $this->encodeText($lang['srv_means_label']), 1, 'C', 0, 0, 0 ,0, true);
+ //$this->pdf->MultiCell($singleWidth, 7, $this->encodeText($lang['srv_means_label4']), 1, 'C', 0, 0, 0 ,0, true);
+ }
+ //$this->pdf->MultiCell(1, 7, $this->encodeText(''), 0, 'C', 0, 1, 0 ,0, true);
+ $tabela .= $this->tableRow($druga, $brezHline)." ";
+ //druga vrstica tabele - konec
+
+ //vrstice s podatki
+ if (count($_means[0]['options']) > 0) {
+
+ foreach ($_means[0]['options'] as $ckey2 =>$crossVariabla2) {
+ $dataVrstica = array();
+ $variabla = $crossVariabla2['naslov'];
+ # če ni tekstovni odgovor dodamo key
+ if ($crossVariabla2['type'] !== 't' ) {
+ if ($crossVariabla2['vr_id'] == null) {
+ $variabla .= ' ( '.$ckey2.' )';
+ } else {
+ $variabla .= ' ( '.$crossVariabla2['vr_id'].' )';
+ }
+ }
+ //$this->pdf->MultiCell(80, 7, $this->encodeText($variabla), 1, 'C', 0, 0, 0 ,0, true);
+ $dataVrstica[] = $this->encodeText($variabla);
+
+ # celice z vsebino
+ for ($i = 0; $i < $cols; $i++) {
+ //$dataVrstica[] = $this->encodeText($this->meansClass->formatNumber($_means[$i]['result'][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL')));
+ $dataVrstica[] = $this->encodeText(self::formatNumber($_means[$i]['result'][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL')));
+ $dataVrstica[] = $this->encodeText((int)$_means[$i]['sumaVrstica'][$ckey2]);
+ //$this->pdf->MultiCell($singleWidth, 7, $this->encodeText($this->meansClass->formatNumber($_means[$i]['result'][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'))), 1, 'C', 0, 0, 0 ,0, true);
+ //$this->pdf->MultiCell($singleWidth, 7, $this->encodeText((int)$_means[$i]['sumaVrstica'][$ckey2]), 1, 'C', 0, 0, 0 ,0, true);
+ }
+ //$this->pdf->MultiCell(1, 7, $this->encodeText(''), 0, 'C', 0, 1, 0 ,0, true);
+ $tabela .= $this->tableRow($dataVrstica, $brezHline)." ";
+ }
+ }
+ // vrstice s podatki - konec
+
+ //SKUPAJ
+ $skupajVrstica = array();
+ //$this->pdf->MultiCell(80, 7, $this->encodeText($lang['srv_means_label3']), 1, 'C', 0, 0, 0 ,0, true);
+ $skupajVrstica[] = $this->encodeText($lang['srv_means_label3']);
+ for ($i = 0; $i < $cols; $i++) {
+ //$skupajVrstica[] = $this->encodeText($this->meansClass->formatNumber($_means[$i]['sumaMeans'], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL')));
+ $skupajVrstica[] = $this->encodeText(self::formatNumber($_means[$i]['sumaMeans'], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL')));
+ //$this->pdf->MultiCell($singleWidth, 7, $this->encodeText($this->meansClass->formatNumber($_means[$i]['sumaMeans'], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'))), 1, 'C', 0, 0, 0 ,0, true);
+ $skupajVrstica[] = $this->encodeText((int)$_means[$i]['sumaSkupna']);
+ //$this->pdf->MultiCell($singleWidth, 7, $this->encodeText((int)$_means[$i]['sumaSkupna']), 1, 'C', 0, 0, 0 ,0, true);
+ }
+ //$this->pdf->MultiCell(1, 7, $this->encodeText(''), 0, 'C', 0, 1, 0 ,0, true);
+ $tabela .= $this->tableRow($skupajVrstica, $brezHline)." ";
+ //SKUPAJ - konec
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tabela .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+ return $tabela;
+ }
+
+ public function displayChart($counter=null, $meanData1=null, $meanData2=null, $sessionData=null){
+ global $lang, $site_path;
+ $texImage = '';
+
+ $path2ChartsImgs = $site_path.'admin/survey/pChart/Cache/';
+
+ //echo $path2ChartsImgs."</br>";
+
+ $variables1 = $meanData1;
+ $variables2 = $meanData2;
+
+ $pos1 = floor($counter / count($variables2));
+ $pos2 = $counter % count($variables2);
+
+ $chartID = implode('_', $variables1[$pos1]).'_'.implode('_', $variables2[$pos2]);
+ $chartID .= '_counter_'.$counter;
+
+ $settings = $sessionData['mean_charts'][$chartID];
+ $imgName = $settings['name'];
+
+ $size = getimagesize('pChart/Cache/'.$imgName);
+ $height = $size[1] / 4;
+
+ copy('pChart/Cache/'.$imgName,'pChart/Cache/'.$imgName.'.png');
+ //$this->pdf->Image('pChart/Cache/'.$imgName, $x='', $y='', $w=200, $h, $type='PNG', $link='', $align='N', $resize=true, $dpi=1600, $palign='C', $ismask=false, $imgmask=false, $border=0);
+
+ $texImage .= "\\begin{center} \\includegraphics[scale=0.75]{".$path2ChartsImgs.$imgName."} \\end{center}"; //latex za sliko, ki je sredinsko poravnana
+
+ //echo "img name: ".$imgName."</br>";
+
+ //unlink('pChart/Cache/'.$imgName.'.png');
+ return $texImage;
+ }
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="...")
+ {
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function drawLine()
+ {
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+ function getCellHeight($string='', $width=null){
+
+ $this->pdf->startTransaction();
+ // get the number of lines calling you method
+ $linecount = $this->pdf->MultiCell($width, 0, $string, 0, 'L', 0, 0, '', '', true, 0, false, true, 0);
+ // restore previous object
+ $this->pdf = $this->pdf->rollbackTransaction();
+
+ $height = ($linecount <= 1) ? 4.7 : $linecount * ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio()) + 2;
+
+ return $height;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaMultiCrosstab.php b/admin/survey/export/latexclasses/Analize/AnalizaMultiCrosstab.php
new file mode 100644
index 0000000..02f6eb9
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaMultiCrosstab.php
@@ -0,0 +1,1909 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php');
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+ define ('SNIPPET_LENGTH', 300);
+
+
+/** Class za generacijo latex
+ *
+ *
+ *
+ */
+class AnalizaMultiCrosstab extends LatexAnalysisElement {
+
+ var $anketa;// = array(); // trenutna anketa
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+ var $db_table = '';
+
+ public $multiCrosstabClass = null; // crosstab class
+
+ private $cellWidth = 1; // sirina celice s podatki
+ private $cellHeight = 1; // visina celice s podadtki
+ private $cellSpan = 1; // stevilo vrstic v celici s podatki
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+ protected $show_valid_percent;
+ protected $texBigSkip = '\bigskip';
+ protected $spaceBetweenTables = ' \newline \vspace*{1 cm} \newline';
+
+ protected $tableSettingsNumerus;
+ protected $tableSettingsPercent;
+ protected $tableSettingsSums;
+ protected $tableSettingsAvgVar;
+ protected $tableSettingsDelezVar;
+
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null){
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ //if ( is_numeric($anketa) ){
+ if ( is_numeric($anketa['id']) ){
+ //$this->anketa['id'] = $anketa;
+ $this->anketa = $anketa;
+ // create new PDF document
+ //$this->pdf = new enka_TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
+ }
+ else{
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+
+ return false;
+ }
+ $_GET['a'] = A_ANALYSIS;
+
+
+ //ustvarimo multicrosstabs objekt
+ //$this->multiCrosstabClass = new SurveyMultiCrosstabs($anketa);
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init()){
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) ){
+ $this->anketa['uid'] = $global_user_id;
+
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ SurveyDataSettingProfiles::Init($this->anketa['id']);
+ }
+ else
+ return false;
+
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+ function checkCreate(){
+ return $this->pi['canCreate'];
+ }
+
+ function getFile($fileName=''){
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+ public function displayTable($multiCrosstabClass=null, $export_format=''){
+ global $site_path;
+ global $lang;
+
+ $tabela = '';
+
+ $this->multiCrosstabClass = $multiCrosstabClass;
+
+ // Napolnimo variable ki so ze izbrane
+ $this->multiCrosstabClass->getSelectedVars();
+
+ // Izpisemo naslov tabele
+ //echo "naslov tabele: ".$this->encodeText($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['title'])."</br>";
+ $tabela .= '\textbf{'.$this->encodeText($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['title']).'}'.$this->texBigSkip.$this->texNewLine;
+ //echo $tabela."</br>";
+/* $this->pdf->setFont('','B','10');
+ $this->pdf->MultiCell(150, 5, $this->encodeText($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['title']), 0, 'L', 0, 1, 0 ,0, true);
+ $this->pdf->ln(5);
+ $this->pdf->setFont('','','6'); */
+
+
+ // TABELA
+
+ // Najprej izracunamo dimenzije
+ $lineHeight = 6;
+ $fullWidth = 270;
+
+ if($this->multiCrosstabClass->rowSpan == 0)
+ //$colspan = 1;
+ $colspan = 2;
+ elseif(!$this->multiCrosstabClass->rowLevel2)
+ $colspan = 2;
+ else
+ $colspan = 4;
+
+ $metaWidth = $colspan * 35;
+ $dataWidth = $fullWidth - $metaWidth;
+
+ $dataCellSpan = 0;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1)
+ $dataCellSpan++;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1)
+ $dataCellSpan++;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] != '')
+ $dataCellSpan++;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] != '')
+ $dataCellSpan++;
+
+ $this->cellSpan = ($dataCellSpan == 0) ? 1 : $dataCellSpan;
+ $this->cellHeight = ($this->cellSpan > 1) ? $this->cellSpan * 5 : $lineHeight;
+
+ $this->tableSettingsNumerus = $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'];
+ $this->tableSettingsPercent = $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'];
+ $this->tableSettingsSums = $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['sums'];
+ $this->tableSettingsAvgVar = $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'];
+ $this->tableSettingsDelezVar = $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'];
+
+ $steviloPodstolpcevV1 = array(); //hrani stevilo podstolpcev za 1. vrstico
+ $steviloPodstolpcevV2 = array(); //hrani stevilo podstolpcev za 2. vrstico
+ $steviloPodstolpcevV3 = array(); //hrani stevilo podstolpcev za 3. vrstico
+ $indeksMultiRow = array(); //hrani, kje je potrebna crta med vrsticami tabele (1) in kje ne (0)
+
+ //$tabela .= $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'];
+
+ $cntVerVars=0;
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $var){
+ $cntVerVars++;
+ }
+ //echo "cntVerVars: ".$cntVerVars."</br>";
+
+ if($this->multiCrosstabClass->colSpan == 0){
+ //$this->cellWidth = $dataWidth/2;
+ //$this->pdf->MultiCell($metaWidth, 0, '', 'B', 'L', 0, 1, 0 ,0, true);
+ $steviloPodstolpcev = 1;
+ $steviloPodstolpcevV1[] = $steviloPodstolpcev;
+ }
+ // Imamo 2 nivoja
+ elseif($this->multiCrosstabClass->colLevel2){
+ //echo "vertikalno izbrane sprem. 1. vrstica, ko imamo 2 nivoja</br>";
+
+ $this->cellWidth = $dataWidth / $this->multiCrosstabClass->colSpan;
+
+ //pridobivanje podatkov zadnja vrstica
+ if(count($this->multiCrosstabClass->selectedVars['ver'])){
+ $cetrtaVrsticaVert = array();
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $parentVar){
+ $steviloPodstolpcev = 0;
+ $cetrtaVrsticaVertTmp = array(); //za pridobitev stevila podstolpcev za posamezno spremenljivko, ce jih je vec
+ // ce imamo childe na 2. nivoju
+ if(count($parentVar['sub']) > 0){
+ foreach($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options'] as $option){
+ foreach($parentVar['sub'] as $var){
+ foreach($this->multiCrosstabClass->variablesList[$var['spr']]['options'] as $suboption){
+ //$this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->snippet($suboption, 25), 1, 'C', 0, 0, 0 ,0, true, $stretch=0, $ishtml=false, $autopadding=false, $maxh=0);
+ if($export_format != 'xls'){
+ $cetrtaVrsticaVertText = $this->snippet($suboption, 25);
+ $cetrtaVrsticaVertTmpText = $this->snippet($suboption, 25);
+ }else{
+ $cetrtaVrsticaVertText = $suboption;
+ $cetrtaVrsticaVertTmpText = $suboption;
+ }
+ $cetrtaVrsticaVert[] = $cetrtaVrsticaVertText;
+ $cetrtaVrsticaVertTmp[] = $cetrtaVrsticaVertTmpText;
+ $indeksMultiRow[] = 1;
+ }
+ $steviloPodstolpcevV3[] = count($this->multiCrosstabClass->variablesList[$var['spr']]['options']);
+ }
+ $steviloPodstolpcev = count($cetrtaVrsticaVertTmp);
+ }
+ }
+ else{
+ //$this->pdf->MultiCell($this->cellWidth*count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options']), $lineHeight, '', 0, 'C', 0, 0, 0 ,0, true);
+
+ foreach($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options'] as $option){
+ //$this->pdf->MultiCell($this->cellWidth, $lineHeight*2, $this->snippet($option, 25), 1, 'C', 0, 0, 0 ,0, true);
+
+ /* $cetrtaVrsticaVert[] = $this->snippet($option, 25);
+ $cetrtaVrsticaVertTmp[] = $this->snippet($suboption, 25); */
+ if($export_format != 'xls'){
+ $cetrtaVrsticaVertText = $this->snippet($option, 25);
+ $cetrtaVrsticaVertTmpText = $this->snippet($suboption, 25);
+ }else{
+ $cetrtaVrsticaVertText = $option;
+ $cetrtaVrsticaVertTmpText = $suboption;
+ }
+ $cetrtaVrsticaVert[] = $cetrtaVrsticaVertText;
+ $cetrtaVrsticaVertTmp[] = $cetrtaVrsticaVertTmpText;
+ $indeksMultiRow[] = 0;
+ }
+ $steviloPodstolpcev = count($cetrtaVrsticaVertTmp);
+ $steviloPodstolpcevV3[] = count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options']);
+ }
+ if($steviloPodstolpcev!=0){
+ $steviloPodstolpcevV1[] = $steviloPodstolpcev;
+ }
+ }
+ }
+ //pridobivanje podatkov zadnja vrstica - konec
+
+
+ // Izrisemo VERTIKALNO izbrane spremenljivkec - 1. vrstica
+ //$this->pdf->MultiCell($metaWidth, $lineHeight, '', 0, 'L', 0, 0, 0 ,0, true);
+
+ if(count($this->multiCrosstabClass->selectedVars['ver'])){
+ $prvaVrsticaVert = array();
+
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $var){
+
+ // Ce imamo tudi 2. nivo pri doloceni spremenljivki
+ if(count($var['sub']) > 0){
+ $rowspan = 1;
+ $width = $this->cellWidth * count($this->multiCrosstabClass->variablesList[$var['sub'][0]['spr']]['options']) * count($this->multiCrosstabClass->variablesList[$var['spr']]['options']);
+ if($export_format != 'xls'){
+ $naslov = $this->encodeText($this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25));
+ }else{
+ $naslov = $this->encodeText($this->multiCrosstabClass->variablesList[$var['spr']]['naslov']);
+ }
+ }
+ else{
+ $rowspan = 2;
+ $width = $this->cellWidth * count($this->multiCrosstabClass->variablesList[$var['spr']]['options']);
+ if($export_format != 'xls'){
+ $naslov = '\multirow{2}{*}{ '.$this->encodeText($this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25)).' }';
+ }else{
+ $naslov = $this->encodeText($this->multiCrosstabClass->variablesList[$var['spr']]['naslov']);
+ }
+ }
+ //$this->pdf->MultiCell($width, $lineHeight*$rowspan, $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25), 1, 'C', 0, 0, 0 ,0, true);
+
+ //$naslov = $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25);
+ //$naslov = $this->encodeText($this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25));
+
+ $prvaVrsticaVert[] = $naslov;
+ //echo "naslov: ".$naslov."</br>";
+ }
+ }
+ //$this->pdf->MultiCell(1, $lineHeight, '', 0, 'L', 0, 1, 0 ,0, true);
+
+ // Izris vrstic za 2. nivo - 3. in 4. vrstica
+ //$this->pdf->MultiCell($metaWidth, $lineHeight, '', 0, 'L', 0, 0, 0 ,0, true);
+ if(count($this->multiCrosstabClass->selectedVars['ver'])){
+ $tretjaVrsticaVert = array();
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $parentVar){
+ // ce imamo childe na 2. nivoju
+ if(count($parentVar['sub']) > 0){
+ //$tretjaVrsticaVert = array();
+ foreach($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options'] as $option){
+ $width = $this->cellWidth * count($this->multiCrosstabClass->variablesList[$parentVar['sub'][0]['spr']]['options']);
+ foreach($parentVar['sub'] as $var){
+ //$this->pdf->MultiCell($width, $lineHeight, $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25), 1, 'C', 0, 0, 0 ,0, true);
+ if($export_format != 'xls'){
+ $tretjaVrsticaVert[] = $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25);
+ }else{
+ $tretjaVrsticaVert[] = $this->multiCrosstabClass->variablesList[$var['spr']]['naslov'];
+ }
+
+ }
+
+ }
+ }
+ else{
+ //$this->pdf->MultiCell($this->cellWidth*count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options']), $lineHeight, '', 0, 'C', 0, 0, 0 ,0, true);
+
+ //$tretjaVrsticaVert[] = '';
+ $tretjaVrsticaVert[] = '\multirow{2}{*}{}';
+
+
+ }
+ }
+ //echo "3. vrstica podvrstice: ".count($tretjaVrsticaVert)."</br>";
+ }
+
+ // Izrisemo VARIABLE za spremenljivko - 2. vrstica
+ //$this->pdf->MultiCell($metaWidth, $lineHeight, '', 0, 'L', 0, 0, 0 ,0, true);
+ if(count($this->multiCrosstabClass->selectedVars['ver'])){
+ $drugaVrsticaVert = array();
+
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $var){
+
+ // Ce imamo tudi 2. nivo pri doloceni spremenljivki
+ if(count($var['sub']) > 0){
+ $drugaVrsticaVertTmp = array();
+ //$width = $this->cellWidth * count($this->multiCrosstabClass->variablesList[$var['sub'][0]['spr']]['options']);
+ foreach($this->multiCrosstabClass->variablesList[$var['spr']]['options'] as $option){
+ //$this->pdf->MultiCell($width, $lineHeight, $this->snippet($option, 25), 1, 'C', 0, 0, 0 ,0, true);
+ if($export_format != 'xls'){
+ $drugaVrsticaVert[] = $this->snippet($option, 25);
+ $drugaVrsticaVertTmp[] = $this->snippet($option, 25);
+ }else{
+ $drugaVrsticaVert[] = $option;
+ $drugaVrsticaVertTmp[] = $option;
+ }
+ }
+
+ foreach($drugaVrsticaVertTmp as $druga){
+ $steviloPodstolpcev = 0;
+ for($i=0;$i<count($var['sub']);$i++){
+ $steviloPodstolpcev = $steviloPodstolpcev + count($this->multiCrosstabClass->variablesList[$var['sub'][$i]['spr']]['options']);
+ }
+ $steviloPodstolpcevV2[] = $steviloPodstolpcev;
+ }
+ }
+ else{
+ $drugaVrsticaVert[] = '';
+ $steviloPodstolpcevV2[] = count($this->multiCrosstabClass->variablesList[$var['spr']]['options']);
+ }
+ }
+ }
+ //$this->pdf->MultiCell(1, $lineHeight, '', 0, 'L', 0, 1, 0 ,0, true);
+ }
+ // Imamo samo 1 nivo
+ else{
+ // Izrisemo VERTIKALNO izbrane spremenljivkec - 1. vrstica
+ //echo "Samo 1 nivo </br>";
+ // Izracunamo sirine celic
+ $this->cellWidth = $dataWidth / $this->multiCrosstabClass->fullColSpan;
+
+ //$this->pdf->MultiCell($metaWidth, $lineHeight, '', 0, 'C', 0, 0, 0 ,0, true);
+
+ if(count($this->multiCrosstabClass->selectedVars['ver'])){
+ $prvaVrsticaVert = array();
+
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $var){
+ $naslov = $this->multiCrosstabClass->variablesList[$var['spr']]['naslov'];
+
+ if($naslov!=''||($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['sums'] == 1 && !$this->multiCrosstabClass->rowLevel2)){
+ if($export_format != 'xls'){
+ $prvaVrsticaVert[] = $this->snippet($naslov, 35);
+ }else{
+ $prvaVrsticaVert[] = $naslov;
+ }
+ }
+
+ //$prvaVrsticaVert[] = $this->snippet($naslov, 35);
+
+ //$sprWidth = count($this->multiCrosstabClass->variablesList[$var['spr']]['options']) * $this->cellWidth;
+ //if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['sums'] == 1 && !$this->multiCrosstabClass->rowLevel2)
+ //$sprWidth += $this->cellWidth;
+ //$this->pdf->MultiCell($sprWidth, $lineHeight, $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 35), 1, 'C', 0, 0, 0 ,0, true);
+
+ }
+
+ //$this->pdf->MultiCell(1, $lineHeight, '', 0, 'C', 0, 1, 0 ,0, true);
+ //$tabela .= $this->tableRow($prvaVrsticaVert);
+ //echo $tabela;
+ }
+ // Nimamo nobene vertikalne spremenljivke in 2 horizontalni
+ elseif($this->multiCrosstabClass->rowLevel2){
+ //$this->pdf->MultiCell($dataWidth, $lineHeight, '', 0, 'C', 0, 0, 0 ,0, true);
+ echo "Nimamo nobene vertikalne spremenljivke in 2 horizontalni </br>";
+ }
+
+
+ // Izrisemo VARIABLE za spremenljivko - 2. vrstica
+ if(count($this->multiCrosstabClass->selectedVars['ver'])){
+ $drugaVrsticaVert = array();
+
+ // Iracunamo visino najvisje celice
+ $cellHeight = $lineHeight;
+/* foreach($this->multiCrosstabClass->selectedVars['ver'] as $var){
+
+ foreach($this->multiCrosstabClass->variablesList[$var['spr']]['options'] as $option){
+ $height = $this->getCellHeight($this->snippet($option, 25), $this->cellWidth);
+
+ $cellHeight = ($height > $cellHeight) ? $height : $cellHeight;
+ }
+ } */
+
+ //$this->pdf->MultiCell($metaWidth, $cellHeight, '', 'B', 'C', 0, 0, 0 ,0, true);
+
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $var){
+ $steviloPodstolpcev = 0;
+ // Loop cez variable spremenljivke
+ foreach($this->multiCrosstabClass->variablesList[$var['spr']]['options'] as $option){
+ //$this->pdf->MultiCell($this->cellWidth, $cellHeight, $this->snippet($option, 25), 1, 'C', 0, 0, 0 ,0, true);
+ if($export_format != 'xls'){
+ $drugaVrsticaVert[] = $this->snippet($option, 25);
+ }else{
+ $drugaVrsticaVert[] = $option;
+ }
+ }
+
+ $steviloPodstolpcev = count($this->multiCrosstabClass->variablesList[$var['spr']]['options']);
+
+ // Suma (ce jo imamo vklopljeno)
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['sums'] == 1 && !$this->multiCrosstabClass->rowLevel2){
+ //$this->pdf->MultiCell($this->cellWidth, $cellHeight, $lang['srv_analiza_crosstab_skupaj'], 1, 'C', 0, 0, 0 ,0, true);
+ $drugaVrsticaVert[] = $lang['srv_analiza_crosstab_skupaj'];
+ $steviloPodstolpcev++;
+ }
+
+/* if($colspan<4){
+ $steviloPodstolpcevV2[] = $steviloPodstolpcev;
+ }elseif($steviloPodstolpcev!=0&&$colspan==4){
+ $steviloPodstolpcevV2[] = $steviloPodstolpcev;
+ } */
+ if($steviloPodstolpcev!=0){
+ $steviloPodstolpcevV1[] = $steviloPodstolpcev;
+ }
+
+ //$steviloPodstolpcevV2[] = $steviloPodstolpcev;
+ }
+ //$tabela .= $this->tableRow($drugaVrsticaVert);
+ //$this->pdf->MultiCell(1, $cellHeight, '', 0, 'C', 0, 1, 0 ,0, true);
+ }
+ }
+
+ ##########################################################################################
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis*/
+ $steviloStolpcevParameterTabular = $this->getSteviloPodstolpcev($steviloPodstolpcevV1);
+ $steviloStolpcevParameterTabular = $steviloStolpcevParameterTabular + $colspan;
+ //echo "Stevilo stolpcev: ".$steviloStolpcevParameterTabular."</br>";
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+
+ $cntHorVars=0;
+ foreach($this->multiCrosstabClass->selectedVars['hor'] as $var){
+ $cntHorVars++;
+ }
+
+ //echo "cntHorVars: ".$cntHorVars."</br>";
+ if($cntHorVars>=1||$this->multiCrosstabClass->rowSpan == 0){
+ $parameterTabular = '|';
+ }
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ $parameterTabular .= ($export_format == 'pdf' ? 'c|' : 'c|');
+ }
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis - konec*/
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ ##########################################################################################
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica na vrhu tabele
+ }
+
+ $tabela .= $this->MultiColCellLatex($colspan, '', 1); //prazne celice v prvi vrstici
+ //$tabela .= $this->tableRow($prvaVrsticaVert, 1, 0, 0, $steviloPodstolpcevV1); //izpis prve vrstice tabele
+ $tabela .= $this->tableRow($prvaVrsticaVert, 1, 0, 0, '', $export_format, $steviloPodstolpcevV1); //izpis prve vrstice tabele
+
+ //prekinjena horizontalna vrstica po prvi vrstici
+ if($export_format != 'xls'){
+ $tabela .= $this->urediCrteTabele($indeksMultiRow, $colspan, $steviloStolpcevParameterTabular);
+ }
+ //prekinjena horizontalna vrstica po prvi vrstici - konec
+
+ if(count($drugaVrsticaVert)){
+ $tabela .= $this->MultiColCellLatex($colspan, '', 1); //prazne celice v drugi vrstici
+ if(count($steviloPodstolpcevV2)){
+ //$tabela .= $this->tableRow($drugaVrsticaVert, 1, 0, 0, $steviloPodstolpcevV2);
+ $tabela .= $this->tableRow($drugaVrsticaVert, 1, 0, 0, '', $export_format, $steviloPodstolpcevV2);
+ }else{
+ $tabela .= $this->tableRow($drugaVrsticaVert, 1);
+ }
+
+ //prekinjena horizontalna vrstica po drugi vrstici
+ if($export_format != 'xls'){
+ $tabela .= $this->urediCrteTabele($indeksMultiRow, $colspan, $steviloStolpcevParameterTabular);
+ }
+ //prekinjena horizontalna vrstica po drugi vrstici - konec
+ }
+
+ if(count($tretjaVrsticaVert)){
+ $tabela .= $this->MultiColCellLatex($colspan, '', 1); //prazne celice v drugi vrstici
+ if(count($steviloPodstolpcevV3)){
+ //$tabela .= $this->tableRow($tretjaVrsticaVert, 1, 0, 0, $steviloPodstolpcevV3);
+ $tabela .= $this->tableRow($tretjaVrsticaVert, 1, 0, 0, '', $export_format, $steviloPodstolpcevV3);
+ }else{
+ $tabela .= $this->tableRow($tretjaVrsticaVert, 1);
+ }
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica po tretji vrstici
+ }
+ }
+
+ if(count($cetrtaVrsticaVert)){
+ $tabela .= $this->MultiColCellLatex($colspan, '', 1); //prazne celice v drugi vrstici
+ $tabela .= $this->tableRow($cetrtaVrsticaVert, 1);
+ }
+
+
+ // Izrisemo HORIZONTALNO izbrane variable
+ if(count($this->multiCrosstabClass->selectedVars['hor'])){
+
+ // Imamo 2 nivoja vrstic
+ if($this->multiCrosstabClass->rowLevel2){
+ if($export_format != 'xls'){
+ $tabela .= ' \hline '; //horizontalna crta na zacetku tabele
+ }
+
+ foreach($this->multiCrosstabClass->selectedVars['hor'] as $parentVar){
+
+ $cnt = 0;
+ $order0 = 0;
+
+ foreach($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options'] as $option){
+ //echo "option hor 2. nivoja: ".$option."</br>";
+ $cnt2 = 0;
+
+ // ce imamo childe na 2. nivoju
+ if(count($parentVar['sub']) > 0){
+
+ $width = $metaWidth / 4;
+
+ foreach($parentVar['sub'] as $var){
+
+ $cnt3 = 0;
+
+ foreach($this->multiCrosstabClass->variablesList[$var['spr']]['options'] as $suboption){
+
+ // Spodnji border pri zadnjem
+/* if($cnt == count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options']) * count($this->multiCrosstabClass->variablesList[$var['spr']]['options']) - 1)
+ $border1 = 'B';
+ else
+ $border1 = '';
+ if($cnt2 == count($this->multiCrosstabClass->variablesList[$var['spr']]['options'])-1)
+ $border2 = 'B';
+ else
+ $border2 = ''; */
+
+ //if($cnt == floor((count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options']) * count($this->multiCrosstabClass->variablesList[$var['spr']]['options'])) / 2)){
+
+
+
+
+ //$tabela .= ' \hline ';
+
+ if($cnt == 0){
+ if($export_format != 'xls'){
+ $tabela .= $this->encodeText($this->snippet($this->multiCrosstabClass->variablesList[$parentVar['spr']]['naslov'], 25))." & ";
+ }else{
+ $tabela .= $this->encodeText($this->multiCrosstabClass->variablesList[$parentVar['spr']]['naslov'])." & ";
+ }
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($this->multiCrosstabClass->variablesList[$parentVar['spr']]['naslov'], 25), 'LR', 'C', 0, 0, 0 ,0, true);
+ //echo "naslov : ".$this->snippet($this->multiCrosstabClass->variablesList[$parentVar['spr']]['naslov'], 25)."</br>";
+ }
+ else{
+ $tabela .= " & ";
+ //$this->pdf->MultiCell($width, $this->cellHeight, '', 'LR'.$border1, 'C', 0, 0, 0 ,0, true);
+ //echo "naslov : </br>";
+ }
+
+
+ // Variabla
+ //if($cnt2 == floor(count($this->multiCrosstabClass->variablesList[$var['spr']]['options'])/2)){
+ if($cnt2 == 0){
+ if($export_format != 'xls'){
+ $tabela .= $this->encodeText($this->snippet($option, 25))." & ";
+ }else{
+ $tabela .= $this->encodeText($option)." & ";
+ }
+ //echo "variabla : ".$this->snippet($option, 25)."</br>";
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($option, 25), 'LR', 'C', 0, 0, 0 ,0, true);
+ }
+ else{
+ $tabela .= " & ";
+ //echo "variabla : </br>";
+ //$this->pdf->MultiCell($width, $this->cellHeight, '', 'LR'.$border2, 'C', 0, 0, 0 ,0, true);
+ }
+
+ //if($cnt3 == floor(count($this->multiCrosstabClass->variablesList[$var['spr']]['options'])/2)){
+ if($cnt3 == 0){
+ if($export_format != 'xls'){
+ $tabela .= $this->encodeText($this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25))." & ";
+ }else{
+ $tabela .= $this->encodeText($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'])." & ";
+ }
+ //echo "variabla cnt3: ".$this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25)."</br>";
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25), 'LR', 'C', 0, 0, 0 ,0, true);
+ }
+ else{
+ $tabela .= " & ";
+ //echo "variabla cnt3: </br>";
+ //$this->pdf->MultiCell($width, $this->cellHeight, '', 'LR'.$border2, 'C', 0, 0, 0 ,0, true);
+ }
+
+ // Variabla 2
+ if($export_format != 'xls'){
+ $tabela .= $this->encodeText($this->snippet($suboption, 25))." & ";
+ }else{
+ $tabela .= $this->encodeText($suboption)." & ";
+ }
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($suboption, 25), 1, 'C', 0, 0, 0 ,0, true);
+ //echo "option variabla 2: ".$this->snippet($suboption, 25)."</br>";
+
+ // Celice s podatki
+ $vrsticaPodatki = $this->displayDataCells($parentVar, $order0, $var, $cnt3);
+ //print_r($vrsticaPodatki);
+ ################# izpis celic s podatki
+ $tabela .= $this->displayDataCellLatex($vrsticaPodatki, $this->tableSettingsNumerus, $this->tableSettingsAvgVar, $this->tableSettingsDelezVar, $colspan, $steviloStolpcevParameterTabular, $export_format);
+ ################# izpis celic s podatki - konec
+ // Celice s podatki - konec
+
+ //$this->pdf->MultiCell(1, $this->cellHeight, '', 0, 'C', 0, 1, 0 ,0, true);
+
+ $cnt++;
+ $cnt2++;
+ $cnt3++;
+
+ //prekinjena horizontalna crta med moznostmi 2. nivoja horizontalne spremenljivke
+ if($export_format != 'xls'){
+ $tabela .= ' \cline {4-'.$steviloStolpcevParameterTabular.'}';
+ }
+ }
+
+ //prekinjena horizontalna crta med moznostmi 1. nivoja horizontalne spremenljivke
+ if($export_format != 'xls'){
+ $tabela .= ' \cline {2-'.$steviloStolpcevParameterTabular.'}';
+ }
+
+ $order0++;
+ }
+ }
+ else{
+ $width = $metaWidth / 2;
+
+ // Spodnji border pri zadnjem
+ if($cnt == count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options']) - 1)
+ $border1 = 'B';
+ else
+ $border1 = '';
+
+ if($cnt == floor(count($this->multiCrosstabClass->variablesList[$parentVar['spr']]['options'])/2)){
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($this->multiCrosstabClass->variablesList[$parentVar['spr']]['naslov'], 25), 'LR', 'C', 0, 0, 0 ,0, true);
+ }
+ else{
+ //$this->pdf->MultiCell($width, $this->cellHeight, '', 'LR'.$border1, 'C', 0, 0, 0 ,0, true);
+ }
+
+ // Variabla
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($option, 25), 1, 'C', 0, 0, 0 ,0, true);
+
+ // Celice s podatki
+ //$this->displayDataCells($parentVar, $cnt);
+
+ //$this->pdf->MultiCell(1, $this->cellHeight, '', 0, 'C', 0, 1, 0 ,0, true);
+
+ $cnt++;
+ }
+ }
+ }
+
+ if($export_format != 'xls'){
+ $tabela .= ' \hline '; //horizontalna crta na koncu tabele
+ }
+
+ }
+ // Imamo samo 1 nivo vrstic
+ else{
+ //echo "1 nivo vrstic";
+ $width = $metaWidth / 2;
+ if($export_format != 'xls'){
+ $tabela .= ' \hline '; //horizontalna vrstica
+ }
+ $cntHorVars = 0;
+ foreach($this->multiCrosstabClass->selectedVars['hor'] as $var){
+
+ // Ce imamo sumo
+ $suma = ($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['sums'] == 1 && count($this->multiCrosstabClass->selectedVars['ver']) > 0 && !$this->multiCrosstabClass->colLevel2) ? true : false;
+
+ $cnt = 0;
+ $vrsticaPodatki = array();
+ $vrstica = array();
+
+ foreach($this->multiCrosstabClass->variablesList[$var['spr']]['options'] as $option){ //vrstice s spremenljivkami
+ //echo "option hor 1. nivo: ".$option."</br>";
+ //Naslov horizontalne vrstice
+ if($cnt==0){
+ if($export_format != 'xls'){
+ $naslovVarHor = $this->snippet($this->multiCrosstabClass->variablesList[$var['spr']]['naslov'], 25);
+ }else{
+ $naslovVarHor = $this->multiCrosstabClass->variablesList[$var['spr']]['naslov'];
+ }
+ //$tabela .= $naslovVarHor." & ";
+ }else{
+ $naslovVarHor = '';
+ }
+ //echo "naslovVarHor: ".$naslovVarHor."</br>";
+ $tabela .= $naslovVarHor." & ";
+
+ // Variabla
+ //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($option, 25), '1', 'C', 0, 0, 0 ,0, true);
+ //echo "variabla: ".$this->snippet($option, 25)."</br>";
+ if($export_format != 'xls'){
+ $tabela .= $this->snippet($option, 25)." & ";
+ }else{
+ $tabela .= $option." & ";
+ }
+
+ // Celice s podatki
+ //echo "celica s podatki: ".$var."</br>";
+ // Ce nimamo nobenega krizanja izpisemo prazne
+ if($spr2 == '' && $this->multiCrosstabClass->colSpan == 0){
+ //$tabela .= " & ";
+ $tabela .= $this->texNewLine;
+ }else{
+ $vrsticaPodatki = $this->displayDataCells($var, $cnt);
+ //print_r($vrsticaPodatki);
+ ################# izpis celic s podatki
+ $tabela .= $this->displayDataCellLatex($vrsticaPodatki, $this->tableSettingsNumerus, $this->tableSettingsAvgVar, $this->tableSettingsDelezVar, $colspan, $steviloStolpcevParameterTabular, $export_format);
+ ################# izpis celic s podatki - konec
+ }
+ //$this->pdf->MultiCell(1, $this->cellHeight, '', 0, 'C', 0, 1, 0 ,0, true);
+
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+
+ $cnt++;
+ }
+ // Vrstica za sumo (ce jo imamo vklopljeno)
+ if($suma){
+
+ //$this->pdf->MultiCell($width, $this->cellHeight, '', 'BLR', 'C', 0, 0, 0 ,0, true);
+ //$this->pdf->MultiCell($width, $this->cellHeight, $lang['srv_analiza_crosstab_skupaj'], '1', 'C', 0, 0, 0 ,0, true);
+ $tabela .= " & ".$this->encodeText($lang['srv_analiza_crosstab_skupaj'])." & ";
+ //$tabela .= $this->encodeText($lang['srv_analiza_crosstab_skupaj'])." & ";
+
+ $vrsticaPodatkiSumNum = array();
+ $vrsticaPodatkiSumPer = array();
+ $vrsticaPodatkiSumAvg = array();
+ $vrsticaPodatkiSumDelez = array();
+ // Loop cez vse stolpce
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $spr2){
+
+ // Loop cez variable trenutnega stolpca
+ $cnt = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr2['spr']]['options'] as $var2){
+ //echo "var2: ".$var2."</br>";
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$var['spr'].'-'.$spr2['spr']];
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val = $keys1[$cnt];
+
+ //$this->displaySumsCell($var, $spr2, $val, $orientation=1);
+ $celicaSums = $this->displaySumsCell($var, $spr2, $val, $orientation=1);
+ if($this->tableSettingsNumerus){
+ $vrsticaPodatkiSumNum[] = $celicaSums['numerus'];
+ }
+ if($this->tableSettingsPercent){
+ $vrsticaPodatkiSumPer[] = $celicaSums['percent'];
+ }
+ if($this->tableSettingsAvgVar){
+ $vrsticaPodatkiSumAvg[] = $celicaSums['avg'];
+ }
+ if($this->tableSettingsDelezVar){
+ $vrsticaPodatkiSumDelez[] = $celicaSums['delez'];
+ }
+ //echo "Loop cez variable trenutnega stolpca </br>";
+ $cnt++;
+ }
+
+ // Krizanje navpicne in vodoravne sume
+ $celicaSums = $this->displaySumsCell($var, $spr2, 0, $orientation=2);
+ if($this->tableSettingsNumerus){
+ $vrsticaPodatkiSumNum[] = $celicaSums['numerus'];
+ }
+ if($this->tableSettingsPercent){
+ $vrsticaPodatkiSumPer[] = $celicaSums['percent'];
+ }
+ if($this->tableSettingsAvgVar){
+ $vrsticaPodatkiSumAvg[] = $celicaSums['avg'];
+ }
+ if($this->tableSettingsDelezVar){
+ $vrsticaPodatkiSumDelez[] = $celicaSums['delez'];
+ }
+
+ //echo "Krizanje navpicne in vodoravne sume </br>";
+ }
+ if($this->tableSettingsNumerus){
+ $tabela .= $this->tableRow($vrsticaPodatkiSumNum,1);
+ if($this->tableSettingsPercent||$this->tableSettingsAvgVar||$this->tableSettingsDelezVar){ //ce je potrebno izpisati se ostale vrstice izracunov
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+ $tabela .= $this->AddEmptyCells($colspan);
+ }
+ }
+ if($this->tableSettingsPercent){
+ $tabela .= $this->tableRow($vrsticaPodatkiSumPer,1);
+ if($this->tableSettingsAvgVar||$this->tableSettingsDelezVar){ //ce je potrebno izpisati se ostale vrstice izracunov
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+ $tabela .= $this->AddEmptyCells($colspan);
+ }
+ }
+ if($this->tableSettingsAvgVar!= ''){
+ $color = 'blue';
+ //$tabela .= $this->tableRow($vrsticaPodatkiSumAvg,1);
+ $tabela .= $this->tableRow($vrsticaPodatkiSumAvg,1,0,0,$color, $export_format);
+ if($this->tableSettingsDelezVar){ //ce je potrebno izpisati se ostale vrstice izracunov
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+ $tabela .= $this->AddEmptyCells($colspan);
+ }
+ }
+ if($this->tableSettingsDelezVar!= ''){
+ $color = 'red';
+ //$tabela .= $this->tableRow($vrsticaPodatkiSumDelez,1);
+ $tabela .= $this->tableRow($vrsticaPodatkiSumDelez,1,0,0,$color, $export_format);
+ }
+ }
+ if($export_format != 'xls'){
+ $tabela .= ' \hline '; //horizontalna vrstica
+ }
+ $cntHorVars++;
+ }
+
+ if($cntVerVars==1&&$cntHorVars==0&&$this->multiCrosstabClass->rowSpan!=0){
+ $tabela .= ' \multicolumn{1}{|c}{} & \multicolumn{3}{|c|}{}';
+ //$tabela .= ' \multicolumn{1}{|X}{} & \multicolumn{3}{|X|}{}';
+ $tabela .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tabela .= ' \hline ';
+ }
+ }
+ }
+ }
+
+ //zaljucek latex tabele z obrobo za drugo tabelo
+ $tabela .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za drugo tabelo - konec
+ //echo "tabela: ".$tabela;
+ return $tabela;
+ }
+
+ // Izpis celic v vrstici s podatki
+ function displayDataCells($spr1='', $var1='', $spr2='', $var2=''){
+ $vrstica = '';
+ $celica = array();
+ $celicaSums = array();
+ $superCelicaNum = array();
+ $superCelicaPer = array();
+ $superCelicaAvg = array();
+ $superCelicaDelez = array();
+ $superCelica = array();
+
+ // Ce nimamo nobenega krizanja izpisemo prazne
+ if($spr2 == '' && $this->multiCrosstabClass->colSpan == 0){
+
+ for($i=0; $i<$this->multiCrosstabClass->colSpan; $i++){
+ //$this->pdf->MultiCell($width, $height, '', '1', 'C', 0, 0, 0 ,0, true);
+ }
+
+ //$this->pdf->MultiCell($dataWidth, $this->cellHeight, '', 1, 'C', 0, 0, 0 ,0, true);
+ //$this->pdf->MultiCell(1, $this->cellHeight, '', 0, 'C', 0, 1, 0 ,0, true);
+ echo "ni ničesar </br>";
+ }
+
+ // Ce nimamo stolpcev - krizanje dveh vrstic
+ elseif($spr2 != '' && $this->multiCrosstabClass->colSpan == 0){
+ echo "krizanje dveh vrstic </br>";
+ $spr1_temp = explode('-', $spr1['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr1['spr']]['grd_id'];
+ $variabla1 = array('seq' => $spr1_temp[1], 'spr' => $spr1_temp[0], 'grd' => $grd);
+
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2])) ? $crosstabs['crosstab'][$val1][$val2] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2])) ? $crosstabs['avg'][$val1][$val2] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2])) ? $crosstabs['delez'][$val1][$val2] : 0;
+
+ $this->displayDataCell($crosstab, $percent, $avg, $delez);
+ }
+
+ // Krizanje 1 vrstice in 1 stolpca
+ elseif($spr2 == '' && !$this->multiCrosstabClass->colLevel2){
+ //echo "Krizanje 1 vrstice in 1 stolpca </br>";
+ // Loop cez vse stolpce
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $spr2){
+
+ $spr1_temp = explode('-', $spr1['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr1['spr']]['grd_id'];
+ $variabla1 = array('seq' => $spr1_temp[1], 'spr' => $spr1_temp[0], 'grd' => $grd);
+
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ // Loop cez variable trenutnega stolpca
+ $cnt = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr2['spr']]['options'] as $var2){
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$cnt];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2])) ? $crosstabs['crosstab'][$val1][$val2] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2])) ? $crosstabs['avg'][$val1][$val2] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2])) ? $crosstabs['delez'][$val1][$val2] : 0;
+
+ //echo "cnt: ".$cnt."</br>";
+ //$celica = $this->displayDataCell($crosstab, $percent, $avg, $delez);
+ $celica = $this->displayDataCell($crosstab, $percent, $avg, $delez, $cnt);
+
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celica['numerus'][$cnt];
+ //echo "Celica izven numerus: ".$celica['numerus'][$cnt]."</br>";
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celica['percent'][$cnt];
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celica['avg'][$cnt];
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celica['delez'][$cnt];
+ }
+
+ //echo "Celica: ".$celica['numerus'][$cnt]."</br>";
+
+ $cnt++;
+ }
+
+ // Suma (ce jo imamo vklopljeno)
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['sums'] == 1 && !$this->multiCrosstabClass->rowLevel2){
+ $celicaSums = $this->displaySumsCell($spr1, $spr2, $val1, $orientation=0);
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celicaSums['numerus'];
+ }
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celicaSums['percent'];
+ }
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celicaSums['avg'];
+ }
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celicaSums['delez'];
+ }
+ }
+ }
+ }
+
+ // Izpisemo vecnivojske podatke (krizanje 3 ali 4 spremenljivk)
+ else{
+ //echo "Izpisemo vecnivojske podatke (krizanje 3 ali 4 spremenljivk) </br>";
+ // Nastavimo 1. vrsticno variablo
+ $spr1_temp = explode('-', $spr1['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr1['spr']]['grd_id'];
+ $variabla1 = array('seq' => $spr1_temp[1], 'spr' => $spr1_temp[0], 'grd' => $grd);
+
+ // Krizanje 2 vrstic in 1 stolpca
+ if(!$this->multiCrosstabClass->colLevel2){
+
+ // Nastavimo 2. vrsticno variablo
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Loop cez vse stolpce
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $spr3){
+
+ $spr3_temp = explode('-', $spr3['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr3['spr']]['grd_id'];
+ $variabla3 = array('seq' => $spr3_temp[1], 'spr' => $spr3_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ // Loop cez variable trenutnega stolpca
+ $cnt = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr3['spr']]['options'] as $var3){
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3])) ? $crosstabs['crosstab'][$val1][$val2][$val3] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3])) ? $crosstabs['avg'][$val1][$val2][$val3] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3])) ? $crosstabs['delez'][$val1][$val2][$val3] : 0;
+
+ //$this->displayDataCell($crosstab, $percent, $avg, $delez);
+ $celica = $this->displayDataCell($crosstab, $percent, $avg, $delez, $cnt);
+
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celica['numerus'][$cnt];
+ //echo "Celica izven numerus: ".$celica['numerus'][$cnt]."</br>";
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celica['percent'][$cnt];
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celica['avg'][$cnt];
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celica['delez'][$cnt];
+ }
+
+ $cnt++;
+ }
+ }
+ }
+
+ // Krizanje 1 vrstice in 2 stolpcev
+ elseif($spr2 == ''){
+ //echo "Krizanje 1 vrstice in 2 stolpcev </br>";
+ // Loop cez vse stolpce 1. navpicne spremenljivke
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $spr2){
+
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Loop cez variable 1. navpicne spremnljivke
+ $cnt2 = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr2['spr']]['options'] as $var2){
+
+ // Loop cez vse navpicne spremenljivke 2. nivoja - ce obstajajo
+ if(count($spr2['sub']) > 0){
+ foreach($spr2['sub'] as $spr3){
+
+ // Nastavimo navpicno spremenljivko 2. nivoja
+ $spr3_temp = explode('-', $spr3['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr3['spr']]['grd_id'];
+ $variabla3 = array('seq' => $spr3_temp[1], 'spr' => $spr3_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$cnt2];
+
+ // Loop cez variable spremenljivke 2. nivoja
+ $cnt3 = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr3['spr']]['options'] as $var3){
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt3];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3])) ? $crosstabs['crosstab'][$val1][$val2][$val3] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3])) ? $crosstabs['avg'][$val1][$val2][$val3] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3])) ? $crosstabs['delez'][$val1][$val2][$val3] : 0;
+
+ //$this->displayDataCell($crosstab, $percent, $avg, $delez);
+ $celica = $this->displayDataCell($crosstab, $percent, $avg, $delez, $cnt3);
+
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celica['numerus'][$cnt3];
+ //echo "Celica izven numerus: ".$celica['numerus'][$cnt]."</br>";
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celica['percent'][$cnt3];
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celica['avg'][$cnt3];
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celica['delez'][$cnt3];
+ }
+ $cnt3++;
+ }
+ }
+ }
+ // 1 nivojska spremenljivka v stolpcu
+ else{
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$cnt2];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2])) ? $crosstabs['crosstab'][$val1][$val2] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2])) ? $crosstabs['avg'][$val1][$val2] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2])) ? $crosstabs['delez'][$val1][$val2] : 0;
+
+ //$this->displayDataCell($crosstab, $percent, $avg, $delez);
+ $celica = $this->displayDataCell($crosstab, $percent, $avg, $delez, $cnt2);
+
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celica['numerus'][$cnt2];
+ //echo "Celica izven numerus: ".$celica['numerus'][$cnt]."</br>";
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celica['percent'][$cnt2];
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celica['avg'][$cnt2];
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celica['delez'][$cnt2];
+ }
+ }
+
+ $cnt2++;
+ }
+ }
+ }
+
+
+
+ // Krizanje 2 vrstic in 2 stolpcev
+ else{
+ //echo "Krizanje 2 vrstic in 2 stolpcev </br>";
+ // Nastavimo 2. vrsticno variablo
+ $spr2_temp = explode('-', $spr2['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr2['spr']]['grd_id'];
+ $variabla2 = array('seq' => $spr2_temp[1], 'spr' => $spr2_temp[0], 'grd' => $grd);
+
+ // Loop cez vse stolpce 1. navpicne spremenljivke
+ foreach($this->multiCrosstabClass->selectedVars['ver'] as $spr3){
+
+ $spr3_temp = explode('-', $spr3['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr3['spr']]['grd_id'];
+ $variabla3 = array('seq' => $spr3_temp[1], 'spr' => $spr3_temp[0], 'grd' => $grd);
+
+ // Loop cez variable 1. navpicne spremnljivke
+ $cnt3 = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr3['spr']]['options'] as $var3){
+
+ // Loop cez vse navpicne spremenljivke 2. nivoja
+ if(count($spr3['sub']) > 0){
+ foreach($spr3['sub'] as $spr4){
+
+ // Nastavimo navpicno spremenljivko 2. nivoja
+ $spr4_temp = explode('-', $spr4['spr']);
+ $grd = $this->multiCrosstabClass->variablesList[$spr4['spr']]['grd_id'];
+ $variabla4 = array('seq' => $spr4_temp[1], 'spr' => $spr4_temp[0], 'grd' => $grd);
+
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+ $variables[3] = array('seq' => $variabla4['seq'], 'spr' => $variabla4['spr'], 'grd' => $variabla4['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr'].'-'.$spr4['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt3];
+
+ // Loop cez variable spremenljivke 2. nivoja
+ $cnt4 = 0;
+ foreach($this->multiCrosstabClass->variablesList[$spr4['spr']]['options'] as $var4){
+
+ $keys4 = array_keys($crosstabs['options4']);
+ $val4 = $keys4[$cnt4];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3][$val4])) ? $crosstabs['crosstab'][$val1][$val2][$val3][$val4] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3][$val4])) ? $crosstabs['avg'][$val1][$val2][$val3][$val4] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3][$val4])) ? $crosstabs['delez'][$val1][$val2][$val3][$val4] : 0;
+
+ //$this->displayDataCell($crosstab, $percent, $avg, $delez);
+ $celica = $this->displayDataCell($crosstab, $percent, $avg, $delez, $cnt4);
+
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celica['numerus'][$cnt4];
+ //echo "Celica izven numerus: ".$celica['numerus'][$cnt]."</br>";
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celica['percent'][$cnt4];
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celica['avg'][$cnt4];
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celica['delez'][$cnt4];
+ }
+
+ $cnt4++;
+ }
+ }
+ }
+ // 1 nivo navpicne spremenljivke
+ else{
+ // Ce se nimamo izracunanih rezultatov jih izracunamo
+ if(isset($this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']]))
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ else{
+ $variables = array();
+ $variables[0] = array('seq' => $variabla1['seq'], 'spr' => $variabla1['spr'], 'grd' => $variabla1['grd']);
+ $variables[1] = array('seq' => $variabla2['seq'], 'spr' => $variabla2['spr'], 'grd' => $variabla2['grd']);
+ $variables[2] = array('seq' => $variabla3['seq'], 'spr' => $variabla3['spr'], 'grd' => $variabla3['grd']);
+
+ $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']] = $this->multiCrosstabClass->createCrostabulation($variables);
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr'].'-'.$spr3['spr']];
+ }
+
+ $keys1 = array_keys($crosstabs['options1']);
+ $val1 = $keys1[$var1];
+
+ $keys2 = array_keys($crosstabs['options2']);
+ $val2 = $keys2[$var2];
+
+ $keys3 = array_keys($crosstabs['options3']);
+ $val3 = $keys3[$cnt3];
+
+ $crosstab = (isset($crosstabs['crosstab'][$val1][$val2][$val3])) ? $crosstabs['crosstab'][$val1][$val2][$val3] : 0;
+ $percent = ($crosstab > 0) ? $this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$val1], $crosstab) : 0;
+ $avg = (isset($crosstabs['avg'][$val1][$val2][$val3])) ? $crosstabs['avg'][$val1][$val2][$val3] : 0;
+ $delez = (isset($crosstabs['delez'][$val1][$val2][$val3])) ? $crosstabs['delez'][$val1][$val2][$val3] : 0;
+
+ //$this->displayDataCell($crosstab, $percent, $avg, $delez);
+ $celica = $this->displayDataCell($crosstab, $percent, $avg, $delez, $cnt3);
+
+ if($this->tableSettingsNumerus){
+ $superCelicaNum[] = $celica['numerus'][$cnt3];
+ //echo "Celica izven numerus: ".$celica['numerus'][$cnt]."</br>";
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelicaPer[] = $celica['percent'][$cnt3];
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelicaAvg[] = $celica['avg'][$cnt3];
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelicaDelez[] = $celica['delez'][$cnt3];
+ }
+
+ }
+
+ $cnt3++;
+ }
+ }
+ }
+ }
+
+ if($this->tableSettingsNumerus){
+ $superCelica['numerus'][] = $superCelicaNum;
+ }
+
+ if($this->tableSettingsPercent){
+ $superCelica['percent'][] = $superCelicaPer;
+ }
+
+ if($this->tableSettingsAvgVar){
+ $superCelica['avg'][] = $superCelicaAvg;
+ }
+
+ if($this->tableSettingsDelezVar){
+ $superCelica['delez'][] = $superCelicaDelez;
+ }
+
+ return $superCelica;
+ }
+
+ // Izpis celic v vrstici s sumami ($orientation 0->vrstica, 1->stolpec, 2->skupaj)
+ function displaySumsCell($spr1=null, $spr2=null, $val=null, $orientation=null){
+ $celicaSums = array();
+
+ //echo "Orientacija skupaj: ".$orientation."</br>";
+/* $startX = $this->pdf->getX();
+ $startY = $this->pdf->getY(); */
+
+ // Nastavimo visino posamezne vrstice
+/* $cellSpan = 0;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1)
+ $cellSpan++;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1)
+ $cellSpan++;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] != '')
+ $cellSpan++;
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] != '')
+ $cellSpan++;
+ $cellSpan = ($cellSpan > 0) ? $cellSpan : 1;
+ $lineHeight = $this->cellHeight / $cellSpan; */
+
+ // Nastavimo barvo texta
+/* $this->pdf->SetTextColor(160, 0, 0);
+ $this->pdf->setFont('','B','6'); */
+
+ $crosstabs = $this->multiCrosstabClass->crosstabData[$spr1['spr'].'-'.$spr2['spr']];
+
+ // Celica s skupno sumo
+ if($orientation == 2){
+
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+ $celicaSums['numerus'] = $crosstabs['sumaSkupna'];
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $crosstabs['sumaSkupna'], 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+ //$celicaSums['percent'] = $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['percent'] = $this->encodeText($this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ // Povprecje
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] > 0){
+
+ // Loop cez vse in izracunamo povprecje z ustreznimi utezmi
+ $avg = 0;
+ if($crosstabs['crosstab']){
+ $tempAvg = 0;
+ foreach($crosstabs['crosstab'] as $key1 => $row){
+ foreach($row as $key2 => $count){
+ $tempAvg += $count * $crosstabs['avg'][$key1][$key2];
+ }
+ }
+ $avg = $tempAvg / $crosstabs['sumaSkupna'];
+ }
+ $celicaSums['avg'] = $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+/* $this->pdf->SetFillColor(220, 220, 255);
+ $this->pdf->SetTextColor(0, 0, 230);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE')), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ // Delez
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] > 0){
+
+ // Loop cez vrstico in izracunamo skupen delez
+ $delez = 0;
+ if($crosstabs['delez']){
+ foreach($crosstabs['delez'] as $row){
+ foreach($row as $tempDelez){
+ $delez += $tempDelez;
+ }
+ }
+ }
+ //$celicaSums['delez'] = $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['delez'] = $this->encodeText($this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->SetFillColor(255, 220, 220);
+ $this->pdf->SetTextColor(230, 0, 0);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ }
+ // Suma na koncu vrstice
+ elseif($orientation == 0){
+
+ // Izpisemo podatek
+ if($crosstabs['sumaVrstica'][$val]){
+
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $crosstabs['sumaVrstica'][$val], 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ $celicaSums['numerus'] = $crosstabs['sumaVrstica'][$val];
+ }
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ //$celicaSums['percent'] = $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['percent'] = $this->encodeText($this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ }
+ }
+ else{
+
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+ $celicaSums['numerus'] = '0';
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, '0', 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+ //$celicaSums['percent'] = $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['percent'] = $this->encodeText($this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ }
+
+ // Povprecje
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] > 0){
+
+ // Loop cez vrstico in izracunamo povprecje z ustreznimi utezmi
+ $avg = 0;
+ if($crosstabs['crosstab'][$val]){
+ $tempAvg = 0;
+ foreach($crosstabs['crosstab'][$val] as $key => $count){
+ $tempAvg += $count * $crosstabs['avg'][$val][$key];
+ }
+ $avg = $tempAvg / $crosstabs['sumaVrstica'][$val];
+ }
+
+ $celicaSums['avg'] = $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+
+/* $this->pdf->SetFillColor(220, 220, 255);
+ $this->pdf->SetTextColor(0, 0, 230);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE')), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ // Delez
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] > 0){
+
+ // Loop cez vrstico in izracunamo skupen delez
+ $delez = 0;
+ if($crosstabs['delez'][$val]){
+ foreach($crosstabs['delez'][$val] as $tempDelez){
+ $delez += $tempDelez;
+ }
+ }
+
+ //$celicaSums['delez'] = $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['delez'] = $this->encodeText($this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+
+/* $this->pdf->SetFillColor(255, 220, 220);
+ $this->pdf->SetTextColor(230, 0, 0);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ }
+ // Suma za stolpce
+ else{
+ // Izpisemo podatek
+ if(isset($crosstabs['sumaStolpec'][$val])){
+
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+ $celicaSums['numerus'] = $crosstabs['sumaStolpec'][$val];
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $crosstabs['sumaStolpec'][$val], 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+ //$celicaSums['percent'] = $this->formatNumber($this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs['sumaStolpec'][$val]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['percent'] = $this->encodeText($this->formatNumber($this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs['sumaStolpec'][$val]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($this->multiCrosstabClass->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs['sumaStolpec'][$val]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ }
+ else{
+
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+ $celicaSums['numerus'] = '0';
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, '0', 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+ //$celicaSums['percent'] = $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['percent'] = $this->encodeText($this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ }
+
+ // Povprecje
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] > 0){
+
+ // Loop cez vrstico in izracunamo povprecje z ustreznimi utezmi
+ $avg = 0;
+ if($crosstabs['crosstab']){
+ $tempAvg = 0;
+ foreach($crosstabs['crosstab'] as $key => $row){
+ if($row[$val] > 0)
+ $tempAvg += $row[$val] * $crosstabs['avg'][$key][$val];
+ }
+ $avg = $tempAvg / $crosstabs['sumaStolpec'][$val];
+ }
+ $celicaSums['avg'] = $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+
+/* $this->pdf->SetFillColor(220, 220, 255);
+ $this->pdf->SetTextColor(0, 0, 230);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE')), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ // Delez
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] > 0){
+
+ // Loop cez vrstico in izracunamo skupen delez
+ $delez = 0;
+ if($crosstabs['delez']){
+ foreach($crosstabs['delez'] as $tempDelez){
+ $delez += $tempDelez[$val];
+ }
+ }
+ //$celicaSums['delez'] = $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $celicaSums['delez'] = $this->encodeText($this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->SetFillColor(255, 220, 220);
+ $this->pdf->SetTextColor(230, 0, 0);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+ }
+
+/* $this->pdf->SetTextColor(0, 0, 0);
+ $this->pdf->setFont('','','6');
+ $this->pdf->setXY($startX + $this->cellWidth, $startY); */
+
+ return $celicaSums;
+ }
+
+ // Izpis celice z vrednostmi
+ //function displayDataCell($crosstab, $percent, $avg, $delez){
+ function displayDataCell($crosstab=null, $percent=null, $avg=null, $delez=null, $cnt=null){
+
+ //$podatekCelice = '';
+ $podatekCelice = array();
+ //$startX = $this->pdf->getX();
+ //$startY = $this->pdf->getY();
+
+ $lineHeight = ($this->cellSpan > 1) ? 5 : 6;
+
+ if($crosstab > 0){
+
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $crosstab, 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ //$podatekCelice = $crosstab;
+ $podatekCelice['numerus'][$cnt] = $crosstab;
+ //echo "Crosstab ce crosstab > 0: ".$crosstab."</br>";
+ }
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ //$podatekCelice = $this->formatNumber($percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ //$podatekCelice['percent'][$cnt] = $this->formatNumber($percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $podatekCelice['percent'][$cnt] = $this->encodeText($this->formatNumber($percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ //echo "Procenti ce crosstab > 0: ".$podatekCelice."</br>";
+ }
+ }
+ else{
+ // Numerus
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['numerus'] == 1){
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, '0', 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ $podatekCelice['numerus'][$cnt] = '0';
+ }
+ // Procenti
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['percent'] == 1){
+/* $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ //$podatekCelice = $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ //$podatekCelice['percent'][$cnt] = $this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ $podatekCelice['percent'][$cnt] = $this->encodeText($this->formatNumber(0, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ }
+ }
+
+ // Povprecje
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] > 0){
+ //$podatekCelice = $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+ //echo "Povprecje: ".$podatekCelice."</br>";
+ $podatekCelice['avg'][$cnt] = $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'));
+/* $this->pdf->SetFillColor(220, 220, 255);
+ $this->pdf->SetTextColor(0, 0, 230);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($avg, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE')), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ // Delez
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] > 0){
+ //$podatekCelice = $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
+ //echo "Delez: ".$podatekCelice."</br>";
+ $podatekCelice['delez'][$cnt] = $this->encodeText($this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+/* $this->pdf->SetFillColor(255, 220, 220);
+ $this->pdf->SetTextColor(230, 0, 0);
+ $this->pdf->MultiCell($this->cellWidth, $lineHeight, $this->formatNumber($delez*100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'), 1, 'C', 1, 0, 0 ,0, true);
+ $this->pdf->SetFillColor(250, 250, 250);
+ $this->pdf->SetTextColor(0, 0, 0);
+
+ $this->pdf->setXY($this->pdf->getX() - $this->cellWidth, $this->pdf->getY() + $lineHeight); */
+ }
+
+ //$this->pdf->setXY($startX + $this->cellWidth, $startY);
+ return $podatekCelice;
+ }
+
+ // Izris legende na dnu
+ function displayLegend($export_format){
+ global $lang;
+ $legend = '';
+
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] > 0 || $this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] > 0){
+ //za zacetek sredinske poravnave
+
+ $legend .= ' \begin{center} ';
+
+ if($export_format == 'rtf'){ //ce je rtf dodaj tole besedilo, ker drugace prva od izpisanih zadev v legendi ni sredinsko poravnana
+ $legend .= $lang['srv_analiza_legenda'].': \\\\';
+ }
+
+
+ // Povprecje
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar'] > 0){
+ $text = $lang['srv_multicrosstabs_avg'].': ';
+ if($export_format == 'pdf'){
+ $color = 'crta';
+ }else{ //ce je rtf
+ $color = 'cyan'; //v rtf pride modra
+ }
+
+
+ $legend .= $this->coloredTextLatex($color, $text);
+
+ $legend .= $this->multiCrosstabClass->variablesList[$this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['avgVar']]['variable'];
+ $legend .= $this->texNewLine;
+ }
+
+ // Delez
+ if($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar'] > 0){
+ $text = $lang['srv_multicrosstabs_delez'].': ';
+
+ if($export_format == 'pdf'){
+ $color = 'crtaGraf';
+ }else{ //ce je rtf
+ $color = 'yellow'; //v rtf pride rdece
+ }
+
+ $legend .= $this->coloredTextLatex($color, $text);
+
+ $delez = unserialize($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delez']);
+ $string = '';
+ $cnt = 1;
+ foreach($delez as $val){
+ if($val == 1)
+ $string .= $cnt.', ';
+ $cnt++;
+ }
+ $string = $this->multiCrosstabClass->variablesList[$this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['delezVar']]['variable'].' ('.substr($string, 0, -2).')';
+
+ $legend .= $string;
+ $legend .= $this->texNewLine;
+ }
+
+ //za konec sredinske poravnave
+ $legend .= ' \end{center} ';
+
+ }
+
+ return $legend;
+ }
+
+
+ function formatNumber($value=null, $digit=0, $sufix=""){
+
+ if ($value <> 0 && $value != null)
+ $result = round($value, $digit);
+ else
+ $result = "0";
+
+ # polovimo decimalna mesta in vejice za tisočice
+ $decimal_point = SurveyDataSettingProfiles :: getSetting('decimal_point');
+ $thousands = SurveyDataSettingProfiles :: getSetting('thousands');
+
+ $result = number_format($result, $digit, $decimal_point, $thousands) . $sufix;
+
+ return $result;
+ }
+
+/* function encodeText($text){
+ // popravimo sumnike ce je potrebno
+ $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
+ $text = str_replace(array("&scaron;","&#353;","&#269;"),array("š","š","č"),$text);
+
+ return strip_tags($text);
+ } */
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="..."){
+ $length=SNIPPET_LENGTH;
+
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length){
+ for($i=1;$text[$length-$i]!=" ";$i++){
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+
+ return $text;
+ }
+
+ function drawLine(){
+
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+
+ function getCellHeight($string='', $width=null){
+
+ $this->pdf->startTransaction();
+ // get the number of lines calling you method
+ $linecount = $this->pdf->MultiCell($width, 0, $string, 0, 'L', 0, 0, '', '', true, 0, false, true, 0);
+ // restore previous object
+ $this->pdf = $this->pdf->rollbackTransaction();
+
+ $height = ($linecount <= 1) ? 4.7 : $linecount * ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio()) + 2;
+
+ return $height;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaSums.php b/admin/survey/export/latexclasses/Analize/AnalizaSums.php
new file mode 100644
index 0000000..ca37139
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaSums.php
@@ -0,0 +1,2984 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+/* include_once('../exportclases/class.pdfIzvozAnalizaFrekvenca.php');
+ include_once('../exportclases/class.pdfIzvozAnalizaFunctions.php');
+ require_once('../exportclases/class.enka.pdf.php'); */
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+ define ('MEJA_DOLZINA_VPRASANJA', 132);
+
+/**
+ * @desc Class za generacijo latex
+ */
+
+class AnalizaSums extends LatexAnalysisElement{
+
+ var $anketa; // trenutna anketa (array)
+ var $spremenljivka; // trenutna spremenljivka
+
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $CID = null; # class za inkrementalno dodajanje fajlov
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ protected $tex;
+ var $currentStyle;
+
+ var $current_loop = 'undefined';
+
+ static public $_FILTRED_OTHER = array(); # filter za polja drugo
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+ protected $show_valid_percent;
+ protected $texBigSkip = '\bigskip';
+ protected $spaceBetweenTables = ' \newline \vspace*{1 cm} \newline';
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $sprID = null, $loop = null)
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ //if ( is_numeric($anketa) )
+ if ( is_numeric($anketa['id']) )
+ {
+ //$this->anketa['id'] = $anketa;
+ //$this->anketa['id'] = $anketa['id'];
+ $this->anketa = $anketa;
+ $this->spremenljivka = $sprID;
+
+ SurveyAnalysis::$setUpJSAnaliza = false;
+
+
+ //SurveyZankaProfiles :: Init($this->anketa['id'], $global_user_id);
+ $this->current_loop = ($loop != null) ? $loop : $this->current_loop;
+
+ //$hideAllSystem = SurveyDataSettingProfiles :: getSetting('hideAllSystem');
+ /* $hideAllSystem = SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT');
+ echo "hideAllSystem: ".$hideAllSystem."</br>"; */
+ //SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT')
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']))
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+
+ function displayTableLatex($headFileName='', $spremenljivka=null, $spid=null, $export_format='', $hideEmpty=null){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ //echo "Spr tip v Sums: ".$spremenljivka['tip']."</br>";
+ $export_format = $export_format;
+ $this->hideEmpty = $hideEmpty;
+ $tabela = '';
+
+ $this->headFileName = $headFileName;
+
+ #preberemo HEADERS iz datoteke
+ //SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
+
+ # polovimo frekvence
+ //dump(SurveyAnalysis::getFrequencys());
+ //die();
+
+ #odstranimo sistemske variable
+ //SurveyAnalysis::removeSystemVariables();
+
+ ###
+ //SurveyMissingProfiles :: Init($spremenljivka['id'], $global_user_id);
+
+
+ ####
+
+ //$vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+ //$line_break = '';
+
+ //echo "Spr tip v Sums: ".$spremenljivka['tip']."</br>";
+ switch ($spremenljivka['tip']) {
+ case 1:
+ # radio - prikaže navpično
+ $tabela .= self::sumVertical($spid,'sums', $export_format);
+ break;
+
+ case 2:
+ #checkbox če je dihotomna:
+ $tabela .= self::sumVerticalCheckbox($spid,'sums', $export_format);
+ break;
+
+ case 3:
+ # dropdown - prikjaže navpično
+ $tabela .= self::sumVertical($spid,'sums', $export_format);
+ break;
+
+ case 6:
+ # multigrid
+ $tabela .= self::sumHorizontal($spid,'sums', $export_format);
+ break;
+
+ case 16:
+ #multicheckbox če je dihotomna:
+ $tabela .= self::sumMultiHorizontalCheckbox($spid, 'sums', $export_format);
+ break;
+
+ case 17:
+ #razvrščanje ce je ordinalna
+ $tabela .= self::sumHorizontal($spid,'sums', $export_format);
+ break;
+
+ case 4: # text
+ case 8: # datum
+ $tabela .= self::sumTextVertical($spid,'sums', $export_format);
+ break;
+
+ case 21: # besedilo*
+ # varabla tipa »besedilo« je v sumarniku IDENTIČNA kot v FREKVENCAH.
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ $tabela .= self::sumTextVertical($spid,'sums', $export_format);
+ } else {
+ $tabela .= self::sumMultiText($spid,'sums', $export_format);
+ }
+ break;
+
+ case 4: # besedilo*
+ # varabla tipa »besedilo« je v sumarniku IDENTIČNA kot v FREKVENCAH.
+ if ($spremenljivka['cnt_all'] == 1) {
+ // če je enodimenzionalna prikažemo kot frekvence
+ // predvsem zaradi vprašanj tipa: language, email...
+ $tabela .= self::sumTextVertical($spid,'sums', $export_format);
+ } else {
+ $tabela .= self::sumMultiText($spid,'sums', $export_format);
+ }
+ break;
+
+ case 19: # multitext
+ $tabela .= self::sumMultiText($spid,'sums', $export_format);
+ break;
+
+ case 7:
+ case 18:
+ case 22:
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ $tabela .= self::sumNumberVertical($spid,'sums', $export_format);
+ break;
+
+ case 20:
+ # variabla tipa »število« je v sumarniku identična kot v DESCRIPTIVES.
+ $tabela .= self::sumMultiNumber($spid,'sums', $export_format);
+ break;
+
+ case 5:
+ # nagovor
+ $tabela .= self::sumNagovor($spid,'sums', $export_format);
+ break;
+
+ case 26: # lokacija
+ $tabela .= self::sumLokacija($spid,'sums', $export_format);
+ break;
+
+ case 27: # heatmap
+ $tabela .= self::sumHeatmap($spid, 'sums', $export_format);
+ break;
+ }
+ //echo "</br> Tex celotne tabele: ".$tabela."</br>";
+ return $tabela;
+ }
+
+ /** Izriše sumarnik v vertikalni obliki z Latex
+ *
+ * @param unknown_type $spid
+ */
+ function sumVertical($spid=null,$_from=null, $export_format='') {
+ //echo "sumVertical </br>";
+ global $lang;
+
+ $tex = '';
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ # dodamo opcijo kje izrisujemo legendo
+ $inline_legenda = false;
+ //$options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false);
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'exportFormat' => $export_format);
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 6;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{>{\hsize=\dimexpr 6\hsize+\arrayrulewidth}X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica tabele z naslovi stolpcev
+ $tex .= $this->tableHeader($export_format);
+
+ //$this->pdf->setFont('','','6');
+
+ /*Naslovni vrstici tabele - konec*/
+
+ $show_valid_percent = (SurveyAnalysis::$_HEADERS[$spid]['show_valid_percent'] == true) ? 1 : 0;
+ $this->show_valid_percent = $show_valid_percent;
+
+ $_answersOther = array();
+ $sum_xi_fi=0;
+ $N = 0;
+
+ $_tmp_for_div = array();
+ # izpis veljavnih odgovorov
+ if (count($spremenljivka['grids']) > 0){
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ // dodamo dodatne vrstice z labelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['text'] != true && $variable['other'] != true) {
+
+
+ $maxAnswer = (SurveyDataSettingProfiles :: getSetting('numOpenAnswers') > 0) ? SurveyDataSettingProfiles :: getSetting('numOpenAnswers') : 30;
+ //echo "tukaj: $maxAnswer </br>";
+ $counter = 0;
+ $_kumulativa = 0;
+
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if (/*$vAnswer['cnt'] > 0 &&*/ $counter < $maxAnswer) { # izpisujemo samo tiste ki nisno 0
+ // za povprečje
+ $xi = $vkey;
+ $fi = $vAnswer['cnt'];
+
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+
+ if ($vAnswer['cnt'] > 0 || true) { // izpisujemo samo tiste ki nisno 0
+ //$counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ $tex .= self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+
+ // za poznejše računannje odklona
+ $_tmp_for_div[] = array('xi'=>$xi, 'fi'=>$fi, 'sequence'=>$_sequence);
+ }
+ $counter++;
+ //echo "stevec: $counter </br>";
+ }
+ // izpišemo sumo veljavnih
+ //$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ $tex .= self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ //echo "tex testni: ".$tex."</br>";
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ $_Z_MV = !$this->hideEmpty;
+ if($_Z_MV){ //ce je potrebno izpisati tudi manjkajoce
+ $tex .= $this->encodeText($lang['srv_anl_missing1']);
+ }
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ //echo "iAnswer cnt: ".$iAnswer['cnt']."</br>";
+ if ($iAnswer['cnt'] > 0 ) { // izpisujemo samo tiste ki niso 0
+ //$counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ $tex .= self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ //echo "Invalid: ".$tex."</br>";
+ $counter++;
+ //echo "stevec: $counter </br>";
+ }
+ }
+ // izpišemo sumo veljavnih
+ //$counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ $tex .= self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ //izpišemo še skupno sumo
+ //$counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ $tex .= self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+ //echo "koda: $tex </br>";
+ }
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ /* odklon */
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+
+ /* standardna diviacija */
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ foreach ( $_tmp_for_div as $tkey => $_tmp_div_data) {
+ $xi = $_tmp_div_data['xi'];
+ $fi = $_tmp_div_data['fi'];
+
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ $div = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+
+ /* izpis st. odklona in povprecja */
+ if ($show_valid_percent == 1 && SurveyAnalysis::$_HEADERS[$spid]['skala'] != 1) {
+ $brezHline = 1;
+ //zacetek latex tabele za drugo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ //zacetek latex tabele za drugo tabelo - konec
+
+ $text = array();
+
+ //$text[] = '';
+ //$text[] = '';
+
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_povprecje1']);
+ $text[] = $this->encodeText(self::formatNumber($avg,NUM_DIGIT_AVERAGE,''));
+
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_odklon']);
+
+ $text[] = $this->encodeText(self::formatNumber($div,NUM_DIGIT_AVERAGE,''));
+
+
+ if($export_format == 'pdf'){
+ $tex .= "\\cline{3-6}"; //horizontalna vrstica od 3 do 6 celice
+ $tex .= "\multicolumn{1}{b}{} & \multicolumn{1}{B|}{} & ";
+ $tex .= $this->tableRow($text, $brezHline)." ";
+ $tex .= "\\cline{3-6}"; //horizontalna vrstica od 3 do 6 celice
+ }elseif($export_format == 'xls'){
+ $brezHline = 1;
+ $tex .= "\\multicolumn{1}{l}{} & \\multicolumn{1}{l|}{} & ";
+ $tex .= $this->tableRow($text, $brezHline)." ";
+ }else{
+ $tex .= "\\cline{3-6}"; //horizontalna vrstica od 3 do 6 celice
+ $tex .= "\\multicolumn{1}{l}{} & \\multicolumn{1}{l|}{} & ";
+ $tex .= $this->tableRow($text, $brezHline)." ";
+ $tex .= "\\cline{3-6}"; //horizontalna vrstica od 3 do 6 celice
+ }
+
+ //zaljucek latex tabele z obrobo za drugo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za drugo tabelo - konec
+
+ }
+
+ /* izpis tekstovnih odgovorov za polja drugo */
+ //echo "štev drugih odgovorov: ".count($_answersOther)."</br>";
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+
+
+ //echo "Latex tabele: ".$tex."</br>";
+ return $tex;
+ }
+
+
+ /*Izpis sumarnika za check box z Latex*/
+ function sumVerticalCheckbox($spid=null,$_from=null, $export_format='') {
+ //echo "sumVerticalCheckbox </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ $_answersOther = array();
+
+ //TODO: Koda se nikjer ne uporablja
+ //$inline_legenda = count ($spremenljivka['grids']) > 1;
+ //if ($variable['other'] != '1' && $variable['text'] != '1') {
+ // $_tip = SurveyAnalysis::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ // $_oblika = SurveyAnalysis::getSpremenljivkaLegenda($spremenljivka,'skala');
+ //} else {
+ // $_tip = $lang['srv_analiza_vrsta_bese'];
+ // $_oblika = $lang['srv_analiza_oblika_nomi'];
+ //}
+
+ /* ugotovimo koliko imamo kolon*/
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_clmn_cnt[$gid] = $grid['cnt_vars']-$grid['cnt_other'];
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ $_valid_cnt[$gid] = max($_valid_cnt[$gid], SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']);
+ $_approp_cnt[$gid] = max($_approp_cnt[$gid], SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $_valid[$gid][$vid] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'];
+ $_navedbe[$gid] += SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ }
+ }
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 9;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ //prva vrstica
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{8}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+ else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{8}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_opisne_subquestion1'])." & \multicolumn{5}{c|}{".$this->encodeText($lang['srv_analiza_opisne_units'])."} & \multicolumn{2}{c|}{".$this->encodeText($lang['srv_analiza_opisne_arguments'])."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //tretja vrstica
+ $text = array();
+ $text[] = '';
+ $text[] = '';
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_frequency']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_valid']);
+ $text[] = $this->encodeText('% - '.$lang['srv_analiza_opisne_valid']);
+ $text[] = $this->encodeText($lang['srv_analiza_num_units_valid']);
+ $text[] = $this->encodeText('% - '.$lang['srv_analiza_num_units_valid']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_frequency']);
+ $text[] = $this->encodeText('%');
+
+ $brezHline = $this->getBrezHline($export_format);
+ //echo "notnot: $brezHline </br>";
+
+ $tex .= $this->tableRow($text, $brezHline); //izpis tretje vrstice
+ //konec naslovnih vrstic
+
+ $_max_valid = 0;
+ $_max_appropriate = 0;
+ if (count ($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] as $gid => $grid) {
+ if (count ($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ if ($variable['other'] != 1) {
+ $_sequence = $variable['sequence'];
+ $cssBack = "anl_bck_desc_2 ".($vid == 0 && $gid != 0 ? 'anl_double_bt ' : '');
+
+ $text = array();
+
+ $text[] = $this->encodeText($variable['variable']);
+ $text[] = $this->encodeText($variable['naslov']);
+
+ // Frekvence
+ $text[] = $this->encodeText((int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']);
+
+ // Veljavni
+ $text[] = $this->encodeText((int)(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['0']['cnt']));
+
+ // Procent - veljavni
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+
+ $text[] = $this->encodeText(self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%'));
+
+ $_max_appropriate = max($_max_appropriate, (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+ $_max_valid = max ($_max_valid, ((int)(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['0']['cnt'])));
+
+ // Ustrezni
+ $text[] = $this->encodeText((int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+ // % Ustrezni
+ $valid = (int)(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['0']['cnt']);
+ $valid = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $_percent = ($_max_appropriate > 0 ) ? 100*$valid / $_max_appropriate : 0;
+
+ $text[] = $this->encodeText(self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%'));
+
+
+ $text[] = $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']);
+
+ $_percent = ($_navedbe[$gid] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] / $_navedbe[$gid] : 0;
+
+ $text[] = $this->encodeText(self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%'));
+
+ $tex .= $this->tableRow($text, $brezHline); //izpis vrstic z odgovori
+ } else {
+ # drugo
+ }
+ }
+
+ $text = array();
+
+ $text[] = '';
+
+ $text[] = $this->encodeText($lang['srv_anl_suma_valid']);
+
+ $text[] = '';
+
+ $text[] = $this->encodeText($_max_valid);
+ $text[] = '';
+
+ $text[] = $this->encodeText($_max_appropriate);
+ $text[] = '';
+
+ $text[] = $this->encodeText($_navedbe[$gid]);
+
+ $text[] = $this->encodeText(self::formatNumber('100',SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%'));
+
+ $tex .= $this->tableRow($text, $brezHline); //izpis vrstice SKUPAJ
+
+ }
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+
+ //echo "Latex tabele: ".$tex."</br>";
+ return $tex;
+ }
+
+ /** Izriše nagovor
+ *
+ */
+ function sumNagovor($spid=null, $_from=null, $export_format='') {
+ //echo "sumNagovor</br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ //$_tip = SurveyAnalysis::getSpremenljivkaLegenda($spremenljivka,'izrazanje');
+ //$_oblika = SurveyAnalysis::getSpremenljivkaLegenda($spremenljivka,'skala');
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 2;
+
+ //$parameterTabular = '';
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'b|' : 'l|');
+ $parameterTabular .= ($export_format == 'pdf' ? 's|' : 'c|');
+ }else if($i == 1){
+ $parameterTabular .= ($export_format == 'pdf' ? 'B|' : 'l|');
+ }
+ else{
+ $parameterTabular .= ($export_format == 'pdf' ? 's|' : 'c|');
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ $tex .= $this->encodeText($spremenljivka['variable'])." & ".$this->encodeText($spremenljivka['naslov'])." ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //$this->pdf->setFont('','','6');
+
+ /*Naslovni vrstici tabele - konec*/
+/* $this->pdf->setFont('','b','6');
+
+ $this->pdf->ln(5);
+ $this->pdf->MultiCell(18, 5, $this->encodeText($spremenljivka['variable']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(162, 5, $this->encodeText($spremenljivka['naslov']), 1, 'L', 0, 1, 0 ,0, true); */
+ //echo "Latex tabele: ".$tex."</br>";
+ return $tex;
+ }
+
+ /** Izriše number odgovore v vertikalni obliki z Latex
+ *
+ * @param unknown_type $spid
+ */
+ function sumNumberVertical($spid=null, $_from=null, $export_format='') {
+ //echo "sumNumberVertical</br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (SurveyAnalysis::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'textAnswerExceed' => false);
+
+ # ali izpisujemo enoto:
+ $show_enota = true;
+ if ((int)$spremenljivka['enota'] == 0 && SurveyAnalysis::$_HEADERS[$spid]['cnt_all'] == 1) {
+ $show_enota = false;
+ }
+
+ # ugotovimo koliko imamo kolon
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_clmn_cnt[$gid] = $grid['cnt_vars']-$grid['cnt_other'];
+ if (count($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable) {
+ $_sequence = $variable['sequence'];
+ $_approp_cnt[$gid] = max($_approp_cnt[$gid], SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+
+ # za povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+ $min = null;
+ $max = null;
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $xi => $_validFreq) {
+
+ $fi = $_validFreq['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ $min = $min != null ? min($min,$xi) : $xi;
+ $max = max($max,$xi);
+ }
+ }
+
+ #povprečje
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ $sum_avg += $avg;
+ SurveyAnalysis::$_FREQUENCYS[$_sequence]['validAvg'] = $avg;
+ SurveyAnalysis::$_FREQUENCYS[$_sequence]['validMin'] = $min;
+ SurveyAnalysis::$_FREQUENCYS[$_sequence]['validMax'] = $max;
+
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $xi => $_validFreq) {
+ $fi = $_validFreq['cnt'];
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ }
+ SurveyAnalysis::$_FREQUENCYS[$_sequence]['validDiv'] = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+ #določimo še polja drugo za kasnejši prikaz
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 8;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ //prva vrstica
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica
+ $text = array();
+
+ $text[] = '';
+
+ if ($show_enota) {
+ if ($spremenljivka['tip'] == 20 || $spremenljivka['tip'] == 7) {
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_subquestion1']);;
+ } else {
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_variable_text1']);
+ }
+ } else {
+ $text[] = '';
+ }
+
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_m']);
+ $text[] = $this->encodeText($lang['srv_analiza_num_units']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_povprecje1']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_odklon']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_min']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_max']);
+
+ $brezHline = $this->getBrezHline($export_format);
+ $tex .= $this->tableRow($text, $brezHline);
+
+/* $this->pdf->setFont('','','6');
+ //konec naslovnih vrstic */
+
+ $_answersOther = array();
+ $_grupa_cnt = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ if (count($spremenljivka['grids']) > 1 && $_grupa_cnt !== 0 && $spremenljivka['tip'] != 6) {
+ $grid['new_grid'] = true;
+ }
+
+ $_grupa_cnt ++;
+ if (count($grid['variables']) > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+
+ $text = array();
+
+ if ($spremenljivka['tip'] != 7 ) {
+ $text[] = $this->encodeText($variable['variable']);
+ }
+ else
+ $text[] = '';
+
+ if ($show_enota) {
+ $text[] = $this->encodeText((count($grid['variables']) > 1 && $spremenljivka['tip'] == 20 ? $grid['naslov'] . ' - ' : '' ).$variable['naslov']);
+ } else {
+ $text[] = '';;
+ }
+
+ $text[] = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+ $text[] = (int)$_approp_cnt[$gid];
+
+ $text[] = self::formatNumber(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validAvg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+
+ $text[] = self::formatNumber(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validDiv'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),'');
+ $text[] = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validMin'];
+ $text[] = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validMax'];
+
+ $tex .= $this->tableRow($text, $brezHline);
+
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $grid['new_grid'] = false;
+ }
+
+ }
+ }
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+
+ //echo "Latex tabele: ".$tex."</br>";
+ return $tex;
+ }
+
+ /** Izriše sumarnik v horizontalni obliki za multigrid z Latex
+ *
+ * @param unknown_type $spid - spremenljivka ID
+ */
+ function sumHorizontal($spid=null,$_from=null, $export_format='') {
+ //echo "sumHorizontal </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ $_answersOther = array();
+ $_clmn_cnt = count($spremenljivka['options']);
+
+ # pri razvrščanju dodamo dva polja za povprečje in odklon
+ $additional_field = false;
+ $add_fld = 0;
+
+ if ($spremenljivka['tip'] == 17 || $spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3 || ($spremenljivka['tip'] == 6 && $spremenljivka['skala'] != 1)) {
+ $additional_field = true;
+ $add_fld = 2;
+ }
+
+ # pri radiu in dropdown ne prikazujemo podvprašanj
+ $_sub_question_col = 1;
+ if ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) {
+ $_sub_question_col = 0;
+ }
+
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 7 + count($spremenljivka['options']);
+
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'b|' : 'l|');
+ $parameterTabular .= ($export_format == 'pdf' ? 's|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }else if($i == 1){
+ $parameterTabular .= ($export_format == 'pdf' ? 'B|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }
+ else{
+ $parameterTabular .= ($export_format == 'pdf' ? 's|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /* prva vrstica */
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|} {'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+/* $this->pdf->setFont('','b','6');
+ $this->pdf->ln(5);
+ $this->pdf->MultiCell(18, 5, $this->encodeText($spremenljivka['variable']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(162, 5, $this->encodeText($spremenljivka['naslov']), 1, 'L', 0, 1, 0 ,0, true); */
+ /* prva vrstica - konec */
+
+ /* druga vrstica */
+ $steviloPodStolpcev2 = count($spremenljivka['options']) + 1;
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_opisne_subquestion1'])." & \multicolumn{".$steviloPodStolpcev2."}{c|}{".$this->encodeText($lang['srv_analiza_opisne_answers'])."} ";
+
+/* $this->pdf->MultiCell(18, 5, $this->encodeText(''), 1, 'L', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(30, 5, $this->encodeText($lang['srv_analiza_opisne_subquestion']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(72, 5, $this->encodeText($lang['srv_analiza_opisne_answers']), 1, 'C', 0, 0, 0 ,0, true); */
+
+ $text = array();
+ if ($additional_field){
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_valid']);
+ $text[] = $this->encodeText($lang['srv_analiza_num_units']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_povprecje1']);
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_odklon']);
+ }
+ else{
+ $text[] = $this->encodeText($lang['srv_analiza_opisne_valid']);
+ $text[] = $this->encodeText($lang['srv_analiza_num_units']);
+ }
+
+ //$tex .= $this->tableRow($text); //izpis ostalega dela vrstice $arrayText, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0
+ $brezHline = 1;
+ $brezNoveVrstice = 1;
+ $nadaljevanjeVrstice = 1;
+ $tex .= $this->tableRow($text, $brezHline, $brezNoveVrstice, $nadaljevanjeVrstice); //izpis ostalega dela vrstice
+
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /* druga vrstica - konec */
+
+ /* tretja vrstica */
+ $brezHline3 = 1;
+ $brezNoveVrstice3 = 1;
+ $nadaljevanjeVrstice3 = 1;
+
+ $textDynamicCells = array();
+ $count = 0;
+ $height_title = 0;
+
+ if (count($spremenljivka['options']) > 0) {
+
+ $singleWidth = round(57 / count($spremenljivka['options']));
+
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ // misinge imamo zdruzene
+ $_label = $kategorija;
+ $textDynamicCells[] = $_label;
+ //$height_title = ($height_title < $this->getCellHeight($_label, $singleWidth)) ? $this->getCellHeight($_label, $singleWidth) : $height_title;
+ $count++;
+ }
+ }
+
+ /*prva prazna stolpca*/
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 2;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+ /*prva prazna stolpca - konec*/
+
+ $tex .= $this->dynamicCells($textDynamicCells, $count); //izpis celic z odgovori v stolpcih (npr. Sploh ne velja, ...)
+
+ $tex .= " & ".$this->encodeText($lang['srv_anl_suma1']); //Skupaj
+
+ /*zadnji stolpci po Skupaj*/
+ if ($additional_field){
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 4;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+ }
+ else{
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 2;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+ }
+ /*zadnji stolpci po Skupaj*/
+
+ $tex .= $this->texNewLine;
+ /* tretja vrstica - konec */
+ //konec naslovnih vrstic
+
+
+ #zlopamo skozi gride
+ $podtabela = 0;
+ if (count($spremenljivka['grids']) > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # zloopamo skozi variable
+ if (count($grid['variables']) > 0)
+ foreach ($grid['variables'] AS $vid => $variable ) {
+ $_sequence = $variable['sequence'];
+ if ($variable['other'] != true) {
+
+ // Ce gre za dvojno tabelo naredimo vrstico s naslovom podtabele
+ if($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 3){
+
+ // Če začnemo z drugo podtabelo izpišemo vrstico z naslovom
+ if($podtabela != $grid['part']){
+
+ $subtitle = $spremenljivka['double'][$grid['part']]['subtitle'];
+ $subtitle = $subtitle == '' ? $lang['srv_grid_subtitle_def'].' '.$grid['part'] : $subtitle;
+
+/* $this->pdf->setFont('','b','6');
+ $this->pdf->MultiCell(180, $height_title, $this->encodeText($subtitle), 1, 'C', 0, 1, 0 ,0, true);
+ $this->pdf->setFont('','','6'); */
+ $tex .= $this->encodeText($subtitle);
+
+ $podtabela = $grid['part'];
+ }
+ }
+
+ if($variable['naslov'] == '')
+ $variable['naslov'] = '';
+
+ /*$linecount = $this->pdf->getNumLines($this->encodeText($variable['naslov']), 30);
+ $linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
+
+ //ce smo na prelomu strani
+/* if( ($this->pdf->getY() + $height) > 270){
+ $this->drawLine();
+ $this->pdf->AddPage('P');
+ $arrayParams['border'] .= 'T';
+ } */
+
+/* $this->pdf->MultiCell(18, $height, $this->encodeText($variable['variable']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(30, $height, $this->encodeText($variable['naslov']), 1, 'C', 0, 0, 0 ,0, true); */
+ $tex .= $this->encodeText($variable['variable']);
+ $tex .= " & ".$this->encodeText($variable['naslov']);
+
+
+ # za odklon in povprečje
+ $sum_xi_fi=0;
+ $N = 0;
+ $div=0;
+
+ $count = 0;
+ $text = array();
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $key => $kategorija) {
+ if ($additional_field) { # za odklon in povprečje
+ $xi = $key;
+ $fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
+ $sum_xi_fi += $xi * $fi ;
+ $N += $fi;
+ }
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'] * 100 / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+
+ $text[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'].' ('.self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').')';
+
+ $count++;
+ }
+ }
+
+ $tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+
+ // suma
+ $tex .= " & ".$this->encodeText((int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'].' ('.self::formatNumber(100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%').')');
+
+ // zamenjano veljavni ustrezni
+ if ($additional_field){
+/* $this->pdf->MultiCell(15, $height, $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(15, $height, $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']), 1, 'C', 0, 0, 0 ,0, true); */
+ $tex .= " & ".$this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']);
+ $tex .= " & ".$this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+ }
+ else{
+/* $this->pdf->MultiCell(30, $height, $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(30, $height, $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']), 1, 'C', 0, 1, 0 ,0, true); */
+ $tex .= " & ".$this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']);
+ $tex .= " & ".$this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+ }
+
+ # za odklon in povprečje
+ if ($additional_field){
+ # odklon
+ $avg = ($N > 0) ? $sum_xi_fi / $N : 0;
+ #standardna diviacija
+ $div = 0;
+ $sum_pow_xi_fi_avg = 0;
+ if (count($spremenljivka['options']) > 0) {
+ foreach ( $spremenljivka['options'] as $xi => $kategorija) {
+ $fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$xi]['cnt'];
+ $sum_pow_xi_fi_avg += pow(($xi - $avg),2) * $fi;
+ }
+ }
+ $div = (($N -1) > 0) ? sqrt($sum_pow_xi_fi_avg / ($N -1)) : 0;
+
+ $tex .= " & ".$this->encodeText(self::formatNumber($avg,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ $tex .= " & ".$this->encodeText(self::formatNumber($div,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ }
+
+ /*zakljucek vrstice*/
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*horizontalna linija*/
+ }
+
+ }
+ else {
+ # immamo polje drugo
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+
+ }
+ }
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+
+ //echo "Latex tabele: ".$tex."</br>";
+ return $tex;
+ }
+
+ /** Izriše tekstovne odgovore v vertikalni obliki z Latex
+ *
+ * @param unknown_type $spid
+ */
+
+ function sumTextVerticalNew($spid=null, $_from=null, $export_format='') {
+ //echo "sumTextVertical </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (SurveyAnalysis::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'textAnswerExceed' => false, 'exportFormat' => $export_format);
+
+ #Priprava prve tabele, z imenom vprasanja/spremenljivke in besedilom vprasanja#######################################################
+
+ //Priprava parametrov za tabelo z imenom vprasanja/spremenljivke in besedilom vprasanja
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'A|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za tabelo z imenom vprasanja/spremenljivke in besedilom vprasanja
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za tabelo - konec
+
+ /*Naslovna vrstica tabele*/
+ //prva vrstica tabele
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{>{\hsize=\dimexpr 6\hsize+\arrayrulewidth}X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ $tex .= $this->encodeText($spremenljivka['variable']).' & '.$this->encodeText($spremenljivka['naslov']).' '.$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //zaljucek latex tabele z obrobo za tabelo z imenom vprasanja/spremenljivke in besedilom vprasanja
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ #Priprava prve tabele, z imenom vprasanja/spremenljivke in besedilom vprasanja - konec #############################################
+
+ #Priprava druge tabele, z odgovori #############################################
+ //Priprava parametrov za tabelo s podatki oz. odgovori
+ $steviloStolpcevParameterTabular = 6;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ $parameterTabular .= ($export_format == 'pdf' ? 'A|' : 'l|');
+ }elseif($i == 1){ //ce je drugi stolpec z odgovori
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize=0.3\textwidth}X|' : 'l|');
+ }else{
+ //$parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|');
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ //druga vrstica tabele z naslovi stolpcev
+ $tex .= $this->tableHeader($export_format);
+ /*Naslovni vrstici tabele - konec*/
+
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ # dodamo dodatne vrstice z labelami grida
+ if ($_variables_count > 1) {
+ self::outputGridLabelVertical($gid,$grid,$vid,$variable,$spid,$options);
+ }
+
+ $maxAnswer = (SurveyDataSettingProfiles :: getSetting('numOpenAnswers') > 0) ? SurveyDataSettingProfiles :: getSetting('numOpenAnswers') : 30;
+ $counter = 0;
+ $_kumulativa = 0;
+ //SurveyAnalysis::$_FREQUENCYS[$_sequence]
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if (/*$vAnswer['cnt'] > 0 &&*/ $counter < $maxAnswer) { # izpisujemo samo tiste ki nisno 0
+ # ali prikažemo vse odgovore ali pa samo toliko koliko je nastavljeno v TEXT_ANSWER_LIMIT
+ $textAnswerExceed = ($counter >= TEXT_ANSWER_LIMIT && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > TEXT_ANSWER_LIMIT+2) ? true : false; # ali začnemo skrivati tekstovne odgovore
+ $options['isTextAnswer']=true;
+ $options['textAnswerExceed'] = $textAnswerExceed;
+ /*$counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);*/
+ $tex .= self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ $counter++;
+ }
+ # izpišemo sumo veljavnih
+ /*$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);*/
+ $tex .= self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ $_Z_MV = !$this->hideEmpty;
+ if($_Z_MV){ //ce je potrebno izpisati tudi manjkajoce
+ $tex .= $this->encodeText($lang['srv_anl_missing1']);
+ }
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ /*$counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);*/
+ $tex .= self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ /*$counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);*/
+ $tex .= self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ /*$counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);*/
+ $tex .= self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ #Priprava druge tabele, z odgovori - konec #############################################
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ /*self::outputOtherAnswers($oAnswers);*/
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+
+ return $tex;
+ }
+
+ function sumTextVertical($spid=null, $_from=null, $export_format='') {
+ //echo "sumTextVertical </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+ $inline_legenda = (SurveyAnalysis::$_HEADERS[$spid]['cnt_all'] == 1 || in_array($spremenljivka['tip'],array(1,8) ) ) ? false: true;
+ $options=array('inline_legenda' => $inline_legenda, 'isTextAnswer' => false, 'isOtherAnswer' => false, 'textAnswerExceed' => false, 'exportFormat' => $export_format);
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 6;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{>{\hsize=\dimexpr 6\hsize+\arrayrulewidth}X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{5}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica tabele z naslovi stolpcev
+ $tex .= $this->tableHeader($export_format);
+ /*Naslovni vrstici tabele - konec*/
+
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ if ($_grids_count > 0)
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0)
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ # dodamo dodatne vrstice z labelami grida
+ if ($_variables_count > 1) {
+ self::outputGridLabelVertical($gid,$grid,$vid,$variable,$spid,$options);
+ }
+
+ $maxAnswer = (SurveyDataSettingProfiles :: getSetting('numOpenAnswers') > 0) ? SurveyDataSettingProfiles :: getSetting('numOpenAnswers') : 30;
+ $counter = 0;
+ $_kumulativa = 0;
+ //SurveyAnalysis::$_FREQUENCYS[$_sequence]
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if (/*$vAnswer['cnt'] > 0 &&*/ $counter < $maxAnswer) { # izpisujemo samo tiste ki nisno 0
+ # ali prikažemo vse odgovore ali pa samo toliko koliko je nastavljeno v TEXT_ANSWER_LIMIT
+ $textAnswerExceed = ($counter >= TEXT_ANSWER_LIMIT && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > TEXT_ANSWER_LIMIT+2) ? true : false; # ali začnemo skrivati tekstovne odgovore
+ $options['isTextAnswer']=true;
+ $options['textAnswerExceed'] = $textAnswerExceed;
+ /*$counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);*/
+ $tex .= self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,$options);
+ }
+ $counter++;
+ }
+ # izpišemo sumo veljavnih
+ /*$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);*/
+ $tex .= self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ $_Z_MV = !$this->hideEmpty;
+ if($_Z_MV){ //ce je potrebno izpisati tudi manjkajoce
+ $tex .= $this->encodeText($lang['srv_anl_missing1']);
+ }
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ /*$counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);*/
+ $tex .= self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,$options);
+ }
+ }
+ # izpišemo sumo veljavnih
+ /*$counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);*/
+ $tex .= self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$options);
+ }
+ #izpišemo še skupno sumo
+ /*$counter = self::outputSumaVertical($counter,$_sequence,$spid,$options);*/
+ $tex .= self::outputSumaVertical($counter,$_sequence,$spid,$options);
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ }
+ }
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ /*self::outputOtherAnswers($oAnswers);*/
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+
+ return $tex;
+ }
+
+ /** Izriše lokacijske odgovore kot tabelo z navedbami z Latex
+ *
+ * @param unknown_type $spid
+ */
+ function sumLokacija($spid=null, $_from=null, $export_format='') {
+ //echo "sumLokacija </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ $enota = $spremenljivka['enota'];
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = SurveyAnalysis::getNumRecords();
+
+ $_answers = SurveyAnalysis::getAnswers($spremenljivka,$num_show_records);
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+
+
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis*/
+ if ($_grids_count > 0) {
+ # naslovna vrstica
+ $_row = $spremenljivka['grids'][0];
+
+ $height = 0;
+
+ $count = 0;
+ $text = array();
+ foreach ($_row['variables'] AS $rid => $_col ){
+ $_sequence = $_col['sequence']; # id kolone z podatki
+
+ if ($_col['other'] != true) {
+ $text[] = $_col['naslov'];
+ }
+ else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+
+ $count++;
+ }
+ }
+
+ $steviloStolpcevParameterTabular = 1 + $count;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ //$parameterTabular = '';
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis - konec*/
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+
+ /*Naslovna vrstica tabele*/
+ /*prva vrstica*/
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /*Konec naslovne vrstice*/
+
+ if ($_grids_count > 0) {
+ $height = 0;
+/* // Testiramo visino vrstice glede na najdaljsi text
+ foreach ($text AS $string){
+ $singleWidth = ($count > 0) ? round(162 / $count): 162;
+ //$height = ($this->getCellHeight($string, $singleWidth) > $height) ? $this->getCellHeight($string, $singleWidth) : $height;
+ $height = 1;
+ } */
+
+ /*$this->pdf->MultiCell(18, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);*/
+
+ /*$this->dynamicCells($text, $count, 162, $height);*/
+ /*$this->pdf->ln($height);*/
+ /*druga vrstica*/
+ $brezHline3 = 1;
+ $brezNoveVrstice3 = 1;
+ $nadaljevanjeVrstice3 = 1;
+ /*prva prazna stolpca v 2. vrstici*/
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 1;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+
+ $tex .= $this->dynamicCells($text, $count); //izpis celic z odgovori v stolpcih (npr. Sploh ne velja, ...)
+
+ $tex .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex;
+ }
+ /*prva prazna stolpca v 2. vrstici - konec*/
+ /*druga vrstica - konec*/
+ $last = 0;
+ /*izpis vrstic s podatki*/
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ $height = 0;
+
+ if ($_variables_count > 0) {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']));
+ }
+
+ # za barvanje
+ $last = ($last & 1) ? 0 : 1 ;
+
+ $count = 0;
+ $text = array();
+
+ $answers = array();
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ # tabela z navedbami
+ $index=0;
+ # odvisno ali imamo odgovor
+ if (count($_valid_answers) > 0) {
+ $text2 = '(';
+ foreach ($_valid_answers AS $answer) {
+
+ $_ans = $answer[$_sequence];
+ if($enota != 3)
+ $_ans = str_replace("<br>","), (",$_ans);
+
+ if ($_ans != null && $_ans != '') {
+ if($enota == 3)
+ $text2 .= $_ans."), (";
+ else
+ $answers[$count][$index]='('.$this->encodeText($_ans).')';
+ }
+
+ $index++;
+ }
+ if($enota == 3)
+ $text[] = substr($text2, 0, -3);
+ }
+ else {
+ $text[] = '&nbsp;';
+ }
+
+ $count++;
+ }
+
+ }
+ $last = $_max_i;
+ }
+
+ if($enota != 3){
+ for($i=0; $i<sizeof($answers[0]); $i++){
+ $row = array();
+ for($j=0; $j<$count; $j++){
+ // Testiramo visino vrstice glede na najdaljsi text
+ $singleWidth = ($count > 0) ? round(162 / $count): 162;
+ //$height = ($this->getCellHeight($answers[$j][$i], $singleWidth) > $height) ? $this->getCellHeight($answers[$j][$i], $singleWidth) : $height;
+ $height = 1;
+ $row[$j] = $answers[$j][$i];
+ }
+
+
+ //$tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+ $tex .= $this->sumLokacijaRowOutput($row, $count, $height, $grid['variable']);
+ /*$this->sumLokacijaRowOutput($row, $count, $height, $grid['variable']);*/
+
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*horizontalna crta*/
+ }
+ }
+ }
+ else{
+ // Testiramo visino vrstice glede na najdaljsi text
+ foreach ($text AS $string){
+ $singleWidth = ($count > 0) ? round(162 / $count): 162;
+ //$height = ($this->getCellHeight($string, $singleWidth) > $height) ? $this->getCellHeight($string, $singleWidth) : $height;
+ $height = 1;
+ }
+
+ //$tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+ $tex .= $this->sumLokacijaRowOutput($text, $count, $height, $grid['variable']);
+ /*$this->sumLokacijaRowOutput($text, $count, $height, $grid['variable']);*/
+ }
+ /*zakljucek vrstice s podatki*/
+/* $tex .= $this->texNewLine; //nova vrstica
+ $tex .= $this->horizontalLineTex; //horizontalna crta */
+ }
+ /*izpis vrstic s podatki - konec*/
+
+
+ //zaljucek latex tabele z obrobo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo - konec
+ }
+ //echo "tex: ".$tex."</br>";
+ return $tex;
+ }
+
+ /**
+ * Izrise vrstico prilagojeno za lokacijo
+ *
+ * @param type $text - array odgovorov
+ * @param type $count - st variabel/stolpcev
+ * @param type $height - izracunana najvisja visina celice v vrstici
+ * @param type $variable - array variabel/stolpcev
+ */
+ function sumLokacijaRowOutput($text='', $count, $height=null, $variable='') {
+ $texSumLokacijaRowOutput = '';
+ $texSumLokacijaRowOutput .= " & ".$this->encodeText($variable);
+/* $this->pdf->MultiCell(18, $height, $this->encodeText($variable), 1, 'C', 0, 0, 0 ,0, true);
+ $this->dynamicCells($text, $count, 162, $height);
+ $this->pdf->ln($height); */
+ $texSumLokacijaRowOutput .= $this->dynamicCells($text, $count);
+
+ return $texSumLokacijaRowOutput;
+ }
+
+ /** Izriše tekstovne odgovore kot tabelo z navedbami z Latex
+ *
+ * @param unknown_type $spid
+ */
+ function sumMultiText($spid=null, $_from, $export_format='') {
+ //echo "sumMultiText </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ # pogledamo koliko je max št odgovorov pri posameznem podvprašanju
+/* $_max_answers = array();
+ $_max_answers_cnt = 0;
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0) {
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_answers[$gid][$vid] = count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']);
+ $_max_answers_cnt = max( $_max_answers_cnt, count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) );
+ }
+ }
+ }
+*/
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = SurveyAnalysis::getNumRecords();
+ //$num_show_records = $_max_answers_cnt <= (int)$num_show_records ? $_max_answers_cnt : $num_show_records;
+
+ $_answers = SurveyAnalysis::getAnswers($spremenljivka,$num_show_records);
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+
+
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis*/
+ if ($_grids_count > 0) {
+ # naslovna vrstica
+ $_row = $spremenljivka['grids'][0];
+ $count = 0;
+ $text = array();
+ foreach ($_row['variables'] AS $rid => $_col ){
+ $_sequence = $_col['sequence']; # id kolone z podatki
+
+ if ($_col['other'] != true) {
+ $text[] = $_col['naslov'];
+ }
+ else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+
+ $count++;
+ }
+ }
+
+ $steviloStolpcevParameterTabular = 2 + $count;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis - konec*/
+
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_opisne_subquestion1'])." & \multicolumn{".$count."}{c|}{".$this->encodeText($lang['srv_analiza_opisne_arguments'])."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //konec naslovnih vrstic
+
+ if ($_grids_count > 0) {
+ /*$height = 0;*/
+
+ // Testiramo visino vrstice glede na najdaljsi text
+/* foreach ($text AS $string){
+ $singleWidth = ($count > 0) ? round(108 / $count): 108;
+ //$height = ($this->getCellHeight($string, $singleWidth) > $height) ? $this->getCellHeight($string, $singleWidth) : $height;
+ $height = 1;
+ } */
+
+ /*tretja vrstica*/
+ $brezHline3 = 1;
+ $brezNoveVrstice3 = 1;
+ $nadaljevanjeVrstice3 = 1;
+ /*prva prazna stolpca v 3. vrstici*/
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 2;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+
+ $tex .= $this->dynamicCells($text, $count); //izpis celic z odgovori v stolpcih (npr. Sploh ne velja, ...)
+
+ $tex .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /*prva prazna stolpca v 3. vrstici - konec*/
+
+ $last = 0;
+ /*izpis vrstic s podatki*/
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+ $height = 0;
+
+ if ($_variables_count > 0) {
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']));
+ }
+
+ # za barvanje
+ $last = ($last & 1) ? 0 : 1 ;
+
+ $count = 0;
+ $text = array();
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ # tabela z navedbami
+ $index=0;
+ # odvisno ali imamo odgovor
+ if (count($_valid_answers) > 0) {
+ $text2 = '';
+ foreach ($_valid_answers AS $answer) {
+ $index++;
+
+ $_ans = $answer[$_sequence];
+
+ if ($_ans != null && $_ans != '') {
+ $text2 .= $_ans.', ';
+ }
+ }
+ $text[] = substr($text2, 0, -2);
+ }
+ else {
+ $text[] = '&nbsp;';
+ }
+
+ $count++;
+ }
+
+ }
+ $last = $_max_i;
+ }
+
+ // Testiramo visino vrstice glede na najdaljsi text
+ foreach ($text AS $string){
+ $singleWidth = ($count > 0) ? round(108 / $count): 108;
+ //$height = ($this->getCellHeight($string, $singleWidth) > $height) ? $this->getCellHeight($string, $singleWidth) : $height;
+ $height = 1;
+ }
+
+ $tex .= $this->encodeText($grid['variable']);
+ $tex .= " & ".$this->encodeText($grid['naslov']);
+
+
+ $tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+
+
+ /*zakljucek vrstice s podatki*/
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*horizontalna crta*/
+ }
+ }
+ /*izpis vrstic s podatki - konec*/
+
+ //zaljucek latex tabele z obrobo za drugo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za drugo tabelo - konec
+ }
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+ return $tex;
+ }
+
+ /** Izriše multi number odgovore. izpiše samo povprečja z Latex
+ *
+ * @param unknown_type $spid
+ */
+ function sumMultiNumber($spid=null, $_from=null, $export_format='') {
+ //echo "sumMultiNumber </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis*/
+ if ($_grids_count > 0) {
+ # naslovna vrstica
+ $_row = $spremenljivka['grids'][0];
+ $count = 0;
+ $text = array();
+ foreach ($_row['variables'] AS $rid => $_col ){
+ $_sequence = $_col['sequence']; # id kolone z podatki
+
+ if ($_col['other'] != true) {
+ $text[] = $_col['naslov'];
+ }
+ else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+
+ $count++;
+ }
+ }
+
+ $steviloStolpcevParameterTabular = 2 + $count;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis - konec*/
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_opisne_subquestion1'])." & \multicolumn{".$count."}{c|}{".$this->encodeText($lang['srv_analiza_sums_average'])."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ /*Konec naslovnih vrstic*/
+
+ if ($_grids_count > 0) {
+ /*tretja vrstica*/
+ $brezHline3 = 1;
+ $brezNoveVrstice3 = 1;
+ $nadaljevanjeVrstice3 = 1;
+ /*prva prazna stolpca v 3. vrstici*/
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 2;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+
+ $tex .= $this->dynamicCells($text, $count); //izpis celic z odgovori v stolpcih (npr. Sploh ne velja, ...)
+
+ $tex .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /*prva prazna stolpca v 3. vrstici - konec*/
+
+ $last = 0;
+ /*izpis vrstic s podatki*/
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ $_variables_count = count($grid['variables']);
+
+ $tex .= $this->encodeText($grid['variable']);
+ $tex .= " & ".$this->encodeText($grid['naslov']);
+
+ if ($_variables_count > 0) {
+
+ $count = 0;
+ $text = array();
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true) {
+ # tabela z navedbami
+ $text[] = self::formatNumber(SurveyAnalysis::$_FREQUENCYS[$_sequence]['average'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ $count++;
+ }
+ //$count++;
+ }
+ $tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+ }
+ /*zakljucek vrstice s podatki*/
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*horizontalna linija*/
+ }
+ }
+ /*izpis vrstic s podatki - konec*/
+
+ //zaljucek latex tabele z obrobo za drugo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za drugo tabelo - konec
+
+ }
+ /*echo "Latex tabele: ".$tex."</br>";*/
+ return $tex;
+ }
+
+
+ /** Izriše sumarnik v horizontalni obliki za multi checkbox z Latex
+ *
+ * @param unknown_type $spid - spremenljivka ID
+ */
+ function sumMultiHorizontalCheckbox($spid=null, $_from=null, $export_format='') {
+ //echo "sumMultiHorizontalCheckbox </br>";
+ global $lang;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+ $_answersOther = array();
+
+ # ugotovimo koliko imamo kolon
+ $gid=0;
+ $_clmn_cnt = SurveyAnalysis::$_HEADERS[$spid]['grids'][$gid]['cnt_vars']-SurveyAnalysis::$_HEADERS[$spid]['grids'][$gid]['cnt_other'];
+ # tekst vprašanja
+
+ /*Priprava parametrov za tabelo in polja za 3. vrstico */
+ $_variables = SurveyAnalysis::$_HEADERS[$spid]['grids'][$gid]['variables'];
+ $count = 0;
+ $height = 0;
+ $textVrstica3 = array();
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ $textVrstica3[] = $variable['naslov'].' ('.$variable['gr_id']. ')';
+
+ /*$singleWidth = round(54 / (count($_variables) + 1));
+ $height = 1; //$height = ($height < $this->getCellHeight($variable['naslov'].' ('.$variable['gr_id']. ')', $singleWidth)) ? $this->getCellHeight($variable['naslov'].' ('.$variable['gr_id']. ')', $singleWidth) : $height; */
+ }
+ $count++;
+ }
+
+ $steviloStolpcevParameterTabular = 5 + 2*$count;
+
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'b|' : 'l|');
+ $parameterTabular .= ($export_format == 'pdf' ? 's|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }else if($i == 1){
+ $parameterTabular .= ($export_format == 'pdf' ? 'B|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }
+ else{
+ $parameterTabular .= ($export_format == 'pdf' ? 's|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }
+
+ }
+ /*Priprava parametrov za tabelo in polja za 3. vrstico - konec*/
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /* prva vrstica */
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /* prva vrstica - konec */
+
+ /* druga vrstica*/
+ //$steviloPodStolpcev2 = count($spremenljivka['options']) + 1;
+ $steviloPodStolpcev2 = $count;
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_opisne_subquestion1'])." & \multicolumn{".$steviloPodStolpcev2."}{c|}{".$this->encodeText($lang['srv_analiza_opisne_answers'])."} ";
+
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_opisne_valid']);
+ $tex .= " & ".$this->encodeText($lang['srv_analiza_num_units']);
+
+ $steviloPodStolpcev3 = $count+1;
+ $tex .= " & \multicolumn{".$steviloPodStolpcev3."}{c|}{".$this->encodeText($lang['srv_analiza_opisne_arguments'])."} ";
+
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /* druga vrstica - konec*/
+
+
+ /*tretja vrstica*/
+ $brezHline3 = 1;
+ $brezNoveVrstice3 = 1;
+ $nadaljevanjeVrstice3 = 1;
+ /*prva prazna stolpca 3. vrstice*/
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 2;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+ /*prva prazna stolpca 3. vrstice - konec*/
+
+ $tex .= $this->dynamicCells($textVrstica3, $count); //izpis celic z odgovori v stolpcih (npr. Sploh ne velja, ...)
+
+ /*se dva prazna stolpca 3. vrstice*/
+ $textPrazniStolpci = array();
+ $steviloPraznihStolpcev = 2;
+ for($i=0;$i<$steviloPraznihStolpcev;$i++){
+ $textPrazniStolpci[$i] = '';
+ }
+ $tex .= $this->tableRow($textPrazniStolpci, $brezHline3, $brezNoveVrstice3, $nadaljevanjeVrstice3); //izpis ostalega dela vrstice
+ /*se dva prazna stolpca 3. vrstice - konec*/
+
+ $tex .= " & ".$this->dynamicCells($textVrstica3, $count); //izpis celic z odgovori v stolpcih (npr. Sploh ne velja, ...)
+
+/* $count = 0;
+ $text = array();
+ foreach ($_variables AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ $text[] = $variable['naslov'].' ('.$variable['gr_id']. ')';
+ }
+ $count++;
+ }
+ $this->dynamicCells($text, $count, 44, $height); */
+
+ $tex .= " & ".$this->encodeText($lang['srv_anl_suma1']); //Skupaj
+
+ $tex .= $this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ } //horizontalna crta
+ /*tretja vrstica - konec*/
+
+ /*vrstice s podatki*/
+ foreach (SurveyAnalysis::$_HEADERS[$spid]['grids'] AS $gid => $grids) {
+
+ $_cnt = 0;
+ $height = 1;//$height = $this->getCellHeight($this->encodeText($grids['naslov']), 18);
+ $height = ($height < 8 ? 8 : $height);
+
+ # vodoravna vrstice s podatki
+ $tex .= $this->encodeText($grids['variable']);
+ $tex .= " & ".$this->encodeText($grids['naslov']);
+
+ $_arguments = 0;
+
+ $_max_appropriate = 0;
+ $_max_cnt = 0;
+ // prikaz frekvenc
+ $count = 0;
+ $text = array();
+ foreach ($grids['variables'] AS $vkey => $variable) {
+ $_sequence = $variable['sequence'];
+ $_valid = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+ $_cnt = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+ $_arguments += $_cnt;
+
+ $_max_appropriate = max($_max_appropriate, (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']);
+ $_max_cnt = max ($_max_cnt, ((int)(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt']+(int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['0']['cnt'])));
+
+ if ($variable['other'] == true) {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vkey,'sequence'=>$_sequence);
+ }
+
+ if ($variable['other'] != true) {
+ $_percent = ($_valid > 0 ) ? $_cnt * 100 / $_valid : 0;
+
+ $text[] = $_cnt . ' (' . self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%') . ')';
+ $count++;
+ }
+
+ }
+
+ $tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+
+ # veljavno
+ $tex .= " & ".$_max_cnt;
+
+ #ustrezno
+ $tex .= " & ".$_max_appropriate;
+
+ $count = 0;
+ $text = array();
+ foreach ($grids['variables'] AS $vkey => $variable) {
+ if ($variable['other'] != true) {
+ $_sequence = $variable['sequence'];
+ $_cnt = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'];
+
+ $_percent = ($_arguments > 0 ) ? $_cnt * 100 / $_arguments : 0;
+
+ $text[] = $_cnt . ' (' . self::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%') . ')';
+ $count++;
+ }
+ }
+
+ $tex .= " & ".$this->dynamicCells($text, $count); //izpis celic z izracuni odgovorov v stolpcih (npr. Sploh ne velja, ...)
+
+ $tex .= " & ".$_arguments;
+
+ /*zakljucek vrstice*/
+ $tex .= $this->texNewLine; //nova vrstica
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ } //horizontalna crta
+ }
+ /*vrstice s podatki - konec*/
+
+ /*zaljucek latex tabele z obrobo za prvo tabelo*/
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ /*zaljucek latex tabele z obrobo za prvo tabelo - konec*/
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format);
+ }
+ }
+ //echo "tex: ".$tex."</br>";
+ return $tex;
+ }
+
+ /** za multi grid tekstovne vrstice doda vrstico z labeliami grida
+ *
+ * @param $gkey
+ * @param $gAnswer
+ * @param $spid
+ * @param $_options
+ */
+ function outputGridLabelVertical($gid=null, $grid=null, $vid=null, $variable=null, $spid=null, $_options=array()) {
+ //echo "outputGridLabelVertical </br>";
+ $text = array();
+
+ $text[] = $this->encodeText($variable['variable']);
+ $text[] = $this->encodeText(($grid['naslov'] != '' ? $grid['naslov']. '&nbsp;-&nbsp;' : '').$variable['naslov']);
+
+ $text[] = '';
+ $text[] = '';
+ $text[] = '';
+ $text[] = '';
+
+ $this->tableRow($text);
+
+ $counter++;
+ return $counter;
+ }
+
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ function formatNumber($value=null, $digit=0, $sufix=""){
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+
+
+
+ /** Izriše heatmap odgovore.
+ *
+ * @param unknown_type $spid
+ */
+ function sumHeatmap($spid=null, $_from=null, $export_format='') {
+ //echo "sumHeatmap </br>";
+ global $lang;
+ global $site_url;
+ global $site_path;
+ $tex = '';
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ //Priprava podatkov za tabelo
+ # preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore in nastavitev
+ $only_valid = 0;
+ if (count($spremenljivka['grids']) > 0) {
+ foreach ($spremenljivka['grids'] AS $gid => $grid) {
+ # dodamo dodatne vrstice z albelami grida
+ if (count($grid['variables']) > 0 )
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $only_valid += (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
+ }
+ }
+ }
+ if (SurveyDataSettingProfiles :: getSetting('hideEmpty') == 1 && $only_valid == 0 && SurveyAnalysis::$_forceShowEmpty == false) {
+ return;
+ }
+
+ # dodamo opcijo kje izrisujemo legendo
+ # če je besedilo * in je samo ena kategorija je inline legenda false
+
+ $_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
+
+ # koliko zapisov prikažemo naenkrat
+ $num_show_records = SurveyAnalysis::getNumRecords();
+
+ $_answers = SurveyAnalysis::getAnswers($spremenljivka,$num_show_records);
+
+ $_all_valid_answers_cnt = $_answers['validCnt'];
+ $_valid_answers = $_answers['valid'];
+
+ $export = 1;
+
+ //2. stolpec - Veljavni za x in y koordinati
+ $validHeatmapRegion = SurveyAnalysis::validHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers, $export);
+ //3. stolpec - Ustrezni za x in y koordinati
+ $ustrezniHeatmapRegion = SurveyAnalysis::ustrezniHeatmapRegion($spid, $_valid_answers, $_sequence); //vsi mozni kliki
+ //4. stolpec - Povprecje za x in y koordinati
+ $povprecjeHeatmapClicksX = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'povprecje', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ $povprecjeHeatmapClicksY = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'povprecje', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ //5. stolpec - Standardni odklon za x in y koordinati
+ $stdevHeatmapClicksX = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'stdev', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ $stdevHeatmapClicksY = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'stdev', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ //6. stolpec - Minimum za x in y koordinati
+ $minHeatmapClicksX = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'min', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ $minHeatmapClicksY = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'min', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ //7. stolpec - Max za x in y koordinati
+ $maxHeatmapClicksX = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'x', $validHeatmapRegion, 'max', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ $maxHeatmapClicksY = self::formatNumber(SurveyAnalysis::heatmapClicksCalc($spremenljivka['grids'], $spid, $_valid_answers, 'y', $validHeatmapRegion, 'max', $export),SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
+ //Priprava podatkov za tabelo - konec
+
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis*/
+ $steviloStolpcevParameterTabular = 7;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ /*Priprava parametrov za tabelo in ostala polja za nadaljnji izpis - konec*/
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ $steviloPodStolpcev1 = $steviloStolpcevParameterTabular - 1;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ //$tex .= $this->encodeText($spremenljivka['variable']).' & \multicolumn{'.$steviloPodStolpcev1.'}{>{\hsize=\dimexpr '.($steviloPodStolpcev1+1).'\hsize + '.($steviloPodStolpcev1+1).'\tabcolsep + \arrayrulewidth}X|}{'.$this->encodeText($spremenljivka['naslov']).'} '.$this->texNewLine;
+ $dolzinaVprasanja = strlen($this->encodeText($spremenljivka['naslov']));
+ //echo $dolzinaVprasanja."</br>";
+ if($dolzinaVprasanja > MEJA_DOLZINA_VPRASANJA){ //ce je dolzina vprasanja daljsa od ene vrstice v tabeli
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{X|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }else{
+ $tex .= $this->encodeText($spremenljivka['variable'])." & \multicolumn{".$steviloPodStolpcev1."}{l|}{".$this->encodeText($spremenljivka['naslov'])."} ".$this->texNewLine;
+ }
+
+
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //druga vrstica
+ $spr_id = $this->GetSprId($spid);
+
+ $heatmapImageFileName = 'heatmap'.$spr_id;
+ $heatmapImageSrc = $site_path.'main/survey/uploads/'.$heatmapImageFileName.'.png';
+ $heatmapImageFileNamePresent = file_exists($heatmapImageSrc);
+ if($heatmapImageFileNamePresent){ //ce je prisotna datoteka heatmap slike
+ $heatmapImage = '\includegraphics[scale=0.5]{'.$heatmapImageFileName.'}';
+ }else{ //ce ni
+ //$heatmapImage = 'Pred izvozom, zgenerirajte heatmap';
+ $heatmapImage = $lang['export_analysis_heatmap_msg'];
+ }
+ $tex .= " & \multicolumn{".$steviloPodStolpcev1."}{c|}{".$heatmapImage."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ /*Konec naslovnih vrstic*/
+
+ //tretja vrstica
+ $tex .= " \multicolumn{".$steviloStolpcevParameterTabular."}{|c|}{".$this->encodeText($lang['srv_analiza_heatmap_clicked_coords'])."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //tretja vrstica - konec
+
+
+ $brezHline = $this->getBrezHline($export_format);
+
+ //cetrta vrstica
+ $cetrtaVrstica = array();
+ $cetrtaVrstica[] = $this->encodeText($lang['coordinates']);
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_valid_heatmap']);
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_analiza_num_units_valid_heatmap']);
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_means_label']);
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_odklon']);
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_min']);
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_max']);
+ $tex .= $this->tableRow($cetrtaVrstica, $brezHline);
+ //cetrta vrstica - konec
+
+ //vrstici s podatki za x in y koordinati
+ //peta vrstica x
+ $petaVrstica = array();
+ $petaVrstica[] = 'x';
+ $petaVrstica[] = $this->encodeText($validHeatmapRegion);
+ $petaVrstica[] = $this->encodeText($ustrezniHeatmapRegion);
+ $petaVrstica[] = $this->encodeText($povprecjeHeatmapClicksX);
+ $petaVrstica[] = $this->encodeText($stdevHeatmapClicksX);
+ $petaVrstica[] = $this->encodeText($minHeatmapClicksX);
+ $petaVrstica[] = $this->encodeText($maxHeatmapClicksX);
+ $tex .= $this->tableRow($petaVrstica, $brezHline);
+ //peta vrstica x - konec
+
+ //sesta vrstica y
+ $sestaVrstica = array();
+ $sestaVrstica[] = 'y';
+ $sestaVrstica[] = $this->encodeText($validHeatmapRegion);
+ $sestaVrstica[] = $this->encodeText($ustrezniHeatmapRegion);
+ $sestaVrstica[] = $this->encodeText($povprecjeHeatmapClicksY);
+ $sestaVrstica[] = $this->encodeText($stdevHeatmapClicksY);
+ $sestaVrstica[] = $this->encodeText($minHeatmapClicksY);
+ $sestaVrstica[] = $this->encodeText($maxHeatmapClicksY);
+ $tex .= $this->tableRow($sestaVrstica, $brezHline);
+ //sesta vrstica y - konec
+ //vrstici s podatki za x in y koordinati - konec
+
+ //preveri, ali je prisotno kaksno obmocje, nadaljuj izris tabele
+ $RegionPresent = self::HeatmapRegionPresence($spremenljivka['grids'], $spid, $_valid_answers);
+ //preveri, ali je prisotno kaksno obmocje, nadaljuj izris tabele - konec
+
+ if($RegionPresent){ //ce imamo obmocja
+ //7. vrstica - naslovna za obmocja
+ $tex .= " \multicolumn{".$steviloStolpcevParameterTabular."}{|c|}{".$this->encodeText($lang['srv_analiza_heatmap_clicked_regions'])."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex; /*obroba*/
+ }
+ //konec - 7. vrstice
+
+ //8. vrstica
+ $osmaVrstica = array();
+ $osmaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_frequency_heatmap']);//od tretjega stolpca dalje, ker prva dva sta za naslov Obmocja kot multicolumn
+ $osmaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_valid_heatmap']);
+ $osmaVrstica[] = $this->encodeText('% - '.$lang['srv_analiza_opisne_valid_heatmap']);
+ $osmaVrstica[] = $this->encodeText($lang['srv_analiza_num_units_valid_heatmap']);
+ $osmaVrstica[] = $this->encodeText('% - '.$lang['srv_analiza_num_units_valid_heatmap']);
+
+ $tex .= " \multicolumn{2}{|c|}{".$this->encodeText($lang['srv_hot_spot_regions_menu'])."} ";
+ $tex .= $this->tableRow($osmaVrstica, 0, 0, 1);
+ //echo $tex;
+ //8. vrstica - konec
+
+ $_answersOther = array();
+ $_grids_count = count($spremenljivka['grids']);
+ $_css_bck = 'anl_bck_desc_2 anl_ac anl_bt_dot ';
+ $last = 0;
+
+ if ($_grids_count > 0) {
+ $_row = $spremenljivka['grids'][0];
+ $indeks = 0;
+ //$veljavnaSkupnaFreq = 0;
+ if (count($_row['variables'])>0){
+ foreach ($_row['variables'] AS $rid => $_col ){
+ $_sequence = $_col['sequence']; # id kolone z podatki
+ if ($_col['other'] != true) {
+ if($indeks != 0){
+ //echo "_col: ".strip_tags ($_col['naslov'])."</br>";
+ //od 9. vrstice dalje, kjer so po vrsticah obmocja in njihovi podatki
+ $devetaVrstica = array();
+ //1. stolpcev z imenom obmocja
+ //echo $_col['naslov'];
+ //$devetaVrstica[] = $this->encodeText($_col['naslov']);
+ $devetaVrstica[] = " \multicolumn{2}{|c|}{".$this->encodeText($_col['naslov'])."} ";
+ //$tex .= " \multicolumn{2}{|c|}{".$this->encodeText($_col['naslov'])."} ";
+ //1. stolpcev z imenom obmocja - konec
+
+ //2. stolpec - Frekvenca
+ $freqHeatmapRegion = SurveyAnalysis::freqHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers, $indeks, $export);
+ $veljavnaSkupnaFreq = $veljavnaSkupnaFreq + $freqHeatmapRegion;
+ //echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$freqHeatmapRegion.'</td>';
+ //$devetaVrstica[] = $this->encodeText($freqHeatmapRegion);
+ $devetaVrstica[] = $freqHeatmapRegion;
+ //2. stolpec - Frekvenca - konec
+
+ //3. stolpec - Veljavni
+ //$validHeatmapRegion = self::validHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers);
+ //echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$validHeatmapRegion.'</td>';
+ $devetaVrstica[] = $this->encodeText($validHeatmapRegion);
+ //3. stolpec - Veljavni - konec
+
+ //4. stolpec - % Veljavni
+ $_procentValidHeatmapRegion = ($validHeatmapRegion > 0 ) ? 100*$freqHeatmapRegion / $validHeatmapRegion : 0;
+ $_procentValidHeatmapRegion = self::formatNumber($_procentValidHeatmapRegion, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ //echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$_procentValidHeatmapRegion.'</td>';
+ $devetaVrstica[] = $this->encodeText($_procentValidHeatmapRegion);
+ //4. stolpec - % Veljavni - konec
+
+ //5. stolpec - Ustrezni
+ $ustrezniHeatmapRegion = SurveyAnalysis::ustrezniHeatmapRegion($spid, $_valid_answers, $_sequence); //vsi mozni kliki
+ //echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$ustrezniHeatmapRegion.'</td>';
+ $devetaVrstica[] = $this->encodeText($ustrezniHeatmapRegion);
+ //5. stolpec - Ustrezni - konec
+
+ //6. stolpec - % Ustrezni
+ $_procentUstrezniHeatmapRegion = ($ustrezniHeatmapRegion > 0 ) ? 100*$freqHeatmapRegion / $ustrezniHeatmapRegion : 0;
+ $_procentUstrezniHeatmapRegion = self::formatNumber($_procentUstrezniHeatmapRegion, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%');
+ //echo '<td class="anl_bl anl_br anl_bb anl_ac">'.$_procentUstrezniHeatmapRegion.'</td>';
+ $devetaVrstica[] = $this->encodeText($_procentUstrezniHeatmapRegion);
+ //6. stolpec - % Ustrezni - konec
+
+ $tex .= $this->tableRow($devetaVrstica, $brezHline);
+ //echo $tex;
+ //od 9. vrstice dalje, kjer so po vrsticah obmocja in njihovi podatki - konec
+
+ //*********** Izris veljavnih in manjkajocih vrednosti
+ $counter = 0;
+ $options['isTextAnswer'] = false;
+ $manjkajoci = $ustrezniHeatmapRegion - $validHeatmapRegion;
+
+ //10. vrstica
+ //$validHeatmapRegion
+ //echo $validHeatmapRegion;
+ //echo "validHeatmapRegion: ".$validHeatmapRegion."</br>";
+ //$counter = SurveyAnalysis::outputSumaValidAnswerHeatmap($counter,$_sequence,$spid,$options, $validHeatmapRegion);
+ $desetaVrstica = array();
+ $desetaVrstica[] = $this->encodeText($lang['srv_analiza_opisne_valid']);
+ $desetaVrstica[] = $this->encodeText($lang['srv_analiza_manjkajocevrednosti']);
+ $desetaVrstica[] = $validHeatmapRegion;
+ $desetaVrstica[] = " \multicolumn{4}{|c|}{ } ";
+ $tex .= $this->tableRow($desetaVrstica, $brezHline);
+ //10. vrstica - konec
+
+ //11. vrstica
+ $enajstaVrstica = array();
+ $enajstaVrstica[] = $this->encodeText($lang['srv_anl_missing1']);
+ $enajstaVrstica[] = $this->encodeText($lang['srv_analiza_manjkajocevrednosti']);
+ $enajstaVrstica[] = $manjkajoci;
+ $enajstaVrstica[] = " \multicolumn{4}{|c|}{ } ";
+ $tex .= $this->tableRow($enajstaVrstica, $brezHline);
+ //11. vrstica - konec
+
+ //12. vrstica
+ $dvanajstaVrstica = array();
+ $dvanajstaVrstica[] = " \multicolumn{2}{|c|}{".$this->encodeText($lang['srv_anl_suma_valid'])." } ";
+ $dvanajstaVrstica[] = $ustrezniHeatmapRegion;
+ $dvanajstaVrstica[] = " \multicolumn{4}{|c|}{ } ";
+ $tex .= $this->tableRow($dvanajstaVrstica, $brezHline);
+ //12. vrstica - konec
+
+/* if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki niso 0
+ //$counter = SurveyAnalysis::outputInvalidAnswerHeatmap($counter,$ikey,$iAnswer,$_sequence,$spid,$options, $manjkajoci);
+ //$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$iAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$iAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+ echo "_invalid: ".$_invalid."</br>";
+ //echo "_percent: ".$_percent."</br>";
+ }
+ }
+ # izpišemo sumo neveljavnih
+ //$counter = SurveyAnalysis::outputSumaInvalidAnswerHeatmap($counter,$_sequence,$spid,$options, $manjkajoci);
+ echo "manjkajoci: ".$manjkajoci."</br>";
+ } */
+ #izpišemo še skupno sumo
+ //$counter = SurveyAnalysis::outputSumaHeatmap($counter,$_sequence,$spid,$options, $ustrezniHeatmapRegion);
+ //$ustrezniHeatmapRegion
+ //echo "ustrezniHeatmapRegion: ".$ustrezniHeatmapRegion."</br>";
+ $veljavnaSkupnaFreq = 0;
+ }
+ //*********** Izris veljavnih in manjkajocih vrednosti - konec
+
+ } else {
+ $_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
+ }
+ $indeks++;
+ }
+ }
+ }
+ }
+
+
+ # izpišemo še tekstovne odgovore za polja drugo
+/* if (count($_answersOther) > 0 && self::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ echo '<div class="div_other_text">';
+ self::outputOtherAnswers($oAnswers);
+ echo '</div>';
+ }
+ } */
+
+
+ //zaljucek latex tabele z obrobo za drugo tabelo
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za drugo tabelo - konec
+
+/* if (count($spremenljivka['grids']) > 0) {
+
+ } */
+ //echo "Latex tabele: ".$tex."</br>";
+
+ return $tex;
+ }
+
+
+
+ //izrisemo dinamicne celice (podamo sirino, stevilo celic in vsebino)
+ //function dynamicCells($arrayText, $count, $width, $height, $arrayParams=array()){
+ //izrisemo dinamicne celice (podamo stevilo celic in vsebino)
+ function dynamicCells($arrayText=null, $count=null){
+ $texDynamicCells = '';
+ if($arrayText[0] == '')
+ $arrayText[0] = '';
+
+ /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 30);
+ $linecount == 1 ? $height = 1 : $height = 4.7 + ($linecount-1)*3.3;*/
+ $text = array();
+ for($i=0; $i<$count-1; $i++){
+ //for($i=0; $i<$count; $i++){
+ if($arrayText[$i] == '')
+ $arrayText[$i] = '';
+ /*$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($arrayText[$i]), 1, 'C', 0, 0, 0 ,0, true);*/
+
+ /*$texDynamicCells .= $this->encodeText($arrayText[$i]);*/
+ $text[$i] = $this->encodeText($arrayText[$i]);
+ }
+
+ //zadnje polje izrisemo druge sirine ker se drugace zaradi zaokrozevanja tabela porusi
+ /*$lastWidth = ($lastWidth < 4) ? 4 : $lastWidth;*/
+ if($count > 0){
+ /*$this->pdf->MultiCell($lastWidth, $height, $this->encodeText($arrayText[$count-1]), 1, 'C', 0, 0, 0 ,0, true);*/
+
+ /*$texDynamicCells .= $this->encodeText($arrayText[$count-1]);*/
+ $text[$count-1] = $this->encodeText($arrayText[$count-1]);
+ }else{
+ /*$this->pdf->MultiCell($lastWidth, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);*/
+
+ /*$texDynamicCells .= $this->encodeText('');*/
+ $text[$count-1] = $this->encodeText('');
+ }
+
+ $brezHline = 1;
+ $brezNoveVrstice = 1;
+ $texDynamicCells .= $this->tableRow($text, $brezHline, $brezNoveVrstice);
+ //echo "texDynamicCells: ".$texDynamicCells."</br>";
+ return $texDynamicCells;
+ }
+
+ function getCellHeight($string='', $width=null){
+
+ // Star nacin
+ //$linecount = $this->pdf->getNumLines($this->encodeText($string), $width);
+ //$height = ( $linecount == 1 ? 4.7 : (4.7 + ($linecount-1)*3.5) );
+
+ $this->pdf->startTransaction();
+ // get the number of lines calling you method
+ $linecount = $this->pdf->MultiCell($width, 0, $string, 0, 'L', 0, 0, '', '', true, 0, false, true, 0);
+ // restore previous object
+ $this->pdf = $this->pdf->rollbackTransaction();
+
+ $height = ($linecount <= 1) ? 4.7 : $linecount * ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio()) + 2;
+
+ return $height;
+ }
+
+ static function HeatmapRegionPresence($spremenljivkaGrids=null, $spid=null, $_valid_answers=null){
+ $HeatmapRegionPresence = false;
+ foreach ($spremenljivkaGrids AS $gid => $grid){
+ $_variables_count = count($grid['variables']);
+ if ($_variables_count > 0){
+ # preštejemo max vrstic na grupo
+ $_max_i = 0;
+ //$numObmocij = 0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ $_max_i = max($_max_i,min($num_show_records,SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']));
+ //$numObmocij++;
+ }
+ $indeksZaObmocja = 0;
+ foreach ($grid['variables'] AS $vid => $variable ){
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($variable['other'] != true)
+ {
+ if (count($_valid_answers) > 0) {
+
+ foreach ($_valid_answers AS $answer) {
+ $_ans = $answer[$_sequence];
+ if ($_ans != null && $_ans != '' && $indeksZaObmocja >= count($_valid_answers))
+ {
+ $HeatmapRegionPresence = true;
+ }
+ $indeksZaObmocja++;
+ }
+ }
+ }
+
+ }
+ }
+ }
+ return $HeatmapRegionPresence;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Analize/AnalizaTTest.php b/admin/survey/export/latexclasses/Analize/AnalizaTTest.php
new file mode 100644
index 0000000..a0f832b
--- /dev/null
+++ b/admin/survey/export/latexclasses/Analize/AnalizaTTest.php
@@ -0,0 +1,413 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+
+/** Class za generacijo izvoza v Latex
+ *
+ * @desc: po novem je potrebno form elemente generirati ro�no kot slike
+ *
+ */
+class AnalizaTTest extends LatexAnalysisElement{
+
+ var $anketa;// = array(); // trenutna anketa
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+ var $db_table = '';
+
+ public $ttestClass = null; //ttest class
+
+ var $ttestVars;
+
+ var $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ protected $texNewLine = '\\\\ ';
+ protected $export_format;
+ protected $horizontalLineTex = "\\hline ";
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $podstran = 'ttest')
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa) )
+ {
+ $this->anketa['id'] = $anketa;
+ $this->anketa['podstran'] = $podstran;
+ // create new PDF document
+ //$this->pdf = new enka_TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']))
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName=null)
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+
+ function init()
+ {
+ global $lang;
+
+ // array used to define the language and charset of the pdf file to be generated
+ $language_meta = Array();
+ $language_meta['a_meta_charset'] = 'UTF-8';
+ $language_meta['a_meta_dir'] = 'ltr';
+ $language_meta['a_meta_language'] = 'sl';
+ $language_meta['w_page'] = $lang['page'];
+
+ //set some language-dependent strings
+ $this->pdf->setLanguageArray($language_meta);
+
+ //set margins
+ $this->pdf->setPrintHeaderFirstPage(true);
+ $this->pdf->setPrintFooterFirstPage(true);
+ $this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
+ $this->pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
+ $this->pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
+
+ // set header and footer fonts
+ $this->pdf->setHeaderFont(Array(FNT_HEADER_TEXT, "I", FNT_HEADER_SIZE));
+ $this->pdf->setFooterFont(Array(FNT_HEADER_TEXT, 'I', FNT_HEADER_SIZE));
+
+
+ // set document information
+ $this->pdf->SetAuthor('An Order Form');
+ $this->pdf->SetTitle('An Order');
+ $this->pdf->SetSubject('An Order');
+
+ // set default header data
+ $this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()));
+
+ //set auto page breaks
+ $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
+
+ $this->pdf->SetFont(FNT_MAIN_TEXT, '', FNT_MAIN_SIZE);
+ //set image scale factor
+ $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
+ return true;
+ }
+
+ public function displayTTestTable($ttest=null, $ttestClass=null, $export_format='', $sessionData=null) {
+ global $lang;
+ $tabela = '';
+
+ $this->ttestClass = $ttestClass;
+ $this->sessionData = $sessionData;
+
+ # preverimo ali imamo izbrano odvisno spremenljivko
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+
+ if (is_array($ttest) && count($ttest) > 0 && (int)$seq1 > 0) {
+
+ $spr_data_1 = $this->ttestClass->_HEADERS[$spid1];
+ if ($grid1 == 'undefined') {
+
+ # imamp lahko več variabel
+ $seq = $seq1;
+ foreach ($spr_data_1['grids'] as $gkey => $grid ) {
+
+ foreach ($grid['variables'] as $vkey => $variable) {
+ $sequence = $variable['sequence'];
+ if ($sequence == $seq) {
+ $sprLabel1 = '('.$variable['variable'].') '. $variable['naslov'];
+ }
+ }
+ }
+ } else {
+ # imamo subgrid
+ $sprLabel1 = '('.$spr_data_1['grids'][$grid1]['variable'].') '. $spr_data_1['grids'][$grid1]['naslov'];
+ }
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 10;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|');
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ //$parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tabela .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($export_format != 'xls'){
+ $tabela .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //zacetek latex tabele z obrobo za prvo tabelo - konec
+
+ # polovio labele
+ $spid2 = $this->sessionData['ttest']['spr2'];
+ $sprLabel2 = trim(str_replace('&nbsp;','',$this->sessionData['ttest']['label2']));
+ $label1 = $this->ttestClass->getVariableLabels($this->sessionData['ttest']['sub_conditions'][0]);
+ $label2 = $this->ttestClass->getVariableLabels($this->sessionData['ttest']['sub_conditions'][1]);
+
+ $this->ttestVars = array($sprLabel1, $sprLabel2);
+
+ if($export_format != 'xls'){
+ //$poravnava = "C";
+ $poravnava = "c";
+ }else{
+ $poravnava = "c";
+ }
+
+ $poravnava = "c";
+
+ $tabela .= " & \multicolumn{".$steviloOstalihStolpcev."}{".$poravnava."|}{".$this->returnBold($this->encodeText($sprLabel1))."} ".$this->texNewLine;
+ //$tabela .= ' & \multicolumn{'.$steviloOstalihStolpcev.'}{>{\hsize=\dimexpr '.($steviloOstalihStolpcev).'\hsize + '.($steviloOstalihStolpcev).'\tabcolsep + \arrayrulewidth}X|}{'.$this->returnBold($this->encodeText($sprLabel1)).'} '.$this->texNewLine;
+ // prva vrstica - konec
+
+ // druga vrstica
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{2-".$steviloStolpcevParameterTabular."} "; //horizontalna vrstica od 2 do zadnje celice
+ }
+ $druga = array();
+ $druga[] = $this->returnBold($this->encodeText($sprLabel2));
+ $druga[] = 'n';
+ $druga[] = 'x';
+ $druga[] = 's$^2$';
+ $druga[] = 'se(x)';
+ $druga[] = '$\pm$1,96$\times$se(x)';
+ $druga[] = 'd';
+ $druga[] = 'se(d)';
+ $druga[] = 'Sig.';
+ $druga[] = 't';
+
+ $brezHline = $this->getBrezHline($export_format);
+
+ $tabela .= $this->tableRow($druga, $brezHline)." ";
+ // druga vrstica - konec
+
+ // vrstici s podatki
+ $zadnjiStolpecDvojnihVrstic = 6;
+
+ //tretja vrstica
+ $tretja = array();
+ $tretja[] = $this->encodeText($label1); //1. stolpec
+ $tretja[] = $this->formatNumber($ttest[1]['n'], 0);
+ $tretja[] = $this->formatNumber($ttest[1]['x'], 3);
+ $tretja[] = $this->formatNumber($ttest[1]['s2'], 3);
+ $tretja[] = $this->formatNumber($ttest[1]['se'], 3);
+ $tretja[] = $this->formatNumber($ttest[1]['margin'], 3);
+ $tretja[] = '';
+ $tretja[] = '';
+ $tretja[] = '';
+ $tretja[] = '';
+ $tabela .= $this->tableRow($tretja, 1)." "; //izpisi tretjo vrstico brez horizontalne crte
+ //tretja vrstica - konec
+
+ //cetrta vrstica
+ $cetrta = array();
+ if($export_format != 'xls'){
+ $cetrta[] = '\cline{1-'.$zadnjiStolpecDvojnihVrstic.'} '.$this->encodeText($label2); //1. stolpec, //crta samo do dolocenega stolpca
+ }else{
+ $cetrta[] = $this->encodeText($label2); //1. stolpec, //crta samo do dolocenega stolpca
+ }
+ $cetrta[] = $this->formatNumber($ttest[2]['n'], 0);
+ $cetrta[] = $this->formatNumber($ttest[2]['x'], 3);
+ $cetrta[] = $this->formatNumber($ttest[2]['s2'], 3);
+ $cetrta[] = $this->formatNumber($ttest[2]['se'], 3);
+ $cetrta[] = $this->formatNumber($ttest[2]['margin'], 3);
+ $cetrta[] = $this->formatNumber($ttest['d'], 3);
+ $cetrta[] = $this->formatNumber($ttest['sed'], 3);
+ $cetrta[] = $this->formatNumber($ttest['sig'], 3);
+ $cetrta[] = $this->formatNumber($ttest['t'], 3);
+ $tabela .= $this->tableRow($cetrta, $brezHline)." ";
+ //cetrta vrstica - konec
+
+ // vrstici s podatki - konec
+
+ //zaljucek latex tabele z obrobo za prvo tabelo
+ $tabela .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele z obrobo za prvo tabelo - konec
+ }
+
+ return $tabela;
+ }
+
+ function displayChart($sessionData=null, $ttestClass=null, $anketa=null, $creport=false){
+ global $lang;
+
+ $this->sessionData = $sessionData;
+ $this->ttestClass = $ttestClass;
+ $this->anketa = $anketa;
+
+ $texImage = '';
+
+ $tableChart = new SurveyTableChart($this->anketa['id'], $this->ttestClass, 'ttest');
+ $tableChart->setTTestChartSession();
+
+ // updatamo session iz baze
+ $this->sessionData = SurveyUserSession::getData();
+
+ $spid1 = $this->sessionData['ttest']['variabla'][0]['spr'];
+ $seq1 = $this->sessionData['ttest']['variabla'][0]['seq'];
+ $grid1 = $this->sessionData['ttest']['variabla'][0]['grd'];
+ $sub1 = $this->sessionData['ttest']['sub_conditions'][0];
+ $sub2 = $this->sessionData['ttest']['sub_conditions'][1];
+ $chartID = $sub1.'_'.$sub2.'_'.$spid1.'_'.$seq1.'_'.$grid1;
+
+ $settings = $this->sessionData['ttest_charts'][$chartID];
+ $imgName = $settings['name'];
+
+ copy('pChart/Cache/'.$imgName,'pChart/Cache/'.$imgName.'.png');
+
+ if($creport==false){
+ // Naslov posameznega grafa
+ $title = $lang['srv_chart_ttest_title'].':'.$this->texNewLine;
+ $title .= $this->encodeText($this->ttestVars[0]);
+ $title .= $this->encodeText('/');
+ $title .= $this->encodeText($this->ttestVars[1]);
+ $boldedTitle = $this->returnBold($title).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+ }else{
+ $boldedTitle = '';
+ }
+ $texImageOnly = " \\includegraphics[scale=0.75]{".$imgName."} "; //latex za sliko
+
+ $texImage .= $this->returnCentered($boldedTitle.$texImageOnly); //vrni sredinsko poravnana naslov in slika
+
+ return $texImage;
+ }
+
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="...")
+ {
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function drawLine()
+ {
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+ function getCellHeight($string='', $width=null){
+
+ $this->pdf->startTransaction();
+ // get the number of lines calling you method
+ $linecount = $this->pdf->MultiCell($width, 0, $string, 0, 'L', 0, 0, '', '', true, 0, false, true, 0);
+ // restore previous object
+ $this->pdf = $this->pdf->rollbackTransaction();
+
+ $height = ($linecount <= 1) ? 4.7 : $linecount * ($this->pdf->getFontSize() * $this->pdf->getCellHeightRatio()) + 2;
+
+ return $height;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/BesediloLatex.php b/admin/survey/export/latexclasses/Vprasanja/BesediloLatex.php
new file mode 100644
index 0000000..0e68338
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/BesediloLatex.php
@@ -0,0 +1,475 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Besedilo
+ *
+ * Vprašanje je prisotno:
+ * tip 21 z vsemi orientacijami
+ *
+ * Autor: Patrik Pucer
+ * Datum: 07-08/2017
+ *****************************************/
+
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+
+class BesediloLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+ protected $texBigSkip = '\bigskip';
+ protected $export_subtype;
+ protected $path2SignatureImages;
+ protected $texGapBeforeTable = '\vspace*{-\baselineskip}';
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new BesediloLatex();
+ }
+
+ public function export($spremenljivke=null, $export_format='', $questionText=null, $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $anketa=null, $export_subtype='', $preveriSpremenljivko=null, $export_data_type=null, $loop_id=null){
+ global $site_path;
+ $this->path2HeatmapImages = $site_path.'main/survey/uploads/';
+
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+ $this->export_subtype=$export_subtype;
+
+ //preveri, ce je kaj v bazi
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+ global $site_url;
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+
+ $tex = '';
+ $podatekVBazi = 0;
+
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0); //poberi simbol checkbox za other in missing moznosti odgovora
+
+ //nastavitve text box-a iz baze##########################
+ $steviloOken = $spremenljivke['text_kosov'];
+ $postavitev = $spremenljivke['orientation'];
+
+ $polozajBesedila = $spremenljivke['text_orientation']; //polozaj besedila pred text box-om
+
+ $textboxHeightOrig = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1);
+ $textboxHeight = ($textboxHeightOrig*0.3).'cm';
+
+ $textboxWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ if($textboxWidth == -1){ //ce je vrednost -1, je default t.j. 30 oz. 0.30 sirine
+ $textboxWidth = 0.30;
+ }else{ //drugace, izracunaj sirino
+ $textboxWidth = $textboxWidth/100; //pretvorimo sirino v odstotke oz. decimalke
+ }
+ //$textboxWidth = $textboxWidth / $steviloOken; //ce je vec oken, se sirina text box-a ustrezno/proporcionalno zmanjsa
+ $textboxWidth = $textboxWidth / ($steviloOken*1.1); //ce je vec oken, se sirina text box-a ustrezno/proporcionalno zmanjsa
+ $textboxWidth = (string)$textboxWidth; //pretvorimo stevilo (decimalke) v string
+
+ /* echo "steviloOken: ".$steviloOken."</br>";
+ echo "visina iz nastavitev: ".$textboxHeightOrig."</br>";
+ echo "sirina iz nastavitev: ".$textboxWidth."</br>";
+ echo "sirina izracunana: ".$textboxWidth."</br>"; */
+ //textboxWidth se rocno povozi pod "ureditev parametrov za tabelo"
+
+ //nastavitve text box-a iz baze - konec####################
+
+ $array_others = array(); //polje za drugo, missing, ...
+ $besedila = array(); //polje, ki hrani besedila, ki pridejo poleg text box-ov
+ $besedila = [];
+ $textBoxes = array(); //polje, ki hrani latex za prazne text box-e
+ $textBoxes = [];
+ $textboxAllignment = 'c'; //poravnava textboxa z besedilom
+
+ $oznakaOdgovora = 'a';
+ $indeksZaWhile = 1;
+ $oznakaVprasanja = $this->UrediOznakoVprasanja($spremenljivke['id']); //uredi oznako vprasanja, ker ne sme biti stevilska
+
+ //ureditev parametrov za tabelo#############################
+ $parameterTabular = '';
+ if($steviloOken == 1){ //ce je samo en okvir za vnos besedila
+ if($polozajBesedila==0 || $polozajBesedila!=1){ //ce ni besedila ali besedilo ni SPREDAJ
+ $steviloStolpcevTabele = $steviloOken;
+ }elseif($polozajBesedila==1){ //ce je besedilo SPREDAJ
+ $steviloStolpcevTabele = $steviloOken*2;
+ }
+ }else{ //ce je vec okvirjev za vnos besedila, se ignorira nastavitev za besedilo SPREDAJ, saj se bo prineslo na ZGORAJ
+ if($polozajBesedila==1){
+ $polozajBesedila=3;
+ }
+ $steviloStolpcevTabele = $steviloOken;
+ }
+
+ for($i = 0; $i < $steviloStolpcevTabele; $i++){
+ if($polozajBesedila==1 && $i%2==0){ //ce je polozaj besedila SPREDAJ in je stolpec za besedilo
+ if($userDataPresent){
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l'); //desna poravnava stolpca
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'R' : 'l'); //desna poravnava stolpca
+ }
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca
+ }
+ }
+ //echo "stevilo oken: ".$steviloOken."</br>";
+ //echo "parametri tabele: ".$parameterTabular."</br>";
+
+ //$textboxWidth = 30 / $steviloStolpcevTabele / 100; //povozil $textboxWidth tako, da zadeva je v skladu s prejsnjimi izvozi
+ //echo "sirina 2: ".$textboxWidth."</br>";
+
+ //ureditev parametrov za tabelo - konec######################
+ //if(0){
+ //if($steviloOken == 1 && $polozajBesedila == 0){ //ce imamo samo en kos besedila brez pripisanega texta
+ //ureditev polja s podatki trenutnega uporabnika ######################################################
+ $rowVrednost = mysqli_fetch_array($sqlVrednosti);
+
+ if($spremenljivke['tip'] == 21){ //ce je ta novo besedilo, ki je v uporabi
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' ";
+ if($loop_id){ //ce je prisoten se loop_id, je tega potrebno dodati sql stavku
+ $sqlUserAnswerString .= " AND loop_id=$loop_id";
+ }
+ //echo $sqlUserAnswerString."</br>";
+ }elseif($spremenljivke['tip'] == 4){ //ce je ta staro besedilo, ki ni vec v uporabi vsaj 9 let (2020)
+ //$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ");
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ";
+ if($loop_id){ //ce je prisoten se loop_id, je tega potrebno dodati sql stavku
+ $sqlUserAnswerString .= " AND loop_id=$loop_id";
+ }
+ }
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer: ".$userAnswer['text']."</br>";
+ //ureditev polja s podatki trenutnega uporabnika - konec ##############################################
+
+ if($userAnswer){ //ce je kaj v bazi oz. se izpisujejo odgovori respondenta
+ $podatekVBazi = 1;
+ //print_r($spremenljivke);
+
+ // imamo upload vprašanje
+ if ($spremenljivke['upload']){
+ //echo "Je upload za ".$spremenljivke['id']."</br>";
+ # imena datotek
+ if($userAnswer['text'] != ''){
+ $textUpload = (''.$site_url.'main/survey/download.php?anketa='.$anketa.'&code='.$userAnswer['text'].' ');
+ }else{
+ $tex .= '';
+ }
+ }
+ // imamo signature vprašanje
+ elseif($spremenljivke['signature'] == 1){
+ $imageName = $usr_id.'_'.$spremenljivke['id'].'_'.$anketa.'.png'; //ime slike
+ $image = PIC_SIZE."{".$this->path2HeatmapImages."".$imageName."}"; //priprave slike predefinirane dimenzije
+ $tex .= $image."".$texNewLine; //izris slike
+
+ //$tex .= $lang['srv_signature_name'].' '.$userAnswer['text'].$texNewLine;
+ $textSignature = $lang['srv_signature_name'].' '.$userAnswer['text'];
+ }
+ else{
+ //$tex .= $userAnswer['text'];
+ //$textboxHeight = 0;
+ }
+
+ if($export_data_type==2){ //ce je izpis skrcen in je prazen vprasalnik
+ $okvir = 0;
+ $izpisanoBesediloPoStarem = 0;
+ }elseif($export_data_type==1){ //ce je izpis razsirjen
+ $okvir = 1; //rabimo okvir
+ //$okvir = 0; //ne rabimo okvir
+ }
+ }else{ //ce je prazen vprasalnik
+ $okvir = 1; //rabimo okvir
+ }
+
+ //}else{
+
+ /* echo "postavitev besedila: ".$postavitev." ".$spremenljivke['id']."</br>";
+ echo "položaj besedila: ".$polozajBesedila."</br>"; */
+ if($okvir == 1){
+
+
+
+ if(($postavitev!=0)){ //ce ni vodoravno ob vprasanju, uporabi za izpis tabelo
+ if($steviloOken>1){ //ce je stevilo oken vec kot 1, zacni novo tabelo
+ //Ureditev dodajanja manjsega razmika med besedilom vprasanja in tabelo
+ $tex .= $this->texGapBeforeTable;
+ //Ureditev dodajanja manjsega razmika med besedilom vprasanja in tabelo - konec
+ #ZACETEK TABELE
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+ }
+
+ //echo "ni vodoravno ob vprašanju </br>";
+ //}elseif($postavitev==0&&($polozajBesedila!=0&&$polozajBesedila!=1)){ //ce je vodoravno ob vprasanju in ni dodatnega besedila ali ni besedila pred okvirjem, uporabi za izpis tabelo
+ }elseif($postavitev==0&&$polozajBesedila==3){ //
+ #ZACETEK TABELE
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+ //echo "je vodoravno ob vprašanju zgoraj</br>";
+ }elseif($postavitev==0&&$polozajBesedila==2){
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+ //echo "je vodoravno ob vprašanju spodaj</br>";
+ }elseif($postavitev==0&&$steviloOken>1){
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+ //echo "stevilo oken večje in ob vprašanju </br>";
+ }
+ }
+ //echo "tex koda: ".$tex."</br>";
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ # po potrebi se prevede besedilo, ki se pojavi pred textbox-om
+ $naslov = $this->srv_language_vrednost($rowVrednost['id']);
+ if ($naslov != '') {
+ $rowVrednost['naslov'] = $naslov;
+ }
+
+
+ //ureditev polja s podatki trenutnega uporabnika ######################################################
+ if($spremenljivke['tip'] == 21){ //ce je ta novo besedilo, ki je v uporabi
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' ";
+ if($loop_id){ //ce je prisoten se loop_id, je tega potrebno dodati sql stavku
+ $sqlUserAnswerString .= " AND loop_id=$loop_id";
+ }
+ //echo "userAnswer: ".$userAnswer['text']."</br>";
+ }elseif($spremenljivke['tip'] == 4){ //ce je ta staro besedilo, ki ni vec v uporabi vsaj 9 let (2020)
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ";
+ if($loop_id){ //ce je prisoten se loop_id, je tega potrebno dodati sql stavku
+ $sqlUserAnswerString .= " AND loop_id=$loop_id";
+ }
+ }
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //ureditev polja s podatki trenutnega uporabnika - konec ##############################################
+
+ //priprava besedila za izpis
+ $stringNaslov = $rowVrednost['naslov'];
+ $stringNaslov = Common::getInstance()->dataPiping($stringNaslov, $usr_id, $loop_id);
+ //priprava besedila za izpis - konec
+
+ //ce ni other ali missing
+ if( (int)$rowVrednost['other'] == 0 ){
+
+
+ //ureditev besedila odgovora respondenta v doloceno barvo
+ if($export_format=='pdf'){
+ $besedilo = '\\textcolor{crta}{';
+ }else{
+ $besedilo = '';
+ }
+ if($spremenljivke['signature'] == 1){
+ $besedilo .= $textSignature;
+ //}elseif($spremenljivke['upload'] == 1){
+ }elseif($spremenljivke['upload']){
+ //$besedilo .= $textUpload;
+ $besedilo .= $this->encodeText($textUpload);
+ }else{
+ //$besedilo .= $userAnswer['text'];
+ $besedilo .= $this->encodeText($userAnswer['text']);
+ }
+
+ if($export_format=='pdf'){
+ $besedilo .= '}';
+ }
+ //ureditev besedila odgovora respondenta v doloceno barvo - konec
+
+ //priprava latex kode za text box dolocene sirine in visine glede na export format z ustreznim besedilom odgovora
+
+ if($okvir == 1){ //ce rabimo okvir, izpisi
+ if($podatekVBazi && $export_format == 'pdf'){ //ce je podatek v bazi in je pdf oz. se izpisuje odgovore respondenta
+ $dataTextBox = $besedilo; //izpis besedila brez okvirja
+ }else{
+ //echo "Pos: ".$postavitev."</br>";
+ if(($postavitev!=0)){ //ce ni vodoravno ob vprasanju
+ $tex .= ' \\\\ '; //skoci v novo vrstico
+ }
+ $dataTextBox = $this->LatexTextBox($export_format, $textboxHeight, $textboxWidth, $besedilo, $textboxAllignment, 0); //izpisi okvir
+ }
+ }else{
+ $dataTextBox = $besedilo; //izpis besedila brez okvirja
+ }
+
+ array_push($textBoxes, $dataTextBox); //filanje polja s praznimi text box-i
+ array_push($besedila, $this->encodeText($stringNaslov)); //filanje polja z besedili
+
+ if($okvir == 0){
+ if($spremenljivke['tip'] == 21){ //ce je ta novo besedilo, ki je v uporabi
+ if($indeksZaWhile!=1){
+ $tex .= ' \\\\ '; //skoci v novo vrstico
+ }
+
+ //izpis besedila
+ if($polozajBesedila!=0){ //ce je prisotno dodatno besedilo ob okvirju
+ $tex .= $this->encodeText($stringNaslov)." ";
+ }
+ $tex .= ' '.$dataTextBox;
+ }elseif($spremenljivke['tip'] == 4){ //ce je ta staro besedilo, ki ni vec v uporabi vsaj 9 let (2020)
+ if($izpisanoBesediloPoStarem == 0){
+ $tex .= $dataTextBox;
+ $izpisanoBesediloPoStarem = 1;
+ }
+ }
+
+ }elseif($okvir == 1){
+ //if($polozajBesedila==1){ //ce je polozaj besedila SPREDAJ
+ if($polozajBesedila==1 && $steviloOken==1){ //ce je polozaj besedila SPREDAJ in je samo 1 okvir za vnos besedila
+ if($indeksZaWhile!=1){
+ $tex .= ' '; //skoci v nov stolpec
+ }
+
+ //izpis besedila
+ $tex .= $this->encodeText($stringNaslov)." ";
+
+ //izpis text box-a dolocene sirine in visine z besedilom odgovora
+ $tex .= ' '.$dataTextBox;
+
+ }
+ }
+ }
+ else { //drugace, ce imamo missinge ali podobne, jih zabelezi v polju
+ // imamo polje drugo - ne vem, zavrnil...
+ /* $array_others[$rowVrednost['id']] = array(
+ 'naslov'=>$rowVrednost['naslov'],
+ 'vrstni_red'=>$rowVrednost['vrstni_red'],
+ 'value'=>$text[$rowVrednost['vrstni_red']],
+ ); */
+ $array_others[$rowVrednost['id']] = array(
+ 'naslov'=>$this->encodeText($stringNaslov),
+ 'vrstni_red'=>$rowVrednost['vrstni_red'],
+ 'value'=>$text[$rowVrednost['vrstni_red']],
+ );
+
+ }
+ $oznakaOdgovora++;
+ $indeksZaWhile++;
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec
+
+ if($okvir == 1){
+ //ureditev polozaja besedila poleg text box-a ZGORAJ
+ if($polozajBesedila!=0 && $polozajBesedila==3){ //ce je prisotno besedilo in ni pod text box-om
+ $tex .= $this->izrisVrsticePoStolpcih($steviloStolpcevTabele, $besedila);
+ $tex .= $texNewLine; //dodaj po izpisu besedil še skok v novo vrstico
+ }
+ //ureditev polozaja besedila poleg text box-a ZGORAJ - konec
+
+ if($polozajBesedila!=1){ //ce ni polozaj besedila SPREDAJ
+ //izpis praznih text box-ov dolocene sirine in visine
+ $tex .= $this->izrisVrsticePoStolpcih($steviloStolpcevTabele, $textBoxes);
+ //izpis praznih text box-ov dolocene sirine in visine - konec
+ }
+
+ //ureditev polozaja besedila poleg text box-a SPODAJ
+ if($polozajBesedila!=0 && $polozajBesedila==2){ //ce je prisotno besedilo in ni pod text box-om
+ $tex .= $texNewLine; //dodaj po izpisu besedil še skok v novo vrstico
+ $tex .= $this->izrisVrsticePoStolpcih($steviloStolpcevTabele, $besedila);
+ }
+ //ureditev polozaja besedila poleg text box-a SPODAJ
+ }
+
+
+ if($okvir == 1){
+ if($postavitev!=0){
+ if($steviloOken>1){ //ce je stevilo oken vec kot 1, zakljuci tabelo
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ #KONEC TABELE
+ }
+ }elseif($postavitev==0&&$polozajBesedila==3){
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ #KONEC TABELE
+ }elseif($postavitev==0&&$polozajBesedila==2){
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ #KONEC TABELE
+ }elseif($postavitev==0&&$steviloOken>1){
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ #KONEC TABELE
+ }
+ }
+ //}
+
+ //$tex .= ' \vspace{0.3cm} ';
+
+ // Izris polj drugo - ne vem...
+ if (count($array_others) > 0) {
+ $tex .= $texNewLine;
+ foreach ($array_others AS $oKey => $other) {
+ $tex .= $symbol.' '.$other['naslov'].' ';
+ if($postavitev!=0){
+ $tex .= $texNewLine;
+ }
+ }
+ }
+
+
+ if(($postavitev==0)){ //ce je vodoravno ob vprasanju
+ $tex .= ' \par } '; //zakljuci odstavek
+ }
+
+ //echo "izpisani podatek: ".$podatekVBazi."</br>";
+ //if($podatekVBazi==1&&$export_data_type==2){ //ce je podatek v bazi in je izpis skrcen
+ if($podatekVBazi==1){ //ce je podatek v bazi
+ if($export_data_type==2 || $steviloOken == 1){ //ce je izpis skrcen ali je stevilo oken 1
+ $tex .= " \ "; //da ni tezave z "there is no line here to end"
+ $tex .= $texNewLine;
+ $tex .= $texNewLine;
+ }
+ }else{
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip." \ ";
+ $tex .= $texNewLine." ";
+ }
+
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ //echo "tex koda: ".$tex." in indeks $indeksZaWhile</br>";
+ }else{ //ce je rtf
+
+ }
+
+ }
+ //echo "tex koda: ".$tex." in indeks $indeksZaWhile</br>";
+ return $tex;
+ }
+
+ #funkcija, ki skrbi za izris vrstice tabele po stolpcih
+ function izrisVrsticePoStolpcih($steviloStolpcevTabele=null, $array=[]){
+ $tex = '';
+ for($i=0;$i<$steviloStolpcevTabele;$i++){
+ if($i!=0){ //ce ni prvi stolpec
+ $tex .= ' & '; //dodaj oznako za prehod v nov stolpec
+ //$tex .= ' \\\\ '; //dodaj oznako za prehod v novo vrstico
+ }
+ $tex .= $array[$i];
+ }
+ return $tex;
+ }
+
+
+ #funkcija, ki skrbi za izris - konec
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/DatumLatex.php b/admin/survey/export/latexclasses/Vprasanja/DatumLatex.php
new file mode 100644
index 0000000..7110873
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/DatumLatex.php
@@ -0,0 +1,140 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za datum
+ *
+ * Vprašanje je prisotno:
+ * tip 8
+ *
+ * Autor: Patrik Pucer
+ * Datum: 08/2017
+ *****************************************/
+
+
+class DatumLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+ protected $texBigSkip = '\bigskip ';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DatumLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype='', $preveriSpremenljivko=null, $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //preveri, ce je kaj v bazi
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+
+ $array_others = array(); //polje za drugo, missing, ...
+
+ $tex = '';
+ $textboxWidth = '0.15'; //sirina okvirja z odgovorom
+ $textboxHeight = '0.3cm'; //visina okvirja z odgovorom
+ $noBorders = 0;
+
+ //priprava latex kode za text box dolocene sirine in visine glede na export format brez besedila
+ $textboxAllignment = 'c';
+ //ureditev polja s podatki trenutnega uporabnika ######################################################
+ $rowVrednost = mysqli_fetch_array($sqlVrednosti);
+ //$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
+ //$sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' ";
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ";
+ //echo $sqlUserAnswerString;
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer: ".$userAnswer['text']."</br>";
+ //ureditev polja s podatki trenutnega uporabnika - konec ##############################################
+
+ //ureditev besedila odgovora respondenta v doloceno barvo
+ $besedilo = '\\textcolor{crta}{';
+ $besedilo .= $userAnswer['text'];
+ $besedilo .= '}';
+ //ureditev besedila odgovora respondenta v doloceno barvo - konec
+
+ if($userAnswer['text']==''){ //ce ni izpisa odgovorov respondentov, priprava izpis s tabelo
+ $answerTextBox = $this->LatexTextBox($export_format, $textboxHeight, $textboxWidth, $besedilo, $textboxAllignment, $noBorders);
+
+ //parametri tabele
+ //$parameterTabular = 'l';
+ if($export_format == 'pdf'){ //ce je pdf
+ $parameterTabular = 'X';
+ }else{ //ce je rtf
+ $parameterTabular = 'l';
+ }
+
+ //IZRIS
+ #ZACETEK TABELE
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ $tex .= $answerTextBox; //izris znotraj tabele
+
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ #KONEC TABELE
+ $tex .= $this->texBigSkip;
+ }else{ //ce je izpis odgovorov respondentov
+ $tex .= $this->texNewLine;
+ $tex .= $besedilo;
+ //$tex .= " \ "; //da ni tezave z "there is no line here to end"
+ $tex .= $texNewLine;
+ $tex .= $texNewLine;
+ }
+
+ //priprava missing-ov
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ if((int)$rowVrednost['other']!=0){ //ce so missing ali drugo
+ $array_others[$rowVrednost['id']] = array(
+ 'naslov'=>$rowVrednost['naslov'],
+ 'vrstni_red'=>$rowVrednost['vrstni_red'],
+ 'value'=>$text[$rowVrednost['vrstni_red']],
+ );
+ }
+ }
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0); //poberi simbol checkbox za other in missing moznosti odgovora
+ //priprava missing-ov - konec
+
+ // Izris polj drugo - ne vem...
+ if (count($array_others) > 0) {
+ $tex .= ' \vspace{0.3cm} '; //prostor med okvirjem in missing
+ $tex .= $texNewLine;
+ foreach ($array_others AS $oKey => $other) {
+ $tex .= $symbol.' '.$other['naslov'].' ';
+ $tex .= $texNewLine;
+ }
+ $tex .= $texNewLine;
+ }
+
+ //IZRIS - KONEC
+
+ return $tex;
+ }
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/GridMultipleLatex.php b/admin/survey/export/latexclasses/Vprasanja/GridMultipleLatex.php
new file mode 100644
index 0000000..3b67102
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/GridMultipleLatex.php
@@ -0,0 +1,559 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za kombinirana tabela oz. GridMultiple
+ *
+ * Vprašanje je prisotno:
+ * tip 24
+ *
+ * Autor: Patrik Pucer
+ * Datum: 09/2017
+ *****************************************/
+
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+define("RADIO_BTN_SIZE", 0.13);
+
+class GridMultipleLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $texBigSkip = '\bigskip ';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new GridMultipleLatex();
+ }
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype='', $preveriSpremenljivko=null, $export_data_type='', $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+ //echo "<b>tip izpisa: $export_data_type</b> </br>"; //$export_data_type: 1 - Razsirjen, 2 - Skrcen
+ $presirokaTabela = 0;
+ //preveri, ce je kaj v bazi
+ $questionText=0;
+ $userDataPresent=0;
+ $izpisOdgovorov = 0;
+ if($usr_id){ //ce je prisotne id uporabnika, je izpis odgovorov in je potrebno narediti naslednje stvari
+ //$userAnswer = $this->GetUsersDataKombinirana($spremenljivke, $db_table, $usr_id, $questionText, $this->loop_id, $export_data_type);
+ $userAnswer = $this->GetUsersDataKombinirana($spremenljivke, $db_table, $usr_id, $presirokaTabela, $this->loop_id, $export_data_type);
+ foreach($userAnswer as $value){
+ if($value!=''){
+ $userDataPresent=1;
+ }
+ //echo "Value: ".$value."</br>";
+ }
+ $izpisOdgovorov = 1;
+ }
+ //echo "Usr_id: ".$usr_id.'</br>';
+ //echo "Stevilo odgovorov: ".count($userAnswer).'</br>';
+
+
+ if($userDataPresent!=0||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ //echo "SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red"."</br>";
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti); //za filanje navpicnih odgovorov
+ //echo "SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red";
+ //novo za kombinirano tabelo
+ $sqlStVrednosti = sisplet_query("SELECT count(*) FROM srv_grid g, srv_grid_multiple m WHERE m.spr_id=g.spr_id AND m.parent='".$spremenljivke['id']."'");
+ $rowStVrednost = mysqli_fetch_array($sqlStVrednosti); //stevilo stolpcev
+ $numColSql = $rowStVrednost['count(*)'] + 1; //stevilo vseh stolpcev upostevajoc prvega z navpicnimi odgovori
+
+ $sqlMultipleSprId = sisplet_query("SELECT spr_id FROM srv_grid_multiple WHERE parent='".$spremenljivke['id']."' ORDER BY vrstni_red"); //poizvedba spr_id dodanih moznosti v kombinirani tabeli
+ $multipleSprId = array(); //polje za shranjevanje spr_id dodanih moznosti v kombinirano tabelo
+ while ($rowMultipleSprId = mysqli_fetch_array($sqlMultipleSprId)) {
+ $multipleSprId[] = $rowMultipleSprId['spr_id'];
+ }
+
+ //poizvedba vseh potrebnih podatkov dodanih moznosti v kombinirani tabeli
+ $sqlMultiple = sisplet_query("SELECT g.*, s.tip, s.enota, s.dostop FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id=m.spr_id AND m.spr_id IN (".implode($multipleSprId, ',').") ORDER BY m.vrstni_red, g.vrstni_red");
+ //echo "SELECT g.*, s.tip, s.enota, s.dostop FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id=m.spr_id AND m.spr_id IN (".implode($multipleSprId, ',').") ORDER BY m.vrstni_red, g.vrstni_red";
+ //poizvedba podnaslovov v kombinirani tabeli
+ $sqlMultiplePodNaslovi = sisplet_query("SELECT naslov FROM srv_spremenljivka WHERE id IN (".implode($multipleSprId, ',').")");
+ //novo za kombinirano tabelo - konec
+
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ $isCheckBox = 0;
+ $enota = $spremenljivke['enota'];
+ $enotaNiNula = $enotaNiNulaTmp = 0;
+ $trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0);
+ $customColumnLabelOption = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1); //1 - "vse" labele, 2 - "le koncne" labele, 3 - "koncne in vmesna" labele
+
+ $tex = '';
+ $navpicniOdgovori = array(); //shranjuje odgovore po vrsticah
+ $vodoravniOdgovori = array(); //shranjuje odgovore po stolpcih
+ $vodoravniOdgovoriVsi = array();
+ $vodoravniOdgovoriTip = array();
+ $vodoravniOdgovoriSprId = array();
+ $vodoravniOdgovoriEnota = array();
+ $podNaslovi = array();
+ $missingOdgovori = array();
+
+ $texNewLineAfterTable = $texNewLine." ".$texNewLine." ".$texNewLine;
+
+ $oznakaVprasanja = $this->UrediOznakoVprasanja($spremenljivke['id']); //uredi oznako vprasanja, ker ne sme biti stevilska
+
+
+ //ce je prisoten id uporabnika - ureditev belezenja vnesenega odgovora pod Drugo:
+ if($usr_id){
+ $multipleVredIdDrugo = array(); //polje za shranjevanje vre_id, kjer je prisotna moznost Drugo:
+ //poizvedba vrednosti polj, kjer se pojavijo polja Drugo:
+ $sqlMultipleVredIdZaDrugo = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id IN (".implode($multipleSprId, ',').") AND other = 1");
+ while ($rowsqlMultipleVredIdZaDrugo = mysqli_fetch_array($sqlMultipleVredIdZaDrugo)) {
+ $multipleVredIdDrugo[] = $rowsqlMultipleVredIdZaDrugo['id'];
+ }
+
+ if(!empty($multipleVredIdDrugo)){
+ $multipleBesediloDrugo = array(); //polje za shranjevanje vnesenega besedila iz strani respondenta, kjer je prisotna moznost Drugo:
+ $sqlStavekMultipleBesediloDrugo = "SELECT text FROM srv_data_text_active WHERE vre_id IN (".implode($multipleVredIdDrugo, ',').") AND usr_id=".$usr_id." ";
+ $sqlMultipleBesediloDrugo = sisplet_query($sqlStavekMultipleBesediloDrugo);
+ while ($rowsqlMultipleBesediloDrugo = mysqli_fetch_array($sqlMultipleBesediloDrugo)) {
+ $multipleBesediloDrugo[] = $rowsqlMultipleBesediloDrugo['text'];
+ }
+ }
+
+ $indeksBesediloDrugo = 0; //definiranje indeksa za izpis vnesenega besedila v Drugo:
+ }
+ //ce je prisoten id uporabnika - ureditev belezenja vnesenega odgovora pod Drugo: - konec
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - navpicni odgovori
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $stringTitleRow = ((( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
+ # po potrebi prevedemo naslov
+ $naslov = $this->srv_language_vrednost($rowVrednost['id']);
+ if ($naslov != '') {
+ //$rowVrednost['naslov'] = $naslov;
+ $stringTitleRow = $naslov;
+ }
+
+ $besediloDrugo = '';
+
+ //ce je drugo vnesen kot odgovor in je prisoten id uporabnika
+ if($rowVrednost['other'] && $usr_id){
+ //zabelezi besedilo, ki je trenuten uporabnik za trenuten odgovor zapisal pod Drugo:
+ $besediloDrugo = $multipleBesediloDrugo[$indeksBesediloDrugo];
+ $this->encodeText($besediloDrugo);
+ $besediloDrugo = ' \\textcolor{crta}{\footnotesize{'.$besediloDrugo.'}} ';
+ $indeksBesediloDrugo++; //povecaj indeks za izpis vnesenega besedila v Drugo:
+ }
+ //ce je drugo vnesen kot odgovor in je prisoten id uporabnika - konec
+
+ array_push($navpicniOdgovori, $this->encodeText($stringTitleRow)." ".$besediloDrugo); //filanje polja z navpicnimi odgovori (po vrsticah)
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - navpicni odgovori - konec
+
+
+ $sqlStolpciVrednosti = sisplet_query("SELECT g.spr_id, g.naslov, g.variable FROM srv_grid g, srv_grid_multiple m WHERE m.parent='".$spremenljivke['id']."' AND g.spr_id=m.spr_id");
+
+ $steviloSkupinRoletSeznamov = 0; //belezi stevilo enot z roletami ali seznamov (pomembno za pravilen izris, za presiroko tabelo)
+ $steviloOdgovorovRoletSeznamov = 0; //belezi stevilo posameznih odgovorov, ki sestavljajo razlicne rolete ali sezname
+ $sprIdRoletSeznamov = 0;
+ $sprIdRoletSeznamovTmp = 0;
+
+ //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti - vodoravni odgovori
+ while ($colVrednost = mysqli_fetch_assoc($sqlStolpciVrednosti)){
+
+ #staro, izpis naslovov stolpcev tabele z isto velikostjo pisave, kot vse ostalo
+ /* $stringTitleCol = $colVrednost['naslov'];
+ array_push($vodoravniOdgovori, $this->encodeText($stringTitleCol, 0, 1) ); //filanje polja z vodoravnimi odgovori (po stolpcih) */
+ #staro - konec
+
+ $stringTitleCol = $this->encodeText($colVrednost['naslov'], 0, 1);
+ $stringTitleCol = '\footnotesize{'.$stringTitleCol.'}'; //zmanjsanje pisave za naslove stolpcev tabele
+ array_push($vodoravniOdgovori, $stringTitleCol); //filanje polja z vodoravnimi odgovori (po stolpcih)
+
+ $rowMultiple = mysqli_fetch_array($sqlMultiple);
+ array_push($vodoravniOdgovoriTip, $rowMultiple['tip']); //filanje polja s tipi spremenljivk
+ array_push($vodoravniOdgovoriSprId, $rowMultiple['spr_id']); //filanje polja z id spremenljivk
+ array_push($vodoravniOdgovoriEnota, $rowMultiple['enota']); //filanje polja z enoto spremenljivk
+
+ //$sprIdRoletSeznamov = $rowMultiple['spr_id'];
+ if(($rowMultiple['enota'] == 2 || $rowMultiple['enota'] == 6)){
+ $sprIdRoletSeznamov = $rowMultiple['spr_id'];
+ }
+
+ /* echo "enota ".$rowMultiple['enota']."</br>";
+ echo "spr ".$rowMultiple['spr_id']."</br>"; */
+ //if(($rowMultiple['enota'] == 2 || $rowMultiple['enota'] == 6)){ //ce je roleta ali seznam IN je izpis odgovorov
+ //if(($rowMultiple['enota'] == 2 || $rowMultiple['enota'] == 6)&&$izpisOdgovorov){ //ce je roleta ali seznam IN je izpis odgovorov
+ if((($rowMultiple['enota'] == 2 || $rowMultiple['enota'] == 6)&&$izpisOdgovorov) || ($izpisOdgovorov&&$rowMultiple['tip']==6&&$export_data_type==2)){ //(ce je roleta ALI seznam IN je izpis odgovorov) ALI (je izpis odgovorov IN je radio button)
+ if($sprIdRoletSeznamovTmp != $sprIdRoletSeznamov){
+ $steviloSkupinRoletSeznamov++;
+ }
+ $steviloOdgovorovRoletSeznamov++;
+ //echo "spr: $sprIdRoletSeznamov </br>";
+ }
+
+ $sprIdRoletSeznamovTmp = $sprIdRoletSeznamov;
+ }
+ //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti - vodoravni odgovori - konec
+
+
+ $vodoravniOdgovoriVsi = $vodoravniOdgovori;
+ /* echo "stevilo skupin rolet/seznamov ".($steviloSkupinRoletSeznamov)." </br>";
+ echo "stevilo odgovorov v roletah ali seznamu ".($steviloOdgovorovRoletSeznamov)." </br>"; */
+
+/* echo "vodoravniOdgovoriSprId: ";
+ print_r($vodoravniOdgovoriSprId);
+ echo "</br>";
+ echo "Enote: ";
+ print_r($vodoravniOdgovoriEnota);
+ echo "</br>"; */
+
+ //ureditev polja z nadnaslovi kombinirane tabele
+ while ($rowMultiplePodNaslovi = mysqli_fetch_array($sqlMultiplePodNaslovi)){
+ array_push($podNaslovi, $this->encodeText($rowMultiplePodNaslovi['naslov']));
+ }
+ //ureditev polja z nadnaslovi kombinirane tabele - konec
+
+ //za ureditev presirokih tabele
+ //$steviloPodstolpcev = $numColSql;
+ $steviloPodatkovZaIzpis = $numColSql-1;
+ $steviloPodstolpcev = $numColSql - $steviloOdgovorovRoletSeznamov + $steviloSkupinRoletSeznamov;
+ $mejaZaVelikeTabele = 7;
+ $velikostTabele = $steviloPodstolpcev-1;
+ //echo "<b>velikost tabele: </b>".($velikostTabele)." </br>";
+ if($velikostTabele > $mejaZaVelikeTabele){ //ce imamo veliko tabelo, jo je potrebno razbiti na vec tabel, ker drugace je presiroka
+ //echo "tabela je prevelika, ima ".($velikostTabele)." stolpcev</br>";
+
+ $presirokaTabela = 1;
+ $steviloTabelCelih = intval($velikostTabele / $mejaZaVelikeTabele);
+ $steviloTabelMod = $velikostTabele % $mejaZaVelikeTabele;
+ $delnaTabela = 0;
+ if($steviloTabelMod != 0){
+ $delnaTabela = 1;
+ }
+ $steviloTabel = $steviloTabelCelih + $delnaTabela;
+
+ //echo "stevilo podtabel celih ".($steviloTabelCelih)." </br>";
+ //echo "stevilo podtabel mod ".($steviloTabelMod)." </br>";
+ //echo "stevilo podtabel za izpis: ".($steviloTabel)." </br>";
+ //echo "stevilo podatkov za izpis: ".($steviloPodatkovZaIzpis)." </br>";
+
+ }else{
+ $presirokaTabela = 0;
+ }
+ //za ureditev presirokih tabele - konec
+
+
+ if($presirokaTabela == 0){ //ce tabela ni presiroka #################################################
+
+
+ //ureditev parametrov za tabelo, pridobitev stevila stolpcev za vsak tip dodanega vprasanja (podstolpec), priprava polj in spremenljivk, ce enota je razlicna od nula oz. izris ni klasicna tabela########
+ $parameterTabular = '';
+ $parameterTabular .= ($export_format == 'pdf' ? 'A' : 'l'); //leva poravnava stolpca fiksne sirine ZA PRVI STOLPEC (parameteri tabele)
+ $indeksParameterTabular=1;
+
+ $indeksPodStolpci=0;
+ $steviloPodStolpcev = array();
+
+ //za preureditev polj, ko imamo seznam ali roleto
+ $indeksVodoravniOdgovori = 0;
+ $vodoravniOdgovoriPrva = $vodoravniOdgovori; //hrani preurejene vodoravne odgovore za prvo vrstico
+ $splice=0;
+ $toDelete = array(); //polje, ki hrani, katere dele polja je potrebno odstraniti, ce imamo seznam ali roleto
+ //za preureditev polj, ko imamo seznam ali roleto - konec
+
+ $valueTmp = null;
+
+ foreach($vodoravniOdgovoriSprId as $value){ //parametri tabele ZA OSTALE STOLPCE+pridobitev stevila stolpcev+priprava polj in spremenljivk ###############
+ //echo $vodoravniOdgovoriEnota[$indeksParameterTabular-1]."</br>";
+ //echo "value: ".$value."</br>";
+ //echo "valueTmp: ".$valueTmp."</br>";
+ //echo "indeksParameterTabular: ".$indeksParameterTabular."</br>";
+ //echo "Stevilo vodoravniOdgovoriSprId: ".count($vodoravniOdgovoriSprId)."</br>";
+
+ if($izpisOdgovorov == 0 || ($izpisOdgovorov == 1 && $vodoravniOdgovoriEnota[$indeksParameterTabular-1]==0 && $export_data_type == 1) || ($izpisOdgovorov == 1 && $vodoravniOdgovoriEnota[$indeksParameterTabular-1]==0 && $vodoravniOdgovoriTip[$indeksParameterTabular-1]!=6 && $export_data_type == 2)){ //ce je prazen vprasalnik ALI (je izpis odgovorov IN ni roleta/seznam IN je Razsirjen izvoz) ALI (je izpis odgovorov IN ni roleta/seznam IN ni radio button IN je skrcen izvoz)
+ if($indeksParameterTabular==1){ //ce je prvi podstolpec
+ $parameterTabular .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava stolpca
+
+ $steviloPodStolpcev[$indeksPodStolpci] = 0;
+ $steviloPodStolpcev[$indeksPodStolpci]++;
+ }else{ //ce so ostali podstolpci
+ //if($value!=$valueTmp&&$indeksParameterTabular!=count($vodoravniOdgovoriSprId)){
+ if($value!=$valueTmp){
+ $parameterTabular .= ($export_format == 'pdf' ? '|C' : '|c'); //sredinska poravnava stolpca z locilom
+ //echo "Sprememba </br>";
+ $indeksPodStolpci++;
+ $steviloPodStolpcev[$indeksPodStolpci] = 0;
+ $steviloPodStolpcev[$indeksPodStolpci]++;
+ }elseif($indeksParameterTabular==count($vodoravniOdgovoriSprId)){
+ $parameterTabular .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava stolpca
+
+ $steviloPodStolpcev[$indeksPodStolpci]++;
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava stolpca
+
+ $steviloPodStolpcev[$indeksPodStolpci]++;
+ }
+ }
+ }
+
+ if(($vodoravniOdgovoriEnota[$indeksParameterTabular-1]!=0&&$izpisOdgovorov&&$export_data_type == 1) || ($izpisOdgovorov&&$export_data_type == 2&&$vodoravniOdgovoriTip[$indeksParameterTabular-1]==6)){ //(ce je roleta ali izberite iz seznama IN je izpis odgovorov IN razsirjen izvoz) ALI (je izpis odgovorov IN skrcen izvoz IN radio button)
+ //echo "tabela ni presiroka </br>";
+ while($enotaNiNulaTmp==0){ //omejimo zanko le na en prehod
+ if($indeksParameterTabular==1){ //ce je prvi podstolpec
+ $parameterTabular .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava stolpca
+
+ $steviloPodStolpcev[$indeksPodStolpci] = 0;
+ $steviloPodStolpcev[$indeksPodStolpci]++;
+
+ if($splice==0){
+ array_splice($vodoravniOdgovoriPrva, $indeksVodoravniOdgovori, 1, ''); //na mesto vodoravnega odgovora dodaj prazen tekst
+ $splice=1;
+ }
+ }else{ //ce so ostali podstolpci
+ if($value!=$valueTmp){ //ce je sprememba spremenljivke
+ $parameterTabular .= ($export_format == 'pdf' ? '|C' : '|c'); //sredinska poravnava stolpca z locilom
+
+ //echo "</br> sprememba spremenljivke iz $valueTmp v $value ".'</br>';
+
+ $indeksPodStolpci++;
+ $steviloPodStolpcev[$indeksPodStolpci] = 0;
+ $steviloPodStolpcev[$indeksPodStolpci]++;
+
+ array_splice($vodoravniOdgovoriPrva, $indeksVodoravniOdgovori, 1, ''); //na mesto vodoravnega odgovora dodaj prazen tekst
+ $splice=1;
+ }else{ //ce ni spremembe spremenljivke
+ array_push($toDelete, $indeksVodoravniOdgovori); //zabelezi indeks elementa polja, ki ga je potrebno izbrisati, da bo stevilo stolpec ustrezno
+ }
+ }
+ $enotaNiNulaTmp = 1;
+ }
+ $enotaNiNulaTmp = 0;
+ $enotaNiNula = 1;
+ } //ce je roleta ali izberite iz seznama in je izpis odgovorov - konec#####################################
+
+ $valueTmp = $value;
+ $indeksParameterTabular++;
+ $indeksVodoravniOdgovori++;
+ } //parametri tabele ZA OSTALE STOLPCE+pridobitev stevila stolpcev+priprava polj in spremenljivk - konec ##########################################
+
+ //echo "Parametri tabel: ".$parameterTabular."</br>";
+
+ //brisanje odvecnih elementov polja in ponovna indeksacija polja
+ foreach($toDelete as $value){
+ unset($vodoravniOdgovoriPrva[$value]); //brisanje ustreznih elementov polja
+ unset($vodoravniOdgovoriEnota[$value]);
+ unset($vodoravniOdgovoriTip[$value]);
+ }
+ $vodoravniOdgovoriPrva = array_values($vodoravniOdgovoriPrva); // reindeksiranje polja za naslovno vrstico tabele
+ $vodoravniOdgovoriEnota = array_values($vodoravniOdgovoriEnota); // reindeksiranje polja za enote vprasanja
+ $vodoravniOdgovoriTip = array_values($vodoravniOdgovoriTip); // reindeksiranje polja za tip vprasanja
+ //brisanje odvecnih elementov polja in ponovna indeksacija polja - konec
+
+ //dodatna priprava polj in spremenljivk, ce enota je razlicna od nula oz. izris ni klasicna tabela #####################################
+
+ if($enotaNiNula==1&&$izpisOdgovorov){ //ce ni klasicna tabela IN je izpis odgovorov
+ $steviloPravihStolpcev = 0;
+ foreach($steviloPodStolpcev as $value){
+ $steviloPravihStolpcev = $steviloPravihStolpcev + $value;
+ }
+
+ $numColSqlPrva = $steviloPravihStolpcev+1; //stevilo stolpcev z vodoravnimi odgovori+stolpec z navpicnimi odgovori
+
+ }else{
+ $numColSqlPrva = $numColSql;
+ }
+ //echo "stevilo stolpcev prva vrstica $numColSqlPrva </br>";
+ //dodatna priprava polj in spremenljivk, ce enota je razlicna od nula oz. izris ni klasicna tabela - konec #############################
+
+ //ureditev parametrov za tabelo, pridobitev stevila stolpcev za vsak tip dodanega vprasanja (podstolpec), priprava polj in spremenljivk, ce enota je razlicna od nula oz. izris ni klasicna tabela - konec ########
+
+
+ //IZRIS TABELE
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1); //zacetek tabele
+
+ #nadnaslovi nad prvo vrstico #########################################################
+ if($spremenljivke['grid_subtitle1']==1){ //ce so podnaslovi
+ for($n=0;$n<count($podNaslovi);$n++){
+ //echo $podNaslovi[$n].'</br>';
+ //$tex .= ' & \multicolumn{'.$steviloPodStolpcev[$n].'}{c}{'.$podNaslovi[$n].'}';
+ $tex .= ' & \multicolumn{'.$steviloPodStolpcev[$n].'}{C}{'.$podNaslovi[$n].'}';
+ }
+ }
+ $tex .= $texNewLine;
+ #nadnaslovi nad prvo vrstico - konec #########################################################
+
+ #prva vrstica tabele ####################################################################################
+ //izris prve vrstice tabele
+ $tex .= $this->LatexPrvaVrsticaMultiGrid($numColSqlPrva, $enota, $trak, $customColumnLabelOption, $spremenljivke, $vodoravniOdgovoriPrva, 0);
+ #prva vrstica tabele - konec ##################################################################################
+
+ $tex .= $texNewLine;
+
+ //print_r($userAnswer);
+
+ #izris vrstic tabele
+ $fillablePdf = 0;
+ //echo "stevilo stolpcev tabele $numColSql </br>";
+ $tex .= $this->LatexVrsticeMultigrid($numRowsSql, $export_format, $enota, $simbolTex, $navpicniOdgovori, 0, $fillablePdf, $numColSql, $spremenljivke, $trak, $vodoravniOdgovori, $texNewLine, 0, 0, $vodoravniOdgovoriTip, $vodoravniOdgovoriEnota, $vodoravniOdgovoriSprId, $userAnswer, $export_subtype, $preveriSpremenljivko, $userDataPresent, $presirokaTabela, $export_data_type);
+ #izris vrstic tabele - konec
+
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular'); //zakljucek tabele
+ //IZRIS TABELE - KONEC
+
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+
+ return $tex;
+
+ }elseif($presirokaTabela == 1){ //ce je tabela presiroka #################################################
+
+
+ //za vsako spremenljivko oz. podtabelo
+ foreach($multipleSprId AS $sprId){
+ //echo "$sprId</br>";
+
+ #pobiranje podatkov o odgovorih respondenta za vsako podtabelo posebej
+ if($usr_id){ //ce je prisotne id uporabnika, je izpis odgovorov in je potrebno narediti naslednje stvari
+ $spremenljivke['id'] = $sprId;
+ $userAnswer = $this->GetUsersDataKombinirana($spremenljivke, $db_table, $usr_id, $presirokaTabela, $this->loop_id, $export_data_type);
+ foreach($userAnswer as $value){
+ if($value!=''){
+ $userDataPresent=1;
+ }
+ //echo "Value: ".$value."</br>";
+ }
+ $izpisOdgovorov = 1;
+ }
+ //echo "podatek je: ".$userDataPresent."</br>";
+ /* print_r($userAnswer);
+ echo "</br>"; */
+ #pobiranje podatkov o odgovorih respondenta za vsako podtabelo posebej - konec
+
+ $vodoravniOdgovoriTip = array();
+ $vodoravniOdgovoriSprId = array();
+ $vodoravniOdgovoriEnota = array();
+ $vodoravniOdgovori = array();
+ $podNaslovi = array();
+ //poizvedba vseh potrebnih podatkov dodanih moznosti v podtabeli kombinirane tabele
+ $sqlStavekPodTabele = "SELECT g.*, s.tip, s.enota, s.dostop FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id=m.spr_id AND m.spr_id = ".$sprId." ORDER BY m.vrstni_red, g.vrstni_red";
+ //echo "$sqlStavekPodTabele</br>";
+ $sqlPodTabele = sisplet_query($sqlStavekPodTabele);
+
+ while($rowMultiple = mysqli_fetch_array($sqlPodTabele)){
+ array_push($vodoravniOdgovoriTip, $rowMultiple['tip']); //filanje polja s tipi spremenljivk
+ array_push($vodoravniOdgovoriSprId, $rowMultiple['spr_id']); //filanje polja z id spremenljivk
+ array_push($vodoravniOdgovoriEnota, $rowMultiple['enota']); //filanje polja z enoto spremenljivk
+ //print_r($vodoravniOdgovoriTip);
+ $stringTitleCol = $this->encodeText($rowMultiple['naslov'], 0, 1);
+ $stringTitleCol = '\footnotesize{'.$stringTitleCol.'}'; //zmanjsanje pisave za naslove stolpcev tabele
+
+ //if(($vodoravniOdgovoriEnota[0] == 2 || $vodoravniOdgovoriEnota[0] == 6) && $izpisOdgovorov && $export_data_type == 1){ //(ce je roleta ALI seznam) IN je izpis odgovorov IN razsirjen izvoz
+ if(($vodoravniOdgovoriEnota[0] == 2 || $vodoravniOdgovoriEnota[0] == 6) && $izpisOdgovorov && $export_data_type == 1 || ($izpisOdgovorov && $export_data_type == 2 && $vodoravniOdgovoriTip[0] == 6 )){ //(ce je roleta ALI seznam) IN je izpis odgovorov IN razsirjen izvoz ALI (je izpis odgovorov IN skrcen izvoz IN radio button)
+
+ }else{
+ array_push($vodoravniOdgovori, $stringTitleCol); //filanje polja z vodoravnimi odgovori (po stolpcih)
+ }
+ //array_push($vodoravniOdgovori, $stringTitleCol); //filanje polja z vodoravnimi odgovori (po stolpcih)
+ //echo $rowMultiple['naslov']."</br>";
+ }
+
+ //poizvedba podnaslovov v podtabeli kombinirane tabele
+ $sqlMultiplePodNaslovi = sisplet_query("SELECT naslov FROM srv_spremenljivka WHERE id =".$sprId);
+ //ureditev polja z nadnaslovi kombinirane tabele
+ while ($rowMultiplePodNaslovi = mysqli_fetch_array($sqlMultiplePodNaslovi)){
+ array_push($podNaslovi, $this->encodeText($rowMultiplePodNaslovi['naslov']));
+ }
+ //ureditev polja z nadnaslovi kombinirane tabele - konec
+
+
+ $enota = $vodoravniOdgovoriEnota[0];
+ /* print_r($vodoravniOdgovoriTip);
+ echo "</br>";
+ print_r($vodoravniOdgovoriSprId);
+ echo "</br>";*/
+ /* print_r($vodoravniOdgovoriEnota);
+ echo "</br>"; */
+ /* print_r($vodoravniOdgovori);
+ echo "</br>"; */
+
+ //ureditev parametrov tabele
+ /* echo "enota:".$vodoravniOdgovoriEnota[0]."</br>";
+ echo "izpisOdgovorov:".$izpisOdgovorov."</br>";
+ echo "tip:".$vodoravniOdgovoriTip[0]."</br>";
+ echo "export_data_type:".$export_data_type."</br>"; */
+ //if(($enota == 2 || $enota == 6) && $izpisOdgovorov && $export_data_type == 1){ //(ce je roleta ALI seznam) IN je izpis odgovorov IN razsirjen izvoz
+ if(($enota == 2 || $enota == 6) && $izpisOdgovorov && $export_data_type == 1 || ($izpisOdgovorov && $export_data_type == 2 && $vodoravniOdgovoriTip[0] == 6 )){ //(ce je roleta ALI seznam) IN je izpis odgovorov IN razsirjen izvoz ALI (je izpis odgovorov IN skrcen izvoz IN radio button)
+ $steviloStolpcev = 1 + 1;
+ }else{
+ $steviloStolpcev = count($vodoravniOdgovoriSprId) + 1;
+ }
+ //echo "stevilo stolpcev: $steviloStolpcev</br>";
+
+ /* if((($vodoravniOdgovoriEnota[0] == 2 || $vodoravniOdgovoriEnota[0] == 6)&&$izpisOdgovorov&&$export_data_type == 1) || ($izpisOdgovorov&&$export_data_type == 2&&$vodoravniOdgovoriTip[$indeksParameterTabular-1]==6)){ //(ce je roleta ali izberite iz seznama IN je izpis odgovorov IN razsirjen izvoz) ALI (je izpis odgovorov IN skrcen izvoz IN radio button)
+
+ } */
+
+
+ //echo "stevilo stolpcev: $steviloStolpcev</br>";
+
+ $parameterTabular = '';
+ $parameterTabular .= ($export_format == 'pdf' ? 'A' : 'l'); //leva poravnava stolpca fiksne sirine ZA PRVI STOLPEC (parameteri tabele)
+
+ for($i=1; $i<$steviloStolpcev;$i++){
+ $parameterTabular .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava stolpca
+ }
+ //echo "parametri tabele: $parameterTabular </br>";
+ //ureditev parametrov tabele - konec
+
+
+ //IZRIS TABELE
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1); //zacetek tabele
+
+ #nadnaslovi nad prvo vrstico #########################################################
+ $steviloPodStolpcev = $steviloStolpcev - 1;
+ if($spremenljivke['grid_subtitle1']==1){ //ce so podnaslovi
+ for($n=0;$n<count($podNaslovi);$n++){
+ //echo "podnaslov za sprem ".$vodoravniOdgovoriSprId[0]." je: ".$podNaslovi[$n]." število stolpcev pa $steviloPodStolpcev</br>";
+ //$tex .= ' & \multicolumn{'.$steviloPodStolpcev.'}{c}{'.$podNaslovi[$n].'}';
+ $tex .= ' & \multicolumn{'.$steviloPodStolpcev.'}{C}{'.$podNaslovi[$n].'}';
+ }
+ }
+ $tex .= $texNewLine;
+ #nadnaslovi nad prvo vrstico - konec #########################################################
+
+ #prva vrstica tabele ####################################################################################
+ //izris prve vrstice tabele
+ $tex .= $this->LatexPrvaVrsticaMultiGrid($steviloStolpcev, $enota, $trak, $customColumnLabelOption, $spremenljivke, $vodoravniOdgovori, 0);
+ #prva vrstica tabele - konec ##################################################################################
+
+ $tex .= $texNewLine;
+
+ #izris vrstic tabele
+ $fillablePdf = 0;
+ //echo "stevilo stolpcev tabele $steviloStolpcev </br>";
+ $tex .= $this->LatexVrsticeMultigrid($numRowsSql, $export_format, $enota, $simbolTex, $navpicniOdgovori, 0, $fillablePdf, $steviloStolpcev, $spremenljivke, $trak, $vodoravniOdgovori, $texNewLine, 0, 0, $vodoravniOdgovoriTip, $vodoravniOdgovoriEnota, $vodoravniOdgovoriSprId, $userAnswer, $export_subtype, $preveriSpremenljivko, $userDataPresent, $presirokaTabela, $export_data_type);
+ #izris vrstic tabele - konec
+
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular'); //zakljucek tabele
+ //IZRIS TABELE - KONEC
+
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+
+
+ }
+
+ return $tex;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/HeatmapLatex.php b/admin/survey/export/latexclasses/Vprasanja/HeatmapLatex.php
new file mode 100644
index 0000000..94e86fb
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/HeatmapLatex.php
@@ -0,0 +1,337 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Heatmap
+ *
+ * Vprašanje je prisotno:
+ * tip 27
+ *
+ * Autor: Patrik Pucer
+ * Datum: 09/2017
+ *****************************************/
+//use enkaParameters;
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+define("RADIO_BTN_SIZE", 0.13);
+
+class HeatmapLatex extends LatexSurveyElement
+{
+ protected $polyX = array();
+ protected $polyY = array();
+ protected $path2Images;
+
+ public function __construct()
+ {
+ global $site_path;
+ $this->path2Images = $site_path.'uploadi/editor/';
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $texBigSkip = '\bigskip';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HeatmapLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype='', $preveriSpremenljivko=null, $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //preveri, ce je kaj v bazi
+ //$userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id);
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+
+ $tex = '';
+ $point = array();
+ //nastavitve iz baze ##########################
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ //nastavitve iz baze - konec ####################
+
+ $navpicniOdgovori = array();
+ $navpicniOdgovori = [];
+ $obmocjaNaSliki = array();
+ $coordsObmocijNaSliki = array();
+
+ $texNewLineAfterTable = $texNewLine." ".$texNewLine." ".$texNewLine;
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $stringTitleRow = $rowVrednost['naslov']; //odgovori na levi strani
+ array_push($navpicniOdgovori, $this->encodeText($stringTitleRow) ); //filanje polja z navpicnimi odgovori (po vrsticah)
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec
+
+
+ //$tex .= $this->IzrisVsotaTabela($spremenljivke, $numRowsSql, $navpicniOdgovori, $texNewLine, $texNewLineAfterTable, $export_format, 0);
+
+ $imageName = $this->getImageName('hotspot', $spremenljivke['id'], 'hotspot_image=');
+ //echo("iz heatmap ime slike: ".$imageName."</br>");
+ $path2Images = $this->path2Images;
+
+ $imageNameTest = $path2Images.$imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku
+
+ //error_log("iz heatmap: ".$imageNameTest);
+ //echo("iz heatmap: ".$imageNameTest."</br>");
+
+ $imageName = $path2Images.$imageName;
+
+ if(filesize($imageNameTest) > 0){
+ $image = PIC_SIZE."{".$imageName."}"; //priprave slike predefinirane dimenzije
+ }else{
+ //$image = 'ni slike';
+ $image = $lang['srv_pc_unavailable'];
+ }
+
+ $tex .= $image."".$texNewLine; //izris slike
+
+ //iz baze poberi imena obmocij
+ $sqlHotSpotRegions = sisplet_query("SELECT region_name, region_coords FROM srv_hotspot_regions WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+
+ //izris imen obmocij po $sqlHotSpotRegions
+ $whileIndeks = 0;
+ while ($rowHotSpotRegions = mysqli_fetch_assoc($sqlHotSpotRegions)){
+ if($whileIndeks == 0){ //ce so prisotna imena obmocij, izpisi besedilo "Obmocja na sliki"
+ $tex .= $lang['srv_export_hotspot_regions_names'].': '.$texNewLine; //izpis besedila "Obmocja na sliki"
+ }
+ $tex .= $rowHotSpotRegions['region_name'].''.$texNewLine;
+ if($rowHotSpotRegions['region_name']){
+ array_push($obmocjaNaSliki, $rowHotSpotRegions['region_name']);
+ //array_push($coordsObmocijNaSliki, $rowHotSpotRegions['region_coords']);
+ $coordsObmocijNaSliki[$rowHotSpotRegions['region_name']]=$rowHotSpotRegions['region_coords'];
+ $point[$rowHotSpotRegions['region_name']] = 0;
+ }
+ $whileIndeks++;
+ }
+
+ $tex .= $texNewLine;
+
+ //ureditev missing-ov
+ if(count($missingOdgovori)!=0){ //ce so missing-i
+ $vodoravniOdgovori = $this->AddMissingsToAnswers($vodoravniOdgovori, $missingOdgovori);
+ }
+ //ureditev missing-ov - konec
+
+
+ /* //izris moznih odgovorov
+ $tex .= $lang['srv_drag_drop_answers'].': '.$texNewLine;
+ for($i=0; $i<$numColSql; $i++){
+ $tex .= $vodoravniOdgovori[$i].$texNewLine;
+ } */
+
+
+ if($userDataPresent){ //ce je kaj v bazi, je potrebno izrisati tabelo s koordinatami in naslovom
+
+ #pobiranje parametrov heatmap
+ $sql = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id = '".$spremenljivke['id']."'");
+ $row = mysqli_fetch_assoc($sql);
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ //html slike
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ //stevilo dovoljenih klikov
+ $heatmap_num_clicks = ($spremenljivkaParams->get('heatmap_num_clicks') ? $spremenljivkaParams->get('heatmap_num_clicks') : 1);
+ #pobiranje parametrov heatmap - konec
+
+ $textboxWidthOdgovori = '1'; //sirina okvirja z odgovorom
+ $textboxHeightOdgovori = 0; //visina okvirja z odgovorom
+ $noBordersOdgovori = 0;
+ $parameterTabular = 'l';
+ //za ureditev stevila tock v izbranih obmocjih
+ $dataPointValue = array();
+ $data = array();
+ $numOfAnswers=count($this->userAnswer);
+ //za ureditev stevila tock v izbranih obmocjih - konec
+ //echo "stevilo odgovorov: ".count($this->userAnswer)."</br>";
+
+ #sporocilo o stevilu moznih klikov
+ $tex .= $lang['srv_vprasanje_heatmap_num_clicks'].": ";
+ //$tex .= $lang['srv_vprasanje_heatmap_num_clicks'].": ".$texNewLine;
+ if($export_format == 'pdf'){
+ $tex .= '\\textcolor{crta}{'.$numOfAnswers.'/'.$heatmap_num_clicks.'}'.$texNewLine;
+ }else if($export_format == 'rtf'){
+ $tex .= ' '.$numOfAnswers.'/'.$heatmap_num_clicks.' '.$texNewLine.$texNewLine;
+ }
+
+
+ #sporocilo o stevilu moznih klikov - konec
+
+ #sporocilo o koordinatah klikov
+ $tex .= $lang['srv_analiza_heatmap_clicked_coords'].": ";
+
+
+ for($i=0; $i<count($this->userAnswer);$i++){ //sprehodi se po tockah
+
+ //echo "rowAnswers: ".$this->userAnswer[$i]['address'].' za odgovore tip '.$spremenljivke['tip'].' id '.$spremenljivke['id'].' usr '.$usr_id.'</br>';
+ #priprava odgovora respondenta #######################################################################################
+ if($export_format == 'pdf'){
+ $answer = "\\textcolor{crta}{".$this->userAnswer[$i]['lat'].", ".$this->userAnswer[$i]['lng']."}";
+ }else if($export_format == 'rtf'){
+ $answer = " ".$this->userAnswer[$i]['lat'].", ".$this->userAnswer[$i]['lng']." ";
+ }
+ $lat = $this->userAnswer[$i]['lat'];
+ $lng = $this->userAnswer[$i]['lng'];
+ if($this->userAnswer[$i]['address']){ //ce je prisoten tudi podatek o naslovu, ga dodaj
+ if($export_format == 'pdf'){
+ $answer .= ", \\textcolor{crta}{".$this->userAnswer[$i]['address']."}";
+ }else if($export_format == 'rtf'){
+ $answer .= ", ".$this->userAnswer[$i]['address']." ";
+ }
+ }
+ if($this->userAnswer[$i]['text']&&!is_numeric($this->userAnswer[$i]['text'])){ //ce je prisoten tudi podatek 'text' (kjer je po navadi odgovor na podvprasanje) in ta ni stevilo, ga dodaj
+ $answer .= $texNewLine;
+ $answer .= $lang['srv_export_marker_podvpr_answer'].": \\textcolor{crta}{".$this->userAnswer[$i]['text']."}";
+ }
+
+ #pridobitev podatkov o obmocjih in podatka o prisotnosti tocke v obmocju
+ if(count($obmocjaNaSliki)!=0){ //ce imamo obmocja na sliki
+ $izpisiObmocij = 0;
+ for($o=0; $o<count($obmocjaNaSliki);$o++){
+
+ $this->polyX = array();
+ $this->polyY = array();
+
+ //pretvori koordinate obmocja
+ $this->convertPolyString($coordsObmocijNaSliki[$obmocjaNaSliki[$o]]);
+
+ //preveri, ce je trenutna tocka v trenutnem obmocju
+ $inside=$this->insidePoly($this->polyX, $this->polyY, $lat, $lng);
+
+ if($inside&&$izpisiObmocij==0){
+ $answer .= " v ".$obmocjaNaSliki[$o];
+ $izpisiObmocij = 1;
+ $point[$obmocjaNaSliki[$o]]++;
+ }elseif($inside&&$izpisiObmocij!=0){
+ $answer .= ", ".$obmocjaNaSliki[$o];
+ $point[$obmocjaNaSliki[$o]]++;
+ }
+ }
+ //echo "stevilo tock znotraj obmocja: ".$point["Besedilo"]."</br>";
+ }
+ #pridobitev podatkov o obmocjih in podatka o prisotnosti tocke v obmocju - konec
+ //echo $answer."</br>";
+
+ #priprava odgovora respondenta - konec ##############################################################################
+
+
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ //izpis latex kode za prazen okvir oz. okvir z odgovori respondenta
+ $tex .= $this->LatexTextBox($export_format, $textboxHeightOdgovori, $textboxWidthOdgovori, $answer, $textboxAllignment, $noBordersOdgovori);
+
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ //$tex .= $texNewLine;
+ }
+
+ if(count($obmocjaNaSliki)!=0){ //ce imamo obmocja na sliki
+ //$tex .= '\par {';
+ //$tex .= $texNewLine.$lang['srv_export_respondent_data_heatmap_regions_number'].": ".$texNewLine;
+ $tex .= $lang['srv_export_respondent_data_heatmap_regions_number'].": ";
+ //$tex .= '\par }';
+ for($o=0; $o<count($obmocjaNaSliki);$o++){
+ //echo "stevilo tock znotraj obmocja: ".$obmocjaNaSliki[$o]." je ".$point[$obmocjaNaSliki[$o]]."</br>";
+ //srv_export_respondent_data_heatmap_regions_number
+
+ if($export_format == 'pdf'){
+ $answerRegions = $obmocjaNaSliki[$o].": \\textcolor{crta}{".$point[$obmocjaNaSliki[$o]]."}";
+ }else if($export_format == 'rtf'){
+ $answerRegions = $obmocjaNaSliki[$o].": ".$point[$obmocjaNaSliki[$o]]."";
+ }
+
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ //izpis latex kode za prazen okvir oz. okvir z odgovori respondenta
+ $tex .= $this->LatexTextBox($export_format, $textboxHeightOdgovori, $textboxWidthOdgovori, $answerRegions, $textboxAllignment, $noBordersOdgovori);
+
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ //$tex .= $texNewLine;
+ }
+
+ }
+/* if($point){ //ce je kaksna tocka v obmocju, izpisi tabelo
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ //izpis latex kode za prazen okvir oz. okvir z odgovori respondenta
+ $tex .= $this->LatexTextBox($export_format, $textboxHeightOdgovori, $textboxWidthOdgovori, ': '.$point, $textboxAllignment, $noBordersOdgovori);
+
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ $tex .= $texNewLine;
+ } */
+ }
+
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+/* $tex .= $texNewLine;
+ $tex .= $texNewLine; */
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+
+ return $tex;
+ }
+ }
+
+
+ #funkcija, ki skrbi za pretvorbo stringa koordinat obmocja v polja
+ function convertPolyString($polypoints=null){
+ $poly = [];
+ //$tmpX;
+ //$tmpY;
+ $j = 0;
+
+ $poly = explode(",", $polypoints);
+ //echo count($poly);
+
+ for($i=0; $i<count($poly); $i++){
+ if($i == 0 || $i%2 == 0){
+ $tmpX = (int)$poly[$i];
+ //echo "x: ".$tmpX."</br>";
+ }else{
+ $tmpY = (int)$poly[$i];
+ //echo "y: ".$tmpY."</br>";
+ array_push($this->polyX, $tmpX);
+ array_push($this->polyY, $tmpY);
+ }
+ }
+ //echo ("dolzina polja za x je: ".count($this->polyX));
+ //echo ("dolzina polja za y je: ".count($this->polyY));
+ }
+ #funkcija, ki skrbi za pretvorbo stringa koordinat obmocja v polja - konec
+
+ #funkcija, ki preveri, ali je dolocena tocka v notranjosti dolocenega obmocja
+ function insidePoly($polyX=null, $polyY=null, $pointx=null, $pointy=null) {
+ //echo("Za poly: je x: ".$pointx." y: ".$pointy."</br>");
+ $inside = false;
+ for ($i = 0, $j = count($polyX) - 1; $i < count($polyX); $j = $i++) {
+ //echo $polyX[$i]." ".$polyY[$i]."</br>";
+ if((($polyY[$i] > $pointy) != ($polyY[$j] > $pointy)) && ($pointx < ($polyX[$j]-$polyX[$i]) * ($pointy-$polyY[$i]) / ($polyY[$j]-$polyY[$i]) + $polyX[$i]) ) $inside = !$inside;
+ }
+ //echo "inside je: ".$inside."</br>";
+ return $inside;
+ }
+ #funkcija, ki preveri, ali je dolocena tocka v notranjosti dolocenega obmocja - konec
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/KalkulacijaLatex.php b/admin/survey/export/latexclasses/Vprasanja/KalkulacijaLatex.php
new file mode 100644
index 0000000..d025c58
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/KalkulacijaLatex.php
@@ -0,0 +1,121 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Kalkulacija
+ *
+ * Vprašanje je prisotno:
+ * tip 22
+ *
+ * Autor: Patrik Pucer
+ * Datum: 05/2018
+ *****************************************/
+
+ define("NAGOVOR_LINE_WIDTH", 0.5);
+
+class KalkulacijaLatex extends LatexSurveyElement
+{
+ protected $texBigSkip = '\bigskip';
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new KalkulacijaLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $fillablePdf=null, $texNewLine='', $export_subtype='', $db_table=null, $usr_id=null){
+
+ global $lang;
+ $tex = '';
+
+ $tex .= $spremenljivke['variable'];
+ $tex .= ' = ';
+
+ //pridobi potrebne podatke za izpis kalkulacije
+ $sqlKalkulacijaString = 'SELECT spr_id, vre_id, grd_id, operator, number, left_bracket, right_bracket, vrstni_red FROM srv_calculation WHERE cnd_id =-'.$spremenljivke['id'].' ORDER BY vrstni_red';
+ //echo $sqlKalkulacijaString."</br>";
+ $sqlKalkulacija = sisplet_query($sqlKalkulacijaString);
+
+ while ($rowKalkulacija = mysqli_fetch_assoc($sqlKalkulacija)){
+
+ if($export_subtype=='q_empty'||$export_subtype=='q_comment'){ //ce je prazen vprasalnik ali je prazen vprasalnik s komentarji
+
+ //operator
+ if($rowKalkulacija['vrstni_red']!=1){
+ $tex .= ' '.$this->GetOperator($rowKalkulacija['operator']).' ';
+ }
+
+
+ //levi oklepaj
+ //if($rowKalkulacija['left_bracket']!=0){
+ for ($i = 1; $i <= $rowKalkulacija['left_bracket']; $i++){
+ $tex .= '(';
+ }
+ //}
+
+ //ime spremenljivke
+ if($rowKalkulacija['vre_id']){ //ce potrebujemo poleg imena spremenljivke (Q1, Q2, ...) se podoznako (a, b, c, ...)
+ $sqlVariableVrednostVrstniRedString = 'SELECT variable FROM srv_vrednost WHERE id ='.$rowKalkulacija['vre_id'].' ';
+ $sqlVariableVrednostVrstniRed = sisplet_query($sqlVariableVrednostVrstniRedString);
+ $rowVariableVrednostVrstniRed = mysqli_fetch_assoc($sqlVariableVrednostVrstniRed);
+ $imeSpremenljivke = $rowVariableVrednostVrstniRed['variable'];
+ }else{
+ if($rowKalkulacija['spr_id']>0){
+ $rowVariableName = Cache::srv_spremenljivka($rowKalkulacija['spr_id']); //pridobitev imena spremenljivke iz njenega id
+ $imeSpremenljivke = $rowVariableName['variable'];
+ }else{
+ $imeSpremenljivke = $rowKalkulacija['number'];
+ }
+ }
+ $tex .= $imeSpremenljivke;
+ //echo "ime variable:".$imeSpremenljivke."</br>";
+ //ime spremenljivke - konec
+
+
+ //desni oklepaj
+ //if($rowKalkulacija['right_bracket']!=0){
+ for ($i = 1; $i <= $rowKalkulacija['right_bracket']; $i++){
+ //$tex .= $rowKalkulacija['right_bracket'];
+ $tex .= ')';
+ }
+
+ //echo $tex."</br>";
+ }
+ }
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+ $userAnswer = mysqli_fetch_array($sqlUserAnswer);
+ $tex .= $userAnswer['text'];
+ }
+
+ //pridobi potrebne podatke za izpis kalkulacije - konec
+
+ //echo $tex."</br>";
+
+/* $tex .= $texNewLine; */
+ $tex .= $texNewLine;
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+
+ if($export_format == 'pdf'){ //ce je pdf
+ $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+
+ return $tex;
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/KvotaLatex.php b/admin/survey/export/latexclasses/Vprasanja/KvotaLatex.php
new file mode 100644
index 0000000..f20eef4
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/KvotaLatex.php
@@ -0,0 +1,145 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Kvota
+ *
+ * Vprašanje je prisotno:
+ * tip 25
+ *
+ * Autor: Patrik Pucer
+ * Datum: 05/2018
+ *****************************************/
+
+ define("NAGOVOR_LINE_WIDTH", 0.5);
+
+class KvotaLatex extends LatexSurveyElement
+{
+ protected $texBigSkip = '\bigskip';
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new KvotaLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $fillablePdf=null, $texNewLine='', $export_subtype='', $db_table=null, $anketa=null, $usr_id=null){
+
+ global $lang;
+ $tex = '';
+
+ $tex .= $spremenljivke['variable'];
+ $tex .= ' = ';
+
+ //pridobi potrebne podatke za izpis kvote spr_id vre_id grd_id operator value left_bracket right_bracket vrstni_red
+ $sqlKvotaString = 'SELECT spr_id, vre_id, grd_id, operator, value, left_bracket, right_bracket, vrstni_red FROM srv_quota WHERE cnd_id =-'.$spremenljivke['id'].' ORDER BY vrstni_red';
+ //echo $sqlKvotaString."</br>";
+ $sqlKvota = sisplet_query($sqlKvotaString);
+
+ while ($rowKvota = mysqli_fetch_assoc($sqlKvota)){
+
+ if($export_subtype=='q_empty'||$export_subtype=='q_comment'){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+
+ //operator
+ if($rowKvota['vrstni_red']!=1){
+ $tex .= ' '.$this->GetOperator($rowKvota['operator']).' ';
+ //$tex .= $this->GetOperator($rowKvota['operator']);
+ }
+
+ //levi oklepaj
+ for ($i = 1; $i <= $rowKvota['left_bracket']; $i++){
+ $tex .= '(';
+ }
+
+ //vrstni red vrednosti spremenljivke
+ $sqlVariableVrednostVrstniRedString = 'SELECT vrstni_red FROM srv_vrednost WHERE id ='.$rowKvota['vre_id'].' ';
+ $sqlVariableVrednostVrstniRed = sisplet_query($sqlVariableVrednostVrstniRedString);
+ $rowVariableVrednostVrstniRed = mysqli_fetch_assoc($sqlVariableVrednostVrstniRed);
+ //echo $rowVariableVrednostVrstniRed['vrstni_red']."</br>";
+
+ //ime spremenljivke
+ if($rowKvota['spr_id']>0){ //ce je spr_id vecji od 0
+ $rowVariableName = Cache::srv_spremenljivka($rowKvota['spr_id']); //pridobitev imena spremenljivke iz njenega id
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$rowVariableName['variable'].$this->encodeText('_').$rowVariableVrednostVrstniRed['vrstni_red'].')';
+ }else{ //drugace, ko je spr_id manjsi od 0, je negativne vrednosti, so zapisani statusi in tipi odgovorov
+ switch ( $rowKvota['spr_id'] ){
+ case -1:
+ // Kvota po statusu
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_1'].')';
+ break;
+ case -2:
+ // Kvota po statusu
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_2'].')';
+ break;
+ case -3:
+ // Kvota po statusu
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_3'].')';
+ break;
+ case -4:
+ // Kvota po statusu
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_4'].')';
+ break;
+ case -5:
+ // Kvota po statusu
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_5'].')';
+ break;
+ case -6:
+ // Kvota po statusu
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_6'].')';
+ break;
+ case -7:
+ // Kvota po ustreznih odgovorih
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_7'].')';
+ break;
+ case -8:
+ // Kvota po vseh odgovorih
+ $tex .= $lang['srv_vprasanje_tip_25'].'('.$lang['srv_quota_status_8'].')';
+ break;
+ }
+ }
+
+ //desni oklepaj
+ for ($i = 1; $i <= $rowKvota['right_bracket']; $i++){
+ $tex .= ')';
+ }
+ //echo $rowKvota['spr_id']."</br>";
+ }
+ }
+
+ /*izpis odgovorov respondentov*/
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov respondentov
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+ $userAnswer = mysqli_fetch_array($sqlUserAnswer);
+ $tex .= $userAnswer['text'];
+ }
+ /*izpis odgovorov respondentov - konec*/
+
+ //pridobi potrebne podatke za izpis kalkulacije - konec
+
+ //echo $tex."</br>";
+
+ $tex .= $texNewLine;
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+
+ if($export_format == 'pdf'){ //ce je pdf
+ $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+ //echo $tex."</br>";
+ return $tex;
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/LokacijaLatex.php b/admin/survey/export/latexclasses/Vprasanja/LokacijaLatex.php
new file mode 100644
index 0000000..90a40c1
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/LokacijaLatex.php
@@ -0,0 +1,142 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za lokacija
+ *
+ * Vprašanje je prisotno:
+ * tip 26
+ *
+ * Autor: Patrik Pucer
+ * Datum: 08/2017
+ *****************************************/
+
+
+class LokacijaLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $texBigSkip = '\bigskip';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new LokacijaLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype='', $preveriSpremenljivko=null, $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //za podtip izberi lokacijo je treba preverjat posebej, ker se vrstica pri userju vedno kreira ampak brez odgovora
+ if($spremenljivke['enota'] == 3){
+ $loop_id_s = $loop_id == null ? " IS NULL" : " = '".$loop_id."'";
+ //ne sme biti negativna stevilka (ker je lahko neodgovor)
+ $qu = "SELECT count(*) as cnt FROM srv_data_map WHERE spr_id='".$spremenljivke['id']."' AND usr_id='$usr_id' AND loop_id $loop_id_s AND (text NOT REGEXP '^[+\-]?[0-9]+$' OR text>=0);";
+ $sql = sisplet_query($qu, 'obj');
+ $userDataPresent = $sql->cnt;
+ //da se kreira $this->userAnswer
+ $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ }
+ else{
+ //preveri, ce je kaj v bazi
+ //$userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id);
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+ }
+
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ $tex = '';
+
+ $textboxWidth = '1'; //sirina okvirja z odgovorom
+ $textboxHeight = '5cm'; //visina okvirja z odgovorom
+ $odgovorLokacija = "Google Maps"; //odgovor
+ $noBorders = 0;
+
+ //priprava latex kode za text box dolocene sirine in visine glede na export format z besedilom
+ $textboxAllignment = 't';
+ //$answerTextBox = $this->LatexTextBox($export_format, $textboxHeight, $textboxWidth, $odgovorLokacija, $textboxAllignment, $noBorders);
+ $answerTextBox = $odgovorLokacija;
+
+ //$tex .= $answerTextBox; //izris okvirja z odgovorom
+ //parametri tabele
+ $parameterTabular = 'l';
+
+ //IZRIS
+ #ZACETEK TABELE
+ //zacetek tabele
+ //$tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ $tex .= $answerTextBox;
+
+ //zakljucek tabele
+ //$tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ #KONEC TABELE
+
+ //$tex .= $texNewLine;
+
+ if($userDataPresent){ //ce je kaj v bazi, je potrebno izrisati tabelo s koordinatami in naslovom
+ $textboxWidthOdgovori = '1'; //sirina okvirja z odgovorom
+ $textboxHeightOdgovori = 0; //visina okvirja z odgovorom
+ $noBordersOdgovori = 0;
+ //echo "stevilo odgovorov: ".count($this->userAnswer)."</br>";
+
+ for($i=0; $i<count($this->userAnswer);$i++){
+ //v primeru, da imamo izberi lokacijo (podtip 3) in brez texta, pomeni, da nimamo odgovora, zato ignoriraj
+ if(!($spremenljivke['enota'] == 3 && ($this->userAnswer[$i]['text'] == "" || $this->userAnswer[$i]['text'] < 0))){
+ //echo "rowAnswers: ".$this->userAnswer[$i]['address'].' za odgovore tip '.$spremenljivke['tip'].' id '.$spremenljivke['id'].' usr '.$usr_id.'</br>';
+ #priprava odgovora respondenta #######################################################################################
+ $answer = "\\textcolor{crta}{".$this->userAnswer[$i]['lat'].", ".$this->userAnswer[$i]['lng']."}";
+ if($this->userAnswer[$i]['address']){ //ce je prisoten tudi podatek o naslovu, ga dodaj
+ $answer .= ", \\textcolor{crta}{".$this->userAnswer[$i]['address']."}";
+ }
+ if($this->userAnswer[$i]['text']&&(/*!is_numeric($this->userAnswer[$i]['text']) ||*/ $this->userAnswer[$i]['text'] >= 0)){ //ce je prisoten tudi podatek 'text' (kjer je po navadi odgovor na podvprasanje), ga dodaj
+ $answer .= $texNewLine;
+ $answer .= $lang['srv_export_marker_podvpr_answer'].": \\textcolor{crta}{".$this->userAnswer[$i]['text']."}";
+ }
+ //echo $answer;
+ #priprava odgovora respondenta - konec #######################################################################################
+
+ //zacetek tabele
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ //izpis latex kode za prazen okvir oz. okvir z odgovori respondenta
+ $tex .= $this->LatexTextBox($export_format, $textboxHeightOdgovori, $textboxWidthOdgovori, $answer, $textboxAllignment, $noBordersOdgovori);
+
+ //zakljucek tabele
+ $tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ //$tex .= $texNewLine;
+ }
+ }
+ }
+
+ if($export_subtype=='q_empty'){
+ $tex .= $texNewLine;
+ $tex .= $texNewLine;
+ }else{
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+ }
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+ return $tex;
+ }
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/MultiGridLatex.php b/admin/survey/export/latexclasses/Vprasanja/MultiGridLatex.php
new file mode 100644
index 0000000..11f4be2
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/MultiGridLatex.php
@@ -0,0 +1,1768 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za MultiGrid
+ *
+ * Vprašanje je prisotno:
+ * tip 6, 16, 19, 20 z vsemi orientacijami
+ *
+ * Autor: Patrik Pucer
+ * Datum: 07-08/2017
+ *****************************************/
+
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+define("RADIO_BTN_SIZE", 0.13);
+define("U_SHAPE_WIDTH_U", 4);
+define("U_SHAPE_WIDTH_OKVIR", 3.62);
+define("U_SHAPE_WIDTH_TEXT_U", 2.2);
+define("U_SHAPE_WIDTH_TEXT_OKVIR", 1.81);
+define("MAXSTEVILOSTOLPCEV", 21); //max Stevilo Stolpcev za prvo vrstico pod Drsnikom, zaradi tezav z izrisom, ce je teh vec kot toliko
+define("VAS_SIZE", 0.04); //VAS_SIZE
+
+class MultiGridLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+ protected $preveriSpremenljivko;
+ protected $skipEmpty;
+ protected $skipEmptySub;
+ protected $userDataPresent;
+ protected $texBigSkip = '\bigskip ';
+ protected $texSmallSkip = '\smallskip ';
+ public $texNewLine = '\\\\ ';
+ protected $exportDataType;
+
+ protected $textL = '';
+ protected $textR = '';
+ protected $textRArray = array();
+ protected $textRArrayIndex = array();
+
+ protected $textRVreId = array(); //belezi vre_id navpicnih odgovorov, ki so bili izbrani in morajo biti na desni strani povleci-spusti
+ protected $navpicniOdgovoriVreId = array(); //belezi vre_id navpicnih odgovorov
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ protected $path2ImagesMulti;
+
+ protected $language;
+
+ public function __construct()
+ {
+ global $site_path;
+ //parent::getGlobalVariables();
+ $this->path2ImagesMulti = $site_path.'uploadi/editor/';
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MultiGridLatex();
+ }
+
+ #funkcija za izvoz vprasalnika za posameznega respondenta
+ public function exportData($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype=''){
+ global $lang;
+ //echo "exportData";
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ //$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other, spr_id FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other, spr_id FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+
+ $sqlStolpciVrednosti = sisplet_query("SELECT id, naslov, vrstni_red, variable, other, part FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY id");
+ $numColSql = mysqli_num_rows($sqlStolpciVrednosti);
+
+ $tex = '';
+ $tex1 = '';
+
+ $navpicniOdgovori = array();
+ $navpicniOdgovori = [];
+ $navpicniOdgovori2 = array();
+ $navpicniOdgovori2 = [];
+ $vodoravniOdgovori = array();
+ $vodoravniOdgovori = [];
+ $missingOdgovori = array();
+ $missingOdgovori = [];
+
+ $odgovoriRespondent = array();
+ $odgovoriRespondent = [];
+ $odgovoriRespondentTmp = array();
+
+
+ $texNewLineAfterTable = $texNewLine." ".$texNewLine." ".$texNewLine;
+ if($spremenljivke['enota']==10){ //ce je image hotspot
+ $indeksZaWhile = 1;
+ //echo "Indeks je ena ce je hotspot </br>";
+ }
+ $indeksDvojnaTabela1 = 1;
+ $indeksDvojnaTabela2 = 1;
+
+ $IndeksZaMissing = 1;
+
+
+
+ //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti
+ while ($colVrednost = mysqli_fetch_assoc($sqlStolpciVrednosti)){
+ if($colVrednost['other'] != 0){
+ $stringMissingOdgovor = $colVrednost['naslov'];
+ array_push($missingOdgovori, $this->encodeText($stringMissingOdgovor) ); //filanje polja z missing odgovori
+ }else{
+ $stringTitleCol = $colVrednost['naslov'];
+ array_push($vodoravniOdgovori, $this->encodeText($stringTitleCol) ); //filanje polja z vodoravnimi odgovori (po stolpcih)
+ }
+ }
+ //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti - konec
+
+ #potrebno urediti za prikazovanje podatkov, ce je missing v multi text ali multi number
+ if($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je grid stevilk ali besedil
+ if(count($missingOdgovori)){ //ce so missing-i
+ $spremenljivkeData = array(); //pripravi polja, ki omogoca pobiranje podatkov za missing
+ $spremenljivkeData['tip'] = 6;
+ $spremenljivkeData['enota'] = 0;
+ }
+ }
+ #potrebno urediti za prikazovanje podatkov, ce je missing v multi text ali multi number - konec
+
+ $indeksZaWhile = 1;
+ $vNovoVrstico = 1;
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $indeksZaWhile = 1;
+ //navpicni odgovori
+ $stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
+
+ // še dodamo textbox če je polje other
+ $_txt = '';
+ if ( $rowVrednost['other'] == 1 ){
+ //$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$usr_id."' AND loop_id $loop_id");
+ $sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id=".$usr_id);
+ $row4 = mysqli_fetch_assoc($sqlOtherText);
+ $_txt = ' '.$row4['text'];
+ //if($_txt!=' '){
+ //$stringCell_title .= $_txt.':';
+ //}
+ }
+ //echo "zacetek funkcije </br>";
+ //if($spremenljivke['enota']!=10){ //ce ni image hotspot
+/* if($spremenljivke['enota']!=10&&$indeksZaWhile==1){ //ce ni image hotspot
+ $indeksZaWhile = 1;
+ echo "Indeks je ena ce ni hotspot </br>";
+ } */
+ //echo "odgovor: ".$stringCell_title." </br>";
+
+ $IndeksZaMissing=1;
+
+ $sqlVsehVrednsti = sisplet_query("SELECT id, naslov, other FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY 'vrstni_red'");
+
+ while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
+
+ $sqlUserAnswer = $this->GetUsersDataGrid($spremenljivke, $db_table, $rowVrednost, $rowVsehVrednosti, $usr_id,0);
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+
+ if((count($missingOdgovori))&&($spremenljivke['tip']==19||$spremenljivke['tip']==20)){ //ce so missing-i
+ //echo "missing</br>";
+ $sqlUserAnswerMissing = $this->GetUsersDataGrid($spremenljivkeData, $db_table, $rowVrednost, $rowVsehVrednosti, $usr_id,0);
+ $userAnswerMissing = mysqli_fetch_assoc($sqlUserAnswerMissing);
+ //echo "userAnswer Missing: ".$userAnswerMissing['grd_id'].'</br>';
+ }
+ //echo "rowVsehVrednosti['id']: ".$rowVsehVrednosti['id'].'</br>';
+ //echo "userAnswer: ".$userAnswer['text'].'</br>';
+ //echo "userAnswer: ".$userAnswer['grd_id'].'</br>';
+ //echo "rowVrednost['spr_id']: ".$rowVrednost['spr_id'].'</br>';
+
+ if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){ //ce je podatek
+
+ if($indeksDvojnaTabela1==1&&$spremenljivke['enota']==3&&in_array($spremenljivke['tip'], array(6, 16))){ //samo prvic izpisi nadnaslov 1, ce je dvojna tabela
+ //naslov prvega dela grida za dvojno tabelo
+ $tex1 .= $this->encodeText($spremenljivke['grid_subtitle1']).$texNewLine;
+ }
+ if($spremenljivke['tip']==6||$spremenljivke['tip']==16){
+ if(($vNovoVrstico==1&&$spremenljivke['tip']==16)||$spremenljivke['tip']==6){
+ $tex1 .= $texNewLine;
+ $stringCell_title .= $_txt.':';
+ $tex1 .= $stringCell_title.' ';
+ $vNovoVrstico=0;
+ }
+ if($spremenljivke['tip']==16&&$indeksZaWhile!=1){
+ $tex1 .= ', ';
+ }
+ $tex1 .= ' '.$this->encodeText($rowVsehVrednosti['naslov']);
+ //$tex1 .= ' \\textcolor{crta}{'.$this->encodeText($rowVsehVrednosti['naslov']).'}';
+ }
+ //echo "Sprememba indeksa </br>";
+ $indeksZaWhile++;
+ $podatek = 1;
+ //echo "Zgornji: ".$indeksZaWhile."</br>";
+ //echo "Zgornji: ".$indeksZaWhile." za ".$this->encodeText($rowVsehVrednosti['naslov'])."</br>";
+ //echo "tex: ".$tex1."</br>";
+ }else{
+ $podatek = 0;
+ }
+
+ //echo $this->encodeText($this->userAnswer['text']).'</br>';
+ if($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je grid stevilk ali besedil
+
+ //echo "Indeks missing: ".$IndeksZaMissing."</br>";
+ if(($IndeksZaMissing > ($numColSql-count($missingOdgovori)))&&(count($missingOdgovori))){
+ //echo "userAnswer Missing je prisoten in njegov grd_id je: ".$userAnswerMissing['grd_id'].'</br>';
+ $okvirZOdgovori = $this->getAnswerSymbol($export_format, $fillablePdf, 6, $spremenljivke['grids'], count($missingOdgovori), $userAnswerMissing['grd_id']);
+ }else{
+ $okvirZOdgovori = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], count($missingOdgovori),$this->encodeText($userAnswer['text']));
+ }
+
+ //$okvirZOdgovori = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], count($missingOdgovori),$this->encodeText($userAnswer['text']));
+ //echo "okvirZOdgovori: ".$okvirZOdgovori."</br>";
+ array_push($odgovoriRespondent, $okvirZOdgovori);
+
+ }
+ $indeksDvojnaTabela1++;
+ $IndeksZaMissing++;
+ //if(($indeksZaWhile!=1)&&in_array($spremenljivke['tip'], array(6, 16))){
+ //if($podatek==1&&in_array($spremenljivke['tip'], array(6, 16))&&$vNovoVrstico){
+ //if(($podatek==1&&$spremenljivke['tip']==6)||($indeksZaWhile==1&&$spremenljivke['tip']==16)){
+ //if(($podatek==1&&$spremenljivke['tip']==6)||($podatek==1&&$indeksZaWhileOuter==1&&$spremenljivke['tip']==16)){
+ //$tex1 .= $texNewLine;
+ //$vNovoVrstico=0;
+ //}
+ }
+ //$tex .= $texNewLine;
+ $vNovoVrstico=1;
+ }
+
+ $tex2 = '';
+
+ $tex .= $tex1.$tex2; //zdruzitev obeh delov latex kode
+ //echo "tex: ".$tex." za ".$spremenljivke['variable']."</br>";
+ if($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je grid stevilk ali besedil
+ //echo "stevilo odgovorov: ".count($odgovoriRespondent)."</br>";
+ //echo "stevilo odgovorov missing: ".count($userAnswerMissing)."</br>";
+ //echo "stevilo odgovorov : ".count($userAnswer)."</br>";
+ return $odgovoriRespondent;
+ }else{
+ return $tex;
+ }
+
+ }
+ #funkcija za izvoz vprasalnika za posameznega respondenta - konec
+
+
+ //public function export($spremenljivke, $export_format, $questionText, $fillablePdf, $texNewLine, $export_subtype){
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype='', $preveriSpremenljivko=null, $skipEmptySub=null, $export_data_type='', $skipEmpty=null, $loop_id=null, $language=null){
+ //echo $export_data_type."</br>";
+ global $lang;
+
+ $this->language = $language;
+
+ $this->preveriSpremenljivko = $preveriSpremenljivko;
+ $this->skipEmpty =$skipEmpty;
+ $this->skipEmptySub = $skipEmptySub;
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ //$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other, spr_id FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other, spr_id FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+
+ $sqlStolpciVrednosti = sisplet_query("SELECT id, naslov, vrstni_red, variable, other, part FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY id");
+ //$sqlStolpciVrednosti = sisplet_query("SELECT id, naslov, vrstni_red, variable, other, part FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY 'vrstni_red'");
+ $numColSql = mysqli_num_rows($sqlStolpciVrednosti);
+
+ $tex = '';
+
+ if($export_subtype!='q_empty'&&$export_data_type!=1){ //ce ni prazen vprasalnik in izpis ni Dolg, dodaj prazno vrstico
+ //$tex .= '\\\\';
+ }
+
+ $navpicniOdgovori = array();
+ $navpicniOdgovori = [];
+ $navpicniOdgovori2 = array();
+ $navpicniOdgovori2 = [];
+ $vodoravniOdgovori = array();
+ $vodoravniOdgovori = [];
+ $missingOdgovori = array();
+ $missingOdgovori = [];
+ $userAnswerData = array();
+ //$textRVreId = array();
+
+ $indeksOdgovorovTextR = 0;
+
+ $texNewLineAfterTable = $texNewLine." ".$texNewLine." ".$texNewLine;
+
+ $indeksZaWhile = 1;
+ $indeksOdgovorov = 0;
+ //echo "Funkcija export </br>";
+
+ $nacinVnosa = $spremenljivke['ranking_k']; //nacin vnosa 0-Stevilo, 1-Drsnik
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ //$prop['full'] = ( isset($userAnswer[$rowVrednost['id']]) );
+
+ //$stringTitleRow = ((( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
+
+ #ce je respondent odgovarjal v drugem jeziku ########################
+ $rowl = $this->srv_language_vrednost($rowVrednost['id']);
+ if (strip_tags($rowl['naslov']) != '') $rowVrednost['naslov'] = $rowl['naslov'];
+ if (strip_tags($rowl['naslov2']) != '') $rowVrednost['naslov2'] = $rowl['naslov2'];
+ #ce je respondent odgovarjal v drugem jeziku - konec ################
+
+ $stringTitleRow = $rowVrednost['naslov']; //odgovori na levi strani (za tabela diferencial)
+ $stringTitleRow2 = $rowVrednost['naslov2']; //odgovori na desni strani (za tabela diferencial)
+
+ array_push($navpicniOdgovori, $this->encodeText($stringTitleRow, $rowVrednost['id']) ); //filanje polja z navpicnimi odgovori (po vrsticah)
+ array_push($navpicniOdgovori2, $this->encodeText($stringTitleRow2, $rowVrednost['id']) ); //filanje polja z navpicnimi odgovori2 (po vrsticah)
+
+ if($spremenljivke['enota']==9){ //ce je povleci-spusti
+ array_push($this->navpicniOdgovoriVreId, $rowVrednost['id'] ); //filanje polja z vre_id navpicnih odgovorov (po vrsticah), potrebno za povleci-spusti
+ //array_push($this->navpicniOdgovoriVreId, $rowVrednost['spr_id'] ); //filanje polja z vre_id navpicnih odgovorov (po vrsticah), potrebno za povleci-spusti
+ }
+
+ $indeksZaWhile++;
+ //echo "rowVrednost['id']: ".$rowVrednost['id'].'</br>';
+ $indeksZaWhileVsehVrednosti = 1;
+ $indeksEnaMoznostProtiDrugi = 0; //belezi stevilo odgovorov v eni vrstici za enota=4
+
+ $sqlVsehVrednsti = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY 'vrstni_red'");
+ //echo "začne drugi while </br>";
+ while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
+ //$indeksZaWhile = $this->GetUsersDataGrid($spremenljivke, $this->db_table, $rowVrednost, $rowVsehVrednosti, $this->usr_id, 1);
+ //$sqlUserAnswer = $this->GetUsersDataGrid($spremenljivke, $db_table, $rowVrednost, $rowVsehVrednosti, $usr_id, 0);
+ $sqlUserAnswer = $this->GetUsersDataGrid($spremenljivke, $db_table, $rowVrednost, $rowVsehVrednosti, $usr_id, 0, $this->loop_id);
+
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer: ".$userAnswer['grd_id'].'</br>';
+ //echo "userAnswerVreId: ".$userAnswer['vre_id'].'</br>';
+ //echo "text: ".$userAnswer['text'].'</br>';
+
+/* if($spremenljivke['enota']==4&&$userAnswer['grd_id']){
+ $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id'];
+ echo "userAnswerData: ".$userAnswerData[$indeksOdgovorov].'</br>';
+ //echo 'je 4 </br>';
+ $indeksOdgovorov++; */
+ if($spremenljivke['enota']==4){ //ce je ena moznost proti drugi
+ //echo 'je 4 '.$indeksOdgovorov.'</br>';
+ if($userAnswer['grd_id']){ //ce je podatek, ga zabelezi
+ $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id'];
+ //echo "userAnswerData s podatkom: ".$userAnswerData[$indeksOdgovorov].'</br>';
+ //echo 'je 4 '.$indeksOdgovorov.'</br>';
+ $indeksOdgovorov++;
+ }else{ //drugace
+ if($indeksEnaMoznostProtiDrugi>=1){
+ $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id'];
+ //echo "rabim prazno polje </br>";
+ //echo "userAnswerData brez podatka: ".$userAnswerData[$indeksOdgovorov].'</br>';
+ //echo 'je 4 '.$indeksOdgovorov.'</br>';
+ $indeksOdgovorov++;
+ }
+ //echo "indeks se spremeni </br>";
+ $indeksEnaMoznostProtiDrugi++;
+ }
+ //echo "indeksEnaMoznostProtiDrugi: ".$indeksEnaMoznostProtiDrugi.'</br>';
+ //echo "userAnswerData: ".$userAnswerData[$indeksOdgovorov].'</br>';
+ }elseif($spremenljivke['enota']!=4){
+ $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id'];
+ $userAnswerDataText[$indeksOdgovorov] = $userAnswer['text'];
+ if($spremenljivke['enota']==9){ //povleci spusti
+ $this->textRVreId[$indeksOdgovorov] = $userAnswer['vre_id'];
+ if(isset($userAnswer['vre_id'])){
+ //$sqlTextRString = 'SELECT naslov FROM srv_vrednost WHERE id='.$userAnswer['vre_id'].' ';
+ $sqlTextRString = 'SELECT naslov FROM srv_vrednost WHERE id='.$userAnswer['vre_id'].' AND hidden="0" ';
+ //echo $sqlTextRString."</br>";
+ $sqlTextR = sisplet_query($sqlTextRString);
+ $rowTextR = mysqli_fetch_assoc($sqlTextR);
+ //echo $rowTextR['naslov']."</br>";
+ //echo $indeksOdgovorovTextR.'</br>';
+
+ //$this->textRArray[$indeksOdgovorovTextR] = $rowTextR['naslov'];
+
+ //$this->textRArrayIndex[$userAnswer['grd_id']] = array($this->textRArray[$indeksOdgovorovTextR]);
+ //echo "this->textRArray indeks ".$userAnswer['grd_id']." ".$this->textRArrayIndex[$userAnswer['grd_id']][$indeksOdgovorovTextR].'</br>';
+
+ $this->textRArray[$indeksOdgovorovTextR][$userAnswer['grd_id']]=$rowTextR['naslov'];
+ //echo "this->textRArray: ".$this->textRArray[$indeksOdgovorovTextR][$userAnswer['grd_id']].'</br>';
+ //echo "this->textRArray indeks ".$indeksOdgovorov." ".$textRVreId[$indeksOdgovorov].'</br>';
+ $indeksOdgovorovTextR++;
+ }
+ }
+
+ $indeksOdgovorov++;
+ }
+ //echo "rowVrednost['spr_id']: ".$rowVrednost['spr_id'].'</br>';
+ //echo "rowVrednost['id']: ".$rowVrednost['id'].'</br>';
+ //echo "rowVsehVrednosti['id']: ".$rowVsehVrednosti['id'].'</br>';
+ if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){
+ $indeksZaWhileVsehVrednosti++;
+ }
+ if($indeksZaWhileVsehVrednosti!=1){
+ $userDataPresent = 1;
+ }
+ //echo "userAnswerData: ".$userAnswerData[$indeksOdgovorov].'</br>';
+ //echo "enota: ".$spremenljivke['enota'].'</br>';
+ //echo "indeksOdgovorov: ".$indeksOdgovorov.'</br>';
+ //$indeksOdgovorov++;
+ }
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec
+
+ /* echo "userDataPresent: ".$userDataPresent."</br>";
+ echo "preveriSpremenljivko: ".$preveriSpremenljivko."</br>"; */
+
+ $this->userDataPresent = $userDataPresent;
+
+ if($userDataPresent!=0||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ //echo count($userAnswerData)." za ".$spremenljivke['id']."</br>";
+ //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti
+ while ($colVrednost = mysqli_fetch_assoc($sqlStolpciVrednosti)){
+ if($colVrednost['other'] != 0){
+ $stringMissingOdgovor = $colVrednost['naslov'];
+ array_push($missingOdgovori, $this->encodeText($stringMissingOdgovor) ); //filanje polja z missing odgovori
+ }else{
+ #ce je respondent odgovarjal v drugem jeziku ########################
+ $rowl = $this->srv_language_grid($colVrednost['id'],$spremenljivke['id']);
+ if (strip_tags($rowl['naslov']) != '') $colVrednost['naslov'] = $rowl['naslov'];
+ #ce je respondent odgovarjal v drugem jeziku - konec ################
+
+ $stringTitleCol = $colVrednost['naslov'];
+ $stringTitleCol = str_replace('<br />','',$stringTitleCol); //odstranitev odvecnih </br> iz naslova stolpcev
+ array_push($vodoravniOdgovori, $this->encodeText($stringTitleCol) ); //filanje polja z vodoravnimi odgovori (po stolpcih)
+ }
+ }
+ //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti - konec
+
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){ //ce je dolg izvoz
+ //pridobitev ustreznega simbola (ali podatkov) za izris odgovorov
+ if($spremenljivke['tip']==6){ //grid radio
+ //if($spremenljivke['enota']!=11){ //ce ni VAS
+ if($spremenljivke['enota']!=11 && $spremenljivke['enota']!=12){ //ce ni VAS in ni slikovni tip
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0);
+ //$tex .= '{\ChoiceMenu[radio,radiosymbol=\ding{108},name=myGroupOfRadiobuttons]{}{='.$stringTitle.'}}'.$stringTitle.' '.$this->texNewLine;
+ //echo "simbol radio grid: ".$symbol."</br>";
+ }else{ //drugace, ce je VAS
+ //$symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0, $spremenljivke['enota']);
+ //echo "simbol VAS: ".$symbol."</br>";
+ //echo "simbol radio grid: ".$spremenljivke['enota']."</br>";
+ }
+ $internalCellHeight = '1 cm'; //visina praznega okvirja @povleci-spusti
+ }else if($spremenljivke['tip']==16){ //grid checkbox
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0);
+ $internalCellHeight = '3 cm'; //visina praznega okvirja @povleci-spusti
+ }else if($spremenljivke['tip']==19||$spremenljivke['tip']==20){//multi text ali multinumber
+ if($export_subtype=='q_empty'||$export_subtype=='q_comment'){ //ce je prazen vprasalnik ali vprasalnik s komentarji
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], count($missingOdgovori), 0);
+ //$internalCellHeight = '3 cm'; //visina praznega okvirja @povleci-spusti
+ }else{ //ce je vprasalnik s podatki
+ $symbol = $this->exportData($spremenljivke, $export_format, $questionText, $fillablePdf, $texNewLine, $usr_id, $db_table, $export_subtype);
+ }
+ }
+ $this->internalCellHeight = $internalCellHeight;
+ //pridobitev ustreznega simbola (ali podatkov) za izris odgovorov - konec
+ }
+
+ $fillablePdf = 0;
+ if((($spremenljivke['enota']==0)&&($spremenljivke['tip']==6||$spremenljivke['tip']==16))||($spremenljivke['tip']==19||$spremenljivke['tip']==20)){ //klasicna tabela ali multitext ali multinumber
+
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ if($spremenljivke['tip']==20){ //ce je tip vprasanja stevilo
+ if(($nacinVnosa == 0)){ //ce je nacin vnosa Stevilo
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerDataText, $export_subtype);
+ }else if($nacinVnosa == 1 && $export_format=='pdf'){ //ce so drsniki in je pdf
+ $tex .= $this->IzrisGridDrsnikov($spremenljivke, $navpicniOdgovori, $export_format, $export_subtype, $missingOdgovori, $userAnswerDataText);
+ }else if($nacinVnosa == 1 && $export_format=='rtf'){ //ce so drsniki in je rtf
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerDataText, $export_subtype);
+ }
+ }else{
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Skrcen izvoz
+ //$tex .= "Navaden ali Kratek izvoz ".$texNewLine;
+ //echo "export_data_type $export_data_type </br>";
+
+ $navpicniOdgovori2 = 0;
+ //if($spremenljivke['tip']==20){ //ce je tip vprasanja stevilo
+ if($spremenljivke['tip']==20 || $spremenljivke['tip']==19){ //ce je tip vprasanja multi stevilo ali multi besedilo
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerDataText, $export_subtype);
+ }else{ //ce je grid en in vec odgovorov
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ //$tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerDataText, $export_subtype);
+ }
+ }
+ }elseif($spremenljivke['enota']==1){ //tabela diferencial
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ $navpicniOdgovori2 = 0;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==2 || $spremenljivke['enota']==6){ //roleta ali izberite s seznama
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==4){ //ena moznost proti drugi
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ //$tex .= "Navaden ali Kratek izvoz ".$texNewLine;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==5){ //maxdiff
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ //$tex .= "Navaden ali Kratek izvoz ".$texNewLine;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==8){ //tabela da/ne
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ //$tex .= "Navaden ali Kratek izvoz ".$texNewLine;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+
+ }
+ }elseif($spremenljivke['enota']==10){ //image hotspot
+ //if($export_subtype=='q_empty'){ //ce je prazen vprasalnik
+ //if($export_subtype=='q_empty'||$export_subtype=='q_comment'){ //ce je prazen vprasalnik
+ if($export_data_type==1||$export_subtype=='q_empty'||$export_subtype=='q_comment'){ //ce je prazen vprasalnik
+ $imageName = $this->getImageName('hotspot', $spremenljivke['id'], 'hotspot_image=');
+ $imageNameTest = $this->path2ImagesMulti.$imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku
+ //echo("za image hot spot grid: ".$imageNameTest."</br>");
+ if(filesize($imageNameTest) > 0){
+ $image = PIC_SIZE."{".$this->path2ImagesMulti."".$imageName."}"; //priprave slike predefinirane dimenzije
+ }else{
+ //$image = 'ni slike';
+ $image = $lang['srv_pc_unavailable'];
+ }
+
+ $tex .= $texNewLine; //prazna vrstica po vprasanju
+ $tex .= $image."".$texNewLine; //izris slike
+
+ //iz baze poberi imena obmocij
+ $sqlHotSpotRegions = sisplet_query("SELECT region_name FROM srv_hotspot_regions WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+
+ //izris imen obmocij po $sqlHotSpotRegions
+ $tex .= $lang['srv_export_hotspot_regions_names'].': '.$texNewLine;
+ while ($rowHotSpotRegions = mysqli_fetch_assoc($sqlHotSpotRegions))
+ {
+ $tex .= $rowHotSpotRegions['region_name'].''.$texNewLine;
+ }
+
+ //$tex .= $texNewLine;
+
+ //ureditev missing-ov
+ if(count($missingOdgovori)!=0){ //ce so missing-i
+ $vodoravniOdgovori = $this->AddMissingsToAnswers($vodoravniOdgovori, $missingOdgovori);
+ }
+ //ureditev missing-ov - konec
+
+
+ //izris moznih odgovorov
+ $tex .= $lang['srv_drag_drop_answers'].': '.$texNewLine;
+ for($i=0; $i<$numColSql; $i++){
+ $tex .= $vodoravniOdgovori[$i].$texNewLine;
+ }
+ }/* else{ //ce je vprasalnik s podatki
+ $tex .= $this->exportData($spremenljivke, $export_format, $questionText, $fillablePdf, $texNewLine, $usr_id, $db_table, $export_subtype);
+ } */
+ if(($export_data_type==1||$export_data_type==0||$export_data_type==2)&&($export_subtype=='q_data'||$export_subtype=='q_data_all')){ //ce je Dolg, Navaden ali Kratek izvoz
+ if($export_data_type==1){ //ce je Dolg izvoz
+ $tex .= $this->texNewLine;
+ $tex .= $lang['srv_respondent_answer'].": ".$this->texNewLine;
+ }
+
+ $navpicniOdgovori2 = 0;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+
+ //prostor po izpisu tabele
+ //$tex .= $texNewLine;
+ //$tex .= $texNewLine;
+
+ }elseif($spremenljivke['enota']==3){ //dvojna tabela
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ $navpicniOdgovori2 = 0;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==9){ //povleci spusti
+
+ //if($export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){
+ //if($export_data_type==1||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){
+ if($export_data_type==1||$export_subtype=='q_empty'||$export_subtype=='q_comment'||($preveriSpremenljivko&&$export_data_type==1)){
+ $this->exportDataType = $export_data_type;
+
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ $navpicniOdgovori2 = 0;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==11){ //VAS
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ $navpicniOdgovori2 = 0;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }elseif($spremenljivke['enota']==12){ //slikovni tip
+ if($export_data_type==1||($export_subtype=='q_empty'||$export_subtype=='q_comment')){//ce je dolg izvoz ali(prazen vprasalnik ali vpr. s komentarji)
+ //izris tabel ustrezne postavitve
+ $tex .= $this->IzrisTabeleMultiGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, 0, $symbol, $texNewLine, $texNewLineAfterTable, $export_format, 0, $missingOdgovori, $userAnswerData, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==2){ //ce je Skrcen izvoz
+ $navpicniOdgovori2 = 0;
+ $tex .= $this->IzpisOdgovorovGrid($spremenljivke, $numColSql, $numRowsSql, $vodoravniOdgovori, $navpicniOdgovori, $navpicniOdgovori2, $export_format, $fillablePdf, $missingOdgovori, $userAnswerData, $export_subtype);
+ }
+ }
+
+ //$tex .= $texNewLine;
+ //$tex .= $this->texBigSkip;
+ //$tex .= $this->texBigSkip;
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+ return $tex;
+ }
+ }
+ #konec export funkcije
+
+
+ #funkcija, ki skrbi za izpis odgovor za grid vprasanja ########################################################################
+ function IzpisOdgovorovGrid($spremenljivke=null, $steviloStolpcev=null, $steviloVrstic=null, $vodoravniOdgovori=null, $navpicniOdgovori=null, $navpicniOdgovori2=null, $export_format='', $fillablePdf=null, $missingOdgovori=null, $data=null, $export_subtype=''){
+ global $lang;
+ $skipRow = false;
+ $izpis = '';
+
+
+ #missingi##################
+ if(count($missingOdgovori)!=0){ //ce so missingi, jih je potrebno dodati polju z odgovori po stolpcih ($vodoravniOdgovori)
+ for($m=0;$m<count($missingOdgovori);$m++){
+ array_push($vodoravniOdgovori, $missingOdgovori[$m]);
+ }
+ }
+ #missingi - konec###########
+
+ // TODO: Zanke, ki ne izpisujejo ničesar
+ /* foreach($vodoravniOdgovori AS $key => $vodoravniOdgovor){ //za vsak odgovor v vrstici
+ echo $vodoravniOdgovor."</br>";
+ //echo $key."</br>";
+ } */
+ //
+ /* foreach($data AS $key => $datum){ //za vsak odgovor v vrstici
+ echo "Podatek: ".$datum."</br>";
+ //echo $key."</br>";
+ } */
+
+ $z = $j = $i = 0;
+
+ if($spremenljivke['enota']==3){ //dvojna tabela
+ //ureditev podnaslovov za izpis
+ $podnaslovi = array();
+ $podnaslov1 = $spremenljivke['grid_subtitle1']; //podnaslova @dvojna tabela
+ $podnaslov2 = $spremenljivke['grid_subtitle2'];
+
+ array_push($podnaslovi,$podnaslov1);
+ array_push($podnaslovi,$podnaslov2);
+
+
+ #priprava razdeljenih podatkov za izpis odgovorov respondenta za dvojna tabela
+ $odgovoriLevo = array();
+ $odgovoriDesno = array();
+ $preklopPolj = 0;
+
+ $steviloPodatkovVPaketu = $steviloStolpcev/2;
+
+ for($iP=0; $iP < count($data); ($iP++)){
+ $paket = array_slice($data, $iP, $steviloPodatkovVPaketu);
+ if($preklopPolj == 0){
+ $odgovoriLevo = array_merge($odgovoriLevo, $paket);
+ $preklopPolj = 1;
+ }else{
+ $odgovoriDesno = array_merge($odgovoriDesno, $paket);
+ $preklopPolj = 0;
+ }
+ $iP = $iP + $steviloPodatkovVPaketu - 1;
+ }
+
+ $steviloStolpcev = $steviloStolpcev/2;
+ #priprava razdeljenih podatkov za izpis odgovorov respondenta za dvojna tabela - konec
+
+ foreach($podnaslovi AS $indeksPodnaslov => $podnaslov){ //za vsak odgovor v vrstici
+ $j=0; //indeks za podatke
+ $i=0; //indeks za odgovore po stolpcih - vodoravniOdgovori
+ $z=0; //indeks za preverjanje preskakovanja manjkajocih podvprasanj
+ $izpis .= '\textbf{'.$podnaslov.'}: '.$this->texNewLine; //izpis podnaslova
+
+ if($indeksPodnaslov == 0){ //ce je leva tabela
+ $data = array();
+ $data = array_merge($data, $odgovoriLevo);
+ }elseif($indeksPodnaslov == 1){ //ce je desna tabela
+ $data = array();
+ $data = array_merge($data, $odgovoriDesno);
+ }
+
+ foreach($navpicniOdgovori AS $key => $navpicniOdgovor){ //za vsak odgovor v vrstici
+ //echo $navpicniOdgovor.": ";
+ #Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici ###############################
+ if($this->skipEmptySub == 1){
+ $skipRow = true;
+ for($z=$z;$z<($steviloStolpcev*($key+1));$z++){
+ if(isset($data[$z])){ //ce je podatek
+ $skipRow = false;
+ }
+ //echo "surov podatek: ".$data[$z]."</br>";
+ }
+ }
+ #Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici - konec #######################
+
+ $steviloSlikovnihIkon = 0; //belezi stevilo slikovnih ikon
+
+ if(!$skipRow){
+ if($spremenljivke['enota']!=4){
+ $izpis .= $navpicniOdgovor.": ";
+ }
+ for($j=$j;$j<($steviloStolpcev*($key+1));$j++){
+ if($i==$steviloStolpcev){
+ $i=0;
+ }
+ if(isset($data[$j])){ //ce je podatek
+ $izpis .= '\\textcolor{crta}{'.$vodoravniOdgovori[$i].'}';
+ }
+ $i++;
+ }
+ $izpis .= $this->texNewLine;
+ }
+ }
+ }
+
+ }else{ //ce ni dvojna tabela
+ if($spremenljivke['enota']==4){ //ce je ena proti drugi
+ $steviloStolpcev = 1;
+ }
+ foreach($navpicniOdgovori AS $key => $navpicniOdgovor){ //za vsak odgovor v vrstici
+ //echo $navpicniOdgovor.": ";
+ #Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici ###############################
+ if($this->skipEmptySub == 1){
+ $skipRow = true;
+ for($z=$z;$z<($steviloStolpcev*($key+1));$z++){
+ if(isset($data[$z])){ //ce je podatek
+ $skipRow = false;
+ }
+ //echo "surov podatek: ".$data[$z]."</br>";
+ }
+ }
+ #Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici - konec #######################
+
+ $steviloSlikovnihIkon = 0; //belezi stevilo slikovnih ikon
+
+
+
+
+ if(!$skipRow){
+ //$izpis .= ' \hspace*{0.25\textwidth} '; //da je indent do 25 % sirine strani
+ if($spremenljivke['enota']!=4){
+ $izpis .= $navpicniOdgovor.": ";
+ }
+ $odgovorPrisoten = 0; //zastavica za ureditev izpisa vejice, ko je vec odgovorov v eni vrstici
+ for($j=$j;$j<($steviloStolpcev*($key+1));$j++){
+ //echo $j.' ';
+ //echo "surov podatek: ".$data[$j]."</br>";
+ if($spremenljivke['enota']==4){ //ce je ena proti drugi
+ if($data[$j]==2){
+ $odgovorEnaProtiDrugi = '\\textcolor{crta}{'.$navpicniOdgovori2[$key].'}';
+ }else{
+ $odgovorEnaProtiDrugi = '\\textcolor{crta}{'.$navpicniOdgovor.'}';
+ }
+ $izpis .= $odgovorEnaProtiDrugi;
+ }/* elseif($spremenljivke['enota']==11){ //ce je VAS
+ //echo "surov podatek: ".$data[$j]."</br>";
+ //echo "stevilo stolpcev VAS: ".$steviloStolpcev."</br>";
+ //$izpis .= "smily ";
+ if($data[$j]){
+ //$symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0, $spremenljivke['enota'], $data[$j]);
+ //$VASNumber = $data[$j];
+ ##########
+ switch ($steviloStolpcev) {
+ case 1:
+ $VAS = "";
+ break;
+ case 2:
+ $arrayVAS = ['vas3checked', 'vas5checked'];
+ break;
+ case 3:
+ $arrayVAS = ['vas3checked', 'vas4checked', 'vas5checked'];
+ break;
+ case 4:
+ $arrayVAS = ['vas2checked', 'vas3checked', 'vas5checked', 'vas6checked'];
+ break;
+ case 5:
+ $arrayVAS = [ 'vas2checked', 'vas3checked', 'vas4checked', 'vas5checked', 'vas6checked'];
+ break;
+ case 6:
+ $arrayVAS = ['vas1checked', 'vas2checked', 'vas3checked', 'vas5checked', 'vas6checked', 'vas7checked'];
+ break;
+ case 7:
+ $arrayVAS = ['vas1checked', 'vas2checked', 'vas3checked', 'vas4checked', 'vas5checked', 'vas6checked', 'vas7checked'];
+ break;
+ }
+
+ ##########
+ if($steviloStolpcev > 1){
+ $VAS = $arrayVAS[($data[$j]-1)];
+ $symbol = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+
+ $izpis .= $symbol;
+ // echo "symbol za VAS odgovor: ".$symbol."</br>";
+ }
+ } elseif($spremenljivke['enota']==12){ //ce je slikovni tip
+ if($data[$j]){ //ce je podatek
+ $steviloSlikovnihIkon = $data[$j];
+ //echo "stevilo slikovnih ikon: ".$steviloSlikovnihIkon."</br>";
+ //echo "_______________________</br>";
+ }
+ }*/else{
+ if($i==$steviloStolpcev){
+ $i=0;
+ }
+ /* echo "tip: ".$spremenljivke['tip']."</br>";
+ echo "enota: ".$spremenljivke['enota']."</br>"; */
+ if(isset($data[$j])){ //ce je podatek
+ //echo $vodoravniOdgovori[$i].", ";
+ //echo $data[$j].", ";
+ if($odgovorPrisoten==0){
+ $odgovorPrisoten = 1;
+ }else{
+ //}elseif($odgovorPrisoten==1){
+ $izpis .= ", ";
+ }
+ //if($spremenljivke['tip']==20){ //ce je tip vprasanja stevilo
+ if($spremenljivke['tip']==20||$spremenljivke['enota']==11||$spremenljivke['enota']==12){ //ce je tip vprasanja stevilo ALI VAS ALI slikovni tip
+ $izpis .= '\\textcolor{crta}{'.$data[$j].'}';
+ }else{
+ if($spremenljivke['tip']==19){ //ce je tip vprasanja besedilo
+ $izpis .= '\\textcolor{crta}{'.$data[$j].'}';
+ }else{
+ $izpis .= '\\textcolor{crta}{'.$vodoravniOdgovori[$i].'}';
+ }
+ }
+ }
+ $i++;
+ }
+ }
+ if($spremenljivke['enota']!=12){ //ce ni slikovni tip, dodaj novo vrstico
+ $izpis .= $this->texNewLine;
+ }
+ }
+ if($spremenljivke['enota']==12){ //ce je slikovni tip, izpisi ustrezno stevilo simbololov
+ $prviOdgovorSlikovniTip = 1;
+ //echo "izpis kode: ".$izpis."</br>";
+ for($p=0; $p<$steviloSlikovnihIkon; $p++){
+ $izpis .= ICON_SIZE."{".$this->path2Images."".$this->getCustomRadioSymbol($spremenljivke['id'], $prviOdgovorSlikovniTip)."}";
+ }
+ $izpis .= $this->texNewLine;
+
+ }
+ }
+ } //konec, ce ni dvojna tabela
+
+ $izpis .= $this->texNewLine;
+ /* if($spremenljivke['enota']==3){
+ echo $izpis;
+ } */
+ return $izpis;
+ }
+ #funkcija, ki skrbi za izpis odgovor za grid vprasanja - konec ########################################################################
+
+ #funkcija, ki skrbi za izris Grida radio buttonov ali checkboxov za klasicno postavitev tabele ################################
+ function IzrisTabeleMultiGrid($spremenljivke=null, $steviloStolpcev=null, $steviloVrstic=null, $vodoravniOdgovori=null, $navpicniOdgovori=null, $navpicniOdgovori2=null, $simbolTex=null, $texNewLine='', $texNewLineAfterTable=null, $typeOfDocument=null, $fillablePdf=null, $missingOdgovori=null, $data=null, $export_subtype=''){
+ global $lang;
+
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ $isCheckBox = 0;
+ $enota = $spremenljivke['enota'];
+ $podnaslov1 = $spremenljivke['grid_subtitle1']; //podnaslova @dvojna tabela
+ $podnaslov2 = $spremenljivke['grid_subtitle2'];
+ $trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0);
+ $customColumnLabelOption = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1); //1 - "vse" labele, 2 - "le koncne" labele, 3 - "koncne in vmesna" labele
+
+
+ //$radioButtonTex = ($export_format=='pdf'?"{\Large $\ocircle$}" : "\\includegraphics[scale=".RADIO_BTN_SIZE."]{radio}");
+
+ //ce je izbrana oblika traku, poberi potrebne parametre spremenljivke ##################
+ if($trak == 1){
+ //stevilo s katerim se zacenja trak
+ $trakStartingNumber = ($spremenljivkaParams->get('diferencial_trak_starting_num') ? $spremenljivkaParams->get('diferencial_trak_starting_num') : 0);
+
+ //stevilo naslovov nad trakom
+ $trakNumOfTitles = ($spremenljivkaParams->get('trak_num_of_titles') ? $spremenljivkaParams->get('trak_num_of_titles') : 0);
+
+ //polje za naslove nad trakom
+ $trakTitles = [];
+
+ //naslovi nad trakom
+ for($i=0; $i<$trakNumOfTitles; $i++){
+ $trakTitles[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) ? $spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) : '');
+ }
+ }
+ //ce je izbrana oblika traku, poberi potrebne parametre spremenljivke - konec ##########
+
+ //echo "Grids: ".$spremenljivke['grids']." ";
+ //echo "Stevilo stolpcev: ".$steviloStolpcev." ";
+
+ //ureditev stevila stolpcev (za parametre tabele in nadaljnji izris) glede na izbrano postavitev #################################################
+
+ //if(($enota == 0||$enota == 3)||$spremenljivke['tip']==19||$spremenljivke['tip']==20){ //klasika ali dvojna tabela ali je multitext ali multinumber
+ //if(($enota == 0||$enota == 3 || $enota == 11)||$spremenljivke['tip']==19||$spremenljivke['tip']==20){ //klasika ali dvojna tabela ali je multitext ali multinumber ali VAS
+ if(($enota == 0||$enota == 3 || $enota == 11 || $enota == 12)||$spremenljivke['tip']==19||$spremenljivke['tip']==20){ //klasika ali dvojna tabela ali je multitext ali multinumber ali VAS ali slikovni tip
+ //if($trak == 0 || $enota == 3 || ($trak == 1 && $spremenljivke['tip'] == 16)){
+ if(($trak == 0 || $enota == 3 || ($trak == 1 && $spremenljivke['tip'] == 16))||($spremenljivke['tip']==19||$spremenljivke['tip']==20)){
+ $steviloStolpcevParameterTabular = $steviloStolpcev = $steviloStolpcev + 1; //ker je prvi stolpec prazen, je potrebno dodati + 1
+ }elseif($trak == 1 && $enota == 0 && $spremenljivke['tip'] == 6){
+ $steviloStolpcevParameterTabular = $steviloStolpcev + 1;
+ }
+ }elseif($enota == 1){ //diferencial
+ if($trak == 0){ //ce ni na traku
+ //$steviloStolpcevParameterTabular = $steviloStolpcev = $steviloStolpcev + 2; //ker sta prvi in zadnji stolpec prazna, je potrebno dodati + 2
+ if(count($missingOdgovori)!=0){ //ce so missingi
+ $steviloStolpcevParameterTabular = $steviloStolpcev + 2; //ker sta prvi in zadnji stolpec prazna, je potrebno dodati + 2
+ $steviloStolpcev = $steviloStolpcev + 2 - count($missingOdgovori);
+ }else{
+ $steviloStolpcevParameterTabular = $steviloStolpcev = $steviloStolpcev + 2; //ker sta prvi in zadnji stolpec prazna, je potrebno dodati + 2
+ }
+ }else{ //ce je na traku
+ $steviloStolpcevParameterTabular = $steviloStolpcev + 2;
+ $steviloStolpcev = $steviloStolpcev + 2 + count($missingOdgovori);
+ }
+ }elseif($enota == 2 || $enota == 6){ //roleta ali izberite s seznama
+ $steviloStolpcevParameterTabular = 2; //pri roleti sta potrebna le dva stolpca
+ if(count($missingOdgovori)!=0){ //ce so missingi
+ $steviloStolpcev = $spremenljivke['grids'] + count($missingOdgovori) + 1; //+1, ker se pri izrisu indeks zacne z 1
+ }
+ }elseif($enota == 4){ //ena moznost proti drugi
+ $steviloStolpcevParameterTabular = 5;
+ if(count($missingOdgovori)!=0){
+ $steviloStolpcevParameterTabular = $steviloStolpcevParameterTabular+count($missingOdgovori);
+ $steviloStolpcev = $steviloStolpcev-count($missingOdgovori);
+ }
+ }elseif($enota == 5){ //maxdiff
+ $steviloStolpcevParameterTabular = 3;
+ if(count($missingOdgovori)!=0){
+ $steviloStolpcevParameterTabular = $steviloStolpcevParameterTabular+count($missingOdgovori);
+ $steviloStolpcev = $steviloStolpcev-count($missingOdgovori);
+ }
+ }elseif($enota == 8){ //tabela da/ne
+ $steviloStolpcevParameterTabular = $steviloStolpcev = 3;
+ if(count($missingOdgovori)!=0){
+ $steviloStolpcevParameterTabular = $steviloStolpcevParameterTabular+count($missingOdgovori);
+ $steviloStolpcev = $steviloStolpcev+count($missingOdgovori);
+ }
+ }
+ //echo $steviloStolpcev.'</br>';
+ //ureditev stevila stolpcev (za parametre tabele in nadaljnji izris) glede na izbrano postavitev - konec #################################################
+
+ //ureditev parametrov za tabelo #################################################################################################
+ $parameterTabular = '';
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec in ni "ena moznost proti drugi" ALI je zadnji stolpec (pred missing-i) in je "diferencial" ali "ena moznost proti drugi" z missing-i
+ if( ($i == 0 && $enota != 4) || ($i == $spremenljivke['grids']+1 && $enota == 1) || (($i == $spremenljivke['grids']+2 && $enota == 4)&&(count($missingOdgovori)!=0)) ) {
+ //$parameterTabular .= ($typeOfDocument == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca
+ //if($enota == 0 || $enota == 1 || $enota == 3){ //ce je "klasicna tabela" ali diferencial ali dvojna tabela
+ //if($enota == 0 || $enota == 1 || $enota == 3 || $enota == 11){ //ce je "klasicna tabela" ali diferencial ali dvojna tabela ali VAS
+ if($enota == 0 || $enota == 1 || $enota == 3 || $enota == 11 || $enota == 12){ //ce je "klasicna tabela" ali diferencial ali dvojna tabela ali VAS ali slikovni tip
+ if($enota == 1){ //ce je diferencial
+ if($i == 0){ //ce je prvi stolpec
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'A' : 'l'); //leva poravnava stolpca fiksne sirine
+ }elseif($i == $spremenljivke['grids']+1){ //ce je zadnji stolpec
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'R' : 'r'); //desna poravnava stolpca fiksne sirine
+ }
+ }else{
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'A' : 'l'); //leva poravnava stolpca fiksne sirine
+ }
+ }else{
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca prilagojena sirini
+ }
+ }elseif($i == $spremenljivke['grids']+2 && $enota == 4){ //ce je zadnji stolpec in je "ena moznost proti drugi" brez missing-ov
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'r' : 'r'); //desna poravnava
+ }
+ elseif($i == 0 && $enota == 4){ //ce je prvi stolpec in "ena moznost proti drugi"
+ //$parameterTabular .= ($typeOfDocument == 'pdf' ? 'r' : 'r'); //desna poravnava stolpca
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'l' : 'l'); //leva poravnava prvega stolpca
+ }elseif($i == (intval($steviloStolpcev/2)) && $enota == 3){ //ce smo na sredini stolpcev in je dvojna tabela
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'C|' : 'c|'); //sredinska poravnava stolpca
+ }elseif($i == ($steviloStolpcev) && $enota == 5){ //ce je zadnji stolpec in je maxdiff
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'R' : 'r'); //desna za pdf in sredinska poravnava stolpca za rtf
+ }else{
+ $parameterTabular .= ($typeOfDocument == 'pdf' ? 'C' : 'c'); //sredinska poravnava stolpca
+ }
+ }
+ //ureditev parametrov za tabelo - konec ##########################################################################################
+ //echo 'Param: '.$parameterTabular.' enota param: '.$enota.'</br>';
+
+ //izpis tabela
+ $tabela = '';
+ //echo $enota;
+
+ #IZPIS ZA POVLECI SPUSTI
+ if($enota == 9){ //ce je povleci spusti
+ //za pridobitev informacij o obliki odgovorov na desni strani (0 - okvir, 1 - skatla)
+ $display_drag_and_drop_new_look = ($spremenljivkaParams->get('display_drag_and_drop_new_look') ? $spremenljivkaParams->get('display_drag_and_drop_new_look') : 0);
+
+ //ureditev missing-ov
+ if(count($missingOdgovori)!=0){ //ce so missing-i
+ $vodoravniOdgovori = $this->AddMissingsToAnswers($vodoravniOdgovori, $missingOdgovori);
+ }
+ //ureditev missing-ov - konec
+
+ #pred zacetkom tabel za povleci spusti#######################################################################
+ //prva vrstica pred tabelo z odgovori
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= '\keepXColumns\begin{tabularx}{0.45\textwidth}{C} '; //izris s tabelo
+ $tabela .= $lang['srv_ranking_available_categories'].': '.$texNewLine;
+ $tabela .= '\rule{0.4\textwidth}{0.7 pt} \end{tabularx}';
+ }else{ //ce je rtf
+ $tabela .= '\begin{tabular}{l} '; //izris z enostolpicno tabelo
+ $tabela .= $lang['srv_ranking_available_categories'].': '.$texNewLine; //Razpolozljive kategorije
+ $tabela .= '\hline \end{tabular} ';
+ }
+ //prva vrstica pred tabelo z odgovori - konec
+
+ #pred zacetkom tabel za povleci spusti - konec ###############################################################
+
+ #tabela s kategorijami odgovorov iz levega okvirja ###########################################################
+ $tableCentering = ($typeOfDocument == 'pdf' ? ' \centering ' : '');
+
+ $parameterTabularL = 'C'; //parameter za levo tabelo
+
+ //zacetek tabele
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= $this->StartLatexTable($typeOfDocument, $parameterTabularL, 'tabularx', 'tabular*', 0.45, 0.2);
+ }
+
+ //argumenti za leve okvirje
+ $textboxWidthL = 0.2;
+ $textboxHeightL = 0; //ker mora biti prilagojena visina tekstu damo na 0
+ $textboxAllignmentL = 'c';
+
+
+ //izris notranjosti leve tabele
+ //if($this->exportDataType){ //ce je dolg izpis izvoza odgovorov respondenta/respondentov
+ if($this->exportDataType&&$spremenljivke['tip']==6){ //ce je dolg izpis izvoza odgovorov respondenta/respondentov in je tabela en odgovor
+ //najdi razlike med poljema, kjer se belezijo vre_id odgovorov iz leve in desni strani @ povleci-spusti
+ $navpicniOdgovori = array();
+ $diffArray = array_merge(array_diff($this->navpicniOdgovoriVreId, $this->textRVreId), array_diff($this->textRVreId, $this->navpicniOdgovoriVreId));
+ if(count($diffArray)){ //ce je kaksna razlika oz. se je premaknilo odgovore iz leve v desno stran povleci-spusti
+ foreach($diffArray AS $diff){
+ if($diff){
+ // iz baze preberemo naslove odgovorov za levo stran povleci-spusti
+ //$sqlTextLString = "SELECT naslov FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND id='".$diff."' ORDER BY vrstni_red";
+ $sqlTextLString = "SELECT naslov FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND id='".$diff."' AND hidden='0' ORDER BY vrstni_red";
+
+ $sqlTextL = sisplet_query($sqlTextLString);
+ $rowTextL = mysqli_fetch_assoc($sqlTextL);
+ array_push($navpicniOdgovori, $this->encodeText($rowTextL['naslov']));
+ }
+ }
+ }
+
+ $steviloVrstic = count($navpicniOdgovori);
+ if($steviloVrstic==0){ //ce ni odgovorov na levi strani povleci-spusti
+ $tabela .= ' \hspace{0.05\textwidth}'; //dodaj nekaj praznega prostora, da bo leva stran poravnana pravilno
+ }
+ }
+
+ for ($i = 1; $i <= $steviloVrstic; $i++){
+
+ $textL = $tableCentering.' '.$navpicniOdgovori[$i-1]; //odgovor znotraj okvirja
+
+ //$tabela .= ' \indent '; //da je okvir premaknjen proti sredini stolpca
+
+ if($typeOfDocument == 'rtf'){ //ce je rtf
+ $tabela .= '\begin{tabular}{c} '; //izris s tabelo brez obrob
+ //$tabela .= '\begin{tabular}{|c|} \hline'; //izris s tabelo z obrobama levo desno in zgoraj
+ }
+ //izpis latex kode za okvir z odgovorom
+ $tabela .= $this->LatexTextBox($typeOfDocument, $textboxHeightL, $textboxWidthL, $textL, $textboxAllignmentL, 0);
+
+ if($typeOfDocument == 'rtf'){ //ce je rtf
+ $tabela .= ' \end{tabular}'; //za zakljuciti izris v tabeli
+ }else{ //ce je pdf
+ $tabela .= ' '.$this->texBigSkip;
+ $tabela .= $texNewLine;
+ }
+ }
+
+ //zakljucek tabele
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= $this->EndLatexTable($typeOfDocument, 'tabularx', 'tabular*');
+ }
+ #tabela s kategorijami odgovorov iz levega okvirja - konec ##################################################################
+
+ //prostor med tabelama, ki sta sedaj ena pod drugo
+ $tabela .= ' '.$this->texBigSkip;
+
+ #pred zacetkom "desne" tabele za povleci spusti#######################################################################
+ //prva vrstica pred tabelo z odgovori
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= '\keepXColumns\begin{tabularx}{0.45\textwidth}{C} '; //izris s tabelo
+ $tabela .= $lang['srv_drag_drop_answers'].': '.$texNewLine;
+ $tabela .= '\rule{0.4\textwidth}{0.7 pt} \end{tabularx}';
+ }else{ //ce je rtf
+ $tabela .= '\begin{tabular}{l} '; //izris z enostolpicno tabelo
+ //$tabela .= $lang['srv_ranking_available_categories'].': '.$texNewLine; //Razpolozljive kategorije
+ $tabela .= $lang['srv_drag_drop_answers'].': '.$texNewLine; //Razpolozljive kategorije
+ $tabela .= '\hline \end{tabular} ';
+ }
+ //prva vrstica pred tabelo z odgovori - konec
+
+ #pred zacetkom "desne" tabele za povleci spusti - konec ###############################################################
+
+ #tabela s kategorijami odgovorov iz desnega okvirja ########################################################################
+
+ $parameterTabularD = 'c'; //parameter za desno tabelo
+
+ //argumenti za desne okvirje
+ $textboxWidthDV = $textboxWidthDE = 0.2; //sirina okvirja z vsebino in empty
+ $textboxHeightDV = 0; //ker mora biti prilagojena visina tekstu damo na 0
+ $textboxAllignmentDV = 'c';
+ $textboxAllignmentDE = 't'; //allignment desnega okvirja, ki je empty
+ $uShapeHeight = 1.5;
+ if($steviloStolpcev > 9){ //ce je stevilo desnih okvirjev vec kot 9, je potrebno visino okvirja zmanjsati
+ $this->internalCellHeight = '0.3 cm';
+ }
+
+ for ($i = 0; $i < $steviloStolpcev; $i++){
+ $jeOdgovor = 0;
+ $izpisano = 0;
+ $textRIzpis = '';
+ $textIzpis = '';
+ $textNaslovOkvir = '';
+
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+
+ if($display_drag_and_drop_new_look == 0){ //ce je oblika okvirja (tekst na vrhu+(prazen okvir spodaj oz. okvir z odgovori))
+ $texSmallSkip = '';
+ $textDV = $vodoravniOdgovori[$i]; //besedilo odgovora v okvirju
+ //izpis latex kode za okvir z odgovorom
+ //$textRIzpis .= ' '.$textDV.' '.$this->texNewLine.' \hline';
+
+ //$textRIzpis .= ' '.$textDV;
+ $textNaslovOkvir .= ' '.$textDV;
+
+ //$tabela .= $texNewLine;
+ //$tabela .= '\indent ';
+ }else{ //drugace, ce je oblika skatle (prazen okvir na vrhu+tekst spodaj)
+ $texSmallSkip = $this->texSmallSkip;
+ }
+
+ if($this->exportDataType){ //ce je dolg izpis izvoza odgovorov respondenta/respondentov
+ $textNaslovOkvir = $textNaslovOkvir.$this->texNewLine;
+
+ foreach($data AS $key => $datum){
+ if(isset($data[$key])){ //ce je izpis latex kode za skatlo z besedilom odgovora
+ if(($i+1)==$datum){ //ce v se nahaja odgovor v tej skatli
+ $jeOdgovor = 1;
+ if(!$izpisano){
+ foreach($this->textRArray AS $indeksTextRArray => $textR){
+ if($this->textRArray[$indeksTextRArray][$datum]){
+ $textR = $this->encodeText($textR[$datum]);
+ $textR = $tableCentering.' '.$textR;
+ //$textRIzpis .= '\fbox{\parbox{0.2\textwidth}{'.$textR.'}} '.$texSmallSkip.' '.$this->texNewLine; //zacetna varianta
+ $textIzpis .= ' \vspace{0.5\baselineskip} ';
+ $textIzpis .= '\fbox{\parbox{0.2\textwidth}{'.$textR.'}} '.$texSmallSkip.' '.$this->texNewLine;
+ //$textRIzpis .= ' \hline \fbox{\parbox{0.2\textwidth}{'.$textR.'}} '.$texSmallSkip.' '.$this->texNewLine;
+ $izpisano = 1;
+ }
+ }
+ }else{
+ //$uShapeHeight=$uShapeHeight+1.5; //
+ $uShapeHeight=$uShapeHeight+0.5; //ureditev visine skatle
+ }
+ }
+ }
+ }
+
+ }
+
+ if(!$jeOdgovor){ //ce ni odgovora
+
+ if($display_drag_and_drop_new_look == 0){ //ce je oblika okvirja, izrisi prazen okvir
+ $tabela .= $this->LatexTextGridOfBoxes($typeOfDocument, $uShapeHeight, U_SHAPE_WIDTH_TEXT_U, $textNaslovOkvir, $jeOdgovor);
+ //textNaslovOkvir
+ }else{ //drugace, ce je skatla, izrisi prazno skatlo
+ //izpis latex kode za skatlo
+ $tabela .= $this->LatexUShape($typeOfDocument, $this->internalCellHeight, U_SHAPE_WIDTH_U, '');
+ //$tabela .= $texNewLine;
+ }
+ }else{ //drugace, izpisi odgovore
+ if($display_drag_and_drop_new_look == 0){ //ce je oblika okvirja
+ $tabela .= $this->LatexTextGridOfBoxes($typeOfDocument, $uShapeHeight, U_SHAPE_WIDTH_TEXT_OKVIR, $textNaslovOkvir, $jeOdgovor, $textIzpis);
+ }else{ //drugace, ce je skatla
+ $tabela .= $this->LatexTextInUShape($typeOfDocument, $uShapeHeight, U_SHAPE_WIDTH_TEXT_U, $textIzpis);
+ }
+ }
+
+ $uShapeHeight = 1.5;
+ //$tabela .= $texNewLine;
+ if($display_drag_and_drop_new_look == 1){ //ce je skatla
+ //izpis latex kode za okvir (brez obrobe oz. fbox) z odgovorom
+ //$tabela .= ' \indent \parbox{0.2\textwidth}{ '.$tableCentering.' '.$vodoravniOdgovori[$i].' } '.$texNewLine;
+ $tabela .= ' \parbox{0.2\textwidth}{ '.$tableCentering.' '.$vodoravniOdgovori[$i].' } '.$texNewLine;
+ $tabela .= '\end{tabularx}'; //konec tabele, ki se je zacela pri izpisu skatle
+ }
+ //echo "TABELA TEX: ".$tabela."</br>";
+ }elseif($typeOfDocument == 'rtf'){
+ if($i != 0){ //ce ni prvi, dodaj prostor
+ $tabela .= ' '.$this->texBigSkip;
+ }
+
+ $tabela .= '\begin{tabular}{c} '; //izris s tabelo brez obrob
+ if($this->exportDataType){ //ce je dolg izpis izvoza odgovorov respondenta/respondentov
+ foreach($data AS $key => $datum){
+ if(isset($data[$key])){ //ce je izpis latex kode za skatlo z besedilom odgovora
+ if(($i+1)==$datum){ //ce v se nahaja odgovor v tej skatli
+ $jeOdgovor = 1;
+ if(!$izpisano){
+ foreach($this->textRArray AS $indeksTextRArray => $textR){
+ if($this->textRArray[$indeksTextRArray][$datum]){
+ $textR = $this->encodeText($textR[$datum]);
+ $textR = $tableCentering.' '.$textR;
+ $textRIzpis .= '\fbox{\parbox{0.2\textwidth}{'.$textR.'}} '.$this->texNewLine;
+ $izpisano = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if($display_drag_and_drop_new_look == 0){ //ce je oblika okvirja (tekst na vrhu+(prazen okvir spodaj oz. okvir z odgovori))
+ //izpis latex kode za okvir (brez obrobe oz. fbox) z odgovorom
+ $tabela .= ' \parbox{0.2\textwidth}{ '.$tableCentering.' '.$vodoravniOdgovori[$i].' } '.$texNewLine;
+ if($jeOdgovor){ //ce je odgovor, dodaj crto
+ $tabela .= '\rule{40mm}{.1pt} '.$texNewLine;
+ }
+ }
+
+ if(!$jeOdgovor){ //ce ni odgovora
+ //izpis latex kode za okvir brez besedila
+ $tabela .= $this->LatexTextBox($typeOfDocument, 0, $textboxWidthDE, '', $textboxAllignmentDE, 0);
+ $tabela .= $texNewLine;
+ }else{ //drugace, izpisi odgovore
+ $tabela .= $textRIzpis;
+ }
+
+ if($display_drag_and_drop_new_look == 1){ //ce je skatla (prazen okvir na vrhu+tekst spodaj)
+ //izpis latex kode za okvir (brez obrobe oz. fbox) z odgovorom
+ if($jeOdgovor){ //ce je odgovor, dodaj crto
+ $tabela .= '\rule{40mm}{.1pt} '.$texNewLine;
+ }
+ $tabela .= ' \parbox{0.2\textwidth}{ '.$tableCentering.' '.$vodoravniOdgovori[$i].' } '.$texNewLine;
+ }
+ $tabela .= ' \end{tabular}'; //za zakljuciti izris v tabeli
+ }
+ }
+ #tabela s kategorijami odgovorov iz desnega okvirja - konec ##########################################################################
+
+ }
+ #IZPIS ZA POVLECI SPUSTI - KONEC
+
+
+ if($enota != 9){ //ce ni povleci spusti
+
+ #ZACETEK MAIN TABELE #########################################################################
+ $tabela .= $this->StartLatexTable($typeOfDocument, $parameterTabular, 'tabularx', 'tabular', 1, 1);
+
+ #nad prvo vrstico, ampak se vedno v tabeli - naslovi trakov, podnaslovi dvojne tabele ################################################
+ if( ($enota == 3) && ($podnaslov1 || $podnaslov2) ){ //ce je dvojna tabela in sta prisotna podnaslova
+ $tabela .= ' & \multicolumn{'.intval($steviloStolpcev/2).'}{c}{'.$podnaslov1.'} & \multicolumn{'.intval($steviloStolpcev/2).'}{c}{'.$podnaslov2.'} '.$texNewLine;
+ //$tabela .= ' & \multicolumn{'.intval($steviloStolpcev/2).'}{c}{'.$podnaslov1.'} & \multicolumn{'.intval($steviloStolpcev/2).'}{c}{'.$podnaslov2.'} ';
+ }elseif($trak == 1 && $spremenljivke['tip'] == 6 && ($enota == 0 || $enota == 1)){ //ce imamo obliko traku, uredi nadnaslove traka
+ if($spremenljivke['grids']%$trakNumOfTitles == 0){ //ce je stevilo stolpcev deljivo s trenutnim izbranim stevilom nadnaslovov
+ for($i=0; $i<$trakNumOfTitles; $i++){
+ $trakTitles[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) ? $spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) : '');
+ if($i==0){ //ce je prvi stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles).'}{l}{'.$trakTitles[$i].'}';
+
+ }elseif( $i==($trakNumOfTitles-1) ){ //ce je zadnji stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles).'}{r}{'.$trakTitles[$i].'}';
+ }else{
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles).'}{c}{'.$trakTitles[$i].'}';
+ }
+ }
+ }elseif($spremenljivke['grids']%$trakNumOfTitles == 2){ //ce po deljenju ostane 2
+ for($i=0; $i<$trakNumOfTitles; $i++){
+ $trakTitles[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) ? $spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) : '');
+ if($i != 0 && $i != ($trakNumOfTitles-1) ){
+ $multiColParameter = intval($spremenljivke['grids']/$trakNumOfTitles);
+ }else{
+ $multiColParameter = 1 + intval($spremenljivke['grids']/$trakNumOfTitles);
+ }
+ if($i==0){ //ce je prvi stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.$multiColParameter.'}{l}{'.$trakTitles[$i].'}';
+ }elseif( $i==($trakNumOfTitles-1) ){ //ce je zadnji stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.$multiColParameter.'}{r}{'.$trakTitles[$i].'}';
+ }else{
+ $tabela .= ' & \multicolumn{'.$multiColParameter.'}{c}{'.$trakTitles[$i].'}';
+ }
+ }
+ }else if($trakNumOfTitles == 2){ //ce sta izbrana samo dva nadnaslova
+ if($spremenljivke['grids']%$trakNumOfTitles == 0){
+ for($i=0; $i<$trakNumOfTitles; $i++){
+ $trakTitles[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) ? $spremenljivkaParams->get('trak_nadnaslov_'.($i+1)) : '');
+ if($i==0){ //ce je prvi stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles).'}{l}{'.$trakTitles[$i].'}';
+ }elseif( $i==($trakNumOfTitles-1) ){ //ce je zadnji stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles).'}{r}{'.$trakTitles[$i].'}';
+ }else{
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles).'}{c}{'.$trakTitles[$i].'}';
+ }
+ }
+ }else{
+ for($i=0; $i<$trakNumOfTitles; $i++){
+ if($i==0){ //ce je prvi stolpec nadnaslovov
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles + 0.5).'}{l}{'.$trakTitles[$i].'}';
+ }else{
+ $tabela .= ' & \multicolumn{'.intval($spremenljivke['grids']/$trakNumOfTitles - 0.5).'}{r}{'.$trakTitles[$i].'}';
+ }
+ }
+ }
+ }
+ if($enota == 1){ //ce je diferencial tabela
+ $tabela .= ' & ';
+ }
+ //echo $tabela;
+
+ //missingi
+ if(count($missingOdgovori)!=0 && ($enota==0||$enota==1)){ //ce so missingi in (je klasicna tabela ali diferencial)
+ for($m=0;$m<count($missingOdgovori);$m++){
+ $tabela .= " & ".$missingOdgovori[$m];
+ }
+ }
+ //missingi - konec
+ }
+ #nad prvo vrstico, ampak se vedno v tabeli - konec#######################################################
+
+ //echo $steviloStolpcev."</br>";
+
+ //ureditev missing-ov za tabela da/ne, klasicna ali dvojna tabela #############################
+ if($enota==8){ //ce je tabela da/ne
+ if(count($missingOdgovori)!=0){ //ce so missing-i
+ $vodoravniOdgovori = $this->AddMissingsToAnswers($vodoravniOdgovori, $missingOdgovori);
+ }
+ }elseif($enota==0 || $enota==3){ //ce je klasicna ali dvojna tabela
+ if(count($missingOdgovori)!=0){ //ce so missing-i
+ if($enota==0){ //ce je klasicna tabela
+ $vodoravniOdgovori = $this->AddMissingsToAnswers($vodoravniOdgovori, $missingOdgovori);
+ }elseif($enota==3){ //ce je dvojna tabela
+ for($m=0;$m<count($missingOdgovori);$m++){
+ $start = $spremenljivke['grids']+($spremenljivke['grids']+1)*$m;
+ array_splice($vodoravniOdgovori,$start,0,$missingOdgovori[$m]); //v trenutno polje z vodoravnimi odgovori dodaj na dolocenem mestu se missinge
+ }
+ }
+ }
+/* for($m=0;$m<count($vodoravniOdgovori);$m++){
+ echo $vodoravniOdgovori[$m].'</br>';
+ } */
+ }
+ //ureditev missing-ov za tabela da/ne, klasicna ali dvojna tabela - konec #####################
+
+ #prva vrstica tabele ####################################################################################
+ $tabela .= $this->LatexPrvaVrsticaMultiGrid($steviloStolpcev, $enota, $trak, $customColumnLabelOption, $spremenljivke, $vodoravniOdgovori, $missingOdgovori);
+ #prva vrstica tabele - konec ##################################################################################
+
+ if($enota!=2 && $enota!=6){ //ce ni roleta in izberite s seznama in ena moznost proti drugi
+ $tabela .= $texNewLine; //skok v drugo vrstico, kjer se zacnejo navpicni odgovori
+ }
+
+ //echo "koda za tabelo: ".$tabela."</br>";
+ //preureditev stevila stolpcev za pravilen izris####################################
+
+ if($enota == 1){ //ce je diferencial tabela
+ if($trak == 0){ //ce ni na traku
+ $steviloStolpcev = $steviloStolpcev - 1 + count($missingOdgovori);
+ }else{ //ce je na traku
+ $steviloStolpcev = $steviloStolpcev - count($missingOdgovori);
+ }
+ }
+
+ if($enota == 0 && $trak == 1 && $spremenljivke['tip'] == 6){ //ce je klasicna tabela na traku in je tabela en odgovor
+ $steviloStolpcev = $steviloStolpcev + 1; // +1, ker se ob izrisu zacne z indeksom 1
+ }
+
+ if(($enota == 0) && count($missingOdgovori)!=0){ //ce je klasicna tabela in so missingi
+ //$steviloStolpcev = $steviloStolpcev + count($missingOdgovori);
+ }
+
+ //echo $steviloStolpcev.'</br>';
+ //echo $spremenljivke['grids'].'</br>';
+
+ //preureditev stevila stolpcev za pravilen izris - konec ############################
+
+ //ureditev missing-ov za roleta in izberite iz seznama ##############################
+ if($enota == 2 || $enota == 6){ //roleta ali izberite s seznama
+ if(count($missingOdgovori)!=0){ //ce so missing-i
+ $vodoravniOdgovori = $this->AddMissingsToAnswers($vodoravniOdgovori, $missingOdgovori);
+ }
+ }
+ //ureditev missing-ov za roleta in izberite iz seznama - konec ######################
+
+ #izris vrstic tabele
+ $trakStartingNumberTmp = null;
+ //$tabela .= $this->LatexVrsticeMultigrid($steviloVrstic, $typeOfDocument, $enota, $simbolTex, $navpicniOdgovori, $trakStartingNumberTmp, $fillablePdf, $steviloStolpcev, $spremenljivke, $trak, $vodoravniOdgovori, $texNewLine, $navpicniOdgovori2, $missingOdgovori, 0, 0, 0, $data, $export_subtype);
+ $tabela .= $this->LatexVrsticeMultigrid($steviloVrstic, $typeOfDocument, $enota, $simbolTex, $navpicniOdgovori, $trakStartingNumberTmp, $fillablePdf, $steviloStolpcev, $spremenljivke, $trak, $vodoravniOdgovori, $texNewLine, $navpicniOdgovori2, $missingOdgovori, 0, 0, 0, $data, $export_subtype, $this->preveriSpremenljivko, $this->userDataPresent);
+ #izris vrstic tabele - konec
+/* if($enota==12||$enota==11){
+ echo "tabela tex: ".$tabela."</br>";
+ } */
+ $tabela .= $this->EndLatexTable($typeOfDocument, 'tabularx', 'tabular'); //zakljucek tabele
+ //$tabela .= $texNewLineAfterTable;
+ #KONEC MAIN TABELE #########################################################################
+ }
+
+ //prostor po izpisu tabele
+ $tabela .= $this->texBigSkip;
+ $tabela .= $this->texBigSkip;
+
+
+ //izpis tabela - konec
+ return $tabela;
+ }
+ #funkcija, ki skrbi za izris Grida radio buttonov ali checkboxov - konec ################################
+
+ #funkcija, ki skrbi za izris Grida drsnikov ################################
+ function IzrisGridDrsnikov($spremenljivke=null, $navpicniOdgovori=null, $export_format='', $export_subtype='', $missingOdgovori=null, $userAnswer=null){
+ global $lang;
+ $tex = '';
+ #############################################################################################################
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ #nastavitve iz baze za drsnik ##################################################################
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0); //0-je rocaj, 1-ni rocaja
+
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0); //Prikaži labele za Min in Max: 0-prikazi, 1-skrij
+
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0); //ali sta prisotni labeli nad drsnikom oz. nad min in max vrednostjo
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : $lang['srv_new_text']); //labela na minumumu
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : $lang['srv_new_text']); //labela na maksimumu
+
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0); //ali naj drsnika prikazuje stevilske labele med maksimumom in minimumom na spodnji strani drsnika
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0); //ali naj drsnika prikazuje opisne labele med maksimumom in minimumom na spodnji strani drsnika
+
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0); //ali imamo vmesen crtice na drsniku, za izris izvoza se bo to ignoriralo
+
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1); //korak drsnika
+
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+
+ //vnesena minimum pa maksimum drsnika
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5); //stevilo opisnih label
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0); //besedilo/string z naslovi opisnih vmesnih label
+
+ //spremenljivke za labele podrocij
+ $slider_labele_podrocij = ($spremenljivkaParams->get('slider_labele_podrocij') ? $spremenljivkaParams->get('slider_labele_podrocij') : 0); //za checkbox
+ $slider_StevLabelPodrocij = ($spremenljivkaParams->get('slider_StevLabelPodrocij') ? $spremenljivkaParams->get('slider_StevLabelPodrocij') : 3);
+ //$slider_table_td_width = 100 / $slider_StevLabelPodrocij; //spremenljivka za razporeditev sirine sliderja po podrocjih
+ //spremenljivke za labele podrocij - konec
+ #nastavitve iz baze za drsnik - konec ##################################################################
+
+ //pridobitev naslovov opisnih vmesnih label za kasnejsi izris ##########################################
+ if($slider_VmesneDescrLabel){ //ce je potrebno izrisati vmesne opisne labele pod drsnikom
+ $descriptiveLabels = [];
+ if($slider_DescriptiveLabel_defaults!=0){ //ce so prednalozene opisne labele
+ $descriptiveLabels = explode(';',$slider_DescriptiveLabel_defaults_naslov1);
+ }else{ //ce so custom opisne labele
+ $slider_CustomDescriptiveLabels = '';
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ $descriptiveLabels = explode(';', $slider_CustomDescriptiveLabels);
+ }
+ }
+ //pridobitev naslovov opisnih vmesnih label za kasnejsi izris - konec ##################################
+
+
+ #IZRIS ODGOVORA IN DRSNIKA V GRID ############################################################################################
+
+ foreach($navpicniOdgovori AS $key => $navpicniOdgovor){ //za vsak odgovor v vrstici
+
+ ################# izpis s samo eno tabelo, saj zaradi ltablex, to ni vec mozno
+ //ureditev parametrov za tabelo
+ $steviloStolpcevPrvaVrstica = $steviloStolpcevPrvaVrsticaOrig = ceil(($slider_MaxNumLabel-$slider_MinNumLabel+1)/$slider_handle_step);//zaokrozi navzgor izracun stevila stolpcev prve vrstice
+
+ //zaradi tezav pri izrisu vmesnih stevilk, ce je teh vec kot 21 (MAXSTEVILOSTOLPCEV), je potrebno programsko omejiti stevilo stolpcev prve vrstice
+ if($steviloStolpcevPrvaVrstica>MAXSTEVILOSTOLPCEV){
+ $steviloStolpcevPrvaVrstica = MAXSTEVILOSTOLPCEV;
+ }
+
+ $parameterTabularLabelePrvaPod='';
+ if($slider_VmesneDescrLabel){ //ce je potrebno izrisati vmesne opisne labele
+ $steviloStolpcevPrvaVrstica = $slider_NumofDescrLabels;
+ }
+
+ //dodamo se en stolpec za prvi stolpec
+ //$steviloStolpcevPrvaVrstica = $steviloStolpcevPrvaVrstica + 1;
+ $steviloStolpcevPrvaVrstica = $steviloStolpcevPrvaVrstica + 1 + 1;
+
+ for($i=0; $i<$steviloStolpcevPrvaVrstica; $i++){
+ if($i==0){ //ce je prvi stolpec
+ //$parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca prilagojena sirini
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'A' : 'l'); //leva poravnava stolpca dolocen sirine
+ }elseif($i==1){ //ce je drugi stolpec
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca prilagojena sirini
+ }elseif($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'R' : 'l'); //desna prilagojena poravnava stolpca
+ }else{ //za vse ostale stolpce med tretjim in zadnjim
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava
+ }
+ }
+ //ureditev parametrov za tabelo - konec
+ //echo "parameterTabularLabelePrvaPod: ".$parameterTabularLabelePrvaPod."</br>";
+
+ //zacetek tabele
+ $tex .= ($export_format == 'pdf' ? '{ \begin{tabularx}{1\textwidth}{'.$parameterTabularLabelePrvaPod.'}' : '\begin{tabular}{'.$parameterTabularLabelePrvaPod.'}');
+
+ //prva vrstica, ce so opisne labele
+ #IZRIS OPISNIH LABEL NAD DRSNIKOM #################################################
+ if($slider_MinMaxLabel){
+
+ #Ureditev preklopa barve vrstice \rowcolor[gray]{.9}
+ if($key%2 == 0 && $export_format == 'pdf'){
+ $tex .= ' \rowcolor[gray]{.9} ';
+ }
+ #Ureditev preklopa barve vrstice - konec
+
+ //prvi prazen stolpec
+ $tex .= ' & ';
+
+ //labela na levi strani
+ $tex .= $this->encodeText($MinLabel);
+
+ //vmesni prazni stolpci
+ $steviloPraznihStolpcev = $steviloStolpcevPrvaVrstica - 2 + 1;
+ for($p=0; $p<$steviloPraznihStolpcev; $p++){
+ if($p==$steviloPraznihStolpcev-2){ //ce je pred-zadnji stolpec
+ $tex .= '\multicolumn{2}{c}{'.$this->encodeText($MaxLabel).'}'; //labela na desni v zadnji dveh desnih stolpcih
+ }elseif($p==$steviloPraznihStolpcev-1){ //ce je zadnji stolpec
+
+ }else{ //drugace
+ $tex .= ' & ';
+ }
+
+ }
+
+ //labela na desni strani
+ //$tex .= $this->encodeText($MaxLabel);
+
+ //v novo vrstico po izrisu opisnih label
+ $tex .= $this->texNewLine;
+ }
+ #IZRIS OPISNIH LABEL NAD DRSNIKOM - KONEC #########################################
+ //prva vrstica, ce so opisne labele - konec
+
+ //druga vrstica, ce so opisne labele
+ #Ureditev preklopa barve vrstice \rowcolor[gray]{.9}
+ if($key%2 == 0 && $export_format == 'pdf'){
+ $tex .= ' \rowcolor[gray]{.9} ';
+ }
+ #Ureditev preklopa barve vrstice - konec
+
+ #IZRIS MOZNIH ODGOVOROV
+ $tex .= $navpicniOdgovor;
+ #IZRIS MOZNIH ODGOVOROV - KONEC
+
+ $tex .= ' & ';
+ //echo $userAnswer[$key]."</br>";
+ if($export_format == 'pdf'){ //ce je pdf, pokazi drsnike tudi graficno
+ #IZRIS DRSNIKA {dolzina}{pozicija bunkice}####################################
+ $steviloStolpcevZaSlider = $steviloStolpcevPrvaVrstica - 1;
+ if($slider_handle==0){ //ce je rocaj na drsniku
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ $pozicijaBunkice = $userAnswer[$key]/$slider_MaxNumLabel;
+ }elseif($export_subtype=='q_empty'||$export_subtype=='q_comment'){
+ $pozicijaBunkice=0.5;
+ }
+ $tex .= '\multicolumn{'.$steviloStolpcevZaSlider.'}{c}{ \circleSLIDER{0.7\textwidth}{'.$pozicijaBunkice.'}}'; //drsnik z rocajem
+ }else{ //drugace, ce ni rocaja
+ $tex .= '\multicolumn{'.$steviloStolpcevZaSlider.'}{c}{ \emptySLIDER{0.7\textwidth} }'; //drsnik brez rocaja
+ }
+ $tex .= $this->texNewLine; //v novo vrstico po izrisu drsnika
+ #IZRIS DRSNIKA {dolzina}{pozicija bunkice} - KONEC ###########################
+ //druga vrstica, ce so opisne labele - konec
+
+ //tretja vrstica
+ #IZRIS PRVE VRSTICE POD DRSNIKOM ##############################################
+ #Ureditev preklopa barve vrstice \rowcolor[gray]{.9}
+ if($key%2 == 0 && $export_format == 'pdf'){
+ $tex .= ' \rowcolor[gray]{.9} ';
+ }
+ #Ureditev preklopa barve vrstice - konec
+
+ //za prazen prvi stolpec
+ if($userAnswer[$key]){ //ce je prisoten odgovor
+ $tex .= $lang['srv_analiza_frekvence_titleAnswer'].': \\textcolor{crta}{'.$userAnswer[$key].'} ';
+ }
+ $tex .= ' & ';
+
+ //izris vrstice in stolpcev v tabeli
+ $steviloStolpcevPrvaVrstica = $steviloStolpcevPrvaVrstica - 1;
+ for($i=0; $i<$steviloStolpcevPrvaVrstica; $i++){
+ if($slider_VmesneDescrLabel){//ce je potrebno izrisati vmesne opisne labele ###################
+ if($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+ $tex .= $descriptiveLabels[$i];
+ }else{
+ $tex .= $descriptiveLabels[$i].' & ';
+ }
+ }else{//ce je potrebno izrisati vmesne stevilske labele #######################################
+ if($i==0){ //ce je prvi stolpec
+ if($slider_MinMaxNumLabelNew==0){
+ $tex .= $slider_MinNumLabel.' & ';
+ }else{
+ $tex .= ' & ';
+ }
+ }//elseif($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+ elseif($i==$steviloStolpcevPrvaVrstica-2){ //ce je pred-zadnji stolpec
+ if($slider_MinMaxNumLabelNew==0){
+ //$tex .= $slider_MaxNumLabel;
+ $tex .= '\multicolumn{2}{c}{'.$slider_MaxNumLabel.'}';
+ }
+ }elseif($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+
+ }else{ //za vse ostale stolpce med prvi in zadnjim
+ if($slider_VmesneNumLabel&&$steviloStolpcevPrvaVrsticaOrig<=MAXSTEVILOSTOLPCEV){ //ce so vmesne labele stevilske in je stevilo stolpcev manjsi od maximalnega dovoljenega za ustrezen izris
+ $vmesnoStevilo = null;
+ if($i==1){
+ $vmesnoStevilo=$slider_MinNumLabel+$slider_handle_step;
+ }else{
+ $vmesnoStevilo=$vmesnoStevilo+$slider_handle_step;
+ }
+ }else{
+ $vmesnoStevilo='';
+ }
+ $tex .= $vmesnoStevilo.' & ';
+ }
+ }
+ }
+ //izris vrstice in stolpcev v tabeli - konec
+
+ $tex .= $this->texNewLine; //v novo vrstico po izrisu prve vrstice pod drsnikom
+ #IZRIS PRVE VRSTICE POD DRSNIKOM - KONEC ######################################
+ //tretja vrstica - konec
+
+ }else{ //ce je rtf, napisi le, da je drsnik na tem mestu in stevilko odgovora, ce je izpis podatkov
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ //$tex .= $lang['srv_number_insert_1'].": ".$userAnswer[$key];
+ $tex .= $userAnswer[$key];
+ }elseif($export_subtype=='q_empty'||$export_subtype=='q_comment'){
+ $tex .= $lang['srv_number_insert_1'];
+ }
+ }
+
+ //konec tabele
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx} }" : "\\end{tabular} \\noindent");
+ //echo $tex;
+ ################# izpis s samo eno tabelo, saj zaradi ltablex, to ni vec mozno - konec
+
+ #Konec tabele za izris odgovora in drsnika - konec #################################################################################
+
+ } //konec foreach
+ #IZRIS ODGOVORA IN DRSNIKA V GRID - KONEC ############################################################################################
+
+ #ZA ENKRAT TEGA NE POTREBUJEMO, SAJ V GRIDU TEGA TRENUTNO NI
+ /* #IZRIS DRUGE VRSTICE POD DRSNIKOM - LABELE PODROCIJ ###########################
+ if($slider_labele_podrocij){ //ce imamo vklopljene labele podrocij
+ $tex .= $texNewLine;
+ //ureditev parametrov za tabeli
+ $parameterTabularLabeleDrugaPod='';
+ $prazniStolpciZaGraficneOznake = '';
+ for($i=0; $i<$slider_StevLabelPodrocij; $i++){
+ $parameterTabularLabeleDrugaPod .= ($export_format == 'pdf' ? '|C|' : '|c|'); //sredinska poravnava
+ $parameterTabularLabeleTretjaPod .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava
+ if($i!=0){
+ $prazniStolpciZaGraficneOznake .= ' & ';
+ }
+ }
+ $prazniStolpciZaGraficneOznake .= $texNewLine.'\hline';
+ //ureditev parametrov za tabeli - konec
+
+ //zacetek tabele z graficnimi oznakami
+ $tex .= ($export_format == 'pdf' ? '\begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabeleDrugaPod.'}' : '\begin{tabular}{'.parameterTabularLabeleDrugaPod.'}');
+
+ //izris prazne vrstice z graficnimi oznakami label (crta horizontal)
+ $tex .= $prazniStolpciZaGraficneOznake;
+ //izris prazne vrstice z graficnimi oznakami label (crta horizontal) - konec
+
+ //konec tabele z graficnimi oznakami
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular} \\noindent");
+
+ $tex .= $texNewLine;
+
+ //zacetek tabele z naslovi label
+ $tex .= ($export_format == 'pdf' ? '\begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabeleTretjaPod.'}' : '\begin{tabular}{'.parameterTabularLabeleTretjaPod.'}');
+
+ //izris naslovov label
+ $slider_Labela_podrocja = []; //polje, ki hrani vpisane naslove labele podrocij
+ for ($i = 1; $i <= $slider_StevLabelPodrocij; $i++) { //priprava polja z naslovi
+ $slider_Labela_podrocja[$i] = ($spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') ? $spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') : $lang['srv_new_text']);
+
+ if($i==1){ //ce je prvi stolpec
+ $tex .= $slider_Labela_podrocja[$i];
+ }else{
+ $tex .= ' & '.$slider_Labela_podrocja[$i];
+ }
+
+ }
+ //izris naslovov label - konec
+
+ //konec tabele z naslovi label
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular} \\noindent");
+ }
+ #IZRIS DRUGE VRSTICE POD DRSNIKOM - LABELE PODROCIJ ########################### */
+ #ZA ENKRAT TEGA NE POTREBUJEMO, SAJ V GRIDU TEGA TRENUTNO NI ##################
+
+ #############################################################################################################
+
+ //se ena tabela, da naredimo dovolj prostora na koncu vprasanja
+ $tex .= ($export_format == 'pdf' ? '\begin{tabularx}{0.9\textwidth}{X}' : '');
+ $tex .= $this->texNewLine;
+ $tex .= ($export_format == 'pdf' ? '\end{tabularx}' : '');
+
+ return $tex;
+ }
+ #funkcija, ki skrbi za izris Grida drsnikov - konec ################################
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/NagovorLatex.php b/admin/survey/export/latexclasses/Vprasanja/NagovorLatex.php
new file mode 100644
index 0000000..23ffe0e
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/NagovorLatex.php
@@ -0,0 +1,73 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za nagovor
+ *
+ * Vprašanje je prisotno:
+ * tip 5
+ *
+ * Autor: Patrik Pucer
+ * Datum: 09/2017
+ *****************************************/
+
+ define("NAGOVOR_LINE_WIDTH", 0.5);
+
+class NagovorLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+ protected $texBigSkip = '\bigskip';
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new NagovorLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $export_subtype='', $preveriSpremenljivko=null, $loop_id=null){
+
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //preveri, ce je kaj v bazi
+ //$userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id);
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+
+ //if($userDataPresent||$export_subtype=='q_empty'){ //ce je kaj v bazi ali je prazen vprasalnik
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ $nagovorLine = ($spremenljivkaParams->get('nagovorLine') ? $spremenljivkaParams->get('nagovorLine') : 0); //0-Privzeto, 1-Ne, 2-Da
+
+ if($nagovorLine!=1){ //CE NI NE
+ $tex .= '\rule{\textwidth}{'.NAGOVOR_LINE_WIDTH.'pt}'; //narisi crto pod tekstom
+ }
+
+/* $tex .= $texNewLine;
+ $tex .= $texNewLine; */
+ $tex .= $this->texBigSkip;
+
+ if($export_format == 'pdf'){ //ce je pdf
+ $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+
+ return $tex;
+ }
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/RadioCheckboxSelectLatex.php b/admin/survey/export/latexclasses/Vprasanja/RadioCheckboxSelectLatex.php
new file mode 100644
index 0000000..51b5ddb
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/RadioCheckboxSelectLatex.php
@@ -0,0 +1,488 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za radio, checkbox, select
+ *
+ * Vprašanje je prisotno:
+ * tip 1, 2, 3 z vsemi orientacijami
+ *
+ * Autor: Patrik Pucer
+ * Datum: 06-07/2017
+ *****************************************/
+
+//namespace Export\Latexclasses\Vprasanja;
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+
+class RadioCheckboxSelectLatex extends LatexSurveyElement
+{
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $texBigSkip = ' \bigskip ';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+ protected $path2ImagesRadio;
+ protected $language;
+ protected $prevod;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new RadioCheckboxSelectLatex();
+ }
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $preveriSpremenljivko=null, $export_data_type=null, $export_subtype=null, $loop_id=null, $language=null){
+ global $lang, $site_path;
+
+ $this->language = $language;
+ $this->path2ImagesRadio = $site_path.'uploadi/editor/';
+
+ //preverjanje, ali je prevod
+ if(isset($_GET['language'])){
+ $this->language = $_GET['language'];
+ $this->prevod = 1;
+ }else{
+ $this->prevod = 0;
+ }
+ //preverjanje, ali je prevod - konec
+
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //echo "exportData za user: ".$usr_id." in language ".$language."</br>";
+ //echo "__________________________________</br>";
+
+ $texBigSkip = ' \bigskip ';
+ $userAnswerData = array(); //belezi podatke respondenta
+ $textRArray = array(); //belezi odgovore respondenta, ki se nahajajo v desnem delu vprasanja
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ //echo "SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red";
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+ $tex = '';
+ $oznakaOdgovora = 'a';
+ $indeksZaWhile = 1;
+ $indeksOdgovorov = 0;
+ $oznakaVprasanja = $this->UrediOznakoVprasanja($spremenljivke['id']); //uredi oznako vprasanja, ker ne sme biti stevilska
+ $prviOdgovorSlikovniTip = 0;
+
+ if ($usr_id){
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id); //zgenerira podatke z odgovori respondenta v $this->userAnswer, zabelezi, ce so podatki prisotni
+ }
+
+ //echo "test: ".$userDataPresent."</br>";
+
+ #izpis izvoza kratek ali zelo kratek ###############################################################################
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izvoz odgovorov respondenta/respodentov
+ //if(($userDataPresent!=0||$preveriSpremenljivko)&&($export_data_type==0||$export_data_type==2)){ //ce (so podatki prisotni ali je potrebno pokazati tudi ne odgovorjena vprasanja) in (je tip izvoza kratek ali zelo kratek)
+ if($userDataPresent!=0||$preveriSpremenljivko){ //ce (so podatki prisotni ali je potrebno pokazati tudi ne odgovorjena vprasanja)
+ $prviOdgovorSlikovniTip = 1;
+ if($export_data_type==0||$export_data_type==2){ //ce je tip izvoza kratek ali zelo kratek
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ if( isset($this->userAnswer[$rowVrednost['id']]) ){ //ce je podatek prisoten
+
+ #ce je respondent odgovarjal v drugem jeziku ########################
+ $rowl = $this->srv_language_vrednost($rowVrednost['id']);
+ if (strip_tags($rowl['naslov']) != '') $rowVrednost['naslov'] = $rowl['naslov'];
+ if (strip_tags($rowl['naslov2']) != '') $rowVrednost['naslov2'] = $rowl['naslov2'];
+ #ce je respondent odgovarjal v drugem jeziku - konec ################
+
+ $stringTitle = ( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] );
+ $stringTitle = Common::getInstance()->dataPiping($stringTitle, $usr_id, $loop_id);
+ $stringTitle = '\\textcolor{crta}{'.$this->encodeText($stringTitle).'}';
+
+ //echo $stringTitle."za indeks: ".$indeksZaWhile."</br>";
+ //stetje stevila vrstic
+ //$stetje_vrstic = $this->pdf->getNumLines($stringTitle, 180*$expand_width);
+ // še dodamo textbox če je polj other
+ $_txt = '';
+ if ( $rowVrednost['other'] == 1 && $usr_id ){
+ //$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
+ $sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id=".$usr_id);
+ $row4 = mysqli_fetch_assoc($sqlOtherText);
+ $_txt = ' \\textcolor{crta}{'.$row4['text'].'}';
+ }
+ //$tex .= ' '.$stringTitle.$_txt.',';
+ if($indeksZaWhile==1){
+ //$tex .= ' '.$stringTitle.$_txt.' ';
+ $tex .= $stringTitle.$_txt;
+ }else{
+ //$tex .= ', '.$stringTitle.$_txt;
+ $tex .= ', \\\\'.$stringTitle.$_txt;
+ }
+ $indeksZaWhile++;
+ }
+
+ $indeksOdgovorov++;
+ }
+ //echo "končni tex: ".$tex."</br>";
+ }
+ }
+ }
+ #izpis izvoza kratek ali zelo kratek - konec ###########################################################################
+
+
+ #izpis praznega vprasalnika ali dolgega izvoza (vprasalnika z odgovori respondenta) ##################################################
+ if($export_subtype=='q_empty'||$export_data_type==1||$export_subtype=='q_comment'){ //ce je izpis praznega vprasalnika ali dolgega izvoza
+ /* echo "orientacija: ".$spremenljivke['orientation']."</br>";
+ echo "tip: ".$spremenljivke['tip']."</br>"; */
+ if($spremenljivke['orientation']==5){ //ce je postavitev Potrditev
+ if($export_format == 'pdf'){ //ce je pdf
+ $tex .= $this->texBigSkip;
+ $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+ //if($spremenljivke['orientation']==0 || $spremenljivke['orientation']==2){ //ce sta vodoravni orientaciji
+ //$tex .= $texNewLine; //dodaj na koncu vprasanja prazno vrstico
+ $tex .= $this->texBigSkip;
+ //}
+ }
+ //echo "tukaj";
+ return $tex;
+ }
+
+ #za ureditev preloma odgovorov, ce so odgovori ob vprasanju - najprej je potrebno zabeleziti dolzino besedila vprasanja
+ if($spremenljivke['orientation']==0 && $export_format == 'pdf'){ //vodoravno ob vprasanju, ce je pdf
+ $tex .= '\settowidth{\questionLength}{'.$this->encodeText($questionText).'}'; //v definirano dolzino shranimo trenutno dolzino teksta vprasanja
+ $tex .= '\addtolength{\questionTotalLength}{\questionLength}'; //celotni dolzini dodamo dolzino vprasanja
+
+ //ce je opomba prisotna, daj spremenljivko na 2
+ if($spremenljivke['info'] != ''){
+ $tex .= '\setcounter{opomba}{2}';
+ }else{
+ $tex .= '\setcounter{opomba}{0}';
+ }
+ }
+ #za ureditev preloma odgovorov, ce so odgovori ob vprasanju - konec
+
+ if($spremenljivke['orientation']==7){ //navpicno - tekst levo
+ //$tex .= '\begin{tabular}{l l}'.$texNewLine;
+ if($export_format == 'pdf'){
+ $tex .= '\begin{tabularx}{.5\textwidth}{l l}';
+ }else{
+ $tex .= '\begin{tabular}{l l}'.$texNewLine; //za omogociti izris odgovorov v tabeli
+ }
+ }elseif($spremenljivke['orientation']==8){ //ce je "povleci-spusti"
+ $tex .= '\setlength{\parindent}{0.1\textwidth} ';
+ //prva vrstica pred tabelo z odgovori
+ if($export_format == 'pdf'){ //ce je pdf
+ $tex .= '\begin{tabular}{l c l} '; //izris z vecstolpicno tabelo
+ //$tex .= '\begin{tabularx}{.5\textwidth}{l c l} '; //izris z vecstolpicno tabelo
+ $tex .= $lang['srv_ranking_available_categories'].': & \hspace{0.1\textwidth} & '.$lang['srv_drag_drop_answers'].': '.$texNewLine;
+ $tex .= '\rule{0.4\textwidth}{0.4 pt} & & \rule{0.4\textwidth}{0.4 pt} \end{tabular} '.$texBigSkip;
+ $tex .= $texNewLine;
+ }else{ //ce je rtf
+ $tex .= '\begin{tabular}{l} '; //izris z enostolpicno tabelo
+ $tex .= $lang['srv_ranking_available_categories'].': '.$texNewLine; //Rapolozljive kategorije
+ //$tex .= '\hline \end{tabular} '.$texBigSkip;
+ $tex .= '\hline \end{tabular} ';
+ }
+ //prva vrstica pred tabelo z odgovori - konec
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\begin{tabular}{c c c} '; //izris s tabelo
+ $tex .= '\begin{tabularx}{.5\textwidth}{c c c} '; //izris s tabelo
+ }
+
+ }elseif($spremenljivke['orientation']==10){ //image hot-spot
+
+ $imageName = $this->getImageName('hotspot', $spremenljivke['id'], 'hotspot_image=');
+ $imageNameTest = $this->path2ImagesRadio.$imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku
+ //error_log("za image hot spot ne grid: ".$imageNameTest);
+ //echo("za image hot spot ne grid: ".$imageNameTest."</br>");
+ if(filesize($imageNameTest) > 0){
+ $image = PIC_SIZE."{".$this->path2ImagesRadio."".$imageName."}"; //priprave slike predefinirane dimenzije
+ }else{
+ //$image = 'ni slike';
+ $image = $lang['srv_pc_unavailable'];
+ }
+
+ $tex .= $image."".$texNewLine; //izris slike
+
+ //iz baze poberi imena obmocij
+ $sqlHotSpotRegions = sisplet_query("SELECT region_name FROM srv_hotspot_regions WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+
+ //izris imen obmocij po $sqlHotSpotRegions
+ $tex .= $lang['srv_export_hotspot_regions_names'].': '.$texNewLine; //besedilo "Obmocja na sliki"
+ while ($rowHotSpotRegions = mysqli_fetch_assoc($sqlHotSpotRegions))
+ {
+ $tex .= $rowHotSpotRegions['region_name'].''.$texNewLine;
+ }
+
+ if($export_data_type==1){ //ce je dolg izvoz, pokazi katera obmocja so bila izbrana
+ $tex .= $texNewLine.$lang['srv_export_hotspot_chosen_regions_names'].': '.$texNewLine; //besedilo "Izbrana obmocja na sliki"
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ if( isset($this->userAnswer[$rowVrednost['id']]) ){ //ce je podatek prisoten
+ $stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
+ // še dodamo textbox če je polj other
+ $_txt = '';
+ if ( $rowVrednost['other'] == 1 && $usr_id ){
+ //$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
+ $sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id=".$usr_id);
+ $row4 = mysqli_fetch_assoc($sqlOtherText);
+ $_txt = ' '.$row4['text'];
+ }
+ $tex .= $stringTitle.$_txt.$texNewLine;
+ }
+ }
+ }
+ }elseif($spremenljivke['orientation']==9 || $spremenljivke['orientation']==11){ //ce je "slikovni tip" ali VAS
+ if($spremenljivke['orientation']==11){ //ce je VAS
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ $vizualnaSkalaNumber = $spremenljivkaParams->get('vizualnaSkalaNumber');
+ $numRowsSql = $vizualnaSkalaNumber;
+ }
+
+ //echo "stevilo zadev: ".$numRowsSql."</br>";
+ if($spremenljivke['orientation']==9){
+ $mejaVAS = 20;
+ }elseif($spremenljivke['orientation']==11){
+ $mejaVAS = 8;
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+ }
+ //if($numRowsSql<20){ //ce je manj kot x slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ if($numRowsSql<$mejaVAS){ //ce je manj kot x slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ $tableParamsSlikovniTip = '';
+ for($i=0; $i<$numRowsSql;$i++){
+ $tableParamsSlikovniTip .= ' c ';
+ }
+ $tex .= '\begin{tabular}{'.$tableParamsSlikovniTip.'} '; //izris s tabelo
+ }
+ //echo "parametri tabele: ".$tableParamsSlikovniTip."</br>";
+ }
+
+ if($spremenljivke['orientation']!=10){ //ce ni image hot-spot
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $prop['full'] = ( isset($userAnswer[$rowVrednost['id']]) );
+
+ if($this->prevod){ //ce je prevod ankete
+ $rowl = $this->srv_language_vrednost($rowVrednost['id']); //pridobi prevod naslova v ustreznem jeziku
+ $stringTitle = ((( $rowl['naslov'] ) ? $rowl['naslov'] : ( ( $rowl['naslov2'] ) ? $rowl['naslov2'] : $rowl['variable'] ) )); //prevod naslova v ustreznem jeziku
+ }else{
+ $stringTitle = ((( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
+ }
+
+ $stringTitle = Common::getInstance()->dataPiping($stringTitle, $usr_id, $loop_id);
+
+ //echo "naslov: $stringTitle</br>";
+ //echo "jezik: ".$this->language."</br>";
+ if ( $spremenljivke['tip'] == 1 || $spremenljivke['tip'] == 3 ){
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, $this->userAnswer[$rowVrednost['id']], $spremenljivke['orientation'], $indeksZaWhile, $vizualnaSkalaNumber);
+ //$tex .= '{\ChoiceMenu[radio,radiosymbol=\ding{108},name=myGroupOfRadiobuttons]{}{='.$stringTitle.'}}'.$stringTitle.' '.$this->texNewLine;
+ $internalCellHeight = '0.3 cm'; //visina praznega okvirja @povleci-spusti
+ }else if ( $spremenljivke['tip'] == 2 ){
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, $this->userAnswer[$rowVrednost['id']]);
+ $internalCellHeight = '3 cm'; //visina praznega okvirja @povleci-spusti
+ }
+
+ if($spremenljivke['orientation']==1&&$spremenljivke['tip'] != 3){ //navpicno
+ $tex .= $symbol.' '.$this->encodeText($stringTitle, $rowVrednost['id']).' '.$texNewLine;
+ //$test = $symbol.' '.$this->encodeText($stringTitle, $rowVrednost['id']).' '.$texNewLine;
+ //echo "tukaj! $test </br>";
+ }elseif($spremenljivke['orientation']==7){ //navpicno - tekst levo
+ $text = $this->encodeText($stringTitle, $rowVrednost['id']).' & '.$symbol.' '.$texNewLine;
+ $textLength = strlen($text);
+ if($textLength > MAX_STRING_LENGTH){
+ $tex .= '\vspace{2 mm}';
+ $tex .= '\parbox{'.LINE_BREAK_AT.'}{'.$this->encodeText($stringTitle, $rowVrednost['id']).'} & '.$symbol.' '.$texNewLine; //tekst odgovora razbij pri LINE_BREAK_AT (5 cm) in zraven dodaj ustrezni simbol
+ }else{
+ $tex .= $text;
+ }
+ }elseif($spremenljivke['orientation']==0){ //vodoravno ob vprasanju
+ $tex .= ' '.$symbol.' '.$this->encodeText($stringTitle, $rowVrednost['id']).' ';
+ }elseif($spremenljivke['orientation']==2){ //vodoravno pod vprasanjem
+ $tex .= ' '.$symbol.' '.$this->encodeText($stringTitle, $rowVrednost['id']).' ';
+ }elseif(($spremenljivke['tip'] == 3&&$spremenljivke['orientation']==1)||$spremenljivke['orientation']==6){ //roleta ali izberite s seznama
+ if($export_data_type==1&&isset($this->userAnswer[$rowVrednost['id']])){ //ce je dolg izvoz in je podatek za odgovor
+ $tex .= ' \textbf{'.$this->encodeText($stringTitle, $rowVrednost['id']).'} '.$texNewLine;
+ }else{
+ $tex .= $this->encodeText($stringTitle, $rowVrednost['id']).' '.$texNewLine;
+ }
+ }elseif($spremenljivke['orientation']==8){ //povleci-spusti
+
+ if(isset($this->userAnswer[$rowVrednost['id']])){
+ $textR = $this->encodeText($stringTitle, $rowVrednost['id']);
+ $textRArray[$indeksZaWhile] = $textR; //rabimo kasneje, za izpis rtf desne strani vprasanja, ce izpisujemo odgovore respondenta
+ $textL = '';
+ }else{
+ $textL = $this->encodeText($stringTitle, $rowVrednost['id']);
+ $textR = '';
+ }
+
+ if($export_format == 'pdf'){ //ce je pdf
+
+ if($textL){
+ $tex .= '\indent \fbox{\parbox{0.2\textwidth}{ \centering '.$textL.' }} & \hspace{0.2\textwidth} '; //prva dva stolpca
+ }else{
+ $tex .= '\indent \hspace{0.2\textwidth} ';
+ }
+
+ if($indeksZaWhile == 1&&($export_subtype=='q_empty')){
+ $tex .= '& \hspace{1.2 cm} \multirow{'.$numRowsSql.'}{*}{\fbox{\parbox[t]['.$internalCellHeight.']{0.2\textwidth}{ \hphantom{\hspace{0.2\textwidth}}} } } '; //v prvi vrstici izrisi prazen okvir, ki se razpotegne skozi vse vrstice
+ }elseif($export_subtype=='q_empty'){
+ $tex .= '& '; //izrisi potrebno praznino za multirow okvir iz prve vrstice
+ }else{
+ if($textR){
+ $tex .= ' & \hspace{0.3\textwidth} & \fbox{\parbox{0.2\textwidth}{ \centering '.$textR.' }} '; //izpisi okvir z odgovorom, ce je ta prisoten
+ }else{
+ $tex .= '& '; //izpisi neviden okvir
+ }
+ }
+ $tex .= $texBigSkip;
+ $tex .= $texNewLine;
+ }else{ //ce je rtf, uredi izvoz leve strani vprasanja
+ if((!isset($this->userAnswer[$rowVrednost['id']])&&$export_data_type==1)||$export_subtype=='q_empty'){ //ce je podatek in je dolg izvoz ali je izvoz praznega vprasalnika
+ $tex .= '\begin{tabular}{c} '; //izris s tabelo brez obrob
+ //$tex .= '\begin{tabular}{|c|} \hline'; //izris s tabelo z obrobama levo desno in zgoraj
+ //$tex .= '\fbox{\parbox{0.2\textwidth}{ '.$this->encodeText($stringTitle).' }} ';
+ $tex .= '\fbox{\parbox{0.2\textwidth}{ '.$textL.' }} ';
+ $tex .= ' \end{tabular}'; //za zakljuciti izris odgovorov v tabeli
+ }
+ }
+
+ }elseif($spremenljivke['orientation']==9){ //ce je "slikovni tip"
+ /* if($numRowsSql>=20){
+ $tex .= '| ';
+ } */
+ if($indeksZaWhile == 1){
+ $tex .= ICON_SIZE."{".$this->path2Images."".$this->getCustomRadioSymbol($spremenljivke['id'], $prviOdgovorSlikovniTip)."}";
+ }else{
+ if($numRowsSql<20){ //ce je manj kot 20 slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ $tex .= ' & ';
+ }
+ $tex .= ICON_SIZE."{".$this->path2Images."".$this->getCustomRadioSymbol($spremenljivke['id'], $prviOdgovorSlikovniTip)."}";
+ //$tex .= ' & '.ICON_SIZE."{".$this->path2Images."".$this->getCustomRadioSymbol($spremenljivke['id'], $prviOdgovorSlikovniTip)."}";
+ }
+ if($numRowsSql>=20){
+ $tex .= ' ('.$indeksZaWhile.') ';
+ //$tex .= ' ('.$indeksZaWhile.')| ';
+ }
+
+ if(isset($this->userAnswer[$rowVrednost['id']])&&$export_data_type==1){
+ $prviOdgovorSlikovniTip = 0;
+ }elseif($export_data_type==1&&$prviOdgovorSlikovniTip==1){
+ $prviOdgovorSlikovniTip = 1;
+ }
+
+ }elseif($spremenljivke['orientation']==11){ //ce je VAS
+ //$tex .= ' '.$symbol.' '.$this->encodeText($stringTitle, $rowVrednost['id']).' ';
+ if($indeksZaWhile == 1){
+ if($numRowsSql<=7){ //ce je manj kot 7 slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ $tex .= ' '.$symbol;
+ }
+ }else{
+ if($numRowsSql<=7){ //ce je manj kot 7 slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ $tex .= ' & '.$symbol;
+ }
+ }
+ if($numRowsSql>7){
+ $tex .= ' ('.$indeksZaWhile.') ';
+ }
+ }else{ //ce ni urejenega izrisa naj bo default oz. navpicno
+ $tex .= $symbol.' '.$this->encodeText($stringTitle, $rowVrednost['id']).' '.$texNewLine;
+ }
+
+ $oznakaOdgovora++;
+ $indeksZaWhile++;
+ }
+ //pregled vseh moznih vrednosti (kategorij, mozni odgovori) po $sqlVrednosti - konec
+ }
+
+ if($spremenljivke['orientation']==9 || $spremenljivke['orientation']==11){ //ce je "slikovni tip" ali VAS - izrisi se spodnjo vrstico odgovorov s stevilkami v oklepaju
+ //if($numRowsSql<20){ //ce je manj kot 20 slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ if($numRowsSql<$mejaVAS){ //ce je manj kot 20 slikovnih tipov, izpisemo s tabelo, drugace simbol in zraven število
+ for($i=1;$i<=$numRowsSql;$i++){
+ if($i==1){
+ $tex .= ' \\\\ ('.$i.')';
+ }else{
+ $tex .= ' & ('.$i.')';
+ }
+ }
+ $tex .= ' \end{tabular}'; //zakljuci izris odgovorov v tabeli za "slikovni tip"
+ }
+ //$tex .= $texNewLine;
+ $tex .= $texNewLine;
+ }elseif($spremenljivke['orientation']==8 || $spremenljivke['orientation']==7 ){ //ce je "povleci-spusti" ali "navpicno - tekst levo"
+ if($export_format == 'pdf'|| $spremenljivke['orientation']==7){ //ce je pdf
+ //if($spremenljivke['orientation']==7 && $export_format == 'pdf'){
+ if($export_format == 'pdf'){
+ $tex .= '\end{tabularx}'; //za zakljuciti izrisa odgovorov v tabeli//tabularx
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+ $tex .= ' \noindent ';
+ }else{
+ $tex .= ' \end{tabular}'; //za zakljuciti izris odgovorov v tabeli
+ $tex .= $texNewLine;
+ $tex .= $texNewLine;
+ }
+
+ }elseif($export_format == 'rtf'&&$spremenljivke['orientation']==8){ //ce je rtf in povleci-spusti, uredi izvoz desne strani vprasanja
+ //izpis opisnega teksta za Odgovori:
+ $tex .= '\begin{tabular}{l} '; //izris z enostolpicno tabelo
+ $tex .= $lang['srv_drag_drop_answers'].': '.$texNewLine; //Odgovori:
+ //$tex .= '\hline \end{tabular} '.$texBigSkip;
+ $tex .= '\hline \end{tabular} ';
+ //izpis opisnega teksta za Odgovori: - konec
+
+ if($export_data_type==1){ //ce je dolg izvoz, podatkov respondenta
+ foreach($textRArray as $odgovor){
+ //izpis okvirja z odgovorom respondenta
+ $tex .= '\begin{tabular}{c} '; //izris z enostolpicno tabelo brez obrob
+ //$tex .= '\begin{tabular}{|c|} \hline'; //izris z enostolpicno tabelo z obrabama levo desno in zgoraj
+
+ $tex .= $odgovor.$texNewLine;
+
+ $tex .= '\end{tabular} ';
+ //izpis okvirja z odgovorom respondenta - konec
+ }
+
+ }else{ //ce je izvoz praznega vprasalnika
+ //izpis praznega okvirja
+ $tex .= '\begin{tabular}{c} '; //izris z enostolpicno tabelo brez obrob
+ //$tex .= '\begin{tabular}{|c|} \hline'; //izris z enostolpicno tabelo z obrabama levo desno in zgoraj
+ //$tex .= ' opsasa '.$texNewLine;
+ $tex .= $texBigSkip;
+ $tex .= '\end{tabular} '.$texBigSkip;
+ //izpis praznega okvirja - konec
+ }
+
+ }
+ //$tex .= $texBigSkip;
+ }
+
+ if(($spremenljivke['orientation']==0||$spremenljivke['orientation']==2)){ //(ce je vodoravno ob vprasanju ali pod vprasanjem)
+ $tex .= $texNewLine;
+ }
+
+ }
+ #izpis praznega vprasalnika ali dolgega izvoza (vprasalnika z odgovori respondenta) - konec ####################################
+
+/* $tex .= $texNewLine;
+ $tex .= $texNewLine; */
+
+ if(($spremenljivke['orientation'] == 7 || $spremenljivke['orientation'] == 8) && $export_data_type==2){ //ce (je tekst na levi ALI povleci spusti) IN je skrcen izpis
+ $tex .= $texNewLine;
+ $tex .= $texNewLine;
+ }
+
+ if( !in_array($spremenljivke['orientation'], array(7, 8)) ){
+ $tex .= $this->texBigSkip;
+ $tex .= $texNewLine;
+ }
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }
+
+ return $tex;
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/RazvrscanjeLatex.php b/admin/survey/export/latexclasses/Vprasanja/RazvrscanjeLatex.php
new file mode 100644
index 0000000..c93ceb0
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/RazvrscanjeLatex.php
@@ -0,0 +1,397 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Razvrscanje
+ *
+ * Vprašanje je prisotno:
+ * tip 17
+ *
+ * Autor: Patrik Pucer
+ * Datum: 08-09/2017
+ *****************************************/
+
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+define("RADIO_BTN_SIZE", 0.13);
+
+class RazvrscanjeLatex extends LatexSurveyElement
+{
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $texBigSkip = ' \bigskip ';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new RazvrscanjeLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype='', $preveriSpremenljivko=null, $export_data_type=null, $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //preveri, ce je kaj v bazi
+ //$userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id);
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ //$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+
+ $tex = '';
+
+ //nastavitve iz baze ##########################
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ $tipRazvrscanja = $spremenljivke['design']; //0-Prestavljanje, 1-Ostevilcevanje, 2-Premikanje
+ $steviloDesnihOkvirjev = $spremenljivke['ranking_k']; //nastavitev Moznosti: 0-Vsi, 1....
+ if($steviloDesnihOkvirjev==0){ //ce je 0, je stevilo desnih okvirjev enako stevilo vnesenih odgovorov na levi strani
+ $steviloDesnihOkvirjev=$numRowsSql;
+ }
+ //nastavitve iz baze - konec ####################
+
+ $navpicniOdgovori = array();
+ $navpicniOdgovori = [];
+
+ $odgovoriRespondenta = array();
+ $odgovoriRespondenta = [];
+
+ $texNewLineAfterTable = $texNewLine." ".$texNewLine." ".$texNewLine;
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $jeOdgovor = 0; //belezi, ali je trenutna vrednost odgovora, odgovor respondenta ali ne
+ $stringTitleRow = $rowVrednost['naslov']; //odgovori na levi strani
+
+ if($userDataPresent){ //ce so prisotni podatki respondenta
+ //preverjanje podatkov trenutnega uporabnika ######################################################
+ //$sqlUserAnswer = sisplet_query("SELECT vrstni_red FROM srv_data_rating WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
+ $sqlUserAnswer = sisplet_query("SELECT vrstni_red FROM srv_data_rating WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' ");
+
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+
+ if($userAnswer){ //ce je kaj v bazi
+ if($tipRazvrscanja==1){ //ce je Ostevilcevanje
+ $odgovorRespondenta = $userAnswer['vrstni_red'];
+ array_push($odgovoriRespondenta, $odgovorRespondenta); //filanje polja z odgovori respondenta (stevilke)
+ }
+ $jeOdgovor = 1;
+ }
+ //preverjanje podatkov trenutnega uporabnika - konec ##############################################
+ }
+
+ if($jeOdgovor==0||$tipRazvrscanja==1){ //ce ni odgovor respondenta, bo naslov na levi strani; ali je Ostevilcevanje
+ array_push($navpicniOdgovori, $this->encodeText($stringTitleRow, $rowVrednost['id']) ); //filanje polja z navpicnimi odgovori (po vrsticah)
+ }
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec
+
+ if($userDataPresent&&$tipRazvrscanja!=1){ //ce so prisotni podatki respondenta in ni Ostevilcevanje
+ #ureditev polja s podatki trenutnega uporabnika ######################################################
+ //$sqlOdgovoriRespondentaString = "SELECT v.naslov, v.id from srv_vrednost v, srv_data_rating r WHERE r.spr_id=v.spr_id AND r.usr_id=".$usr_id." AND r.vre_id=v.id AND r.spr_id=".$spremenljivke['id']." ORDER BY r.vrstni_red";
+ $sqlOdgovoriRespondentaString = "SELECT v.naslov, v.id from srv_vrednost v, srv_data_rating r WHERE r.spr_id=v.spr_id AND r.usr_id=".$usr_id." AND r.vre_id=v.id AND r.spr_id=".$spremenljivke['id']." AND hidden='0' ORDER BY r.vrstni_red";
+ //echo $sqlOdgovoriRespondentaString."</br>";
+ $sqlOdgovoriRespondenta = sisplet_query($sqlOdgovoriRespondentaString);
+ //pregled vseh odgovorov respondenta razvrsceni kot morajo biti
+ while ($rowOdgovoriRespondenta = mysqli_fetch_assoc($sqlOdgovoriRespondenta)){
+ $odgovorRespondenta = $this->encodeText($rowOdgovoriRespondenta['naslov'], $rowOdgovoriRespondenta['id']);
+ array_push($odgovoriRespondenta, $odgovorRespondenta); //filanje polja z odgovori respondenta
+ }
+ //pregled vseh odgovorov respondenta razvrsceni kot morajo biti
+ #ureditev polja s podatki trenutnega uporabnika - konec ##############################################
+ }
+
+ //izris tabel dolocenega razvrscanja
+ if($export_data_type==2){ //ce je kratek izpis izvoza
+ $tex .= $this->IzrisRazvrscanjaKratko($spremenljivke, $steviloDesnihOkvirjev, $numRowsSql, $navpicniOdgovori, $texNewLine, $texNewLineAfterTable, $export_format, 0, $tipRazvrscanja, $odgovoriRespondenta, $export_subtype);
+ }elseif($export_data_type==0||$export_data_type==1){ //ce je navaden ali dolg izpis izvoza
+ if($tipRazvrscanja==0||$tipRazvrscanja==2){ //ce je Prestavljanje ali Premikanje
+ $tex .= $this->IzrisRazvrscanjaTabele($spremenljivke, $steviloDesnihOkvirjev, $numRowsSql, $navpicniOdgovori, $texNewLine, $texNewLineAfterTable, $export_format, 0, $tipRazvrscanja, $odgovoriRespondenta, $export_subtype);
+ }elseif($tipRazvrscanja==1){ //ce je Ostevilcevanje
+ $tex .= $this->IzrisRazvrscanja($spremenljivke, $numRowsSql, $navpicniOdgovori, $odgovoriRespondenta, $texNewLine, $export_format, 0);
+ }
+ }
+ //izris tabel dolocenega razvrscanja - konec
+
+
+ if($export_data_type!=2){ //ce ni skrcen izpis izvoza
+ if($tipRazvrscanja==1){ //ce je Ostevilcevanje
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ }else{
+ $tex .= $this->texBigSkip;
+ }
+ }
+
+ return $tex;
+ }
+ }
+
+
+ #funkcija, ki skrbi za izris ustreznih tabel za razvrscanje (postavitev: Prestavljanje in Premikanje) ################################
+ function IzrisRazvrscanjaTabele($spremenljivke=null, $steviloDesnihOkvirjev=null, $steviloVrstic=null, $navpicniOdgovori=null, $texNewLine='', $texNewLineAfterTable=null, $typeOfDocument=null, $fillablePdf=null, $tipRazvrscanja=null, $odgovoriRespondenta=null, $export_subtype=null){
+ global $lang;
+
+ //izpis kode tabela
+ $tabela = '';
+
+ if($tipRazvrscanja==0){ //ce je postavitev Prestavljanje
+ #pred zacetkom tabel s kategorijami #######################################################################
+ $tabela .= '\setlength{\parindent}{0.1\textwidth} ';
+ //prva vrstica pred tabelo z odgovori
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= '\begin{tabularx}{\textwidth}{l c l} '; //izris s tabelo tabularx
+ $tabela .= $lang['srv_ranking_available_categories'].': & \hspace{0.1\textwidth} & '.$lang['srv_ranking_ranked_categories1'].': '.$texNewLine;
+ $tabela .= '\rule{0.4\textwidth}{0.7 pt} & & \rule{0.4\textwidth}{0.4 pt} \end{tabularx} ';
+ }else{ //ce je rtf
+ $tabela .= '\begin{tabular}{l c l} '; //izris s tabelo
+ $tabela .= $lang['srv_ranking_available_categories'].': & & '.$lang['srv_ranking_ranked_categories1'].': '.$texNewLine;
+ $tabela .= '\rule{0.4\textwidth}{0.7 pt} & & \rule{0.4\textwidth}{0.4 pt} \end{tabular} ';
+ }
+ //prva vrstica pred tabelo z odgovori - konec
+ #pred zacetkom tabel s kategorijami - konec ###############################################################
+
+ $parameterTabularL = 'ccc'; //parameter za celotno tabelo z levimi in desnimi okvirji odgovorov za Prestavljanje
+ }
+
+
+ $tableCentering = ($typeOfDocument == 'pdf' ? ' \centering ' : '');
+
+ if($tipRazvrscanja==2){ //ce je postavitev Premikanje
+ $parameterTabularL = 'c'; //parameter za celotno tabelo z levimi in desnimi okvirji odgovorov za Premikanje
+ if($typeOfDocument == 'pdf'){
+ $tabela .= '\begin{center}'; //naj bo tabela na sredini lista, zacetek obmocja za center
+ }
+ }
+
+ #################################################
+ //zacetek tabele
+ $tabela .= $this->StartLatexTable($typeOfDocument, $parameterTabularL, 'tabularx', 'tabular', 1, 0.2);
+
+ //argumenti za leve okvirje
+ $textboxWidthL = 0.25;
+ $textboxAllignmentL = 'c';
+ $indeksZaStevilaL=1;
+ $indeksZaStevilaD=1;
+
+ //if($tipRazvrscanja==0||($tipRazvrscanja==2&&count($odgovoriRespondenta)==0)){ //ce je Prestavljanje ali Premikanje in ni podatkov respondenta
+ if(($tipRazvrscanja==2&&count($odgovoriRespondenta)==0)){ //Premikanje in ni podatkov respondenta
+ $steviloOdgovorov=count($navpicniOdgovori);
+ $textboxHeightL = 0;
+ }elseif($tipRazvrscanja==2&&count($odgovoriRespondenta)!=0){ //ce je postavitev Premikanje in imamo odgovore respondenta
+ $steviloOdgovorov=count($odgovoriRespondenta);
+ $textboxHeightL = 0; //ker mora biti prilagojena visina tekstu damo na 0
+ }elseif($tipRazvrscanja==0){ //ce je Prestavljanje
+ //$steviloOdgovorov=count($navpicniOdgovori)+$steviloDesnihOkvirjev;
+ $steviloOdgovorov=$steviloDesnihOkvirjev;
+ $textboxHeightL = 0;
+ }
+
+ //echo "textboxHeightL: ".$textboxHeightL."</br>";
+/* echo "odgovori respondenta: ".count($odgovoriRespondenta)."</br>";
+ echo "navpični odgovori: ".count($navpicniOdgovori)."</br>";
+ echo "stevilo Odgovorov: ".$steviloOdgovorov."</br>";
+ echo "stevilo desnih okvirjev: ".$steviloDesnihOkvirjev."</br>"; */
+
+ //izris notranjosti tabele
+ for ($i = 1; $i <= $steviloOdgovorov; $i++){
+
+ $textL = $tableCentering.' '.$navpicniOdgovori[$i-1]; //odgovor znotraj okvirja
+
+ if($tipRazvrscanja==2){ //ce je postavitev Premikanje
+
+ $tabela .= $indeksZaStevilaL.'. '; //pred okvirjem s kategorijo odgovora dodaj stevilko s piko
+
+ }elseif($tipRazvrscanja==0&&$typeOfDocument == 'rtf'){
+ //$tabela .= '\begin{tabular}{c} '; //izris s tabelo brez obrob
+ }
+
+ //izpis latex kode za okvir z odgovorom
+ if($tipRazvrscanja==0||($tipRazvrscanja==2&&count($odgovoriRespondenta)==0)){ //ce je Prestavljanje ali Premikanje in ni podatkov respondenta
+ if($navpicniOdgovori[$i-1]!=''){ //ce so prisotni odgovori
+ $textVOkvirju = $textL;
+ }
+ }elseif($tipRazvrscanja==2&&count($odgovoriRespondenta)!=0){ //ce je postavitev Premikanje in imamo odgovore respondenta
+ $textVOkvirju = $odgovoriRespondenta[$i-1];
+ }
+
+ //echo "text V Okvirju: ".$textVOkvirju."</br>";
+
+ //izpis latex kode za okvir z odgovorom
+ if($tipRazvrscanja==0&&$navpicniOdgovori[$i-1]!=''){
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= $this->LatexTextBox($typeOfDocument, $textboxHeightL, $textboxWidthL, $textVOkvirju, $textboxAllignmentL, 0);
+ }else{
+ $tabela .= $textVOkvirju;
+ }
+ }elseif($tipRazvrscanja==2||$tipRazvrscanja==1){
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= $this->LatexTextBox($typeOfDocument, $textboxHeightL, $textboxWidthL, $textVOkvirju, $textboxAllignmentL, 0);
+ }else{
+ $tabela .= $textVOkvirju;
+ }
+ }
+/* if(($tipRazvrscanja==0&&$navpicniOdgovori[$i-1]!='')||($tipRazvrscanja==2||$tipRazvrscanja==1)){
+ if($typeOfDocument == 'pdf'){ //ce je pdf
+ $tabela .= $this->LatexTextBox($typeOfDocument, $textboxHeightL, $textboxWidthL, $textVOkvirju, $textboxAllignmentL, 0);
+ }else{
+ $tabela .= $textVOkvirju;
+ }
+ } */
+
+ if($typeOfDocument == 'pdf'){
+ $tabela .= ' \bigskip ';
+ }
+
+ if($tipRazvrscanja==2){ //ce je Premikanje
+ $tabela .= $texNewLine;
+ }
+
+ ################
+ if($tipRazvrscanja==0){ //ce je postavitev Prestavljanje
+ //prazen prostor med levim delom in desnim delom
+ $tabela .= '& \hspace{0.2\textwidth} &';
+
+ //desni del vprasanja
+ $textboxWidthDE = 0.25; //sirina okvirja z vsebino in empty
+ $textboxAllignmentDE = 'c'; //allignment desnega okvirja, ki je empty
+ if($indeksZaStevilaD <= $steviloDesnihOkvirjev){ //ce se ni preseglo zeleno stevilo desnih okvirjev
+ $tabela .= $indeksZaStevilaD.'. ';
+ $odgovorZaIzpis = $odgovoriRespondenta[$i-1];
+ if($typeOfDocument == 'pdf'){
+ //echo "odgovori respondenta na desni: ".$odgovoriRespondenta[$i-1]."</br>";
+ if($odgovorZaIzpis){ //ce je odgovor respondenta
+ $textboxHeight = 0; //ker mora biti prilagojena visina tekstu damo na 0
+ }else{
+ $textboxHeight = '0.3cm';
+ }
+ //izpis latex kode za okvir brez besedila oz. z odgovorom respondenta
+ $tabela .= $this->LatexTextBox($typeOfDocument, $textboxHeight, $textboxWidthDE, $odgovorZaIzpis, $textboxAllignmentDE, 0);
+ $tabela .= $texNewLine;
+ }elseif($typeOfDocument == 'rtf'){
+ //izpis latex kode za okvir brez besedila oz. z odgovorom respondenta
+ $tabela .= $this->LatexTextBox($typeOfDocument, 0, $textboxWidthDE, $odgovorZaIzpis, $textboxAllignmentDE, 0);
+ $tabela .= $texNewLine;
+ }
+
+ $indeksZaStevilaD++;
+ }else{ //ce se je preseglo stevilo zelenih okvirjev na desni strani, izpisi prazno celico
+ $tabela .= ' '.$texNewLine;
+ }
+ }
+ ################
+ $indeksZaStevilaL++;
+
+ }
+
+ //$tabela .= ' \bigskip ';
+
+
+ //if(count($navpicniOdgovori)==0){ //ce ni odgovorov na desni strani, uredi prazen neviden okvir
+ if(count($navpicniOdgovori)==0 && $typeOfDocument == 'pdf'){ //ce ni odgovorov na desni strani, uredi prazen neviden okvir
+ $tabela .= $this->LatexTextBox($typeOfDocument, $textboxHeightL, $textboxWidthL, '', $textboxAllignmentL, 1);
+ }
+
+ //zakljucek tabele
+ $tabela .= $this->EndLatexTable($typeOfDocument, 'tabularx', 'tabular');
+ #################################################
+
+ if($tipRazvrscanja==2){ //ce je postavitev Premikanje
+ if($typeOfDocument == 'pdf'){
+ $tabela .= '\end{center}'; //naj bo tabela na sredini lista, konec obmocja za center
+ }
+ }
+ //izpis kode tabela - konec
+
+ return $tabela;
+ }
+ #funkcija, ki skrbi za izris ustreznih tabel za razvrscanje (postavitev: Prestavljanje in Premikanje) - konec ################################
+
+
+
+ #funkcija, ki skrbi za izris ustreznih tabel za razvrscanje (postavitev: Prestavljanje in Premikanje) ################################
+
+ #funkcija, ki skrbi za izris razvrscanja (postavitev: Ostevilcevanje) ################################
+ function IzrisRazvrscanja($spremenljivke=null, $steviloVrstic=null, $navpicniOdgovori=null, $odgovoriRespondenta=null, $texNewLine='', $typeOfDocument=null, $fillablePdf=null){
+ $tex = '';
+ $textboxWidth = 0.1;
+ $textboxHeight = '0.2cm';
+ $textboxAllignment = 'c'; //dummy spremenljivka
+
+ if($typeOfDocument == 'rtf'){ //ce je rtf, zacetek tabele, kjer sta dva stolpca (prazen okvir + okvir z odgovorom)
+ //$tex .= '\begin{tabular}{l l} '; //izris z enostolpicno tabelo
+ $tex .= '\begin{tabular}{c l} '; //izris z enostolpicno tabelo
+ }
+
+ for ($i = 1; $i <= $steviloVrstic; $i++){
+ $tex .= ' \noindent '; //da ni premika besedila v desno
+
+ //izpis latex kode za prazen okvir oz. okvirjem z ustreznim stevilskim odgovorom
+ //$tex .= $this->LatexTextBox($typeOfDocument, $textboxHeight, $textboxWidth, $odgovoriRespondenta[$i-1], $textboxAllignment, 0);
+ $tex .= $this->LatexTextBox($typeOfDocument, $textboxHeight, $textboxWidth, '\\textcolor{crta}{'.$odgovoriRespondenta[$i-1].'}', $textboxAllignment, 0);
+
+ if($typeOfDocument == 'rtf'){ //ce je rtf
+ $tex .= ' & '; //meja med stolpcema tabele 1. prazen okvir (okvir s stevilskim odgovorom), 2. navpicni odgovor
+ }
+
+ //odgovor ob praznem okvirju
+ $tex .= ' '.$navpicniOdgovori[$i-1];
+
+ //v novo vrstico
+ $tex .= $texNewLine;
+ }
+
+ if($typeOfDocument == 'rtf'){ // ce je rtf, zakljuci tabelo s stolpcema
+ $tex .= ' \end{tabular} ';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za izris razvrscanja (postavitev: Ostevilcevanje) - konec ################################
+
+ #funkcija, ki skrbi za izris razvrscanje za kratek izpis izvoza ################################
+ function IzrisRazvrscanjaKratko($spremenljivke=null, $steviloDesnihOkvirjev=null, $steviloVrstic=null, $navpicniOdgovori=null, $texNewLine='', $texNewLineAfterTable=null, $typeOfDocument=null, $fillablePdf=null, $tipRazvrscanja=null, $odgovoriRespondenta=null, $export_subtype=null){
+ global $lang;
+
+ $indeksZaStevila=1;
+ $steviloOdgovorov=count($navpicniOdgovori);
+ $steviloOdgovorov=count($odgovoriRespondenta);
+
+ $tex = '';
+
+ //izpis stevil in odgovorov
+ for ($i = 1; $i <= $steviloOdgovorov; $i++){
+ if($tipRazvrscanja==0||$tipRazvrscanja==2){ //ce je Prestavljanje ali Premikanje
+ $tex .= $indeksZaStevila.'. '; //stevilka pred odgovorom
+ //$tex .= $odgovoriRespondenta[$i-1]; //odgovor
+ $tex .= '\\textcolor{crta}{'.$odgovoriRespondenta[$i-1].'}'; //odgovor
+ }elseif($tipRazvrscanja==1){ //ce je Ostevilcevanje
+ $tex .= $navpicniOdgovori[$i-1].': ';
+ //$tex .= $odgovoriRespondenta[$i-1]; //odgovor
+ $tex .= '\\textcolor{crta}{'.$odgovoriRespondenta[$i-1].'}'; //odgovor
+ }
+ $tex .= '; ';
+ $indeksZaStevila++;
+ }
+
+ $tex .= ' \\\\ ';
+ $tex .= ' \\\\ ';
+
+ return $tex;
+ }
+ #funkcija, ki skrbi za izris razvrscanje za kratek izpis izvoza - konec ################################
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/SNImena.php b/admin/survey/export/latexclasses/Vprasanja/SNImena.php
new file mode 100644
index 0000000..e7d7ef1
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/SNImena.php
@@ -0,0 +1,94 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za SNImena
+ *
+ * Vprašanje je prisotno:
+ * tip 9, 10, 11, 14, 12, 15, 13
+ *
+ * Autor: Patrik Pucer
+ * Datum: 05/2018
+ *****************************************/
+
+ define("NAGOVOR_LINE_WIDTH", 0.5);
+
+class SNImenaLatex extends LatexSurveyElement
+{
+ protected $texBigSkip = '\bigskip';
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new SNImenaLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $fillablePdf=null, $texNewLine='', $export_subtype='', $db_table=null, $anketa=null, $usr_id=null, $loop_id_raw=null){
+
+ global $lang;
+ $tex = '';
+ $textboxHeightL = 0; //ker mora biti prilagojena visina tekstu damo na 0
+ $textboxWidthL = 0.25;
+ $textboxAllignmentL = 'l';
+ $noBorders = 0;
+ $textVOkvirju = array();
+
+ // Ce je spremenljivka v loopu
+ //$this->loop_id = $loop_id;
+ $loop_id = $loop_id_raw == null ? " IS NULL" : " = '".$loop_id_raw."'";
+
+
+ if($export_subtype=='q_empty'||$export_subtype=='q_comment'){ //ce je prazen vprasalnik ali komentarji
+ $steviloOkvirjev = 5;
+ for($i=0; $i<$steviloOkvirjev;$i++){
+ array_push($textVOkvirju, '');
+ }
+ }elseif($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ if ($usr_id){
+ $sqlUserAnswerString = "SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND loop_id $loop_id ";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+ while($userAnswer = mysqli_fetch_array($sqlUserAnswer)){
+ array_push($textVOkvirju, $this->encodeText($userAnswer['text']));
+ }
+ $steviloOkvirjev=count($textVOkvirju);
+ }
+ }
+
+ foreach($textVOkvirju AS $textOkvir){
+ //izpis latex kode za okvir z odgovorom
+ if($export_format == 'pdf'){ //ce je pdf
+ $textOkvir = '\\textcolor{crta}{'.$textOkvir.'}';
+ $tex .= $this->LatexTextBox($export_format, $textboxHeightL, $textboxWidthL, $textOkvir, $textboxAllignmentL, $noBorders);
+ $tex .= $texNewLine;
+ }elseif($export_format == 'rtf'){
+ $tex .= '\begin{tabular}{l} '; //izris s tabelo brez obrob
+ //izpis latex kode za okvir brez besedila oz. z odgovorom respondenta
+ $tex .= $this->LatexTextBox($export_format, $textboxHeightL, $textboxWidthL, $textOkvir, $textboxAllignmentL, $noBorders);
+ $tex .= ' \end{tabular}'; //za zakljuciti izris v tabeli
+ }
+ }
+
+ $tex .= $texNewLine;
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+
+ if($export_format == 'pdf'){ //ce je pdf
+ $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+ return $tex;
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/SteviloLatex.php b/admin/survey/export/latexclasses/Vprasanja/SteviloLatex.php
new file mode 100644
index 0000000..b6def64
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/SteviloLatex.php
@@ -0,0 +1,702 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Število
+ *
+ * Vprašanje je prisotno:
+ * tip 7 z vsemi nacini vnosa (Stevilo, Drsnik) in postavitev (Vodoravno ob vprasanju in Vodoravno pod vprasanjem)
+ *
+ * Autor: Patrik Pucer
+ * Datum: 08/2017
+ *****************************************/
+
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+define("MAXSTEVILOSTOLPCEV", 21); //max Stevilo Stolpcev za prvo vrstico pod Drsnikom, zaradi tezav z izrisom, ce je teh vec kot toliko
+
+class SteviloLatex extends LatexSurveyElement
+{
+ var $internalCellHeight;
+ protected $texBigSkip = '\bigskip';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new SteviloLatex();
+ }
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype=null, $preveriSpremenljivko=null, $export_data_type=null, $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //preveri, ce je kaj v bazi
+ //$userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id);
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+
+ $tex = '';
+
+ $symbol = $this->getAnswerSymbol($export_format, $fillablePdf, 2, 10, 0, 0); //poberi simbol checkbox za other in missing moznosti odgovora
+
+ //nastavitve iz baze ##########################
+ $steviloOken = $spremenljivke['size']; //stevilo oken
+ $postavitev = $spremenljivke['orientation']; //0-vodoravno ob vprasanju, 1-vodoravno pod vprasanjem
+ $polozajEnota = $spremenljivke['enota']; //polozaj enote 0-Ne, 1-Na levi, 2-Na desni
+ $nacinVnosa = $spremenljivke['ranking_k']; //nacin vnosa 0-Stevilo, 1-Drsnik
+
+
+ $textboxHeightOrig = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1);
+ $textboxHeight = ($textboxHeightOrig*0.3).'cm';
+
+ $textboxWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ if($textboxWidth == -1){ //ce je vrednost -1, je default t.j. 30 oz. 0.30 sirine
+ $textboxWidth = 0.30;
+ }else{ //drugace, izracunaj sirino
+ $textboxWidth = $textboxWidth/100; //pretvorimo sirino v odstotke oz. decimalke
+ }
+
+ if($textboxWidth == 1){ //ce je sirina 100, jo zmanjsaj za 5%
+ $textboxWidth = $textboxWidth*0.95;
+ }
+
+ $textboxWidth = (string)$textboxWidth; //pretvorimo stevilo (decimalke) v string
+ //echo "sirina: ".$textboxWidth."</br>";
+ //textboxWidth se rocno povozi pod "ureditev parametrov za tabelo" - NE VEC, ker se hoce sirino okvirja tako kot je nastavljena v nastavitvah
+
+ //nastavitve iz baze - konec ####################
+
+ $array_others = array(); //polje za drugo, missing, ...
+ $besedilaEnote = array(); //polje, ki hrani besedila enot
+ $besedilaEnote = [];
+ $textBoxes = array(); //polje, ki hrani latex za prazne text box-e
+ $textBoxes = [];
+ $textboxAllignment = 'c'; //poravnava textboxa s stevilom
+
+ $oznakaOdgovora = 'a';
+ $indeksZaWhile = 1;
+ $oznakaVprasanja = $this->UrediOznakoVprasanja($spremenljivke['id']); //uredi oznako vprasanja, ker ne sme biti stevilska
+
+ $okvirVNovoVrstico = 0;
+
+ /* if($postavitev!=0){
+ $tex .= $texNewLine;
+ } */
+
+ //ureditev polja s podatki trenutnega uporabnika ######################################################
+ //$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
+ $sqlUserAnswer = sisplet_query("SELECT text, text2 FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' ");
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer: ".$userAnswer['text']."</br>";
+ //ureditev polja s podatki trenutnega uporabnika - konec ##############################################
+
+
+
+ if(($nacinVnosa==0) || ($nacinVnosa==1&&$export_format=='rtf')){ //ce je nacin vnosa Stevilo ali je Drsnik in je izvoz v rtf
+
+ if($polozajEnota!=0){ //ce je izpis z besedilom enote
+ $tex .= $texNewLine;
+ }
+
+ //ureditev parametrov za tabelo#############################
+ $parameterTabular = '';
+ if($polozajEnota==0){ //ce ni besedila za enoto
+ $steviloStolpcevTabele = $steviloOken;
+ }else{ //ce je besedilo enote na LEVI ali DESNI
+ $steviloStolpcevTabele = $steviloOken*2;
+ }
+ for($i = 0; $i < $steviloStolpcevTabele; $i++){
+ //echo "i%2: ".($i%2)."</br>";
+ if($polozajEnota==1 && $i%2==0){ //ce je polozaj besedila enote na LEVI in je stolpec za besedilo
+ //$parameterTabular .= ($export_format == 'pdf' ? 'r' : 'l'); //desna poravnava stolpca ali leva, ce je rtf
+ //$parameterTabular .= ($export_format == 'pdf' ? '>{\hsize=0.3\hsize}r' : 'l'); //desna poravnava stolpca fiksne dimenzije ali leva, ce je rtf
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\raggedleft}p{0.2\textwidth}' : 'l'); //desna poravnava stolpca fiksne dimenzije ali leva, ce je rtf
+ }elseif($polozajEnota==2 && $i%2==1){ //ce je polozaj besedila enote na DESNI in je stolpec za besedilo
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\raggedright\arraybackslash}p{0.2\textwidth}' : 'l'); //leva poravnava stolpca fiksne dimenzije ali leva, ce je rtf
+ }else{
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca
+/* if($textboxWidth<0.80){ //ce je urejeni okvir manjsi od 80, naj bo sirina ta ki je bila nastavljen
+ $parameterTabular .= ($export_format == 'pdf' ? 'p{'.$textboxWidth.'\textwidth}' : 'l'); //leva poravnava stolpca
+ }else{ //drugace, ce je okvri vecji od 80, naj bo sirina fiksna na 75
+ $parameterTabular .= ($export_format == 'pdf' ? 'p{0.75\textwidth}' : 'l'); //leva poravnava stolpca
+ $textboxWidth = 0.75;
+ } */
+
+ if($textboxWidth>=0.80){ //ce je urejeni okvir vecji od 80, naj oznaci, saj moramo prenesti okvirje v novo vrstico
+ $okvirVNovoVrstico = 1;
+ }
+ $parameterTabular .= ($export_format == 'pdf' ? 'p{'.$textboxWidth.'\textwidth}' : 'l'); //stolpec z nastavljeno sirino okvirja, rtf: leva poravnava
+
+ }
+ }
+ //echo "parametri tabele: ".$parameterTabular."</br>";
+ //ureditev parametrov za tabelo - konec######################
+
+ if($userAnswer['text']){
+ $okvir = 0;
+ }elseif($userAnswer['text'] == ''){ //ce nimamo odgovora
+ $okvir = 1; //rabimo okvir
+ }
+
+ #ZACETEK TABELE
+ //zacetek tabele
+ if($polozajEnota!=0){ //ce je prisotno besedilo za enoto
+ //$tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular',1, 1);
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabular', 'tabular',1, 1);
+ }elseif($polozajEnota==0&&$steviloOken>1){ //ce ni prisotno besedilo za enoto in je vec oken
+ //$tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular',1, 1);
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabular', 'tabular',1, 1);
+ }
+
+ $izpisStevilk = 0; //belezi, ali se je stevilo ali stevila ze izpisalo
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ # po potrebi se prevede besedilo, ki se pojavi pred textbox-om
+ $naslov = $this->srv_language_vrednost($rowVrednost['id']);
+ if ($naslov != '') {
+ $rowVrednost['naslov'] = $naslov;
+ }
+
+ //ce ni other ali missing
+
+ if( (int)$rowVrednost['other'] == 0 && $rowVrednost['naslov']){ //in se ni se izpisalo stevila
+
+ $drugoStevilo = $userAnswer['text2']; //belezi drugo mozno stevilo
+
+ if($izpisStevilk == 0 && $okvir == 0){ //ce ni bilo se izpisano nobeno stevilo in ne rabimo tabele za izpis
+ $txtTmp = [];
+ if($export_format=='pdf'){
+ if($polozajEnota==0){ //ce ni besedila za enoto, rabimo odstavek za pravilen izpis
+ $txtTmp1 = " \par { ";
+ $txtTmp1 .= ' \\textcolor{crta}{'.$userAnswer['text'].'}';
+ }else{
+ $txtTmp1 = ' \\textcolor{crta}{'.$userAnswer['text'].'}';
+ }
+ if($polozajEnota==0){ //ce ni besedila za enoto
+ //$txtTmp1 .= " \par } ";
+ $txtTmp1 .= " } ";
+ }
+ }elseif($export_format == 'rtf'){
+ $txtTmp1 = $userAnswer['text']; //prvo stevilo
+ }
+ array_push($txtTmp, $txtTmp1); //filanje polja z besedili
+ if($drugoStevilo){ //ce je se drugo stevilo
+ if($export_format=='pdf'){
+ if($polozajEnota==0){ //ce ni besedila za enoto, rabimo odstavek za pravilen izpis
+ $txtTmp2 = " \par { ";
+ $txtTmp2 .= ' \\textcolor{crta}{'.$drugoStevilo.'}';
+ }else{
+ $txtTmp2 = ' \\textcolor{crta}{'.$drugoStevilo.'}';
+ }
+ if($polozajEnota==0){ //ce ni besedila za enoto
+ //$txtTmp2 .= " \par } ";
+ $txtTmp2 .= " } ";
+ }
+ }elseif($export_format == 'rtf'){
+ $txtTmp2 = $drugoStevilo;
+ }
+ array_push($txtTmp, $txtTmp2); //filanje polja z besedili
+ }
+ }
+
+ if($okvir == 1){ //ce rabimo okvir, izpisi
+ //$dataTextBox = $this->LatexTextBox($export_format, $textboxHeight, $textboxWidth, $txtTmp, $textboxAllignment, 0);
+ if($polozajEnota==0){ //ce ni besedila za enoto, rabimo odstavek za pravilen izpis
+ if($steviloOken>1){
+ $dataTextBox = " \par { ";
+ }
+ $dataTextBox .= $this->LatexTextBox($export_format, $textboxHeight, $textboxWidth, $txtTmp, $textboxAllignment, 0);
+ }else{
+ $dataTextBox = $this->LatexTextBox($export_format, $textboxHeight, $textboxWidth, $txtTmp, $textboxAllignment, 0);
+ }
+
+ if($polozajEnota==0){ //ce ni besedila za enoto
+ if($steviloOken>1){
+ //$dataTextBox .= " \par } ";
+ $dataTextBox .= " } ";
+ }
+ }
+ array_push($textBoxes, $dataTextBox);
+
+ }
+
+
+ if($polozajEnota==0){ //ce polozaja besedila enote je na NE
+ if($indeksZaWhile!=1){
+ //if($okvir == 1){ //ce rabimo prazen okvir, izpisi
+ if($okvir == 1 && $textboxWidth<0.49){ //ce rabimo prazen okvir, izpisi
+ $tex .= ' & '; //skoci v nov stolpec
+ }else{
+ $tex .= ' \\\\ '; //pojdi v novo vrstico
+ }
+ }
+
+ if($okvir == 1){ //ce rabimo prazen okvir, izpisi
+ //izpis praznega text box-a dolocene sirine in visine
+ //$tex .= ' & '.$dataTextBox;
+ $tex .= ' '.$dataTextBox;
+ }else{ //ce je podatek ob levi enoti
+ //$tex .= ' & '.$txtTmp[$indeksZaWhile-1];
+ $tex .= ' '.$txtTmp[$indeksZaWhile-1];
+ }
+
+ }
+ //if($polozajEnota==1){ //ce je polozaj besedila enote na LEVI
+ elseif($polozajEnota==1){ //ce je polozaj besedila enote na LEVI
+ if($indeksZaWhile!=1){
+ if($okvir == 1 && $textboxWidth<0.30){ //ce rabimo prazen okvir in je njegova sirina manjsa od 30, izpisi
+ $tex .= ' & '; //skoci v nov stolpec
+ }else{
+ $tex .= ' \\\\ '; //pojdi v novo vrstico
+ }
+ }
+
+ //izpis besedila enote
+ $stringEnota = $rowVrednost['naslov'];
+ $stringEnota = Common::getInstance()->dataPiping($stringEnota, $usr_id, $loop_id);
+ $tex .= $this->encodeText($stringEnota);
+
+ if($okvir == 1){ //ce rabimo prazen okvir, izpisi
+ //izpis praznega text box-a dolocene sirine in visine
+ if($okvirVNovoVrstico){ //v novo vrstico, ce je predolg
+ $tex .= ' \\\\ '.$dataTextBox;
+ }else{
+ $tex .= ' & '.$dataTextBox;
+ }
+ }else{ //ce je podatek ob levi enoti
+ $tex .= ' & '.$txtTmp[$indeksZaWhile-1];
+ }
+
+ //echo "tex koda: ".$tex."</br>";
+
+ }elseif($polozajEnota==2){ //ce je polozaj besedila enote na DESNI
+ //if($indeksZaWhile!=1&&$export_format=='rtf'){//ce je drugi okvir in je rtf
+ if($indeksZaWhile!=1){//ce je drugi okvir
+ //if($okvir == 1){ //ce rabimo prazen okvir, izpisi
+ //if($okvir == 1&& $textboxWidth<0.49){ //ce rabimo prazen okvir in je njegova sirina manjsa od 49, izpisi
+ if($okvir == 1&& $textboxWidth<=0.25){ //ce rabimo prazen okvir in je njegova sirina manjsa od 25, izpisi
+ $tex .= ' & '; //skoci v nov stolpec
+ }else{
+ $tex .= ' \\\\ '; //pojdi v novo vrstico
+ }
+ }
+
+ if($okvir == 1){ //ce rabimo prazen okvir, izpisi
+ //izpis praznega text box-a dolocene sirine in visine
+ $tex .= $dataTextBox;
+ }else{
+ if($indeksZaWhile!=1){
+ $tex .= ' \\\\ '; //pojdi v novo vrstico
+ }
+ $tex .= $txtTmp[$indeksZaWhile-1].' ';
+ }
+
+ //izpis besedila enote
+ if($okvirVNovoVrstico){ //v novo vrstico, ce je predolg
+ $tex .= ' \\\\ '; //pojdi v novo vrstico
+ }else{
+ $tex .= ' & '; //v nov stolpec tabele
+ }
+
+ $stringEnota = $rowVrednost['naslov'];
+ $stringEnota = Common::getInstance()->dataPiping($stringEnota, $usr_id, $loop_id);
+ $tex .= ' '.$this->encodeText($stringEnota);
+
+ if($indeksZaWhile==1&&$export_format=='pdf'){ //ce je prvi okvir in je pdf
+ //$tex .= ' \hspace{0.5cm} '; //dodaj še nekaj prostora, za prvim okvirjem, da bo dovolj prostora
+ }
+
+ //echo "tex koda za na desni: ".$tex."</br>";
+ }
+
+ if($drugoStevilo){
+ $izpisStevilk=1;
+ }
+
+ }
+ elseif((int)$rowVrednost['other'] != 0) { //drugace, ce imamo missinge ali podobne, jih zabelezi v polju
+ // imamo polje drugo - ne vem, zavrnil...
+ $array_others[$rowVrednost['id']] = array(
+ 'naslov'=>$rowVrednost['naslov'],
+ 'vrstni_red'=>$rowVrednost['vrstni_red'],
+ 'value'=>$text[$rowVrednost['vrstni_red']],
+ );
+
+ }
+ $oznakaOdgovora++;
+ $indeksZaWhile++;
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec
+
+
+/* if($polozajEnota==0){ //ce polozaja besedila enote je na NE
+ //$tex .= $texNewLine;
+ if($okvir == 1){
+ //izpis praznih text box-ov dolocene sirine in visine
+ $tex .= $this->izrisVrsticePoStolpcih($steviloStolpcevTabele, $textBoxes);
+ //izpis praznih text box-ov dolocene sirine in visine - konec
+ }else{
+ $tex .= $this->izrisVrsticePoStolpcih($steviloStolpcevTabele, $txtTmp);
+ }
+ } */
+
+ if($polozajEnota!=0){ //ce polozaja besedila enote ni na NE
+ //zakljucek tabele
+ //$tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ $tex .= $this->EndLatexTable($export_format, 'tabular', 'tabular');
+ #KONEC TABELE
+ }elseif($polozajEnota==0&&$steviloOken>1){
+ //zakljucek tabele
+ //$tex .= $this->EndLatexTable($export_format, 'tabularx', 'tabular');
+ $tex .= $this->EndLatexTable($export_format, 'tabular', 'tabular');
+ #KONEC TABELE
+ }
+ //echo "tex koda: ".$tex."</br>";
+
+/* $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ if($okvir == 1){ //ce je prazen vprasalnik, dodaj se dve prazni vrstici
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ } */
+
+ }elseif($nacinVnosa==1&&$export_format=='pdf'){ //ce je drsnik in je izvoz v pdf
+
+ if($export_data_type==2){ //ce je kratek izpis izvoza
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ $tex .= $texNewLine; //gremo v novo vrstico, da je odgovor pod vprasanjem
+ //$tex .= '\\textcolor{crta}{'.$userAnswer['text'].'}'.$texNewLine; //izpis odgovora
+ $tex .= '\\textcolor{crta}{'.$userAnswer['text'].'}'; //izpis odgovora
+ }
+ }
+
+ if($export_data_type==1||$export_data_type==0){ //ce je dolg ali navaden izpis izvoza, izrisi drsnik
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ $tex .= $lang['srv_number_answer'].': \\textcolor{crta}{'.$userAnswer['text'].'}'.$texNewLine; //izpis odgovora
+ }
+
+ //zakljucek odstavka, da bo lahko drsnik sredinsko poravnan
+ $tex .= '\par'; //odstavek
+
+ #nastavitve iz baze za drsnik ##################################################################
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0); //0-je rocaj, 1-ni rocaja
+
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0); //Prikaži labele za Min in Max: 0-prikazi, 1-skrij
+
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0); //ali sta prisotni labeli nad drsnikom oz. nad min in max vrednostjo
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : $lang['srv_new_text']); //labela na minumumu
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : $lang['srv_new_text']); //labela na maksimumu
+
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0); //ali naj drsnika prikazuje stevilske labele med maksimumom in minimumom na spodnji strani drsnika
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0); //ali naj drsnika prikazuje opisne labele med maksimumom in minimumom na spodnji strani drsnika
+
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0); //ali imamo vmesen crtice na drsniku, za izris izvoza se bo to ignoriralo
+
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1); //korak drsnika
+
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+
+ //vnesena minimum pa maksimum drsnika
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5); //stevilo opisnih label
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0); //besedilo/string z naslovi opisnih vmesnih label
+
+ //spremenljivke za labele podrocij
+ $slider_labele_podrocij = ($spremenljivkaParams->get('slider_labele_podrocij') ? $spremenljivkaParams->get('slider_labele_podrocij') : 0); //za checkbox
+ $slider_StevLabelPodrocij = ($spremenljivkaParams->get('slider_StevLabelPodrocij') ? $spremenljivkaParams->get('slider_StevLabelPodrocij') : 3);
+ //$slider_table_td_width = 100 / $slider_StevLabelPodrocij; //spremenljivka za razporeditev sirine sliderja po podrocjih
+ //spremenljivke za labele podrocij - konec
+ #nastavitve iz baze za drsnik - konec ##################################################################
+
+ //pridobitev missing-ov za njihov izris ###############################################################
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ if( (int)$rowVrednost['other']!=0 ){ //ce imamo missinge ali podobne, jih zabelezi v polju
+ // imamo polje drugo - ne vem, zavrnil...
+ $array_others[$rowVrednost['id']] = array(
+ 'naslov'=>$rowVrednost['naslov'],
+ 'vrstni_red'=>$rowVrednost['vrstni_red'],
+ 'value'=>$text[$rowVrednost['vrstni_red']],
+ );
+ }
+ }
+ //pridobitev missing-ov za njihov izris - konec ########################################################
+
+ //pridobitev naslovov opisnih vmesnih label za kasnejsi izris ##########################################
+ if($slider_VmesneDescrLabel){ //ce je potrebno izrisati vmesne opisne labele pod drsnikom
+ $descriptiveLabels = [];
+ if($slider_DescriptiveLabel_defaults!=0){ //ce so prednalozene opisne labele
+ $descriptiveLabels = explode(';',$slider_DescriptiveLabel_defaults_naslov1);
+ }else{ //ce so custom opisne labele
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ $descriptiveLabels = explode(';', $slider_CustomDescriptiveLabels);
+ }
+ }
+ //pridobitev naslovov opisnih vmesnih label za kasnejsi izris - konec ##################################
+
+
+ #IZRIS OPISNIH LABEL NAD DRSNIKOM #################################################
+ if($slider_MinMaxLabel){
+ //parametri tabele
+ $parameterTabularLabeleNad = 'lR'; //leva (l) pa desna poravnava, ki se prilagaja (R)
+
+ //zacetek tabele
+ $tex .= ($export_format == 'pdf' ? '\keepXColumns \begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabeleNad.'}' : '\begin{tabular*}{3 cm}{c}');
+
+ //vrstice in stolpci v tabeli
+ $tex .= $this->encodeText($MinLabel).' & '.$this->encodeText($MaxLabel); //izpis naslovov label v eni vrstici
+ //vrstice in stolpci v tabeli - konec
+
+ //konec tabele
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular*} \\noindent");
+
+ //$tex .= $texNewLine; //v novo vrstico po izrisu label
+ $tex .= '\par'; //odstavek
+ }
+ #IZRIS OPISNIH LABEL NAD DRSNIKOM - KONEC #########################################
+
+ #IZRIS DRSNIKA {dolzina}{pozicija bunkice}####################################
+ if($slider_handle==0){ //ce je rocaj na drsniku
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ $pozicijaBunkice = $userAnswer['text']/$slider_MaxNumLabel;
+ }elseif($export_subtype=='q_empty'||$export_subtype=='q_comment'){
+ $pozicijaBunkice=0.5;
+ }
+ //echo "pozicija bunkice na drsniku: ".$pozicijaBunkice."</br>";
+ //$tex .= '\noindent \circleSLIDER{0.9\textwidth}{'.$pozicijaBunkice.'}'; //drsnik z rocajem
+ $tex .= '{\centering \circleSLIDER{0.85\textwidth}{'.$pozicijaBunkice.'} \par}'; //drsnik z rocajem
+
+ }else{ //drugace, ce ni rocaja
+ //$tex .= '\noindent \emptySLIDER{0.9\textwidth}'; //drsnik brez rocaja
+ $tex .= '{\centering \emptySLIDER{0.85\textwidth} \par}'; //drsnik brez rocaja
+ }
+ #IZRIS DRSNIKA {dolzina}{pozicija bunkice} - KONEC ###########################
+
+ #IZRIS PRVE VRSTICE POD DRSNIKOM ##############################################
+ //ureditev parametrov za tabelo
+ $steviloStolpcevPrvaVrstica = $steviloStolpcevPrvaVrsticaOrig = ceil(($slider_MaxNumLabel-$slider_MinNumLabel+1)/$slider_handle_step);//zaokrozi navzgor izracun stevila stolpcev prve vrstice
+
+ //zaradi tezav pri izrisu vmesnih stevilk, ce je teh vec kot 21 (MAXSTEVILOSTOLPCEV), je potrebno programsko omejiti stevilo stolpcev prve vrstice
+ if($steviloStolpcevPrvaVrstica>MAXSTEVILOSTOLPCEV){
+ $steviloStolpcevPrvaVrstica = MAXSTEVILOSTOLPCEV;
+ }
+
+ $parameterTabularLabelePrvaPod='';
+ if($slider_VmesneDescrLabel){ //ce je potrebno izrisati vmesne opisne labele
+ $steviloStolpcevPrvaVrstica = $slider_NumofDescrLabels;
+ }
+
+ for($i=0; $i<$steviloStolpcevPrvaVrstica; $i++){
+ if($i==0){ //ce je prvi stolpec
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'X' : 'l'); //leva poravnava stolpca prilagojena sirini
+ }elseif($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'R' : 'l'); //desna prilagojena poravnava stolpca
+ }else{ //za vse ostale stolpce med prvi in zadnjim
+ $parameterTabularLabelePrvaPod .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava
+ }
+ }
+ //ureditev parametrov za tabelo - konec
+
+ //zacetek tabele
+ //$tex .= ($export_format == 'pdf' ? '\begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabelePrvaPod.'}' : '\begin{tabular}{'.$parameterTabularLabelePrvaPod.'}');
+ $tex .= ($export_format == 'pdf' ? '\keepXColumns \begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabelePrvaPod.'}' : '\begin{tabular}{'.$parameterTabularLabelePrvaPod.'}');
+ // \keepXColumns
+ //izris vrstice in stolpcev v tabeli
+ for($i=0; $i<$steviloStolpcevPrvaVrstica; $i++){
+ //if($slider_VmesneDescrLabel&&$slider_DescriptiveLabel_defaults!=0){//ce je potrebno izrisati vmesne opisne labele ###################
+ if($slider_VmesneDescrLabel){//ce je potrebno izrisati vmesne opisne labele ###################
+ if($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+ $tex .= $descriptiveLabels[$i];
+ }else{
+ $tex .= $descriptiveLabels[$i].' & ';
+ }
+ }else{//ce je potrebno izrisati vmesne stevilske labele #######################################
+ if($i==0){ //ce je prvi stolpec
+ if($slider_MinMaxNumLabelNew==0){
+ $tex .= $slider_MinNumLabel.' & ';
+ }else{
+ $tex .= ' & ';
+ }
+ }
+ elseif($i==$steviloStolpcevPrvaVrstica-1){ //ce je zadnji stolpec
+ if($slider_MinMaxNumLabelNew==0){
+ $tex .= $slider_MaxNumLabel;
+ }
+ }else{ //za vse ostale stolpce med prvi in zadnjim
+ if($slider_VmesneNumLabel&&$steviloStolpcevPrvaVrsticaOrig<=MAXSTEVILOSTOLPCEV){ //ce so vmesne labele stevilske in je stevilo stolpcev manjsi od maximalnega dovoljenega za ustrezen izris
+ if($i==1){
+ $vmesnoStevilo=$slider_MinNumLabel+$slider_handle_step;
+ }else{
+ $vmesnoStevilo=$vmesnoStevilo+$slider_handle_step;
+ }
+ }else{
+ $vmesnoStevilo='';
+ }
+ $tex .= $vmesnoStevilo.' & ';
+ }
+ }
+ }
+ //izris vrstice in stolpcev v tabeli - konec
+
+ //konec tabele
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular} \\noindent");
+ #IZRIS PRVE VRSTICE POD DRSNIKOM - KONEC ######################################
+ //echo $tex;
+
+ #IZRIS DRUGE VRSTICE POD DRSNIKOM - LABELE PODROCIJ ###########################
+ if($slider_labele_podrocij){ //ce imamo vklopljene labele podrocij
+ $tex .= $texNewLine;
+ //ureditev parametrov za tabeli
+ $parameterTabularLabeleDrugaPod='';
+ $prazniStolpciZaGraficneOznake = '';
+ for($i=0; $i<$slider_StevLabelPodrocij; $i++){
+ $parameterTabularLabeleDrugaPod .= ($export_format == 'pdf' ? '|C|' : '|c|'); //sredinska poravnava
+ $parameterTabularLabeleTretjaPod .= ($export_format == 'pdf' ? 'C' : 'c'); //sredinska poravnava
+ if($i!=0){
+ $prazniStolpciZaGraficneOznake .= ' & ';
+ }
+ }
+ $prazniStolpciZaGraficneOznake .= $texNewLine.'\hline';
+ //ureditev parametrov za tabeli - konec
+
+ //zacetek tabele z graficnimi oznakami
+ $tex .= ($export_format == 'pdf' ? '\begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabeleDrugaPod.'}' : '\begin{tabular}{'.$parameterTabularLabeleDrugaPod.'}');
+
+ //izris prazne vrstice z graficnimi oznakami label (crta horizontal)
+ $tex .= $prazniStolpciZaGraficneOznake;
+ //izris prazne vrstice z graficnimi oznakami label (crta horizontal) - konec
+
+ //konec tabele z graficnimi oznakami
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular} \\noindent");
+
+ $tex .= $texNewLine;
+
+ //zacetek tabele z naslovi label
+ $tex .= ($export_format == 'pdf' ? '\begin{tabularx}{0.9\textwidth}{'.$parameterTabularLabeleTretjaPod.'}' : '\begin{tabular}{'.$parameterTabularLabeleTretjaPod.'}');
+
+ //izris naslovov label
+ $slider_Labela_podrocja = []; //polje, ki hrani vpisane naslove labele podrocij
+ for ($i = 1; $i <= $slider_StevLabelPodrocij; $i++) { //priprava polja z naslovi
+ $slider_Labela_podrocja[$i] = ($spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') ? $spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') : $lang['srv_new_text']);
+
+ if($i==1){ //ce je prvi stolpec
+ $tex .= $slider_Labela_podrocja[$i];
+ }else{
+ $tex .= ' & '.$slider_Labela_podrocja[$i];
+ }
+
+ }
+ //izris naslovov label - konec
+
+ //konec tabele z naslovi label
+ $tex .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular} \\noindent");
+ }
+ #IZRIS DRUGE VRSTICE POD DRSNIKOM - LABELE PODROCIJ ###########################
+ //echo $tex;
+
+ }
+ }
+ //$tex .= ' \vspace{0.3cm} ';
+
+ // Izris polj drugo - ne vem...
+ if (count($array_others) > 0) {
+ if($export_data_type==2||$nacinVnosa==0){ //ce je skrcen izpis izvoza ALI je stevilo
+ $tex .= $texNewLine;
+ }
+ //$tex .= $texNewLine;
+ foreach ($array_others AS $oKey => $other) {
+ $tex .= $symbol.' '.$other['naslov'].' ';
+ if($postavitev!=0){
+ //if($postavitev!=0&&$nacinVnosa!=1){ //ce je 0-vodoravno ob vprasanju IN ni drsnik
+ //$tex .= $texNewLine;
+ }
+ }
+ }
+
+ if($nacinVnosa==1){ //ce je drsnik
+ //if($export_data_type==1||$export_data_type==0){ //ce je dolg ali navaden izpis izvoza, ko se izrisuje drsnik
+ if(($export_data_type==1||$export_data_type==0)&&(count($array_others)==0)){ //ce je dolg ALI navaden izpis izvoza IN ni missing, ko se izrisuje drsnik
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip." ";
+ }elseif($export_data_type==2 || count($array_others) > 0){ //ce je skrcen izpis izvoza ALI so missingi
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ }
+ }else{
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ if($okvir == 1){ //ce je prazen vprasalnik, dodaj se dve prazni vrstici
+ $tex .= $this->texNewLine;
+ //$tex .= $this->texNewLine;
+ }
+ }
+
+
+/* $tex .= $texNewLine;
+ $tex .= $texNewLine; */
+ /* $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip." "; */
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+ return $tex;
+ }
+
+ }
+
+ #funkcija, ki skrbi za izris vrstice tabele po stolpcih
+ function izrisVrsticePoStolpcih($steviloStolpcevTabele=null, $array=null){
+ $tex = '';
+ for($i=0;$i<$steviloStolpcevTabele;$i++){
+ if($i!=0){ //ce ni prvi stolpec
+ $tex .= ' & '; //dodaj oznako za prehod v nov stolpec
+ }
+ $tex .= $array[$i];
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za izris vrstice tabele po stolpcih - konec
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/Vprasanja/VsotaLatex.php b/admin/survey/export/latexclasses/Vprasanja/VsotaLatex.php
new file mode 100644
index 0000000..3cd5a14
--- /dev/null
+++ b/admin/survey/export/latexclasses/Vprasanja/VsotaLatex.php
@@ -0,0 +1,167 @@
+<?php
+/***************************************
+ * Description: Priprava Latex kode za Vsota
+ *
+ * Vprašanje je prisotno:
+ * tip 18
+ *
+ * Autor: Patrik Pucer
+ * Datum: 09/2017
+ *****************************************/
+
+
+define("PIC_SIZE", "\includegraphics[width=10cm]"); //slika sirine 50mm
+define("ICON_SIZE", "\includegraphics[width=0.5cm]"); //za ikone @ slikovni tip
+define("RADIO_BTN_SIZE", 0.13);
+
+class VsotaLatex extends LatexSurveyElement
+{
+ public function __construct()
+ {
+ //parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+ protected $texBigSkip = ' \bigskip ';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new VsotaLatex();
+ }
+
+
+ public function export($spremenljivke=null, $export_format='', $questionText='', $fillablePdf=null, $texNewLine='', $usr_id=null, $db_table=null, $export_subtype=null, $preveriSpremenljivko=null, $loop_id=null){
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ //preveri, ce je kaj v bazi
+ //$userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id);
+ $userDataPresent = $this->GetUsersData($db_table, $spremenljivke['id'], $spremenljivke['tip'], $usr_id, $this->loop_id);
+ //echo "userDataPresent za spremenljivko".$spremenljivke['id']." je: ".$userDataPresent."</br>";
+
+ if($userDataPresent||$export_subtype=='q_empty'||$export_subtype=='q_comment'||$preveriSpremenljivko){ //ce je kaj v bazi ali je prazen vprasalnik ali je potrebno pokazati tudi ne odgovorjena vprasanja
+ global $lang;
+
+ // iz baze preberemo vse moznosti - ko nimamo izpisa z odgovori respondenta
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' AND hidden='0' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednosti);
+
+ $tex = '';
+
+ //nastavitve iz baze ##########################
+ $spremenljivkaParams = new enkaParameters($spremenljivke['params']);
+ //nastavitve iz baze - konec ####################
+
+ $navpicniOdgovori = array();
+ $navpicniOdgovori = [];
+
+ $odgovoriRespondenta = array();
+ $odgovoriRespondenta = [];
+
+ $texNewLineAfterTable = $texNewLine." ".$texNewLine." ".$texNewLine;
+
+ $vsota = 0;
+
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $stringTitleRow = $rowVrednost['naslov']; //odgovori na levi strani
+ array_push($navpicniOdgovori, $this->encodeText($stringTitleRow) ); //filanje polja z navpicnimi odgovori (po vrsticah)
+
+ //ureditev polja s podatki trenutnega uporabnika ######################################################
+ //$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
+ $sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$usr_id."' AND vre_id='".$rowVrednost['id']."' ");
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer: ".$userAnswer['text']." za vre_id: ".$rowVrednost['id']."</br>";
+ array_push($odgovoriRespondenta, '\\textcolor{crta}{'.$userAnswer['text'].'}' ); //filanje polja z odgovori respondenta
+ //ureditev polja s podatki trenutnega uporabnika - konec ##############################################
+
+ $vsota += $userAnswer['text']; //izracun sprotne vsote
+ }
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec
+
+ if($userDataPresent){
+ //array_push($odgovoriRespondenta, $vsota ); //filanje polja z vsoto
+ array_push($odgovoriRespondenta, '\\textcolor{crta}{'.$vsota.'}' ); //filanje polja z vsoto
+ }
+
+
+ $tex .= $this->IzrisVsotaTabela($spremenljivke, $numRowsSql, $navpicniOdgovori, $odgovoriRespondenta, $texNewLine, $texNewLineAfterTable, $export_format, 0, $userDataPresent);
+
+/* $tex .= ' \break ';
+ $tex .= ' \break '; */
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+
+ if($export_format == 'pdf'){ //ce je pdf
+ //$tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+
+ }
+
+ return $tex;
+ }
+ }
+
+ #funkcija, ki skrbi za izris vsote v tabeli ################################
+ function IzrisVsotaTabela($spremenljivke=null, $steviloVrstic=null, $navpicniOdgovori=null, $odgovoriRespondenta=null, $texNewLine='', $texNewLineAfterTable=null, $typeOfDocument=null, $fillablePdf=null, $userDataPresent=null){
+ global $lang;
+
+ //izpis kode tabela
+ $tabela = '';
+
+ $parameterTabularL = 'rl'; //parametri za tabelo
+
+ $textVsota = $this->encodeText($spremenljivke['vsota']);
+
+ if($textVsota==''){
+ $textVsota = $lang['srv_vsota_text'];
+ }
+
+ //zacetek tabele
+ $tabela .= $this->StartLatexTable($typeOfDocument, $parameterTabularL, 'tabularx', 'tabular*', 0.45, 0.2);
+
+ //argumenti za leve okvirje
+ $textboxWidthL = 0.2;
+ $textboxHeightL = 0; //ker mora biti prilagojena visina tekstu damo na 0
+ $textboxAllignment = 'c';
+ //$textboxAllignment = 'l';
+ $textboxWidth = 0.1;
+ $textboxHeight = '0.2cm';
+ $noBorders = 0;
+
+ for ($i = 1; $i <= $steviloVrstic; $i++){
+
+ $tabela .= ' '.$navpicniOdgovori[$i-1]; //odgovor pred okvirjem
+
+ //izpis latex kode za prazen okvir oz. okvir z odgovori respondenta
+ $tabela .= ' & '.$this->LatexTextBox($typeOfDocument, $textboxHeight, $textboxWidth, $odgovoriRespondenta[$i-1], $textboxAllignment, $noBorders);
+ //izpis latex kode za okvir z odgovorom oz. okvir z odgovori respondenta
+
+ $tabela .= $texNewLine;
+
+ if($i==$steviloVrstic){
+ $tabela .= ' \hline ';
+ }
+ }
+
+ //besedilo in okvir pod crto, kjer je prikazana koncna vsota
+ $tabela .= $textVsota.' & '.$this->LatexTextBox($typeOfDocument, $textboxHeight, $textboxWidth, $odgovoriRespondenta[$i-1], $textboxAllignment, $noBorders);
+ //$tabela .= $lang['srv_vsota_text'].' & '.$this->LatexTextBox($typeOfDocument, $textboxHeight, $textboxWidth, $odgovoriRespondenta[$i-1], $textboxAllignment, $noBorders);
+
+ //zakljucek tabele
+ $tabela .= $this->EndLatexTable($typeOfDocument, 'tabularx', 'tabular*');
+
+ //izpis kode tabela - konec
+
+ return $tabela;
+ }
+ #funkcija, ki skrbi za izris vsote v tabeli - konec ################################
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexAnalysis.php b/admin/survey/export/latexclasses/class.LatexAnalysis.php
new file mode 100644
index 0000000..ec00834
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexAnalysis.php
@@ -0,0 +1,287 @@
+<?php
+
+/**
+ *
+ * Class ki skrbi za izris porocila analiz v latex
+ *
+ *
+ */
+
+
+//include('../../function.php');
+include('../../vendor/autoload.php');
+include_once('../../function.php');
+include_once('../survey/definition.php');
+
+
+class LatexAnalysis{
+
+ protected $anketa;
+ protected $export_format;
+ protected $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ protected $pdf;
+ protected $currentStyle;
+ protected $spremenljivka = null;
+
+ private $headFileName = null; # pot do header fajla
+
+ protected $current_loop = 'undefined';
+
+ protected $texNewLine = '\\\\ ';
+ protected $texBigSkip = '\bigskip';
+
+
+ function __construct($anketa=null, $export_format='', $sprID = null){
+ global $site_path, $global_user_id, $admin_type, $lang;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa) ){
+
+ $this->anketa['id'] = $anketa;
+
+ $this->spremenljivka = $sprID;
+
+ $this->export_format = $export_format;
+ //echo 'To je tip analysis za anketo: '.$anketa.' za '.$this->export_format.'</br>';
+
+ SurveyAnalysis::Init($this->anketa['id']);
+ SurveyAnalysis::$setUpJSAnaliza = false;
+
+ // Poskrbimo za datoteko s podatki
+ $SDF = SurveyDataFile::get_instance();
+ $SDF->init($this->anketa['id']);
+ $SDF->prepareFiles();
+
+ $this->headFileName = $SDF->getHeaderFileName();
+
+ $loop = SurveyZankaProfiles :: Init($this->anketa, $global_user_id);
+
+ $this->current_loop = ($loop != null) ? $loop : $this->current_loop;
+ }else{
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init()){
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) ){
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }else{
+ return false;
+ }
+
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+
+ public function displayAnalysis($export_subtype=''){
+ global $lang;
+ $tex = '';
+
+ // Pripravimo podatke, ki se uporabijo v tabelah
+ # preberemo header
+ if ($this->headFileName !== null) {
+ //polovimo podatke o nastavitvah trenutnega profila (missingi..)
+ //SurveyMissingProfiles :: Init(self::$sid,$global_user_id);
+ SurveyMissingProfiles :: Init($this->spremenljivka,$this->anketa['uid']);
+ SurveyAnalysis::$missingProfileData = SurveyMissingProfiles::getProfile(SurveyAnalysis::$currentMissingProfile);
+ //echo "SurveyAnalysis::missingProfileData in displayAnalysis: ".SurveyAnalysis::$missingProfileData." </br>";
+ //echo "Indeksi SurveyAnalysis::missingProfileData v displayAnalysis: ".print_r(array_keys(SurveyAnalysis::$missingProfileData))." </br>";
+
+ //echo "display_mv_type in displayAnalysis: ".SurveyAnalysis::$missingProfileData['display_mv_type']." </br>";
+ // Preverimo ce imamo zanke (po skupinah)
+ SurveyAnalysis::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+
+ #preberemo HEADERS iz datoteke
+ SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
+ //echo $this->headFileName."</br>";
+
+ # polovimo frekvence
+ SurveyAnalysis::getFrequencys();
+
+ #odstranimo sistemske variable
+ SurveyAnalysis::removeSystemVariables();
+
+ //echo in_array($this->$spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES );
+
+ //$vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+
+ //echo 'sprID: '.$_GET['sprID'].'</br>';
+ //echo 'export_subtype: '.$export_subtype.'</br>';
+
+ /*Izpis naslova izvoza*/
+ switch ( $export_subtype ){
+ case 'sums':
+ $naslovIzvoza = $lang['export_analisys_sums'];
+ break;
+ case 'freq':
+ $naslovIzvoza = $lang['export_analisys_freq'];
+ break;
+ case 'desc':
+ $naslovIzvoza = $lang['export_analisys_desc'];
+ break;
+ case 'chart':
+ $naslovIzvoza = $lang['export_analisys_charts'];
+ break;
+ case 'crosstab':
+ $naslovIzvoza = $lang['export_analisys_crosstabs'];
+ break;
+ case 'multicrosstab':
+ $naslovIzvoza = $lang['export_analisys_multicrosstabs'];
+ break;
+ case 'mean':
+ $naslovIzvoza = $lang['export_analisys_means'];
+ break;
+ case 'ttest':
+ $naslovIzvoza = $lang['export_analisys_ttest'];
+ break;
+ case 'break':
+ $naslovIzvoza = $lang['export_analisys_break'];
+ break;
+ case 'heatmap_image_pdf':
+ $naslovIzvoza = $lang['export_analysis_heatmap_image'];
+ break;
+ }
+
+ if($export_subtype!='creport'){
+ //$tex .= '\textbf{'.$naslovIzvoza.'}'.$this->texBigSkip.$this->texNewLine;
+ $tex .= '\MakeUppercase{\huge \textbf{'.$naslovIzvoza.'}}'.$this->texBigSkip.$this->texNewLine; //{\\huge {'.$imeAnkete.'} \\par}
+ }
+
+
+ /*Izpis naslova izvoza - konec*/
+
+ //if($this->export_format == 'pdf'){
+ if($this->export_format == 'pdf'&&$export_subtype!='creport'){
+ $tex .= '\begin{tableAnalysis}'; /*zacetek environmenta z manjsim fontom*/
+ }
+
+ switch ($export_subtype){
+ case 'sums':
+ case 'freq':
+ foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
+ $analysisTable = new LatexAnalysisElement($this->anketa, $spremenljivka, $this->export_format, 0, $spid, $this->headFileName, $export_subtype);
+ //if(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]){
+ if (($spremenljivka['tip'] != 'm'
+ && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
+ && (!isset($_spid) || (isset($_spid) && $_spid == $spid))
+ && ($this->spremenljivka == $spid || $this->spremenljivka == null) ){
+ //echo "spremenljivka tip : ".$spremenljivka['tip']."</br>";
+ /*echo "spr_id: ".$this->spremenljivka."</br>";
+ echo "spid : ".$spid."</br>"; */
+ # če nimamo zank
+ if(count(SurveyAnalysis::$_LOOPS) == 0){
+ $tex .= $analysisTable->displayTablesLatex($spid, $this->export_format);
+ }
+ else{
+ // izrisemo samo eno tabelo iz enega loopa
+ if($this->current_loop > 0){
+
+ $loop = SurveyAnalysis::$_LOOPS[(int)$this->current_loop-1];
+ $loop['cnt'] = $this->current_loop;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+
+ // Izpisemo naslov zanke za skupino
+ $tex .= $analysisTable->displayTablesLatex($spid, $this->export_format);
+ }
+ // Izrisemo vse tabele spremenljivka (iz vseh loopov)
+ else{
+ $loop_cnt = 0;
+ # če mamo zanke
+ foreach(SurveyAnalysis::$_LOOPS AS $loop) {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+ $tex .= $analysisTable->displayTablesLatex($spid, $this->export_format);
+ }
+ }
+ }
+ }
+ } // end foreach SurveyAnalysis::$_HEADERS
+ break;
+ case 'desc':
+ //$analysisTable = new LatexAnalysisElement($this->anketa, $spremenljivka, $this->export_format, 0, $spid, $this->headFileName, $export_subtype);
+
+ $analysisTable = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+
+ # če nimamo zank
+ if(count(SurveyAnalysis::$_LOOPS) == 0){
+ $tex .= $analysisTable->displayTablesLatex(0, $this->export_format);
+ }
+ else{
+ // izrisemo samo eno tabelo iz enega loopa
+ if($this->current_loop > 0){
+
+ $loop = SurveyAnalysis::$_LOOPS[(int)$this->current_loop-1];
+ $loop['cnt'] = $this->current_loop;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+
+ // Izpisemo naslov zanke za skupino
+ $tex .= $analysisTable->displayTablesLatex(0, $this->export_format);
+ }
+ // Izrisemo vse tabele spremenljivka (iz vseh loopov)
+ else{
+ $loop_cnt = 0;
+ # če mamo zanke
+ foreach(SurveyAnalysis::$_LOOPS AS $loop) {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+ $tex .= $analysisTable->displayTablesLatex(0, $this->export_format);
+ }
+ }
+ }
+
+ break;
+ case 'crosstab':
+ $crossData1 = explode(",", $_GET['data1']);
+ $crossData2 = explode(",", $_GET['data2']);
+ $analysisTable = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisTable->displayCrosstabsTablesLatex($crossData1, $crossData2);
+ break;
+ case 'multicrosstab':
+ $analysisTable = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisTable->displayMultiCrosstabsTablesLatex();
+ break;
+ case 'mean':
+ $analysisTable = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisTable->displayMeanTablesLatex();
+ break;
+ case 'ttest':
+ $analysisTable = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisTable->displayTTestTablesLatex();
+ break;
+ case 'break':
+ $analysisTable = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisTable->displayBreakTablesLatex();
+ break;
+ case 'heatmap_image_pdf':
+ $analysisHeatmapImage = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisHeatmapImage->displayHeatmapImageLatex($_GET['sprID']);
+ break;
+ case 'chart':
+ $analysisChart = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisChart->displayChartLatex($_GET['sprID']);
+ break;
+ case 'creport':
+ $analysisCreport = new LatexAnalysisElement($this->anketa, 0, $this->export_format, 0, 0, $this->headFileName, $export_subtype);
+ $tex .= $analysisCreport->displayCreportLatex();
+ break;
+ }
+
+
+ //if($this->export_format == 'pdf'){
+ if($this->export_format == 'pdf'&&$export_subtype!='creport'){
+ $tex .= '\end{tableAnalysis}'; /*zakljucek environmenta z manjsim fontom*/
+ }
+
+ } // end if else ($_headFileName == null)
+ return $tex;
+ // Loop cez vsa vprasanja
+ // Znotraj loopa vsak element posebej izrisemo kot objekt LatexFreqElement - pomembno, ker zelimo recimo posamezno tabelo frekvenc (sa specificno vprasanje) izrisati tudi v kaksnem drugem porocilu (npr custom report). Zato se mora vsak element neodvisno izrisovati.
+ }
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexAnalysisElement.php b/admin/survey/export/latexclasses/class.LatexAnalysisElement.php
new file mode 100644
index 0000000..9b3cec2
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexAnalysisElement.php
@@ -0,0 +1,2022 @@
+<?php
+
+/**
+ *
+ * Class ki skrbi za izris posamezne tabele analiz
+ *
+ *
+ */
+
+
+include('../../vendor/autoload.php');
+define("MAX_STRING_LENGTH", 20);
+
+
+class LatexAnalysisElement{
+
+ var $anketa; // ID ankete
+ var $spremenljivka; // ID spremenljivke za katero izrisujemo frekvence
+ protected $spid;
+ private $headFileName = null; # pot do header fajla
+ private $dataFileName = null; # pot do data fajla
+ private $dataFileStatus = null; # status data datoteke
+ private $CID = null; # class za inkrementalno dodajanje fajlov
+
+ var $current_loop = 'undefined';
+
+ protected $texNewLine = '\\\\ ';
+ protected $horizontalLineTex = ' \hline ';
+ protected $numbering = 0; // ostevillcevanje vprasanj
+ protected $skin;
+ protected $frontpage;
+ protected $showLegenda;
+ protected $hideEmpty;
+ protected $hideAllSystem;
+
+ protected $export_subtype;
+ protected $export_format;
+
+ public $crosstabClass = null; //crosstab class
+ protected $crossData1;
+ protected $crossData2;
+
+ public $multiCrosstabClass = null; // crosstab class
+
+ protected $meansClass;
+
+ public $breakClass = null; // break class
+ protected $spr = 0; // spremenljivka za katero delamo razbitje
+ protected $seq; // sekvenca
+ protected $break_percent; // opcija za odstotke
+ public $break_charts = 0; // ali prikazujemo graf ali tabelo za razbitje
+
+ protected $sessionData; // podatki ki so bili prej v sessionu - za nastavitve, ki se prenasajo v izvoze...
+
+ protected $user_id;
+ protected $from;
+ protected $exportClass; // instanca razreda v katerem izrisujemo PDF
+ protected $analizaClass; // instanca razreda kjer imamo analize (crosstab, means, ttest...)
+
+ protected $path2Images;
+ protected $path2Charts;
+
+
+ //function __construct($anketa, $spremenljivka){ //$anketa, $export_format, $fillablePdf, $usr_id
+ //function __construct($anketa, $export_format, $fillablePdf, $usr_id, $export_subtype){
+ //function __construct($anketa, $spremenljivka=0, $export_format, $fillablePdf, $spid=0, $headFileName, $export_subtype, $crossData1=0, $crossData2=0){ //$anketa, $export_format, $fillablePdf, $usr_id
+ function __construct($anketa=null, $spremenljivka=0, $export_format='', $fillablePdf = 0, $spid=0, $headFileName=null, $export_subtype=''){
+ global $site_path, $global_user_id, $admin_type, $lang;
+
+ $this->anketa = $anketa;
+ $this->spremenljivka = $spremenljivka;
+ $this->spid = $spid;
+ $this->headFileName = $headFileName;
+ $this->export_subtype = $export_subtype;
+ $this->export_format = $export_format;
+
+
+ //Za pobiranje nastavitev
+ SurveyUserSetting::getInstance()->Init($this->anketa, $global_user_id);
+
+ //Nastavitve - Splosni prikazi analiz
+ # ali izrisujemo legendo
+ $this->showLegenda = (SurveyDataSettingProfiles :: getSetting('analiza_legenda') == true) ? true : false;
+ $this->hideEmpty = SurveyDataSettingProfiles :: getSetting('hideEmpty');
+ //echo "this->hideEmpty: ".$this->hideEmpty."</br>";
+ $this->hideAllSystem = SurveyDataSettingProfiles :: getSetting('hideAllSystem');
+ //echo "hideAllSystem: ".$this->hideAllSystem."</br>";
+
+ //Nastavitve - Splosni prikazi analiz - konec
+
+ //Nastavitve grafov
+ $this->skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
+ $this->numbering = SurveyDataSettingProfiles :: getSetting('chartNumbering');
+ $this->frontpage = SurveyDataSettingProfiles :: getSetting('chartFP');
+ //echo "Numbering: ".$this->numbering."</br>";
+ //Nastavitve grafov - konec
+
+ //echo $this->spremenljivka['tip']."</br>";
+ //echo "Spid v construct: ".$spid."</br>";
+ //echo "Spid v construct: ".$this->spid."</br>";
+ //echo "head file name: ".$this->headFileName."</br>";
+
+ //echo 'To je construct tip analysis </br>';
+
+ }
+
+
+
+ public function displayTablesLatex($spid=0, $export_format=''){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+
+
+ //echo 'funkcija displayTableLatex</br>';
+ //echo "Tip: ".$this->spremenljivka['tip']."</br>";
+ //echo "Export subtype: ".$this->export_subtype."</br>";
+
+ //TODO: Omenjene funkcije se ne potrebujejo
+ //# polovimo frekvence
+ //SurveyAnalysis::getFrequencys();
+ //
+ //#odstranimo sistemske variable
+ //SurveyAnalysis::removeSystemVariables();
+ //
+ //$vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
+
+ $tabela = '';
+
+ switch ( $this->export_subtype ){
+ case 'sums':
+ $sums = new AnalizaSums($this->anketa);
+ $tabela .= $sums->displayTableLatex($this->headFileName, $this->spremenljivka, $spid, $export_format, $this->hideEmpty);
+ break;
+ case 'freq':
+ $freq = new AnalizaFreq($this->anketa);
+ $tabela .= $freq->displayTableLatex($this->headFileName, $this->spremenljivka, $spid, $export_format, $this->hideEmpty);
+ break;
+ case 'desc':
+ $desc = new AnalizaDesc($this->anketa);
+ //$tabela .= $desc->displayTableLatex($this->headFileName, $this->spremenljivka, $spid, $export_format, $this->hideEmpty);
+ $tabela .= $desc->displayTableLatex($this->headFileName, $this->spremenljivka, $export_format, $this->hideEmpty);
+ break;
+ }
+
+ return $tabela;
+ }
+
+ public function displayCrosstabsTablesLatex($crossData1=null, $crossData2=null){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $tabela = '';
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData('crosstab_charts');
+
+ //ustvarimo crosstab objekt in mu napolnimo variable (var1, var2, checkboxi)
+ $this->crosstabClass = new SurveyCrosstabs();
+ $this->crosstabClass->Init($this->anketa['id']);
+
+ for($i=0; $i<sizeof($crossData1)/3; $i++){
+ $index = $i * 3;
+ $this->crossData1[$i] = array($crossData1[$index],$crossData1[$index+1],$crossData1[$index+2]);
+ }
+ for($i=0; $i<sizeof($crossData2)/3; $i++){
+ $index = $i * 3;
+ $this->crossData2[$i] = array($crossData2[$index],$crossData2[$index+1],$crossData2[$index+2]);
+ }
+
+ switch ( $this->export_subtype ){
+ case 'crosstab':
+ $this->crosstabClass->_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ //echo "stevilo crosstab loopov: ".count($this->crosstabClass->_LOOPS)."</br>";
+ if (count($this->crosstabClass->_LOOPS) > 0) {
+ # če mamo zanke
+ foreach ( $this->crosstabClass->_LOOPS AS $loop) {
+ $this->crosstabClass->_CURRENT_LOOP = $loop;
+ $tabela .= $this->displayCrosstabsTable();
+ }
+ } else {
+
+ // loopamo cez vse izbrane variable in izrisemo vse tabele
+ $addPage = false;
+ $this->counter = 0;
+ for($j=0; $j<sizeof($this->crossData2); $j++){
+ for($i=0; $i<sizeof($this->crossData1); $i++){
+
+ if($addPage)
+ $this->pdf->AddPage();
+ else
+ $addPage = true;
+
+ /*$this->pdf->ln(5);*/
+ $this->crosstabClass->setVariables($this->crossData2[$j][0],$this->crossData2[$j][1],$this->crossData2[$j][2],$this->crossData1[$i][0],$this->crossData1[$i][1],$this->crossData1[$i][2]);
+ $tabela .= $this->displayCrosstabsTable($this->counter);
+
+ $this->counter++;
+ }
+ }
+ }
+
+ //$tabela .= $crosstab->displayTableLatex($this->headFileName, $this->spremenljivka, $spid, $export_format, $this->hideEmpty);
+ //$tabela .= 'To je podtip crosstab';
+ break;
+ }
+ //echo "tabela: ".$tabela."</br>";
+ return $tabela;
+ }
+
+
+ public function displayMultiCrosstabsTablesLatex(){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $tabela = '';
+
+ //ustvarimo multicrosstabs objekt
+ $this->multiCrosstabClass = new SurveyMultiCrosstabs($this->anketa['id']);
+
+ if (class_exists('AnalizaMultiCrosstab')) {
+ $multiCrossTabs = new AnalizaMultiCrosstab($this->anketa);
+ }
+
+ // Napolnimo variable s katerimi lahko operiramo
+ $this->multiCrosstabClass->getVariableList();
+
+ // Izris tabele
+ $tabela .= $multiCrossTabs->displayTable($this->multiCrosstabClass, $this->export_format);
+
+ // Izris legende
+ $tabela .= $multiCrossTabs->displayLegend($this->export_format);
+
+ return $tabela;
+ }
+
+ public function displayBreakTablesLatex(){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $tabela = '';
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData();
+
+ // ustvarimo break objekt
+ $this->breakClass = new SurveyBreak($this->anketa['id']);
+ $this->spr = $this->sessionData['break']['spr'];
+ // poiščemo sekvenco
+ $this->seq = $this->sessionData['break']['seq'];
+
+ $this->break_percent = (isset($this->sessionData['break']['break_percent']) && $this->sessionData['break']['break_percent'] == false) ? false : true;
+
+ // ali prikazujemo tabele ali grafe
+ $this->break_charts = (isset($this->sessionData['break']['break_show_charts']) && (int)$this->sessionData['break']['break_show_charts'] == 1) ? 1 : 0;
+
+ if ($this->spr != 0){
+
+ if (class_exists('AnalizaBreak')) {
+ $break = new AnalizaBreak($this->anketa);
+ }
+
+ // poiščemo pripadajoče variable
+ $_spr_data = $this->breakClass->_HEADERS[$this->spr];
+
+ // poiščemo opcije
+ $options = $_spr_data['options'];
+
+ // za vsako opcijo posebej izračunamo povprečja za vse spremenljivke
+ $frequencys = null;
+ if (count($options) > 0) {
+ foreach ($options as $okey => $option) {
+
+ // zloopamo skozi variable
+ $okeyfrequencys = $this->breakClass->getAllFrequencys($okey, $this->seq, $this->spr);
+ if ($okeyfrequencys != null) {
+ if ($frequencys == null) {
+ $frequencys = array();
+ }
+ $frequencys[$okey] = $okeyfrequencys;
+ }
+ }
+ }
+ $tabela .= $break->displayBreak($this->spr, $this->seq, $frequencys, $this->breakClass, $this->break_charts, $this->export_format);
+ } else {
+ //$this->pdf->MultiCell(150, 5, $lang['srv_break_error_note_1'], 0, 'L', 0, 1, 0 ,0, true);
+ $tabela .= $lang['srv_break_error_note_1'];
+ }
+
+ //echo "TABELA: ".$tabela."</br>";
+ return $tabela;
+ }
+
+ public function displayMeanTablesLatex(){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $tabela = '';
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData();
+ // ustvarimo means objekt
+ $this->meansClass = new SurveyMeans($this->anketa['id']);
+
+ $meanData1 = $this->sessionData['means']['means_variables']['variabla1'];
+ $meanData2 = $this->sessionData['means']['means_variables']['variabla2'];
+
+ $means = array();
+
+ if (meanData1 !== null && $meanData2 !== null) {
+ $variables1 = $meanData2;
+ $variables2 = $meanData1;
+ $c1=0;
+ $c2=0;
+
+ if (class_exists('AnalizaMean')) {
+ $mean = new AnalizaMean($this->anketa);
+ }
+
+ if(is_array($variables2) && count($variables2) > 0){
+ #prikazujemo ločeno
+ if ($this->sessionData['means']['meansSeperateTables'] == true || $this->sessionData['mean_charts']['showChart'] == '1') {
+ foreach ($variables2 AS $v_second) {
+ if (is_array($variables1) && count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $_means = $this->meansClass->createMeans($v_first, $v_second);
+ if ($_means != null) {
+ $means[$c1][0] = $_means;
+ }
+ $c1++;
+ }
+ }
+ }
+ }
+ #prikazujemo skupaj
+ else {
+ foreach ($variables2 AS $v_second) {
+ if (is_array($variables1) && count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $_means = $this->meansClass->createMeans($v_first, $v_second);
+ if ($_means != null) {
+ $means[$c1][$c2] = $_means;
+ }
+ $c2++;
+ }
+ }
+ $c1++;
+ $c2=0;
+ }
+ }
+ }
+
+
+ if (is_array($means) && count($means) > 0) {
+ $count = 0;
+ foreach ($means AS $mean_sub_grup) {
+
+ if($this->sessionData['mean_charts']['showChart'] == '1'){
+ //$this->displayMeansTable($mean_sub_grup);
+ $tabela .= $mean->displayMeansTable($mean_sub_grup, $this->meansClass, $this->export_format);
+
+ //$this->displayChart($count);
+ $tabela .= $mean->displayChart($count, $meanData1, $meanData2, $this->sessionData);
+ }
+ else{
+ $tabela .= $mean->displayMeansTable($mean_sub_grup, $this->meansClass, $this->export_format);
+ }
+ $count++;
+ }
+ }
+ }
+
+ //echo "tabela: ".$tabela."</br>";
+ return $tabela;
+ }
+
+ public function displayTTestTablesLatex(){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $tabela = '';
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData();
+
+ // ustvarimo ttest objekt
+ $this->ttestClass = new SurveyTTest($this->anketa['id']);
+
+ if (class_exists('AnalizaTTest')) {
+ $tTest = new AnalizaTTest($this->anketa);
+ }
+
+ if (count($this->sessionData['ttest']['sub_conditions']) > 1 ) {
+ $variables1 = $this->ttestClass->getSelectedVariables();
+ if (count($variables1) > 0) {
+ foreach ($variables1 AS $v_first) {
+ $ttest = null;
+ $ttest = $this->ttestClass->createTTest($v_first, $this->sessionData['ttest']['sub_conditions']);
+ $tabela .= $tTest->displayTTestTable($ttest, $this->ttestClass, $this->export_format, $this->sessionData);
+ // Izrisemo graf za tabelo - zaenkrat samo admin
+ if(isset($this->sessionData['ttest_charts']['showChart']) && $this->sessionData['ttest_charts']['showChart'] == true){
+ $tabela .= $tTest->displayChart($this->sessionData, $this->ttestClass, $this->anketa);
+ }
+ }
+ }
+ }
+
+ //echo "tabela: ".$tabela."</br>";
+ return $tabela;
+ }
+
+
+ function displayCrosstabsTable() {
+ global $lang;
+ $tabela = '';
+ $crosstab = new AnalizaCrosstab($this->anketa, $this->crosstabClass, $this->counter);
+ $tabela .= $crosstab->showCrosstabsTable($this->crosstabClass, $this->export_format);
+ return $tabela;
+ }
+
+
+ public function displayChartLatex($spr_id_0=null){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $graf = '';
+ # preberemo header
+ if ($this->headFileName !== null) {
+ //polovimo podatke o nastavitvah trenutnega profila (missingi..)
+ //SurveyAnalysis::$missingProfileData = SurveyMissingProfiles::getProfile(SurveyAnalysis::$currentMissingProfile);
+
+ // Preverimo ce imamo zanke (po skupinah)
+ SurveyAnalysis::$_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ if (class_exists('AnalizaCharts')) {
+ $chart = new AnalizaCharts($this->anketa, $this->export_format, $spr_id_0);
+ }
+ # če nimamo zank
+ if(count(SurveyAnalysis::$_LOOPS) == 0){
+
+ $graf .= $chart->displayCharts();
+ }
+ else{
+ // izrisemo samo eno tabelo iz enega loopa
+ if($this->current_loop > 0){
+
+ $loop = SurveyAnalysis::$_LOOPS[(int)$this->current_loop-1];
+ $loop['cnt'] = $this->current_loop;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+
+ // Izpisemo naslov zanke za skupino
+/* $this->pdf->setFont('','B','10');
+ $this->pdf->ln(5);
+ $this->pdf->MultiCell(200, 5, $this->encodeText($lang['srv_zanka_note'].$loop['text']), 0, 'L', 0, 1, 0 ,0, true);
+ $this->pdf->ln(5);
+ $this->pdf->setFont('','','6'); */
+
+ //$graf .= $this->displayCharts();
+ $graf .= $chart->displayCharts();
+
+ }
+ // Izrisemo vse tabele spremenljivka (iz vseh loopov)
+ else{
+ $loop_cnt = 0;
+ # če mamo zanke
+ foreach(SurveyAnalysis::$_LOOPS AS $loop) {
+ $loop_cnt++;
+ $loop['cnt'] = $loop_cnt;
+ SurveyAnalysis::$_CURRENT_LOOP = $loop;
+
+ // Izpisemo naslov zanke za skupino
+/* $this->pdf->setFont('','B','10');
+ $this->pdf->ln(5);
+ $this->pdf->MultiCell(200, 5, $this->encodeText($lang['srv_zanka_note'].$loop['text']), 0, 'L', 0, 1, 0 ,0, true);
+ $this->pdf->ln(5);
+ $this->pdf->setFont('','','6'); */
+
+ //$graf .= $this->displayCharts();
+ $graf .= $chart->displayCharts();
+ }
+ }
+ }
+
+ } // end if else ($_headFileName == null)
+
+
+ return $graf;
+ }
+
+
+ public function displayCreportLatex(){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+ $creportLatex = '';
+
+ $creport = new AnalizaCReport($this->anketa, $this->export_format);
+ //$creport = new AnalizaCReport($this->anketa);
+ $anketaId = $this->anketa['id'];
+
+
+ //*******************************************************************
+ $creportProfile= $creport->getCreportProfile();
+ $what = 'creport_title_profile_'.$creportProfile;
+
+ $sqlT = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->usr_id' AND what='$what'");
+
+ if(mysqli_num_rows($sqlT) == 0){
+ $titleString = $lang['export_analisys_creport'].': '.SurveyInfo::getInstance()->getSurveyTitle();
+ }
+ else{
+ $rowT = mysqli_fetch_array($sqlT);
+ $titleString = $rowT['value'];
+ }
+
+ $naslovIzvoza = $this->encodeText($titleString);
+ //$creportLatex .= '\textbf{'.$naslovIzvoza.'}'.$this->texBigSkip.$this->texNewLine;
+ $creportLatex .= '\MakeUppercase{\huge \textbf{'.$naslovIzvoza.'}}'.$this->texBigSkip.$this->texNewLine;
+
+ if($this->export_format == 'pdf'){
+ $creportLatex .= '\begin{tableAnalysis}'; /*zacetek environmenta z manjsim fontom*/
+ }
+
+ if ($creport->getDataFileStatus() == FILE_STATUS_NO_DATA || $creport->getDataFileStatus() == FILE_STATUS_NO_FILE || $creport->getDataFileStatus() == FILE_STATUS_SRV_DELETED) {
+ $creportLatex .= 'NAPAKA!!! Manjkajo datoteke s podatki.'.$this->texNewLine;
+ }
+ else{
+ $sqlString = "SELECT * FROM srv_custom_report WHERE ank_id='$anketaId' AND usr_id='$global_user_id' AND profile='$creportProfile' ORDER BY vrstni_red ASC";
+ $sql = sisplet_query($sqlString);
+ if(mysqli_num_rows($sql) > 0){
+ // Loop po vseh dodanih elementih porocila
+ while($row = mysqli_fetch_array($sql)){
+ //echo "tipi spremenljivk: ".$row['type']."</br>";
+
+ switch($row['type']){
+ // sumarnik
+ case '1':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ $creportLatex .= $creport->displaySum($row);
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // frekvence
+ case '2':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ $creportLatex .= $creport->displayFreq($row);
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // opisne
+ case '3':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ $creportLatex .= $creport->displayDesc($row);
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // grafi
+ case '4':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ $creportLatex .= $creport->displayChart($row);
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // crosstab
+ case '5':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ // tabela
+ if($row['sub_type'] == '0'){
+ $creportLatex .= $creport->displayCrosstab($row);
+ }
+ // graf
+ else{
+ $creportLatex .= $creport->displayCrosstabChart($row);
+ }
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // mean
+ case '6':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ // tabela
+ if($row['sub_type'] == '0'){
+ $creportLatex .= $creport->displayMean($row);
+ }
+ // graf
+ else{
+ $creportLatex .= $creport->displayMeanChart($row);
+ }
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // ttest
+ case '7':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ // tabela
+ if($row['sub_type'] == '0')
+ $creportLatex .= $creport->displayTTest($row);
+ // graf
+ else
+ $creportLatex .= $creport->displayTTestChart($row);
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // text
+ case '8':
+ $creportLatex .= $creport->displayText($row['text']);
+ break;
+
+ // break
+ case '9':
+ // naslov elementa
+ $creportLatex .= $creport->displayTitle($row);
+
+ // tabela
+ if($row['sub_type'] == '0'){
+ $creportLatex .= $creport->displayBreak($row);
+ }
+ // graf
+ else{
+ $creportLatex .= $creport->displayBreakChart($row);
+ }
+
+ // Komentar elementa
+ $creportLatex .= $creport->displayComment($row['text']);
+
+ break;
+
+ // page break
+/* case '-1':
+ if($this->pdf->getY() > 30)
+ $this->pdf->AddPage();
+
+ break; */
+ }
+ }
+ }
+ }
+
+ if($this->export_format == 'pdf'){
+ $creportLatex .= '\end{tableAnalysis}'; /*zakljucek environmenta z manjsim fontom*/
+ }
+
+ //*******************************************************************
+ //echo $creportLatex."</br>";
+ return $creportLatex;
+ }
+
+ /*Moje funkcije*/
+
+ // Izrisujemo NAVADEN GRAF
+ public function displayChartsInLatex($spid=null, $type=0, $fromCharts=false, $anketa=null, $from='sums', $exportClass=null, $export_format='', $analizaClass=null){
+ global $site_path;
+ global $lang;
+ global $global_user_id;
+
+ //iniciacija spremenljivk
+ //$charts = '';
+ //$charts = '\begin{absolutelynopagebreak}'; //da se naslov in graf pojavljata na eni strani
+ $charts = ''; //da se naslov in graf pojavljata na eni strani
+ $this->anketa = $anketa;
+ $this->user_id = $global_user_id;
+ $this->from = $from;
+ $this->exportClass = $exportClass;
+ $this->export_format = $export_format;
+
+ if($analizaClass != null){
+ $this->analizaClass = $analizaClass;
+ }
+
+ $spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
+
+ // preberemo nastavitve iz baze (prej v sessionu)
+
+ SurveyUserSession::Init($this->anketa['id']);
+ $this->sessionData = SurveyUserSession::getData();
+
+ // ce ga imamo v sessionu ga preberemo
+ if(isset($this->sessionData['charts'][$spid])){
+
+ // Napolnimo podatke za graf - rabimo za cache
+ if(count(SurveyAnalysis::$_LOOPS) == 0){
+ $settings = $this->sessionData['charts'][$spid];
+
+ }else{
+ $settings = $this->sessionData['charts'][$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']];
+ }
+
+ $DataSet = SurveyChart::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ //self::displayEmptyWarning($spid);
+ return;
+ }
+
+ // preberemo ime slike iz sessiona
+ $imgName = $settings['name'];
+
+ }
+ // ce ga nimamo v sessionu
+ else{
+ // Napolnimo podatke za graf - rabimo za cache
+ $settings = SurveyChart::getDefaultSettings();
+
+ $DataSet = SurveyChart::getDataSet($spid, $settings);
+
+ // nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
+ if($DataSet == 0){
+ //self::displayEmptyWarning($spid);
+ return;
+ }
+
+ $ID = SurveyChart::generateChartId($spid, $settings, $DataSet->GetNumerus());
+
+ $Cache = new pCache('pChart/Cache/');
+ $Cache = new pCache('../survey/pChart/Cache/');
+ $imgName = $Cache->GetHash($ID,$DataSet->GetData());
+ }
+
+ // Izrisemo naslov (v creportu ne, ker imamo drugacne naslove)
+ if($fromCharts){
+
+ $stevilcenje = ($this->exportClass->numbering == 1 ? $spremenljivka['variable'].' - ' : '');
+ $title = $stevilcenje . $spremenljivka['naslov'];
+
+ if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 0){
+ $title .= ' (n = '.$DataSet->GetNumerus().')';
+ }
+
+ // Preverimo ce prebija slika stran
+/* if(isset($this->sessionData['charts'][$spid])){
+ if(count(SurveyAnalysis::$_LOOPS) == 0)
+ $settings = $this->sessionData['charts'][$spid];
+ else
+ $settings = $this->sessionData['charts'][$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']];
+
+ $imgName = $settings['name'];
+ $size = getimagesize('pChart/Cache/'.$imgName);
+ $ratio = ($size[0] / 800) < 1 ? 1 : ($size[0] / 800);
+ $height = $size[1] / 5;
+ } */
+
+ //self::$exportClass->pdf->setFont('','b','6');
+ //self::$exportClass->pdf->MultiCell(165, 5, $title, 0, 'C', 0, 1, 0 ,0, true);
+ $boldedTitle = $this->returnBold($this->encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+
+ if($spremenljivka['tip'] == 2){
+ //self::$exportClass->pdf->setFont('','','5');
+ //self::$exportClass->pdf->MultiCell(165, 1, $lang['srv_info_checkbox'], 0, 'C', 0, 1, 0 ,0, true);
+ $boldedSubTitle .= $lang['srv_info_checkbox'].$this->texNewLine;
+ }
+ //self::$exportClass->pdf->setFont('','','6');
+ }
+
+
+
+ // IZRIS GRAFA
+ $this->path2Charts = $site_path.'admin/survey/pChart/Cache/';
+
+ //kopiranje slik kot png, ker latex mora imeti extension za prikazovanje slike
+ //copy('pChart/Cache/'.$imgName,'pChart/Cache/'.$imgName.'.png');
+
+ ##### ZA TESTIRANJE ureditev pretvorbe slike v pdf
+ chdir($this->path2Charts);
+ $pretvoriPng_v_Pdf = "/usr/bin/convert $imgName $imgName.pdf";
+ shell_exec($pretvoriPng_v_Pdf);
+ ##### ZA TESTIRANJE ureditev pretvorbe slike v pdf - konec
+
+ $texImageOnly = " \\includegraphics[scale=0.66]{".$this->path2Charts."".$imgName."} "; //latex za sliko
+ //$texImageOnly = " \\includegraphics[scale=0.66, draft=false]{".$this->path2Charts."".$imgName."} "; //latex za sliko
+ //$texImageOnly = " \\includegraphics[scale=0.85]{".$this->path2Charts."".$imgName."} "; //latex za sliko
+ //echo "ime slike: $texImageOnly </br>";
+
+
+ $charts .= $this->returnCentered($boldedTitle.$boldedSubTitle.$texImageOnly, $export_format); //vrni sredinsko poravnana naslov in slika
+
+ # izpišemo še tekstovne odgovore za polja drugo
+ $_answersOther = $DataSet->GetOther();
+ if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
+ foreach ($_answersOther AS $oAnswers) {
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+ if(count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0){
+ $charts .= $this->outputOtherAnswers($oAnswers, '', $export_format);
+ }
+ }
+ }
+
+
+ // Dodamo space (v creportu ne, ker imamo drugacen izpis)
+ //if($fromCharts)
+ //self::$exportClass->pdf->setY(self::$exportClass->pdf->getY() + 10);
+
+ //$charts .= '\end{absolutelynopagebreak}';
+ //echo "Charts: ".$charts."</br>";
+ return $charts;
+ }
+
+
+ #moja funkcija encodeText
+ function encodeText($text=''){
+ // popravimo sumnike ce je potrebno
+ //$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
+ //$text = str_replace("&scaron;","š",$text);
+ //echo "Encoding ".$text."</br>";
+
+ //resevanje razbirajanja predolgih neprekinjenih besed in URL - spremenljivke za kasnejsi prilagojen izpis
+ $numOfWords = str_word_count($text, 0); //stevilo besed v besedilu
+ $numOfSpacesPrej = substr_count($text, ' '); //stevilo presledkov v besedilu
+ $stringLength = strlen($text); //dolzina besedila
+
+ $findSpace = ' ';
+ $findHttp = 'http://';
+ $findHttps = 'https://';
+ $posHttp = strpos($text, $findHttp);
+ $posHttps = strpos($text, $findHttps);
+ $isURL = 0;
+ /* if($posHttp !== false || $posHttps !== false) { //imamo URL naslov
+ $isURL = 1;
+ } */
+ //resevanje razbirajanja predolgih neprekinjenih besed in URL - konec
+
+ if($text == ''){ //ce ni teksta, vrni se
+ return;
+ }
+ $textOrig = $text;
+ $findme = '<br />';
+ $findmeLength = strlen($findme);
+ $findImg = '<img';
+ $findImgLength = strlen($findImg);
+
+ $pos = strpos($text, $findme);
+ $posImg = strpos($text, $findImg);
+
+ //ureditev izrisa slike
+ if($posImg !== false){
+ $numOfImgs = substr_count($text, $findImg); //stevilo '<br />' v tekstu
+ $posImg = strpos($text, $findImg);
+ $textPrej = '';
+ $textPotem = '';
+ for($i=0; $i<$numOfImgs; $i++){
+ $posImg = strpos($text, $findImg);
+ $textPrej = substr($text, 0, $posImg); //tekst do img
+ $textPotem = substr($text, $posImg); //tekst po img, z vkljuceno hmlt kodo z img
+ $posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
+ $textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
+
+ //$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
+ $text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2Images."".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
+
+ }
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
+ $findImgCode = '\includegraphics';
+ $posOfImgCode = strpos($text, $findImgCode);
+ //echo $posOfImgCode."</br>";
+ $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode
+ //echo $textToImgCode."</br>";
+ $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode
+ //echo $textFromImgCode."</br>";
+ $findImgCodeEnd = '}';
+ //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd);
+ $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd);
+ //echo $posOfImgCodeEnd."</br>";
+ $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd
+ //echo $textAfterImgCode."</br>";
+ $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1);
+ //echo $textOfImgCode."</br>";
+
+ $text = $textToImgCode.$textAfterImgCode;
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - konec
+ }
+ //ureditev izrisa slike - konec
+
+ //ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
+ $text = str_replace('\\','\textbackslash{} ',$text);
+ //$text = str_replace('{','\{',$text);
+ //$text = str_replace('}','\}',$text);
+ $text = str_replace('$','\$ ',$text);
+ $text = str_replace('#','\# ',$text);
+ //$text = str_replace('%','\% ',$text);
+ $text = str_replace('%','\%',$text);
+ $text = str_replace('€','\euro',$text);
+ $text = str_replace('^','\textasciicircum{} ',$text);
+ //$text = str_replace('_','\_ ',$text);
+ $text = str_replace('_','\_',$text);
+ $text = str_replace('~','\textasciitilde{} ',$text);
+ if(strpos($text, '&amp;')){ //ce je prisotno v besedilu &amp;'
+ $text = str_replace('&amp;','\& ',$text);
+ }else{
+ $text = str_replace('&','\& ',$text);
+ }
+
+ $andSymbolPresent = 0;
+ $posAndSymbolPresent = strpos($text,'&amp;');
+ if($posAndSymbolPresent !== false){ //ce je v besedilu prisoten '&' zapisan kot '&amp;'
+ $text = str_replace('&amp;','\&',$text);
+ $andSymbolPresent = 1;
+ }
+ if($andSymbolPresent == 0){
+ $text = str_replace('&','\&',$text);
+ }
+
+ //$text = str_replace('&lt;','\textless ',$text);
+ $text = str_replace('&lt;','\textless',$text);
+ //$text = str_replace('&gt;','\textgreater ',$text);
+ $text = str_replace('&gt;','\textgreater',$text);
+ $text = str_replace('&nbsp;',' ',$text);
+ //ureditev posebnih karakterjev za Latex - konec
+
+ //ureditev grskih crk
+ $text = str_replace('α','\textalpha ',$text);
+ $text = str_replace('β','\textbeta ',$text);
+ $text = str_replace('γ','\textgamma ',$text);
+ $text = str_replace('δ','\textdelta ',$text);
+ $text = str_replace('ε','\textepsilon ',$text);
+ $text = str_replace('ζ','\textzeta ',$text);
+ $text = str_replace('η','\texteta ',$text);
+ $text = str_replace('θ','\texttheta ',$text);
+ $text = str_replace('ι','\textiota ',$text);
+ $text = str_replace('κ','\textkappa ',$text);
+ $text = str_replace('λ','\textlambda ',$text);
+ $text = str_replace('μ','\textmugreek ',$text);
+ $text = str_replace('ν','\textnu ',$text);
+ $text = str_replace('ξ','\textxi ',$text);
+ //$text = str_replace('ο','\textomikron ',$text);
+ $text = str_replace('π','\textpi ',$text);
+ $text = str_replace('ρ','\textrho ',$text);
+ $text = str_replace('σ','\textsigma ',$text);
+ $text = str_replace('τ','\texttau ',$text);
+ $text = str_replace('υ','\textupsilon ',$text);
+ $text = str_replace('φ','\textphi ',$text);
+ $text = str_replace('χ','\textchi ',$text);
+ $text = str_replace('ψ','\textpsi ',$text);
+ $text = str_replace('ω','\textomega ',$text);
+ //ureditev grskih crk - konec
+
+ //ureditev preureditve html kode ul in li v latex itemize
+ $findUl = '<ul';
+ $findUlLength = strlen($findUl);
+ $posUl = strpos($text, $findUl);
+ if($posUl !== false){
+ //echo "text prej: ".$text."</br>";
+ $numOfUl = substr_count($text, $findUl); //stevilo '<ul' v tekstu
+ //echo "numOfUl ".$numOfUl."</br>";
+ ######################
+ if($numOfUl!=0){
+ $text = str_replace('<ul>','\begin{itemize} ', $text);
+ $text = str_replace('<li>','\item ', $text);
+ $text = str_replace('</ul>','\end{itemize} ', $text);
+ }
+ //echo "prazno v html: ".strpos($text, '\r')."</br>";
+ //echo "text potem: ".$text."</br>";
+ ######################
+ }
+
+ //ureditev preureditve html kode ul in li v latex itemize - konec
+
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+ if($posImg !== false){
+ $text = substr_replace($text, $textOfImgCode, $posOfImgCode, 0);
+ }
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+
+ if($pos === false && $posImg === false) { //v tekstu ni br in img
+ //return $text;
+/* echo "encode pred strip: ".$text."</br>";
+ echo "encode po strip: ".strip_tags($text)."</br>";
+ return strip_tags($text); */
+ }else { //v tekstu sta prisotna br ali img
+ $text2Return = ''; //tekst ki bo vrnjen
+
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
+ if($pos !== false){
+ $pos = strpos($text, $findme);
+ $numOfBr = substr_count($text, $findme); //stevilo '<br />' v tekstu
+ for($i=0; $i<$numOfBr; $i++){
+ if($i == 0){ //ce je prvi najdeni '<br />'
+ $textPrej = substr($text, 0, $pos);
+ $textPotem = substr($text, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ $text2Return .= $textPrej.' \break '.$textPotem;
+ }else{
+ $text2Return .= $textPrej.' \break ';
+ }
+ }else{ //drugace
+ $pos = strpos($textPotem, $findme);
+ $textPrej = substr($textPotem, 0, $pos);
+ $textPotem = substr($textPotem, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ $text2Return .= $textPrej.' \break '.$textPotem;
+ }else{
+ $text2Return .= $textPrej.' \break ';
+ }
+ }
+ }
+ $text = $text2Return;
+ }
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
+/* echo "encode pred strip: ".$text."</br>";
+ echo "encode po strip: ".strip_tags($text)."</br>";
+ return strip_tags($text); //vrni tekst brez html tag-ov */
+ }
+
+ //ureditev odstranjevanja presledkov, ce so na zacetku ali koncu besedila
+ if(($numOfSpacesPrej)){ //ce so prisotni presledki
+ $odstranjeno = 0; //belezi, ali so bili presledki odstranjeni iz zacetka ali konca
+ for($numPresledkovTmp = 1; $numPresledkovTmp <= $numOfSpacesPrej; $numPresledkovTmp++){ //za vsak presledek
+ $posSpace = strpos($text, $findSpace); //najdi pozicijo presledka v besedilu//preveri, kje se nahaja
+ if($posSpace==0){ //ce je presledek na zacetku besedila
+ $text = substr_replace($text, '', $posSpace, 1); //odstrani presledek iz besedila
+ $stringLength = strlen($text);
+ $odstranjeno = 1;
+ }elseif($posSpace==$stringLength){ //ce je presledek na koncu besedila
+ $text = substr_replace($text, '', $posSpace, 1); //odstrani presledek iz besedila
+ $stringLength = strlen($text);
+ $odstranjeno = 1;
+ }
+ }
+ $numOfSpacesPrej = substr_count($text, ' '); //stevilo presledkov v besedilu
+ }
+ //ureditev odstranjevanja presledkov, ce so na zacetku ali koncu besedila - konec
+
+ //echo "v besedilu $text je stevilo presledkov $numOfSpacesPrej in besed $numOfWords </br>";
+ //priprava izpisa zelo dolgega besedila brez presledkov s seqsplit (URL, email, ...)
+ if( ($numOfSpacesPrej == 0 && $stringLength >= MAX_STRING_LENGTH && $odstranjeno) ){ //ce v besedilu ni presledkov in je besedilo daljse od max dovoljene dolzine
+ $text = "\seqsplit{".$text."}"; //ni v redu seqsplit, ker ne dela, če so posebni znaki
+ }
+ //priprava izpisa zelo dolgega besedila brez presledkov - konec
+
+ return strip_tags($text); //vrni tekst brez html tag-ov
+ }
+
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele ##################################################################################
+ #argumenti 1. export_format, 2. parametri tabele, 3. tip tabele za pdf, 4. tip tabele za rtf, 5. sirina pdf tabele (delez sirine strani), 6. sirina rtf tabele (delez sirine strani)
+ function StartLatexTable($export_format='', $parameterTabular='', $pdfTable='', $rtfTable='', $pdfTableWidth=null, $rtfTableWidth=null){
+ $tex = '';
+ $tex .= '\keepXColumns';
+ if($export_format == 'pdf'){
+ $tex .= '\begin{'.$pdfTable.'}';
+ if($pdfTable=='tabularx'){
+ //$tex .= '{'.$pdfTableWidth.'\textwidth}';
+ $tex .= '{\hsize}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }elseif($export_format == 'rtf'||$export_format == 'xls'){
+ $tex .= '\begin{'.$rtfTable.'}';
+ if($rtfTable=='tabular*'){
+ $tex .= '{'.$pdfTableWidth.'\textwidth}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele - konec ##########################################################################
+
+ function outputSumaValidAnswerVertical($counter=null,$_sequence=null,$spid=null,$_options=array()) {
+ global $lang;
+
+ $text = array();
+ $texoutputSumaValidAnswerVertical = '';
+
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'textAnswerExceed'=>false # ali presegamo število tekstovnih odgovorov za prikaz
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ $_brez_MV = ((int)SurveyAnalysis::$currentMissingProfile == 2) ? TRUE : FALSE;
+
+ $_sufix = '';
+
+ $text[] = $this->encodeText($lang['srv_anl_valid']);
+ $text[] = $this->encodeText($lang['srv_anl_suma1']);
+
+ $text[] = $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0);
+
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+
+ $text[] = '';
+
+
+ $exportformat = $options['exportFormat'];
+ $brezHline = $this->getBrezHline($exportformat);
+
+ $outputSumaValidAnswerVertical .= self::tableRow($text, $brezHline);
+ return $outputSumaValidAnswerVertical;
+ //$counter++;
+ //return $counter;
+ }
+
+ function outputValidAnswerVertical($counter=null,$vkey='', $vAnswer=null, $_sequence=null,$spid=null, &$_kumulativa=null,$_options=array()) {
+ global $lang;
+ //echo "funkcija outputValidAnswerVertical </br>";
+ $text = array();
+
+ $texoutputValidAnswerVertical = '';
+
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'textAnswerExceed'=>false # ali presegamo število tekstovnih odgovorov za prikaz
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+ $cssBck = ' '.SurveyAnalysis::$cssColors['0_' . ($counter & 1)];
+
+ $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_kumulativa += $_valid;
+
+ # ali presegamo število prikazanih vrstic, takrat v zadnji prikazani dodamo link več.. ostale vrstice pa skrijemo
+/* if ($options['textAnswerExceed'] == true) {
+ if ($counter == TEXT_ANSWER_LIMIT ) {
+ # link za več
+ $show_more = '<div id="valid_row_togle_'.$_sequence.'" class="floatRight blue pointer" onclick="showHidenTextRow(\''.$_sequence.'\');return false;">(več...)</div>'.NEW_LINE;
+ } elseif ($counter > TEXT_ANSWER_LIMIT ) {
+ $hide_row = ' hidden';
+ $_exceed = true;
+ }
+ } */
+
+ //if ($counter < TEXT_MAX_ANSWER_LIMIT) {
+ $text[] = '';
+
+ $addText = (($options['isTextAnswer'] == false && (string)$vkey != $vAnswer['text']) ? ' ('.$vAnswer['text'] .')' : '');
+ //$text[] = $this->encodeText(' '.$vkey.$addText);
+ $text[] = $this->snippet($this->encodeText(' '.$vkey.$addText), 400);
+
+ $text[] = (int)$vAnswer['cnt'];
+
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_kumulativa, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber($_kumulativa, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+
+ /*} elseif ($counter == TEXT_MAX_ANSWER_LIMIT ) {
+ echo '<tr id="'.$spid.'_'.$_sequence.'_'.$counter.'" name="valid_row_'.$_sequence.'">';
+ echo '<td class="anl_bl anl_ac anl_br gray anl_dash_bt anl_dash_bb" colspan="'.(6+(int)SurveyAnalysis::$_HEADERS[$spid]['show_valid_percent']+((int)SurveyAnalysis::$_SHOW_LEGENDA*2)).'"> . . . Prikazujemo samo prvih '.TEXT_MAX_ANSWER_LIMIT.' veljavnih odgovorov!</td>';
+ echo '</tr>';
+ }*/
+
+ $exportformat = $options['exportFormat'];
+ $brezHline = $this->getBrezHline($exportformat);
+
+ $texoutputValidAnswerVertical .= self::tableRow($text, $brezHline);
+ //echo "Besedilo na koncu funkcije outputValidAnswerVertical:".$texoutputValidAnswerVertical."</br>";
+ return $texoutputValidAnswerVertical;
+/* $counter++;
+ return $counter; */
+ }
+
+ function outputInvalidAnswerVertical($counter=null,$vkey='', $vAnswer=null, $_sequence=null, $spid=null, $_options=array()) {
+ global $lang;
+
+ $text = array();
+ $texoutputInvalidAnswerVertical = '';
+
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'textAnswerExceed'=>false # ali presegamo število tekstovnih odgovorov za prikaz
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $exportformat = $options['exportFormat'];
+ $brezHline = $this->getBrezHline($exportformat);
+
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+
+ $_sufix = '';
+
+ //$_Z_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE; //po tej stari kodi ne pridem do zelene informacije, tudi stari izvozi ne delajo pravilno, ce se zeli pokazati missinge
+
+ $_Z_MV = !$this->hideEmpty;
+
+ //$_Z_MV = 1;
+ if($_Z_MV){
+ //echo "this->hideEmpty: ".$this->hideEmpty."</br>";
+ //$text[] = $this->encodeText($lang['srv_anl_missing1']);
+ //$text[] = '\multirow{ '.$vAnswer['cnt'].'}{*}{ '.$this->encodeText($lang['srv_anl_missing1']).' }';
+
+ $text[] = '';
+
+ $text[] = $this->encodeText($vkey.' (' . $vAnswer['text'].')');
+
+ $text[] = $this->encodeText((int)$vAnswer['cnt']);
+
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+
+ $text[] = '';
+ $text[] = '';
+
+ $texoutputInvalidAnswerVertical .= $this->tableRow($text, $brezHline);
+ }
+ $counter++;
+ //echo "Besedilo na koncu funkcije outputInvalidAnswerVertical:".$texoutputInvalidAnswerVertical."</br>";
+ return $texoutputInvalidAnswerVertical;
+
+ /*return $counter; */
+ }
+
+ function outputSumaInvalidAnswerVertical($counter=null, $_sequence=null, $spid=null, $_options = array()) {
+ global $lang;
+
+ $texoutputSumaInvalidAnswerVertical = '';
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'textAnswerExceed'=>false # ali presegamo število tekstovnih odgovorov za prikaz
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $exportformat = $options['exportFormat'];
+ $brezHline = $this->getBrezHline($exportformat);
+
+ $cssBck = ' '.SurveyAnalysis::$cssColors['text_' . ($counter & 1)];
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+
+ //$_brez_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+ $_brez_MV = $this->hideEmpty;
+ if(!$_brez_MV){
+ $text = array();
+
+ //$text[] = $this->encodeText($lang['srv_anl_missing1']);
+ $text[] = '';
+
+ $text[] = $this->encodeText($lang['srv_anl_suma1']);
+ //$text[] = $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt']);
+
+ $answer['cnt'] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
+ $text[] = $this->encodeText((int)$answer['cnt']);
+
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = '';
+ $text[] = '';
+
+ $texoutputSumaInvalidAnswerVertical .= $this->tableRow($text, $brezHline);
+ }
+ //echo $texoutputSumaInvalidAnswerVertical."</br>";
+ return $texoutputSumaInvalidAnswerVertical;
+/* $counter++;
+ return $counter; */
+ }
+
+ function outputSumaVertical($counter=null, $_sequence=null, $spid=null, $_options = array()) {
+ global $lang;
+
+ $texoutputSumaVertical = '';
+ # opcije
+ $options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
+ 'isOtherAnswer' => false, # ali je odgovor Drugo
+ 'inline_legenda' => true, # ali je legenda inline ali v headerju
+ 'textAnswerExceed'=>false # ali presegamo število tekstovnih odgovorov za prikaz
+ );
+ foreach ($_options as $_oKey => $_option) {
+ $options[$_oKey] = $_option;
+ }
+
+ $cssBck = ' '.SurveyAnalysis::$cssColors['0_' .($counter & 1)];
+
+ //$_brez_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
+
+/* if($options['exportFormat'] == 'xls'){
+ $brezHline = 1;
+ }else{
+ $brezHline = 0;
+ } */
+
+ $exportformat = $options['exportFormat'];
+ $brezHline = $this->getBrezHline($exportformat);
+
+ $_brez_MV = $this->hideEmpty;
+ if(!$_brez_MV){
+
+ $text = array();
+
+ $text[] = '';
+ $text[] = $this->encodeText($lang['srv_anl_suma2']);
+ $text[] = $this->encodeText((SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0));
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = $this->encodeText(self::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = '';
+ $text[] = '';
+
+
+ $texoutputSumaVertical .= $this->tableRow($text, $brezHline);
+ }
+ return $texoutputSumaVertical;
+
+ }
+
+ function outputOtherAnswers($oAnswers=null, $parameterTabular='', $export_format='') {
+ global $lang;
+ $spid = $oAnswers['spid'];
+ $_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
+ $_sequence = $_variable['sequence'];
+ $_frekvence = SurveyAnalysis::$_FREQUENCYS[$_variable['sequence']];
+
+ $this->export_format = $export_format;
+
+ $texOutputOtherAnswers = '';
+
+ //Priprava parametrov za tabelo
+ $steviloStolpcevParameterTabular = 6;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'P|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X|' : 'c|'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ }
+
+ }
+ //Priprava parametrov za tabelo - konec
+
+ //zacetek latex tabele z obrobo za Drugo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texOutputOtherAnswers .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+ if($export_format != 'xls'){
+ $texOutputOtherAnswers .= $this->horizontalLineTex; /*obroba*/
+ }
+ //zacetek latex tabele z obrobo za Drugo - konec
+
+ /*Naslovni vrstici tabele*/
+ //prva vrstica tabele
+ $texOutputOtherAnswers .= $this->encodeText($_variable['variable'])." & \multicolumn{5}{l|}{".$this->encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )')."} ".$this->texNewLine;
+ //$texOutputOtherAnswers .= $this->encodeText($_variable['variable'])." & \multicolumn{5}{X|}{".$this->encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )')."} ".$this->texNewLine;
+ if($export_format != 'xls'){
+ $texOutputOtherAnswers .= $this->horizontalLineTex; /*obroba*/
+ $brezHline = 1;
+ }
+
+ //druga vrstica tabele z naslovi stolpcev
+ $texOutputOtherAnswers .= $this->tableHeader();
+
+ //$this->pdf->setFont('','','6');
+
+ /*Naslovni vrstici tabele - konec*/
+
+
+
+ //prva vrstica
+/* $this->pdf->setFont('','b','6');
+ $this->pdf->ln(5);
+ $this->pdf->MultiCell(18, $height, $this->encodeText($_variable['variable']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(162, $height, $this->encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )'), 1, 'L', 0, 1, 0 ,0, true); */
+
+ //druga vrstica
+/* $this->tableHeader();
+ $this->pdf->setFont('','','6'); */
+ // konec naslovne vrstice
+
+ $counter = 1;
+ $_kumulativa = 0;
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
+ if ($vAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ //$counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,array('isOtherAnswer'=>true));
+ $texOutputOtherAnswers .= self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,array('isOtherAnswer'=>true, 'exportFormat'=>$export_format));
+ }
+ }
+ # izpišemo sumo veljavnih
+ //$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ $texOutputOtherAnswers .= self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true, 'exportFormat'=>$export_format));
+ }
+ if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
+ $_Z_MV = !$this->hideEmpty;
+ if($_Z_MV){ //ce je potrebno izpisati tudi manjkajoce
+ $texOutputOtherAnswers .= $this->encodeText($lang['srv_anl_missing1']);
+ }
+ foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
+ if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
+ //$counter = self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,array('isOtherAnswer'=>true));
+ $texOutputOtherAnswers .= self::outputInvalidAnswerVertical($counter,$ikey,$iAnswer,$_sequence,$spid,array('isOtherAnswer'=>true, 'exportFormat'=>$export_format));
+ }
+ }
+ # izpišemo sumo veljavnih
+ //$counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ //$texOutputOtherAnswers .= self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ $texOutputOtherAnswers .= self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true, 'exportFormat'=>$export_format));
+ }
+ #izpišemo še skupno sumo
+ //$texOutputOtherAnswers .= self::outputSumaVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
+ $texOutputOtherAnswers .= self::outputSumaVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true, 'exportFormat'=>$export_format));
+
+ //zaljucek latex tabele za Drugo
+ $texOutputOtherAnswers .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ //zaljucek latex tabele za Drugo - konec
+
+ return $texOutputOtherAnswers;
+ }
+
+ function tableHeader($export_format=''){
+ global $lang;
+
+ $tableHeader = '';
+
+ $naslov = array();
+ $naslov[] = '';
+ $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleAnswers']);
+ $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleFrekvenca']);
+ $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleOdstotek']);
+ $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleVeljavni']);
+ $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleKumulativa']);
+
+ $params = array('border' => 'TB', 'bold' => 'B', 'align2' => 'C');
+
+ //$tableHeader .= $this->tableRow($naslov, $params);
+ if($export_format=='xls'){
+ $brezHline = 1;
+ }else{
+ $brezHline = 0;
+ }
+
+ $tableHeader .= $this->tableRow($naslov, $brezHline);
+ /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
+ $linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
+ $height = 1; //$height = $this->getCellHeight($this->encodeText($arrayText[1]), 90);
+
+ //ce smo na prelomu strani
+/* if( ($this->pdf->getY() + $height) > 270){
+ $this->drawLine();
+ $this->pdf->AddPage('P');
+ $arrayParams['border'] .= 'T';
+ } */
+/*
+ if($arrayParams['align2'] != 'C')
+ $arrayParams['align2'] = 'L';
+
+ for($i=0;$i<count($naslov);$i++){
+ $tableHeader .= $naslov[$i].$this->texNewLine;
+ echo "naslovi v tabeli: ".$naslov[$i]."</br>";
+ } */
+
+ return $tableHeader;
+ }
+
+ //funkcija skrbi za izpis multicol celice
+ function MultiColCellLatex($steviloVmesnihStolpcevPodvrstic=null, $text='', $odZacetka=0){
+ $tabela = '';
+ //echo "steviloVmesnihStolpcevPodvrstic: $steviloVmesnihStolpcevPodvrstic</br>";
+ if($steviloVmesnihStolpcevPodvrstic==1){ //ce je 1, ne sme biti multicolumn{1}, saj so drugace tezave z izpisom
+ $tabela .= " & ".$text." ";
+ }else{
+ $steviloTabColSep = ($steviloVmesnihStolpcevPodvrstic-1)*2;
+ $steviloArrayrulewidth = ($steviloVmesnihStolpcevPodvrstic-1);
+ if($odZacetka==0){
+ //$tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}{";//zacetek multicol
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{>{\hsize=\dimexpr".$steviloVmesnihStolpcevPodvrstic."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{";//zacetek multicol
+ }else{
+ //$tabela .= " \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}{";//zacetek multicol
+ $tabela .= " \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{>{\hsize=\dimexpr".$steviloVmesnihStolpcevPodvrstic."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{";//zacetek multicol
+ }
+ $tabela .= $text;
+ if($odZacetka==0){
+ $tabela .= '} ';//zakljucek multicol
+ }else{
+ $tabela .= '} &';//zakljucek multicol
+ }
+ }
+
+ //echo "fukcija s tekstom: ".$tabela." </br>";
+ return $tabela;
+ }
+
+ //funkcija skrbi za izpis multirow celice, ce je ta potrebna
+ function MultiRowCellLatex($steviloVmesnihVrstic=null, $text='', $tabela2 = '', $tabela3 = '', $cols=1){
+ $tabela = '';
+ global $lang;
+ //echo "cols: $cols</br>";
+ //if($steviloVmesnihVrstic > 1){ //ce je potrebno multirow prikazovanje
+ if($steviloVmesnihVrstic > 1 && (($tabela2!=''&&$tabela3=='') || ($tabela2!=''&&$tabela3!=''))){ //ce je potrebno multirow prikazovanje
+ $tabela .= '\multirow{'.$steviloVmesnihVrstic.'}{*}{'; //zacetek multirow
+ }
+ $tabela .= $text;
+ /* if($cols==0 && $text==$this->encodeText($lang['srv_analiza_crosstab_skupaj'])){ //premaknil nize, ker je delalo težave pri izpisu daljsih tabel
+ $tabela .= ' & ';
+ } */
+ //if($steviloVmesnihVrstic > 1){ //ce je potrebno multirow prikazovanje
+ if($steviloVmesnihVrstic > 1 && (($tabela2!=''&&$tabela3=='') || ($tabela2!=''&&$tabela3!=''))){ //ce je potrebno multirow prikazovanje
+ $tabela .= '}'; //konec multirow
+ }
+
+ if($cols==0 && $text==$this->encodeText($lang['srv_analiza_crosstab_skupaj'])){
+ $tabela .= ' & ';
+ }
+ //echo $tabela."</br>";
+ return $tabela;
+ }
+
+ function DisplayLatexCells($crossChk='', $podVrstice=null, $colNum=null, $steviloVmesnihStolpcevPodvrstic=2, $niSodo = 0){
+ $tabela = '';
+ //echo "steviloVmesnihStolpcevPodvrstic: $steviloVmesnihStolpcevPodvrstic </br>";
+ //echo "crossChk: $crossChk </br>";
+ if($steviloVmesnihStolpcevPodvrstic > 1 && $podVrstice){ //ce je potrebno multicol prikazovanje
+ //if($niSodo == 1 && $podVrstice && $steviloVmesnihStolpcevPodvrstic > 1){ //ce je potrebno multicol prikazovanje
+ $tabela .= $this->MultiColCellLatex($colNum, $crossChk);
+ }else{
+ $tabela .= " & ";
+ $tabela .= $crossChk;
+ }
+ return $tabela;
+ }
+
+ //function tableRow($arrayText, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $steviloPodstolpcev){
+ //function tableRow($arrayText, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $color='', $export_format, $steviloPodstolpcev){
+ function tableRow($arrayText=[], $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $color='', $export_format='', $steviloPodstolpcev=[]){
+ $tableRow = '';
+ /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
+ $linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
+ $height = 1; //$height = $this->getCellHeight($this->encodeText($arrayText[1]), 90);
+/* echo $arrayText[0]."</br>";
+ echo $arrayText[1]."</br>";
+ echo "brez hline: ".$brezHline."</br>"; */
+
+ if($arrayParams['align2'] != 'C')
+ $arrayParams['align2'] = 'L';
+ //echo "velikost polja s tekstom: ".count($arrayText)."</br>";
+
+ if($export_format == 'pdf'){
+ if($color=='blue'){
+ //$cellBgColor = 'cyan';
+ $cellBgColor = 'crta';
+ $color = 'besedilo';
+ }elseif($color=='red'){
+ //$cellBgColor = 'pink';
+ $cellBgColor = 'crtaGraf';
+ $color = 'besedilo';
+ }
+ $cellColoring = ' \cellcolor{'.$cellBgColor.'} ';
+ }else{ //drugace, ce je rtf
+ $cellColoring = '';
+ if($color=='blue'){
+ $color = 'cyan'; //v rtf pride modra
+ }elseif($color=='red'){
+ //$color = 'green'; //v rtf pride cyan
+ //$color = 'red'; //v rtf pride viola
+ $color = 'yellow'; //v rtf pride rdece
+ }
+ }
+
+ for($i=0;$i<count($arrayText);$i++){
+ //echo "array text: ".$arrayText[$i]."</br>";
+
+ ####### koda, kjer sem testiral seqsplit za ureditev dolgih besed
+/* if($arrayText[$i]==''){ //ce je prazen
+ $arrayBesedilo = $arrayText[$i];
+ }else{
+ ##################### preveri, ali ima podatek, ki mora se pojaviti v celici na koncu presledek, to je pomembno za delovanje razbijanja dolgih besed v celici tabele oz. \seqsplit
+ $zadnjiChar = substr($arrayText[$i], -1);
+ if($zadnjiChar == ' '){
+ $arrayText[$i] = substr($arrayText[$i], 0, -1);
+ }
+ #####################
+ ##################### ureditev specialnih znakov, da se jih da izpisati
+ //$arrayText[$i] = $this->pripraviBesediloZaSeqsplit($arrayText[$i]);
+ $arrayText[$i] = $this->pripraviBesediloZaSeqsplit($arrayText[$i]);
+ #####################
+ $arrayBesedilo = '\seqsplit{'.$arrayText[$i].'}';
+ } */
+ ####### koda, kjer sem testiral seqsplit za ureditev dolgih besed - konec
+
+ $arrayBesedilo = $arrayText[$i];
+
+ if($color!=''){ //ce je potrebno besedilo dolocene barve
+ //$text = ' \cellcolor{'.$cellBgColor.'} '.$this->coloredTextLatex($color, $arrayText[$i]);
+ //$text = $cellColoring.''.$this->coloredTextLatex($color, '\seqsplit{'.$arrayText[$i].'}');
+ $text = $cellColoring.''.$this->coloredTextLatex($color, $arrayBesedilo);
+ }else{
+ //$text = $arrayText[$i];
+ //$text = '\seqsplit{'.$arrayText[$i].'}';
+ $text = $arrayBesedilo;
+ }
+ if($i==0&&!$nadaljevanjeVrstice&&!count($steviloPodstolpcev)){
+ $tableRow .= $text;
+ }
+ elseif($i==0&&!$nadaljevanjeVrstice&&count($steviloPodstolpcev)){
+ //$tableRow .= ' \multicolumn{'.$steviloPodstolpcev[$i].'}{c|}{ '.$text.' }';
+ $tableRow .= ' \multicolumn{'.$steviloPodstolpcev[$i].'}{X|}{ '.$text.' }';
+ }elseif(count($steviloPodstolpcev)){ //ce rabimo multicolumn
+ //$tableRow .= ' & \multicolumn{'.$steviloPodstolpcev[$i].'}{c|}{ '.$text.' }';
+ $tableRow .= ' & \multicolumn{'.$steviloPodstolpcev[$i].'}{X|}{ '.$text.' }';
+ }
+ else{
+ $tableRow .= ' & '.$text;
+ }
+ }
+
+ if(!$brezNoveVrstice){
+ $tableRow .= $this->texNewLine; /*nova vrstica*/
+ }
+
+ if (!$brezHline) { //dodaj se horizontal line, ce je to potrebno (po navadi vse povsod razen npr. za tabelo s st. odklonom in povprecjem)
+ //if($export_format != 'xls'){
+ if($this->export_format != 'xls'){
+ $tableRow .= $this->horizontalLineTex; /*obroba*/
+ }
+ }
+
+ //echo "Vrstica tabele: ".$tableRow."</br>";
+
+ return $tableRow;
+ }
+
+ function getSteviloPodstolpcev($steviloPodstolpcevPolje=null){
+ $steviloPodstolpcev = 0;
+ foreach($steviloPodstolpcevPolje as $stevilo){
+ $steviloPodstolpcev = $steviloPodstolpcev + $stevilo;
+ }
+ return $steviloPodstolpcev;
+ }
+
+ function AddEmptyCells($colspan=null){
+ $tabela = '';
+ if($colspan){ //ce imamo tudi horizontalne spremenljivke
+ for($i=0;$i<$colspan;$i++){ //dodamo ustrezno stevilo praznih celic v ustezni vrstici
+ $tabela .= ' & ';
+ }
+ }
+ return $tabela;
+ }
+
+ function urediCrteTabele($indeksMultiRow=null, $colspan=null, $steviloStolpcevParameterTabular=null){
+ $tabela = '';
+ if (in_array(0, $indeksMultiRow)){ //ce v polju je 0, ce ne potrebujemo vse povsod crte
+ for($j=0;$j<2;$j++){ //inicializacija indeksMultiRow, saj prva dva stolpca ne potrebujeta crt
+ array_unshift($indeksMultiRow,0); //dodaj na zacetku polja se 2 nicli
+ }
+ $clinesPrvi = array();
+ $clinesZadnji = array();
+ $prviZabelezen = 0;
+ foreach($indeksMultiRow as $indeks=>$vrednost){
+ if($vrednost==1&&$prviZabelezen==0){
+ $clinesPrvi[] = ($indeks+1);
+ $prviZabelezen = 1;
+ }elseif($vrednost==0&&$prviZabelezen==1){
+ $clinesZadnji[] = ($indeks);
+ $prviZabelezen = 0;
+ }
+ }
+ if(count($clinesPrvi)!=count($clinesZadnji)){ //ce ni istega stevila indeksov za cline
+ $clinesZadnji[] = $steviloStolpcevParameterTabular; //je zadnji indeks stevilo vseh stolpcev
+ }
+ foreach($clinesPrvi as $indeksPrvi=>$clinePrvi){
+ $tabela .= "\\cline{".$clinePrvi."-".$clinesZadnji[$indeksPrvi]."}";
+ }
+ }else{
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}";
+ }
+ return $tabela;
+ }
+
+ function displayDataCellLatex($vrsticaPodatki=null, $tableSettingsNumerus=null, $tableSettingsAvgVar=null, $tableSettingsDelezVar=null, $colspan=null, $steviloStolpcevParameterTabular=null, $export_format=''){
+ $tabela = '';
+
+ if($this->tableSettingsNumerus){
+ if($this->tableSettingsPercent||$this->tableSettingsAvgVar||$this->tableSettingsDelezVar){ //ce je potrebno izpisati se ostale vrstice izracunov
+ $tabela .= $this->tableRow($vrsticaPodatki['numerus'][0],1);
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+ $tabela .= $this->AddEmptyCells($colspan); //dodaj prazne celice
+ }else{
+ $tabela .= $this->tableRow($vrsticaPodatki['numerus'][0],1);
+ }
+ }
+ if($this->tableSettingsPercent){
+ if($this->tableSettingsAvgVar||$this->tableSettingsDelezVar){ //ce je potrebno izpisati se ostale vrstice izracunov
+ $tabela .= $this->tableRow($vrsticaPodatki['percent'][0],1);
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+ $tabela .= $this->AddEmptyCells($colspan); //dodaj prazne celice
+ }else{
+ $tabela .= $this->tableRow($vrsticaPodatki['percent'][0],1);
+ }
+ }
+ if($this->tableSettingsAvgVar!= ''){
+ $color = 'blue';
+ if($this->tableSettingsDelezVar){ //ce je potrebno izpisati se ostale vrstice izracunov
+ $tabela .= $this->tableRow($vrsticaPodatki['avg'][0],1,0,0,$color, $export_format);
+ //$tabela .= $this->tableRow($vrsticaPodatki['avg'][0],1);
+ if($export_format != 'xls'){
+ $tabela .= "\\cline{".($colspan+1)."-".$steviloStolpcevParameterTabular."}"; //prekinjena horizontalna vrstica
+ }
+ $tabela .= $this->AddEmptyCells($colspan); //dodaj prazne celice
+ }else{
+ $tabela .= $this->tableRow($vrsticaPodatki['avg'][0],1,0,0,$color, $export_format);
+ //$tabela .= $this->tableRow($vrsticaPodatki['avg'][0],1);
+ }
+ }
+ if($this->tableSettingsDelezVar!= ''){
+ $color = 'red';
+ $tabela .= $this->tableRow($vrsticaPodatki['delez'][0],1,0,0,$color, $export_format);
+ //$tabela .= $this->tableRow($vrsticaPodatki['delez'][0],1);
+ }
+
+ return $tabela;
+ }
+
+ function coloredTextLatex($color='', $text=''){
+ $coloredText = '';
+ $coloredText .= '\textcolor{'.$color.'}{'.$text.'}';
+ return $coloredText;
+ }
+
+ /** Izriše vrstico z opisnimi z Latex
+ *
+ * @param unknown_type $spremenljivka
+ * @param unknown_type $variable
+ */
+ function displayDescriptivesSpremenljivkaRow($spid=null,$spremenljivka=null,$show_enota=null,$_sequence = null) {
+ global $lang;
+ //echo "funkcija displayDescriptivesSpremenljivkaRow: ".$spremenljivka['variable']." </br>";
+ $texDisplayDescriptivesSpremenljivkaRow = '';
+ if ($_sequence != null) {
+ $_desc = SurveyAnalysis::$_DESCRIPTIVES[$_sequence];
+ }
+
+ $text = array();
+ $text[] = '\textbf{'.$this->encodeText($spremenljivka['variable']).'}';
+ $text[] = '\textbf{'.$this->encodeText($spremenljivka['naslov']).'}';
+
+ #veljavno
+ $text[] = $this->encodeText((!$show_enota ? (int)$_desc['validCnt'] : ''));
+
+ #ustrezno
+ $text[] = $this->encodeText((!$show_enota ? (int)$_desc['allCnt'] : ''));
+
+ if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1)
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ $text[] = $this->encodeText(self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ else
+ $text[] = $this->encodeText('');
+
+ if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1)
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ $text[] = $this->encodeText(self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ else
+ $text[] = $this->encodeText('');
+
+ //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '');
+ //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '');
+ $text[] = (int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '';
+ $text[] = (int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '';
+
+
+ //$texDisplayDescriptivesSpremenljivkaRow .= $this->descTableRow($text);
+ $texDisplayDescriptivesSpremenljivkaRow .= $this->tableRow($text);
+
+ //echo "tex iz funkcije displayDescriptivesSpremenljivkaRow: ".$texDisplayDescriptivesSpremenljivkaRow."</br>";
+ return $texDisplayDescriptivesSpremenljivkaRow;
+ }
+
+ /** Izriše vrstico z opisnimi
+ *
+ * @param unknown_type $spremenljivka
+ * @param unknown_type $variable
+ */
+ function displayDescriptivesVariablaRow($spremenljivka=null, $grid=null, $variable=null) {
+ global $lang;
+ //echo "funkcija displayDescriptivesVariablaRow: ".$spremenljivka['variable']." </br>";
+ $texDescriptivesVariablaRow = '';
+ $_sequence = $variable['sequence']; # id kolone z podatki
+ if ($_sequence != null) {
+ $_desc = SurveyAnalysis::$_DESCRIPTIVES[$_sequence];
+ }
+
+ $text = array();
+
+ $text[] = $this->encodeText($variable['variable']);
+ $text[] = $this->encodeText($variable['naslov']);
+
+ #veljavno
+ $text[] = $this->encodeText((int)$_desc['validCnt']);
+
+ #ustrezno
+ $text[] = $this->encodeText((int)$_desc['allCnt']);
+
+ //if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1)
+ //if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1 && $spremenljivka['tip'] != 16)
+ if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2))
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ $text[] = $this->encodeText(self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ //else if (isset($_desc['avg']) && $spremenljivka['tip'] == 2 && (int)$spremenljivka['skala'] == 1 )
+ else if (isset($_desc['avg']) && $spremenljivka['tip'] == 2 && (int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16))
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'));
+ $text[] = $this->encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'));
+ else
+ $text[] = $this->encodeText('');
+
+ //if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1)
+ //if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1 && $spremenljivka['tip'] != 16)
+ if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2))
+ //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ $text[] = $this->encodeText(self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ else
+ $text[] = $this->encodeText('');
+
+ //if ((int)$spremenljivka['skala'] !== 1 && $spremenljivka['tip'] != 16){
+ if ((int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2)){
+ $text[] = $this->encodeText($_desc['min']);
+ $text[] = $this->encodeText($_desc['max']);
+ }else{
+ $text[] = $this->encodeText('');
+ $text[] = $this->encodeText('');
+ }
+
+ //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '');
+ //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '');
+
+
+ $texDescriptivesVariablaRow .= $this->tableRow($text);
+ //echo "nekaj: ".$this->encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'))." ".$spremenljivka['tip']."</br>";
+ //echo "tex iz funkcije displayDescriptivesVariablaRow: ".$texDescriptivesVariablaRow."</br>";
+ return $texDescriptivesVariablaRow;
+ }
+
+ function returnBold($text=''){
+ $boldedText = '';
+ $boldedText .= '\textbf{'.$text.'}';
+ return $boldedText;
+ }
+
+ function returnCentered($text='', $export_format = ''){
+ //echo "$export_format </br>";
+ $centeredText = '';
+ if($export_format == 'pdf'){
+ $centeredText .= ' \begin{absolutelynopagebreak} ';
+ }
+ $centeredText .= '\begin{center}{'.$text.'} \end{center}';
+ if($export_format == 'pdf'){
+ $centeredText .= ' \end{absolutelynopagebreak} ';
+ }
+ //$centeredText .= ' \begin{absolutelynopagebreak} \begin{center}{'.$text.'} \end{center} \end{absolutelynopagebreak} ';
+
+ return $centeredText;
+ }
+
+ function GetSprId($spid=null){
+ $find = '_';
+ $findPos = strpos($spid, $find);
+ $sprId = '';
+ $sprId = substr_replace($spid,'',$findPos);
+ return $sprId;
+ }
+
+ function displayHeatmapImageLatex($sprId=null){
+ global $site_path;
+ $tex = '';
+ $this->path2HeatmapImages = $site_path.'main/survey/uploads/';
+
+ //$heatmapImageFileName = $site_url.'main/survey/uploads/heatmap'.$sprId.'.png';
+ $heatmapImageFileName = 'heatmap'.$sprId;
+ $tex .= '\includegraphics[scale=0.5]{'.$this->path2HeatmapImages.''.$heatmapImageFileName.'}';
+ return $tex;
+ }
+
+ //funkcija, ki okrog posebnih crk dodaja {}, da lahko knjiznica seqsplit lahko deluje
+ function pripraviBesediloZaSeqsplit($besedilo=''){
+ //najdi posebno crko in okoli nje dodaj {}
+ //echo "array text: ".$besedilo."</br>";
+ $chars = array('č', 'ć', 'ž', 'š', 'đ', 'Č', 'Ć', 'Ž', 'Š', 'Đ'); //polje s najbolj pogostimi posebnimi crkami, ki jih seqsplit ne sprejema
+ foreach($chars AS $char){ //za vsako posebno crko, uredi {}
+ $moreChars = 0;
+ $pozicijaChar = '';
+ $pozicijaChar = strpos($besedilo, $char); //najdi pozicijo posebne crke
+ if(is_numeric($pozicijaChar)){ //ce je prisotna posebna crka v besedilu
+
+ //echo "črka: ".$char."</br>";
+ //echo "pozicija črke: ".$pozicijaChar."</br>";
+ $textToChar = substr($besedilo, 0, $pozicijaChar); //tekst do posebne crke
+ //echo $textToChar."</br>";
+ $tmpTextFromChar = substr($besedilo, $pozicijaChar); //tekst po posebne crke posebno crko
+ //echo $tmpTextFromChar."</br>";
+ $textFromChar = substr($tmpTextFromChar, 2); //tekst po posebni crki dalje
+ //echo $textFromChar."</br>";
+
+ //$besediloTmp = $textToChar."{".$char."}".$textFromChar;
+ $besedilo = $textToChar."{".$char."}".$textFromChar;
+ $besediloTmp = $textToChar."{".$char."}";
+ //echo "besedilo: ".$besedilo."</br>";
+ //$besedilo = $besediloTmp;
+
+ do{
+ //ce je prisotna se kaksna posebna crka v drugem delu besedila, ponovi
+ $pozicijaChar = '';
+ $pozicijaChar = strpos($textFromChar, $char); //najdi pozicijo posebne crke v ostalem delu besedila
+ if(is_numeric($pozicijaChar)){ //ce je prisotna posebna crka v besedilu v ostalem delu besedila
+ $moreChars = 1;
+ $textToChar = substr($textFromChar, 0, $pozicijaChar); //tekst do posebne crke
+ $tmpTextFromChar = substr($textFromChar, $pozicijaChar); //tekst po posebne crke posebno crko
+ $textFromChar = substr($tmpTextFromChar, 2); //tekst po posebni crki dalje
+ $besediloTmp .= $textToChar."{".$char."}";
+ }else{
+ $moreChars = 0;
+ $besediloTmp .= $textFromChar;
+ }
+ //echo "moreChars: ".$moreChars."</br>";
+ $besedilo = $besediloTmp;
+ }while($moreChars == 1);
+
+ }
+ }
+ //echo "besedilo končno: ".$besedilo."</br>";
+ return $besedilo;
+ }
+ //funkcija, ki okrog posebnih crk dodaja {}, da lahko knjiznica seqsplit lahko deluje - konec
+
+ /*Moje funkcije - konec*/
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="...")
+ {
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+ return $result;
+ }
+
+ function getBrezHline($exportformat=''){
+ if($exportformat=='xls'){
+ $brezHline = 1;
+ }else{
+ $brezHline = 0;
+ }
+ return $brezHline;
+ }
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexDocument.php b/admin/survey/export/latexclasses/class.LatexDocument.php
new file mode 100644
index 0000000..dce1108
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexDocument.php
@@ -0,0 +1,1423 @@
+<?php
+
+/**
+ *
+ * Class ki skrbi inicializacijo latex dokumenta
+ *
+ *
+ */
+
+####################################
+/*Uporabljeni Latex Packages:
+- geometry za robove, ipd.
+- tabularx za lazje urejanje tabel (ni podprto v latex2rtf)
+- \usepackage{ltablex} - za vecstransko tabelo, \textheight=730pt za portrait, pred vsako tabelo \keepXColumns, da obdrzi sirino tabele na sirini teksta
+- inputenc za uporabo utf8
+- fancyhdr za ureditev glav in nog
+- lastpage za pridobitev zadnje strani v dokumentu oz. stevilo strani v dokumentu, da deluje, je potrebno tex compile-at 2 krat
+- \usepackage{multirow} za vecvrsticno tabelo
+- \usepackage{tikz} in \usetikzlibrary{calc} za risanje drsnikov
+- \usepackage{enumitem} za itemize, ki je potreben za pravilen izris rolet in izberite iz seznama v tabelah
+- \usepackage{eurosym} za izpis simbola €
+- \usepackage[export]{adjustbox} za poravnavo slik
+
+
+linespread je razmik med vrsticami
+
+\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}} za sredinsko poravnane zadeve v tabularx tabeli
+
+newenvironment{absolutelynopagebreak} za prepreciti prelome strani, kjer ni potrebno
+
+\newcolumntype{s}{>{\hsize=.55\hsize \centering\arraybackslash}X} za sredinsko poravnane celice manjse dimenzije (0.55 navadne dimenzije)
+
+\newcolumntype{S}{>{\hsize=.2\hsize}X} za celice manjse dimenzije (0.3 navadne dimenzije)
+
+\newcolumntype{b}{>{\hsize=.5\hsize}X} za celice manjse dimenzije (0.5 navadne dimenzije)
+
+\newcolumntype{B}{>{\hsize=1.3\hsize}X} za celico vecje dimenzije od navadne (1.3 navadne dimenzije)
+
+\newcolumntype{A}{>{\hsize=3cm}X} za fiksno sirino prvega stolpca@tabularx
+
+\newcolumntype{C}{>{\centering\arraybackslash}X} za sredinsko poravnavo celice, ki se samodejno prilagaja sirini
+
+\newcolumntype{R}{>{\raggedleft\arraybackslash}X} za desno poravnavo celice, ki se samodejno prilagaja sirini
+
+\newcolumntype{P}{>{\hsize=.1\hsize \centering\arraybackslash}X} za fiksno 10% fiksno sirino stolpca, ki ima sredinsko poravnavo (npr. analiza prvi, levi stolpec)
+
+\usepackage{montserrat} pisava v novem slogu 1KA
+
+\usepackage{wasysym} za neposredno risanje checkbox in radio button
+
+#za prenos predolgega odgovora v novo vrstico########################
+\usepackage{pgf} za aritmetiko z length
+
+#za prenos predolgega odgovora v novo vrstico za vodoravno pod vprasanjem
+ \newcommand{\isAnswerBreakPodVprasanjem}[1]{\settowidth{\answerLength}{#1} \addtolength{\questionTotalLength}{\answerLength} \ifnum\questionTotalLength>\textwidth \mbox{} \\\\ #1 \settowidth{\questionTotalLength}{0} \else #1 \fi}
+
+ \renewcommand{\isAnswerBreakPodVprasanjem}[1]{
+ \settowidth{\answerLength}{#1} %dolzina odgovora
+ \addtolength{\questionTotalLength}{\answerLength} %dolzini odgovora dodaj trenutni dolzini celotnega vprasanja (vrstice)
+ \ifnum\questionTotalLength>\textwidth %ce je trenutna dolzina vprasanja vecja od sirine teksta (lista)
+ \mbox{} \\\\ #1 %pejdi v novo vrstico in izpisi odgovor
+ \ifnum\answerLength>\textwidth %ce je dolzina odgovora daljsa od od sirine teksta (lista)
+ \pgfmathsetmacro{\ratio}{\answerLength/\textwidth} %koliko je tekst vprasanja daljsi od sirine teksta (lista)
+ \pgfmathtruncatemacro{\macro}{\answerLength/\textwidth} %kaksen je ostanek, decimalke, brez celih stevilk
+ \pgfmathsetmacro{\newLengthA}{\the\textwidth * (\ratio-\macro)} %dolzina vrstice, kjer se konca predolgo besedilo odgovora
+ \setlength{\questionTotalLength}{\newLengthA pt} %trenutna dolzina celotnega vprasanja (vrstice) je enaka dolzini vrstice, kjer se konca predolgo besedilo odgovora
+ \else %drugace, torej dolzina odgovora ni daljsa od ene vrstice
+ \setlength{\questionTotalLength}{\answerLength} %trenutna dolzina celotnega vprasanja (vrstice) je enaka dolzini odgovora
+ \fi
+ \else %drugace, torej trenutna dolzina vprasanja ni vecja od sirine teksta (lista)
+ #1 %izpisi odgovor
+ \fi
+ }
+#za prenos predolgega odgovora v novo vrstico za vodoravno pod vprasanjem - konec
+
+#za prenos predolgega odgovora v novo vrstico za vodoravno ob vprasanju
+
+#za prenos predolgega odgovora v novo vrstico za vodoravno ob vprasanju - konec
+
+#za prenos predolgega odgovora v novo vrstico - konec########################
+
+#za izris izbranega radio button
+\newcommand{\radio}{\ooalign{\hidewidth$\bullet$\hidewidth\cr$\ocircle$}}
+#za izris izbranega radio button - konec
+
+#ureditev barve za celotno besedilo
+default barva je #333 oz. RGB: 51, 51, 51
+omenjeno kodo je potrebno deliti z 255, da dobimo stevilke, ki ustrezajo Latex => 51/255=0.2
+\definecolor{oneclick}{rgb}{0.2, 0.2, 0.2} - definicija barve
+\color{oneclick} v preamble, torej pred \begin{document} - sprozi uporabo barve za celoten dokument
+#ureditev barve za celotno besedilo - konec
+
+
+*/
+####################################konec
+
+//namespace Export\Latexclasses;
+//include('../../function.php');
+include('../../vendor/autoload.php');
+define("ENKA_LOGO_SIZE", 'width=3.51cm,height=2cm,keepaspectratio');
+define("ENKA_LOGO_SIZE_HEADER", 'width=1.75cm,height=1cm,keepaspectratio');
+define("SINGLE_TABLE_WIDTH", 3000);
+define("PAGE_TEXT_WIDTH", 10200); //17 cm, 170 mm, je 10200 twips, 1 mm je 60 twips
+
+#definicija za izris drsnika s kroglico
+define ("circleSlider", '\def\circleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
+ \tikz[baseline=-0.1cm]{
+ \coordinate (start) at (0,-0.1cm);
+ \coordinate (end) at (#1,0.1cm);
+ \coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
+ \fill[rounded corners=0.1cm, draw=gray, fill=lightgray] (start) rectangle (end);
+ \fill[draw=gray, rounded corners=0.2mm, fill=gray!20!gray] (mark) circle(.15) ;
+ }
+ }');
+
+#definicija za izris drsnika brez kroglice
+define ("emptySlider", '\def\emptySLIDER#1{% 1: length
+ \tikz[baseline=-0.1cm]{
+ \coordinate (start) at (0,-0.1cm);
+ \coordinate (end) at (#1,0.1cm);
+ \fill[rounded corners=0.1cm, draw=gray, fill=lightgray] (start) rectangle (end);
+ }
+ }');
+
+#definicija latex kode za dodajanje skripte za generiranje xls iz html
+define ("headWithXlsScript",
+ '\ifdefined\HCode
+ \AtBeginDocument{%
+ \Configure{@HEAD}{\HCode{<script src="./export/script/saveAsExcel2.js"></script>\Hnewline}}
+ \ConfigureEnv{quote}{\Tg<quote>}{\Tg</quote>}{}{}
+ }
+ \fi');
+
+class LatexDocument{
+
+ var $export_type; // Tip izvoza (vprašalnik, analize...)
+ var $export_subtype; // Podtip izvoza
+ var $export_format; // Format izvoza (latex->pdf, latex->rtf, xls...)
+
+ var $anketa; // ID ankete
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+
+ var $grupa = null; // trenutna grupa
+ var $usrId = null; // trenutni user
+ var $spremenljivka = null; // trenutna spremenljivka
+
+ //spremenljivke za Nastavitve pdf/rtf izvozov
+ var $export_font_size = 10;
+ var $export_numbering = 0;
+ var $export_show_if = 0;
+ var $export_show_intro = 0;
+ //var $export_show_gdpr_intro = 0;
+ //var $export_data_type = 0; // nacin izpisa vprasanlnika - kratek -> 0, dolg -> 1, zelo kratek -> 2
+ var $export_data_type = 0; // nacin izpisa vprasalnika - Razsirjen -> 1, Skrcen -> 2
+ var $export_data_font_size;
+ var $export_data_numbering;
+ var $export_data_show_recnum;
+ var $export_data_show_if;
+ var $export_data_PB;
+ var $export_data_skip_empty;
+ var $export_data_skip_empty_sub;
+ var $export_data_landscape;
+ //spremenljivke za Nastavitve pdf/rtf izvozov - konec
+
+ var $head; // za shrambo tex preamble in zacetek dokumenta
+ var $tail; // za shrambo tex zakljucka dokumenta
+ var $naslovnicaUkaz; //za shrambo ukaza za izris naslovnice dokumenta
+
+ var $headerAndFooter; //za shrambo ukaza za izris glave in noge dokumenta
+ protected $surveyStyle; //za shrambo environmenta vprasalnika (omogoca spreminjanje velikosti besedila glede na izbrano nastavitev)
+ protected $analysisStyle; //za shrambo environmenta vprasalnika (omogoca spreminjanje velikosti besedila glede na izbrano nastavitev)
+ protected $statusStyle; //za shrambo environmenta vprasalnika (omogoca spreminjanje velikosti besedila glede na izbrano nastavitev)
+
+ var $commentType = 1; // tip izpisa komentarjev
+
+ var $texNewLine = '\\\\ ';
+
+ protected $isAnswer = '';
+ protected $isAnswerBreakPodVprasanjem = '';
+
+ protected $pathToTexFile;
+
+ protected $path2Images;
+
+ protected $language = -1; // Katero verzijo prevoda izvazamo
+ protected $usr_id; //id respondenta
+
+ protected $admin_type;
+ public $casIzvajanjaPhp = null; //Funkcija namenjena samo testiranju
+
+ function __construct($anketa=null){
+ global $site_path, $global_user_id, $admin_type, $lang;
+ $this->anketa = $anketa;
+ $this->path2Images = $site_path.'admin/survey/export/latexclasses/textemp/images/';
+ $this->admin_type = $admin_type;
+
+ $this->casIzvajanjaPhp = microtime(true);
+ }
+ ###################################### konec construct-a
+
+ public function createDocument($export_type='', $export_subtype='', $export_format='', $sprID = null){
+ global $lang, $site_path;
+ $this->usr_id = $_GET['usr_id'];
+ if($export_subtype=='heatmap_image'){ //ce je potrebno zgenerirati sliko heatmap
+ $this->HeatmapImage($_GET['sprID']);
+ return;
+ }
+
+ $this->spremenljivka = $sprID;
+
+ // Ustvarimo ogrodje dokumenta (locena funkcija), glavo, nogo, naslovnico...
+ $this->InitDocumentVars($export_type, $export_subtype, $export_format); //pridobi vse potrebne spremenljivke za ustvarjanje ogrodja dokumenta
+
+ #spremenljivke#################################################################
+ $datumGeneriranjaIzvoza = date("d. m. Y");
+
+ $anketaUstvarjena = SurveyInfo::getInstance()->getSurveyInsertDate();
+ $dolgoImeAnkete = $this->encodeText(SurveyInfo::getSurveyColumn('akronim'));
+
+ if($this->language!=-1){ //ce ni default jezik, ampak je prevod
+ $_lang = '_'.$this->language;
+ $kratkoImeAnkete = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime'.$_lang);
+ }else{
+ $kratkoImeAnkete = SurveyInfo::getSurveyColumn('naslov');
+ }
+ $kratkoImeAnkete = $this->encodeText($kratkoImeAnkete);
+
+ $steviloVprasanj = SurveyInfo::getSurveyQuestionCount();
+ $anketaSpremenjena = SurveyInfo::getSurveyEditDate();
+ $avtorAnkete = SurveyInfo::getSurveyInsertName();
+ $avtorSpremenilAnketo = SurveyInfo::getSurveyEditName();
+ $surveyId = SurveyInfo::getSurveyId();
+ ################################################
+ #spremenljivke################################################################# konec
+
+ /*echo 'export_type: '.$export_type.'</br>';
+ echo 'export_subtype: '.$export_subtype.'</br>';
+ echo 'export_format: '.$export_format.'</br>';
+ echo 'anketaID: '.$_GET['anketa'].'</br>';
+ /*echo 'sprID: '.$_GET['sprID'].'</br>';
+ echo '$this->export_font_size: '.$this->export_font_size.'</br>';
+ echo '$this->export_data_type: '.$this->export_data_type.'</br>';
+ echo 'SurveyId: '.SurveyInfo::getSurveyId().'</br>'; */
+
+ #za pridobitev jezika respondenta
+ //pridobitev splosnega jezika ankete za respondenta nastavitev=> Osnovni jezik za respondente:
+ $sqlL = sisplet_query("SELECT lang_resp FROM srv_anketa WHERE id='$this->anketa' ");
+ $rowL = mysqli_fetch_array($sqlL);
+ $this->language = $rowL['lang_resp'];
+
+ ############testiranje za jezik
+ if(isset($_GET['language'])){
+ $this->language = $_GET['language'];
+ //echo "jezik test: ".$this->language."</br>";
+ // Naložimo jezikovno datoteko
+ $file = '../../lang/'.$this->language.'.php';
+ include($file);
+ $_SESSION['langX'] = $site_url .'lang/'.$this->language.'.php';
+ }
+ ############testiranje za jezik - konec
+
+ if ($this->usr_id != '') { //ce je izpis za dolocenega respondenta
+ $sqlL = sisplet_query("SELECT language FROM srv_user WHERE id = '$this->usr_id ' AND ank_id='$this->anketa' ");
+ $rowL = mysqli_fetch_array($sqlL);
+ $this->language = $rowL['language'];
+ $lang['id'] = $this->language;
+ }
+ #za pridobitev jezika respondenta - konec
+
+ //Tex preamble in zacetek latex dokumenta
+ $tex = $this->head;
+
+ //Dodatek h kodi, da bo črka đ vidna v pdf
+ if($export_format == 'pdf'){
+ $tex .= "\\fontencoding{T1}\selectfont \n";
+ }
+
+ if($export_format != 'xls'){ //ce ni xls
+ //izris glave pa noge
+ $tex .= $this->GenerateHeaderFooter($dolgoImeAnkete, $lang['page'], $datumGeneriranjaIzvoza, $export_format);
+
+ //ce ni izpis za enega respondenta IN ni izpis analize IN ni izpis status
+ if($export_subtype!='q_data' && $export_type!='analysis' && $export_type!='status' && $export_subtype!='edits_analysis' && $export_type!='gdpr'){
+
+ //Izris naslovnice
+ if($export_subtype=='q_data_all'){ //ce je izpis vseh odgovorov
+ $vsiOdgovoriBesedilo = $lang['export_firstpage_results'];
+ }else{
+ $vsiOdgovoriBesedilo = $lang['srv_rep_vprasalnik'];
+ }
+ $tex .= $this->GenerateNaslovnica ($export_format, $anketaSpremenjena, $lang['export_firstpage_shortname'], $kratkoImeAnkete, $lang['export_firstpage_longname'], $lang['export_firstpage_qcount'], $steviloVprasanj, $lang['export_firstpage_author'], $avtorAnkete, $lang['export_firstpage_edit'], $avtorSpremenilAnketo, $anketaUstvarjena, $dolgoImeAnkete, $lang['export_firstpage_date'], $vsiOdgovoriBesedilo);
+ //za ureditev naslova in podnaslova na naslovnici
+ //$tex .= $this->GenerateNaslovnicaNaslovi ($export_format, $anketaSpremenjena, $lang['export_firstpage_shortname'], $kratkoImeAnkete, $lang['export_firstpage_longname'], $lang['export_firstpage_qcount'], $steviloVprasanj, $lang['export_firstpage_author'], $avtorAnkete, $lang['export_firstpage_edit'], $avtorSpremenilAnketo, $anketaUstvarjena, $dolgoImeAnkete, $lang['export_firstpage_date'], $vsiOdgovoriBesedilo);
+ }
+ }
+
+ //zacetek izpisa ############################################################################
+ $tex .= '\begin{'.$export_type.'} ';
+
+ if($export_format == 'rtf'){ //ce je rtf, pred prvim vprasanjem, dodatna prazna vrstica zaradi tezav s poravnavo
+ $tex .= $this->texNewLine;
+ }
+
+ // Glede na tip in podtip poklicemo ustrezen razred za izris vsebine porocila (npr LatexFreq, LatexTTest, ...)
+
+ switch ( $export_type )
+ {
+ case 'survey':
+ $survey = new LatexSurvey($this->anketa, $export_format, $this->export_show_intro, $this->export_show_if, $this->export_data_skip_empty, $this->export_data_skip_empty_sub);
+ //$tex .= $survey->displaySurvey($export_subtype);
+ switch ( $export_subtype )
+ {
+ case 'q_empty':
+ $tex .= $survey->displaySurvey($export_subtype, $this->export_data_type, $this->language);
+ break;
+ case 'q_data':
+ $tex .= $survey->displaySurvey($export_subtype, $this->export_data_type, $this->language);
+ break;
+ case 'q_data_all':
+ $tex .= $survey->displayAllSurveys($export_subtype, $export_format, $this->export_data_type);
+ break;
+ case 'q_comment':
+ $tex .= $survey->displaySurveyCommentaries($export_subtype, $this->export_data_type);
+ break;
+ }
+ break;
+
+ case 'analysis':
+ $analysis = new LatexAnalysis($this->anketa, $export_format, $this->spremenljivka);
+ $tex .= $analysis->displayAnalysis($export_subtype);
+ break;
+
+ case 'status':
+ $status = new LatexStatus($this->anketa);
+ $tex .= $status->displayStatus();
+ break;
+
+ case 'gdpr':
+ $gdpr = new LatexGDPR($this->anketa);
+ $tex .= $gdpr->displayGDPR($export_subtype);
+ break;
+
+ case 'other':
+ if($export_subtype == 'edits_analysis'){
+/* if ($_GET['seansa'] > 0){
+ //if (isset ($_GET['seansa'])){
+ $seansa = $_GET['seansa'];
+ }else{
+ $seansa = '30';
+ }
+ if (isset ($_GET['time'])){
+ $time = $_GET['time'];
+ }else{
+ $time = '1 month';
+ }
+ if (isset ($_GET['status'])){
+ $status = $_GET['status'];
+ }else{
+ $status = 0;
+ }
+ if (isset ($_GET['from'])){
+ $from = $_GET['from'];
+ }else{
+ $from = '';
+ }
+ if (isset ($_GET['to'])){
+ $to = $_GET['to'];
+ }else{
+ $to = '';
+ }
+ if (isset ($_GET['user'])){
+ $user = $_GET['user'];
+ }else{
+ $user = 'all';
+ }
+ if (isset ($_GET['period'])){
+ $period = $_GET['period'];
+ }else{
+ $period = 'day';
+ }
+ //print_r($_GET);
+ //print_r($_POST);
+ if (isset ($_GET['seansa'])){
+ echo "seansa iz get: ".$_GET['seansa']."</br>";
+ } */
+
+ //$editAnalysis = new LatexEditsAnalysis($this->anketa, $seansa, $time, $status, $from, $to, $user, $period);
+ $editAnalysis = new LatexEditsAnalysis($this->anketa);
+ $tex .= $editAnalysis->displayEditAnalysis();
+ }
+ break;
+
+ case 'data':
+ echo "exporting data";
+ $tex .= 'To je tip data \\\\ ';
+ case 'full':
+ $tex .= 'To je podtip full';
+ break;
+ case 'list':
+ $tex .= 'To je podtip list';
+ break;
+ break;
+ }
+
+ //konec izpisa######################################################################################################
+ $tex .= ' \end{'.$export_type.'}';
+
+ //zakljucek latex dokumenta
+ $tex.= $this->tail;
+ ############################################################### - zakljucek latex dokumenta
+
+
+ //izris latex kode
+
+ $this->export_subtype = $export_subtype;
+ $this->export_format = $export_format;
+
+ # generating tex file
+ $this->pathToTexFile = $site_path.'admin/survey/export/latexclasses/textemp/';
+ //$filenameTex = $this->pathToTexFile.'export_'.$export_subtype.'_'.$surveyId.'_'.$export_format.'.tex';
+
+ $niPrijavljenUporabnik = 0;
+ if ($this->admin_type==-1) { //ce ni prijavljen uporabnik
+ $niPrijavljenUporabnik = 1; //dodaj info v imenu tex datoteke
+ }
+ $filenameTex = $this->pathToTexFile.'export_'.$export_subtype.'_'.$surveyId.'_'.$export_format.'_'.$niPrijavljenUporabnik.'.tex';
+ $filename = $this->pathToTexFile.'export_'.$export_subtype.'_'.$surveyId.'_'.$export_format.'_'.$niPrijavljenUporabnik;
+ $fp = fopen($filenameTex, "w") or
+ die ("cannot generate file $filenameTex<br>\n");
+ fwrite($fp, $tex) or
+ die ("cannot send data to file<br>\n");
+ fclose($fp);
+ # generating tex file - konec
+
+ /*********************** TEST ********************************/
+ //TODO: Samo za test briši na produkciji
+ global $admin_type;
+ if($admin_type == 0){
+ $koncniCas = number_format((microtime(true) - $this->casIzvajanjaPhp), 2);
+
+ $SL = new SurveyLog();
+ $SL->addMessage(SurveyLog::IZVOZ, 'PHP: '.$koncniCas.'s, anketa: '.$this->anketa.', vrsta datoteke: '.$export_format.', vrsta izvoza: '.$export_subtype);
+ $SL->write();
+
+ $samoLatex = microtime(true);
+ }
+ /********************* END TEST ******************************/
+
+ /*UREDITEV ODSTRANJEVANJA PRAZNIH VRSTIC IN CHARACTER-JEV IZ TEX DATOTEKE******************/
+ $ukazOdstrani = "sed -i '/^[[:space:]]*$/d' ".$filenameTex;
+ exec($ukazOdstrani);
+ /*UREDITEV ODSTRANJEVANJA PRAZNIH VRSTIC IN CHARACTER-JEV IZ TEX DATOTEKE - END ******************/
+
+ if($export_format == 'pdf'){
+ # generating pdf output
+ $this->OutputPdf($filenameTex, $surveyId, $niPrijavljenUporabnik);
+ # generating pdf output - konec
+ }elseif($export_format == 'rtf'){
+ # generating rtf output
+ $this->OutputRtf($filenameTex, $surveyId, $niPrijavljenUporabnik);
+ # generating rtf output - konec
+ }elseif($export_format == 'xls'){
+ # generating html output
+ $this->OutputHtml($filenameTex, $surveyId, $filename);
+ # generating html output - konec
+ }
+
+ /*********************** TEST ********************************/
+ //TODO: Samo za test briši na produkciji
+ if($admin_type == 0){
+ $koncniCas = number_format((microtime(true) - $samoLatex), 2);
+
+ $SL = new SurveyLog();
+ $SL->addMessage(SurveyLog::IZVOZ, 'Latex: '.$koncniCas.'s, anketa: '.$this->anketa.', vrsta datoteke: '.$export_format.', vrsta izvoza: '.$export_subtype);
+ $SL->write();
+ }
+ /********************* END TEST *****************************/
+
+ //brisanje temp datotek tex
+ unlink($filenameTex); //tex
+ unlink($filename.".aux"); //aux
+ unlink($filename.".log"); //log
+ unlink($filename.".pdf"); //pdf
+ unlink($filename.".out"); //out
+ //brisanje temp datotek tex - konec
+
+ //brisanje temp slikovnih datotek
+ $this->DeleteTmpImages($surveyId);
+ //brisanje temp slikovnih datotek - konec
+
+ }
+ ###################################### konec funkcije createDocument
+
+
+ #####################################################################################################
+ //Podporne funkcije za delovanje createDocument
+ #####################################################################################################
+ function InitDocumentVars($export_type='', $export_subtype='', $export_format='')
+ {
+ global $site_path;
+ global $lang;
+ $baseLineSkip = intval($this->export_font_size*1.2);
+
+ $this->export_type = $export_type;
+ $this->export_subtype = $export_subtype;
+
+ if($export_format == 'xls'){
+ //$xlsExportFilename = $export_format.'_'.$export_type.'_'.$export_subtype.'_'.$this->anketa;
+ if($this->spremenljivka){
+ $xlsExportFilename = $export_format.'_'.$export_type.'_'.$export_subtype.'_'.$this->anketa.'_'.$this->spremenljivka;
+ }else{
+ $xlsExportFilename = $export_format.'_'.$export_type.'_'.$export_subtype.'_'.$this->anketa;
+ }
+
+ $button4XlsExport = '\Configure{BODY}
+ {\SaveEndP\IgnorePar
+ \HCode{<input type="button" value="'.$lang['srv_export_2_xls_button'].'" onclick="exportTableToExcel(\''.$xlsExportFilename.'\', \''.$this->export_subtype.'\')"/>\Hnewline
+ }\ShowPar\par}';
+
+ }
+
+ //if($export_type == 'survey'||$export_type == 'analysis'){ //ce je format 'survey' ali 'analysis', potrebuje naslednje nastavitve
+ if($export_type == 'survey'){ //ce je format 'survey', potrebuje naslednje nastavitve
+
+ #Nastavitve pdf/rtf izvozov################################################################
+
+ SurveySetting::getInstance()->Init($this->anketa);
+
+ ############testiranje za jezik
+ if(isset($_GET['language'])){
+ $this->language = $_GET['language'];
+ //echo "jezik test: ".$this->language."</br>";
+ // Naložimo jezikovno datoteko
+ $file = '../../lang/'.$this->language.'.php';
+ include($file);
+ $_SESSION['langX'] = $site_url .'lang/'.$this->language.'.php';
+ }
+ ############testiranje za jezik - konec
+
+ //Izpis vprasalnika
+ // Prikazi uvoda (default ne)
+ $this->export_show_intro = SurveySetting::getInstance()->getSurveyMiscSetting('export_show_intro');
+ //Ce je vprasalnik z izpisom odgovorov respondentov - $export_subtype => 'q_data' || 'q_data_all'
+ if($export_subtype == 'q_data' || $export_subtype == 'q_data_all'){ // ce je subtype-a 'q_data' || 'q_data_all'
+ // Tip izvoza (0->navaden-default, 1->dolg, 2->kratek) -> ne velja vec, saj sedaj sta samo dva tipa izvozov (razsirjen in skrcen)
+ // Tip izvoza (1->razsirjen, 2->skrcen)
+ $this->export_data_type = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_type');
+ //echo "tip izvoza: ".$this->export_data_type."</br>";
+ if($this->export_data_type == 0) {
+ $this->export_data_type = 1;
+ }
+ //$this->export_type = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_type');
+ //$this->type = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_type');
+ // Velikost pisave (default 10)
+ //$this->export_data_font_size = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_font_size');
+ $this->export_font_size = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_font_size');
+ // Številčenje vprašanj (default da)
+ //$this->export_data_numbering = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_numbering');
+ $this->export_numbering = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_numbering');
+ // Prikaz recnuma (default da)
+ //$this->export_data_show_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_recnum');
+ $this->export_show_recnum = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_recnum');
+ // Prikaz pogojev (default da)
+ //$this->export_data_show_if = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_if');
+ $this->export_show_if = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_if');
+ // Page break med posameznimi respondenti (default ne)
+ $this->export_data_PB = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_PB');
+ // Izpusti vprasanja brez odgovora (default ne)
+ $this->export_data_skip_empty = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty');
+ // Izpusti podvprasanja brez odgovora (default ne)
+ $this->export_data_skip_empty_sub = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty_sub');
+ // Landscape postavitev izvoza (default ne)
+ $this->export_data_landscape = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_landscape');
+ }else{ //ce je prazen vprasalnik
+ //$this->export_type = SurveySetting::getInstance()->getSurveyMiscSetting('export_type');
+ // Prikaz pogojev (default da)
+ $this->export_show_if = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_show_if');
+ // Velikost pisave (default 10) - samo vprasanj
+ $this->export_font_size = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_font_size');
+ // Številčenje vprašanj (default da)
+ $this->export_numbering = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_numbering');
+ }
+ #Nastavitve pdf/rtf izvozov################################################################konec
+ }
+
+ //echo "export show if: ".$this->export_show_if."</br>";
+ //echo "export type: ".$export_type." subtype: ".$this->export_subtype."</br>";
+ #### pokomentiral, ker z uporabo template ni vec potrebno in ker po novih specifikacijah je velikost pisave in razmik med vrsticami predefiniran
+/* if($export_type == 'analysis'||$export_type == 'status'||$export_type == 'other'){ //ce je izpis analize ALI status ALI drugo
+ if($export_type == 'analysis'){
+ $tableAnalysisEnvironment = ' \newenvironment{tableAnalysis}
+ {\parindent0pt \fontsize{6}{'.$baseLineSkip.'} \selectfont }
+ { }';
+ if($export_format == 'xls' || $export_format == 'pdf'){
+ $lTablex = '\usepackage{ltablex}';
+ }
+ //$linespread = 1.15;
+ $linespread = 1.5;
+ //}elseif($export_type == 'status'){
+ }elseif($export_type == 'status'||$export_subtype == 'edits_analysis'){
+ $tableStatusEnvironment = ' \newenvironment{tableStatus}
+ {\parindent0pt \fontsize{8}{'.$baseLineSkip.'} \selectfont }
+ { }';
+ //$linespread = 0.8;
+ $linespread = 1;
+ }
+ }else{
+ $tableAnalysisEnvironment = '';
+ $tableStatusEnvironment = '';
+ $lTablex = ''; //ce je ltablex prisoten pri survey izvozih, so tezave
+ //$linespread = 1.15;
+ $linespread = 1.5;
+ }
+ if($this->export_data_landscape==1||($export_type=='analysis'&&($this->export_subtype=='crosstab'||$this->export_subtype=='mean'||$this->export_subtype=='ttest'||$this->export_subtype=='multicrosstab')||$this->export_subtype=='break'||$this->export_subtype=='chart'||$this->export_subtype=='creport'||$this->export_subtype=='status')){ //ce je postavitev landscape ALI je izvoz analiz in (Tabele ali Povprecja ali T-test ali Multitabele ali razbitje)
+ $landscapePostavitev = "landscape";
+ $visinaTeksta = 210;
+ $sirinaTeksta = 294;
+ $hSize = '\hsize='.$sirinaTeksta.'mm';
+ }else{
+ $landscapePostavitev = "portrait";
+ $visinaTeksta = 294;
+ $hSize = '';
+ } */
+ #### pokomentiral, ker z uporabo template ni vec potrebno in ker po novih specifikacijah je velikost pisave in razmik med vrsticami predefiniran - konec
+
+ if($export_format == 'pdf'){
+ ####################################
+ //tex template dokumenta za pdf
+ if($export_type=='analysis'&&($this->export_subtype=='sums'||$this->export_subtype=='freq'||$this->export_subtype=='desc')){ //ce je analiza, kjer ni potreben landscape pogled
+ $this->head = '
+ \documentclass{latexTemplatePdfAnalysisPortrait} %include datoteke s template
+ \graphicspath{ {'.$site_path.'admin/survey/export/latexclasses/textemp/images/}, {'.$site_path.'uploadi/editor/}, {'.$site_path.'main/survey/uploads/}, {'.$site_path.'admin/survey/pChart/Cache/} }
+ \begin{document}
+ ';
+ //}elseif($this->export_data_landscape==1||($export_type=='analysis'&&($this->export_subtype=='crosstab'||$this->export_subtype=='mean'||$this->export_subtype=='ttest'||$this->export_subtype=='multicrosstab')||$this->export_subtype=='break'||$this->export_subtype=='chart'||$this->export_subtype=='creport'||$this->export_subtype=='status')||($export_type=='other'&&$export_subtype == 'edits_analysis')){ //ce je potreben landscape pogled
+ }elseif(($export_type=='analysis'&&($this->export_subtype=='crosstab'||$this->export_subtype=='mean'||$this->export_subtype=='ttest'||$this->export_subtype=='multicrosstab')||$this->export_subtype=='break'||$this->export_subtype=='chart'||$this->export_subtype=='creport'||$this->export_subtype=='status')||($export_type=='other'&&$export_subtype == 'edits_analysis')){ //ce je potreben landscape pogled
+ $this->head = '
+ \documentclass{latexTemplatePdfAnalysisAndOtherLandscape} %include datoteke s template
+ \graphicspath{ {'.$site_path.'admin/survey/export/latexclasses/textemp/images/}, {'.$site_path.'uploadi/editor/}, {'.$site_path.'main/survey/uploads/}, {'.$site_path.'admin/survey/pChart/Cache/} }
+ \begin{document}
+ ';
+
+ }else{ //ce je vprasalnik
+ $this->head = '
+ \documentclass{latexTemplatePdfSurvey} %include datoteke s template
+ \graphicspath{ {'.$site_path.'admin/survey/export/latexclasses/textemp/images/}, {'.$site_path.'uploadi/editor/}, {'.$site_path.'main/survey/uploads/}, {'.$site_path.'admin/survey/pChart/Cache/} }
+ '.circleSlider.' %funkcija za izris sliderja z bunkico
+ '.emptySlider.' %funkcija za izris sliderja
+ \begin{document}
+ ';
+ }
+ #################################### definiranje ukaza za glave in noge pdf - konec
+
+ }else if($export_format == 'rtf'||$export_format == 'xls'){
+ ####################################
+ //tex preamble + zacetek dokumenta za rtf
+ $this->head = '
+ \documentclass[10pt]{article}
+ \usepackage[a4paper, margin=20mm]{geometry}
+ \usepackage[utf8]{inputenc}
+ \usepackage{color}
+ \usepackage{graphicx}
+ \newenvironment{'.$export_type.'}
+ { }
+ { }
+ \newenvironment{tableAnalysis}
+ {\parindent0pt \fontsize{6}{'.$baseLineSkip.'} \selectfont }
+ { }
+ \usepackage{fancyhdr}
+ \pagestyle{fancy}
+ ';
+
+ if($export_format == 'rtf'&&$export_type=='analysis'){
+ //$this->head .= '\graphicspath{ {'.$site_path.'admin/survey/export/latexclasses/textemp/images/}, {'.$site_path.'uploadi/editor/}, {'.$site_path.'main/survey/uploads/}, {'.$site_path.'admin/survey/pChart/Cache/} }';
+ }
+
+ if($export_format == 'xls'){
+ $this->head .= '
+ '.headWithXlsScript.'
+ '.$button4XlsExport.'
+ ';
+ }
+
+ $this->head .= '
+ \begin{document}
+ ';
+
+ #################################### tex preamble + zacetek dokumenta za rtf - konec
+ ####################################
+ //definiranje ukaza za glave in noge za rtf
+ /*ima 5 vhodnih podatkov:
+ 1. ime ankete v glavi levo;
+ 2. logo 1KA v glavi na desni;
+ 3. besedilo "Stran" v nogi na desni;
+ 4. velikost logo 1KA v glavi na desni;
+ 5. datum generiranja izvoza v nogi na levi.
+ */
+ /* $this->headerAndFooter = '
+ \\newcommand{\headerfooter}[5]{
+ \\lhead{\\includegraphics[scale=#4]{#2} #1}
+ \\lfoot{www.1ka.si}
+ \\rfoot{#3 \\thepage}
+ }
+ '; */
+
+ if($this->usr_id){
+ //echo "usr id: ".$this->usr_id;
+ $recnum = $this->getRecnum();
+ if($recnum && (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_recnum')){
+ $recnumBesedilo = "(Recnum $recnum)";
+ }else{
+ $recnumBesedilo = "";
+ }
+ }
+
+ $this->headerAndFooter = '
+ \\newcommand{\headerfooter}[6]{
+ \\lhead{\\includegraphics[scale=#4]{#2} #1 '.$recnumBesedilo.'}
+ \\lfoot{www.1ka.si}
+ \\rfoot{#3 \\thepage}
+ }
+ ';
+/* $this->headerAndFooter = '
+ \\newcommand{\headerfooter}[5]{
+ \\lhead{#1}
+ \\rhead{\\includegraphics[scale=#4]{#2}}
+ \\lfoot{www.1ka.si}
+ \\rfoot{#3 \\thepage}
+ }
+ '; */
+ #################################### definiranje ukaza za glave in noge za rtf - konec
+ }
+
+ ####################################
+ //zakljucek dokumenta
+ $this->tail='
+ \end{document}
+ ';
+ ####################################konec
+
+ }
+ ###################################### konec InitDocumentVars
+
+ //Funkcija za izris glave in noge za pdf ######################################
+ function GenerateHeaderFooter($imeAnkete='', $stranDokumenta=null, $datumGeneriranjaIzvoza='', $export_format=''){
+ global $lang, $site_path;
+ //Definiranje ukaza
+ $tex = $this->headerAndFooter; //definiranje ukaza za glavo in nogo dokumenta
+
+ //izbira ustreznega logotipa za določen jezik
+ if($lang['id'] == 1){ //ce je id 1, naj bo slovenski
+ $logo1ka = 'logo1ka';
+ }else{ //ce je bilo kateri drugi, naj bo angleski
+ $logo1ka = 'logo1kaeng';
+ }
+ //izbira ustreznega logotipa za določen jezik - konec
+
+ if($this->usr_id){
+
+ $recnum = $this->getRecnum();
+
+ if($recnum && (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_recnum') == 1){
+ $recnumBesedilo = "(Recnum $recnum)";
+ }else{
+ $recnumBesedilo = "";
+ }
+ }
+
+ //Izris glave in noge s predefiniranim ukazom za pdf
+ $tex .= "\headerfooter{".$imeAnkete."}{".$this->path2Images."".$logo1ka."}{".$stranDokumenta."}{".ENKA_LOGO_SIZE_HEADER."}{".$datumGeneriranjaIzvoza."}{".$recnumBesedilo."}";
+
+ return $tex;
+ }
+ ######################################
+
+
+ //Funkcija za izpis naslovnice ######################################
+ function GenerateNaslovnica($export_format='', $anketaSpremenjenaNaslovnica='', $kratkoImeAnketeBesedilo='', $kratkoImeAnkete='', $dolgoImeAnketeBesedilo='', $steviloVprasanjNaslovnicaBesedilo='', $steviloVprasanjNaslovnica='', $avtorNaslovnicaBesedilo='', $avtorNaslovnica='', $avtorSpremenilNaslovnicaBesedilo='', $avtorSpremenilNaslovnica='', $anketaUstvarjenaNaslovnica='', $imeAnkete='', $dneBesedilo='', $vsiOdgovoriBesedilo=''){
+ global $lang, $site_path;
+ $tex = '';
+
+ //Aktiviranost ankete ##########################################################
+ $activity = SurveyInfo::getSurveyActivity();
+ $activityTex = $this->GetAktiviranostAnkete($activity);
+ //Aktiviranost ankete - konec ##################################################
+
+ //izbira ustreznega logotipa za določen jezik
+ if($lang['id'] == 1){ //ce je id 1, naj bo slovenski
+ $logo1ka = 'logo1ka';
+ }else{ //ce je bilo kateri drugi, naj bo angleski
+ $logo1ka = 'logo1kaeng';
+ }
+ //izbira ustreznega logotipa za določen jezik - konec
+ //echo "stevilo spremenljivk: ".(SurveyInfo::getSurveyVariableCount());
+ $steviloSpremenljivk = SurveyInfo::getSurveyVariableCount();
+
+
+
+ if($export_format == 'pdf'){
+ ####################################
+ //klicanje latex funkcije za generiranje naslovnice
+ $tex .= '
+ \naslovnica
+ {'.ENKA_LOGO_SIZE.', right}
+ {'.$logo1ka.'}
+ {'.$imeAnkete.'}
+ {'.$vsiOdgovoriBesedilo.'}
+ {\MakeUppercase{{'.$kratkoImeAnketeBesedilo.'}}: & {'.$kratkoImeAnkete.'}}
+ {\MakeUppercase{{'.$steviloVprasanjNaslovnicaBesedilo.'}}: & {'.$steviloVprasanjNaslovnica.'} \\\\
+ & \\\\
+ \MakeUppercase{{'.$lang['srv_usableResp_qcount'].'}}: & {'.$steviloSpremenljivk.'}}
+ {\MakeUppercase{{'.$lang['srv_displaydata_status'].'}}: & {'.$activityTex.'}}
+ {\MakeUppercase{{'.$avtorNaslovnicaBesedilo.'}}: & {'.$avtorNaslovnica.', '.$anketaUstvarjenaNaslovnica.'}}
+ {\MakeUppercase{{'.$avtorSpremenilNaslovnicaBesedilo.'}}: & {'.$avtorSpremenilNaslovnica.', '.$anketaSpremenjenaNaslovnica.'}}
+ ';
+ #################################### //tex za pdf naslovnico - konec
+ }else if($export_format == 'rtf'){
+ ####################################
+ //tex za rtf naslovnico
+ $tex .= '
+ %\\includegraphics['.ENKA_LOGO_SIZE.', right]{'.$this->path2Images.''.$logo1ka.'} \\par
+ \\vspace{4cm}
+ \\noindent
+ {\\huge \\textbf{\\noindent {'.$imeAnkete.'} }} \\par
+ \\vspace{1cm}
+ \\vspace{0.5cm}
+ \\noindent
+ {\\huge \\textbf{\\noindent {'.$vsiOdgovoriBesedilo.'} }} \\par
+ \\noindent
+ \\begin{tabular}{ll}
+ & \\\\
+ '.$kratkoImeAnketeBesedilo.': & '.$kratkoImeAnkete.' \\\\
+ & \\\\
+ '.$steviloVprasanjNaslovnicaBesedilo.': & '.$steviloVprasanjNaslovnica.' \\\\
+ & \\\\
+ '.$lang['srv_usableResp_qcount'].': & '.$steviloSpremenljivk.' \\\\
+ & \\\\
+ '.$lang['srv_displaydata_status'].': & '.$activityTex.' \\\\
+ & \\\\
+ '.$avtorNaslovnicaBesedilo.': & '.$avtorNaslovnica.', '.$anketaUstvarjenaNaslovnica.' \\\\
+ & \\\\
+ '.$avtorSpremenilNaslovnicaBesedilo.': & '.$avtorSpremenilNaslovnica.', '.$anketaSpremenjenaNaslovnica.'
+ \\end{tabular}
+ \\newline
+ \\newpage
+ ';
+ #################################### //tex za rtf naslovnico - konec
+ }
+ return $tex;
+ }
+ ###########################################
+
+ //Funkcija za pridobitev aktiviranosti ankete
+ function GetAktiviranostAnkete($activity=''){
+ global $lang;
+ $tex = '';
+ $_last_active = end($activity);
+ if (SurveyInfo::getSurveyColumn('active') == 1) { //ce je anketa aktivna
+ $tex = ''.$lang['srv_anketa_active2'].''; //zapisi: "Anketa je aktivna"
+ }else {
+ # preverimo ali je bila anketa že aktivirana
+ if (!isset($_last_active['starts'])) {
+ # anketa še sploh ni bila aktivirana
+ $tex = ''.$lang['srv_survey_non_active_notActivated1'].''; //zapisi: "Anketa se ni bila aktivirana"
+ } else {
+ # anketa je že bila aktivirana ampak je sedaj neaktivna
+ $tex = ''.$lang['srv_survey_non_active1'].''; //zapisi: "Anketa je zakljucena"
+ }
+ }
+ // Aktivnost
+ if( count($activity) > 0 ){
+ $tex = ''.$lang['export_firstpage_active_from'].': '.SurveyInfo::getSurveyStartsDate().''; //zapisi: "Aktivna od:"
+ $tex .= ' '.$lang['export_firstpage_active_until'].': '.SurveyInfo::getInstance()->getSurveyExpireDate().' '; //zapisi: "Aktivna do:"
+ }
+ return $tex;
+ }
+ #############################################
+
+ //Funkcija za generiranje in brisanje datotek za pdf izvoz
+ function OutputPdf($filenameTex='', $surveyId=null, $niPrijavljenUporabnik=null){
+ global $site_path;
+
+ # generating pdf file //ukaz je potrebno zagnati 2x, ker drugace ne pride do koncnega stevila strani, ki se nahaja v nogi, poleg trenutne strani
+ chdir($this->pathToTexFile);
+ if(IS_WINDOWS){
+ //za windows sisteme
+ $ukaz = 'latexmk -pdf '.$filenameTex;
+ //$ukaz = "latexmk -silent -f -pdf -e \'$max_repeat=2\' -pdflatex=\"/usr/bin/pdflatex -interaction=batchmode \"". $filenameTex;
+ exec($ukaz);
+ }elseif(IS_LINUX){
+ //za linux sisteme
+ exec("/usr/bin/pdflatex ".$filenameTex);
+ //exec("/usr/bin/buf_size=2000000 pdflatex ".$filenameTex);
+
+ }
+ # generating pdf file - konec
+
+ $filename = 'export_'.$this->export_subtype.'_'.$surveyId.'_'.$this->export_format.'_'.$niPrijavljenUporabnik;
+ $filenamePdf = $filename.'.pdf';
+ $filenameAux = $filename.'.aux';
+ $filenameLog = $filename.'.log';
+ $filenameOut = $filename.'.out';
+ $file = $this->pathToTexFile.$filenamePdf;
+
+ header('Content-type: application/pdf');
+ header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1');
+ header('Pragma: public');
+ header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+ //header('Content-Transfer-Encoding: binary');
+ //header('Accept-Ranges: bytes');
+ //header("Content-Length: " . filesize($file));
+ header('Content-Disposition: inline; filename="' . $filenamePdf . '"');
+
+ readfile($file);
+
+ //brisanje temp datotek slik
+ $this->DeleteChartTmpImage();
+ //brisanje temp datotek slik - konec
+ }
+ #############################################
+
+ //Funkcija, ki skrbi za brisanje tmp png datotek za izpis izvozov chart
+ function DeleteChartTmpImage(){
+ global $site_path;
+ $path = $site_path.'admin/survey/pChart/Cache/';
+ $dirList = glob($path . '*');
+ foreach ($dirList as $file) {
+ $fileExtArr = explode('.', $file);
+ $fileExt = $fileExtArr[count($fileExtArr)-1];
+ //if($fileExt == 'png'){
+ if($fileExt == 'pdf'){
+ unlink($file);
+ }
+ }
+ }
+ //Funkcija, ki skrbi za brisanje tmp png datotek za izpis izvozov chart - konec
+
+ //Funkcija, ki skrbi za brisanje tmp slikovnih datotek
+ function DeleteTmpImages($surveyId=null){
+ global $site_path;
+ $path = $site_path.'uploadi/editor/'; //pot do mape s tmp slikovnimi datotekami
+
+ $sqlSprem = sisplet_query("SELECT element_spr FROM srv_branching WHERE ank_id='".$surveyId."' ");
+ $sqlStavek = "SELECT element_spr FROM srv_branching WHERE ank_id='".$surveyId."' ";
+
+ while ($rowSprem = mysqli_fetch_assoc($sqlSprem)){
+
+ if($rowSprem['element_spr']){
+ //$textTest = $path.$rowSprem['element_spr'];
+ $textTest = $path.$rowSprem['element_spr']."_tmpImage";
+ //echo "Funkcija DeleteTmpImages ".$textTest." </br>";
+ $file2Delete = glob($textTest.'*');
+ //echo count($file2Delete)."</br>";
+ foreach ($file2Delete as $file) {
+ //echo "Funkcija DeleteTmpImages ".$file." </br>";
+ unlink($file);
+ }
+ }
+ }
+ }
+ //Funkcija, ki skrbi za brisanje tmp slikovnih datotek - konec
+
+
+
+ //Funkcija za generiranje in brisanje datotek za rtf izvoz
+ function OutputRtf($filenameTex='', $surveyId=null, $niPrijavljenUporabnik=null){
+ global $site_path;
+
+ # generating rtf file
+ if(IS_WINDOWS){
+ //za windows sisteme
+ $latex2Rtf = 'latex2rt';
+ }elseif(IS_LINUX){
+ //za linux sisteme
+ $latex2Rtf = 'latex2rtf';
+ }
+
+ $rtfGeneratingCommand = $latex2Rtf.' '.$filenameTex;
+ //$rtfGeneratingCommand = $latex2Rtf.' -d 2 '.$filenameTex.' 2>latex2rtf2.log'; //ukaz, ki ustavri se log datoteko
+ chdir($this->pathToTexFile);
+ //exec($rtfGeneratingCommand);
+
+ shell_exec($rtfGeneratingCommand);
+ # generating rtf file - konec
+
+ //$filename = 'export_'.$this->export_subtype.'_'.$surveyId.'_'.$this->export_format;
+ $filename = 'export_'.$this->export_subtype.'_'.$surveyId.'_'.$this->export_format.'_'.$niPrijavljenUporabnik;
+ $filenameRtf = $filename.'.rtf';
+ $file = $this->pathToTexFile.$filenameRtf;
+ //$file = $filenameRtf;
+ //echo "file: ".$file;
+
+ #uredi sirino stolpca tabele glede na stevilo stolpcev v tabeli neposredno v rtf ############################################
+ $this->urediStolpceTabele($file);
+ #uredi sirino stolpca tabele glede na stevilo stolpcev v tabeli neposredno v rtf - konec ####################################
+
+ #spremeni font v Montserrat neposredno v rtf ############################################
+ $this->urediFont($file);
+ #spremeni font v Montserrat neposredno v rtf - konec ####################################
+
+ #dodaj ustrezno barvo za crto glave in naslovnice neposredno v rtf ############################################
+ $this->urediBarvoCrte($file);
+ #dodaj ustrezno barvo za crto glave in naslovnice neposredno v rtf - konec ####################################
+
+ #dodaj ustrezno navpicno crto pred informacijami o anketi neposredno v rtf ############################################
+ if($this->export_subtype=="q_empty"||$this->export_subtype=="q_data_all"){
+ $this->dodajCrtoPred($file);
+ }
+ #dodaj ustrezno navpicno crto pred informacijami o anketi neposredno v rtf - konec ####################################
+
+ #dodaj ustrezno navpicno crto v glavi dokumenta neposredno v rtf ############################################
+ $this->dodajCrtoGlava($file);
+ #dodaj ustrezno navpicno crto v glavi dokumenta neposredno v rtf - konec ####################################
+
+ #dodaj ustrezno navpicno crto v nogi dokumenta neposredno v rtf ############################################
+ $this->dodajCrtoNoga($file);
+ #dodaj ustrezno navpicno crto v nogi dokumenta neposredno v rtf - konec ####################################
+
+ #header-ji rtf datoteke
+ header('Content-type: application/rtf');
+ header('Content-Transfer-Encoding: binary');
+ //header('Content-Length: ' . filesize($file));
+ header('Content-Disposition: inline; filename="' . $filenameRtf . '"');
+ //header('Content-Disposition: attachment;filename="'.basename($filename).'"');
+ #header-ji rtf datoteke - konec
+
+ #Stara varianta
+ //readfile($file);
+ #Stara varianta - konec
+
+ #nova varianta
+ set_time_limit(0);
+ $chunksize = 2 * (1024 * 1024); //5 MB (= 5 242 880 bytes) per one chunk of file.
+ //$fileD = @fopen($file,"r");
+ $fileD = @fopen($file,"rb");
+ while(!feof($fileD))
+ {
+ print(@fread($fileD, $chunksize));
+ ob_flush();
+ flush();
+ }
+ #nova varianta - konec
+
+ //brisanje temp datotek
+ unlink($file); //rtf
+ //brisanje temp datotek - konec
+ }
+ #############################################
+
+ //Funkcija za generiranje html kode
+ function OutputHtml($filenameTex='', $surveyId=null, $filename=''){
+ global $site_path;
+ //echo "filename: ".$filename." ";
+
+ # generating html file
+ $htmlGeneratingCommand = 'htlatex '.$filenameTex;
+ //$htmlGeneratingCommand = 'htlatex '.$filenameTex.' hello';
+ chdir($this->pathToTexFile);
+ exec($htmlGeneratingCommand); //5 kratna ponovitev ukaza, da se \multicolumn latex koda lahko prenese pravilno v colspan HTML
+ exec($htmlGeneratingCommand);
+ exec($htmlGeneratingCommand);
+ exec($htmlGeneratingCommand);
+ exec($htmlGeneratingCommand);
+ # generating html file - konec
+
+ echo file_get_contents($filename.'.html'); //odpri in pokazi html izvoz z gumbom za izvoz iz html v xls
+
+ $filenameCss = $filename.'.css';
+ $filenameHtml = $filename.'.html';
+ $filenameIdv = $filename.'.idv';
+ $filenameLg = $filename.'.lg';
+ $filenameTmp = $filename.'.tmp';
+ $filename4tc = $filename.'.4tc';
+ $filenameAux = $filename.'.aux';
+ $filenameDvi = $filename.'.dvi';
+ $filenameLog = $filename.'.log';
+ $filenameXref = $filename.'.xref';
+ $filename4ct = $filename.'.4ct';
+
+ //brisanje temp datotek
+ unlink($filenameCss); //css
+ unlink($filenameHtml); //html
+ unlink($filenameIdv); //idv
+ unlink($filenameLg); //lg
+ unlink($filenameTmp); //tmp
+ unlink($filename4tc); //4tc
+ unlink($filenameAux); //Aux
+ unlink($filenameDvi); //Dvi
+ unlink($filenameLog); //log
+ unlink($filenameXref); //Xref
+ unlink($filename4ct); //4ct
+ //brisanje temp datotek - konec
+ }
+ #############################################
+
+
+ ####################################################################################
+ //Funkcija, ki skrbi za urejanje sirine stolpca tabele glede na stevilo stolpcev v tabeli
+ function urediStolpceTabele($file=null){
+ $rtfCode = file_get_contents($file); //string z generirano rtf kodo
+
+ $pos = 0; //belezi pozicijo cellx kode v rtf
+ $posRowB = 0; //belezi pozicijo \\trowd kode v rtf, zacetek vrstice tabele
+ $posRowEnd = 0; //belezi pozicijo \\row kode v rtf, zakljucek vrstice tabele
+ $findB = 'trowd'; //rtf koda za zacetek tabele
+ $findCellx = 'cellx'; //rtrf koda za ureditev sirine celice
+ $findRow = '\row';
+ $numOfRowOccurrences = substr_count ($rtfCode, $findB); //belezi stevilo najdenih "trowd" v rtf kodi, stevilo vrstic v tabeli
+
+ if($numOfRowOccurrences){ //ce se pojavi kaksna vrstica v tabeli
+
+ for($i=0;$i<$numOfRowOccurrences;$i++){ //preleti vsako vrstico tabele
+ $posRowB = strpos($rtfCode, '\trowd', $posRowB+1); //belezi pozicijo zacetka kode za vrstico v tabeli
+ $posRowEnd = strpos($rtfCode, $findRow, $posRowEnd+1); //belezi pozicijo konca kode za vrstico v tabeli
+ $posRowEnd = $posRowEnd + strlen($findRow);
+
+ $substringVrstice = substr($rtfCode, $posRowB, (($posRowEnd-$posRowB)+1)); //belezi kodo celotne vrstice v tabeli
+
+ $lengthSubstringVrstice = strlen($substringVrstice); //dolzina trenutnega substring-a s katero se bo odstranilo staro kodo
+
+ $numOfCellxOccurrences = substr_count ($substringVrstice, $findCellx); //belezi stevilo najdenih "cellx" v rtf kodi za eno vrstico tabele
+ $pos = 0;
+ $posB = 0;
+ //echo "trowd: ".$posRowB."</br>";
+ //echo "numOfCellxOccurrences: ".$numOfCellxOccurrences."</br>";
+
+ if($numOfCellxOccurrences>2){ //ce imamo vec kot 2 stolpca, prilagodi sirino stolpca glede na stevilo stolpcev
+ for($j=1;$j<=$numOfCellxOccurrences;$j++){
+ $width = round( $j*PAGE_TEXT_WIDTH/($numOfCellxOccurrences) );
+ //echo "substringVrstice: ".$substringVrstice."</br></br>";
+
+ $posB = strpos($substringVrstice, 'cellx', $posB+1); //pozicija zacetka cellx kode, ki jo je potrebno nadomestiti
+ $posE = strpos($substringVrstice, "\\", $posB+1); //pozicija konca cellx kode, ki jo je potrebno nadomestiti
+
+ $cellXString = substr($substringVrstice, $posB, (($posE-$posB))); //trenutna cellx koda s sirino stolpca
+ //echo $cellXString."</br>";
+ $lastCellx = substr_count ($cellXString, '{'); //belezi stevilo najdenih "cellx" v rtf kodi za eno vrstico tabele
+ if($lastCellx){
+ $posSymbol = strpos($cellXString, '{', 0);
+ $cellXString = substr($cellXString,0,$posSymbol);
+ //echo $cellXString."</br>";
+ }
+ //echo $cellXString."</br>";
+ $replace = 'cellx'.$width; //nadomestna cellx koda s prilagojeno sirino glede na stevilo stolpcev
+
+ $substringVrstice = substr_replace($substringVrstice,'',$posB,strlen($cellXString)); //izbrisi trenutno kodo za cellx
+
+ $substringVrstice = substr_replace($substringVrstice,$replace,$posB,0); //nadomesti z novo kodo s posodobljeno sirino stolpca za cellx
+
+ }
+ //echo "</br> substringVrstice changed: ".$substringVrstice."</br></br></br>";
+
+ //iz trenutne rtf kode odstrani del s starim substring-om
+ $rtfCode = substr_replace($rtfCode,'',$posRowB, $lengthSubstringVrstice);
+
+ //na mestu starega substring dodaj spremenjenega
+ $rtfCode = substr_replace($rtfCode,$substringVrstice,$posRowB,0);
+
+ }elseif($numOfCellxOccurrences==1){ //ce je samo ena tabela (Izberite s seznama, Povleci-spusti, ...)
+ //echo "substringVrstice: ".$substringVrstice."</br></br>";
+
+ $posB = strpos($substringVrstice, 'cellx', $posB+1); //pozicija zacetka cellx kode, ki jo je potrebno nadomestiti
+ $posE = strpos($substringVrstice, "\\", $posB+1); //pozicija konca cellx kode, ki jo je potrebno nadomestiti
+
+ $cellXString = substr($substringVrstice, $posB, (($posE-$posB))); //trenutna cellx koda s sirino stolpca
+ //echo $cellXString."</br>";
+ $lastCellx = substr_count ($cellXString, '{'); //belezi stevilo najdenih "cellx" v rtf kodi za eno vrstico tabele
+ if($lastCellx){
+ $posSymbol = strpos($cellXString, '{', 0);
+ $cellXString = substr($cellXString,0,$posSymbol);
+ //echo $cellXString."</br>";
+ }
+ //echo $cellXString."</br>";
+ //$replace = 'cellx'.$width; //nadomestna cellx koda s prilagojeno sirino glede na stevilo stolpcev
+ $replace = 'cellx'.SINGLE_TABLE_WIDTH; //nadomestna cellx koda s prilagojeno sirino glede na stevilo stolpcev
+
+ $substringVrstice = substr_replace($substringVrstice,'',$posB,strlen($cellXString)); //izbrisi trenutno kodo za cellx
+
+ $substringVrstice = substr_replace($substringVrstice,$replace,$posB,0); //nadomesti z novo kodo s posodobljeno sirino stolpca za cellx
+
+ //iz trenutne rtf kode odstrani del s starim substring-om
+ $rtfCode = substr_replace($rtfCode,'',$posRowB, $lengthSubstringVrstice);
+
+ //na mestu starega substring dodaj spremenjenega
+ $rtfCode = substr_replace($rtfCode,$substringVrstice,$posRowB,0);
+ }
+ }
+ }
+
+ file_put_contents($file, $rtfCode); //prenesi preurejeno kodo v obstojeco rtf datoteko
+ }
+
+ //Funkcija, ki skrbi za urejanje sirine stolpca tabele glede na stevilo stolpcev v tabeli - konec
+ ###################################################################################################
+
+ ####################################################################################
+ //Funkcija, ki skrbi za spremembo fonta rtf dokumenta neposredno v rtf
+ function urediFont($file=null){
+ $rtfCode = file_get_contents($file); //string z generirano rtf kodo
+
+ $posOrigFont = 0; //belezi pozicijo imena fonta "Times New Roman" v rtf
+ $origFont = 'Times New Roman'; //belezi ime fonta, ki ga zelimo zamenjati
+ $lenOrigFont = strlen($origFont);
+ $newFont = 'Montserrat';
+
+ $posOrigFont = strpos($rtfCode, $origFont);
+ //echo "posOrigFont: ".$posOrigFont."</br>";
+ //echo "lenOrigFont: ".$lenOrigFont."</br>";
+
+ //iz trenutne rtf kode odstrani del s starim substring-om
+ $rtfCode = substr_replace($rtfCode,'', $posOrigFont, $lenOrigFont);
+
+ //na mestu starega substring dodaj spremenjenega
+ $rtfCode = substr_replace($rtfCode, $newFont, $posOrigFont, 0);
+
+// echo "rtfCode: </br>";
+// echo $rtfCode;
+
+ file_put_contents($file, $rtfCode); //prenesi preurejeno kodo v obstojeco rtf datoteko
+ }
+ //Funkcija, ki skrbi za spremembo fonta rtf dokumenta neposredno v rtf - konec
+ ###################################################################################################
+
+ ####################################################################################
+ //Funkcija, ki skrbi za dodajanje ustrezne barve navpicne crte neposredno v rtf
+ function urediBarvoCrte($file=null){
+ $rtfCode = file_get_contents($file); //string z generirano rtf kodo
+
+ $posColorTbl = 0; //belezi pozicijo besedila "\colortbl;" v rtf
+ $textColorTbl = '\colortbl;'; //belezi besedilo, ki iscemo
+ $lenColorTbl = strlen($textColorTbl); //dolzina besedila "\colortbl;", po kateri je potrebno dodati novo barvo
+
+ $newColor = '\red30\green136\blue229;';
+
+ $posColorTbl = strpos($rtfCode, $textColorTbl);
+ $posNewColor = $posColorTbl + $lenColorTbl; //hrani pozicijo nove barve
+
+ //na ustreznem mestu dodaj novo barvo - substr_replace(string,replacement,start,length)
+ $rtfCode = substr_replace($rtfCode, $newColor, $posNewColor, 0);
+
+ file_put_contents($file, $rtfCode); //prenesi preurejeno kodo v obstojeco rtf datoteko
+ }
+ //Funkcija, ki skrbi za dodajanje ustrezne barve navpicne crte neposredno v rtf - konec
+ ###################################################################################################
+
+ ####################################################################################
+ //Funkcija, ki skrbi za dodajanje navpicne crte pred informacijami o anketi neposredno v rtf
+ function dodajCrtoPred($file=null){
+ $rtfCode = file_get_contents($file); //string z generirano rtf kodo
+
+ $textPar = '{\pard\plain\s0\qj\widctlpar\f0\fs20\sl240\slmult1 \fi0 \par'; //hrani besedilo za zacetek naslednjega odstavka pred katerim se mora nahajati crta
+ $posBesedila = 0; //dodal definicijo pred klicem strpos, ker je javilo napako
+ $posPar = strpos($rtfCode, $textPar, $posBesedila); //pozicija zacetka naslednjega odstavka pred katerim se mora nahajati crta - //strpos(string,find,start)
+
+ $textCrta = '\pard \brdrb \brdrs\brdrw120\brsp20\brdrcf1 {\fs4\~}\par \pard'; //hrani besedilo za izris crte zelene debeline (120) in barve (brdrcf1), ki je potrebno dodati rtf kodi
+ $posCrta = $posPar; //hrani pozicijo kode z zeleno crto
+
+ //na ustreznem mestu dodaj zeleno crto - substr_replace(string,replacement,start,length)
+ $rtfCode = substr_replace($rtfCode, $textCrta, $posCrta, 0);
+
+ file_put_contents($file, $rtfCode); //prenesi preurejeno kodo v obstojeco rtf datoteko
+ }
+ //Funkcija, ki skrbi za dodajanje navpicne crte pred informacijami o anketi neposredno v rtf - konec
+ ###################################################################################################
+
+ ###################################################################################
+ //Funkcija, ki skrbi za dodajanje crte v glavi neposredno v rtf
+ function dodajCrtoGlava($file=null){
+ global $lang;
+
+ $rtfCode = file_get_contents($file); //string z generirano rtf kodo
+
+ $findHeaderStart = '\header'; //hrani besedilo zacetka glave, ki jo je potrebno najti
+ $posHeaderStart = strrpos($rtfCode, $findHeaderStart); //pozicija besedila za zacetek glave dokumenta - //strrpos(string,find)
+
+ $findPicStart = '\pict'; //hrani besedilo zacetka slike v glavi, kjer je potrebno dodati crto
+ $posPicStart = strpos($rtfCode, $findPicStart, $posHeaderStart); //pozicija besedila zacetka slike - //strpos(string,find,start)
+
+ $findPicEnd = '}'; //hrani besedilo konca slike v glavi
+ $posPicEnd = strpos($rtfCode, $findPicEnd, $posPicStart); //pozicija besedila konca slike v glavi dokumenta - //strpos(string,find,start)
+
+ $findTitleEnd = '\tab'; //hrani besedilo konca naslova vprasalnika v glavi, kjer je potrebno dodati crto
+ $posTitleEnd = strpos($rtfCode, $findTitleEnd, $posPicEnd); //pozicija besedila konca naslova vprasalnika v glavi dokumenta - //strpos(string,find,start)
+
+ $textCrta = '\pard \brdrb \brdrs\brdrw120\brsp20\brdrcf1 {\fs4\~}\par \pard'; //hrani besedilo za izris crte zelene debeline (120) in barve (brdrcf1), ki je potrebno dodati rtf kodi
+ $posCrta = $posTitleEnd+strlen($findTitleEnd); //hrani pozicijo kode z zeleno crto
+
+ //na ustreznem mestu dodaj zeleno crto - substr_replace(string,replacement,start,length)
+ $rtfCode = substr_replace($rtfCode, $textCrta, $posCrta, 0);
+
+ file_put_contents($file, $rtfCode); //prenesi preurejeno kodo v obstojeco rtf datoteko
+ }
+ //Funkcija, ki skrbi za dodajanje crte v glavi neposredno v rtf
+ ###################################################################################################
+
+
+ ####################################################################################
+ //Funkcija, ki skrbi za dodajanje crte v nogi neposredno v rtf
+ function dodajCrtoNoga($file=null){
+ global $lang;
+
+ $rtfCode = file_get_contents($file); //string z generirano rtf kodo
+
+ $findFooterStart = '\footer'; //hrani besedilo zacetka noge
+ $posFooterStart = strrpos($rtfCode, $findFooterStart); //pozicija besedila za zacetek noge dokumenta - //strrpos(string,find,start) - najde zadnje besedilo v kodi
+ $lenFooterStart = strlen($findFooterStart); //dolzina besedila "\footer", po kateri je potrebno dodati kodo za crto v nogi
+
+ $textCrta = '\pard \brdrb \brdrs\brdrw10\brsp20\brdrcf2 {\fs4\~}\par \pard'; //hrani besedilo za izris crte zelene debeline (10) in barve (brdrcf2), ki je potrebno dodati rtf kodi
+ $posCrta = $posFooterStart + $lenFooterStart; //hrani pozicijo kode z zeleno crto
+
+ //na ustreznem mestu dodaj zeleno crto - substr_replace(string,replacement,start,length)
+ $rtfCode = substr_replace($rtfCode, $textCrta, $posCrta, 0);
+
+ file_put_contents($file, $rtfCode); //prenesi preurejeno kodo v obstojeco rtf datoteko
+ }
+ //Funkcija, ki skrbi za dodajanje crte v nogi neposredno v rtf - konec
+ ###################################################################################################
+
+ function HeatmapImage($sprId=null){
+ $imageFileName = 'heatmap'.$sprId.'.png';
+ //echo "imageFileName: ".$imageFileName."</br>";
+ global $site_path;
+ global $site_url;
+ //echo '<img alt="" src="'.$site_url.'main/survey/uploads/'.$fileName.'"></br>';
+ $src = $site_url.'main/survey/uploads/'.$imageFileName;
+ $image = imagecreatefrompng($src);
+
+ imagealphablending($image, false);
+ imagesavealpha($image, true);
+
+ header('Content-Disposition: Attachment;filename='.$imageFileName.';filename*=utf8'.$imageFileName);
+ header('Content-Type: image/png');
+ //header('Content-Type: image/png; charset=utf-8');
+ //header('Content-Type: application/force-download');
+
+ imagepng($image);
+ imagedestroy($image);
+ }
+
+ function getRecnum(){
+ $izbranStatusProfile = SurveyStatusProfiles :: getStatusAsQueryString();
+ $sqluString = "SELECT id, last_status, lurker, recnum FROM srv_user WHERE ank_id = '".$this->anketa."' ".$izbranStatusProfile." AND deleted='0' AND preview='0' AND id='".$this->usr_id."' ORDER BY recnum";
+ //echo $sqluString;
+ $sqlu = sisplet_query($sqluString);
+ $rowu = mysqli_fetch_array($sqlu);
+ $recnum = $rowu['recnum'];
+ return $recnum;
+ }
+
+ #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno
+ function encodeText($text=''){
+ global $site_path, $lang;
+ //$text = str_replace(' ','X',$text); //nadomesti presledke
+ //echo "Encoding ".$text."</br>";
+
+ $this->path2UploadedImages = $site_path.'uploadi/editor/';
+ if($text == ''){ //ce ni teksta, vrni se
+ return;
+ }
+
+ //ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
+ $text = str_replace('\\','\textbackslash{} ',$text);
+ //$text = str_replace('{','\{',$text);
+ //$text = str_replace('}','\}',$text);
+ $text = str_replace('$','\$ ',$text);
+ $text = str_replace('#','\# ',$text);
+ $text = str_replace('%','\% ',$text);
+ $text = str_replace('€','\euro',$text);
+ $text = str_replace('^','\textasciicircum{} ',$text);
+ $text = str_replace('_','\_ ',$text);
+ $text = str_replace('~','\textasciitilde{} ',$text);
+ if(strpos($text, '&amp;')){ //ce je prisotno v besedilu &amp;'
+ $text = str_replace('&amp;','\& ',$text);
+ }else{
+ $text = str_replace('&','\& ',$text);
+ }
+ $text = str_replace('&nbsp;','~',$text);
+ //$text = str_replace('&lt;','\textless ',$text);
+ $text = str_replace('&lt;',' \textless ',$text);
+ //$text = str_replace('&gt;','\textgreater ',$text);
+ $text = str_replace('&gt;',' \textgreater ',$text);
+ //ureditev posebnih karakterjev za Latex - konec
+
+ //ureditev grskih crk
+ $text = str_replace('α','\textalpha ',$text);
+ $text = str_replace('β','\textbeta ',$text);
+ $text = str_replace('γ','\textgamma ',$text);
+ $text = str_replace('δ','\textdelta ',$text);
+ $text = str_replace('ε','\textepsilon ',$text);
+ $text = str_replace('ζ','\textzeta ',$text);
+ $text = str_replace('η','\texteta ',$text);
+ $text = str_replace('θ','\texttheta ',$text);
+ $text = str_replace('ι','\textiota ',$text);
+ $text = str_replace('κ','\textkappa ',$text);
+ $text = str_replace('λ','\textlambda ',$text);
+ $text = str_replace('μ','\textmugreek ',$text);
+ $text = str_replace('ν','\textnu ',$text);
+ $text = str_replace('ξ','\textxi ',$text);
+ //$text = str_replace('ο','\textomikron ',$text);
+ $text = str_replace('π','\textpi ',$text);
+ $text = str_replace('ρ','\textrho ',$text);
+ $text = str_replace('σ','\textsigma ',$text);
+ $text = str_replace('τ','\texttau ',$text);
+ $text = str_replace('υ','\textupsilon ',$text);
+ $text = str_replace('φ','\textphi ',$text);
+ $text = str_replace('χ','\textchi ',$text);
+ $text = str_replace('ψ','\textpsi ',$text);
+ $text = str_replace('ω','\textomega ',$text);
+ //ureditev grskih crk - konec
+
+
+ //RESEVANJE BESEDILA V CIRILICI
+ $contains_cyrillic = (bool) preg_match('/[\p{Cyrillic}]/u', $text); //ali je v besedilu cirilica?
+ if($contains_cyrillic){ // ce je cirilica v besedilu
+ $text = '\foreignlanguage{russian}{'.$text.'}';
+ }
+ //RESEVANJE BESEDILA V CIRILICI - konec
+
+ return $text;
+ }
+ #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno - konec
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexEditsAnalysis.php b/admin/survey/export/latexclasses/class.LatexEditsAnalysis.php
new file mode 100644
index 0000000..698f79c
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexEditsAnalysis.php
@@ -0,0 +1,1305 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+ //require_once('../exportclases/class.enka.pdf.php');
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('FRAME_TEXT_WIDTH', 0.3);
+ define ('FRAME_WIDTH', 480);
+ define ('FRAME_HEIGTH', 203);
+ define ('GRAPH_LINE_WIDTH', 0.15);
+ define ('GRAPH_LINE_LENGTH_MAX', 7);
+
+
+
+/** Class za generacijo pdf-a
+ *
+ * @desc: po novem je potrebno form elemente generirati ro�no kot slike
+ *
+ */
+class LatexEditsAnalysis {
+
+ var $anketa;// = array(); // trenutna anketa
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+ var $db_table = '';
+
+ public static $ss = null; //SurveyStatistic class
+ public static $sas = null; // $sas = new SurveyAdminSettings();class
+
+ protected $texNewLine = '\\\\ ';
+ protected $texBigSkip = '\bigskip';
+ protected $texSmallSkip = '\smallskip';
+ protected $horizontalLineTex = "\\hline ";
+
+ //nastavitve za prikazovanje
+ protected $seansa = '30';
+ protected $times = '1 month';
+ protected $status = 0;
+ protected $from = '';
+ protected $to = '';
+ protected $period = 'day';
+ protected $user = 'all';
+ //nastavitve za prikazovanje - konec
+
+ protected $interval;
+ protected $data;
+ protected $statuses;
+
+ protected $sum_data;
+
+ protected $texTimeEdits='';
+
+ protected $vrsticaTex = array();
+
+ public static $sea = null; //SurveyEditsAnalysis class
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $ssData = null)
+ {
+ global $site_path;
+ global $global_user_id;
+ global $lang;
+
+ //error_log(json_encode($_GET));
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa) )
+ {
+ $this->anketa['id'] = $anketa;
+ $this->anketa['podstran'] = $podstran;
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+
+ $this->sea=new SurveyEditsAnalysis($this->anketa['id']);
+
+ if ($_GET['seansa'] > 0){
+ //if (isset ($_GET['seansa'])){
+ $seansa = $_GET['seansa'];
+ }else{
+ $seansa = '30';
+ }
+ if (isset ($_GET['time'])){
+ $time = $_GET['time'];
+ }else{
+ $time = '1 month';
+ }
+ if (isset ($_GET['status'])){
+ $status = $_GET['status'];
+ }else{
+ $status = 0;
+ }
+ if (isset ($_GET['from'])){
+ $from = $_GET['from'];
+ }else{
+ $from = '';
+ }
+ if (isset ($_GET['to'])){
+ $to = $_GET['to'];
+ }else{
+ $to = '';
+ }
+ if (isset ($_GET['user'])){
+ $user = $_GET['user'];
+ }else{
+ $user = 'all';
+ }
+ if (isset ($_GET['period'])){
+ $period = $_GET['period'];
+ }else{
+ $period = 'day';
+ }
+
+ $this->seansa = $seansa;
+ $this->times = $time;
+ $this->status = $status;
+ $this->from = $from;
+ $this->to = $to;
+ $this->period = $period;
+ $this->user = $user;
+
+ // Legenda statusov
+ $this->statuses = array(
+ -1 => $lang['srv_vsi'],
+ 0 => $lang['srv_urejanje'],
+ 1 => $lang['import_data'],
+ 2 => $lang['export_analisys'],
+ 3 => $lang['srv_reporti'],
+ 4 => $lang['srv_podatki'],
+ 5 => $lang['srv_inv_nav_email'],
+ 20 => $lang['srv_hierarchy'], // Splošni podatki o hierarhiji
+ 21 => $lang['srv_hierarchy_structure'], // Grajenje hierarhije
+ 22 => $lang['srv_hierarchy_users'], // Urejanje uporabnikov
+ );
+
+ // Legenda seans
+ $this->seanse = array(
+ 5 => $lang['srv_edits_analysis_seansa_5min'],
+ 10 => $lang['srv_edits_analysis_seansa_10min'],
+ 30 => $lang['srv_edits_analysis_seansa_30min'], // Grajenje hierarhije
+ 60 => $lang['srv_edits_analysis_seansa_60min'], // Urejanje uporabnikov
+ );
+
+ // Legenda casov
+ $this->timings = array(
+ 'lifetime' => $lang['srv_edits_analysis_period_lifetime'],
+ '1 hour' => $lang['srv_diagnostics_1 hour'],
+ '6 hour' => $lang['srv_diagnostics_6 hour'],
+ '12 hour' => $lang['srv_diagnostics_12 hour'],
+ '1 day' => $lang['srv_diagnostics_1 day'],
+ '2 day' => $lang['srv_diagnostics_2 day'],
+ '5 day' => $lang['srv_diagnostics_5 day'],
+ '7 day' => $lang['srv_diagnostics_7 day'],
+ '14 day' => $lang['srv_diagnostics_14 day'],
+ '1 month' => $lang['srv_diagnostics_1 month'],
+ '3 month' => $lang['srv_diagnostics_3 month'],
+ '6 month' => $lang['srv_diagnostics_6 month'],
+ '99date' => $lang['srv_diagnostics_choose_date'],
+ );
+
+ // Legenda intervalov
+ $this->interval_criteria = array(
+ 'hour' => $lang['srv_statistic_period_hour_period'],
+ 'day' => $lang['srv_statistic_period_day_period'],
+ );
+
+
+ //print_r($_GET);
+
+ //create iterval - SQL where statement
+ $this->interval = $this->sea->createInterval($time, $from, $to);
+
+ //get object of all edits data
+ $this->data = $this->sea->getData($status, $this->interval);
+
+ $sum_data = $this->TimeEdits($this->data['timeEdits'], $this->seansa*60, $status);
+ $this->sum_data = $sum_data;
+
+ $this->sas = new SurveyAdminSettings(0,$this->anketa['id']);
+ //ustvarimo SurveyStatistic objekt in mu napolnimo variable
+ $this->ss = new SurveyStatistic();
+ $this->ss->Init($this->anketa['id'],true);
+ /*
+
+ $this->ss->realUsersByStatus_base = $ssData[0];
+
+ $this->ss->type = $ssData[1];
+ $this->ss->period = $ssData[2];
+ */
+ /* intervali se več ne pošiljajo preko get, ker se polovijo iz porfila
+ if($ssData[1] != 'undefined')
+ $this->ss->startDate = $ssData[1];
+ if($ssData[2] != 'undefined')
+ $this->ss->endDate = $ssData[2];
+ $this->ss->type = $ssData[3];
+ $this->ss->period = $ssData[4];
+ //$this->ss->isDefaultFilters = false;
+ */
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']))
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+ public function displayEditAnalysis() {
+ global $lang;
+
+ $texEditAnalysis = '';
+
+ // imamo vnose, prikažemo statistiko
+ //$this->ss->PrepareDateView();
+ //$this->ss->PrepareStatusView();
+
+ //naslov izvoza
+ //$texEditAnalysis .= $this->returnBold($lang['srv_edits_analysis']).$this->texNewLine.$this->texNewLine;
+ $texEditAnalysis .= '\MakeUppercase{\huge \textbf{Status - '.$lang['srv_edits_analysis'].'}}'.$this->texBigSkip.$this->texNewLine;
+
+ //$texStatus .= '\begin{tableStatus}'; /*zacetek environmenta z manjsim fontom*/
+ $texEditAnalysis .= '\begin{tableStatus}'; /*zacetek environmenta z manjsim fontom*/
+
+ //vrstica z nastavitvami #########################
+ $texEditAnalysis .= $this->returnBold($lang['srv_edits_analysis_seansa']).''.$this->seanse[$this->seansa].' '.$this->returnBold($lang['status']).''.$this->statuses[$this->status].' '.$this->returnBold($lang['in']).':'.$this->timings[$this->times].''.$this->returnBold($lang['srv_diagnostics_orfrom']).' '.$this->from.' '.$this->returnBold($lang['srv_diagnostics_to']).' '.$this->to.'';
+ $texEditAnalysis .= $this->texBigSkip.$this->texNewLine;
+
+
+ if(sizeof($this->data) == 0){
+ $texEditAnalysis .= $lang['srv_edits_analysis_no_data'];
+ }
+ else{
+ //Akcije urejanja #########################
+ $texEditAnalysis .= $this->DisplayCounter();
+
+ //prostor med tabelama
+ $texEditAnalysis .= $this->texBigSkip.$this->texBigSkip.$this->texNewLine;
+
+ //Neprekinjeno urejanje #########################
+ $texEditAnalysis .= $this->DisplayContinu();
+
+ //prostor med tabelama
+ //$texEditAnalysis .= $this->texBigSkip.$this->texBigSkip.$this->texNewLine;
+ $texEditAnalysis .= $this->texBigSkip.$this->texBigSkip;
+
+ //Podrobnosti urejanja #########################
+ $texEditAnalysis .= $this->DisplayTimeEdits();
+
+ }
+ //$texStatus .= '\end{tableStatus}'; /*zakljucek environmenta z manjsim fontom*/
+ $texEditAnalysis .= '\end{tableStatus}'; /*zakljucek environmenta z manjsim fontom*/
+ //echo $texEditAnalysis;
+ return $texEditAnalysis;
+
+ }
+
+ /** Funkcija prikaze Akcije urejanja
+ *
+ */
+ function DisplayCounter() {
+ global $lang;
+ global $site_url;
+
+ $tex = '';
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_edits_analysis_counter']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ if(sizeof($this->data) == 0)
+ $tex .= $lang['srv_edits_analysis_no_data'];
+ else{
+
+ $sum_data = $this->sum_data;
+
+ //izpis stevila urejevalcev
+ $tex .= $lang['srv_edits_analysis_counter_editors'].': '.sizeof($sum_data).$this->texBigSkip.$this->texNewLine;
+
+ $sum_akcij = 0;
+ $sum_time = 0;
+ $sum_seans = 0;
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 4;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ $parameterTabular .= 'l|';
+ }elseif($i == $steviloOstalihStolpcev){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'C' : 'c');
+ $parameterTabular .='c';
+ }else{
+ //$parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|');
+ $parameterTabular .= 'c|';
+ }
+ }
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabular';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //Priprava podatkov za izpis vrstic tabele in njihov izpis
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($lang['srv_edits_analysis_counter_editor']);
+ $prvaVrstica[] = $this->encodeText($lang['srv_edits_analysis_time_time']);
+ $prvaVrstica[] = $this->encodeText($lang['srv_edits_analysis_num_sessions']);
+ $prvaVrstica[] = $this->encodeText($lang['srv_edits_analysis_time_actions']);
+
+ $tex .= $this->tableRow($prvaVrstica); //Izpis 1. vrstice tabele
+
+
+ foreach ($sum_data as $key => $value) {
+ $vrsticaPodatki = array();
+ $vrsticaPodatki[] = $key;
+ $vrsticaPodatki[] = $this->sea->calculateTimeFromSeconds($value['time_sum']);
+ $vrsticaPodatki[] = $value['st_seans_sum'];
+ $vrsticaPodatki[] = $value['st_akcij_sum'];
+ $tex .= $this->tableRow($vrsticaPodatki); //Izpis vrstic tabele s podatki
+
+ $sum_akcij += $value['st_akcij_sum'];
+ $sum_time += $value['time_sum'];
+ $sum_seans += $value['st_seans_sum'];
+ }
+
+
+ // vsota veljavnih
+ $vrsticaSum = array();
+ $vrsticaSum[] = $this->encodeText($lang['srv_edits_analysis_time_total']);
+ $vrsticaSum[] = $this->sea->calculateTimeFromSeconds($sum_time);
+ $vrsticaSum[] = $sum_seans;
+ $vrsticaSum[] = $sum_akcij;
+ $tex .= $this->tableRow($vrsticaSum); //Izpis vrstice s sumo
+
+ //Priprava podatkov za izpis vrstic tabele in njihov izpis - konec
+
+ //zaljucek latex tabele s podatki
+ $tex .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+ }
+ //izpis tabele v okvir
+ //$texText = $this->FrameText($title.$tex);
+ $texText = ($title.$tex);
+
+ //echo $tex;
+ return $texText;
+ }
+
+ /** Funkcija prikaze Neprekinjeno urejanje
+ *
+ */
+ function DisplayContinu() {
+ global $lang;
+
+ $tex = '';
+ $sum_data = $this->sum_data;
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_edits_analysis_countinu']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ //izpis nastavitev
+ if($this->user == 'all'){
+ $user = $lang['srv_edits_analysis_counter_all'];
+ }else{
+ foreach ($sum_data as $email => $row) {
+ if($row['user_id'] == $this->user){
+ $user = $email;
+ }
+ }
+ }
+ $tex .= $lang['srv_edits_analysis_counter_editors'].': '.$user.'; '.$lang['srv_statistic_period'].': '.$this->interval_criteria[$this->period].$this->texBigSkip.$this->texNewLine;
+ //izpis nastavitev - konec
+
+
+ $interval_criteria = $this->period;
+ $user_criteria = $this->user;
+ $continu_data = $this->sea->continuEditsQuery($this->status, $this->interval, $interval_criteria, $user_criteria);
+
+ $data = $continu_data;
+
+ ##################
+ $maxValue = 0;
+
+ $interval_seconds = ($interval_criteria == 'day') ? 86400 : 3600;
+ $interval_crit = ($interval_criteria == 'day') ? '' : ' H';
+
+ if ($data) {
+ $temp_time = null;
+ //units
+ $zapored = 0;
+ $results = array();
+
+ foreach ($data as $row) {
+ if($temp_time == null){
+ //$format = 'Y-m-d'.$interval_crit;
+ $temp_time = DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']);
+ //$temp_time = DateTime::createFromFormat($format, $row['formatdate']);
+
+ }
+ else{
+ //calculate seconds between actions (rounded on 3600 or 86400)
+ $interval = $this->sea->calculateTimeBetweenActions($temp_time, DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']));
+
+ //if interval between actions are 1 unit (1 hour or 1 day), add it to continued editing session
+ if($interval/$interval_seconds-$zapored < 2){
+ $zapored++;
+ //set maxValue, needed for width of bars
+ $maxValue = max($maxValue, $zapored);
+ }
+ //interval is more than 1 unit apart, not in continued editing session
+ else{
+ //if there is continued editing session until previous action, store it to array - ignore otherwise
+ if($zapored > 0){
+ array_push($results, array('time' => $temp_time, 'zapored' => $zapored));
+ }
+ //restart all
+ $temp_time = DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']);
+ $zapored = 0;
+ }
+ }
+ }
+ //if there is continued editing session in last actions, store it to array - ignore otherwise
+ if($zapored > 0){
+ //$this->ContinuRow($temp_time, $zapored, $maxValue, $value);
+ array_push($results, array('time' => $temp_time, 'zapored' => $zapored));
+ }
+ if(!$results){
+ //$this->echoNoData();
+ $tex .= $this->encodeText($lang['srv_no_data']).$this->texNewLine;
+ }
+ else{
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+ //$parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize=.3\hsize}X' : 'l'); //fiksna sirina prvega stolpca, da sprejme datum in uro
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+ //reduce bars a little
+ $maxValue *= GRAPH_REDUCE;//najvecje stevilo
+
+ //draw all data and bars
+ foreach ($results as $row) {
+ $text = $this->ContinuRow($row['time'], $row['zapored'], $maxValue, $interval_criteria);
+ $tex .= $this->displayLineWithGraph($text, ($row['zapored']+1), $maxValue);
+ }
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic - konec
+
+ //zaljucek latex tabele s podatki
+ $tex .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+ }
+ } else{
+ //$this->echoNoData();
+ $tex .= $this->encodeText($lang['srv_no_data']).$this->texNewLine;
+ }
+ #################
+
+ //izpis tabele in besedila v okvir
+ //$texText = $this->FrameText($title.$tex);
+ $texText = ($title.$tex);
+
+ return $texText;
+ }
+
+ /**
+ * Returns time string in exact format
+ * @param type $temp_time - the last edit
+ * @param type $zapored - hour of continuoed editing
+ * @param type $maxValue - max value of bars
+ * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour'
+ */
+ function ContinuRow($temp_time=null, $zapored=null, $maxValue=null, $interval_criteria=null){
+ $s_time = '';
+
+ $time_last = clone $temp_time;
+ //edit DateTime get starting of continued editting session by subtracting units
+ $temp_time->modify('- '.$zapored.' '.$interval_criteria);
+
+ //if hour criteria
+ if($interval_criteria == 'hour'){
+ //add 1 hour because of from to view
+ $time_last->modify('+ 1 '.$interval_criteria);
+ $s_time = $temp_time->format('Y-m-d H:00') .' - '. $time_last->format('H:00');
+ }
+ elseif($interval_criteria == 'day'){
+ $s_time = $temp_time->format('Y-m-d') .' - '. $time_last->format('Y-m-d');
+ }
+
+ return $s_time;
+
+ }
+
+ /** Funkcija prikaze Podrobnosti urejanja
+ *
+ */
+ function DisplayTimeEdits() {
+ global $lang;
+
+ $tex = '';
+ $sum_data = $this->sum_data;
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_edits_analysis_editing_details']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ $tex .= $this->texTimeEdits;
+
+
+ //izpis tabele in besedila v okvir
+ //$texText = $this->FrameText($title.$tex);
+ $texText = ($title.$tex);
+
+ return $texText;
+ }
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="..."){
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+ #moja funkcija encodeText
+ function encodeText($text=''){
+ // popravimo sumnike ce je potrebno
+ //$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
+ //$text = str_replace("&scaron;","š",$text);
+ //echo "Encoding ".$text."</br>";
+ if($text == ''){ //ce ni teksta, vrni se
+ return;
+ }
+ $textOrig = $text;
+ $findme = '<br />';
+ $findmeLength = strlen($findme);
+ $findImg = '<img';
+ $findImgLength = strlen($findImg);
+
+ $pos = strpos($text, $findme);
+ $posImg = strpos($text, $findImg);
+
+ //ureditev izrisa slike
+ if($posImg !== false){
+ $numOfImgs = substr_count($text, $findImg); //stevilo '<br />' v tekstu
+ $posImg = strpos($text, $findImg);
+ $textPrej = '';
+ $textPotem = '';
+ for($i=0; $i<$numOfImgs; $i++){
+ $posImg = strpos($text, $findImg);
+ $textPrej = substr($text, 0, $posImg); //tekst do img
+ $textPotem = substr($text, $posImg); //tekst po img, z vkljuceno hmlt kodo z img
+ $posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
+ $textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
+
+ $text = $textPrej.' '.PIC_SIZE_ANS."{".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
+ //$text2Return = $textPrej.' '.PIC_SIZE_ANS."{".$this->getImageName($text2Return, 0, 'img')."}".' '.$textPotem;
+ }
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
+ $findImgCode = '\includegraphics';
+ $posOfImgCode = strpos($text, $findImgCode);
+ //echo $posOfImgCode."</br>";
+ $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode
+ //echo $textToImgCode."</br>";
+ $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode
+ //echo $textFromImgCode."</br>";
+ $findImgCodeEnd = '}';
+ //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd);
+ $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd);
+ //echo $posOfImgCodeEnd."</br>";
+ $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd
+ //echo $textAfterImgCode."</br>";
+ $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1);
+ //echo $textOfImgCode."</br>";
+
+ $text = $textToImgCode.$textAfterImgCode;
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - konec
+ }
+ //ureditev izrisa slike - konec
+
+ //ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
+ $text = str_replace('\\','\textbackslash{} ',$text);
+ //$text = str_replace('{','\{',$text);
+ //$text = str_replace('}','\}',$text);
+ $text = str_replace('$','\$ ',$text);
+ $text = str_replace('#','\# ',$text);
+ $text = str_replace('%','\% ',$text);
+ $text = str_replace('€','\euro',$text);
+ $text = str_replace('^','\textasciicircum{} ',$text);
+ //$text = str_replace('_','\_ ',$text);
+ $text = str_replace('_','\_',$text);
+ $text = str_replace('~','\textasciitilde{} ',$text);
+ $text = str_replace('&amp;','\&',$text);
+ $text = str_replace('&','\&',$text);
+ //$text = str_replace('&lt;','\textless ',$text);
+ $text = str_replace('&lt;','\textless',$text);
+ //$text = str_replace('&gt;','\textgreater ',$text);
+ $text = str_replace('&gt;','\textgreater',$text);
+ $text = str_replace('&nbsp;',' ',$text);
+ //ureditev posebnih karakterjev za Latex - konec
+
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+ if($posImg !== false){
+ $text = substr_replace($text, $textOfImgCode, $posOfImgCode, 0);
+ }
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+
+ if($pos === false && $posImg === false) { //v tekstu ni br in img
+ //return $text;
+/* echo "encode pred strip: ".$text."</br>";
+ echo "encode po strip: ".strip_tags($text)."</br>";
+ return strip_tags($text); */
+ }else { //v tekstu sta prisotna br ali img
+ $text2Return = ''; //tekst ki bo vrnjen
+
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
+ if($pos !== false){
+ $pos = strpos($text, $findme);
+ $numOfBr = substr_count($text, $findme); //stevilo '<br />' v tekstu
+ for($i=0; $i<$numOfBr; $i++){
+ if($i == 0){ //ce je prvi najdeni '<br />'
+ $textPrej = substr($text, 0, $pos);
+ $textPotem = substr($text, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ $text2Return .= $textPrej.' \break '.$textPotem;
+ }else{
+ $text2Return .= $textPrej.' \break ';
+ }
+ }else{ //drugace
+ $pos = strpos($textPotem, $findme);
+ $textPrej = substr($textPotem, 0, $pos);
+ $textPotem = substr($textPotem, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ $text2Return .= $textPrej.' \break '.$textPotem;
+ }else{
+ $text2Return .= $textPrej.' \break ';
+ }
+ }
+ }
+ $text = $text2Return;
+ }
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
+/* echo "encode pred strip: ".$text."</br>";
+ echo "encode po strip: ".strip_tags($text)."</br>";
+ return strip_tags($text); //vrni tekst brez html tag-ov */
+ }
+
+ //preveri, ce je url v besedilu (http:// ... ) in uredi Latex izpis le-tega
+ $findHttp = 'http://';
+ $findHttps = 'https://';
+ $posHttp = strpos($text, $findHttp);
+ $posHttps = strpos($text, $findHttps);
+
+ if($posHttp !== false || $posHttps !== false) { //v imamo URL naslov
+ $space = ' ';
+ if($posHttp !== false){
+ $text = substr_replace($text, $space, ($posHttp+7), 0);
+ }elseif($posHttps !== false){
+ $text = substr_replace($text, $space, ($posHttps+8), 0);
+ }
+ }
+ //preveri, ce je url v besedilu (http:// ... ) in uredi Latex izpis le-tega - konec
+
+ return strip_tags($text); //vrni tekst brez html tag-ov
+ }
+
+ function returnBold($text=''){
+ $boldedText = '';
+ $boldedText .= '\textbf{'.$text.'}';
+ return $boldedText;
+ }
+
+ function returnBoldAndRed($text=''){
+ //$this->naslovnicaUkaz .= ' {\\textcolor{red}{'.$lang['srv_survey_non_active1'].'}} \\\\';
+ $tex = '';
+ $tex .= ' {\\textcolor{red}{'.$text.'}} ';
+ return $tex;
+ }
+
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele ##################################################################################
+ #argumenti 1. export_format, 2. parametri tabele, 3. tip tabele za pdf, 4. tip tabele za rtf, 5. sirina pdf tabele (delez sirine strani), 6. sirina rtf tabele (delez sirine strani)
+ function StartLatexTable($export_format='', $parameterTabular='', $pdfTable='', $rtfTable='', $pdfTableWidth='', $rtfTableWidth=''){
+ $tex = '';
+ //$tex .= '\keepXColumns';
+ if($export_format == 'pdf'){
+ $tex .= '\begin{'.$pdfTable.'}';
+ if($pdfTable=='tabularx'){
+ //$tex .= '{'.$pdfTableWidth.'\textwidth}';
+ $tex .= '{\hsize}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }elseif($export_format == 'rtf'){
+ $tex .= '\begin{'.$rtfTable.'}';
+ if($rtfTable=='tabular*'){
+ $tex .= '{'.$pdfTableWidth.'\textwidth}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele - konec ##########################################################################
+
+ //omogoca izpis okvirja z dolocene sirine in visine s tekstom dolocene sirine
+ function FrameText($text=''){
+ $framedText = '';
+ //$framedText .= '\framebox('.FRAME_WIDTH.','.FRAME_HEIGTH.')[t]{ \parbox[t]{'.FRAME_TEXT_WIDTH.'\textwidth}{'.$this->texSmallSkip.$text.'} }';
+ $framedText .= '\framebox('.FRAME_WIDTH.','.FRAME_HEIGTH.')[t]{ \parbox[t]{'.FRAME_WIDTH.'pt}{'.$this->texSmallSkip.$text.'} }';
+ return $framedText;
+ }
+
+ //function tableRow($arrayText, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $steviloPodstolpcev){
+ function tableRow($arrayText=null, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $color='', $export_format = null, $steviloPodstolpcev = null){
+ $tableRow = '';
+ /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
+ $linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
+ $height = 1; //$height = $this->getCellHeight($this->encodeText($arrayText[1]), 90);
+
+ if($arrayParams['align2'] != 'C')
+ $arrayParams['align2'] = 'L';
+ //echo "velikost polja s tekstom: ".count($arrayText)."</br>";
+
+ if($export_format == 'pdf'){
+ if($color=='blue'){
+ $cellBgColor = 'cyan';
+ }elseif($color=='red'){
+ $cellBgColor = 'pink';
+ }
+ $cellColoring = ' \cellcolor{'.$cellBgColor.'} ';
+ }else{
+ $cellColoring = '';
+ }
+
+ for($i=0;$i<count($arrayText);$i++){
+ //echo "array text: ".$arrayText[$i]."</br>";
+ if($color!=''){ //ce je potrebno besedilo dolocene barve
+ //$text = ' \cellcolor{'.$cellBgColor.'} '.$this->coloredTextLatex($color, $arrayText[$i]);
+ $text = $cellColoring.''.$this->coloredTextLatex($color, $arrayText[$i]);
+ }else{
+ $text = $arrayText[$i];
+ }
+ if($i==0&&!$nadaljevanjeVrstice&&!count($steviloPodstolpcev)){
+ $tableRow .= $text;
+ }
+ elseif($i==0&&!$nadaljevanjeVrstice&&count($steviloPodstolpcev)){
+ $tableRow .= ' \multicolumn{'.$steviloPodstolpcev[$i].'}{c|}{ '.$text.' }';
+ }elseif(count($steviloPodstolpcev)){ //ce rabimo multicolumn
+ $tableRow .= ' & \multicolumn{'.$steviloPodstolpcev[$i].'}{c|}{ '.$text.' }';
+ }
+ else{
+ $tableRow .= ' & '.$text;
+ }
+ }
+
+ if(!$brezNoveVrstice){
+ $tableRow .= $this->texNewLine; /*nova vrstica*/
+ }
+
+ if (!$brezHline) { //dodaj se horizontal line, ce je to potrebno (po navadi vse povsod razen npr. za tabelo s st. odklonom in povprecjem)
+ if($export_format != 'xls'){
+ $tableRow .= $this->horizontalLineTex; /*obroba*/
+ }
+ }
+
+ //echo "Vrstica tabele: ".$tableRow."</br>";
+
+ return $tableRow;
+ }
+
+ //funkcija, ki skrbi za izris grafa ustrezne dolzine
+ function drawGraphLatex($graphLineLength=null, $value=null){
+ $texGraph = '';
+ $texGraph .= '\begin{tikzpicture} \fill[crtaGraf] (0,0) -- ('.$graphLineLength.',0) -- ('.$graphLineLength.','.GRAPH_LINE_WIDTH.') -- (0,'.GRAPH_LINE_WIDTH.') -- (0,0); \end{tikzpicture} '.$value;
+ return $texGraph;
+ }
+
+ function displayLineWithGraph($text='', $value=null, $maxValue=null){
+ $texStatusLine = '';
+ $vrsticaPodatki = array();
+ $vrsticaPodatki[] = $text;
+ if($value){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$maxValue)*$value;
+ $vrsticaPodatki[] = $this->drawGraphLatex($graphLineLength, $value);
+ }else{
+ $vrsticaPodatki[] = 0;
+ }
+ $texStatusLine .= $this->tableRow($vrsticaPodatki,1);
+
+ return $texStatusLine;
+ }
+
+
+ function TimeEdits($data=null, $seansa=null, $status=null){
+ global $lang;
+ $tex = '';
+ $sum_data = array();
+
+ $datetime_last = null;
+ $datetime_start = null;
+ $st_akcij = 0;
+ $st_akcij_sum = 0;
+ $st_seans_sum = 0;
+ $time_sum = 0;
+ $user_temp = null;
+ $user_id = 0;
+ $row_id = 0;
+ $action_type = null;
+ $action_type_sum = null;
+ $statuses = null;
+
+ if($status == -1){
+ $statuses = array(
+ 0 => array("name"=>$lang['srv_urejanje'], "sum"=>0),
+ 1 => array("name"=>$lang['import_data'], "sum"=>0),
+ 2 => array("name"=>$lang['export_analisys'], "sum"=>0),
+ 3 => array("name"=>$lang['srv_reporti'], "sum"=>0),
+ 4 => array("name"=>$lang['srv_podatki'], "sum"=>0),
+ 5 => array("name"=>$lang['srv_inv_nav_email'], "sum"=>0),
+ //20 => array("name"=>$lang['srv_hierarchy'], "sum"=>0),// Splošni podatki o hierarhiji
+ //21 => array("name"=>$lang['srv_hierarchy_structure'], "sum"=>0),// Grajenje hierarhije
+ //22 => array("name"=>$lang['srv_hierarchy_users'], "sum"=>0),// Urejanje uporabnikov
+ );
+ $action_type = $statuses;
+ $action_type_sum = $statuses;
+ }
+ else if($status == 0){
+ $statuses = array();
+ $action_type = array();
+ $action_type_sum = array();
+ }
+
+ //echo '<h2>'.$lang["srv_edits_analysis_editing_details"].'</h2>';
+
+ foreach ($data as $rowGrupa) {
+ //$post = $this->convertToJSON($rowGrupa['post']);
+ $akcija = null;
+ if($status == -1)
+ $akcija = $rowGrupa['status'];
+ else if($status == 0){
+ $get = $this->convertToJSON($rowGrupa['get']);
+ $akcija = $get['a'];
+ }
+
+ //zacetek risanja
+ if(!isset($user_temp)){
+ $user_temp = $rowGrupa['email'];
+ $user_id = $rowGrupa['id'];
+ //izpis zacetka tabele za prvega urejevalca (prvi dve vrstici z naslovi)
+ $tex .= $this->zacetekTabelePodrobnostiLatex($user_temp, $status, $user_id);
+ //izpis zacetka tabele za prvega urejevalca (prvi dve vrstici z naslovi) - konec
+
+ }
+ //naslednji editor
+ else if($user_temp != $rowGrupa['email']){
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic /////////////////////////////////////////////////////
+
+ $time_sum += $this -> TimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+
+ //Izpis posameznih vrstic
+ foreach($this->vrsticaTex as $vrstica){
+ $tex .= $vrstica;
+ }
+ //Izpis posameznih vrstic - konec
+
+ //izrisi se zadnjo vrstico prejsnjega urejevalca
+ //izpis vrstice podatkov za Skupaj
+ $tex .= $this -> echoTimeEditsFootRow($time_sum, $st_akcij_sum, $action_type_sum, $user_id.'_sum');
+ //izpis vrstice podatkov za Skupaj - konec
+ //izrisi se zadnjo vrstico prejsnjega urejevalca - konec
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic - konec /////////////////////////////////////////////
+
+ //zaljucek latex tabele s podatki za prvega urejevalca
+ $tex .= $this->konecTabelePodrobnostiLatex();
+ //zaljucek latex tabele s podatki za prvega urejevalca - konec
+
+ //prostor po tabeli
+ $tex .= $this->texBigSkip;
+ $tex .=$this->texNewLine;
+ //prostor po tabeli - konec
+
+ $sum_data[$user_temp]['time_sum']=$time_sum;
+ $sum_data[$user_temp]['st_akcij_sum']=$st_akcij_sum;
+ $sum_data[$user_temp]['st_seans_sum']=$st_seans_sum;
+ $sum_data[$user_temp]['user_id']=$user_id;
+ $action_type_sum = $statuses;
+
+ //nova tabela - nov urejevalec
+ $user_temp = $rowGrupa['email'];
+ $user_id = $rowGrupa['id'];
+ $this->vrsticaTex = array(); //resetiranje polja s kodo vrstic ostalih urejevalcev
+ //izpis zacetka tabele za naslednje urejevalce (prvi dve vrstici z naslovi)
+ $tex .= $this->zacetekTabelePodrobnostiLatex($user_temp, $status, $user_id);
+ //izpis zacetka tabele za naslednje urejevalce (prvi dve vrstici z naslovi) - konec
+
+ //ponastavi spremenljivke
+ $datetime_last = null;
+ $datetime_start = null;
+ $st_akcij = 0;
+ $st_akcij_sum = 0;
+ $st_seans_sum = 0;
+ $time_sum = 0;
+ }
+
+ //izpis vrstic
+ //nov start seanse
+ if(!isset($datetime_start)){
+ $datetime_start = new DateTime($rowGrupa['datetime']);
+ $st_akcij++;
+ $st_seans_sum++;
+ $action_type = $statuses;
+ }
+ //se ni druge akcije
+ else if(!isset($datetime_last)){
+ $temp_time = new DateTime($rowGrupa['datetime']);
+ $interval = $this->sea->calculateTimeBetweenActions($datetime_start, $temp_time);
+
+ //ce je akcija od starta v kriteriju seanse, jo dodaj k seansi
+ if($interval <= $seansa){
+ $datetime_last = clone $temp_time;
+ $st_akcij++;
+ }
+ //akcija je izven kriterija seanse, izpisi samo to akcijo
+ else{
+ $datetime_last = clone $datetime_start;
+ $datetime_last->add(new DateInterval('PT5S'));
+ $time_sum += $this -> TimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+ $st_akcij = 1;
+ $st_seans_sum++;
+ $datetime_start = clone $temp_time;
+ $datetime_last = null;
+ $action_type = $statuses;
+ }
+ }
+ //seasna ze ima vsaj dve akciji
+ else{
+ $temp_time = new DateTime($rowGrupa['datetime']);
+ $interval = $this->sea->calculateTimeBetweenActions($datetime_last, $temp_time);
+
+ //ce je akcija od prejsnje v kriteriju seanse, jo dodaj k seansi
+ if($interval <= $seansa){
+ $datetime_last = clone $temp_time;
+ $st_akcij++;
+ }
+ //akcija je izven kriterija seanse, izpisi vse prejsnje akcije
+ else{
+ $time_sum += $this -> TimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+ $st_akcij = 1;
+ $st_seans_sum++;
+ $datetime_start = clone $temp_time;
+ $datetime_last = null;
+ $action_type = $statuses;
+ }
+ }
+ $st_akcij_sum++;
+ $row_id++;
+ if($status == -1){
+ $action_type[$akcija]['sum'] ++;
+ $action_type_sum[$akcija]['sum'] ++;
+ }
+ else if($status == 0){
+ $action_type[$akcija] = isset($action_type[$akcija]) ? $action_type[$akcija]+1 : 1;
+ $action_type_sum[$akcija] = isset($action_type_sum[$akcija]) ? $action_type_sum[$akcija]+1 : 1;
+ }
+ }
+
+ //izrisi se zadnjo vrstico, ki jo ni foreach ter footer
+ if($datetime_last == null){
+ $datetime_last = clone $datetime_start;
+ $datetime_last->add(new DateInterval('PT5S'));
+ }
+
+ $time_sum += $this -> TimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id);
+
+ //Izpis posameznih vrstic
+ foreach($this->vrsticaTex as $vrstica){
+ $tex .= $vrstica;
+ }
+ //Izpis posameznih vrstic - konec
+
+ $tex .= $this -> echoTimeEditsFootRow($time_sum, $st_akcij_sum, $action_type_sum, $user_id.'_sum');
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic - konec
+
+ //zaljucek latex tabele s podatki
+ $tex .= $this->konecTabelePodrobnostiLatex();
+ //zaljucek latex tabele s podatki - konec
+
+
+ $this->texTimeEdits = $tex;
+ //echo "tex: ".$tex."</br>";
+
+ $sum_data[$user_temp]['time_sum']=$time_sum;
+ $sum_data[$user_temp]['st_akcij_sum']=$st_akcij_sum;
+ $sum_data[$user_temp]['st_seans_sum']=$st_seans_sum;
+ $sum_data[$user_temp]['user_id']=$user_id;
+
+/* echo "time_sum: ".$time_sum."</br>";
+ echo "st_akcij_sum: ".$st_akcij_sum."</br>";
+ echo "st_seans_sum: ".$st_seans_sum."</br>";
+ echo "user_id: ".$user_id."</br>";
+ echo "action_type_sum: ".$action_type_sum."</br>"; */
+
+ //echo '</table>';
+
+ return $sum_data;
+ }
+
+ /**
+ * Nastavi in izrise vrstico urejanja
+ *
+ * @param type $datetime_start - datetime start of editing
+ * @param type $datetime_last - datetime end of editing
+ * @param type $st_akcij - num ob actions during editing
+ * @param type $action_type - string of type of action
+ * @param type $row_id - int sequence nuber of row (unique, for this site, no need to be ID)
+ * @return type int - calculated second of editing session
+ */
+ function TimeEditsRow($datetime_start=null, $datetime_last=null, $st_akcij=null, $action_type = null, $row_id = null){
+ $seconds = 0;
+ $tex = '';
+ //create string of actions type
+ $action_type_string = ($action_type != null) ? $this -> createActionsTypeString($action_type, $row_id) : null;
+ if(isset($datetime_last)){
+ $seconds = $this->sea->calculateTimeBetweenActions($datetime_start, $datetime_last);
+ $this->vrsticaTex[] = $this -> echoTimeEditsRow($datetime_last->format('Y-m-d H:i:s') .' - '. $datetime_start->format('Y-m-d H:i:s'), $this->sea->calculateTimeFromSeconds($seconds), $st_akcij, $action_type_string);
+ }
+ //ce je samo ena akcija
+ else{
+ $this->vrsticaTex[] = $this -> echoTimeEditsRow($datetime_start->format('Y-m-d H:i:s'), 0 ,1, $action_type_string);
+ }
+
+ return $seconds;
+ }
+
+ /**
+ * Convert false JSON (with keys without quotes and no stat and end braces)
+ * from DB to valid JSON
+ * @param type $toJSON string to convert to JSON (with keys without
+ * quotes and no stat and end braces)
+ * @return type valid converted JSON
+ */
+ function convertToJSON($toJSON=null){
+ $toJSON = preg_replace('/("(.*?)"|(\w+))(\s*:\s*(".*?"|.))/s', '"$2$3"$4', $toJSON);
+ $toJSON = '{'.$toJSON.'}';
+ return json_decode($toJSON, true);
+ }
+
+ /**
+ * Izrise vrstico urejanja
+ * @param type $datetime - string from to editing
+ * @param type $cas_seanse - editing time
+ * @param type $st_akcij - num of editing actions
+ * @param type $action_type - string of type of action
+ */
+ function echoTimeEditsRow($datetime=null, $cas_seanse=null, $st_akcij=null, $action_type = null){
+ $tex = '';
+
+ $latexVrstica = array();
+
+ //casovni razpon urejanja
+ $latexVrstica[] = $this->encodeText($datetime);
+
+ //cas urejanja
+ $latexVrstica[] = $this->encodeText($cas_seanse);
+
+ //stevilo akcij
+ $latexVrstica[] = $this->encodeText($st_akcij);
+
+ if($action_type != null){
+ //vrsta akcij
+ $latexVrstica[] = $this->encodeText($action_type.' ');
+ }
+ $tex .= $this->tableRow($latexVrstica);
+
+ //echo $tex;
+ return $tex;
+ }
+
+ /**
+ * Create/convert array of action types to string for table cell
+ * @param type $action_type - array of action types
+ * @param type $row_id - int sequence nuber of row (unique user int and row in table)
+ * @return string - converter array to string to put it in table cell
+ */
+ function createActionsTypeString($action_type=null, $row_id=null){
+ $action_type_string = '';
+ //urejanje - ali drug specificen status
+ if(!isset($action_type[0]['sum'])){
+ global $lang;
+ $i = 0;
+ foreach ($action_type as $key => $at){
+/* if($i == 3)
+ $action_type_string .= '<div class="srv_edits_analysis_'.$row_id.' as_link" onclick="$(\'.srv_edits_analysis_'.$row_id.'\').toggle();">'.$lang['srv_more'].'</div>';
+ if($i < 3)
+ $action_type_string .= '<div>'.$key.' ('.$at.')'.'</div>';
+ else
+ $action_type_string .= '<div class="srv_edits_analysis_'.$row_id.' displayNone">'.$key.' ('.$at.')'.'</div>';
+ $i++; */
+ $action_type_string .= $key.' ('.$at.')'.'; ';
+ }
+/* if($i > 3)
+ $action_type_string .= '<div class="srv_edits_analysis_'.$row_id.' as_link displayNone" onclick="$(\'.srv_edits_analysis_'.$row_id.'\').toggle();">'.$lang['srv_less'].'</div>'; */
+ }
+ //vsi statusi
+ else{
+ foreach ($action_type as $at){
+ if($at['sum'] > 0){
+ if($action_type_string != '')
+ $action_type_string .= ' ';
+ $action_type_string .= $at['name'].' ('.$at['sum'].')';
+ }
+ }
+ }
+
+ return $action_type_string;
+ }
+
+ /**
+ * Izrise total/footer vrstico urejanja
+ * @param type $time - seconds of editing
+ * @param type $st_akcij - num of editing actions
+ * @param type $action_type - string of type of actions
+ * @param type $row_id - int sequence nuber of user (unique, for this site, no need to be ID)
+ */
+ function echoTimeEditsFootRow($time=null, $st_akcij=null, $action_type = null, $row_id = 0){
+ global $lang;
+ $tex = '';
+ $vrsticaPodatkovSkupaj = array();
+ //casovni razpon urejanja
+ $vrsticaPodatkovSkupaj[] = $this->returnBold($this->encodeText($lang['srv_edits_analysis_time_total']));
+
+ //cas urejanja
+ $vrsticaPodatkovSkupaj[] = $this->returnBold($this->sea->calculateTimeFromSeconds($time));
+
+ //stevilo akcij
+ $vrsticaPodatkovSkupaj[] = $this->returnBold($st_akcij);
+
+ if($action_type != null){
+ //vrsta akcij
+ $vrsticaPodatkovSkupaj[] = $this->returnBold($this->encodeText($this->createActionsTypeString($action_type, $row_id)));
+ }
+
+ $tex .= $this->tableRow($vrsticaPodatkovSkupaj); //Izpis vrstic tabele s podatki o sumi
+ return $tex;
+ }
+
+ function zacetekTabelePodrobnostiLatex($user_temp=null, $status=null, $user_id=null){
+ global $lang;
+ $tex = '';
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 4;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ /* if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize=.3\hsize}X' : 'l'); //fiksna sirina prvega stolpca, da sprejme datum in uro
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ } */
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|');
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $tex .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+ if($export_format != 'xls'){
+ $tex .= $this->horizontalLineTex;
+ }
+
+
+ $prvaVrstica = array();
+ $prvaVrstica[] = ' \multicolumn{'.$steviloStolpcevParameterTabular.'}{|c|}{ '.$user_temp.' }';
+ $tex .= $this->tableRow($prvaVrstica);
+
+ $drugaVrstica = array();
+ $drugaVrstica[] = $this->encodeText($lang['srv_edits_analysis_time_span']);
+ $drugaVrstica[] = $this->encodeText($lang['srv_edits_analysis_time_time']);
+ $drugaVrstica[] = $this->encodeText($lang['srv_edits_analysis_time_actions']);
+ if($status < 1){
+ $drugaVrstica[] = $this->encodeText($lang['srv_edits_analysis_action_type']);
+ }else{
+ $drugaVrstica[] = '';
+ }
+ $tex .= $this->tableRow($drugaVrstica);
+ return $tex;
+ }
+
+ function konecTabelePodrobnostiLatex(){
+ $tex = "\\end{tabularx}";
+ return $tex;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexGDPR.php b/admin/survey/export/latexclasses/class.LatexGDPR.php
new file mode 100644
index 0000000..f56c2b2
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexGDPR.php
@@ -0,0 +1,115 @@
+<?php
+
+/**
+ *
+ * Class ki skrbi za izris GDPR dokumentov v latex
+ *
+ *
+ */
+
+
+//include('../../function.php');
+include('../../vendor/autoload.php');
+
+
+class LatexGDPR{
+
+ protected $anketa;
+
+ protected $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ protected $pdf;
+ protected $currentStyle;
+
+ protected $texNewLine = '\\\\ ';
+ protected $texBigSkip = '\bigskip';
+
+
+ function __construct($anketa=null){
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa) ){
+ $this->anketa = $anketa;
+ }
+ else{
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+
+ return false;
+ }
+
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+
+ public function displayGDPR($export_subtype=''){
+ global $lang;
+
+ $tex = '';
+
+ // Definiramo
+ $tex = '';
+
+ // Izpis posameznega porocila
+ if($export_subtype == 'individual'){
+
+ // Naslov dokumenta
+ $tex .= '\noindent\MakeUppercase{\huge \textbf{'.$lang['export_gdpr_individual'].'}}'.$this->texBigSkip.$this->texNewLine.$this->texNewLine;
+
+ // Pridobimo array z vsemi texti
+ $text_array = GDPR::getGDPRInfoArray($this->anketa);
+ }
+ elseif($export_subtype == 'activity'){
+
+ // Naslov dokumenta
+ $tex .= '\noindent\MakeUppercase{\huge \textbf{'.$lang['export_gdpr_activity'].'}}'.$this->texBigSkip.$this->texNewLine.$this->texNewLine;
+
+ // Pridobimo array z vsemi texti
+ $text_array = GDPR::getGDPREvidencaArray($this->anketa);
+ }
+
+
+ // Loop po posameznih sklopih
+ foreach($text_array as $sklop){
+
+ // Naslov sklopa
+ $tex .= '\textbf{'.$sklop['heading'].'}';
+ $tex .= $this->texNewLine;
+
+ // Loop po posameznih vrsticah
+ foreach($sklop['text'] as $vrstica){
+
+ //$tex .= '\text{'.$vrstica.'}';
+ $tex .= '{'.$vrstica.'}';
+ $tex .= $this->texNewLine;
+ }
+
+ $tex .= $this->texNewLine;
+ }
+
+ $tex .= $this->texNewLine.$lang['date'].': '.date('j.n.Y').$this->texNewLine;
+
+
+ // Se pobarvamo text znotraj <strong> taga
+ //$tex = str_replace('<strong>', '\textcolor{1ka_orange}{', $tex);
+ $tex = str_replace('<strong>', '\textcolor{crta}{', $tex);
+ $tex = str_replace('</strong>', '}', $tex);
+
+ // Se replacamo href-e
+ preg_match_all("|<a.*(?=href=\"([^\"]*)\")[^>]*>([^<]*)</a>|i", $tex, $matches);
+ foreach($matches[0] as $key => $val){
+
+ $url = $matches[1][$key];
+ $url_text = $matches[2][$key];
+
+ $tex = str_replace($matches[0][$key], '\textcolor{crta}{\underline{\href{'.$url.'}'.'{'.$url_text.'}}}', $tex);
+ }
+
+
+ return $tex;
+ }
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexStatus.php b/admin/survey/export/latexclasses/class.LatexStatus.php
new file mode 100644
index 0000000..522e843
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexStatus.php
@@ -0,0 +1,1517 @@
+<?php
+
+ global $site_path;
+
+ include_once('../../function.php');
+ include_once('../survey/definition.php');
+ //require_once('../exportclases/class.enka.pdf.php');
+
+ define("ALLOW_HIDE_ZERRO_REGULAR", false); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za navadne odgovore
+ define("ALLOW_HIDE_ZERRO_MISSING", true); // omogočimo delovanje prikazovanja/skrivanja ničelnih vnosti za missinge
+
+ define("NUM_DIGIT_AVERAGE", 2); // stevilo digitalnih mest za povprecje
+ define("NUM_DIGIT_DEVIATION", 2); // stevilo digitalnih mest za povprecje
+
+ define("M_ANALIZA_DESCRIPTOR", "descriptor");
+ define("M_ANALIZA_FREQUENCY", "frequency");
+
+ define("FNT_FREESERIF", "freeserif");
+ define("FNT_FREESANS", "freesans");
+ define("FNT_HELVETICA", "helvetica");
+
+ define("FNT_MAIN_TEXT", FNT_FREESANS);
+ define("FNT_QUESTION_TEXT", FNT_FREESANS);
+ define("FNT_HEADER_TEXT", FNT_FREESANS);
+
+ define("FNT_MAIN_SIZE", 10);
+ define("FNT_QUESTION_SIZE", 9);
+ define("FNT_HEADER_SIZE", 10);
+
+ define("RADIO_BTN_SIZE", 3);
+ define("CHCK_BTN_SIZE", 3);
+ define("LINE_BREAK", 6);
+
+ define ('PDF_MARGIN_HEADER', 8);
+ define ('PDF_MARGIN_FOOTER', 12);
+ define ('PDF_MARGIN_TOP', 18);
+ define ('PDF_MARGIN_BOTTOM', 18);
+ define ('PDF_MARGIN_LEFT', 15);
+ define ('PDF_MARGIN_RIGHT', 15);
+
+ define ('FRAME_TEXT_WIDTH', 0.3);
+ define ('FRAME_WIDTH', 233);
+ define ('FRAME_HEIGTH', 330);
+ define ('GRAPH_LINE_WIDTH', 0.15);
+ define ('GRAPH_LINE_LENGTH_MAX', 3);
+
+
+/** Class za generacijo pdf-a
+ *
+ * @desc: po novem je potrebno form elemente generirati ro�no kot slike
+ *
+ */
+class LatexStatus {
+
+ var $anketa;// = array(); // trenutna anketa
+
+ var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
+ var $pdf;
+ var $currentStyle;
+ var $db_table = '';
+ protected $texNewLine = '\\\\ ';
+ protected $texBigSkip = '\bigskip';
+ protected $texSmallSkip = '\smallskip';
+ protected $horizontalLineTex = "\\hline ";
+
+
+ public static $ss = null; //SurveyStatistic class
+ public static $sas = null; // $sas = new SurveyAdminSettings();class
+
+ /**
+ * @desc konstruktor
+ */
+ function __construct ($anketa = null, $ssData = null)
+ {
+ global $site_path;
+ global $global_user_id;
+
+ // preverimo ali imamo stevilko ankete
+ if ( is_numeric($anketa) )
+ {
+ $this->anketa['id'] = $anketa;
+ $this->anketa['podstran'] = $podstran;
+ // create new PDF document
+ //$this->pdf = new enka_TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
+ }
+ else
+ {
+ $this->pi['msg'] = "Anketa ni izbrana!";
+ $this->pi['canCreate'] = false;
+ return false;
+ }
+
+
+ $this->sas = new SurveyAdminSettings(0,$this->anketa['id']);
+ //ustvarimo SurveyStatistic objekt in mu napolnimo variable
+ $this->ss = new SurveyStatistic();
+ $this->ss->Init($this->anketa['id'],true);
+ /*
+
+ $this->ss->realUsersByStatus_base = $ssData[0];
+
+ $this->ss->type = $ssData[1];
+ $this->ss->period = $ssData[2];
+ */
+ /* intervali se več ne pošiljajo preko get, ker se polovijo iz porfila
+ if($ssData[1] != 'undefined')
+ $this->ss->startDate = $ssData[1];
+ if($ssData[2] != 'undefined')
+ $this->ss->endDate = $ssData[2];
+ $this->ss->type = $ssData[3];
+ $this->ss->period = $ssData[4];
+ //$this->ss->isDefaultFilters = false;
+ */
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) )
+ {
+ $this->anketa['uid'] = $global_user_id;
+ SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
+ }
+ else
+ return false;
+ // ce smo prisli do tu je vse ok
+ $this->pi['canCreate'] = true;
+
+ return true;
+ }
+
+ // SETTERS && GETTERS
+
+ function checkCreate()
+ {
+ return $this->pi['canCreate'];
+ }
+ function getFile($fileName='')
+ {
+ //Close and output PDF document
+ ob_end_clean();
+ $this->pdf->Output($fileName, 'I');
+ }
+
+ public function displayStatus() {
+ global $lang;
+ $texStatus = '';
+
+ // imamo vnose, prikažemo statistiko
+ $this->ss->PrepareDateView();
+ $this->ss->PrepareStatusView();
+
+ //naslov izvoza
+ //$texStatus .= $this->returnBold('Status').$this->texNewLine.$this->texNewLine;
+ $texStatus .= '\MakeUppercase{\huge \textbf{Status - '.$lang['srv_status_summary'].'}}'.$this->texBigSkip.$this->texNewLine;
+
+
+ $texStatus .= '\begin{tableStatus}'; /*zacetek environmenta z manjsim fontom*/
+
+ // zgornji boxi #########################
+ $texStatus .= $this -> DisplayInfoView();
+
+ //prostor med 1. in 2. okvirjem
+ $texStatus .= ' \hspace*{0.02\textwidth}';
+
+ $texStatus .= $this -> DisplayStatusView();
+
+ //prostor med 2. in 3. okvirjem
+ $texStatus .= ' \hspace*{0.02\textwidth}';
+
+ $texStatus .= $this -> DisplayAnswerStateView();
+
+ //prostor med zgornjimi in spodnjimi okvirji
+ $texStatus .= $this->texNewLine;
+ $texStatus .= $this->texNewLine;
+
+ // zgornji boxi - konec #################
+
+ // spodnji boxi #########################
+ $texStatus .= $this -> DisplayReferalsView();
+
+ //prostor med 1. in 2. okvirjem
+ $texStatus .= ' \hspace*{0.02\textwidth}';
+
+ $texStatus .= $this -> DisplayDateView();
+
+ //prostor med 2. in 3. okvirjem
+ $texStatus .= ' \hspace*{0.02\textwidth}';
+
+ $texStatus .= $this -> DisplayPagesStateView();
+
+ // spodnji boxi - konec #################
+
+ $texStatus .= '\end{tableStatus}'; /*zakljucek environmenta z manjsim fontom*/
+
+ return $texStatus;
+ }
+
+ /** Funkcija prikaze osnovnih informacij
+ *
+ */
+ function DisplayInfoView() {
+ global $lang;
+ global $site_url;
+
+ $texStatusInfo = '';
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_statistic_info_title']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ //$steviloStolpcevParameterTabular = 3;
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ //ce je prvi stolpec
+ if($i == 0){
+ //$parameterTabular .= ($export_format == 'pdf' ? 'P' : 'l');
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }else{
+ //$parameterTabular .= ($export_format == 'pdf' ? '>{\hsize='.$sirinaOstalihStolpcev.'\hsize \centering\arraybackslash}X' : 'c'); /*sirina ostalih je odvisna od njihovega stevila, da se sirine razporedijo po celotni sirini tabele*/
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+ }
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texStatusInfo .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //Priprava podatkov za izpis vrstic tabele
+
+ //ime ankete
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($lang['srv_info_name'].':');
+ //$prvaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText(SurveyInfo::getSurveyTitle()).'} ';
+ $prvaVrstica[] = $this->encodeText(SurveyInfo::getSurveyTitle());
+
+ //katere napredne možnosti so vklopljene
+ $row = SurveyInfo::getSurveyRow();
+ $enabled_advanced = null;
+ $prefix = '';
+ if ($row['uporabnost'] == 1) {
+ $enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_4'];
+ $prefix = ', ';
+ }
+ if ($row['user_from_cms'] == 1) {
+ $enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_5'];
+ $prefix = ', ';
+ }
+ if ($row['quiz'] == 1) {
+ $enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_6'];
+ $prefix = ', ';
+ }
+ if ($row['voting'] == 1) {
+ $enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_18'];
+ $prefix = ', ';
+ }
+ if ($row['phone'] == 1) {
+ $enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_7'];
+ $prefix = ', ';
+ }
+ if ($row['social_network'] == 1) {
+ $enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_8'];
+ $prefix = ', ';
+ }
+
+ //tip ankete
+ $drugaVrstica = array();
+ $drugaVrstica[] = $this->encodeText($lang['srv_info_type'].':');
+ //$drugaVrstica[] = '\multicolumn{2}{l}{ '.$lang['srv_vrsta_survey_type_'.SurveyInfo::getSurveyType()] . ($enabled_advanced != null ? ' ('.$enabled_advanced.')' : '' ).'} ';
+ $drugaVrstica[] = $lang['srv_vrsta_survey_type_'.SurveyInfo::getSurveyType()] . ($enabled_advanced != null ? ' ('.$enabled_advanced.')' : '' );
+
+/* //vprašanj, variabel
+ $tretjaVrstica = array();
+ //$tretjaVrstica[] = $this->encodeText($lang['srv_info_questions1'].': ').$this->encodeText(SurveyInfo::getSurveyQuestionCount());
+ $tretjaVrstica[] = $this->encodeText($lang['srv_info_questions1'].': ');
+ $tretjaVrstica[] = $this->encodeText(SurveyInfo::getSurveyQuestionCount());
+ //$tretjaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_info_variables'].': ').$this->encodeText(SurveyInfo::getSurveyVariableCount()).'} ';
+ $tretjaVrstica[] = $this->encodeText($lang['srv_info_variables'].': ').$this->encodeText(SurveyInfo::getSurveyVariableCount()); */
+
+ //vprašanj
+ $tretjaVrsticaA = array();
+ //$tretjaVrstica[] = $this->encodeText($lang['srv_info_questions1'].': ').$this->encodeText(SurveyInfo::getSurveyQuestionCount());
+ $tretjaVrsticaA[] = $this->encodeText($lang['srv_info_questions1'].': ');
+ $tretjaVrsticaA[] = $this->encodeText(SurveyInfo::getSurveyQuestionCount());
+
+ //variabel
+ $tretjaVrsticaB = array();
+ $tretjaVrsticaB[] = $this->encodeText($lang['srv_info_variables'].': ');
+ $tretjaVrsticaB[] = $this->encodeText(SurveyInfo::getSurveyVariableCount());
+
+/* //uporabnikov, odgovorov
+ $cetrtaVrstica = array();
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_analiza_stUporabnikov'].':');
+ $cetrtaVrstica[] = $this->encodeText(SurveyInfo::getSurveyAnswersCount());
+ $cetrtaVrstica[] = $this->encodeText($lang['srv_info_answers_valid'].': ').$this->encodeText(SurveyInfo::getSurveyApropriateAnswersCount()); */
+
+ //uporabnikov
+ $cetrtaVrsticaA = array();
+ $cetrtaVrsticaA[] = $this->encodeText($lang['srv_analiza_stUporabnikov'].':');
+ $cetrtaVrsticaA[] = $this->encodeText(SurveyInfo::getSurveyAnswersCount());
+
+ //odgovorov
+ $cetrtaVrsticaB = array();
+ $cetrtaVrsticaB[] = $this->encodeText($lang['srv_info_answers_valid'].': ');
+ $cetrtaVrsticaB[] = $this->encodeText(SurveyInfo::getSurveyApropriateAnswersCount());
+
+ //jezik ankete
+ $petaVrstica = array();
+ $petaVrstica[] = $this->encodeText($lang['srv_info_language'].':');
+ //$petaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText(SurveyInfo::getRespondentLanguage()).'} ';
+ $petaVrstica[] = $this->encodeText(SurveyInfo::getRespondentLanguage());
+
+ //avtor
+ $sestaVrstica = array();
+ $sestaVrstica[] = $this->encodeText($lang['srv_info_creator'].':');
+ $text = '';
+ $text .= SurveyInfo::getSurveyInsertName();
+ if (SurveyInfo::getSurveyInsertDate() && SurveyInfo::getSurveyInsertDate() != "00.00.0000")
+ $text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyInsertDate(),DATE_FORMAT_SHORT);
+ if (SurveyInfo::getSurveyInsertTime() && SurveyInfo::getSurveyInsertTime() != "00:00:00")
+ $text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyInsertTime(),TIME_FORMAT_SHORT);
+
+ //$sestaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($text).'} ';
+ $sestaVrstica[] = $this->encodeText($text);
+
+ //spreminjal
+ $sedmaVrstica = array();
+ $sedmaVrstica[] = $this->encodeText($lang['srv_info_modify'].':');
+ $text = '';
+ $text .= SurveyInfo::getSurveyEditName();
+ if (SurveyInfo::getSurveyEditDate() && SurveyInfo::getSurveyEditDate() != "00.00.0000")
+ $text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyEditDate(),DATE_FORMAT_SHORT);
+ if (SurveyInfo::getSurveyEditTime() && SurveyInfo::getSurveyEditTime() != "00:00:00")
+ $text .= SurveyInfo::getDateTimeSeperator() . $this->ss->dateFormat(SurveyInfo::getSurveyEditTime(),TIME_FORMAT_SHORT);
+
+ //$sedmaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($text).'} ';
+ $sedmaVrstica[] = $this->encodeText($text);
+
+ //dostop, Kdo razen avtorja ima dostop
+ $dostop = SurveyInfo::getSurveyAccessUsers();
+ if ($dostop) {
+ //$this->pdf->Cell(20, 3, $this->encodeText($lang['srv_info_access'].':'), 0, 0, 'L', 0);
+ $osmaVrstica = array();
+ $osmaVrstica[] = $this->encodeText($lang['srv_info_access'].':');
+ $prefix='';
+ foreach ( $dostop as $user) {
+ $prefix .= $user['name'].'; ';
+ }
+ $prefix = substr($prefix, 0, -2);
+ //$osmaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($prefix).'} ';
+ $osmaVrstica[] = $this->encodeText($prefix);
+ }
+
+ //aktivnost
+ $devetaVrstica = array();
+ $activity = SurveyInfo:: getSurveyActivity();
+ $_last_active = end($activity);
+ $devetaVrstica[] = $this->encodeText($lang['srv_displaydata_status'].':');
+ if (SurveyInfo::getSurveyColumn('active') == 1) {
+ //$devetaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_anketa_active2']).'} ';
+ $devetaVrstica[] = $this->encodeText($lang['srv_anketa_active2']);
+ } else {
+ # preverimo ali je bila anketa že aktivirana
+ if (!isset($_last_active['starts'])) {
+ # anketa še sploh ni bila aktivirana
+ //$devetaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_survey_non_active_notActivated1']).'} ';
+ $devetaVrstica[] = $this->encodeText($lang['srv_survey_non_active_notActivated1']);
+ } else {
+ # anketa je že bila aktivirna ampak je sedaj neaktivna
+ //$devetaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_survey_non_active1']).'} ';
+ $devetaVrstica[] = $this->encodeText($lang['srv_survey_non_active1']);
+ }
+ }
+
+ //trajanje: datumi aktivnosti
+ if ( count($activity) > 0 ) {
+ $desetaVrstica = array();
+ $desetaVrstica[] = $this->encodeText($lang['srv_info_activity'].':');
+ $prefix = '';
+ foreach ($activity as $active) {
+ $_starts = explode('-',$active['starts']);
+ $_expire = explode('-',$active['expire']);
+
+ $prefix .= $_starts[2].'.'.$_starts[1].'.'.$_starts[0].'-'.$_expire[2].'.'.$_expire[1].'.'.$_expire[0];
+ $prefix .= '; ';
+ }
+ //$desetaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($prefix).'} ';
+ $desetaVrstica[] = $this->encodeText($prefix);
+ }
+
+ # predviceni cas trajanja enkete
+ $skupni_cas = $this->sas->testiranje_cas(1);
+ $skupni_predvideni_cas = $this->sas->testiranje_predvidenicas(1);
+
+ $d = new Dostop();
+
+ //predviceni cas trajanja enkete
+ $enajstaVrstica = array();
+ $enajstaVrstica[] = $this->encodeText($lang['srv_info_duration'].':');
+ $text = '';
+ $text .= ($skupni_cas != '') ? $skupni_cas.', ' : '';
+ $text .= $lang['srv_predvideno'].': '.$skupni_predvideni_cas;
+ //$enajstaVrstica[] = '\multicolumn{2}{l}{ '.$this->encodeText($text).'} ';
+ $enajstaVrstica[] = $this->encodeText($text);
+
+
+ //VNOSI - prvi / zadnji vnos
+ $prvi_vnos_date = SurveyInfo::getSurveyFirstEntryDate();
+ $prvi_vnos_time = SurveyInfo::getSurveyFirstEntryTime();
+ $zadnji_vnos_date = SurveyInfo::getSurveyLastEntryDate();
+ $zadnji_vnos_time = SurveyInfo::getSurveyLastEntryTime();
+ $dvanajstaVrstica = array();
+ $dvanajstaVrsticaA = array();
+ if ($prvi_vnos_date != null) {
+ $dvanajstaVrstica[] = $this->encodeText($lang['srv_info_first_entry'].':');
+ $text = '';
+ $text .= $this->ss->dateFormat($prvi_vnos_date,DATE_FORMAT_SHORT);
+ $text .= $prvi_vnos_time != null ? (SurveyInfo::$dateTimeSeperator .$this->ss->dateFormat($prvi_vnos_time,TIME_FORMAT_SHORT)) : '';
+ $dvanajstaVrstica[] = $this->encodeText($text);
+ }else{
+ $dvanajstaVrstica[] = '';
+ $dvanajstaVrstica[] = '';
+ }
+ if ($zadnji_vnos_date != null) {
+ $dvanajstaVrsticaA[] = $this->encodeText($lang['srv_info_last_entry'].':');
+ $text = '';
+ $text .= $this->ss->dateFormat($zadnji_vnos_date,DATE_FORMAT_SHORT);
+ $text .= $zadnji_vnos_time != null ? (SurveyInfo::$dateTimeSeperator .$this->ss->dateFormat($zadnji_vnos_time,TIME_FORMAT_SHORT)) : '';
+ //$dvanajstaVrsticaA[] = $this->encodeText($lang['srv_info_last_entry'].': '.$this->encodeText($text));
+ $dvanajstaVrsticaA[] = $this->encodeText($text);
+ }else{
+ $dvanajstaVrsticaA[] = '';
+ }
+
+ // Komentarji
+ $SD = new SurveyDiagnostics($this->anketa['id']);
+ $comments = $SD->testComments();
+
+ list($commentsAll,$commentsUnresolved,$commentsQuestionAll,$commentsQuestionUnresolved,$commentsUser,$commentsUserFinished) = $comments;
+
+ $commentsUserUnresolved = $commentsUser - $commentsUserFinished;
+ $komentarji = 0;
+ if (( (int)$commentsAll
+ +(int)$commentsUnresolved
+ +(int)$commentsQuestionAll
+ +(int)$commentsQuestionUnresolved
+ +(int)$commentsUser
+ +(int)$commentsUserFinished
+ ) > 0 ) {
+
+ $trinajstaVrsticaA = array();
+ $trinajstaVrsticaB = array();
+ $trinajstaVrsticaC = array();
+
+ $trinajstaVrsticaA[] = $this->encodeText($lang['srv_diagnostic_4_element_0'].':');
+ //$trinajstaVrsticaA[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_diagnostic_4_element_1'].': '.(int)$commentsAll.' / '.(int)$commentsUnresolved).'} ';
+ $trinajstaVrsticaA[] = $this->encodeText($lang['srv_diagnostic_4_element_1'].': '.(int)$commentsAll.' / '.(int)$commentsUnresolved);
+
+ $trinajstaVrsticaB[] = '';
+ //$trinajstaVrsticaB[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_diagnostic_4_element_6'].': '.(int)$commentsQuestionAll.' / '.(int)$commentsQuestionUnresolved).'} ';
+ $trinajstaVrsticaB[] = $this->encodeText($lang['srv_diagnostic_4_element_6'].': '.(int)$commentsQuestionAll.' / '.(int)$commentsQuestionUnresolved);
+
+ $trinajstaVrsticaC[] = '';
+ //$trinajstaVrsticaC[] = '\multicolumn{2}{l}{ '.$this->encodeText($lang['srv_diagnostic_4_element_7'].': '.(int)$commentsUser.' / '.(int)$commentsUserUnresolved).'} ';
+ $trinajstaVrsticaC[] = $this->encodeText($lang['srv_diagnostic_4_element_7'].': '.(int)$commentsUser.' / '.(int)$commentsUserUnresolved);
+
+ $komentarji = 1;
+ }
+
+ //Priprava podatkov za izpis vrstic tabele - konec
+
+ //Izpis vrstic tabele s podatki
+ $texStatusInfo .= $this->tableRow($prvaVrstica, 1);
+ $texStatusInfo .= $this->tableRow($drugaVrstica, 1);
+ //$texStatusInfo .= $this->tableRow($tretjaVrstica, 1);
+ $texStatusInfo .= $this->tableRow($tretjaVrsticaA, 1);
+ $texStatusInfo .= $this->tableRow($tretjaVrsticaB, 1);
+ //$texStatusInfo .= $this->tableRow($cetrtaVrstica, 1);
+ $texStatusInfo .= $this->tableRow($cetrtaVrsticaA, 1);
+ $texStatusInfo .= $this->tableRow($cetrtaVrsticaB, 1);
+ $texStatusInfo .= $this->tableRow($petaVrstica, 1);
+ $texStatusInfo .= $this->tableRow($sestaVrstica, 1);
+ $texStatusInfo .= $this->tableRow($sedmaVrstica, 1);
+ if ($dostop) {
+ $texStatusInfo .= $this->tableRow($osmaVrstica, 1);
+ }
+ $texStatusInfo .= $this->tableRow($devetaVrstica, 1);
+ if ( count($activity) > 0 ) {
+ $texStatusInfo .= $this->tableRow($desetaVrstica, 1);
+ }
+ $texStatusInfo .= $this->tableRow($enajstaVrstica, 1);
+/* if ($prvi_vnos_date != null || $zadnji_vnos_date != null) {
+ $texStatusInfo .= $this->tableRow($dvanajstaVrstica, 1);
+ } */
+ if ($prvi_vnos_date != null) {
+ $texStatusInfo .= $this->tableRow($dvanajstaVrstica, 1);
+ }
+ if ($zadnji_vnos_date != null) {
+ $texStatusInfo .= $this->tableRow($dvanajstaVrsticaA, 1);
+ }
+ if($komentarji){
+ $texStatusInfo .= $this->tableRow($trinajstaVrsticaA, 1);
+ $texStatusInfo .= $this->tableRow($trinajstaVrsticaB, 1);
+ $texStatusInfo .= $this->tableRow($trinajstaVrsticaC, 1);
+ }
+
+
+ //zaljucek latex tabele s podatki
+ $texStatusInfo .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+
+ //izpis tabele v okvir
+ $texText = $this->FrameText($title.$texStatusInfo);
+
+ //echo $texStatusInfo;
+ //return $texStatusInfo;
+ return $texText;
+ }
+
+ /** Funkcija prikaže statuse
+ *
+ */
+ function DisplayStatusView() {
+ global $lang;
+
+ $texStatusView = '';
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_statistic_status_title1']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+
+ //zacetek latex tabele z obrobo za prvo tabelo
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texStatusView .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth); /*zacetek tabele*/
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+
+ $cntValid = 0; // da vemo ali izpisemo skupne
+ $cntNonValid = 0; // da vemo ali izpisemo skupne
+
+ foreach ($this->ss->appropriateStatus as $status) {
+ $vrsticaA = array();
+ if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['valid'][$status] == 0)) {// da ne delamo po neporebnem
+ $vrsticaA[] = $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :');
+ $vrsticaA[] = $this->encodeText($this->ss->userByStatus['valid'][$status]);
+ $texStatusView .= $this->tableRow($vrsticaA,1);
+ $cntValid++;
+ }
+ }
+
+ // vsota vlejavnih
+ if ($cntValid > 0 || !$this->ss->hideNullValues_status) {
+ $vrsticaB = array();
+/* $this->pdf->setFont('','B','6');
+ $this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum_valid']), 'T', 0, 'L', 0);
+ $this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['valid']), 'T', 1, 'L', 0);
+
+ $this->pdf->setY($this->pdf->getY() + 3);
+ $this->pdf->setX($X);
+ $this->pdf->setFont('','','6'); */
+ $texStatusView .= $this->horizontalLineTex;
+ $vrsticaB[] = $this->encodeText($lang['srv_statistic_redirection_sum_valid']);
+ $vrsticaB[] = $this->encodeText($this->ss->cntUserByStatus['valid']);
+ $texStatusView .= $this->tableRow($vrsticaB,1);
+ $texStatusView .= $this->texNewLine;
+ }
+
+ // izpišemo še neveljavne
+ foreach ($this->ss->unAppropriateStatus as $status) {
+ $vrsticaC = array();
+ if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['nonvalid'][$status] == 0)) {// da ne delamo po neporebnem
+ //$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :'), 0, 0, 'L', 0);
+ //$this->pdf->Cell(45, 0, $this->encodeText($this->ss->userByStatus['nonvalid'][$status]), 0, 1, 'L', 0);
+ $vrsticaC[] = $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :');
+ $vrsticaC[] = $this->encodeText($this->ss->userByStatus['nonvalid'][$status]);
+ $texStatusView .= $this->tableRow($vrsticaC,1);
+ $cntNonValid++;
+ //$this->pdf->setX($X);
+ }
+ }
+ // se status null (neznan status)
+ if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['nonvalid'][-1] == 0)) {// da ne delamo po neporebnem
+ $vrsticaD = array();
+ //$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_null']), 0, 0, 'L', 0);
+ //$this->pdf->Cell(45, 0, $this->encodeText(isset($this->ss->userByStatus['nonvalid'][-1]) ? $this->ss->userByStatus['nonvalid'][-1] : '0'), 0, 1, 'L', 0);
+
+ //$texStatusView .= $this->horizontalLineTex;
+ $vrsticaD[] = $this->encodeText($lang['srv_userstatus_null']);
+ $vrsticaD[] = $this->encodeText(isset($this->ss->userByStatus['nonvalid'][-1]) ? $this->ss->userByStatus['nonvalid'][-1] : '0');
+ $texStatusView .= $this->tableRow($vrsticaD,1);
+ //$texStatusView .= $this->texNewLine;
+ $cntNonValid++;
+ //$this->pdf->setX($X);
+ }
+
+ // vsota nevlejavnih
+ if ($cntNonValid > 0 || !$this->ss->hideNullValues_status) {
+ $vrsticaE = array();
+/* $this->pdf->setFont('','B','6');
+ $this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum_nonvalid']), 'T', 0, 'L', 0);
+ $this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['nonvalid']), 'T', 1, 'L', 0);
+
+ $this->pdf->setY($this->pdf->getY() + 3);
+ $this->pdf->setX($X);
+ $this->pdf->setFont('','','6'); */
+
+ $vrsticaE[] = $this->encodeText($lang['srv_statistic_redirection_sum_nonvalid']);
+ $vrsticaE[] = $this->encodeText($this->ss->cntUserByStatus['nonvalid']);
+ $texStatusView .= $this->horizontalLineTex;
+ $texStatusView .= $this->tableRow($vrsticaE,1);
+ $texStatusView .= $this->texNewLine;
+ }
+/* $this->pdf->setFont('','B','6');
+ $this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum']), 'T', 0, 'L', 0);
+ $this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['valid']+$this->ss->cntUserByStatus['nonvalid']), 'T', 1, 'L', 0);
+ $this->pdf->setFont('','','6');
+ $this->pdf->setX($X); */
+ $texStatusView .= $this->horizontalLineTex;
+ $vrsticaF = array();
+ $vrsticaF[] = $this->encodeText($lang['srv_statistic_redirection_sum']);
+ if(($this->encodeText($this->ss->cntUserByStatus['valid']+$this->ss->cntUserByStatus['nonvalid']))){
+ $vrsticaF[] = $this->encodeText($this->ss->cntUserByStatus['valid']+$this->ss->cntUserByStatus['nonvalid']);
+ }else{
+ $vrsticaF[] = 0;
+ }
+ $texStatusView .= $this->tableRow($vrsticaF,1);
+ $texStatusView .= $this->texNewLine;
+
+ # preštejemo še neposlana vabila
+ $str = "SELECT count(*) FROM srv_invitations_recipients WHERE ank_id='".$this->anketa['id']."' AND sent='0' AND deleted='0'";
+ $qry = sisplet_query($str);
+ list($cntUnsent) = mysqli_fetch_row($qry);
+ $this->ss->userByStatus['invitation'][0] = (int)$cntUnsent;
+
+ # še email vabila
+ foreach ($this->ss->invitationStatus as $status){
+ $vrsticaG = array();
+ if (!($this->ss->hideNullValues_status && $this->ss->userByStatus['invitation'][$status] == 0)){// da ne delamo po neporebnem
+ //$this->pdf->Cell(45, 0, $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :'), 0, 0, 'L', 0);
+ //$this->pdf->Cell(45, 0, $this->encodeText($this->ss->userByStatus['invitation'][$status]), 0, 1, 'L', 0);
+ $vrsticaG[] = $this->encodeText($lang['srv_userstatus_'.$status] . ' ('.$status.') :');
+ $vrsticaG[] = $this->encodeText($this->ss->userByStatus['invitation'][$status]);
+ $texStatusView .= $this->tableRow($vrsticaG,1);
+ $cntInvitation++;
+ }
+ }
+
+ // vsota emaili
+ if ($cntInvitation > 0 || !$this->ss->hideNullValues_status) {
+ $vrsticaH = array();
+/* $this->pdf->setFont('','B','6');
+ $this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum_invitation']), 'T', 0, 'L', 0);
+ $this->pdf->Cell(45, 0, $this->encodeText($this->ss->cntUserByStatus['invitation']), 'T', 1, 'L', 0);
+
+ $this->pdf->setY($this->pdf->getY() + 3);
+ $this->pdf->setX($X);
+ $this->pdf->setFont('','','6'); */
+ $vrsticaH[] = $this->encodeText($lang['srv_statistic_redirection_sum_invitation']);
+ $vrsticaH[] = $this->encodeText($this->ss->cntUserByStatus['invitation']);
+ $texStatusView .= $this->horizontalLineTex;
+ $texStatusView .= $this->tableRow($vrsticaH,1);
+ $texStatusView .= $this->texNewLine;
+ }
+
+ // testni podatki
+ if ((int)$this->ss->testDataCount > 0) {
+ $vrsticaI = array();
+/* $this->pdf->setFont('','B','6');
+
+ $this->pdf->Cell(90, 6, '', 'B', 1, 'L', 0);
+ $this->pdf->setX($X);
+
+ $this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_test']), 'T', 0, 'L', 0);
+ $this->pdf->Cell(45, 0, $this->encodeText((int)$this->ss->testDataCount), 'T', 1, 'L', 0);
+
+ $this->pdf->setX($X);
+ $this->pdf->setFont('','','6'); */
+
+ $vrsticaI[] = $this->encodeText($lang['srv_statistic_redirection_test']);
+ $vrsticaI[] = $this->encodeText((int)$this->ss->testDataCount);
+ $texStatusView .= $this->horizontalLineTex;
+ $texStatusView .= $this->tableRow($vrsticaI,1);
+ $texStatusView .= $this->texNewLine;
+ }
+
+ // Skupaj enot
+ SurveySetting::getInstance()->setSID($this->anketa);
+ $view_count = SurveySetting::getInstance()->getSurveyMiscSetting('view_count'); if ($view_count == "") $view_count = 0;
+
+ if ($view_count > 0 || !$this->ss->hideNullValues_status){
+ $vrsticaJ = array();
+/* $this->pdf->setFont('','B','6');
+ $this->pdf->Cell(45, 0, $this->encodeText($lang['srv_statistic_redirection_sum_view']), 'T', 0, 'L', 0);
+ $this->pdf->Cell(45, 0, $this->encodeText($view_count), 'T', 1, 'L', 0);
+
+ $this->pdf->setX($X);
+ $this->pdf->setFont('','','6'); */
+ $vrsticaJ[] = $this->encodeText($lang['srv_statistic_redirection_sum_view']);
+ $vrsticaJ[] = $this->encodeText($view_count);
+ $texStatusView .= $this->horizontalLineTex;
+ $texStatusView .= $this->tableRow($vrsticaJ,1);
+ $texStatusView .= $this->texNewLine;
+ }
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic - konec
+
+ //zaljucek latex tabele s podatki
+ $texStatusView .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+
+ //izpis tabele v okvir
+ $texText = $this->FrameText($title.$texStatusView);
+ return $texText;
+ }
+
+ /** Funkcija prikaže statuse odgovorov
+ *
+ */
+ function DisplayAnswerStateView() {
+ global $lang;
+
+ $texAnswerStateView = '';
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_statistic_answer_state_title']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 3;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+ $parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? 'X|' : 'l|');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'C|' : 'c|');
+ }
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texAnswerStateView .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+
+ //prva vrstica
+ $prvaVrstica = array();
+ $prvaVrstica[] = $this->encodeText($lang['srv_statistic_answer_state_status']);
+ $prvaVrstica[] = $this->encodeText($lang['srv_statistic_answer_state_frequency']);
+ $prvaVrstica[] = $this->encodeText($lang['srv_statistic_answer_state_percent']);
+ $texAnswerStateView .= $this->tableRow($prvaVrstica,1);
+ $texAnswerStateView .= $this->horizontalLineTex;
+
+
+ $order = array('3ll','4ll','5ll',5,6);
+
+ foreach ($order as $key) {
+ $vrstica2N = array();
+ $vrstica2N[] = $this->encodeText($lang['srv_userstatus_'.$key]);
+ $vrstica2N[] = $this->encodeText($this->ss->realUsersByStatus[$key]['cnt'] > 0 ? $this->ss->realUsersByStatus[$key]['cnt'] : '0');
+ $vrstica2N[] = $this->encodeText( ((float)$this->ss->realUsersByStatus[$key]['percent'] > 1.0) ? '--' : $this->formatNumber($this->ss->realUsersByStatus[$key]['percent']*100,NUM_DIGIT_PERCENT,'%') );
+ $texAnswerStateView .= $this->tableRow($vrstica2N,1);
+ }
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic - konec
+
+ //zaljucek latex tabele s podatki
+ $texAnswerStateView .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+
+ //izpis tabele v okvir
+ $texText = $this->FrameText($title.$texAnswerStateView);
+ return $texText;
+ }
+
+
+ /** Funkcija za prikaz referalov
+ *
+ */
+ function DisplayReferalsView() {
+ global $lang;
+ global $admin_type;
+
+ $texReferalsView = '';
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_statistic_redirection_title']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ // izrisemo graf
+ if ( ( $this->ss->cntValidRedirections + $this->ss->cntNonValidRedirections ) > 0) {
+ $maxValue = $this->ss->maxRedirection * GRAPH_REDUCE;
+ $value_sum = 0;
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+ //$parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texReferalsView .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+
+ //naslovna vrstica
+ $naslovnaVrstica = array();
+ $naslovnaVrstica[] = $this->encodeText($lang['srv_statistic_redirection_site']);
+ $naslovnaVrstica[] = $this->encodeText($lang['srv_statistic_redirection_click']);
+ $texReferalsView .= $this->tableRow($naslovnaVrstica);
+
+ //pridobitev skupnega stevila klikov $value_sum za izris grafov
+ if (count($this->ss->userRedirections["valid"])) {
+ $lineCount = 0;
+ foreach ($this->ss->userRedirections["valid"] as $key => $value) {
+ $value_sum += $value;
+ $lineCount++;
+ }
+ }
+ // dodamo še direktni link
+ if ($this->ss->userRedirections["direct"] > 0) {
+ $value = $this->ss->userRedirections["direct"];
+ $value_sum += $value;
+ }
+ // dodamo še email klik
+ if ($this->ss->userRedirections["email"] > 0) {
+ $value = $this->ss->userRedirections["email"];
+ $value_sum += $value;
+ }
+ //pridobitev skupnega stevila klikov za izris grafov - konec
+
+ if (count($this->ss->userRedirections["valid"])) {
+ foreach ($this->ss->userRedirections["valid"] as $key => $value) {
+ $vmesnaVrsticaA = array();
+ $vmesnaVrsticaA[] = $this->encodeText($key);
+ if($this->encodeText($value)){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$value_sum)*$this->encodeText($value);
+ $vmesnaVrsticaA[] = $this->drawGraphLatex($graphLineLength, $this->encodeText($value));
+ }else{
+ $vmesnaVrsticaA[] = 0;
+ }
+ $texReferalsView .= $this->tableRow($vmesnaVrsticaA,1);
+ }
+ }
+
+ // dodamo še direktni link
+ if ($this->ss->userRedirections["direct"] > 0) {
+ $value = $this->ss->userRedirections["direct"];
+ $vmesnaVrsticaB = array();
+ $vmesnaVrsticaB[] = $this->encodeText($lang['srv_statistic_redirection_direct']);
+ if($this->encodeText($value)){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$value_sum)*$this->encodeText($value);
+ $vmesnaVrsticaB[] = $this->drawGraphLatex($graphLineLength, $this->encodeText($value));
+ }else{
+ $vmesnaVrsticaB[] = 0;
+ }
+ $texReferalsView .= $this->tableRow($vmesnaVrsticaB,1);
+ }
+
+ // dodamo še email klik
+ if ($this->ss->userRedirections["email"] > 0) {
+ $value = $this->ss->userRedirections["email"];
+ $vmesnaVrsticaC = array();
+ $vmesnaVrsticaC[] = $this->encodeText($lang['srv_statistic_redirection_email']);
+ if($this->encodeText($value)){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$value_sum)*$this->encodeText($value);
+ $vmesnaVrsticaC[] = $this->drawGraphLatex($graphLineLength, $this->encodeText($value));
+ }else{
+ $vmesnaVrsticaC[] = 0;
+ }
+ $texReferalsView .= $this->tableRow($vmesnaVrsticaC,1);
+ }
+
+ // dodamo sumo
+ $texReferalsView .= $this->horizontalLineTex;
+ $vrsticaSuma = array();
+ $vrsticaSuma[] = $this->encodeText($lang['srv_statistic_redirection_sum_clicked']);
+ $vrsticaSuma[] = $this->encodeText($value_sum);
+ $texReferalsView .= $this->tableRow($vrsticaSuma,1);
+
+ // dodamo se neveljavne *******************************************
+ //pridobitev skupnega stevila klikov $value_sum_nonvalid za izris grafov
+ $value_sum_nonvalid = 0;
+ for ($key = 2; $key >= 0; $key--) {
+ $value = $this->ss->userRedirections["$key"];
+ if ($value > 0) {
+ $value_sum_nonvalid += $value;
+ }
+ }
+ //pridobitev skupnega stevila klikov $value_sum_nonvalid za izris grafov - konec
+
+ for ($key = 2; $key >= 0; $key--) {
+ $value = $this->ss->userRedirections["$key"];
+ if ($value > 0) {
+ $vrsticaNeveljavni = array();
+ $vrsticaNeveljavni[] = $this->encodeText($lang['srv_userstatus_'.$key]);
+ if($this->encodeText($value)){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$value_sum)*$this->encodeText($value);
+ $vrsticaNeveljavni[] = $this->drawGraphLatex($graphLineLength, $this->encodeText($value));
+ }else{
+ $vrsticaNeveljavni[] = 0;
+ }
+ $texReferalsView .= $this->tableRow($vrsticaNeveljavni,1);
+ }
+ }
+ // dodamo sumo
+ if ($value_sum_nonvalid > 0 ) {
+ $texReferalsView .= $this->horizontalLineTex;
+ $vrsticaSumaNeveljavni = array();
+ $vrsticaSumaNeveljavni[] = $this->encodeText($lang['srv_statistic_redirection_sum_nonvalid']);
+ $vrsticaSumaNeveljavni[] = $this->encodeText($value_sum_nonvalid);
+ $texReferalsView .= $this->tableRow($vrsticaSumaNeveljavni,1);
+ }
+ if (!($value_sum_nonvalid == 0 || $value_sum == 0 )) {
+ $texReferalsView .= $this->horizontalLineTex;
+ $vrsticaSumaNeveljavni = array();
+ $vrsticaSumaNeveljavni[] = $this->encodeText($lang['srv_statistic_redirection_sum']);
+ $vrsticaSumaNeveljavni[] = $this->encodeText($value_sum+$value_sum_nonvalid);
+ $texReferalsView .= $this->tableRow($vrsticaSumaNeveljavni,1);
+ }
+ // dodamo se neveljavne - konec *******************************************
+
+ //zaljucek latex tabele s podatki
+ $texReferalsView .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+ }
+ else {
+ $texReferalsView .= $this->encodeText($lang['srv_statistic_show_no_referals']).$this->texNewLine;
+
+ }
+
+ //stevilo razlicnih IP stevilk
+ $texReferalsView .= $this->texBigSkip.' ';
+ //$texReferalsView .= $this->texNewLine;
+ $texReferalsView .= $this->encodeText($lang['srv_count_ip_list'].': '.count($this->ss->ip_list));
+
+ if ($admin_type==0 && count($this->ss->ip_list) > 0) {
+ $texReferalsView .= ' '.$this->texBigSkip;
+ $texReferalsView .= $this->texNewLine;
+ $titleTextIP = $this->encodeText($lang['srv_detail_ip_list']);
+ $titleIP = $this->returnBoldAndRed($titleTextIP);
+ $texReferalsView .= $this->returnBoldAndRed($titleIP).$this->texNewLine;
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texReferalsView .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //Izpis vrstic
+ foreach($this->ss->ip_list AS $key => $val) {
+ $vrsticaIP = array();
+ $vrsticaIP[] = $this->encodeText($val);
+ $vrsticaIP[] = $this->encodeText($key);
+ $texReferalsView .= $this->tableRow($vrsticaIP,1);
+ }
+
+ //zaljucek latex tabele s podatki IP
+ $texReferalsView .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki IP - konec
+ }
+
+ //izpis tabele in beedila v okvir
+ $texText = $this->FrameText($title.$texReferalsView);
+
+ return $texText;
+ }
+
+ /** Funkcija prikaze statistike
+ *
+ */
+ function DisplayDateView() {
+ global $lang;
+
+ $texDateView = '';
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_statistic_timeline_title']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ $this->ss->maxValue *= GRAPH_REDUCE;
+ $cnt=0;
+
+ if ($this->ss->arrayRange) {
+ $lineCount = 0;
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ if($i == 0){
+ $parameterTabular .= ($export_format == 'pdf' ? '>{\hsize=.40\hsize \centering\arraybackslash}X' : 'l');
+ }else{
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texDateView .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //pridobitev skupnega stevila enot $cnt za izris grafov
+ foreach ($this->ss->arrayRange as $key => $value) {
+ $cnt+=$value;
+ }
+ //pridobitev skupnega stevila enot $cnt za izris grafov - konec
+
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+ foreach ($this->ss->arrayRange as $key => $value) {
+ $label = $this->ss->formatStatsString($key, $this->ss->period);
+ $vmesnaVrstica = array();
+ $vmesnaVrstica[] = $this->encodeText($label);
+ //if($this->encodeText($value)){ //ce vrednost ni nula
+ if($value){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$cnt)*$this->encodeText($value);
+ //$vmesnaVrstica[] = $this->drawGraphLatex($graphLineLength, $this->encodeText($value));
+ $vmesnaVrstica[] = $this->drawGraphLatex($graphLineLength, $value);
+ }else{
+ $vmesnaVrstica[] = 0;
+ }
+ $texDateView .= $this->tableRow($vmesnaVrstica,1);
+ }
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic - konec
+
+ // dodamo sumo
+ $texDateView .= $this->horizontalLineTex;
+ $vrsticaSuma = array();
+ $vrsticaSuma[] = $this->encodeText($lang['srv_statistic_redirection_sum']);
+ $vrsticaSuma[] = $this->encodeText($cnt);
+ $texDateView .= $this->tableRow($vrsticaSuma,1);
+
+ //zaljucek latex tabele s podatki
+ $texDateView .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+ }
+ else {
+ $texDateView .= $this->encodeText($lang['srv_no_data']).$this->texNewLine;
+ }
+
+ //izpis tabele in beedila v okvir
+ $texText = $this->FrameText($title.$texDateView);
+
+ return $texText;
+ }
+
+ /** Funkcija za prikaz klikov po straneh
+ *
+ */
+ function DisplayPagesStateView() {
+ global $lang;
+
+ $texPagesStateView = '';
+
+ //naslov okvirja
+ $titleText = $this->encodeText($lang['srv_statistic_pages_state_title']).$this->texNewLine;
+ $title = $this->returnBoldAndRed($titleText);
+
+ //ali lovimo samo strani ki niso bile preskočene
+ $grupa_jump = "AND ug.preskocena = 0 ";
+
+ $sql = "SELECT g.id, g.naslov, COUNT(ug.usr_id) cnt FROM srv_grupa g".
+ " LEFT JOIN (SELECT * FROM srv_user_grupa".$this->ss->db_table." ug WHERE".
+ " ug.time_edit BETWEEN '".$this->ss->startDate."' AND '".$this->ss->endDate."' + INTERVAL 1 DAY ".$grupa_jump.") as ug ON g.id = ug.gru_id".
+ " WHERE g.ank_id = '".$this->ss->getSurveyId()."' GROUP BY g.id ORDER BY g.vrstni_red";
+
+ $qry = sisplet_query($sql);
+ $pages=array();
+ $maxValue = 0;
+ while ($row = mysqli_fetch_assoc($qry)) {
+ $pages[$row['id']] = array('naslov'=>$row['naslov'],'cnt'=>$row['cnt']);
+ $maxValue = max($maxValue, $row['cnt']);
+ }
+
+ $maxValue = max($maxValue, $this->ss->realUsersByStatus['3ll']['cnt']);
+ $maxValue = $maxValue * GRAPH_REDUCE;
+
+ //Priprava parametrov za tabelo s podatki o anketi
+ $steviloStolpcevParameterTabular = 2;
+ $steviloOstalihStolpcev = $steviloStolpcevParameterTabular - 1; /*stevilo stolpcev brez prvega stolpca, ki ima fiksno sirino*/
+ $sirinaOstalihStolpcev = 0.9/$steviloOstalihStolpcev;
+ $parameterTabular = '';
+ $export_format = 'pdf';
+ //$parameterTabular = '|';
+
+ for($i = 0; $i < $steviloStolpcevParameterTabular; $i++){
+ $parameterTabular .= ($export_format == 'pdf' ? 'X' : 'l');
+ }
+
+ $pdfTable = 'tabularx';
+ $rtfTable = 'tabular';
+ $pdfTableWidth = 1;
+ $rtfTableWidth = 1;
+
+ $texPagesStateView .= $this->StartLatexTable($export_format, $parameterTabular, $pdfTable, $rtfTable, $pdfTableWidth, $rtfTableWidth);
+
+ //Priprava parametrov za tabelo s podatki o anketi - konec
+
+ //Priprava podatkov za izpis vrstic tabele in izpis vrstic
+ //naslovna vrstica
+ $naslovnaVrstica = array();
+ $naslovnaVrstica[] = $this->encodeText($lang['srv_statistic_answer_state_status']);
+ $naslovnaVrstica[] = $this->encodeText($lang['srv_statistic_redirection_click']);
+ $texPagesStateView .= $this->tableRow($naslovnaVrstica);
+
+ # status 3 - "Klik na anketo"
+ $value = $this->ss->realUsersByStatus['3ll']['cnt'];
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($lang['srv_userstatus_3']), $this->encodeText($value), $maxValue);
+
+ # status 4 - "Klik na prvo stran"
+ $value = $this->ss->realUsersByStatus['4ll']['cnt'];
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($lang['srv_userstatus_4']), $this->encodeText($value), $maxValue);
+
+ # status 5 - "Zacel izpolnjevati",
+ $value = $this->ss->realUsersByStatus[5]['cnt'];
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($lang['srv_userstatus_5']), $this->encodeText($value), $maxValue);
+
+ $texPagesStateView .= $this->horizontalLineTex; //horizontalna crta
+ $texPagesStateView .= $this->texNewLine; //prazna crta
+
+ #strani
+ foreach ($pages as $key => $page) {
+ $value = $page['cnt'];
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($page['naslov']), $this->encodeText($value), $maxValue);
+ }
+
+ $texPagesStateView .= $this->horizontalLineTex; //horizontalna crta
+ $texPagesStateView .= $this->texNewLine; //prazna crta
+
+ # status 6 - "Koncal",
+ $value6 = $this->ss->realUsersByStatus[6]['cnt'];
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($lang['srv_userstatus_6']), $this->encodeText($value6), $maxValue);
+
+ #če imamo lurkerje 6l dodamo skupaj konačal anketo (to je 6 + 6l) in nato še koliko jih je samo s statusom 6 (končal anketo)
+ # status 6l - "Koncal - lurker", izpišemo samo če obstajajo 6l
+ $lurkerjev = $this->ss->realUsersByStatus['6ll']['cnt'] - $value6;
+ if ($lurkerjev > 0) {
+ $valueall = $this->ss->realUsersByStatus['6ll']['cnt'] ;
+
+ # končal s tem da je lurker (6l)
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($lang['srv_userstatus_6l']), $this->encodeText($lurkerjev), $maxValue);
+
+ #črta
+ $texPagesStateView .= $this->horizontalLineTex; //horizontalna crta
+
+ # končal ne glede na to ali je lurker
+ $texPagesStateView .= $this->displayStatusLine($this->encodeText($lang['srv_userstatus_all']), $this->encodeText($valueall), $maxValue);
+ }
+
+ //zaljucek latex tabele s podatki
+ $texPagesStateView .= "\\end{".$pdfTable."}";
+ //zaljucek latex tabele s podatki - konec
+
+ //izpis tabele in beedila v okvir
+ $texText = $this->FrameText($title.$texPagesStateView);
+ return $texText;
+ }
+
+
+ /*Skrajsa tekst in doda '...' na koncu*/
+ function snippet($text='', $length=64, $tail="...")
+ {
+ $text = trim($text);
+ $txtl = strlen($text);
+ if($txtl > $length)
+ {
+ for($i=1;$text[$length-$i]!=" ";$i++)
+ {
+ if($i == $length)
+ {
+ return substr($text,0,$length) . $tail;
+ }
+ }
+ $text = substr($text,0,$length-$i+1) . $tail;
+ }
+ return $text;
+ }
+
+ function drawLine()
+ {
+ $cy = $this->pdf->getY();
+ $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
+ }
+
+ function setUserId($usrId=null) {$this->anketa['uid'] = $usrId;}
+ function getUserId() {return ($this->anketa['uid'])?$this->anketa['uid']:false;}
+
+ function formatNumber($value=null, $digit=0, $sufix="")
+ {
+ if ( $value <> 0 && $value != null )
+ $result = round($value,$digit);
+ else
+ $result = "0";
+ $result = number_format($result, $digit, ',', '.').$sufix;
+
+ return $result;
+ }
+
+ #moja funkcija encodeText
+ function encodeText($text=''){
+ // popravimo sumnike ce je potrebno
+ //$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
+ //$text = str_replace("&scaron;","š",$text);
+ //echo "Encoding ".$text."</br>";
+ if($text == ''){ //ce ni teksta, vrni se
+ return;
+ }
+ $textOrig = $text;
+ $findme = '<br />';
+ $findmeLength = strlen($findme);
+ $findImg = '<img';
+ $findImgLength = strlen($findImg);
+
+ $pos = strpos($text, $findme);
+ $posImg = strpos($text, $findImg);
+
+ //ureditev izrisa slike
+ if($posImg !== false){
+ $numOfImgs = substr_count($text, $findImg); //stevilo '<br />' v tekstu
+ $posImg = strpos($text, $findImg);
+ $textPrej = '';
+ $textPotem = '';
+ for($i=0; $i<$numOfImgs; $i++){
+ $posImg = strpos($text, $findImg);
+ $textPrej = substr($text, 0, $posImg); //tekst do img
+ $textPotem = substr($text, $posImg); //tekst po img, z vkljuceno hmlt kodo z img
+ $posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
+ $textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
+
+ $text = $textPrej.' '.PIC_SIZE_ANS."{".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
+ //$text2Return = $textPrej.' '.PIC_SIZE_ANS."{".$this->getImageName($text2Return, 0, 'img')."}".' '.$textPotem;
+ }
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
+ $findImgCode = '\includegraphics';
+ $posOfImgCode = strpos($text, $findImgCode);
+ //echo $posOfImgCode."</br>";
+ $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode
+ //echo $textToImgCode."</br>";
+ $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode
+ //echo $textFromImgCode."</br>";
+ $findImgCodeEnd = '}';
+ //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd);
+ $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd);
+ //echo $posOfImgCodeEnd."</br>";
+ $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd
+ //echo $textAfterImgCode."</br>";
+ $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1);
+ //echo $textOfImgCode."</br>";
+
+ $text = $textToImgCode.$textAfterImgCode;
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - konec
+ }
+ //ureditev izrisa slike - konec
+
+ //ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
+ $text = str_replace('\\','\textbackslash{} ',$text);
+ //$text = str_replace('{','\{',$text);
+ //$text = str_replace('}','\}',$text);
+ $text = str_replace('$','\$ ',$text);
+ $text = str_replace('#','\# ',$text);
+ $text = str_replace('%','\% ',$text);
+ $text = str_replace('€','\euro',$text);
+ $text = str_replace('^','\textasciicircum{} ',$text);
+ //$text = str_replace('_','\_ ',$text);
+ $text = str_replace('_','\_',$text);
+ $text = str_replace('~','\textasciitilde{} ',$text);
+ $text = str_replace('&amp;','\&',$text);
+ $text = str_replace('&','\&',$text);
+ //$text = str_replace('&lt;','\textless ',$text);
+ $text = str_replace('&lt;','\textless',$text);
+ //$text = str_replace('&gt;','\textgreater ',$text);
+ $text = str_replace('&gt;','\textgreater',$text);
+ $text = str_replace('&nbsp;',' ',$text);
+ //ureditev posebnih karakterjev za Latex - konec
+
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+ if($posImg !== false){
+ $text = substr_replace($text, $textOfImgCode, $posOfImgCode, 0);
+ }
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+
+ if($pos === false && $posImg === false) { //v tekstu ni br in img
+ //return $text;
+/* echo "encode pred strip: ".$text."</br>";
+ echo "encode po strip: ".strip_tags($text)."</br>";
+ return strip_tags($text); */
+ }else { //v tekstu sta prisotna br ali img
+ $text2Return = ''; //tekst ki bo vrnjen
+
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
+ if($pos !== false){
+ $pos = strpos($text, $findme);
+ $numOfBr = substr_count($text, $findme); //stevilo '<br />' v tekstu
+ for($i=0; $i<$numOfBr; $i++){
+ if($i == 0){ //ce je prvi najdeni '<br />'
+ $textPrej = substr($text, 0, $pos);
+ $textPotem = substr($text, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ $text2Return .= $textPrej.' \break '.$textPotem;
+ }else{
+ $text2Return .= $textPrej.' \break ';
+ }
+ }else{ //drugace
+ $pos = strpos($textPotem, $findme);
+ $textPrej = substr($textPotem, 0, $pos);
+ $textPotem = substr($textPotem, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ $text2Return .= $textPrej.' \break '.$textPotem;
+ }else{
+ $text2Return .= $textPrej.' \break ';
+ }
+ }
+ }
+ $text = $text2Return;
+ }
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
+/* echo "encode pred strip: ".$text."</br>";
+ echo "encode po strip: ".strip_tags($text)."</br>";
+ return strip_tags($text); //vrni tekst brez html tag-ov */
+ }
+
+ //preveri, ce je url v besedilu (http:// ... ) in uredi Latex izpis le-tega
+ $findHttp = 'http://';
+ $findHttps = 'https://';
+ $posHttp = strpos($text, $findHttp);
+ $posHttps = strpos($text, $findHttps);
+
+ if($posHttp !== false || $posHttps !== false) { //v imamo URL naslov
+ $space = ' ';
+ if($posHttp !== false){
+ $text = substr_replace($text, $space, ($posHttp+7), 0);
+ }elseif($posHttps !== false){
+ $text = substr_replace($text, $space, ($posHttps+8), 0);
+ }
+ }
+ //preveri, ce je url v besedilu (http:// ... ) in uredi Latex izpis le-tega - konec
+
+ return strip_tags($text); //vrni tekst brez html tag-ov
+ }
+
+ function returnBold($text=''){
+ $boldedText = '';
+ $boldedText .= '\textbf{'.$text.'}';
+ return $boldedText;
+ }
+
+ function returnBoldAndRed($text=''){
+ //$this->naslovnicaUkaz .= ' {\\textcolor{red}{'.$lang['srv_survey_non_active1'].'}} \\\\';
+ $tex = '';
+ $tex .= ' {\\textcolor{red}{'.$text.'}} ';
+ return $tex;
+ }
+
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele ##################################################################################
+ #argumenti 1. export_format, 2. parametri tabele, 3. tip tabele za pdf, 4. tip tabele za rtf, 5. sirina pdf tabele (delez sirine strani), 6. sirina rtf tabele (delez sirine strani)
+ function StartLatexTable($export_format='', $parameterTabular='', $pdfTable='', $rtfTable='', $pdfTableWidth=null, $rtfTableWidth=null){
+ $tex = '';
+ //$tex .= '\keepXColumns';
+ if($export_format == 'pdf'){
+ $tex .= '\begin{'.$pdfTable.'}';
+ if($pdfTable=='tabularx'){
+ //$tex .= '{'.$pdfTableWidth.'\textwidth}';
+ $tex .= '{\hsize}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }elseif($export_format == 'rtf'){
+ $tex .= '\begin{'.$rtfTable.'}';
+ if($rtfTable=='tabular*'){
+ $tex .= '{'.$pdfTableWidth.'\textwidth}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele - konec ##########################################################################
+
+ //omogoca izpis okvirja z dolocene sirine in visine s tekstom dolocene sirine
+ function FrameText($text=''){
+ $framedText = '';
+ //$framedText .= '\framebox('.FRAME_WIDTH.','.FRAME_HEIGTH.'){ \parbox[t]{'.FRAME_TEXT_WIDTH.'\textwidth}{'.$text.'} }';
+ $framedText .= '\framebox('.FRAME_WIDTH.','.FRAME_HEIGTH.')[t]{ \parbox[t]{'.FRAME_TEXT_WIDTH.'\textwidth}{'.$this->texSmallSkip.$text.'} }';
+ return $framedText;
+ }
+
+ function tableRow($arrayText=[], $brezHline=0){
+ $tableRow = '';
+ /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
+ $linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
+ $height = 1; //$height = $this->getCellHeight($this->encodeText($arrayText[1]), 90);
+
+ if($arrayParams['align2'] != 'C')
+ $arrayParams['align2'] = 'L';
+ //echo "velikost polja s tekstom: ".count($arrayText)."</br>";
+
+ for($i=0;$i<count($arrayText);$i++){
+ //echo "array text: ".$arrayText[$i]."</br>";
+ $text = $arrayText[$i];
+ if($i==0){
+ $tableRow .= $text;
+ }else{
+ $tableRow .= ' & '.$text;
+ }
+ }
+
+ $tableRow .= $this->texNewLine; /*nova vrstica*/
+
+ if (!$brezHline) { //dodaj se horizontal line, ce je to potrebno (po navadi vse povsod razen npr. za tabelo s st. odklonom in povprecjem)
+ $tableRow .= $this->horizontalLineTex; /*obroba*/
+ }
+
+ //echo "Vrstica tabele: ".$tableRow."</br>";
+
+ return $tableRow;
+ }
+
+ //funkcija, ki skrbi za izris grafa ustrezne dolzine
+ function drawGraphLatex($graphLineLength=null, $value=null){
+ $texGraph = '';
+ $texGraph .= '\begin{tikzpicture} \fill[crtaGraf] (0,0) -- ('.$graphLineLength.',0) -- ('.$graphLineLength.','.GRAPH_LINE_WIDTH.') -- (0,'.GRAPH_LINE_WIDTH.') -- (0,0); \end{tikzpicture} '.$value;
+ return $texGraph;
+ }
+
+ function displayStatusLine($text='', $value=null, $maxValue=null){
+ $texStatusLine = '';
+ $vrsticaPodatki = array();
+ $vrsticaPodatki[] = $text;
+ if($value){ //ce vrednost ni nula
+ $graphLineLength = (GRAPH_LINE_LENGTH_MAX/$maxValue)*$value;
+ $vrsticaPodatki[] = $this->drawGraphLatex($graphLineLength, $value);
+ }else{
+ $vrsticaPodatki[] = 0;
+ }
+ $texStatusLine .= $this->tableRow($vrsticaPodatki,1);
+
+ return $texStatusLine;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexSurvey.php b/admin/survey/export/latexclasses/class.LatexSurvey.php
new file mode 100644
index 0000000..7f93749
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexSurvey.php
@@ -0,0 +1,1342 @@
+<?php
+
+/**
+ *
+ * Class ki skrbi za izris vprasalnika v latex
+ *
+ *
+ */
+//namespace Export\Latexclasses;
+
+include('../../vendor/autoload.php');
+
+define("RADIO_BTN_SIZE", 0.13);
+
+class LatexSurvey{
+
+ var $anketa; // ID ankete
+ var $tex; //shrani tex kodo
+ var $texNewLine = '\\\\ ';
+ //var $texPageBreak = "\\pagebreak";
+ var $texPageBreak = "\\newpage";
+ var $export_format;
+ var $export_data_show_recnum;
+ var $exportDataPageBreak=0; //vsak respondent na svoji strani
+
+ var $commentType = 1; // tip izpisa komentarjev
+
+ var $loop_id = null; // id trenutnega loopa ce jih imamo
+
+ var $db_table = '';
+
+ protected $showIntro = 0;
+ protected $showGDPRIntro = 0;
+ protected $GDPRIntro = '';
+ protected $type = 0; // tip izpisa - 0->navaden, 1->iz prve strani, 2->s komentarji
+
+ protected $showIf = 0; // izpis if-ov
+
+ var $skipEmpty = 0; // izpusti vprasanja brez odgovora
+ var $skipEmptySub = 0; // izpusti podvprasanja brez odgovora
+
+ protected $recnum = 0;
+ protected $usr_id = 0;
+ protected $texBigSkip = '\bigskip';
+
+ protected $admin_type;
+
+ protected $path2UploadedImages;
+
+ protected $language = -1; // Katero verzijo prevoda izvazamo
+
+ //function __construct($anketa, $export_format){
+ function __construct($anketa=null, $export_format='', $export_show_intro=null, $export_show_if=null, $export_data_skip_empty=null, $export_data_skip_empty_sub=null){
+ global $site_path, $global_user_id, $admin_type, $lang;
+
+ $this->anketa = $anketa;
+ $this->export_format = $export_format;
+
+ $this->admin_type = $admin_type;
+
+ $this->usr_id = $_GET['usr_id'];
+
+ $this->showIntro = $export_show_intro;
+ $this->showIf = $export_show_if;
+
+ $this->skipEmpty = $export_data_skip_empty;
+
+ $this->skipEmptySub = $export_data_skip_empty_sub;
+
+ $this->path2Images = $site_path.'admin/survey/export/latexclasses/textemp/images/';
+
+
+ //Prikazi GDPR v uvodu
+ $gdpr = new GDPR();
+ $this->showGDPRIntro = $gdpr->isGDPRSurveyTemplate($this->anketa);
+ //echo "gdpr nastavitve: ".$this->showGDPRIntro."</br>";
+ if($this->showGDPRIntro){
+ $this->GDPRIntro = $gdpr->getSurveyIntro($this->anketa);
+ //echo "gdpr te: ".$this->GDPRIntro."</br>";
+ }
+
+ if ($this->usr_id != '') {
+ $sqlR = sisplet_query("SELECT recnum FROM srv_user WHERE id = '$this->usr_id '");
+ $rowR = mysqli_fetch_array($sqlR);
+ $this->recnum = $rowR['recnum'];
+ }
+
+ //pridobitev nastavitev izvoza
+ SurveySetting::getInstance()->Init($this->anketa);
+ $this->export_data_show_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_recnum'); //ali je potrebno pokazati recnum ob vsakem respondentu
+ $this->exportDataPageBreak = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_PB'); //ali mora vsak izpis odgovorov respondenta zaceti na svoji strani
+
+ SurveyStatusProfiles::Init($this->anketa);
+
+ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
+ if ( SurveyInfo::getInstance()->SurveyInit($this->anketa) )
+ {
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1){
+ $this->db_table = '_active';
+ }
+ }
+ else{
+ return false;
+ }
+ }
+
+ #funkcija, ki skrbi za izpis praznega vprasalnika in vprasalnika z odgovori enega respondenta
+ public function displaySurvey($export_subtype='', $export_data_type='', $language=null){
+ global $lang, $site_url;
+ //echo "Funkcija displaySurvey user: $this->usr_id</br>";
+ $this->language = $language;
+ if($this->language!=-1){
+ // Naložimo jezikovno datoteko
+ $file = '../../lang/'.$this->language.'.php';
+ include($file);
+ $_SESSION['langX'] = $site_url .'lang/'.$this->language.'.php';
+ }
+
+ $surveyExpanded = SurveyInfo::getInstance()->getSurveyColumn('expanded');
+
+ // filtriramo spremenljivke glede na profil
+ SurveyVariablesProfiles :: Init($this->anketa);
+
+ $dvp = SurveyUserSetting :: getInstance()->getSettings('default_variable_profile');
+ $_currentVariableProfile = SurveyVariablesProfiles :: checkDefaultProfile($dvp);
+
+ $tmp_svp_pv = SurveyVariablesProfiles :: getProfileVariables($_currentVariableProfile);
+
+ foreach ( $tmp_svp_pv as $vid => $variable) {
+ $tmp_svp_pv[$vid] = substr($vid, 0, strpos($vid, '_'));
+ }
+
+
+ if($export_subtype=='q_data'){ //ce je vprasalnik za enega respondenta
+ //pridobitev podatkov trenutnega respondenta za izpis Recnum
+ $izbranStatusProfile = SurveyStatusProfiles :: getStatusAsQueryString();
+ $sqluString = "SELECT id, last_status, lurker, recnum FROM srv_user WHERE ank_id = '".$this->anketa."' ".$izbranStatusProfile." AND deleted='0' AND preview='0' AND id='".$this->usr_id."' ORDER BY recnum";
+ //echo $sqluString;
+ $sqlu = sisplet_query($sqluString);
+ $rowu = mysqli_fetch_array($sqlu);
+ $recnum = $rowu['recnum'];
+ if($recnum && $this->export_data_show_recnum){
+ $recnumBesedilo = "(Recnum $recnum)";
+ }else{
+ $recnumBesedilo = "";
+ }
+ //pridobitev podatkov trenutnega respondenta za izpis Recnum - konec
+
+
+
+ //$tex .= $lang['srv_respondent_answer'].": ".$this->recnum;
+ $tex .= '\MakeUppercase{\huge \textbf{'.$lang['srv_respondent_answer'].' '.$recnumBesedilo.'}}'; //izpisi "Odgovori respondenta"
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ }
+
+ //ce je potrebno izpisati GDPR besedilo v intro
+ if($this->showGDPRIntro == 1){
+ //$GDPRintro = "gdpr INTRO";
+ $GDPRintro = strip_tags($this->GDPRIntro, '<a><img><ul><li><ol><br><p>');
+ $GDPRintro = $this->encodeTextHere($GDPRintro);
+ $tex .= ' \textbf{'.$GDPRintro.'} ';
+
+ //radio buttona
+ if($export_subtype=='q_empty'){ //ce je prazen vprasalnik
+ $radioButtonTex = ("\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio}");
+ $tex .= '\\\\'.$radioButtonTex.' '.$lang['srv_gdpr_intro_no'];
+ $tex .= '\\\\'.$radioButtonTex.' '.$lang['srv_gdpr_intro_yes'];
+ }else{
+ //pridobitev ID grupe
+ $sqlGrupeStringGDPR = "SELECT id FROM srv_grupa WHERE ank_id='".$this->anketa."' ORDER BY vrstni_red";
+ $sqlGrupeGDPR = sisplet_query($sqlGrupeStringGDPR);
+ $rowGrupeGDPR = mysqli_fetch_array( $sqlGrupeGDPR );
+ $grupa = $rowGrupeGDPR['id'];
+ //pridobitev ID grupe - konec
+
+ //pridobitev informacije obiska strani oz. ankete
+ $sqlStringStran = "SELECT time_edit FROM srv_user_grupa".$this->db_table." WHERE usr_id='".$this->usr_id."' AND gru_id='".$grupa."'";
+ //echo $sqlStringStran;
+ $sqlStran = sisplet_query($sqlStringStran);
+ $rowStran = mysqli_fetch_array( $sqlStran );
+ $stran = $rowStran['time_edit'];
+ //echo $stran;
+ //pridobitev informacije obiska strani oz. ankete - konec
+
+ if($stran){
+ $radioButtonTexNo = ("\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio}");
+ $radioButtonTexYes = ("\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio2}");
+ }else{
+ $radioButtonTexNo = ("\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio2}");
+ $radioButtonTexYes = ("\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio}");
+ }
+
+ $tex .= '\\\\'.$radioButtonTexNo.' '.$lang['srv_gdpr_intro_no'];
+ $tex .= '\\\\'.$radioButtonTexYes.' '.$lang['srv_gdpr_intro_yes'];
+
+ }
+
+
+ //radio buttona - konec
+
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ }
+
+ // ce obstaja intro izpisemo intro - pri izpisu vprasalnika brez odgovorov (ce smo na prvi strani moramo biti v razsirjenem nacinu)
+ if( ($surveyExpanded != 0 || $this->type != 1) && $this->showIntro == 1 ){
+ if ( SurveyInfo::getInstance()->getSurveyShowIntro() )
+ {
+ //preverjanje, ali je prevod
+ if(isset($_GET['language'])){
+ $this->language = $_GET['language'];
+ $prevod = 1;
+ }else{
+ $prevod = 0;
+ }
+ //preverjanje, ali je prevod - konec
+
+ //if($this->language!=-1){ //ce je prevod ankete
+ if($prevod){ //ce je prevod ankete
+ $spr_id_uvod = -1;
+ $sqll = sisplet_query("SELECT naslov, info FROM srv_language_spremenljivka WHERE ank_id='".$this->anketa."' AND spr_id='".$spr_id_uvod."' AND lang_id='".$this->language."'");
+ $rowl = mysqli_fetch_array($sqll); //pridobi prevod uvoda v ustreznem jeziku
+ $intro = $rowl['naslov']; //prevod uvoda v ustreznem jeziku
+ }else{
+ $intro = (SurveyInfo::getInstance()->getSurveyIntro() == '') ? $lang['srv_intro'] : SurveyInfo::getInstance()->getSurveyIntro();
+ }
+ $tex .= $this->encodeTextHere($intro);
+ if($intro){
+ $tex .= $this->texNewLine;
+ $tex .= $this->texNewLine;
+ }
+
+ }
+ }
+
+ $sqlGrupeString = "SELECT id FROM srv_grupa WHERE ank_id='".$this->anketa."' ORDER BY vrstni_red";
+ $sqlGrupe = sisplet_query($sqlGrupeString);
+
+ //echo "__________________________________</br>";
+ //echo "Funkcija displaySurvey user: $this->usr_id</br>";
+ if($this->export_format == 'rtf'){
+ $tex .= $this->texNewLine;
+ }
+
+ $question = new LatexSurveyElement($this->anketa, $this->export_format, 0, $this->usr_id, $export_subtype, $language);
+
+ ########
+ while ( $rowGrupe = mysqli_fetch_assoc( $sqlGrupe ) )
+ { // sprehodmo se skozi grupe ankete
+ $this->grupa = $rowGrupe['id'];
+
+ // Pogledamo prvo spremenljivko v grupi ce je v loopu
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
+ $row = mysqli_fetch_array($sql);
+
+ // ce je ima loop za parenta
+ $if_id = $this->find_parent_loop($row['id']);
+
+ if ($if_id > 0 && ($export_subtype=='q_data'||$export_subtype=='q_data_all')){ //ce je loop in (je izpis odgovorov respondentov)
+ $texLoop = '';
+ //echo "Je v loopu $if_id </br>";
+ $sql1 = sisplet_query("SELECT if_id FROM srv_loop WHERE if_id = '$if_id'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $this->loop_id = $this->findNextLoopId($row1['if_id']);
+ //echo "Loop id: ".$this->loop_id."</br>";
+ //echo " id: ".$row['id']."</br>";
+ $if = Cache::srv_if($if_id);
+ //echo "If label: ".$if['label']."</br>";
+ //echo "If : ".print_r($if)."</br>";
+ $loop_title = $if['label'];
+
+ // gremo cez vse spremenljivke v trenutnem loopu
+ while($this->loop_id != null){
+ //echo "Loop id: ".$this->loop_id."</br>";
+
+ // Izrisemo naslov loopa
+ $tex .= $this->dataPiping($loop_title);
+
+ //TODO: TUdi tu se celotna spremenljivka prenaša naprej
+ $sqlSpremenljivke = sisplet_query("SELECT id, tip, visible, sistem, variable, naslov, info, orientation, dostop FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
+ //echo "SELECT id, tip, visible, sistem, variable, naslov, info, orientation FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC "."</br>";
+
+ while ($rowSpremenljivke = mysqli_fetch_assoc($sqlSpremenljivke))
+ { // sprehodimo se skozi spremenljivke grupe
+
+ $spremenljivka = $rowSpremenljivke['id'];
+
+ if ($rowSpremenljivke['visible'] == 0 || !( ($this->admin_type <= $rowSpremenljivke['dostop'] && $this->admin_type>=0) || ($this->admin_type==-1 && $rowSpremenljivke['dostop']==4) ) ) {
+ //echo "ni admin za sprem: ".$rowSpremenljivke['id']."</br>";
+ continue;
+ }
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je vprasalnik s podatki za enega ali vse respondente
+ $preveriSpremenljivko = $this->checkSpremenljivkaData($spremenljivka, $this->loop_id);
+ }else{ //ce je prazen vprasalnik ali vprasalnik s komentarji
+ $preveriSpremenljivko = $this->checkSpremenljivka($spremenljivka);
+ }
+
+ //if ( $this->checkSpremenljivka ($spremenljivka) /*|| $this->showIf == 1*/ )
+ if ($preveriSpremenljivko)
+ { // lahko izrišemo spremenljivke
+
+ // po potrebi obarvamo vprašanja
+ //$this->pdf->SetTextColor(0);
+ if ($rowSpremenljivke['visible'] == 0)
+ {
+ if ($rowSpremenljivke['sistem'] == 1)
+ { // če je oboje = vijolčno
+ $this->pdf->SetTextColor(128,0,128);
+ }
+ else
+ { // Če je skrito = rdeče
+ $this->pdf->SetTextColor(255,0,0);
+ }
+ }
+ else if ($rowSpremenljivke['sistem'] == 1)
+ $this->pdf->SetTextColor(0,0,255);
+
+
+ // Izpis vprasalnika z rezultati
+
+ // Ce imamo kombinirano tabelo pogledamo ce prikazujemo katero od podtabel
+ if($rowSpremenljivke['tip'] == 24){
+
+ $subGrids = array();
+ $showGridMultiple = false;
+
+ // Loop po podskupinah gridov
+ $sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivka."' AND m.spr_id=s.id");
+ while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
+ if(in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0){
+ $showGridMultiple = true;
+ break;
+ }
+ }
+ }
+ // ce je nastavljen profil s filtriranimi spremenljivkami
+ if(in_array($spremenljivka,$tmp_svp_pv) || count($tmp_svp_pv) == 0 || ($rowSpremenljivke['tip'] == 24 && $showGridMultiple) || $rowSpremenljivke['tip'] == 5){
+
+ $this->currentHeight = 0;
+
+ //izpisi tekst vprasanja
+ $tex .= $question->displayQuestionText($rowSpremenljivke, $stevilcenje, $export_subtype, $preveriSpremenljivko, $this->loop_id, $export_data_type); //izpisi tekst vprasanja
+
+ //izpisi odgovore
+ $tex .= $question->displayAnswers($rowSpremenljivke, $export_subtype, $preveriSpremenljivko, $export_data_type, $this->loop_id); //izpisi odgovore
+ }
+ }
+ }
+ $this->loop_id = $this->findNextLoopId();
+
+ //ce je prazen vprasalnik, ustavi
+ if($export_subtype=='q_empty'){
+ break;
+ }
+ }
+ }
+ // Navadne spremenljivke ki niso v loopu
+ else{
+ //echo "Ni v loop-u </br>";
+ $loop_id = 'IS NULL';
+ $zaporedna = 0;
+ //TODO: Omenjen query je potrebno optimizirati in da se naprej samo prenaša ID, ki se potem v podfunkcijah kliče ustrezen query
+ // trenutno se potrebuje: id, tip, visible, sistem, variable, params
+ $sqlSpremenljivke = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
+
+ //$testniStavek = "SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC";
+ //echo "sql stavek za testiranje: ".$testniStavek."</br>";
+ while ($rowSpremenljivke = mysqli_fetch_assoc($sqlSpremenljivke)){ // sprehodimo se skozi spremenljivke grupe
+ $spremenljivka = $rowSpremenljivke['id'];
+
+ if ($rowSpremenljivke['visible'] == 0 || !( ($this->admin_type <= $rowSpremenljivke['dostop'] && $this->admin_type>=0) || ($this->admin_type==-1 && $rowSpremenljivke['dostop']==4) ) ) {
+ //echo "ni admin za sprem: ".$rowSpremenljivke['id']."</br>";
+ continue;
+ }
+
+ //echo "Ni v loop-u:".$rowSpremenljivke['tip']." </br>";
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je vprasalnik s podatki za enega ali vse respondente
+ $preveriSpremenljivko = $this->checkSpremenljivkaData($spremenljivka, $loop_id);
+ }else{ //ce je prazen vprasalnik ali vprasalnik s komentarji
+ $preveriSpremenljivko = $this->checkSpremenljivka($spremenljivka);
+ }
+
+ //if ( $this->checkSpremenljivka ($spremenljivka) /*|| $this->showIf == 1*/ )
+ if ($preveriSpremenljivko)
+ { // lahko izrišemo spremenljivke
+
+ // po potrebi obarvamo vprašanja
+ //$this->pdf->SetTextColor(0);
+ if ($rowSpremenljivke['visible'] == 0)
+ {
+ if ($rowSpremenljivke['sistem'] == 1)
+ { // če je oboje = vijolčno
+ //$this->pdf->SetTextColor(128,0,128);
+ }
+ else
+ { // Če je skrito = rdeče
+ //$this->pdf->SetTextColor(255,0,0);
+ }
+ }
+ else if ($rowSpremenljivke['sistem'] == 1)
+ //$this->pdf->SetTextColor(0,0,255);
+
+
+ // če imamo številčenje Type = 1 potem številčimo V1
+ if (SurveyInfo::getInstance()->getSurveyCountType())
+ $zaporedna++;
+ $stevilcenje = ( SurveyInfo::getInstance()->getSurveyCountType() ) ?
+ ( ( SurveyInfo::getInstance()->getSurveyCountType() == 2 ) ? $rowSpremenljivke['variable'].") " : $zaporedna.") " ) : null;
+
+ $this->currentHeight = 0;
+
+ // izpis skrcenega vprasalnika (samo pri izpisu iz urejanja)
+ if($surveyExpanded == 0 && $this->type == 1){
+ //$this->outputVprasanjeCollapsed($rowSpremenljivke, $stevilcenje);
+ }
+
+ // izpis navadnega vprasalnika
+ else{
+ //echo "while stavek za".$rowSpremenljivke['id']." </br>";
+ $tex .= $question->displayQuestionText($rowSpremenljivke, $stevilcenje, $export_subtype, $preveriSpremenljivko, $this->loop_id, $export_data_type); //izpisi tekst vprasanja
+ $tex .= $question->displayAnswers($rowSpremenljivke, $export_subtype, $preveriSpremenljivko, $export_data_type, $this->loop_id); //izpisi odgovore
+ }
+ //$this->pdf->Ln(LINE_BREAK);
+ }
+ }
+ //echo "Končni tex brez loopa: ".$tex."</br>";
+ }
+ //$tex .= $this->texBigSkip;
+ if($this->export_format == 'rtf'){
+ $tex .= $this->texBigSkip;
+ }
+ //$tex .= $texLoop;
+ //echo "Končni tex: ".$tex."</br>";
+ }
+ //echo "Končni tex: ".$tex."</br>";
+ // če izpisujemo grupo, ne izpisujemo zakljucka
+ if ( !$this->getGrupa() ){
+ if ( SurveyInfo::getInstance()->getSurveyShowConcl() && SurveyInfo::getInstance()->getSurveyConcl() )
+ { // ce obstaja footer izpisemo footer
+
+ }
+ }
+
+
+ // Izpis grafa in tabele za NIJZ na koncu dokumenta
+ global $site_domain;
+ if( ($site_domain == 'test.1ka.si' && $this->anketa == '8892') || ($site_domain == 'anketa.nijz.si' && $this->anketa == '126738') ){
+
+ // Page break
+ $tex .= '\cleardoublepage';
+
+ // Naslov "Ocena bivalnega okolja"
+ $tex .= '\begin{center} \textbf{Ocena bivalnega okolja} \end{center}';
+
+ $nijz = new SurveyNIJZ($this->anketa, $this->usr_id);
+
+ // Latex nijz slika grafa
+ $tex .= $nijz->displayRadarLatex();
+
+ // Latex nijz tabela
+ $tex .= $nijz->displayTableLatex();
+ }
+
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis praznega vprasalnika in vprasalnika z odgovori enega respondenta - konec
+
+
+ #funkcija, ki skrbi za izpis vseh odgovorov (vsi respondenti -> max 300) //po outputAllResults() iz class.pdfIzvozResults.php
+ public function displayAllSurveys($export_subtype='', $export_format='', $export_data_type=''){
+ global $lang, $site_url;
+ $tex = '';
+ $izbranStatusProfile = SurveyStatusProfiles :: getStatusAsQueryString();
+
+ $sqluString = "SELECT id, last_status, lurker, recnum FROM srv_user WHERE ank_id = '".$this->anketa."' ".$izbranStatusProfile." AND deleted='0' AND preview='0' ORDER BY recnum";
+ //echo $sqluString;
+ $sqlu = sisplet_query($sqluString);
+
+ $numOfUsers = mysqli_num_rows($sqlu); //stevilo respondentov
+
+ if($numOfUsers > 300){
+ $tex .= $lang['srv_export_all_respondent_data_error'].' ('.$numOfUsers.').';
+ }
+ else{
+ //za vsak user oz respondent
+ while($rowu = mysqli_fetch_array($sqlu)){
+ //belezenje statusa
+ switch($rowu['last_status']){
+ case '0':
+ $status = $lang['srv_userstatus_0'];
+ break;
+ case '1':
+ $status = $lang['srv_userstatus_1'];
+ break;
+ case '2':
+ $status = $lang['srv_userstatus_2'];
+ break;
+ case '3':
+ $status = $lang['srv_userstatus_3'];
+ break;
+ case '4':
+ $status = $lang['srv_userstatus_4'];
+ break;
+ case '5':
+ $status = $lang['srv_userstatus_5'];
+ break;
+ case '6':
+ $status = $lang['srv_userstatus_6'];
+ $status .= ($rowu['lurker'] == '1') ? ' - lurker' : '';
+ break;
+ }
+
+ #prenos odgovorov vsakega respondenta na novo stran, če je to potrebno
+ //if($this->exportDataPageBreak == 1){ //ce mora vsak respondent imeti svoje odgovore na svoji strani
+ if($this->exportDataPageBreak == 1 && $export_format == 'pdf'){ //ce mora vsak respondent imeti svoje odgovore na svoji strani in je pdf izvoz, saj za rtf pagebreak ne deluje
+ $tex .= $this->texPageBreak;
+ }
+ #prenos odgovorov vsakega respondenta na novo stran, če je to potrebno - konec
+
+ //$this->export_data_show_recnum = 1;
+ #izpis statusa respondenta in anketiranja
+ if($this->export_data_show_recnum == 1){ //ce je potrebno pokazati stevilko respondenta
+ $tex .= '{\\Large Status '.$rowu['last_status'].' - '.$status.' (Recnum '.$rowu['recnum'].')} '.$this->texNewLine.' \\par ';
+ }else{
+ $tex .= '{\\Large Status '.$rowu['last_status'].' - '.$status.$this->texNewLine.' \\par}';
+ }
+ #izpis statusa respondenta in anketiranja - konec
+
+
+ #izpis odgovorov posameznega userja
+ $this->usr_id = $rowu['id'];
+
+ #za pridobitev jezika respondenta
+ if ($this->usr_id != '') {
+ $sqlL = sisplet_query("SELECT language FROM srv_user WHERE id = '$this->usr_id ' ");
+ $rowL = mysqli_fetch_array($sqlL);
+ $language = $rowL['language'];
+ }
+ #za pridobitev jezika respondenta - konec
+
+ $tex .= $this->displaySurvey($export_subtype, $export_data_type, $language);
+ #izpis odgovorov posameznega userja - konec
+
+ }
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis vseh odgovorov (vsi respondenti -> max 300) - konec
+
+
+ #funkcija, ki skrbi za izpis praznega vprasalnika s komentarji //po outputCommentaries() iz class.pdfIzvoz.php
+ public function displaySurveyCommentaries($export_subtype='', $export_data_type=''){
+
+ global $lang;
+ global $site_url;
+ global $admin_type;
+ global $global_user_id;
+ $texBigSkip = '\bigskip';
+ $tex = '';
+
+ $this->commentType = (isset($_GET['only_unresolved'])) ? $_GET['only_unresolved'] : 1;
+
+ $f = new Forum;
+ $c = 0;
+
+ $b = new Branching($this->anketa);
+
+ $rowi = SurveyInfo::getInstance()->getSurveyRow();
+
+ SurveySetting::getInstance()->Init($this->anketa);
+ $question_resp_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_viewadminonly');
+ $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly');
+ $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor');
+ $sortpostorder = SurveySetting::getInstance()->getSurveyMiscSetting('sortpostorder');
+ $question_note_view = SurveySetting::getInstance()->getSurveyMiscSetting('question_note_view');
+ $addfieldposition = SurveySetting::getInstance()->getSurveyMiscSetting('addfieldposition');
+ $commentmarks = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks');
+ $commentmarks_who = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks_who');
+
+ $sqlString = "SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa."' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC";
+ $sql = sisplet_query($sqlString);
+
+ $question = new LatexSurveyElement($this->anketa, $this->export_format, 0, 0, 0);
+
+
+ if ( mysqli_num_rows($sql) > 0 && ( (int)$question_resp_comment_viewadminonly + (int)$question_comment_viewadminonly ) > 0 ) {
+
+ while ($row = mysqli_fetch_array($sql)) {
+
+ $sql1 = sisplet_query("SELECT thread, note FROM srv_spremenljivka WHERE id = '$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $orderby = $sortpostorder == 1 ? 'DESC' : 'ASC' ;
+ $tid = $row1['thread'];
+
+ $only_unresolved = " ";
+ $only_unresolved2 = " ";
+
+ if ($this->commentType == 1) $only_unresolved = " AND ocena <= 1 ";
+ if ($this->commentType == 1) $only_unresolved2 = " AND text2 <= 1 ";
+
+ if ($this->commentType == 2) $only_unresolved = " AND ocena = 0 ";
+ if ($this->commentType == 2) $only_unresolved2 = " AND text2 = 0 ";
+
+ if ($this->commentType == 3) $only_unresolved = " AND ocena = 1 ";
+ if ($this->commentType == 3) $only_unresolved2 = " AND text2 = 1 ";
+
+ if ($this->commentType == 4) $only_unresolved = " AND ocena = 2 ";
+ if ($this->commentType == 4) $only_unresolved2 = " AND text2 = 2 ";
+
+ if ($this->commentType == 5) $only_unresolved = " AND ocena = 3 ";
+ if ($this->commentType == 5) $only_unresolved2 = " AND text2 = 3 ";
+
+
+ $tema_vsebuje = substr($lang['srv_forum_intro'],0,10); // da ne prikazujemo 1. default sporocila
+
+ if ($admin_type <= $question_comment_viewadminonly) { // vidi vse komentarje
+ $sqlt = sisplet_query("SELECT uid, time, vsebina FROM post WHERE vsebina NOT LIKE '%{$tema_vsebuje}%' AND tid='$tid' $only_unresolved ORDER BY time $orderby, id $orderby");
+
+ } elseif ($question_comment_viewauthor==1) { // vidi samo svoje komentarje
+ $sqlt = sisplet_query("SELECT uid, time, vsebina FROM post WHERE vsebina NOT LIKE '%{$tema_vsebuje}%' AND tid='$tid' $only_unresolved AND uid='$global_user_id' ORDER BY time $orderby, id $orderby");
+
+ } else { // ne vidi nobenih komentarjev
+ $sqlt = sisplet_query("SELECT uid, time, vsebina FROM post WHERE 1=0");
+ }
+
+ $sql2 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_text".$this->db_table." WHERE spr_id='0' AND vre_id='$row[id]' $only_unresolved2");
+ $row2 = mysqli_fetch_array($sql2);
+
+ if ( mysqli_num_rows($sqlt) > 0 || $row2['count'] > 0 || $row1['note'] != '') {
+ $c++;
+ $preveriSpremenljivko = 0; //ni potrebno
+ $tex .= $question->displayQuestionText($row, $stevilcenje, $export_subtype, $preveriSpremenljivko, null, $export_data_type); //izpisi tekst vprasanja
+ $tex .= $question->displayAnswers($row, $export_subtype, $preveriSpremenljivko, $export_data_type, null); //izpisi odgovore
+
+ if ($admin_type <= $question_note_view || $question_note_view == '') {
+
+ if ($row1['note'] != '') {
+
+ //$tex .= $texNewLine;
+ $tex .= $this->texNewLine;
+ $tex .= $question->encodeText($lang['hour_comment']);
+
+ //$tex .= $texNewLine;
+ $tex .= $this->texNewLine;
+ $tex .= $question->encodeText($row1['note']);
+ }
+ }
+
+ // komentarji na vprasanje
+ if ($row1['thread'] > 0) {
+
+ if (mysqli_num_rows($sqlt) > 0) {
+ //$tex .= $texNewLine;
+ $tex .= $this->texNewLine;
+ //$tex .= '\textbf{'.$question->encodeText($lang['srv_admin_comment']).'}'; //izpis naslova komentarjev
+ $tex .= '\textcolor{komentar}{\textbf{'.$question->encodeText($lang['srv_admin_comment']).'}}'; //izpis naslova komentarjev
+ //$tex .= '\textcolor{komentar}{\textbf{'.$question->encodeText($lang['srv_admin_comment']).'}}'; //izpis naslova komentarjev
+ $tex .= '\\\\';
+
+ $i = 0;
+ while ($rowt = mysqli_fetch_array($sqlt)) {
+
+ $tex .= '\textbf{'.$question->encodeText($f->user($rowt['uid'])).'}'; //izpis imena trenutnega urednika
+
+ $tex .= $question->encodeText(' ('.$f->datetime1($rowt['time']).'):'); //izpis datuma komentarja
+
+ $tex .= '\\\\';
+
+ // Popravimo vsebino ce imamo replike
+ $vsebina = $rowt['vsebina'];
+ $odgovori = explode("<blockquote style=\"margin-left:20px\">", $vsebina);
+
+ $tex .= $question->encodeText($odgovori[0]); //izpis komentarja
+
+ unset($odgovori[0]);
+ foreach($odgovori as $odgovor){ //izpis replik
+ $odgovor = explode('<br />', $odgovor);
+ $avtor = explode('</b> ', $odgovor[0]);
+
+ $tex .= '\\\\';
+ $tex .= '\forceindent'; //da je indented
+ $tex .= '\textbf{'.$question->encodeText($avtor[0]).'} '; //avtor replike
+ $tex .= $question->encodeText($avtor[1]); //izpis datuma replike
+
+ $tex .= '\\\\';
+ $tex .= '\forceindent '; //da je indented
+ $tex .= $question->encodeText($odgovor[1]); //izpis replike
+ }
+
+ // Crta
+ $tex .= '\\\\';
+ $tex .= '\noindent\rule{0.9\textwidth}{0.5pt} ';
+ $tex .= '\\\\';
+ }
+ }
+ }
+
+ // komentarji respondentov
+ if ($row2['count'] > 0) {
+
+ if ($admin_type <= $question_resp_comment_viewadminonly) {
+
+/* $this->pdf->Ln(3);
+ $this->pdf->setFont('','B', 10);
+ $this->pdf->Write (0, $this->encodeText($lang['srv_repondent_comment']), '', 0, 'l', 1, 1); */
+ //$tex .= $texNewLine;
+ $tex .= $this->texNewLine;
+ //$tex .= '\textbf{'.$question->encodeText($lang['srv_repondent_comment']).'}'; //izpisa naslova komentarjev
+ $tex .= '\textcolor{komentar}{\textbf{'.$question->encodeText($lang['srv_repondent_comment']).'}}'; //izpisa naslova komentarjev
+ $tex .= '\\\\';
+
+ //$this->pdf->Ln(3);
+
+ if ($this->commentType == 1) $only_unresolved = " AND d.text2 <= 1 "; else $only_unresolved = " ";
+
+ $sqlt = sisplet_query("SELECT d.text AS text, u.time_edit AS time_edit FROM srv_data_text".$this->db_table." d, srv_user u WHERE d.spr_id='0' AND d.vre_id='$row[id]' AND u.id=d.usr_id $only_unresolved2 ORDER BY d.id ASC");
+ if (!$sqlt) echo mysqli_error($GLOBALS['connect_db']);
+ while ($rowt = mysqli_fetch_array($sqlt)) {
+
+/* $this->pdf->setFont('','', 10);
+ $this->pdf->Write(0, $this->encodeText($f->datetime1($rowt['time_edit']).':'), '', 0, 'l', 1, 1);*/
+
+ $tex .= $question->encodeText($f->datetime1($rowt['time_edit']).':'); //izpis datuma komentarja
+
+ $tex .= '\\\\';
+
+ //$this->pdf->MultiCell(100, 0, $this->encodeText($rowt['text']),0,'L',0,1,0,0,true,0);
+ $tex .= $question->encodeText($rowt['text']); //izpis komentarja respondenta
+
+ $tex .= '\\\\';
+
+ // Crta
+ $tex .= '\noindent\rule{0.9\textwidth}{0.5pt} ';
+ $tex .= '\\\\';
+
+
+ }
+ }
+ }
+
+ //$this->pdf->Ln(LINE_BREAK);
+ $tex .= $texBigSkip;
+ $tex .= $texBigSkip;
+ }
+ }
+
+
+ }
+
+
+ return $tex;
+ }
+
+ function getGrupa() {return $this->grupa;}
+
+
+ /**
+ * @desc preveri ali je spremenljivka vidna (zaradi branchinga)
+ */
+ function checkSpremenljivka ($spremenljivka=null) {
+
+ $row = sisplet_query("SELECT visible FROM srv_spremenljivka WHERE id = '".$spremenljivka."'", "obj");
+ if ($row->visible == 0) {
+ return false;
+ }
+
+ //TODO: Omenjen del kode je nepotreben, ker vedno vrne true
+ //$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 false;*/
+
+ return true;
+ }
+
+ /**
+ * @desc preveri ali je spremenljivka vidna (zaradi branchinga), ko je q_data ali q_data_all
+ */
+ //function checkSpremenljivkaData ($spremenljivka, $gridMultiple=false) {
+ function checkSpremenljivkaData ($spremenljivka=null, $loop_id_raw=null, $gridMultiple=false) {
+
+ $loop_id = $loop_id_raw == 'IS NULL' ? " IS NULL" : " = '".$loop_id_raw."'";
+
+ //$row = sisplet_query("SELECT id, visible, dostop, tip, enota FROM srv_spremenljivka WHERE id = '".$spremenljivka."'", "array");
+ $sql = sisplet_query("SELECT id, visible, dostop, tip, enota FROM srv_spremenljivka WHERE id = '".$spremenljivka."'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ // Ce vprasanje ni vidno ali ce uporabnik nima dostopa do vprasanja
+ if ($row['visible'] == 0 || !( ($this->admin_type <= $row['dostop'] && $this->admin_type>=0) || ($this->admin_type==-1 && $row['dostop']==4) ) ) {
+ return false;
+ }
+
+ // Kalklulacije in kvote ne prikazujemo
+ if($row['tip'] == 22 || $row['tip'] == 25) {
+ return false;
+ }
+
+ // Preverjamo ce je vprasanje prazno in ce preskakujemo prazne
+ if($this->skipEmpty==1 && !$gridMultiple){
+
+ $isEmpty = true;
+ //echo "isEmpty: ".$isEmpty."</br>";
+ switch ( $row['tip'] ){
+ case 1: //radio
+ case 2: //check
+ case 3: //select -> radio
+ //$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$row[id]' AND usr_id='".$this->usr_id."' AND vre_id!='-2'");
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$row[id]' AND usr_id='".$this->usr_id."' AND vre_id>'0' AND loop_id $loop_id ";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0){
+ $isEmpty = false;
+ }
+ break;
+
+ case 6: //multigrid
+ case 16:// multicheckbox
+ case 19:// multitext
+ case 20:// multinumber
+ if($row['tip'] == 6 && $row['enota'] != 3){
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->usr_id."' AND loop_id $loop_id";
+ }
+ elseif($row['tip'] == 16 || ($row['tip'] == 6 && $row['enota'] == 3)){
+ //$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->usr_id."'");
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->usr_id."' AND loop_id $loop_id";
+ }
+ else{
+ //$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->usr_id."'");
+ $sqlUserAnswerString ="SELECT COUNT(*) AS st FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->usr_id."' AND loop_id $loop_id";
+ }
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ //echo "stevilo podatkov: ".mysqli_num_rows($sqlUserAnswer)."</br>";
+ if($sqlUserAnswer->st > 0){
+ $isEmpty = false;
+ }
+ break;
+
+ case 7: //number
+ case 8: //datum
+ case 18: //vsota
+ case 21: //besedilo*
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_text".$this->db_table." WHERE spr_id='".$row['id']."' AND usr_id='".$this->usr_id."' AND loop_id $loop_id";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0)
+ $isEmpty = false;
+ break;
+
+ case 4: //besedilo*
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_text".$this->db_table." WHERE spr_id='".$row['id']."' AND usr_id='".$this->usr_id."' AND loop_id $loop_id";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0)
+ $isEmpty = false;
+ break;
+
+ case 17: //ranking
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_rating WHERE spr_id=".$row['id']." AND usr_id='".$this->usr_id."' AND loop_id $loop_id";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0)
+ $isEmpty = false;
+ break;
+
+ case 24: //mesan multigrid
+ // loop po podskupinah gridov
+ $sqlSubGrid = sisplet_query("SELECT m.spr_id AS spr_id, s.tip AS tip, s.enota FROM srv_grid_multiple AS m LEFT JOIN srv_spremenljivka AS s ON m.spr_id=s.id WHERE m.parent='".$spremenljivka."'");
+ while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
+ if($rowSubGrid['tip'] == 6){
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->usr_id."' AND loop_id $loop_id";
+ }
+ elseif($rowSubGrid['tip'] == 16){
+ $sqlUserAnswerString ="SELECT COUNT(*) AS st FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->usr_id."' AND loop_id $loop_id";
+ }
+ else{
+ $sqlUserAnswerString = "SELECT COUNT(*) AS st FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->usr_id."' AND loop_id $loop_id";
+ }
+
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0){
+ $isEmpty = false;
+ break;
+ }
+ }
+ break;
+
+ case 5: //nagovor
+ // Ce je nagovor v loopu, ga prikazemo
+ if($this->loop_id != null)
+ $isEmpty = false;
+ break;
+
+ case 26: //lokacija
+ //za podtip izberi lokacijo je treba preverjat posebej, ker se vrstica pri userju vedno kreira ampak brez odgovora
+ if($row['enota'] == 3){
+ $qu = "SELECT count(*) as cnt FROM srv_data_map WHERE spr_id='".$row['id']."' AND usr_id='$this->usr_id' AND loop_id $loop_id AND (text NOT REGEXP '^[+\-]?[0-9]+$' OR text>=0);";
+ $sql = sisplet_query($qu, 'obj');
+ if($sql->cnt > 0)
+ $isEmpty = false;
+ }
+ else{
+ //$sqlUserAnswerString ="SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='".$row['id']."' AND usr_id='".$this->usr_id."' ";
+ $sqlUserAnswerString ="SELECT COUNT(*) AS st FROM srv_data_map WHERE spr_id='".$row['id']."' AND usr_id='".$this->usr_id."' AND loop_id $loop_id";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0)
+ $isEmpty = false;
+ }
+ break;
+
+ case 27: //heatmap
+ //$sqlUserAnswerString ="SELECT lat, lng, address, text FROM srv_data_heatmap WHERE spr_id='".$row['id']."' AND usr_id='".$this->usr_id."' ";
+ $sqlUserAnswerString ="SELECT COUNT(*) AS st FROM srv_data_heatmap WHERE spr_id='".$row['id']."' AND usr_id='".$this->usr_id."' AND loop_id $loop_id";
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString, "obj");
+ if($sqlUserAnswer->st > 0)
+ $isEmpty = false;
+ break;
+
+ default:
+ $isEmpty = false;
+ //$isEmpty = true;
+ break;
+ }
+ //echo "isEmpty na koncu: ".$isEmpty."</br>";
+ if($isEmpty == true){
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ function displayIf($if=null){
+ global $lang;
+ //echo "</br> displayIf funkcija </br> ";
+ $sql_if_string = "SELECT tip, number FROM srv_if WHERE id = '$if'";
+ //echo "sql_if_string: ".$sql_if_string." </br>";
+ //$sql_if = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'");
+ $sql_if = sisplet_query($sql_if_string);
+ $row_if = mysqli_fetch_array($sql_if);
+ //echo "tip: ".$row_if['tip']." </br>";
+
+ // Blok
+ if($row_if['tip'] == 1)
+ $output = strtoupper($lang['srv_block']).' ';
+ // Loop
+ elseif($row_if['tip'] == 2)
+ $output = strtoupper($lang['srv_loop']).' ';
+ // IF
+ else
+ $output = 'IF ';
+
+ $output .= '('.$row_if['number'].') ';
+
+ $sql = Cache::srv_condition($if);
+
+ $bracket = 0;
+ $i = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($i++ != 0)
+ if ($row['conjunction'] == 0)
+ $output .= ' and ';
+ else
+ $output .= ' or ';
+
+ if ($row['negation'] == 1)
+ $output .= ' NOT ';
+
+ for ($i=1; $i<=$row['left_bracket']; $i++)
+ $output .= ' ( ';
+
+ // obicajne spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ $row2 = Cache::srv_spremenljivka($row['spr_id']);
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+ $row1 = Cache::srv_spremenljivka($row['spr_id']);
+ // multigrid
+ } elseif ($row['vre_id'] > 0) {
+ $sql1 = sisplet_query("SELECT variable FROM srv_vrednost WHERE id = '$row[vre_id]'");
+ $row1 = mysqli_fetch_array($sql1);
+ } else
+ $row1 = null;
+
+ $output .= $row1['variable'];
+
+ // radio, checkbox, dropdown in multigrid
+ if (($row2['tip'] <= 3 || $row2['tip'] == 6) && ($row['spr_id'] || $row['vre_id'])) {
+
+ if ($row['operator'] == 0)
+ $output .= ' = ';
+ else
+ $output .= ' != ';
+
+ $output .= '[';
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+ $sql2 = sisplet_query("SELECT v.variable AS variable FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id");
+
+ $j = 0;
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ if ($j++ != 0) $output .= ', ';
+ $output .= $row2['variable'];
+ }
+ // multigrid
+ } elseif ($row['vre_id'] > 0) {
+ $sql2 = sisplet_query("SELECT g.variable AS variable FROM srv_condition_grid c, srv_grid g WHERE c.cond_id='$row[id]' AND c.grd_id=g.id AND g.spr_id='$row[spr_id]'");
+
+ $j = 0;
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ if ($j++ != 0) $output .= ', ';
+ $output .= $row2['variable'];
+ }
+ }
+
+ $output .= ']';
+
+ // textbox in nubmer mata drugacne pogoje in opcije
+ } elseif ($row2['tip'] == 4 ||$row2['tip'] == 21 || $row2['tip'] == 7 || $row2['tip'] == 22) {
+
+ if ($row['operator'] == 0)
+ $output .= ' = ';
+ elseif ($row['operator'] == 1)
+ $output .= ' <> ';
+ elseif ($row['operator'] == 2)
+ $output .= ' < ';
+ elseif ($row['operator'] == 3)
+ $output .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $output .= ' > ';
+ elseif ($row['operator'] == 5)
+ $output .= ' >= ';
+
+ $output .= '\''.$row['text'].'\'';
+
+ }
+
+ // recnum
+ } elseif ($row['spr_id'] == -1) {
+
+ $output .= 'mod(recnum, '.$row['modul'].') = '.$row['ostanek'];
+
+ }
+
+ for ($i=1; $i<=$row['right_bracket']; $i++)
+ $output .= ' ) ';
+ }
+
+ if ($row_if['label'] != '') {
+ $output .= ' (';
+ $output .= ' '.$row_if['label'].' ';
+ $output .= ') ';
+ }
+
+ return $output;
+ }
+
+ /* poisce, ce ima podani element parenta, ki je loop
+ *
+ */
+ function find_parent_loop ($element_spr=null, $element_if=0) {
+
+ //$sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='".$this->anketa['id']."'");
+ $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='".$this->anketa."'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ if ($row['parent'] == 0) return 0;
+
+ $count = sisplet_query("SELECT COUNT(*) AS st FROM srv_if WHERE id = '$row[parent]' AND tip = '2'", "obj");
+ if ($count->st > 0) {
+ return $row['parent'];
+ }else {
+ return $this->find_parent_loop(0, $row['parent']);
+ }
+ }
+
+ /**
+ * poisce naslednjo vre_id v loopu
+ *
+ */
+ function findNextLoopId ($if_id=0) {
+ if ($if_id == 0) {
+ $sql = sisplet_query("SELECT if_id FROM srv_loop_data WHERE id='$this->loop_id'");
+ $row = mysqli_fetch_array($sql);
+ $if_id = $row['if_id'];
+ $loop_id = $this->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);
+ //echo "spr tip: ".$spr['tip']."</br>";
+
+
+ if ($spr['tip'] == 2 || $spr['tip'] == 3 || $spr['tip'] == 9) {
+ $data_vrednost = array();
+ if($spr['tip'] == 9){
+ if($this->usr_id){
+ $sql1String = "SELECT vre_id FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->usr_id."' ";
+ }else{
+ $sql1String = "SELECT vre_id FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' ";
+ }
+ }
+ else{
+ if($this->usr_id){
+ $sql1String = "SELECT vre_id FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->usr_id."'";
+ }else{
+ $sql1String = "SELECT vre_id FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spr_id' ";
+ }
+ }
+ //echo "sql1String: ".$sql1String."</br>";
+ $sql1 = sisplet_query($sql1String);
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $data_vrednost[$row1['vre_id']] = 1;
+ }
+
+ $vre_id = '';
+ $i = 1;
+ //$sql = sisplet_query("SELECT * FROM srv_loop_vre WHERE if_id='$if_id'");
+
+ $sql = sisplet_query("SELECT lv.vre_id AS vre_id, lv.tip AS 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;
+
+ //Stari query srv_vrednost se ni nikjer uporabljal
+ //$sql = sisplet_query("SELECT l.* 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");
+ //Problematicni sql, ker ocitno tale zadeva z obj ne dela najbolje
+ //$sql = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id' AND vre_id IN ($vre_id) ORDER BY id ASC", "obj");
+
+ $sqlTestString = "SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id' AND vre_id IN ($vre_id) ORDER BY id ASC";
+ //echo "sqlString: ".$sqlTestString."</br>";
+ $sqlTest = sisplet_query($sqlTestString);
+ $rowTest = mysqli_fetch_array($sqlTest);
+
+ if (count($sql) > 0)
+ return $rowTest['id'];
+ //return $sql->id;
+ else
+ return null;
+
+ // number
+ } elseif ($spr['tip'] == 7) {
+
+ //$sql1 = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->getUserId()."'");
+ $sql1String = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->usr_id."'";
+ //echo "sql1String: ".$sql1String."</br>";
+ $sql1 = sisplet_query($sql1String);
+ $row1 = mysqli_fetch_array($sql1);
+
+ $num = (int)$row1['text'];
+
+ //$countLoopManjsi = sisplet_query("SELECT COUNT(*) AS st FROM srv_loop_data WHERE if_id='$if_id' AND id <= '$loop_id'", "obj");
+ $countLoopManjsiString = "SELECT COUNT(*) AS st FROM srv_loop_data WHERE if_id='$if_id' AND id <= '$loop_id'";
+ $countLoopManjsi = sisplet_query($countLoopManjsiString);
+ $rowcountLoopManjsi = mysqli_fetch_array($countLoopManjsi);
+ //echo "countLoopManjsiString: ".$countLoopManjsiString."</br>";
+ //if ($countLoopManjsi->st >= $num || ($countLoopManjsi->st >= $max && $max>0)) {
+ if ($rowcountLoopManjsi['st'] >= $num || ($rowcountLoopManjsi['st'] >= $max && $max>0)) {
+ return null;
+ }
+
+ //$loopVecji = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id'", "obj");
+ $loopVecjiString = "SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id'";
+ //echo "loopVecjiString: ".$loopVecjiString."</br>";
+ $loopVecji = sisplet_query($loopVecjiString);
+ $rowcountLoopVecji = mysqli_fetch_array($loopVecji);
+ //if (count($loopVecji) > 0) {
+ if (mysqli_num_rows($loopVecji) > 0) {
+ //return $loopVecji->id;
+ return $rowcountLoopVecji['id'];
+ }else {
+ return null;
+ }
+
+ }
+ }
+
+ /**
+ * @desc V podanem stringu poisce spremenljivke in jih spajpa z vrednostmi
+ */
+ function dataPiping ($text='') {
+ Common::getInstance()->Init($this->anketa);
+ return Common::getInstance()->dataPiping($text, $this->usr_id, $this->loop_id);
+ }
+
+ #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno
+ function encodeTextHere($text='', $vre_id=0){
+ global $site_path, $lang;
+
+ //echo "Encoding ".$text."</br>";
+ //echo "vre_id: ".$vre_id."</br>";
+
+ $this->path2UploadedImages = $site_path.'uploadi/editor/';
+ if($text == ''){ //ce ni teksta, vrni se
+ return;
+ }
+ $textOrig = $text;
+ $findme = '<br />';
+ $findmeLength = strlen($findme);
+ $findImg = '<img';
+ $findImgLength = strlen($findImg);
+ $findUl = '<ul';
+ $findUlLength = strlen($findUl);
+ $findLi = '<li';
+
+ $findPar = '<p>';
+
+ $pos = strpos($text, $findme);
+ $posImg = strpos($text, $findImg);
+ $posUl = strpos($text, $findUl);
+ $posLi = strpos($text, $findLi);
+ $posPar = strpos($text, $findPar);
+
+
+ //ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
+ $text = str_replace('\\','\textbackslash{} ',$text);
+ //$text = str_replace('{','\{',$text);
+ //$text = str_replace('}','\}',$text);
+ $text = str_replace('$','\$ ',$text);
+ $text = str_replace('#','\# ',$text);
+ $text = str_replace('%','\% ',$text);
+ $text = str_replace('€','\euro',$text);
+ $text = str_replace('^','\textasciicircum{} ',$text);
+ $text = str_replace('_','\_ ',$text);
+ $text = str_replace('~','\textasciitilde{} ',$text);
+ $text = str_replace('&amp;','\&',$text);
+ //$text = str_replace('&lt;','\textless ',$text);
+ $text = str_replace('&lt;','\textless',$text);
+ //$text = str_replace('&gt;','\textgreater ',$text);
+ $text = str_replace('&gt;','\textgreater',$text);
+ //ureditev posebnih karakterjev za Latex - konec
+
+ //ureditev preureditve html kode ul in li v latex itemize
+ if($posUl !== false){
+ //echo "text prej: ".$text."</br>";
+ $numOfUl = substr_count($text, $findUl); //stevilo '<ul' v tekstu
+ //echo "numOfUl ".$numOfUl."</br>";
+ ######################
+ //if($numOfUl!=0){
+ if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
+ $text = str_replace('<ul>','\begin{itemize} ', $text);
+ $text = str_replace('<li>','\item ', $text);
+ $text = str_replace('</ul>','\end{itemize} ', $text);
+ }
+ //echo "prazno v html: ".strpos($text, '\r')."</br>";
+ //echo "text potem: ".$text."</br>";
+ ######################
+ }
+ //ureditev preureditve html kode ul in li v latex itemize - konec
+
+ if($posPar !== false){ //ce je kaksen html tag <p>, dodaj prazno vrstico oz. break
+ if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
+ $divider = ' ';
+ }else{
+ $divider = ' \\ \\\\ ';
+ }
+ //$text = str_replace('<p>',' ', $text);
+ //$text = str_replace('<p>',' \break ', $text);
+ //$text = str_replace('<p>',' \\\\ ', $text);
+
+ $text = str_replace('<p>', $divider, $text);
+ }
+
+ if($pos === false && $posImg === false) { //v tekstu ni br in img
+
+ $text = preg_replace("/(\R){2,}/", "$1", $text);
+ return strip_tags($text);
+ }else { //v tekstu sta prisotna br ali img
+ $text2Return = ''; //tekst ki bo vrnjen
+
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
+ if($pos !== false){
+ $pos = strpos($text, $findme);
+ $numOfBr = substr_count($text, $findme); //stevilo '<br />' v tekstu
+ for($i=0; $i<$numOfBr; $i++){
+ if($i == 0){ //ce je prvi najdeni '<br />'
+ $textPrej = substr($text, 0, $pos);
+ $textPotem = substr($text, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ //$text2Return .= $textPrej.' \break '.$textPotem;
+ $text2Return .= $textPrej.' \\\\ '.$textPotem;
+ }else{
+ //$text2Return .= $textPrej.' \break ';
+ $text2Return .= $textPrej.' \\\\ ';
+ }
+ }else{ //drugace
+ $pos = strpos($textPotem, $findme);
+ $textPrej = substr($textPotem, 0, $pos);
+ $textPotem = substr($textPotem, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ //$text2Return .= $textPrej.' \break '.$textPotem;
+ $text2Return .= $textPrej.' \\\\ '.$textPotem;
+ }else{
+ //$text2Return .= $textPrej.' \break ';
+ $text2Return .= $textPrej.' \\\\ ';
+ }
+ }
+ }
+ $text = $text2Return;
+ }
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
+ //echo "text potem: ".$text."</br>";
+ $text = preg_replace("/(\R){2,}/", "$1", $text);
+ return strip_tags($text); //vrni tekst brez html tag-ov
+ }
+ }
+ #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno - konec
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/class.LatexSurveyElement.php b/admin/survey/export/latexclasses/class.LatexSurveyElement.php
new file mode 100644
index 0000000..587fb3a
--- /dev/null
+++ b/admin/survey/export/latexclasses/class.LatexSurveyElement.php
@@ -0,0 +1,2372 @@
+<?php
+
+/**
+ *
+ * Class ki skrbi za izris posameznega vprasanja za vprašalnik
+ *
+ *
+ */
+
+
+include('../../vendor/autoload.php');
+
+define("MAX_STRING_LENGTH", 90);
+define("LINE_BREAK_AT", '7 cm');
+define("RADIO_BTN_SIZE", 0.13);
+define("CHCK_BTN_SIZE", 0.13);
+define("PIC_SIZE_ANS", "\includegraphics[width=3cm]"); //slika dolocene sirine
+define("DROPDOWN_SIZE", 0.8);
+define("VAS_SIZE", 0.04); //VAS_SIZE
+
+
+class LatexSurveyElement{
+
+ public $anketa; // ID ankete
+ public static $spremenljivka;
+ public $spremenljivkaParams;
+ public $stevilcenje;
+ public $showIf = 0; // izpis if-ov
+ public $numbering = 0; // ostevillcevanje vprasanj
+ public $texNewLine = '\\\\ ';
+ //public $texNewLine = '\newline ';
+ public $export_format;
+ public $fillablePdf;
+ public $questionText;
+ protected $usr_id = null; // id userja ki je odgovarjal (na katerega so vezani podatki)
+ protected $db_table = '';
+ protected $loop_id = null; // id trenutnega loopa ce jih imamo
+ protected $userAnswer = array();
+ protected $texBigSkip = '\bigskip';
+ //protected $userDataPresent = array();
+ //protected $userDataPresent = 0;
+
+ protected $skipEmpty = 0; // izpusti vprasanja brez odgovora
+ protected $skipEmptySub = 0; // izpusti podvprasanja brez odgovora
+ protected $path2Images;
+ protected $path2UploadedImages;
+ protected $language;
+ protected $prevod;
+ protected $admin_type;
+ protected $variableName;
+
+
+ function __construct($anketa=null, $export_format='', $fillablePdf=null, $usr_id=null, $export_subtype='', $language=null){
+ global $site_path, $global_user_id, $admin_type, $lang;
+
+ $this->anketa = $anketa;
+ $this->path2Images = $site_path.'admin/survey/export/latexclasses/textemp/images/';
+ $this->path2UploadedImages = $site_path.'uploadi/editor/';
+ $this->path2UrlImages = $site_path.'uploadi/editor/';
+
+ $this->admin_type = $admin_type;
+
+/* $this->spremenljivka = $spremenljivka;
+ $this->stevilcenje = $stevilcenje; */
+ if($export_subtype=='q_empty'||$export_subtype=='q_comment'){
+ $this->showIf = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_show_if');
+ $this->numbering = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_numbering');
+ }elseif($export_subtype=='q_data'||$export_subtype=='q_data_all'){
+ $this->showIf = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_if');
+ $this->numbering = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_numbering');
+ $this->skipEmpty = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty');
+ $this->skipEmptySub = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty_sub');
+ }
+
+ $this->export_format = $export_format;
+ $this->fillablePdf = $fillablePdf;
+
+ //$this->usr_id = $_GET['usr_id'];
+ $this->usr_id = $usr_id;
+
+ if ($this->usr_id != '') {
+ $sqlL = sisplet_query("SELECT language FROM srv_user WHERE id = '$this->usr_id ' AND ank_id='$this->anketa' ");
+ $rowL = mysqli_fetch_array($sqlL);
+ $this->language = $rowL['language'];
+ }
+
+ //preverjanje, ali je prevod
+ if(isset($_GET['language'])){
+ $this->language = $_GET['language'];
+ $this->prevod = 1;
+ }else{
+ $this->prevod = 0;
+ }
+ //preverjanje, ali je prevod - konec
+
+ //if($language!=-1){ //ce ni default jezik, ampak je prevod
+ if($this->prevod){ //ce ni default jezik, ampak je prevod
+ $this->language = $language;
+ }
+
+ if ( SurveyInfo::getInstance()->SurveyInit($anketa))
+ {
+ SurveyUserSetting::getInstance()->Init($anketa, $global_user_id);
+
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
+ $this->db_table = '_active';
+ }
+ else{
+ return false;
+ }
+
+ }
+
+
+ #funkcija, ki pripravi latex kodo za prikazovanje besedila vprasanja ############################################################################
+ public function displayQuestionText($spremenljivke=null, $zaporedna=null, $export_subtype='', $preveriSpremenljivko=null, $loop_id=null, $export_data_type=''){
+ $tex = '';
+ $userDataPresent = null; //dodal definicijo spremenljivke zaradi intellisense napake
+ //echo "Funkcija displayQuestionText </br>";
+ self::$spremenljivka = $spremenljivke['id'];
+ $row = Cache::srv_spremenljivka($spremenljivke['id']);
+ $this->spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Ce je spremenljivka v loopu
+ $this->loop_id = $loop_id;
+
+ #pridobitev podatkov o odgovorih respondenta na trenutno vprasanje
+ if($export_subtype!='q_empty'){
+ if( in_array($spremenljivke['tip'], array(1, 2, 3)) ){ //ce je radio,checkbox ali roleta
+ //if( in_array($spremenljivke['tip'], array(1, 2, 3)) && $spremenljivke['orientation']!=5){
+ //echo "orientation: ".$spremenljivke['orientation'];
+ $userDataPresent = $this->GetUsersData($this->db_table, $spremenljivke['id'], $spremenljivke['tip'], $this->usr_id, $this->loop_id);
+ }elseif( in_array($spremenljivke['tip'], array(6, 16, 19, 20)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo
+ $sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other, spr_id FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ //echo "Funkcija displayQuestionText </br>";
+ //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti
+ while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)){
+ $indeksZaWhile = 1;
+ //echo "rowVrednost['id']: ".$rowVrednost['id'].'</br>';
+ $sqlVsehVrednsti = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY 'vrstni_red'");
+ while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
+ $sqlUserAnswer = $this->GetUsersDataGrid($spremenljivke, $this->db_table, $rowVrednost, $rowVsehVrednosti, $this->usr_id, 0, $this->loop_id);
+
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){
+ $indeksZaWhile++;
+ }
+ if($indeksZaWhile!=1){
+ $userDataPresent = 1;
+ }
+ }
+ }
+ //}elseif(in_array($spremenljivke['tip'], array(21, 7, 8, 18, 17, 26, 27))){ //ce je besedilo ali stevilo ali datum ali vsota
+ }elseif(in_array($spremenljivke['tip'], array(21, 4, 7, 8, 18, 17, 26, 27))){ //ce je besedilo ali staro besedilo (4) ali stevilo ali datum ali vsota
+ $userDataPresent = $this->GetUsersData($this->db_table, $spremenljivke['id'], $spremenljivke['tip'], $this->usr_id, $this->loop_id);
+ }elseif($spremenljivke['tip']==24){ //ce je kombinirana tabela
+ //GetUsersDataKombinirana($spremenljivke, $db_table, $usr_id)
+ $questionText=1;
+ $indeksPolja = 0;
+ $userDataPresentArray = $this->GetUsersDataKombinirana($spremenljivke, $this->db_table, $this->usr_id, $questionText, $this->loop_id);
+ if (is_array($userDataPresentArray)){
+ //echo "je polje".'</br>';
+ $userDataPresent=0;
+ //echo "Dolzina polja: ".count($userDataPresentArray)."</br>";
+ //echo "Id: ".$spremenljivke['id']."</br>";
+ foreach($userDataPresentArray as $key=>$value){
+ if($key==$indeksPolja){
+ if($value!=''){
+ $userDataPresent=1;
+ }
+ //echo "Podatek z indeksom ".$key." je :".$value."</br>";
+ $indeksPolja++;
+ }
+ }
+ }else{
+ if($userDataPresent!=0){
+ $userDataPresent=1;
+ }else{
+ $userDataPresent=0;
+ }
+ }
+ }
+ }
+ //echo "userDataPresent za spremenljivko ".$spremenljivke['id'].': '.$userDataPresent.'</br>';
+ //echo "Preveri spremenljivko: $preveriSpremenljivko</br>";
+ #pridobitev podatkov o odgovorih respondenta na trenutno vprasanje - konec ####################################
+
+ if(($export_subtype=='q_empty')||($export_subtype=='q_comment')||(($export_subtype=='q_data'||$export_subtype=='q_data_all')&&($userDataPresent!=0||$preveriSpremenljivko))){ //ce je prazen vprasalnik ali (je vprasalnik poln in (so podatki prisotni ali je potrebno pokazati vprasanje tudi, ce ni podatkov))
+ $rowl = $this->srv_language_spremenljivka($spremenljivke);
+ if (strip_tags($rowl['naslov']) != '') $spremenljivke['naslov'] = $rowl['naslov'];
+ if (strip_tags($rowl['info']) != '') $spremenljivke['info'] = $rowl['info'];
+
+ #Pridobimo tekst vprasanja#################################################################################
+
+ $sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'");
+ $rowVrstic = mysqli_fetch_row($sqlVrstic);
+ $visina = round(($rowVrstic[0]+2) * 8);
+
+ //$linecount_vprasanja = $this->pdf->getNumLines($spremenljivke['naslov'], $this->pdf->getPageWidth());
+
+ //$tex = $spremenljivke['naslov'];
+ ######################################### Pridobimo tekst vprasanja - konec
+
+ #Stevilcenje vprasanj###############################################################
+ //$numberingText = ($this->numbering == 1) ? $spremenljivke['variable'].' - ' : '';
+ $numberingText = ($this->numbering == 1) ? $this->encodeText($spremenljivke['variable']).' - ' : '';
+ ######################################### Stevilcenje vprasanj - konec
+ //echo "goli naslov: ".$spremenljivke['naslov']."</br>";
+
+ //belezenje imena spremenljivke, zaradi GDPR vprasanja
+ $this->variableName =$spremenljivke['variable'];
+ //belezenje imena spremenljivke, zaradi GDPR vprasanja - konec
+
+ #Izris stevilke in besedila vprasanja ter IF ali BLOK, ce so prisotni ###############################################
+ //$text = strip_tags($numberingText . $spremenljivke['naslov'], '<a><img><ul><li><ol><br>');
+ $text = strip_tags($numberingText . $spremenljivke['naslov'], '<a><img><ul><li><ol><br><p>'); //je potrebno spustiti <p>, zaradi GDPR vprasanja
+
+ //echo "naslov: ".$text."</br>";
+ //$tex = $text." ".$texNewLine;
+ if( !in_array($spremenljivke['tip'], array(1, 2, 3, 4, 7, 8, 6, 16, 19, 20, 21, 17, 18, 24, 26, 27)) ){ //ce ni radio, check, roleta, stevilo, datum, multigrid radio, checkbox, besedilo, stevilo, razvrscanje, vsota ali kombinirana tabela, lokacija, ali heatmap
+ $tex .= ($this->export_format == 'pdf' ? '\\begin{absolutelynopagebreak} \\noindent ' : ' '); //ce je pdf uredimo, da med vprasanji ne bo prelomov strani
+ }
+
+ #Izpis if-ov pri vprasanju#########################################################
+ if($this->showIf == 1){
+
+ // TODO: Stara koda za iskanje po branchingu (briši, če je vse ok)
+ //$b = new Branching($this->anketa);
+ //$parents = $b->get_parents($spremenljivke['id']);
+ //$parents = explode('p_', $parents);
+ //foreach ($parents AS $key => $val) {
+ // if ( is_numeric(trim($val)) ) {
+ // $parents[$key] = (int)$val;
+ // } else {
+ // unset($parents[$key]);
+ // }
+ //}
+
+ /* $b = new Branching($this->anketa);
+ $parents = $b->get_parents($spremenljivke['id']);
+ $parents = explode('p_', $parents);
+ foreach ($parents AS $key => $val) {
+ if ( is_numeric(trim($val)) ) {
+ $parents[$key] = (int)$val;
+ } else {
+ unset($parents[$key]);
+ }
+ }
+
+ foreach ($parents AS $if) {
+ $tex .= $this->displayIf($if);
+ $tex .= $this->texNewLine;
+ }*/
+ ###### stara koda, ki je delavala
+
+
+ // Po novem izpisemo pred vsakim vprasanjem vse ife znotraj katerih se nahaja
+ Cache::cache_all_srv_branching($this->anketa);
+ $parents = Cache::srv_branching($spremenljivke['id'], 0)['parent'];
+ if($parents){
+ $tex .= $this->displayIf($parents);
+ $tex .= $this->texNewLine;
+ }
+ #preuredil kodo, da zadeva deluje tako kot ta stara, ki se nahaja nad tem
+
+ }
+ ######################################### Izpis if-ov pri vprasanju - konec
+
+ //$tex .= '\textbf{'.$text.'} '.$texNewLine; //izris besedila vprasanja
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov
+ $text = $this->dataPiping($text); //pokazi odgovore po zanki
+ }
+
+ $tex .= ' \noindent '; //dodal pred vsakim tekstom vprasanja, da ni indent-a
+
+ if($spremenljivke['orientation']==0){ //ce je vodoravno ob vprasanju
+ //if($spremenljivke['tip'] == 21){ //ce je besedilo (vodoravno ob vprasanju)
+ if($spremenljivke['tip'] == 21 || $spremenljivke['tip'] == 4){ //ce je besedilo (vodoravno ob vprasanju)
+ $tex .= ' \par { '; //dodaj zacetek odstavka, ki je pomemben za pravile izpis
+ }
+ }
+
+ $tex .= '\textbf{'.$this->encodeText($text).'} '; //izris besedila vprasanja
+
+ $this->questionText = $text; //zabelezimo tekst vprasanja, ki ga potrebujemo kasneje
+
+ #Izris stevilke in besedila vprasanja ter IF ali BLOK, ce so prisotni - konec ###############################################
+
+ #Izris opombe ###############################################################################
+ if($spremenljivke['orientation']!=0){ //ce ni vodoravno ob vprasanju,
+
+ //ce imamo opombo, jo izpisi
+ if($spremenljivke['info'] != ''){
+ $tex .= $this->texNewLine;
+ $tex .= '\vspace{2 mm}';
+ //$tex .= ' {\noindent \\footnotesize '.$this->encodeText($spremenljivke['info']).'}';
+ $tex .= ' \noindent \\footnotesize '.$this->encodeText($spremenljivke['info']).' \\normalsize ';
+ }
+
+ if( !in_array($spremenljivke['tip'], array(4, 6, 16, 19, 20, 21, 7, 8, 18)) ){ //ce ni multigrid radio, checkbox, besedilo, stevilo, datum ali vsota ki ne potrebujejo prazne vrstice zaradi uporabe tabele
+ $tex .= $this->texNewLine;
+ }
+
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov
+ if($export_data_type==0||$export_data_type==2){ //ce je Navaden ali Kratek izvoz
+ if( in_array($spremenljivke['tip'], array(4, 6, 16, 19, 20, 21)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo in je Navaden ali Kratek izpis
+ $tex .= $this->texNewLine;
+ }
+ }else{
+ if( in_array($spremenljivke['tip'], array(4, 21)) ){ //ce je besedilo
+ $tex .= $this->texNewLine;
+ }
+ }
+ }
+
+ ####################
+/* if( !in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce ni multigrid radio, checkbox, besedilo ali stevilo
+
+ //preveri, ce je itemize v besedilu in ustrezno uredi prazno vrstico
+ $findItemize = '\begin{itemize}';
+ $posItemize = strpos($tex, $findItemize); //v trenutni tex kodi najdi prisotnost besedila za itemize
+ if($posItemize === false){ //ce ni besedila itemize, dodaj prazno vrstico
+ //pejdi v novo vrstico
+ $tex .= $this->texNewLine;
+ }
+ //preveri, ce je itemize v besedilu in ustrezno uredi prazno vrstico - konec
+ }
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov
+ if( in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo
+ $tex .= $this->texNewLine;
+ //echo "ni vodoravno ob vprašanju in je število ali besedilo </br>";
+ }
+ }
+
+ //ce imamo opombo, jo izpisi
+ if($spremenljivke['info'] != ''){
+ if( in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo
+ $tex .= $this->texNewLine;
+ echo "ni vodoravno ob vprašanju in je število ali besedilo </br>";
+ }
+ //$tex .= $this->texNewLine;
+ $tex .= '\vspace{2 mm}';
+ $tex .= ' {\indent \\footnotesize '.$this->encodeText($spremenljivke['info']).'}';
+ if( !in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce ni multigrid radio, checkbox, besedilo ali stevilo
+ $tex .= $this->texNewLine;
+ }
+ } */
+ ####################
+ }else{ //ce je vodoravno ob vprasanju
+ //ce imamo opombo, jo izpisi
+ if($spremenljivke['info'] != ''){
+ //pejdi v novo vrstico
+ $tex .= $this->texNewLine;
+ $tex .= '\vspace{2 mm}';
+ //$tex .= ' {\indent \\footnotesize '.$this->encodeText($spremenljivke['info']).'} ';
+ $tex .= ' {\noindent \\footnotesize '.$this->encodeText($spremenljivke['info']).' \\normalsize } ';
+ }
+
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov
+ if(!in_array($spremenljivke['tip'], array(8))){ //ce ni datum
+ $tex .= $this->texNewLine; //dodaj prazno vrstico
+ }
+ }
+ }
+ #Izris opombe - konec #########################################################################
+
+ #ce vprasanje nima moznih odgovorov, je potrebno zakljuciti environment (absolutelynopagebreak) pri pdf
+ //echo $rowVrstic[0]."za spremenljivko: ".$spremenljivke['tip']."</br>";
+ if($rowVrstic[0]==0 && (in_array($spremenljivke['tip'], array(1, 2, 3, 6, 16, 17, 20, 9, 19, 17))) ){
+ if($this->export_format == 'pdf'){ //ce je pdf
+ if($spremenljivke['orientation']==0 || $spremenljivke['orientation']==2){ //ce sta vodoravni orientaciji
+ $tex .= $this->texNewLine; //dodaj na koncu vprasanja prazno vrstico
+ }
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+ $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani
+ }else{ //ce je rtf
+ if($spremenljivke['orientation']==0 || $spremenljivke['orientation']==2){ //ce sta vodoravni orientaciji
+ $tex .= $this->texNewLine; //dodaj na koncu vprasanja prazno vrstico
+ }
+ $tex .= $this->texBigSkip;
+ $tex .= $this->texBigSkip;
+ }
+ }
+ #ce vprasanje nima moznih odgovorov, je potrebno zakljuciti environment (absolutelynopagebreak) pri pdf - konec
+ }
+ //echo "tex: ".$tex."</br>";
+ return $tex;
+ }
+ #funkcija, ki pripravi latex kodo za prikazovanje besedila vprasanja - konec ############################################################################
+
+
+ #funkcija, ki pripravi latex kodo za prikazovanje moznih odgovorov glede na tip vprasanja################################################################
+ public function displayAnswers($spremenljivke=null, $export_subtype='', $preveriSpremenljivko=null, $export_data_type='', $loop_id=null){
+
+ switch ( $spremenljivke['tip'] )
+ {
+ case 1: //radio
+ case 2: //check
+ case 3: //select -> radio
+ return RadioCheckboxSelectLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $preveriSpremenljivko, $export_data_type, $export_subtype, $loop_id, $this->language);
+ break;
+ case 6: //multigrid
+ case 16:// multicheckbox
+ case 19:// multitext
+ case 20:// multinumber
+ return MultiGridLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $this->skipEmptySub, $export_data_type, $this->skipEmpty, $loop_id, $this->language);
+ break;
+ case 21: //besedilo
+ return BesediloLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $this->anketa, $export_subtype, $preveriSpremenljivko, $export_data_type, $loop_id);
+ break;
+ case 4: //besedilo staro
+ return BesediloLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $this->anketa, $export_subtype, $preveriSpremenljivko, $export_data_type, $loop_id);
+ break;
+ case 7: //stevilo
+ return SteviloLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $export_data_type, $loop_id);
+ break;
+ case 8: //datum
+ return DatumLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $loop_id);
+ break;
+ case 17: //ranking
+ return RazvrscanjeLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $export_data_type, $loop_id);
+ break;
+ case 18: //vsota
+ return VsotaLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $loop_id);
+ break;
+ case 24: // kombinirana tabela
+ return GridMultipleLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $export_data_type, $loop_id);
+ break;
+ case 26: //lokacija
+ return LokacijaLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $loop_id);
+ break;
+ case 27: //heatmap
+ return HeatmapLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $this->getUserId(), $this->db_table, $export_subtype, $preveriSpremenljivko, $loop_id);
+ break;
+ case 5: //nagovor
+ return NagovorLatex::getInstance()->export($spremenljivke, $this->export_format, $this->questionText, $this->fillablePdf, $this->texNewLine, $export_subtype, $preveriSpremenljivko, $loop_id);
+ break;
+ case 22: //kalkulacija
+ return KalkulacijaLatex::getInstance()->export($spremenljivke, $this->export_format, $this->fillablePdf, $this->texNewLine, $export_subtype, $this->db_table, $this->getUserId(), $loop_id);
+ break;
+ case 25: //kvota
+ return KvotaLatex::getInstance()->export($spremenljivke, $this->export_format, $this->fillablePdf, $this->texNewLine, $export_subtype, $this->db_table, $this->anketa, $this->getUserId(), $loop_id);
+ break;
+ case 9: //SN-imena
+ return SNImenaLatex::getInstance()->export($spremenljivke, $this->export_format, $this->fillablePdf, $this->texNewLine, $export_subtype, $this->db_table, $this->anketa, $this->getUserId(), $loop_id);
+ break;
+ }
+ }
+ #funkcija, ki pripravi latex kodo za prikazovanje moznih odgovorov glede na tip vprasanja - konec #######################################################
+
+ /**
+ * prevod za srv_spremenljivka
+ */
+ function srv_language_spremenljivka ($spremenljivka=null) {
+
+ // if ($this->language != -1) {
+ if ($this->prevod) {
+ $sqll = sisplet_query("SELECT naslov, info FROM srv_language_spremenljivka WHERE ank_id='".$this->anketa."' AND spr_id='".$spremenljivka['id']."' AND lang_id='".$this->language."'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ return $rowl;
+ }
+
+ return false;
+ }
+
+ function displayIf($if=null){
+ global $lang;
+ //echo "funckija za if </br>";
+ $sql_if = sisplet_query("SELECT tip FROM srv_if WHERE id = '$if'");
+ $row_if = mysqli_fetch_array($sql_if);
+
+ // Blok
+ if($row_if['tip'] == 1)
+ $output = strtoupper($lang['srv_block']).' ';
+ // Loop
+ elseif($row_if['tip'] == 2)
+ $output = strtoupper($lang['srv_loop']).' ';
+ // IF
+ else
+ $output = 'IF ';
+
+ $sql_if = sisplet_query("SELECT number, label FROM srv_if WHERE id = '$if'");
+ $row_if = mysqli_fetch_array($sql_if);
+ $output .= '('.$row_if['number'].') ';
+
+ $sql = Cache::srv_condition($if);
+
+ $bracket = 0;
+ $i = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($i++ != 0)
+ if ($row['conjunction'] == 0)
+ $output .= ' and ';
+ else
+ $output .= ' or ';
+
+ if ($row['negation'] == 1)
+ $output .= ' NOT ';
+
+ for ($i=1; $i<=$row['left_bracket']; $i++)
+ $output .= ' ( ';
+
+ // obicajne spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ $row2 = Cache::srv_spremenljivka($row['spr_id']);
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+ $row1 = Cache::srv_spremenljivka($row['spr_id']);
+ // multigrid
+ } elseif ($row['vre_id'] > 0) {
+ $sql1 = sisplet_query("SELECT variable FROM srv_vrednost WHERE id = '$row[vre_id]'");
+ $row1 = mysqli_fetch_array($sql1);
+ } else
+ $row1 = null;
+
+ $output .= $this->encodeText($row1['variable']);
+ // radio, checkbox, dropdown in multigrid
+ if (($row2['tip'] <= 3 || $row2['tip'] == 6) && ($row['spr_id'] || $row['vre_id'])) {
+
+ if ($row['operator'] == 0)
+ $output .= ' = ';
+ else
+ $output .= ' != ';
+
+ $output .= '[';
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+ $sql2 = sisplet_query("SELECT v.variable as variable FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id");
+
+ $j = 0;
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ if ($j++ != 0) $output .= ', ';
+ $output .= $row2['variable'];
+ }
+ // multigrid
+ } elseif ($row['vre_id'] > 0) {
+ $sql2 = sisplet_query("SELECT g.variable as variable FROM srv_condition_grid c, srv_grid g WHERE c.cond_id='$row[id]' AND c.grd_id=g.id AND g.spr_id='$row[spr_id]'");
+
+ $j = 0;
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ if ($j++ != 0) $output .= ', ';
+ $output .= $row2['variable'];
+ }
+ }
+
+ $output .= ']';
+
+ // textbox in nubmer mata drugacne pogoje in opcije
+ } elseif ($row2['tip'] == 4 || $row2['tip'] == 21 || $row2['tip'] == 7 || $row2['tip'] == 22) {
+
+ if ($row['operator'] == 0)
+ $output .= ' = ';
+ elseif ($row['operator'] == 1)
+ $output .= ' <> ';
+ elseif ($row['operator'] == 2)
+ $output .= ' < ';
+ elseif ($row['operator'] == 3)
+ $output .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $output .= ' > ';
+ elseif ($row['operator'] == 5)
+ $output .= ' >= ';
+
+ $output .= '\''.$row['text'].'\'';
+
+ }
+
+ // recnum
+ } elseif ($row['spr_id'] == -1) {
+
+ $output .= 'mod(recnum, '.$row['modul'].') = '.$row['ostanek'];
+
+ }
+
+ for ($i=1; $i<=$row['right_bracket']; $i++)
+ $output .= ' ) ';
+ }
+
+ if ($row_if['label'] != '') {
+ $output .= ' (';
+ $output .= ' '.$row_if['label'].' ';
+ $output .= ') ';
+ }
+
+ return $output;
+ }
+
+ #funkcija, ki skrbi za izbiro radio, checkbox ali ostale simbole, ki so potrebni za izris odgovorov #############################################################
+ function getAnswerSymbol($export_format='', $fillablePdf=null, $spremenljivkeTip=null, $spremenljivkeGrids=null, $numOfMissings=null, $data=null, $enota='', $indeksVASIcon='', $VASNumberRadio='', $spremenljivkeId=null){
+ $tip=$spremenljivkeTip;
+ global $site_path;
+ $this->path2Images = $site_path.'admin/survey/export/latexclasses/textemp/images/';
+ //echo $tip;
+ //$numGrids=$spremenljivke['grids'];
+ $numGrids=$spremenljivkeGrids;
+ //echo "Data:".($data)."</br>";
+ //echo "DataCount:".count($data)."</br>";
+ //if($tip==21||$tip==8){ //ce je besedilo ali datum,
+ if($tip==21||$tip==4||$tip==8){ //ce je besedilo ali datum,
+ $tip=2; //naj se pobere checkbox
+ }
+
+ if( ($export_format=='pdf'&&$fillablePdf==0)||$export_format=='rtf'){//ce je navaden pdf ali rtf dokument (brez moznosti izbire ali vnosa v polja)
+
+ if($data){
+ $data = $this->encodeText($data);
+ }
+
+ if($tip==1||$tip==6){ //radio ali multigrid z radio
+ if($data){ //ce je odgovor respondenta
+ if($enota!=11&&$enota!=12){ //ce ni VAS ali slikovni tip
+ $radioButtonTex = ($export_format=='pdf'?"{\\radio}" : "\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio2}"); //\radio je newcommand
+ }elseif($enota==11){ //drugace, ce je VAS
+ if($tip==1){
+ $VASNumber = $VASNumberRadio;
+ }else{
+ $spremenljivkeGrids = $spremenljivkeGrids - 1;
+ $VASNumber = $spremenljivkeGrids;
+ }
+ $indeksVASIcon = $indeksVASIcon - 1;
+ $radioButtonTex = [];
+ if($VASNumber>1){
+ switch ($VASNumber) {
+ case 1:
+ $radioButtonTex = "";
+ break;
+ case 2:
+ $arrayVAS = ['vas3checked', 'vas5checked'];
+ foreach($arrayVAS AS $VAS){
+ //$radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 3:
+ $arrayVAS = ['vas3checked', 'vas4checked', 'vas5checked'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 4:
+ $arrayVAS = ['vas2checked', 'vas3checked', 'vas5checked', 'vas6checked'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 5:
+ $arrayVAS = [ 'vas2checked', 'vas3checked', 'vas4checked', 'vas5checked', 'vas6checked'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 6:
+ $arrayVAS = ['vas1checked', 'vas2checked', 'vas3checked', 'vas5checked', 'vas6checked', 'vas7checked'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 7:
+ $arrayVAS = ['vas1checked', 'vas2checked', 'vas3checked', 'vas4checked', 'vas5checked', 'vas6checked', 'vas7checked'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ }
+ return $radioButtonTex[$indeksVASIcon]; //$indeksVASIcon
+ }
+ }elseif($enota==12){ //drugace, ce je slikovni tip
+ $prviOdgovorSlikovniTip = 1;
+ $radioButtonTex = ICON_SIZE."{".$this->path2Images."".$this->getCustomRadioSymbol($spremenljivkeId, $prviOdgovorSlikovniTip)."}";
+ }
+ }else{
+ if($enota!=11&&$enota!=12){ //ce ni VAS ali slikovni tip
+ $radioButtonTex = ($export_format=='pdf'?"{\Large $\ocircle$}" : "\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio}");
+ }elseif($enota==11){ //drugace, ce je VAS
+ if($tip==1){
+ $VASNumber = $VASNumberRadio;
+ }else{
+ $spremenljivkeGrids = $spremenljivkeGrids - 1;
+ $VASNumber = $spremenljivkeGrids;
+ }
+ $indeksVASIcon = $indeksVASIcon - 1;
+ $radioButtonTex = [];
+ if($VASNumber>1){
+ switch ($VASNumber) {
+ case 1:
+ $radioButtonTex = "";
+ break;
+ case 2:
+ $arrayVAS = ['vas3', 'vas5'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 3:
+ $arrayVAS = ['vas3', 'vas4', 'vas5'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 4:
+ $arrayVAS = ['vas2', 'vas3', 'vas5', 'vas6'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 5:
+ $arrayVAS = [ 'vas2', 'vas3', 'vas4', 'vas5', 'vas6'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 6:
+ $arrayVAS = ['vas1', 'vas2', 'vas3', 'vas5', 'vas6', 'vas7'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ case 7:
+ $arrayVAS = ['vas1', 'vas2', 'vas3', 'vas4', 'vas5', 'vas6', 'vas7'];
+ foreach($arrayVAS AS $VAS){
+ $radioButtonTex[] = "\\includegraphics[scale=".VAS_SIZE."]{".$this->path2Images."".$VAS."}";
+ }
+ break;
+ }
+ return $radioButtonTex[$indeksVASIcon]; //$indeksVASIcon
+ }
+
+ }elseif($enota==12){
+ $prviOdgovorSlikovniTip = 0;
+ $radioButtonTex = ICON_SIZE."{".$this->path2Images."".$this->getCustomRadioSymbol($spremenljivkeId, $prviOdgovorSlikovniTip)."}";
+ }
+ }
+ return $radioButtonTex;
+ }else if($tip==2||$tip==16){ //checkbox ali multigrid s checkbox
+ if($data){
+ $checkboxTex = ($export_format=='pdf'?'{\Large \CheckedBox}' : "\\includegraphics[scale=".CHCK_BTN_SIZE."]{".$this->path2Images."checkbox2}");
+ }else{
+ $checkboxTex = ($export_format=='pdf'?'{\Large \Square}' : "\\includegraphics[scale=".CHCK_BTN_SIZE."]{".$this->path2Images."checkbox}");
+ }
+ return $checkboxTex;
+ }elseif($tip==19||$tip==20){ //multi text ali multi number
+ $textboxWidth = 0.5/($numGrids+$numOfMissings); //sirina praznega textbox-a
+ //priprava latex kode za prazen text box dolocene sirine in visine glede na export format
+ if($export_format == 'pdf'){
+ if($data!=''){
+ $TextBoxWithText = ' \\textcolor{crta}{\footnotesize{'.$data.'}} ';
+ //$TextBoxWithText = ' \\textcolor{crta}{\footnotesize{'.$this->encodeText($data).'}} ';
+ $emptyTextBox = $TextBoxWithText;
+ }else{
+ if($this->export_subtype == 'q_empty' || $this->export_subtype == 'q_comments'){
+ $emptyTextBox = ' \fbox{\parbox{'.$textboxWidth.'\textwidth}{ \hphantom{\hspace{'.$textboxWidth.'\textwidth}} }} ';
+ }else{
+ $emptyTextBox = ' ';
+ }
+
+ }
+ }elseif($export_format == 'rtf'){
+ if($data!=''){
+ $TextBoxWithText = ' '.$data.' ';
+ $emptyTextBox = $TextBoxWithText;
+ }else{
+ if($this->export_subtype == 'q_empty' || $this->export_subtype == 'q_comments'){
+ $emptyTextBox =' \fbox{\parbox{'.$textboxWidth.'\textwidth}{ \hphantom{\hspace{'.$textboxWidth.'\textwidth}} }} ';
+ }else{
+ $emptyTextBox = ' ';
+ }
+ }
+ }
+ return $emptyTextBox;
+ }
+ }else if($export_format=='pdf'&&$fillablePdf==1){//ce je pdf dokument, kjer je mozno vpisati v polja
+ $radioButtonTex ="{\Large $\ocircle$}";
+ $checkboxTex ='{\Large \Square}';
+ }
+ }
+ #funkcija, ki skrbi za izbiro radio, checkbox ali ostale simbole, ki so potrebni za izris odgovorov - konec #####################################################
+
+ #funkcija, ki ureja pretvorbo stevilskega ID vprasanja v "crkovsko" identifikacijo, ker Latex ne podpira imen s stevilkami ######################################
+ function UrediOznakoVprasanja($sprId=null){
+ $sprId = (string) $sprId;
+ $sprIdArray = str_split($sprId);
+ $temp='';
+ foreach($sprIdArray as $data){
+ $temp .= chr($data+65);
+ }
+ return $temp;
+ }
+ #funkcija, ki ureja pretvorbo stevilskega ID vprasanja v "crkovsko" identifikacijo, ker Latex ne podpira imen s stevilkami - konec #############################
+
+ #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno
+ function encodeText($text='', $vre_id=0, $naslovStolpca = 0){
+ global $site_path, $lang;
+ //$text = str_replace(' ','X',$text); //nadomesti presledke
+ //echo "Encoding ".$text."</br>";
+ //echo "vre_id: ".$vre_id."</br>";
+ //echo "ime spremenljivke ".$this->variableName."</br>";
+
+ $text = htmlspecialchars_decode($text); //vse html special chars kot je &amp; spremeni v ustrezne simbole (npr. &amp;=>&)
+
+ //resevanje razbirajanja predolgih neprekinjenih besed in URL - spremenljivke za kasnejsi prilagojen izpis
+ //$numOfWords = str_word_count($text, 0);
+ $numOfSpacesPrej = substr_count($text, ' '); //stevilo presledkov v besedilu
+ $stringLength = strlen($text);
+
+ $findSpace = ' ';
+ $posSpace1 = strpos($text, $findSpace); //najdi pozicijo prvega presledka v besedilu
+ $posSpace2 = strripos($text, $findSpace); //najdi pozicijo zadnjega presledka v besedilu
+
+
+ $findHttp = 'http://';
+ $findHttps = 'https://';
+ $posHttp = strpos($text, $findHttp);
+ $posHttps = strpos($text, $findHttps);
+ $isURL = 0;
+ /* if($posHttp !== false || $posHttps !== false) { //imamo URL naslov
+ $isURL = 1;
+ } */
+ //resevanje razbirajanja predolgih neprekinjenih besed in URL - konec
+
+ $this->path2UploadedImages = $site_path.'uploadi/editor/';
+ if($text == ''){ //ce ni teksta, vrni se
+ return;
+ }
+ $textOrig = $text;
+ $findme = '<br />';
+ $findmeLength = strlen($findme);
+ $findImg = '<img';
+ $findImgLength = strlen($findImg);
+ $findUl = '<ul';
+ $findUlLength = strlen($findUl);
+ $findOl = '<ol';
+ $findLi = '<li';
+
+ $findPar = '<p>';
+
+ $pos = strpos($text, $findme);
+ $posImg = strpos($text, $findImg);
+ $posUl = strpos($text, $findUl);
+ $posOl = strpos($text, $findOl);
+ $posLi = strpos($text, $findLi);
+ $posPar = strpos($text, $findPar);
+
+ //echo "pozicija paragrafa: $posPar </br>";
+
+ //ureditev izrisa slike
+ if($posImg !== false){
+ $numOfImgs = substr_count($text, $findImg); //stevilo '<img ' v tekstu
+ $posImg = strpos($text, $findImg);
+ $textPrej = '';
+ $textPotem = '';
+ for($i=0; $i<$numOfImgs; $i++){
+ $posImg = strpos($text, $findImg);
+ $textPrej = substr($text, 0, $posImg); //tekst do img
+ $textPotem = substr($text, $posImg); //tekst po img, z vkljuceno hmlt kodo z img
+ $posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
+ $textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
+
+ //$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2UploadedImages."".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
+ //$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2UploadedImages."".$this->getImageName($text, 0, '<img', $vre_id)."}".' '.$textPotem;
+ $imageName = $this->path2UploadedImages."".$this->getImageName($text, 0, '<img', $vre_id);
+ $imageNameTest = $imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku
+ //error_log("iz survey element: ".$imageNameTest);
+ //echo("iz survey element: ".$imageNameTest."</br>");
+ if(filesize($imageNameTest) > 0){
+ $text = $textPrej.' '.PIC_SIZE_ANS."{".$imageName."}".' '.$textPotem;
+ }else{
+ $image = $lang['srv_pc_unavailable'];
+ $text = $textPrej.' '.$image.' '.$textPotem;
+ }
+ }
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
+ $findImgCode = '\includegraphics';
+ $posOfImgCode = strpos($text, $findImgCode);
+ //echo $posOfImgCode."</br>";
+ $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode
+ //echo $textToImgCode."</br>";
+ $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode
+ //echo $textFromImgCode."</br>";
+ $findImgCodeEnd = '}';
+ //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd);
+ $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd);
+ //echo $posOfImgCodeEnd."</br>";
+ $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd
+ //echo $textAfterImgCode."</br>";
+ $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1);
+ //echo $textOfImgCode."</br>";
+
+ $text = $textToImgCode.$textAfterImgCode;
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - konec
+ }
+ //ureditev izrisa slike - konec
+
+ //ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
+ $text = str_replace('\\','\textbackslash{} ',$text);
+ //$text = str_replace('{','\{',$text);
+ //$text = str_replace('}','\}',$text);
+ $text = str_replace('$','\$ ',$text);
+
+ if(substr_count($text, '#')){ //ce je stevilo # vecje od 1
+ $text = str_replace('#','\#',$text);
+ }else{
+ $text = str_replace('#','\# ',$text);
+ }
+ $text = str_replace('%','\% ',$text);
+ $text = str_replace('€','\euro',$text);
+ $text = str_replace('^','\textasciicircum{} ',$text);
+ $text = str_replace('_','\_ ',$text);
+ $text = str_replace('~','\textasciitilde{} ',$text);
+ if(strpos($text, '&amp;')){ //ce je prisotno v besedilu &amp;'
+ $text = str_replace('&amp;','\& ',$text);
+ }else{
+ $text = str_replace('&','\& ',$text);
+ }
+ $text = str_replace('&nbsp;','~',$text);
+ //$text = str_replace('&lt;','\textless ',$text);
+ $text = str_replace('&lt;',' \textless ',$text);
+ //$text = str_replace('&gt;','\textgreater ',$text);
+ $text = str_replace('&gt;',' \textgreater ',$text);
+ //ureditev posebnih karakterjev za Latex - konec
+
+ //ureditev grskih crk
+ $text = str_replace('α','\textalpha ',$text);
+ $text = str_replace('β','\textbeta ',$text);
+ $text = str_replace('γ','\textgamma ',$text);
+ $text = str_replace('δ','\textdelta ',$text);
+ $text = str_replace('ε','\textepsilon ',$text);
+ $text = str_replace('ζ','\textzeta ',$text);
+ $text = str_replace('η','\texteta ',$text);
+ $text = str_replace('θ','\texttheta ',$text);
+ $text = str_replace('ι','\textiota ',$text);
+ $text = str_replace('κ','\textkappa ',$text);
+ $text = str_replace('λ','\textlambda ',$text);
+ $text = str_replace('μ','\textmugreek ',$text);
+ $text = str_replace('ν','\textnu ',$text);
+ $text = str_replace('ξ','\textxi ',$text);
+ //$text = str_replace('ο','\textomikron ',$text);
+ $text = str_replace('π','\textpi ',$text);
+ $text = str_replace('ρ','\textrho ',$text);
+ $text = str_replace('σ','\textsigma ',$text);
+ $text = str_replace('τ','\texttau ',$text);
+ $text = str_replace('υ','\textupsilon ',$text);
+ $text = str_replace('φ','\textphi ',$text);
+ $text = str_replace('χ','\textchi ',$text);
+ $text = str_replace('ψ','\textpsi ',$text);
+ $text = str_replace('ω','\textomega ',$text);
+ //ureditev grskih crk - konec
+
+ //ureditev preureditve html kode ul in li v latex itemize
+ if($posUl !== false){
+ //echo "text prej: ".$text."</br>";
+ $numOfUl = substr_count($text, $findUl); //stevilo '<ul' v tekstu
+ //echo "numOfUl ".$numOfUl."</br>";
+ ######################
+ //if($numOfUl!=0){
+ if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
+ $text = str_replace('<ul>','\begin{itemize} ', $text);
+ $text = str_replace('<ul','\begin{itemize} ', $text);
+ $text = str_replace('<li>','\item ', $text);
+ $text = str_replace('<li','\item ', $text);
+ $text = str_replace('</ul>','\end{itemize} \ ', $text);
+ }
+ //echo "prazno v html: ".strpos($text, '\r')."</br>";
+ //echo "text potem: ".$text."</br>";
+ ######################
+ }
+ //ureditev preureditve html kode ul in li v latex itemize - konec
+
+ //ureditev preureditve html kode ol in li v latex enumerate, ki je ostevilcen
+ if($posOl !== false){
+ //echo "text prej: ".$text."</br>";
+ $numOfOl = substr_count($text, $findOl); //stevilo '<ol' v tekstu
+ //echo "numOfUl ".$numOfUl."</br>";
+ ######################
+ //if($numOfUl!=0){
+ if($numOfOl!=0 && $posLi !== false){ //ce imamo ol in li
+ $text = str_replace('<ol>','\begin{enumerate} ', $text);
+ $text = str_replace('<li>','\item ', $text);
+ $text = str_replace('<li','\item ', $text);
+ $text = str_replace('</ol>','\end{enumerate} \ ', $text);
+ }
+ //echo "prazno v html: ".strpos($text, '\r')."</br>";
+ //echo "text potem: ".$text."</br>";
+ ######################
+ }
+ //ureditev preureditve html kode ol in li v latex enumerate, ki je ostevilcen - konec
+
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+ if($posImg !== false){
+ $text = substr_replace($text, $textOfImgCode, $posOfImgCode, 0);
+ }
+ //po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
+
+ if($posPar !== false){ //ce je kaksen html tag <p>, dodaj prazno vrstico oz. break
+ if($this->variableName=='gdpr'){
+ if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
+ $divider = ' ';
+ }else{
+ $divider = ' \\ \\\\ ';
+ }
+ $text = str_replace('<p>',$divider, $text);
+ }else{
+ $text = str_replace('<p>',' ', $text);
+ }
+ }
+
+
+ //priprava izpisa zelo dolgega besedila brez presledkov (URL, email, ...)
+ //if($numOfSpacesPrej == 0 && ($stringLength >= MAX_STRING_LENGTH)){ //ce v besedilu ni presledkov in je besedilo daljse od max dovoljene dolzine
+ if( ($numOfSpacesPrej == 0 && ($stringLength >= MAX_STRING_LENGTH)) || ($numOfSpacesPrej == 1 && $posSpace1 == $posSpace2 && $stringLength >= MAX_STRING_LENGTH)){ //ce v besedilu ni presledkov in je besedilo daljse od max dovoljene dolzine
+ //$text = "\seqsplit{".$text."}"; //ni v redu seqsplit, ker ne dela, če so posebni znaki
+ $text = substr_replace($text, $this->texNewLine, MAX_STRING_LENGTH, 0); //dodaj na ustrezni dolzini besedila prehod v novo vrstico
+ }
+ //priprava izpisa zelo dolgega besedila brez presledkov - konec
+ //echo "text potem: ".$text."</br>";
+
+ //detekcija prisotnosti e-naslova v besedilu in primerna preureditev, da pride do pravilnega izpisa
+ $findAt = '@';
+ $numOfAt = substr_count($text, $findAt); //stevilo '@' v besedilu
+
+ $posAt = strpos($text, $findAt);
+ if($posAt && $posSpace1){ //ce je prisotna afna in je prisoten presledek v besedilu
+ //echo "afna je: $posAt </br>";
+ //echo "Encoding: ".$text."</br>";
+
+ //najdi prvi presledek po afni
+ //echo substr($text, $posAt) ."</br>";
+ $posSpace1Mail = strpos(substr($text, $posAt), $findSpace); //najdi pozicijo prvega presledka v besedilu po e-naslovu
+ $posSpace1Mail = $posSpace1Mail+$posAt; //koncna pozicija, ce se gleda celotno besedilo
+ //echo $posSpace1Mail."</br>";
+
+ //najdi prvi presledek pred afno
+ $posSpace2Mail = strripos(substr($text, 0, $posAt), $findSpace); //najdi pozicijo zadnjega presledka v besedilu pred e-naslovom
+ //echo $posSpace2Mail."</br>";
+
+ //dodaj po e-naslovu potrebno latex kodo za zakljucek url
+ $text = substr_replace($text, '}', $posSpace1Mail, 0);
+
+ //dodaj pred e-naslovom potrebno latex kodo za url
+ //substr_replace(string_name, replacement_string, start_pos, length)
+ $text = substr_replace($text, ' \url{', $posSpace2Mail+1, 0);
+ //echo $text."</br>";
+ }
+ //detekcija prisotnosti e-naslova v besedilu in primerna preureditev, da pride do pravilnega izpisa - konec
+
+
+ //RESEVANJE BESEDILA V CIRILICI
+ $contains_cyrillic = (bool) preg_match('/[\p{Cyrillic}]/u', $text); //ali je v besedilu cirilica?
+ if($contains_cyrillic){ // ce je cirilica v besedilu
+ $text = '\foreignlanguage{russian}{'.$text.'}';
+ }
+ //RESEVANJE BESEDILA V CIRILICI - konec
+
+
+
+ //RESEVANJE odstranitve dodatnih style tag-ov po ul, ipd. #######################################################
+ $findStyleTag = 'style="';
+ //$findStyleTagEnd = '"';
+ $findStyleTagEnd = '">';
+ $numOfStyleTags = substr_count($text, $findStyleTag); //stevilo 'style=" ' v tekstu
+ //echo "stevilo style: ".$numOfStyleTags." </br>";
+ //echo $text."</br>";
+ for($s=0; $s<$numOfStyleTags; $s++){ //za vsako najdeno 'style=" ' besedilo, uredi njeno odstranitev
+ $posStyleTag = strpos($text, $findStyleTag);
+ $posStyleTagEnd = strpos($text, $findStyleTagEnd, $posStyleTag); //strpos(string,find,start) najdi $findStyleTagEnd v $text, isci od $posStyleTag dalje
+ $dolzinaOff = $posStyleTagEnd - $posStyleTag + 2;
+ $text = substr_replace($text, "", $posStyleTag, $dolzinaOff);
+
+ }
+ //RESEVANJE odstranitve dodatnih style tag-ov po ul, ipd. - konec #################################################
+
+ if($pos === false && $posImg === false) { //v tekstu ni br in img
+
+ $text = preg_replace("/(\R){2,}/", "$1", $text);
+ return strip_tags($text);
+ }else { //v tekstu sta prisotna br ali img
+ $text2Return = ''; //tekst ki bo vrnjen
+
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
+ if($naslovStolpca==0){ // ce besedilo ni naslov stolpca tabele
+ if($pos !== false){
+ $pos = strpos($text, $findme);
+ $numOfBr = substr_count($text, $findme); //stevilo '<br />' v tekstu
+ for($i=0; $i<$numOfBr; $i++){
+ if($i == 0){ //ce je prvi najdeni '<br />'
+ $textPrej = substr($text, 0, $pos);
+ $textPotem = substr($text, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ //$text2Return .= $textPrej.' \break '.$textPotem;
+ $text2Return .= $textPrej.' \\\\ '.$textPotem;
+ }else{
+ //$text2Return .= $textPrej.' \break ';
+ $text2Return .= $textPrej.' \\\\ ';
+ }
+ }else{ //drugace
+ $pos = strpos($textPotem, $findme);
+ $textPrej = substr($textPotem, 0, $pos);
+ $textPotem = substr($textPotem, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ //$text2Return .= $textPrej.' \break '.$textPotem;
+ $text2Return .= $textPrej.' \\\\ '.$textPotem;
+ }else{
+ //$text2Return .= $textPrej.' \break ';
+ $text2Return .= $textPrej.' \\\\ ';
+ }
+ }
+ }
+ $text = $text2Return;
+ }
+ }
+ //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
+ //echo "text potem: ".$text."</br>";
+ $text = preg_replace("/(\R){2,}/", "$1", $text);
+ return strip_tags($text); //vrni tekst brez html tag-ov
+ }
+ }
+ #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno - konec
+
+ #funkcija, ki skrbi za pridobitev imena slike, ki jo je potrebno izrisati ######################################
+ function getImageName($text='', $sprId=null, $findme='', $vre_id=0){
+ global $site_path;
+ $imageName = '';
+
+ if($text == 'hotspot' && $findme == 'hotspot_image='){
+ $sqlParametrov = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id='".$sprId."'");
+ $rowParametrov = mysqli_fetch_row($sqlParametrov);
+ $text = $rowParametrov[0];
+ }
+
+ $pos = strpos($text, $findme); //najdi pozicijo teksta v $findme
+ //echo "text za echo: ".$text."</br>";
+ //if($pos!=''){ //ce je slika v bazi
+ if($pos!=''||$pos==0){ //ce je slika v bazi
+ $imageName = substr($text,$pos); //pokazi le del text od besedila $findme dalje (vkljucno z besedilom)
+ //echo "imageName prej: ".$imageName."</br>";
+
+ $findme = $site_path.'uploadi/editor/';
+ //$findme = 'uploadi/editor/';
+
+ $pos = strpos($imageName, $findme); //najdi pozicijo teksta v $findme
+ //echo "najdi tole: ".$findme."</br>";
+ //echo "najdi tukaj: ".$imageName."</br>";
+ //echo "pozicija tega: ".$pos."</br>";
+ if($pos){ //ce je slika na strezniku
+ $slikaNaStrezniku = 1;
+ }else{//ce slike ni na strezniku
+ $slikaNaStrezniku = 0;
+ }
+ //echo "ali je slika na strežniku: ".$slikaNaStrezniku."</br>";
+ if($slikaNaStrezniku==1){ //ce je slika na strezniku
+ $imageName = substr($imageName,$pos+7); //pokazi le del params od besedila 'editor/' dalje, brez besedila 'editor/'
+ $pos = $this->getEndPosition($imageName); //najdi pozicijo konca URL slike
+ $imageExtension = substr($imageName, $pos-3, 3); //pridobi koncnico slike (za gif je potrebno sliko pretvoriti v png, saj latex ne podpira gif)
+ /* echo "exr1: ".$imageExtension."</br>";
+ $imageExtension = strrchr($imageName, '.'); //pridobi koncnico slike (za gif je potrebno sliko pretvoriti v png, saj latex ne podpira gif, jpg in jpeg)
+ echo "exr2: ".$imageExtension."</br>"; */
+
+ $imageName = substr($imageName, 0, $pos); //pokazi le del params od zacetka besedila do '"' oz. konca URL slike
+
+ $path = $site_path.'uploadi/editor/'.$imageName;
+
+ if($imageExtension == 'gif'){ //ce je slika gif, jo je potrebno pretvoriti v png
+ $this->convertGifToPng($path, $slikaNaStrezniku);
+ }
+
+ if($imageExtension == 'jpg' || $imageExtension == 'peg'){ //ce je slika jpg ali jpeg, jo je potrebno pretvoriti v png
+ $this->convertJpgToPng($path, $slikaNaStrezniku, $imageExtension);
+ }
+ }elseif($slikaNaStrezniku==0){ //ce slike ni na strezniku
+ //echo "vre_id: $vre_id </br>";
+ $imageName = $this->getOnlineImageName($imageName, $slikaNaStrezniku, $vre_id); //pridobi njen URL
+ }
+
+ $imageName = substr($imageName, 0, strrpos($imageName, '.'));
+
+ }
+
+ //echo "imagename pred return: ".$imageName."</br>";
+ return $imageName;
+ }
+ #funkcija, ki skrbi za pridobitev imena slike, ki jo je potrebno izrisati - konec ###############################
+
+
+ #funkcija, ki skrbi za pridobitev ustrezne strezniske poti do slike - trenutno ni v uporabi ########################################################
+ function getPath2Images($text='', $sprId=null, $findme=''){
+ global $site_path;
+ $imageName = '';
+
+ if($text == 'hotspot' && $findme == 'hotspot_image='){
+ $sqlParametrov = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id='".$sprId."'");
+ $rowParametrov = mysqli_fetch_row($sqlParametrov);
+ $text = $rowParametrov[0];
+ }
+
+ $pos = strpos($text, $findme); //najdi pozicijo teksta v $findme
+
+ if($pos!=''||$pos==0){ //ce je slika v bazi
+ $imageName = substr($text,$pos); //pokazi le del text od besedila $findme dalje (vkljucno z besedilom)
+
+ $findme = 'editor/';
+ $pos = strpos($imageName, $findme); //najdi pozicijo teksta 'editor/'
+
+ if($pos){ //ce je slika na strezniku
+ $slikaNaStrezniku = 1;
+ }else{//ce slike ni na strezniku
+ $slikaNaStrezniku = 0;
+ }
+
+ if($slikaNaStrezniku==1){ //ce slika je bila prenesena na streznik
+ $path2Images = $site_path.'admin/survey/export/latexclasses/textemp/images/';
+ }elseif($slikaNaStrezniku==0){ //ce slika je bila na dolocenem URL
+ $path2Images = $site_path.'uploadi/editor/';
+ }
+
+ }
+ //echo "pot do slik: ".$path2Images."</br>";
+ return $path2Images;
+ }
+ #funkcija, ki skrbi za pridobitev ustrezne strezniske poti do slike - konec ########################################################
+
+
+ #funkcija, ki skrbi za pridobitev slike, ki se nahaja nekje online in jo je potrebno izrisati, in vrne lokalno ime slike ######################################
+ function getOnlineImageName($imageName='', $slikaNaStrezniku=null, $vre_id=null){
+ global $site_path;
+ //echo "imageName v getOnlineImageName nekje vmes 1: ".$imageName."</br>";
+ $row = Cache::srv_spremenljivka(self::$spremenljivka);
+ //echo "sprem: ".self::$spremenljivka."</br>";
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ //echo "params: ".$spremenljivkaParams->get('hotspot_image')."</br>";
+ $imageNameTmp = $spremenljivkaParams->get('hotspot_image');
+ //if($imageNameTmp!=''){ //ce je hotspot
+ if($imageNameTmp!=''&&$vre_id==0){ //ce je hotspot
+ $imageName = $imageNameTmp;
+ }
+
+ $findHttp = 'http';
+ $posHttp = strpos($imageName, $findHttp);
+ $imageName = substr($imageName,$posHttp); //besedilo do zacetka http
+
+ $pos = $this->getEndPosition($imageName); //najdi pozicijo konca URL slike
+ $imageName = substr($imageName, 0, $pos); //pokazi le del params od zacetka besedila do '"' oz. konca URL slike
+ //echo "imageName v getOnlineImageName nekje vmes 2: ".$imageName."</br>";
+ $imageExtension = substr($imageName, $pos-3, 3); //pridobi koncnico slike
+ //echo "imageExtension: ".$imageExtension."</br>";
+
+ if($imageExtension!='jpg'&&$imageExtension!='png'&&$imageExtension!='gif'&&$imageExtension!='jpeg'){ //ce ni veljavnen extension, spremeni ga v png
+ $imageExtension='png';
+ }
+
+ if($vre_id){ //ce se pridobiva imena tmp slik iz vrednosti vprasanja
+ $imgFilename = self::$spremenljivka.'_'.$vre_id.'_tmpImage.'.$imageExtension; //tmp ime slike, ki je sestavljeno iz id spremenljivke+tmpImage+extension
+ }else{
+ $imgFilename = self::$spremenljivka.'_tmpImage.'.$imageExtension; //tmp ime slike, ki je sestavljeno iz id spremenljivke+tmpImage+extension
+ }
+
+ $pathDir = $site_path.'uploadi/editor/'; //pot za novo mapo, kjer se bodo shranjevale slike za trenutno anketo
+ $path = $pathDir.$imgFilename; //pot do datoteke z imenom datoteke
+
+ # ukaz za pretakanje slike
+ if(IS_WINDOWS){
+ //za windows sisteme //powershell -command "& { iwr URL -OutFile 'PATH' }"
+ $command = 'powershell -command "& { iwr \''.$imageName.'\' -OutFile \''.$path.'\' }"';
+ //$command = 'wget -O \''.$imageName.'\' -O '.$path.' ';
+ }elseif(IS_LINUX){
+ //za linux sisteme //exec('wget URL -P PATH ');
+ //$command = 'wget \''.$imageName.'\' -P '.$path.' ';
+ $command = 'wget -O '.$path.' \''.$imageName.'\' ';
+ }
+
+ //echo "command: ".$command."</br>";
+ exec($command); //pretoci sliko
+
+ //$path = $pathDir.$imgFilename; //pot do datoteke z imenom datoteke
+
+/* if($imageExtension == 'gif'){ //ce je slika gif, jo je potrebno pretvoriti v png, saj latex ne podpira gif
+ $this->convertGifToPng($path, $slikaNaStrezniku);
+ } */
+
+ if($imageExtension != 'png'){ //ce slika ni png, jo pretvori
+ if($imageExtension == 'gif'){ //ce je slika gif, jo je potrebno pretvoriti v png, saj latex ne podpira gif
+ $this->convertGifToPng($path, $slikaNaStrezniku);
+ }else{
+ $this->convertJpgToPng($path, $slikaNaStrezniku, $imageExtension);
+ }
+ }
+
+ //echo "imgfilename: ".$imgFilename."</br>";
+ return $imgFilename;
+ }
+ #funkcija, ki skrbi za pridobitev slike, ki se nahaja nekje online in jo je potrebno izrisati, in vrne lokalno ime slike - konec ###############################
+
+
+ function convertGifToPng($path='', $slikaNaStrezniku=null){
+ //echo "path: ".$path."</br>";
+ $image = imagecreatefromgif($path); //pripravi sliko iz gif za pretvorbo
+ $imageName = substr($path, 0, -3); //ime slike brez extension-a
+ //echo $imageName."</br>";
+ $imageNamePNG = $imageName.'png'; //ime slike z ustreznim extension
+ imagepng($image, $imageNamePNG); //pretvori pripravljeno gif sliko v png
+
+ if($slikaNaStrezniku==0){ //ce slika je iz URL in ni na strezniku, GIF izbrisi
+ unlink($imageName.'gif'); //izbrisi gif sliko
+ }
+ }
+
+ function convertJpgToPng($path='', $slikaNaStrezniku=null, $imageExtension=''){
+ $image = imagecreatefromjpeg($path); //pripravi sliko iz jpg za pretvorbo
+ $imageName = substr($path, 0, strrpos($path, '.')); //ime slike brez extension-a
+
+ $imageNamePNG = $imageName.'.png'; //ime slike z ustreznim extension
+ imagepng($image, $imageNamePNG); //pretvori pripravljeno jpg sliko v png
+
+ //$origExtension = strrchr($path, '.');
+
+ if($slikaNaStrezniku==0){ //ce slika je iz URL in ni na strezniku, izbrisi jo
+ if($imageExtension == 'jpg'){
+ unlink($imageName.'.'.$imageExtension); //izbrisi sliko
+ }elseif($imageExtension == 'peg'){
+ unlink($imageName.'.j'.$imageExtension); //izbrisi sliko
+ }
+ }
+ }
+
+ function getEndPosition($imageName=''){
+ $findme = '"';
+ $pos = strpos($imageName, $findme); //najdi pozicijo teksta '"'
+ return $pos;
+ }
+
+
+ #funkcija, ki skrbi za pridobitev simbola za slikovni tip ######################################
+ function getCustomRadioSymbol($sprId=null, $odgovor=null){
+ $customRadioSymbol = '';
+ $findme = 'customRadio=';
+ $finishAt = 'customRadioNumber';
+
+ $row = Cache::srv_spremenljivka($sprId);
+ $this->spremenljivkaParams = new enkaParameters($row['params']);
+ $customRadioSymbol = $this->spremenljivkaParams->get('customRadio');
+
+ if($odgovor){ //ce je odgovor
+ $customRadioSymbol = $customRadioSymbol."Inverted"; //preuredi, da bo razvidna grafika, ko je prisoten odgovor respondenta
+ }
+ //echo $customRadioSymbol.' asca</br>';
+ return $customRadioSymbol;
+ }
+ #funkcija, ki skrbi za pridobitev simbola za slikovni tip - konec ###############################
+
+
+ /**
+ * vrne prevod za srv_vrednost
+ *
+ * @param mixed $vrednost
+ */
+ function srv_language_vrednost ($vre_id=null) {
+ //if ($this->language != -1) {
+ if ($this->prevod) {
+ $sqllString = "SELECT naslov, naslov2 FROM srv_language_vrednost WHERE vre_id='".$vre_id."' AND lang_id='".$this->language."'";
+ $sqll = sisplet_query($sqllString);
+ $rowl = mysqli_fetch_array($sqll);
+ return $rowl;
+ }
+ return false;
+ }
+
+ /**
+ * vrne prevod za srv_grid
+ *
+ * @param mixed $vrednost
+ */
+ function srv_language_grid ($grd_id=null, $spr_id=null) {
+
+ //if ($this->language != -1) {
+ if ($this->prevod) {
+ $sqllString = "SELECT naslov FROM srv_language_grid WHERE spr_id = '".$spr_id."' AND grd_id='".$grd_id."' AND lang_id='".$this->language."'";
+ $sqll = sisplet_query($sqllString);
+ $rowl = mysqli_fetch_array($sqll);
+ return $rowl;
+ }
+
+ return false;
+ }
+/* function srv_language_grid ($spremenljivka, $grid) {
+
+ if ($this->language != -1) {
+ $sqll = sisplet_query("SELECT * FROM srv_language_grid WHERE ank_id='".$this->anketa['id']."' AND spr_id='".$spremenljivka."' AND grd_id='".$grid."' AND lang_id='".$this->language."'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if ($rowl['naslov'] != '') return $rowl['naslov'];
+ }
+
+ return false;
+ } */
+
+ #funkcija, ki skrbi za filanje obstojecega polja z odgovori z missing odgovori #############################################################
+ function AddMissingsToAnswers($vodoravniOdgovori=[], $missingOdgovori=[]){
+ for($m=0;$m<count($missingOdgovori);$m++){
+ array_push($vodoravniOdgovori,$missingOdgovori[$m]);
+ }
+ return $vodoravniOdgovori;
+ }
+ #funkcija, ki skrbi za filanje obstojecega polja z odgovori z missing odgovori - konec #####################################################
+
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele ##################################################################################
+ #argumenti 1. export_format, 2. parametri tabele, 3. tip tabele za pdf, 4. tip tabele za rtf, 5. sirina pdf tabele (delez sirine strani), 6. sirina rtf tabele (delez sirine strani)
+ function StartLatexTable($export_format='', $parameterTabular='', $pdfTable=null, $rtfTable=null, $pdfTableWidth=null, $rtfTableWidth=null){
+ $tex = '';
+ $tex .= '\keepXColumns';
+ if($export_format == 'pdf'){
+ $tex .= '\begin{'.$pdfTable.'}';
+ if($pdfTable=='tabularx'){
+ $tex .= '{'.$pdfTableWidth.'\textwidth}';
+ }
+ $tex .= '{ '.$parameterTabular.' }';
+ }elseif($export_format == 'rtf'){
+ $tex .= '\begin{'.$rtfTable.'}';
+ if($rtfTable=='tabular*'){
+ $tex .= '{'.$pdfTableWidth.'\textwidth}';
+ }
+ //$tex .= '{ '.$parameterTabular.' }';
+ $tex .= '{@{} '.$parameterTabular.' }'; //dodal @{} , da ni indent-a
+ }
+
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis latex kode za zacetek tabele - konec ##########################################################################
+
+ #funkcija, ki skrbi za izpis latex kode za zakljucek tabele ##################################################################################
+ #argumenti 1. export_format, 2. tip tabele za pdf, 3. tip tabele za rtf
+ function EndLatexTable($export_format='', $pdfTable=null, $rtfTable=null){
+ $tex = '';
+ $tex .= ($export_format == 'pdf' ? '\end{'.$pdfTable.'}' : '\end{'.$rtfTable.'}');
+ return $tex;
+ }
+ #funkcija, ki skrbi za izpis latex kode za zakljucek tabele - konec ##########################################################################
+
+ #funkcija, ki skrbi za pripravo latex kode za text box (okvirja) (prazen ali z besedilom) dolocene sirine in visine glede na export format ####################
+ #argumenti 1. export_format, 2. visina okvirja, 3. sirina okvirja, 4. besedilo v okvirju, 5. poravnava, 6. obrobe
+ function LatexTextBox($export_format='', $textboxHeight=null, $textboxWidth=null, $text='', $textboxAllignment=null, $noBorders=null){
+ $tex = '';
+
+ //zacetek okvirja
+ if($export_format == 'pdf'&&$textboxHeight!=0&&$noBorders==0){
+ $tex .= ' \fbox{\parbox['.$textboxAllignment.']['.$textboxHeight.']{'.$textboxWidth.'\textwidth}';
+ }elseif((($export_format == 'pdf'&&$textboxHeight==0))&&$noBorders==0){
+ $tex .= ' \fbox{\parbox{'.$textboxWidth.'\textwidth}';
+ }elseif( ($export_format == 'rtf'||$export_format == 'pdf')&&$noBorders ){
+ $tex .= ' {\parbox{'.$textboxWidth.'\textwidth}';
+ }
+
+
+ if($text==''){ //ce ni teksta, je okvir prazen
+ if($export_format == 'pdf'){
+ $tex .= '{ \hphantom{\hspace{'.$textboxWidth.'\textwidth}} }}';
+ }elseif($export_format == 'rtf'){
+ //$tex .= ' \rule{40mm}{.1pt} '; //izpisi neprekinjeno crto, ki je dolga 40mmm in debela 0.1pt
+ $tex .= ' \rule{'.$textboxWidth.'\textwidth}{.1pt} '; //izpisi neprekinjeno crto, ki je dolga 40mmm in debela 0.1pt
+ }
+ }else{ //drugace, izpisi besedilo
+ if($export_format == 'pdf'){
+ $tex .= '{ '.$text.' }}'; //izpis besedila v okvirju
+ }elseif($export_format == 'rtf'){
+ $tex .= '{ '.$text.' }'; //izpis besedila v okvirju
+ }
+ }
+
+ return $tex;
+ }
+ #funkcija, ki skrbi za pripravo latex kode za text box (okvirja) (prazen ali z besedilom) dolocene sirine in visine glede na export format - konec ############
+
+ #funkcija, ki skrbi za pripravo latex U oblike dolocene sirine in visine glede na export format ####################
+ #argumenti 1. export_format, 2. visina okvirja, 3. sirina okvirja
+ function LatexUShape($export_format='', $textboxHeight=null, $textboxWidth=null){
+ $tex = '';
+ if($export_format == 'pdf'&&$textboxHeight!=0){
+ $tex .= '\keepXColumns\begin{tabularx}{0.25\textwidth}{C} '; //zacetek tabele, ki bo zgledala kot okvir
+ $tex .= ' \begin{tikzpicture} ';
+ //$tex .= ' \draw (0,0) -- (4,0) -- (4,4) (0,4) -- (0,0);';
+ $tex .= ' \draw (0,0) -- ('.$textboxWidth.',0) -- ('.$textboxWidth.','.$textboxHeight.') (0,'.$textboxHeight.') -- (0,0);';
+ $tex .= ' \end{tikzpicture} ';
+
+ }elseif($export_format == 'rtf'||($export_format == 'pdf'&&$textboxHeight==0)){
+ $tex .= ' \fbox{\parbox{'.$textboxWidth.'\textwidth}';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za pripravo latex U oblike dolocene sirine in visine glede na export format - konec ############
+
+ #funkcija, ki skrbi za pripravo latex U oblike s tekstom dolocene sirine in visine glede na export format ####################
+ #argumenti 1. export_format, 2. visina okvirja, 3. sirina okvirja, 4. tekst oz. koda za odgovore v okvirjih
+ function LatexTextInUShape($export_format='', $textboxHeight=null, $textboxWidth=null, $text=''){
+ //\begin{tikzpicture} \draw (-2,0) -- (2,0) -- (2,1.5 cm) (-2,1.5 cm) -- (-2,0) node[above right] {\begin{tabular}{c} \fbox{\parbox{0.2\textwidth}{ \centering Vpišite besedilo odgovora 11 }} \\ \fbox{\parbox{0.2\textwidth}{ \centering Vpišite besedilo odgovora 12 }} \end{tabular} }; \end{tikzpicture}
+ $tex = '';
+ if($export_format == 'pdf'&&$textboxHeight!=0){
+
+ $tex .= '\keepXColumns\begin{tabularx}{0.25\textwidth}{C} '; //zacetek tabele, ki bo zgledala kot okvir
+ $tex .= ' \begin{tikzpicture} ';
+
+ //\draw (-2,0) -- (2,0) -- (2,1.5 cm) (-2,1.5 cm) -- (-2,0)
+ $tex .= ' \draw (-'.$textboxWidth.',0) -- ('.$textboxWidth.',0) -- ('.$textboxWidth.','.$textboxHeight.' cm) (-'.$textboxWidth.','.$textboxHeight.' cm) -- (-'.$textboxWidth.',0) node[above right] { ';
+
+ $tex .= '\begin{tabular}{c} '; //zacetek tabele znotraj skatle, da je lahko vec odgovorov (eden pod drugim) znotraj skatle
+
+ $tex .= $text;
+
+ $tex .= ' \end{tabular} '; //konec tabele znotraj skatle
+
+
+ $tex .= ' }; \end{tikzpicture} ';
+
+ }elseif($export_format == 'rtf'||($export_format == 'pdf'&&$textboxHeight==0)){
+ $tex .= ' \fbox{\parbox{'.$textboxWidth.'\textwidth}';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za pripravo latex U oblike s tekstom dolocene sirine in visine glede na export format - konec ############
+
+ #funkcija, ki skrbi za pripravo latex okvirja za grid drag and drop ####################
+ #argumenti 1. export_format, 2. visina okvirja, 3. sirina okvirja, 4. tekst naslova okvirja, 5. ali je odgovor prisoten, 6. tekst za odgovore v okvirjih
+ function LatexTextGridOfBoxes($export_format='', $textboxHeight=null, $textboxWidth=null, $textNaslovOkvir='', $jeOdgovor=null, $textIzpis=''){
+ $tex = '';
+ if($export_format == 'pdf'&&$textboxHeight!=0){
+ if($jeOdgovor==0){
+ $tex .= '\keepXColumns\begin{tabularx}{0.25\textwidth}{|C|} '; //zacetek tabele, ki bo zgledala kot okvir
+ $tex .= '\hline'; //izris horizontalne obrobe za zacetek tabele
+ $tex .= '{\parbox{0.25\textwidth}{\vspace{0.5\baselineskip} \centering ';
+ $tex .= $textNaslovOkvir;
+ $tex .= '\vspace{0.5\baselineskip}}}';
+ $tex .= $this->texNewLine;
+ $tex .= '\hline'; //izris horizontalne obrobe za zakljuciti tabelo
+ $tex .= '{\parbox{0.25\textwidth}{\vspace{0.5\baselineskip} \centering ';
+ $tex .= '';
+ $tex .= '\vspace{0.5\baselineskip}}}';
+ $tex .= $this->texNewLine;
+ $tex .= '\hline'; //izris horizontalne obrobe za zakljuciti tabelo
+ $tex .= '\end{tabularx}'; //konec tabele znotraj skatle
+ }else{
+ $tex .= '\keepXColumns\begin{tabularx}{0.25\textwidth}{|C|} '; //zacetek tabele, ki bo zgledala kot okvir
+ $tex .= '\hline'; //izris horizontalne obrobe za zacetek tabele
+ $tex .= $textNaslovOkvir;
+ $tex .= '\hline'; //izris horizontalne obrobe za zakljuciti tabelo
+ $tex .= $textIzpis;
+ $tex .= '\hline'; //izris horizontalne obrobe za zakljuciti tabelo
+ $tex .= '\end{tabularx}'; //konec tabele znotraj skatle
+ }
+ }elseif($export_format == 'rtf'||($export_format == 'pdf'&&$textboxHeight==0)){
+ $tex .= ' \fbox{\parbox{'.$textboxWidth.'\textwidth}';
+ }
+ return $tex;
+ }
+ #funkcija, ki skrbi za pripravo latex okvirja za grid drag and drop - konec ############
+
+
+
+ #funkcija, ki skrbi za pravilen izris prve vrstice v tabelah (vrstica z vodoravnimi naslovi multigridov) #############################
+ function LatexPrvaVrsticaMultiGrid($steviloStolpcev=null, $enota=null, $trak=null, $customColumnLabelOption=null, $spremenljivke=null, $vodoravniOdgovori=null, $missingOdgovori=null){
+ $tex = '';
+ for($i = 0; $i < $steviloStolpcev; $i++){
+ if ($i != 0){ //ce ni prvi stolpec
+ //if($enota==11 || $enota==12 || ($enota==0 && ($trak==0&&$customColumnLabelOption==1)) ||($enota==0 && $spremenljivke['tip']==16) ||($enota==1 && ($trak==0&&$customColumnLabelOption==1)) || $enota==8 || $enota==3){ //klasicna ali diferencial tabela (brez traku) ali tabela da/ne ali dvojna tabela ali VAS ali slikovni tip
+ if(($enota==0 && ($trak==0&&$customColumnLabelOption==1)) ||($enota==0 && $spremenljivke['tip']==16) ||($enota==1 && ($trak==0&&$customColumnLabelOption==1)) || $enota==8 || $enota==3 || $enota==11 || $enota==12 || ($enota==2 && $spremenljivke['tip']==24)){ // ce je klasicna ali diferencial tabela (brez traku) ali tabela da/ne ali dvojna tabela ali VAS ali slikovni tip ali roleta/seznam v kombinirani tabeli
+ if($i==$steviloStolpcev-1 && $enota==1){ //ce je zadnji stolpec in je diferencial
+ for($m=0;$m<count($missingOdgovori);$m++){
+ $tex .= " & ".$missingOdgovori[$m];
+ }
+ $tex .= " & ";
+ }else{
+ $tex .= " & ".$vodoravniOdgovori[$i-1];
+ }
+ }elseif($enota == 5){ //maxdiff
+ if($i == 1){
+ $tex .= ' & ';
+ }
+ $tex .= $vodoravniOdgovori[$i];
+ }
+ }elseif($i == 0 && $enota != 5){ //ce je prvi stolpec tabele in ni "maxdiff"
+ $tex .= '';
+ }elseif($i == 0 && $enota == 5){ //ce je prvi stolpec tabele in "maxdiff"
+ $tex .= $vodoravniOdgovori[$i].' & ';
+ //}elseif( ($i == $steviloStolpcev-1 && $enota != 5) || $enota == 1){ //ce je zadnji stolpec tabele in ni "maxdiff" ali je diferencial
+ }elseif( ($i == $steviloStolpcev-1 && $enota != 5) ){ //ce je zadnji stolpec tabele in ni "maxdiff" ali je diferencial
+ $tex .= ' & ';
+ }
+
+
+ //echo "odgovori ".$i.": ".$vodoravniOdgovori[$i-1]." </br>";
+ //echo "koda za indeks ".$i.": ".$tex." </br>";
+ }
+
+ #Nastavitev UPORABA LABEL
+ if( $customColumnLabelOption!=1 && $trak==0 && ($enota==0||$enota==1) && $spremenljivke['tip'] == 6 ){ //ce ni potrebno izrisati vseh label vodoravnih odgovorov in je "klasicna tabela" ali "diferencial" (uredi vodoravne labele nad radio buttoni)
+ $numGrids = $spremenljivke['grids'];
+ if($customColumnLabelOption == 2){ //ce je trenutna moznost prilagajanja "le koncne"
+ if(($numGrids%2) == 0){ //ce je parno stevilo, spoji polovico label na vsako skupino label
+ $colParameter1 = $colParameter2 = intval(($numGrids)/2);
+ }else if(($numGrids%2) != 0){ //ce ni parno stevilo, spoji prvi skupini label eno celico vec kot pri drugi skupini label
+ $colParameter1 = intval(($numGrids)/2 + 0.5);
+ $colParameter2 = intval(($numGrids)/2 - 0.5);
+ }
+ for($i=0; $i<$numGrids; $i++){
+ if($i==0){ //ce je prvi stolpec nadnaslovov
+ $tex .= ' & \multicolumn{'.$colParameter1.'}{l}{'.$vodoravniOdgovori[$i].'}';
+ }elseif( $i==($numGrids-1) ){ //ce je zadnji stolpec nadnaslovov
+ $tex .= ' & \multicolumn{'.$colParameter2.'}{r}{'.$vodoravniOdgovori[$i].'}';
+ }
+ }
+ }else if($customColumnLabelOption == 3){ //ce je trenutna moznost prilagajanja "koncne in vmesna"
+ if(($numGrids%3) == 0){ //ce je velikost deljiva s 3, spoji vsako tretjino label
+ $colParameter1 = $colParameter2 = $colParameter3 = $numGrids/3;
+ $sredina = $numGrids/3;
+ }else if(($numGrids%3) == 1){ //ce pri deljenju z 3 je ostanek 1
+ $colParameter1 = $colParameter2 = intval($numGrids/3);
+ $colParameter3 = intval($numGrids/3)+1;
+ $sredina = intval(1 + $numGrids/3);
+ }elseif(($numGrids%3) == 2){ //ce pri deljenju z 3 je ostanek 2
+ $colParameter1 = $colParameter2 = 1 + intval($numGrids/3);
+ $colParameter3 = intval($numGrids/3);
+ $sredina = $numGrids%3 + intval($numGrids/3);
+ }
+
+ for($i=0; $i<$numGrids; $i++){
+ if($i==0){ //ce je prvi stolpec nadnaslovov (prva labela)
+ $tex .= ' & \multicolumn{'.$colParameter1.'}{l}{'.$vodoravniOdgovori[$i].'}';
+ }elseif($i==$sredina){ //ce je sredina (vmesna labela)
+ $tex .= ' & \multicolumn{'.$colParameter3.'}{c}{'.$vodoravniOdgovori[$i].'}';
+ }elseif( $i==(($numGrids)-1) ){ //ce je zadnji stolpec nadnaslovov (zadnja labela)
+ $tex .= ' & \multicolumn{'.$colParameter2.'}{r}{'.$vodoravniOdgovori[$i].'}';
+ }
+
+ }
+ }
+ }
+ #Nastavitev UPORABA LABEL - KONEC
+ //echo "</br>";
+ //$tex .= '\endhead'; //da se naslovna vrstica ponovi na vsaki strani, ce tabela gre na novo stran
+ //echo "koda: ".$tex."</br>";
+ return $tex;
+ }
+ #funkcija, ki skrbi za pravilen izris prve vrstice v tabelah (vrstica z vodoravnimi naslovi multigridov) - konec #####################
+
+ #funkcija, ki skrbi za izris vrstic tabele (z multigrid) ###########################################################
+ function LatexVrsticeMultigrid($numRowsSql=null, $export_format='', $enota=null, $simbolTex=null, $navpicniOdgovori=null, $trakStartingNumberTmp=null, $fillablePdf=null, $numColSql=null, $spremenljivke=null, $trak=null, $vodoravniOdgovori=null, $texNewLine='', $navpicniOdgovori2=null, $missingOdgovori=null, $vodoravniOdgovoriTip=null, $vodoravniOdgovoriEnota=null, $vodoravniOdgovoriSprId=null, $data=null, $export_subtype=null, $preveriSpremenljivko=null, $userDataPresent=null, $presirokaKombo = null, $export_data_type=null){
+ $this->export_subtype = $export_subtype;
+ $tex = '';
+ global $lang, $site_path;
+ $this->path2Images = $site_path.'admin/survey/export/latexclasses/textemp/images/';
+ //$radioButtonTex = ($export_format=='pdf'?"{\Large $\ocircle$}" : "\\includegraphics[scale=".RADIO_BTN_SIZE."]{radio}");
+ $indeksOdgovorovRespondentMultiNumText = 0;
+
+ if($spremenljivke['enota']==2||$spremenljivke['enota']==6){ //ce je seznam ali roleta //$enota == 2 || $enota == 6
+ if(count($missingOdgovori)==0){ //ce ni missing vrednosti
+ $numColSql = $numColSql + 1;
+ }
+ }
+ $userAnswerIndex = array();
+ $userAnswerIndex[$spremenljivke['id']] = 0;
+ $z = 0;
+ $skipRow = false;
+
+ $this->skipEmpty = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty'); // izpusti vprasanja brez odgovora
+ $this->skipEmptySub = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty_sub'); // izpusti podvprasanja brez odgovora
+
+ if($spremenljivke['tip']==24){ //ce je kombinirana tabela
+ //echo "stevilo stolpcev za izpis kombinirane podan: ".$numColSql."</br>";
+ //print_r($data);
+ //if($presirokaKombo == 1 && count($data) != 0 && ($enota == 2 || $enota == 6)){
+ if($presirokaKombo == 1 && count($data) != 0 && (($enota == 2 || $enota == 6) || $export_data_type == 2 && $vodoravniOdgovoriTip[0] == 6)){
+ $numColSql = 1 + 1;
+ //echo "stevilo stolpcev za izpis kombinirane izračunan: ".$numColSql."</br>";
+ }else{
+ $numColSql = count($vodoravniOdgovoriEnota) + 1;
+ }
+ }
+
+ //echo "stevilo vrstic: $numRowsSql za enoto: ".$spremenljivke['enota']."</br>";
+
+ //IZRIS PO VRSTICAH
+ for ($i = 1; $i <= $numRowsSql; $i++){ //za vsako vrstico
+
+ if($i == 1 && ($enota == 2 || $enota == 6)&&$spremenljivke['tip']!=24){ //ce je prvi dogovor IN je roleta ALI seznam IN ni kombinirana tabela
+ if($export_format == 'rtf'){ //ce je rtf
+ $tex .= ' \hline '; //dodaj crto
+ }
+ }
+
+ //echo "preskakovanje vprašanj: ".$this->skipEmptySub."</br>";
+
+ // Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici
+ if($this->skipEmptySub == 1){
+ $skipRow = true;
+ for($z=$z;$z<$i*($numColSql-1);$z++){
+ //echo "Podatek: ".$data[$z]."</br>";
+ if($data[$z]){
+ //echo "Podatek je"."</br>";
+ $skipRow = false;
+ $podatekZaSlikovniTip = $data[$z]; //belezi podatek za slikovni tip, ki pride prav za pravilen izpis izvoza
+ }
+ }
+ }
+
+ /* echo "skipRow je $skipRow"."</br>";
+ echo "userDataPresent je $userDataPresent"."</br>";
+ echo "skipEmpty je ".$this->skipEmpty."</br>"; */
+ //echo "____________________________________________</br>";
+ // Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici - konec
+ //echo "za vrstico $i je $skipRow na stolpcih: $numColSql</br>";
+ //if(!$skipRow||(!$userDataPresent&&$this->skipEmpty==0)){ /* ce je potrebno preskociti vrstico ALI (ni podatkov za prikaz, vendar je potrebno pokazati vprasanja brez odgovorov) */
+ if(!$skipRow||(!$userDataPresent&&$this->skipEmpty==0)||$export_subtype == 'q_empty'){ /* ce je potrebno preskociti vrstico ALI (ni podatkov za prikaz, vendar je potrebno pokazati vprasanja brez odgovorov) */
+ if($i%2 != 0 && $export_format == 'pdf'){
+ if($enota == 5){ //ce je maxdiff
+ //$tex .= "\\rowcolor[gray]{.9}".$simbolTex.' & '; //pobarvaj ozadje vrstice
+ $tex .= "\\rowcolor[gray]{.9}".$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]).' & '; //pobarvaj ozadje vrstice
+ $userAnswerIndex[$spremenljivke['id']]++;
+ }else{
+ $tex .= "\\rowcolor[gray]{.9}".$navpicniOdgovori[$i-1]; //pobarvaj ozadje vrstice
+ }
+ }else{
+ if($enota == 5){ //ce je maxdiff
+ //$tex .= $simbolTex.' & ';
+ $tex .= $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]).' & ';
+ $userAnswerIndex[$spremenljivke['id']]++;
+ }else{
+ $tex .= $navpicniOdgovori[$i-1];
+ }
+ }
+
+ //tmp spremenljivka, ki je potrebna za pravilen izris stevilk, ce imamo trak
+ //$trakStartingNumberTmp = intval($trakStartingNumber);
+ $trakStartingNumberTmp = intval($trakStartingNumberTmp); //spremenil, zaradi intelephense napake
+
+ //ureditev spremenljivk za pravilen kasnejsi izris seznama ali rolete
+ $roletaAliSeznam = 0; //belezi, ali je tak tip podtabele ali tabele prisoten
+ $indeksRoleta = 1;
+ $noItem = 1;
+ if($spremenljivke['tip']==24){ //ce je kombinirana tabela, uredi enote znotraj te tabele
+ foreach($vodoravniOdgovoriEnota as $enota){
+ if($enota == 2 || $enota == 6){ //roleta ali izberite s seznama, uredi ogrodje za itemize, da se bo dalo zadevo pravilno izrisati
+ $roletaAliSeznam = 1;
+ $indeksRoleta = 1;
+ $noItem = 1;
+ }
+ }
+
+
+ //$numColSql = count($vodoravniOdgovoriEnota) + 1;
+
+
+ //echo "stevilo stolpcev za izpis kombinirane izračunan: ".$numColSql."</br>";
+ //echo "stevilo stolpcev za izpis kombinirane izračunan: ".count($vodoravniOdgovoriEnota)."</br>";
+ //print_r($vodoravniOdgovoriEnota);
+ //$numColSql = 4;
+ /* echo "Enote: ";
+ print_r($vodoravniOdgovoriEnota);
+ echo "</br>";
+ echo "Vodoravni odgvoroi spr id: ";
+ print_r($vodoravniOdgovoriSprId);
+ echo "</br>";
+ echo "Podatki: ";
+ print_r($data);
+ echo "</br>";
+ echo "Tip: ";
+ print_r($vodoravniOdgovoriTip);
+ echo "</br>"; */
+ }
+ //ureditev spremenljivk za pravilen kasnejsi izris seznama ali rolete - konec
+ //echo "___________________________________________________</br>";
+
+
+ $izpisRoletePresiroka = 0;
+
+ if($fillablePdf == 0){ //naveden pdf (brez vnosnih polj) in rtf
+ //echo "INDEKS vrstic: ".$i."</br>";
+ //IZRIS PO STOLPCIH
+ //echo "___________________________________________________</br>";
+ //echo "stevilo stolpcev izpis: ".$numColSql."</br>";
+ for($j = 1; $j < $numColSql; $j++){ //izris posameznega stolpca v vrstici
+
+ //for($j = 1; $j <= $numColSql; $j++){ //izris posameznega stolpca v vrstici #################### PAZI!!! DODAL ROČNO ZA TESTIRANJE
+ if($spremenljivke['tip']==24){ //ce je kombinirana tabela, uredi enote znotraj te tabele
+
+ if($presirokaKombo == 1 && count($data) != 0 && ($enota == 2 || $enota == 6)){
+ $enota = $vodoravniOdgovoriEnota[0];
+ }else{
+ $enota = $vodoravniOdgovoriEnota[$j-1];
+ }
+
+ //$enota = $vodoravniOdgovoriEnota[$j-1];
+ $sprID = $vodoravniOdgovoriSprId[$j-1];
+
+
+ //echo "Odgovori: ".$vodoravniOdgovori[$j-1]."</br>";
+ //echo "INDEKS: ".$j."</br>";
+ //echo "id spremenljivke: ".$sprID."</br>";
+ //echo "enota tukaj: ".$enota."</br>";
+ //if($j == 1){
+ /* echo "___________________________________________________</br>";
+ echo "Enote: ";
+ print_r($vodoravniOdgovoriEnota);
+ echo "</br>";
+ echo "Vodoravni odgovori spr id: ";
+ print_r($vodoravniOdgovoriSprId);
+ echo "</br>";
+ echo "Odgovori: ";
+ print_r($vodoravniOdgovori);
+ echo "</br>";
+ echo "Tip: ";
+ print_r($vodoravniOdgovoriTip);
+ echo "</br>"; */
+
+ /* echo "indeks for zanke: ".($j-1)."</br>";
+ echo "enota for zanke: ".($enota)."</br>";
+ echo "spr for zanke: ".($sprID )."</br>";
+ echo "___________________________________________________</br>"; */
+ //}
+ }
+
+ if($enota==0||$enota==1||$enota==3||$enota==11||$enota==12||$spremenljivke['tip']==19||$spremenljivke['tip']==20){ //klasika ali diferencial ali VAS ali slikovni tip ali multitext ali multinumber
+ if(($trak == 1 && $enota != 3 && $spremenljivke['tip'] == 6)||($spremenljivke['tip']==19||$spremenljivke['tip']==20)){ //ce je trak ali multitext
+ if($j<=$spremenljivke['grids']){ //ce so stolpci, ki vsebujejo trak s stevilkami ali textbox-e
+ if($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je multitext ali multinumber
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je odgovor respondenta ali vec respondentov
+ $tex .= "& ".$simbolTex[$indeksOdgovorovRespondentMultiNumText];
+ }elseif($export_subtype=='q_empty'||$export_subtype=='q_comment'){
+ $tex .= "& ".$simbolTex;
+ }
+ }else{
+ $tex .= '& '.($trakStartingNumberTmp); //prikazovanje brez obrob celic
+
+ //$tabela .= '& \multicolumn{1}{|c|}{'.($trakStartingNumberTmp).'} '; //1. moznost z navpicnimi obrobami
+
+ //2. moznost z navpicnimi obrobami
+ /*if($j==1){ //ce je prvi stolpec, ko je trak
+ $tabela .= '& \multicolumn{1}{|c}{'.($trakStartingNumberTmp).'} ';
+ }else{
+ $tabela .= '& \multicolumn{1}{c|}{'.($trakStartingNumberTmp).'} ';
+ } */
+ $trakStartingNumberTmp++;
+ }
+ }else{ //drugace so missing-i, kjer je potrebno izrisati ustrezen simbol (radio button)
+ if($enota==0&&($spremenljivke['tip']==6||$spremenljivke['tip']==16)){ //ce je klasicna tabela ali multitext ali multinumber
+ $tex .= "& ".$simbolTex;
+ }elseif($spremenljivke['tip']==19||$spremenljivke['tip']==20){//ce je multitext ali multinumber, izrisi missing simbol kot radio
+ if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je odgovor respondenta ali vec respondentov
+ $tex .= "& ".$simbolTex[$indeksOdgovorovRespondentMultiNumText];
+ }else{
+ $radioButtonTex = ($export_format=='pdf'?"{\Large $\ocircle$}" : "\\includegraphics[scale=".RADIO_BTN_SIZE."]{".$this->path2Images."radio}");
+ $tex .= "& ".$radioButtonTex;
+ }
+ //$tex .= "& ".$radioButtonTex;
+
+ //echo "radio button, ko je missing: ".$radioButtonTex."</br>";
+ }
+ }
+ }else{
+ if($spremenljivke['tip']==24){ //ce je kombinirana tabela, s klasicno podtabelo
+
+ //$tex .= "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $vodoravniOdgovoriTip[$j-1], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ //$test = "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $vodoravniOdgovoriTip[$j-1], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ //echo "vodoravni odgovori tip ".$vodoravniOdgovoriTip[$j-1]." $i</br>";
+ //echo "tip exp: ".$export_data_type."</br>";
+ //echo "testna koda $test z enoto $enota</br>";
+
+ if($export_data_type==0 || $export_data_type==1 || ($export_data_type==2 && $vodoravniOdgovoriTip[$j-1] != 6)){ //ce je razsirjen izvoz ALI je skrcen izvoz IN ni klasicna tabela
+ $tex .= "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $vodoravniOdgovoriTip[$j-1], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ //$test = "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $vodoravniOdgovoriTip[$j-1], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ //echo "testna koda $test z enoto $enota</br>";
+ //echo "tip exp: ".$export_data_type."</br>";
+ //echo $vodoravniOdgovoriTip[$j-1]."</br>";
+
+ }else{
+ $tex .= ' & \\textcolor{crta}{\footnotesize{'.$data[$userAnswerIndex[$spremenljivke['id']]].'}}';
+ //echo "vodoravni odgovori tip ".$vodoravniOdgovoriTip[$j-1]." $i</br>";
+ }
+ /* elseif($export_data_type==2 && $vodoravniOdgovoriTip[$j-1]){ //ce je skrcen izvoz IN
+
+ } */
+
+ }else{ //ce so ostali tipi vprasanj
+ if($enota == 12){ //ce je slikovni tip
+ $podatekSlikovniTip = $podatekZaSlikovniTip;
+ if($j <= $podatekSlikovniTip){
+ $podatekSlikovniTipTmp = $podatekSlikovniTip;
+ }else{
+ $podatekSlikovniTipTmp = 0;
+ }
+ $tex .= "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0,
+ $podatekSlikovniTipTmp, $enota, $j, '', $spremenljivke['id']);
+ }else{
+ $tex .= "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]], $enota, $j, '', $spremenljivke['id']);
+ }
+ //echo "tukaj ".$spremenljivke['id']." </br>";
+ //echo "userAnswerData: ".$data[$userAnswerIndex[$spremenljivke['id']]]."</br>";
+ }
+ }
+ }elseif($enota==2||$enota==6){ //roleta ali izberite s seznama
+ if($export_format == 'pdf'){ //ce je pdf
+ $beginItemize = '& \begin{itemize}[leftmargin=*]'; //zacetek itemize, ce je pdf
+ }else{
+ $beginItemize = '& \begin{itemize}'; //zacetek itemize, ce je rtf
+ }
+ if($spremenljivke['tip']!=24){ //ce ni kombinirana tabela
+ if($j==1){ //ce je prvi mozen odgovor v roleti ali seznamu
+ $tex .= $beginItemize; //zacetek itemize
+ }
+ //$tex .= '\item[] '.$vodoravniOdgovori[$j-1]; //izris odgovora v roleti ali seznamu kot item
+ }/* elseif($spremenljivke['tip']==24){ //ce je kombinirana tabela
+ if($presirokaKombo == 0){ //ce ni presiroka kombinirana tabela, zacni z itemize
+ if($roletaAliSeznam){ //ce je zacetek seznama ali rolete
+ //$tex .= $beginItemize; //zacetek itemize
+ //$tex .= ' & ';
+ $roletaAliSeznam = 0;
+ }
+ }
+ } */
+
+ if($export_subtype=='q_empty'){ //ce je prazen vprasalnik
+ //echo count($vodoravniOdgovori);
+ if($spremenljivke['tip']==24){ //ce je kombinirana tabela z izberite s seznama (ali roleto)
+ //echo "id spremenljivk $sprID ".$vodoravniOdgovoriSprId[$j]." za indeks $j </br>";
+ //$tex .= ' & '.$vodoravniOdgovori[$j-1]; //izpis odgovora
+ //$tex .= ' & radio'; //izpis kot radio odgovora
+ $tex .= "& ".$this->getAnswerSymbol($export_format, $fillablePdf, $vodoravniOdgovoriTip[$j-1], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ }
+ else{ //ce je roleta ali seznam
+ if($i==1){ //samo za prvo vrstico izpisi vse mozne odgovore v roleti
+ $tex .= '\item[] '.$vodoravniOdgovori[$j-1]; //izris odgovora v roleti kot item
+ }elseif($j==1){
+ $tex .= '\item[] '; //prazno vrstico
+ }
+ }
+ }else{ //drugace, ce je vprasalnik z odgovori
+ if($spremenljivke['tip'] != 24){ //ce ni kombinirana tabela z izberite s seznama (ali roleto)
+ if($data[$userAnswerIndex[$spremenljivke['id']]]==($indeksRoleta)){ //ce je prisoten podatek za doloceni indeks seznama, ga izpisi
+ //$tex .= '& \\textcolor{crta}{'.$vodoravniOdgovori[$j-1].'}'; //izris odgovora respondenta v roleti ali seznamu
+ //$tex .= '& \\textcolor{crta}{\footnotesize{'.$vodoravniOdgovori[$j-1].'}}'; //izris odgovora respondenta v roleti ali seznamu
+ if($export_data_type==0||$export_data_type==2){ //ce skrcen izvoz
+ $tex .= '& \\textcolor{crta}{\footnotesize{'.$vodoravniOdgovori[$j-1].'}}'; //izris odgovora respondenta v roleti ali
+ }else{ //drugace, ce je razsirjen izvoz
+ $tex .= '\item[] \\textcolor{crta}{\footnotesize{'.$vodoravniOdgovori[$j-1].'}}'; //izris odgovora respondenta v roleti ali
+ }
+ $noItem = 0;
+
+ }else{
+ //echo "tip exp: ".$export_data_type."</br>";
+ if($export_data_type==0||$export_data_type==2){ //ce skrcen izvoz
+ $tex .= ' & '.$vodoravniOdgovori[$j-1];
+ }else{ //drugace, ce je razsirjen izvoz
+
+ }
+
+ }
+ }else{ //ce je kombinirana tabela z izberite s seznama (ali roleto)
+ $tex .= ' & \\textcolor{crta}{\footnotesize{'.$data[$userAnswerIndex[$spremenljivke['id']]].'}}';
+ /* echo "odgovor : ".$data[$userAnswerIndex[$spremenljivke['id']]]."</br>";
+ print_r($data); */
+
+ }
+
+ }
+
+ $indeksRoleta++;
+ /* echo "indeks za testirati tale del: ".$j."</br>";
+ echo "spremenljivka sprID: ".$sprID."</br>";
+ echo "spremenljivka odoravniOdgovoriSprId: ".$vodoravniOdgovoriSprId[$j]."</br>"; */
+
+
+
+ if($spremenljivke['tip']==24&&$sprID!=$vodoravniOdgovoriSprId[$j]){//ce je naslednji ID spremenljivke razlicen od trenutnega ID
+ if($presirokaKombo == 0){
+ //$tex .= '\end{itemize}'; //zakljucek itemize
+ }
+ $roletaAliSeznam = 1;
+ }
+
+
+ }elseif($enota == 4){ //ena moznost proti drugi
+ //$tex .= '& '.$simbolTex.' & '.$lang['srv_tip_sample_t6_4_vmes'].' & '.$simbolTex;
+ //$this->getAnswerSymbol($export_format, $fillablePdf, $vodoravniOdgovoriTip[$j-1], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]])
+ //echo "userAnswerData: ".$data[$userAnswerIndex[$spremenljivke['id']]]." ".$spremenljivke['id']."</br>";
+ //echo "V latexSurveyElement </br>";
+ //echo "userAnswerData: ".$data[$userAnswerIndex[$spremenljivke['id']]]." </br>";
+ //echo "indeks: ".$userAnswerIndex[$spremenljivke['id']]." </br>";
+ if($data[$userAnswerIndex[$spremenljivke['id']]]==1){
+ $simbolTex1=$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ $simbolTex2=$simbolTex;
+ //echo "levo </br>";
+ }elseif($data[$userAnswerIndex[$spremenljivke['id']]]==2){
+ $simbolTex1=$simbolTex;
+ $simbolTex2=$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, 1);
+ //echo "desno</br>";
+ }elseif($data[$userAnswerIndex[$spremenljivke['id']]]==''){
+ $simbolTex1=$simbolTex;
+ $simbolTex2=$simbolTex;
+ $simbolTex3='';
+ }
+ $tex .= '& '.$simbolTex1.' & '.$lang['srv_tip_sample_t6_4_vmes'].' & '.$simbolTex2;
+ //echo "userAnswerData: ".$data[$userAnswerIndex[$spremenljivke['id']]]."</br>";
+ }elseif($enota == 5){ //maxdiff
+ //$tex .= $navpicniOdgovori[$i-1].' & '.$simbolTex;
+ $tex .= $navpicniOdgovori[$i-1].' & '.$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ }elseif($enota == 8){ //tabela da/ne
+ //$tex .= ' & '.$simbolTex;
+ $tex .= ' & '.$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ }
+
+ $indeksOdgovorovRespondentMultiNumText++;
+
+ $userAnswerIndex[$spremenljivke['id']]++;
+ //echo "simbolTex: ".$simbolTex."</br>";
+ } //IZRIS PO STOLPCIH - KONEC
+ }else if($fillablePdf == 1){
+ $isCheckBox = null;
+ for($j = 1; $j < $numColSql; $j++){
+ if($isCheckBox){
+ $tex .= '& {\CheckBox[name=checkbox_'.$j.'_'.$i.',checkboxsymbol=\ding{56}]{}}';
+ }else{
+ $tex .= '& {\ChoiceMenu[radio, name=radio_'.$i.',radiosymbol=\ding{108}]{}{='.$j.'}}';
+ }
+ }
+ }
+
+ if($enota==1 || $enota==4){ //ce je "diferencial tabela" ali "ena moznost proti drugi", dodaj se tekst v zadnjem stolpcu tabele
+ $tex .= ' & '.$navpicniOdgovori2[$i-1].' '; //tekst v drugem stolpcu ob symbol
+
+ if(($enota==4 && count($missingOdgovori)!=0)||($enota==1 && $trak==1 && count($missingOdgovori)!=0)){ //ce je "ena moznost proti drugi" in so missingi ALI je "diferencial tabela" na traku in so missingi
+ for($m=0;$m<count($missingOdgovori);$m++){
+ //$tex .= ' & '.$simbolTex;
+ $tex .= ' & '.$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]);
+ $userAnswerIndex[$spremenljivke['id']]++;
+ if($enota==4){ //ce je "ena moznost proti drugi"
+ $tex .= ' '.$missingOdgovori[$m]; //izpisi se missing odgovor
+ }
+ }
+ }
+
+ }
+
+ if($enota==5&&count($missingOdgovori)!=0){ //ce je maxdiff in so missingi
+ for($m=0;$m<count($missingOdgovori);$m++){
+ //$tex .= ' & '.$simbolTex.' '.$missingOdgovori[$m];
+ $tex .= ' & '.$this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $numColSql, 0, $data[$userAnswerIndex[$spremenljivke['id']]]).' '.$missingOdgovori[$m];
+ $userAnswerIndex[$spremenljivke['id']]++;
+ }
+ }
+
+ if(($enota == 2 || $enota == 6)&&$spremenljivke['tip']!=24){ //ce je roleta ali seznam in ni kombinirana tabela
+ $tex .= '\end{itemize}'; //zakljucek itemize
+
+ /* if($export_format == 'rtf'){ //ce je rtf
+ $tex .= ' \hline '; //dodaj crto na koncu vrstice
+ } */
+
+ }
+
+ $tex .= $texNewLine;
+ //echo "tex: ".$tex."</br>";
+ if($spremenljivke['tip']==24){
+ //$userAnswerIndex++;
+ }
+ }else{
+ $userAnswerIndex[$spremenljivke['id']]=$z;
+ }
+ if(($enota == 2 || $enota == 6)&&$spremenljivke['tip']!=24){ //ce je roleta ali seznam in ni kombinirana tabela
+ if($export_format == 'rtf'){ //ce je rtf
+ $tex .= ' \hline '; //dodaj crto na koncu vrstice
+ }
+ }
+ }
+ //IZRIS PO VRSTICAH - KONEC
+ //echo "tex: ".$tex."</br>";
+ return $tex;
+ }
+ #funkcija, ki skrbi za izris vrstic tabele (z multigrid) - konec ###########################################################
+
+ function getUserId() {return ($this->usr_id)?$this->usr_id:false;}
+
+ #funkcija, ki skrbi za preverjanje obstoja podatkov za vprasanja, ki niso grid ali kombinirana tabela
+ function GetUsersData($db_table=null, $spremenljivkeId=null, $spremenljivkeTip=null, $usr_id=null, $loop_id_raw=null){
+ $userDataPresent = 0; //belezi, ali je odgovor respondenta prisoten in je indeks za določena polja, ki shranjujejo podatke o odgovorih respondenta
+ $loop_id = $loop_id_raw == null ? " IS NULL" : " = '".$loop_id_raw."'";
+ //echo "loop_id v GetUsersData: ".$loop_id."</br>";
+
+ // če imamo vnose, pogledamo kaj je odgovoril uporabnik
+ //if( in_array($spremenljivkeTip, array(21, 7, 8, 18)) ){ //ce je tip besedilo ali stevilo ali datum ali vsota
+ if( in_array($spremenljivkeTip, array(21, 4, 7, 8, 18)) ){ //ce je tip besedilo ali besedilo staro (4) ali stevilo ali datum ali vsota
+ $sqlUserAnswerString ="SELECT text FROM srv_data_text".$db_table." WHERE spr_id='".$spremenljivkeId."' AND usr_id='".$usr_id."' AND loop_id $loop_id ";
+ }elseif($spremenljivkeTip==17){ //ce je razvrscanje
+ //$sqlUserAnswer = sisplet_query("SELECT vrstni_red FROM srv_data_rating WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
+ //$sqlUserAnswerString = "SELECT vrstni_red FROM srv_data_rating WHERE spr_id='".$spremenljivkeId."' AND usr_id='".$usr_id."' ";
+ $sqlUserAnswerString = "SELECT vrstni_red FROM srv_data_rating WHERE spr_id='".$spremenljivkeId."' AND usr_id='$usr_id' AND loop_id $loop_id ";
+ //echo $sqlUserAnswerString."</br>";
+ }elseif($spremenljivkeTip==26){ //ce je lokacija
+ //$sqlUserAnswerString ="SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='".$spremenljivkeId."' AND usr_id='".$usr_id."' ";
+ $sqlUserAnswerString ="SELECT IF(dm.lat > 0, dm.lat, vm.lat) as lat, IF(dm.lng > 0, dm.lng, vm.lng) as lng, IF(dm.address != \"\", dm.address, vm.address) as address, text FROM srv_data_map as dm "
+ . "LEFT JOIN (SELECT lat, lng, address, vre_id FROM srv_vrednost_map) AS vm on vm.vre_id=dm.vre_id "
+ . "WHERE spr_id='".$spremenljivkeId."' AND usr_id='$usr_id' AND loop_id $loop_id ";
+ //echo $sqlUserAnswerString."</br>";
+ }elseif($spremenljivkeTip==27){ //ce je heatmap
+ //$sqlUserAnswerString ="SELECT lat, lng, address, text FROM srv_data_heatmap WHERE spr_id='".$spremenljivkeId."' AND usr_id='".$usr_id."' ";
+ $sqlUserAnswerString ="SELECT lat, lng, address, text FROM srv_data_heatmap WHERE spr_id='".$spremenljivkeId."' AND usr_id='$usr_id' AND loop_id $loop_id ";
+ //echo $sqlUserAnswerString."</br>";
+ }else{
+ //$sqlUserAnswerString = "SELECT vre_id FROM srv_data_vrednost".$db_table." WHERE spr_id='$spremenljivkeId' AND usr_id=$usr_id";
+ $sqlUserAnswerString = "SELECT vre_id FROM srv_data_vrednost".$db_table." WHERE spr_id='$spremenljivkeId' AND usr_id='$usr_id' AND loop_id $loop_id";
+ //echo $sqlUserAnswerString."</br>";
+ }
+
+ $sqlUserAnswer = sisplet_query($sqlUserAnswerString);
+
+ if( in_array($spremenljivkeTip, array(21, 4, 7, 8, 18, 17)) ){//ce je tip besedilo ali stevilo ali datum ali vsota ali razvrscanje
+ $rowAnswers = mysqli_fetch_assoc($sqlUserAnswer);
+ if($rowAnswers){ //ce je kaj v bazi
+ //echo "Nekaj je v bazi za spremenljivko".$spremenljivkeId." in usr ".$usr_id."</br>";
+ $userDataPresent++;
+ }
+ }else{
+ if($sqlUserAnswer){ //ce je kaj v bazi
+ while ($rowAnswers = mysqli_fetch_assoc($sqlUserAnswer)){
+ if($spremenljivkeTip==26||$spremenljivkeTip==27){
+ //$this->userAnswer = $rowAnswers;
+ $this->userAnswer[$userDataPresent] = $rowAnswers;
+ //echo "rowAnswers: ".$this->userAnswer['address'].' za odgovore tip '.$spremenljivkeTip.' id '.$spremenljivkeId.' usr '.$usr_id.'</br>';
+ $userDataPresent++;
+ }else{
+ $this->userAnswer[$rowAnswers['vre_id']] = $rowAnswers['vre_id'];
+ //echo "rowAnswers: ".$rowAnswers['vre_id'].' za odgovore tip '.$spremenljivkeTip.' id '.$spremenljivkeId.' usr '.$usr_id.'</br>';
+ if($rowAnswers['vre_id']>0){
+ $userDataPresent++;
+ }
+ }
+ }
+ }
+ }
+ //echo "userDataPresent za tip ".$spremenljivkeTip." id ".$spremenljivkeId." usr ".$usr_id." je:".$userDataPresent." in loop: $loop_id</br>";
+ return $userDataPresent;
+ }
+ #funkcija, ki skrbi za preverjanje obstoja podatkov za vprasanja, ki niso grid ali kombinirana tabela - konec
+
+ #funkcija, ki skrbi za preverjanje obstoja podatkov za vprasanja z grid
+ function GetUsersDataGrid($spremenljivke=null, $db_table=null, $rowVrednost=null, $rowVsehVrednosti=null, $usr_id=null, $subtip=null, $loop_id_raw=null, $export_data_type=null){
+ $loop_id = $loop_id_raw == null ? " IS NULL" : " = '".$loop_id_raw."'";
+
+ // poiščemo kaj je odgovoril uporabnik: PREVERITI, CE JE POTREBEN STAVEK Z LOOP IN KDAJ JE TO AKTUALNO
+ if(($spremenljivke['tip']==16)||($spremenljivke['tip']==6&&$spremenljivke['enota']==3)){ //ce je grid checkbox ali dvojna tabela
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' AND loop_id $loop_id");
+ //$sqlString = "SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+
+ //$sqlString = "SELECT grd_id, vre_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+ $sqlString = "SELECT grd_id, vre_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']." AND loop_id $loop_id";
+
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']);
+ $sqlUserAnswer = sisplet_query($sqlString);
+ //}elseif($spremenljivke['tip']==6){ //ce je grid radio
+ }elseif($spremenljivke['tip']==6){ //ce je grid radio
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
+
+ //$sqlString ="SELECT grd_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+
+ //$sqlString ="SELECT grd_id, vre_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+ $sqlString ="SELECT grd_id, vre_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']." AND loop_id $loop_id";
+ //echo $sqlString."</br>";
+ $sqlUserAnswer = sisplet_query($sqlString);
+
+ //echo $sqlString."</br>";
+ }elseif($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je grid besedila ali stevil
+ $sqlString = "SELECT grd_id, text, vre_id FROM srv_data_textgrid".$db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']);
+ //echo "sqlString: ".$sqlString."</br>";
+ $sqlUserAnswer = sisplet_query($sqlString);
+ }elseif($spremenljivke['tip']==24){ //ce je kombo
+ //echo "Subtip kombo vprasanja: ".$subtip."</br>";
+ //echo "enota kombo vprasanja: ".$rowVrednost['enota']."</br>";
+
+ if($subtip==6){ //ce je grid radio
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$usr_id."' AND vre_id = ".$rowVrednost['id']);
+ //$sqlString ="SELECT grd_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = ".$rowVrednost['id'];
+ //$sqlString ="SELECT grd_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+ //if($rowVrednost['enota'] != 2 && $rowVrednost['enota'] != 6){ //ce ni roleta ali seznam
+ if($rowVrednost['enota'] != 2 && $rowVrednost['enota'] != 6 && ($export_data_type == 1)){ //ce ni roleta in seznam IN je razsirjen izvoz
+ $sqlString ="SELECT grd_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']." AND loop_id $loop_id";
+ }else{ //ce je roleta ali seznam
+ //$sqlString ="SELECT grd_id FROM srv_data_grid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id";
+ $sqlString ="SELECT g.naslov, gdata.grd_id FROM srv_grid g, srv_data_grid".$db_table." gdata WHERE g.id=gdata.grd_id AND g.spr_id = '".$rowVrednost['spr_id']."' AND gdata.usr_id = '".$usr_id."' AND gdata.vre_id = '".$rowVrednost['id']."' AND gdata.loop_id $loop_id";
+ }
+
+ //echo $sqlString."</br>";
+ $sqlUserAnswer = sisplet_query($sqlString);
+
+ //echo $sqlString."</br>";
+ }elseif($subtip==16){ //ce je grid checkbox ali dvojna tabela
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' AND loop_id $loop_id");
+
+ //$sqlString = "SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+ $sqlString = "SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']." AND loop_id $loop_id";
+ //$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id']);
+ $sqlUserAnswer = sisplet_query($sqlString);
+ }elseif($subtip==19||$subtip==20){ //ce je grid besedila ali stevil
+ $sqlString = "SELECT grd_id, text FROM srv_data_textgrid".$db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$usr_id."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = ".$rowVsehVrednosti['id'];
+
+ $sqlUserAnswer = sisplet_query($sqlString);
+
+ //$this->userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer v funkciji: ".$this->userAnswer['text'].'</br>';
+ }
+ }
+
+ //echo $sqlString."</br>";
+ //$this->userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ //echo "userAnswer v funkciji: ".$this->userAnswer['grd_id'].'</br>';
+ //echo "userAnswer v funkciji: ".$userAnswer['text'].'</br>';
+ //echo "userAnswer v funkciji: ".$userAnswer['grd_id'].'</br>';
+
+ return $sqlUserAnswer;
+
+ }
+ #funkcija, ki skrbi za preverjanje obstoja podatkov za vprasanja z grid - konec
+
+ #funkcija, ki skrbi za preverjanje obstoja podatkov za vprasanja s kombinirano tabelo
+ function GetUsersDataKombinirana($spremenljivke=null, $db_table=null, $usr_id=null, $presirokaTabela=0, $loop_id_raw=null, $export_data_type=null){
+ //function GetUsersDataKombinirana($spremenljivke=null, $db_table=null, $usr_id=null, $questionText=null, $loop_id_raw=null, $export_data_type=null){
+ $userDataPresent = 0; //belezi, ali je odgovor respondenta prisoten in je indeks za določena polja, ki shranjujejo podatke o odgovorih respondenta
+ $userAnswerSprIds = array();
+ $userAnswerSprTip = array();
+ $userAnswerSprIdsIndex = 0;
+ $orStavek = '';
+ //$loop_id = $loop_id_raw == null ? " IS NULL" : " = '".$loop_id_raw."'";
+ $loop_id = $loop_id_raw;
+
+ #za pridobitev stevila vrstic
+ //echo "SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red </br>";
+ $sqlVrednostiKombo = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
+ $numRowsSql = mysqli_num_rows($sqlVrednostiKombo);
+ //echo $numRowsSql."</br>";
+ //echo $spremenljivke['id']."</br>";
+
+ #za pridobitev stevila vrstic - konec
+
+ #za pridobitev stevila stolpcev
+ $sqlStVrednostiKombo = sisplet_query("SELECT count(*) FROM srv_grid g, srv_grid_multiple m WHERE m.spr_id=g.spr_id AND m.parent='".$spremenljivke['id']."'");
+ $rowStVrednost = mysqli_fetch_array($sqlStVrednostiKombo); //stevilo stolpcev
+ $numColSql = $rowStVrednost['count(*)']; //stevilo vseh stolpcev
+ //echo "stevilo stolpcev: ".$numColSql."</br>";
+ #za pridobitev stevila stolpcev - konec
+
+ //echo "presirokaTabela: ".$presirokaTabela."</br>";
+ if($presirokaTabela==0){ //ce tabela ni presiroka
+ $sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND m.spr_id=s.id ORDER BY m.vrstni_red"); //pridobimo spr_id in tip podvprasanj, ki sestavljajo kombinirano tabelo
+ //echo "SELECT m.spr_id, s.tip FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND m.spr_id=s.id ORDER BY m.vrstni_red"."</br>";
+
+ while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
+ array_push($userAnswerSprIds, $rowSubGrid['spr_id'] ); //filanje polja s spr_id podvprasanj
+ array_push($userAnswerSprTip, $rowSubGrid['tip'] ); //filanje polja s tip podvprasanj
+ if($userAnswerSprIdsIndex){
+ $orStavek .= ' OR ';
+ }
+ //$orStavek .= "spr_id='".$rowSubGrid['spr_id']."' ";
+ $orStavek .= "v.spr_id='".$rowSubGrid['spr_id']."' ";
+ $userAnswerSprIdsIndex++;
+ }
+ }else{
+ $orStavek = "v.spr_id='".$spremenljivke['id']."' ";
+ }
+ //echo $orStavek."</br>";
+
+ //echo count($userAnswerSprTip)."</br>";
+
+ for($i=1;$i<=$numRowsSql;$i++){
+ //$sqlVrednostiString = "SELECT id, naslov, spr_id FROM srv_vrednost WHERE (".$orStavek.") AND vrstni_red=".($i).";";
+ //$sqlVrednostiString = "SELECT v.spr_id, v.naslov, s.tip, v.id FROM srv_vrednost v, srv_spremenljivka s WHERE v.spr_id=s.id AND (".$orStavek.") AND v.vrstni_red=".($i).";";
+ $sqlVrednostiString = "SELECT v.spr_id, v.naslov, s.tip, v.id, s.enota FROM srv_vrednost v, srv_spremenljivka s WHERE v.spr_id=s.id AND (".$orStavek.") AND v.vrstni_red=".($i).";";
+ //echo $sqlVrednostiString."</br>";
+ $sqlVrednosti = sisplet_query($sqlVrednostiString);
+ while($rowVrednosti = mysqli_fetch_assoc($sqlVrednosti)){
+ $sqlVsehVrednostiString = "SELECT id, naslov FROM srv_grid WHERE spr_id='".$rowVrednosti['spr_id']."' ORDER BY 'vrstni_red'";
+
+ //echo $sqlVsehVrednostiString."</br>";
+ //echo $rowVrednosti['tip']."</br>";
+ //echo $rowVrednosti['other']."</br>";
+ //echo "Vrednost: ".$rowVrednosti['spr_id']."</br>";
+ $sqlVsehVrednosti = sisplet_query($sqlVsehVrednostiString);
+ //echo mysqli_num_rows($sqlVsehVrednosti)."</br>";
+
+
+
+ $roletaZabelezena = 0;
+
+ while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednosti)){
+ if($roletaZabelezena == 0){
+ $sqlUserAnswer = $this->GetUsersDataGrid($spremenljivke, $db_table, $rowVrednosti, $rowVsehVrednosti, $usr_id, $rowVrednosti['tip'], $loop_id, $export_data_type);
+ }
+ $userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
+ if($rowVrednosti['tip']==19||$rowVrednosti['tip']==20){
+ $userAnswers[$userDataPresent] = $userAnswer['text'];
+ }else{
+ if($roletaZabelezena == 0){
+ //$userAnswers[$userDataPresent] = $userAnswer['grd_id'];
+ $userAnswers[$userDataPresent] = $userAnswer['naslov'];
+ //if($rowVrednosti['enota']==2 || $rowVrednosti['enota']==6){ //ce je roleta ali seznam
+ if($rowVrednosti['enota']==2 || $rowVrednosti['enota']==6 || ($export_data_type==2 && $rowVrednosti['tip']==6)){ //ce je roleta ali seznam
+ $roletaZabelezena = 1;
+ $userDataPresent++;
+ }else{
+ $userAnswers[$userDataPresent] = $userAnswer['grd_id'];
+ }
+
+ }
+ }
+ //echo $this->userAnswer[$userDataPresent]."</br>";
+ //echo "odgovori respondenta: ".$userAnswers[$userDataPresent]."</br>";
+ //echo "index userDataPresent: ".$userDataPresent."</br>";
+ /* if($rowVrednosti['enota']==2){
+ $roletaZabelezena = 1;
+ }*/
+ if($roletaZabelezena == 0){
+ $userDataPresent++;
+ }
+ }
+
+ }
+
+ }
+ //if($questionText){
+ //return $userDataPresent;
+ //}else{
+ //return $this->userAnswer;
+ return $userAnswers;
+ //}
+ }
+ #funkcija, ki skrbi za preverjanje obstoja podatkov za vprasanja s kombinirano tabelo - konec
+
+ #funkcija, ki skrbi za pridobitev operatorja iz stevilskega podatka ###########################################################
+ function GetOperator($operatorNum=null){
+ if ($operatorNum == 0){
+ $operator = $this->encodeText('+');
+ }elseif ($operatorNum == 1){
+ $operator = $this->encodeText('-');
+ }elseif ($operatorNum == 2){
+ $operator = $this->encodeText('*');
+ }elseif ($operatorNum == 3){
+ $operator = $this->encodeText('/');
+ }
+ return $operator;
+ }
+ #funkcija, ki skrbi za pridobitev operatorja iz stevilskega podatka - konec ###################################################
+
+ /**
+ * @desc V podanem stringu poisce spremenljivke in jih spajpa z vrednostmi
+ */
+ function dataPiping ($text='') {
+/* echo "text: ".$text."</br>";
+ echo "Usr_id: ".$this->usr_id."</br>";
+ echo "Loop_id: ".$this->loop_id."</br>";
+ echo "_____________________</br>"; */
+ Common::getInstance()->Init($this->anketa);
+ //echo Common::getInstance()->dataPiping($text, $this->usr_id, $this->loop_id);
+ return Common::getInstance()->dataPiping($text, $this->usr_id, $this->loop_id);
+ }
+
+
+} \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/textemp/.gitignore b/admin/survey/export/latexclasses/textemp/.gitignore
new file mode 100644
index 0000000..f3786c2
--- /dev/null
+++ b/admin/survey/export/latexclasses/textemp/.gitignore
@@ -0,0 +1,4 @@
+*
+!.gitignore
+!images
+!*.cls \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisAndOtherLandscape.cls b/admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisAndOtherLandscape.cls
new file mode 100644
index 0000000..535b617
--- /dev/null
+++ b/admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisAndOtherLandscape.cls
@@ -0,0 +1,100 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{latexTemplatePdfAnalysisAndOtherLandscape}
+\LoadClass[10pt]{article}
+%uporabljene knjiznice
+\usepackage[a4paper, landscape, left=20mm, right=20mm, headheight=1cm, top=1cm, bottom=2cm, footskip=3cm, includehead, includefoot, heightrounded]{geometry} % za robove, ipd.
+\usepackage{tabularx, booktabs} % za lazje urejanje in izris tabel (ni podprto v latex2rtf)
+\usepackage{color}
+\usepackage[dvipsnames]{xcolor} % za uporabo HTML in RGB barv
+\usepackage{pgf} % za aritmetiko z length
+\usepackage{printlen} %
+\usepackage{eurosym} % za izpis simbola €
+\usepackage[export]{adjustbox} % za poravnavo slik
+\usepackage[utf8]{inputenc} % za uporabo utf8
+\usepackage{amssymb} %za unicode simbole
+\usepackage{graphicx} % za prikazovanje slik in ostalih grafik
+%\usepackage[allfiguresdraft]{draftfigure}
+\usepackage{colortbl} %The pack­age al­lows rows and columns to be coloured, and even in­di­vid­ual cells
+\usepackage{fancyhdr} % za ureditev glav in nog
+\usepackage{montserrat} % za uporabo Montserrat pisave v dokumentu
+\usepackage{multirow} % za spajanje vrstic v tabeli
+\usepackage{hyperref}
+\usepackage{tikz} % za risanje crt, ki oznacujejo stevilo klikov v Status
+\usepackage{ltablex}
+\usepackage{seqsplit} % za samodejno razbijanje dolgih besed v tabelah
+\usepackage{url} %za razbijanje url-jev v tabelah
+\usepackage{textgreek} %za resevanje grskih crk
+\urlstyle{same} %nastavitev, da je font URL isti kot je font ostalega besedila (http://ctan.ijs.si/tex-archive/macros/latex/contrib/url/url.pdf)
+%definiranje uporabljenih barv
+\definecolor{besedilo}{HTML}{535050}
+\definecolor{crta}{HTML}{1e88e5}
+\definecolor{crtaGraf}{HTML}{ffa608}
+\definecolor{komentar}{HTML}{ff0000}
+%definiranje poravnav za tabele
+\hsize=294mm
+\newcolumntype{C}{>{\centering\arraybackslash}X} % za sredinsko poravnavo celice, ki se samodejno prilagaja sirini
+\newcolumntype{R}{>{\raggedleft\arraybackslash}X} % za desno poravnavo celice, ki se samodejno prilagaja sirini
+\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}} % za sredinsko poravnane zadeve v tabularx tabeli
+\newcolumntype{s}{>{\hsize=.55\hsize \centering\arraybackslash}X} % za sredinsko poravnane celice manjse dimenzije (0.55 navadne dimenzije)
+\newcolumntype{S}{>{\hsize=.2\hsize}X} % za celice manjse dimenzije (0.3 navadne dimenzije)
+\newcolumntype{b}{>{\hsize=.5\hsize}X} % za celice manjse dimenzije (0.5 navadne dimenzije)
+\newcolumntype{B}{>{\hsize=1.3\hsize}X} % za celico vecje dimenzije od navadne (1.3 navadne dimenzije)
+\newcolumntype{P}{>{\hsize=.1\hsize \centering\arraybackslash}X} % za fiksno 10% fiksno sirino stolpca, ki ima sredinsko poravnavo (npr. analiza prvi, levi stolpec)
+\newcolumntype{A}{>{\hsize=0.17\textwidth}X} % za fiksno sirino prvega stolpca@tabularx
+\newcolumntype{Y}{p{\dimexpr(\textwidth+1\arrayrulewidth+1\tabcolsep)/12\relax}} %za dolge tabele z reziduali in odstotki
+%definiranje spremenljivk (dolzin, ...)
+\newlength{\questionTotalLength}
+\newlength{\answerLength}
+\newlength{\questionLength}
+\newlength{\opombaLength}
+\newcounter{opomba}
+%definiranje novih ukazov, funkcij, nastavitev potrebnih za izris dolocenih delov besedila
+\linespread{1} % za razmik med vrsticami
+\fontencoding{T1}\selectfont % za encode besedila
+\renewcommand{\familydefault}{\sfdefault} % za izbiro novega fonta Montserrat
+\color{besedilo} % za izbiro barve besedila
+\newenvironment{analysis} % za ureditev prostora za izpis analize
+ {\parindent0pt \fontsize{10}{12} \selectfont }
+ { }
+\newenvironment{tableAnalysis} % za ureditev prostora za izpis tabele v analizah
+ {\parindent0pt \fontsize{6}{12} \selectfont }
+ { }
+\newenvironment{status} % za ureditev prostora za izpis statusa
+ {\parindent0pt \fontsize{10}{12} \selectfont }
+ { }
+ \newenvironment{tableStatus} % za ureditev prostora za izpis tabele v status
+ {\parindent0pt \fontsize{8}{12} \selectfont }
+ { }
+ \newenvironment{other} % za ureditev prostora za izpis tabele v status
+ {\parindent0pt \fontsize{8}{12} \selectfont }
+ { }
+\newenvironment{absolutelynopagebreak} % za ureditev dela besedila, kjer ne sme biti odsek strani; za prepreciti prelome strani, kjer ni potrebno
+ {\par\nobreak\vfil\penalty0\vfilneg
+ \vtop\bgroup}
+ {\par\xdef\tpd{\the\prevdepth}\egroup
+ \prevdepth=\tpd}
+\newcommand{\forceindent}{\leavevmode{\parindent=1em\indent}} %
+\pdfcompresslevel=0 %uncompressed PDFs za pohitritev
+\pdfobjcompresslevel=0 %uncompressed PDFs za pohitritev
+%vse za glavo in nogo
+\pagestyle{fancy}
+\fancyhf{}
+\setlength{\headheight}{41pt} %Make it at least 40.35403pt.
+\renewcommand{\headrule}{\hbox to\headwidth{\color{crta}\leaders\hrule height \headrulewidth\hfill}} %ureditev druge barve za crto glave
+\renewcommand{\headrulewidth}{6pt} %debelina crte glave
+\renewcommand{\footrulewidth}{0.25pt} %debelina crte noga
+\setlength{\headsep}{1.5cm} %odmik iz roba strani
+\newcommand{\headerfooter}[5]{ %funkcija za izpis glave in noge
+ \lhead{\begin{tabular}{@{} m{135mm} } #1 \end{tabular}}
+ \rhead{\includegraphics[#4]{#2}}
+ \fancyfoot[l]{www.1ka.si}
+ \fancyfoot[r]{\thepage}
+}
+%vse za glavo in nogo - konec
+
+\DeclareUnicodeCharacter{200B}{{\hskip 0pt}}
+\DeclareUnicodeCharacter{03C7}{$\chi$}
+\DeclareUnicodeCharacter{2265}{$\geq$}
+\DeclareUnicodeCharacter{03B5}{$\epsilon$
+\DeclareUnicodeCharacter{2003}{$\enspace$}}
+\DeclareUnicodeCharacter{0014}{$\thinspace$} %ni ta pravi nadomestek, ker v Latexu tak simbol ne obstaja \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisPortrait.cls b/admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisPortrait.cls
new file mode 100644
index 0000000..e21e21a
--- /dev/null
+++ b/admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisPortrait.cls
@@ -0,0 +1,98 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{latexTemplatePdfAnalysisPortrait}
+\LoadClass[10pt]{article}
+%uporabljene knjiznice
+%\usepackage[a4paper, portrait, left=20mm, right=20mm, headheight=1cm, top=1cm, bottom=2cm, footskip=3cm, includehead, includefoot, heightrounded]{geometry} % za robove, ipd.
+\usepackage[a4paper, portrait, left=15mm, right=15mm, headheight=1cm, top=1cm, bottom=2cm, footskip=3cm, includehead, includefoot, heightrounded]{geometry} % za robove, ipd.
+\usepackage{tabularx, booktabs} % za lazje urejanje in izris tabel (ni podprto v latex2rtf)
+\usepackage{ltablex} % Mod­i­fies the tab­u­larx en­vi­ron­ment to com­bine the fea­tures of the tab­u­larx pack­age (auto-sized columns in a fixed width ta­ble) with those of the longtable pack­age (multi-page ta­bles)
+\usepackage{color}
+\usepackage[dvipsnames]{xcolor} % za uporabo HTML in RGB barv
+\usepackage{pgf} % za aritmetiko z length
+\usepackage{printlen} %
+\usepackage{eurosym} % za izpis simbola €
+\usepackage[export]{adjustbox} % za poravnavo slik
+\usepackage[utf8]{inputenc} % za uporabo utf8
+\usepackage{amssymb} %za unicode simbole
+\usepackage{graphicx} % za prikazovanje slik in ostalih grafik
+\usepackage{colortbl} %The pack­age al­lows rows and columns to be coloured, and even in­di­vid­ual cells
+\usepackage{fancyhdr} % za ureditev glav in nog
+\usepackage{montserrat} % za uporabo Montserrat pisave v dokumentu
+\usepackage{multirow} % za spajanje vrstic v tabeli
+\usepackage{hyperref}
+\usepackage{tikz} % za risanje
+\usepackage{seqsplit} % za samodejno razbijanje dolgih besed v tabelah
+\usepackage{url} %za razbijanje url-jev v tabelah
+\usepackage{textgreek} %za resevanje grskih crk
+\urlstyle{same} %nastavitev, da je font URL isti kot je font ostalega besedila (http://ctan.ijs.si/tex-archive/macros/latex/contrib/url/url.pdf)
+%\usepackage{adjustbox} %za samodejno dimenzioniranje tabel
+%definiranje uporabljenih barv
+\definecolor{besedilo}{HTML}{535050}
+\definecolor{crta}{HTML}{1e88e5}
+\definecolor{crtaGraf}{HTML}{ffa608}
+\definecolor{komentar}{HTML}{ff0000}
+%definiranje poravnav za tabele
+\newcolumntype{C}{>{\centering\arraybackslash}X} % za sredinsko poravnavo celice, ki se samodejno prilagaja sirini
+\newcolumntype{R}{>{\raggedleft\arraybackslash}X} % za desno poravnavo celice, ki se samodejno prilagaja sirini
+\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}} % za sredinsko poravnane zadeve v tabularx tabeli
+\newcolumntype{s}{>{\hsize=.55\hsize \centering\arraybackslash}X} % za sredinsko poravnane celice manjse dimenzije (0.55 navadne dimenzije)
+\newcolumntype{S}{>{\hsize=.2\hsize}X} % za celice manjse dimenzije (0.3 navadne dimenzije)
+\newcolumntype{b}{>{\hsize=.5\hsize}X} % za celice manjse dimenzije (0.5 navadne dimenzije)
+\newcolumntype{B}{>{\hsize=1.3\hsize}X} % za celico vecje dimenzije od navadne (1.3 navadne dimenzije)
+\newcolumntype{P}{>{\hsize=.1\hsize \centering\arraybackslash}X} % za fiksno 10% fiksno sirino stolpca, ki ima sredinsko poravnavo (npr. analiza prvi, levi stolpec)
+\newcolumntype{A}{>{\hsize=0.17\textwidth}X} % za fiksno sirino prvega stolpca@tabularx
+%\newcolumntype{A}{>{\hsize=0.1\textwidth}X} % za fiksno sirino prvega stolpca@tabularx
+%definiranje spremenljivk (dolzin, ...)
+\newlength{\questionTotalLength}
+\newlength{\answerLength}
+\newlength{\questionLength}
+\newlength{\opombaLength}
+\newcounter{opomba}
+%definiranje novih ukazov, funkcij, nastavitev potrebnih za izris dolocenih delov besedila
+%\linespread{1.5} % za razmik med vrsticami
+\linespread{1.2} % za razmik med vrsticami
+\fontencoding{T1}\selectfont % za encode besedila
+\renewcommand{\familydefault}{\sfdefault} % za izbiro novega fonta Montserrat
+\renewcommand{\arraystretch}{1.5}
+\color{besedilo} % za izbiro barve besedila
+\newenvironment{analysis} % za ureditev prostora za izpis analize
+ {\parindent0pt \fontsize{6}{6} \selectfont}
+ { }
+\newenvironment{tableAnalysis} % za ureditev prostora za izpis tabele v analizah
+ {\parindent0pt \fontsize{6}{6} \selectfont}
+ { }
+\newenvironment{tableStatus} % za ureditev prostora za izpis tabele v status
+ %{\parindent0pt \fontsize{8}{12} \selectfont }
+ {\parindent0pt \fontsize{8}{9} \selectfont }
+ { }
+\newenvironment{other} % za ureditev prostora za izpis tabele v status
+ %{\parindent0pt \fontsize{8}{12} \selectfont }
+ {\parindent0pt \fontsize{8}{9} \selectfont }
+ { }
+\newcommand{\forceindent}{\leavevmode{\parindent=1em\indent}} %
+\pdfcompresslevel=0 %uncompressed PDFs za pohitritev
+\pdfobjcompresslevel=0 %uncompressed PDFs za pohitritev
+%vse za glavo in nogo
+\pagestyle{fancy}
+\fancyhf{}
+\setlength{\headheight}{41pt} %Make it at least 40.35403pt.
+\renewcommand{\headrule}{\hbox to\headwidth{\color{crta}\leaders\hrule height \headrulewidth\hfill}} %ureditev druge barve za crto glave
+\renewcommand{\headrulewidth}{6pt} %debelina crte glave
+\renewcommand{\footrulewidth}{0.25pt} %debelina crte noga
+\setlength{\headsep}{1.5cm} %odmik iz roba strani
+\newcommand{\headerfooter}[5]{ %funkcija za izpis glave in noge
+ \lhead{\begin{tabular}{@{} m{135mm} } #1 \end{tabular}}
+ \rhead{\includegraphics[#4]{#2}}
+ \fancyfoot[l]{www.1ka.si}
+ \fancyfoot[r]{\thepage}
+}
+%vse za glavo in nogo - konec
+
+\DeclareUnicodeCharacter{2212}{-}
+\DeclareUnicodeCharacter{030C}{Č}
+\DeclareUnicodeCharacter{200B}{{\hskip 0pt}}
+\DeclareUnicodeCharacter{03C7}{$\chi$}
+\DeclareUnicodeCharacter{2265}{$\geq$}
+\DeclareUnicodeCharacter{03B5}{$\epsilon$}
+\DeclareUnicodeCharacter{2003}{$\enspace$}
+\DeclareUnicodeCharacter{0014}{$\thinspace$} %ni ta pravi nadomestek, ker v Latexu tak simbol ne obstaja \ No newline at end of file
diff --git a/admin/survey/export/latexclasses/textemp/latexTemplatePdfSurvey.cls b/admin/survey/export/latexclasses/textemp/latexTemplatePdfSurvey.cls
new file mode 100644
index 0000000..378680c
--- /dev/null
+++ b/admin/survey/export/latexclasses/textemp/latexTemplatePdfSurvey.cls
@@ -0,0 +1,226 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{latexTemplatePdfSurvey}
+\LoadClass{article}
+%uporabljene knjiznice
+\usepackage[a4paper, portrait, left=20mm, right=20mm, headheight=1cm, top=1cm, bottom=2cm, footskip=3cm, includehead, includefoot, heightrounded]{geometry} % za robove, ipd.
+\usepackage{tabularx, booktabs} % za lazje urejanje in izris tabel (ni podprto v latex2rtf)
+\usepackage{ltablex} % Mod­i­fies the tab­u­larx en­vi­ron­ment to com­bine the fea­tures of the tab­u­larx pack­age (auto-sized columns in a fixed width ta­ble) with those of the longtable pack­age (multi-page ta­bles)
+ %\usepackage{color}
+\usepackage[dvipsnames]{xcolor} % za uporabo HTML in RGB barv
+\usepackage{pgf} % za aritmetiko z length
+\usepackage{printlen} %
+\usepackage{enumitem} % za itemize, ki je potreben za pravilen izris rolet in izberite iz seznama v tabelah
+\usepackage{eurosym} % za izpis simbola €
+\usepackage[export]{adjustbox} % za poravnavo slik
+\usepackage{wasysym} % za izris radio button, checkbox
+
+\usepackage{tikzsymbols} %za izpis emoji-jev
+
+\usepackage{textgreek} %za resevanje grskih crk
+
+\usepackage[T2A,T1]{fontenc} %za cirilico
+\usepackage[russian,english]{babel} %za cirilico
+%\usepackage[russian]{babel} %za cirilico
+
+\usepackage[utf8]{inputenc} % za uporabo utf8
+\usepackage{amssymb} %za unicode simbole
+
+%DEFINIRANJE NADOMESTIL NEIZPISLJIVIH UNICODE CHARACTER-JEV
+\DeclareUnicodeCharacter{200B}{{\hskip 0pt}}
+\DeclareUnicodeCharacter{03C7}{$\chi$}
+\DeclareUnicodeCharacter{2265}{$\geq$}
+\DeclareUnicodeCharacter{03B5}{$\epsilon$}
+\DeclareUnicodeCharacter{2003}{$\enspace$}
+\DeclareUnicodeCharacter{0014}{$\thinspace$} %ni ta pravi nadomestek, ker v Latexu tak simbol ne obstaja
+
+%Emoji - izpis urejen s slikicami emoji-jev
+\DeclareUnicodeCharacter{1F600}{\includegraphics[height=1em]{1F600.png}}
+\DeclareUnicodeCharacter{1F601}{\includegraphics[height=1em]{1F601.png}}
+\DeclareUnicodeCharacter{1F602}{\includegraphics[height=1em]{1F602.png}}
+\DeclareUnicodeCharacter{1F603}{\includegraphics[height=1em]{1F603.png}}
+\DeclareUnicodeCharacter{1F604}{\includegraphics[height=1em]{1F604.png}}
+\DeclareUnicodeCharacter{1F605}{\includegraphics[height=1em]{1F605.png}}
+\DeclareUnicodeCharacter{1F606}{\includegraphics[height=1em]{1F606.png}}
+\DeclareUnicodeCharacter{1F609}{\includegraphics[height=1em]{1F609.png}}
+\DeclareUnicodeCharacter{1F60A}{\includegraphics[height=1em]{1F60A.png}}
+\DeclareUnicodeCharacter{1F60B}{\includegraphics[height=1em]{1F60B.png}}
+\DeclareUnicodeCharacter{1F60E}{\includegraphics[height=1em]{1F60C.png}}
+\DeclareUnicodeCharacter{1F60D}{\includegraphics[height=1em]{1F60D.png}}
+\DeclareUnicodeCharacter{1F60E}{\includegraphics[height=1em]{1F60E.png}}
+\DeclareUnicodeCharacter{1F60D}{\includegraphics[height=1em]{1F60F.png}}
+
+\DeclareUnicodeCharacter{1F600}{\includegraphics[height=1em]{1F610.png}}
+\DeclareUnicodeCharacter{1F611}{\includegraphics[height=1em]{1F611.png}}
+\DeclareUnicodeCharacter{1F612}{\includegraphics[height=1em]{1F612.png}}
+\DeclareUnicodeCharacter{1F613}{\includegraphics[height=1em]{1F613.png}}
+\DeclareUnicodeCharacter{1F614}{\includegraphics[height=1em]{1F614.png}}
+\DeclareUnicodeCharacter{1F615}{\includegraphics[height=1em]{1F615.png}}
+\DeclareUnicodeCharacter{1F616}{\includegraphics[height=1em]{1F616.png}}
+\DeclareUnicodeCharacter{1F619}{\includegraphics[height=1em]{1F619.png}}
+\DeclareUnicodeCharacter{1F61A}{\includegraphics[height=1em]{1F61A.png}}
+\DeclareUnicodeCharacter{1F61B}{\includegraphics[height=1em]{1F61B.png}}
+\DeclareUnicodeCharacter{1F61E}{\includegraphics[height=1em]{1F61C.png}}
+\DeclareUnicodeCharacter{1F61D}{\includegraphics[height=1em]{1F61D.png}}
+\DeclareUnicodeCharacter{1F61E}{\includegraphics[height=1em]{1F61E.png}}
+\DeclareUnicodeCharacter{1F61D}{\includegraphics[height=1em]{1F61F.png}}
+
+\DeclareUnicodeCharacter{1F600}{\includegraphics[height=1em]{1F620.png}}
+\DeclareUnicodeCharacter{1F621}{\includegraphics[height=1em]{1F621.png}}
+\DeclareUnicodeCharacter{1F622}{\includegraphics[height=1em]{1F622.png}}
+\DeclareUnicodeCharacter{1F623}{\includegraphics[height=1em]{1F623.png}}
+\DeclareUnicodeCharacter{1F624}{\includegraphics[height=1em]{1F624.png}}
+\DeclareUnicodeCharacter{1F625}{\includegraphics[height=1em]{1F625.png}}
+\DeclareUnicodeCharacter{1F626}{\includegraphics[height=1em]{1F626.png}}
+\DeclareUnicodeCharacter{1F629}{\includegraphics[height=1em]{1F629.png}}
+\DeclareUnicodeCharacter{1F62A}{\includegraphics[height=1em]{1F62A.png}}
+\DeclareUnicodeCharacter{1F62B}{\includegraphics[height=1em]{1F62B.png}}
+\DeclareUnicodeCharacter{1F62E}{\includegraphics[height=1em]{1F62C.png}}
+\DeclareUnicodeCharacter{1F62D}{\includegraphics[height=1em]{1F62D.png}}
+\DeclareUnicodeCharacter{1F62E}{\includegraphics[height=1em]{1F62E.png}}
+\DeclareUnicodeCharacter{1F62D}{\includegraphics[height=1em]{1F62F.png}}
+
+\DeclareUnicodeCharacter{1F600}{\includegraphics[height=1em]{1F630.png}}
+\DeclareUnicodeCharacter{1F631}{\includegraphics[height=1em]{1F631.png}}
+\DeclareUnicodeCharacter{1F632}{\includegraphics[height=1em]{1F632.png}}
+\DeclareUnicodeCharacter{1F633}{\includegraphics[height=1em]{1F633.png}}
+\DeclareUnicodeCharacter{1F634}{\includegraphics[height=1em]{1F634.png}}
+\DeclareUnicodeCharacter{1F635}{\includegraphics[height=1em]{1F635.png}}
+\DeclareUnicodeCharacter{1F636}{\includegraphics[height=1em]{1F636.png}}
+\DeclareUnicodeCharacter{1F639}{\includegraphics[height=1em]{1F639.png}}
+\DeclareUnicodeCharacter{1F63A}{\includegraphics[height=1em]{1F63A.png}}
+\DeclareUnicodeCharacter{1F63B}{\includegraphics[height=1em]{1F63B.png}}
+\DeclareUnicodeCharacter{1F63E}{\includegraphics[height=1em]{1F63C.png}}
+\DeclareUnicodeCharacter{1F63D}{\includegraphics[height=1em]{1F63D.png}}
+\DeclareUnicodeCharacter{1F63E}{\includegraphics[height=1em]{1F63E.png}}
+\DeclareUnicodeCharacter{1F63D}{\includegraphics[height=1em]{1F63F.png}}
+
+\DeclareUnicodeCharacter{1F600}{\includegraphics[height=1em]{1F640.png}}
+\DeclareUnicodeCharacter{1F641}{\includegraphics[height=1em]{1F641.png}}
+\DeclareUnicodeCharacter{1F642}{\includegraphics[height=1em]{1F642.png}}
+\DeclareUnicodeCharacter{1F643}{\includegraphics[height=1em]{1F643.png}}
+\DeclareUnicodeCharacter{1F644}{\includegraphics[height=1em]{1F644.png}}
+\DeclareUnicodeCharacter{1F645}{\includegraphics[height=1em]{1F645.png}}
+\DeclareUnicodeCharacter{1F646}{\includegraphics[height=1em]{1F646.png}}
+\DeclareUnicodeCharacter{1F649}{\includegraphics[height=1em]{1F649.png}}
+\DeclareUnicodeCharacter{1F64A}{\includegraphics[height=1em]{1F64A.png}}
+\DeclareUnicodeCharacter{1F64B}{\includegraphics[height=1em]{1F64B.png}}
+\DeclareUnicodeCharacter{1F64E}{\includegraphics[height=1em]{1F64C.png}}
+\DeclareUnicodeCharacter{1F64D}{\includegraphics[height=1em]{1F64D.png}}
+\DeclareUnicodeCharacter{1F64E}{\includegraphics[height=1em]{1F64E.png}}
+\DeclareUnicodeCharacter{1F64D}{\includegraphics[height=1em]{1F64F.png}}
+
+%Emoji - izpis urejen s slikicami emoji-jev - konec
+
+%DEFINIRANJE NADOMESTIL NEIZPISLJIVIH UNICODE CHARACTER-JEV - KONEC
+
+\usepackage{graphicx} % za prikazovanje slik in ostalih grafik
+\usepackage{colortbl} %The pack­age al­lows rows and columns to be coloured, and even in­di­vid­ual cells
+\usepackage{fancyhdr} % za ureditev glav in nog
+\usepackage{seqsplit} % za samodejno razbijanje dolgih besed v tabelah
+\usepackage{url} %za razbijanje url-jev v tabelah
+\urlstyle{same} %nastavitev, da je font URL isti kot je font ostalega besedila (http://ctan.ijs.si/tex-archive/macros/latex/contrib/url/url.pdf)
+\usepackage{montserrat} % za uporabo Montserrat pisave v dokumentu
+\usepackage{multirow} % za spajanje vrstic v tabeli
+\usepackage[hidelinks]{hyperref}
+\usepackage{tikz} % za risanje drsnikov
+\usetikzlibrary{calc} % za risanje drsnikov
+%definiranje uporabljenih barv
+\definecolor{Mycolor1}{HTML}{00F9DE}
+\definecolor{oneclick}{rgb}{0.2, 0.2, 0.2}
+\definecolor{besedilo}{HTML}{535050}
+\definecolor{crta}{HTML}{1e88e5}
+\definecolor{1ka_orange}{HTML}{ffa608}
+\definecolor{komentar}{HTML}{ff0000}
+%definiranje poravnav za tabele
+\newcolumntype{C}{>{\centering\arraybackslash}X} % za sredinsko poravnavo celice, ki se samodejno prilagaja sirini
+\newcolumntype{R}{>{\raggedleft\arraybackslash}X} % za desno poravnavo celice, ki se samodejno prilagaja sirini
+\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}} % za sredinsko poravnane zadeve v tabularx tabeli
+\newcolumntype{s}{>{\hsize=.55\hsize \centering\arraybackslash}X} % za sredinsko poravnane celice manjse dimenzije (0.55 navadne dimenzije)
+\newcolumntype{S}{>{\hsize=.2\hsize}X} % za celice manjse dimenzije (0.3 navadne dimenzije)
+\newcolumntype{b}{>{\hsize=.5\hsize}X} % za celice manjse dimenzije (0.5 navadne dimenzije)
+\newcolumntype{B}{>{\hsize=1.3\hsize}X} % za celico vecje dimenzije od navadne (1.3 navadne dimenzije)
+\newcolumntype{P}{>{\hsize=.1\hsize \centering\arraybackslash}X} % za fiksno 10% fiksno sirino stolpca, ki ima sredinsko poravnavo (npr. analiza prvi, levi stolpec)
+\newcolumntype{A}{>{\hsize=0.17\textwidth}X} % za fiksno sirino prvega stolpca@tabularx
+%definiranje spremenljivk (dolzin, ...)
+\newlength{\questionTotalLength}
+\newlength{\answerLength}
+\newlength{\questionLength}
+\newlength{\opombaLength}
+\newcounter{opomba}
+%definiranje novih ukazov, funkcij, nastavitev potrebnih za izris dolocenih delov besedila
+\newcommand{\radio}{\Large \ooalign{\hidewidth$\bullet$\hidewidth\cr$\ocircle$}} %za izris radio button
+\linespread{1.5} % za razmik med vrsticami
+%\fontencoding{T1}\selectfont % za encode besedila
+%\fontencoding{T2A,T1}\selectfont % za encode besedila
+\renewcommand{\familydefault}{\sfdefault} % za izbiro novega fonta Montserrat
+\color{besedilo} % za izbiro barve besedila
+\newenvironment{absolutelynopagebreak} % za ureditev dela besedila, kjer ne sme biti odsek strani; za prepreciti prelome strani, kjer ni potrebno
+ {\par\nobreak\vfil\penalty0\vfilneg
+ \vtop\bgroup}
+ {\par\xdef\tpd{\the\prevdepth}\egroup
+ \prevdepth=\tpd}
+\newenvironment{survey} % za ureditev prostora za izpis vprasalnika
+ {\parindent0pt \fontsize{10}{12} \selectfont }
+ { }
+ \newenvironment{gdpr} % za ureditev prostora za izpis gdpr
+ %{\parindent0pt \fontsize{10}{12} \selectfont }
+ { }
+ { }
+\newcommand{\forceindent}{\leavevmode{\parindent=1em\indent}} %
+\pdfcompresslevel=0 %uncompressed PDFs za pohitritev
+\pdfobjcompresslevel=0 %uncompressed PDFs za pohitritev
+%vse za glavo in nogo
+\pagestyle{fancy}
+\fancyhf{}
+\setlength{\headheight}{41pt} %Make it at least 40.35403pt.
+\renewcommand{\headrule}{\hbox to\headwidth{\color{crta}\leaders\hrule height \headrulewidth\hfill}} %ureditev druge barve za crto glave
+\renewcommand{\headrulewidth}{6pt} %debelina crte glave
+\renewcommand{\footrulewidth}{0.25pt} %debelina crte noga
+\setlength{\headsep}{1.5cm} %odmik iz roba strani
+%newcommand{\headerfooter}[5]{ %funkcija za izpis glave in noge
+% \lhead{\begin{tabular}{@{} m{135mm} } #1 \end{tabular}}
+% \rhead{\includegraphics[#4]{#2}}
+% \fancyfoot[l]{www.1ka.si}
+% %\fancyfoot[r]{#3 \thepage{}}
+% \fancyfoot[r]{ \thepage}
+%}
+\newcommand{\headerfooter}[6]{ %funkcija za izpis glave in noge
+ \lhead{\begin{tabular}{@{} m{135mm} } #1 #6 \end{tabular}}
+ \rhead{\includegraphics[#4]{#2}}
+ \fancyfoot[l]{www.1ka.si}
+ %\fancyfoot[r]{#3 \thepage{}}
+ \fancyfoot[r]{ \thepage}
+}
+%vse za glavo in nogo - konec
+%vse za naslovnico
+\newcommand{\naslovnica}[9]{
+ \begin{titlepage}
+ \linespread{1}
+ \includegraphics[#1]{#2}
+ \vfill
+ \noindent
+ \huge \fontseries{l}\selectfont {#3}\par
+ \vspace{0.5cm}
+ \noindent
+ \MakeUppercase{{\huge \textbf{\noindent {#4} }}} \par
+ \noindent
+ \textcolor{crta}{\noindent\makebox[\linewidth]{\rule{\textwidth}{6pt}}} \par
+ \noindent
+ {\large \fontseries{l} \selectfont
+ \begin{tabularx}{\textwidth}{Xl}
+ & \\
+ #5 \\
+ & \\
+ #6 \\
+ & \\
+ #7 \\
+ & \\
+ #8 \\
+ & \\
+ #9
+ \end{tabularx}
+ }
+ \vfill
+ \end{titlepage}
+}
+%vse za naslovnico - konec \ No newline at end of file