Nijz izvoz - radar graf in tabela
This commit is contained in:
parent
f79d14894a
commit
1e2aa3ba8d
@ -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."</br>";
|
||||
/* $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 '<img ' v tekstu
|
||||
$posImg = strpos($text, $findImg);
|
||||
$textPrej = '';
|
||||
$textPotem = '';
|
||||
for($i=0; $i<$numOfImgs; $i++){
|
||||
$posImg = strpos($text, $findImg);
|
||||
$textPrej = substr($text, 0, $posImg); //tekst do img
|
||||
$textPotem = substr($text, $posImg); //tekst po img, z vkljuceno hmlt kodo z img
|
||||
$posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
|
||||
$textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
|
||||
|
||||
//$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2UploadedImages."".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
|
||||
//$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2UploadedImages."".$this->getImageName($text, 0, '<img', $vre_id)."}".' '.$textPotem;
|
||||
$imageName = $this->path2UploadedImages."".$this->getImageName($text, 0, '<img', $vre_id);
|
||||
$imageNameTest = $imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku
|
||||
//error_log("iz survey element: ".$imageNameTest);
|
||||
//echo("iz survey element: ".$imageNameTest."</br>");
|
||||
if(filesize($imageNameTest) > 0){
|
||||
$text = $textPrej.' '.PIC_SIZE_ANS."{".$imageName."}".' '.$textPotem;
|
||||
}else{
|
||||
$image = $lang['srv_pc_unavailable'];
|
||||
$text = $textPrej.' '.$image.' '.$textPotem;
|
||||
}
|
||||
}
|
||||
|
||||
//pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
|
||||
$findImgCode = '\includegraphics';
|
||||
$posOfImgCode = strpos($text, $findImgCode);
|
||||
//echo $posOfImgCode."</br>";
|
||||
$textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode
|
||||
//echo $textToImgCode."</br>";
|
||||
$textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode
|
||||
//echo $textFromImgCode."</br>";
|
||||
$findImgCodeEnd = '}';
|
||||
//$posOfImgCodeEnd = strpos($text, $findImgCodeEnd);
|
||||
$posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd);
|
||||
//echo $posOfImgCodeEnd."</br>";
|
||||
$textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd
|
||||
//echo $textAfterImgCode."</br>";
|
||||
$textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1);
|
||||
//echo $textOfImgCode."</br>";
|
||||
|
||||
$text = $textToImgCode.$textAfterImgCode;
|
||||
|
||||
//pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - konec
|
||||
} */
|
||||
//ureditev izrisa slike - konec
|
||||
|
||||
|
||||
//ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
|
||||
$text = str_replace('\\','\textbackslash{} ',$text);
|
||||
//$text = str_replace('{','\{',$text);
|
||||
@ -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 <p>, dodaj prazno vrstico oz. break
|
||||
if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
|
||||
$divider = ' ';
|
||||
|
@ -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']."</br>";
|
||||
|
||||
//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 </br>";
|
||||
}
|
||||
}
|
||||
|
||||
//ce imamo opombo, jo izpisi
|
||||
if($spremenljivke['info'] != ''){
|
||||
if( in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce je multigrid radio, checkbox, besedilo ali stevilo
|
||||
$tex .= $this->texNewLine;
|
||||
echo "ni vodoravno ob vprašanju in je število ali besedilo </br>";
|
||||
}
|
||||
//$tex .= $this->texNewLine;
|
||||
$tex .= '\vspace{2 mm}';
|
||||
$tex .= ' {\indent \\footnotesize '.$this->encodeText($spremenljivke['info']).'}';
|
||||
if( !in_array($spremenljivke['tip'], array(6, 16, 19, 20, 21, 7)) ){ //ce ni multigrid radio, checkbox, besedilo ali stevilo
|
||||
$tex .= $this->texNewLine;
|
||||
}
|
||||
} */
|
||||
####################
|
||||
}else{ //ce je vodoravno ob vprasanju
|
||||
}
|
||||
}
|
||||
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']."</br>";
|
||||
if($rowVrstic[0]==0 && (in_array($spremenljivke['tip'], array(1, 2, 3, 6, 16, 17, 20, 9, 19, 17))) ){
|
||||
if($this->export_format == 'pdf'){ //ce je pdf
|
||||
|
||||
if($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."</br>";
|
||||
|
||||
return $tex;
|
||||
}
|
||||
#funkcija, ki pripravi latex kodo za prikazovanje besedila vprasanja - konec ############################################################################
|
||||
|
@ -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 '<style>
|
||||
@ -101,17 +119,42 @@ class SurveyNIJZ{
|
||||
|
||||
echo '<h1 class="nijz_title radar_title">Ocena bivalnega okolja</h1>';
|
||||
|
||||
echo '<img src="'.$site_url.RESULTS_FOLDER.'/radar_'.$this->usr_id.'.png">';
|
||||
echo '<img src="'.$radar_image.'">';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// Prikazemo radar graf po temah v pdf izvozu
|
||||
public function displayRadarLatex(){
|
||||
global $lang;
|
||||
global $site_path;
|
||||
|
||||
$this->createRadar();
|
||||
|
||||
$tex = '';
|
||||
|
||||
$tex .= '\graphicspath{ {'.$site_path.RESULTS_FOLDER.'/} }';
|
||||
|
||||
$radar_image = 'radar_'.$this->usr_id.'.png';
|
||||
//$radar_image = 'radar.png';
|
||||
|
||||
// Vstavimo graf
|
||||
$tex .= '
|
||||
\begin{center}
|
||||
\includegraphics[width=15cm]{'.$radar_image.'}
|
||||
\end{center}
|
||||
';
|
||||
|
||||
return $tex;
|
||||
}
|
||||
|
||||
// Prikazemo tabelo po temah
|
||||
public function displayTable(){
|
||||
global $lang;
|
||||
|
||||
// CSS:)
|
||||
echo '<style>
|
||||
echo '<style>';
|
||||
echo '
|
||||
.nijz_table_holder{
|
||||
|
||||
}
|
||||
@ -141,21 +184,12 @@ class SurveyNIJZ{
|
||||
.nijz_table_holder table.nijz_table tr td:nth-child(3){
|
||||
width: 280px;
|
||||
}
|
||||
.nijz_table_holder table.nijz_table tr td.tema1{ color: #9966cc; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema2{ color: #cc0099; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema3{ color: #FFD700; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema4{ color: #cc6699; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema5{ color: #FFA500; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema6{ color: #008000; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema7{ color: #3399cc; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema8{ color: #99cc33; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema9{ color: #0099cc; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema10{ color: #669900; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema11{ color: #66cc99; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema12{ color: #FF0000; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema13{ color: #FF8C00; }
|
||||
.nijz_table_holder table.nijz_table tr td.tema14{ color: #99cccc; }
|
||||
</style>';
|
||||
';
|
||||
foreach($this->colors as $key => $color){
|
||||
echo '.nijz_table_holder table.nijz_table tr td.tema'.$key.'{ color: #'.$color.'; }';
|
||||
}
|
||||
echo '</style>';
|
||||
|
||||
|
||||
echo '<div class="spremenljivka nijz_table_holder">';
|
||||
|
||||
@ -183,10 +217,49 @@ class SurveyNIJZ{
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// 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 '<div>';
|
||||
@ -215,6 +290,8 @@ class SurveyNIJZ{
|
||||
|
||||
// Na koncu pobrisemo zacasne datoteke
|
||||
$this->deleteTemp();
|
||||
|
||||
return $radar_image;
|
||||
}
|
||||
|
||||
// Pripravimo zacasne datoteke
|
||||
|
Loading…
x
Reference in New Issue
Block a user