/home/banprang/domains/plai.go.th/public_html/coremain/function_theme.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
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
<?php
import_request_variables
('pG''p_');
//#5.3#//if($p_select!="")                                {     $select=trim($p_select);            }
$select = isset($p_select) ? $p_select '';

if(
$select!=""){
    
$sql="update cms_main_themes set status=0 where status=1";
    
$result=mysql_query($sql);

    
$sqlch="SELECT * FROM cms_main_themes WHERE id='$select'";
    
$re=mysql_query($sqlch);
    
$d=mysql_num_rows($re);
    if(
$d==1){
        
$sql="update cms_main_themes set status='1' where id='$select'";
        
$result=mysql_query($sql);
    }else{
        
$sql="INSERT INTO `cms_main_themes` VALUES('$select', '#AFB98A', '1', 'f01.swf', 'f02.jpg', '#66CD00', '#c9d4e5', '#e9b4da', '#B0DE00', '#F8FCE2', '#C2DFCA', '#77a091', 'menu1', 'top_1.jpg', 'top_2.jpg', 'top_3.jpg', 1, 0, '#9cbbea', '#daff6a', '', '', '', '', 'marker.gif')";
        
$re=mysql_query($sql);

        
$sql="update cms_main_themes set status='1' where id='$select'";
        
$result=mysql_query($sql);     
    }
  
  
##### T25 #####
  
if($select == 'v25'){
    
$header $_SESSION['web_name'].'/theme/'.$_SESSION['themes_'].'/'.$_SESSION['flash'];
    
$newheader $_SESSION['web_name'].'/theme/'.$select.'/'.$_SESSION['flash'];
    if (!
copy($header$newheader)) {
      echo 
"failed to copy $header...\n";
    }

    
$footer $_SESSION['web_name'].'/theme/'.$_SESSION['themes_'].'/'.$_SESSION["footer_bg"];
    
$newfooter $_SESSION['web_name'].'/theme/'.$select.'/'.$_SESSION["footer_bg"];
    if (!
copy($footer$newfooter)) {
      echo 
"failed to copy $footer...\n";
    }
       
    
mysql_query("UPDATE cms_main_themes SET home_template = 't25'");
    
mysql_query("UPDATE cms_menu_sub SET status = 0 WHERE url LIKE '%manage_template%'");
    
    
$curr_menu = array();
    
$m_count 0;
    
$sel_menu "SELECT * FROM cms_menu_top WHERE module_type!='other' and `lock`='1' and module_type in ('link','code','sponser') ORDER BY left_right, position";
    
$que_menu mysql_query($sel_menu);
    
$count 0;
    while(
$obj_menu mysql_fetch_assoc($que_menu)){
      
$curr_menu[$count] = $obj_menu;
      ++
$count;
    }
    
    foreach(
$curr_menu as $obj){
      ++
$m_count;
      
$obj['new_order'] = $m_count;
      
$array_menu[1][$obj['id_top']] = $obj;
    }
    
    foreach(
$array_menu as $blog => $element){
      foreach(
$element as $id => $ele){
        
$upd_menu "UPDATE cms_menu_top SET left_right = '$blog', position = '$ele[new_order]' WHERE id_top = '$ele[id_top]'";
        
mysql_query($upd_menu);
      }
    }
    
    echo
"<meta http-equiv='refresh' content='0; url=index.php'>";
  }else{
    if(
$_SESSION['template'] == 't25'){
      
mysql_query("UPDATE cms_main_themes SET home_template = 't01'");
      
mysql_query("UPDATE cms_menu_sub SET status = 1 WHERE url LIKE '%manage_template%'");
      
      
$sql_sub "SELECT id_top FROM cms_menu_sub WHERE url LIKE '%mod=question%'";
      
$que_sub mysql_query($sql_sub);
      while(
$obj_sub mysql_fetch_assoc($que_sub)){
        
mysql_query("UPDATE cms_menu_top SET module_type = 'link' WHERE id_top = '".$obj_sub['id_top']."'");
      }
      
      echo
"<meta http-equiv='refresh' content='0; url=index.php'>";
    }
  }
}


        
$sql="SELECT * FROM cms_main_themes WHERE status='1'";        
        
$re=mysql_query($sql);
        
$data=mysql_fetch_array($re);
            
            
$_SESSION['themes_']="$data[id]";                             // version_theme
            
$_SESSION['title_color']="$data[title_color]";                // title_color
            
$_SESSION['bg_body2']="$data[color1]";                        // bg_body2

            // table color
            
$_SESSION["tb_bgcolor"]="$data[bg_textrun]";                // table bgcolor
            
$_SESSION["tb_row_color1"]="$data[color]";                    // table row bgcolor 1  for swap color
            
$_SESSION["tb_row_color2"]="$data[color1]";                    // table row bgcolor 2  for swap color
            
$_SESSION["menu"]="$data[menu_ccs]";                        // menu_css
            
$_SESSION["tb_head_bgcolor"]="$data[bg_menu]";                
            
            
$_SESSION['bg_textrun']="$data[bg_textrun]";                //กลาง
            
$_SESSION['bg_header']="$data[heder_color]";                
                            
            
$_SESSION['bg_line']="$data[line_title_table]";                //เข้ม
            
            
$_SESSION['bg_menu']="$data[bg_menu]";                    //อ่อน

            //สีตัวอักษร
            
$_SESSION['bg_body1']="$data[color]";                                                                // Font Color

            //ขนาดความสูงของ Footer
            
$_SESSION['herder_top_03']="$data[herder_top_03]";                                    //ขนาดความสูงของ Footer        
    
            
            //menu font color
            
$_SESSION["head_menu_color"] = $data['h_menu_color'];
            
$_SESSION["sub_menu_color"] =  $data['sub_menu_color'];

            
// font footer
            
$_SESSION["footer_head"] = $data['footer_head'];
            
$_SESSION["footer_sub"] =  $data['footer_sub'];

            
// Image_Menu
            
$_SESSION['main_menu'] = isset($data['herder_top_01']) ? $data['herder_top_01'] : 'title.png';
            
$_SESSION["image_menu"] = isset($data['image_menu']) ? $data['image_menu'] : 'menu.jpg';

            
// Flash Header
            
$_SESSION["flash"] = $data['flash'];
            
$_SESSION["flash_width"] = isset($data['footer_head']) && $data['footer_head'] > $data['footer_head'] : ($_SESSION["flash_width"] != '' $_SESSION["flash_width"] : '100%');
            
$_SESSION["flash_height"] = isset($data['footer_sub']) && $data['footer_sub'] > $data['footer_sub'] : ($_SESSION["flash_height"] != '' $_SESSION["flash_height"] : '');

            
// Background
            
$_SESSION["background1"] = $data['herder_top_01'];
            
$_SESSION["background2"] = isset($data['sub_menu_color']) ? $data['sub_menu_color'] : 'background.gif';
            
$_SESSION["background3"] = $data['herder_top_02'];

            
// Footer
            
$_SESSION["footer_bg"] = isset($data['h_menu_color']) ? $data['h_menu_color'] : 'footer.gif';

            
// Navagator
            
$_SESSION["header_navigator"] = isset($data['header_navigator']) ? $data['header_navigator'] : 'navagator.jpg';
            
$_SESSION["height_navigator"] = isset($data['height_navigator']) ? $data['height_navigator'] : '30';        
            
$_SESSION["icon_navigator"] = isset($data['icon_navigator']) ? $data['icon_navigator'] : (file_exists("$_SESSION[web_name]/theme/$_SESSION[themes_]/$data[image_menu]") ? $data['image_menu'] : 'icon.gif');        
            
// Bar Header
             
$_SESSION["bar_header1"] = isset($data['header_navigator']) ? $data['navigrator'] : (file_exists("$_SESSION[web_name]/theme/$_SESSION[themes_]/bar1.gif") ? 'bar1.gif' 'bar01.gif');
            
$_SESSION["bar_header2"] = isset($data['header_navigator']) ? $data['title_color'] : (file_exists("$_SESSION[web_name]/theme/$_SESSION[themes_]/bar1.gif") ? 'bar2.gif' 'bar02.gif');
            
