-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
3533 lines (3008 loc) · 183 KB
/
ajax.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
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
<?php
define("IN_SITEDRIVE", 1);
session_start();
# INCLUDES ##############################################################################
require_once('./common.php'); // SiteDrive API and initialize
require_once('./admin/includes/config.php'); // Настройки SiteDrive
require_once('./admin/includes/values.php'); // Работа с константами
# MAIN ##################################################################################
db_connect(DB_HOST, DB_LOGIN, DB_PASSWORD);
db_select_db(DB_NAME);
# VARIABLES #############################################################################
$lang_index = 'ru';
$options = null;
function categoryTreeOptions($parent_id = 0, $sub_mark = ''){
global $options;
$query = db_query("SELECT * FROM new_module_departments WHERE parent_id = $parent_id ORDER BY name ASC");
if (db_num_rows($query) > 0) {
while ($row = db_fetch_array($query)) {
$options .= '<option value="' . $row['id'] . '">' . $sub_mark . $row['name'] . '</option>';
categoryTreeOptions($row['id'], $sub_mark . '---');
}
}
return $options;
}
function categoryIndicatorsTreeOptions($parent_id = 0, $sub_mark = ''){
global $options;
$query = db_query("SELECT * FROM new_module_indicator_categories WHERE parent_id = $parent_id ORDER BY name ASC");
if (db_num_rows($query) > 0) {
while ($row = db_fetch_array($query)) {
$options .= '<option value="' . $row['id'] . '">' . $sub_mark . $row['name'] . '</option>';
categoryIndicatorsTreeOptions($row['id'], $sub_mark . '---');
}
}
return $options;
}
function logging($request_id, $description, $who_type, $who_id)
{
$sql = "INSERT module_logging SET request_id = '" . $request_id . "',
description = '" . $description . "',
who_type = '" . $who_type . "',
who_id = '" . $who_id . "',
time_create = NOW()";
db_query($sql);
}
$author_id = $_SESSION['id'];
$author_type = $_SESSION['type'];
function noticeUsers($author_id, $author_type, $for_id, $for_type, $title, $description, $house_id, $flat_id)
{
$sql = "INSERT module_notifications SET author_id = '" . $author_id . "',
author_type = '" . $author_type . "',
for_id = '" . $for_id . "',
for_type = '" . $for_type . "',
title = '" . $title . "',
description = '" . $description . "',
house_id = '" . $house_id . "',
flat_id = '" . $flat_id . "',
time_create = NOW()";
db_query($sql);
}
if (isset($_POST['type'])) {
if ($_POST['type'] == "html-request") {
// меняем статус в модуле my_houses_osi
if ($_POST['action'] == 1) {
$id = intval($_POST['id']);
$status = intval($_POST['status']);
$sql = "UPDATE module_houses SET status = '" . $status . "' WHERE id = " . $id;
db_query($sql);
$out = $status + 1;
}
// получаем список домов по илице
// if ($_POST['action'] == 2) {
// $street = cleanStr($_POST['value']);
// $out .= '<option selected="selected">' . getval("STR_SELECT_HOUSE_NUMBER_TITLE") . '</option>';
// $result = db_query("SELECT * FROM module_houses WHERE street = '" . $street . "' AND status = 1 ORDER BY id");
// if (db_num_rows($result) > 0) {
// while ($row = db_fetch_array($result)) {
// $out .= '<option value="' . $row['house_number'] . '">' . $row['house_number'] . '</option>';
// }
// }
// }
if ($_POST['action'] == 3) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_flats_citizens WHERE id = " . $id;
$connect = db_get_data("SELECT * from module_flats_citizens WHERE flat_id = " . $id);
$citizens = db_get_data("SELECT * from module_citizens WHERE id = " . $connect['citizen_id']);
$fullData = db_get_data("SELECT t1.*, t2.osi_id, t2.house_id, t2.flat_number, t2.city_id FROM module_flats_citizens AS t1 LEFT JOIN module_flats AS t2 ON t2.id = t1.flat_id WHERE t1.id =" . $id);
$city = db_get_data("SELECT name FROM module_cities WHERE id = " . $fullData['city_id'], "name");
$street = db_get_data("SELECT street FROM module_houses WHERE id = " . $fullData['house_id'], "street");
$house_number = db_get_data("SELECT house_number FROM module_houses WHERE id = " . $fullData['house_id'], "house_number");
$fullAdress .= '' . $city . ', ' . getval("STR_STREET_SOKR_TITLE") . ' ' . $street . ' ' . $house_number . ', ' . getval("STR_FLAT_SOKR_TITLE") . ' ' . $fullData['flat_number'] . '';
noticeUsers($_SESSION['id'], $_SESSION['type'], $fullData['osi_id'], 2, 'Квартира удалена', 'Житель: <b>' . $citizens['name'] . ' </b> удалил(а) квартиру по адресу: <b> ' . $fullAdress . '</b>', 0, $fullData['flat_id']);
db_query($sql);
// $sql = "DELETE FROM module_flats WHERE id = " . $id;
// db_query($sql);
}
if ($_POST['action'] == 4) { // Жангирхан сделал
$id = intval($_POST['id']);
$status = intval($_POST['status']);
$sql = "UPDATE module_osi_and_ucs SET status = " . $status . " WHERE id = " . $id;
$connect = db_get_data("SELECT * from module_osi_and_ucs WHERE id = " . $id);
if ($_SESSION['type'] == 2) {
$who = $connect['ucs_id'];
$who_type = 1;
$uc_data = db_get_data("SELECT * from module_ucs WHERE id = " . $connect['ucs_id']);
if ($status == 2) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Деактивация УК', 'ОСИ деактивировала УК: <b>' . $uc_data['name'] . '</b>', 0, 0);
//проверка новая УК
if ($new_entry == 0) {
$out = 2;
} else if ($new_entry) {
$out = 1;
}
} else if ($status == 1) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Активация УК', 'ОСИ активировала УК: <b>' . $uc_data['name'] . '</b>', 0, 0);
//проверка новая УК
if ($new_entry == 0) {
$out = 2;
} else if ($new_entry) {
$out = 3;
}
}
} else if ($_SESSION['type'] == 1) {
$who = $connect['osi_id'];
$who_type = 2;
$osi_data = db_get_data("SELECT * from module_osi WHERE id = " . $connect['osi_id']);
if ($status == 2) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Деактивация ОСИ', 'УК деактивировала ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
//проверка новая ОСИ
if ($new_entry == 0) {
$out = 2;
} else if ($new_entry) {
$out = 1;
}
} else if ($status == 1) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Активация ОСИ', 'УК активировала ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
//проверка новая ОСИ
if ($new_entry == 0) {
$out = 2;
} else if ($new_entry) {
$out = 3;
}
}
}
db_query($sql);
}
if ($_POST['action'] == 5) {
$id = intval($_POST['id']);
$status = intval($_POST['status']);
$sql = "UPDATE module_flats_citizens SET status = " . $status . " WHERE id = " . $id;
$connect = db_get_data("SELECT * from module_flats_citizens WHERE id = " . $id);
$flat_data = db_get_data("SELECT * from module_flats WHERE id = " . $connect['flat_id']);
if ($_SESSION['type'] == 2) {
$who = $connect['citizen_id'];
$who_type = 3;
$osi_data = db_get_data("SELECT * from module_osi WHERE id = " . $flat_data['osi_id']);
$citizen_data = db_get_data("SELECT * from module_citizens WHERE id = " . $connect['citizen_id']);
$fullData = db_get_data("SELECT t1.*, t2.osi_id, t2.house_id, t2.flat_number, t2.city_id FROM module_flats_citizens AS t1 LEFT JOIN module_flats AS t2 ON t2.id = t1.flat_id WHERE t1.id =" . $id);
$city = db_get_data("SELECT name FROM module_cities WHERE id = " . $fullData['city_id'], "name");
$street = db_get_data("SELECT street FROM module_houses WHERE id = " . $fullData['house_id'], "street");
$house_number = db_get_data("SELECT house_number FROM module_houses WHERE id = " . $fullData['house_id'], "house_number");
$fullAdress .= '' . $city . ', ' . getval("STR_STREET_SOKR_TITLE") . ' ' . $street . ' ' . $house_number . ', ' . getval("STR_FLAT_SOKR_TITLE") . ' ' . $fullData['flat_number'] . '';
if ($status == 0) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Деактивация жителя', 'ОСИ: <b>' . $osi_data['name'] . '</b> деактивировала жителя: <b>' . $citizen_data['name'] . '</b> живущего по адресу: <b>' . $fullAdress . '</b>', 0, $flat_data['id']);
} else if ($status == 1) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Активация жителя', 'ОСИ: <b>' . $osi_data['name'] . '</b> активировала жителя: <b>' . $citizen_data['name'] . '</b> живущего по адресу: <b>' . $fullAdress . '</b>', 0, $flat_data['id']);
}
} else if ($_SESSION['type'] == 1) {
$who = $connect['osi_id'];
$who_type = 2;
$uc_data = db_get_data("SELECT * from module_ucs WHERE id = " . $_SESSION['id']);
$osi_data = db_get_data("SELECT * from module_osi WHERE id = " . $flat_data['osi_id']);
if ($status == 0) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Деактивация ОСИ', 'УК: <b>' . $uc_data['name'] . '</b> деактивировала ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
} else if ($status == 1) {
noticeUsers($_SESSION['id'], $_SESSION['type'], $who, $who_type, 'Деактивация ОСИ', 'УК: <b>' . $uc_data['name'] . '</b> активировала ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
}
}
db_query($sql);
$sql = "UPDATE module_flats SET status = " . $status . " WHERE id = " . $connect['flat_id'];
db_query($sql);
}
// получаем управляющие компании по городу
if ($_POST['action'] == 6) {
$id = cleanStr($_POST['id']);
$out .= '<option selected="selected">' . getval("STR_SELECT_UC_NAME") . '</option>';
$result = db_query("SELECT * FROM module_ucs WHERE city_id = '" . $id . "' AND status = 1 ORDER BY id");
if (db_num_rows($result) > 0) {
while ($row = db_fetch_array($result)) {
$out .= '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
}
}
}
// Удаляем связь между УК и ОСИ
if ($_POST['action'] == 7) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_osi_and_ucs WHERE id = " . $id;
db_query($sql);
$out = 2;
}
// получение статуса
if ($_POST['action'] == 8) {
$id = intval($_POST['id']);
$status = intval($_POST['status']);
if ($status == 3) {
$sql = "UPDATE module_requests SET request_status_inner_id = " . $status . " WHERE id = " . $id . "";
} else {
$sql = "UPDATE module_requests SET request_status_id = " . $status . ", request_status_inner_id = 0 WHERE id = " . $id . "";
}
db_query($sql);
}
// не удалять жангир написал)
if ($_POST['action'] == 9) {
$id = intval($_POST['id']);
$who = intval($_POST['who']);
$who_type = intval($_POST['who_type']);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
if ($request['uc_id'] == 0) {
$for_id_id = $request['osi_id'];
$for_type_type = 2;
} else {
$for_id_id = $request['uc_id'];
$for_type_type = 1;
}
$citizen_data = db_get_data("SELECT * from module_citizens WHERE id = " . $_SESSION['id']);
noticeUsers($_SESSION['id'], $_SESSION['type'], $for_id_id, $for_type_type, 'Заявка удалена', 'Житель: <b>' . $citizen_data['name'] . '</b> удалил(а) заявку <b>#' . $request['id'] . '</b>', 0, 0);
$sql = "DELETE FROM module_requests WHERE id = " . $id;
db_query($sql);
}
// Меняем статус принятия у всех
#Статусы принятия (accepted)
# 0 - новая заявка
# 1 - принятая завка
# 2 - не принятая заявка
# 3 - ожидает оценки
# 4 - выполненная заявка
# 5 - не выполненная заявка
if ($_POST['action'] == 10) {
$id = intval($_POST['id']);
$status = intval($_POST['status']);
$name = intval($_POST['name']);
$who = intval($_POST['who']);
$who_type = intval($_POST['who_type']);
if ($name == 1) {
if ($status == 1) {
$nameAccepted = "uc_accepted";
$sql = "UPDATE module_requests SET " . $nameAccepted . " = " . $status . " WHERE id = " . $id . "";
$uc_data = db_get_data("SELECT name, phone from module_ucs WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка была принята Управляющей Компанией: ' . $uc_data['name'] . ' / ' . $uc_data['phone'], $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['osi_id'], 2, 'Заявка принята', 'УК: <b>' . $uc_data['name'] . '</b> принял(а) заявку <b> #' . $id . '</b>', 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка принята', 'УК: <b>' . $uc_data['name'] . '</b> принял(а) заявку <b> #' . $id . '</b>', 0, 0);
} else if ($status == 11) {
$nameAccepted = "uc_accepted";
$sql = "UPDATE module_requests SET " . $nameAccepted . " = 1, request_status_id = 1 WHERE id = " . $id . "";
$uc_data = db_get_data("SELECT name, phone from module_ucs WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка была принята Управляющей Компанией: ' . $uc_data['name'] . ' / ' . $uc_data['phone'], $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['osi_id'], 2, 'Заявка принята', 'УК: <b>' . $uc_data['name'] . '</b> принял(а) заявку <b> #' . $id . '</b>', 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка принята', 'УК: <b>' . $uc_data['name'] . '</b> принял(а) заявку <b> #' . $id . '</b>', 0, 0);
}
} else if ($name == 2) {
$nameAccepted = "osi_accepted";
if ($status == 1) {
//$sql = "UPDATE module_requests SET ".$nameAccepted." = ".$status." WHERE id = ".$id."";
$sql = "UPDATE module_requests SET request_status_id = 1," . $nameAccepted . " = " . $status . " WHERE id = " . $id . "";
$osi_data = db_get_data("SELECT name, phone from module_osi WHERE id = " . $who);
logging($id, 'Заявка была принята ОСИ', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка принята', 'ОСИ: <b>' . $osi_data['name'] . '</b> принял(а) заявку <b> #' . $id . '</b>', 0, 0);
} else if ($status == 2) {
$sql = "UPDATE module_requests SET request_status_id = 2," . $nameAccepted . " = " . $status . " WHERE id = " . $id . "";
$osi_data = db_get_data("SELECT name, phone from module_osi WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка была взята в работу самим ОСИ', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка взята в работу самим ОСИ', 'ОСИ: <b>' . $osi_data['name'] . '</b> самостоятельно взялся выполнить заявку <b> #' . $id . '</b>', 0, 0);
} else if ($status == 3) {
$sql = "UPDATE module_requests SET request_status_id = 3, " . $nameAccepted . " = 3 WHERE id = '" . $id . "'";
$osi_data = db_get_data("SELECT name, phone from module_osi WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка ожидает оценки:', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка выполнена и ожидает оценки', 'Заявка <b>#' . $id . '</b> выполнена и ожидает оценки', 0, 0);
} else if ($status == 4) {
$sql = "UPDATE module_requests SET request_status_id = 1, " . $nameAccepted . " = 1, uc_id = 0 WHERE id = '" . $id . "'";
$osi_data = db_get_data("SELECT name, phone from module_osi WHERE id = " . $_SESSION['id']);
logging($id, 'Перенаправление заявки было отменено', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Перенаправление было отменено', 'Перенаправление заявки было отменено ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['uc_id'], 1, 'Перенаправление было отменено', 'Перенаправление заявки было отменено ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
}
} else if ($name == 3) {
$nameAccepted = "citizen_accepted";
} else if ($name == 4) {
$nameAccepted = "worker_uc_accepted";
if ($status == 3) {
$sql = "UPDATE module_requests SET request_status_id = 3, " . $nameAccepted . " = 3 WHERE id = '" . $id . "'";
$worker_data = db_get_data("SELECT name, phone from module_worker_uc WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка ожидает оценки', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка ожидает оценки', 'Cотрудник УК: <b>' . $worker_data['name'] . '</b> выполнил заявку #' . $id . ' и ожидает оценки', 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['osi_id'], 2, 'Заявка ожидает оценки', 'Cотрудник УК: <b>' . $worker_data['name'] . '</b> выполнил заявку #' . $id . ' и ожидает оценки', 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['uc_id'], 1, 'Заявка ожидает оценки', 'Cотрудник УК: <b>' . $worker_data['name'] . '</b> выполнил заявку #' . $id . ' и ожидает оценки', 0, 0);
} else if ($status == 4) {
$sql = "UPDATE module_requests SET request_status_id = 4, " . $nameAccepted . " = 1 WHERE id = '" . $id . "'";
$worker_data = db_get_data("SELECT name, phone from module_worker_uc WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка была выполнена', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка выполнена', 'Cотрудник УК: <b>' . $worker_data['name'] . '</b> выполнил заявку #' . $id . '', 0, 0);
} else if ($status == 5) {
$sql = "UPDATE module_requests SET request_status_id = 5, " . $nameAccepted . " = 2 WHERE id = '" . $id . "'";
$worker_data = db_get_data("SELECT name, phone from module_worker_uc WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка была не выполнена', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка не выполнена', 'Сотрудник УК: <b>' . $worker_data['name'] . '</b> не выполнил заявку #' . $id . '', 0, 0);
} else {
$sql = "UPDATE module_requests SET request_status_id = 2, " . $nameAccepted . " = '" . $status . "' WHERE id = '" . $id . "'";
$worker_data = db_get_data("SELECT name, phone from module_worker_uc WHERE id = " . $_SESSION['id']);
logging($id, 'Заявка была взята в работу', $who_type, $who);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 3, 'Заявка в работе', 'Сотрудник УК: <b>' . $worker_data['name'] . '</b> взял заявку #' . $id . ' в работу', 0, 0);
}
} else if ($name == 5) {
$nameAccepted = "manager_uc_accepted";
}
db_query($sql);
}
// Меняем статус у любой заявки
// if ($type == 1) $table = 'module_ucs';
// if ($type == 2) $table = 'module_osi';
// if ($type == 3) $table = 'module_citizens';
// if ($type == 4) $table = 'module_worker_uc';
// if ($type == 5) $table = 'module_manager_uc';
if ($_POST['action'] == 11) {
$id = intval($_POST['id']);
$name = cleanStr($_POST['name']);
if ($name == 1) {
$nameAccepted = "uc_accepted";
} else if ($name == 2) {
$nameAccepted = "osi_accepted";
} else if ($name == 3) {
$nameAccepted = "citizen_accepted";
} else if ($name == 4) {
$nameAccepted = "worker_uc_accepted";
} else if ($name == 5) {
$nameAccepted = "manager_uc_accepted";
}
$accept = cleanStr($_POST['accept']);
$status = intval($_POST['status']);
$sql = "UPDATE module_requests SET request_status_id = " . $status . ", " . $nameAccepted . " = " . $accept . " WHERE id = " . $id . "";
db_query($sql);
}
if ($_POST['action'] == 12) {
$id = intval($_POST['id']);
$name = intval($_POST['name']);
if ($name == 1) {
$nameAccepted = "uc_accepted";
} else if ($name == 2) {
$sql = "INSERT into module_requests(city_id, osi_id, house_id, flat_id, uc_id, description , photo_i, type_id, request_status_id, time_create) select city_id, osi_id, house_id, flat_id, uc_id, description , photo_i, type_id, 11, NOW() from module_requests where id = " . $id . ";";
$nameAccepted = "osi_accepted";
$osi_data = db_get_data("SELECT name, phone from module_osi WHERE id = " . $_SESSION['id']);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['uc_id'], 1, 'Заявка продублирована', 'Заявка: <b>#' . $id . '</b> была продублирована ОСИ: <b>' . $osi_data['name'] . '</b>', 0, 0);
} else if ($name == 3) {
$sql = "INSERT into module_requests(city_id, osi_id, house_id, flat_id, citizen_id, description , photo_i, type_id, request_status_id, time_create) select city_id, osi_id, house_id, flat_id, citizen_id, description , photo_i, type_id, 11, NOW() from module_requests where id = " . $id . ";";
$nameAccepted = "citizen_accepted";
$citizen_data = db_get_data("SELECT name, phone from module_citizens WHERE id = " . $_SESSION['id']);
$request = db_get_data("SELECT * from module_requests WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $request['citizen_id'], 1, 'Заявка продублирована', 'Заявка: <b>#' . $id . '</b> была продублирована жителем: <b>' . $citizen_data['name'] . '</b>', 0, 0);
} else if ($name == 4) {
$nameAccepted = "worker_uc_accepted";
} else if ($name == 5) {
$nameAccepted = "manager_uc_accepted";
}
$new_id = db_query($sql);
logging($id, 'Заявка была дублирована: ' . $new_id, $_SESSION['type'], $_SESSION['id']);
}
if ($_POST['action'] == 13) {
$id = intval($_POST['id']);
$result = "";
$out = "";
$result = db_query("SELECT * from module_logging WHERE request_id = " . $id . " ORDER BY time_create DESC");
if (db_num_rows($result) > 0) {
while ($row = db_fetch_array($result)) {
$who_type = $row['who_type'];
if ($who_type == 1) {
$who_data = db_get_data("SELECT name, phone from module_ucs WHERE id = " . $row['who_id']);
$type = "Управляющая компания";
} else if ($who_type == 2) {
$who_data = db_get_data("SELECT name, phone from module_osi WHERE id = " . $row['who_id']);
$type = "Объеденение Собственников Иммущества";
} else if ($who_type == 3) {
$who_data = db_get_data("SELECT name, phone from module_citizens WHERE id = " . $row['who_id']);
$type = "Житель";
} else if ($who_type == 4) {
$who_data = db_get_data("SELECT name, phone from module_worker_uc WHERE id = " . $row['who_id']);
$type = "Сотрудник компании";
} else if ($who_type == 5) {
}
$out .= '<tr>
<td>
' . date("d.m.Y H:i s", strtotime($row['time_create'])) . '
</td>
<td style="white-space: normal">' . $row['description'] . '</td>
<td>' . $who_data['name'] . ' <br/> ' . $who_data['phone'] . '</td>
<td>
' . $type . '
</td>
</tr>';
}
}
//echo $out;
}
// деактивация голосования
if ($_POST['action'] == 14) {
$sql = "UPDATE module_polls SET `active` = 1 WHERE id = " . intval($_POST['id']);
db_query($sql);
}
// активация голосования
if ($_POST['action'] == 15) {
$sql = "UPDATE module_polls SET `active` = 0 WHERE id = " . intval($_POST['id']);
db_query($sql);
}
// активация и деактивация
if ($_POST['action'] == 16) {
$id = intval($_POST['id']);
$worker_type = $_POST['worker_type'];
$activeStatus = $_POST['activeStatus'];
if ($activeStatus == 'Неактивный') {
if ($worker_type == 'Менеджер') {
$sql = "UPDATE module_manager_uc SET status = 1 WHERE id = " . $id;
$manager_data = db_get_data("SELECT * from module_manager_uc WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $id, 5, 'Менеджер активирован', 'Менеджер был активирован: <b>' . $manager_data['name'] . '</b>', 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $manager_data['uc_id'], 1, 'Менеджер активирован', 'Менеджер был активирован: ' . $manager_data['name'], 0, 0);
} else {
$sql = "UPDATE module_worker_uc SET status = 1 WHERE id = " . $id;
$worker_data = db_get_data("SELECT * from module_worker_uc WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $id, 4, 'Сотрудник активирован', 'Сотрудник был активирован: <b>' . $worker_data['name'], 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $worker_data['uc_id'], 1, 'Сотрудник активирован', 'Сотрудник был активирован: ' . $worker_data['name'] . '</b>', 0, 0);
}
$out = 2; //вот так указываеш что это второй таб
} else {
if ($worker_type == 'Менеджер') {
$sql = "UPDATE module_manager_uc SET status = 0 WHERE id = " . $id;
$manager_data = db_get_data("SELECT * from module_manager_uc WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $id, 5, 'Менеджер деактивирован', 'Менеджер был деактивирован: <b>' . $manager_data['name'], 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $manager_data['uc_id'], 1, 'Менеджер деактивирован', 'Менеджер был деактивирован: ' . $manager_data['name'] . '</b>', 0, 0);
} else {
$sql = "UPDATE module_worker_uc SET status = 0 WHERE id = " . $id;
$worker_data = db_get_data("SELECT * from module_worker_uc WHERE id = " . $id);
noticeUsers($_SESSION['id'], $_SESSION['type'], $id, 4, 'Сотрудник деактивирован', 'Сотрудник был деактивирован: <b>' . $worker_data['name'], 0, 0);
noticeUsers($_SESSION['id'], $_SESSION['type'], $worker_data['uc_id'], 1, 'Сотрудник деактивирован', 'Сотрудник был деактивирован: ' . $worker_data['name'] . '</b>', 0, 0);
}
$out = 1; // вот так как первый таб он передается js как data
}
db_query($sql);
}
// Отправка нового пароля на почту
if ($_POST['action'] == 17) {
$email = cleanStr($_POST['email']);
$worker_type = cleanStr($_POST['worker_type']);
//Создаем новый пароль
$chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
$max = 6;
$size = StrLen($chars) - 1;
$password = null;
while ($max--) {
$password .= $chars[rand(0, $size)];
}
$to_email = $email;
$subject = 'Смена пароля от сайта Ehome';
$body = 'Вам был выдан новый пароль пожалуйста успользуйте новый пароль для входа в систему. <br/>Ваш новый пароль: ' . $password;
$headers = 'From: noreply@ehome.sidelka-galina.kz';
sendMail($to_email, $subject, $body, $sender_name = "", $sender_mail = "");
$password2 = md5($password);
echo $password2;
print_r($password2);
if ($worker_type == "Менеджер") {
$sql = "UPDATE module_manager_uc SET password = '" . $password2 . "' WHERE email = '" . $email . "'";
} else {
$sql = "UPDATE module_worker_uc SET password = '" . $password2 . "' WHERE email = '" . $email . "'";
}
db_query($sql);
}
if ($_POST['action'] == 18) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_smeta_items WHERE id = " . $id;
db_query($sql);
}
if ($_POST['action'] == 19) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_smeta WHERE id = " . $id;
db_query($sql);
$sql = "DELETE FROM module_smeta_items WHERE smeta_id = " . $id;
db_query($sql);
}
if ($_POST['action'] == 20) {
$id = intval($_POST['id']);
$data = db_get_data("SELECT * FROM module_smeta WHERE id = " . $id);
$out = json_encode($data);
}
if ($_POST['action'] == 21) {
$id = intval($_POST['id']);
if ($id == 1) {
// список домов ОСИ
$flat_list = '';
$result = db_query("SELECT * FROM module_houses WHERE osi_id = " . $_SESSION['id']);
if (db_num_rows($result) > 0) {
while ($row = db_fetch_array($result)) {
$city = db_get_data("SELECT name FROM module_cities WHERE id = " . $row['city_id'], "name");
$flat_list .= '<option value="' . $row['id'] . '">' . $city . ', ' . getval("STR_STREET_SOKR_TITLE") . ' ' . $row['street'] . ' ' . $row['house_number'] . '</option>';
}
}
$out = $flat_list;
//$tpl->assign("FLAT_LIST", $flat_list);
} else if ($id == 2) {
// список квартир
$flat_list = '';
$result = db_query("SELECT * FROM module_flats WHERE osi_id = " . $_SESSION['id']);
if (db_num_rows($result) > 0) {
while ($row = db_fetch_array($result)) {
$city = db_get_data("SELECT name FROM module_cities WHERE id = " . $row['city_id'], "name");
$house = db_get_data("SELECT * FROM module_houses WHERE id = '" . $row['house_id'] . "'");
$flat_list .= '<option value="' . $row['id'] . '">' . $city . ', ' . getval("STR_STREET_SOKR_TITLE") . ' ' . $house['street'] . ' ' . $house['house_number'] . ', кв. ' . $row['flat_number'] . '</option>';
}
}
$out = $flat_list;
} else if ($id == 3) {
// список жильцов в квартире
$flat_list = '';
//$result = db_query("SELECT t1.*, t2.* FROM module_flats_citizens AS t1 LEFT JOIN module_citizens AS t2 ON t2.id = t1.citizen_id WHERE t2.osi_id = ".$_SESSION['id']);
//$result = db_query("SELECT t1.id, t1.name FROM module_citizens AS t1 INNER JOIN module_flats_citizens AS t2 ON t1.id= t2.citizen_id INNER JOIN module_flats AS t3 ON t3.id = t2.flat_id WHERE t3.osi_id = '".$_SESSION['id']."' GROUP BY t1.name");
$result = db_query("SELECT t2.id, t2.name FROM module_flats_citizens AS t1 LEFT JOIN module_citizens AS t2 ON t2.id = t1.citizen_id INNER JOIN module_flats AS t3 ON t3.id = t1.flat_id WHERE t3.osi_id = '" . $_SESSION['id'] . "' GROUP BY t1.citizen_id");
if (db_num_rows($result) > 0) {
while ($row = db_fetch_array($result)) {
$flat_list .= '<option value="' . $row['id'] . '">' . $row['name'] . '</option>';
}
}
$out = $flat_list;
}
}
if ($_POST['action'] == 22) {
$phone = cleanStr($_POST['phone']);
$type = intval($_POST['type_user']);
$forgot = intval($_POST['forgot']);
if ($type == 1) {
$table = 'module_ucs';
$link = 'panel_uk';
}
if ($type == 2) {
$table = 'module_osi';
$link = 'panel_osi';
}
if ($type == 3) {
$table = 'module_citizens';
$link = 'cabinet';
}
if ($type == 5) {
$table = 'module_specialists';
$link = 'cabinet';
}
$count = db_table_count($table, "phone = " . $phone);
if ($count == 0) {
$code = '';
for ($i = 0; $i < 6; $i++) {
$code .= rand(0, 9);
}
$_SESSION['sms_code'] = $code;
$message = 'Ваш номер ' . $code . ' для регистрации на портале ehome.kz';
if ($curl = curl_init()) {
$query = 'https://smsc.kz/sys/send.php?login=e-home&psw=123456&phones=' . $phone . '&mes=' . $message;
curl_setopt($curl, CURLOPT_URL, $query);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec($curl);
curl_close($curl);
}
$out = '<div class="alert alert-primary">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>СМС отправлено</strong></div>';
} else {
if ($forgot == 1) {
$code = '';
for ($i = 0; $i < 6; $i++) {
$code .= rand(0, 9);
}
$_SESSION['sms_code'] = $code;
$message = 'Ваш номер ' . $code . ' для регистрации на портале ehome.kz';
if ($curl = curl_init()) {
$query = 'https://smsc.kz/sys/send.php?login=e-home&psw=123456&phones=' . $phone . '&mes=' . $message;
curl_setopt($curl, CURLOPT_URL, $query);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec($curl);
curl_close($curl);
}
$out = '<div class="alert alert-primary">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>СМС отправлено</strong></div>';
} else {
$out = '<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Номер уже зарегестрирован</strong></div>';
}
}
}
if ($_POST['action'] == 23) {
$id = intval($_POST['id']);
$sql = '';
$check = db_get_data("SELECT id FROM module_reads WHERE notification_id = '" . $id . "' AND reader_type = " . $_SESSION['type'] . " AND reader_id = " . $_SESSION['id']);
if (empty($check['id'])) {
// $sql = "INSERT INTO module_reads (time_create, reader_type, reader_id, notification_id)
// VALUES ( NOW(), '".$_SESSION['type']."', '".$_SESSION['id']."', '".$id."'";
$sql = "INSERT INTO module_reads ( time_create, reader_type, reader_id, notification_id)
VALUES ( now() ,'" . $_SESSION['type'] . "', '" . $_SESSION['id'] . "', '" . $id . "')";
$add = db_query($sql);
} else {
$add = 'false';
}
// Вывод уведомления в окне
//Работники ИД через запятую
$result = db_query("SELECT * FROM module_notifications WHERE id = " . $id);
if (db_num_rows($result) > 0) {
while ($row = db_fetch_array($result)) {
if ($_SESSION['type'] == 1) {
if ($row['author_type'] == 4) {
$name = db_get_data("SELECT name FROM module_worker_uc WHERE id = " . $row['author_id'], "name");
} else if ($row['author_type'] == 5) {
$name = db_get_data("SELECT name FROM module_manager_uc WHERE id = " . $row['author_id'], "name");
} else {
$name = db_get_data("SELECT name FROM module_ucs WHERE id = " . $row['for_id'], "name");
}
$readed = db_get_data("SELECT id FROM module_reads WHERE reader_id = '" . $_SESSION['id'] . "' AND reader_type = 1 AND Notification_ID =" . $row['id'], "id");
} else if ($_SESSION['type'] == 2) {
if ($row['author_type'] == 3) {
$name = db_get_data("SELECT name FROM module_citizens WHERE id = " . $row['author_id'], "name");
} else if ($row['author_type'] == 1) {
$name = db_get_data("SELECT name FROM module_ucs WHERE id = " . $row['author_id'], "name");
}
$readed = db_get_data("SELECT id FROM module_reads WHERE reader_id = '" . $_SESSION['id'] . "' AND reader_type = 2 AND Notification_ID =" . $row['id'], "id");
} else if ($_SESSION['type'] == 3) {
if ($row['author_type'] == 2) {
$name = db_get_data("SELECT name FROM module_osi WHERE id = " . $row['author_id'], "name");
} else if ($row['author_type'] == 4) {
$name = db_get_data("SELECT name FROM module_ucs WHERE id = " . $row['author_id'], "name");
}
$readed = db_get_data("SELECT id FROM module_reads WHERE reader_id = '" . $_SESSION['id'] . "' AND reader_type = 3 AND Notification_ID =" . $row['id'], "id");
} else if ($_SESSION['type'] == 4) {
$name = db_get_data("SELECT name FROM module_ucs WHERE id = " . $row['for_id'], "name");
$readed = db_get_data("SELECT id FROM module_reads WHERE reader_id = '" . $_SESSION['id'] . "' AND reader_type = 4 AND Notification_ID =" . $row['id'], "id");
} else if ($_SESSION['type'] == 5) {
}
//Файлы
$files = unserialize($row['files_id']);
$files_list = "";
if ($files) {
foreach ($files as &$file) {
$file_url = db_get_data("SELECT url_files FROM module_files WHERE id = " . $file);
$files_list .= '<a class="btn btn-primary btn-sm" data-toggle="tooltip" data-original-title="Скачать файл" href="../files/' . $file_url[0] . '"><i class="fa fa-download"></i></a>';
}
} else {
$files_list = '<p>Вложенные файлы отсутствует</p>';
}
//Фотографии
$images = unserialize($row['photo_i']);
$image_list = "";
$i = 0;
if ($images) {
foreach ($images as &$image) {
$image_url = db_get_data("SELECT url_photos FROM module_photos WHERE id = " . $image);
if ($i == 0) {
$image_list .= '<div class="carousel-item active"><img class="d-block w-100" loading="lazy" height="200px" alt="" src="../photos/' . $image_url[0] . '" data-holder-rendered="true"></div>';
} else {
$image_list .= '<div class="carousel-item"><img class="d-block w-100" loading="lazy" height="200px" alt="" src="../photos/' . $image_url[0] . '" data-holder-rendered="true"></div>';
}
$i++;
}
} else {
$image_list = '<p style="text-align: center;">Вложенные фотографии отсутствует</p>';
}
$id = $row['id'];
$description = $row['description'];
}
}
$out = '<div class="modal fade" tabindex="-1" id="openinfonotice" data-id="openinfonotice" role="dialog" aria-hidden="true" style="z-index: 1500 !important ;">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content ">
<div class="modal-header pd-x-20">
<h6 class="modal-title" id="openinfotitle">Уведомление №' . $id . '</h6>
<button type="button" class="close" data-dismiss="modal" aria-label="Закрыть">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body pd-20">
<div class="row">
<div class="col-xs-6 col-md-6 col-xl-6 col-lg-6">
<h5>Описание:</h5>
<p style="white-space: normal;">' . $description . '</p>
</div>
<div class="col-xs-6 col-md-6 col-xl-6 col-lg-6">
<div id="carousel-controls-' . $id . '" class="carousel slide" data-ride="carousel-' . $id . '">
<div class="carousel-inner">
' . $image_list . '
</div>
<a class="carousel-control-prev" href="#carousel-controls-' . $id . '" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Пред.</span>
</a>
<a class="carousel-control-next" href="#carousel-controls-' . $id . '" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">След.</span>
</a>
</div>
</div>
</div>
</div>
<div class="modal-footer">
' . $files_list . '
</div>
</div>
</div>
</div>
';
//$out = $add;
}
if ($_POST['action'] == 24) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_knowledgebases WHERE id = " . $id;
db_query($sql);
}
if ($_POST['action'] == 25) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_gallery_images WHERE id = " . $id;
db_query($sql);
$out = 4;
}
if ($_POST['action'] == 26) {
$id = intval($_POST['id']);
$sql = "DELETE FROM module_gallery WHERE id = " . $id;
db_query($sql);
$sql = "DELETE FROM module_gallery_images WHERE album_id = " . $id;
db_query($sql);
}
if ($_POST['action'] == 27) {
$id = intval($_POST['id']);
$file_id = db_get_data("SELECT file_id FROM module_docs WHERE id = " . $id, "file_id");
$file_url = db_get_data("SELECT url_files FROM module_files WHERE id = " . $file_id, "url_files");
$sql = "DELETE FROM module_docs WHERE id = " . $id;
db_query($sql);
unlink("../files/" . $file_url);
}
if ($_POST['action'] == 28) {
$id_request = intval($_POST['id']);
$tab = intval($_POST['tab']);
$request = db_get_data("SELECT * FROM module_requests WHERE id = " . $id_request);
$type = db_get_data("SELECT name FROM module_request_types WHERE id = " . $request['type_id'], "name");
$city = db_get_data("SELECT name FROM module_cities WHERE id = " . $request['city_id'], "name");
$name = db_get_data("SELECT name FROM module_citizens WHERE id = " . $request['citizen_id'], "name");
$name_phone = db_get_data("SELECT phone FROM module_citizens WHERE id = " . $request['citizen_id'], "phone");
$osi = db_get_data("SELECT name FROM module_osi WHERE id = " . $request['osi_id'], "name");
$osi_phone = db_get_data("SELECT phone FROM module_osi WHERE id = " . $request['osi_id'], "phone");
$uc = db_get_data("SELECT name FROM module_ucs WHERE id = " . $request['uc_id'], "name");
$uc_phone = db_get_data("SELECT phone FROM module_ucs WHERE id = " . $request['uc_id'], "phone");
$uc_worker = db_get_data("SELECT name FROM module_worker_uc WHERE id = " . $request['worker_uc_id'], "name");
$uc_worker_phone = db_get_data("SELECT phone FROM module_worker_uc WHERE id = " . $request['worker_uc_id'], "phone");
$status = db_get_data("SELECT name FROM module_request_statuses WHERE id = " . $request['request_status_id'], "name");
$flat_data = db_get_data("SELECT t1.*, t2.house_id, t2.flat_number FROM module_flats_citizens AS t1 LEFT JOIN module_flats AS t2 ON t2.id = t1.flat_id WHERE t1.id = " . $request['flat_id']);
$house = db_get_data("SELECT * FROM module_houses WHERE id = " . $request['house_id']);
$review = db_get_data("SELECT rating_id FROM module_request_reviews WHERE request_id = " . $request['id'], "rating_id");
$review_text = '';
$review_text = db_get_data("SELECT description FROM module_request_reviews WHERE request_id = " . $request['id'], "description");
$images = unserialize($request['photo_i']);
$image_list = "";
$i = 0;
if ($images) {
foreach ($images as &$image) {
$image_url = db_get_data("SELECT url_photos FROM module_photos WHERE id = " . $image);
if ($i == 0) {
$image_list .= '<div class="carousel-item active" data-responsive="../photos/' . $image_url[0] . '" data-src="../photos/' . $image_url[0] . '" data-sub-html="AA"><img class="d-block center img-responsive" style="display:block; margin:auto;" loading="lazy" height="200px" alt="" src="../photos/' . $image_url[0] . '" data-holder-rendered="true"></div>';
} else {
$image_list .= '<div class="carousel-item" data-responsive="../photos/' . $image_url[0] . '" data-src="../photos/' . $image_url[0] . '" data-sub-html="AA"><img class="d-block center" style="display:block; margin:auto;" loading="lazy" height="200px" alt="" src="../photos/' . $image_url[0] . '" data-holder-rendered="true"></div>';
}
$i++;
}
} else {
$image_list = '<div class="carousel-item active"><p style="display:block; margin:auto; text-align: center;">Вложенные фотографии отсутствует</p></div>';
}
if (intval($request['citizen_id']) > 0) {
$author = "Житель: " . $name;
$author_phone = $name_phone;
$city = 'г.' . $city;
$street = ' ул.' . $house['street'];
$house = ' ' . $house['house_number'];
$flat_number = ", кв. " . $flat_data['flat_number'];
if ($request['uc_accepted'] > 0) {
if ($request['worker_uc_id'] > 0) {
$executor_name = "Сотрудник УК: " . $uc_worker;
$executor_name_phone = $uc_worker_phone;
} else {
$executor_name = "УК: " . $uc;
$executor_name_phone = $uc_phone;
}
} else {
$executor_name = "ОСИ: " . $osi;
$executor_name_phone = $osi_phone;
}
} else {
$author = "ОСИ: " . $osi;
$author_phone = $osi_phone;
$flat_number = " ";
$street = ' ул.' . $house['street'];
$house = ' ' . $house['house_number'];
$city = 'г.' . $city;
if ($request['uc_id'] > 0) {
if ($request['uc_accepted'] > 0) {
if ($request['worker_uc_id'] > 0) {