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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
|
<?php
/*
* Created on 31.3.2009
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
//error_reporting(E_ALL);
set_time_limit(1800);
include_once('../../function.php');
require_once('../exportclases/class.enka.pdf.php');
require_once('../../vendor/autoload.php');
require_once('../survey/definition.php');
define("FNT_FREESERIF", "freeserif", true);
define("FNT_FREESANS", "freesans", true);
define("FNT_HELVETICA", "helvetica", true);
define("FNT_MAIN_TEXT", FNT_FREESANS, true);
define("FNT_QUESTION_TEXT", FNT_FREESANS, true);
define("FNT_HEADER_TEXT", FNT_FREESANS, true);
define("FNT_MAIN_SIZE", 10, true);
define("FNT_QUESTION_SIZE", 9, true);
define("FNT_HEADER_SIZE", 10, true);
define("RADIO_BTN_SIZE", 3, true);
define("CHCK_BTN_SIZE", 3, true);
define("LINE_BREAK", 6, true);
define ('PDF_MARGIN_HEADER', 8);
define ('PDF_MARGIN_FOOTER', 12);
define ('PDF_MARGIN_TOP', 18);
define ('PDF_MARGIN_BOTTOM', 18);
define ('PDF_MARGIN_LEFT', 15);
define ('PDF_MARGIN_RIGHT', 15);
/** Class za generacijo pdf-a
*
* @desc: po novem je potrebno form elemente generirati ročno kot slike
*
*/
class PdfIzvozResults {
var $anketa;// = array(); // trenutna anketa
var $grupa = null; // trenutna grupa
var $spremenljivka; // trenutna spremenljivka
var $printPreview = false; // ali kliče konstruktor
var $pi=array('canCreate'=>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 $type = 0; // nacin izpisa vprasanj - kratek -> 0, dolg -> 1, 2 -> zelo kratek
var $pageBreak = 0; // vsak respondent na svoji strani
var $showIf = 0; // izpis if-ov
var $font = 10; // velikost pisave
var $numbering = 0; // ostevillcevanje vprasanj
var $showRecnum = 1; // prikaz recnuma
var $skipEmpty = 0; // izpusti vprasanja brez odgovora
var $skipEmptySub = 0; // izpusti podvprasanja brez odgovora
var $landscape = 0; // landscape izpis
var $loop_id = null; // id trenutnega loopa ce jih imamo
var $usr_type = null; // tip userja (null->iz vmesnika, author->avtor iz maila, respondent->respondent iz maila, other->other iz maila)
var $usr_id = null; // id userja ki je odgovarjal (na katerega so vezani podatki)
var $resp_id = null; // id userja na katerega so vezane nastavitve ankete (filtriranje spremenljivk...)
var $admin_type = -1; // tip userja ki odpira pdf (posebej nastavimo ker global admin_type ne dela iz mailov)
/**
* @desc konstruktor
*/
function __construct ($anketa = null, $usr_type = null, $usr_id = null)
{
global $site_path;
global $global_user_id;
// preverimo ali imamo stevilko ankete
if ( is_numeric($anketa) )
{
$this->anketa['id'] = $anketa;
$this->usr_id = $_GET['usr_id'];
// Ce prihajamo iz maila imamo nastavljen usr_type in usr_id
if($usr_type != null && $usr_id != null){
$this->usr_type = $usr_type;
//$this->resp_id = $usr_id;
// Ajda hoce da ce dobi po mailu pdf mora bit isti kot ga dobi respondent
$this->resp_id = $_GET['usr_id'];
}
// Drugace prihajamo normalno iz podatkov (usr_id je avtorjev -> $global_user_id)
else{
$this->resp_id = $global_user_id;
}
// Nastavimo admin type
$sqlU = sisplet_query("SELECT type FROM users WHERE id='".$this->resp_id."'");
if($rowU = mysqli_fetch_array($sqlU))
$this->admin_type = $rowU['type'];
// Po novem imamo globalne nastavitve
SurveySetting::getInstance()->Init($anketa);
$this->type = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_type');
$this->font = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_font_size');
$this->showIf = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_if');
$this->numbering = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_numbering');
$this->pageBreak = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_PB');
$this->showRecnum = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_show_recnum');
$this->skipEmpty = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty');
$this->skipEmptySub = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_skip_empty_sub');
$this->landscape = (int)SurveySetting::getInstance()->getSurveyMiscSetting('export_data_landscape');
SurveyStatusProfiles::Init($anketa);
// create new PDF document
$orientation = ($this->landscape == 1) ? 'L' : 'P';
$this->pdf = new enka_TCPDF($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())
{
SurveyUserSetting::getInstance()->Init($this->anketa['id'], $global_user_id);
$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()
{
global $lang;
// 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'] = $lang['page'];
//set some language-dependent strings
$this->pdf->setLanguageArray($language_meta);
//set margins
if(!$this->getUserId()){
$this->pdf->setPrintHeaderFirstPage(false);
$this->pdf->setPrintFooterFirstPage(false);
}
else{
$this->pdf->setPrintHeaderFirstPage(true);
$this->pdf->setPrintFooterFirstPage(true);
}
$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
if($this->getUserId()){
$sqlu = sisplet_query("SELECT * FROM srv_user WHERE id = '".$this->getUserId()."'");
$rowu = mysqli_fetch_array($sqlu);
$rightTitle = ($this->showRecnum == 1) ? SurveyInfo::getInstance()->getSurveyAkronim().' (recnum '.$rowu['recnum'].')' : SurveyInfo::getInstance()->getSurveyAkronim();
$this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText($rightTitle));
//nastavimo datum za footer
$this->pdf->SetFooterDate($rowu['time_edit']);
}
else
$this->pdf->SetHeaderData(null, null, "www.1ka.si", $this->encodeText(SurveyInfo::getInstance()->getSurveyAkronim()));
//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 vseh odgovorov (vsi respondenti -> max 300)
if(!$this->getUserId())
$this->outputAllResults();
// Izpis odgovorov enega respondenta
else
$this->outputSurvey();
}
function createFrontPage()
{
global $lang;
// 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);
if(!$this->getUserId()){
$this->pdf->Cell(0, 10, $this->encodeText(SurveyInfo::getInstance()->getSurveyTitle()), '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);
}
else{
$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()->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(SurveyInfo::getInstance()->getSurveyAkronim()), 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 vseh userjev, ki so odgovorili
function outputAllResults(){
global $lang;
//$izbranStatusProfile = SurveyUserSetting :: getInstance()->getSettings('default_status_profile_export');
$izbranStatusProfile = SurveyStatusProfiles :: getStatusAsQueryString();
$sqlu = sisplet_query("SELECT * FROM srv_user WHERE ank_id = '".$this->anketa['id']."' ".$izbranStatusProfile." AND deleted='0' AND preview='0' ORDER BY recnum");
//ce imamo vec kot 300 anketirancev ne izpisemo
$count = mysqli_num_rows($sqlu);
if( $count > 300 ){
$this->pdf->AddPage();
$this->pdf->setFont('','B','15');
$this->pdf->MultiCell(150, 5, 'NAPAKA!', 0, 'L', 0, 1, 0 ,0, true);
$this->pdf->MultiCell(150, 5, 'Izpis ni možen zaradi prevelikega števila odgovorov ('.$count.')', 0, 'L', 0, 1, 0 ,0, true);
$this->pdf->ln(5);
}
else{
// izpišemo prvo stran
$this->createFrontPage();
if($this->pageBreak == 0)
$this->pdf->AddPage();
while( $rowu = mysqli_fetch_array($sqlu) ){
//izpis statusa
switch($rowu['last_status']){
case '0':
$status = $lang['srv_userstatus_0'];
break;
case '1':
$status = $lang['srv_userstatus_1'];
break;
case '2':
$status = $lang['srv_userstatus_2'];
break;
case '3':
$status = $lang['srv_userstatus_3'];
break;
case '4':
$status = $lang['srv_userstatus_4'];
break;
case '5':
$status = $lang['srv_userstatus_5'];
break;
case '6':
$status = $lang['srv_userstatus_6'];
$status .= ($rowu['lurker'] == '1') ? ' - lurker' : '';
break;
}
if($this->pageBreak == 1)
$this->pdf->AddPage();
$this->pdf->setFont('','B', 14);
if($this->showRecnum == 1)
$this->pdf->MultiCell(150, 5, 'Recnum '.$rowu['recnum'].' (status '.$rowu['last_status'].' - '.$status.')', 0, 'L', 0, 1, 0 ,0, true);
else
$this->pdf->MultiCell(150, 5, 'Status '.$rowu['last_status'].' - '.$status, 0, 'L', 0, 1, 0 ,0, true);
$this->pdf->ln(5);
//izpis posameznega userja
$this->usr_id = $rowu['id'];
$this->outputUser();
}
}
}
// Izpis vprasalnika z odgovori
function outputSurvey(){
global $lang;
$rowA = SurveyInfo::getInstance()->getSurveyRow();
// izpišemo prvo stran
if (false)
$this->createFrontPage();
// Izpisemo vprasalnik
$this->pdf->AddPage();
// filtriramo spremenljivke glede na profil - SAMO CE NE PRIHAJAMO IZ MAILA!
$tmp_svp_pv = array();
if($this->usr_type == null){
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'] == 1 && $this->allResults == 3) || (!$this->getUserId() && $this->allResults == 0)){
if ( SurveyInfo::getInstance()->getSurveyShowIntro() )
{
$intro = (SurveyInfo::getInstance()->getSurveyIntro() == '') ? $lang['srv_intro'] : SurveyInfo::getInstance()->getSurveyIntro();
$this->pdf->Write (0, $this->encodeText(SurveyInfo::getInstance()->getSurveyIntro()), '', 0, 'L', 1, 1);
$this->pdf->Ln(LINE_BREAK);
//$this->pdf->drawLine();
$this->pdf->Ln(LINE_BREAK);
}
}*/
if ( $this->getGrupa() )
{
$sqlGrupeString = "SELECT id FROM srv_grupa WHERE ank_id='".$this->anketa['id']."' AND id = '".$this->getGrupa()."' ORDER BY vrstni_red";
}
else
{
$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'];
// Pogledamo prvo spremenljivko v grupi ce je v loopu
$sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
$row = mysqli_fetch_array($sql);
// ce je ima loop za parenta
$if_id = $this->find_parent_loop($row['id']);
if ($if_id > 0){
$sql1 = sisplet_query("SELECT * FROM srv_loop WHERE if_id = '$if_id'");
$row1 = mysqli_fetch_array($sql1);
$this->loop_id = $this->findNextLoopId($row1['if_id']);
$if = Cache::srv_if($if_id);
$loop_title = $if['label'];
// gremo cez vse spremenljivke v trenutnem loopu
while($this->loop_id != null){
// Izrisemo naslov loopa
$this->pdf->SetTextColor(0,0,200);
$this->pdf->SetDrawColor(0,0,200);
$this->pdf->setFont('','B',$this->font);
$this->pdf->Write (0, $this->encodeText($this->dataPiping($loop_title)), '', 0, 'L', 1, 1);
$this->pdf->SetTextColor(0,0,200);
$this->pdf->SetDrawColor(0,0,200);
$this->pdf->setFont('','',$this->font);
$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);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->SetDrawColor(0,0,0);
// Izpis vprasalnika z rezultati
// Ce imamo kombinirano tabelo pogledamo ce prikazujemo katero od podtabel
if($rowSpremenljivke['tip'] == 24){
$subGrids = array();
$showGridMultiple = false;
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivka."' AND m.spr_id=s.id");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if(in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0){
$showGridMultiple = true;
break;
}
}
}
// ce je nastavljen profil s filtriranimi spremenljivkami
if(in_array($spremenljivka,$tmp_svp_pv) || count($tmp_svp_pv) == 0 || ($rowSpremenljivke['tip'] == 24 && $showGridMultiple) || $rowSpremenljivke['tip'] == 5){
$this->currentHeight = 0;
// NAVADEN IZPIS rezultatov spremenljivke - kratek samo pri radio, checkbox, multiradio, multicheckbox, besedilo
//if( $this->type == 0 && in_array($rowSpremenljivke['tip'], array(1,2,3,6,16,21,7,8)) ){
if( $this->type == 0 && in_array($rowSpremenljivke['tip'], array(1,2,3,6,16,21,7,8,27)) ){
if($rowSpremenljivke['tip'] < 4)
$this->outputVprasanjeValues($rowSpremenljivke);
else
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// KRATEK IZPIS rezultatov spremenljivke
elseif($this->type == 2 && $rowSpremenljivke['tip'] != 24){
$this->outputVprasanjeValues($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// DOLG IZPIS rezultatov
else{
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivke($rowSpremenljivke);
}
$this->pdf->Ln(LINE_BREAK);
}
}
}
$this->loop_id = $this->findNextLoopId();
}
}
// Navadne spremenljivke ki niso v loopu
else{
$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);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->SetDrawColor(0,0,0);
// Izpis vprasalnika z rezultati
// Ce imamo kombinirano tabelo pogledamo ce prikazujemo katero od podtabel
if($rowSpremenljivke['tip'] == 24){
$subGrids = array();
$showGridMultiple = false;
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivka."' AND m.spr_id=s.id");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if(in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0){
$showGridMultiple = true;
break;
}
}
}
// ce je nastavljen profil s filtriranimi spremenljivkami
if(in_array($spremenljivka,$tmp_svp_pv) || count($tmp_svp_pv) == 0 || $rowSpremenljivke['tip'] == 5 || ($rowSpremenljivke['tip'] == 24 && $showGridMultiple)){
$this->currentHeight = 0;
// NAVADEN IZPIS rezultatov spremenljivke - kratek samo pri radio, checkbox, multiradio, multicheckbox, besedilo
if( $this->type == 0 && in_array($rowSpremenljivke['tip'], array(1,2,3,6,16,21,7,8)) ){
if($rowSpremenljivke['tip'] < 4)
$this->outputVprasanjeValues($rowSpremenljivke);
else
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// KRATEK IZPIS rezultatov spremenljivke
elseif($this->type == 2 && $rowSpremenljivke['tip'] != 24){
$this->outputVprasanjeValues($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// DOLG IZPIS rezultatov
else{
$this->outputVprasanje($rowSpremenljivke);
$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);
}
}
}
function outputVprasanje($spremenljivke){
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
// 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);
$naslov = $this->dataPiping($spremenljivke['naslov']);
$linecount_vprasanja = $this->pdf->getNumLines($naslov, $this->pdf->getPageWidth());
if($pozicija_vprasanja + $linecount_vprasanja*4.7 /*+ $visina*/ > 240/$expand_width)
{
$this->pdf->AddPage();
}
//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);
$this->pdf->Write (0, $numberingText . $this->encodeText($naslov), '', 0, 'l', 1, 1);
/*$text = strip_tags($numberingText . $spremenljivke['naslov'], '<a><img><ul><li><ol><br>');
$this->pdf->WriteHTML($text);*/
$this->pdf->setFont('','',$this->font);
if($spremenljivke['tip'] != 5)
$this->pdf->Ln(LINE_BREAK);
}
function outputSpremenljivke($spremenljivke){
global $site_url;
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
// Ce je spremenljivka v loopu
$loop_id = $this->loop_id == null ? " IS NULL" : " = '".$this->loop_id."'";
switch ( $spremenljivke['tip'] )
{
case 1: //radio
case 2: //check
case 3: //select -> radio
if ($this->getUserId())
{
// če imamo vnose, pogledamo kaj je odgovoril uporabnik
$sqlUserAnswerString = "SELECT vre_id FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spremenljivke[id]' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id";
$sqlUserAnswer = sisplet_query($sqlUserAnswerString);
while ($rowAnswers = mysqli_fetch_assoc($sqlUserAnswer))
$userAnswer[$rowAnswers['vre_id']] = $rowAnswers['vre_id'];
}
// 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*$expand_width;
//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 '<div style="float:left; width:'.(100/$stolpci).'%">';
$kategorij = mysqli_num_rows($sqlVrednosti);
$v_stolpcu = ceil($kategorij / $stolpci);
$width = round(180*$expand_width / $stolpci);
}
$yStart = $this->pdf->GetY();
$xStart = $this->pdf->GetX();
$count = 0;
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$prop['full'] = ( isset($userAnswer[$rowVrednost['id']]) );
//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 )
{
$this->pdf->RadioButton('vpr_'. $spremenljivke['id'], RADIO_BTN_SIZE, $prop);
$y1=$this->pdf->GetY();
$x1=$this->pdf->GetX();
}
else if ( $spremenljivke['tip'] == 2 )
{
$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, '');
$stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
// še dodamo textbox če je polj other
if ($rowVrednost['other'] == 1 && $this->getUserId())
{
$_txt = '';
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = $row4['text'];
$stringTitle .= ' '.$_txt;
}
$this->currentHeight = $this->pdf->getNumLines($stringTitle, $width);
if ( $spremenljivke['tip'] == 2 )
{
$y=$y-2;
$x=$x+3;
$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x,$y);
}
else
{
$y1=$y1-1;
$x1=$x1+3;
$this->pdf->MultiCell($width, 1, $stringTitle,0,'L',0,0,$x1,$y1);
}
$this->currentHeight = ($this->currentHeight == 1) ? 2 : $this->currentHeight;
$this->pdf->setY($this->pdf->getY() + $this->currentHeight*4.7);
$count++;
}
break;
case 6: //multigrid
case 16:// multicheckbox
case 19:// multitext
case 20:// multinumber
//izris dvojnega multigrida
if(($spremenljivke['tip'] == 6 || $spremenljivke['tip'] == 16) && $spremenljivke['enota'] == 3){
$this->displayDoubleGrid($spremenljivke);
break;
}
$sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'");
$rowVrstic = mysqli_fetch_row($sqlVrstic);
$visina = round(($rowVrstic[0]+2) * 8);
$defw_full = 210*$expand_width;
$defw_fc = 24*$expand_width; // sirina prve celice
$defw_max = 35*$expand_width; // max sirina ostalih celic
$sqlStVrednosti = sisplet_query("SELECT count(*) FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY id");
$rowStVrednost = mysqli_fetch_row($sqlStVrednosti);
$kolon = $rowStVrednost[0]+1;
// Ce imamo diferencial
if($spremenljivke['tip'] == 6 && $spremenljivke['enota'] == 1){
$kolon++;
}
switch($kolon)
{
case 2:
$defw_fc = 110*$expand_width;
break;
case 3:
$defw_fc = 85*$expand_width;
break;
case 4:
$defw_fc = 60*$expand_width;
break;
case 5:
$defw_fc = 40*$expand_width;
break;
case 6:
$defw_fc = 35*$expand_width;
break;
default:
$defw_fc = 24*$expand_width;
}
$w_oc = ( $defw_full - $defw_fc ) / $kolon;
if ( $w_oc > $defw_max )
$w_oc = $defw_max;
$countVrednosti=0;
$halfWidth = ($w_oc)/ 2;
// Prelom strani ce je kateri od naslovov gridov predolg
$sqlVsehVrednsti = sisplet_query("SELECT naslov, variable,vrstni_red FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$linecount = 0;
$break = false;
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// če je naslov null izpišemo variable
$stringHeader_title = $this->encodeText( $rowVsehVrednosti['naslov'] ? $rowVsehVrednosti['naslov'] : $rowVsehVrednosti['variable'] );
/*Zascita pred prepisovanjem na novo stran za zgornje parametre*/
$pozicija_vrha = $this->pdf->getY();
$linecount = $this->pdf->getNumLines($stringHeader_title, $w_oc);
$this->currentHeight = ($linecount > $this->currentHeight) ? $linecount : $this->currentHeight;
if(!$break && $pozicija_vrha + $linecount*4.7 > 250/$expand_width)
{
$this->pdf->AddPage();
$break = true;
}
}
/*Izpis presledka na začetku*/
$this->pdf->Cell($defw_fc, 0,'');
// izišemo header celice
$sqlVsehVrednsti = sisplet_query("SELECT naslov, variable,vrstni_red FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// če je naslov null izpišemo variable
$stringHeader_title = $this->encodeText( $rowVsehVrednosti['naslov'] ? $rowVsehVrednosti['naslov'] : $rowVsehVrednosti['variable'] );
/*Izpis zgornje vrstice*/
$this->pdf->MultiCell($w_oc, 1,$stringHeader_title,0,'C',0,0,0,0,true,0);
}
$this->pdf->setY($this->pdf->getY() + $this->currentHeight*6);
$row_count = 1;
$sqlVrednosti = sisplet_query("SELECT *,id, naslov, naslov2, variable FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$skipRow = false;
// Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici
if($this->skipEmptySub == 1){
$skipRow = true;
if($spremenljivke['tip'] == 6)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
elseif($spremenljivke['tip'] == 16)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
if(mysqli_num_rows($sqlUserAnswer) > 0)
$skipRow = false;
}
if($skipRow == false){
// barva vrstice
$row_color = $row_count%2;
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
/*Zascita pred prepisovanjem na novo stran za bocne parametre*/
$pozicija_boka = $this->pdf->getY();
$pozicija_bokaX = $this->pdf->getX();
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$stringCell_title .= $_txt.':';
$firstHeight = 0;
$linecount = $this->pdf->getNumLines($stringCell_title, $defw_fc);
$cellHeight1 = 0;
$cellHeight2 = 0;
if($spremenljivke['tip'] == 6 && $spremenljivke['enota'] == 1){
$stringCell_title2 = $this->encodeText($rowVrednost['naslov2']);
$linecount = ($this->pdf->getNumLines($stringCell_title2, $defw_fc) > $linecount) ? $this->pdf->getNumLines($stringCell_title2, $defw_fc) : $linecount;
$cellHeight1 = $this->getCellHeight($this->encodeText($stringCell_title), $defw_fc);
$cellHeight2 = $this->getCellHeight($this->encodeText($stringCell_title2), $defw_fc);
$endY = ($cellHeight2 > $cellHeight1) ? $pozicija_boka+$cellHeight2 : $pozicija_boka+$cellHeight1;
$endY = ($endY - $startY > LINE_BREAK) ? $endY : $pozicija_boka+LINE_BREAK;
$startX = $this->pdf->getX() + $defw_fc;
}
if($pozicija_boka + $linecount*4.7 > 250/$expand_width)
{
$this->pdf->AddPage();
$pozicija_boka = $this->pdf->getY();
}
$firstHeight = $linecount;
if($spremenljivke['tip'] == 6 && $spremenljivke['enota'] == 1){
$endY = ($cellHeight2 > $cellHeight1) ? $pozicija_boka+$cellHeight2 : $pozicija_boka+$cellHeight1;
$endY = ($endY - $startY > LINE_BREAK) ? $endY : $pozicija_boka+LINE_BREAK;
}
$startX = $this->pdf->getX() + $defw_fc;
$startY = $pozicija_boka;
/*Izpis bočnega stolpca*/
if($cellHeight2 > $cellHeight1)
$this->pdf->SetXY($this->pdf->getX(), ($startY+$endY)/2 - ($cellHeight1)/2);
$this->pdf->MultiCell($defw_fc, $cellHeight1, $stringCell_title,0,'C',0,1,0,0,true,0);
if($spremenljivke['tip'] != 6 || $spremenljivke['enota'] != 1){
$endY = $this->pdf->getY();
}
$shtevec = 0;
// Pri multitext in multinumber loopamo cez vrstico da dobimo visino najvisje celice
if($spremenljivke['tip'] == 19 || $spremenljivke['tip'] == 20){
$height = 0;
$sqlVsehVrednsti = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
// poiščemo kaj je odgovoril uporabnik:
if ($this->getGrupa())
{
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
}
$linecount = $this->pdf->getNumLines($userAnswer['text'], $w_oc);
$height = ($linecount*4.2 > $height) ? $linecount*4.2 : $height;
}
if($height > 5){
$endY += $height - LINE_BREAK;
}
else{
$height = LINE_BREAK;
}
$height = ($height > $firstHeight*4.7) ? $height : $firstHeight*4.7;
}
// Vsaka druga vrstica ima sivo ozadje
$XX = $this->pdf->getX();
$YY = $this->pdf->getY();
$this->pdf->setXY(15, $startY);
$this->pdf->SetFillColor(242,243,241);
$this->pdf->MultiCell($defw_full, $endY-$startY,'',0,'C',$row_color,1,0,0,true,0);
$this->pdf->SetFillColor(0);
$this->pdf->setXY($XX, $YY);
$row_count++;
// Loopamo cez vrstice in izrisujemo celice
$sqlVsehVrednsti = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
// poiščemo kaj je odgovoril uporabnik:
if ($this->getGrupa())
{
if($spremenljivke['tip'] == 6)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
elseif($spremenljivke['tip'] == 16)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' AND loop_id $loop_id");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
}
$prop['full'] = ($rowVsehVrednosti['id'] == $userAnswer['grd_id']) ? true : false;
$this->pdf->SetXY($startX + $shtevec*$w_oc , ($startY+$endY)/2 - (CHCK_BTN_SIZE+1)/2);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
if($spremenljivke['tip']==6) {
$this->pdf->RadioButton('vpr_'. $rowVrednost['id'], RADIO_BTN_SIZE, $prop);
}
elseif($spremenljivke['tip']==16) {
$this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop);
}
else{
$this->pdf->SetXY($this->pdf->getX() - $w_oc/2, $startY);
//$this->pdf->setX($this->pdf->getX() - $w_oc/2);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', 8);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
//$this->pdf->TextBoxes($w_oc,LINE_BREAK);
$this->pdf->SetFillColor(255,255,255);
$this->pdf->MultiCell($w_oc-1, $height, $userAnswer['text'],1,'C',1,1,0,0,true,0);
$this->pdf->SetFillColor(0);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font);
$this->pdf->SetTextColor(0,0,0);
}
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$shtevec++;
}
// Bocni stolpec na desni (ce imamo diferencial)
if($spremenljivke['tip'] == 6 && $spremenljivke['enota'] == 1){
if($cellHeight1 > $cellHeight2)
$this->pdf->SetXY($this->pdf->getX(), ($startY+$endY)/2 - ($cellHeight2)/2);
else
$this->pdf->setXY($this->pdf->getX(), $startY);
$this->pdf->MultiCell($defw_fc, $cellHeight2,$stringCell_title2,0,'C',0,1,0,0,true,0);
}
$this->pdf->setY($endY);
}
}
break;
case 24: // Mesan multigrid
$this->displayGridMultiple($spremenljivke);
break;
case 4: //text
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(180*$expand_width, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 1, 0 ,0, false);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->TextField('vpr_'. $spremenljivke['id'], 180*$expand_width, 18, array('multiline'=>true,'strokeColor'=>'dkGray'));
$this->pdf->TextBox(180*$expand_width,18);
$this->pdf->Ln(LINE_BREAK * 3);
}
break;
case 21: //besedilo*
// Posebej ipisemo ce imamo samo en kos besedila brez pripisanega texta
if($spremenljivke['text_kosov'] == 1 && $spremenljivke['text_orientation'] == 0){
$sqlVrednost = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
// imamo upload vprašanje
if ($spremenljivke['upload'] == 1){
# imena datotek
if($userAnswer['text'] != '')
$answer = ''.$site_url.'main/survey/download.php?anketa='.$this->anketa['id'].'&code='.$userAnswer['text'].'';
else
$answer = '';
}
// imamo signature vprašanje
elseif($spremenljivke['signature'] == 1){
$answer = $userAnswer['text'];
// relativna pot
$image = $site_url.'main/survey/uploads/'.$this->getUserId().'_'.$spremenljivke['id'].'_'.$this->anketa['id'].'.png';
$this->pdf->Image($image, $x='', $y='', $w=140, $h, $type='PNG', $link='', $align='N', $resize=true, $dpi=1600, $palign='C', $ismask=false, $imgmask=false, $border=0);
}
else{
$answer = $userAnswer['text'];
}
$this->pdf->SetTextColor(179,0,128);
//$this->pdf->Write(0, $userAnswer['text'], '', 0, 'l', 1, 1);
$this->pdf->MultiCell(180*$expand_width, 1,$this->encodeText($answer),0,'L',0,1,0,0,true,0);
$this->pdf->SetTextColor(0,0,0);
}
else{
$count = $spremenljivke['text_kosov'];
$width = round(170*$expand_width/$count);
$this->currentHeight = 4;
if($spremenljivke['text_orientation'] == 1)
$width -= 20*$expand_width;
$sqlVrednost = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
for($i=0; $i<$count; $i++){
$rowVrednost = mysqli_fetch_array($sqlVrednost);
if($spremenljivke['text_orientation'] == 1){
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(20*$expand_width, 1,$stringHeader_title,0,'R',0,0,0,0,true,0);
$linecount_vprasanja = $this->pdf->getNumLines($stringHeader_title, 20*$expand_width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
if ( $this->getUserId() )
{
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
// imamo upload vprašanje
if ($spremenljivke['upload'] == 1){
# imena datotek
if($userAnswer['text'] != '')
$answer = ''.$site_url.'main/survey/download.php?anketa='.$this->anketa['id'].'&code='.$userAnswer['text'].'';
else
$answer = '';
}
else{
$answer = $userAnswer['text'];
}
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell($width, 18, $this->encodeText($answer), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
$linecount_vprasanja = $this->pdf->getNumLines($answer, $width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
else
{
$this->pdf->TextBoxes($width,18);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
//$this->pdf->setX($this->pdf->getX() + (10/$count)+$width);
}
if($spremenljivke['text_orientation'] == 2){
mysqli_data_seek($sqlVrednost, 0);
$this->pdf->setY($this->pdf->getY() + 20);
for($i=0; $i<$count; $i++){
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell($width, 1,$stringHeader_title,0,'C',0,0,0,0,true,0);
$this->pdf->setX($this->pdf->getX() + 10/$count);
$linecount_vprasanja = $this->pdf->getNumLines($stringHeader_title, $width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
}
$this->pdf->setY($this->pdf->getY() + $this->currentHeight*4.7);
}
//$this->pdf->Ln(LINE_BREAK * 3);
break;
case 5: //label
// $this->pdf->Ln(6);
break;
case 7: //number
error_log("Number @outputSpremenljivke");
# z enoto na levi
if($spremenljivke['enota'] == 1){
# enota
$sqlVrednost = sisplet_query("SELECT naslov FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(30*$expand_width, 5,$stringHeader_title,0,'R',0,0,0,0,true,0);
# odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."';";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(30*$expand_width, 5, '', 1, 'L', 0, 0, 0 ,0, true);
}
//dodatno polje
if($spremenljivke['size'] == 2){
#enota
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(30*$expand_width, 5,$stringHeader_title,0,'R',0,0,0,0,true,0);
#odgovor
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."';";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text2']), 1, 'L', 0, 1, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
}
else {
$this->pdf->MultiCell(30*$expand_width, 5, '', 1, 'L', 0, 1, 0 ,0, true);
}
}
else
$this->pdf->Ln(LINE_BREAK);
# z enoto na desni
} else if($spremenljivke['enota'] == 2){
#odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text']), 1, 'R', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(30*$expand_width, 5, '', 1, 'R', 0, 0, 0 ,0, true);
}
# enota
$sqlVrednost = sisplet_query("SELECT naslov FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(30*$expand_width, 5,$stringHeader_title,0,'L',0,0,0,0,true,0);
//dodatno polje
if($spremenljivke['size'] == 2){
#enota
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
#odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text2']), 1, 'R', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(30*$expand_width, 5, '', 1, 'R', 0, 0, 0 ,0, true);
}
$this->pdf->MultiCell(30*$expand_width, 5,$stringHeader_title,0,'L',0,1,0,0,true,0);
/*
#odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."';";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$this->pdf->SetTextColor(0,128,0);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text2']), 1, 'L', 0, 1, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(30, 5, '', 1, 'L', 0, 1, 0 ,0, true);
}
#enota
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $rowVrednost['naslov'];
$this->pdf->MultiCell(30, 5,$stringHeader_title,0,'L',0,0,0,0,true,0);
*/
} else {
$this->pdf->Ln(LINE_BREAK);
}
}
//brez enote
else{
$this->pdf->setX(20*$expand_width);
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->MultiCell(30*$expand_width, 5, '', 1, 'L', 0, 0, 0 ,0, true);
}
//dodatno polje
if($spremenljivke['size'] == 2){
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->setX($this->pdf->getX() + 5);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text2']), 1, 'L', 0, 1, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->setX($this->pdf->getX() + 5);
$this->pdf->MultiCell(30*$expand_width, 5, '', 1, 'L', 0, 1, 0 ,0, true);
}
}
else
$this->pdf->Ln(LINE_BREAK);
}
/*if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."';";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 1, 0 ,0, false);
}
else
{
$this->pdf->TextField('vpr_'. $spremenljivke['id'], 30, 5, array('multiline'=>true,'strokeColor'=>'dkGray'));
$this->pdf->TextBox(50,LINE_BREAK);
$this->pdf->Ln(LINE_BREAK);
}*/
break;
case 8: //datum
// če imamo odgovor od uporabnika, potem ga izpišemo, čene damo prazen box
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30*$expand_width, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 1, 0 ,0, false);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->TextField('vpr_'. $spremenljivke['id'], 30*$expand_width, 5, array('multiline'=>true,'strokeColor'=>'dkGray'));
$this->pdf->TextBox(50*$expand_width,LINE_BREAK);
$this->pdf->Ln(LINE_BREAK);
}
break;
case 17: //ranking
// iz baze preberemo vse moznosti
$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
// če imamo vnose, pogledamo kaj je odgovoril uporabnik
if ($this->getUserId())
{
$sqlUserAnswer = sisplet_query("SELECT vrstni_red FROM srv_data_rating WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$rowAnswers = mysqli_fetch_assoc($sqlUserAnswer);
}
//dodamo eno celico da zamaknemo malo
$this->pdf->Cell(2, 5, '');
$y=$this->pdf->GetY();
$x=$this->pdf->GetX();
$stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
//stetje stevila vrstic
$stetje_vrstic = $this->pdf->getNumLines($stringTitle, 90*$expand_width);
$y=$y+1;
$this->pdf->MultiCell(90*$expand_width, 1, $stringTitle,1,'L',0,0,$x,$y);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(8, 6, $rowAnswers['vrstni_red'],1,'L',0,0,$x+100*$expand_width,$y);
$this->pdf->SetTextColor(0,0,0);
$stevec=1;
while($stevec<$stetje_vrstic)
{
$this->pdf->Ln(LINE_BREAK);
$stevec++;
}
$this->pdf->Ln(LINE_BREAK);
}
break;
case 18: //vsota
$sum = 0;
// iz baze preberemo vse moznosti
$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
// če imamo vnose, pogledamo kaj je odgovoril uporabnik
if ($this->getUserId())
{
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$rowAnswers = mysqli_fetch_assoc($sqlUserAnswer);
}
//dodamo eno celico da zamaknemo malo
$this->pdf->Cell(2, 5, '');
$y=$this->pdf->GetY();
$x=$this->pdf->GetX();
$stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
//stetje stevila vrstic
$stetje_vrstic = $this->pdf->getNumLines($stringTitle, 90*$expand_width);
$y=$y+1;
$this->pdf->MultiCell(60*$expand_width, 1, $stringTitle,0,'R',0,0,$x,$y);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(20*$expand_width, 6, $rowAnswers['text'],1,'L',0,0,$x+65*$expand_width,$y);
$this->pdf->SetTextColor(0,0,0);
$sum += (int)$rowAnswers['text'];
$stevec=1;
while($stevec<$stetje_vrstic)
{
$this->pdf->Ln(LINE_BREAK);
$stevec++;
}
$this->pdf->Ln(LINE_BREAK);
}
//izris crte
$this->currentStyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(128, 128, 128));
$cy = $this->pdf->getY()+2;
$this->pdf->Line(15, $cy , 110*$expand_width, $cy , $this->currentStyle);
//izris vsote
$y=$y+10;
$this->pdf->MultiCell(60*$expand_width, 1, $spremenljivke['vsota'],0,'R',0,0,$x,$y);
$this->pdf->MultiCell(20*$expand_width, 6, $sum,1,'L',0,0,$x+65*$expand_width,$y);
//omejitev vsote
if($spremenljivke['vsota_limit'] != 0 && $spremenljivke['vsota_limit'] == $spremenljivke['vsota_min'])
$limit = '('.$spremenljivke['vsota_min'].')';
elseif($spremenljivke['vsota_limit'] != 0 && $spremenljivke['vsota_min'] != 0)
$limit = '(min '.$spremenljivke['vsota_min'].', max '.$spremenljivke['vsota_limit'].')';
elseif($spremenljivke['vsota_limit'] != 0)
$limit = '(max '.$spremenljivke['vsota_limit'].')';
elseif($spremenljivke['vsota_min'] != 0)
$limit = '(min '.$spremenljivke['vsota_min'].')';
if($limit != ''){
$this->pdf->SetTextColor(255, 0, 0);
$this->pdf->MultiCell(50*$expand_width, 6, $limit,0,'L',0,0,$x+86,$y);
}
$this->pdf->Ln(LINE_BREAK);
break;
case 9: //SN-imena
if ( $this->getUserId() ){
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
while($userAnswer = mysqli_fetch_array($sqlUserAnswer)){
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(80, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 1, 0 ,0, false);
$this->pdf->MultiCell(80, 1, '', 0, 'L', 0, 1, 0 ,0, false);
$this->pdf->SetTextColor(0,0,0);
}
}
else{
$this->pdf->Ln(LINE_BREAK);
}
break;
case 10: // SN - social support dve koloni po 5 celic
$this->pdf->TabledTextBox(2,5);
break;
case 11: // SN - podvprasanje (podobno kot mgrid - z radio gumbki, 5 ponovitev)
case 14: // AW - podvprasanje
$sqlVrednosti = sisplet_query("SELECT naslov, naslov2, variable FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowHeaders = array();
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
$rowHeaders[] =$stringCell_title;
}
$this->pdf->TabledTextBox(5,sizeof($rowHeaders)+1, array('rowHeaders' => $rowHeaders, 'type' => 'radio', 'vLine' => 0, 'hLine' => 0, 'headerBox' => 1, 'spaceWidth' => 2));
break;
case 12: // SN - number
case 15: // AW - number
$this->pdf->TabledTextBox(5,$spremenljivke['size']+1, array('type' => 'box', 'vLine' => 0, 'hLine' => 0, 'headerBox' => 1, 'spaceWidth' => 2));
break;
case 13: // SN - povezave
$this->pdf->TabledTextBox(5,5, array('type' => 'povezave', 'vLine' => 0, 'hLine' => 0, 'headerBox' => 1, 'spaceWidth' => 2));
break;
case 27:
//error_log("Heatmap @outputSpremenljivke");
#spremenljivke##############################
global $site_url;
global $site_path;
global $lang;
$usr_id = $this->getUserId();
$spr_id = $spremenljivke['id'];
$landscapeBgImgWidthMm = 140; //predefinirana sirina slike v mm za pdf dokument, ce je ta lezeca
$portraitBgImgWidthMm = 100; //predefinirana sirina slike v mm za pdf dokument, ce je ta pokoncna
#spremenljivke##############################konec
#pridobitev informacij o sliki in klikih iz baze ###################################################
$data4BgImage = sisplet_query("SELECT params from srv_spremenljivka WHERE id = $spr_id");
$rowBgImageHtml = mysqli_fetch_assoc($data4BgImage);
$spremenljivkaParams = new enkaParameters($rowBgImageHtml['params']);
$backgroundImgHtml = $spremenljivkaParams->get('hotspot_image');
$heatmap_show_counter_clicks = ($spremenljivkaParams->get('heatmap_show_counter_clicks') ? $spremenljivkaParams->get('heatmap_show_counter_clicks') : 0); //za prikazovanje/skrivanje stevca klikov
$heatmap_show_clicks = ($spremenljivkaParams->get('heatmap_show_clicks') ? $spremenljivkaParams->get('heatmap_show_clicks') : 0); //za prikazovanje/skrivanje klikov
$heatmap_num_clicks = ($spremenljivkaParams->get('heatmap_num_clicks') ? $spremenljivkaParams->get('heatmap_num_clicks') : 1); //stevilo moznih klikov
$heatmap_click_color = ($spremenljivkaParams->get('heatmap_click_color') ? $spremenljivkaParams->get('heatmap_click_color') : "");
$heatmap_click_size = ($spremenljivkaParams->get('heatmap_click_size') ? $spremenljivkaParams->get('heatmap_click_size') : 5);
$heatmap_click_shape = ($spremenljivkaParams->get('heatmap_click_shape') ? $spremenljivkaParams->get('heatmap_click_shape') : 1);
#pridobitev informacij o sliki in klikih iz baze ###################################################konec
#pridobitev slike za ozadje##############################################################
$position = strpos($backgroundImgHtml, 'src="');
$backgroundImg = substr($backgroundImgHtml, $position+5);
$position = strpos($backgroundImg, '"');
$backgroundImg = str_replace(substr($backgroundImg, $position),"",$backgroundImg);
$bgImageType = substr($backgroundImg, -3); //koncnica slike, tip slike
//$bgImageType = 'png';
//error_log($bgImageType);
#pridobitev slike za ozadje##############################################################konec
#pridobitev dimenzij slike za ozadje#####################################################
//realna velikost slike pobrana iz datoteke - ni v redu, ker je potrebno dobiti dimenzije, ki jih je nastavil uporabnik
$bgImgSize = getimagesize($backgroundImg);
//error_log("Width: $bgImgSize[0]");
//error_log("Height: $bgImgSize[1]");
$bgImgWidthPx = $bgImgSize[0];
$bgImgHeightPx = $bgImgSize[1];
//realna velikost slike pobrana iz datoteke - konec
//visina slike, ki jo je nastavil uporabnik
$positionImgHeight = strpos($backgroundImgHtml, 'height:');
$ImgHeight = substr($backgroundImgHtml, $positionImgHeight+7);
$positionImgheightPx = strpos($ImgHeight, 'px');
$ImgHeight = str_replace(substr($ImgHeight, $positionImgheightPx),"",$ImgHeight);
//error_log($ImgHeight);
//visina slike, ki jo je nastavil uporabnik - konec
//sirina slike, ki jo je nastavil uporabnik
$positionImgWidth = strpos($backgroundImgHtml, 'width:');
$ImgWidth = substr($backgroundImgHtml, $positionImgWidth+6);
$positionImgWidthPx = strpos($ImgWidth, 'px');
$ImgWidth = str_replace(substr($ImgWidth, $positionImgWidthPx),"",$ImgWidth);
//error_log($ImgWidth);
//sirina slike, ki jo je nastavil uporabnik - konec
#pridobitev dimenzij slike za ozadje#####################################################konec
#ureditev ustrezne velikosti slike za ozadje##############################################################
$bgImgWidthInMm = ($ImgWidth > $ImgHeight ? $landscapeBgImgWidthMm : $portraitBgImgWidthMm);
$bgImgHeightInMm = ($bgImgWidthInMm / $ImgWidth) * $ImgHeight;
//error_log("bgImgHeightInMm: $bgImgHeightInMm");
#ureditev ustrezne velikosti slike za ozadje##############################################################konec
#pridobitev koordinat klikanih tock za uporabnika $usr_id#################################################
$data4Coords = sisplet_query("SELECT lat, lng from srv_data_map WHERE usr_id = $usr_id AND spr_id = $spr_id");
$i = 0;
//error_log($spr_id);
#pridobitev koordinat klikanih tock za uporabnika $usr_id#################################################konec
#izris tock na sliko######################################################################################
//if($heatmap_show_clicks == 1){
define('UPLOAD_DIR', $site_path.'admin/exportclases/temp/');
$imageFinal = $this->pdf->prepareHeatmapImage($data4Coords, $backgroundImg, $lat, $lng, $ImgWidth, $ImgHeight, $heatmap_click_size, $heatmap_click_color, $heatmap_click_shape, $spr_id, $bgImageType, UPLOAD_DIR);
//}
#izris tock na sliko######################################################################################konec
//izris slike v pdf
//$this->pdf->Image($imageFinal, $x='', $y='', $w=$bgImgWidthInMm, $h, $type=$bgImageType);
$this->pdf->Image($imageFinal, $x='', $y='', $w=$bgImgWidthInMm, $bgImgHeightInMm, $type='png');
//izbris slike iz mape streznika
//if($heatmap_show_clicks == 1){
unlink($imageFinal);
//}
#izris stevca klikov######################################################################################
if($heatmap_show_counter_clicks){
//$this->pdf->Write(10, $lang['srv_vprasanje_heatmap_num_clicks'].': '.mysqli_num_rows($data4Coords).'/'.$heatmap_num_clicks);
$y=$this->pdf->GetY();
$this->pdf->setY($bgImgHeightInMm+$y);
$this->pdf->Write(10, $lang['srv_vprasanje_heatmap_num_clicks'].': ');
$this->pdf->Ln(LINE_BREAK);
$this->pdf->Write(10, mysqli_num_rows($data4Coords).'/'.$heatmap_num_clicks);
}
#izris stevca klikov######################################################################################konec
$this->pdf->Ln(LINE_BREAK);
break;
}
}
function outputVprasanjeValues($spremenljivke)
{
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
// 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);
$naslov = $this->dataPiping($spremenljivke['naslov']);
$linecount_vprasanja = $this->getCellHeight($naslov, 90);
$this->currentHeight = $linecount_vprasanja;
if($pozicija_vprasanja + $linecount_vprasanja > 240/$expand_width)
{
$this->pdf->AddPage();
}
//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']);
}
}
// stevilcenje vprasanj
$numberingText = ($this->numbering == 1) ? $spremenljivke['variable'].' - ' : '';
$this->pdf->setFont('','B',$this->font);
$this->pdf->MultiCell(80*$expand_width , 1, $numberingText . $this->encodeText($naslov),0,'L',0,0,0,0);
$this->pdf->setFont('','',$this->font);
}
function outputSpremenljivkeValues($spremenljivke){
global $site_url;
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
// Ce je spremenljivka v loopu
$loop_id = $this->loop_id == null ? " IS NULL" : " = '".$this->loop_id."'";
switch ( $spremenljivke['tip'] )
{
case 1: //radio
case 2: //check
case 3: //select -> radio
// če imamo vnose, pogledamo kaj je odgovoril uporabnik
$sqlUserAnswerString = "SELECT vre_id FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spremenljivke[id]' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id";
$sqlUserAnswer = sisplet_query($sqlUserAnswerString);
while ($rowAnswers = mysqli_fetch_assoc($sqlUserAnswer))
$userAnswer[$rowAnswers['vre_id']] = $rowAnswers['vre_id'];
// 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");
$resultString = '';
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
//izpisemo samo izbrane vrednosti
if( isset($userAnswer[$rowVrednost['id']]) ){
$stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
//stetje stevila vrstic
$stetje_vrstic = $this->pdf->getNumLines($stringTitle, 180*$expand_width);
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$resultString .= ' '.$stringTitle.$_txt.',';
}
}
$resultString = substr($resultString, 0, -1);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(90*$expand_width, 1, $resultString,0,'L',0,0,95*$expand_width,0);
$this->pdf->SetTextColor(0,0,0);
$linecount_vprasanja = $this->getCellHeight($resultString, 90*$expand_width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
$this->pdf->setY($this->pdf->getY() + $this->currentHeight);
//$this->pdf->Ln(LINE_BREAK);
break;
case 6: //multigrid
case 16:// multicheckbox
//izris dvojnega multigrida
if($spremenljivke['enota'] == 3){
$this->displayDoubleGridValues($spremenljivke);
break;
}
$sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'");
$rowVrstic = mysqli_fetch_row($sqlVrstic);
$visina = round(($rowVrstic[0]+2) * 8);
$defw_fc = 85*$expand_width;
$w_oc = 1;
$halfWidth = $w_oc/2;
$this->pdf->setX(15);
$sqlVrednosti = sisplet_query("SELECT *,id, naslov, naslov2, variable FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$skipRow = false;
// Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici
if($this->skipEmptySub == 1){
$skipRow = true;
if($spremenljivke['tip'] == 6)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
if(mysqli_num_rows($sqlUserAnswer) > 0)
$skipRow = false;
}
if($skipRow == false){
$this->currentHeight = 0;
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
/*Zascita pred prepisovanjem na novo stran za bocne parametre*/
$pozicija_boka = $this->pdf->getY();
$pozicija_bokaX = $this->pdf->getX();
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$stringCell_title .= $_txt.':';
//$linecount_vprasanja = $this->pdf->getNumLines($stringCell_title, $defw_fc);
//$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
$this->currentHeight = ($this->getCellHeight($stringCell_title, $defw_fc) > $this->currentHeight ? $this->getCellHeight($stringCell_title, $defw_fc) : $this->currentHeight);
if($pozicija_boka + ($this->currentHeight/**4.7*/) > 250/$expand_width)
{
$this->pdf->AddPage();
$pozicija_boka = $this->pdf->getY();
}
/*Izpis bočnega stolpca*/
$this->pdf->MultiCell($defw_fc, 1,$stringCell_title,0,'R',0,1,0,0,true,0);
$startY = $this->pdf->getY();
$endY = $this->pdf->getY();
$startX = $this->pdf->getX();
$sqlVsehVrednsti = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY 'vrstni_red'");
$startX = $startX + $defw_fc;
$startY = $pozicija_boka;
//izpis rezultatov
$resultString = '';
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// poiščemo kaj je odgovoril uporabnik:
if($spremenljivke['tip']==16)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' AND loop_id $loop_id");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." where spr_id = '".$rowVrednost['spr_id']."' and usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$this->pdf->SetXY($startX + $w_oc , ($startY+$endY-7) /2);
if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){
$resultString .= ' '.$this->encodeText($rowVsehVrednosti['naslov']).',';
}
}
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$resultString = substr($resultString, 0, -1);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(100*$expand_width, 1, $resultString,0,'L',0,0,0,0);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
/*$linecount_vprasanja = $this->pdf->getNumLines($resultString, 100*$expand_width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;*/
$this->currentHeight = ($this->getCellHeight($stringCell_title, $defw_fc) > $this->currentHeight ? $this->getCellHeight($stringCell_title, $defw_fc) : $this->currentHeight);
$this->pdf->setY($endY);
//$this->pdf->setY($this->pdf->getY() + $this->currentHeight/**4.7*/);
}
}
break;
case 21: //besedilo*
// Posebej ipisemo ce imamo samo en kos besedila brez pripisanega texta
if($spremenljivke['text_kosov'] == 1 && $spremenljivke['text_orientation'] == 0 && $this->type == 0){
$sqlVrednost = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
// imamo upload vprašanje
if ($spremenljivke['upload'] == 1){
# imena datotek
if($userAnswer['text'] != '')
$answer = ''.$site_url.'main/survey/download.php?anketa='.$this->anketa['id'].'&code='.$userAnswer['text'].'';
else
$answer = '';
}
// imamo signature vprašanje
elseif($spremenljivke['signature'] == 1){
$answer = $userAnswer['text'];
// relativna pot
$image = $site_url.'main/survey/uploads/'.$this->getUserId().'_'.$spremenljivke['id'].'_'.$this->anketa['id'].'.png';
$this->pdf->Image($image, $x='', $y='', $w=140, $h, $type='PNG', $link='', $align='N', $resize=true, $dpi=1600, $palign='C', $ismask=false, $imgmask=false, $border=0);
}
else{
$answer = $userAnswer['text'];
}
$this->pdf->SetTextColor(179,0,128);
//$this->pdf->Write(0, $userAnswer['text'], '', 0, 'l', 1, 1);
$this->pdf->MultiCell(180*$expand_width, 1,$this->encodeText($answer),0,'L',0,1,0,0,true,0);
$this->pdf->SetTextColor(0,0,0);
}
else{
$count = $spremenljivke['text_kosov'];
$width = round(170/$count);
$this->currentHeight = 0;
if($spremenljivke['text_orientation'] == 1)
$width -= 20;
if($this->type == 2){
$this->pdf->setX(80);
}
$sqlVrednost = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
for($i=0; $i<$count; $i++){
$rowVrednost = mysqli_fetch_array($sqlVrednost);
if($spremenljivke['text_orientation'] == 1){
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(20, 1,$stringHeader_title.': ',0,'R',0,0,0,0,true,0);
$linecount_vprasanja = $this->pdf->getNumLines($stringHeader_title, 20);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
if ( $this->getUserId() )
{
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
// imamo upload vprašanje
if ($spremenljivke['upload'] == 1){
# imena datotek
if($userAnswer['text'] != '')
$answer = ''.$site_url.'main/survey/download.php?anketa='.$this->anketa['id'].'&code='.$userAnswer['text'].'';
else
$answer = '';
}
else{
$answer = $userAnswer['text'];
}
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell($width, 1, $this->encodeText($answer), 0, 'L', 0, 0, 0 ,0, true, 0);
$this->pdf->SetTextColor(0,0,0);
$linecount_vprasanja = $this->pdf->getNumLines($answer, $width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
else
{
$this->pdf->TextBoxes($width,18);
}
//$this->pdf->setX($this->pdf->getX() + (10/$count)+$width);
}
if($spremenljivke['text_orientation'] == 2){
mysqli_data_seek($sqlVrednost, 0);
$this->pdf->setY($this->pdf->getY() + 20);
for($i=0; $i<$count; $i++){
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell($width, 1,$stringHeader_title,0,'C',0,0,0,0,true,0);
$this->pdf->setX($this->pdf->getX() + 10/$count);
$linecount_vprasanja = $this->pdf->getNumLines($stringHeader_title, $width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
}
}
$this->pdf->setY($this->pdf->getY() + $this->currentHeight*4.7);
}
break;
case 7: //number
error_log("Number @outputSpremenljivkeValues");
# z enoto na levi
if($spremenljivke['enota'] == 1){
# enota
$sqlVrednost = sisplet_query("SELECT naslov FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(20, 5,$stringHeader_title,0,'R',0,0,0,0,true,0);
# odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(20, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(20, 5, '', 1, 'L', 0, 0, 0 ,0, true);
}
//dodatno polje
if($spremenljivke['size'] == 2){
#enota
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(20, 5,$stringHeader_title,0,'R',0,0,0,0,true,0);
#odgovor
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(20, 5, $this->encodeText($userAnswer['text2']), 1, 'L', 0, 1, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
}
else {
$this->pdf->MultiCell(20, 5, '', 1, 'L', 0, 1, 0 ,0, true);
}
}
else
$this->pdf->Ln(LINE_BREAK);
# z enoto na desni
} else if($spremenljivke['enota'] == 2){
#odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(20, 5, $this->encodeText($userAnswer['text']), 1, 'R', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(20, 5, '', 1, 'R', 0, 0, 0 ,0, true);
}
# enota
$sqlVrednost = sisplet_query("SELECT naslov FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
$this->pdf->MultiCell(20, 5,$stringHeader_title,0,'L',0,0,0,0,true,0);
//dodatno polje
if($spremenljivke['size'] == 2){
#enota
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $this->encodeText($rowVrednost['naslov']);
#odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(20, 5, $this->encodeText($userAnswer['text2']), 1, 'R', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(20, 5, '', 1, 'R', 0, 0, 0 ,0, true);
}
$this->pdf->MultiCell(20, 5,$stringHeader_title,0,'L',0,1,0,0,true,0);
/*
#odgovor
if ( $this->getUserId() ) {
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."';";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$this->pdf->SetTextColor(0,128,0);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text2']), 1, 'L', 0, 1, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
} else {
$this->pdf->MultiCell(30, 5, '', 1, 'L', 0, 1, 0 ,0, true);
}
#enota
$rowVrednost = mysqli_fetch_array($sqlVrednost);
$stringHeader_title = $rowVrednost['naslov'];
$this->pdf->MultiCell(30, 5,$stringHeader_title,0,'L',0,0,0,0,true,0);
*/
} else {
$this->pdf->Ln(LINE_BREAK);
}
}
//brez enote
else{
$this->pdf->setX(20);
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 0, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->MultiCell(30, 5, '', 1, 'L', 0, 0, 0 ,0, true);
}
//dodatno polje
if($spremenljivke['size'] == 2){
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text2 FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->setX($this->pdf->getX() + 5);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text2']), 1, 'L', 0, 1, 0 ,0, true);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->setX($this->pdf->getX() + 5);
$this->pdf->MultiCell(30, 5, '', 1, 'L', 0, 1, 0 ,0, true);
}
}
else
$this->pdf->Ln(LINE_BREAK);
}
/*if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."';";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 1, 0 ,0, false);
}
else
{
$this->pdf->TextField('vpr_'. $spremenljivke['id'], 30, 5, array('multiline'=>true,'strokeColor'=>'dkGray'));
$this->pdf->TextBox(50,LINE_BREAK);
$this->pdf->Ln(LINE_BREAK);
}*/
break;
case 8: //datum
// če imamo odgovor od uporabnika, potem ga izpišemo, čene damo prazen box
if ( $this->getUserId() )
{
$userAnswerString = "SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id;";
$sqlUserAnswer = sisplet_query($userAnswerString);
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(30, 5, $this->encodeText($userAnswer['text']), 1, 'L', 0, 1, 0 ,0, false);
$this->pdf->SetTextColor(0,0,0);
}
else
{
$this->pdf->TextField('vpr_'. $spremenljivke['id'], 30, 5, array('multiline'=>true,'strokeColor'=>'dkGray'));
$this->pdf->TextBox(50,LINE_BREAK);
$this->pdf->Ln(LINE_BREAK);
}
break;
case 17: //ranking
// iz baze preberemo vse moznosti
$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
// če imamo vnose, pogledamo kaj je odgovoril uporabnik
if ($this->getUserId())
{
$sqlUserAnswer = sisplet_query("SELECT vrstni_red FROM srv_data_rating WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$rowAnswers = mysqli_fetch_assoc($sqlUserAnswer);
}
//dodamo eno celico da zamaknemo malo
$this->pdf->Cell(2, 5, '');
$y=$this->pdf->GetY();
$x=65;
$stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
//stetje stevila vrstic
$stetje_vrstic = $this->pdf->getNumLines($stringTitle, 90);
$y=$y+1;
$this->pdf->MultiCell(30, 1, $stringTitle,0,'R',0,0,$x,$y);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(8, 6, $rowAnswers['vrstni_red'],1,'L',0,0,$x+35,$y);
$this->pdf->SetTextColor(0,0,0);
$stevec=1;
while($stevec<$stetje_vrstic)
{
$this->pdf->Ln(LINE_BREAK);
$stevec++;
}
$this->pdf->Ln(LINE_BREAK);
}
break;
case 18: //vsota
$sum = 0;
$this->pdf->setX(15);
// iz baze preberemo vse moznosti
$sqlVrednosti = sisplet_query("SELECT id, naslov, naslov2, variable, other FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
// če imamo vnose, pogledamo kaj je odgovoril uporabnik
if ($this->getUserId())
{
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id=".$spremenljivke['id']." AND usr_id='".$this->getUserId()."' AND vre_id='".$rowVrednost['id']."' AND loop_id $loop_id");
$rowAnswers = mysqli_fetch_assoc($sqlUserAnswer);
}
//dodamo eno celico da zamaknemo malo
$this->pdf->Cell(2, 5, '');
$y=$this->pdf->GetY();
$x=$this->pdf->GetX();
$stringTitle = ($this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) ));
//stetje stevila vrstic
$stetje_vrstic = $this->pdf->getNumLines($stringTitle, 90);
$y=$y+1;
$this->pdf->MultiCell(60, 1, $stringTitle,0,'R',0,0,$x,$y);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(20, 6, $rowAnswers['text'],1,'L',0,0,$x+65,$y);
$this->pdf->SetTextColor(0,0,0);
$sum += (int)$rowAnswers['text'];
$stevec=1;
while($stevec<$stetje_vrstic)
{
$this->pdf->Ln(LINE_BREAK);
$stevec++;
}
$this->pdf->Ln(LINE_BREAK);
}
//izris crte
$this->currentStyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(128, 128, 128));
$cy = $this->pdf->getY()+2;
$this->pdf->Line(15, $cy , 110, $cy , $this->currentStyle);
//izris vsote
$y=$y+10;
$this->pdf->MultiCell(60, 1, $spremenljivke['vsota'],0,'R',0,0,$x,$y);
$this->pdf->MultiCell(20, 6, $sum,1,'L',0,0,$x+65,$y);
//omejitev vsote
if($spremenljivke['vsota_limit'] != 0 && $spremenljivke['vsota_limit'] == $spremenljivke['vsota_min'])
$limit = '('.$spremenljivke['vsota_min'].')';
elseif($spremenljivke['vsota_limit'] != 0 && $spremenljivke['vsota_min'] != 0)
$limit = '(min '.$spremenljivke['vsota_min'].', max '.$spremenljivke['vsota_limit'].')';
elseif($spremenljivke['vsota_limit'] != 0)
$limit = '(max '.$spremenljivke['vsota_limit'].')';
elseif($spremenljivke['vsota_min'] != 0)
$limit = '(min '.$spremenljivke['vsota_min'].')';
if($limit != ''){
$this->pdf->SetTextColor(255, 0, 0);
$this->pdf->MultiCell(50, 6, $limit,0,'L',0,0,$x+86,$y);
}
$this->pdf->Ln(LINE_BREAK);
break;
case 9: //SN-imena
if ( $this->getUserId() ){
$answer = '';
$sqlUserAnswer = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND usr_id='".$this->getUserId()."' AND loop_id $loop_id");
while($userAnswer = mysqli_fetch_array($sqlUserAnswer)){
$answer .= $this->encodeText($userAnswer['text']).', ';
}
$answer = substr($answer, 0, -2);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(90*$expand_width, 1, $answer,0,'L',0,0,95*$expand_width,0);
$this->pdf->SetTextColor(0,0,0);
$linecount_vprasanja = $this->pdf->getNumLines($answer, 90*$expand_width);
$this->currentHeight = ($linecount_vprasanja > $this->currentHeight) ? $linecount_vprasanja : $this->currentHeight;
$this->pdf->setY($this->pdf->getY() + $this->currentHeight*4.7);
}
else{
$this->pdf->Ln(LINE_BREAK);
}
break;
case 27:
error_log("Heatmap @outputSpremenljivkeValues");
break;
}
}
//izris kratkega nacina doubleGrid
function displayDoubleGridValues($spremenljivke) {
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
$sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'");
$rowVrstic = mysqli_fetch_row($sqlVrstic);
$visina = round(($rowVrstic[0]+2) * 8);
$defw_fc = 85;
$w_oc = 1;
$halfWidth = $w_oc/2;
//naslov prvega dela grida
$this->pdf->MultiCell(180, 1, $this->encodeText($spremenljivke['grid_subtitle1']),0,'C',0,1,0,0);
$sqlVrednosti = sisplet_query("SELECT *,id, naslov, naslov2, variable FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
/*Zascita pred prepisovanjem na novo stran za bocne parametre*/
$pozicija_boka = $this->pdf->getY();
$pozicija_bokaX = $this->pdf->getX();
//$linecount_boka = $this->pdf->getNumLines($stringCell_title, $defw_fc);
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."'");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$stringCell_title .= $_txt.':';
if($pozicija_boka + $visina > 250/$expand_width)
{
$this->pdf->AddPage();
$pozicija_boka = $this->pdf->getY();
}
/*Izpis bočnega stolpca*/
$this->pdf->MultiCell($defw_fc, 0,$stringCell_title,0,'R',0,1,0,0,true,0);
$startY = $this->pdf->getY();
$endY = $this->pdf->getY();
$startX = $this->pdf->getX();
// print_r($pozicija_boka. " : ". $startY."<br>");
$linecount_boka--;
$sqlVsehVrednsti = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' AND part='1' ORDER BY 'vrstni_red'");
$startX = $startX + $defw_fc;
$startY = $pozicija_boka;
//izpis rezultatov
$resultString = '';
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// poiščemo kaj je odgovoril uporabnik:
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."'");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){
$this->pdf->SetXY($startX + $w_oc , ($startY+$endY-7) /2);
$resultString .= ' '.$this->encodeText($rowVsehVrednosti['naslov']).',';
}
}
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$resultString = substr($resultString, 0, -1);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(180, 1, $resultString,0,'L',0,0,0,0);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$this->pdf->setY($endY);
}
//se drugi del grida
//naslov drugega dela grida
$this->pdf->MultiCell(180, 1, $this->encodeText($spremenljivke['grid_subtitle2']),0,'C',0,1,0,0);
$sqlVrednosti = sisplet_query("SELECT *,id, naslov, naslov2, variable FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
/*Zascita pred prepisovanjem na novo stran za bocne parametre*/
$pozicija_boka = $this->pdf->getY();
$pozicija_bokaX = $this->pdf->getX();
//$linecount_boka = $this->pdf->getNumLines($stringCell_title, $defw_fc);
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."'");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$stringCell_title .= $_txt.':';
if($pozicija_boka + $visina > 250/$expand_width)
{
$this->pdf->AddPage();
$pozicija_boka = $this->pdf->getY();
}
/*Izpis bočnega stolpca*/
$this->pdf->MultiCell($defw_fc, 0,$stringCell_title,0,'R',0,1,0,0,true,0);
$startY = $this->pdf->getY();
$endY = $this->pdf->getY();
$startX = $this->pdf->getX();
// print_r($pozicija_boka. " : ". $startY."<br>");
$linecount_boka--;
$sqlVsehVrednsti = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' AND part='2' ORDER BY 'vrstni_red'");
$startX = $startX + $defw_fc;
$startY = $pozicija_boka;
//izpis rezultatov
$resultString = '';
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// poiščemo kaj je odgovoril uporabnik:
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."'");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
if($rowVsehVrednosti['id'] == $userAnswer['grd_id']){
$this->pdf->SetXY($startX + $w_oc , ($startY+$endY-7) /2);
$resultString .= ' '.$this->encodeText($rowVsehVrednosti['naslov']).',';
}
}
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$resultString = substr($resultString, 0, -1);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell(180, 1, $resultString,0,'L',0,0,0,0);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$this->pdf->setY($endY);
}
}
//izris dolgega nacina doubleGrid
function displayDoubleGrid($spremenljivke) {
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
$sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'");
$rowVrstic = mysqli_fetch_row($sqlVrstic);
$visina = round(($rowVrstic[0]+2) * 6);
$defw_full = 200;
$defw_fc = 24; // sirina prve celice
$defw_max = 35; // max sirina ostalih celic
$sqlStVrednosti = sisplet_query("SELECT count(*) FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY id");
$rowStVrednost = mysqli_fetch_row($sqlStVrednosti);
$kolon = $rowStVrednost[0]+1;
$w_oc = ( $defw_full - $defw_fc ) / $kolon;
if ( $w_oc > $defw_max )
$w_oc = $defw_max;
$countVrednosti=0;
$halfWidth = ($w_oc)/ 2;
//izpis naslovov posameznih delov grida
$this->pdf->MultiCell($defw_fc, LINE_BREAK, '',0,'C',0,0);
$this->pdf->MultiCell(80, LINE_BREAK, $this->encodeText($spremenljivke['grid_subtitle1']),'B','C',0,0);
$this->pdf->MultiCell(80, LINE_BREAK, $this->encodeText($spremenljivke['grid_subtitle2']),'B','C',0,1);
//izpis vmesne crte
$this->pdf->Line($defw_fc+95, $this->pdf->getY()-6, $defw_fc+95, $this->pdf->getY()+$visina);
/*Izpis presledka na začetku*/
$this->pdf->Cell($defw_fc, 0,'');
// izišemo header celice
$sqlVsehVrednsti = sisplet_query("SELECT naslov, variable,vrstni_red FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY part, vrstni_red");
$linecount = 0;
$maxlinecount = 0;
$linecount1 = 0;
$maxlinecount1 = 0;
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// če je naslov null izpišemo variable
$stringHeader_title = $this->encodeText( ( $rowVsehVrednosti['naslov'] ) ? $rowVsehVrednosti['naslov'] : $rowVsehVrednosti['variable'] );
/*Zascita pred prepisovanjem na novo stran za zgornje parametre*/
$pozicija_vrha = $this->pdf->getY();
//$linecount_vrha = $this->pdf->getNumLines($stringHeader_title, $w_oc);
if($pozicija_vrha + $visina > 250/$expand_width)
{
$this->pdf->AddPage();
$this->pdf->Cell($defw_fc, 0,'');
}
/*Izpis zgornje vrstice*/
$this->pdf->MultiCell($w_oc, 1,$stringHeader_title,0,'C',0,0,0,0,true,0);
if($linecount_vrha>$maxlinecount) {$maxlinecount=$linecount_vrha;}
$countVrednosti++;
}
$this->pdf->Ln(1.5 * LINE_BREAK);
$i=0;
while($i<($maxlinecount))
{
$this->pdf->Ln(LINE_BREAK);
$i++;
}
$sqlVrednosti = sisplet_query("SELECT *,id, naslov, naslov2, variable FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
/*Zascita pred prepisovanjem na novo stran za bocne parametre*/
$pozicija_boka = $this->pdf->getY();
$pozicija_bokaX = $this->pdf->getX();
//$linecount_boka = $this->pdf->getNumLines($stringCell_title, $defw_fc);
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."'");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$stringCell_title .= $_txt;
if($pozicija_boka + $visina > 250/$expand_width)
{
$this->pdf->AddPage();
$pozicija_boka = $this->pdf->getY();
}
/*Izpis bočnega stolpca*/
$this->pdf->MultiCell($defw_fc, 0,$stringCell_title,0,'C',0,1,0,0,true,0);
$startY = $this->pdf->getY();
$endY = $this->pdf->getY();
$startX = $this->pdf->getX();
// print_r($pozicija_boka. " : ". $startY."<br>");
$linecount_boka--;
$sqlVsehVrednsti = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$spremenljivke['id']."' ORDER BY part, vrstni_red");
$shtevec=0;
$startX = $startX + $defw_fc;
$startY = $pozicija_boka;
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// poiščemo kaj je odgovoril uporabnik:
if ($this->getGrupa())
{
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowVrednost['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowVrednost['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' ");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
}
$prop['full'] = ($rowVsehVrednosti['id'] == $userAnswer['grd_id']) ? true : false;
$this->pdf->SetXY($startX + $shtevec*$w_oc , ($startY+$endY)/2 - (CHCK_BTN_SIZE+1)/2);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
if($spremenljivke['tip']==6) {
$this->pdf->RadioButton('vpr_'. $rowVrednost['id'], RADIO_BTN_SIZE, $prop);
}
elseif($spremenljivke['tip']==16) {
$this->pdf->CheckBox('vpr_'. $spremenljivke['id'].'_'.$rowVrednost['id'], CHCK_BTN_SIZE, $prop);
}
else{
$this->pdf->setX($this->pdf->getX() - $w_oc/2);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', 8);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
//$this->pdf->TextBoxes($w_oc,LINE_BREAK);
$this->pdf->MultiCell($w_oc-1, LINE_BREAK,$userAnswer['text'],1,'C',0,1,0,0,true,0);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font);
$this->pdf->SetTextColor(0,0,0);
}
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$shtevec++;
}
$this->pdf->setY($endY);
}
}
// Izris mesanega multigrida
function displayGridMultiple($spremenljivke){
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
$sqlVrstic = sisplet_query("SELECT count(*) FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."'");
$rowVrstic = mysqli_fetch_row($sqlVrstic);
$visina = round(($rowVrstic[0]+2) * 8);
$defw_full = 210*$expand_width;
$defw_fc = 24*$expand_width; // sirina prve celice
$defw_max = 35*$expand_width; // max sirina ostalih celic
$kolon = 1;
// Preverjamo ce imamo filter na podskupini grida - SAMO CE NE PRIHAJAMO IZ MAILA!
$tmp_svp_pv = array();
if($this->usr_type == null){
$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, '_'));
}
}
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND m.spr_id=s.id");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if((in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0) && $this->checkSpremenljivka($rowSubGrid['spr_id'], $gridMultiple=true)){
// Ce gre za podskupino multigrid z dropdowni - potem izrisemo samo en stolpec
if($rowSubGrid['tip'] == 6 && $rowSubGrid['enota'] == 2){
$kolon ++;
}
else{
$sqlStVrednosti = sisplet_query("SELECT count(*) FROM srv_grid WHERE spr_id='".$rowSubGrid['spr_id']."' ");
$rowStVrednost = mysqli_fetch_array($sqlStVrednosti);
$kolon += $rowStVrednost['count(*)'];
}
}
}
switch($kolon)
{
case 2:
$defw_fc = 110*$expand_width;
break;
case 3:
$defw_fc = 85*$expand_width;
break;
case 4:
$defw_fc = 60*$expand_width;
break;
case 5:
$defw_fc = 40*$expand_width;
break;
case 6:
$defw_fc = 35*$expand_width;
break;
default:
$defw_fc = 24*$expand_width;
}
$w_oc = ( $defw_full - $defw_fc ) / $kolon;
if ( $w_oc > $defw_max )
$w_oc = $defw_max;
$countVrednosti=0;
$halfWidth = ($w_oc)/ 2;
// Prelom strani ce je kateri od naslovov gridov predolg
$sqlVsehVrednsti = sisplet_query("SELECT g.naslov, g.variable, s.tip, s.enota FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND g.spr_id=m.spr_id AND m.spr_id=s.id ");
$linecount = 0;
$break = false;
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// Pri multigrid dropdownih ne izpisujemo naslova
if($rowVsehVrednosti['tip'] != 6 || $rowVsehVrednosti['enota'] != 2){
// če je naslov null izpišemo variable
$stringHeader_title = $this->encodeText( $rowVsehVrednosti['naslov'] ? $rowVsehVrednosti['naslov'] : $rowVsehVrednosti['variable'] );
/*Zascita pred prepisovanjem na novo stran za zgornje parametre*/
$pozicija_vrha = $this->pdf->getY();
$linecount = $this->pdf->getNumLines($stringHeader_title, $w_oc);
$this->currentHeight = ($linecount > $this->currentHeight) ? $linecount : $this->currentHeight;
if(!$break && $pozicija_vrha + $linecount*4.7 > 250/$expand_width)
{
$this->pdf->AddPage();
$break = true;
}
}
}
/*Izpis presledka na začetku*/
$this->pdf->Cell($defw_fc, 0,'');
// izišemo header celice
$sqlSubGrid = sisplet_query("SELECT m.spr_id, m.vrstni_red, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND m.spr_id=s.id ORDER BY m.vrstni_red");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if((in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0) && $this->checkSpremenljivka($rowSubGrid['spr_id'], $gridMultiple=true)){
$sqlVsehVrednsti = sisplet_query("SELECT naslov, variable FROM srv_grid WHERE spr_id='".$rowSubGrid['spr_id']."' ");
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti))
{
// Pri multigrid dropdownih ne izpisujemo naslova
if($rowSubGrid['tip'] != 6 || $rowSubGrid['enota'] != 2){
// če je naslov null izpišemo variable
$stringHeader_title = $this->encodeText( $rowVsehVrednosti['naslov'] ? $rowVsehVrednosti['naslov'] : $rowVsehVrednosti['variable'] );
/*Izpis zgornje vrstice*/
$this->pdf->MultiCell($w_oc, 1,$stringHeader_title,0,'C',0,0,0,0,true,0);
}
else{
$this->pdf->MultiCell($w_oc, 1, '',0,'C',0,0,0,0,true,0);
break;
}
}
}
}
$this->pdf->setY($this->pdf->getY() + $this->currentHeight*6);
$row_count = 1;
$sqlVrednosti = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$spremenljivke['id']."' ORDER BY vrstni_red");
while ($rowVrednost = mysqli_fetch_assoc($sqlVrednosti))
{
$skipRow = false;
// Ce imamo nastavljeno preskakovanje podvprasanj preverimo ce je kaksen odgovor v vrstici
if($this->skipEmptySub == 1){
$skipRow = true;
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND m.spr_id=s.id ORDER BY m.vrstni_red");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if((in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0) && $this->checkSpremenljivka($rowSubGrid['spr_id'], $gridMultiple=true)){
$sqlSubVar = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$rowSubGrid['spr_id']."' AND vrstni_red='".$rowVrednost['vrstni_red']."' ");
$rowSubVar = mysqli_fetch_array($sqlSubVar);
if($rowSubGrid['tip'] == 6)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."'");
elseif($rowSubGrid['tip'] == 16)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."'");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."'");
if(mysqli_num_rows($sqlUserAnswer) > 0){
$skipRow = false;
break;
}
}
}
}
if($skipRow == false){
// barva vrstice
$row_color = $row_count%2;
$stringCell_title = $this->encodeText(( $rowVrednost['naslov'] ) ? $rowVrednost['naslov'] : ( ( $rowVrednost['naslov2'] ) ? $rowVrednost['naslov2'] : $rowVrednost['variable'] ) );
/*Zascita pred prepisovanjem na novo stran za bocne parametre*/
$pozicija_boka = $this->pdf->getY();
$pozicija_bokaX = $this->pdf->getX();
//$linecount_boka = $this->pdf->getNumLines($stringCell_title, $defw_fc);
// še dodamo textbox če je polj other
$_txt = '';
if ( $rowVrednost['other'] == 1 && $this->getUserId() )
{
$sqlOtherText = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$spremenljivke['id']."' AND vre_id='".$rowVrednost['id']."' AND usr_id='".$this->getUserId()."'");
$row4 = mysqli_fetch_assoc($sqlOtherText);
$_txt = ' '.$row4['text'];
}
$stringCell_title .= $_txt.':';
// Dobimo visino prve (bocne) celice
$height = $this->pdf->getNumLines($stringCell_title, $defw_fc);
// Loop po podskupinah gridov - pri multitext, multinumber in mg dropdown loopamo cez vrstico da dobimo visino najvisje celice
$sqlSubGrid = sisplet_query("SELECT m.spr_id, m.vrstni_red, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND m.spr_id=s.id ORDER BY m.vrstni_red");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if((in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0) && $this->checkSpremenljivka($rowSubGrid['spr_id'], $gridMultiple=true)){
if($rowSubGrid['tip'] == 19 || $rowSubGrid['tip'] == 20){
$sqlSubVar = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$rowSubGrid['spr_id']."' AND vrstni_red='".$rowVrednost['vrstni_red']."' ");
$rowSubVar = mysqli_fetch_array($sqlSubVar);
$sqlVsehVrednsti = sisplet_query("SELECT id FROM srv_grid WHERE spr_id='".$rowSubGrid['spr_id']."' ORDER BY vrstni_red");
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
// poiščemo kaj je odgovoril uporabnik:
if ($this->getGrupa())
{
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' ");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
}
$linecount = $this->pdf->getNumLines($userAnswer['text'], $w_oc);
$height = ($linecount > $height) ? $linecount : $height;
}
}
// MG dropdown
elseif($rowSubGrid['tip'] == 6 && $rowSubGrid['enota'] == 2){
$sqlSubVar = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$rowSubGrid['spr_id']."' AND vrstni_red='".$rowVrednost['vrstni_red']."' ");
$rowSubVar = mysqli_fetch_array($sqlSubVar);
$sqlUserAnswer = sisplet_query("SELECT d.grd_id, g.naslov, g.variable FROM srv_grid g INNER JOIN srv_data_grid".$this->db_table." d ON g.id=d.grd_id AND g.spr_id=d.spr_id WHERE d.spr_id='".$rowSubGrid['spr_id']."' AND d.usr_id='".$this->getUserId()."' AND d.vre_id='".$rowSubVar['id']."'");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$title = $this->encodeText( $userAnswer['naslov'] ? $userAnswer['naslov'] : $userAnswer['variable'] );
$linecount = $this->pdf->getNumLines($title, $w_oc);
$height = ($linecount > $height) ? $linecount : $height;
}
}
}
if($height > 1){
$height = $height*4.5;
}
else{
$height = LINE_BREAK;
}
// Naredimo pb ce prebija katera vrstica
if($pozicija_boka + $height > 250/$expand_width)
{
$this->pdf->AddPage();
$pozicija_boka = $this->pdf->getY();
}
/*Izpis bočnega stolpca*/
$startY = $this->pdf->getY();
$endY = $this->pdf->getY();
$this->pdf->MultiCell($defw_fc, 0,$stringCell_title,0,'C',0,1,0,0,true,0);
$startX = $this->pdf->getX();
// print_r($pozicija_boka. " : ". $startY."<br>");
$linecount_boka--;
$shtevec=0;
$startX = $startX + $defw_fc;
$startY = $pozicija_boka;
$endY = $startY + $height + 3;
// Vsaka druga vrstica ima sivo ozadje
$XX = $this->pdf->getX();
$YY = $this->pdf->getY();
$this->pdf->setXY(15, $startY);
$this->pdf->SetFillColor(242,243,241);
$this->pdf->MultiCell($defw_full, $endY-$startY,'',0,'C',$row_color,1,0,0,true,0);
$this->pdf->SetFillColor(0);
$this->pdf->setXY($XX, $YY);
$row_count++;
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivke['id']."' AND s.id=m.spr_id ORDER BY m.vrstni_red");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if((in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0) && $this->checkSpremenljivka($rowSubGrid['spr_id'], $gridMultiple=true)){
// Dobimo se var_id od trenutne podskupine
$sqlSubVar = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='".$rowSubGrid['spr_id']."' AND vrstni_red='".$rowVrednost['vrstni_red']."' ");
$rowSubVar = mysqli_fetch_array($sqlSubVar);
// dropdown (samo izpisemo naslov odgovora - kot textbox)
if($rowSubGrid['tip'] == 6 && $rowSubGrid['enota'] == 2) {
$sqlUserAnswer = sisplet_query("SELECT d.grd_id, g.naslov, g.variable FROM srv_grid g INNER JOIN srv_data_grid".$this->db_table." d ON g.id=d.grd_id AND g.spr_id=d.spr_id WHERE d.spr_id='".$rowSubGrid['spr_id']."' AND d.usr_id='".$this->getUserId()."' AND d.vre_id='".$rowSubVar['id']."'");
if(mysqli_num_rows($sqlUserAnswer) > 0){
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
$title = $this->encodeText( $userAnswer['naslov'] ? $userAnswer['naslov'] : $userAnswer['variable'] );
}
else
$title = '';
$this->pdf->SetXY($startX + $shtevec*$w_oc , ($startY+$endY)/2 - (CHCK_BTN_SIZE)/2);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$this->pdf->SetXY($this->pdf->getX() - $w_oc/2, $startY + (CHCK_BTN_SIZE/2));
$this->pdf->SetFont(FNT_MAIN_TEXT, '', 8);
$this->pdf->SetTextColor(179,0,128);
$this->pdf->MultiCell($w_oc-1, $height, $title,1,'C',0,0,0,0,true,0);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$shtevec++;
}
else{
$sqlVsehVrednsti = sisplet_query("SELECT id, naslov, variable FROM srv_grid WHERE spr_id='".$rowSubGrid['spr_id']."' ORDER BY vrstni_red");
while ($rowVsehVrednosti = mysqli_fetch_assoc($sqlVsehVrednsti)){
// poiščemo kaj je odgovoril uporabnik:
if ($this->getGrupa())
{
if($rowSubGrid['tip'] == 6)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowSubVar['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."'");
elseif($rowSubGrid['tip'] == 16)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowSubVar['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' ");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowSubVar['spr_id']."' AND usr_id = '".$this->getUserId()."' AND vre_id = '".$rowSubVar['id']."' AND grd_id = '".$rowVsehVrednosti['id']."' ");
$userAnswer = mysqli_fetch_assoc($sqlUserAnswer);
}
$prop['full'] = ($rowVsehVrednosti['id'] == $userAnswer['grd_id']) ? true : false;
$this->pdf->SetXY($startX + $shtevec*$w_oc , ($startY+$endY)/2 - (CHCK_BTN_SIZE)/2);
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
// radio
if($rowSubGrid['tip'] == 6) {
$this->pdf->SetXY($startX + $shtevec*$w_oc + $halfWidth, ($startY+$endY)/2 - (CHCK_BTN_SIZE*3/4));
$this->pdf->RadioButton('vpr_'. $rowSubVar['id'], RADIO_BTN_SIZE, $prop);
}
// checkbox
elseif($rowSubGrid['tip'] == 16) {
$this->pdf->SetXY($startX + $shtevec*$w_oc + $halfWidth, ($startY+$endY)/2 - (CHCK_BTN_SIZE)/2);
$this->pdf->CheckBox('vpr_'. $rowSubGrid['id'].'_'.$rowSubVar['id'], CHCK_BTN_SIZE, $prop);
}
// textbox
else{
$this->pdf->SetXY($this->pdf->getX() - $w_oc/2, $startY + (CHCK_BTN_SIZE/2));
$this->pdf->SetFont(FNT_MAIN_TEXT, '', 8);
//$this->pdf->SetTextColor(0,128,0);
$this->pdf->SetTextColor(179,0,128);
//$this->pdf->TextBoxes($w_oc,LINE_BREAK);
$this->pdf->MultiCell($w_oc-1, $height, $userAnswer['text'],1,'C',0,0,0,0,true,0);
$this->pdf->SetFont(FNT_MAIN_TEXT, '', $this->font);
$this->pdf->SetTextColor(0,0,0);
}
$this->pdf->Cell($halfWidth, 0, '',0,0,1,0);
$shtevec++;
}
}
}
}
$this->pdf->setY($endY);
}
}
}
function encodeText($text)
{ // popravimo sumnike ce je potrebno
$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
$text = str_replace("š","š",$text);
$text = trim($text);
return strip_tags($text);
}
/* Skrajsa niz in doda ... nakoncu
* snippet(phrase,[max length],[phrase tail])
* snippetgreedy(phrase,[max length before next space],[phrase tail])
*
* iz: http://snipplr.com/view/9520/php-substring-without-breaking-words/
*/
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 drawLine()
{
$cy = $this->pdf->getY();
$this->pdf->Line(15, $cy , 195, $cy , $this->currentStyle);
}
function setGrupa($grupa) {$this->grupa = $grupa;}
function getGrupa() {return $this->grupa;}
function setUserId($usrId) {$this->usr_id = $usrId;}
function getUserId() {return ($this->usr_id)?$this->usr_id:false;}
function setDisplayFrontPage($display) {$this->pi['displayFrontPage'] = $display;}
function getDisplayFrontPage() {return ($this->pi['displayFrontPage'] == true || $this->pi['displayFrontPage'] == 1);}
/// To bo najbolše dat v en class
/**
* @desc preveri ali so na trenutni grupi prikazana vprasanja (zaradi branchinga)
*/
function checkGrupa () {
$sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id = '".$this->grupa."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
while ($row = mysqli_fetch_array($sql)) {
if ($this->checkSpremenljivka($row['id']))
return true;
}
return false;
}
/**
* @desc preveri ali je spremenljivka vidna (zaradi branchinga)
*/
function checkSpremenljivka ($spremenljivka, $gridMultiple=false) {
$sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE id = '".$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
// Ce vprasanje ni vidno ali ce uporabnik nima dostopa do vprasanja
if ($row['visible'] == 0 || !( ($this->admin_type <= $row['dostop'] && $this->admin_type>=0) || ($this->admin_type==-1 && $row['dostop']==4) ) )
return false;
// Kalklulacije in kvote ne prikazujemo
if($row['tip'] == 22 || $row['tip'] == 25)
return false;
// Preverjamo ce je vprasanje prazno in ce preskakujemo prazne
if($this->skipEmpty == 1 && !$gridMultiple){
$isEmpty = true;
switch ( $row['tip'] ){
case 1: //radio
case 2: //check
case 3: //select -> radio
$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$row[id]' AND usr_id='".$this->getUserId()."' AND vre_id!='-2'");
if(mysqli_num_rows($sqlUserAnswer) > 0)
$isEmpty = false;
break;
case 6: //multigrid
case 16:// multicheckbox
case 19:// multitext
case 20:// multinumber
if($row['tip'] == 6 && $row['enota'] != 3)
$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->getUserId()."'");
elseif($row['tip'] == 16 || ($row['tip'] == 6 && $row['enota'] == 3))
$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->getUserId()."'");
else
$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$row['id']."' AND usr_id = '".$this->getUserId()."'");
if(mysqli_num_rows($sqlUserAnswer) > 0)
$isEmpty = false;
break;
case 7: //number
case 8: //datum
case 18: //vsota
case 21: //besedilo*
$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='".$row['id']."' AND usr_id='".$this->getUserId()."'");
if(mysqli_num_rows($sqlUserAnswer) > 0)
$isEmpty = false;
break;
case 17: //ranking
$sqlUserAnswer = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id=".$row['id']." AND usr_id='".$this->getUserId()."'");
if(mysqli_num_rows($sqlUserAnswer) > 0)
$isEmpty = false;
break;
case 24: //mesan multigrid
// loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivka."' AND m.spr_id=s.id");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if($rowSubGrid['tip'] == 6)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_grid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."'");
elseif($rowSubGrid['tip'] == 16)
$sqlUserAnswer = sisplet_query("SELECT grd_id FROM srv_data_checkgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."'");
else
$sqlUserAnswer = sisplet_query("SELECT grd_id, text FROM srv_data_textgrid".$this->db_table." WHERE spr_id = '".$rowSubGrid['spr_id']."' AND usr_id = '".$this->getUserId()."'");
if(mysqli_num_rows($sqlUserAnswer) > 0){
$isEmpty = false;
break;
}
}
break;
case 5: //nagovor
// Ce je nagovor v loopu, ga prikazemo
if($this->loop_id != null)
$isEmpty = false;
break;
default:
$isEmpty = false;
break;
}
if($isEmpty == true){
return false;
}
}
return true;
}
/**
* @desc preveri ali se elementi v podanem IFu prikazejo ali ne
*/
function checkIf ($if) {
if ($if == 0) return true;
// preverimo po strukturi navzgor
$sql = sisplet_query("SELECT * FROM srv_branching WHERE element_if = '".$if."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
if (!$this->checkIf($row['parent'])) return false;
// ce je IF oznacen kot blok, potem se vedno prikaze
$sql = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
if ($row['tip'] == 1) return true;
$eval = "if (";
$sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id = '$if' ORDER BY vrstni_red ASC");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$i = 0;
// zgeneriramo pogoje z oklepaji, ki jih potem spustimo skozi eval
while ($row = mysqli_fetch_array($sql)) {
if ($i++ != 0)
if ($row['conjunction'] == 0)
$eval .= ' && ';
else
$eval .= ' || ';
if ($row['negation'] == 1)
$eval .= ' ! ';
for ($i=1; $i<=$row['left_bracket']; $i++)
$eval .= ' ( ';
if ($this->checkCondition($row[id]))
$eval .= ' true ';
else
$eval .= ' false ';
for ($i=1; $i<=$row['right_bracket']; $i++)
$eval .= ' ) ';
}
$eval .= ") return true; else return false; ";
// ne glih best practice, ampak takle mamo...
return eval($eval);
}
/**
* @desc preveri podani condition
*/
function checkCondition ($condition) {
$sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
// obicne spremenljivke
if ($row['spr_id'] > 0) {
$sql2 = sisplet_query("SELECT * FROM srv_spremenljivka WHERE id = '$row[spr_id]'");
$row2 = mysqli_fetch_array($sql2);
// radio, checkbox, dropdown in multigrid
if ($row2['tip'] <= 3 || $row2['tip'] == 6) {
// obicne spremenljivke
if ($row['vre_id'] == 0) {
$sql3 = sisplet_query("SELECT * FROM srv_condition_vre c, srv_data_vrednost v
WHERE c.cond_id='$condition' AND c.vre_id=v.vre_id
AND v.spr_id='$row[spr_id]' AND usr_id='".$this->getUserId()."'");
if ($row['operator'] == 0 && mysqli_num_rows($sql3) == 0)
return false;
elseif ($row['operator'] == 1 && mysqli_num_rows($sql3) > 0)
return false;
// multigrid
} elseif ($row['vre_id'] > 0) {
$sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_grid d
WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
AND c.grd_id=d.grd_id AND d.usr_id='".$this->getUserId()."'");
if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0)
return false;
elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0)
return false;
}
// number in text
} else {
$sql3 = sisplet_query("SELECT * FROM srv_data_text".$this->db_table." WHERE spr_id='$row[spr_id]' AND usr_id='".$this->getUserId()."'");
if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
$row3 = mysqli_fetch_array($sql3);
if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
return false;
elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
return false;
elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
return false;
elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
return false;
elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
return false;
elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
return false;
}
// recnum
} elseif ($row['spr_id'] == -1) {
$sqlu = sisplet_query("SELECT * FROM srv_user WHERE id = '".$this->getUserId()."'");
$rowu = mysqli_fetch_array($sqlu);
if (!($rowu['recnum'] % $row['modul'] == $row['ostanek']))
return false;
}
return true;
}
/**
* @desc poisce naslednjo stran - grupo, 0 pomeni konec
*/
function findNextGrupa() {
//vrstni red trenutne grupe
if ($this->grupa > 0) {
$sql = sisplet_query("SELECT * FROM srv_grupa WHERE id = '".$this->grupa."'");
$row = mysqli_fetch_array($sql);
$vrstni_red = $row['vrstni_red'];
} else {
$vrstni_red = 0;
}
$sql = sisplet_query("SELECT * FROM srv_grupa WHERE ank_id='".$this->anketa['id']."' AND vrstni_red>'".$vrstni_red."' ORDER BY vrstni_red ASC LIMIT 1");
// naslednja stran
if (mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_array($sql);
return $row['id'];
}
// konec
else {
return 0;
}
}
/**
* poisce, ce ima podani element parenta, ki je loop
*
*/
function find_parent_loop ($element_spr, $element_if=0) {
$sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='".$this->anketa['id']."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
if ($row['parent'] == 0) return 0;
$sql = sisplet_query("SELECT id FROM srv_if WHERE id = '$row[parent]' AND tip = '2'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
if (mysqli_num_rows($sql) > 0)
return $row['parent'];
else
return $this->find_parent_loop(0, $row['parent']);
}
/**
* poisce naslednjo vre_id v loopu
*
*/
function findNextLoopId ($if_id=0) {
if ($if_id == 0) {
$sql = sisplet_query("SELECT * FROM srv_loop_data WHERE id='$this->loop_id'");
$row = mysqli_fetch_array($sql);
$if_id = $row['if_id'];
$loop_id = $this->loop_id;
} else
$loop_id = 0;
$sql = sisplet_query("SELECT * FROM srv_loop WHERE if_id = '$if_id'");
$row = mysqli_fetch_array($sql);
$spr_id = $row['spr_id'];
$max = $row['max'];
$spr = Cache::srv_spremenljivka($spr_id);
if ($spr['tip'] == 2 || $spr['tip'] == 3 || $spr['tip'] == 9) {
$data_vrednost = array();
if($spr['tip'] == 9)
$sql1 = sisplet_query("SELECT vre_id FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->getUserId()."'");
else
$sql1 = sisplet_query("SELECT vre_id FROM srv_data_vrednost".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->getUserId()."'");
while ($row1 = mysqli_fetch_array($sql1)) {
$data_vrednost[$row1['vre_id']] = 1;
}
$vre_id = '';
$i = 1;
//$sql = sisplet_query("SELECT * FROM srv_loop_vre WHERE if_id='$if_id'");
$sql = sisplet_query("SELECT * FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC");
while ($row = mysqli_fetch_array($sql)) {
if ($row['tip'] == 0) { // izbran
if ( isset($data_vrednost[$row['vre_id']]) ) {
$vre_id .= ', '.$row['vre_id'];
$i++;
}
} elseif ($row['tip'] == 1) { // ni izbran
if ( !isset($data_vrednost[$row['vre_id']]) ) {
$vre_id .= ', '.$row['vre_id'];
$i++;
}
} elseif ($row['tip'] == 2) { // vedno
$vre_id .= ', '.$row['vre_id'];
$i++;
} // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze
if ($i > $max && $max>0) break;
}
$vre_id = substr($vre_id, 2);
if ($vre_id == '') return null;
$sql = sisplet_query("SELECT l.* FROM srv_loop_data l, srv_vrednost v WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id) AND l.vre_id=v.id ORDER BY l.id ASC");
if (!$sql) { echo 'err56545'.mysqli_error($GLOBALS['connect_db']); die();}
$row = mysqli_fetch_array($sql);
if (mysqli_num_rows($sql) > 0)
return $row['id'];
else
return null;
// number
} elseif ($spr['tip'] == 7) {
$sql1 = sisplet_query("SELECT text FROM srv_data_text".$this->db_table." WHERE spr_id='$spr_id' AND usr_id='".$this->getUserId()."'");
$row1 = mysqli_fetch_array($sql1);
$num = (int)$row1['text'];
$sql2 = sisplet_query("SELECT * FROM srv_loop_data WHERE if_id='$if_id' AND id <= '$loop_id'");
if (mysqli_num_rows($sql2) >= $num || (mysqli_num_rows($sql2) >= $max && $max>0))
return null;
$sql = sisplet_query("SELECT * FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id'");
$row = mysqli_fetch_array($sql);
if (mysqli_num_rows($sql) > 0)
return $row['id'];
else
return null;
}
}
/**
* @desc V podanem stringu poisce spremenljivke in jih spajpa z vrednostmi
*/
function dataPiping ($text) {
Common::getInstance()->Init($this->anketa['id']);
return Common::getInstance()->dataPiping($text, $this->usr_id, $this->loop_id);
}
function displayIf($if){
global $lang;
// razsiritev ce imamo landscape postavitev
$expand_width = $this->landscape == 1 ? 1.5 : 1;
$sql_if = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'");
$row_if = mysqli_fetch_array($sql_if);
// Blok
if($row_if['tip'] == 1)
$output = strtoupper($lang['srv_block']).' ';
// Loop
elseif($row_if['tip'] == 2)
$output = strtoupper($lang['srv_loop']).' ';
// IF
else
$output = 'IF ';
$sql_if = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'");
$row_if = mysqli_fetch_array($sql_if);
$output .= '('.$row_if['number'].') ';
$sql = Cache::srv_condition($if);
$bracket = 0;
$i = 0;
while ($row = mysqli_fetch_array($sql)) {
if ($i++ != 0)
if ($row['conjunction'] == 0)
$output .= ' and ';
else
$output .= ' or ';
if ($row['negation'] == 1)
$output .= ' NOT ';
for ($i=1; $i<=$row['left_bracket']; $i++)
$output .= ' ( ';
// obicajne spremenljivke
if ($row['spr_id'] > 0) {
$row2 = Cache::srv_spremenljivka($row['spr_id']);
// obicne spremenljivke
if ($row['vre_id'] == 0) {
$row1 = Cache::srv_spremenljivka($row['spr_id']);
// multigrid
} elseif ($row['vre_id'] > 0) {
$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE id = '$row[vre_id]'");
$row1 = mysqli_fetch_array($sql1);
} else
$row1 = null;
$output .= $row1['variable'];
// radio, checkbox, dropdown in multigrid
if (($row2['tip'] <= 3 || $row2['tip'] == 6) && ($row['spr_id'] || $row['vre_id'])) {
if ($row['operator'] == 0)
$output .= ' = ';
else
$output .= ' != ';
$output .= '[';
// obicne spremenljivke
if ($row['vre_id'] == 0) {
$sql2 = sisplet_query("SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id");
$j = 0;
while ($row2 = mysqli_fetch_array($sql2)) {
if ($j++ != 0) $output .= ', ';
$output .= $row2['variable'];
}
// multigrid
} elseif ($row['vre_id'] > 0) {
$sql2 = sisplet_query("SELECT g.* FROM srv_condition_grid c, srv_grid g WHERE c.cond_id='$row[id]' AND c.grd_id=g.id AND g.spr_id='$row[spr_id]'");
$j = 0;
while ($row2 = mysqli_fetch_array($sql2)) {
if ($j++ != 0) $output .= ', ';
$output .= $row2['variable'];
}
}
$output .= ']';
// textbox in nubmer mata drugacne pogoje in opcije
} elseif ($row2['tip'] == 4 || $row2['tip'] == 21 || $row2['tip'] == 7 || $row2['tip'] == 22) {
if ($row['operator'] == 0)
$output .= ' = ';
elseif ($row['operator'] == 1)
$output .= ' <> ';
elseif ($row['operator'] == 2)
$output .= ' < ';
elseif ($row['operator'] == 3)
$output .= ' <= ';
elseif ($row['operator'] == 4)
$output .= ' > ';
elseif ($row['operator'] == 5)
$output .= ' >= ';
$output .= '\''.$row['text'].'\'';
}
// recnum
} elseif ($row['spr_id'] == -1) {
$output .= 'mod(recnum, '.$row['modul'].') = '.$row['ostanek'];
}
for ($i=1; $i<=$row['right_bracket']; $i++)
$output .= ' ) ';
}
if ($row_if['label'] != '') {
$output .= ' (';
$output .= ' '.$row_if['label'].' ';
$output .= ') ';
}
$this->pdf->SetTextColor(0,0,150);
$this->pdf->setFont('','B',$this->font);
$this->pdf->MultiCell(90*$expand_width, 1, $this->encodeText($output),0,'L',0,1,0,0);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->setFont('','',$this->font);
}
function outputUser()
{
$sqlGrupeString = "SELECT id FROM srv_grupa WHERE ank_id='".$this->anketa['id']."' ORDER BY vrstni_red";
$sqlGrupe = sisplet_query($sqlGrupeString);
// filtriramo spremenljivke glede na profil - SAMO CE NE PRIHAJAMO IZ MAILA!
$tmp_svp_pv = array();
if($this->usr_type == null){
SurveyVariablesProfiles :: Init($this->anketa['id'], $this->resp_id, true, false);
$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, '_'));
}
}
while ( $rowGrupe = mysqli_fetch_assoc( $sqlGrupe ) )
{ // sprehodmo se skozi grupe ankete
$this->grupa = $rowGrupe['id'];
// Pogledamo prvo spremenljivko v grupi ce je v loopu
$sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
$row = mysqli_fetch_array($sql);
// ce je ima loop za parenta
$if_id = $this->find_parent_loop($row['id']);
if ($if_id > 0){
$sql1 = sisplet_query("SELECT * FROM srv_loop WHERE if_id = '$if_id'");
$row1 = mysqli_fetch_array($sql1);
$this->loop_id = $this->findNextLoopId($row1['if_id']);
$if = Cache::srv_if($if_id);
$loop_title = $if['label'];
// gremo cez vse spremenljivke v trenutnem loopu
while($this->loop_id != null){
// Izrisemo naslov loopa
$this->pdf->SetTextColor(0,0,200);
$this->pdf->SetDrawColor(0,0,200);
$this->pdf->setFont('','B',$this->font);
$this->pdf->Write (0, $this->encodeText($this->dataPiping($loop_title)), '', 0, 'L', 1, 1);
$this->pdf->SetTextColor(0,0,200);
$this->pdf->SetDrawColor(0,0,200);
$this->pdf->setFont('','',$this->font);
$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);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->SetDrawColor(0,0,0);
// Ce imamo kombinirano tabelo pogledamo ce prikazujemo katero od podtabel
if($rowSpremenljivke['tip'] == 24){
$subGrids = array();
$showGridMultiple = false;
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivka."' AND m.spr_id=s.id");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid)){
if(in_array($rowSubGrid['spr_id'],$tmp_svp_pv) || count($tmp_svp_pv) == 0){
$showGridMultiple = true;
break;
}
}
}
// ce je nastavljen profil s filtriranimi spremenljivkami
if(in_array($spremenljivka,$tmp_svp_pv) || count($tmp_svp_pv) == 0 || ($rowSpremenljivke['tip'] == 24 && $showGridMultiple)){
$this->currentHeight = 0;
// NAVADEN IZPIS rezultatov spremenljivke - kratek samo pri radio, checkbox, multiradio, multicheckbox, besedilo
if( $this->type == 0 && in_array($rowSpremenljivke['tip'], array(1,2,3,6,16,21,7,8)) ){
if($rowSpremenljivke['tip'] < 4)
$this->outputVprasanjeValues($rowSpremenljivke);
else
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// KRATEK IZPIS rezultatov spremenljivke
elseif($this->type == 2 && $rowSpremenljivke['tip'] != 24){
$this->outputVprasanjeValues($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// DOLG IZPIS rezultatov
else{
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivke($rowSpremenljivke);
}
$this->pdf->Ln(LINE_BREAK);
}
}
}
$this->loop_id = $this->findNextLoopId();
}
}
// Navadne spremenljivke ki niso v loopu
else{
$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);
$this->pdf->SetTextColor(0,0,0);
$this->pdf->SetDrawColor(0,0,0);
// Ce imamo kombinirano tabelo pogledamo ce prikazujemo katero od podtabel
if($rowSpremenljivke['tip'] == 24){
$subGrids = array();
$showGridMultiple = false;
// Loop po podskupinah gridov
$sqlSubGrid = sisplet_query("SELECT m.spr_id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='".$spremenljivka."' AND m.spr_id=s.id");
while($rowSubGrid = mysqli_fetch_array($sqlSubGrid) || count($tmp_svp_pv) == 0){
if(in_array($rowSubGrid['spr_id'],$tmp_svp_pv)){
$showGridMultiple = true;
break;
}
}
}
// ce je nastavljen profil s filtriranimi spremenljivkami
if(in_array($spremenljivka,$tmp_svp_pv) || count($tmp_svp_pv) == 0 || ($rowSpremenljivke['tip'] == 24 && $showGridMultiple)){
$this->currentHeight = 0;
// NAVADEN IZPIS rezultatov spremenljivke - kratek samo pri radio, checkbox, multiradio, multicheckbox, besedilo
if( $this->type == 0 && in_array($rowSpremenljivke['tip'], array(1,2,3,6,16,21,7,8)) ){
if($rowSpremenljivke['tip'] < 4)
$this->outputVprasanjeValues($rowSpremenljivke);
else
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// KRATEK IZPIS rezultatov spremenljivke
elseif($this->type == 2 && $rowSpremenljivke['tip'] != 24){
$this->outputVprasanjeValues($rowSpremenljivke);
$this->outputSpremenljivkeValues($rowSpremenljivke);
}
// DOLG IZPIS rezultatov
else{
$this->outputVprasanje($rowSpremenljivke);
$this->outputSpremenljivke($rowSpremenljivke);
}
$this->pdf->Ln(LINE_BREAK);
}
}
}
}
}
if($this->pageBreak == 0){
$this->pdf->Ln(LINE_BREAK);
$this->drawLine();
$this->pdf->Ln(LINE_BREAK);
}
}
function getCellHeight($string, $width){
$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;
}
function convertPx2Mm($WidthInMm, $WidthPx, $NPx){
$convertedInMm = ($WidthInMm/$WidthPx)*$NPx;
//error_log("convertedInMm: $convertedInMm");
return $convertedInMm;
}
}
?>
|