function whatsapp(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "whatsapp", name: jQuery("#name").val(), phone: jQuery("#phone").val(), question: jQuery("#question").val() }), success: function(responseText, responseStatus) { if(responseText.substr(0,4)=="Sila"){ jQuery("#divStatus").html(responseText); }else{ parent.window.location = responseText; } } }); } function signup(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "signup", name: jQuery("#name").val(), phone: jQuery("#phone").val(), username: jQuery("#username").val(), code: jQuery("#code").val() }), success: function(responseText, responseStatus) { if(responseText.substr(0,4)=="Sila" || responseText.substr(0,4)=="Maaf"){ jQuery("#divStatus").html(responseText); }else if(responseText=="success"){ parent.window.location = "https://niagawan.com/my/referral-thank/"; } } }); } function addCart(c){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "addCart", code: c }), success: function(responseText, responseStatus) { //Redirect window.location = responseText; } }); } function listCart(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "listCart" }), success: function(responseText, responseStatus) { jQuery("#divContent").html(responseText); selectCartMethod(jQuery('#paymethod').val()); } }); } function selectCartMethod(m){ if(m=="FPX"){ document.getElementById("divFPX").style.display = "block"; document.getElementById("divMaybank").style.display = "none"; document.getElementById("tabFPX").className = "tabactive"; document.getElementById("tabMaybank").className = "tab"; document.getElementById("paymethod").value = "FPX"; }else if(m=="Maybank"){ document.getElementById("divFPX").style.display = "none"; document.getElementById("divMaybank").style.display = "block"; document.getElementById("tabFPX").className = "tab"; document.getElementById("tabMaybank").className = "tabactive"; document.getElementById("paymethod").value = "Maybank"; } updateCart(); } function delCart(i){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "delCart", item_id: i }), success: function(responseText, responseStatus) { listCart(); } }); } function updateCart(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "updateCart", company: jQuery("#company").val(), name: jQuery("#name").val(), phone: jQuery("#phone").val(), email: jQuery("#email").val(), username: jQuery("#username").val(), paymethod: jQuery("#paymethod").val(), payfpx: jQuery("#payfpx").val() }), success: function(responseText, responseStatus) { } }); } function confirmCart(){ if(document.getElementById("company").value==""){ jQuery("#divStatus").html("Sila isi Nama Syarikat anda."); }else if(document.getElementById("name").value==""){ jQuery("#divStatus").html("Sila isi Nama anda."); }else if(document.getElementById("phone").value==""){ jQuery("#divStatus").html("Sila isi No Telefon anda."); }else if(document.getElementById("email").value==""){ jQuery("#divStatus").html("Sila isi Emel anda."); }else if(document.getElementById("username").value==""){ jQuery("#divStatus").html("Sila isi ID Pengguna anda."); }else if(document.getElementById("chkusername").value!="yes"){ jQuery("#divStatus").html("Sila pilih ID Pengguna yang lain."); }else{ if(document.getElementById("paymethod").value=="FPX"){ if(document.getElementById("payfpx").value==""){ jQuery("#divStatus").html("Sila pilih Bank pilihan anda."); }else{ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "confirmCart", company: jQuery("#company").val(), name: jQuery("#name").val(), phone: jQuery("#phone").val(), email: jQuery("#email").val(), username: jQuery("#username").val(), chkusername: jQuery("#chkusername").val(), gotitem: jQuery("#gotitem").val(), paymethod: jQuery("#paymethod").val(), payfpx: jQuery("#payfpx").val(), payproof: jQuery("#payproof").val() }), success: function(responseText, responseStatus) { if(responseText=="success"){ parent.window.location = "https://niagawan.com/my/order-confirm"; }else{ jQuery("#divStatus").html(responseText); } } }); } }else if(document.getElementById("paymethod").value=="Maybank"){ if(document.getElementById("payproof").value==""){ jQuery("#divStatus").html("Sila pilih Muat Naik Slip Bayaran anda."); }else{ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "confirmCart", company: jQuery("#company").val(), name: jQuery("#name").val(), phone: jQuery("#phone").val(), email: jQuery("#email").val(), username: jQuery("#username").val(), chkusername: jQuery("#chkusername").val(), gotitem: jQuery("#gotitem").val(), paymethod: jQuery("#paymethod").val(), payfpx: jQuery("#payfpx").val(), payproof: jQuery("#payproof").val() }), success: function(responseText, responseStatus) { if(responseText=="success"){ parent.window.location = "https://niagawan.com/my/order-confirm"; }else{ jQuery("#divStatus").html(responseText); } } }); } }else if(document.getElementById("paymethod").value=="Coupon"){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "confirmCart", company: jQuery("#company").val(), name: jQuery("#name").val(), phone: jQuery("#phone").val(), email: jQuery("#email").val(), username: jQuery("#username").val(), chkusername: jQuery("#chkusername").val(), gotitem: jQuery("#gotitem").val(), paymethod: jQuery("#paymethod").val(), payfpx: jQuery("#payfpx").val(), payproof: jQuery("#payproof").val() }), success: function(responseText, responseStatus) { if(responseText=="success"){ parent.window.location = "https://niagawan.com/my/order-confirm"; }else{ jQuery("#divStatus").html(responseText); } } }); } } } function reviewCart(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "reviewCart" }), success: function(responseText, responseStatus) { jQuery("#divContent").html(responseText); } }); } function submitCart(){ document.getElementById("divSubmit").style.display = "none"; document.getElementById("divSubmited").style.display = "block"; jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "submitCart", company: jQuery("#company").val(), name: jQuery("#name").val(), phone: jQuery("#phone").val(), email: jQuery("#email").val(), username: jQuery("#username").val(), chkusername: jQuery("#chkusername").val(), gotitem: jQuery("#gotitem").val(), paymethod: jQuery("#paymethod").val(), payproof: jQuery("#payproof").val() }), success: function(responseText, responseStatus) { window.location = responseText; } }); } function submitToyyib(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "submitToyyib", company: jQuery("#company").val(), name: jQuery("#name").val(), phone: jQuery("#phone").val(), email: jQuery("#email").val(), username: jQuery("#username").val(), chkusername: jQuery("#chkusername").val(), gotitem: jQuery("#gotitem").val(), paymethod: jQuery("#paymethod").val(), payproof: jQuery("#payproof").val() }), success: function(responseText, responseStatus) { parent.window.location = responseText; } }); } function chkUsername(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "chkUsername", username: jQuery("#username").val() }), success: function(responseText, responseStatus) { jQuery("#divUsername").html(responseText); } }); } function redeemCoupon(){ jQuery.ajax({ type: "POST", dataType: "html", url: webpath + "ajax.cart.php", data: ({ pageaction: "redeemCoupon", coupon: jQuery("#coupon").val() }), success: function(responseText, responseStatus) { jQuery("#divCoupon").html(responseText); if(responseText.substr(0,45)=="
Coupon sah.
"){ listCart(); } } }); }