ตั้ม บริการ - WECANFIX - บริษัท วีแคนฟิกซ์ จำกัด
ตั้ม บริการ
จังหวัด นครพนม อำเภอ เมือง , 170/1 ถ.นครพนม-ท่าอุเทน อ.เมือง จ.นครพนม
086-4458485 , 087-481-888
อู่ที่ใกล้กับ ตั้ม บริการ
โตโยต้า เจริญศรี (สำนักงานใหญ่)
นครพนมฮอนด้าคาร์ส
โตโยต้า นครพนม
พี.เจ.เซอร์วิส
โตโยต้านครพนม (1992) (สำนักงานใหญ่)
ทอง บริการ
'; $("#garage_review_box").html(item); } }); }, onClickPagination: function () { var requestReviews = Feature.requestReviews; $("#garage_review_box").on('click', "[name=btn_pagination]", function () { review_page = $(this).data("page"); requestReviews(); document.getElementById("garage_review_box").scrollIntoView(); }); }, onRatingStar: function () { var garage_rating_star = "[name=garage_rating_star]"; var check_star = false; $(garage_rating_star).on("mouseover", function () { var score = $(this).data("score"); if (!check_star) { $(garage_rating_star).each(function (index, element) { if (index <= (score - 1)) { $(element).addClass("active"); } else { $(element).removeClass("active"); } }); } }); $(garage_rating_star).on("mouseout", function () { var score = $(this).data("score"); if (!check_star) { $(garage_rating_star).each(function (index, element) { $(element).removeClass("active"); }); } }); $(garage_rating_star).on("click", function () { var score = $(this).data("score"); if (check_star) { $(garage_rating_star).each(function (index, element) { $(element).removeClass("active"); }); check_star = false; } else { $(garage_rating_star).each(function (index, element) { if (index < (score)) { $(element).addClass("active"); } }); check_star = true; } }); }, onClickReportReview: function () { $('#garage_review_box').on('click', '[name=report_review]', function () { var id = $(this).data('id'); $('#suggestion_review_id').val(id); }); }, validateReview: function () { var error = $('.alert-danger', $('#review_form')); var success = $('.alert-success', $('#review_form')); $('#review_form').validate({ errorElement: 'span', //default input error message container errorClass: 'help-block help-block-error', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", // validate all fields including form hidden input rules: { review_comment: { required: true, maxlength: 500 } }, invalidHandler: function (e, t) { success.hide(), error.show() //App.scrollTo(error, -200) }, errorPlacement: function (e, r) { var i = $(r).parent(".input-icon").children("i"); i.removeClass("fa-check").addClass("fa-warning"), i.attr("data-original-title", e.text()).tooltip({ container: "body" }); }, highlight: function (element) { $(element).closest(".form-group").removeClass("has-success").addClass("has-error"); }, unhighlight: function (element) { }, success: function (element, r) { var i = $(r).parent(".input-icon").children("i"); $(r).closest(".form-group").removeClass("has-error").addClass("has-success"), i.removeClass("fa-warning").addClass("fa-check"); }, submitHandler: function (form) { success.show(); error.hide(); } }); }, submitReview: function (active) { var review_score = $('[name=garage_rating_star].active').length; var data = new FormData(); data.append("id", 0); data.append("garage_id", 1383); //data.append("garage_booking_id", null); data.append("review_score", review_score); data.append("review_comment", $("#review_comment").val()); data.append("image_json_data", JSON.stringify(image_review_data)); data.append("active", active); if ('' != '' && '' == 1) { data.append("tracking_id", ); } App.blockUI({ target: "#review_modal .modal-dialog" }); $.ajax({ url: '/Garage/SubmitReviewGarage', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI("#review_modal .modal-dialog"); if (result.startsWith('SUCCESS')) { bootbox.alert('เขียนรีวิวสำเร็จ', function () { window.location.href = '/Garage/GarageProfile/1383/%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%A1-%E0%B8%9A%E0%B8%A3%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A3'; }); } else if (result.startsWith('ERROR')) { var err_value = result.split(':')[2]; switch (err_value) { case 901: bootbox.alert('เขียนรีวิวไม่สำเร็จ กรุณาล็อคอินเข้าสู่ระบบก่อนเพื่อทำการเขียนรีวิว ต้องการล็อคอิน?'); break; default: bootbox.alert(result.split(':')[1]); break; } } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI(); bootbox.alert(xhr.status + " " + thrownError); } }); }, onSubmitReview: function () { var submitReviewFunction = Feature.submitReview; $('#btn_submit_review').on('click', function () { var active = 1; var review_score = $('[name=garage_rating_star].active').length; if (review_score == 0) { $("#text_required").css("color", "#db1313"); $("#text_required").html("กรุณากรอกคะแนนให้อู่รถนี้"); return; } if (!$("#review_form").valid()) { bootbox.alert("กรุณากรอกรายละเอียดการรีวิวค่ะ"); return; } else { submitReviewFunction(active); } }); }, submitDeleteReview: function (review_id) { var calculateReviewScore = Feature.calculateReviewScore; var requestReviews = Feature.requestReviews; App.blockUI(); var data = new FormData(); data.append("id", review_id); $.ajax({ url: '/Garage/SubmitDeleteReviewGarage', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI(); if (result.startsWith('SUCCESS')) { bootbox.alert('ลบรีวิวสำเร็จ !', function () { requestReviews(); calculateReviewScore(); }); } else if (result.startsWith('ERROR')) { var err_value = result.split(':')[2]; switch (err_value) { case 901: bootbox.alert('ลบรีวิวไม่สำเร็จ กรุณาล็อคอินเข้าสู่ระบบก่อนเพื่อทำการลบรีวิว'); return; default: bootbox.alert("เกิดข้อผิดพลาดลบรีวิวไม่สำเร็จ"); return; } } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI(); bootbox.alert(xhr.status + " " + thrownError); } }); }, onSubmitDeleteReview: function () { var submitDeleteReview = Feature.submitDeleteReview; $('#garage_review_box').on('click', '[name=delete_review]', function () { var review_id = $(this).data('id'); bootbox.confirm({ message: 'คุณต้องการที่จะลบรีวิวนี้ ?', buttons: { cancel: { label: ' ปิด' }, confirm: { label: ' ลบรีวิว' } }, callback: function (confirm) { if (confirm) { submitDeleteReview(review_id); } } }) }); }, calculateReviewScore: function () { App.blockUI(); var data = new FormData(); data.append("garage_id", 1383); $.ajax({ url: '/Garage/AjaxReviewScore', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI(); if (result.startsWith('ERROR')) { bootbox.alert('ERROR' + result); return; } else { var resultData = JSON.parse(result); var reviewScoreResult = resultData["review_score"]; var totalScore = reviewScoreResult["total_score"]; var totalReview = reviewScoreResult["review_total"]; $('[name=total_review_score]').text(totalScore); //t-review_star var text_star = ''; for (var i = 0; i < 5; i++) { if (i < totalScore) { if (parseInt(totalScore, 10) == i && parseFloat(totalScore) % parseInt(totalScore, 10) >= 0.5) { text_star += ''; } else { text_star += ''; } } else { text_star += ''; } } $('#t-review_star').html(text_star); $('[name=total_review]').text(totalReview); $('#review_score_row_1').find('#review_garage_score_count_1').text(reviewScoreResult["review_star_1"] + ' คน'); $('#review_score_row_1').find('.item_middle .progress-bar') .attr('aria-valuenow', reviewScoreResult["review_s1"]) .attr('aria-valuemax', totalReview) .css('width', reviewScoreResult["review_s1"] + '%'); $('#review_score_row_2').find('#review_garage_score_count_2').text(reviewScoreResult["review_star_2"] + ' คน'); $('#review_score_row_2').find('.item_middle .progress-bar') .attr('aria-valuenow', reviewScoreResult["review_s2"]) .attr('aria-valuemax', totalReview) .css('width', reviewScoreResult["review_s2"] + '%'); $('#review_score_row_3').find('#review_garage_score_count_3').text(reviewScoreResult["review_star_3"] + ' คน'); $('#review_score_row_3').find('.item_middle .progress-bar') .attr('aria-valuenow', reviewScoreResult["review_s3"]) .attr('aria-valuemax', totalReview) .css('width', reviewScoreResult["review_s3"] + '%'); $('#review_score_row_4').find('#review_garage_score_count_4').text(reviewScoreResult["review_star_4"] + ' คน'); $('#review_score_row_4').find('.item_middle .progress-bar') .attr('aria-valuenow', reviewScoreResult["review_s4"]) .attr('aria-valuemax', totalReview) .css('width', reviewScoreResult["review_s4"] + '%'); $('#review_score_row_5').find('#review_garage_score_count_5').text(reviewScoreResult["review_star_5"] + ' คน'); $('#review_score_row_5').find('.item_middle .progress-bar') .attr('aria-valuenow', reviewScoreResult["review_s5"]) .attr('aria-valuemax', totalReview) .css('width', reviewScoreResult["review_s5"] + '%'); } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI(); bootbox.alert(xhr.status + " " + thrownError); } }); }, fetchComments: function (review_id, comment_position) { var data = new FormData(); //App.blockUI({ // target: "#rowReview" + review_id + " .review-box" //}); data.append("review_id", review_id); data.append("comment_position", comment_position); $.ajax({ url: '/Garage/AjaxCommentReview', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { //App.unblockUI("#rowReview" + review_id + " .review-box"); if (result.startsWith('ERROR')) { bootbox.alert("การแสดงคอมเมนท์ไม่สำเร็จ"); } else { var jResult = JSON.parse(result); var jCommentResult = jResult["comment_result"]; var i, j, len = jCommentResult.length; $("#commentBox_" + review_id).removeClass("hidden"); var totalComment = Math.abs(jResult["totalComment"] - jResult["comment_result"].length - $("#commentBox_" + review_id + " div.panel-heading").length); $("#totalComment_" + review_id).text(totalComment + " ความคิดเห็น"); if (totalComment <= 0) { $("#totalComment_" + review_id).parent().remove(); } var item = ''; for (i = 0; i < len; i++) { var jComment = jCommentResult[i]; item += '
'; } if ($("#commentBox_" + review_id + " div.panel-heading").length < totalComment) { $("#commentBox_" + review_id).prepend(item); } else { $("#commentBox_" + review_id).append(item); } $("#comment_detail_" + review_id).val(''); setTimeout(function () { $('.lazy').lazy({ bind: 'event', threshold: "2000", onError: function (element) { $(element).prop("src", "https://www.wecanfix.co.th/content/assets/images/notfound.jpg"); } }).trigger('lazyload'); }, 200); } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI(); bootbox.alert(xhr.status + " " + thrownError); } }); }, submitComment: function (comment_id, review_id, active) { var fetchCommentsFunction = Feature.fetchComments; App.blockUI(); var review_comment_detail = $("#comment_detail_" + review_id).val(); var data = new FormData(); data.append("id", comment_id); data.append("garage_id", 1383); data.append("garage_booking_id", ""); data.append("comment_at_review_id", review_id); data.append("review_score", 0); data.append("review_comment", review_comment_detail); data.append("image_json_data", JSON.stringify(image_review_data)); data.append("active", active); $.ajax({ url: '/Garage/SubmitReviewGarage', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI(); if (result.startsWith('SUCCESS')) { //window.location.reload(); var comment_position = result.split(":")[1]; $("[name=btn_comment_total][data-id=" + review_id + "]").data("comment_total", comment_position); $("#commentBox_" + review_id).html(""); fetchCommentsFunction(review_id, 0); //window.location.reload(); } else if (result.startsWith('ERROR')) { var err_value = result.split(':')[2]; switch (err_value) { case 901: bootbox.confirm('คอมเม้นไม่สำเร็จ กรุณาล็อคอินเข้าสู่ระบบก่อนเพื่อทำการคอมเม้น ต้องการล็อคอิน?', function (confirm) { if (confirm) { window.location.href = "/Signin/Index"; } }); return; default: bootbox.alert("เกิดข้อผิดพลาดคอมเม้นไม่สำเร็จ"); return; } } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI(); bootbox.alert(xhr.status + " " + thrownError); } }); }, onSubmitComment: function () { var submitComment = Feature.submitComment; $("#garage_review_box").on('click', '[name=btn_submit_comment]', function () { var review_id = $(this).data("review_id"); var comment_id = 0; var review_comment_detail = $("#comment_detail_" + review_id).val(); if (review_comment_detail != "") { var active = 1; submitComment(comment_id , review_id, active); } else { bootbox.alert("กรุณากรอกข้อความ"); return; } }); }, onTotalComment: function () { var fetchComments = Feature.fetchComments; $("#garage_review_box").on('click', '[name=btn_comment_total]', function () { var review_id = $(this).data("id"); var commentTotal = $(this).data("comment_total"); var comment_position = $("#commentBox_" + review_id + " div.panel-heading").length; if (comment_position < commentTotal) { fetchComments(review_id, comment_position + 1); } }); }, onRemoveComment: function () { var submitComment = Feature.submitComment; $('#garage_review_box').on('click', '[name=remove_comment]', function () { var comment_id = $(this).data('id'); var review_id = $(this).data('review_id'); bootbox.confirm({ message: 'คุณต้องการที่จะลบคอมเมนท์นี้ ?', buttons: { cancel: { label: ' ปิด' }, confirm: { label: ' ลบคอมเมนท์' } }, callback: function (confirm) { if (confirm) { submitComment(comment_id, review_id, 0); } } }) }); }, validateSuggestion: function () { var error = $('.alert-danger', $('#suggestion_form')); var success = $('.alert-success', $('#suggestion_form')); $('#suggestion_form').validate({ errorElement: 'span', //default input error message container errorClass: 'help-block help-block-error', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", // validate all fields including form hidden input rules: { suggestion_type: { required: true } }, invalidHandler: function (e, t) { success.hide(), error.show() //App.scrollTo(error, -200) }, errorPlacement: function (e, r) { var i = $(r).parent(".input-icon").children("i"); i.removeClass("fa-check").addClass("fa-warning"), i.attr("data-original-title", e.text()).tooltip({ container: "body" }); }, highlight: function (element) { $(element).closest(".form-group").removeClass("has-success").addClass("has-error"); }, unhighlight: function (element) { }, success: function (element, r) { var i = $(r).parent(".input-icon").children("i"); $(r).closest(".form-group").removeClass("has-error").addClass("has-success"), i.removeClass("fa-warning").addClass("fa-check"); }, submitHandler: function (form) { success.show(); error.hide(); } }); }, //onSubmitSuggestion: function () { // $("#garage_review_box").on('click', '#btn_submit_suggestion', function () { // var active = 1; // submitSuggestion(active); // }); //}, onSubmitSuggestion: function () { var submitSuggestion = Feature.submitSuggestion; $("#btn_submit_suggestion").on('click', function () { var id_review = $("#suggestion_review_id").val(); var suggestion_type_id = $("#suggestion_type").val(); var suggestion_detail = $("#report_detail").val(); var active = 1; if (!$('#suggestion_form').valid()) { bootbox.alert("กรุณากรอกข้อมูลให้ถูกต้องค่ะ"); return; } else { bootbox.confirm({ message: "กดปุ่มตกลงเพื่อแจ้งความไม่เหมาะสม", buttons: { cancel: { label: ' ปิด', className: '' }, confirm: { label: ' ตกลง', className: 'btn btn-primary' } }, callback: function (confirm) { if (confirm) { submitSuggestion(id_review, suggestion_type_id, suggestion_detail, active); } } }); } }); }, submitSuggestion: function (id_review, suggestion_type_id, suggestion_detail, active) { App.blockUI(); var data = new FormData(); data.append("review_id", id_review); data.append("suggestion_type_id", 1); data.append("suggestion_detail", suggestion_detail); data.append("image_json_data", JSON.stringify(image_suggestion_data)); data.append("active", active); $.ajax({ url: '/Garage/SubmitSuggestion', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI(); if (result.startsWith('SUCCESS')) { bootbox.alert('รายงานความไม่เหมาะสมเรียบร้อยแล้วทางทีมงานจะทำการตรวจสอบความไม่เหมาะสมของการรีวิว', function () { window.location.reload(); }); } else if (result.startsWith('ERROR')) { var err_value = result.split(':')[1]; switch (err_value) { default: bootbox.alert(err_value); break; } } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI(); bootbox.alert("รายงานไม่สำเร็จ " + xhr.status + " " + thrownError); } }); }, onClickCheckBookingHasInsurance: function () { $("[name=has_insurance]").on('click', function () { var bookingDropzone = Dropzone.forElement("#bk_garage_image"); var policyDropzone = Dropzone.forElement("#bk_policy_no_img"); var claimDropzone = Dropzone.forElement("#bk_claim_no_img"); bookingDropzone.removeAllFiles(true); policyDropzone.removeAllFiles(true); claimDropzone.removeAllFiles(true); image_garage_booking = new Array(); image_policy_no = new Array(); image_claim_no = new Array(); if ($(this).is(':checked')) { $("[name=has_insurance]").not(this).prop('checked', false); //$("#show_form_booking").removeClass('hidden'); $("#show_form_booking").slideDown('slow'); if (0 > 0 && $("#btn_request_booking_log").attr("has_clicked") != 1) $("#btn_request_booking_log").removeClass("hidden"); } else { $("#show_form_booking").slideUp('slow'); //$("#show_form_booking").addClass('hidden'); $("#show_form_booking input,#show_form_booking textarea, #show_form_booking select").each(function (index, element) { $(element).val('').trigger('change'); //clear value }); $("#btn_request_booking_log").addClass('hidden'); $("#btn_request_booking_log").attr("has_clicked", 0); } if ($(this).attr("has_insurance") == 1) { $("#has_insurance_form").removeClass('hidden'); } else { $("#has_insurance_form").addClass('hidden'); } }); }, onChangeVehicleBrand: function () { $('#bk_vehicle_brand_id').on('change', function () { if ($(this).val() == -1) { $('#display_vehicle_brand').removeClass('col-sm-6').addClass('col-sm-3'); $('#display_vehicle_brand_other').removeClass('hidden'); } else { $('#display_vehicle_brand').removeClass('col-sm-3').addClass('col-sm-6'); $('#display_vehicle_brand_other').addClass('hidden'); } }); }, onClickBookingInsurance: function () { $("#bk_insurance_id").on('change', function (selected) { var element_insurance_id = $('#display_insurance_list'); var element_insurance_other = $("#display_insurance_other"); if ($(this).val() == -1) { $('#bk_insurance_name').prop('disabled', false); element_insurance_other.removeClass('hidden'); element_insurance_id.removeClass('col-sm-12').addClass('col-sm-6'); } else { $('#bk_insurance_name').prop('disabled', true); element_insurance_other.addClass('hidden'); element_insurance_id.removeClass('col-sm-6').addClass('col-sm-12'); } }); }, onClickMemberBooking: function () { $("#member_booking_btn").on('click', function () { if (0 == 0) { bootbox.confirm({ message: 'กรุณากรอกเบอร์ติดต่อใน Profile เมื่อกรอกเบอร์ติดต่อแล้วระบบจะนำทางกลับมายัง ตั้ม บริการ เพื่อกรอกรายละเอียดการจองซ่อม ค่ะ', buttons: { confirm: { label: ' ตกลง', className: "btn btn-primary" }, cancel: { label: ' ปิด' } }, callback: function (confirm) { if (confirm) { window.open('/Profile/Profile?fid=1383&fp=301', {target: '_blank'}); } } }); } }); }, requestOldBooking: function () { App.blockUI({ target: "#modal_booking .modal-dialog" }); var bookingDropzone = Dropzone.forElement("#bk_garage_image"); var data = new FormData(); data.append("garage_id", 1383); $.ajax({ url: '/Garage/AjaxRequestBookingLog', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI("#modal_booking .modal-dialog"); if (result.startsWith('ERROR')) { bootbox.alert(result); } else { var jResult = JSON.parse(result); var jBookingLog = jResult["booking_result"]; var i, j; if (jBookingLog) { var date = new Date(jBookingLog["booking_request_date"]); $("#bk_request_date").datepicker('setDate', new Date(date.getFullYear(), date.getMonth(), date.getDate())); $("#bk_car_model").val(jBookingLog["booking_car_model"]); $("#bk_vehicle_brand_id").val(jBookingLog["booking_vehicle_brand_id"]); $("#bk_vehicle_brand_id").trigger('change'); if ($("#has_insurance").is(":checked")) { $("#bk_insurance_id").val(jBookingLog["booking_insurance_id"]); $("#bk_insurance_id").trigger('change'); $("#bk_insurance_name").val(jBookingLog["booking_insurance_name"]); $("#bk_policy_no").val(jBookingLog["booking_policy_no"]); $("#bk_claim_no").val(jBookingLog["booking_claim_no"]); } $("#bk_license_no").val(jBookingLog["booking_license_no"]); $("#bk_note").val(jBookingLog["booking_request_note"]); if (jBookingLog["booking_has_insurance"] === 1) { if (jBookingLog["booking_has_img_policy"] === 1) { var policy_image_name = "policy_no_image.jpg"; var policy_image_url = "https://www.wecanfix.co.th/content/upload/booking/" + jBookingLog["booking_id"] + "/" + policy_image_name; var policyObj = { name: policy_image_name, url: policy_image_url, fileRef: count_file++ }; policyDropzone.emit("addedfile", policyObj); policyDropzone.emit("thumbnail", policyObj, policy_image_url); policyDropzone.emit("complete", policyObj); policyDropzone.files.push(policyObj); image_policy_no.push({ fileRef: count_file, fileName: policy_image_name, fileUrl: policy_image_url, id: jBookingLog["booking_id"] }); } if (jBookingLog["booking_has_img_claim"] === 1) { var claim_image_name = "claim_no_image.jpg"; var claim_image_url = "https://www.wecanfix.co.th/content/upload/booking/" + jBookingLog["booking_id"] + "/" + claim_image_name; var claimObj = { name: claim_image_name, url: claim_image_url, fileRef: count_file++ }; claimDropzone.emit("addedfile", claimObj); claimDropzone.emit("thumbnail", claimObj, claim_image_url); claimDropzone.emit("complete", claimObj); claimDropzone.files.push(claimObj); image_claim_no.push({ fileRef: count_file, fileName: claim_image_name, fileUrl: claim_image_url, id: jBookingLog["booking_id"] }); } } if (jBookingLog["booking_attachment_list"].length > 0) { var jAttach_File = jBookingLog["booking_attachment_list"]; for (j = 0; j < jAttach_File.length; j++) { var file_ref = 0; if (image_garage_booking.length > 0) { file_ref = image_garage_booking[image_garage_booking.length - 1].fileRef; } var attachment_name = jAttach_File[j]["attachment_url"]; var attachment_url = "https://www.wecanfix.co.th/content/upload/booking/" + jBookingLog["booking_id"] + "/" + jAttach_File[j]["attachment_url"]; var fileObj = { name: attachment_name, url: attachment_url, fileRef: count_file++ }; bookingDropzone.emit("addedfile", fileObj); bookingDropzone.emit("thumbnail", fileObj, attachment_url); bookingDropzone.emit("complete", fileObj); bookingDropzone.files.push(fileObj); file_ref++; image_garage_booking.push({ fileRef: file_ref, fileName: attachment_name, fileUrl: attachment_name }); } } } } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI("#modal_booking .modal-dialog"); bootbox.alert(xhr.status + " " + thrownError); } }); }, onClickRequestOldBooking: function () { var requestOldBooking = Feature.requestOldBooking; $("#btn_request_booking_log").on('click', function () { $(this).addClass('hidden'); $(this).attr('has_clicked', 1); requestOldBooking(); }); }, validateBooking: function () { var error = $('.alert-danger', $('#booking_form')); var success = $('.alert-success', $('#booking_form')); $('#booking_form').validate({ errorElement: 'span', //default input error message container errorClass: 'help-block help-block-error', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", // validate all fields including form hidden input rules: { has_insurance: { required: true }, bk_request_date: { required: true }, bk_license_no: { required: true }, bk_car_model: { required: true }, bk_insurance_id: { required: function () { if ($('#has_insurance').is(':checked')) { return true } else { return false } } }, bk_insurance_other: { required: function () { if ($('#bk_insurance_id').val() == -1) { return true } else { return false } } }, bk_vehicle_brand_id: { required: true }, bk_vehicle_brand_other: { required: function () { if ($("#bk_vehicle_brand_id").val() == -1) { return true } else { return false } } }, bk_policy_no: { required: function () { if ($('#has_insurance').is(':checked')) { return true } else { return false } } }, bk_note: { required: true } }, messages: { has_insurance: 'กรุณาระบุว่ามีประกันหรือไม่มีประกันค่ะค่ะ', bk_request_date: "กรุณากรอกวันที่ขอนำรถเข้าอู่ค่ะ", bk_license_no: "กรุณากรอกเลขทำเบียนค่ะ", bk_insurance_id: 'กรุณาเลือกประกันค่ะ', bk_insurance_other: 'กรุณากรอกประกันอื่นๆค่ะ', bk_vehicle_brand_id: "กรุณาเลือกยี่ห้อรถค่ะ", bk_vehicle_brand_other: "กรุณากรอกยี่ห้อรถอื่นๆค่ะ", bk_policy_no: "กรุณากรอกเลขกรมธรรม์ค่ะ", bk_car_model: "กรุณากรอกรุ่นรถค่ะ", bk_note: "กรุณาอธิบายปัญหารถที่เกิดขึ้นค่ะ" }, invalidHandler: function (e, t) { success.hide(), error.show() }, errorPlacement: function (e, r) { var i = $(r).parent(".input-icon").children("i"); i.removeClass("fa-check").addClass("fa-warning"), i.attr("data-original-title", e.text()).tooltip({ container: "body" }); }, highlight: function (element) { $(element).closest(".form-group").removeClass("has-success").addClass("has-error"); }, unhighlight: function (element) { }, success: function (element, r) { var i = $(r).parent(".input-icon").children("i"); $(r).closest(".form-group").removeClass("has-error").addClass("has-success"), i.removeClass("fa-warning").addClass("fa-check"); }, submitHandler: function (form) { success.show(); error.hide(); } }); }, submitBooking: function (active) { var requestDateraw = $("#bk_request_date").data('datepicker').getFormattedDate('dd mm yyyy').split(" "); var requestDate = requestDateraw[2] - 543 + " " + requestDateraw[1] + " " + requestDateraw[0]; var has_insurance = $("#has_insurance").is(":checked") ? 1 : $("#not_has_insurance").is(":checked") ? 0 : -1; if (has_insurance == -1) { bootbox.alert("กรุณาเลือกว่ามีประกัน หรือ ไม่มีประกันก่อนค่ะ"); return; } else if (has_insurance == 1) { if (image_policy_no.length == 0) { bootbox.alert("กรุณาอัพโหลดรูปภาพสำเนากรมธรรม์ค่ะ"); App.unblockUI(); return } } if (image_garage_booking.length == 0) { bootbox.alert("กรุณาอัพโหลดรูปภาพรถก่อนค่ะ"); return; } var vehicle_brand_other = $('#bk_vehicle_brand_id').val() == -1 ? $('#bk_vehicle_brand_other').val() : ''; var insurance_other = $('#insurance_id').val() == -1 ? $('#bk_insurance_name').val() : ''; App.blockUI({ target: "#modal_booking .modal-dialog" }); var data = new FormData(); data.append("id", 0); data.append("garage_id", 1383); data.append("request_date", requestDate); data.append("request_note", $("#bk_note").val()); data.append("car_model", $("#bk_car_model").val()); data.append("vehicle_brand_id", $("#bk_vehicle_brand_id").val()); data.append("vehicle_brand_name", vehicle_brand_other); data.append("has_insurance", has_insurance); data.append("policy_no_img", JSON.stringify(image_policy_no)); data.append("claim_no_img", JSON.stringify(image_claim_no)); data.append("license_no", $("#bk_license_no").val()); data.append("insurance_id", $("#bk_insurance_id").val()); data.append("insurance_name", insurance_other); data.append("policy_no", $("#bk_policy_no").val()); data.append("claim_no", $("#bk_claim_no").val()); data.append("image_json_data", JSON.stringify(image_garage_booking)); data.append("active", 1); $.ajax({ url: '/GarageBooking/SubmitGarageBooking', type: 'POST', data: data, cache: false, processData: false, contentType: false, success: function (result) { App.unblockUI("#modal_booking .modal-dialog"); if (result.startsWith('SUCCESS')) { bootbox.alert('ระบบได้รับการติดต่อนำรถเข้าอู่ ตั้ม บริการ เรียบร้อยแล้ว ทางทีมงานจะทำการติดต่อไปทางเบอร์โทรศัพท์ หรือ อีเมลของท่านภายใน 24 ชั่วโมงค่ะ', function () { window.location = window.location.href.split('#')[0]; }); } else if (result.startsWith('ERROR')) { var err_value = result.split(':')[1]; switch (err_value) { case '905': bootbox.alert('กรุณากรอกเบอร์ติดต่อใน Profile ด้วยค่ะ', function () { window.open('/Profile/Profile', 'blank'); }); return; case '902': bootbox.alert(result.split(':')[2], function () { }); return; case '601': bootbox.alert("ระบบได้รับการติดต่อนำรถเข้าอู่ ตั้ม บริการ เรียบร้อยแล้วทางทีมงานจะทำการติดต่อไปทางเบอร์โทรศัพท์ หรือ อีเมลของท่านภายใน 24 ชั่วโมงค่ะ ", function () { window.location = window.location.href.split('#')[0]; }); return; default: bootbox.alert(err_value, function () { //window.location.href = "/Profile/Profile?fp="+301 + "&fid=" + 1383 ; }); return; } } }, error: function (xhr, ajaxOptions, thrownError) { App.unblockUI("#modal_booking .modal-dialog"); bootbox.alert(xhr.status + " " + thrownError); } }); }, onSubmitBooking: function () { var submitBooking = Feature.submitBooking; $("#btn_submit_booking").on("click", function () { var active = 1; if (!$('#booking_form').valid()) { bootbox.alert(' ' + $("#booking_form").validate().errorList[0].message); return; } else { bootbox.confirm({ message: 'กดปุ่มตกลงเพื่อยืนยันการจอง', buttons: { cancel: { label: ' ปิด', className: 'btn-default' }, confirm: { label: ' ตกลง', className: 'btn-primary' } }, callback: function (confirm) { if (confirm) { submitBooking(active); } } }); } }); }, init: function () { this.initDatePicker(); this.initImageError(); this.initOwlCarousel(); this.initBindGallery(); this.onClickStarReview(); //this.onClickBookingBtn(); this.onClickPagination(); this.requestFavourite(); this.requestReviews(); this.onClickMemberBooking(); this.onTotalComment(); } } }(); $(document).ready(function () { Feature.init(); }); $(document).ready(function () { if ("" != "") { setTimeout(function () { document.getElementById('rowReview' + '').scrollIntoView(); $('#rowReview' + '' + ' .review-box').css({ 'box-shadow': '1px 2px 3px #bcc9f9', 'transition': 'opacity 1s ease-in' }); }, 500); } });