$_SESSION["bar_header3"] = isset($data['header_navigator']) ? $data['bg_list_table'] : (file_exists("$_SESSION[web_name]/theme/$_SESSION[themes_]/bar1.gif") ? 'bar3.gif' 'bar03.gif');
            
            if(!isset(
$data['home_template'])){
              
mysql_query("ALTER TABLE `cms_main_themes` ADD `home_template` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 't01';");
              
mysql_query("ALTER TABLE `cms_main_themes` CHANGE `h_menu_color` `h_menu_color` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
              
mysql_query("ALTER TABLE `cms_main_themes` CHANGE `sub_menu_color` `sub_menu_color` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;");
              
$_SESSION['template'] = 't01';
              
              
$chkMTemplate mysql_query("SELECT id_sub FROM cms_menu_sub WHERE name = 'เปลี่ยนรูปแบบ/Template'");
              
$MTemplate mysql_num_rows($chkMTemplate);
              if(
$MTemplate == 0){
                
$queOrder mysql_query("SELECT MAX(position) AS position FROM cms_menu_sub WHERE id_top = '1'");
                
$objOrder mysql_fetch_assoc($queOrder);
                
$mxOrder $objOrder['position'] + 1;
                
mysql_query("INSERT INTO `cms_menu_sub` (`id_sub`, `id_top`, `id_type`, `name`, `url`, `position`, `status`) VALUES ('0', '1', '1', 'เปลี่ยนรูปแบบ/Template', 'index.php?mod=manage_template&path=template', '$mxOrder', '1');");
                
mysql_query("UPDATE `cms_menu_sub` SET name = 'เปลี่ยน Banner/พื้นหลัง/Footer' WHERE name = 'เปลี่ยน Flash/พื้นหลัง/Footer';");
              
                
set_menu_graphic();
              }
            }else{
              
$_SESSION['template'] = $data['home_template'];
            }
            
            
//##### T25 +++ Animation #####
            
if(!isset($data['animation_01'])){
              
mysql_query("ALTER TABLE `cms_main_themes` ADD `web_main` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;");
              
mysql_query("ALTER TABLE `cms_main_themes` ADD `animation_01` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;");
              
mysql_query("ALTER TABLE `cms_main_themes` ADD `animation_01_status` INT NOT NULL DEFAULT '0';");
              
mysql_query("ALTER TABLE `cms_main_themes` ADD `animation_02` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;");
              
mysql_query("ALTER TABLE `cms_main_themes` ADD `animation_02_status` INT NOT NULL DEFAULT '0';");
              
mysql_query("UPDATE `cms_main_themes` SET `web_main` = 'coremain'");
              
mysql_query("INSERT INTO `cms_main_themes` (`id`, `footer`, `flash`, `navigrator`, `heder_color`, `title_color`, `line_title_table`, `bg_list_table`, `color`, `color1`, `menu_ccs`, `herder_top_01`, `herder_top_02`, `herder_top_03`, `herder_status`, `status`, `bg_textrun`, `bg_menu`, `h_menu_color`, `sub_menu_color`, `footer_head`, `footer_sub`, `image_menu`, `id_type`, `home_template`, `web_main`, `animation_01`, `animation_02`) VALUES ('v25', '2', '".$_SESSION['flash']."', '#cc9122', '#ac535c', '#b88474', '#774233', '#ddc29e', '#f2ecda', '#a5a89e', '".$_SESSION['menu']."', 'main_icon.png', 'bar_icon.png', 'icon.png', 1, 0, '#537e75', '#ddc29e', '".$_SESSION['footer_bg']."', '".$_SESSION['background2']."', '1000', '300', 'menu_icon.png', 1, '".$_SESSION['template']."', 'web_main', '', '')");
              
$_SESSION['animation_01'] = '';
              
$_SESSION['animation_01_status'] = '0';
              
$_SESSION['animation_02'] = '';
              
$_SESSION['animation_02_status'] = '0';
            }else{
              
$_SESSION['animation_01'] = $data['animation_01'];
              
$_SESSION['animation_01_status'] = $data['animation_01_status'];
              
$_SESSION['animation_02'] = $data['animation_02'];
              
$_SESSION['animation_02_status'] = $data['animation_02_status'];
            }
            
$sT25 "SELECT id FROM cms_main_themes WHERE id = 'v25'";
            
$qT25 mysql_query($sT25);
            
$nT25 mysql_num_rows($qT25);
            if(
$nT25 == 0){
              
mysql_query("INSERT INTO `cms_main_themes` (`id`, `footer`, `flash`, `navigrator`, `heder_color`, `title_color`, `line_title_table`, `bg_list_table`, `color`, `color1`, `menu_ccs`, `herder_top_01`, `herder_top_02`, `herder_top_03`, `herder_status`, `status`, `bg_textrun`, `bg_menu`, `h_menu_color`, `sub_menu_color`, `footer_head`, `footer_sub`, `image_menu`, `id_type`, `home_template`, `web_main`, `animation_01`, `animation_02`) VALUES ('v25', '2', '".$_SESSION['flash']."', '#cc9122', '#ac535c', '#b88474', '#774233', '#ddc29e', '#f2ecda', '#a5a89e', '".$_SESSION['menu']."', 'main_icon.png', 'bar_icon.png', 'icon.png', 1, 0, '#537e75', '#ddc29e', '".$_SESSION['footer_bg']."', '".$_SESSION['background2']."', '1000', '300', 'menu_icon.png', 1, '".$_SESSION['template']."', 'web_main', '', '')");
            }
  
//##### New Module #####//
$chkModuleQuestion mysql_query("select * from cms_module where e_name = 'question'");
$numModuleQuestion mysql_num_rows($chkModuleQuestion);
if(
$numModuleQuestion == 0){
  
//##### 1 - Questionnaire #####//
  
mysql_query("insert into cms_module (name, allow, e_name) values ('แบบสอบถาม', '3', 'question')");
  
  
mysql_query("CREATE TABLE `cms_question` (
                `id_question` int(11) NOT NULL PRIMARY KEY,
                `topic` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
                `status` int(11) NOT NULL DEFAULT '1',
                `id_sub` int(11) NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("CREATE TABLE `cms_question_ansheader` (
                `header_id` int(11) NOT NULL PRIMARY KEY,
                `question_id` int(11) NOT NULL,
                `user_ip` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
                `datetime` varchar(50) COLLATE utf8_unicode_ci NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("CREATE TABLE `cms_question_answer` (
                `answer_id` int(11) NOT NULL PRIMARY KEY,
                `header_id` int(11) NOT NULL,
                `question_id` int(11) NOT NULL,
                `title_id` int(11) NOT NULL,
                `type_id` int(11) NOT NULL,
                `parent_id` int(11) NOT NULL,
                `answer` text COLLATE utf8_unicode_ci NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("CREATE TABLE `cms_question_choice` (
                `choice_id` int(11) NOT NULL PRIMARY KEY,
                `choice_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `choice_order` int(11) NOT NULL,
                `title_id` int(11) NOT NULL,
                `question_id` int(11) NOT NULL,
                `choice_status` int(11) NOT NULL DEFAULT '1'
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("CREATE TABLE `cms_question_title` (
                `title_id` int(11) NOT NULL PRIMARY KEY,
                `title_name` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
                `title_parent` int(11) NOT NULL,
                `title_order` int(11) NOT NULL,
                `question_id` int(11) NOT NULL,
                `type_id` int(11) NOT NULL,
                `title_other` int(11) NOT NULL DEFAULT '0',
                `title_status` int(11) NOT NULL DEFAULT '1',
                `title_validate` int(11) NOT NULL DEFAULT '1'
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("CREATE TABLE `cms_question_type` (
                `type_id` int(11) NOT NULL PRIMARY KEY,
                `type_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("INSERT INTO `cms_question_type` (`type_id`, `type_name`) VALUES
                  (1, 'ถาม-ตอบ'),
                  (2, 'ระดับความพึงพอใจ'),
                  (3, 'ตอบได้หลายข้อ'),
                  (4, 'ตอบได้ข้อเดียว'),
                  (5, 'ข้อเสนอแนะ'),
                  (6, 'คำอธิบาย');"
);
  
  
//##### 2 - E-Service #####//
  
mysql_query("CREATE TABLE `cms_eservice` (
                `id` int(11) NOT NULL PRIMARY KEY,
                `type_id` int(11) NOT NULL,
                `topic` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `detail` text COLLATE utf8_unicode_ci NOT NULL,
                `sender_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `sender_tel` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
                `sender_mail` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
                `send_date` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
                `sender_ip` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
                `file_attach` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `service_status` int(11) NOT NULL DEFAULT '0' COMMENT '0:receive, 1:waiting, 2:complete, 3:information',
                `remark` text COLLATE utf8_unicode_ci NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("CREATE TABLE `cms_service_title` (
                `title_id` int(11) NOT NULL PRIMARY KEY,
                `title_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `title_status` int(11) NOT NULL DEFAULT '1'
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("INSERT INTO `cms_service_title` (`title_id`, `title_name`, `title_status`) VALUES
                  (1, 'รับเรื่องราวร้องทุกข์', 1),
                  (2, 'ร้องเรียนการทุจริต', 1),
                  (3, 'สายตรงนายกองค์การบริหารส่วนตำบล', 1),
                  (4, 'สายตรงปลัดองค์การบริหารส่วนตำบล', 1);"
);


  
//##### 3 - EGP #####//
  
mysql_query("CREATE TABLE `cms_egprss` (
                `egp_id` int(11) NOT NULL,
                `egp_title` varchar(500) NOT NULL,
                `egp_description` varchar(250) NOT NULL,
                `egp_rss_title` varchar(500) NOT NULL,
                `egp_rss_link` varchar(500) NOT NULL,
                `egp_rss_pub_date` date NOT NULL,
                `egp_date` date NOT NULL,
                `id_home` int(11) NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
);
  
  
  
// default questionnaire
    # main blog
    
$sqlTop "select max(id_top+1) from cms_menu_top";
    
$queTop mysql_query($sqlTop);
    
$maxTop mysql_fetch_row($queTop);
    
$sqlPos "select max(`position`+1) from cms_menu_top where left_right = '2'";
    
$quePos mysql_query($sqlPos);
    
$maxPos mysql_fetch_row($quePos);
    
mysql_query("INSERT INTO cms_menu_top (id_top, name, position, left_right, `status`, `lock`, module_type, permission) values ('$maxTop[0]', 'แบบสอบถาม', '$maxPos[0]', '2', '1', 1, 'link', 0)");
    
# sub menu
    
$sqlSub "select max(id_sub+1) from `cms_menu_sub`";
    
$queSub mysql_query($sqlSub);
    
$maxSub mysql_fetch_row($queSub);
    
$url "index.php?mod=question&path=question&id_sub=$maxSub[0]";
    
$menuname 'แบบสอบถามความพึงพอใจต่อการให้บริการ';
    
mysql_query("INSERT INTO `cms_menu_sub` (`id_sub`, `id_top`, `id_type`, `name`, `url`, `position`, `status`) VALUES ('$maxSub[0]', '$maxTop[0]', '1', '$menuname', '$url', '1', '1')");
    
# main question
    
$sqlQst "select max(id_question) + 1 from cms_question";
    
$queQst mysql_query($sqlQst);
    
$maxQst mysql_fetch_row($queQst);
    
$QstId $maxQst[0] == '' $maxQst[0];
    
mysql_query("INSERT INTO cms_question (id_question, topic, id_sub) VALUES ('$QstId', '$menuname', '$maxSub[0]')");
    
# question title
    
$sqlMain "select name_web from cms_main_data where id_main_data = '1'";
    
$queMain mysql_query($sqlMain);
    
$objMain mysql_fetch_row($queMain);
    
$MainName $objMain[0];
    
mysql_query("INSERT INTO `cms_question_title` (`title_id`, `title_name`, `title_parent`, `title_order`, `question_id`, `type_id`, `title_other`, `title_status`, `title_validate`) VALUES
      (1, 'แบบสอบถามความพึงพอใจ', 0, 1, 1, 6, 0, 1, 1),
      (2, '<p> 
$MainName ได้จัดทำแบบสอบถามความพึงพอใจของประชาชนที่มีต่อการให้บริการของ$MainName หรือหน่วยงานต่างๆ ที่มาติดต่อใช้บริการงานด้านต่างๆ ของ$MainName เพื่อนำข้อมูลที่ได้จากการสำรวจนี้มาประมวลสรุปผลลัพธ์ทำแผนปรับปรุงการให้บริการ และดำเนินการแก้ไขข้อบกพร่องของการบริการด้านต่างๆ ให้มีประสิทธิภาพ และตรงกับความต้องการของผู้รับบริการมากยิ่งขึ้นต่อไป</p>\r\n', 1, 1, 1, 0, 0, 1, 1),
      (3, 'ส่วนที่ 1 : ข้อมูลทั่วไปผู้ขอรับบริการ', 0, 2, 1, 1, 0, 1, 1),
      (4, 'ชื่อผู้ขอรับบริการ (บุคคลหรือหน่วยงาน)', 3, 1, 1, 0, 0, 1, 1),
      (5, 'ที่อยู่ผู้ขอรับบริการ', 3, 2, 1, 0, 0, 1, 0),
      (6, 'โทรศัพท์ผู้ขอรับบริการ', 3, 3, 1, 0, 0, 1, 1),
      (7, 'ขอรับบริการจาก (ชื่อหน่วยงานผู้ให้บริการ)', 3, 4, 1, 0, 0, 1, 1),
      (8, 'ส่วนที่ 2 : เรื่องที่ขอรับบริการ', 0, 3, 1, 4, 0, 1, 1),
      (9, 'การขอข้อมูลข่าวสารทางราชการ', 8, 1, 1, 0, 0, 1, 1),
      (10, 'การยื่นเรื่องร้องทุกข์/ร้องเรียน', 8, 2, 1, 0, 0, 1, 1),
      (11, 'การใช้ Internet ตำบล', 8, 3, 1, 0, 0, 1, 1),
      (12, 'การขออนุญาตปลูกสร้างอาคาร', 8, 4, 1, 0, 0, 1, 1),
      (13, 'การขอแบบบ้านเพื่อประชาชน', 8, 5, 1, 0, 0, 1, 1),
      (14, 'การออกแบบอาคาร', 8, 6, 1, 0, 0, 1, 1),
      (15, 'การชำระภาษีโรงเรือนและที่ดิน', 8, 7, 1, 0, 0, 1, 1),
      (16, 'การชำระภาษีป้าย', 8, 8, 1, 0, 0, 1, 1),
      (17, 'การชำระภาษีบำรุงท้องที่', 8, 9, 1, 0, 0, 1, 1),
      (18, 'การขอรับเบี้ยยังชีพผู้สูงอายุ', 8, 10, 1, 0, 0, 1, 1),
      (19, 'การขอรับเบี้ยยังชีพคนพิการ', 8, 11, 1, 0, 0, 1, 1),
      (20, 'การขอรับเบี้ยยังชีพผู้ป่วยโรคเอดส์', 8, 12, 1, 0, 0, 1, 1),
      (21, 'การฉีดวัคซีนป้องกันโรคพิษสุนัขบ้า', 8, 13, 1, 0, 0, 1, 1),
      (22, 'การฉีดพ่นสารเคมีเพื่อป้องกันโรคไข้เลือดออก', 8, 14, 1, 0, 0, 1, 1),
      (23, 'การขอจัดตั้งสถานจำหน่ายอาหารและสะสมอาหาร', 8, 15, 1, 0, 0, 1, 1),
      (24, 'การขอประกอบกิจการที่เป็นอันตรายต่อสุขภาพ', 8, 16, 1, 0, 0, 1, 1),
      (25, 'การสมัครเข้าเรียนในศูนย์ศิลปวัฒนธรรม และภูมิปัญญาท้องถิ่น', 8, 17, 1, 0, 0, 1, 1),
      (26, 'อื่นๆ', 8, 18, 1, 0, 1, 1, 1),
      (27, 'ส่วนที่ 3 : แบบสอบถามความพึงพอใจที่มีต่อการให้บริการ', 0, 4, 1, 6, 0, 1, 1),
      (28, '<p>หัวข้อแบบสอบถามความพึงพอใจ</p>\r\n', 27, 1, 1, 0, 0, 1, 1),
      (29, '1. ด้านเจ้าหน้าที่ผู้ให้บริการ', 0, 5, 1, 2, 0, 1, 1),
      (30, 'เจ้าหน้าที่พูดจาสุภาพ อัธยาศัยดี แต่งกายสุภาพ การวางตัว เรียบร้อย', 29, 1, 1, 0, 0, 1, 1),
      (31, 'เจ้าหน้าที่ให้บริการด้วยความเต็มใจ รวดเร็ว และเอาใจใส่', 29, 2, 1, 0, 0, 1, 1),
      (32, 'เจ้าหน้าที่ให้คำแนะนำ ตอบข้อซักถามได้อย่างชัดเจน ถูกต้อง น่าเชื่อถือ', 29, 3, 1, 0, 0, 1, 1),
      (33, 'เจ้าหน้าที่สามารถแก้ปัญหา อุปสรรค ที่เกิดขึ้นได้อย่างเหมาะสม', 29, 4, 1, 0, 0, 1, 1),
      (34, '2. ด้านกระบวนการขั้นตอนการให้บริการ', 0, 6, 1, 2, 0, 1, 1),
      (35, 'มีช่องทางการให้บริการที่หลากหลาย', 34, 1, 1, 0, 0, 1, 1),
      (36, 'ขั้นตอนการให้บริการมีระบบ ไม่ยุ่งยาก ซับซ้อน มีความชัดเจน', 34, 2, 1, 0, 0, 1, 1),
      (37, 'ขั้นตอนการให้บริการแต่ละขั้นตอนมีความสะดวก รวดเร็ว', 34, 3, 1, 0, 0, 1, 1),
      (38, 'มีผังลำดับขั้นตอนและระยะเวลาการให้บริการอย่างชัดเจน', 34, 4, 1, 0, 0, 1, 1),
      (39, '3. ด้านสิ่งอำนวยความสะดวก', 0, 7, 1, 2, 0, 1, 1),
      (40, 'การจัดสิ่งอำนวยความสะดวกในสถานที่ให้บริการ เช่น ที่จอดรถ น้ำดื่ม', 39, 1, 1, 0, 0, 1, 1),
      (41, 'มีเครื่องมือ/อุปกรณ์/ระบบในการบริการข้อมูลสารสนเทศ', 39, 2, 1, 0, 0, 1, 1),
      (42, 'มีการจัดผังการให้บริการและการใช้อาคารไว้อย่างชัดเจนสะดวก เหมาะสม', 39, 3, 1, 0, 0, 1, 1),
      (43, 'อาคารสถานที่มีความสะอาด ปลอดภัย', 39, 4, 1, 0, 0, 1, 1),
      (44, 'ส่วนที่ 4 : ท่านคิดว่า 
$MainName ควรปรับปรุงด้านใด (ตอบได้มากกว่า 1 ข้อ)', 0, 8, 1, 3, 0, 1, 1),
      (45, 'ด้านการให้บริการของเจ้าหน้าที่ในหน่วยงาน', 44, 1, 1, 0, 0, 1, 1),
      (46, 'ด้านข้อมูลข่าวสารที่ให้บริการแก่ประชาชน', 44, 2, 1, 0, 0, 1, 1),
      (47, 'ด้านสถานที่ในการบริการข้อมูลข่าวสาร', 44, 3, 1, 0, 0, 1, 1),
      (48, 'ด้านวิธีการเข้ามามีส่วนร่วมของประชาชนในการจัดทำแผนพัฒนา', 44, 4, 1, 0, 0, 1, 1),
      (49, 'ด้านบริการการรับชำระภาษี', 44, 5, 1, 0, 0, 1, 1),
      (50, 'ด้านบริการการอนุญาตก่อสร้างอาคาร', 44, 6, 1, 0, 0, 1, 1),
      (51, 'อื่นๆ', 44, 7, 1, 0, 1, 1, 1),
      (52, 'ข้อเสนอแนะ', 0, 9, 1, 5, 0, 1, 1);"
);
    
mysql_query("INSERT INTO `cms_question_choice` (`choice_id`, `choice_name`, `choice_order`, `title_id`, `question_id`, `choice_status`) VALUES
      (1, 'มากที่สุด', 1, 29, 1, 1),
      (2, 'มาก', 2, 29, 1, 1),
      (3, 'ปานกลาง', 3, 29, 1, 1),
      (4, 'น้อย', 4, 29, 1, 1),
      (5, 'ควรปรับปรุง', 5, 29, 1, 1),
      (6, 'มากที่สุด', 1, 34, 1, 1),
      (7, 'มาก', 2, 34, 1, 1),
      (8, 'ปานกลาง', 3, 34, 1, 1),
      (9, 'น้อย', 4, 34, 1, 1),
      (10, 'ควรปรับปรุง', 5, 34, 1, 1),
      (11, 'มากที่สุด', 1, 39, 1, 1),
      (12, 'มาก', 2, 39, 1, 1),
      (13, 'ปานกลาง', 3, 39, 1, 1),
      (14, 'น้อย', 4, 39, 1, 1),
      (15, 'ควรปรับปรุง', 5, 39, 1, 1);"
);
}

chmod($_SESSION['web_name'], 0755);
# create folder for e-service
$dir_eservice $_SESSION['web_name'].'/module_eservice/';
if(
$_SESSION['web_name'] != '' && !is_dir($dir_eservice)){
  
mkdir($dir_eservice0755true);
}
# create folder for e-service1 # 25032021
$dir_eservice1 $_SESSION['web_name'].'/module_eservice1/';
if(
$_SESSION['web_name'] != '' && !is_dir($dir_eservice1)){
  
mkdir($dir_eservice10755true);
  
  
//##### 25/03/2021 : E-Service1 #####//
  
mysql_query("CREATE TABLE `cms_eservice1` (
                `id` int(11) NOT NULL PRIMARY KEY,
                `type_id` int(11) NOT NULL,
                `topic` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `detail` text COLLATE utf8_unicode_ci NOT NULL,
                `sender_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `sender_tel` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
                `sender_mail` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
                `send_date` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
                `sender_ip` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
                `file_attach` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `service_status` int(11) NOT NULL DEFAULT '0' COMMENT '0:receive, 1:waiting, 2:complete, 3:information',
                `remark` text COLLATE utf8_unicode_ci NOT NULL
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
//##### 26/03/2021 #####//
  
mysql_query("CREATE TABLE `cms_service_title1` (
                `title_id` int(11) NOT NULL PRIMARY KEY,
                `title_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `title_status` int(11) NOT NULL DEFAULT '1'
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
  
mysql_query("INSERT INTO `cms_service_title1` (`title_id`, `title_name`, `title_status`) VALUES
                  (1, 'คำร้องขอใช้รถน้ำ', 1),
                  (2, 'คำร้องขอใช้น้ำประปา', 1);"
);
}
# create folder for file editor thumb
$dir_editor $_SESSION['web_name'].'/file_thumbs/';
if(
$_SESSION['web_name'] != '' && !is_dir($dir_editor)){
  
mkdir($dir_editor0755true);
}
chmod($_SESSION['web_name'], 0555);
//####### End New Module ########//

$template = isset($p_template) ? $p_template '';
if(
$template != ''){
  
$currTemplate $_SESSION['template'];
  
$_SESSION['template'] = $template;
  
  
$menu_top = array();
  
$menu_count = array('1' => 0'2' => 0'3' => 0);
//  $template_34 = array('boss_message' => '1', 'calendar' => '2', 'service' => '3', 'poll' => '4', 'counter' => '5');
  
$template_78 = array('calendar' => '1''service' => '2''web_link' => '3''poll' => '4''counter' => '5');
  
$sel_menu "SELECT * FROM cms_menu_top WHERE module_type!='other' and `lock`='1' ORDER BY left_right, position";
  
$que_menu mysql_query($sel_menu);
  
$count 0;
  while(
$obj_menu mysql_fetch_assoc($que_menu)){
//    $menu_top[$obj_menu['id_top']] = $obj_menu;
//    $menu_order[$obj_menu['position']] = $obj_menu;
    
$menu_top[$count] = $obj_menu;
    
$curr_blog[$obj_menu['left_right']] = $obj_menu['left_right'];
    ++
$count;
  }
  
sort($curr_blog);
  
$str_blog implode(''$curr_blog);
  
$half round($count 2);
  
  
$array_menu = array();
  if(
$currTemplate == 't07'# 123
  
{
    if(
in_array($template, array('t01''t02'))){ # 12
      
foreach($menu_top as $codr => $obj){
        if(
$codr $half){
          ++
$menu_count[1];
          
$obj['new_order'] = $menu_count[1];
          
$array_menu[1][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[2];
          
$obj['new_order'] = $menu_count[2];
          
$array_menu[2][$obj['id_top']] = $obj;
        }
      }
    }else if(
in_array($template, array('t03''t05''t09'))){ # 13
      
foreach($menu_top as $codr => $obj){
        if(
$codr $half){
          ++
$menu_count[1];
          
$obj['new_order'] = $menu_count[1];
          
$array_menu[1][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[3];
          
$obj['new_order'] = $menu_count[3];
          
$array_menu[3][$obj['id_top']] = $obj;
        }
      }
    }else if(
in_array($template, array('t04''t06''t10'))){ # 23
      
foreach($menu_top as $codr => $obj){
        if(
$codr $half){
          ++
$menu_count[2];
          
$obj['new_order'] = $menu_count[2];
          
$array_menu[2][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[3];
          
$obj['new_order'] = $menu_count[3];
          
$array_menu[3][$obj['id_top']] = $obj;
        }
      }
    }else if(
$template == 't08'){ # 213
      
foreach($menu_top as $obj){
        if(
$obj['left_right'] == 3){
          ++
$menu_count[3];
          
$obj['new_order'] = $menu_count[3];
          
$array_menu[3][$obj['id_top']] = $obj;
        }else if(
$obj['left_right'] == 1){
          ++
$menu_count[2];
          
$obj['new_order'] = $menu_count[2];
          
$array_menu[2][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[1];
          
$obj['new_order'] = $menu_count[1];
          
$array_menu[1][$obj['id_top']] = $obj;
        }
      }
    }else{
      foreach(
$menu_top as $obj){
        ++
$menu_count[$obj['left_right']];
        
$obj['new_order'] = $menu_count[$obj['left_right']];
        
$array_menu[$obj['left_right']][$obj['id_top']] = $obj;
      }
    }
  }
  else if(
$currTemplate == 't08'# 213
  
{
    if(
in_array($template, array('t01''t02'))){ # 12
      
foreach($menu_top as $codr => $obj){
        if(
$codr $half){
          ++
$menu_count[1];
          
$obj['new_order'] = $menu_count[1];
          
$array_menu[1][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[2];
          
$obj['new_order'] = $menu_count[2];
          
$array_menu[2][$obj['id_top']] = $obj;
        }
      }
    }else if(
in_array($template, array('t03''t05''t09'))){ # 13
      
foreach($menu_top as $codr => $obj){
        if(
$codr $half){
          ++
$menu_count[1];
          
$obj['new_order'] = $menu_count[1];
          
$array_menu[1][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[3];
          
$obj['new_order'] = $menu_count[3];
          
$array_menu[3][$obj['id_top']] = $obj;
        }
      }
    }else if(
in_array($template, array('t04''t06''t10'))){ # 23
      
foreach($menu_top as $codr => $obj){
        if(
$codr $half){
          ++
$menu_count[2];
          
$obj['new_order'] = $menu_count[2];
          
$array_menu[2][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[3];
          
$obj['new_order'] = $menu_count[3];
          
$array_menu[3][$obj['id_top']] = $obj;
        }
      }
    }else if(
$template == 't07'){ # 123
      
foreach($menu_top as $obj){
        if(
$obj['left_right'] == 3){
          ++
$menu_count[3];
          
$obj['new_order'] = $menu_count[3];
          
$array_menu[3][$obj['id_top']] = $obj;
        }else if(
$obj['left_right'] == 1){
          ++
$menu_count[2];
          
$obj['new_order'] = $menu_count[2];
          
$array_menu[2][$obj['id_top']] = $obj;
        }else{
          ++
$menu_count[1];
          
$obj['new_order'] = $menu_count[1];
          
$array_menu[1][$obj['id_top']] = $obj;
        }
      }
    }else{
      foreach(
$menu_top as $obj){
        ++
$menu_count[$obj['left_right']];
        
$obj['new_order'] = $menu_count[$obj['left_right']];
        
$array_menu[$obj['left_right']][$obj['id_top']] = $obj;
      }
    }
  }
  else
  {
    if(
$str_blog == '12'# t01, t02
    
{
      if(
in_array($template, array('t03''t05''t09'))){
        foreach(
$menu_top as $obj){
          if(
$obj['left_right'] == 1){
            ++
$menu_count[1];
            
$obj['new_order'] = $menu_count[1];
            
$array_menu[1][$obj['id_top']] = $obj;
          }else if(
$obj['left_right'] == 2){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }
        }
      }else if(
in_array($template, array('t04''t06''t10'))){
        foreach(
$menu_top as $obj){
          if(
$obj['left_right'] == 2){
            ++
$menu_count[2];
            
$obj['new_order'] = $menu_count[2];
            
$array_menu[2][$obj['id_top']] = $obj;
          }else if(
$obj['left_right'] == 1){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }
        }
      }else if(
$template == 't07'){
        foreach(
$menu_top as $codr => $obj){
          if(
$obj['left_right'] == 2){
            ++
$menu_count[2];
            
$obj['new_order'] = $menu_count[2];
            
$array_menu[2][$obj['id_top']] = $obj;
          }else{
            if(
$codr 4){
              ++
$menu_count[1];
              
$obj['new_order'] = $menu_count[1];
              
$array_menu[1][$obj['id_top']] = $obj;
            }else{
              ++
$menu_count[3];
              
$obj['new_order'] = $menu_count[3];
              
$array_menu[3][$obj['id_top']] = $obj;
            }
          }
        }
      }else if(
$template == 't08'){
        foreach(
$menu_top as $codr => $obj){
          if(
$obj['left_right'] == 1){
            ++
$menu_count[1];
            
$obj['new_order'] = $menu_count[1];
            
$array_menu[1][$obj['id_top']] = $obj;
          }else{
            if(
$codr 4){
              ++
$menu_count[2];
              
$obj['new_order'] = $menu_count[2];
              
$array_menu[2][$obj['id_top']] = $obj;
            }else{
              ++
$menu_count[3];
              
$obj['new_order'] = $menu_count[3];
              
$array_menu[3][$obj['id_top']] = $obj;
            }
          }
        }
      }else{
        foreach(
$menu_top as $obj){
          ++
$menu_count[$obj['left_right']];
          
$obj['new_order'] = $menu_count[$obj['left_right']];
          
$array_menu[$obj['left_right']][$obj['id_top']] = $obj;
        }
      }
    }
    else if(
$str_blog == '13'# t03, t05, t09
    
{
      if(
in_array($template, array('t01''t02'))){
        foreach(
$menu_top as $obj){
          if(
$obj['left_right'] == 1){
            ++
$menu_count[1];
            
$obj['new_order'] = $menu_count[1];
            
$array_menu[1][$obj['id_top']] = $obj;
          }else if(
$obj['left_right'] == 3){
            ++
$menu_count[2];
            
$obj['new_order'] = $menu_count[2];
            
$array_menu[2][$obj['id_top']] = $obj;
          }
        }
      }else if(
in_array($template, array('t04''t06''t10'))){
        foreach(
$menu_top as $obj){
          if(
$obj['left_right'] == 3){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }else if(
$obj['left_right'] == 1){
            ++
$menu_count[2];
            
$obj['new_order'] = $menu_count[2];
            
$array_menu[2][$obj['id_top']] = $obj;
          }
        }
      }else if(
$template == 't07'){
        foreach(
$menu_top as $codr => $obj){
          if(
$obj['left_right'] == 3){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }else{
            if(
$codr 4){
              ++
$menu_count[1];
              
$obj['new_order'] = $menu_count[1];
              
$array_menu[1][$obj['id_top']] = $obj;
            }else{
              ++
$menu_count[2];
              
$obj['new_order'] = $menu_count[2];
              
$array_menu[2][$obj['id_top']] = $obj;
            }
          }
        }
      }else if(
$template == 't08'){
        foreach(
$menu_top as $codr => $obj){
          if(
$obj['left_right'] == 3){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }else{
            if(
$codr 4){
              ++
$menu_count[2];
              
$obj['new_order'] = $menu_count[2];
              
$array_menu[2][$obj['id_top']] = $obj;
            }else{
              ++
$menu_count[1];
              
$obj['new_order'] = $menu_count[1];
              
$array_menu[1][$obj['id_top']] = $obj;
            }
          }
        }
      }else{
        foreach(
$menu_top as $obj){
          ++
$menu_count[$obj['left_right']];
          
$obj['new_order'] = $menu_count[$obj['left_right']];
          
$array_menu[$obj['left_right']][$obj['id_top']] = $obj;
        }
      }
    }
    else if(
$str_blog == '23'# t04, t06, t10
    
{
      if(
in_array($template, array('t01''t02'))){
        foreach(
$menu_top as $obj){
          if(
$obj['left_right'] == 2){
            ++
$menu_count[2];
            
$obj['new_order'] = $menu_count[2];
            
$array_menu[2][$obj['id_top']] = $obj;
          }else if(
$obj['left_right'] == 3){
            ++
$menu_count[1];
            
$obj['new_order'] = $menu_count[1];
            
$array_menu[1][$obj['id_top']] = $obj;
          }
        }
      }else if(
in_array($template, array('t03''t05''t09'))){
        foreach(
$menu_top as $obj){
          if(
$obj['left_right'] == 3){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }else if(
$obj['left_right'] == 2){
            ++
$menu_count[1];
            
$obj['new_order'] = $menu_count[1];
            
$array_menu[1][$obj['id_top']] = $obj;
          }
        }
      }else if(
$template == 't07'){
        foreach(
$menu_top as $codr => $obj){
          if(
$obj['left_right'] == 3){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }else{
            if(
$codr 4){
              ++
$menu_count[1];
              
$obj['new_order'] = $menu_count[1];
              
$array_menu[1][$obj['id_top']] = $obj;
            }else{
              ++
$menu_count[2];
              
$obj['new_order'] = $menu_count[2];
              
$array_menu[2][$obj['id_top']] = $obj;
            }
          }
        }
      }else if(
$template == 't08'){
        foreach(
$menu_top as $codr => $obj){
          if(
$obj['left_right'] == 3){
            ++
$menu_count[3];
            
$obj['new_order'] = $menu_count[3];
            
$array_menu[3][$obj['id_top']] = $obj;
          }else{
            if(
$codr 4){
              ++
$menu_count[2];
              
$obj['new_order'] = $menu_count[2];
              
$array_menu[2][$obj['id_top']] = $obj;
            }else{
              ++
$menu_count[1];
              
$obj['new_order'] = $menu_count[1];
              
$array_menu[1][$obj['id_top']] = $obj;
            }
          }
        }
      }else{
        foreach(
$menu_top as $obj){
          ++
$menu_count[$obj['left_right']];
          
$obj['new_order'] = $menu_count[$obj['left_right']];
          
$array_menu[$obj['left_right']][$obj['id_top']] = $obj;
        }
      }
    }
  }
//  echo '<pre>';
//  print_r($array_menu);
//  echo '</pre>';
  
  
$update_template "UPDATE cms_main_themes SET home_template = '$template'";
  
$query_update mysql_query($update_template);
  if(
$query_update){
    foreach(
$array_menu as $blog => $element){
      foreach(
$element as $id => $ele){
        
$upd_menu "UPDATE cms_menu_top SET left_right = '$blog', position = '$ele[new_order]' WHERE id_top = '$ele[id_top]'";
        
mysql_query($upd_menu);
      }
    }
  }
  
  echo 
"<meta http-equiv='refresh' content='0; url=index.php'>";
}


function 
set_menu_graphic(){
  
$arrayMTop = array(
    
'0.gif' => 'อบต.ในเครือข่าย',
    
'1.gif' => 'หมู่บ้านในเขต อบต.',
    
'2.gif' => 'ปฏิทินกิจกรรม',
    
'3.gif' => 'โรงแรม/ที่พัก',
    
'4.gif' => 'ข้อมูลพื้นฐาน อบต.',
    
'5.gif' => 'รวมลิงค์ต่างๆ',
    
'6.gif' => 'ระบบ MIS',
    
'7.gif' => 'โครงสร้างการบริหาร',
    
'8.gif' => 'ผลิตภัณฑ์ประจำตำบล',
    
'9.gif' => 'ทำเนียบบุคลากร',
    
'10.gif' => 'แบบสำรวจความคิดเห็น',
    
'11.gif' => 'แนะนำร้านอาหาร',
    
'12.gif' => 'การให้บริการ',
    
'13.gif' => 'สาส์นจากผู้บริหาร',
    
'14.gif' => 'สถิติผู้เข้าชมเว็บไซต์',
    
'15.gif' => 'สถานที่ท่องเที่ยว',
    
'16.gif' => 'จัดการระบบเว็บไซต์',
    
'17.gif' => 'สาส์นจากนายกฯ',
    
'18.gif' => 'สาส์นจากประธานสภา',
    
'19.gif' => 'สาส์นจากปลัด',
    
'20.gif' => 'งบประมาณ อบต.',
    
'21.gif' => 'ความรู้เกี่ยวกับภาษี',
    
'22.gif' => 'ความรู้เกี่ยวกับ อบต.',
    
'23.gif' => 'กฎหมายน่ารู้',
    
'24.gif' => 'ราคาน้ำมันวันนี้',
    
'25.gif' => 'เว็บไซต์บริการ',
    
'26.gif' => 'เว็บไซต์ท้องถิ่นไทย',
    
'27.gif' => 'ข่าวจากกรมส่งเสริมการปกครองท้องถิ่น',
    
'28.gif' => 'สำนักปลัด',
    
'29.gif' => 'ส่วนการคลัง',
    
'30.gif' => 'ส่วนการศึกษา',
    
'31.gif' => 'ส่วนโยธา',
    
'32.gif' => 'ส่วนสาธารณสุข',
    
'33.gif' => 'ส่วนส่งเสริมการเกษตร',
    
'34.gif' => 'งานควบคุมภายใน',
    
'35.gif' => 'งานบริหารบุคคล',
    
'36.gif' => 'ศูนย์พัฒนาเด็กเล็ก',
    
'37.gif' => 'แผนพัฒนาตำบล',
    
'38.gif' => 'งานการเงิน',
    
'39.gif' => 'งานนโยบายและแผน',
    
'40.gif' => 'งานงบประมาณ',
    
'41.gif' => 'งานพัสดุ',
    
'42.gif' => 'งานสังคมสงเคราะห์',
    
'43.gif' => 'ข้อมูลพื้นฐานเทศบาล',
    
'44.gif' => 'Link กระทรวง',
    
'45.gif' => 'หมู่บ้านในเขตเทศบาล',
    
'46.gif' => 'เครือข่ายของเรา',
    
'47.gif' => 'ความรู้เกี่ยวกับเทศบาล',
    
'48.gif' => 'สายตรงผู้บริหาร',
    
'49.gif' => 'ขั้นตอนการติดต่อราชการ',
    
'50.gif' => 'ข้อมูลการจัดซื้อจัดจ้าง',
    
'51.gif' => 'บริการออนไลน์'
  
);
  foreach(
$arrayMTop as $gif => $text){
    
mysql_query("UPDATE cms_menu_top SET name = '$text' WHERE name = '$gif';");
  }
}



#/*//##### delete old news and old news_tender #####//
$sqlNews "select * from cms_news where year(date_post) < '2558' OR year(date_post) < '2015'";
$queNews mysql_query($sqlNews);
while(
$news mysql_fetch_assoc($queNews)){
    if(
$news['pic1'] != '' && file_exists($_SESSION['web_name'].'/mainfile/'.$news['pic1'])){
        @
unlink($_SESSION['web_name'].'/mainfile/'.$news['pic1']);
    }
    if(
$news['pic2'] != '' && file_exists($_SESSION['web_name'].'/mainfile/'.$news['pic2'])){
        @
unlink($_SESSION['web_name'].'/mainfile/'.$news['pic2']);
    }
    if(
$news['pic3'] != '' && file_exists($_SESSION['web_name'].'/mainfile/'.$news['pic3'])){
        @
unlink($_SESSION['web_name'].'/mainfile/'.$news['pic3']);
    }
    if(
$news['pic4'] != '' && file_exists($_SESSION['web_name'].'/mainfile/'.$news['pic4'])){
        @
unlink($_SESSION['web_name'].'/mainfile/'.$news['pic4']);
    }
    if(
$news['files'] != '' && file_exists($_SESSION['web_name'].'/mainfile/'.$news['files'])){
        @
unlink($_SESSION['web_name'].'/mainfile/'.$news['files']);
    }
    
    
mysql_query("delete from cms_news where id = '$news[id]'");
}
$sqlTender "select * from cms_news_tender where year(date_post) < '2558' OR year(date_post) < '2015'";
$queTender mysql_query($sqlTender);
while(
$tender mysql_fetch_assoc($queTender)){
    if(
$tender['file'] != '' && file_exists($_SESSION['web_name'].'/mainfile/'.$tender['file'])){
        @
unlink($_SESSION['web_name'].'/mainfile/'.$tender['file']);
    }
    
    
mysql_query("delete from cms_tender where id = '$tender[file]'");
}

##### ITA #####
$sTopITA mysql_query("SELECT * from cms_menu_top WHERE name = 'ข้อมูล ITA' AND module_type = 'link'");
$nTopITA mysql_num_rows($sTopITA);
if(
$nTopITA == 0){
  
$sNew "select max(id_top) + 1 AS idtp, max(`position`) + 1 AS pstn from cms_menu_top";
  
$qNew mysql_query($sNew);
  
$dNew mysql_fetch_row($qNew);
  
mysql_query("INSERT INTO cms_menu_top (id_top,name,position,left_right,`status`,`lock`,module_type,permission) VALUES ('$dNew[0]','ข้อมูล ITA','$dNew[1]','1','1',1,'link',0)");
  
  
$maxid "select max(id_sub+1) from `cms_menu_sub`";
  
$resultmaxid mysql_query($maxid);
  
$datamaxid mysql_fetch_row($resultmaxid);
  
$id_sub $datamaxid[0];
  
$url "index.php?mod=link&path=link&id_sub=$id_sub";
  
mysql_query("INSERT INTO cms_menu_sub (id_sub, id_top,id_type,name,url,position,status) VALUES ('$id_sub', '$dNew[0]','1','ข้อมูล ITA ประจำปี 2564','$url','1','1')");
  
  
$sMxLG "SELECT MAX(id_group) FROM cms_link_group";
  
$qMxLG mysql_query($sMxLG);
  
$dMxLG mysql_fetch_row($qMxLG);
  
$maxLG = (int) $dMxLG[0];
  
mysql_query("INSERT INTO `cms_link_group` (`id_group`, `id_sub`, `name_group`, `status`) VALUES
                ("
.($maxLG+1).", $id_sub, 'ข้อมูล ITA ประจำปี 2564', '1'),
                ("
.($maxLG+2).", $id_sub, 'ตัวชี้วัดที่ 9 การเปิดเผยข้อมูล', '1'),
                ("
.($maxLG+3).", $id_sub, 'ตัวชี้วัดย่อยที่ 9.1 ข้อมูลพื้นฐาน', '1'),
                ("
.($maxLG+4).", $id_sub, 'ข้อมูลพื้นฐาน', '1'),
                ("
.($maxLG+5).", $id_sub, 'ข่าวประชาสัมพันธ์', '1'),
                ("
.($maxLG+6).", $id_sub, 'การปฏิสัมพันธ์ข้อมูล', '1'),
                ("
.($maxLG+7).", $id_sub, 'ตัวชี้วัดย่อยที่ 9.2 การบริหารงาน', '1'),
                ("
.($maxLG+8).", $id_sub, 'แผนการดำเนินงาน', '1'),
                ("
.($maxLG+9).", $id_sub, 'การปฏิบัติงาน', '1'),
                ("
.($maxLG+10).", $id_sub, 'การให้บริการ', '1'),
                ("
.($maxLG+11).", $id_sub, 'ตัวชี้วัดย่อยที่ 9.3 การบริหารเงินงบประมาณ', '1'),
                ("
.($maxLG+12).", $id_sub, 'แผนการใช้จ่ายงบประมาณประจำปี', '1'),
                ("
.($maxLG+13).", $id_sub, 'การจัดซื้อจัดจ้างหรือการจัดหาพัสดุ', '1'),
                ("
.($maxLG+14).", $id_sub, 'ตัวชี้วัดย่อยที่9.4 การบริหารและพัฒนาทรัพยากรบุคคล', '1'),
                ("
.($maxLG+15).", $id_sub, 'การบริหารและพัฒนาทรัพยากรบุคคล', '1'),
                ("
.($maxLG+16).", $id_sub, 'ตัวชี้วัดย่อยที่ 9.5 การส่งเสริมความโปร่งใส', '1'),
                ("
.($maxLG+17).", $id_sub, 'การจัดการเรื่องร้องเรียนการทุจริต', '1'),
                ("
.($maxLG+18).", $id_sub, 'การเปิดโอกาสให้เกิดการมีส่วนร่วม', '1'),
                ("
.($maxLG+19).", $id_sub, 'ตัวชี้วัดที่ 10 การป้องกันการทุจริต', '1'),
                ("
.($maxLG+20).", $id_sub, 'ตัวชี้วัดย่อยที่10.1การดำเนินการเพื่อป้องกันการทุจ', '1'),
                ("
.($maxLG+21).", $id_sub, 'เจตจำนงสุจริตของผู้บริหาร', '1'),
                ("
.($maxLG+22).", $id_sub, 'การประเมินความเสี่ยงเพื่อการป้องกันการทุจริต', '1'),
                ("
.($maxLG+23).", $id_sub, 'การเสริมสร้างวัฒนธรรมองค์กร', '1'),
                ("
.($maxLG+24).", $id_sub, 'แผนปฏิบัติการป้องกันการทุจริต', '1'),
                ("
.($maxLG+25).", $id_sub, 'ตัวชี้วัดย่อยที่10.2มาตรการภายในเพื่อป้องกันการทุจ', '1'),
                ("
.($maxLG+26).", $id_sub, 'มาตรการส่งเสริมความโปร่งใสและป้องกันการทุจริตภายใน', '1');");
  
  
mysql_query("IF NOT EXISTS(SELECT NULL FROM INFORMATION_SCHEMA.COLUMNS
            WHERE table_name = 'cms_link'
            AND table_schema = '"
.$_SESSION['dbname']."'
            AND column_name = 'text_full')
        THEN
            ALTER TABLE `cms_link` ADD `text_full` text NOT NULL;
        END IF;"
);
  
mysql_query("IF NOT EXISTS(SELECT NULL FROM INFORMATION_SCHEMA.COLUMNS
            WHERE table_name = 'cms_link'
            AND table_schema = '"
.$_SESSION['dbname']."'
            AND column_name = 'picture1')
        THEN
            ALTER TABLE `cms_link` ADD `picture1` VARCHAR(60) COLLATE utf8_unicode_ci NOT NULL;
        END IF;"
);
  
mysql_query("IF NOT EXISTS(SELECT NULL FROM INFORMATION_SCHEMA.COLUMNS
            WHERE table_name = 'cms_link'
            AND table_schema = '"
.$_SESSION['dbname']."'
            AND column_name = 'picture2')
        THEN
            ALTER TABLE `cms_link` ADD `picture2` VARCHAR(60) COLLATE utf8_unicode_ci NOT NULL;
        END IF;"
);

  
mysql_query("INSERT INTO `cms_link` (`id_group`, `url`, `msg`, `picture`, `state`, `status`, `position`, `text_full`, `picture1`, `picture2`) VALUES
                ("
.($maxLG+4).", '', 'ข้อ O1 โครงสร้าง', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+4).", '', 'ข้อ O2 ข้อมูลผู้บริหาร', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+4).", '', 'ข้อ O3 อำนาจหน้าที่', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+4).", '', 'ข้อ O4 แผนยุทธศาสตร์หรือแผนพัฒนาหน่วยงาน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+4).", 'index.php?mod=blog&path=blog&id_sub=0', 'ข้อ O5 ข้อมูลการติดต่อ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+4).", '', 'ข้อมูล O6 กฎหมายที่เกี่ยวข้อง', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+5).", 'index.php?mod=news_old&id_type=1&id_sub=99999&path=news', 'ข้อ O7 ข่าวประชาสัมพันธ์', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+6).", 'index.php?mod=search&path=webboard', 'ข้อ O8 Q&A', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+6).", 'index.php', 'ข้อ O9 Social Network', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+8).", '', 'ข้อ O10 แผนดำเนินงานประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+8).", '', 'ข้อ O11 รายงานการกำกับติดตามการดำเนินงานประจำปี รอบ 6 เดือน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+8).", '', 'ข้อ O12 รายงานผลการดำเนินงานประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+9).", '', 'ข้อ O13 คู่มือหรือมาตรฐานการปฏิบัติงาน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+10).", '', 'ข้อ O14    คู่มือหรือมาตรฐานการให้บริการ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+10).", '', 'ข้อ O15 ข้อมูลเชิงสถิติการให้บริการ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+10).", '', 'ข้อ O16 รายงานผลการสำรวจความพึงพอใจการให้บริการ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+10).", 'index.php?mod=e_service1&path=e_service1', 'ข้อ O17 E-Service', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+12).", '', 'ข้อ O18 แผนการใช้จ่ายงบประมาณประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+12).", '', 'ข้อ O19 รายงานการกำกับติดตามการใช้จ่ายงบประมาณ ประจำปี รอบ 6 เดือน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+12).", '', 'ข้อ O20 รายงานผลการใช้จ่ายงบประมาณประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+13).", '', 'ข้อ O21 แผนการจัดซื้อจัดจ้างหรือแผนการจัดหาพัสดุ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+13).", 'index.php?mod=news_tender_old&path=news_tender', 'ข้อ O22 ประกาศต่าง ๆ เกี่ยวกับการจัดซื้อจัดจ้างหรือการจัดหาพัสดุ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+13).", '', 'ข้อ O23 สรุปผลการจัดซื้อจัดจ้างหรือการจัดหาพัสดุรายเดือน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+13).", '', 'ข้อ O24 รายงานผลการจัดซื้อจัดจ้างหรือการจัดหาพัสดุประจำปี', '', 1, '1', 1, '', '', '');");
  
mysql_query("INSERT INTO `cms_link` (`id_group`, `url`, `msg`, `picture`, `state`, `status`, `position`, `text_full`, `picture1`, `picture2`) VALUES
                ("
.($maxLG+14).", '', 'ข้อ O25 นโยบายการบริหารทรัพยากรบุคคล', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+14).", '', 'ข้อ O26 การดำเนินการตามนโยบายการบริหารทรัพยากรบุคคล', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+14).", '', 'ข้อ O27 หลักเกณฑ์การบริหารและพัฒนาทรัพยากรบุคคล', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+14).", '', 'ข้อ O28 รายงานผลการบริหารและพัฒนาทรัพยากรบุคคลประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+17).", '', 'ข้อ O29 แนวปฏิบัติการจัดการเรื่องร้องเรียนการทุจริตและประพฤติมิชอบ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+17).", 'index.php?mod=e_service&path=e_service', 'ข้อ O30 ช่องทางแจ้งเรื่องร้องเรียนการทุจริตและประพฤติมิชอบ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+17).", '', 'ข้อ O31 ข้อมูลเชิงสถิติเรื่องร้องเรียนการทุจริตและประพฤติมิชอบ', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+18).", 'index.php?mod=gbook&path=gbook&id_type=1', 'ข้อ O32 ช่องทางการรับฟังความคิดเห็น', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+18).", 'index.php?mod=gallery&path=gallery', 'ข้อ O33 การเปิดโอกาสให้เกิดการมีส่วนร่วม', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+21).", '', 'ข้อ O34 เจตจำนงสุจริตของผู้บริหาร', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+21).", 'index.php?mod=gallery&path=gallery', 'ข้อ O35 การมีส่วนร่วมของผู้บริหาร', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+22).", '', 'ข้อ O36 การประเมินความเสี่ยงการทุจริตประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+22).", '', 'ข้อ O37 การดำเนินการเพื่อจัดการความเสี่ยงการทุจริต', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+23).", '', 'ข้อ O38 การเสริมสร้างวัฒนธรรมองค์กร', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+24).", '', 'ข้อ O39 แผนปฏิบัติการป้องกันการทุจริต', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+24).", '', 'ข้อ O40 รายงานการกำกับติดตามการดำเนินการป้องกันการทุจริตประจำปี รอบ 6 เดือน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+24).", '', 'ข้อ O41 รายงานผลการดำเนินการป้องกันการทุจริตประจำปี', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+26).", '', 'ข้อ O42 มาตรการส่งเสริมคุณธรรมและความโปร่งใสภายในหน่วยงาน', '', 1, '1', 1, '', '', ''),
                ("
.($maxLG+26).", '', 'ข้อ O43 การดำเนินการตามมาตรการส่งเสริมคุณธรรมและความโปร่งใสภายในหน่วยงาน', '', 1, '1', 1, '', '', '');");
}

/*$chk_ita = "SELECT id_link FROM cms_link WHERE msg = 'ข้อ O1 โครงสร้าง' OR msg = 'ข้อ O25 นโยบายการบริหารทรัพยากรบุคคล'";
$que_chk = mysql_query($chk_ita);
$num_chk = mysql_num_rows($que_chk);
if($num_chk == 0){
  $sTopITA = mysql_query("SELECT id_top FROM cms_menu_top WHERE name = 'ข้อมูล ITA' AND module_type = 'link'");
  $aTopITA = mysql_fetch_row($sTopITA);
  $sSubITA = mysql_query("SELECT id_sub FROM cms_menu_sub WHERE id_top = '$aTopITA[0]'");
  $aSubITA = mysql_fetch_row($sSubITA);
  
  mysql_query("DELETE FROM cms_menu_sub WHERE id_sub = '$aSubITA[0]'");
  mysql_query("DELETE FROM cms_link_group WHERE id_sub = '$aSubITA[0]'");
  mysql_query("DELETE FROM cms_menu_top WHERE id_top = '$aTopITA[0]'");
}*/
### END ITA ###

include('coremain/connec_out.php');
$sqlOut "select * from cms_news where year(date_post) < '2558' OR year(date_post) < '2015'";
$queOut mysql_query($sqlOut);
while(
$out mysql_fetch_assoc($queOut)){
    
mysql_query("delete from cms_news where id = '$out[id]'");
}
$sqlTOut "select * from cms_news_tender where year(date_post) < '2558' OR year(date_post) < '2015'";
$queTOut mysql_query($sqlTOut);
while(
$tout mysql_fetch_assoc($queTOut)){
    
mysql_query("delete from cms_news_tender where id = '$tout[id]'");
}
mysql_close($handle_out);
include(
"$_SESSION[web_name]/connect.php");
//################## end delete #################//*/

  
  
?>