Path : /var/www/html/jewelry-pos/public/admin-asset/js/ |
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
Current File : /var/www/html/jewelry-pos/public/admin-asset/js/custom.js |
// <!-- Preview image upload script --> function preview() { frame.src = URL.createObjectURL(event.target.files[0]); } function clearImage() { document.getElementById("formFile").value = null; frame.src = ""; } // preview 2 field in tbl js function previewfav() { framefav.src = URL.createObjectURL(event.target.files[0]); var form = new FormData(); form.append("image", $('#formFile')[0].files[0]); form.append("product_id", product_id); $.ajax({ // url: "{{route('sell.store')}}", "url": "http://127.0.0.1:8000/api/product/update-image", "method": "POST", "timeout": 0, "processData": false, "mimeType": "multipart/form-data", "contentType": false, data:form, success: function (response) { response = JSON.parse(response) console.log(response); if(response){ Swal.fire({ position: "top-end", icon: "success", title: response.message, showConfirmButton: false, timer: 1200, width: '250px', }); } }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); } function clearImagefav() { document.getElementById("formFilefav").value = null; framefav.src = ""; } // dropdown more in tbl $(".h-auto").on("show.bs.dropdown", function () { $(".h-auto").css("overflow", "inherit"); }); $(".h-auto").on("hide.bs.dropdown", function () { $(".h-auto").css("overflow", "auto"); }); $(".number-only") .keyup(function (e) { if (this.value != "-") while (isNaN(this.value)) this.value = this.value .split("") .reverse() .join("") .replace(/[\D]/i, "") .split("") .reverse() .join(""); }) .on("cut copy paste", function (e) { e.preventDefault(); }); //func reject sweet alert function rejectTransaction( t, id, url, label = "Reason", placeholder = "Why do you reject this transacton?", requiredMessage = "Your reason is required", buttonLabel = "Reject" ) { const {value: text} = Swal.fire({ input: "textarea", inputLabel: label, inputPlaceholder: placeholder, inputAttributes: { "aria-label": placeholder, }, confirmButtonText: buttonLabel, preConfirm: (value) => { if (!value) { Swal.showValidationMessage( '<i class="fa fa-info-circle"></i> ' + requiredMessage ); } }, // cancelButtonText: "Close", // showCancelButton: true }).then(function (data) { if (data.isConfirmed) { $("input." + t + id).val(data.value); $("form." + t + id).submit(); } else { console.log("Reason is required"); } }); if (text) { return true; } return false; } // not allow delete function notAllowDelete() { // Swal.fire("<h4>Not Allow to delete it!</h3>"); Swal.fire({ title: "Not Allow to delete it!", icon: "error", showCloseButton: true }); } function focusSearch() { var search = localStorage.getItem('parseQ'); if(search){ setTimeout(function (){ document.getElementById('input').value = search; if(search.length >= 4){ changeAutoComplete(); } },50); // document.getElementById('autocomplete').focus(); } } focusSearch(); function isInputNumberReal(evt) { var ch = String.fromCharCode(evt.which); if (!(/^[0-9]*\.?[0-9]*$/.test(ch))) { evt.preventDefault(); } } function isInputNumberDolar(evt) { var ch = String.fromCharCode(evt.which); if (!(/^[0-9]*\.?[0-9]*$/.test(ch))) { evt.preventDefault(); } } function isInputNumberBth(evt) { var ch = String.fromCharCode(evt.which); if (!(/^[0-9]*\.?[0-9]*$/.test(ch))) { evt.preventDefault(); } } document.addEventListener("DOMContentLoaded", function(event) { var returnKhr = document.getElementById('returnkhr'); returnKhr.disabled = true; var returnUsd = document.getElementById('returnusd'); var returnThb = document.getElementById('returnthb'); returnUsd.disabled = true; returnThb.disabled = true; }); function displayColorReal() { var realAmount = document.getElementById("khrAmount"); var returnReal = document.getElementById("returnkhr"); var realPay = document.getElementById("realPay"); var returnDolar = document.getElementById('returnusd'); // returnReal.value = realPay.value - realAmount.value; // var rateKhr = 4090.60; // // var rateThb = 36.83; // var rThb = returnDolar.value * rateThb; // var rUsd = returnReal.value / rateKhr; // document.getElementById('returnkhr').value = returnReal.value; // document.getElementById('returnthb').value = rThb; // document.getElementById('returnusd').value = rUsd; var txtreturnReal = document.getElementById('returnkhr').value; if (txtreturnReal >= 0) { document.getElementById('returnkhr').style.color = "blue"; document.getElementById('returnkhr').style.fontWeight = "bold"; } else { document.getElementById('returnkhr').style.color = "red"; document.getElementById('returnkhr').style.fontWeight = "bold"; } } function displayColorDolar() { var dolarAmount = document.getElementById("dolarAmount"); var returnDolar = document.getElementById("returnusd"); var dolarPay = document.getElementById('dolarPay'); // returnDolar.value = dolarPay.value - dolarAmount.value; // var rateKhr = 4090.60; // var rKhr = returnDolar.value * rateKhr; // var rateThb = 36.83; // var rThb = returnDolar.value * rateThb; // document.getElementById('returnusd').value = returnDolar.value; // document.getElementById('returnkhr').value = rKhr; // document.getElementById('returnthb').value = rThb; var txtreturnDolar = document.getElementById('returnusd').value; if (txtreturnDolar >= 0) { document.getElementById('returnusd').style.color = "blue"; document.getElementById('returnusd').style.fontWeight = "bold"; } else { document.getElementById('returnusd').style.color = "red"; document.getElementById('returnusd').style.fontWeight = "bold"; } } function displayColorBth() { var bthAmount = document.getElementById("thbAmount"); var returnBth = document.getElementById("returnthb"); var bthPay = document.getElementById("bthPay"); var returnDolar = document.getElementById('returnusd'); // returnBth.value = bthPay.value - bthAmount.value; // var rateThb = 36.83; // var rUsd = returnBth.value / rateThb; // var rateKhr = 4090.60; // var rKhr = returnDolar.value / rateKhr; // document.getElementById('returnusd').value = rUsd; // document.getElementById('returnkhr').value = rKhr; var txtreturnBth = document.getElementById('returnthb').value; if (txtreturnBth >= 0) { document.getElementById('returnthb').style.color = "blue"; document.getElementById('returnthb').style.fontWeight = "bold"; } else { document.getElementById('returnthb').style.color = "red"; document.getElementById('returnthb').style.fontWeight = "bold"; } } document.addEventListener("DOMContentLoaded", function (event) { document.getElementById('returnkhr').style.color = "red"; document.getElementById('returnkhr').style.fontWeight = "bold"; document.getElementById('returnusd').style.color = "red"; document.getElementById('returnusd').style.fontWeight = "bold"; document.getElementById('returnthb').style.color = "red"; document.getElementById('returnthb').style.fontWeight = "bold"; }); function calReturnReal() { displayColorReal(); } function calReturnDolar() { displayColorDolar(); } function calReturnBth() { displayColorBth(); } // document.getElementById('khrAmount').disabled = true; // document.getElementById('dolarAmount').disabled = true; // document.getElementById('thbAmount').disabled = true; document.addEventListener("DOMContentLoaded", function (event){ // var txtAmountReal = document.getElementById('khrAmount').value; // if (txtAmountReal >= 0) { // document.getElementById('khrAmount').style.color = "blue"; // document.getElementById('khrAmount').style.fontWeight = "bold"; // } else { // document.getElementById('khrAmount').style.color = "red"; // document.getElementById('khrAmount').style.fontWeight = "bold"; // } // var txtAmountDolar = document.getElementById('dolarAmount').value; // if (txtAmountDolar >= 0) { // document.getElementById('dolarAmount').style.color = "blue"; // document.getElementById('dolarAmount').style.fontWeight = "bold"; // } else { // document.getElementById('dolarAmount').style.color = "red"; // document.getElementById('dolarAmount').style.fontWeight = "bold"; // } // var txtAmountBth = document.getElementById('thbAmount').value; // if (txtAmountBth >= 0) { // document.getElementById('thbAmount').style.color = "blue"; // document.getElementById('thbAmount').style.fontWeight = "bold"; // } else { // document.getElementById('thbAmount').style.color = "red"; // document.getElementById('thbAmount').style.fontWeight = "bold"; // } var modalPay = document.getElementById('modal_pay'); modalPay.addEventListener("click", function () { var txtbthPay = document.getElementById('bthPay').value; var lenbthPay = txtbthPay.length; var textCustomer = document.getElementById('customerName').value; var lenCustomer = textCustomer.length; let PhoneNumber = document.getElementById('phone').value; let lenghtPhone = PhoneNumber.length; var txtdolarPay = document.getElementById('dolarPay').value; var lendolarPay = txtdolarPay.length; var txtDolarAmount = document.getElementById('dolarAmount').value; var lenDolarAmount = txtDolarAmount.length; var txtrealPay = document.getElementById('realPay').value; var lenrealPay = txtrealPay.length; // if (lenCustomer == 0) { // document.getElementById('customerName').focus(); // return; // } if(lenghtPhone == 0 || lenghtPhone <= 8){ document.getElementById('phone').focus(); return; } // if (lendolarPay == 0 || lenrealPay == 0 || lenbthPay == 0) { return; } // if(selectUsd ) // if(lendolarPay == 0 ){ // document.getElementById('dolarPay').focus(); // return; // } // if(lenrealPay == 0 && lendolarPay == 0 && lenbthPay == 0){ // document.getElementById('realPay').focus(); // } // if(lenbthPay == 0 && lenrealPay == 0 && lendolarPay == 0){ // document.getElementById('bthPay').focus(); // } // if(lenrealPay != 0){ // document.getElementById('datePaid').focus(); // } // if(lendolarPay != 0){ // document.getElementById('datePaid').focus(); // } // if(lenbthPay != 0){ // document.getElementById('datePaid').focus(); // } }); }); function focusRealPay() { document.getElementById('realPay').focus(); } function noValue() { displayColorReal(); displayColorDolar(); displayColorBth(); } var realPay = document.getElementById("realPay"); function f_focusCalReal() { document.getElementById('dot').onclick = function () { realPay.value += '.'; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('x').onclick = function () { var bsp = document.getElementById('realPay').value; document.getElementById("realPay").value = bsp.substring(0, bsp.length - 1); focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('7').onclick = function () { realPay.value += "7"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('8').onclick = function () { realPay.value += "8"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('9').onclick = function () { realPay.value += "9"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('4').onclick = function () { realPay.value += "4"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('5').onclick = function () { realPay.value += "5"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('6').onclick = function () { realPay.value += "6"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('1').onclick = function () { realPay.value += "1"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('2').onclick = function () { realPay.value += "2"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('3').onclick = function () { realPay.value += "3"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('0').onclick = function () { realPay.value += "0"; focusRealPay(); displayColorReal(); returnCash(); } document.getElementById('clear').onclick = function () { document.getElementById('returnkhr').value = 0; document.getElementById('realPay').value = ""; displayColorReal(); noValue(); returnCash(); } } function focusDolarPay() { document.getElementById('dolarPay').focus(); } var dolarPay = document.getElementById('dolarPay'); function f_focusCalDolar() { document.getElementById('7').onclick = function () { dolarPay.value += "7"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('8').onclick = function () { dolarPay.value += "8"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('9').onclick = function () { dolarPay.value += "9"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('4').onclick = function () { dolarPay.value += "4"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('5').onclick = function () { dolarPay.value += "5"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('6').onclick = function () { dolarPay.value += "6"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('1').onclick = function () { dolarPay.value += "1"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('2').onclick = function () { dolarPay.value += "2"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('3').onclick = function () { dolarPay.value += "3"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('0').onclick = function () { dolarPay.value += "0"; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('dot').onclick = function () { dolarPay.value += "."; focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('x').onclick = function () { var bsp = document.getElementById('dolarPay').value; document.getElementById("dolarPay").value = bsp.substring(0, bsp.length - 1); focusDolarPay(); displayColorDolar(); returnCash(); } document.getElementById('clear').onclick = function () { document.getElementById('returnusd').value = 0; document.getElementById('dolarPay').value = ""; focusDolarPay(); noValue(); returnCash(); } } function focusBthPay() { document.getElementById('bthPay').focus(); } var bthPay = document.getElementById('bthPay') function f_focusCalBth() { document.getElementById('7').onclick = function () { bthPay.value += "7"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('8').onclick = function () { bthPay.value += "8"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('9').onclick = function () { bthPay.value += "9"; focusBthPay() displayColorBth(); returnCash(); } document.getElementById('4').onclick = function () { bthPay.value += "4"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('5').onclick = function () { bthPay.value += "5"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('6').onclick = function () { bthPay.value += "6"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('1').onclick = function () { bthPay.value += "1"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('2').onclick = function () { bthPay.value += "2"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('3').onclick = function () { bthPay.value += "3"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('0').onclick = function () { bthPay.value += "0"; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('dot').onclick = function () { bthPay.value += "."; focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('x').onclick = function () { var bsp = document.getElementById('bthPay').value; document.getElementById("bthPay").value = bsp.substring(0, bsp.length - 1); focusBthPay(); displayColorBth(); returnCash(); } document.getElementById('clear').onclick = function () { document.getElementById('returnthb').value = 0; document.getElementById('bthPay').value = ""; focusBthPay(); noValue(); returnCash(); } } function f_dolarAmount() { document.getElementById('dot').onclick = function () { document.getElementById("dolarAmount").value += "."; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('x').onclick = function () { var bsp = document.getElementById('dolarAmount').value; document.getElementById("dolarAmount").value = bsp.substring(0, bsp.length - 1); document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('7').onclick = function () { document.getElementById("dolarAmount").value += "7"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('8').onclick = function () { document.getElementById("dolarAmount").value += "8"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('9').onclick = function () { document.getElementById("dolarAmount").value += "9"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('4').onclick = function () { document.getElementById("dolarAmount").value += "4"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('5').onclick = function () { document.getElementById("dolarAmount").value += "5"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('6').onclick = function () { document.getElementById("dolarAmount").value += "6"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('1').onclick = function () { document.getElementById("dolarAmount").value += "1"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('2').onclick = function () { document.getElementById("dolarAmount").value += "2"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('3').onclick = function () { document.getElementById("dolarAmount").value += "3"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('0').onclick = function () { document.getElementById("dolarAmount").value += "0"; document.getElementById("dolarAmount").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('clear').onclick = function () { document.getElementById('returnkhr').value = 0; document.getElementById('dolarAmount').value = ""; displayColorReal(); noValue(); returnCash(); modify_price(); } } function f_phoneNumber() { document.getElementById('dot').onclick = function () { document.getElementById("phone").value += "."; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('x').onclick = function () { var bsp = document.getElementById('phone').value; document.getElementById("phone").value = bsp.substring(0, bsp.length - 1); document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('7').onclick = function () { document.getElementById("phone").value += "7"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('8').onclick = function () { document.getElementById("phone").value += "8"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('9').onclick = function () { document.getElementById("phone").value += "9"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('4').onclick = function () { document.getElementById("phone").value += "4"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('5').onclick = function () { document.getElementById("phone").value += "5"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('6').onclick = function () { document.getElementById("phone").value += "6"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('1').onclick = function () { document.getElementById("phone").value += "1"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('2').onclick = function () { document.getElementById("phone").value += "2"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('3').onclick = function () { document.getElementById("phone").value += "3"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('0').onclick = function () { document.getElementById("phone").value += "0"; document.getElementById("phone").focus(); displayColorReal(); returnCash(); modify_price(); } document.getElementById('clear').onclick = function () { document.getElementById('phone').value = 0; document.getElementById('phone').value = ""; displayColorReal(); noValue(); returnCash(); modify_price(); } } function clickdownload () { var url = $("#download-button").attr("href") $("#search input, #search select").each(function(key, val){ console.log($(this).val(),$(this).attr("name")); if(key==0) { url = url+"?" } else{ url = url+ "&"; } url = url+$(this).attr("name")+"="+$(this).val(); }); $("#download-button").attr("href", url); return true; } function inputTooShort () { const lang = window.localStorage.getItem('lang') let message switch (lang){ case 'kh': message = 'សូមបញ្ចូលតួអក្សរ 1 ឬច្រើន។' break; case 'en': message = 'Please Enter 1 or more characters.' break; case 'th': message = 'โปรดป้อนอักขระ 1 ตัวขึ้นไป' } return message }