From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- admin/survey/export/class.ExportController.php | 574 ++++ admin/survey/export/export_definitions.php | 97 + .../export/latexclasses/Analize/AnalizaBreak.php | 1343 +++++++++ .../export/latexclasses/Analize/AnalizaCReport.php | 1337 +++++++++ .../export/latexclasses/Analize/AnalizaCharts.php | 293 ++ .../latexclasses/Analize/AnalizaCrosstab.php | 1320 +++++++++ .../export/latexclasses/Analize/AnalizaDesc.php | 319 +++ .../export/latexclasses/Analize/AnalizaFreq.php | 384 +++ .../export/latexclasses/Analize/AnalizaMean.php | 371 +++ .../latexclasses/Analize/AnalizaMultiCrosstab.php | 1909 +++++++++++++ .../export/latexclasses/Analize/AnalizaSums.php | 2984 ++++++++++++++++++++ .../export/latexclasses/Analize/AnalizaTTest.php | 413 +++ .../latexclasses/Vprasanja/BesediloLatex.php | 475 ++++ .../export/latexclasses/Vprasanja/DatumLatex.php | 140 + .../latexclasses/Vprasanja/GridMultipleLatex.php | 559 ++++ .../export/latexclasses/Vprasanja/HeatmapLatex.php | 337 +++ .../latexclasses/Vprasanja/KalkulacijaLatex.php | 121 + .../export/latexclasses/Vprasanja/KvotaLatex.php | 145 + .../latexclasses/Vprasanja/LokacijaLatex.php | 142 + .../latexclasses/Vprasanja/MultiGridLatex.php | 1768 ++++++++++++ .../export/latexclasses/Vprasanja/NagovorLatex.php | 73 + .../Vprasanja/RadioCheckboxSelectLatex.php | 488 ++++ .../latexclasses/Vprasanja/RazvrscanjeLatex.php | 397 +++ .../export/latexclasses/Vprasanja/SNImena.php | 94 + .../export/latexclasses/Vprasanja/SteviloLatex.php | 702 +++++ .../export/latexclasses/Vprasanja/VsotaLatex.php | 167 ++ .../export/latexclasses/class.LatexAnalysis.php | 287 ++ .../latexclasses/class.LatexAnalysisElement.php | 2022 +++++++++++++ .../export/latexclasses/class.LatexDocument.php | 1423 ++++++++++ .../latexclasses/class.LatexEditsAnalysis.php | 1305 +++++++++ .../survey/export/latexclasses/class.LatexGDPR.php | 115 + .../export/latexclasses/class.LatexStatus.php | 1517 ++++++++++ .../export/latexclasses/class.LatexSurvey.php | 1342 +++++++++ .../latexclasses/class.LatexSurveyElement.php | 2372 ++++++++++++++++ .../survey/export/latexclasses/textemp/.gitignore | 4 + .../latexTemplatePdfAnalysisAndOtherLandscape.cls | 100 + .../textemp/latexTemplatePdfAnalysisPortrait.cls | 98 + .../textemp/latexTemplatePdfSurvey.cls | 226 ++ .../libs/PHPPowerPoint/DocumentProperties.php | 299 ++ .../survey/export/libs/PHPPowerPoint/HashTable.php | 220 ++ .../export/libs/PHPPowerPoint/IComparable.php | 62 + .../survey/export/libs/PHPPowerPoint/IOFactory.php | 187 ++ .../export/libs/PHPPowerPoint/Reader/IReader.php | 53 + .../libs/PHPPowerPoint/Reader/Serialized.php | 125 + admin/survey/export/libs/PHPPowerPoint/Shape.php | 358 +++ .../libs/PHPPowerPoint/Shape/BaseDrawing.php | 272 ++ .../export/libs/PHPPowerPoint/Shape/Drawing.php | 185 ++ .../libs/PHPPowerPoint/Shape/MemoryDrawing.php | 235 ++ .../export/libs/PHPPowerPoint/Shape/RichText.php | 264 ++ .../libs/PHPPowerPoint/Shape/RichText/Break.php | 88 + .../PHPPowerPoint/Shape/RichText/ITextElement.php | 67 + .../libs/PHPPowerPoint/Shape/RichText/Run.php | 110 + .../PHPPowerPoint/Shape/RichText/TextElement.php | 113 + .../export/libs/PHPPowerPoint/Shape/Shadow.php | 314 ++ .../export/libs/PHPPowerPoint/Shared/Drawing.php | 109 + .../export/libs/PHPPowerPoint/Shared/File.php | 98 + .../export/libs/PHPPowerPoint/Shared/Font.php | 67 + .../export/libs/PHPPowerPoint/Shared/String.php | 270 ++ .../export/libs/PHPPowerPoint/Shared/XMLWriter.php | 141 + .../libs/PHPPowerPoint/Shared/ZipStreamWrapper.php | 182 ++ admin/survey/export/libs/PHPPowerPoint/Slide.php | 261 ++ .../export/libs/PHPPowerPoint/Slide/Layout.php | 50 + .../export/libs/PHPPowerPoint/SlideIterator.php | 118 + .../export/libs/PHPPowerPoint/Style/Alignment.php | 243 ++ .../export/libs/PHPPowerPoint/Style/Color.php | 170 ++ .../export/libs/PHPPowerPoint/Style/Fill.php | 245 ++ .../export/libs/PHPPowerPoint/Style/Font.php | 411 +++ .../libs/PHPPowerPoint/Style/_notused_Border.php | 331 +++ .../libs/PHPPowerPoint/Style/_notused_Borders.php | 577 ++++ .../export/libs/PHPPowerPoint/Writer/IWriter.php | 45 + .../libs/PHPPowerPoint/Writer/PowerPoint2007.php | 411 +++ .../Writer/PowerPoint2007/ContentTypes.php | 219 ++ .../Writer/PowerPoint2007/DocProps.php | 218 ++ .../Writer/PowerPoint2007/Drawing.php | 94 + .../Writer/PowerPoint2007/LayoutPack.php | 124 + .../Writer/PowerPoint2007/LayoutPack/Default.php | 2983 +++++++++++++++++++ .../Writer/PowerPoint2007/Presentation.php | 151 + .../PHPPowerPoint/Writer/PowerPoint2007/Rels.php | 347 +++ .../PHPPowerPoint/Writer/PowerPoint2007/Slide.php | 520 ++++ .../PHPPowerPoint/Writer/PowerPoint2007/Theme.php | 1215 ++++++++ .../Writer/PowerPoint2007/WriterPart.php | 72 + .../libs/PHPPowerPoint/Writer/Serialized.php | 187 ++ admin/survey/export/script/saveAsExcel2.js | 104 + .../export/xmlClasses/Vprasanja/BesediloXml.php | 94 + .../export/xmlClasses/Vprasanja/CheckboxXml.php | 178 ++ .../export/xmlClasses/Vprasanja/MultiGridXml.php | 395 +++ .../export/xmlClasses/Vprasanja/RadioXml.php | 140 + .../export/xmlClasses/Vprasanja/SteviloXml.php | 124 + .../survey/export/xmlClasses/class.XmlDocument.php | 360 +++ admin/survey/export/xmlClasses/class.XmlSurvey.php | 590 ++++ .../export/xmlClasses/class.XmlSurveyElement.php | 433 +++ 91 files changed, 42992 insertions(+) create mode 100644 admin/survey/export/class.ExportController.php create mode 100644 admin/survey/export/export_definitions.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaBreak.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaCReport.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaCharts.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaCrosstab.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaDesc.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaFreq.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaMean.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaMultiCrosstab.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaSums.php create mode 100644 admin/survey/export/latexclasses/Analize/AnalizaTTest.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/BesediloLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/DatumLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/GridMultipleLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/HeatmapLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/KalkulacijaLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/KvotaLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/LokacijaLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/MultiGridLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/NagovorLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/RadioCheckboxSelectLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/RazvrscanjeLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/SNImena.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/SteviloLatex.php create mode 100644 admin/survey/export/latexclasses/Vprasanja/VsotaLatex.php create mode 100644 admin/survey/export/latexclasses/class.LatexAnalysis.php create mode 100644 admin/survey/export/latexclasses/class.LatexAnalysisElement.php create mode 100644 admin/survey/export/latexclasses/class.LatexDocument.php create mode 100644 admin/survey/export/latexclasses/class.LatexEditsAnalysis.php create mode 100644 admin/survey/export/latexclasses/class.LatexGDPR.php create mode 100644 admin/survey/export/latexclasses/class.LatexStatus.php create mode 100644 admin/survey/export/latexclasses/class.LatexSurvey.php create mode 100644 admin/survey/export/latexclasses/class.LatexSurveyElement.php create mode 100644 admin/survey/export/latexclasses/textemp/.gitignore create mode 100644 admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisAndOtherLandscape.cls create mode 100644 admin/survey/export/latexclasses/textemp/latexTemplatePdfAnalysisPortrait.cls create mode 100644 admin/survey/export/latexclasses/textemp/latexTemplatePdfSurvey.cls create mode 100644 admin/survey/export/libs/PHPPowerPoint/DocumentProperties.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/HashTable.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/IComparable.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/IOFactory.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Reader/IReader.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Reader/Serialized.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/BaseDrawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/Drawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/MemoryDrawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Break.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/ITextElement.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Run.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/TextElement.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/Shadow.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/Drawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/File.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/Font.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/String.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/XMLWriter.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/ZipStreamWrapper.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Slide.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Slide/Layout.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/SlideIterator.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Alignment.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Color.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Fill.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Font.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/_notused_Border.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/_notused_Borders.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/IWriter.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/DocProps.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Drawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Rels.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Slide.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Theme.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/Serialized.php create mode 100644 admin/survey/export/script/saveAsExcel2.js create mode 100644 admin/survey/export/xmlClasses/Vprasanja/BesediloXml.php create mode 100644 admin/survey/export/xmlClasses/Vprasanja/CheckboxXml.php create mode 100644 admin/survey/export/xmlClasses/Vprasanja/MultiGridXml.php create mode 100644 admin/survey/export/xmlClasses/Vprasanja/RadioXml.php create mode 100644 admin/survey/export/xmlClasses/Vprasanja/SteviloXml.php create mode 100644 admin/survey/export/xmlClasses/class.XmlDocument.php create mode 100644 admin/survey/export/xmlClasses/class.XmlSurvey.php create mode 100644 admin/survey/export/xmlClasses/class.XmlSurveyElement.php (limited to 'admin/survey/export') diff --git a/admin/survey/export/class.ExportController.php b/admin/survey/export/class.ExportController.php new file mode 100644 index 0000000..9cffefd --- /dev/null +++ b/admin/survey/export/class.ExportController.php @@ -0,0 +1,574 @@ +povzetek") + * + * 'data' - izvoz podatkov + * - 'full' - celotna tabela podatkov - potrebno prenesti iz SurveyExport - TO SE LAHKO PRENAŠA NAKNADNO + * - 'list' - kratek izpis podatkov - samo prvih 5 spremenljivk + * + * 'other' - poseben izvoz (Evoli, Hierarhija, MFDPS, MJU...) + * - 'usable' - uporabni respondenti + * - 'text_analysis' - analiza besedil v anketi + * - 'speeder' - speeder index + * - 'edits_analysis' - analiza urejanja ankete + * - 'evoli' + * - 'evoli_teammeter' + * - 'hierarhija' + * - 'mfdps' + * - 'adecco_360' - treba dodatno prenesti + * - '1ka_360' - treba dodatno prenesti + * + * 'gdpr' - izvoz gdpr porocil (ce je vklopljen gdpr v anketi) + * - 'individual' - podrobnosti o zbiranju osebnih podatkov + * - 'activity' - evidenca dejavnosti obdelav + * + * Formati izvoza: + * - 'pdf' + * - 'rtf' + * - 'xls' + * - 'csv' + * - 'txt' + * - 'html' + * - 'spss_syntax' + * - 'spss_sav' + * - 'ppt' + * + * + */ + + +//use Export\Latexclasses\LatexDocument as LatexDocument; +//include('../../function.php'); +include('../../vendor/autoload.php'); +include('export_definitions.php'); + + +class ExportController{ + + + var $anketa; // ID ankete + + + function __construct(){ + global $site_path, $global_user_id, $admin_type, $lang; + + # če pridemo iz rekodiranga urlja + if (!isset($_GET['anketa']) && isset($_GET['dc']) && $_GET['dc'] != null) { + $data = $_GET['dc']; + $data = base64_decode($data); + $data = unserialize($data); + foreach ($data AS $get_param => $value) { + if ($get_param != null && $get_param != '' && $value != null && $value != '' && $value != 'undefined') { + $_GET[$get_param] = $value; + } + } + } + + // Nastavimo ID ankete + $this->anketa = $_GET['anketa']; + + # PDF lahko vidijo vsi, ki kliknejo na link za kreacijo PDF-ja + # zato, kadar uporabnik ni logiran v CMS za pdf nastavimo $global_user_id kateri je enak avtorju ankete + if ($global_user_id === null || $global_user_id === 0) { + $sql = sisplet_query("SELECT insert_uid FROM srv_anketa WHERE id='$this->anketa'"); + $row = mysqli_fetch_assoc($sql); + $global_user_id = $row['insert_uid']; + } + + // nastavimo jezik + SurveyInfo::SurveyInit($this->anketa); + $lang_admin = SurveyInfo::getInstance()->getSurveyColumn('lang_admin'); + //$file = '../../../lang/'.$lang_admin.'.php'; + $file = $site_path.'lang/'.$lang_admin.'.php'; + include($file); + } + + + // Izvedemo export + public function executeExport(){ + global $site_path; + + // Nastavimo tip, podtip in format izvoza + $export_type = $this->getExportType(); + $export_format = $this->getExportFormat(); + $exportType = $export_type['export_type']; + $subtype = $export_type['export_subtype']; + + /* echo "anketa: ".$this->anketa."
"; + echo "subtype: ".$subtype."
"; + echo "exportType: ".$exportType."
"; + echo "export_format: ".$export_format."
"; */ + + // Posebni izvozi, ki se izvajajo drugje (za npr. locene module - evoli, mfdps...) + if( $exportType == 'other' && in_array($subtype, array('evoli', 'evoli_teammeter', 'mfdps', 'heirarhija', 'text_analysis', 'usable', 'speeder')) ){ + $this->exportOther($subtype); + } + else{ + switch($export_format){ + case 'pdf': + case 'rtf': + case 'html': + // Ustvarimo latex dokument + $document = new LatexDocument($this->anketa); + $document->createDocument($export_type['export_type'], $export_type['export_subtype'], $export_format, $_GET['sprID']); + break; + + case 'xml': + // Ustvarimo xml dokument + $document = new XmlDocument($this->anketa); + $document->createXmlDocument($export_type['export_type'], $export_type['export_subtype'], $export_format); + break; + + case 'xls': // Mogoce lahko tudi xls po novem naredimo preko html-ja iz latexa? Html tabele se naceloma vredu izpisejo v xls... + + //Nov nacin izvoza xls iz Latex datoteke + //$document = new LatexDocument($this->anketa); + //$document->createDocument($export_type['export_type'], $export_type['export_subtype'], $export_format, $_GET['sprID']); + //Nov nacin izvoza xls iz Latex datoteke - konec + + //Star nacin izvoza xls + switch($subtype){ + case 'sums': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaSums.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaSums ($_GET['anketa'], $_GET['sprID'], $_GET['loop']); + break; + case 'desc': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaStatistics.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaStatistics ($_GET['anketa'], $_GET['sprID'], $_GET['loop']); + break; + case 'freq': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaFrekvenca.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaFrekvenca ($_GET['anketa'], $_GET['sprID'], $_GET['loop']); + break; + case 'crosstab': + //poberemo tabelo s podatki + $crossData1 = explode(",", $_GET['data1']); + $crossData2 = explode(",", $_GET['data2']); + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaCrosstab.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaCrosstab ($_GET['anketa'], $crossData1, $crossData2); + break; + case 'multicrosstab': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaMultiCrosstab.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaMultiCrosstab ($_GET['anketa']); + break; + case 'mean': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaMean.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaMean ($_GET['anketa']); + break; + case 'ttest': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaTTest.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaTTest ($_GET['anketa']); + break; + case 'break': + $path = $site_path.'admin/exportclases/class.xlsIzvozAnalizaBreak.php'; + include ($path); + $izvoz = new XlsIzvozAnalizaBreak ($_GET['anketa']); + break; + } + + $izvoz->createXls(); + $izvoz->getFile('xls_analiza_'.$subtype.'_'.time().'.xls'); + //Star nacin izvoza xls - konec + + break; + + case 'ppt': + switch($subtype){ + case 'chart': + $path = $site_path.'admin/exportclases/class.pptIzvozAnalizaCharts.php'; + include ($path); + $izvoz = new PptIzvozAnalizaCharts ($_GET['anketa'], $_GET['sprID'], $_GET['loop']); + $izvoz->createPpt(); + $izvoz->getFile('ppt_analiza_'.$subtype.'_'.time().'.pptx'); + break; + case 'heatmap': + $path = $site_path.'admin/exportclases/class.pptIzvozHeatmapImage.php'; + include ($path); + $izvoz = new pptIzvozHeatmapImage ($_GET['anketa'], $_GET['sprID'], $_GET['loop']); + $izvoz->createPpt(); + $izvoz->getFile('ppt_analiza_heatmap_image_'.$_GET['sprID'].'_'.time().'.ppt'); + break; + } + break; + + case 'csv': + case 'txt': + case 'spss_syntax': + case 'spss_sav': + break; + } + } + } + + // Izvozi, ki se izvedejo drugje v locenih modulih (npr. evoli, mfdps, hierarhija...) + private function exportOther($subtype=''){ + global $site_path; + switch($subtype){ + + case 'evoli': + $usr_id = (isset($_GET['usr_id']) && $_GET['usr_id'] > 0) ? $_GET['usr_id'] : 0; + $evoli = new SurveyEvoli($_GET['anketa']); + $evoli->executeExport($usr_id); + break; + + case 'evoli_teammeter': + $skupina = (isset($_GET['skupina']) && $_GET['skupina'] > 0) ? $_GET['skupina'] : 0; + $evoli_tm = new SurveyTeamMeter($_GET['anketa']); + $evoli_tm->executeExport($skupina); + break; + + case 'mfdps': + $usr_id = (isset($_GET['usr_id']) && $_GET['usr_id'] > 0) ? $_GET['usr_id'] : 0; + $evoli = new SurveyMFDPS($_GET['anketa']); + $evoli->executePDFExport($usr_id); + break; + + case 'hierarhija': + //include ($site_path.'admin/survey/modules/mod_hierarhija/class/HierarhijaIzvozAnalize.php'); + $izvoz = new \Hierarhija\HierarhijaIzvozAnalize($_GET['anketa']); + $izvoz->createPdf(); + + $izvoz->getFile('pdf_analiza1'.time().'.pdf'); + break; + + case 'text_analysis': + //include ($site_path.'admin/survey/classes/class.SurveyTextAnalysis.php'); + $STA = new SurveyTextAnalysis($_GET['anketa']); + $STA->exportCSVTable($_GET['type']); + break; + + case 'usable': + $path = $site_path.'admin/exportclases/class.xlsIzvozUsable.php'; + include ($path); + $izvoz = new XlsIzvozUsable ($_GET['anketa']); + $izvoz->createXls(); + $izvoz->getFile('xls_usable'.time().'.xls'); + break; + + case 'speeder': + include ($site_path.'admin/exportclases/class.xlsIzvozSpeeder.php'); + $izvoz = new XlsIzvozSpeeder ($_GET['anketa']); + $izvoz->createXls(); + $izvoz->getFile('xls_speeder'.time().'.xls'); + break; + } + } + + + + // Nastavimo tip izvoza + private function getExportType(){ + global $site_path, $global_user_id, $admin_type, $lang; + + switch ( $_GET['a'] ) { + case A_REPORT_VPRASALNIK_PDF: + case A_REPORT_VPRASALNIK_RTF: + $export_type = 'survey'; + $export_subtype = 'q_empty'; + break; + + case A_REPORT_VPRASALNIK_XML: + $export_type = 'survey'; + $export_subtype = 'q_empty_xml'; + break; + + case A_REPORT_PDF_RESULTS: + case A_REPORT_RTF_RESULTS: + $export_type = 'survey'; + if(isset($_GET['usr_id'])) + $export_subtype = 'q_data'; // če je definiran $_GET['usr_id'] izpisemo samo njegove odgovore + else + $export_subtype = 'q_data_all'; // če ni usr_id definiran vprasalnike z odgovori vseh respondentov enega za drugim + break; + + case A_REPORT_PDF_COMMENT: + case A_REPORT_RTF_COMMENT: + $export_type = 'survey'; + $export_subtype = 'q_comment'; + break; + + case A_REPORT_PDF_STATUS: + $export_type = 'status'; + $export_subtype = 'status'; + break; + + case A_REPORT_PDF_EDITS_ANALYSIS: + $export_type = 'other'; + $export_subtype = 'edits_analysis'; + break; + + case A_REPORT_PDF_LIST: + case A_REPORT_RTF_LIST: + case A_REPORT_XLS_LIST: + $export_type = 'data'; + $export_subtype = 'list'; + break; + + case A_GDPR_PDF_INDIVIDUAL: + case A_GDPR_RTF_INDIVIDUAL: + $export_type = 'gdpr'; + $export_subtype = 'individual'; + break; + + case A_GDPR_PDF_ACTIVITY: + case A_GDPR_RTF_ACTIVITY: + $export_type = 'gdpr'; + $export_subtype = 'activity'; + break; + } + switch ( $_GET['m'] ) { + + // Kakšna je razlika med tema dvema izvozoma?? + //case M_REPORT_ANALIZA_HEATMAP_IMAGE: + //case M_REPORT_PDF_HEATMAP_IMAGE: + case M_REPORT_ANALIZA_PPT_HEATMAP_IMAGE: + $export_type = 'analysis'; + $export_subtype = 'heatmap'; + break; + + case M_REPORT_ANALIZA_HEATMAP_IMAGE: + $export_type = 'analysis'; + $export_subtype = 'heatmap_image'; + break; + + case M_REPORT_PDF_HEATMAP_IMAGE: + case M_REPORT_ANALIZA_RTF_HEATMAP_IMAGE: + $export_type = 'analysis'; + $export_subtype = 'heatmap_image_pdf'; + break; + + case M_REPORT_ANALIZA_PDF_SUMS: + case M_REPORT_ANALIZA_RTF_SUMS: + case M_REPORT_ANALIZA_XLS_SUMS: + $export_type = 'analysis'; + $export_subtype = 'sums'; + break; + + case M_REPORT_ANALIZA_PDF_FREKVENCA: + case M_REPORT_ANALIZA_RTF_FREKVENCA: + case M_REPORT_ANALIZA_XLS_FREKVENCA: + $export_type = 'analysis'; + $export_subtype = 'freq'; + break; + + case M_REPORT_ANALIZA_PDF_STAT: + case M_REPORT_ANALIZA_RTF_STAT: + case M_REPORT_ANALIZA_XLS_STAT: + $export_type = 'analysis'; + $export_subtype = 'desc'; + break; + + case M_REPORT_ANALIZA_PDF_CHARTS: + case M_REPORT_ANALIZA_RTF_CHARTS: + case M_REPORT_ANALIZA_PPT_CHARTS: + $export_type = 'analysis'; + $export_subtype = 'chart'; + break; + + case M_REPORT_ANALIZA_PDF_CROSSTAB_IZPIS: + case M_REPORT_ANALIZA_RTF_CROSSTAB_IZPIS: + case M_REPORT_ANALIZA_XLS_CROSSTAB_IZPIS: + $export_type = 'analysis'; + $export_subtype = 'crosstab'; + break; + + case M_REPORT_ANALIZA_PDF_MULTICROSSTAB_IZPIS: + case M_REPORT_ANALIZA_RTF_MULTICROSSTAB_IZPIS: + case M_REPORT_ANALIZA_XLS_MULTICROSSTAB_IZPIS: + $export_type = 'analysis'; + $export_subtype = 'multicrosstab'; + break; + + case M_REPORT_ANALIZA_PDF_MEAN_IZPIS: + case M_REPORT_ANALIZA_RTF_MEAN_IZPIS: + case M_REPORT_ANALIZA_XLS_MEAN_IZPIS: + $export_type = 'analysis'; + $export_subtype = 'mean'; + break; + + case M_REPORT_ANALIZA_PDF_TTEST_IZPIS: + case M_REPORT_ANALIZA_RTF_TTEST_IZPIS: + case M_REPORT_ANALIZA_XLS_TTEST_IZPIS: + $export_type = 'analysis'; + $export_subtype = 'ttest'; + break; + + case M_REPORT_ANALIZA_PDF_BREAK_IZPIS: + case M_REPORT_ANALIZA_RTF_BREAK_IZPIS: + case M_REPORT_ANALIZA_XLS_BREAK_IZPIS: + $export_type = 'analysis'; + $export_subtype = 'break'; + break; + + case M_REPORT_ANALIZA_PDF_CREPORT: + case M_REPORT_ANALIZA_RTF_CREPORT: + $export_type = 'analysis'; + $export_subtype = 'creport'; + break; + + + case M_REPORT_PDF_EVOLI: + $export_type = 'other'; + $export_subtype = 'evoli'; + break; + case M_REPORT_PDF_TEAMMETER: + $export_type = 'other'; + $export_subtype = 'evoli_teammeter'; + break; + case M_REPORT_PDF_MFDPS: + $export_type = 'other'; + $export_subtype = 'mfdps'; + break; + case M_REPORT_HIERARHIJA_PDF_IZPIS: + $export_type = 'other'; + $export_subtype = 'hierarhija'; + break; + case A_REPORT_XLS_USABLE: + $export_type = 'other'; + $export_subtype = 'usable'; + break; + case A_REPORT_XLS_SPEEDER: + $export_type = 'other'; + $export_subtype = 'speeder'; + break; + case A_REPORT_XLS_TEXT_ANALYSIS: + case A_REPORT_CSV_TEXT_ANALYSIS: + $export_type = 'other'; + $export_subtype = 'text_analysis'; + break; + } + + return array('export_type'=>$export_type, 'export_subtype'=>$export_subtype); + } + + // Nastavimo format izvoza + private function getExportFormat(){ + global $site_path, $global_user_id, $admin_type, $lang; + + switch ( $_GET['a'] ) { + case A_REPORT_VPRASALNIK_PDF: + case A_REPORT_PDF_RESULTS: + case A_REPORT_PDF_COMMENT: + case A_REPORT_PDF_STATUS: + case A_REPORT_PDF_EDITS_ANALYSIS: + case A_REPORT_PDF_LIST: + case A_GDPR_PDF_INDIVIDUAL: + case A_GDPR_PDF_ACTIVITY: + $export_format = 'pdf'; + break; + + case A_REPORT_RTF_COMMENT: + case A_REPORT_VPRASALNIK_RTF: + case A_REPORT_RTF_RESULTS: + case A_REPORT_RTF_LIST: + case A_GDPR_RTF_INDIVIDUAL: + case A_GDPR_RTF_ACTIVITY: + $export_format = 'rtf'; + break; + + case A_REPORT_XLS_LIST: + $export_format = 'xls'; + break; + + case A_REPORT_VPRASALNIK_XML: + $export_format = 'xml'; + break; + } + switch ( $_GET['m'] ) { + + // Kakšna je razlika med tema dvema izvozoma?? + case M_REPORT_ANALIZA_HEATMAP_IMAGE: + case M_REPORT_PDF_HEATMAP_IMAGE: + + case M_REPORT_ANALIZA_PDF_FREKVENCA: + case M_REPORT_ANALIZA_PDF_CROSSTAB_IZPIS: + case M_REPORT_ANALIZA_PDF_MULTICROSSTAB_IZPIS: + case M_REPORT_ANALIZA_PDF_MEAN_IZPIS: + case M_REPORT_ANALIZA_PDF_TTEST_IZPIS: + case M_REPORT_ANALIZA_PDF_BREAK_IZPIS: + case M_REPORT_ANALIZA_PDF_STAT: + case M_REPORT_ANALIZA_PDF_SUMS: + case M_REPORT_ANALIZA_PDF_CHARTS: + case M_REPORT_ANALIZA_PDF_CREPORT: + case M_REPORT_PDF_EVOLI: + case M_REPORT_PDF_TEAMMETER: + case M_REPORT_PDF_MFDPS: + case M_REPORT_HIERARHIJA_PDF_IZPIS: + $export_format = 'pdf'; + break; + + case M_REPORT_ANALIZA_RTF_STAT: + case M_REPORT_ANALIZA_RTF_SUMS: + case M_REPORT_ANALIZA_RTF_FREKVENCA: + case M_REPORT_ANALIZA_RTF_CROSSTAB_IZPIS: + case M_REPORT_ANALIZA_RTF_MULTICROSSTAB_IZPIS: + case M_REPORT_ANALIZA_RTF_MEAN_IZPIS: + case M_REPORT_ANALIZA_RTF_TTEST_IZPIS: + case M_REPORT_ANALIZA_RTF_BREAK_IZPIS: + case M_REPORT_ANALIZA_RTF_CHARTS: + case M_REPORT_ANALIZA_RTF_CREPORT: + case M_REPORT_ANALIZA_RTF_HEATMAP_IMAGE: + $export_format = 'rtf'; + break; + + case M_REPORT_ANALIZA_XLS_FREKVENCA: + case M_REPORT_ANALIZA_XLS_CROSSTAB_IZPIS: + case M_REPORT_ANALIZA_XLS_MULTICROSSTAB_IZPIS: + case M_REPORT_ANALIZA_XLS_STAT: + case M_REPORT_ANALIZA_XLS_SUMS: + case M_REPORT_ANALIZA_XLS_MEAN_IZPIS: + case M_REPORT_ANALIZA_XLS_TTEST_IZPIS: + case M_REPORT_ANALIZA_XLS_BREAK_IZPIS: + case A_REPORT_XLS_USABLE: + case A_REPORT_XLS_SPEEDER: + case A_REPORT_XLS_TEXT_ANALYSIS: + $export_format = 'xls'; + break; + + case A_REPORT_CSV_TEXT_ANALYSIS: + $export_format = 'csv'; + break; + + case M_REPORT_ANALIZA_PPT_CHARTS: + case M_REPORT_ANALIZA_PPT_HEATMAP_IMAGE: + $export_format = 'ppt'; + break; + } + + return $export_format; + } + +} \ No newline at end of file diff --git a/admin/survey/export/export_definitions.php b/admin/survey/export/export_definitions.php new file mode 100644 index 0000000..252cab7 --- /dev/null +++ b/admin/survey/export/export_definitions.php @@ -0,0 +1,97 @@ + \ No newline at end of file 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 @@ +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("š","š","č"),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
"; + //echo "tip vprašanja: ".$spremenljivka['tip']."
"; + // 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
"; + $presirokaTabela = 1; + $steviloTabelCelih = intval($velikostTabele / $mejaZaVelikeTabele); + $steviloTabelMod = $velikostTabele % $mejaZaVelikeTabele; + $delnaTabela = 0; + if($steviloTabelMod != 0){ + $delnaTabela = 1; + } + $steviloTabel = $steviloTabelCelih + $delnaTabela; + +/* echo "stevilo podtabel celih ".($steviloTabelCelih)."
"; + echo "stevilo podtabel mod ".($steviloTabelMod)."
"; + echo "stevilo podtabel ".($steviloTabel)."
"; */ + }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."
"; + $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."
"; + + 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'])."
"; + 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'])."
"; + } + } + $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'),'')."
"; + } + } + } + $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."
"; + }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."
"; + $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."
"; + //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."
"; + //echo "indeks podatkov prej: ".$indeksPodatkov."
"; + + 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."
"; + $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'])."
"; + //echo "znotraj
"; + 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."
"; + + // VRSTICE S PODATKI + //print_r($frequencys); + //echo "vrstice: ".count($frequencys)."
"; + //foreach ($frequencys AS $fkey => $fkeyFrequency) { + $steviloVrsticSPodatki = count($frequencys); + + for($fkey=1; $fkey<=($steviloVrsticSPodatki); $fkey++){ //izpis vsake vrstice posebej + //echo "indeks freq: ".$fkey."
"; + $podatkiVrstica = array(); + $podatkiVrstica[] = $this->encodeText($forSpremenljivka['options'][$fkey]); //naslov horizontalne vrstice + //echo "debug text: ".$this->encodeText($forSpremenljivka['options'][$fkey])."
"; + + //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
"; + /* 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'])."
"; + } + } */ + $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'),'')."
"; + } + } + //print_r($podatkiVrstica); + $tabela .= $this->tableRow($podatkiVrstica, $brezHline); //izpis vrstice s podatki + //echo "indeks podatkov: ".$indeksPodatkov1."
"; + //echo "limit for zanke ".(5+$indeksPodatkovOld)."
"; + //echo "konec vrstice
"; + } + //Izpis vrstic tabele - konec ################## + + /*zakljucek latex tabele*/ + $tabela .= ($this->export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}"); + /*zaljucek latex tabele - konec */ + //echo "tabela :".$tabela."
"; + + } + + + } + }else + { + $rowspan = 2; + $colspan = $spremenljivka['grids'][0]['cnt_vars']; + $singleWidth = floor(200 / $colspan); + //echo "colspan spodaj: ".$colspan."
"; + + # 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
"; + //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']."
"; + 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 @@ +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 "
Tex celotne tabele: ".$descLatex."
"; + 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; $icrossData1[$i] = array($crossData1[$index],$crossData1[$index+1],$crossData1[$index+2]); + } + for($i=0; $icrossData2[$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; $jcrossData2); $j++){ + for($i=0; $icrossData1); $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 .= '
'. strip_tags($grid1['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid1['variable']) . ')' : ''); + } else { + $sub_q1 .= '
' . 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 ? ' ('.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.= '
' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid2['variable']) . ')' : ''); + } else { + $sub_q2.= '
' . 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 ? '  ' : '    ' )) . $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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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'].') '.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 @@ +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 @@ +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]."
"; + //$hideAllSystem = SurveyDataSettingProfiles :: getSetting('hideAllSystem'); + /* $hideAllSystem = SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'); + echo "hideAllSystem: ".$hideAllSystem."
"; */ + //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 "
"; */ + + $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 .= ' ('.strip_tags($spr1['variable']).')'; + } + if ($spr1['tip'] == '16') { + $sub_q1 .= ', ' . strip_tags($grid1['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid1['variable']) . ')' : ''); + } else { + $sub_q1 .= ', ' . 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 ? ' ('.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 .= ' ('.strip_tags($spr2['variable']).')'; + } + if ($spr2['tip'] == '16') { + $sub_q2.= ', ' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid2['variable']) . ')' : ''); + } else { + $sub_q2.= ', ' . 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']).')' : ''); + } + + $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."
"; + //echo "steviloVmesnihStolpcevPodvrstica2: ".$steviloVmesnihStolpcevPodvrstica2."
"; + //echo "steviloVmesnihStolpcevPodvrstica3: ".$steviloVmesnihStolpcevPodvrstica3."
"; + + $podVrstice = 0; + + //if($steviloVmesnihStolpcevPodvrstica2||$steviloVmesnihStolpcevPodvrstica3){ + if($steviloVmesnihStolpcevPodvrstica2&&$steviloVmesnihStolpcevPodvrstica3){ + //echo "1
"; + if($steviloVmesnihStolpcevPodvrstica2 >= $steviloVmesnihStolpcevPodvrstica3){ + $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica2; + //}else{ + }elseif(0 < $steviloVmesnihStolpcevPodvrstica2 && $steviloVmesnihStolpcevPodvrstica2 < $steviloVmesnihStolpcevPodvrstica3){ + $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica3; + } + //eksperiment + $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica2*$steviloVmesnihStolpcevPodvrstica3; + $podVrstice = 1; + }elseif($steviloVmesnihStolpcevPodvrstica2){ + //echo "2
"; + $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica2; + $podVrstice = 1; + }elseif($steviloVmesnihStolpcevPodvrstica3){ + //echo "3
"; + $steviloVmesnihStolpcevPodvrstic = $steviloVmesnihStolpcevPodvrstica3; + $podVrstice = 1; + }else{ + //echo "4
"; + $steviloVmesnihStolpcevPodvrstic = 1; + } + //echo "steviloVmesnihStolpcevPodvrstic: ".$steviloVmesnihStolpcevPodvrstic."
"; + //echo "Podvrstice: ".$podVrstice."
"; + //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 "velikost tabele: ".($velikostTabele)." podatkov je : $cols
"; + + 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
"; + $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)."
"; + echo "stevilo podtabel mod ".($steviloTabelMod)."
"; + echo "stevilo stolpcev delna podtabela ".($steviloStolpcevDelnaTabela)."
"; + echo "stevilo podtabel za izpis: ".($steviloTabel)."
"; */ + + + + $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'])."
"; + $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'])."
"; + /* $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
"; + + }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
"; + $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)."
"; + //echo "testiram, kjer ssem: ".$steviloTabColSep."
"; + $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."
"; + 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 "velikost tabele: ".($velikostTabele)." podatkov je : $cols
"; + //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)."
"; + //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."
"; + 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
"; + echo "steviloStolpcevParameterTabular1: $steviloStolpcevParameterTabular
"; */ + //$steviloStolpcevParameterTabular++; + }else{ + $steviloStolpcevParameterTabular = $mejaZaVelikeTabele + 1; + } + } + + if($steviloStolpcevParameterTabular <= 2){ + $steviloStolpcevParameterTabular++; + } + //echo "steviloStolpcevParameterTabular2: $steviloStolpcevParameterTabular
"; + $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]
"; + $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
"; + ########## + + 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)."
"; + + 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
"; + + // druga vrstica #################################################################################### + $tabela .= $this->encodeText($sub_q2); //prvi stolpec 2. vrstice + //echo "testiram, kjer ssem: ".$this->encodeText($sub_q2)."
"; + //echo "testiram, kjer ssem: ".$steviloTabColSep."
"; + $drugaVrstica = array(); + + //echo count($crosstabsOptions1All[$t])."
"; + //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
"; + //echo $this->encodeText($text)."
"; + } + 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."
"; + 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'])."
"; + //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
"; + } + + //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
"; + 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
"; + //echo "tabela 3: $tabela3
"; + + // 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]."
"; + //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
"; + echo "tabelaZadnja2: $tabelaZadnja2
"; */ + + $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
"; + 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']."
"; + // Izris grafa (ce je vklopljena nastavitev) + if($this->sessionData['showChart'] == '1' && $creport == false){ + $tabela .= $this->displayCrosstabChart(); + } + } + //echo "
Tex celotne tabele: ".$tabela."
"; + 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 @@ +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."
"; */ + //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
'; + $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 "
Tex celotne tabele: ".$tabela."
"; + 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 @@ +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']."
"; + + #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 "
Tex celotne tabele: ".$tabela."
"; + 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 @@ +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."
"; + //echo "vrstice: ".$rows."
"; + + $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."
"; + + $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."
"; + + //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 @@ +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'])."
"; + $tabela .= '\textbf{'.$this->encodeText($this->multiCrosstabClass->table_settings[$this->multiCrosstabClass->table_id]['title']).'}'.$this->texBigSkip.$this->texNewLine; + //echo $tabela."
"; +/* $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."
"; + + 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
"; + + $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."
"; + } + } + //$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)."
"; + } + + // 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;$imultiCrosstabClass->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
"; + // 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
"; + } + + + // 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."
"; + $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."
"; + 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."
"; + $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)."
"; + } + else{ + $tabela .= " & "; + //$this->pdf->MultiCell($width, $this->cellHeight, '', 'LR'.$border1, 'C', 0, 0, 0 ,0, true); + //echo "naslov :
"; + } + + + // 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)."
"; + //$this->pdf->MultiCell($width, $this->cellHeight, $this->snippet($option, 25), 'LR', 'C', 0, 0, 0 ,0, true); + } + else{ + $tabela .= " & "; + //echo "variabla :
"; + //$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)."
"; + //$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:
"; + //$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)."
"; + + // 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."
"; + //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."
"; + $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)."
"; + if($export_format != 'xls'){ + $tabela .= $this->snippet($option, 25)." & "; + }else{ + $tabela .= $option." & "; + } + + // Celice s podatki + //echo "celica s podatki: ".$var."
"; + // 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."
"; + $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
"; + $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
"; + } + 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
"; + } + + // Ce nimamo stolpcev - krizanje dveh vrstic + elseif($spr2 != '' && $this->multiCrosstabClass->colSpan == 0){ + echo "krizanje dveh vrstic
"; + $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
"; + // 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."
"; + //$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]."
"; + } + + 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]."
"; + + $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)
"; + // 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]."
"; + } + + 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
"; + // 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]."
"; + } + + 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]."
"; + } + + 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
"; + // 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]."
"; + } + + 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]."
"; + } + + 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."
"; +/* $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."
"; + } + // 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."
"; + } + } + 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."
"; + $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."
"; + $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("š","š","č"),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 @@ +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."
"; */ + //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']."
"; + $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']."
"; + 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 "
Tex celotne tabele: ".$tabela."
"; + return $tabela; + } + + /** Izriše sumarnik v vertikalni obliki z Latex + * + * @param unknown_type $spid + */ + function sumVertical($spid=null,$_from=null, $export_format='') { + //echo "sumVertical
"; + 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."
"; + 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
"; + $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
"; + } + // izpišemo sumo veljavnih + //$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options); + $tex .= self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,$options); + //echo "tex testni: ".$tex."
"; + } + 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']."
"; + 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."
"; + $counter++; + //echo "stevec: $counter
"; + } + } + // 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
"; + } + + //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)."
"; + if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) { + foreach ($_answersOther AS $oAnswers) { + $tex .= self::outputOtherAnswers($oAnswers, $parameterTabular, $export_format); + } + } + + + //echo "Latex tabele: ".$tex."
"; + return $tex; + } + + + /*Izpis sumarnika za check box z Latex*/ + function sumVerticalCheckbox($spid=null,$_from=null, $export_format='') { + //echo "sumVerticalCheckbox
"; + 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
"; + + $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."
"; + return $tex; + } + + /** Izriše nagovor + * + */ + function sumNagovor($spid=null, $_from=null, $export_format='') { + //echo "sumNagovor
"; + 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."
"; + 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
"; + 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."
"; + 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."
"; + 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
"; + 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."
"; + 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."
"; + 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
"; + 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
"; + 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."
"; + 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
"; + 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."
"; + 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("
","), (",$_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[] = ' '; + } + + $count++; + } + + } + $last = $_max_i; + } + + if($enota != 3){ + for($i=0; $i 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."
"; + 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
"; + 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."
"; + 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[] = ' '; + } + + $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
"; + 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."
"; + 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."
";*/ + 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
"; + 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."
"; + 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."
"; + 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
"; + $text = array(); + + $text[] = $this->encodeText($variable['variable']); + $text[] = $this->encodeText(($grid['naslov'] != '' ? $grid['naslov']. ' - ' : '').$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
"; + 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."
"; + 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'])."
"; + //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 ''.$freqHeatmapRegion.''; + //$devetaVrstica[] = $this->encodeText($freqHeatmapRegion); + $devetaVrstica[] = $freqHeatmapRegion; + //2. stolpec - Frekvenca - konec + + //3. stolpec - Veljavni + //$validHeatmapRegion = self::validHeatmapRegion($spremenljivka['grids'], $spid, $_valid_answers); + //echo ''.$validHeatmapRegion.''; + $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 ''.$_procentValidHeatmapRegion.''; + $devetaVrstica[] = $this->encodeText($_procentValidHeatmapRegion); + //4. stolpec - % Veljavni - konec + + //5. stolpec - Ustrezni + $ustrezniHeatmapRegion = SurveyAnalysis::ustrezniHeatmapRegion($spid, $_valid_answers, $_sequence); //vsi mozni kliki + //echo ''.$ustrezniHeatmapRegion.''; + $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 ''.$_procentUstrezniHeatmapRegion.''; + $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."
"; + //$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."
"; + //echo "_percent: ".$_percent."
"; + } + } + # izpišemo sumo neveljavnih + //$counter = SurveyAnalysis::outputSumaInvalidAnswerHeatmap($counter,$_sequence,$spid,$options, $manjkajoci); + echo "manjkajoci: ".$manjkajoci."
"; + } */ + #izpišemo še skupno sumo + //$counter = SurveyAnalysis::outputSumaHeatmap($counter,$_sequence,$spid,$options, $ustrezniHeatmapRegion); + //$ustrezniHeatmapRegion + //echo "ustrezniHeatmapRegion: ".$ustrezniHeatmapRegion."
"; + $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 '
'; + self::outputOtherAnswers($oAnswers); + echo '
'; + } + } */ + + + //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."
"; + + 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."
"; + 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 @@ +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(' ','',$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 @@ +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."
"; + 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."
"; + echo "visina iz nastavitev: ".$textboxHeightOrig."
"; + echo "sirina iz nastavitev: ".$textboxWidth."
"; + echo "sirina izracunana: ".$textboxWidth."
"; */ + //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."
"; + //echo "parametri tabele: ".$parameterTabular."
"; + + //$textboxWidth = 30 / $steviloStolpcevTabele / 100; //povozil $textboxWidth tako, da zadeva je v skladu s prejsnjimi izvozi + //echo "sirina 2: ".$textboxWidth."
"; + + //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."
"; + }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']."
"; + //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']."
"; + # 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']."
"; + echo "položaj besedila: ".$polozajBesedila."
"; */ + 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
"; + //}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
"; + }elseif($postavitev==0&&$polozajBesedila==2){ + //zacetek tabele + $tex .= $this->StartLatexTable($export_format, $parameterTabular, 'tabularx', 'tabular', 1, 1); + //echo "je vodoravno ob vprašanju spodaj
"; + }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
"; + } + } + //echo "tex koda: ".$tex."
"; + // 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']."
"; + }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."
"; + 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."
"; + //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
"; + }else{ //ce je rtf + + } + + } + //echo "tex koda: ".$tex." in indeks $indeksZaWhile
"; + 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 @@ +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."
"; + + 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']."
"; + //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 @@ +loop_id = $loop_id; + //echo "tip izpisa: $export_data_type
"; //$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."
"; + } + $izpisOdgovorov = 1; + } + //echo "Usr_id: ".$usr_id.'
'; + //echo "Stevilo odgovorov: ".count($userAnswer).'
'; + + + 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"."
"; + $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']."
"; + echo "spr ".$rowMultiple['spr_id']."
"; */ + //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
"; + } + + $sprIdRoletSeznamovTmp = $sprIdRoletSeznamov; + } + //pregled vseh odgovorov po stolpcih po $sqlStolpciVrednosti - vodoravni odgovori - konec + + + $vodoravniOdgovoriVsi = $vodoravniOdgovori; + /* echo "stevilo skupin rolet/seznamov ".($steviloSkupinRoletSeznamov)."
"; + echo "stevilo odgovorov v roletah ali seznamu ".($steviloOdgovorovRoletSeznamov)."
"; */ + +/* echo "vodoravniOdgovoriSprId: "; + print_r($vodoravniOdgovoriSprId); + echo "
"; + echo "Enote: "; + print_r($vodoravniOdgovoriEnota); + echo "
"; */ + + //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 "velikost tabele: ".($velikostTabele)."
"; + 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
"; + + $presirokaTabela = 1; + $steviloTabelCelih = intval($velikostTabele / $mejaZaVelikeTabele); + $steviloTabelMod = $velikostTabele % $mejaZaVelikeTabele; + $delnaTabela = 0; + if($steviloTabelMod != 0){ + $delnaTabela = 1; + } + $steviloTabel = $steviloTabelCelih + $delnaTabela; + + //echo "stevilo podtabel celih ".($steviloTabelCelih)."
"; + //echo "stevilo podtabel mod ".($steviloTabelMod)."
"; + //echo "stevilo podtabel za izpis: ".($steviloTabel)."
"; + //echo "stevilo podatkov za izpis: ".($steviloPodatkovZaIzpis)."
"; + + }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]."
"; + //echo "value: ".$value."
"; + //echo "valueTmp: ".$valueTmp."
"; + //echo "indeksParameterTabular: ".$indeksParameterTabular."
"; + //echo "Stevilo vodoravniOdgovoriSprId: ".count($vodoravniOdgovoriSprId)."
"; + + 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
"; + $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
"; + 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 "
sprememba spremenljivke iz $valueTmp v $value ".'
'; + + $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."
"; + + //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
"; + //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'; + //$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
"; + $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
"; + + #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."
"; + } + $izpisOdgovorov = 1; + } + //echo "podatek je: ".$userDataPresent."
"; + /* print_r($userAnswer); + echo "
"; */ + #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
"; + $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']."
"; + } + + //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 "
"; + print_r($vodoravniOdgovoriSprId); + echo "
";*/ + /* print_r($vodoravniOdgovoriEnota); + echo "
"; */ + /* print_r($vodoravniOdgovori); + echo "
"; */ + + //ureditev parametrov tabele + /* echo "enota:".$vodoravniOdgovoriEnota[0]."
"; + echo "izpisOdgovorov:".$izpisOdgovorov."
"; + echo "tip:".$vodoravniOdgovoriTip[0]."
"; + echo "export_data_type:".$export_data_type."
"; */ + //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
"; + + /* 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
"; + + $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
"; + //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"; + //$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
"; + $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 @@ +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."
"; + + 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."
"); + $path2Images = $this->path2Images; + + $imageNameTest = $path2Images.$imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku + + //error_log("iz heatmap: ".$imageNameTest); + //echo("iz heatmap: ".$imageNameTest."
"); + + $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)."
"; + + #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; $iuserAnswer);$i++){ //sprehodi se po tockah + + //echo "rowAnswers: ".$this->userAnswer[$i]['address'].' za odgovore tip '.$spremenljivke['tip'].' id '.$spremenljivke['id'].' usr '.$usr_id.'
'; + #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; $opolyX = 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"]."
"; + } + #pridobitev podatkov o obmocjih in podatka o prisotnosti tocke v obmocju - konec + //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(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"; + //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"; + }else{ + $tmpY = (int)$poly[$i]; + //echo "y: ".$tmpY."
"; + 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."
"); + $inside = false; + for ($i = 0, $j = count($polyX) - 1; $i < count($polyX); $j = $i++) { + //echo $polyX[$i]." ".$polyY[$i]."
"; + 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."
"; + 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 @@ +"; + $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."
"; + //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."
"; + } + } + + 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."
"; + +/* $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 @@ +"; + $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']."
"; + + //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']."
"; + } + } + + /*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."
"; + + $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."
"; + 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 @@ +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."
"; + } + + 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)."
"; + + for($i=0; $iuserAnswer);$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.'
'; + #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 @@ +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
"; + } + $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
"; + //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
"; + } */ + //echo "odgovor: ".$stringCell_title."
"; + + $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
"; + $sqlUserAnswerMissing = $this->GetUsersDataGrid($spremenljivkeData, $db_table, $rowVrednost, $rowVsehVrednosti, $usr_id,0); + $userAnswerMissing = mysqli_fetch_assoc($sqlUserAnswerMissing); + //echo "userAnswer Missing: ".$userAnswerMissing['grd_id'].'
'; + } + //echo "rowVsehVrednosti['id']: ".$rowVsehVrednosti['id'].'
'; + //echo "userAnswer: ".$userAnswer['text'].'
'; + //echo "userAnswer: ".$userAnswer['grd_id'].'
'; + //echo "rowVrednost['spr_id']: ".$rowVrednost['spr_id'].'
'; + + 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
"; + $indeksZaWhile++; + $podatek = 1; + //echo "Zgornji: ".$indeksZaWhile."
"; + //echo "Zgornji: ".$indeksZaWhile." za ".$this->encodeText($rowVsehVrednosti['naslov'])."
"; + //echo "tex: ".$tex1."
"; + }else{ + $podatek = 0; + } + + //echo $this->encodeText($this->userAnswer['text']).'
'; + if($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je grid stevilk ali besedil + + //echo "Indeks missing: ".$IndeksZaMissing."
"; + if(($IndeksZaMissing > ($numColSql-count($missingOdgovori)))&&(count($missingOdgovori))){ + //echo "userAnswer Missing je prisoten in njegov grd_id je: ".$userAnswerMissing['grd_id'].'
'; + $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."
"; + 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']."
"; + if($spremenljivke['tip']==19||$spremenljivke['tip']==20){ //ce je grid stevilk ali besedil + //echo "stevilo odgovorov: ".count($odgovoriRespondent)."
"; + //echo "stevilo odgovorov missing: ".count($userAnswerMissing)."
"; + //echo "stevilo odgovorov : ".count($userAnswer)."
"; + 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."
"; + 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
"; + + $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'].'
'; + $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
"; + 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'].'
'; + //echo "userAnswerVreId: ".$userAnswer['vre_id'].'
'; + //echo "text: ".$userAnswer['text'].'
'; + +/* if($spremenljivke['enota']==4&&$userAnswer['grd_id']){ + $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id']; + echo "userAnswerData: ".$userAnswerData[$indeksOdgovorov].'
'; + //echo 'je 4
'; + $indeksOdgovorov++; */ + if($spremenljivke['enota']==4){ //ce je ena moznost proti drugi + //echo 'je 4 '.$indeksOdgovorov.'
'; + if($userAnswer['grd_id']){ //ce je podatek, ga zabelezi + $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id']; + //echo "userAnswerData s podatkom: ".$userAnswerData[$indeksOdgovorov].'
'; + //echo 'je 4 '.$indeksOdgovorov.'
'; + $indeksOdgovorov++; + }else{ //drugace + if($indeksEnaMoznostProtiDrugi>=1){ + $userAnswerData[$indeksOdgovorov] = $userAnswer['grd_id']; + //echo "rabim prazno polje
"; + //echo "userAnswerData brez podatka: ".$userAnswerData[$indeksOdgovorov].'
'; + //echo 'je 4 '.$indeksOdgovorov.'
'; + $indeksOdgovorov++; + } + //echo "indeks se spremeni
"; + $indeksEnaMoznostProtiDrugi++; + } + //echo "indeksEnaMoznostProtiDrugi: ".$indeksEnaMoznostProtiDrugi.'
'; + //echo "userAnswerData: ".$userAnswerData[$indeksOdgovorov].'
'; + }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."
"; + $sqlTextR = sisplet_query($sqlTextRString); + $rowTextR = mysqli_fetch_assoc($sqlTextR); + //echo $rowTextR['naslov']."
"; + //echo $indeksOdgovorovTextR.'
'; + + //$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].'
'; + + $this->textRArray[$indeksOdgovorovTextR][$userAnswer['grd_id']]=$rowTextR['naslov']; + //echo "this->textRArray: ".$this->textRArray[$indeksOdgovorovTextR][$userAnswer['grd_id']].'
'; + //echo "this->textRArray indeks ".$indeksOdgovorov." ".$textRVreId[$indeksOdgovorov].'
'; + $indeksOdgovorovTextR++; + } + } + + $indeksOdgovorov++; + } + //echo "rowVrednost['spr_id']: ".$rowVrednost['spr_id'].'
'; + //echo "rowVrednost['id']: ".$rowVrednost['id'].'
'; + //echo "rowVsehVrednosti['id']: ".$rowVsehVrednosti['id'].'
'; + if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){ + $indeksZaWhileVsehVrednosti++; + } + if($indeksZaWhileVsehVrednosti!=1){ + $userDataPresent = 1; + } + //echo "userAnswerData: ".$userAnswerData[$indeksOdgovorov].'
'; + //echo "enota: ".$spremenljivke['enota'].'
'; + //echo "indeksOdgovorov: ".$indeksOdgovorov.'
'; + //$indeksOdgovorov++; + } + } + //pregled vseh moznih vrednosti (kategorij) po $sqlVrednosti - konec + + /* echo "userDataPresent: ".$userDataPresent."
"; + echo "preveriSpremenljivko: ".$preveriSpremenljivko."
"; */ + + $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']."
"; + //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('
','',$stringTitleCol); //odstranitev odvecnih
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."
"; + }else{ //drugace, ce je VAS + //$symbol = $this->getAnswerSymbol($export_format, $fillablePdf, $spremenljivke['tip'], $spremenljivke['grids'], 0, 0, $spremenljivke['enota']); + //echo "simbol VAS: ".$symbol."
"; + //echo "simbol radio grid: ".$spremenljivke['enota']."
"; + } + $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
"; + + $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."
"); + 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 $vodoravniOdgovor){ //za vsak odgovor v vrstici + echo $vodoravniOdgovor."
"; + //echo $key."
"; + } */ + // + /* foreach($data AS $key => $datum){ //za vsak odgovor v vrstici + echo "Podatek: ".$datum."
"; + //echo $key."
"; + } */ + + $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]."
"; + } + } + #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]."
"; + } + } + #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]."
"; + 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]."
"; + //echo "stevilo stolpcev VAS: ".$steviloStolpcev."
"; + //$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."
"; + } + } elseif($spremenljivke['enota']==12){ //ce je slikovni tip + if($data[$j]){ //ce je podatek + $steviloSlikovnihIkon = $data[$j]; + //echo "stevilo slikovnih ikon: ".$steviloSlikovnihIkon."
"; + //echo "_______________________
"; + } + }*/else{ + if($i==$steviloStolpcev){ + $i=0; + } + /* echo "tip: ".$spremenljivke['tip']."
"; + echo "enota: ".$spremenljivke['enota']."
"; */ + 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."
"; + 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.'
'; + //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.'
'; + + //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."
"; + }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"; + + //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'; + } */ + } + //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."
"; + //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.'
'; + //echo $spremenljivke['grids'].'
'; + + //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."
"; + } */ + $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| /",' ',$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."
"; + + //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]."
"; + 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 @@ +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."
"; + + //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 @@ +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."
"; + //echo "__________________________________
"; + + $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."
"; + + #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."
"; + //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."
"; + } + } + } + #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']."
"; + echo "tip: ".$spremenljivke['tip']."
"; */ + 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."
"); + 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."
"; + 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."
"; + } + + 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
"; + //echo "jezik: ".$this->language."
"; + 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
"; + }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 @@ +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."
"; + $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."
"; +/* echo "odgovori respondenta: ".count($odgovoriRespondenta)."
"; + echo "navpični odgovori: ".count($navpicniOdgovori)."
"; + echo "stevilo Odgovorov: ".$steviloOdgovorov."
"; + echo "stevilo desnih okvirjev: ".$steviloDesnihOkvirjev."
"; */ + + //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."
"; + + //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]."
"; + 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 @@ +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 @@ +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."
"; + + 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."
"; + //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']."
"; + //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)."
"; + 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."
"; + //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."
"; + + }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."
"; + } + + 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."
"; + +/* $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| /",' ',$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."
"; + //$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 @@ +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."
"; + + 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']."
"; + 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 @@ +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.'
'; + + 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."
"; + //echo "Indeksi SurveyAnalysis::missingProfileData v displayAnalysis: ".print_r(array_keys(SurveyAnalysis::$missingProfileData))."
"; + + //echo "display_mv_type in displayAnalysis: ".SurveyAnalysis::$missingProfileData['display_mv_type']."
"; + // 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."
"; + + # 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'].'
'; + //echo 'export_subtype: '.$export_subtype.'
'; + + /*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']."
"; + /*echo "spr_id: ".$this->spremenljivka."
"; + echo "spid : ".$spid."
"; */ + # č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 @@ +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."
"; + $this->hideAllSystem = SurveyDataSettingProfiles :: getSetting('hideAllSystem'); + //echo "hideAllSystem: ".$this->hideAllSystem."
"; + + //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."
"; + //Nastavitve grafov - konec + + //echo $this->spremenljivka['tip']."
"; + //echo "Spid v construct: ".$spid."
"; + //echo "Spid v construct: ".$this->spid."
"; + //echo "head file name: ".$this->headFileName."
"; + + //echo 'To je construct tip analysis
'; + + } + + + + public function displayTablesLatex($spid=0, $export_format=''){ + global $site_path; + global $lang; + global $global_user_id; + + + //echo 'funkcija displayTableLatex
'; + //echo "Tip: ".$this->spremenljivka['tip']."
"; + //echo "Export subtype: ".$this->export_subtype."
"; + + //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; $icrossData1[$i] = array($crossData1[$index],$crossData1[$index+1],$crossData1[$index+2]); + } + for($i=0; $icrossData2[$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)."
"; + 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; $jcrossData2); $j++){ + for($i=0; $icrossData1); $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."
"; + 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."
"; + 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."
"; + 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."
"; + 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']."
"; + + 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."
"; + 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
"; + + + $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."
"; + 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("š","š",$text); + //echo "Encoding ".$text."
"; + + //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 = '
'; + $findmeLength = strlen($findme); + $findImg = '' 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, 'path2Images."".$this->getImageName($text, 0, '"; + $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode + //echo $textToImgCode."
"; + $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode + //echo $textFromImgCode."
"; + $findImgCodeEnd = '}'; + //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd); + $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd); + //echo $posOfImgCodeEnd."
"; + $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd + //echo $textAfterImgCode."
"; + $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1); + //echo $textOfImgCode."
"; + + $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, '&')){ //ce je prisotno v besedilu &' + $text = str_replace('&','\& ',$text); + }else{ + $text = str_replace('&','\& ',$text); + } + + $andSymbolPresent = 0; + $posAndSymbolPresent = strpos($text,'&'); + if($posAndSymbolPresent !== false){ //ce je v besedilu prisoten '&' zapisan kot '&' + $text = str_replace('&','\&',$text); + $andSymbolPresent = 1; + } + if($andSymbolPresent == 0){ + $text = str_replace('&','\&',$text); + } + + //$text = str_replace('<','\textless ',$text); + $text = str_replace('<','\textless',$text); + //$text = str_replace('>','\textgreater ',$text); + $text = str_replace('>','\textgreater',$text); + $text = str_replace(' ',' ',$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 = '"; + $numOfUl = substr_count($text, $findUl); //stevilo '"; + ###################### + if($numOfUl!=0){ + $text = str_replace('
    ','\begin{itemize} ', $text); + $text = str_replace('
  • ','\item ', $text); + $text = str_replace('
','\end{itemize} ', $text); + } + //echo "prazno v html: ".strpos($text, '\r')."
"; + //echo "text potem: ".$text."
"; + ###################### + } + + //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."
"; + echo "encode po strip: ".strip_tags($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 '
' v tekstu + for($i=0; $i<$numOfBr; $i++){ + if($i == 0){ //ce je prvi najdeni '
' + $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."
"; + echo "encode po strip: ".strip_tags($text)."
"; + 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
"; + //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
"; + $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 = '
(več...)
'.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 ''; + echo ' . . . Prikazujemo samo prvih '.TEXT_MAX_ANSWER_LIMIT.' veljavnih odgovorov!'; + echo ''; + }*/ + + $exportformat = $options['exportFormat']; + $brezHline = $this->getBrezHline($exportformat); + + $texoutputValidAnswerVertical .= self::tableRow($text, $brezHline); + //echo "Besedilo na koncu funkcije outputValidAnswerVertical:".$texoutputValidAnswerVertical."
"; + 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."
"; + //$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."
"; + 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."
"; + 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;$itexNewLine; + echo "naslovi v tabeli: ".$naslov[$i]."
"; + } */ + + return $tableHeader; + } + + //funkcija skrbi za izpis multicol celice + function MultiColCellLatex($steviloVmesnihStolpcevPodvrstic=null, $text='', $odZacetka=0){ + $tabela = ''; + //echo "steviloVmesnihStolpcevPodvrstic: $steviloVmesnihStolpcevPodvrstic
"; + 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."
"; + 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
"; + //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."
"; + return $tabela; + } + + function DisplayLatexCells($crossChk='', $podVrstice=null, $colNum=null, $steviloVmesnihStolpcevPodvrstic=2, $niSodo = 0){ + $tabela = ''; + //echo "steviloVmesnihStolpcevPodvrstic: $steviloVmesnihStolpcevPodvrstic
"; + //echo "crossChk: $crossChk
"; + 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]."
"; + echo $arrayText[1]."
"; + echo "brez hline: ".$brezHline."
"; */ + + if($arrayParams['align2'] != 'C') + $arrayParams['align2'] = 'L'; + //echo "velikost polja s tekstom: ".count($arrayText)."
"; + + 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"; + + ####### 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."
"; + + 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']."
"; + $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."
"; + 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']."
"; + $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'),' %')); + $text[] = $this->encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),' %')); + 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'),' %'))." ".$spremenljivka['tip']."
"; + //echo "tex iz funkcije displayDescriptivesVariablaRow: ".$texDescriptivesVariablaRow."
"; + return $texDescriptivesVariablaRow; + } + + function returnBold($text=''){ + $boldedText = ''; + $boldedText .= '\textbf{'.$text.'}'; + return $boldedText; + } + + function returnCentered($text='', $export_format = ''){ + //echo "$export_format
"; + $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."
"; + $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."
"; + //echo "pozicija črke: ".$pozicijaChar."
"; + $textToChar = substr($besedilo, 0, $pozicijaChar); //tekst do posebne crke + //echo $textToChar."
"; + $tmpTextFromChar = substr($besedilo, $pozicijaChar); //tekst po posebne crke posebno crko + //echo $tmpTextFromChar."
"; + $textFromChar = substr($tmpTextFromChar, 2); //tekst po posebni crki dalje + //echo $textFromChar."
"; + + //$besediloTmp = $textToChar."{".$char."}".$textFromChar; + $besedilo = $textToChar."{".$char."}".$textFromChar; + $besediloTmp = $textToChar."{".$char."}"; + //echo "besedilo: ".$besedilo."
"; + //$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."
"; + $besedilo = $besediloTmp; + }while($moreChars == 1); + + } + } + //echo "besedilo končno: ".$besedilo."
"; + 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 @@ +{\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{\Hnewline}} + \ConfigureEnv{quote}{\Tg}{\Tg}{}{} + } + \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.'
'; + echo 'export_subtype: '.$export_subtype.'
'; + echo 'export_format: '.$export_format.'
'; + echo 'anketaID: '.$_GET['anketa'].'
'; + /*echo 'sprID: '.$_GET['sprID'].'
'; + echo '$this->export_font_size: '.$this->export_font_size.'
'; + echo '$this->export_data_type: '.$this->export_data_type.'
'; + echo 'SurveyId: '.SurveyInfo::getSurveyId().'
'; */ + + #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."
"; + // 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']."
"; + } */ + + //$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
\n"); + fwrite($fp, $tex) or + die ("cannot send data to file
\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{\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."
"; + // 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."
"; + 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."
"; + //echo "export type: ".$export_type." subtype: ".$this->export_subtype."
"; + #### 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."
"; + $file2Delete = glob($textTest.'*'); + //echo count($file2Delete)."
"; + foreach ($file2Delete as $file) { + //echo "Funkcija DeleteTmpImages ".$file."
"; + 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."
"; + //echo "numOfCellxOccurrences: ".$numOfCellxOccurrences."
"; + + 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."

"; + + $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."
"; + $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."
"; + } + //echo $cellXString."
"; + $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 "
substringVrstice changed: ".$substringVrstice."


"; + + //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."

"; + + $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."
"; + $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."
"; + } + //echo $cellXString."
"; + //$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."
"; + //echo "lenOrigFont: ".$lenOrigFont."
"; + + //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:
"; +// 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."
"; + global $site_path; + global $site_url; + //echo '
'; + $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."
"; + + $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, '&')){ //ce je prisotno v besedilu &' + $text = str_replace('&','\& ',$text); + }else{ + $text = str_replace('&','\& ',$text); + } + $text = str_replace(' ','~',$text); + //$text = str_replace('<','\textless ',$text); + $text = str_replace('<',' \textless ',$text); + //$text = str_replace('>','\textgreater ',$text); + $text = str_replace('>',' \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 @@ +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("š","š",$text); + //echo "Encoding ".$text."
"; + if($text == ''){ //ce ni teksta, vrni se + return; + } + $textOrig = $text; + $findme = '
'; + $findmeLength = strlen($findme); + $findImg = '' 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, '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."
"; + $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode + //echo $textToImgCode."
"; + $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode + //echo $textFromImgCode."
"; + $findImgCodeEnd = '}'; + //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd); + $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd); + //echo $posOfImgCodeEnd."
"; + $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd + //echo $textAfterImgCode."
"; + $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1); + //echo $textOfImgCode."
"; + + $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('&','\&',$text); + $text = str_replace('&','\&',$text); + //$text = str_replace('<','\textless ',$text); + $text = str_replace('<','\textless',$text); + //$text = str_replace('>','\textgreater ',$text); + $text = str_replace('>','\textgreater',$text); + $text = str_replace(' ',' ',$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."
"; + echo "encode po strip: ".strip_tags($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 '
' v tekstu + for($i=0; $i<$numOfBr; $i++){ + if($i == 0){ //ce je prvi najdeni '
' + $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."
"; + echo "encode po strip: ".strip_tags($text)."
"; + 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)."
"; + + if($export_format == 'pdf'){ + if($color=='blue'){ + $cellBgColor = 'cyan'; + }elseif($color=='red'){ + $cellBgColor = 'pink'; + } + $cellColoring = ' \cellcolor{'.$cellBgColor.'} '; + }else{ + $cellColoring = ''; + } + + for($i=0;$i"; + 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."
"; + + 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 '

'.$lang["srv_edits_analysis_editing_details"].'

'; + + 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."
"; + + $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."
"; + echo "st_akcij_sum: ".$st_akcij_sum."
"; + echo "st_seans_sum: ".$st_seans_sum."
"; + echo "user_id: ".$user_id."
"; + echo "action_type_sum: ".$action_type_sum."
"; */ + + //echo ''; + + 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 .= ''; + if($i < 3) + $action_type_string .= '
'.$key.' ('.$at.')'.'
'; + else + $action_type_string .= '
'.$key.' ('.$at.')'.'
'; + $i++; */ + $action_type_string .= $key.' ('.$at.')'.'; '; + } +/* if($i > 3) + $action_type_string .= ''; */ + } + //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 @@ +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 taga + //$tex = str_replace('', '\textcolor{1ka_orange}{', $tex); + $tex = str_replace('', '\textcolor{crta}{', $tex); + $tex = str_replace('', '}', $tex); + + // Se replacamo href-e + preg_match_all("|]*>([^<]*)|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 @@ +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("š","š",$text); + //echo "Encoding ".$text."
"; + if($text == ''){ //ce ni teksta, vrni se + return; + } + $textOrig = $text; + $findme = '
'; + $findmeLength = strlen($findme); + $findImg = '' 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, '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."
"; + $textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode + //echo $textToImgCode."
"; + $textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode + //echo $textFromImgCode."
"; + $findImgCodeEnd = '}'; + //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd); + $posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd); + //echo $posOfImgCodeEnd."
"; + $textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd + //echo $textAfterImgCode."
"; + $textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1); + //echo $textOfImgCode."
"; + + $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('&','\&',$text); + $text = str_replace('&','\&',$text); + //$text = str_replace('<','\textless ',$text); + $text = str_replace('<','\textless',$text); + //$text = str_replace('>','\textgreater ',$text); + $text = str_replace('>','\textgreater',$text); + $text = str_replace(' ',' ',$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."
"; + echo "encode po strip: ".strip_tags($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 '
' v tekstu + for($i=0; $i<$numOfBr; $i++){ + if($i == 0){ //ce je prvi najdeni '
' + $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."
"; + echo "encode po strip: ".strip_tags($text)."
"; + 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)."
"; + + for($i=0;$i"; + $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."
"; + + 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 @@ +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."
"; + if($this->showGDPRIntro){ + $this->GDPRIntro = $gdpr->getSurveyIntro($this->anketa); + //echo "gdpr te: ".$this->GDPRIntro."
"; + } + + 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
"; + $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, '