/
home
/
efamember
/
domains
/
efa-member.com
/
public_html
/
backoffice
/
up file
home
<?php include('header.php'); ?> <input type="hidden" id="start_no" value="<?php echo $_GET['start'] ?>"> <body class="top-navigation"> <div id="wrapper"> <div id="page-wrapper" class="gray-bg"> <div class="wrapper wrapper-content animated fadeInRight" id="showForm"> </div> </div> </div> <!--- init layout --> <?php include('footer.php'); ?> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-lg modal-dialog-centered"> <div class="modal-content animated fadeIn"> <div id="showModal"></div> </div> </div> </div> <audio src="error.mp3" id="errorSound"></audio> <script> $(document).ready(function () { getFormData(); }); function getFormData() { let start_no = $("#start_no").val(); $.ajax({ type: "post", url: "ajax/application/form", data: {start_no:start_no}, dataType: "html", success: function (response) { $("#showForm").html(response); $(".deleteRowStorage").hide(); $(".deleteRowStorage").first().show(); $("#inputQR").focus(); $("#inputQR").keypress(function (e) { var key = e.which; if (key == 13) { let inputData = $(this).val(); let countNo = setTextCommaToNumber($("#countNo").val()); countNo = countNo + 1; let nextNo = setTextCommaToNumber($("#nextNo").val()); $.ajax({ type: "post", url: "ajax/application/updateStorage", data: { start_no:start_no, inputData:inputData, countNo:countNo, nextNo:nextNo, }, dataType: "json", success: function (response) { if (response.status == 1) { swal({ title: "ดำนเนิการสำเร็จ!", text: "บันทึกข้อมูลเรียบร้อย", type: "success", showConfirmButton: false }); $("#countNo").val(countNo); $("#storage_count").html(numberWithCommas(countNo)); let content = "<tr>"; content = content + "<td class='text-center'>" + numberWithCommas(nextNo) + "</td>"; content = content + "<td>" + response.member_name + "</td>"; content = content + "<td class='text-center'>"; content = content + "<button class='btn btn-sm btn-danger deleteRowStorage' type='button' data-id='" + response.member_id + "' onclick='deleteRowStorage(this);'>"; content = content + "<i class='fa fa-close'>ลบ</i></button></td></tr>"; $("#tableData tbody").prepend(content); nextNo = nextNo + 1; $("#storage_next").html(numberWithCommas(nextNo)); $("#nextNo").val(nextNo); $(".deleteRowStorage").hide(); $(".deleteRowStorage").first().show(); } else { swal({ title: "ดำนเนิการไม่สำเร็จ!", text: "ไม่พบข้อมูล", type: "error", showConfirmButton: false }); $("#errorSound")[0].play(); } setTimeout(() => { $("#inputQR").val(''); $("#inputQR").focus(); swal.close(); }, 1500); } }); } }); } }); } function numberWithCommas(number) { return number.toString().replace(/(\d)(?=(\d{3})+\.)/g, "$1,"); } function setTextCommaToNumber(value) { if (value != "") { let text = value.replace(/,/g, ''); return parseFloat(text); } else { return 0; } } function deleteRowStorage(button) { swal({ title: 'กรุณายืนยันเพื่อทำรายการ', type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', cancelButtonText: 'ยกเลิก', confirmButtonText: 'ยืนยัน', closeOnConfirm: false }, function() { let member_id = $(button).data('id'); let countNo = setTextCommaToNumber($("#countNo").val()); countNo = countNo - 1; $.ajax({ type: "post", url: "ajax/application/deleteRowStorage", data: { member_id:member_id, countNo:countNo, }, dataType: "json", success: function (response) { if (response.status == 1) { swal({ title: "ดำนเนิการสำเร็จ!", text: "ลบข้อมูลเรียบร้อย", type: "success", showConfirmButton: false }); let nextNo = setTextCommaToNumber($("#nextNo").val()); nextNo = nextNo - 1; $(button).parents('tr').remove(); $("#storage_next").html(numberWithCommas(nextNo)); $("#nextNo").val(nextNo); nextNo = nextNo - 1; $("#countNo").val(countNo); $("#storage_count").html(numberWithCommas(countNo)); $(".deleteRowStorage").hide(); $(".deleteRowStorage").first().show(); } else { swal({ title: "ดำนเนิการไม่สำเร็จ!", text: "ไม่สามารถเชื่อมต่อฐานข้อมูลได้", type: "error", showConfirmButton: false }); } setTimeout(() => { $("#inputQR").focus(); swal.close(); }, 1500); } }); }); } </script> </body> </html>