diff --git a/admin/survey/export/latexclasses/class.LatexSurvey.php b/admin/survey/export/latexclasses/class.LatexSurvey.php index 84ebb462b..7a873a891 100644 --- a/admin/survey/export/latexclasses/class.LatexSurvey.php +++ b/admin/survey/export/latexclasses/class.LatexSurvey.php @@ -440,21 +440,30 @@ class LatexSurvey{ if ( !$this->getGrupa() ){ if ( SurveyInfo::getInstance()->getSurveyShowConcl() && SurveyInfo::getInstance()->getSurveyConcl() ) { // ce obstaja footer izpisemo footer -/* $this->pdf->Ln(LINE_BREAK); - $this->pdf->drawLine(); - $this->pdf->Ln(LINE_BREAK); - $this->pdf->Write (0, $this->encodeText(SurveyInfo::getInstance()->getSurveyConcl()), '', 0, 'L', 1, 1); */ + } } - - ######## - - // Pripravimo podatke, ki se uporabijo v tabelah - - // 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. - //$this->tex .= ' testni tekst display survey'; + + // Izpis grafa in tabele za NIJZ na koncu dokumenta + global $site_domain; + //if($this->anketa == '140'){ + if( ($site_domain == 'test.1ka.si' && $site_domain == '8892') || ($site_domain == 'anketa.nijz.si' && $site_domain == '9999999') ){ + + // Page break + $tex .= '\cleardoublepage'; + + // Naslov "Ocena bivalnega okolja" + $tex .= '\begin{center} \textbf{Ocena bivalnega okolja} \end{center}'; + + $nijz = new SurveyNIJZ($this->anketa, $this->usr_id); + + // Latex nijz slika grafa + $tex .= $nijz->displayRadarLatex(); + + // Latex nijz tabela + $tex .= $nijz->displayTableLatex(); + } return $tex; } @@ -1049,12 +1058,6 @@ class LatexSurvey{ $output .= ' '.$row_if['label'].' '; $output .= ') '; } - //echo $output."
"; -/* $this->pdf->SetTextColor(0,0,150); - $this->pdf->setFont('','B',$this->font); - $this->pdf->MultiCell(90, 1, $this->encodeText($output),0,'L',0,1,0,0); - $this->pdf->SetTextColor(0,0,0); - $this->pdf->setFont('','',$this->font); */ return $output; } @@ -1242,56 +1245,7 @@ class LatexSurvey{ $posLi = strpos($text, $findLi); $posPar = strpos($text, $findPar); - //ureditev izrisa slike -/* if($posImg !== false){ - $numOfImgs = substr_count($text, $findImg); //stevilo ''); //pozicija, kjer se konca html koda za img - $textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje - - //$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2UploadedImages."".$this->getImageName($text, 0, 'path2UploadedImages."".$this->getImageName($text, 0, 'path2UploadedImages."".$this->getImageName($text, 0, '"); - if(filesize($imageNameTest) > 0){ - $text = $textPrej.' '.PIC_SIZE_ANS."{".$imageName."}".' '.$textPotem; - }else{ - $image = $lang['srv_pc_unavailable']; - $text = $textPrej.' '.$image.' '.$textPotem; - } - } - - //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - $findImgCode = '\includegraphics'; - $posOfImgCode = strpos($text, $findImgCode); - //echo $posOfImgCode."
"; - $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); @@ -1327,13 +1281,7 @@ class LatexSurvey{ ###################### } //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($posPar !== false){ //ce je kaksen html tag

, dodaj prazno vrstico oz. break if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li $divider = ' '; diff --git a/admin/survey/export/latexclasses/class.LatexSurveyElement.php b/admin/survey/export/latexclasses/class.LatexSurveyElement.php index dd675953b..f1c988a4b 100644 --- a/admin/survey/export/latexclasses/class.LatexSurveyElement.php +++ b/admin/survey/export/latexclasses/class.LatexSurveyElement.php @@ -195,17 +195,12 @@ class LatexSurveyElement{ $sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'"); $rowVrstic = mysqli_fetch_row($sqlVrstic); $visina = round(($rowVrstic[0]+2) * 8); - - //$linecount_vprasanja = $this->pdf->getNumLines($spremenljivke['naslov'], $this->pdf->getPageWidth()); - - //$tex = $spremenljivke['naslov']; + ######################################### Pridobimo tekst vprasanja - konec #Stevilcenje vprasanj############################################################### - //$numberingText = ($this->numbering == 1) ? $spremenljivke['variable'].' - ' : ''; $numberingText = ($this->numbering == 1) ? $this->encodeText($spremenljivke['variable']).' - ' : ''; ######################################### Stevilcenje vprasanj - konec - //echo "goli naslov: ".$spremenljivke['naslov']."
"; //belezenje imena spremenljivke, zaradi GDPR vprasanja $this->variableName =$spremenljivke['variable']; @@ -224,36 +219,6 @@ class LatexSurveyElement{ #Izpis if-ov pri vprasanju######################################################### if($this->showIf == 1){ - // TODO: Stara koda za iskanje po branchingu (briši, če je vse ok) - //$b = new Branching($this->anketa); - //$parents = $b->get_parents($spremenljivke['id']); - //$parents = explode('p_', $parents); - //foreach ($parents AS $key => $val) { - // if ( is_numeric(trim($val)) ) { - // $parents[$key] = (int)$val; - // } else { - // unset($parents[$key]); - // } - //} - - /* $b = new Branching($this->anketa); - $parents = $b->get_parents($spremenljivke['id']); - $parents = explode('p_', $parents); - foreach ($parents AS $key => $val) { - if ( is_numeric(trim($val)) ) { - $parents[$key] = (int)$val; - } else { - unset($parents[$key]); - } - } - - foreach ($parents AS $if) { - $tex .= $this->displayIf($if); - $tex .= $this->texNewLine; - }*/ - ###### stara koda, ki je delavala - - // Po novem izpisemo pred vsakim vprasanjem vse ife znotraj katerih se nahaja Cache::cache_all_srv_branching($this->anketa); $parents = Cache::srv_branching($spremenljivke['id'], 0)['parent']; @@ -265,8 +230,6 @@ class LatexSurveyElement{ } ######################################### Izpis if-ov pri vprasanju - konec - - //$tex .= '\textbf{'.$text.'} '.$texNewLine; //izris besedila vprasanja if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov $text = $this->dataPiping($text); //pokazi odgovore po zanki @@ -313,43 +276,9 @@ class LatexSurveyElement{ $tex .= $this->texNewLine; } } - } - - #################### -/* if( !in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce ni multigrid radio, checkbox, besedilo ali stevilo - - //preveri, ce je itemize v besedilu in ustrezno uredi prazno vrstico - $findItemize = '\begin{itemize}'; - $posItemize = strpos($tex, $findItemize); //v trenutni tex kodi najdi prisotnost besedila za itemize - if($posItemize === false){ //ce ni besedila itemize, dodaj prazno vrstico - //pejdi v novo vrstico - $tex .= $this->texNewLine; - } - //preveri, ce je itemize v besedilu in ustrezno uredi prazno vrstico - konec - } - - if($export_subtype=='q_data'||$export_subtype=='q_data_all'){ //ce je izpis odgovorov - if( in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo - $tex .= $this->texNewLine; - //echo "ni vodoravno ob vprašanju in je število ali besedilo
"; - } - } - - //ce imamo opombo, jo izpisi - if($spremenljivke['info'] != ''){ - if( in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo - $tex .= $this->texNewLine; - echo "ni vodoravno ob vprašanju in je število ali besedilo
"; - } - //$tex .= $this->texNewLine; - $tex .= '\vspace{2 mm}'; - $tex .= ' {\indent \\footnotesize '.$this->encodeText($spremenljivke['info']).'}'; - if( !in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce ni multigrid radio, checkbox, besedilo ali stevilo - $tex .= $this->texNewLine; - } - } */ - #################### - }else{ //ce je vodoravno ob vprasanju + } + } + else{ //ce je vodoravno ob vprasanju //ce imamo opombo, jo izpisi if($spremenljivke['info'] != ''){ //pejdi v novo vrstico @@ -370,14 +299,16 @@ class LatexSurveyElement{ #ce vprasanje nima moznih odgovorov, je potrebno zakljuciti environment (absolutelynopagebreak) pri pdf //echo $rowVrstic[0]."za spremenljivko: ".$spremenljivke['tip']."
"; if($rowVrstic[0]==0 && (in_array($spremenljivke['tip'], array(1, 2, 3, 6, 16, 17, 20, 9, 19, 17))) ){ - if($this->export_format == 'pdf'){ //ce je pdf + + if($this->export_format == 'pdf'){ //ce je pdf if($spremenljivke['orientation']==0 || $spremenljivke['orientation']==2){ //ce sta vodoravni orientaciji $tex .= $this->texNewLine; //dodaj na koncu vprasanja prazno vrstico } $tex .= $this->texBigSkip; $tex .= $this->texBigSkip; $tex .= '\\end{absolutelynopagebreak}'; //zakljucimo environment, da med vprasanji ne bo prelomov strani - }else{ //ce je rtf + } + else{ //ce je rtf if($spremenljivke['orientation']==0 || $spremenljivke['orientation']==2){ //ce sta vodoravni orientaciji $tex .= $this->texNewLine; //dodaj na koncu vprasanja prazno vrstico } @@ -387,7 +318,7 @@ class LatexSurveyElement{ } #ce vprasanje nima moznih odgovorov, je potrebno zakljuciti environment (absolutelynopagebreak) pri pdf - konec } - //echo "tex: ".$tex."
"; + return $tex; } #funkcija, ki pripravi latex kodo za prikazovanje besedila vprasanja - konec ############################################################################ diff --git a/admin/survey/modules/mod_NIJZ/class.SurveyNIJZ.php b/admin/survey/modules/mod_NIJZ/class.SurveyNIJZ.php index 5078ffced..97c121c2b 100644 --- a/admin/survey/modules/mod_NIJZ/class.SurveyNIJZ.php +++ b/admin/survey/modules/mod_NIJZ/class.SurveyNIJZ.php @@ -13,6 +13,24 @@ class SurveyNIJZ{ private $vprasanja_radar = array(); // array z vsemi vprasanji in odgovori na njih, ki jih obravnavamo + // Barve + private $colors = array( + 1 => '9966cc', + 2 => 'cc0099', + 3 => 'FFD700', + 4 => 'cc6699', + 5 => 'FFA500', + 6 => '008000', + 7 => '3399cc', + 8 => '99cc33', + 9 => '0099cc', + 10 => '669900', + 11 => '66cc99', + 12 => 'FF0000', + 13 => 'FF8C00', + 14 => '99cccc', + ); + function __construct($anketa, $usr_id){ @@ -81,7 +99,7 @@ class SurveyNIJZ{ global $lang; global $site_url; - $this->createRadar(); + $radar_image = $this->createRadar(); // CSS:) echo ''; + '; + foreach($this->colors as $key => $color){ + echo '.nijz_table_holder table.nijz_table tr td.tema'.$key.'{ color: #'.$color.'; }'; + } + echo ''; + echo '

'; @@ -183,10 +217,49 @@ class SurveyNIJZ{ echo '
'; } + // Prikazemo tabelo po temah v pdf izvozu + public function displayTableLatex(){ + global $lang; + + $half = round(count($this->vprasanja_radar) / 2); + + $tex = ''; + + // Definiramo barve + foreach($this->colors as $key => $color){ + $tex .= '\definecolor{tablecolor'.$key.'}{HTML}{'.$color.'}'; + } + + // Vstavimo tabelo + $tex .= ' + \begin{table}[h] + \centering + \begin{tabular}{|p{6cm}|c|p{6cm}|c|} + '; + for($i=1; $i<=$half; $i++) { + + $tex .= ' \hline '; + + $tex .= '\textcolor{tablecolor'.$i.'}{'.$this->vprasanja_radar[$i]['naslov'].'} & \textcolor{tablecolor'.$i.'}{'.$this->vprasanja_radar[$i]['data'].'} & '; + $j = $i + $half; + $tex .= '\textcolor{tablecolor'.$j.'}{'.$this->vprasanja_radar[$j]['naslov'].'} & \textcolor{tablecolor'.$j.'}{'.$this->vprasanja_radar[$j]['data'].'}'; + + $tex .= ' \\\\ '; + } + $tex .= ' + \hline + \end{tabular} + \end{table} + '; + + return $tex; + } + // Zgeneriramo pdf analizo public function createRadar(){ global $site_path; + global $site_url; global $admin_type; // Najprej pocistimo morebitno obstojeco sliko grafa @@ -204,6 +277,8 @@ class SurveyNIJZ{ return $e->getMessage(); } + $radar_image = $site_url.RESULTS_FOLDER.'/radar_'.$this->usr_id.'.png'; + // Testiranje - izpis errorjev /*if($admin_type == 0){ echo '
'; @@ -215,6 +290,8 @@ class SurveyNIJZ{ // Na koncu pobrisemo zacasne datoteke $this->deleteTemp(); + + return $radar_image; } // Pripravimo zacasne datoteke