-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
902 lines (648 loc) · 28.8 KB
/
functions.php
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
<?php
/// STOP Zakazeniom version. 1.0 ALPHA
/// Copyright (C) by Wiktor Jezioro
/// Distributed in GNU General Public license
///////////////////////////////
///////////////////////////////
/// Searching for relations beetwen inspections
function get_relations_in_inspection ($actual_inspection, $prev_or_next_insp) {
db_connect();
$inspections = mysql_query("SELECT * FROM inspections WHERE id='".$actual_inspection."' AND checking_for_inspection='".$prev_or_next_insp."';");
$inspections_rows = mysql_num_rows($inspections);
if ($inspections_rows > 0) {
return true;
} else {
}
}
//////////////////////////////
/// Count control points in pomieszczenie///
function count_control_points_in_pomieszczenie ($pomieszczenie_id) {
db_connect();
$inspections = mysql_query("SELECT * FROM control_points WHERE pomieszczenie_id='".$pomieszczenie_id."';");
$inspections_rows = mysql_num_rows($inspections);
return $inspections_rows;
}
////////////////////////////////
//// STATISTICS ///////////////
function print_all_inspections_number() {
db_connect();
$inspections = mysql_query("SELECT * FROM inspections;");
$inspections_rows = mysql_num_rows($inspections);
return $inspections_rows;
}
function all_votes ($inspection_type) {
}
function print_statistics($parametr) {
db_connect();
if ($parametr == "all_good") {
$data = mysql_query("SELECT * FROM inspections_data WHERE state=1;");
$data_rows = mysql_num_rows($data);
echo ($data_rows);
}
///////////////////////
if ($parametr == "all_bad") {
$data = mysql_query("SELECT * FROM inspections_data WHERE state=0;");
$data_rows = mysql_num_rows($data);
echo ($data_rows);
}
///////////////////////
if ($parametr == "all_oddzialy") {
$data = mysql_query("SELECT * FROM oddzialy;");
$data_rows = mysql_num_rows($data);
echo ($data_rows);
}
///////////////////////
if ($parametr == "all_pomieszczenia") {
$data = mysql_query("SELECT * FROM pomieszczenia;");
$data_rows = mysql_num_rows($data);
echo ($data_rows);
}
///////////////////////
if ($parametr == "all_cp") {
$data = mysql_query("SELECT * FROM control_points;");
$data_rows = mysql_num_rows($data);
echo ($data_rows);
}
///// PROCENTY //////
///////////////////////
if ($parametr == "all_good_percent") {
$data = mysql_query("SELECT * FROM inspections_data WHERE state=1;");
$data_rows = mysql_num_rows($data);
$dobre_pr = procent_proporcja ($data_rows, all_votes($inspection_type));
return $dobre_pr;
}
////////////////////////
}
//////////////////////////////
function count_votes_in_oddzial ($oddzial_id, $vote_type) {
db_connect();
$vote_type = (int)$vote_type;
$data = mysql_query("SELECT * FROM inspections_data WHERE state='".$vote_type."' AND oddzial_id='".$oddzial_id."';");
$summary = mysql_num_rows($data);
///////////////////////
return (int)$summary;
}
//////////////////////////////
function procent_proporcja ($a, $wszystko) {
////
//// x = (a * 100%) / all
////
////
$x = ($a * 100) / $wszystko;
return $x;
}
///// STATISTICS END ///////////
////////////////////////////////
function oddzial_add($name, $description)
{
db_connect();
$timestamp = time();
mysql_query("INSERT INTO oddzialy ( oddzial_name, oddzial_text, create_date )
VALUES
( '" . $name . "', '" . $description . "', '" . $timestamp . "' );");
return true;
}
/////////////////////////////
function pomieszczenie_add($name, $description, $oddzial_id)
{
db_connect();
$timestamp = time();
mysql_query("INSERT INTO pomieszczenia ( pomieszczenie_name, pomieszczenie_text, pomieszczenie_create_date, oddzial_id )
VALUES
( '" . $name . "', '" . $description . "', '" . $timestamp . "', '" . $oddzial_id . "' );");
return true;
}
///////////////////////////////
function controled_point_add($name, $description, $pomieszczenie_id)
{
db_connect();
$timestamp = time();
mysql_query("INSERT INTO control_points ( cp_name, cp_description, cp_create_date, pomieszczenie_id )
VALUES
( '" . $name . "', '" . $description . "', '" . $timestamp . "', '" . $pomieszczenie_id . "' );");
return true;
}
////////////////////////////////////
function count_pomieszczenia_in_oddzial($oddzial_id)
{
db_connect();
$pomieszczenia = mysql_query("SELECT * FROM pomieszczenia WHERE oddzial_id=" . $oddzial_id . ";");
$pomieszczenia_rows = mysql_num_rows($pomieszczenia);
return $pomieszczenia_rows;
}
///////////////////////////////////
function print_oddzial_list($why_option, $choice_referer, $delete)
{
echo (' <table class="table table-hover table-bordered">
<thead style="background: #A2E7FA; ">
<tr>
<th>Lp.</th>
<th>Nazwa oddziału</th>
<th>Opis oddziału</th>
<th>Data dodania</th>
<th>Ilość pomieszczeń</th>
<th>Ilość punktów kontrolowanych</th>
');
if ($delete == true) {
echo ('
<th>Usuwanie</th>');
}
if ($why_option == true) {
echo ('
<th>Wybór</th>');
}
echo ('
</tr>
</thead>
<tbody>');
$oddzialy = mysql_query("SELECT * FROM oddzialy;");
$i = null;
while ($oddzialy_row = mysql_fetch_array($oddzialy)) {
$i++;
echo (' <tr>');
echo (' <td>' . $i . '</td>');
echo (' <td>' . $oddzialy_row['oddzial_name'] . '</td>');
echo (' <td>' . $oddzialy_row['oddzial_text'] . '</td>');
echo (' <td>' . $oddzialy_row['create_date'] . '</td>');
echo (' <td>' . $pomieszczenia_oddzial . '</td>');
echo (' <td>' . $punkty_kontrolowane_oddzial . '</td>');
if ($delete == true) {
echo (' <td><a href="delete.php?type=oddzial&oddzial_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-danger">Usuń</button></a></td>');
}
if ($why_option == true) {
echo (' <td><a href="' . $choice_referer . '&oddzial_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-warning">Wwbierz</button></a></td>');
}
echo (' </tr>');
}
echo ('
</tbody> </table> ');
}
////////////////////////////
function print_pomieszczenia_list($oddzial_id, $why_option, $choice_referer, $delete, $more_GET_values)
{
echo (' <table class="table table-hover table-bordered">
<thead style="background: #A2E7FA; ">
<tr>
<th>Lp.</th>
<th>Nazwa pomieszczenia</th>
<th>Opis pomieszczenia</th>
<th>Oddział</th>
<th>Ilość punktów kontrolowanych</th>
');
if ($delete == true) {
echo ('
<th>Usuwanie</th>');
}
if ($why_option == true) {
echo ('
<th>Wybór</th>');
}
echo ('
</tr>
</thead>
<tbody>');
$oddzialy = mysql_query("SELECT * FROM pomieszczenia WHERE oddzial_id=" . $oddzial_id . ";");
$oddzial_name = get_object_data("oddzial", "name", $_GET['oddzial_id']);
$i = null;
while ($oddzialy_row = mysql_fetch_array($oddzialy)) {
$i++;
echo (' <tr>');
echo (' <td>' . $i . '</td>');
echo (' <td>' . $oddzialy_row['pomieszczenie_name'] . '</td>');
echo (' <td>' . $oddzialy_row['pomieszczenie_text'] . '</td>');
echo (' <td>' . $oddzial_name . '</td>');
echo (' <td>' . $punkty_kontrolowane_pomieszczenie . '</td>');
if ($delete == true) {
echo (' <td><a href="delete.php?type=pomieszczenie&oddzial_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-danger">Usuń</button></a></td>');
}
if ($why_option == true) {
echo (' <td><a href="' . $choice_referer . '?pomieszczenie_id=' . $oddzialy_row['id'] . $more_GET_values . '"><button type="button" style="width: 100%;" class="btn btn-warning">Wwbierz</button></a></td>');
}
echo (' </tr>');
}
echo ('
</tbody> </table> ');
}
////////////////////////////
function get_object_data($object_type, $object_property, $object_id)
{
db_connect();
if ($object_type == "oddzial") {
if ($object_property == "name") {
$object_mysql_result = mysql_query("SELECT * FROM oddzialy WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
return $object_row['oddzial_name'];
}
}
}
//////////////////////
if ($object_type == "pomieszczenie") {
if ($object_property == "name") {
$object_mysql_result = mysql_query("SELECT * FROM pomieszczenia WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
return $object_row['pomieszczenie_name'];
}
}
}
//////////////////////
//////////////////////
if ($object_type == "control_point") {
if ($object_property == "name") {
$object_mysql_result = mysql_query("SELECT * FROM control_points WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
return $object_row['cp_name'];
}
}
}
//////////////////////
if ($object_type == "inspection") {
if ($object_property == "name") {
$object_mysql_result = mysql_query("SELECT * FROM inspections WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
return $object_row['inspection_name'];
}
}
/////////
if ($object_property == "type") {
$object_mysql_result = mysql_query("SELECT * FROM inspections WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
if ($object_row['inspection_type'] == "1") {
return "podstawowa";
}
/////
if ($object_row['inspection_type'] == "2") {
return "sprawdzająca";
}
}
}
////////
/////////
if ($object_property == "type_BOOLEAN") {
$object_mysql_result = mysql_query("SELECT * FROM inspections WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
if ($object_row['inspection_type'] == "1") {
return 1;
}
/////
if ($object_row['inspection_type'] == "2") {
return 2;
}
}
}
////////
/////////
if ($object_property == "state") {
$object_mysql_result = mysql_query("SELECT * FROM inspections WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
if ($object_row['inspection_state'] == "1") {
return "<font color='green'>Aktywna</font>";
}
/////
if ($object_row['inspection_state'] == "2") {
return "<font color='red'>Zakończona</font>";
}
}
}
////////
if ($object_property == "mode") {
$object_mysql_result = mysql_query("SELECT * FROM inspections WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
if ($object_row['inspection_mode'] == "1") {
return "oznaczająca obiekty";
}
/////
if ($object_row['inspection_mode'] == "2") {
return "oceniająca obiekty";
}
}
}
////////
if ($object_property == "mode_INT") {
$object_mysql_result = mysql_query("SELECT * FROM inspections WHERE id='" . $object_id . "';");
while ($object_row = mysql_fetch_array($object_mysql_result)) {
if ($object_row['inspection_mode'] == "1") {
return 1;
}
/////
if ($object_row['inspection_mode'] == "2") {
return 2;
}
}
}
}
}
////////////////////////////
function inspection_add($inspection_name, $inspection_description, $inspection_date, $inspection_type, $inspection_mode, $checking_for_inspection)
{
/// inspection_mode - oznaczanie lub ocenianie wcześniej oznaczonych
db_connect();
$timestamp = time();
mysql_query("INSERT INTO inspections ( inspection_name, inspection_description, inspection_date, inspection_type, inspection_mode, checking_for_inspection )
VALUES
( '" . $inspection_name . "', '" . $inspection_description . "', '" . $timestamp . "', '" . $inspection_type . "', '" . $inspection_mode . "', '" . $checking_for_inspection . "' );");
return true;
}
///////////////////////////
function get_oddzial_from_pomieszczenie_id($pomieszczenie_id)
{
db_connect();
$pom_result = mysql_query("SELECT * FROM pomieszczenia WHERE id='" . $pomieszczenie_id . "';");
while ($pom_row = mysql_fetch_array($pom_result)) {
$r1 = $pom_row['oddzial_id'];
}
return $r1;
}
///////////////////////////
function get_other_data_from_controlpoint_id()
{
}
/////////////////////////////
function already_voted($inspection_id, $cp_id)
{
db_connect();
$vote_result = mysql_query("SELECT * FROM inspections_data WHERE cp_id='" . $cp_id . "' AND inspection_id='" . $inspection_id . "';");
if (mysql_num_rows($vote_result) == 1 || mysql_num_rows($vote_result) > 1) {
return true;
} else {
return false;
}
}
//////////////////////////////
function get_vote_state($inspection_id, $cp_id)
{
db_connect();
$vote_result = mysql_query("SELECT * FROM inspections_data WHERE cp_id='" . $cp_id . "' AND inspection_id='" . $inspection_id . "';");
while ($vote_row = mysql_fetch_array($vote_result)) {
return (int) $vote_row['state'];
}
}
//////////////////////////////
function get_checking_from_voting_inspection ($voting_inspection) {
db_connect();
$insp_result = mysql_query("SELECT * FROM inspections WHERE id='" . $voting_inspection . "';");
while ($insp_row = mysql_fetch_array($insp_result)) {
return $insp_row['checking_for_inspection'];
}
}
//////////////////////////////
function get_poprzednia_ocena_from_checking ($inspection_id, $cp_id) {
db_connect();
$insp_result = mysql_query("SELECT * FROM inspections WHERE id='" . $inspection_id . "';");
while ($insp_row = mysql_fetch_array($insp_result)) {
$checking = $insp_row['checking_for_inspection'];
}
$checking_result = mysql_query("SELECT * FROM inspections_data WHERE cp_id='".$cp_id."' AND inspection_id='" . $checking . "';");
while ($checking_row = mysql_fetch_array($checking_result)) {
$answer = $checking_row['state'];
}
return (int)$answer;
}
//////////////////////////////
function print_controled_points_list($pomieszczenie_id, $table_mode, $delete_button, $inspection_mode_type, $inspection_id, $checking_inspection_id)
{
$inspection_type_BOOL = get_object_data ("inspection", "type_BOOLEAN", $inspection_id);
/// table_mode - tryb wyświetlania albo inspekcji 1 wyswietlanie 2 inspekcja
/// oznaczanie lub ocenianie - $inspection_mode_type
/// 1 - oznaczanie
/// 2 - ocena
//echo ($inspection_type_BOOL);
echo (' <table class="table table-hover table-bordered">
<thead style="background: #A2E7FA; ">
<tr>
<th>Lp.</th>
<th>Nazwa punktu kontrolowanego</th>
<th>Opis punktu kontrolowanego</th>
');
if ($table_mode == 2) {
if ($inspection_type_BOOL == 2) {
echo ('
<th>Poprzednia ocena</th>');
}
if ($inspection_mode_type == 1) {
echo ('
<th>Oznaczanie</th>');
}
else {
echo ('
<th style="width: 10%;">Ocena</th>');
}
}
if ($delete == true) {
echo ('
<th>Usuwanie</th>');
}
echo ('
</tr>
</thead>
<tbody>');
$oddzialy = mysql_query("SELECT * FROM control_points WHERE pomieszczenie_id=" . $pomieszczenie_id . ";");
$i = null;
while ($oddzialy_row = mysql_fetch_array($oddzialy)) {
$checked = false;
//echo (get_poprzednia_ocena_from_checking ($inspection_id, $oddzialy_row['id']));
if ($table_mode == 2) // jeżli tryb wyświetlania inspekcji
{
if (already_voted($checking_inspection_id, $oddzialy_row['id'])) {
if (get_vote_state($checking_inspection_id, $oddzialy_row['id']) == 3) { /// 3 oznacza oznaczenie
$checked = true;
}
}
if ($inspection_type_BOOL == 2) {
if (get_poprzednia_ocena_from_checking ($inspection_id, $oddzialy_row['id']) == 0) {
$czy_wyswietlic = true;
$checked = true;
} else {
$czy_wyswietlic = false;
}
} else {
$czy_wyswietlic = true;
}
if ($checked == true AND $inspection_mode_type == 2 AND $czy_wyswietlic == true) // sprawdzamy czy oznaczono i czy jest tryb oceniania
{
// echo ("tst");
$i++;
echo (' <tr>');
echo (' <td>' . $i . '</td>');
echo (' <td>' . $oddzialy_row['cp_name'] . '</td>');
echo (' <td>' . $oddzialy_row['cp_description'] . '</td>');
if ($table_mode == 2) {
$oddzial_id = get_oddzial_from_pomieszczenie_id($pomieszczenie_id);
if ($inspection_mode_type == 1) {
if (already_voted($inspection_id, $oddzialy_row['id'])) {
if (get_vote_state($inspection_id, $oddzialy_row['id']) == 3) { /// 3 oznacza oznaczenie
echo ('
<th><center><h4><b><font color="black">Oznaczono</font></b></h4></th></center>');
}
} else {
echo ('
<th>
<a href="inspection_excuting.php?inspection_id=' . $inspection_id . '&inspection_mode=1&pomieszczenie_id=' . $pomieszczenie_id . '&answer=3&control_point_id=' . $oddzialy_row['id'] . '&oddzial_id=' . $oddzial_id . '">
<button type="button" style="width: 100%; background: #C7960E; color: white;" class="btn btn-primary btn-sm">Oznacz</button></a></th>');
}
}
else {
///////////jeżeli sprawdzająca poprzednią///////
if ($inspection_type_BOOL == 2) {
echo ('
<th><center><h4><font color="red">Źle</center></h4></font></th>');
//echo ("dfgdg");
}
////////////////////////////////////////////////
if (already_voted($inspection_id, $oddzialy_row['id'])) {
if (get_vote_state($inspection_id, $oddzialy_row['id']) == 1) {
echo ('
<th><center><h4><b><font color="green">Dobrze</font></b></h4></center></th>');
} else {
echo ('
<th><center><h4><b><font color="red">Źle</font></b></h4></center></th>');
}
} else {
echo ('
<th><a href="inspection_excuting.php?checking_inspection_id=' . $checking_inspection_id . '&inspection_id=' . $inspection_id . '&inspection_mode=2&pomieszczenie_id=' . $pomieszczenie_id . '&answer=1&control_point_id=' . $oddzialy_row['id'] . '&oddzial_id=' . $oddzial_id . '"><button type="button" style="width: 100%; background: #54CF17; color: white;" class="btn btn-primary btn-sm">+</button></a>
<br>
<br>
<a href="inspection_excuting.php?checking_inspection_id=' . $checking_inspection_id . '&inspection_id=' . $inspection_id . '&inspection_mode=2&pomieszczenie_id=' . $pomieszczenie_id . '&answer=0&control_point_id=' . $oddzialy_row['id'] . '&oddzial_id=' . $oddzial_id . '"><button type="button" style="width: 100%; background: #F22742; color: white;" class="btn btn-primary btn-sm">-</button></a>
</th>');
}
}
}
if ($delete == true) {
echo (' <td><a href="delete.php?type=oddzial&oddzial_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-danger">Usuń</button></a></td>');
}
echo (' </tr>');
} else {
$tmp_var_1 == true;
}
} else {
$tmp_var_1 == true;
}
if ($table_mode == 1 OR $inspection_mode_type == 1) // jeżli tryb oznaczania
{
$i++;
echo (' <tr>');
echo (' <td>' . $i . '</td>');
echo (' <td>' . $oddzialy_row['cp_name'] . '</td>');
echo (' <td>' . $oddzialy_row['cp_description'] . '</td>');
if ($table_mode == 2) {
$oddzial_id = get_oddzial_from_pomieszczenie_id($pomieszczenie_id);
if ($inspection_mode_type == 1) {
if (already_voted($inspection_id, $oddzialy_row['id'])) {
if (get_vote_state($inspection_id, $oddzialy_row['id']) == 3) { /// 3 oznacza oznaczenie
echo ('
<th><center><h4><b><font color="black">Oznaczono</font></b></h4></th></center>');
}
} else {
echo ('
<th>
<a href="inspection_excuting.php?inspection_id=' . $inspection_id . '&inspection_mode=1&pomieszczenie_id=' . $pomieszczenie_id . '&answer=3&control_point_id=' . $oddzialy_row['id'] . '&oddzial_id=' . $oddzial_id . '">
<button type="button" style="width: 100%; background: #C7960E; color: white;" class="btn btn-primary btn-sm">Oznacz</button></a></th>');
}
}
else {
if (already_voted($inspection_id, $oddzialy_row['id'])) {
if (get_vote_state($inspection_id, $oddzialy_row['id']) == 1) {
echo ('
<th><h3><b><font color="green">Dobrze</font></b></h3></th>');
} else {
echo ('
<th><h3><b><font color="red">Źle</font></b></h3></th>');
}
} else {
echo ('
<th><a href="inspection_excuting.php?inspection_id=' . $inspection_id . '&inspection_mode=2&pomieszczenie_id=' . $pomieszczenie_id . '&answer=1&control_point_id=' . $oddzialy_row['id'] . '&oddzial_id=' . $oddzial_id . '"><button type="button" style="width: 100%; background: #54CF17; color: white;" class="btn btn-primary btn-sm">+</button></a>
<br>
<br>
<a href="inspection_excuting.php?inspection_id=' . $inspection_id . '&inspection_mode=2&pomieszczenie_id=' . $pomieszczenie_id . '&answer=0&control_point_id=' . $oddzialy_row['id'] . '&oddzial_id=' . $oddzial_id . '"><button type="button" style="width: 100%; background: #F22742; color: white;" class="btn btn-primary btn-sm">-</button></a>
</th>');
}
}
}
if ($delete == true) {
echo (' <td><a href="delete.php?type=oddzial&oddzial_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-danger">Usuń</button></a></td>');
}
echo (' </tr>');
}
}
echo ('
</tbody> </table> ');
}
//////////////////////////
function print_inspections_list () {
echo (' <table class="table table-hover table-bordered">
<thead style="background: #A2E7FA; ">
<tr>
<th>Lp.</th>
<th>Nazwa inspekcji</th>
<th>Opis inspekcji</th>
<th>Rodzaj inspekcji</th>
<th>Tryb inspekcji</th>
<th>Stan inspekcji</th>
<th>Oceniająca/sprawdzająca inspekcję</th>
');
echo ('
<th>Usuwanie</th>');
echo ('
<th>Wybór</th>');
echo ('
</tr>
</thead>
<tbody>');
$oddzialy = mysql_query("SELECT * FROM inspections ;");
$i = null;
while ($oddzialy_row = mysql_fetch_array($oddzialy)) {
$i++;
$inspection_type = get_object_data ("inspection", "type", $oddzialy_row['id']);
$inspection_mode = get_object_data ("inspection", "mode", $oddzialy_row['id']);
$inspection_state = get_object_data ("inspection", "state", $oddzialy_row['id']);
if ($oddzialy_row['checking_for_inspection'] != "") {
$checking = $oddzialy_row['checking_for_inspection'];
} else {
$checking = "Nie dotyczy";
}
echo (' <tr>');
echo (' <td>' . $i . '</td>');
echo (' <td>' . $oddzialy_row['inspection_name'] . '</td>');
echo (' <td>' . $oddzialy_row['inspection_description'] . '</td>');
echo (' <td>' . $inspection_type . '</td>');
echo (' <td>' . $inspection_mode . '</td>');
echo (' <td>' . $inspection_state . '</td>');
echo (' <td>' . $checking . '</td>');
echo (' <td><a href="delete.php?type=inspection&oddzial_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-danger">Usuń</button></a></td>');
echo (' <td><a href="inspection_excuting.php?checking_inspection_id='.$oddzialy_row['checking_for_inspection'].'&inspection_id=' . $oddzialy_row['id'] . '"><button type="button" style="width: 100%;" class="btn btn-warning">Idź</button></a></td>');
echo (' </tr>');
}
echo ('
</tbody> </table> ');
}
///////////////////////////
function print_combobox_inspections_list () {
db_connect();
$oddzialy = mysql_query("SELECT * FROM inspections WHERE `inspection_mode` = '1' OR `inspection_type` = '1';");
$i = null;
while ($oddzialy_row = mysql_fetch_array($oddzialy)) {
$i++;
echo (' <option value="'.$oddzialy_row['id'].'">' . $oddzialy_row['inspection_name'] . '</option>');
}
echo ('
</tbody> </table> ');
}
///////////////////////////
function get_actual_year() {
$actual_year = date ("Y");
return $actual_year;
}
///////////////////////////
function print_years () {
$actual_year = get_actual_year();
$ile_lat = 5;
$i = null;
$year_T = $actual_year;
while ($i != $ile_lat)
{
$i++;
echo ("<option value='".$year_T."'>".$year_T."</option>");
$year_T = $year_T - 1;
}
}
///////////////////////////
?>