1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
|
<?php
global $site_path;
include_once('../../function.php');
include_once('../survey/definition.php');
require_once('../exportclases/class.xls.php');
class XlsIzvozAnalizaCrosstab {
var $anketa; // trenutna anketa
var $pi=array('canCreate'=>false); // za shrambo parametrov in sporocil
public $crosstabClass = null; //crosstab class
var $crossData1;
var $crossData2;
/**
* @desc konstruktor
*/
function __construct ($anketa = null, $crossData1, $crossData2, $podstran = M_ANALIZA_CROSSTAB)
{
global $site_path;
global $global_user_id;
global $output;
// preverimo ali imamo stevilko ankete
if ( is_numeric($anketa) )
{
$this->anketa['id'] = $anketa;
$this->anketa['podstran'] = $podstran;
// create new XLS document
$this->xls = new xls();
}
else
{
$this->pi['msg'] = "Anketa ni izbrana!";
$this->pi['canCreate'] = false;
return false;
}
$_GET['a'] = A_ANALYSIS;
//ustvarimo crosstab objekt in mu napolnimo variable (var1, var2, checkboxi)
$this->crosstabClass = new SurveyCrosstabs();
$this->crosstabClass->Init($anketa);
for($i=0; $i<sizeof($crossData1)/3; $i++){
$index = $i * 3;
$this->crossData1[$i] = array($crossData1[$index],$crossData1[$index+1],$crossData1[$index+2]);
}
for($i=0; $i<sizeof($crossData2)/3; $i++){
$index = $i * 3;
$this->crossData2[$i] = array($crossData2[$index],$crossData2[$index+1],$crossData2[$index+2]);
}
if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
{
$this->anketa['uid'] = $global_user_id;
SurveyUserSetting::getInstance()->Init($this->anketa['id'], $this->anketa['uid']);
}
else
return false;
// ce smo prisli do tu je vse ok
$this->pi['canCreate'] = true;
return true;
}
// SETTERS && GETTERS
function checkCreate()
{
return $this->pi['canCreate'];
}
function getFile($fileName)
{
$output = $this->createXls();
$this->xls->display($fileName, $output);
}
function init()
{
return true;
}
function encodeText($text)
{ // popravimo sumnike ce je potrebno
$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
$text = str_replace(array("š","š","č"),array("š","š","č"),$text);
return strip_tags($text);
}
function createXls()
{
global $site_path;
global $lang;
global $output;
$convertTypes = array('charSet' => "windows-1250",
'delimit' => ";",
'newLine' => "\n",
'BOMchar' => "\xEF\xBB\xBF");
$output = $convertTypes['BOMchar'];
$output .= '<table border="0"><tr><td colspan="10"><font size="3"><b>'.$lang['export_analisys_crosstabs'].'</b></font></td></tr></table>';
# polovimo nastavtve missing profila
//SurveyConditionProfiles:: getConditionString();
$this->crosstabClass->_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
if (count($this->crosstabClass->_LOOPS) > 0) {
# če mamo zanke
foreach ( $this->crosstabClass->_LOOPS AS $loop) {
$this->crosstabClass->_CURRENT_LOOP = $loop;
$this->displayCrosstabsTable();
}
} else {
// loopamo cez vse izbrane variable in izrisemo vse tabele
for($j=0; $j<sizeof($this->crossData2); $j++){
for($i=0; $i<sizeof($this->crossData1); $i++){
$this->crosstabClass->setVariables($this->crossData2[$j][0],$this->crossData2[$j][1],$this->crossData2[$j][2],$this->crossData1[$i][0],$this->crossData1[$i][1],$this->crossData1[$i][2]);
$this->displayCrosstabsTable();
}
}
}
return $output;
}
public function displayCrosstabsTable() {
global $lang;
global $output;
if ($this->crosstabClass->getSelectedVariables(1) !== null && $this->crosstabClass->getSelectedVariables(2) !== null) {
$variables1 = $this->crosstabClass->getSelectedVariables(1);
$variables2 = $this->crosstabClass->getSelectedVariables(2);
foreach ($variables1 AS $v_first) {
foreach ($variables2 AS $v_second) {
$crosstabs = null;
$crosstabs_value = null;
$crosstabs = $this->crosstabClass->createCrostabulation($v_first, $v_second);
$crosstabs_value = $crosstabs['crosstab'];
# podatki spremenljivk
$spr1 = $this->crosstabClass->_HEADERS[$v_first['spr']];
$spr2 = $this->crosstabClass->_HEADERS[$v_second['spr']];
$grid1 = $spr1['grids'][$v_first['grd']];
$grid2 = $spr2['grids'][$v_second['grd']];
#število vratic in število kolon
$cols = count($crosstabs['options1']);
$rows = count($crosstabs['options2']);
# ali prikazujemo vrednosti variable pri spremenljivkah
$show_variables_values = $this->crosstabClass->doValues;
# nastavitve oblike
if (($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) && ($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR)) {
# dodamo procente in residuale
$rowSpan = 3;
$numColumnPercent = $this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3;
$numColumnResidual = $this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR;
$tblColumn = max($numColumnPercent,$numColumnResidual);
} else if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
# imamo samo procente
$rowSpan = 2;
$numColumnPercent = $this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3;
$numColumnResidual = 0;
$tblColumn = $numColumnPercent;
} else if ($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR) {
# imamo samo residuale
$rowSpan = 2;
$numColumnPercent = 0;
$numColumnResidual = $this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR;
$tblColumn = $numColumnResidual;
} else {
#prikazujemo samo podatke
$rowSpan = 1;
$numColumnPercent = 0;
$numColumnResidual = 0;
$tblColumn = 1;
}
//izracun sirine ene celice
$singleWidth = round( 170 / $cols );
//izracun visine ene celice
if($rowSpan == 1)
$height = 8;
elseif($rowSpan == 2)
$height = 10;
else
$height = 15;
# izrišemo tabelo
# najprej izrišemo naslovne vrstice
# za multicheckboxe popravimo naslov, na podtip
$sub_q1 = null;
if ($spr1['tip'] == '6' || $spr1['tip'] == '16' || $spr1['tip'] == '17' || $spr1['tip'] == '19' || $spr1['tip'] == '20') {
foreach ($spr1['grids'] AS $grid) {
foreach ($grid['variables'] AS $variable) {
if ($variable['sequence'] == $v_first['seq']) {
$sub_q1 = strip_tags($spr1['naslov']);
if ($show_variables_values == true ) {
$sub_q1 .= ' ('.strip_tags($spr1['variable']).')';
}
if ($spr1['tip'] == '16') {
$sub_q1 .= ', ' . strip_tags($grid1['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid1['variable']) . ')' : '');
} else {
$sub_q1 .= ', ' . strip_tags($variable['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($variable['variable']) . ')' : '');
}
}
}
}
}
if ($sub_q1 == null) {
$sub_q1 .= strip_tags($spr1['naslov']);
$sub_q1 .= ($show_variables_values == true ? ' ('.strip_tags($spr1['variable']).')' : '');
}
$sub_q2 = null;
if ($spr2['tip'] == '6' || $spr2['tip'] == '16' || $spr2['tip'] == '17' || $spr2['tip'] == '19' || $spr2['tip'] == '20') {
foreach ($spr2['grids'] AS $grid) {
foreach ($grid['variables'] AS $variable) {
if ($variable['sequence'] == $v_second['seq']) {
$sub_q2 = strip_tags($spr2['naslov']);
if ($show_variables_values == true) {
$sub_q2 .= ' ('.strip_tags($spr2['variable']).')';
}
if ($spr2['tip'] == '16') {
$sub_q2.= ', <br style="mso-data-placement:same-cell;" />' . strip_tags($grid2['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($grid2['variable']) . ')' : '');
} else {
$sub_q2.= ', <br style="mso-data-placement:same-cell;" />' . strip_tags($variable['naslov']) . ($show_variables_values == true ? ' (' . strip_tags($variable['variable']) . ')' : '');
}
}
}
}
}
if ($sub_q2 == null) {
$sub_q2 .= strip_tags($spr2['naslov']);
$sub_q2 .= ($show_variables_values == true ? ' ('.strip_tags($spr2['variable']).')' : '');
}
$output .= '<table border="0"><tr><td></td></tr></table>';
# izrišemo tabelo
# najprej izrišemo naslovne vrstice
$output .= '<table border="1">';
/*$output .= '<colgroup>';
$output .= '<col style="width:auto; min-width:150px;" />';
$output .= '<col style="width:auto; min-width:150px;" />';
if (count($crosstabs['options1']) > 0 ) {
$_width_percent = round(100 / count($crosstabs['options1'],2));
foreach ($crosstabs['options1'] as $ckey1 =>$crossVariabla) {
$output .= '<col style="width:'.$_width_percent.'%;" />';
}
}
$output .= '<col style="width:auto;" />';
$output .= '</colgroup>';*/
$output .= '<tr><td></td><td></td>';
/*$output .= '<td>Χ<sup>2</sup> = ';
$output .= $this->formatNumber($crosstabs['hi2'], 3, '');
$output .= '</td>';*/
$output .= '<td align="center" colspan="' . $cols . '">';
$output .= '<b>'.$sub_q1.'</b>';
$output .= '</td>';
$output .= '<td> </td>';
$output .= '</tr>';
$output .= '<tr><td></td><td></td>';
$col_cnt=0;
if (count($crosstabs['options1']) > 0 ) {
foreach ($crosstabs['options1'] as $ckey1 =>$crossVariabla) {
$col_cnt++;
#ime variable
$output .= '<td align="center">';
$output .= $crossVariabla['naslov'];
# če ni tekstovni odgovor dodamo key
if ($crossVariabla['type'] != 't' && $show_variables_values == true) {
if ($crossVariabla['vr_id'] == null ) {
$output .= '<br style="mso-data-placement:same-cell;" /> ( '.$ckey1.' )';
} else {
$output .= '<br style="mso-data-placement:same-cell;" /> ( '.$crossVariabla['vr_id'].' )';
}
}
$output .= '</td>';
}
}
$col_cnt++;
$output .= '<td align="center">' . $lang['srv_analiza_crosstab_skupaj'] . '</td>';
$output .= '</tr>';
$cntY = 0;
if (count($crosstabs['options2']) > 0) {
foreach ($crosstabs['options2'] as $ckey2 =>$crossVariabla2) {
$cntY++;
$output .= '<tr>';
if ($cntY == 1) {
# ime variable
$output .= '<td align="center" rowspan="' . $rows . '" valign="top">';
$output .= '<b>'.$sub_q2.'</b>';
$output .= '</td>';
}
//$css_backY = 'rsdl_bck_variable'.($cntY & 1);
$css_backY = ' rsdl_bck_variable1';
$output .= '<td align="center">';
$output .= $crossVariabla2['naslov'];
# če ni tekstovni odgovor dodamo key
if ($crossVariabla2['type'] !== 't' && $show_variables_values == true ) {
if ($crossVariabla2['vr_id'] == null) {
$output .= '<br style="mso-data-placement:same-cell;" /> ( '.$ckey2.' )';
} else {
$output .= '<br style="mso-data-placement:same-cell;" /> ( '.$crossVariabla2['vr_id'].' )';
}
}
$output .= '</td>';
foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
$output .= '<td align="center">';
# celica z vebino
{
# prikazujemo eno ali več od: frekvenc, odstotkov, residualov
$output .= '<table>';
if ($this->crosstabClass->crossChk0) {
# izpišemo frekvence crostabov
$output .= '<tr>';
$output .= '<td align="center">';
$output .= ((int)$crosstabs_value[$ckey1][$ckey2] > 0) ? $crosstabs_value[$ckey1][$ckey2] : 0;
# .$crossTab[$crossVariabla1[cell_id]][$ckey2]
#
$output .= '</td>';
$output .= '</tr>';
}
if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
# sirina celice v %
if ( ($this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3) == 3 )
$css_width = ' ctb_w33p';
elseif (($this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3) == 2 )
$css_width = ' ctb_w50p';
else
$css_width = '';
$css_bt = ( $this->crosstabClass->crossChk0 ) ? 'anl_dash_bt' : '';
# izpisemo procente
$output .= '<tr>';
$output .= '<td align="center">';
$output .= '<table>';
$output .= '<tr>';
$col=0;
if ($this->crosstabClass->crossChk1) {
#procent vrstica
$col++;
$css_color = ($this->crosstabClass->doColor == 'true') ? 'ctbChck_sp1' : '';
$css_br = $numColumnPercent > $col ? ' anl_dash_br' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaVrstica'][$ckey2], $crosstabs_value[$ckey1][$ckey2]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk2) {
#procent stolpec
$col++;
$css_br = $numColumnPercent > $col ? ' anl_dash_br' : '';
$css_color = ($this->crosstabClass->doColor == 'true') ? 'ctbChck_sp2' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaStolpec'][$ckey1], $crosstabs_value[$ckey1][$ckey2]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk3) {
#procent skupni
$col++;
$css_br = $numColumnPercent > $col ? ' anl_dash_br' : '';
$css_color = ($this->crosstabClass->doColor == 'true') ? 'ctbChck_sp3' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($this->crosstabClass->getCrossTabPercentage($crosstabs['sumaSkupna'], $crosstabs_value[$ckey1][$ckey2]), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
$output .= '</tr>';
$output .= '</table>';
$output .= '</td>';
$output .= '</tr>';
}
# izpisemo residuale
if ($this->crosstabClass->crossChkEC || $this->crosstabClass->crossChkRE || $this->crosstabClass->crossChkSR || $this->crosstabClass->crossChkAR) {
# sirina celice v %
if ( ($this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR) == 4 )
$css_width = ' ctb_w25p';
elseif ( ($this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR) == 3 )
$css_width = ' ctb_w33p';
elseif ( ($this->crosstabClass->crossChkEC + $this->crosstabClass->crossChkRE + $this->crosstabClass->crossChkSR + $this->crosstabClass->crossChkAR) == 2 )
$css_width = ' ctb_w50p';
else
$css_width = '';
$css_bt = ( $this->crosstabClass->crossChk0 || ($this->crosstabClass->crossChk1 && $this->crosstabClass->crossChk2 && $this->crosstabClass->crossChk3)) ? 'anl_dash_bt' : '';
$output .= '<tr>';
$output .= '<td align="center">';
$output .= '<table>';
$output .= '<tr>';
$col=0;
if ($this->crosstabClass->crossChkEC) {
$col++;
$css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
$css_color = ($this->crosstabClass->doColor == 'true') ? 'crossCheck_EC' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($crosstabs['exC'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
$output .= '</td>';
}
if ($this->crosstabClass->crossChkRE) {
$col++;
$css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
$css_color = ($this->crosstabClass->doColor == 'true') ? 'crossCheck_RE' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($crosstabs['res'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
$output .= '</td>';
}
if ($this->crosstabClass->crossChkSR) {
$col++;
$css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
$css_color = ($this->crosstabClass->doColor == 'true') ? 'crossCheck_SR' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($crosstabs['stR'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
$output .= '</td>';
}
if ($this->crosstabClass->crossChkAR) {
$col++;
$css_br = $numColumnResidual > $col ? ' anl_dash_br' : '';
$css_color = ($this->crosstabClass->doColor == 'true') ? 'crossCheck_AR' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber($crosstabs['adR'][$ckey1][$ckey2], SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_RESIDUAL'), '');
$output .= '</td>';
}
$output .= '</tr>';
$output .= '</table>';
$output .= '</td>';
$output .= '</tr>';
}
$output .= '</table>';
}
# konec celice z vsebino
$output .= '</td>';
}
// vedno rišemo zadnji stolpec.
$output .= '<td align="center" >';
$output .= '<table>';
if ($this->crosstabClass->crossChk0) {
$output .= '<tr>';
$output .= '<td align="center" colspan="' . ( $this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3 ).'">';
# suma po vrsticah
$output .= (int)$crosstabs['sumaVrstica'][$ckey2];
$output .= '</td>';
$output .= '</tr>';
}
if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
if (($this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3) == 3) {
$css_width = ' ctb_w33p';
} else if (($this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3) == 2) {
$css_width = ' ctb_w50p';
} else {
$css_width = '';
}
$css_bt = ( $this->crosstabClass->crossChk0 ) ? ' anl_dash_bt' : '';
# suma po vrsticah v procentih
$output .= '<tr>';
if ($this->crosstabClass->crossChk1) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp1' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk2) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp2' : '';
$css_border = ($this->crosstabClass->crossChk1 ? ' anl_dash_bl ' : '');
$output .= '<td align="center">';
$output .= $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk3) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp3' : '';
$css_border = ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 ? ' anl_dash_bl ' : '');
$output .= '<td align="center">';
$output .= $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaVrstica'][$ckey2] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
$output .= '</td>';
$output .= '</tr>';
}
}
$cntY++;
$output .= '<tr>';
$output .= '<td align="center"> </th>';
//$css_backY = 'rsdl_bck_variable'.($cntY & 1);
$css_backY = ' rsdl_bck_variable1';
$output .= '<td align="center">' . $lang['srv_analiza_crosstab_skupaj'] . '</td>';
// skupni sestevki po stolpcih
if (count($crosstabs['options1']) > 0)
foreach ($crosstabs['options1'] as $ckey1 => $crossVariabla1) {
$output .= '<td align="center" >';
{
# prikazujemo eno od treh možnosti
$output .= '<table>';
if ($this->crosstabClass->crossChk0) {
$output .= '<tr>';
$output .= '<td align="center" colspan="'.($this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3).'">';
# suma po stolpcih
$output .= (int)$crosstabs['sumaStolpec'][$ckey1];
$output .= '</td>';
$output .= '</tr>';
}
if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
# suma po stolpcih v procentih
$css_bt = ($this->crosstabClass->crossChk0) ? ' anl_dash_bt' : '';
$output .= '<tr>';
if ($this->crosstabClass->crossChk1) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp1' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk2) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp2' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk3)
{
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp3' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber( ($crosstabs['sumaSkupna'] > 0 ? (100 * $crosstabs['sumaStolpec'][$ckey1] / $crosstabs['sumaSkupna']) : 0), SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
}
$output .= '</td>';
}
# zadnja celica z skupno sumo
$output .= '<td align="center">';
{
$output .= '<table>';
if ($this->crosstabClass->crossChk0) {
$output .= '<tr>';
$output .= '<td align="center" colspan="'.($this->crosstabClass->crossChk1 + $this->crosstabClass->crossChk2 + $this->crosstabClass->crossChk3).'">';
# skupna suma
$output .= (int)$crosstabs['sumaSkupna'];
$output .= '</td>';
$output .= '</tr>';
}
if ($this->crosstabClass->crossChk1 || $this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) {
# suma po stolpcih v procentih
$css_bt = ($this->crosstabClass->crossChk0) ? ' anl_dash_bt' : '';
$output .= '<tr>';
if ($this->crosstabClass->crossChk1) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp1' : '';
$css_border = ($this->crosstabClass->crossChk2 || $this->crosstabClass->crossChk3) ? ' anl_dash_br' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk2) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp2' : '';
$css_border = ($this->crosstabClass->crossChk3) ? ' anl_dash_br' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
if ($this->crosstabClass->crossChk3) {
$css_color = ($this->crosstabClass->doColor == 'true') ? ' ctbChck_sp3' : '';
$output .= '<td align="center">';
$output .= $this->formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%');
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
}
$output .= '</td>';
$output .= '</tr>';
$output .= '</table>';
}
}
}
}
/*Skrajsa tekst in doda '...' na koncu*/
function snippet($text,$length=64,$tail="...")
{
$text = trim($text);
$txtl = strlen($text);
if($txtl > $length)
{
for($i=1;$text[$length-$i]!=" ";$i++)
{
if($i == $length)
{
return substr($text,0,$length) . $tail;
}
}
$text = substr($text,0,$length-$i+1) . $tail;
}
return $text;
}
function setUserId($usrId) {$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;
$result = number_format($result, $digit, ',', '') . $sufix;
// Preprecimo da bi se stevilo z decimalko pretvorilo v datum
//$result = '="'. $result.'"';
return $result;
}
}
?>
|