false); // za shrambo parametrov in sporocil var $pdf; var $currentStyle; var $currentHeight = 0; // visina trenutnega vprasanja var $SUS; //SurveyUserSettng var $SA; //SurveyAnketa var $db_table = ''; var $language = -1; // Katero verzijo prevoda izvazamo var $type = 0; // tip izpisa - 0->navaden, 1->iz prve strani, 2->s komentarji var $commentType = 1; // tip izpisa komentarjev var $showIf = 0; // izpis if-ov var $font = 10; // velikost pisave var $numbering = 0; // ostevillcevanje vprasanj var $showIntro = 0; // prikaz uvoda /** * @desc konstruktor */ function __construct ($anketa = null, $type = 0, $commentType = 1){ global $site_path; global $global_user_id; global $site_url; global $lang; // preverimo ali imamo stevilko ankete if ( is_numeric($anketa) ) { $this->anketa['id'] = $anketa; $this->usrId = $_GET['usr_id']; $this->type = $type; $this->commentType = $commentType; // Po novem imamo globalne nastavitve SurveySetting::getInstance()->Init($anketa); $this->font = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_font_size'); $this->showIf = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_show_if'); $this->numbering = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_numbering'); $this->showIntro = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_show_intro'); if(isset($_GET['language'])){ $this->language = $_GET['language']; // Naložimo jezikovno datoteko $file = '../../lang/'.$this->language.'.php'; include($file); $_SESSION['langX'] = $site_url .'lang/'.$this->language.'.php'; } // create new PDF document $this->pdf = new enka_TCPDF(PDF_PAGE_ORIENTATION, 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()) { $this->anketa['uid'] = $global_user_id; SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']); $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString(); } 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 $this->pdf->Output($fileName, 'I'); } function init() { // 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'] = 'stran'; //set some language-dependent strings $this->pdf->setLanguageArray($language_meta); //set margins $this->pdf->setPrintHeaderFirstPage(false); $this->pdf->setPrintFooterFirstPage(false); $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()->getSurveyTitle())); if ($this->language != -1) { SurveySetting::getInstance()->Init($this->anketa['id']); $_lang = '_'.$this->language; $srv_novaanketa_kratkoime = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime'.$_lang); } else{ $srv_novaanketa_kratkoime = SurveyInfo::getInstance()->getSurveyAkronim(); } $this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText($srv_novaanketa_kratkoime)); //set auto page breaks $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font); //set image scale factor $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); return true; } function createPdf() { // Izpis vprasanj s komentarji if($this->type == 2) $this->outputCommentaries(); // Izpis vprasalnika oz odgovorov enega respondenta else $this->outputSurvey(); } function createFrontPage(){ global $lang; // dodamo prvo stran $this->pdf->AddPage(); $this->pdf->SetFont(FNT_MAIN_TEXT, '', 16); if ($this->language != -1) { SurveySetting::getInstance()->Init($this->anketa['id']); $_lang = '_'.$this->language; $srv_anketa_naslov = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime'.$_lang); } else{ $srv_anketa_naslov = SurveyInfo::getInstance()->getSurveyAkronim(); } // dodamo naslov $this->pdf->SetFillColor(224, 235, 255); $this->pdf->SetTextColor(0); $this->pdf->SetDrawColor(128, 0, 0); $this->pdf->SetLineWidth(0.1); $this->pdf->Sety(100); if($this->allResults == 1){ $this->pdf->Cell(0, 10, $this->encodeText($srv_anketa_naslov), 'TLR', 1,'C', 1, 0,0); $this->pdf->SetFont(FNT_MAIN_TEXT, '', 13); $this->pdf->Cell(0, 10, $this->encodeText($lang['export_firstpage_results']), 'BLR', 1,'C', 1, 0,0); } elseif($this->allResults == 2){ $this->pdf->Cell(0, 10, $this->encodeText($srv_anketa_naslov), 'TLR', 1,'C', 1, 0,0); $this->pdf->SetFont(FNT_MAIN_TEXT, '', 13); $this->pdf->Cell(0, 10, $this->encodeText($lang['srv_testiranje_komentarji']), 'BLR', 1,'C', 1, 0,0); } else{ $this->pdf->Cell(0, 16, $this->encodeText($srv_anketa_naslov), 1, 1,'C', 1, 0,0); } // dodamo info: $this->pdf->SetFont(FNT_MAIN_TEXT, '', 12); $this->currentStyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(128, 0, 0)); $this->pdf->ln(30); // $this->pdf->Write (0, $this->encodeText("Info:"), '', 0, 'l', 1, 1); $this->drawLine(); // avtorja, št vprašanj, datum kreiranja $this->pdf->MultiCell(95, 5, $lang['export_firstpage_shortname'].': '.$this->encodeText(SurveyInfo::getInstance()->getSurveyTitle()), 0, 'L', 0, 1, 0 ,0, true); if ( SurveyInfo::getInstance()->getSurveyTitle() != SurveyInfo::getInstance()->getSurveyAkronim()) $this->pdf->MultiCell(95, 5, $lang['export_firstpage_longname'].': '.$this->encodeText($srv_anketa_naslov), 0, 'L', 0, 1, 0 ,0, true); $this->pdf->MultiCell(95, 5, $lang['export_firstpage_qcount'].': '.SurveyInfo::getInstance()->getSurveyQuestionCount(), 0, 'L', 0, 1, 0 ,0, true); // Aktiviranost $activity = SurveyInfo:: getSurveyActivity(); $_last_active = end($activity); if (SurveyInfo::getSurveyColumn('active') == 1) { $this->pdf->SetTextColor(0,150,0); $this->pdf->MultiCell(95, 5, $this->encodeText($lang['srv_anketa_active2']), 0, 'L', 0, 1, 0 ,0, true); } else { # preverimo ali je bila anketa že aktivirana if (!isset($_last_active['starts'])) { # anketa še sploh ni bila aktivirana $this->pdf->SetTextColor(255,120,0); $this->pdf->MultiCell(95, 5, $this->encodeText($lang['srv_survey_non_active_notActivated']), 0, 'L', 0, 1, 0 ,0, true); } else { # anketa je že bila aktivirna ampak je sedaj neaktivna $this->pdf->SetTextColor(255,120,0); $this->pdf->MultiCell(95, 5, $this->encodeText($lang['srv_survey_non_active']), 0, 'L', 0, 1, 0 ,0, true); } } $this->pdf->SetTextColor(0); // Aktivnost if( count($activity) > 0 ){ $this->pdf->MultiCell(95, 5, $lang['export_firstpage_active_from'].': '.SurveyInfo::getInstance()->getSurveyStartsDate(), 0, 'L', 0, 0, 0 ,0, true); $this->pdf->MultiCell(95, 5, $lang['export_firstpage_active_until'].': '.SurveyInfo::getInstance()->getSurveyExpireDate(), 0, 'L', 0, 1, 0 ,0, true); } $this->pdf->MultiCell(95, 5, $lang['export_firstpage_author'].': '.$this->encodeText(SurveyInfo::getInstance()->getSurveyInsertName()), 0, 'L', 0, 0, 0 ,0, true); $this->pdf->MultiCell(95, 5, $lang['export_firstpage_edit'].': '.$this->encodeText(SurveyInfo::getInstance()->getSurveyEditName()), 0, 'L', 0, 1, 0 ,0, true); $this->pdf->MultiCell(95, 5, $lang['export_firstpage_date'].': '.SurveyInfo::getInstance()->getSurveyInsertDate(), 0, 'L', 0, 0, 0 ,0, true); $this->pdf->MultiCell(95, 5, $lang['export_firstpage_date'].': '.SurveyInfo::getInstance()->getSurveyEditDate(), 0, 'L', 0, 1, 0 ,0, true); if ( SurveyInfo::getInstance()->getSurveyInfo() ) $this->pdf->MultiCell(95, 5, $lang['export_firstpage_desc'].': '.$this->encodeText(SurveyInfo::getInstance()->getSurveyInfo()), 0, 'L', 0, 1, 0 ,0, true); $this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font); $this->pdf->SetFillColor(0, 0, 0); } // Izpis vprasalnika (z ali brez odgovorov) function outputSurvey(){ global $lang; $rowA = SurveyInfo::getInstance()->getSurveyRow(); // izpišemo prvo stran $this->createFrontPage(); // Izpisemo vprasalnik $this->pdf->AddPage(); // filtriramo spremenljivke glede na profil SurveyVariablesProfiles :: Init($this->anketa['id']); $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, '_')); } // ce obstaja intro izpisemo intro - pri izpisu vprasalnika brez odgovorov (ce smo na prvi strani moramo biti v razsirjenem nacinu) if( ($rowA['expanded'] != 0 || $this->type != 1) && $this->showIntro == 1 ){ if ( SurveyInfo::getInstance()->getSurveyShowIntro() ) { $intro = (SurveyInfo::getInstance()->getSurveyIntro() == '') ? $lang['srv_intro'] : SurveyInfo::getInstance()->getSurveyIntro(); // po potrebi prevedemo uvod $naslovIntro = $this->srv_language_intro(); if ($naslovIntro != '') { $intro = $naslovIntro; } $this->pdf->Write (0, $this->encodeText($intro), '', 0, 'L', 1, 1); $this->pdf->Ln(LINE_BREAK); //$this->pdf->drawLine(); $this->pdf->Ln(LINE_BREAK); } } $sqlGrupeString = "SELECT id FROM srv_grupa WHERE ank_id='".$this->anketa['id']."' ORDER BY vrstni_red"; $sqlGrupe = sisplet_query($sqlGrupeString); while ( $rowGrupe = mysqli_fetch_assoc( $sqlGrupe ) ) { // sprehodmo se skozi grupe ankete $this->grupa = $rowGrupe['id']; $zaporedna = 0; $sqlSpremenljivke = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC"); while ($rowSpremenljivke = mysqli_fetch_assoc($sqlSpremenljivke)) { // sprehodimo se skozi spremenljivke grupe $spremenljivka = $rowSpremenljivke['id']; if ( $this->checkSpremenljivka ($spremenljivka) /*|| $this->showIf == 1*/ ) { // lahko izrišemo spremenljivke // po potrebi obarvamo vprašanja $this->pdf->SetTextColor(0); if ($rowSpremenljivke['visible'] == 0) { if ($rowSpremenljivke['sistem'] == 1) { // če je oboje = vijolčno $this->pdf->SetTextColor(128,0,128); } else { // Če je skrito = rdeče $this->pdf->SetTextColor(255,0,0); } } else if ($rowSpremenljivke['sistem'] == 1) $this->pdf->SetTextColor(0,0,255); // če imamo številčenje Type = 1 potem številčimo V1 if (SurveyInfo::getInstance()->getSurveyCountType()) $zaporedna++; $stevilcenje = ( SurveyInfo::getInstance()->getSurveyCountType() ) ? ( ( SurveyInfo::getInstance()->getSurveyCountType() == 2 ) ? $rowSpremenljivke['variable'].") " : $zaporedna.") " ) : null; $this->pdf->SetTextColor(0,0,0); $this->pdf->SetDrawColor(0,0,0); $this->currentHeight = 0; // izpis skrcenega vprasalnika (samo pri izpisu iz urejanja) if($rowA['expanded'] == 0 && $this->type == 1){ $this->outputVprasanjeCollapsed($rowSpremenljivke, $stevilcenje); } // izpis navadnega vprasalnika else{ $this->outputVprasanje($rowSpremenljivke, $stevilcenje); $this->outputSpremenljivke($rowSpremenljivke); } $this->pdf->Ln(LINE_BREAK); } } } // če izpisujemo grupo, ne izpisujemo zakljucka 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); } } } // Izpis vprasanj s komentarji function outputCommentaries(){ global $lang; global $site_url; global $admin_type; global $global_user_id; $this->createFrontPage(); $this->pdf->AddPage(); $f = new Forum; $c = 0; $b = new Branching($this->anketa['id']); $rowi = SurveyInfo::getInstance()->getSurveyRow(); SurveySetting::getInstance()->Init($this->anketa['id']); $question_resp_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_viewadminonly'); $question_comment_viewadminonly = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewadminonly'); $question_comment_viewauthor = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_viewauthor'); $sortpostorder = SurveySetting::getInstance()->getSurveyMiscSetting('sortpostorder'); $question_note_view = SurveySetting::getInstance()->getSurveyMiscSetting('question_note_view'); $addfieldposition = SurveySetting::getInstance()->getSurveyMiscSetting('addfieldposition'); $commentmarks = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks'); $commentmarks_who = SurveySetting::getInstance()->getSurveyMiscSetting('commentmarks_who'); $sql = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa['id']."' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC"); if ( mysqli_num_rows($sql) > 0 && ( (int)$question_resp_comment_viewadminonly + (int)$question_comment_viewadminonly ) > 0 ) { while ($row = mysqli_fetch_array($sql)) { $sql1 = sisplet_query("SELECT thread, note FROM srv_spremenljivka WHERE id = '$row[id]'"); $row1 = mysqli_fetch_array($sql1); $orderby = $sortpostorder == 1 ? 'DESC' : 'ASC' ; $tid = $row1['thread']; $only_unresolved = " "; $only_unresolved2 = " "; if ($this->commentType == 1) $only_unresolved = " AND ocena <= 1 "; if ($this->commentType == 1) $only_unresolved2 = " AND text2 <= 1 "; if ($this->commentType == 2) $only_unresolved = " AND ocena = 0 "; if ($this->commentType == 2) $only_unresolved2 = " AND text2 = 0 "; if ($this->commentType == 3) $only_unresolved = " AND ocena = 1 "; if ($this->commentType == 3) $only_unresolved2 = " AND text2 = 1 "; if ($this->commentType == 4) $only_unresolved = " AND ocena = 2 "; if ($this->commentType == 4) $only_unresolved2 = " AND text2 = 2 "; if ($this->commentType == 5) $only_unresolved = " AND ocena = 3 "; if ($this->commentType == 5) $only_unresolved2 = " AND text2 = 3 "; $tema_vsebuje = substr($lang['srv_forum_intro'],0,10); // da ne prikazujemo 1. default sporocila if ($admin_type <= $question_comment_viewadminonly) { // vidi vse komentarje $sqlt = sisplet_query("SELECT * FROM post WHERE vsebina NOT LIKE '%{$tema_vsebuje}%' AND tid='$tid' $only_unresolved ORDER BY time $orderby, id $orderby"); } elseif ($question_comment_viewauthor==1) { // vidi samo svoje komentarje $sqlt = sisplet_query("SELECT * FROM post WHERE vsebina NOT LIKE '%{$tema_vsebuje}%' AND tid='$tid' $only_unresolved AND uid='$global_user_id' ORDER BY time $orderby, id $orderby"); } else { // ne vidi nobenih komentarjev $sqlt = sisplet_query("SELECT * FROM post WHERE 1=0"); } $sql2 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_text".$this->db_table." WHERE spr_id='0' AND vre_id='$row[id]' $only_unresolved2"); $row2 = mysqli_fetch_array($sql2); if ( mysqli_num_rows($sqlt) > 0 || $row2['count'] > 0 || $row1['note'] != '') { $c++; $this->currentHeight = 0; $this->outputVprasanje($row, null); $this->outputSpremenljivke($row); if ($admin_type <= $question_note_view || $question_note_view == '') { if ($row1['note'] != '') { $this->pdf->Ln(3); $this->pdf->setFont('','B', 10); $this->pdf->Write(0, $this->encodeText($lang['hour_comment']), '', 0, 'l', 1, 1); $this->pdf->Ln(3); $this->pdf->setFont('','', 10); $this->pdf->Write(0, $this->encodeText($row1['note']), '', 0, 'l', 1, 1); } } // komentarji na vprasanje if ($row1['thread'] > 0) { if (mysqli_num_rows($sqlt) > 0) { $this->pdf->Ln(3); $this->pdf->setFont('','B', 10); $this->pdf->Write (0, $this->encodeText($lang['srv_admin_comment']), '', 0, 'l', 1, 1); $this->pdf->Ln(3); $i = 0; while ($rowt = mysqli_fetch_array($sqlt)) { $this->pdf->setFont('','B', 10); $this->pdf->Write (0, $this->encodeText($f->user($rowt['uid'])), '', 0, 'l', 0, 1); $this->pdf->setFont('','', 10); $this->pdf->Write (0, $this->encodeText(' ('.$f->datetime1($rowt['time']).'):'), '', 0, 'l', 1, 1); // Popravimo vsebino ce imamo replike $vsebina = iconv("iso-8859-2", "UTF-8", $rowt['vsebina']); $odgovori = explode("
", $vsebina); $this->pdf->MultiCell(100, 0, $this->encodeText($odgovori[0]),0,'L',0,1,0,0,true,0); unset($odgovori[0]); foreach($odgovori as $odgovor){ $this->pdf->Ln(2); $this->pdf->setX($this->pdf->getX()+8); $odgovor = explode('
', $odgovor); $avtor = explode(' ', $odgovor[0]); $this->pdf->setFont('','B', 10); $this->pdf->Write(0, $this->encodeText($avtor[0]), '', 0, 'l', 0, 1); $this->pdf->setFont('','', 10); $this->pdf->Write(0, $this->encodeText($avtor[1]), '', 0, 'l', 1, 1); $this->pdf->setX($this->pdf->getX()+8); $this->pdf->MultiCell(92, 0, $this->encodeText($odgovor[1]),0,'L',0,1,0,0,true,0); } // Crta $this->pdf->MultiCell(100, 2, '',0,'L',0,1,0,0,true,0); $this->pdf->MultiCell(100, 2, '','T','L',0,1,0,0,true,0); } } } // komentarji respondentov if ($row2['count'] > 0) { if ($admin_type <= $question_resp_comment_viewadminonly) { $this->pdf->Ln(3); $this->pdf->setFont('','B', 10); $this->pdf->Write (0, $this->encodeText($lang['srv_repondent_comment']), '', 0, 'l', 1, 1); $this->pdf->Ln(3); if ($this->commentType == 1) $only_unresolved = " AND d.text2 <= 1 "; else $only_unresolved = " "; $sqlt = sisplet_query("SELECT d.*, u.time_edit FROM srv_data_text".$this->db_table." d, srv_user u WHERE d.spr_id='0' AND d.vre_id='$row[id]' AND u.id=d.usr_id $only_unresolved2 ORDER BY d.id ASC"); if (!$sqlt) echo mysqli_error($GLOBALS['connect_db']); while ($rowt = mysqli_fetch_array($sqlt)) { $this->pdf->setFont('','', 10); $this->pdf->Write(0, $this->encodeText($f->datetime1($rowt['time_edit']).':'), '', 0, 'l', 1, 1); $this->pdf->MultiCell(100, 0, $this->encodeText($rowt['text']),0,'L',0,1,0,0,true,0); // Crta $this->pdf->MultiCell(100, 2, '',0,'L',0,1,0,0,true,0); $this->pdf->MultiCell(100, 2, '','T','L',0,1,0,0,true,0); } } } $this->pdf->Ln(LINE_BREAK); } } /*if ($c == 0) { //echo $lang['srv_no_comments_solved'].'
'; }*/ } else { //echo $lang['srv_no_comments'].'
'; } } // Izpis skrcenih vprasanj - v eni vrstici function outputVprasanjeCollapsed($spremenljivke, $zaporedna){ global $lang; $b = new Branching($this->anketa['id']); $sqlIf = sisplet_query("SELECT * FROM srv_branching WHERE element_spr='$spremenljivke[id]'"); $rowIf = mysqli_fetch_array($sqlIf); // Izpisemo tekst vprasanja $this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font); // Zamik zaradi ifov $zamik = ( $b->level($spremenljivke['id'],0) > 0 ? (($b->level($spremenljivke['id'],0)-1)*10) : 0 ); $this->pdf->setX($this->pdf->getX()+$zamik); $rowl = $this->srv_language_spremenljivka($spremenljivke); if (strip_tags($rowl['naslov']) != '') $spremenljivke['naslov'] = $rowl['naslov']; //izpis if-ov pri vprasanju if(/*$this->showIf == 1*/ true){ if ($rowIf['parent'] > 0){ $rowb = Cache::srv_if($rowIf['parent']); if ($rowb['tip'] == 0){ $this->displayIf($rowIf['parent']); $this->pdf->setX($this->pdf->getX()+$zamik+10); } } } // stevilcenje vprasanj $numberingText = '('.$spremenljivke['variable'].') '; $this->pdf->setFont('','B',$this->font); $this->pdf->SetTextColor(0,128,0); $this->pdf->Write (0, $numberingText, '', 0, 'l', 0, 1); $this->pdf->SetTextColor(0,0,0); $this->pdf->Write (0, $this->snippet($this->encodeText($spremenljivke['naslov']), 80), '', 0, 'l', 0, 1); $this->pdf->setFont('','I',$this->font); $this->pdf->SetTextColor(128,128,128); $this->pdf->Write (0, $this->encodeText(' ( '.$lang['srv_vprasanje_tip_long_'.$spremenljivke['tip']].' )'), '', 0, 'l', 1, 1); $this->pdf->SetTextColor(0,0,0); // izpis pagebreaka if($b->pagebreak($spremenljivke['id'])){ $this->currentStyle = array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter', 'dash' => '2,2', 'color' => array(128, 128, 128)); $cy = $this->pdf->getY()+3; $this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle); } } function outputVprasanje($spremenljivke, $zaporedna){ $rowl = $this->srv_language_spremenljivka($spremenljivke); if (strip_tags($rowl['naslov']) != '') $spremenljivke['naslov'] = $rowl['naslov']; if (strip_tags($rowl['info']) != '') $spremenljivke['info'] = $rowl['info']; // Izpisemo tekst vprasanja $this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font); $pozicija_vprasanja = $this->pdf->getY(); $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()); if($pozicija_vprasanja + $linecount_vprasanja*4.7 /*+ $visina*/ > 240) { $this->pdf->AddPage('P'); } //izpis if-ov pri vprasanju if($this->showIf == 1){ /*$sqlIf = sisplet_query("SELECT * FROM srv_branching WHERE element_spr='$spremenljivke[id]'"); $rowIf = mysqli_fetch_array($sqlIf); if ($rowIf['parent'] > 0){ $rowb = Cache::srv_if($rowIf['parent']); if ($rowb['tip'] == 0) $this->displayIf($rowIf['parent']); }*/ // Po novem izpisemo pred vsakim vprasanjem vse ife znotraj katerih se nahaja $b = new Branching($this->anketa['id']); $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) { $this->displayIf($if); } } // stevilcenje vprasanj $numberingText = ($this->numbering == 1) ? $spremenljivke['variable'].' - ' : ''; $this->pdf->setFont('','B',$this->font); if($spremenljivke['orientation']!=0){ //ce ni vodoravno ob vprasanju, pejdi v novo vrstico //$this->pdf->Write(0, $numberingText . $this->encodeText($spremenljivke['naslov']), '', 0, 'l', 1, 1); $text = strip_tags($numberingText . $spremenljivke['naslov'], '
'); $this->pdf->WriteHTML($text, $ln=true, $fill=false, $reseth=true); // Izpisemo opombo, ce jo imamo if($spremenljivke['info'] != ''){ //$this->pdf->Ln(1); $this->pdf->setFont('','',$this->font-2); $this->pdf->SetTextColor(100,100,100); //$this->pdf->WriteHTML($spremenljivke['info']); $this->pdf->Write(0, $this->encodeText($spremenljivke['info']), '', 0, 'l', 1, 1); $this->pdf->setFont('','',$this->font); $this->pdf->SetTextColor(0); } //$this->pdf->setFont('','',$this->font); $this->pdf->Ln(LINE_BREAK); }else{ //ce je vodoravno ob vprasanju $text = strip_tags($numberingText . $spremenljivke['naslov'], '
'); //$this->pdf->WriteHTML($text, $ln=true, $fill=false, $reseth=true); //$this->pdf->WriteHTML($text, $ln=false, $fill=false, $reseth=true); $this->pdf->writeHTMLCell(70,1,$x1,$y1,$text,0,0,0,1,'L',1); } $this->pdf->setFont('','',$this->font); } function outputSpremenljivke($spremenljivke) { switch ( $spremenljivke['tip'] ) { case 1: //radio case 2: //check case 3: //select -> radio // 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"); $width = 180; //ce imamo prikaz v vec stoplcih $spremenljivkaParams = new enkaParameters($spremenljivke['params']); $stolpci = ($spremenljivkaParams->get('stolpci') ? $spremenljivkaParams->get('stolpci') : 1); $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0); if ($stolpci > 1 && $spremenljivke['orientation']==1) { //echo ''; $kategorij = mysqli_num_rows($sqlVrednosti); $v_stolpcu = ceil($kategorij / $stolpci); $width = round(180 / $stolpci); } $yStart = $this->pdf->GetY(); $xStart = $this->pdf->GetX(); $count = 0; $questionWidth = 85; $answerWidth = 33; $maxHeight = 0; $opombaAdded = 0; $maxPageWidth = $this->pdf->getPageWidth() - 30; $seznam = ""; while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti)) { $prop['full'] = ( isset($userAnswer[$rowVrednost['id']]) ); # po potrebi prevedemo naslov $naslov = $this->srv_language_vrednost($rowVrednost['id']); if ($naslov != '') { $rowVrednost['naslov'] = $naslov; } $stringTitle = ($this->encodeTextHtml(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) )); //$stringTitle = (( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] )); //encodeText sem presaltal, tako, da sem lahko uporabljal writeHTMLCell(), saj drugace ni slik, ni teksta v novi vrstici, ipd. //popravimo lokacijo ce imamo postavitev v vec stolpcih if ( ($stolpci > 1) && ($spremenljivke['orientation']==1) ) { $yPos = $count % $v_stolpcu; $xPos = floor($count / $v_stolpcu); $this->pdf->SetXY($this->pdf->GetX()+($width*$xPos), $yStart+(7*$yPos)); } //dodamo eno celico da zamaknemo malo $this->pdf->Cell(2, 5, ''); if ( $spremenljivke['tip'] == 1 || $spremenljivke['tip'] == 3 ) { if($spremenljivke['orientation']==1) { //navpicno $this->pdf->RadioButton('vpr_'. $spremenljivke['id'], RADIO_BTN_SIZE, $prop); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==7) { //navpicno - tekst levo $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1); $this->pdf->writeHTMLCell(60,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); //$this->checkLineHeight($height); }elseif($spremenljivke['orientation']==0) { //vodoravno ob vprasanju $this->pdf->Cell(2, 5, ''); $this->pdf->RadioButton('vpr_'. $spremenljivke['id'], RADIO_BTN_SIZE, $prop); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==2) { //vodoravno pod vprasanjem $this->pdf->Cell(2, 5, ''); $this->pdf->RadioButton('vpr_'. $spremenljivke['id'], RADIO_BTN_SIZE, $prop); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==6) { //izberite s seznama if($count == 0){ $this->pdf->Cell(2, 5, ''); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); } $seznam .= $stringTitle.'
'; //$this->currentHeight = ($this->currentHeight == 1) ? 2 : $this->currentHeight; }elseif($spremenljivke['orientation']==8) { //povleci-spusti $this->pdf->Cell(2, 5, ''); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==10) //image hot-spot { if($count == 0){ $this->pdf->Cell(2, 5, ''); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); } } else { //ce ni urejenega izrisa naj bo default oz. navpicno $this->pdf->RadioButton('vpr_'. $spremenljivke['id'], RADIO_BTN_SIZE, $prop); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); } } else if ( $spremenljivke['tip'] == 2 ) { if($spremenljivke['orientation']==1){ //navpicno $this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop); $y=$this->pdf->GetY(); $x=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==7){ //navpicno - tekst levo $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1); $this->pdf->writeHTMLCell(60,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); //$this->checkLineHeight($height); }elseif($spremenljivke['orientation']==0){ //vodoravno ob vprasanju $this->pdf->Cell(2, 5, ''); $this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==2){ //vodoravno pod vprasanjem $this->pdf->Cell(2, 5, ''); $this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==6){ //izberite s seznama if($count == 0){ $this->pdf->Cell(2, 5, ''); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); } $seznam .= $stringTitle.'
'; //$this->currentHeight = ($this->currentHeight == 1) ? 2 : $this->currentHeight; }elseif($spremenljivke['orientation']==8) { //povleci-spusti $this->pdf->Cell(2, 5, ''); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); }elseif($spremenljivke['orientation']==10) //image hot-spot { if($count == 0){ $this->pdf->Cell(2, 5, ''); $y1=$this->pdf->GetY(); $x1=$this->pdf->GetX(); } } else { //ce ni urejenega izrisa naj bo default oz. navpicno $this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop); $y=$this->pdf->GetY(); $x=$this->pdf->GetX(); } } $this->pdf->Cell(4, 0, ''); $this->currentHeight = $this->pdf->getNumLines($stringTitle, $width); if ( $spremenljivke['tip'] == 2 ) { if($spremenljivke['orientation']==1){ //navpicno $y=$y-2; $x=$x+3; //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x,$y); $this->pdf->writeHTMLCell($width,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); $this->checkLineHeight($height); }elseif($spremenljivke['orientation']==7){ //navpicno - tekst levo //$y1=$y1-1; //$x1=$x1+3; //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1); $this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop); $this->checkLineHeight($height); }elseif($spremenljivke['orientation']==0){ //vodoravno ob vprasanju $x1=$x1+3; $questionWidth = $questionWidth + $answerWidth; if($height > $maxHeight){ $maxHeight = $height; } //$this->pdf->writeHTMLCell(40,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $this->pdf->writeHTMLCell($answerWidth,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); }elseif($spremenljivke['orientation']==2){ //vodoravno pod vprasanjem //$y1=$y1-1; $x1=$x1+3; $questionWidth = $questionWidth + $answerWidth; if($height > $maxHeight){ $maxHeight = $height; } //$this->pdf->writeHTMLCell(40,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $this->pdf->writeHTMLCell($answerWidth,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); }elseif($spremenljivke['orientation']==8) { //povleci-spusti $y1=$y1-1; $x1=$x1+3; $this->pdf->writeHTMLCell(70,1,$x1,$y1,$stringTitle,1,0,0,1,'L',1); $height = $this->pdf->getLastH(); //v prvi vrstici dodaj se drugi stolpec if($count == 0){ $this->pdf->Cell(20, 0, ''); $this->pdf->Cell(70, 7, '', 1); } $this->checkLineHeight($height); } elseif($spremenljivke['orientation']!=6 && $spremenljivke['orientation']!=10){ $y=$y-2; $x=$x+3; //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x,$y); $this->pdf->writeHTMLCell($width,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); $this->checkLineHeight($height); } } elseif($spremenljivke['tip'] == 1) { if($spremenljivke['orientation']==1) { //navpicno $y1=$y1-1; $x1=$x1+3; //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1); $this->pdf->writeHTMLCell($width,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); $this->checkLineHeight($height); }elseif($spremenljivke['orientation']==7) { //navpicno - tekst levo //$y1=$y1-1; //$x1=$x1+3; //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1); $this->pdf->RadioButton('vpr_'. $spremenljivke['id'], RADIO_BTN_SIZE, $prop); $this->checkLineHeight($height); }elseif($spremenljivke['orientation']==0) { //vodoravno ob vprasanju $x1=$x1+3; $questionWidth = $questionWidth + $answerWidth; if($height > $maxHeight){ $maxHeight = $height; } //$this->pdf->writeHTMLCell(40,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $this->pdf->writeHTMLCell($answerWidth,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); }elseif($spremenljivke['orientation']==2) { //vodoravno pod vprasanjem //$y1=$y1-1; $x1=$x1+3; $questionWidth = $questionWidth + $answerWidth; if($height > $maxHeight){ $maxHeight = $height; } //$this->pdf->writeHTMLCell(40,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $this->pdf->writeHTMLCell($answerWidth,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $height = $this->pdf->getLastH(); }elseif($spremenljivke['orientation']==8) { //povleci-spusti $y1=$y1-1; $x1=$x1+3; $this->pdf->writeHTMLCell(70,1,$x1,$y1,$stringTitle,1,0,0,1,'L',1); $height = $this->pdf->getLastH(); //v prvi vrstici dodaj se drugi stolpec if($count == 0){ $this->pdf->Cell(20, 0, ''); $this->pdf->Cell(70, 7, '', 1); } $this->checkLineHeight($height); } elseif($spremenljivke['orientation']!=6 && $spremenljivke['orientation']!=10) { //ce ni urejenega izrisa naj bo default oz. navpicno $y1=$y1-1; $x1=$x1+3; //$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1); $this->pdf->writeHTMLCell($width,1,$x1,$y1,$stringTitle,0,0,0,1,'L',1); $this->checkLineHeight($height); } } if($spremenljivke['orientation']!=0 && $spremenljivke['orientation']!=2 && $spremenljivke['orientation']!=6) { //ce ni vodoravno ob vprasanju in ni vodoravno pod vprasanjem in ni seznam $this->currentHeight = ($this->currentHeight == 1) ? 2 : $this->currentHeight; $this->pdf->setY($this->pdf->getY() + $this->currentHeight*4.7); }elseif($spremenljivke['orientation']==0 || $spremenljivke['orientation']==2) { //ce je vodoravno ob vprasanju oz. vodoravno pod vprasanjem if($questionWidth >= $maxPageWidth){ //ce je sirina vprasanja vecja od max sirine strani if($spremenljivke['info'] != '' && $opombaAdded == 0 && $spremenljivke['orientation']==0){ //ce je prisotna opomba in ni bila ze dodana @ vodoravno ob vprasanju //da dobimo, koliko vrstic je dolgo besedilo vprasanja $numberingText = ($this->numbering == 1) ? $spremenljivke['variable'].' - ' : ''; $text = strip_tags($numberingText . $spremenljivke['naslov'], '