0) ? round(162 / $count): 162;
$height = ($this->getCellHeight($answers[$j][$i], $singleWidth) > $height) ? $this->getCellHeight($answers[$j][$i], $singleWidth) : $height;
$row[$j] = $answers[$j][$i];
}
$this->sumLokacijaRowOutput($row, $count, $height, $grid['variable']);
}
}
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;
}
$this->sumLokacijaRowOutput($text, $count, $height, $grid['variable']);
}
}
}
}
/**
* 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, $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);
}
/** Izriše tekstovne odgovore kot tabelo z navedbami
*
* @param unknown_type $spid
*/
function sumMultiText($spid,$_from) {
global $lang;
$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'];
//prva vrstica
$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);
//druga vrstica
$this->pdf->MultiCell(18, 5, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, 5, $this->encodeText($lang['srv_analiza_opisne_subquestion']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(108, 5, $this->encodeText($lang['srv_analiza_opisne_arguments']), 1, 'C', 0, 1, 0 ,0, true);
$this->pdf->setFont('','','6');
//konec naslovnih vrstic
$_answersOther = array();
$_grids_count = count($spremenljivka['grids']);
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++;
}
// 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;
}
$this->pdf->MultiCell(18, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->dynamicCells($text, $count, 108, $height);
$this->pdf->ln($height);
$last = 0;
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;
}
$this->pdf->MultiCell(18, $height, $this->encodeText($grid['variable']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, $height, $this->encodeText($grid['naslov']), 1, 'C', 0, 0, 0 ,0, true);
$this->dynamicCells($text, $count, 108, $height);
$this->pdf->ln($height);
}
}
# izpišemo še tekstovne odgovore za polja drugo
if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
foreach ($_answersOther AS $oAnswers) {
self::outputOtherAnswers($oAnswers);
}
}
}
/** Izriše multi number odgovore. izpiše samo povprečja
*
* @param unknown_type $spid
*/
function sumMultiNumber($spid,$_from) {
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
$_cols = $spremenljivka['cnt_all'] / $spremenljivka['cnt_grids'];
//prva vrstica
$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);
//druga vrstica
$this->pdf->MultiCell(18, 5, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, 5, $this->encodeText($lang['srv_analiza_opisne_subquestion']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(108, 5, $this->encodeText($lang['srv_analiza_sums_average']), 1, 'C', 0, 1, 0 ,0, true);
$this->pdf->setFont('','','6');
//konec naslovnih vrstic
$_answersOther = array();
$_grids_count = count($spremenljivka['grids']);
if ($_grids_count > 0) {
# naslovna vrstica
$_row = $spremenljivka['grids'][0];
$this->pdf->MultiCell(18, 13, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, 13, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$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++;
}
$this->dynamicCells($text, $count, 108, 13);
$this->pdf->ln(5);
$last = 0;
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$_variables_count = count($grid['variables']);
$this->pdf->MultiCell(18, 5, $this->encodeText($grid['variable']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, 5, $this->encodeText($grid['naslov']), 1, 'C', 0, 0, 0 ,0, true);
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[] = SurveyAnalysis::formatNumber(SurveyAnalysis::$_FREQUENCYS[$_sequence]['average'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'');
}
$count++;
}
$this->dynamicCells($text, $count, 108, 5);
$this->pdf->ln(5);
}
}
}
}
/** Izriše sumarnik v horizontalni obliki za multi checbox
*
* @param unknown_type $spid - spremenljivka ID
*/
function sumMultiHorizontalCheckbox($spid,$_from) {
global $lang;
$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
//prva vrstica
$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);
//druga vrstica
$this->pdf->MultiCell(18, 5, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, 5, $this->encodeText($lang['srv_analiza_opisne_subquestion']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, 5, $this->encodeText($lang['srv_analiza_opisne_answers']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, 5, $this->encodeText($lang['srv_analiza_opisne_valid']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, 5, $this->encodeText($lang['srv_analiza_num_units']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, 5, $this->encodeText($lang['srv_analiza_opisne_arguments']), 1, 'C', 0, 1, 0 ,0, true);
$this->pdf->setFont('','','6');
$_variables = SurveyAnalysis::$_HEADERS[$spid]['grids'][$gid]['variables'];
//tretja vrstica
$count = 0;
$height = 0;
$text = array();
foreach ($_variables AS $vkey => $variable) {
if ($variable['other'] != true) {
$text[] = $variable['naslov'].' ('.$variable['gr_id']. ')';
$singleWidth = round(54 / (count($_variables) + 1));
$height = ($height < $this->getCellHeight($variable['naslov'].' ('.$variable['gr_id']. ')', $singleWidth)) ? $this->getCellHeight($variable['naslov'].' ('.$variable['gr_id']. ')', $singleWidth) : $height;
}
$count++;
}
$this->pdf->MultiCell(18, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->dynamicCells($text, $count, 54, $height);
$this->pdf->MultiCell(18, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
$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);
$this->pdf->MultiCell(10, $height, $this->encodeText($lang['srv_anl_suma1']), 1, 'C', 0, 1, 0 ,0, true);
//vrstice s podatki
foreach (SurveyAnalysis::$_HEADERS[$spid]['grids'] AS $gid => $grids) {
$_cnt = 0;
$height = $this->getCellHeight($this->encodeText($grids['naslov']), 18);
$height = ($height < 8 ? 8 : $height);
# vodoravna vrstice s podatki
$this->pdf->MultiCell(18, $height, $this->encodeText($grids['variable']), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($grids['naslov']), 1, 'C', 0, 0, 0 ,0, true);
$_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 . ' (' . SurveyAnalysis::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%') . ')';
$count++;
}
}
$this->dynamicCells($text, $count, 54, $height);
# veljavno
$this->pdf->MultiCell(18, $height, $this->encodeText($_max_cnt), 1, 'C', 0, 0, 0 ,0, true);
#ustrezno
$this->pdf->MultiCell(18, $height, $this->encodeText($_max_appropriate), 1, 'C', 0, 0, 0 ,0, true);
$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 . ' (' . SurveyAnalysis::formatNumber($_percent,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'),'%') . ')';
$count++;
}
}
$this->dynamicCells($text, $count, 44, $height);
$this->pdf->MultiCell(10, $height, $this->encodeText($_arguments), 1, 'C', 0, 1, 0 ,0, true);
}
# izpišemo še tekstovne odgovore za polja drugo
if (count($_answersOther) > 0 && SurveyAnalysis::$_FILTRED_OTHER) {
foreach ($_answersOther AS $oAnswers) {
self::outputOtherAnswers($oAnswers);
}
}
}
function outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,&$_kumulativa,$_options=array()) {
global $lang;
$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;
}
$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[] = (int)$vAnswer['cnt'];
$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = $this->encodeText(SurveyAnalysis::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 '
';
}*/
self::tableRow($text);
$counter++;
return $counter;
}
function outputSumaValidAnswerVertical($counter,$_sequence,$spid,$_options=array()) {
global $lang;
$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;
}
$_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(SurveyAnalysis::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = '';
self::tableRow($text);
$counter++;
return $counter;
}
function outputInvalidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_options=array()) {
global $lang;
$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;
}
$_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;
if($_Z_MV){
$text[] = '';
$text[] = $this->encodeText($vkey.' (' . $vAnswer['text'].')');
//echo ''.SurveyAnalysis::formatNumber($_invalid, NUM_DIGIT_PERCENT, '%').'
'.NEW_LINE;
//echo ''.$vAnswer['cnt'].'
'.NEW_LINE;
$text[] = $this->encodeText((int)$vAnswer['cnt']);
$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = '';
$text[] = '';
$this->tableRow($text);
}
$counter++;
return $counter;
}
function outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,$_options = array()) {
global $lang;
# 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['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;
if(!$_brez_MV){
$text = array();
$text[] = $this->encodeText($lang['srv_anl_missing']);
$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[] = '';
$text[] = '';
$this->tableRow($text);
}
$counter++;
return $counter;
}
function outputSumaVertical($counter,$_sequence,$spid, $_options = array()) {
global $lang;
# 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(!$_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[] = '';
$text[] = '';
$this->tableRow($text);
}
}
function outputOtherAnswers($oAnswers) {
global $lang;
$spid = $oAnswers['spid'];
$_variable = SurveyAnalysis::$_HEADERS[$spid]['grids'][$oAnswers['gid']]['variables'][$oAnswers['vid']];
$_sequence = $_variable['sequence'];
$_frekvence = SurveyAnalysis::$_FREQUENCYS[$_variable['sequence']];
//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));
}
}
# izpišemo sumo veljavnih
$counter = self::outputSumaValidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
}
if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
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));
}
}
# izpišemo sumo veljavnih
$counter = self::outputSumaInvalidAnswerVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
}
#izpišemo še skupno sumo
$counter = self::outputSumaVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true));
}
/** za multi grid tekstovne vrstice doda vrstico z labeliami grida
*
* @param $gkey
* @param $gAnswer
* @param $spid
* @param $_options
*/
function outputGridLabelVertical($gid,$grid,$vid,$variable,$spid,$_options=array()) {
$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 createFrontPage(){
// dodamo prvo stran
$this->pdf->AddPage();
$this->pdf->SetFont(FNT_MAIN_TEXT, '', 16);
// 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);
$this->pdf->Cell(0, 16, $this->encodeText(SurveyInfo::getInstance()->getSurveyTitle()), 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()->getSurveyAkronim()), 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(SurveyInfo::getInstance()->getSurveyTitle()), 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);
$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, '', FNT_MAIN_SIZE);
$this->pdf->SetFillColor(0, 0, 0);
}
function setUserId($usrId) {$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 drawLine(){
$cy = $this->pdf->getY();
$this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
}
function tableHeader(){
global $lang;
$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');
$this->tableRow($naslov, $params);
}
function tableRow($arrayText, $arrayParams=array()){
/*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
$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';
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[0]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(90, $height, $this->encodeText($arrayText[1]), 1, $arrayParams['align2'], 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $arrayText[2], 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[3]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[4]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[5]), 1, 'C', 0, 1, 0 ,0, true);
}
function tableRowVerticalCheckbox($arrayText, $arrayParams=array()){
if($arrayText[1] == '')
$arrayText[1] = '';
/*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 54);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
$height = $this->getCellHeight($this->encodeText($arrayText[1]), 54);
//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($arrayText[0]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(50, $height, $this->encodeText($arrayText[1]), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[2]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[3]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[4]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[5]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[6]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[7]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(16, $height, $this->encodeText($arrayText[8]), 1, 'C', 0, 1, 0 ,0, true);
}
function tableRowNumberVertical($arrayText, $arrayParams=array()){
if($arrayText[1] == '')
$arrayText[1] = '';
for($i=2; $i<8; $i++){
if( $arrayText[$i] == '' )
$arrayText[$i] = '0';
}
/*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 54);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
$height = $this->getCellHeight($this->encodeText($arrayText[1]), 54);
//ce smo na prelomu strani
if( ($this->pdf->getY() + $height) > 270){
$this->drawLine();
$this->pdf->AddPage('P');
$arrayParams['border'] .= 'T';
}
$arrayText[1] == '' ? $arrayParams['border'] = 0 : $arrayParams['border'] = 1;
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[0]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(54, $height, $this->encodeText($arrayText[1]), $arrayParams['border'], 'L', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[2]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[3]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[4]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[5]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[6]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[7]), 1, 'C', 0, 1, 0 ,0, true);
}
function tableRowHorizontal($arrayText, $arrayParams=array()){
if($arrayText[1] == '')
$arrayText[1] = '';
/*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 30);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
$height = $this->getCellHeight($this->encodeText($arrayText[1]), 30);
//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($arrayText[0]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(30, $height, $this->encodeText($arrayText[1]), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(78, $height, $this->encodeText($arrayText[2]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[3]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[4]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(18, $height, $this->encodeText($arrayText[5]), 1, 'C', 0, 1, 0 ,0, true);
}
function tableRowMultiText($arrayText, $arrayParams=array()){
if($arrayText[1] == '')
$arrayText[1] = '';
/*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 30);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
$height = $this->getCellHeight($this->encodeText($arrayText[1]), 30);
//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($arrayText[0]), 1, 'C', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(30, $height, $this->encodeText($arrayText[1]), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->MultiCell(132, $height, $this->encodeText($arrayText[2]), 1, 'C', 0, 1, 0 ,0, true);
}
//izrisemo dinamicne celice (podamo sirino, stevilo celic in vsebino)
function dynamicCells($arrayText, $count, $width, $height, $arrayParams=array()){
if($count > 0){
$singleWidth = round($width / $count);
$lastWidth = $width - (($count-1)*$singleWidth);
}
else{
$singleWidth = $width;
$lastWidth = $width;
}
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;*/
for($i=0; $i<$count-1; $i++){
if($arrayText[$i] == '')
$arrayText[$i] = '';
$this->pdf->MultiCell($singleWidth, $height, $this->encodeText($arrayText[$i]), 1, 'C', 0, 0, 0 ,0, true);
}
//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);
else
$this->pdf->MultiCell($lastWidth, $height, $this->encodeText(''), 1, 'C', 0, 0, 0 ,0, true);
}
function getCellHeight($string, $width){
// 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;
}
}
?>