PageSourceSearch

https://care.ditp.go.th/frontend/js/index_function.js

js ditp.go.th collected 2026-10-02 04:02:31 UTC 104,569 bytes, 2,272 lines download raw bytes

1var fileTumbnail = "";
2
3function readURL_thumbnail(input, callback) {
4
5    if (input.files && input.files[0]) {
6        var reader = new FileReader();
7
8        reader.onload = function(e) {
9            fileTumbnail = e.target.result;
10            if (typeof callback === "function") {
11                callback(fileTumbnail);
12            }
13        }
14
15        reader.readAsDataURL(input.files[0]);
16    }
17}
18
19var file_tmp_list = [];
20$(document).ready(function() {
21
22    var filePreview_new = function(input, callback) {
23        if (input) {
24
25            var reader = new FileReader();
26
27            reader.onload = function(event) {
28                var file_tmp = event.target.result;
29                if (typeof callback === "function") {
30                    callback(file_tmp);
31                }
32            }
33
34            reader.readAsDataURL(input);
35        }
36
37    }
38
39    $('.file_box').change(function() {
40        var file_attach = $(this)[0].files;
41        var file_attach_length = file_attach.length;
42        for (i = 0; i < file_attach_length; i++) {
43            var fileview = filePreview_new(this.files[i], function(file_tmp) {
44                file_tmp_list.push(file_tmp);
45            });
46        }
47    });
48
49});
50
51$(document).delegate(".btn_browse_file", "click", function() {
52    $(".file_box").click();
53});
54
55
56
57$(document).delegate(".file_profile", "change", function() {
58    $('.name_file_edit').val(this.files[0].name);
59    readURL_thumbnail(this, function(pathfile) {
60        $('.img_profile_edit').attr('src', pathfile);
61        var image = new Image();
62        image.src = pathfile;
63        image.onload = function() {
64            $('.img_profile_edit').attr('style', getPositionImage(this.width, this.height, 120));
65        }
66
67        // $('.img_profile_edit').css('background-image', 'url(' + pathfile + ')');
68    });
69});
70
71
72function getPositionImage(width, height, size) {
73    var ratio = (width / height); // width/height
74    var css = "";
75    if (ratio > 1) {
76        width = (size * ratio);
77        height = size;
78        css = " width:auto; height:100%; margin-left:-" + ((width * 0.5) - (size * 0.5)) + "px";
79    } else {
80        width = size;
81        height = (size / ratio);
82        css = "height:auto; width:100%; top:0;";
83    }
84    return css;
85}
86
87function count_checkcorporation_clicked(){
88    $.ajax({
89        url: 'function_php/function_index.php',
90        type: 'POST',
91        dataType: "json",
92        async: true,
93        data: {
94            method: "count_checkcorporation_clicked",
95            // member_id: member_id,
96        },
97        success: function(data) {
98            console.log(data);
99
100        },
101        error: function(err) {
102            console.log({
103                error: err
104            });
105
106        }
107    });
108}
109
110
111
112function show_modal(type) {
113    if (type == 1) {
114        $('#modal_chk_invite').modal('hide');
115    } else {
116        $('#modal_chk_invite').modal('show');
117    }
118}
119$(document).delegate(".btn-chk-detail", "click", function() {
120    var lang = $('.language_hidden').val();
121    if (lang == 2) {
122        var txt = "Please choose accept condition";
123    } else {
124        var txt = "กรุณาเลือกทราบและยอมรับเงื่อนไข";
125    }
126    var chk_conf = false;
127    $('#chk_invite_detail').each(function() {
128        if ($(this).is(":checked")) {
129            chk_conf = true;
130        }
131    });
132    if (chk_conf == true) {
133        var chk_invite_con = $("input[name='chk_invite_detail']:checked").val();
134        $('.chk_confirm').val(chk_invite_con);
135    } else {
136        bootbox.alert(txt, function() {
137            window.location.reload();
138        });
139    }
140
141});
142
143$(document).delegate(".btn-chk-invite", "click", function() {
144    var lang = $('.language_hidden').val();
145    var chk_radio_step = $('#rdi_compType_id').val();
146    var compType_other_txt = $('.compType_other_txt').val();
147    // var chk_radio_step1 = $('input[name=rdi_compTypeSub1]:checked', '#chk_invite_step1').val();
148    // var chk_radio_step2 = $('input[name=rdi_compTypeSub2]:checked', '#chk_invite_step1').val();
149
150    var chk_radio_step1 = $('input[name=rdi_compTypeSub1]', '#chk_invite_step1').val();
151    var chk_radio_step2 = $('input[name=rdi_compTypeSub2]', '#chk_invite_step1').val();
152
153    if ($('.chk_confirm').val() == "") {
154        if (lang == "2") {
155            bootbox.alert("Please agree to the terms and conditions before creating petition", function() {
156                window.location.reload();
157            });
158        } else {
159            bootbox.alert("กรุณายอมรับเงื่อนไขก่อนตั้งเรื่องร้องเรียน", function() {
160                window.location.reload();
161            });
162        }
163        // location.reload();
164    } else {
165        $('#wait_process').css('display', 'block');
166        $.ajax({
167            url: 'function_php/function_index.php',
168            type: 'POST',
169            async: false,
170            responseType: "json",
171            data: {
172                'chk_radio_step': chk_radio_step,
173                'compType_other_txt': compType_other_txt,
174                'chk_radio_step1': chk_radio_step1,
175                'chk_radio_step2': chk_radio_step2,
176                'method': "chk_invite_step"
177            },
178            success: function(res) {
179                if (res.in_chk == "00") {
180                    $("#chk_invite_step1").submit();
181                } else if (res.in_chk == "02") {
182                    $("#chk_invite_step1").submit();
183                } else if (res.in_chk == "03") {
184                    if (lang == "2") {
185                        bootbox.alert("Please specify", function() {
186                            $('#wait_process').css('display', 'none');
187                        });
188                    } else {
189                        bootbox.alert("กรุณาระบุให้ครบถ้วน", function() {
190                            $('#wait_process').css('display', 'none');
191                        });
192                    }
193                } else {
194                    if (lang == "2") {
195                        bootbox.alert("Please select the type of complaint", function() {
196                            $('#wait_process').css('display', 'none');
197                        });
198                    } else {
199                        bootbox.alert("กรุณาเลืกประเภทเรื่องร้องเรียน", function() {
200                            $('#wait_process').css('display', 'none');
201                        });
202                    }
203
204                }
205            },
206            error: function(jqXHR, textStatus, errorThrown) {
207                console.log(jqXHR, textStatus, errorThrown);
208            }
209        });
210    }
211
212
213});
214
215function validateForm(x) {
216    var atpos = x.indexOf("@");
217    var dotpos = x.lastIndexOf(".");
218    if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
219        return false;
220    } else {
221        return true;
222    }
223}
224
225function validateEmail(email) {
226    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
227    return re.test(email);
228}
229
230function bootbox_person(txt, index){
231    bootbox.confirm(txt, function() {
232        $('#wait_process').css('display', 'none');
233        setTimeout(function() {
234            $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
235        }, 500);
236    });
237}
238
239function bootbox_person1(txt, index){
240    bootbox.confirm(txt, function() {
241        $('#wait_process').css('display', 'none');
242        setTimeout(function() {
243            if(index == 13) {
244                $('input[name="appint_personinfo13"]').focus();
245            } else {
246                $("[name='appint_personinfo1[]']:eq(" + (index) + ")").focus();
247            }
248        }, 500);
249    });
250}
251
252function bootbox_Represent(txt, index){
253    bootbox.confirm(txt, function() {
254        $('#wait_process').css('display', 'none');
255        setTimeout(function() {
256            $("[name='Represent_value[]']:eq(" + index + ")").focus();
257        }, 500);
258    });
259}
260
261function Alert_valEmptyPerson(index_empty){
262        if(index_empty == 0)
263        bootbox_person("กรุณากรอกชื่อ", index_empty)
264    else if(index_empty == 1)
265        bootbox_person("กรุณากรอกนามสกุล", index_empty)
266    else if(index_empty == 2)
267        bootbox_person("กรุณากรอกเลขบัตรประชาชน", index_empty)
268    else if(index_empty == 3)
269        bootbox_person("กรุณากรอกเบอร์โทรศัพท์", index_empty)
270    else if(index_empty == 4)
271        bootbox_person("กรุณากรอกอีเมล", index_empty)
272    else if(index_empty == 5)
273        bootbox_person("กรุณากรอกที่อยู่", index_empty)
274    else if(index_empty == 7)
275        bootbox_person("กรุณากรอกรหัสไปรษณีย์", index_empty) 
276    else if(index_empty == 15)
277        bootbox_person("กรุณาเลือก รหัสประเทศ", index_empty)    
278}
279
280function Alert_valEmptyPerson1(index_empty, type){
281    if(type == 2){
282        bootbox.confirm("กรุณากรอกอาชีพในการยืนเรื่องนามบุคคลธรรมดา", function() {
283            $('#wait_process').css('display', 'none');
284            setTimeout(function() {
285                $("[name='appint_personinfo2[]']").focus();
286            }, 500);
287        });
288    } else {
289        // console.log(index_empty);
290        if(index_empty == 0)
291            bootbox_person1("กรุณากรอกเลขนิติบุคคล", index_empty);
292        else if(index_empty == 1)
293            bootbox_person1("กรุณากรอกชื่อบริษัทที่จดทะเบียน", index_empty);
294        else if(index_empty == 4)
295            bootbox_person1("กรุณากรอกตำแหน่ง", index_empty);
296        else if(index_empty == 5)
297            bootbox_person1("กรุณากรอกเบอร์โทรศัพท์ให้ครบ 10 หลัก", index_empty);
298        else if(index_empty == 6)
299            bootbox_person1("กรุณากรอกเว็บไซต์", index_empty);
300        else if(index_empty == 7)
301            bootbox_person1("กรุณากรอกที่อยู่ติดต่อ", index_empty);
302        else if(index_empty == 8)
303            bootbox_person1("กรุณากรอกประเทศ", index_empty);
304        else if(index_empty == 9)
305            bootbox_person1("กรุณากรอกรหัสไปรษณีย์", index_empty);
306        else if(index_empty == 13)
307            bootbox_person1("กรุณากรอกประเภทธุรกิจ", index_empty);
308        else if(index_empty == 91)
309            bootbox_person1("กรุณากรอกรหัสไปรษณีย์ให้ครบ 5 หลัก", 9);
310        else if(index_empty == 15)
311            bootbox_person("กรุณาเลือก รหัสประเทศ", index_empty);   
312    }
313    
314}
315
316function Checkvalue_Represent(value){
317    var valid = true;
318    var index_empty;
319    $.each(value, function(index, propval) {
320        if(propval == ''){
321            member_type = $('#member_type').val();
322            if(member_type != 1) {
323                if(index == 3 || index == 4 || index == 6){
324
325                }else{
326                    $("[name='Represent_value[]']:eq(" + index + ")").focus();
327                    index_empty = index;
328                    return valid = false;
329                }
330            }
331        }
332    })
333    if(valid == false){
334        Alert_valEmpty(index_empty, 1)
335    }
336    return valid;
337}
338
339function Alert_valEmpty(index_empty, select){
340    if(select == 2){
341        bootbox.confirm("กรุณาเลือกอาชีพในการยืนเรื่องนามบุคคลธรรมดา", function() {
342            $('#wait_process').css('display', 'none');
343            setTimeout(function() {
344                $("[name='appint_personinfo2[]']").focus();
345            }, 500);
346        });
347    }
348    else{
349        // console.log(index_empty);
350        if(index_empty == 0)
351            bootbox_Represent("กรุณากรอกเลขนิติบุคคล", index_empty);
352        else if(index_empty == 1)
353            bootbox_Represent("กรุณากรอกชื่อบริษัทที่จดทะเบียน", index_empty);
354        else if(index_empty == 3)
355            bootbox_Represent("กรุณากรอกประเภทธุรกิจ", index_empty);
356        else if(index_empty == 5)
357            bootbox_Represent("กรุณากรอกเบอร์โทรศัพท์", index_empty);
358        else if(index_empty == 6)
359            bootbox_Represent("กรุณากรอกเว็บไซต์", index_empty);
360        else if(index_empty == 7)
361            bootbox_Represent("กรุณากรอกที่อยู่ติดต่อ", index_empty);
362        else if(index_empty == 8)
363            bootbox_Represent("กรุณากรอกรหัสไปรษณีย์", index_empty);
364    }
365}
366
367function Checkvalue_Natural(value){
368    var valid = true;
369    var index_empty;
370    $.each(value, function(index, propval) {
371        // if(propval == ''){
372        //     $("[name='appint_personinfo2[]']").focus();
373        //     index_empty = index;
374        //     return valid = false;
375        // }
376    })
377    if(valid == false){
378        Alert_valEmpty(index_empty, 2)
379    }
380    console.log(valid);
381    return valid;
382}
383
384function Check_Personinfo(){
385    var values = $("[name='appint_personinfo[]']").map(function(){
386        return $(this).val();
387    }).get();
388    values.splice(0, 2);
389
390    var type = '';
391    $('[name="appint_personType[]"]').each(function() {
392        var sThisVal = (this.checked ? $(this).val() : "");
393        if (sThisVal != '') {
394            type = sThisVal;
395        }
396    })
397
398    var values1 = $("[name='appint_personinfo1[]']").map(function(){
399        return $(this).val();
400    }).get();
401
402    var valid = true;
403    var valid1 = true;
404    var index_empty;
405
406    // console.log(values1);
407
408    var country = '';
409    $.each(values, function(index, value){
410        if(index == 6) {
411            country = value;
412        }
413    })
414    $.each(values, function(index, value){
415        if(index == 2){
416            if(country == 162) {
417                if(value.length != 13) {
418                    $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
419                    bootbox_person("กรุณากรอกเลขบัตรประชาชนให้ครบ 13 หลัก", index)    
420                    return valid = false;
421                }
422            }
423        } else if(index == 3){
424            if(country == 162) {
425                if(value.length != 10) {
426                    $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
427                    bootbox_person("กรุณากรอกเบอร์โทรศัพท์ให้ครบ 10 หลัก", index)    
428                    return valid = false;
429                }
430            }
431
432            var ctry3 = intPhoneInfo.getSelectedCountryData().iso2
433            var code3 = intPhoneInfo.getSelectedCountryData().dialCode
434
435            if(!ctry3) {
436                index_empty = 15;
437                return valid = false;
438            } else {
439                $("[name='applnt_mobile_country']").val(ctry3.toUpperCase());
440                $("[name='applnt_mobile_code']").val('+'+code3);
441            }
442
443        } else if(index == 4){
444            if(validateEmail(value) == false){
445                $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
446                index_empty = index;
447                return valid = false;
448            }
449        } else if(index == 6) {
450            country = value;
451        } else  if(index == 7) {
452            if(country == 162) {
453                if(value.length != 5) {
454                    $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
455                    bootbox_person("กรุณากรอกรหัสไปรษณีย์ให้ครบ 5 หลัก", index)    
456                    return valid = false;
457                }
458            } else {
459                if(value == '') {
460                    $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
461                    bootbox_person("กรุณากรอกรหัสไปรษณีย์", index)    
462                    return valid = false;
463                }
464            }
465            
466        } else{
467            if(value == ''){
468                $("[name='appint_personinfo[]']:eq(" + (index + 2) + ")").focus();
469                index_empty = index;
470                return valid = false;
471            }
472        }
473    })
474
475    if(valid == false){
476        Alert_valEmptyPerson(index_empty);
477        return 0;
478    }
479    
480
481    var valuec = '';
482    var country = '';
483
484    
485
486    if(type == 1) {
487        $('#appint_personType').val(1);
488        member_type = $("[name='rdi_compTypeSub1']").val();
489
490        $.each(values1, function(index, value){
491            if(index == 8) {
492                country = value;
493            }
494        })
495        $.each(values1, function(index, value){
496            // console.log(value);
497            if(index == 2) {
498                if(value == 0) {
499                    valuec = $('input[name="appint_personinfo13"]').val();
500                    if(valuec == '') {
501                        // bootbox_person1("กรุณากรอกประเภทธุรกิจ", 13) 
502                        index_empty = 13;
503                        return valid1 = false;
504                    }
505                } 
506            } else if(index == 5) {
507                if(country == 162) {
508                    if(value.length != 10) {
509                        // bootbox_person1("กรุณากรอกรหัสไปรษณีย์ให้ครบ 5 หลัก", index)    
510                        index_empty = index;
511                        return valid1 = false;
512                    }
513                }
514                var ctry = intPhone.getSelectedCountryData().iso2
515                var code = intPhone.getSelectedCountryData().dialCode
516    
517                if(!ctry) {
518                    index_empty = 15;
519                    return valid1 = false;
520                } else {
521                    $("[name='applntOrg_mobile_country']").val(ctry.toUpperCase());
522                    $("[name='applntOrg_mobile_code']").val('+'+code);
523                }
524
525                
526            } else if(index == 8) {
527                country = value;
528                if(country == 0) {
529                    index_empty = index;
530                    return valid1 = false;
531                }
532            } else if(index == 9) {
533                if(country == 162) {
534                    if(value.length != 5) {
535                        // bootbox_person1("กรุณากรอกรหัสไปรษณีย์ให้ครบ 5 หลัก", index)    
536                        index_empty = 91;
537                        return valid1 = false;
538                    }
539                } else {
540                    if(value == '') {
541                        // bootbox_person1("กรุณากรอกรหัสไปรษณีย์", index)    
542                        index_empty = 9;
543                        return valid1 = false;
544                    }
545                }
546                
547            } else if (index == 3 || index == 4 || index == 6) {
548                
549            } else {
550                if(value == ''){
551                    index_empty = index;
552                    return valid1 = false;
553                }
554            }
555        })
556        
557        
558        
559    } else {
560        $('#appint_personType').val(2);
561        // value = $('input[name="appint_personinfo2[]"]').val();
562        // // console.log(value);
563        // if(value == '') {
564        //     index_empty = 1;
565        //     valid1 = false;
566        // }
567    }
568
569    if(valid1 == false) {
570        // console.log(type);
571        Alert_valEmptyPerson1(index_empty, type);
572        return 0;
573    } 
574
575    
576
577    
578}
579
580function Newbtn_submit(){
581    var rdicompType = $("input[name='rdi_compTypeSub1']").val();
582    if(rdicompType == 1){
583        if($('#CheckboxagentDefault').prop('checked') == true){
584            var values = $("[name='appint_personinfo1[]']").map(function(){
585                return $(this).val();
586            }).get();
587
588            if($('#selecttype_comp option:selected').val() != 0)
589                values[3] = $('#selecttype_comp option:selected').text();
590        
591            var country_id = $('.country_newpanel option:selected').val();
592            if(country_id == 0){
593                bootbox.confirm("กรุณาเลือกประเทศ", function() {
594                    $('#wait_process').css('display', 'none');
595                    setTimeout(function() {
596                        $('.country_newpanel .btn.dropdown-toggle').focus();
597                    }, 500);
598                });
599                return false;
600            }
601            else{
602                var country = $('.selectpicker.country_newpanel').parent().find('.btn.dropdown-toggle').attr('title');
603                if(!country_id) {
604                    var country_id = $('.person_country option:selected').val();
605                }
606                if(!country) {
607                    var country = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
608                }
609                values.push(country_id);
610                values.push(country);
611                if(Checkvalue_Represent(values) == false){
612                    return false;
613                }else{
614                    $('#appIntOrg_selectagenORposition').val(1);
615                    $('#appIntOrg_countryname').val(country);
616                    var appinfoperson = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
617                    $('#appintpersoninfo').append(`<input type="text" class="form-control" id="" name="appint_personinfo[]" value="${appinfoperson}">`);
618                    return values;
619                }
620            }
621        }else{
622            var values = $("input[name='appint_personinfo2[]']").map(function(){return $(this).val();}).get();
623            if(Checkvalue_Natural(values) == false){
624                return false;
625            }else{
626                $('#appIntOrg_selectagenORposition').val(2);
627                var appinfoperson = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
628                $('#appintpersoninfo').append(`<input type="text" class="form-control" id="" name="appint_personinfo[]" value="${appinfoperson}">`);
629                return true;
630            }
631        }
632    }
633    else{
634        var appinfoperson = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
635        $('#appintpersoninfo').append(`<input type="text" class="form-control" id="" name="appint_personinfo[]" value="${appinfoperson}">`);
636        return true;
637    }
638}
639
640function Newbtn_editsubmit(){
641    var rdicompType = $("input[name='rdi_compTypeSub1']").val();
642    if(rdicompType == 1){
643        if($('#CheckboxagentDefault').prop('checked') == true){
644            var values = $("[name='Represent_value[]']").map(function(){
645                return $(this).val();
646            }).get();
647
648            if($('#selecttype_comp option:selected').val() != 0)
649                values[3] = $('#selecttype_comp option:selected').text();
650        
651            var country_id = $('.country_newpanel option:selected').val();
652            if(country_id == 0){
653                bootbox.confirm("กรุณาเลือกประเทศ", function() {
654                    $('#wait_process').css('display', 'none');
655                    setTimeout(function() {
656                        $('.country_newpanel .btn.dropdown-toggle').focus();
657                    }, 500);
658                });
659                return false;
660            }
661            else{
662                var country = $('.selectpicker.country_newpanel').parent().find('.btn.dropdown-toggle').attr('title');
663                values.push(country_id);
664                values.push(country);
665                $('[name="appIntOrg_countryname"]').val(country);
666                if(Checkvalue_Represent(values) == false){
667                    return false;
668                }else{
669                    $('#appIntOrg_selectagenORposition').val(1);
670                    var appinfoperson = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
671                    $('#appintpersoninfo').append(`<input type="text" class="form-control" id="" name="appint_personinfo[]" value="${appinfoperson}">`);
672                    return values;
673                }
674            }
675        }else{
676            var values = $("input[name='appint_personinfo2[]']").map(function(){return $(this).val();}).get();
677            // console.log(rdicompType);
678            if(Checkvalue_Natural(values) == false){
679                return false;
680            }else{
681                $('#appIntOrg_selectagenORposition').val(2);
682                var appinfoperson = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
683                $('#appintpersoninfo').append(`<input type="text" class="form-control" id="" name="appint_personinfo[]" value="${appinfoperson}">`);
684                return true;
685            }
686        }
687    }
688    else{
689        var appinfoperson = $('.selectpicker.person_country').parent().find('.btn.dropdown-toggle').attr('title');
690        $('#appintpersoninfo').append(`<input type="text" class="form-control" id="" name="appint_personinfo[]" value="${appinfoperson}">`);
691        return true;
692    }
693}
694
695function btnchkinvitestep2(status_upload) {
696    var lang = $('.language_hidden').val();
697    var formSetId_a = $("input[name='formSetId_a']").val();
698    var formSetId_b = $("input[name='formSetId_b']").val();
699    var formSetId_c = $("input[name='formSetId_c']").val();
700
701    var email = $("input[name='complnt_contact_email_IdxFs_" + formSetId_b + "']").val();
702    var chkmail = true;
703    if (email != "") {
704        chkmail = validateEmail(email);
705    }
706
707    var ctry = intPhoneCmp.getSelectedCountryData().iso2
708    var code = intPhoneCmp.getSelectedCountryData().dialCode
709
710    if(!ctry) {
711        ctry = '';
712    } else {
713        $("[name='complnt_mobile_country']").val(ctry.toUpperCase());
714        $("[name='complnt_mobile_code']").val('+'+code);
715    }
716
717    if(!ctry) {
718        ctry = '';
719    }
720
721    ///from1
722    var form_data = new FormData();
723    if (status_upload != true) {
724        $.each($('input[type=file]')[0].files, function(i, file) {
725            form_data.append('file[]', file);
726        });
727
728        $('input[name="caseAttach_file_name[]"]').each(function() {
729            form_data.append('caseAttach_file_name[]', $(this).val());
730        });
731    }
732    form_data.append('fileinput_file_remove', $("input[name='fileinput_file_remove").val());
733
734    // form_data.append('applntOrg_name', $("input[name='applntOrg_name_IdxFs_" + formSetId_a + "']").val());
735    // form_data.append('applntOrg_position', $("input[name='applntOrg_position_IdxFs_" + formSetId_a + "']").val());
736    // form_data.append('applntOrg_trade_number', $("input[name='applntOrg_trade_number_IdxFs_" + formSetId_a + "']").val());
737    // form_data.append('applntOrg_address', $("textarea[name='applntOrg_address_IdxFs_" + formSetId_a + "']").val());
738    // form_data.append('applntOrg_tel', $("input[name='applntOrg_tel_IdxFs_" + formSetId_a + "']").val());
739    // form_data.append('applntOrg_zipcode', $("input[name='applntOrg_zipcode_IdxFs_" + formSetId_a + "']").val());
740    // form_data.append('applnt_country_id', $("select[name='applnt_country_id_IdxFs_" + formSetId_a + "']").val());
741
742    ///endfrom1
743    ///from2
744    form_data.append('complnt_name', $("input[name='complnt_name_IdxFs_" + formSetId_b + "']").val());
745    form_data.append('complnt_import_export', $("select[name='complnt_import_export_IdxFs_" + formSetId_b + "']").val());
746    form_data.append('complnt_contact_address', $("textarea[name='complnt_contact_address_IdxFs_" + formSetId_b + "']").val());
747    form_data.append('complnt_prov_id', $("select[name='complnt_prov_id_IdxFs_" + formSetId_b + "']").val());
748    form_data.append('complnt_country_id', $("select[name='complnt_country_id_IdxFs_" + formSetId_b + "']").val());
749
750    form_data.append('complnt_branch', $("input[name='complnt_branch_Id
750xFs_" + formSetId_b + "']").val());
751    form_data.append('complnt_position', $("input[name='complnt_position_IdxFs_" + formSetId_b + "']").val());
752    form_data.append('complnt_zipcode', $("input[name='complnt_zipcode_IdxFs_" + formSetId_b + "']").val());
753    ///endfrom2
754    ///from3
755    form_data.append('caseDtl_title', $("input[name='caseDtl_title_IdxFs_" + formSetId_c + "']").val());
756    form_data.append('prodType_id', $("select[name='prodType_id_IdxFs_" + formSetId_c + "']").val());
757    form_data.append('incType_id', $("select[name='incType_id_IdxFs_" + formSetId_c + "']").val());
758    form_data.append('caseDtl_derivation', $("textarea[name='caseDtl_derivation_IdxFs_" + formSetId_c + "']").val());
759    form_data.append('caseDtl_damage_val', $("input[name='caseDtl_damage_val_IdxFs_" + formSetId_c + "']").val());
760    form_data.append('caseDtl_complnt_need', $("textarea[name='caseDtl_complnt_need_IdxFs_" + formSetId_c + "']").val());
761    ///endfrom3
762
763    //files
764
765
766    //endfiles
767
768    form_data.append('formSetId_a', formSetId_a);
769    form_data.append('formSetId_b', formSetId_b);
770    form_data.append('formSetId_c', formSetId_c);
771    form_data.append('applntOrg_show', $('.applntOrg_show').val());
772    form_data.append('rdi_compTypeSub1', $("input[name='rdi_compTypeSub1']").val());
773    form_data.append('method', "chk_invite_txt");
774
775    form_data.append('complnt_contact_tel_IdxFs_', $("input[name='complnt_contact_tel_IdxFs_" + formSetId_b + "']").val());
776    form_data.append('complnt_contact_email_IdxFs_', $("input[name='complnt_contact_email_IdxFs_" + formSetId_b + "']").val());
777
778    form_data.append('phone-number-complnt', ctry);
779
780
781    var Newresult = Newbtn_submit();
782
783    if (chkmail == false) {
784        if (lang == 2) {
785            var txt_mail = "Please check the format of your email correctly.";
786        } else {
787            var txt_mail = "กรุณาตรวจสอบรูปแบบอีเมล์ของท่านให้ถูกต้อง";
788        }
789        bootbox.alert(txt_mail);
790    }else if(Newresult == false){
791        return false;
792    }else {
793        $('#wait_process').css('display', 'block');
794        $.ajax({
795            url: 'function_php/function_index.php',
796            type: 'POST',
797            enctype: 'multipart/form-data',
798            // timeout: 20000,
799            cache: false,
800            processData: false,
801            contentType: false,
802            responseType: "json",
803            data: form_data,
804            success: function(res) {
805                // console.log(res);
806                $('#wait_process').css('display', 'none');
807
808                var txt = "";
809                if (lang == 2) {
810                    if (res.in_chk_file == "caseAttach_file_name") {
811                        txt = "Please fill in File Name";
812                    }
813
814                    if (formSetId_b == 7) {
815                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
816                            txt = "Please fill in Full name";
817                        } else if (res.in_chk_error == "complnt_branch_IdxFs_" + formSetId_b) {
818                            txt = "Please fill in Organization";
819                        } else if (res.in_chk_error == "complnt_position_IdxFs_" + formSetId_b) {
820                            txt = "Please fill in Position";
821                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
822                            txt = "Please fill in Petition topic";
823                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
824                            txt = "Please choose Type of goods";
825                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
826                            txt = "Please fill in Background information of the petition";
827                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
828                            txt = "You have not determined the value of the damage. Do you want to change the value of the damage?";
829                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
830                            txt = "Please fill in Petitioner’s requirement";
831                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
832                            txt = "Please choose Type of complaint";
833                        }
834                    } else {
835                        // if (res.in_chk_error == "applntOrg_name_IdxFs_" + formSetId_a) {
836                        //     txt = "Please fill in Company Name";
837                        // } else if (res.in_chk_error == "applntOrg_position_IdxFs_" + formSetId_a) {
838                        //     txt = "Please fill in Position";
839                        // } else if (res.in_chk_error == "applntOrg_trade_number_IdxFs_" + formSetId_a) {
840                        //     txt = "Please fill in Business Registration Number";
841                        // } else if (res.in_chk_error == "applntOrg_address_IdxFs_" + formSetId_a) {
842                        //     txt = "Please fill in Address";
843                        // } else if (res.in_chk_error == "applntOrg_tel_IdxFs_" + formSetId_a) {
844                        //     txt = "Please fill in Telephone Number";
845                        // } else if (res.in_chk_error == "applntOrg_zipcode_IdxFs_" + formSetId_a) {
846                        //     txt = "Please fill in Postcode";
847                        // } else if (res.in_chk_error == "applnt_country_id_IdxFs_" + formSetId_a) {
848                        //     txt = "Please choose Country";
849                        // } 
850                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
851                            txt = "Please fill in Defendant’s company name";
852                        } else if (res.in_chk_error == "complnt_import_export_IdxFs_" + formSetId_b) {
853                            txt = "Please choose Type of business";
854                        } else if (res.in_chk_error == "complnt_contact_address_IdxFs_" + formSetId_b) {
855                            txt = "Please fill in Address";
856                        } else if (res.in_chk_error == "complnt_prov_id_IdxFs_" + formSetId_b) {
857                            txt = "Please choose Province";
858                        } else if (res.in_chk_error == "complnt_country_id_IdxFs_" + formSetId_b) {
859                            txt = "Please choose Country";
860                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
861                            txt = "Please fill in Petition topic";
862                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
863                            txt = "Please choose Type of goods";
864                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
865                            txt = "Please fill in Background information of the petition";
866                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
867                            txt = "You have not determined the value of the damage. Do you want to change the value of the damage?";
868                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
869                            txt = "Please fill in Petitioner’s requirement";
870                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
871                            txt = "Please choose Type of complaint";
872                        } else if (res.in_chk_error == "complnt_contact_tel_IdxFs_" + formSetId_b) {
873                            txt = "Please enter your phone number.";
874                        } else if (res.in_chk_error == "complnt_contact_email_IdxFs_" + formSetId_b) {
875                            txt = "Please fill email";
876                        }
877                    }
878
879                } else {
880                    if (res.in_chk_file == "caseAttach_file_name") {
881                        txt = "กรุณากรอก ชื่อไฟล์เอกสาร";
882                    }
883                    if (formSetId_b == 7) {
884                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
885                            txt = "กรุณากรอก ชื่อ-นามสกุล";
886                        }
886 else if (res.in_chk_error == "complnt_branch_IdxFs_" + formSetId_b) {
887                            txt = "กรุณากรอก หน่วยงาน";
888                        } else if (res.in_chk_error == "complnt_position_IdxFs_" + formSetId_b) {
889                            txt = "กรุณากรอก ตำแหน่ง";
890                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
891                            txt = "กรุณากรอก หัวข้อเรื่องร้องเรียน";
892                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
893                            txt = "กรุณาเลือก ประเภทสินค้า";
894                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
895                            txt = "กรุณากรอก ความเป็นมาของประเด็นเรื่องร้องเรียน";
896                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
897                            txt = "ท่านยังไม่ได้กำหนดมูลค่าความเสียหายท่านต้องการเปลี่ยนแปลงมูลค่าความเสียหายหรือไม่ ?";
898                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
899                            txt = "กรุณากรอก ความต้องการของผู้ร้องเรียน";
900                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
901                            txt = "กรุณาเลือก ประเภทความผิด";
902                        }
903                    } else {
904                        // if (res.in_chk_error == "applntOrg_name_IdxFs_" + formSetId_a) {
905                        //     txt = "กรุณากรอก ชื่อบริษัท";
906                        // } else if (res.in_chk_error == "applntOrg_position_IdxFs_" + formSetId_a) {
907                        //     txt = "กรุณากรอก ตำแหน่ง";
908                        // } else if (res.in_chk_error == "applntOrg_trade_number_IdxFs_" + formSetId_a) {
909                        //     txt = "กรุณากรอก เลขนิติบุคคล";
910                        // } else if (res.in_chk_error == "applntOrg_address_IdxFs_" + formSetId_a) {
911                        //     txt = "กรุณากรอก ที่อยู่ติดต่อ";
912                        // } else if (res.in_chk_error == "applntOrg_tel_IdxFs_" + formSetId_a) {
913                        //     txt = "กรุณากรอก เบอร์โทรศัพท์";
914                        // } else if (res.in_chk_error == "applntOrg_zipcode_IdxFs_" + formSetId_a) {
915                        //     txt = "กรุณากรอก รหัสไปรษณีย์";
916                        // } else if (res.in_chk_error == "applnt_country_id_IdxFs_" + formSetId_a) {
917                        //     txt = "กรุณาเลือก ประเทศ";
918                        // } 
919                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
920                            txt = "กรุณากรอก ชื่อบริษัทที่ต้องการร้องเรียน";
921                        } else if (res.in_chk_error == "complnt_import_export_IdxFs_" + formSetId_b) {
922                            txt = "กรุณาเลือก ประเภทธุรกิจ";
923                        } else if (res.in_chk_error == "complnt_contact_address_IdxFs_" + formSetId_b) {
924                            txt = "กรุณากรอก ที่อยู่ติดต่อ";
925                        } else if (res.in_chk_error == "complnt_prov_id_IdxFs_" + formSetId_b) {
926                            txt = "กรุณาเลือก จังหวัด";
927                        } else if (res.in_chk_error == "complnt_country_id_IdxFs_" + formSetId_b) {
928                            txt = "กรุณากรอก ประเทศ";
929                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
930                            txt = "กรุณากรอก หัวข้อเรื่องร้องเรียน";
931                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
932                            txt = "กรุณาเลือก ประเภทสินค้า";
933                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
934                            txt = "กรุณากรอก ความเป็นมาของประเด็นเรื่องร้องเรียน";
935                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
936                            txt = "ท่านยังไม่ได้กำหนดมูลค่าความเสียหายท่านต้องการเปลี่ยนแปลงมูลค่าความเสียหายหรือไม่ ?";
937                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
938                            txt = "กรุณากรอก ความต้องการของผู้ร้องเรียน";
939                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
940                            txt = "กรุณาเลือก ประเภทความผิด";
941                        } else if (res.in_chk_error == "complnt_contact_tel_IdxFs_" + formSetId_b) {
942                            if (res.in_chk_error1 == "telth") {
943                                txt = "กรุณากรอก หมายเลขโทรศัพท์ที่ติดต่อให้ครบ 10 หลัก";
944                            } else if (res.in_chk_error1 == "telen") {
945                                txt = "กรุณากรอก หมายเลขโทรศัพท์ที่ติดต่อ";
946                            } else if(res.in_chk_error1 == "telcode") {
947                                txt = "กรุณาเลือก รหัสประเทศ";
948                            }
949                        } else if (res.in_chk_error == "complnt_contact_email_IdxFs_" + formSetId_b) {
950                            txt = "กรุณากรอก E-mail ที่ติดต่อ";
951                        } else if (res.in_chk_error == "complnt_zipcode_IdxFs_" + formSetId_b) {
952                            txt = "กรุณากรอก รหัสไปรษณีย์ให้ครบ 5 หลัก";
953                        }  else if (res.in_chk_error == "caseAttach_file_name" + res.in_chk_error1) {
954                            txt = "กรุณากรอก หัวข้อของไฟล์แนบ";
955                        } else if (res.in_chk_error == "file_invite"){
956                            txt = "ประเภทไฟล์ไม่ถูกต้อง";
957                        }
958                    }
959                }
960                if (res.in_chk == "01") {
961
962                    var in_chk_error = res.in_chk_error;
963                    bootbox.alert(txt, function() {
964                        setTimeout(function() {
965                            $("[name='" + in_chk_error + "']").focus();
966                        }, 500);
967                    });
968
969
970                } else if (res.in_chk == "02") {
971                    bootbox.confirm(txt, function(result) {
972                        if (result) {
973                            $('#wait_process').css('display', 'none');
974                            var in_chk_error = res.in_chk_error;
975                            setTimeout(function() {
976                                $("[name='" + in_chk_error + "']").focus();
977                            }, 500);
978                        } else {
979                            $("#chk_invite_step2").submit();
980                            $('#wait_process').css('display', 'none');
981
982                        }
983                    });
984                } else if (res.in_chk == "05") {
985                    var in_chk_error = res.in_chk_error;
986                    bootbox.alert(txt, function() {
987                        setTimeout(function() {
988                            $("#" + in_chk_error).focus();
989                        }, 500);
990                    });
991                } else {
992                    $("#chk_invite_step2").submit();
993                }
994            },
995            error: function(jqXHR, textStatus, errorThrown) {
996                console.log(jqXHR);
997
998                if (jqXHR.status == 0) {
999                    bootbox.confirm("ขออภัยเนื่องจากอินเตอร์เน็ตของท่านขัดข้อง อาจทำให้ไฟล์แนบของท่านไม่สามารถอัพโหลดเข้าระบบได้ ท่านต้องการบันทึกเรื่องร้องเรียนหรือไม่?", function(result) {
1000                        if (result) {
1001                            btnchkinvitestep2(true);
1002                            $('#wait_process').css('display', 'none');
1003                        } else {
1004                            $('#wait_process').css('display', 'none');
1005                        }
1006                    });
1007                } else {
1008                    bootbox.alert("ขออภัย เนื่องจากระบบเกิดข้อผิดพลาด กรุณาลองใหม่ภายหลัง", function() {
1009                        $('#wait_process').css('display', 'none');
1010                    });
1011                }
1012            }
1013        });
1014
1015    }
1016}
1017
1018
1019
1020function btnchkinviteedit(status_upload) {
1021    var lang = $('.language_hidden').val();
1022    var formSetId_a = $("input[name='formSetId_a']").val();
1023    var formSetId_b = $("input[name='formSetId_b']").val();
1024    var formSetId_c = $("input[name='formSetId_c']").val();
1025    var email = $("input[name='complnt_contact_email_IdxFs_" + formSetId_b + "']").val();
1026    var chkmail = true;
1027    if (email != "") {
1028        chkmail = validateEmail(email);
1029    }
1030
1031    // console.log(lang);
1032    ///from1
1033    var form_data = new FormData();
1034    if (status_upload != true) {
1035        $.each($('input[type=file]')[0].files, function(i, file) {
1036            form_data.append('file[]', file);
1037        });
1038
1039        $('input[name="caseAttach_file_name[]"]').each(function() {
1040            form_data.append('caseAttach_file_name[]', $(this).val());
1041        });
1042    }
1043    form_data.append('fileinput_file_remove', $("input[name='fileinput_file_remove").val());
1044    // form_data.append('applntOrg_name', $("input[name='applntOrg_name_IdxFs_" + formSetId_a + "']").val());
1045    // form_data.append('applntOrg_position', $("input[name='applntOrg_position_IdxFs_" + formSetId_a + "']").val());
1046    // form_data.append('applntOrg_trade_number', $("input[name='applntOrg_trade_number_IdxFs_" + formSetId_a + "']").val());
1047    // form_data.append('applntOrg_address', $("textarea[name='applntOrg_address_IdxFs_" + formSetId_a + "']").val());
1048    // form_data.append('applntOrg_tel', $("input[name='applntOrg_tel_IdxFs_" + formSetId_a + "']").val());
1049    // form_data.append('applntOrg_zipcode', $("input[name='applntOrg_zipcode_IdxFs_" + formSetId_a + "']").val());
1050    // form_data.append('applnt_country_id', $("select[name='applnt_country_id_IdxFs_" + formSetId_a + "']").val());
1051    ///endfrom1
1052    ///from2
1053    form_data.append('complnt_name', $("input[name='complnt_name_IdxFs_" + formSetId_b + "']").val());
1054    form_data.append('complnt_import_export', $("select[name='complnt_import_export_IdxFs_" + formSetId_b + "']").val());
1055    form_data.append('complnt_contact_address', $("textarea[name='complnt_contact_address_IdxFs_" + formSetId_b + "']").val());
1056    form_data.append('complnt_prov_id', $("select[name='complnt_prov_id_IdxFs_" + formSetId_b + "']").val());
1057    form_data.append('complnt_country_id', $("select[name='complnt_country_id_IdxFs_" + formSetId_b + "']").val());
1058
1059    form_data.append('complnt_branch', $("input[name='complnt_branch_Id
1059xFs_" + formSetId_b + "']").val());
1060    form_data.append('complnt_position', $("input[name='complnt_position_IdxFs_" + formSetId_b + "']").val());
1061    ///endfrom2
1062    ///from3
1063    form_data.append('caseDtl_title', $("input[name='caseDtl_title_IdxFs_" + formSetId_c + "']").val());
1064    form_data.append('prodType_id', $("select[name='prodType_id_IdxFs_" + formSetId_c + "']").val());
1065    form_data.append('incType_id', $("select[name='incType_id_IdxFs_" + formSetId_c + "']").val());
1066    form_data.append('caseDtl_derivation', $("textarea[name='caseDtl_derivation_IdxFs_" + formSetId_c + "']").val());
1067    form_data.append('caseDtl_damage_val', $("input[name='caseDtl_damage_val_IdxFs_" + formSetId_c + "']").val());
1068    form_data.append('caseDtl_complnt_need', $("textarea[name='caseDtl_complnt_need_IdxFs_" + formSetId_c + "']").val());
1069    ///endfrom3
1070
1071
1072    form_data.append('formSetId_a', formSetId_a);
1073    form_data.append('formSetId_b', formSetId_b);
1074    form_data.append('formSetId_c', formSetId_c);
1075    form_data.append('applntOrg_show', $('.applntOrg_show').val());
1076    form_data.append('method', "chk_invite_txt_edit");
1077
1078    var Newresult = Newbtn_editsubmit();
1079
1080    if (chkmail == false) {
1081        if (lang == 2) {
1082            var txt_mail = "Please check the format of your email correctly.";
1083        } else {
1084            var txt_mail = "กรุณาตรวจสอบรูปแบบอีเมล์ของท่านให้ถูกต้อง";
1085        }
1086        bootbox.alert(txt_mail);
1087    }else if(Newresult == false){
1088        return false;
1089    } else {
1090        $('#wait_process').css('display', 'block');
1091        $.ajax({
1092            url: 'function_php/function_index.php',
1093            type: 'POST',
1094            enctype: 'multipart/form-data',
1095            timeout: 20000,
1096            cache: false,
1097            processData: false,
1098            contentType: false,
1099            responseType: "json",
1100            data: form_data,
1101            success: function(res) {
1102
1103                var txt = "";
1104                if (lang == 2) {
1105
1106                    if (res.in_chk_file == "caseAttach_file_name") {
1107                        txt = "Please fill in File Name";
1108                    }
1109                    if (formSetId_b == 7) {
1110                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
1111                            txt = "Please fill in Full name";
1112                        } else if (res.in_chk_error == "complnt_branch_IdxFs_" + formSetId_b) {
1113                            txt = "Please fill in Organization";
1114                        } else if (res.in_chk_error == "complnt_position_IdxFs_" + formSetId_b) {
1115                            txt = "Please fill in Position";
1116                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
1117                            txt = "Please fill in Petition topic";
1118                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
1119                            txt = "Please choose Type of goods";
1120                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
1121                            txt = "Please fill in Background information of the petition";
1122                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
1123                            txt = "You have not determined the value of the damage. Do you want to change the value of the damage?";
1124                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
1125                            txt = "Please fill in Petitioner’s requirement";
1126                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
1127                            txt = "Please choose Type of complaint";
1128                        }
1129                    } else {
1130                        // if (res.in_chk_error == "applntOrg_name_IdxFs_" + formSetId_a) {
1131                        //     txt = "Please fill in Company Name";
1132                        // } else if (res.in_chk_error == "applntOrg_position_IdxFs_" + formSetId_a) {
1133                        //     txt = "Please fill in Position";
1134                        // } else if (res.in_chk_error == "applntOrg_trade_number_IdxFs_" + formSetId_a) {
1135                        //     txt = "Please fill in Business Registration Number";
1136                        // } else if (res.in_chk_error == "applntOrg_address_IdxFs_" + formSetId_a) {
1137                        //     txt = "Please fill in Address";
1138                        // } else if (res.in_chk_error == "applntOrg_tel_IdxFs_" + formSetId_a) {
1139                        //     txt = "Please fill in Telephone Number";
1140                        // } else if (res.in_chk_error == "applntOrg_zipcode_IdxFs_" + formSetId_a) {
1141                        //     txt = "Please fill in Postcode";
1142                        // } else if (res.in_chk_error == "applnt_country_id_IdxFs_" + formSetId_a) {
1143                        //     txt = "Please choose Country";
1144                        // } 
1145                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
1146                            txt = "Please fill in Defendant’s company name";
1147                        } else if (res.in_chk_error == "complnt_import_export_IdxFs_" + formSetId_b) {
1148                            txt = "Please choose Type of business";
1149                        } else if (res.in_chk_error == "complnt_contact_address_IdxFs_" + formSetId_b) {
1150                            txt = "Please fill in Address";
1151                        } else if (res.in_chk_error == "complnt_prov_id_IdxFs_" + formSetId_b) {
1152                            txt = "Please choose Province";
1153                        } else if (res.in_chk_error == "complnt_country_id_IdxFs_" + formSetId_b) {
1154                            txt = "Please choose Country";
1155                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
1156                            txt = "Please fill in Petition topic";
1157                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
1158                            txt = "Please choose Type of goods";
1159                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
1160                            txt = "Please fill in Background information of the petition";
1161                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
1162                            txt = "You have not determined the value of the damage. Do you want to change the value of the damage?";
1163                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
1164                            txt = "Please fill in Petitioner’s requirement";
1165                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
1166                            txt = "Please choose Type of complaint";
1167                        }
1168                    }
1169
1170                } else {
1171                    if (res.in_chk_file == "caseAttach_file_name") {
1172                        txt = "กรุณากรอก ชื่อไฟล์เอกสาร";
1173                    }
1174                    if (formSetId_b == 7) {
1175                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
1176                            txt = "กรุณากรอก ชื่อ-นามสกุล";
1177                        } else if (res.in_chk_error == "complnt_branch_IdxFs_" + formSetId_b) {
1178                            txt = "กรุณากรอก หน่วยงาน";
1179                        } else if (res.in_chk_error == "complnt_position_IdxFs_" + formSetId_b) {
1180                            txt = "กรุณากรอก ตำแหน่ง";
1181                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
1182                            txt = "กรุณากรอก หัวข้อเรื่องร้องเรียน";
1183                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
1184                            txt = "กรุณาเลือก ประเภทสินค้า";
1185                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
1186                            txt = "กรุณากรอก ความเป็นมาของประเด็นเรื่องร้องเรียน";
1187                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
1188                            txt = "ท่านยังไม่ได้กำหนดมูลค่าความเสียหายท่านต้องการเปลี่ยนแปลงมูลค่าความเสียหายหรือไม่ ?";
1189                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
1190                            txt = "กรุณากรอก ความต้องการของผู้ร้องเรียน";
1191                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
1192                            txt = "กรุณาเลือก ประเภทความผิด";
1193                        }
1194                    } else {
1195                        // if (res.in_chk_error == "applntOrg_name_IdxFs_" + formSetId_a) {
1196                        //     txt = "กรุณากรอก ชื่อบริษัท";
1197                        // } else if (res.in_chk_error == "applntOrg_position_IdxFs_" + formSetId_a) {
1198                        //     txt = "กรุณากรอก ตำแหน่ง";
1199                        // } else if (res.in_chk_error == "applntOrg_trade_number_IdxFs_" + formSetId_a) {
1200                        //     txt = "กรุณากรอก เลขนิติบุคคล";
1201                        // } else if (res.in_chk_error == "applntOrg_address_IdxFs_" + formSetId_a) {
1202                        //     txt = "กรุณากรอก ที่อยู่ติดต่อ";
1203                        // } else if (res.in_chk_error == "applntOrg_tel_IdxFs_" + formSetId_a) {
1204                        //     txt = "กรุณากรอก เบอร์โทรศัพท์";
1205                        // } else if (res.in_chk_error == "applntOrg_zipcode_IdxFs_" + formSetId_a) {
1206                        //     txt = "กรุณากรอก รหัสไปรษณีย์";
1207                        // } else if (res.in_chk_error == "applnt_country_id_IdxFs_" + formSetId_a) {
1208                        //     txt = "กรุณาเลือก ประเทศ";
1209                        // }
1210                        if (res.in_chk_error == "complnt_name_IdxFs_" + formSetId_b) {
1211                            txt = "กรุณากรอก ชื่อบริษัทที่ต้องการร้องเรียน";
1212                        } else if (res.in_chk_error == "complnt_import_export_IdxFs_" + formSetId_b) {
1213                            txt = "กรุณาเลือก ประเภทธุรกิจ";
1214                        } else if (res.in_chk_error == "complnt_contact_address_IdxFs_" + formSetId_b) {
1215                            txt = "กรุณากรอก ที่อยู่ติดต่อ";
1216                        } else if (res.in_chk_error == "complnt_prov_id_IdxFs_" + formSetId_b) {
1217                            txt = "กรุณาเลือก จังหวัด";
1218                        } else if (res.in_chk_error == "complnt_country_id_IdxFs_" + formSetId_b) {
1219                            txt = "กรุณากรอก ประเทศ";
1220                        } else if (res.in_chk_error == "caseDtl_title_IdxFs_" + formSetId_c) {
1221                            txt = "กรุณากรอก หัวข้อเรื่องร้องเรียน";
1222                        } else if (res.in_chk_error == "prodType_id_IdxFs_" + formSetId_c) {
1223                            txt = "กรุณาเลือก ประเภทสินค้า";
1224                        } else if (res.in_chk_error == "caseDtl_derivation_IdxFs_" + formSetId_c) {
1225                            txt = "กรุณากรอก ความเป็นมาของประเด็นเรื่องร้องเรียน";
1226                        } else if (res.in_chk_error == "caseDtl_damage_val_IdxFs_" + formSetId_c) {
1227                            txt = "ท่านยังไม่ได้กำหนดมูลค่าความเสียหายท่านต้องการเปลี่ยนแปลงมูลค่าความเสียหายหรือไม่ ?";
1228                        } else if (res.in_chk_error == "caseDtl_complnt_need_IdxFs_" + formSetId_c) {
1229                            txt = "กรุณากรอก ความต้องการของผู้ร้องเรียน";
1230                        } else if (res.in_chk_error == "incType_id_IdxFs_" + formSetId_c) {
1231                            txt = "กรุณาเลือก ประเภทความผิด";
1232                        } else if (res.in_chk_error == "file_invite"){
1233                            txt = "ประเภทไฟล์ไม่ถูกต้อง";
1234                        }
1235                    }
1236                }
1237                // console.log(txt, res.in_chk_error);
1238                $('#wait_process').css('display', 'none');
1239                if (res.in_chk == "01") {
1240                    var in_chk_error = res.in_chk_error;
1241                    bootbox.alert(txt, function() {
1242                        setTimeout(function() {
1243                            $("[name='" + in_chk_error + "']").focus();
1244                        }, 500);
1245                    });
1246
1247
1248                } else if (res.in_chk == "02") {
1249                    bootbox.confirm(txt, function(result) {
1250                        if (result) {
1251                            $('#wait_process').css('display', 'none');
1252                            var in_chk_error = res.in_chk_error;
1253                            setTimeout(function() {
1254                                $("[name='" + in_chk_error + "']").focus();
1255                            }, 500);
1256                        } else {
1257                            $("#chk_invite_step2").submit();
1258                            $('#wait_process').css('display', 'none');
1259                        }
1260                    });
1261                } else if (res.in_chk == "05") {
1262                    var in_chk_error = res.in_chk_error;
1263                    bootbox.alert(txt, function() {
1264                        setTimeout(function() {
1265                            $("#" + in_chk_error).focus();
1266                        }, 500);
1267                    });
1268                } else {
1269
1270                    $("#chk_invite_step2").submit();
1271                }
1272            },
1273            error: function(jqXHR, textStatus, errorThrown) {
1274                console.log(jqXHR);
1275
1276                if (jqXHR.status == 0) {
1277                    bootbox.confirm("ขออภัยเนื่องจากอินเตอร์เน็ตของท่านขัดข้อง อาจทำให้ไฟล์แนบของท่านไม่สามารถอัพโหลดเข้าระบบได้ ท่านต้องการไปขั้นตอนต่อไปหรือไม่?", function(result) {
1278                        if (result) {
1279                            btnchkinviteedit(true);
1280                            $('#wait_process').css('display', 'none');
1281                        } else {
1282                            $('#wait_process').css('display', 'none');
1283                        }
1284                    });
1285                } else {
1286                    bootbox.alert("ขออภัย เนื่องจากระบบเกิดข้อผิดพลาด กรุณาลองใหม่ภายหลัง", function() {
1287                        $('#wait_process').css('display', 'none');
1288                    });
1289                }
1290
1291            }
1292        });
1293    }
1294}
1295
1296
1297
1298function submit_case(form, form_this, ignore_file) {
1299
1300    if (ignore_file == true) {
1301        var formData = $('#chk_invite_step3').serialize();
1302    } else {
1303        var formData = $('#chk_invite_step3').serialize();
1304    }
1305    var $submit = form.find('button[type="submit"]');
1306    // console.log(formData);
1307    $submit.attr("disabled", true);
1308    $.ajax({
1309        url: "function_php/function_index.php?method=create_invite",
1310        type: "POST",
1311        dataType: "json",
1312        timeout: 20000,
1313        cache: false,
1314        contentType: false,
1315        processData: false,
1316        data: formData,
1317        success: function(data) {
1318
1319            if (data.status_response == "00") {
1320                bootbox.alert('ระบบบันทึกเรื่องร้องเรียนเรียบร้อยแล้ว', function() {
1321                    window.location.href = "index.php?page=appeal";
1322                });
1323            } else if (data.status_response == "01") {
1324                bootbox.alert("บันทึกเรื่องร้องเรียนเกิดข้อผิดพลาด กรุณาลองใหม่อีกครั้ง", function() {
1325                    $submit.attr("disabled", false);
1326                });
1327            }
1328        },
1329        error: function(jqXHR, textStatus, errorThrown) {
1330            console.log(jqXHR);
1331
1332            if (jqXHR.status == 0) {
1333                bootbox.confirm("ขออภัยเนื่องจากอินเตอร์เน็ตของท่านขัดข้อง อาจทำให้ไฟล์แนบของท่านไม่สามารถอัพโหลดเข้าระบบได้ ท่านต้องการไปขั้นตอนต่อไปหรือไม่?", function(result) {
1334                    if (result) {
1335                        submit_case(form, form_this, true);
1336                    } else {
1337                        $submit.attr("disabled", false);
1338                    }
1339                });
1340            } else {
1341                bootbox.alert("ขออภัย เนื่องจากระบบเกิดข้อผิดพลาด กรุณาลองใหม่ภายหลัง");
1342                $submit.attr("disabled", false);
1343            }
1344        }
1345    });
1346}
1347
1348function submitForm(action, target) {
1349    // $('#wait_process').css('display', 'block');
1350    var form = document.getElementById('chk_invite_step3');
1351    $form = $('#chk_invite_step3');
1352    form.action = action;
1353    if (target == 2) {
1354        form.target = 'chk_invite';
1355        form.submit();
1356    } else {
1357        form.target = '';
1358        form.submit();
1359    }
1360}
1361
1362// $(function(){
1363//   $( "#chk_invite_step3" ).submit(function( event ) {
1364//       var lang = $('.language_hidden').val();
1365//       if(lang == "2"){
1366//         var ArlogIn = "Confirm the petition?";
1367//       }else {
1368//         var ArlogIn = "ยืนยันบันทึกการแจ้งเรื่อง ?";
1369//       }
1370//     event.preventDefault();
1371//       bootbox.confirm(ArlogIn, function(result) {
1372//           if (result) {
1373//             submit_case($(this),this);
1374//           }
1375//       });
1376//   });
1377// });
1378
1379
1380function register_modal(status) {
1381    $('#modal_chk_register').modal('show');
1382    $('.status_login').val(status);
1383}
1384
1385function login_modal() {
1386    $('#modal_chk_login').modal('show');
1387}
1388
1389function open_modal_register(status) {
1390    $('#modal_chk_login').modal('hide');
1391    $('#modal_chk_register').modal('show');
1392    $('.status_login').val(status);
1393}
1394
1395function sel_status_appeal() {
1396    $('.appeal_center').hide();
1397    var e = document.getElementById("sel_status_appeal");
1398    var strUser = e.options[e.selectedIndex].value;
1399    $.ajax({
1400        url: 'appeal.php',
1401        type: 'POST',
1402        async: false,
1403        responseType: "json",
1404        data: {
1405            chk_status: strUser,
1406            method: "filter_appeal"
1407        },
1408        success: function(res) {
1409            $('.appeal_center_filter').html(res);
1410        },
1411        error: function(jqXHR, textStatus, errorThrown) {
1412            console.log(jqXHR, textStatus, errorThrown);
1413        }
1414    });
1415}
1416
1417function search_appeal_enter(e) {
1418    if (e.keyCode == 13) {
1419        $('.appeal_center').hide();
1420        var txt_search = $('.search_text').val();
1421        var e = document.getElementById("sel_status_appeal");
1422        var strUser = e.options[e.selectedIndex].value;
1423        $.ajax({
1424            url: 'appeal.php',
1425            type: 'POST',
1426            async: false,
1427            responseType: "json",
1428            data: {
1429                chk_status: strUser,
1430                txt_search: txt_search,
1431                method: "filter_appeal_search"
1432            },
1433            success: function(res) {
1434                $('.appeal_center_filter').html(res);
1435            },
1436            error: function(jqXHR, textStatus, errorThrown) {
1437                console.log(jqXHR, textStatus, errorThrown);
1438            }
1439        });
1440    }
1441}
1442
1443function search_appeal() {
1444    $('.appeal_center').hide();
1445    var txt_search = $('.search_text').val();
1446    var e = document.getElementById("sel_status_appeal");
1447    var strUser = e.options[e.selectedIndex].value;
1448    $.ajax({
1449        url: 'appeal.php',
1450        type: 'POST',
1451        async: false,
1452        responseType: "json",
1453        data: {
1454            chk_status: strUser,
1455            txt_search: txt_search,
1456            method: "filter_appeal_search"
1457        },
1458        success: function(res) {
1459            $('.appeal_center_filter').html(res);
1460        },
1461        error: function(jqXHR, textStatus, errorThrown) {
1462            console.log(jqXHR, textStatus, errorThrown);
1463        }
1464    });
1465}
1466
1467function search_appeal_enter_all(e) {
1468    if (e.keyCode == 13) {
1469        $('.appeal_center').hide();
1470        var txt_search = $('.search_text').val();
1471        var strUser = $('.get_status').val();
1472        $.ajax({
1473            url: 'all_appeal.php',
1474            type: 'POST',
1475            async: false,
1476            responseType: "json",
1477            data: {
1478                chk_status: strUser,
1479                txt_search: txt_search,
1480                method: "filter_appeal"
1481            },
1482            success: function(res) {
1483                $('.appeal_center_filter').html(res);
1484            },
1485            error: function(jqXHR, textStatus, errorThrown) {
1486                console.log(jqXHR, textStatus, errorThrown);
1487            }
1488        });
1489    }
1490}
1491
1492function search_appeal_all() {
1493    $('.appeal_center').hide();
1494    var txt_search = $('.search_text').val();
1495    var strUser = $('.get_status').val();
1496    $.ajax({
1497        url: 'all_appeal.php',
1498        type: 'POST',
1499        async: false,
1500        responseType: "json",
1501        data: {
1502            chk_status: strUser,
1503            txt_search: txt_search,
1504            method: "filter_appeal"
1505        },
1506        success: function(res) {
1507            $('.appeal_center_filter').html(res);
1508        },
1509        error: function(jqXHR, textStatus, errorThrown) {
1510            console.log(jqXHR, textStatus, errorThrown);
1511        }
1512    });
1513}
1514
1515function show_modal_profile() {
1516
1517    $('#modal_profile').modal('show');
1518    $('.img_profile_edit').attr('src', $('.pathfile_profile').val());
1519    var image = new Image();
1520    image.src = $('.pathfile_profile').val();
1521    image.onload = function() {
1522            console.log('this.width');
1523            $('.img_profile_edit').attr('style', getPositionImage(this.width, this.height, 120));
1524        }
1525        // $('.img_profile_edit').css('background-image', 'url(' + $('.pathfile_profile').val() + ')');
1526}
1527
1528function click_edit_img_profile() {
1529    $(".file_profile").click();
1530}
1531
1532$(document).delegate(".edit_profile_modal", "click", function() {
1533    $(`input[name="tel_country_code"]`).val($(`#tel1`).find(`.iti__active`).attr("data-country-code"));
1534    $(`input[name="tel_code"]`).val($(`#tel1`).find(`.iti__active`).find('.iti__dial-code').html());
1535    var lang = $('.language_hidden').val();
1536    if (lang == "2") {
1537        var Companyname = "Please fill in Company name";
1538        var Branch = "Please fill in Branch";
1539        var Business = "Please fill in Business Registration Number";
1540        var Typebusiness = "Please choose Type of business";
1541        var Telephone = "Please fill in Telephone number";
1542        var Address = "Please fill in Address";
1543        var Country = "Please choose Country";
1544        var Postcode = "Please fill in Postcode";
1545        var fname = "Please fill in First name";
1546        var lname = "Please fill in Last names";
1547        var Code = "Please fill in 13-digit Population Identification Code";
1548        var sex = "Please choose Gender";
1549        var position = "Please fill in Position'";
1550        var Mtelephone = "Please fill in Mobile telephone number";
1551        var Csubmit = "Are you sure you want to make changes";
1552        var Occ = "Please fill in Occupation";
1553    } else {
1554        var Companyname = "กรุณากรอก ชื่อบริษัท";
1555        var Branch = "กรุณากรอก สาขา";
1556        var Business = "กรุณากรอก เลขนิติบุคคล";
1557        var Typebusiness = "กรุณาเลือก ประเภทธุรกิจ";
1558        var Telephone = "กรุณากรอก เบอร์โทรศัพท์";
1559        var Address = "กรุณากรอก ที่อยู่ติดต่อ";
1560        var Country = "กรุณาเลือก ประเทศ";
1561        var Postcode = "กรุณากรอก รหัสไปรษณีย์";
1562        var fname = "กรุณากรอก ชื่อ";
1563        var lname = "กรุณากรอก นามสกุล";
1564        var Code = "กรุณากรอก เลขบัตรประชาชนให้ครบ";
1565        var sex = "กรุณาเลือก เพศ";
1566        var position = "กรุณากรอก ตำแหน่ง'";
1567        var Mtelephone = "กรุณากรอก เบอร์โทรศัพท์มือถือให้ครบ";
1568        var Csubmit = "ยืนยันการแก้ไขข้อมูลหรือไม่";
1569        var Occ = "กรุณากรอก อาชีพ";
1570    }
1571    if ($('.member_type').val() == "1") {
1572        if ($('.member_comp_name').val() == "") {
1573            bootbox.alert(Companyname, function() {
1574                $(".bootbox-alert").on("hidden.bs.modal", function() {
1575                    $('body').addClass('modal-open');
1576                });
1577            });
1578        } else if ($('.member_comp_branch').val() == "") {
1579            bootbox.alert(Branch, function() {
1580                $(".bootbox-alert").on("hidden.bs.modal", function() {
1581                    $('body').addClass('modal-open');
1582                });
1583            });
1584        } else if ($('.member_comp_taxid').val() == "") {
1585            bootbox.alert(Business, function() {
1586                $(".bootbox-alert").on("hidden.bs.modal", function() {
1587                    $('body').addClass('modal-open');
1588                });
1589            });
1590        } else if ($('#sel_business_person_office').val() == "") {
1591            bootbox.alert(Typebusiness, function() {
1592                $(".bootbox-alert").on("hidden.bs.modal", function() {
1593                    $('body').addClass('modal-open');
1594                });
1595            });
1596        } else if ($('.member_comp_phone').val() == "") {
1597            bootbox.alert(Telephone, function() {
1598                $(".bootbox-alert").on("hidden.bs.modal", function() {
1599                    $('body').addClass('modal-open');
1600                });
1601            });
1602        } else if ($('.member_comp_address').val() == "") {
1603            bootbox.alert(Address, function() {
1604                $(".bootbox-alert").on("hidden.bs.modal", function() {
1605                    $('body').addClass('modal-open');
1606                });
1607            });
1608        } else if ($('#country_id_com').val() == "") {
1609            bootbox.alert(Country, function() {
1610                $(".bootbox-alert").on("hidden.bs.modal", function() {
1611                    $('body').addClass('modal-open');
1612                });
1613            });
1614        } else if ($('.member_comp_postcode').val() == "") {
1615            bootbox.alert(Postcode, function() {
1616                $(".bootbox-alert").on("hidden.bs.modal", function() {
1617                    $('body').addClass('modal-open');
1618                });
1619            });
1620        } else if ($('.name_profile').val() == "") {
1621            bootbox.alert(fname, function() {
1622                $(".bootbox-alert").on("hidden.bs.modal", function() {
1623                    $('body').addClass('modal-open');
1624                });
1625            });
1626        } else if ($('.lastname_profile').val() == "") {
1627            bootbox.alert(lname, function() {
1628                $(".bootbox-alert").on("hidden.bs.modal", function() {
1629                    $('body').addClass('modal-open');
1630                });
1631            });
1632        } else if ($('.member_cid').val().length != 13) {
1633            bootbox.alert(Code, function() {
1634                $(".bootbox-alert").on("hidden.bs.modal", function() {
1635                    $('body').addClass('modal-open');
1636                });
1637            });
1638        } else if ($('#sex').val() == "") {
1639            bootbox.alert(sex, function() {
1640                $(".bootbox-alert").on("hidden.bs.modal", function() {
1641                    $('body').addClass('modal-open');
1642                });
1643            });
1644        } else if ($('.member_position').val() == "") {
1645            bootbox.alert(position, function() {
1646                $(".bootbox-alert").on("hidden.bs.modal", function() {
1647                    $('body').addClass('modal-open');
1648                });
1649            });
1650        } else if ($('.member_phone').val().length != 10) {
1651            bootbox.alert(Mtelephone, function() {
1652                $(".bootbox-alert").on("hidden.bs.modal", function() {
1653                    $('body').addClass('modal-open');
1654                });
1655            });
1656        } else if ($('.member_address').val() == "") {
1657            bootbox.alert(Address, function() {
1658                $(".bootbox-alert").on("hidden.bs.modal", function() {
1659                    $('body').addClass('modal-open');
1660                });
1661            });
1662        } else if ($('#country_id').val() == "") {
1663            bootbox.alert(Country, function() {
1664                $(".bootbox-alert").on("hidden.bs.modal", function() {
1665                    $('body').addClass('modal-open');
1666                });
1667            });
1668        } else if ($('.member_postcode').val() == "") {
1669            bootbox.alert(Postcode, function() {
1670                $(".bootbox-alert").on("hidden.bs.modal", function() {
1671                    $('body').addClass('modal-open');
1672                });
1673            });
1674        } else {
1675            bootbox.confirm({
1676                message: Csubmit,
1677                buttons: {
1678                    confirm: {
1679                        label: 'Yes',
1680                        className: 'btn-success'
1681                    },
1682                    cancel: {
1683                        label: 'No',
1684                        className: 'btn-danger'
1685                    }
1686                },
1687                callback: function(result) {
1688                    if (result == true) {
1689                        $('#wait_process').css('display', 'block');
1690                        var form_data = new FormData();
1691                        form_data.append('file', fileTumbnail);
1692                        form_data.append('member_type', $(".member_type").val());
1693                        form_data.append('name_profile', $(".name_profile").val());
1694                        form_data.append('lastname_profile', $(".lastname_profile").val());
1695                        form_data.append('member_cid', $(".member_cid").val());
1696                        form_data.append('sex', $("#sex").val());
1697                        form_data.append('member_position', $(".member_position").val());
1698                        form_data.append('member_occupation', $(".member_occupation").val());
1699                        form_data.append('member_phone', $(".member_phone").val());
1700                        form_data.append('member_cellphone', $(".member_cellphone").val());
1701                        form_data.append('member_address', $(".member_address").val());
1702                        form_data.append('country_id', $("#country_id").val());
1703                        form_data.append('prov_id', $("#prov_id").val());
1704                        form_data.append('member_postcode', $(".member_postcode").val());
1705
1706                        form_data.append('member_comp_name', $(".member_comp_name").val());
1707                        form_data.append('member_comp_branch', $(".member_comp_branch").val());
1708                        form_data.append('member_comp_taxid', $(".member_comp_taxid").val());
1709                        form_data.append('member_comp_phone', $(".member_comp_phone").val());
1710                        form_data.append('member_comp_fax', $(".member_comp_fax").val());
1711                        form_data.append('member_comp_address', $(".member_comp_address").val());
1712                        form_data.append('country_id_com', $("#country_id_com").val());
1713                        form_data.append('prov_id_com', $("#prov_id_com").val());
1714                        form_data.append('member_comp_postcode', $(".member_comp_postcode").val());
1715                        form_data.append('method', "edit_profile_modal");
1716                        form_data.append('tel_country_code', $(`input[name="tel_country_code"]`).val());
1717                        form_data.append('tel_code', $(`input[name="tel_code"]`).val());
1718                        $.ajax({
1719                            url: 'function_php/function_index.php',
1720                            type: 'POST',
1721                            enctype: 'multipart/form-data',
1722                            async: false,
1723                            processData: false,
1724                            contentType: false,
1725                            responseType: "json",
1726                            data: form_data,
1727                            success: function(res) {
1728                                $("#modal_profile_form").submit();
1729                            },
1730                            error: function(jqXHR, textStatus, errorThrown) {
1731                                console.log(jqXHR, textStatus, errorThrown);
1732                            }
1733                        });
1734                    } else {
1735                        $(".bootbox-confirm").on("hidden.bs.modal", function() {
1736                            $('body').addClass('modal-open');
1737                        });
1738                    }
1739                }
1740            });
1741        }
1742
1743    } else {
1744
1745        if ($('.name_profile').val() == "") {
1746            bootbox.alert(fname, function() {
1747                $(".bootbox-alert").on("hidden.bs.modal", function() {
1748                    $('body').addClass('modal-open');
1749                });
1750            });
1751        } else if ($('.lastname_profile').val() == "") {
1752            bootbox.alert(lname, function() {
1753                $(".bootbox-alert").on("hidden.bs.modal", function() {
1754                    $('body').addClass('modal-open');
1755                });
1756            });
1757        } else if ($('.member_cid').val().length != 13) {
1758            bootbox.alert(Code, function() {
1759                $(".bootbox-alert").on("hidden.bs.modal", function() {
1760                    $('body').addClass('modal-open');
1761                });
1762            });
1763        } else if ($('#sex').val() == "") {
1764            bootbox.alert(sex, function() {
1765                $(".bootbox-alert").on("hidden.bs.modal", function() {
1766                    $('body').addClass('modal-open');
1767                });
1768            });
1769        } else if ($('.member_occupation').val() == "") {
1770            bootbox.alert(Occ, function() {
1771                $(".bootbox-alert").on("hidden.bs.modal", function() {
1772                    $('body').addClass('modal-open');
1773                });
1774            });
1775        } else if ($('.member_phone').val().length != 10) {
1776            bootbox.alert(Mtelephone, function() {
1777                $(".bootbox-alert").on("hidden.bs.modal", function() {
1778                    $('body').addClass('modal-open');
1779                });
1780            });
1781        } else if ($('.member_address').val() == "") {
1782            bootbox.alert(Address, function() {
1783                $(".bootbox-alert").on("hidden.bs.modal", function() {
1784                    $('body').addClass('modal-open');
1785                });
1786            });
1787        } else if ($('#country_id').val() == "") {
1788            bootbox.alert(Country, function() {
1789                $(".bootbox-alert").on("hidden.bs.modal", function() {
1790                    $('body').addClass('modal-open');
1791                });
1792            });
1793        } else if ($('.member_postcode').val() == "") {
1794            bootbox.alert(Postcode, function() {
1795                $(".bootbox-alert").on("hidden.bs.modal", function() {
1796                    $('body').addClass('modal-open');
1797                });
1798            });
1799        } else {
1800
1801            bootbox.confirm({
1802                message: Csubmit,
1803                buttons: {
1804                    confirm: {
1805                        label: 'Yes',
1806                        className: 'btn-success'
1807                    },
1808                    cancel: {
1809                        label: 'No',
1810                        className: 'btn-danger'
1811                    }
1812                },
1813                callback: function(result) {
1814                    if (result == true) {
1815                        $('#wait_process').css('display', 'block');
1816                        var form_data = new FormData();
1817                        form_data.append('file', fileTumbnail);
1818                        form_data.append('member_type', $(".member_type").val());
1819                        form_data.append('name_profile', $(".name_profile").val());
1820                        form_data.append('lastname_profile', $(".lastname_profile").val());
1821                        form_data.append('member_cid', $(".member_cid").val());
1822                        form_data.append('sex', $("#sex").val());
1823                        form_data.append('member_position', $(".member_position").val());
1824                        form_data.append('member_occupation', $(".member_occupation").val());
1825                        form_data.append('member_phone', $(".member_phone").val());
1826                        form_data.append('member_cellphone', $(".member_cellphone").val());
1827                        form_data.append('member_address', $(".member_address").val());
1828                        form_data.append('country_id', $("#country_id").val());
1829                        form_data.append('prov_id', $("#prov_id").val());
1830                        form_data.append('member_postcode', $(".member_postcode").val());
1831                        form_data.append('method', "edit_profile_modal");
1832                        form_data.append('tel_country_code', $(`input[name="tel_country_code"]`).val());
1833                        form_data.append('tel_code', $(`input[name="tel_code"]`).val());
1834                        $.ajax({
1835                            url: 'function_php/function_index.php',
1836                            type: 'POST',
1837                            enctype: 'multipart/form-data',
1838                            async: false,
1839                            processData: false,
1840                            contentType: false,
1841                            responseType: "json",
1842                            data: form_data,
1843                            success: function(res) {
1844                                $("#modal_profile_form").submit();
1845                            },
1846                            error: function(jqXHR, textStatus, errorThrown) {
1847                                console.log(jqXHR, textStatus, errorThrown);
1848
1849                            }
1850                        });
1851                    } else {
1852                        $(".bootbox-confirm").on("hidden.bs.modal", function() {
1853                            $('body').addClass('modal-open');
1854                        });
1855                    }
1856                }
1857            });
1858        }
1859    }
1860
1861});
1862
1863$(document).delegate(".country_id_com", "click", function() {
1864    var country_id_com = document.getElementById('country_id_com').selectedOptions[0].text;
1865    if (country_id_com != "Thailand") {
1866        $('.prov_id_com').hide();
1867        $('#prov_id_com').val('');
1868    } else {
1869        $('.prov_id_com').show();
1870    }
1871});
1872
1873$(document).delegate(".country_id", "click", function() {
1874    var country_id = document.getElementById('country_id').selectedOptions[0].text;
1875    if (country_id != "Thailand") {
1876        $('.prov_id').hide();
1877        $('#prov_id').val('');
1878    } else {
1879        $('.prov_id').show();
1880    }
1881});
1882
1883function show_modal_repassword() {
1884    $('#modal_chk_repassword').modal('show');
1885}
1886
1887$(document).delegate(".edit_password_modal", "click", function() {
1888    var lang = $('.language_hidden').val();
1889    var password = $('.txt_password').val();
1890    var newpassword = $('.txt_newpassword').val();
1891    var newpassword_con = $('.txt_newpassword_con').val();
1892    if (lang == "2") {
1893        var passAr = "Please type corresponding password";
1894        var CpassAr = "Are you sure you want to make changes?";
1895        var Chkpass = "must contain alphanumeric A-Z, a-z, 0-9, with at least 8 digits in length";
1896        var sukpass = "Password has been changed";
1897        var flpass = "You have typed wrong original password";
1898    } else {
1899        var passAr = "กรุณากรอกข้อมูลให้ตรงกัน";
1900        var CpassAr = "ยืนยันการแก้ไขข้อมูลหรือไม่ ?";
1901        var Chkpass = "รหัสผ่านต้อ
1901งมี A-Z,a-z และ 0-9 อย่างน้อย 1 ตัว และมีอย่างน้อย 8 หลัก";
1902        var sukpass = "เปลี่ยนรหัสผ่านเรียบร้อย";
1903        var flpass = "รหัสผ่านเดิมไม่ถูกต้อง";
1904    }
1905    var re = new RegExp(/^(?=.*\d)(?=.*[0-9a-zA-Z]).{8,}$/);
1906    if (re.test(newpassword) == true) {
1907        if (newpassword != newpassword_con) {
1908            bootbox.alert(passAr);
1909        } else {
1910
1911            bootbox.confirm({
1912                message: CpassAr,
1913                buttons: {
1914                    confirm: {
1915                        label: 'Yes',
1916                        className: 'btn-success'
1917                    },
1918                    cancel: {
1919                        label: 'No',
1920                        className: 'btn-danger'
1921                    }
1922                },
1923                callback: function(result) {
1924                    if (result == true) {
1925                        $('#wait_process').css('display', 'block');
1926                        $.ajax({
1927                            url: 'function_php/function_index.php',
1928                            type: 'POST',
1929                            async: false,
1930                            responseType: "json",
1931                            data: {
1932                                'password': password,
1933                                'newpassword': newpassword,
1934                                'newpassword_con': newpassword_con,
1935                                "method": "repassword"
1936                            },
1937                            success: function(res) {
1938                                if (res.pass_chk == "00") {
1939                                    bootbox.alert(sukpass);
1940                                    window.location.href = '/frontend/index.php?page=profile';
1941                                } else {
1942                                    bootbox.alert(flpass, function() {
1943                                        $('#wait_process').css('display', 'none');
1944                                    });
1945                                }
1946                            },
1947                            error: function(jqXHR, textStatus, errorThrown) {
1948                                console.log(jqXHR, textStatus, errorThrown);
1949
1950                            }
1951                        });
1952                    }
1953                }
1954            });
1955        }
1956    } else {
1957        bootbox.alert(Chkpass);
1958    }
1959
1960});
1961
1962
1963function logout() {
1964    var lang = $('.language_hidden').val();
1965    if (lang == "2") {
1966        var Arlog = "Are you sure you want to quit?";
1967    } else {
1968        var Arlog = "ยืนยันการออกจากระบบ ?";
1969    }
1970    bootbox.confirm({
1971        message: Arlog,
1972        buttons: {
1973            confirm: {
1974                label: 'Yes',
1975                className: 'btn-success'
1976            },
1977            cancel: {
1978                label: 'No',
1979                className: 'btn-danger'
1980            }
1981        },
1982        callback: function(result) {
1983            if (result == true) {
1984                window.location.href = "https://sso.ditp.go.th/auth/clientLogout?callback=https://care.ditp.go.th/frontend/logout.php";
1985                //window.location.href = 'logout.php';
1986            }
1987        }
1988    });
1989}
1990
1991
1992// function update_noti_bell(){
1993//   $.ajax({
1994//       url: 'function_php/function_index.php',
1995//       type: 'POST',
1996//       async: false,
1997//       responseType: "json",
1998//       data: {
1999//         "method":"update_noti_bell"
2000//       },
2001//     success: function(res) {
2002//
2003//     },
2004//     error: function(jqXHR, textStatus, errorThrown) {
2005//       console.log(jqXHR, textStatus, errorThrown);
2006//
2007//     }
2008//   });
2009// }
2010
2011function read_mesBox(msgBox_id) {
2012    $.ajax({
2013        url: 'function_php/function_index.php',
2014        type: 'POST',
2015        async: false,
2016        responseType: "json",
2017        data: {
2018            'msgBox_id': msgBox_id,
2019            "method": "read_mesBox"
2020        },
2021        success: function(res) {
2022            $('#fa_circle_' + msgBox_id).remove();
2023        },
2024        error: function(jqXHR, textStatus, errorThrown) {
2025            console.log(jqXHR, textStatus, errorThrown);
2026
2027        }
2028    });
2029}
2030
2031function update_noti_letter() {
2032    $.ajax({
2033        url: 'function_php/function_index.php',
2034        type: 'POST',
2035        async: false,
2036        responseType: "json",
2037        data: {
2038            "method": "update_noti_letter"
2039        },
2040        success: function(res) {
2041
2042        },
2043        error: function(jqXHR, textStatus, errorThrown) {
2044            console.log(jqXHR, textStatus, errorThrown);
2045
2046        }
2047    });
2048}
2049
2050function del_msgBox(id) {
2051    var lang = $('.language_hidden').val();
2052    if (lang == "2") {
2053        var ArlogIn = "Will you delete the message?";
2054    } else {
2055        var ArlogIn = "คุณจะลบข้อความหรือไม่ ?";
2056    }
2057    bootbox.confirm({
2058        message: ArlogIn,
2059        buttons: {
2060            confirm: {
2061                label: 'Yes',
2062                className: 'btn-success'
2063            },
2064            cancel: {
2065                label: 'No',
2066                className: 'btn-danger'
2067            }
2068        },
2069        callback: function(result) {
2070            if (result == true) {
2071                $.ajax({
2072                    url: 'function_php/function_index.php',
2073                    type: 'POST',
2074                    async: false,
2075                    responseType: "json",
2076                    data: {
2077                        'msgBox_id': id,
2078                        "method": "del_msgBox"
2079                    },
2080                    success: function(res) {
2081                        window.location.href = '/frontend/index.php?page=letter';
2082                    },
2083                    error: function(jqXHR, textStatus, errorThrown) {
2084                        console.log(jqXHR, textStatus, errorThrown);
2085
2086                    }
2087                });
2088            }
2089        }
2090    });
2091}
2092
2093function del_msgnoti(id) {
2094    var lang = $('.language_hidden').val();
2095    if (lang == "2") {
2096        var ArlogIn = "Do you want to delete the notification?";
2097    } else {
2098        var ArlogIn = "คุณจะลบการแจ้งเตือนหรือไม่ ?";
2099    }
2100    bootbox.confirm({
2101        message: "คุณจะลบการแจ้งเตือนหรือไม่ ?",
2102        buttons: {
2103            confirm: {
2104                label: 'Yes',
2105                className: 'btn-success'
2106            },
2107            cancel: {
2108                label: 'No',
2109                className: 'btn-danger'
2110            }
2111        },
2112        callback: function(result) {
2113            if (result == true) {
2114                $.ajax({
2115                    url: 'function_php/function_index.php',
2116                    type: 'POST',
2117                    async: false,
2118                    responseType: "json",
2119                    data: {
2120                        'msgNotiApp_id': id,
2121                        "method": "del_msgnoti"
2122                    },
2123                    success: function(res) {
2124                        window.location.href = '/frontend/index.php?page=bell';
2125                    },
2126                    error: function(jqXHR, textStatus, errorThrown) {
2127                        console.log(jqXHR, textStatus, errorThrown);
2128
2129                    }
2130                });
2131            }
2132        }
2133    });
2134}
2135$(document).delegate(".btn_forgot_password", "click", function() {
2136
2137    $('#wait_process_mail').css('display', 'block');
2138    setTimeout(function() { set_time_mail(); }, 1000);
2139
2140});
2141
2142function set_time_mail() {
2143    var email = $('.forgot_email').val();
2144    var lang = $('.language_hidden').val();
2145    if (lang == "2") {
2146        var Armail = "The system will send you the password correct link to your e-mail.";
2147        var Armail_x = "E-mail is not in the system.";
2148        var Armail_z = "Your Email did not confirm your subscription.";
2149    } else {
2150        var Armail = "ระบบทำการส่งลิ้งค์แก้ไขรหัสผ่านให้ท่านทาง E-mail ของคุณเรียบร้อยแล้ว";
2151        var Armail_x = "E-mail ไม่มีอยู่ในระบบ";
2152        var Armail_z = "E-mail ของท่านไม่ได้ยืนยันการสมัครสมาชิก";
2153    }
2154    $.ajax({
2155        url: 'function_php/function_index.php',
2156        type: 'POST',
2157        async: false,
2158        responseType: "json",
2159        data: {
2160            'email': email,
2161            "method": "forgot_password"
2162        },
2163        success: function(res) {
2164            if (res.chk_mail == "00") {
2165                bootbox.alert(Armail, function() {
2166                    $('#wait_process_mail').css('display', 'none');
2167                    $('#modal_forgot_password').modal('hide');
2168                });
2169            } else if (res.chk_mail == "02") {
2170                bootbox.alert(Armail_z, function() {
2171                    $('#wait_process_mail').css('display', 'none');
2172                });
2173            } else {
2174                bootbox.alert(Armail_x, function() {
2175                    $('#wait_process_mail').css('display', 'none');
2176                });
2177            }
2178        },
2179        error: function(jqXHR, textStatus, errorThrown) {
2180            console.log(jqXHR, textStatus, errorThrown);
2181
2182        }
2183    });
2184}
2185var getUrlParameter = function getUrlParameter(sParam) {
2186    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
2187        sURLVariables = sPageURL.split('&'),
2188        sParameterName,
2189        i;
2190
2191    for (i = 0; i < sURLVariables.length; i++) {
2192        sParameterName = sURLVariables[i].split('=');
2193
2194        if (sParameterName[0] === sParam) {
2195            return sParameterName[1] === undefined ? true : sParameterName[1];
2196        }
2197    }
2198};
2199
2200function language_select(type) {
2201    var lang = $('.language_hidden').val();
2202    var lang_sess = $('.language_sess').val();
2203    var ck_id = $('.ck_id').val();
2204    if (lang_sess == "") {
2205        $('.language_hidden').val(type);
2206
2207        var blog = getUrlParameter('page');
2208        if (blog == "info_detail") {
2209            window.location.href = '/frontend/index.php?page=' + blog + '&ck_id=' + ck_id + '&lang=' + type + '';
2210        } else {
2211            window.location.href = '/frontend/index.php?page=' + blog + '&lang=' + type + '';
2212        }
2213    } else {
2214        $.ajax({
2215            url: 'function_php/function_index.php',
2216            type: 'POST',
2217            async: false,
2218            responseType: "json",
2219            data: {
2220                'type': type,
2221                "method": "language_select"
2222            },
2223            success: function(res) {
2224                window.location.reload();
2225            },
2226            error: function(jqXHR, textStatus, errorThrown) {
2227                console.log(jqXHR, textStatus, errorThrown);
2228
2229            }
2230        });
2231    }
2232}
2233
2234function toggleMenu() {
2235    var menuBox = document.getElementById('menu-box');
2236    if (menuBox.style.display == "block") { // if is menuBox displayed, hide it
2237        menuBox.style.display = "none";
2238    } else { // if is menuBox hidden, display it
2239        menuBox.style.display = "block";
2240    }
2241}
2242
2243function chk_div_category() {
2244    var lang = $('.language_hidden').val();
2245    $.ajax({
2246        url: 'function_php/function_index.php',
2247        type: 'POST',
2248        async: false,
2249        responseType: "json",
2250        data: {
2251            "lang": lang,
2252            "method": "chk_div_category"
2253        },
2254
2255        success: function(res) {
2256            $('.div_category_2').html(res);
2257
2258            // setTimeout(function(){
2259
2260            $('.div_category_1').hide();
2261            $('.div_category_2').css('display', 'inline-block');
2262            $('.selectpicker').selectpicker('refresh');
2263            // }, 1000);
2264
2265
2266        },
2267        error: function(jqXHR, textStatus, errorThrown) {
2268            console.log(jqXHR, textStatus, errorThrown);
2269
2270        }
2271    });
2272}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.