var org_id = kariah_id = 226; function swal_ok_countdown(title, message, timer = null, redirect = null) { let countdown = timer; let intervalId; const swalInstance = Swal.fire({ title: title, html: message, icon: "success", showConfirmButton: true, confirmButtonText: timer > 0 ? `OK (${countdown})` : 'OK', allowOutsideClick: false, allowEscapeKey: false, allowEnterKey: false }); if (timer > 0) { intervalId = setInterval(() => { countdown--; if (countdown <= 0) { clearInterval(intervalId); swalInstance.close(); } else { swalInstance.update({ confirmButtonText: `OK (${countdown})` }); } }, 1000); } swalInstance.then((result) => { if (intervalId) clearInterval(intervalId); if (redirect === 'reload') { window.location.reload(); } else if (typeof redirect === 'string' && redirect.length > 0) { window.location.href = redirect; } }); } function notify(msg,typealert){ if (typealert=='alert'){ var icon = ' '; } else if (typealert=='success'){ var icon = ' '; } else if (typealert=='warning'){ var icon = ' '; } else if (typealert=='error'){ var icon = ' '; } else if (typealert=='info'){ var icon = ' '; } new Noty({ text: icon+msg, type: typealert, timeout: 3500, killer: true, progressBar: true, theme: 'metroui' }).show(); } function showmap(lat,lang,where,zoomratio) { var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; var latlng = new google.maps.LatLng(lat,lang); directionsDisplay = new google.maps.DirectionsRenderer(); var myOptions = { zoom: zoomratio, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP , travelMode: google.maps.TravelMode.DRIVING }; var map = new google.maps.Map(document.getElementById(where), myOptions); directionsDisplay.setMap(map); var image = '../../assets/images/location.png'; var myLatLng = new google.maps.LatLng(lat,lang); var beachMarker = new google.maps.Marker({ position: myLatLng, map: map, icon: image }); } function get_location(){ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(GEOprocess, GEOdeclined); }else{ swal.fire('Sorry','Your browser does not allow location to be detected',"danger"); //document.getElementById('geo').innerHTML = 'Your browser sucks. Upgrade it.'; } } function get_directions(dest_lat,dest_lng){ var ori_lat = $("#latitude").val(); var ori_lng = $("#longitude").val(); var latlng = new google.maps.LatLng(ori_lat,ori_lng); var directionsService = new google.maps.DirectionsService; var directionsDisplay = new google.maps.DirectionsRenderer; directionsService.route({ origin: new google.maps.LatLng(ori_lat,ori_lng), destination: new google.maps.LatLng(dest_lat,dest_lng), travelMode: google.maps.TravelMode.DRIVING }, function(response, status) { if (status === google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } else { window.alert('Directions request failed due to ' + status); } }); var myOptions = { zoom: 7, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP , travelMode: google.maps.TravelMode.DRIVING }; var map = new google.maps.Map(document.getElementById('map_box'), myOptions); directionsDisplay.setMap(map); get_distance(dest_lat,dest_lng); } function get_distance(dest_lat,dest_lng) { var ori_lat = $("#latitude").val(); var ori_lng = $("#longitude").val(); var latlng = [new google.maps.LatLng(ori_lat,ori_lng)]; var dest_latlng = [new google.maps.LatLng(dest_lat,dest_lng)]; var geocoder = new google.maps.Geocoder; var service = new google.maps.DistanceMatrixService; service.getDistanceMatrix({ origins: latlng, destinations: dest_latlng, travelMode: google.maps.TravelMode.DRIVING, unitSystem: google.maps.UnitSystem.METRIC, avoidHighways: false, avoidTolls: false }, function(response, status) { if (status !== google.maps.DistanceMatrixStatus.OK) { //alert('Error was: ' + status); } else { //alert('Response was: ' + response.distance); var originList = response.originAddresses; var destinationList = response.destinationAddresses; for (var i = 0; i < originList.length; i++) { var results = response.rows[i].elements; for (var j = 0; j < results.length; j++) { var element = results[j]; var distance = element.distance.text; var duration = element.duration.text; var duration_bm = duration.replace("hours","jam").replace("hour","jam").replace("mins","minit"); var from = originList[i]; var to = destinationList[j]; } } //$("#output").html("Lokasi Asal (A)
"+originList+"

Destinasi (B)
"+destinationList+"

Jarak
"+distance+"

Tempoh
"+duration); } }); } function GEOprocess(position){ $("#latitude").val((position.coords.latitude).toFixed(7)); $("#longitude").val((position.coords.longitude).toFixed(7)); GEOajax("../plugins/geolocation/geo.php?accuracy=" + position.coords.accuracy + "&latlng=" + position.coords.latitude + "," + position.coords.longitude +"&altitude="+position.coords.altitude+"&altitude_accuracy="+position.coords.altitudeAccuracy+"&heading="+position.coords.heading+"&speed="+position.coords.speed+""); var lat = $("#latitude").val(); var long = $("#longitude").val(); showmap(lat, long, "map_box",14); $("#show_kariah_div").load("show_kariah.php?lat="+lat+"&long="+long,function(){ }); } function GEOdeclined(error){ $("#show_kariah_div").html(""); } function GEOdeclined2(error){ $("#pilih_kariah_div_top").load("enter_poskod.php", function(){ Swal.fire('Organization Location Identification','Please allow your location',"info"); }); } function GEOdeclined3(error){ $("#enter_poskod_div").load("enter_poskod.php?allow_poskod_search=1&ping=1", function(){ Swal.fire('Organization Location Identification','Please allow your location',"info"); $("#show_map_div").fadeOut(); $("#geodeclined").fadeIn(); }); } function search_poskod(allow_poskod_search){ $("#pilih_kariah_div_top").load("enter_poskod.php?allow_poskod_search="+allow_poskod_search+"&ping=1", function(){ Swal.fire('Organization Location Identification','Please allow your location',"info"); }); } function search_poskod_on_map(allow_poskod_search,popup=1){ $("#show_map_div").load("enter_poskod.php?allow_poskod_search="+allow_poskod_search+"&ping=0", function(){ if (popup==1){ Swal.fire('Organization Location Identification','Please allow your location',"info"); } $("#show_map_div").addClass("container"); }); } function search_hebahan(){ var q = $("#search_hebahan_form").serializeArray(); $("#list_hebahan_div").load("list_hebahan.php", q, function(){}) } function GEOajax(url){ xmlHttp.open("GET", url, true); xmlHttp.onreadystatechange=updatePage; xmlHttp.send(null); } function updatePage(){ if (xmlHttp.readyState==4){ var response=xmlHttp.responseText; $("#lokasi").html(response); } } function daftar(kariah_id){ location.href="daftar.php?kariah_id="+kariah_id; } // 20200616 - comment by izzat //20200616 - added by izzat // function register_form_submit(){ // var pwd1 =$("#organisasi_password").val(); // var pwd2 =$("#organisasi_password2").val(); // var org_id = $("#peserta_kariah_id").val(); // if (pwd1!=pwd2){ // Swal.fire('Error','Password Is Not The Same',"error"); // } else { // var query = $("#register_form").serializeArray(), json={}; // $("#action_submit").load("daftar_submit_organisasi.php", query, function(data){ // if (data>5){ // Swal.fire({ // title: 'Congratulations', // html: 'You successfully registered your organization as a Virtual member.
Please check your email for more information on how you can manage your organization membership.', // icon: 'success', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // sendmailer_data(data,'terima_kasih'); // location.href="../peserta/login.php?org_id="+org_id; // } // }); // /*if (organisasi_id==1){ // sendmailer_data(data,'terima_kasih_default'); // location.href="../manage/login.php"; // } else { // sendmailer_data(data,'terima_kasih'); // location.href="../manage/login.php"; // }*/ // } else if (data<0){ // dt=new Date(-data * 1000).toLocaleString(); // resp = 'You have registered before on %s. Please login.'; // Swal.fire({ // title: 'You Have Registered', // text: resp.replace("%s", dt), // icon: 'error', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // location.href="../peserta/login.php?org_id="+org_id; // } // }); // } else if (data==2){ // Swal.fire({ // title: 'Welcome', // text: "Anda adalah ahli maya sedia ada. Sila log masuk.", // icon: 'success', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // sendmailer_data(data,'terima_kasih'); // location.href="../peserta/login.php?org_id="+org_id; // } // }); // } else if (data==3){ // Swal.fire({ // title: 'Selamat Kembali', // text: "Anda adalah ahli maya sedia ada. Sila kemaskinikan maklumat tanggungan dan buat bayaran untuk pembaharuan keahlian", // icon: 'success', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // sendmailer_data(data,'terima_kasih'); // location.href="../peserta/login.php?org_id="+org_id; // } // }); // } else if (data==4){ // Swal.fire({ // title: 'Error', // text: 'Your Email Is Invalid', // icon: 'error', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // // location.href="index.php"; // } // }); // } else if (data==5){ // Swal.fire({ // title: 'Error', // text: "Pendaftaran anda mengalami masalah teknikal!", // icon: 'error', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // // location.href="index.php"; // } // }); // } // }); // } // } function register_tanggungan_submit(){ //alert('submit'); var tanggungan_mykad = $("#kk_peserta_tanggungan_nokp").val(); var kk_peserta_nama_tanggungan_name = $("#kk_peserta_nama_tanggungan_name").val(); var kk_peserta_tanggungan_relationship = $('input[name="kk_peserta_tanggungan_relationship"]:checked').val(); var kk_peserta_tanggungan_sex = $('input[name="kk_peserta_tanggungan_sex"]:checked').val(); var kariah_id = $("#kk_peserta_tanggungan_kariah_id").val(); var kk_peserta_tanggungan_id = $("#kk_peserta_tanggungan_id").val(); var kk_peserta_tanggungan_notel = $("#kk_peserta_tanggungan_notel").val(); var query = $("#register_tanggungan_form").serializeArray(), json={}; query.push({"name":"kk_peserta_tanggungan_nokp", "value":tanggungan_mykad}); query.push({"name":"kk_peserta_nama_tanggungan_name", "value":kk_peserta_nama_tanggungan_name}); query.push({"name":"kk_peserta_tanggungan_relationship", "value":kk_peserta_tanggungan_relationship}); query.push({"name":"kk_peserta_tanggungan_sex", "value":kk_peserta_tanggungan_sex}); query.push({"name":"kariah_id", "value":kariah_id}); query.push({"name":"kk_peserta_tanggungan_id", "value":kk_peserta_tanggungan_id}); query.push({"name":"kk_peserta_tanggungan_notel", "value":kk_peserta_tanggungan_notel}); query.push({"name":"MM_insert_tanggungan", "value":"register_tanggungan"}); if (check_tanggungan_limit(kk_peserta_tanggungan_id,kariah_id)=="0"){ // check tanggungan limit. if 0, proceed if (kk_peserta_tanggungan_relationship==9){ if (check_tanggungan_waris_limit(kk_peserta_tanggungan_id,kariah_id)=="0"){ var mykad = /(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))([0-9]{2})([0-9]{4})/g; if (tanggungan_mykad.match(mykad)){ //var query = $("#register_tanggungan_form, #register_form").serializeArray(), json={}; $("#list_tanggungan").load("daftar_tanggungan_list.php", query, function(data){ $("input.reset").val(""); }) } else { Swal.fire('Identity Card No. Format Error','Please enter the correct identity card number',"error"); } } else { Swal.fire('Already Reached the Limit of Heir Liability','You have reached the limit of the number of beneficiaries that have been set by your organization.',"error"); } } else { var mykad = /(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))([0-9]{2})([0-9]{4})/g; if (tanggungan_mykad.match(mykad)){ //var query = $("#register_tanggungan_form, #register_form").serializeArray(), json={}; $("#list_tanggungan").load("daftar_tanggungan_list.php", query, function(data){ $("input.reset").val(""); }) } else { Swal.fire('Identity Card No. Format Error','Please enter the correct identity card number',"error"); } } } else { Swal.fire('Already Reached the Limit of Heir Liability','You have reached the limit of the number of dependents that have been set by your organization.',"error"); } } function padam_tanggungan(tanggungan_id){ Swal.fire({ title: 'Are You Sure?', text: 'This action cannot be undone', icon: 'warning', showCancelButton: true, cancelButtonText: 'No', confirmButtonText: 'Yes', confirmButtonColor: '#258', cancelButtonColor: '#f00' }).then((result) => { $("#list_tanggungan").load("daftar_tanggungan_list.php", {"MM_delete_tanggungan":"padam_tanggungan","tanggungan_id":tanggungan_id}, function(data){ }) }) } function update_tanggungan_submit(){ var query = $("#register_tanggungan_form").serializeArray(), json={}; $("#list_tanggungan").load("daftar_tanggungan_list.php", query, function(data){ $("#register_tanggungan_div").load("register_tanggungan.php", function(){}) }) } function kemaskini_tanggungan(tanggungan_id){ $("#register_tanggungan_div").load("register_tanggungan.php", {"MM_update_tanggungan":"update_tanggungan","tanggungan_id":tanggungan_id}, function(data){ whatsex(); }) } function log_keluar(org_id){ $("#action_submit").load("logout.php", function(){ location.href="index.php?org_id="+org_id; }) } function log_masuk(org_id=null, isPopup = false){ //$("#action_submit").load("login.php", function(){ if(isPopup) login_popup(false); else location.href="login.php?org_id="+org_id; //}) } function batal_tanggungan(){ $("#register_tanggungan_div").load("register_tanggungan.php", function(){}); } function pilih_kariah(peserta_id){ location.href="pilih_kariah.php?peserta_id="+peserta_id; } function login_submit(org_id, fund_id=null, url=null){ var query = $("#login_form").serializeArray(), json={}; $("#action_submit").load("login_submit.php", query, function(data){ if (data==1){ if(fund_id) { location.href="bayar_kariah_list_selected.php?kk_fund_id="+fund_id; } else { if (url) { location.href=url; } else { location.href="akaun_saya.php?org_id="+org_id; } } } else { Swal.fire('Wrong Password Entered','You have entered an incorrect password. Please try again.',"error"); } }) } function login_fb(){ FB.login(function(response) { if (response.status === 'connected') { // Logged into your app and Facebook. FB.api('/me', {fields: 'id,name,email,picture'}, function(response) { if (check_fb_id(response.id)>0){ location.href="akaun_saya.php"; }else{ Swal.fire('Not registered yet','You have never registered before. Please register first.',"error"); } }); } else { // The person is not logged into this app or we are unable to tell. Swal.fire('Not registered yet','You have never registered before. Please register first.',"error"); } },{scope: 'email'}); } function connect_fb(){ FB.login(function(response) { if (response.status === 'connected') { // Logged into your app and Facebook. FB.api('/me', {fields: 'id,name,email,picture'}, function(response) { var peserta_login_id = $("#peserta_login_id").val(); if (connect_peserta_fb(response.id,peserta_login_id,response.picture.data.url)>0){ location.href="akaun_saya.php"; } }); } else { // The person is not logged into this app or we are unable to tell. } },{scope: 'email'}); } function sign_up_fb(){ FB.login(function(response) { if (response.status === 'connected') { // Logged into your app and Facebook. FB.api('/me', {fields: 'id,name,email,picture'}, function(response) { $("#peserta_nama").val(response.name); $("#peserta_email").val(response.email); $("#peserta_fb_id").val(response.id); $("#peserta_fb_picture").val(response.picture.data.url); $("#sign_up_result").html("
The system has obtained your information from facebook. However, you will need to complete other information.
Not you? Logout of Facebook
") $("#password_div").slideUp(); $("#peserta_mykad_password2").removeAttr("required").removeClass("required").attr("disabled",true).val(""); $("#peserta_mykad_password").removeAttr("required").removeClass("required").attr("disabled",true).val(""); //console.log(JSON.stringify(response)); //alert(JSON.stringify(response)); }); } else { // The person is not logged into this app or we are unable to tell. } },{scope: 'email'}); } function logout_fb(){ FB.logout(function(response) { $("#sign_up_result").html("
You have been logged out. Please log in again on facebook
"); $(".form-control").val(""); animateCSS('#fb_button', 'tada', function() { animateCSS('#fb_button', 'bounce', function() { animateCSS('#fb_button', 'heartBeat', function() { // Do something after animation }) }) }) }); } function whoami(){ FB.api('/me?fields=id,name,email,birthday', function(response) { console.log(JSON.stringify(response)); alert(JSON.stringify(response)); }); } function animateCSS(element, animationName, callback) { const node = document.querySelector(element) node.classList.add('animated', animationName) function handleAnimationEnd() { node.classList.remove('animated', animationName) node.removeEventListener('animationend', handleAnimationEnd) if (typeof callback === 'function') callback() } node.addEventListener('animationend', handleAnimationEnd) } function daftar_kariah_submit(){ var query = $("#daftar_kariah_form").serializeArray(), json={}; $("#action_submit").load("daftar_kariah.php", query, function(data){ $("#daftar_kariah_div").slideUp(); $("#action_result").html("
Thank you. We will contact you if the mosque / surau / organization you have registered has become a member of the Death Benefit System
You also can register mosques / suraus / other organizations
").slideDown(); }) } function daftar_kariah_lain(){ $("#daftar_kariah_div").slideDown(); $("#action_result").slideUp(); $("#daftar_kariah_form .reset").val(""); } function get_poskod_data(position){ var lat = (position.coords.latitude).toFixed(7); var long = (position.coords.longitude).toFixed(7); $.getJSON('https://maps.googleapis.com/maps/api/geocode/json?latlng='+lat+','+long+'&key=AIzaSyBUvK1P8VvN5QOw7ALgDPsOXHxE3oT248Q', function(data){ //Swal.fire("Pengesanan Lokasi","Sistem telah mengesan anda berada di poskod "+data.results[4].address_components[0].short_name,"error"); Swal.fire({ title: 'Location Detection', //text: "Sistem telah mengesan anda berada di poskod "+data.results[4].address_components[0].short_name, text: 'The System Has Detected That You Are At The Coordinate ' +lat+","+long, imageUrl: "../../assets/images/map.png", imageWidth: 100 }) //alert(data.results[4].address_components[0].short_name); $("#pilih_kariah_div_top").load("pilih_kariah_list.php?allow_poskod_search=1&latitude="+lat+"&longitude="+long); }); } function get_poskod(){ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(get_poskod_data, GEOdeclined2); }else{ Swal.fire('Thank you. We will contact you if the mosque / surau / organization you have registered has become a member of the Death Benefit System','Your browser does not allow location to be detected',"danger"); //document.getElementById('geo').innerHTML = 'Your browser sucks. Upgrade it.'; } } function pilih_kariah_peserta(kariah_id,peserta_id,kariah_tahun){ $("#action_submit").load("pilih_kariah_submit.php", {"MM_pilih_kariah":1,"kariah_id":kariah_id,"peserta_id":peserta_id,"kariah_tahun":kariah_tahun}, function(){ //Swal.fire("Berjaya","Anda telah ditetapkan kepada kariah yang dipilih","success"); location.href="bayar_kariah_peserta.php?kariah_id="+kariah_id+"&peserta_id="+peserta_id+"&kariah_tahun="+kariah_tahun; }) } function daftar_kariah_nopeserta(kariah_id){ location.href="daftar.php?kariah_id="+kariah_id; } function bayar_kariah_peserta(kariah_fund_id,kariah_id,peserta_id,fiscal_year,payment_type){ // must check if peserta_id is already a member of the kariah // if yes, allow renewal. otherwise, only allow new registration if (check_payment_is_allowed_for_peserta(kariah_fund_id, kariah_id, peserta_id)==0) { Swal.fire('Pending Membership Approval','Your membership must be approved by an admin first before you can pay.',"error"); return false; } else { // read fund value var fund_value = $("#fund_value_"+kariah_fund_id).val(); console.log(fund_value); fund_value = fund_value ?? 0; console.log(fund_value); if(payment_type==1){ if (fund_value=="0.00" || fund_value=='' || fund_value=='0' || fund_value===null || fund_value=== undefined){ // check fund value.. if 0, ask for real value if (check_fund_value(kariah_fund_id)=="0"){ Swal.fire({ title: 'Value Must Be Entered', html: 'The value entered must be more or equal to RM2.00', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, cancelButtonText: 'Cancel', confirmButtonText: 'Save', showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { var fixed_value = parseFloat(result.value).toFixed(2); if (fixed_value<2) { Swal.fire('Value Must Be More Than RM2.00','Please enter a value greater than or equal to RM2.00',"warning"); $(".price-note").show(); } else { $("#fund_"+kariah_fund_id).html(fixed_value); $("#fund_value_"+kariah_fund_id).val(fixed_value); $("#fund_value_rm_"+kariah_fund_id).text(fixed_value); $(".price-note").show(); $("#real_value").html('Update') } } }); } else if (check_fund_value(kariah_fund_id)=="-1"){ Swal.fire('Error','The selected product/service does not exist',"error"); } else { location.href="bayar_kariah_list_selected.php?kk_fund_id="+kariah_fund_id+'&peserta_id='+peserta_id+'&kariah_tahun='+fiscal_year+'&kariah_id='+kariah_id; } } else { location.href="bayar_kariah_list_selected.php?kk_fund_id="+kariah_fund_id+'&peserta_id='+peserta_id+'&kariah_tahun='+fiscal_year+'&kariah_id='+kariah_id+'&fund_value='+fund_value; } }else{ $("#action_submit").load("kemaskini_tanpa_bayaran.php?kariah_fund_id="+kariah_fund_id+"&kariah_id="+kariah_id+"&peserta_id="+peserta_id+"&fiscal_year="+fiscal_year, function(data){ if (data==1){ Swal.fire({ title: 'Success', text: 'You successfully become an official member', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); location.href="akaun_saya.php"; } else if (data==2){ Swal.fire({ title: 'Success', text: 'You become an official member', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); } else { Swal.fire({ title: 'Technical Problem', text: 'Please try again', icon: 'warning', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); } }); } } } function update_fund_value(kariah_fund_id,kariah_id,peserta_id,fiscal_year){ // read fund value var fund_value = $("#fund_value_"+kariah_fund_id).val(); Swal.fire({ title: 'Please Enter a Value', html: 'The value entered must be more or equal to RM2.00', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, cancelButtonText: 'Cancel', confirmButtonText: 'Save', showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { var fixed_value = parseFloat(result.value).toFixed(2); if (fixed_value<2) { Swal.fire('Value Must Be More Than RM2.00','Please enter a value greater than or equal to RM2.00',"warning"); $(".price-note").show(); } else { $("#fund_"+kariah_fund_id).html(fixed_value); $("#fund_value_"+kariah_fund_id).val(fixed_value); $(".price-note").show(); $("#real_value").html('Update') } } }) } function payment_confirm() { var query = $("#bayar_kariah_selected_form").serializeArray(); $.ajax({ type: "POST", url: "bayar_kariah_register.php", data: query, dataType: "json", success: function(res) { console.log("Server Response:", res); if (res.status==1) { if (res && res.order_id && res.account_id && res.kariah_id) { register_pd(res.order_id, res.account_id, res.kariah_id, function() { // Only submit the form after register_pd finishes $("#bayar_kariah_selected_form").attr("action", "https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); }); } else { console.error("Unexpected response:", res); } } else { var d = $("#bayar_kariah_selected_form #detail").val(); var a = $("#bayar_kariah_selected_form #amount").val(); $.when(reorder_id(res.order_id,d,a)).done(function(){ $("#bayar_kariah_selected_form").attr("action","https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); //alert(data); }); } }, error: function(xhr, status, error) { console.error("AJAX error:", status, error); } }); } function payment_manual() { var query = $("#bayar_kariah_selected_form").serializeArray(); // Push manual_payment = 1 into query query.push({ name: "manual_payment", value: 1 }); // Create a temporary form for POST redirection var form = $('
', { method: 'POST', action: 'bayar_kariah_list_manual.php' }); // Append all form data as hidden inputs query.forEach(function (item) { form.append($('', { type: 'hidden', name: item.name, value: item.value })); }); // Append form to body and submit $('body').append(form); form.submit(); } function payment_manual_submit() { var query = $("#bayar_kariah_selected_form").serializeArray(); // Push manual_payment = 1 into query query.push({ name: "manual_payment", value: 1 }); $.ajax({ type: "POST", url: "bayar_kariah_manual_submit.php", data: query, dataType: "json", success: function(res) { console.log("Server Response:", res); if (res.status==1) { if (res && res.order_id && res.account_id && res.kariah_id) { register_pd(res.order_id, res.account_id, res.kariah_id, function() { // Only submit the form after register_pd finishes $("#bayar_kariah_selected_form").attr("action", "https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); }); } else { console.error("Unexpected response:", res); } } }, error: function(xhr, status, error) { console.error("AJAX error:", status, error); } }); } function register_pd(invoice_no, account_id, kariah_id, callback) { $.ajax({ url: 'https://authenteqa.com/register_pd.php', type: 'POST', data: { invoice_no: invoice_no, account_id: account_id, kariah_id: kariah_id }, dataType: 'text', // or 'json' if the response is JSON success: function(response) { console.log("register_pd response:", response); if (typeof callback === "function") { callback(); // Call the next step only after success } }, error: function(xhr, status, error) { console.error("register_pd error:", status, error); console.log(xhr.responseText); } }); } // 20210421 - izzat add bayaran brgan function bayar_brgan_submit(){ //alert('test');return false; $("#email").val($("#peserta_email").val()); $("#buyer_email").val($("#peserta_email").val()); $("#name").val($("#peserta_nama").val()); $("#buyer_name").val($("#peserta_nama").val()); $("#phone").val($("#peserta_notel_bimbit").val()); //alert($("#event_payment_form #order_id").val()); var query = $("#bayar_brgan_selected_form").serializeArray(), json={}; var s = $("#bayar_brgan_selected_form #s").val(); var d = $("#bayar_brgan_selected_form #detail").val(); var a = $("#bayar_brgan_selected_form #amount").val(); var hashed = $("#hashed").val(); query.push({"name":"hash","value": hashed}); $("#action_submit").load("bayar_brgan_submit.php", query, function(data){ // if data == 1, then proceed to payment gateway. otherwise, update orderid with value given and then baru proceed to payment gateway console.log(data); d = JSON.parse(data); $("#peserta_id").val(d.peserta_id); $("#hashed").attr("id","hash"); $("#hash").attr("name","hash"); //alert(data); if (d.status_val==1){ $("#bayar_brgan_selected_form").attr("action","https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_brgan_selected_form").submit(); } else { Swal.fire('A problem occurred','Please try again',"error"); } }); } //10092020 - payment without login first function payment_confirm_first(){ var s = $("#bayar_kariah_selected_form #s").val(); var d = $("#bayar_kariah_selected_form #detail").val(); var a = $("#bayar_kariah_selected_form #amount_input").val(); var a = parseFloat(a).toFixed(2); var o = $("#bayar_kariah_selected_form #order_id").val(); var hash = hash_pd(o, a, d); $("#bayar_kariah_selected_form #amount").val(a); $("#bayar_kariah_selected_form #hash").val(hash); var buyer_name = $("#bayar_kariah_selected_form #buyer_name").val(); var buyer_email = $("#bayar_kariah_selected_form #buyer_email").val(); var phone = $("#bayar_kariah_selected_form #phone").val(); var query = $("#bayar_kariah_selected_form").serializeArray(), json={}; if(buyer_name=="" || buyer_email=="" || phone==""){ Swal.fire('Incomplete','Please Complete The Required Information',"error"); }else{ $("#action_submit").load("bayar_kariah_register_unregistered.php", query, function(data){ // if data == 1, then proceed to payment gateway. otherwise, update orderid with value given and then baru proceed to payment gateway if (data==1){ $("#bayar_kariah_selected_form").attr("action","https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); } else if(data==2){ //Swal.fire("Berjaya","Sistem telah mencipta akaun untuk anda bagi organisasi ini. Sila ke halaman seterusnya untuk pembayaran.","success").then(() => { $("#bayar_kariah_selected_form").attr("action","https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); //}); } else if(data==3){ //Swal.fire("Berjaya","Sistem telah mencipta akaun untuk anda bagi organisasi ini. Sila ke halaman seterusnya untuk pembayaran.","success").then(() => { $("#bayar_kariah_selected_form").attr("action","https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); //}); } else { //alert(data); $.when(reorder_id(data,d,a)).done(function(){ $("#bayar_kariah_selected_form").attr("action","https://www.qlicknpay.com/merchant/api/v2/receiver"); $("#bayar_kariah_selected_form").submit(); //alert(data); }); } }); } } //10092020 - until here payment without login first function reorder_id(order_id,d,a){ var hash = hash_pd(order_id, a, d); $("#bayar_kariah_selected_form #order_id").val(order_id); $("#bayar_kariah_selected_form #invoice").val(order_id); $("#bayar_kariah_selected_form #hash").val(hash); //$("#hash").val(hash); } function hash_pd(order_id, amount, detail){ var return_value = $.ajax({ url: 'hash_pd.php', data: {"order_id":order_id,"amount":amount,"detail":detail}, async: false }).responseText; return return_value; } function check_fb_id(fb_id){ var return_value = $.ajax({ url: 'check_fb_id.php', data: {"fb_id":fb_id}, async: false }).responseText; return return_value; } function connect_peserta_fb(fb_id,peserta_id,picture){ var return_value = $.ajax({ url: 'connect_peserta_fb.php', data: {"fb_id":fb_id,"peserta_id":peserta_id,"picture":picture}, async: false }).responseText; return return_value; } /** * Given a single jQuery element with [data-custom], * return an array of its three serialized entries. */ function serializeOneCustomField($el) { var name = $el.attr('name'); var $group = $('[name="' + name + '"]'); var order = $group.data('custom-order'); var value; if ($group.is(':radio')) { value = $group.filter(':checked').val() || ''; } else if ($group.is(':checkbox')) { value = $group.filter(':checked').map(function(){ return this.value; }).get(); } else if ($group.is('select[multiple]')) { var vals = $group.find('option:selected').map(function(){ return this.value; }).get(); value = vals.map(JSON.stringify).join(','); } else { value = $group.val() || ''; } return [ { name: 'kk_peserta_custom_value[]', value: value }, { name: 'kk_peserta_custom_name[]', value: name }, { name: 'kk_peserta_custom_order[]', value: order } ]; } /** * Loop over every unique [data-custom] name, * call serializeOneCustomField, and flatten the results. */ function serializeCustomFields() { var seen = {}; var result = []; $('*[data-custom]').each(function() { var name = this.name; if (seen[name]) return; seen[name] = true; result = result.concat( serializeOneCustomField( $(this) ) ); }); return result; } function akaun_saya_submit(){ // First send your main form to get d.status_val back var query = $("#akaun_saya_form").serializeArray(); $("#action_submit").load("akaun_saya_submit.php", query, function(data){ var d = JSON.parse(data); // —— Replace the old manual each() bit with this: var serialized = serializeCustomFields(); // then tack on your extra fixed params serialized.push({ name: "kk_peserta_custom_peserta_id", value: d.peserta_id }); serialized.push({ name: "kk_peserta_custom_org_id", value: $("#peserta_org_id").val() }); serialized.push({ name: "MM_update", value: "kemaskini_submit" }); // now send everything off $.ajax({ type: "POST", url: "kemaskini_peserta_submit.php", data: serialized, dataType: "json", async: false, complete: function(){ // optional post-complete logic } }); // finally, show success if applicable if (d.complete == 1){ Swal.fire({ title: 'Your Information Updated', text: 'Your personal information has been updated', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }); } }); } function batal_kariah(peserta_kariah_id){ Swal.fire({ title: 'Are You Sure?', text: 'You want to cancel your registration in the selected organization', icon: 'warning', showCancelButton: true, confirmButtonColor: '#258', cancelButtonColor: '#f00', cancelButtonText: 'No', confirmButtonText: 'Yes! Confirm' }).then((result) => { if (result.value) { $("#kariah_list_div").load("kariah_peserta.php", {"MM_batal":"batal_kariah","peserta_kariah_id":peserta_kariah_id}, function(){ }) } }) } function sendmail(peserta_id,order_id,email_template_subject){ var return_value = $.ajax({ url: 'sendmail.php', data: {"order_id":order_id,"peserta_id":peserta_id,"email_template_subject":email_template_subject}, async: false }).responseText; return return_value; } function sendmailer(peserta_id,email_template_subject){ var return_value = $.ajax({ url: 'sendmailer.php', data: {"peserta_id":peserta_id,"email_template_subject":email_template_subject}, method:'post', async: false }).responseText; return return_value; } function sendmailer_data(kariah_id,peserta_id,email_template_subject){ var return_value = $.ajax({ url: 'sendmailer_data.php', data: {"kariah_id":kariah_id,"peserta_id":peserta_id,"email_template_subject":email_template_subject}, method:'post', async: false }).responseText; return return_value; } function sendmailer_data_async(kariah_id,peserta_id,email_template_subject){ var return_value = $.ajax({ url: 'sendmailer_data.php', data: {"kariah_id":kariah_id,"peserta_id":peserta_id,"email_template_subject":email_template_subject}, method:'post', async: true }).responseText; return return_value; } //fungsi untuk buka page hebahan---- function open_content(content_id){ var dialog = BootstrapDialog.show({ title: 'Announcements', message: $('
').load('content_hebahan.php?hebahan_id='+content_id, function() { }), buttons: [{ id: 'btn-popup-fullscreen-1', icon: 'fa fa-expand', label: 'Full Screen', cssClass: 'btn-primary btn-fullscreen ', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen-1").show(); $("#btn-popup-fullscreen-1").hide(); } },{ id: 'btn-popup-widescreen-1', icon: 'fa fa-compress', label: 'Normal Screen', cssClass: 'btn-info btn-widescreen ', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-1").show(); $("#btn-popup-widescreen-1").hide(); } },{ id: 'view-popup-close-1', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-danger float-left ', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','88vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); $("#btn-popup-fullscreen-1").show(); $("#btn-popup-widescreen-1").hide(); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } //sampai di sini fungsi buka page hebahan---- //20201012 - fungsi untuk sharable link hebahan function share_link_hebahan(id_kk_content) { var fullLink = document.createElement('input'); document.body.appendChild(fullLink); // Get the current domain using window.location var currentDomain = window.location.protocol + "//" + window.location.host; // Create the full link fullLink.value = currentDomain + "/peserta/hebahan_page.php?content_id=" + id_kk_content; // Select and copy the full link fullLink.select(); document.execCommand("copy", false); // Remove the input field fullLink.remove(); // Show the success message using Swal.fire Swal.fire('Link copied successfully', fullLink.value, "success"); } //20201012 - until here fungsi untuk sharable link hebahan function pilih_kariah_poskod(allow_poskod_search){ var query = $("#enter_poskod_form").serializeArray(),json={}; $("#pilih_kariah_div_top").load("pilih_kariah_list.php?allow_poskod_search="+allow_poskod_search, query, function(){}).html(" Please wait while the system searches for organization information"); $("#geodeclined").fadeIn(); } function first_time_login(kariah_id){ var dialog = BootstrapDialog.show({ title: 'First Time Login', message: $('
').load('forgot_password.php?kariah_id='+kariah_id, function() { }), buttons: [{ id: 'btn-get-pwd-2', icon: 'fa fa-lock-open', label: 'Email Me My New Password', cssClass: 'btn-primary float-right ', autospin: true, action: function(dialog){ lupa_katalaluan_submit_first_time(dialog); } },{ id: 'btn-new-reg-2', icon: 'fa fa-user-plus', label: 'New Registration', cssClass: 'btn-secondary float-right ', autospin: true, action: function(dialog){ window.location.href = '/peserta/daftar.php?kariah_id='+kariah_id; } },{ id: 'view-popup-close-2', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-danger float-left ', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','65vh'); $('.modal-body').css('height','auto'); $('.modal-body').css('max-height','55vh'); $('.modal-body').css("overflow-y","scroll"); $("#btn-popup-widescreen-2").hide(); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function lupa_katalaluan(kariah_id){ var dialog = BootstrapDialog.show({ title: 'Forgot Password', message: $('
').load('forgot_password.php?kariah_id='+kariah_id, function() { }), buttons: [{ id: 'btn-get-pwd-2', icon: 'fa fa-lock-open', label: 'Reset Password', cssClass: 'btn-primary float-right ', autospin: true, action: function(dialog){ lupa_katalaluan_submit(dialog); } },{ id: 'view-popup-close-2', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-danger float-left ', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','65vh'); $('.modal-body').css('height','auto'); $('.modal-body').css('max-height','55vh'); $('.modal-body').css("overflow-y","scroll"); $("#btn-popup-widescreen-2").hide(); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function lupa_katalaluan_submit(dialog){ // check if record sent exists var u = $("#forgot_password_form #forgot_mykad").val(); var e = $("#forgot_password_form #forgot_email").val(); var org_id = $("#forgot_password_form #kariah_id").val(); var new_e = $("#forgot_password_form #new_email").val(); var got_new_e = $("#email_changer").css("visibility") != "hidden"; if (u!=''&&e!='' && (got_new_e ? new_e!='' : 1)){ // check email validity if ((isEmail(e) || e.startsWith('[MISSING EMAIL]')) && (got_new_e ? isEmail(new_e) : 1)){ var user_check = check_user(u,e,new_e); if (user_check ==1){ // Show SweetAlert waiting message Swal.fire({ title: 'Please Wait', text: 'We are changing your password', icon: 'info', allowOutsideClick: false, didOpen: () => { Swal.showLoading(); // Show loading animation } }); var query = $("#forgot_password_form").serializeArray(), json={}; var return_value = $.ajax({ url: 'lupa_katalaluan_submit.php', data: query, method: 'post', async: true, success:function(data){ data = parseInt(data); if (data==1){ Swal.fire({ title: 'New Password Sent', text: 'The system has sent you a new password via email. Please check your email including Spam box', icon: 'success', showCancelButton: false, confirmButtonText: 'OK', confirmButtonColor: '#258' }).then((result) => { //$("#register_form_submit").html("Register"); if (result.value) { location.href="../peserta/login.php?org_id="+org_id; } }) /*Swal.fire({ title: 'New Password Sent', text: 'The system has sent you a new password via email. Please check your email including Spam box', icon: 'success' }).then((result) => { //console.log(result); if (result.value==true) { // Redirect to login.php when "OK" is clicked window.location.href = 'login.php'; } }); dialog.close();*/ } else if(data===0) { Swal.fire('Record not found','The system did not find your record based on the information entered. Please try again.',"error"); } else if(data==-1) { Swal.fire('Email Error','Your email is not in the correct format. Please correct first.',"error"); } else if (data===-2) { Swal.fire( 'Missing IC Number', 'Your email is found in the database, but we do not have your IC No in our record. Please enter your full name (as per IC) or mobile number instead.', 'error' ); } else if (data===-3) { Swal.fire( 'Missing Phone Number', 'Your email is found in the database, but we do not have your phone number in our record. Please enter your full name (as per IC) or MyKad number instead.', 'error' ); } else { Swal.fire('Unknown Error',data,"error"); } //Swal.close(); // Close the waiting alert } }).responseText; } else if(user_check == -2) { Swal.fire({ title: 'Email Already Exists!', text: 'Sorry, email already used', icon: 'warning', showCancelButton: false, confirmButtonText: 'OK', confirmButtonColor: '#258', }) } else if (user_check==-3) { Swal.fire( 'Missing IC Number', 'Your email is found in the database, but we do not have your IC No in our record. Please enter your full name (as per IC) or mobile number instead.', 'error' ); } else if (user_check==-4) { Swal.fire( 'Missing Phone Number', 'Your email is found in the database, but we do not have your phone number in our record. Please enter your full name (as per IC) or MyKad number instead.', 'error' ); }else { swal_no_rec_found_reg_new(); } } else { Swal.fire('Email Error','Your email is not in the correct format. Please correct first.',"error"); } } else { Swal.fire('Error','You must enter both the Identity Card No. and Email',"error"); } //return return_value; } function lupa_katalaluan_submit_first_time(dialog){ // check if record sent exists var u = $("#forgot_password_form #forgot_mykad").val(); var e = $("#forgot_password_form #forgot_email").val(); var org_id = $("#forgot_password_form #kariah_id").val(); var new_e = $("#forgot_password_form #new_email").val(); var got_new_e = $("#email_changer").css("visibility") != "hidden"; if (u!=''&&e!='' && (got_new_e ? new_e!='' : 1)){ // check email validity if ((isEmail(e) || e.startsWith('[MISSING EMAIL]')) && (got_new_e ? isEmail(new_e) : 1)){ var user_check = check_user(u,e,new_e); if (user_check ==1){ // Show SweetAlert waiting message Swal.fire({ title: 'Please Wait', text: 'We are changing your password', icon: 'info', allowOutsideClick: false, didOpen: () => { Swal.showLoading(); // Show loading animation } }); var query = $("#forgot_password_form").serializeArray(), json={}; var return_value = $.ajax({ url: 'lupa_katalaluan_submit.php?first_time=1', data: query, method: 'post', async: true, success:function(data){ data = parseInt(data); if (data==1){ Swal.fire({ title: 'New Password Sent', text: 'The system has sent you a new password via email. Please check your email including Spam box', icon: 'success', showCancelButton: false, confirmButtonText: 'OK', confirmButtonColor: '#258' }).then((result) => { //$("#register_form_submit").html("Register"); if (result.value) { location.href="../peserta/login.php?org_id="+org_id; } }) /*Swal.fire({ title: 'New Password Sent', text: 'The system has sent you a new password via email. Please check your email including Spam box', icon: 'success' }).then((result) => { //console.log(result); if (result.value==true) { // Redirect to login.php when "OK" is clicked window.location.href = 'login.php'; } }); dialog.close();*/ } else if(data===0) { Swal.fire('Record not found','The system did not find your record based on the information entered. Please try again.',"error"); } else if(data==-1) { Swal.fire('Email Error','Your email is not in the correct format. Please correct first.',"error"); } else if (data===-2) { Swal.fire( 'Missing IC Number', 'Your email is found in the database, but we do not have your IC No in our record. Please enter your full name (as per IC) or mobile number instead.', 'error' ); } else if (data===-3) { Swal.fire( 'Missing Phone Number', 'Your email is found in the database, but we do not have your phone number in our record. Please enter your full name (as per IC) or MyKad number instead.', 'error' ); } else { Swal.fire('Unknown Error',data,"error"); } //Swal.close(); // Close the waiting alert } }).responseText; } else if(user_check == -2) { Swal.fire({ title: 'Email Already Exists!', text: 'Sorry, email already used', icon: 'warning', showCancelButton: false, confirmButtonText: 'OK', confirmButtonColor: '#258', }) } else if (user_check==-3) { Swal.fire( 'Missing IC Number', 'Your email is found in the database, but we do not have your IC No in our record. Please enter your full name (as per IC) or mobile number instead.', 'error' ); } else if (user_check==-4) { Swal.fire( 'Missing Phone Number', 'Your email is found in the database, but we do not have your phone number in our record. Please enter your full name (as per IC) or MyKad number instead.', 'error' ); } else { swal_no_rec_found_reg_new(); } } else { Swal.fire('Email Error','Your email is not in the correct format. Please correct first.',"error"); } } else { Swal.fire('Error','You must enter both the Identity Card No. and Email',"error"); } //return return_value; } function check_user(){ var query = $("#forgot_password_form").serializeArray(), json={}; var return_value = $.ajax({ url: 'check_user.php', data: query, method: 'post', async: false, }).responseText; return return_value; } function tukar_password(peserta_id){ var dialog = BootstrapDialog.show({ title: 'Change Password', message: $('
').load('tukar_password.php?peserta_id='+peserta_id, function() { }), buttons: [{ id: 'btn-get-pwd-3', icon: 'fa fa-lock', label: 'Set Password', cssClass: 'btn-primary float-right ', autospin: false, action: function(dialog){ tukar_password_submit(peserta_id,dialog); } },{ id: 'view-popup-close-3', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-danger float-left ', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','50vh'); $('.modal-body').css('max-height','40vh'); $('.modal-body').css("overflow-y","scroll"); $("#btn-popup-widescreen-3").hide(); $('#peserta_mykad_password').strengthMeter('progressBar', { container: $('#password-strength-meter1') }); $('#peserta_mykad_password2').strengthMeter('progressBar', { container: $('#password-strength-meter2') }); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function tukar_password_submit(peserta_id,dialog){ // check if record sent exists var p1 = $("#tukar_password_form #peserta_mykad_password").val(); var p2 = $("#tukar_password_form #peserta_mykad_password2").val(); if (p1!=p2){ Swal.fire('Error','Password Is Not The Same',"error"); } else { var query = $("#tukar_password_form").serializeArray(), json={}; var return_value = $.ajax({ url: 'tukar_password_submit.php', data: query, method: 'post', async: false, success:function(data){ if (data==1){ Swal.fire('Change Password','You have successfully changed your password. Please use the new password when you sign in again',"success"); dialog.close(); } else { } } }).responseText; } //return return_value; } // function print_payment_detail(id_kk_peserta_kariah){ window.open('print_receipt.php?bayar_id='+id_kk_peserta_kariah); } function print_payment_detail_by_orderid(bayar_id){ window.open('print_receipt_by_orderid.php?bayar_id='+bayar_id); } function print_payment_detail_by_id(bayar_id){ window.open('print_receipt_by_id.php?bayar_id='+bayar_id); } function print_payment_detail_by_id_org(bayar_id,org_id){ window.open('print_receipt_by_id.php?bayar_id='+bayar_id+'&org_id='+org_id); } function print_payment_detail_by_id_org_non_membership(bayar_id,org_id){ window.open('print_receipt_by_id_non_membership.php?bayar_id='+bayar_id+'&org_id='+org_id); } function register_save_custom_data(peserta_id, peserta_kariah_id) { // build your custom-fields payload in one go: var serialized = serializeCustomFields(); serialized.push({ name: "kk_peserta_custom_peserta_id", value: peserta_id }); serialized.push({ name: "kk_peserta_custom_org_id", value: peserta_kariah_id }); serialized.push({ name: "MM_insert", value: "daftar_submit" }); // send custom data off $.ajax({ type: "POST", url: "kemaskini_peserta_submit.php", data: serialized, dataType: "json", async: false, complete: function(){ } }); } // function register_peserta_form_submit(fund_id=null){ $("#register_form_submit").html('  Processing...'); // check for fb_id. if exist, no need password var peserta_kariah_id = $("#peserta_kariah_id").val() || get_org_id(); var fb_id = $("#peserta_fb_id").val(); var google_id = $("#peserta_google_id").val(); if(peserta_kariah_id==1){ //using kariah maya.my - no longer allowed.. must register via proper org ID Swal.fire({ title: 'Registration Blocked', text: 'You have not selected an organization to register. Registration cannot proceed.', icon: 'error', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { }) return; } else { // check for FB/google registration first if(fb_id=="" && google_id =="") { // password required // processing registration without FB and google var pwd1 =$("#peserta_mykad_password").val(); var pwd2 =$("#peserta_mykad_password2").val(); if (pwd1!=pwd2){ Swal.fire('Error','Password Is Not The Same',"error"); return; } } // baca value file selected.. kalau 0, proceed macam biasa.. // kalau 1, kena run uploadifive dulu, lepas tu baru proceed mcm biasa // this is hardcoded.. kena tukar to be dynamic.. var file_selected = $("#file_selected").val(); if (file_selected == 1){ $('#sijil_akademik_uploadifive').uploadifive('upload'); } daftar_submit_peribadi(); } } function check_fund_value(fund_id){ var return_value = $.ajax({ url: 'check_fund_value.php', data: {"fund_id":fund_id}, async: false }).responseText; return return_value; } function lihat_fail(file_id){ var return_value = $.ajax({ url: 'get_filename_peserta.php', data: {"file_id":file_id}, async: false }).responseText; openpdf_peserta(return_value); } function openpdf(filename) { //var title_color = Cookies.get("color-title"); var pdffile = (filename); var dialog = BootstrapDialog.show({ title: 'Lihat Dokumen', size: BootstrapDialog.SIZE_WIDE , message: function(dialog) { var $message = $('
'); var pageToLoad = dialog.getData('pageToLoad'); $message.load(pageToLoad); return $message; }, closable: false, buttons: [{ id: 'btn-popup-fullscreen-4', icon: 'fa fa-expand', label: ' Full Screen', cssClass: 'btn-primary btn-fullscreen float-right', autospin: false, action: function(dialog){ //$(".modal .bootstrap-dialog").addClass("fullscreen"); dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen").show(); $("#btn-popup-fullscreen").hide(); } },{ id: 'btn-popup-widescreen-4', icon: 'fa fa-compress', label: ' Normal Screen', cssClass: 'btn-success btn-widescreen float-right ', autospin: false, action: function(dialog){ //$(".modal .bootstrap-dialog").addClass("fullscreen"); dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-4").show(); $("#btn-popup-widescreen-4").hide(); } },{ id: 'view-popup-close-4', icon: 'fas fa-times-circle', label: ' Close', cssClass: 'btn-danger', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $("#btn-popup-fullscreen-4").show(); $("#btn-popup-widescreen-4").hide(); //$('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','85vh'); //$('.modal-content').css('height','90vh'); //$('.modal-body').css('max-height','80vh'); //$('.modal-body').css('max-height','70vh'); $('.modal-body').css('max-height','85vh'); $("object#objectfile").css('height','73vh'); $('.modal-body').css('overflow-y','scroll'); }, data: { 'pageToLoad': 'iframe_peserta.php?filename='+pdffile } }); //dialog.getModalHeader().css('background-color', title_color); } function openpdf_file_folder(filename,folder) { //var title_color = Cookies.get("color-title"); var pdffile = (filename); var dialog = BootstrapDialog.show({ title: 'Lihat Dokumen', size: BootstrapDialog.SIZE_WIDE , message: function(dialog) { var $message = $('
'); var pageToLoad = dialog.getData('pageToLoad'); $message.load(pageToLoad); return $message; }, closable: false, buttons: [{ id: 'btn-popup-fullscreen-5', icon: 'fa fa-expand', label: ' Full Screen', cssClass: 'btn-primary btn-fullscreen float-right', autospin: false, action: function(dialog){ //$(".modal .bootstrap-dialog").addClass("fullscreen"); dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen").show(); $("#btn-popup-fullscreen").hide(); } },{ id: 'btn-popup-widescreen-5', icon: 'fa fa-compress', label: ' Normal Screen', cssClass: 'btn-success btn-widescreen float-right ', autospin: false, action: function(dialog){ //$(".modal .bootstrap-dialog").addClass("fullscreen"); dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-5").show(); $("#btn-popup-widescreen-5").hide(); } },{ id: 'view-popup-close-5', icon: 'fas fa-times-circle', label: ' Close', cssClass: 'btn-danger', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $("#btn-popup-fullscreen-5").show(); $("#btn-popup-widescreen-5").hide(); //$('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','85vh'); //$('.modal-content').css('height','90vh'); //$('.modal-body').css('max-height','80vh'); //$('.modal-body').css('max-height','70vh'); $('.modal-body').css('max-height','85vh'); $("object#objectfile").css('height','73vh'); $('.modal-body').css('overflow-y','scroll'); }, data: { 'pageToLoad': 'iframe_file_folder.php?filename='+pdffile+'&folder='+folder } }); //dialog.getModalHeader().css('background-color', title_color); } function openpdf_peserta(filename) { //var title_color = Cookies.get("color-title"); var pdffile = (filename); var dialog = BootstrapDialog.show({ title: 'View Document', size: BootstrapDialog.SIZE_WIDE , message: function(dialog) { var $message = $('
'); var pageToLoad = dialog.getData('pageToLoad'); $message.load(pageToLoad); return $message; }, closable: false, buttons: [{ id: 'btn-popup-fullscreen-6', icon: 'fa fa-expand', label: ' Full Screen', cssClass: 'btn-primary btn-fullscreen float-right', autospin: false, action: function(dialog){ //$(".modal .bootstrap-dialog").addClass("fullscreen"); dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen").show(); $("#btn-popup-fullscreen").hide(); } },{ id: 'btn-popup-widescreen-6', icon: 'fa fa-compress', label: ' Normal Screen', cssClass: 'btn-success btn-widescreen float-right ', autospin: false, action: function(dialog){ //$(".modal .bootstrap-dialog").addClass("fullscreen"); dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-6").show(); $("#btn-popup-widescreen-6").hide(); } },{ id: 'view-popup-close-6', icon: 'fas fa-times-circle', label: ' Close', cssClass: 'btn-danger', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $("#btn-popup-fullscreen-6").show(); $("#btn-popup-widescreen-6").hide(); //$('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','85vh'); //$('.modal-content').css('height','90vh'); //$('.modal-body').css('max-height','80vh'); //$('.modal-body').css('max-height','70vh'); $('.modal-body').css('max-height','85vh'); $("object#objectfile").css('height','73vh'); $('.modal-body').css('overflow-y','scroll'); }, data: { 'pageToLoad': 'iframe_peserta.php?filename='+pdffile } }); //dialog.getModalHeader().css('background-color', title_color); } function padam_fail(id,type,peserta_id){ Swal.fire({ title: 'Are You Sure?', text: 'This action cannot be undone', icon: 'warning', showCancelButton: true, cancelButtonText: 'No', confirmButtonText: 'Yes', confirmButtonColor: '#258', cancelButtonColor: '#f00' }).then((result) => { $("#uploaded_"+type).load("uploads_file.php", {"MM_delete":"padam_fail","id":id,"file_type":type,"peserta_id":peserta_id}, function(){ notify('The file has been deleted',"success"); }) }) } function padam_fail_custom(id,type,peserta_id,maya_file_page_id){ Swal.fire({ title: 'Are You Sure?', text: 'This action cannot be undone', icon: 'warning', showCancelButton: true, cancelButtonText: 'No', confirmButtonText: 'Yes', confirmButtonColor: '#258', cancelButtonColor: '#f00' }).then((result) => { $("#uploaded_"+maya_file_page_id).load("uploads_file_custom.php", {"MM_delete":"padam_fail_custom","id":id,"file_type":type,"peserta_id":peserta_id,"maya_file_page_id":maya_file_page_id}, function(){ notify('The file has been deleted',"success"); }) }) } function whatsex_change() { $("input[name='kk_peserta_tanggungan_relationship']").change(function(){ whatsex(); }) } function whatsex(){ var value = $("input[name='kk_peserta_tanggungan_relationship']:checked").val(); //alert(value); if (value==2 || value==4 || value==5) { // isteri $("#kk_peserta_tanggungan_sex_1").prop("checked",true); $("#kk_peserta_tanggungan_sex_0").prop("checked",false); $("#kk_peserta_tanggungan_sex_0").prop("disabled",true); $("#kk_peserta_tanggungan_sex_1").prop("disabled",false); } else if (value == 3 || value == 6 || value == 7){ // suami $("#kk_peserta_tanggungan_sex_0").prop("checked",true); $("#kk_peserta_tanggungan_sex_1").prop("checked",false); $("#kk_peserta_tanggungan_sex_1").prop("disabled",true); $("#kk_peserta_tanggungan_sex_0").prop("disabled",false); } else { $("#kk_peserta_tanggungan_sex_1").prop("disabled",false); $("#kk_peserta_tanggungan_sex_0").prop("disabled",false); $("#kk_peserta_tanggungan_sex_0").prop("checked",true); } } function cetak_sijil(id_kk_sijil,peserta_id, kid,id_kk_sijil_peserta){ var dialog = BootstrapDialog.show({ title: 'Certificate Info', size: BootstrapDialog.SIZE_WIDE , message:$('
').load('cetak_sijil_iframe.php?id_kk_sijil='+id_kk_sijil+'&peserta_id='+peserta_id+'&kariah_id='+kid+'&id_kk_sijil_peserta='+id_kk_sijil_peserta), buttons: [{ id: 'btn-popup-fullscreen-1a', icon: 'fa fa-expand', label: 'Full Screen', cssClass: 'btn-primary btn-fullscreen hidden-xs', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen-1a").show(); $("#btn-popup-fullscreen-1a").hide(); $('.modal-content').css('height','90vh'); $('.modal-body').css('height','84vh'); $('.modal-footer').css('bottom','-5px').css('position','absolute'); $('.bootstrap-dialog-message iframe').css('height','74vh'); } },{ id: 'btn-popup-widescreen-1a', icon: 'fa fa-compress', label: 'Normal Screen', cssClass: 'btn-danger btn-widescreen hidden-xs', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-1a").show(); $("#btn-popup-widescreen-1a").hide(); $('.modal-content').css('height',''); $('.modal-body').css('height',''); $('.modal-footer').css('bottom','-5px').css('position',''); $('.bootstrap-dialog-message iframe').css('height',''); } },{ id: 'view-popup-close-1', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-warning', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $("#btn-popup-fullscreen-1a").show(); $("#btn-popup-widescreen-1a").hide(); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','90vh'); $('.modal-body').css('max-height','70vh'); $("#objectfile").css("height",'68vh'); } }); } function cetak_ecard(id_kk_kariah,peserta_id){ var dialog = BootstrapDialog.show({ title: 'ECard Info', size: BootstrapDialog.SIZE_WIDE , message:$('
').load('cetak_ecard_iframe.php?id_kk_kariah='+id_kk_kariah+'&peserta_id='+peserta_id), buttons: [{ id: 'btn-popup-fullscreen-1a', icon: 'fa fa-expand', label: 'Full Screen', cssClass: 'btn-primary btn-fullscreen hidden-xs', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen-1a").show(); $("#btn-popup-fullscreen-1a").hide(); $('.modal-content').css('height','90vh'); $('.modal-body').css('height','84vh'); $('.modal-footer').css('bottom','-5px').css('position','absolute'); $('.bootstrap-dialog-message iframe').css('height','74vh'); } },{ id: 'btn-popup-widescreen-1a', icon: 'fa fa-compress', label: 'Normal Screen', cssClass: 'btn-danger btn-widescreen hidden-xs', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-1a").show(); $("#btn-popup-widescreen-1a").hide(); $('.modal-content').css('height',''); $('.modal-body').css('height',''); $('.modal-footer').css('bottom','-5px').css('position',''); $('.bootstrap-dialog-message iframe').css('height',''); } },{ id: 'view-popup-close-1', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-warning', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $("#btn-popup-fullscreen-1a").show(); $("#btn-popup-widescreen-1a").hide(); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','90vh'); $('.modal-body').css('max-height','70vh'); $("#objectfile").css("height",'68vh'); } }); } function cetak_ecard2(id_kk_kariah,peserta_id,id_kk_ecard){ var dialog = BootstrapDialog.show({ title: 'ECard Info', size: BootstrapDialog.SIZE_WIDE , message:$('
').load('cetak_ecard_iframe.php?id_kk_kariah='+id_kk_kariah+'&peserta_id='+peserta_id+'&id_kk_ecard='+id_kk_ecard), buttons: [{ id: 'btn-popup-fullscreen-1a', icon: 'fa fa-expand', label: 'Full Screen', cssClass: 'btn-primary btn-fullscreen hidden-xs', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen-1a").show(); $("#btn-popup-fullscreen-1a").hide(); $('.modal-content').css('height','90vh'); $('.modal-body').css('height','84vh'); $('.modal-footer').css('bottom','-5px').css('position','absolute'); $('.bootstrap-dialog-message iframe').css('height','74vh'); } },{ id: 'btn-popup-widescreen-1a', icon: 'fa fa-compress', label: 'Normal Screen', cssClass: 'btn-danger btn-widescreen hidden-xs', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-1a").show(); $("#btn-popup-widescreen-1a").hide(); $('.modal-content').css('height',''); $('.modal-body').css('height',''); $('.modal-footer').css('bottom','-5px').css('position',''); $('.bootstrap-dialog-message iframe').css('height',''); } },{ id: 'view-popup-close-1', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-warning', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $("#btn-popup-fullscreen-1a").show(); $("#btn-popup-widescreen-1a").hide(); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','90vh'); $('.modal-body').css('max-height','70vh'); $("#objectfile").css("height",'68vh'); } }); } // 20210421 - izzat added for invoice function lihat_detail_invoice(id_kk_produk_bayar){ var dialog = BootstrapDialog.show({ title: 'Detail Invoice', spinicon: 'fa fa-spinner', closable: false, closeByBackdrop: false, closeByKeyboard: false, message: $('
').load('lihat_detail_invoice.php?id_kk_produk_bayar='+id_kk_produk_bayar, function() { }), buttons: [{ id: 'view-popup-close-7', icon: 'fa fa-times-circle', label: 'Close', cssClass: 'btn-danger float-left', autospin: true, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $(document).off('focusin.modal'); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','100vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function lihat_receipt_invoice(id_kk_produk_bayar){ window.open('print_receipt_invoice.php?id_kk_produk_bayar='+id_kk_produk_bayar); } // 20210421 - until here izzat added for invoice // 20210514 - izzat add for cart jquery // This button will increment the value $('[data-quantity="plus"]').click(function(e){ // Stop acting like a button console.log("plus"); e.preventDefault(); // Get the field name fieldName = $(this).attr('data-field'); idName = $(this).attr('data-id-desc'); priceName = $(this).attr('data-price'); console.log(fieldName); console.log(idName); // Get its current value var currentVal = parseInt($('input[name='+fieldName+']').val()); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=add"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); // If is not undefined if (!isNaN(currentVal)) { // Increment $('input[name='+fieldName+']').val(currentVal + 1); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=add"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); } else { // Otherwise put a 1 there $('input[name='+fieldName+']').val(1); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=add"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); } }); // This button will decrement the value till 0 $('[data-quantity="minus"]').click(function(e) { // Stop acting like a button e.preventDefault(); // Get the field name fieldName = $(this).attr('data-field'); idName = $(this).attr('data-id-desc'); priceName = $(this).attr('data-price'); // Get its current value var currentVal = parseInt($('input[name='+fieldName+']').val()); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=minus"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); // If it isn't undefined or its greater than 0 if (!isNaN(currentVal) && currentVal > 1) { // Decrement one $('input[name='+fieldName+']').val(currentVal - 1); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=minus"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); } else { // Otherwise put a 1 there $('input[name='+fieldName+']').val(1); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=minus"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); } }); // for the input $('[data-quantity="same"]').change(function(){ fieldName = $(this).attr('data-field'); idName = $(this).attr('data-id-desc'); priceName = $(this).attr('data-price'); var currentVal = parseInt($('input[name='+fieldName+']').val()); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+idName+"&price="+priceName+"&value="+currentVal+"&ope=same"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); }); function updateQuantity(id, price) { fieldName = $(this).attr('data-field'); idName = $(this).attr('data-id-desc'); var currentVal = parseInt($('input[name='+fieldName+']').val()); $("#price_produk_"+idName).load("produk_perubahan_harga.php?id_desc="+id+"&price="+price+"&value="+currentVal+"&ope=same"); $("#price_seluruh").load("produk_perubahan_seluruh.php"); } // 20210514 - until here add for cart jquery // 20210606 - NAF continue shopping cart functions function add_to_cart(){ var id_kk_produk_desc = $("#id_kk_produk_desc").val(); var cart_qty = $("#cart_qty").val(); $("#cart_id").load("add_to_cart.php?org_id=", {"id_kk_produk_desc":id_kk_produk_desc,"cart_qty":cart_qty}, function(){ notify('Item Added',"success"); }) } function cart_qty_plus(){ var cart_qty = $("#cart_qty").val(); $("#cart_qty").val(eval(cart_qty)+1); } function cart_qty_minus(){ var cart_qty = $("#cart_qty").val(); var newcart = eval(cart_qty)-1; if (newcart<1){newcart=1;} $("#cart_qty").val(newcart); } function padam_produk(produk_id){ $("#cart_detail_div").load("cart_detail.php?org_id=", {"action":"remove","id_desc":produk_id}, function(){ notify('Item Has Been Deleted',"success"); }) } // 20210615 - izzat add desc_product function desc_product(){ var produk_what_id = $("#kk_produk_desc_what").val(); $("#description_product_div").load("desc_product_what.php?id_kk_produk_desc="+produk_what_id+"&org_id="); } //fungsi untuk kemaskini_alamat---- function kemaskini_alamat(peserta_id){ var dialog = BootstrapDialog.show({ title: 'Update Address', spinicon: 'fa fa-spinner', closable: false, closeByBackdrop: false, closeByKeyboard: false, message: $('
').load('kemaskini_alamat.php?peserta_id='+peserta_id+"&org_id=", function() { }), buttons: [{ id: 'view-popup-close-1', icon: 'fa fa-times-circle', label: 'Close', cssClass: 'btn-danger', autospin: false, action: function(dialog){ dialog.close(); } },{ id: 'kemaskini-alamat-1', icon: 'fa fa-edit', label: 'Update', cssClass: 'btn-primary float-right', autospin: false, action: function(dialog){ kemaskini_alamat_submit(dialog); } }], draggable: true, onshown: function(){ $(document).off('focusin.modal'); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','100vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function kemaskini_alamat_submit(dialog){ var query = $("#alamat_form").serializeArray(), json={}; if($("#alamat_form").parsley().isValid()==true){ $("#action_submit").load("kemaskini_alamat_submit.php?org_id=", query, function(data){ if (data==1){ new Noty({ type: 'success', theme: 'bootstrap-v4', killer: true, timeout: 3500, layout: 'topRight', text: 'Address Record updated successfully' }).show(); dialog.close(); } else { Swal.fire({ title: 'Technical Problem', text: 'Records tried to be updated without going through a valid module', icon: 'warning', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }) } }) }else{ $("#alamat_form").parsley().validate(); } } function tnc_form_submit(){ var q=$("#tnc_form").serializeArray(), json={}; var setuju = $("#tnc_form #kk_peserta_kariah_tnc_status").is(':checked'); //console.log(setuju); //alert(setuju); if (setuju==true){ var kid = $("#kariah_id").val(); location.href="daftar.php?kariah_id="+kid+"&setuju="+setuju; } else { Swal.fire('You Must Agree','We require that you agree to the terms and conditions set out before you can register as a member',"error") } } function check_tanggungan_limit(kk_peserta_tanggungan_id,kariah_id){ var return_value = $.ajax({ url: 'check_tanggungan_limit.php', data: {"kk_peserta_tanggungan_id":kk_peserta_tanggungan_id,"kariah_id":kariah_id}, async: false, method: 'post' }).responseText; return return_value; } function check_tanggungan_waris_limit(kk_peserta_tanggungan_id,kariah_id){ var return_value = $.ajax({ url: 'check_tanggungan_waris_limit.php', data: {"kk_peserta_tanggungan_id":kk_peserta_tanggungan_id,"kariah_id":kariah_id}, async: false, method: 'post' }).responseText; return return_value; } function url_add_param(url, param, value) { if(document.location.href.contains('?')) { var url = document.location.href+"&"+param+"="+value; }else{ var url = document.location.href+"?"+param+"="+value; } return url; } function login_popup(isPreloaded = false) { var dialog = BootstrapDialog.show({ title: 'Login into ', message: (isPreloaded ? $("section#loginPopup") : $('
').load('login.php?org_id=', function() { })), draggable: true, onshown: function(){ $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','88vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); $("#btn-popup-widescreen-1").hide(); }, }).setSize(BootstrapDialog.SIZE_NORMAL); dialog.getModalHeader().css('background-color', 'black'); } function pilih_pakej(fund_id) { if(fund_id> 0) { window.fund_id = fund_id; $("form#register_form").attr('action', "javascript:register_peserta_form_submit("+fund_id+")"); } else window.fund_id = 0; window.membership_type = $("div#div_"+fund_id).data("membership-type"); fund_id = Math.abs(fund_id); $("div.fund_divs").css("border", "none"); $("div#div_"+fund_id).css("border", "4px solid darkred"); $("div.fund_divs h3").css("background-color", "lightgray").css("color","black"); $("div#div_"+fund_id +" h3").css("background-color", "black").css("color","white"); $("div.fund_divs a").html("Select"); $("div#div_"+fund_id +" a").html("Selected"); $("input#chosen_package").val(fund_id); pakejInput = document.getElementById("chosen_package"); pakejInput.setCustomValidity(''); $('.form-control.required').trigger("change"); $("a[href='#Pilihan_Pakej']").closest('li.nav-item').next().find('a').trigger('click'); } // NAF 20220511 View Member function function view_member(peserta_id, org_id){ var dialog = BootstrapDialog.show({ title: 'View Member Info', spinicon: 'fa fa-spinner', closable: false, closeByBackdrop: false, closeByKeyboard: false, message: $('
').load('view_member.php?peserta_id='+peserta_id+"&org_id="+org_id, function() { }), buttons: [{ id: 'view-popup-close-1', icon: 'fa fa-times-circle', label: 'Close', cssClass: 'btn-danger', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $(document).off('focusin.modal'); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','100vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function toTitleCase(str) { return str.replace(/(?:^|\s)\w/g, function(match) { return match.toUpperCase(); }); } function show_pass(){ $("#show_pass").toggleClass("fa-eye fa-eye-slash"); var input = $("#peserta_mykad_password"); if (input.attr("type") === "password") { input.attr("type", "text"); } else { input.attr("type", "password"); } } function show_pwd(which,what){ $("#"+what).toggleClass("fa-eye fa-eye-slash"); var input = $("#"+which); if (input.attr("type") === "password") { input.attr("type", "text"); } else { input.attr("type", "password"); } } function next_tab(){ // find the current
  • whose has the active class var $currentLi = $('.nav-tabs li').has('a.active'); // look for the next visible
  • var $nextLi = $currentLi.nextAll('li:visible').first(); if ($nextLi.length) { $nextLi.find('a').tab('show'); } } function prev_tab(){ var $currentLi = $('.nav-tabs li').has('a.active'); // look for the previous visible
  • var $prevLi = $currentLi.prevAll('li:visible').first(); if ($prevLi.length) { $prevLi.find('a').tab('show'); } } function setInputSelection(input, startPos, endPos) { input.focus(); if (typeof input.selectionStart != "undefined") { input.selectionStart = startPos; input.selectionEnd = endPos; } else if (document.selection && document.selection.createRange) { // IE branch input.select(); var range = document.selection.createRange(); range.collapse(true); range.moveEnd("character", endPos); range.moveStart("character", startPos); range.select(); } } function change_email() { $("#email_changer").css('visibility', ($("#email_changer").css('visibility') != "hidden" ? 'hidden' : 'visible')); $("#banEmailIcon").css('visibility', ($("#banEmailIcon").css('visibility') != "hidden" ? 'hidden' : 'visible')); //$("#forgot_email").prop("disabled", ($("#banEmailIcon").css('visibility') != "hidden" ? true : false)); $("#oldEmailLabel").html(function(index,html){ if($("#email_changer").css('visibility') != "hidden") return html.replace("Email","Old Email"); else return html.replace("Old Email","Email"); }); } function swal_no_rec_found_reg_new(kariah_id) { if(!kariah_id) kariah_id = 226; Swal.fire({ title: 'Record not found', text: 'Cannot find any email registered under that name/IC/Phone No', icon: 'warning', showCancelButton: true, cancelButtonText: 'Close', confirmButtonText: 'Register New Profile', confirmButtonColor: '#258', cancelButtonColor: '#f00' }).then((result) => { if (result.value) { window.location.href = '/peserta/daftar.php?kariah_id='+kariah_id; } }) } var forgotten_emails = []; function get_registered_email(kariah_id) { var peserta_mykad = $("#forgot_mykad").val(); //var peserta_nama = $("#forgot_nama").val(); if(!peserta_mykad //|| !peserta_nama ) { blinkElement('#forgot_mykad'); //swal.fire('Missing Info','Must fill Full Name or IC No or Mobile Phone No',"danger"); //alert("Must fill Full Name or IC No or Mobile Phone No"); $('#forgot_mykad') //.attr('data-toggle', 'tooltip').attr('title', 'Must fill Full Name or IC No or Mobile Phone No').tooltip('show') .focus(); // setTimeout(function() { // $('#forgot_mykad').removeAttr('title data-toggle'); // }, 5000); // 5000 milliseconds = 5 seconds return; } var return_value = $.ajax({ url: 'get_registered_email.php', type: "POST", data: { //"peserta_nama":peserta_nama, "peserta_mykad":peserta_mykad, "kariah_id":kariah_id }, async: false, method: 'post' }).responseText; if(return_value == "-1") { //alert("Cannot find any email registered under that name/IC/Phone No"); swal_no_rec_found_reg_new(kariah_id); } else { forgotten_emails = JSON.parse(return_value); $("#forgot_email") .addClass('autocomplete-w3school') .attr("autocomplete", "off") .attr("data-autocomplete", forgotten_emails) .val(forgotten_emails[0]); autocomplete(document.getElementById("forgot_email"), forgotten_emails, false); //$("#forgot_email").trigger('click'); //$("#forgot_email").click(); //show_autocomplete_list(document.getElementById("forgot_email"), forgotten_emails, 1); if(forgotten_emails.length>1) setTimeout(function() {$("#forgot_email").click();}, 500); startPos = forgotten_emails[0].indexOf("*"); endPos = forgotten_emails[0].lastIndexOf("*")+1; setInputSelection(document.getElementById("forgot_email"), startPos, endPos); $('#forgot_email').attr('data-toggle', 'tooltip').attr('title', 'Your email address is obscured to protect your privacy. Please replace the * with the correct email address').tooltip('show'); //$("#forgot_email").val(return_value); } //$("#email_results").load('get_registered_email.php?peserta_nama='+peserta_nama+"&peserta_mykad="+peserta_mykad) } function daftar_submit_peribadi(){ // Disable the register button and show spinner var $submitButton = $("#register_form_submit"); $submitButton.prop("disabled", true); $submitButton.html('  Processing...'); // 1) Gather the main form data var query = $("#register_form").serializeArray(); var peserta_kariah_id = $("#peserta_kariah_id").val() || get_org_id(); // 2) Submit to get back dd.status_val $("#action_submit").load("daftar_submit_peribadi.php", query, function(data){ var dd = JSON.parse(data); peserta_id = dd.peserta_id; // ————————— New user inserted —————————— if (dd.status_val == 3) { register_save_custom_data(peserta_id, peserta_kariah_id); // email + success dialog sendmailer_data_async(peserta_kariah_id, peserta_id, 'terima_kasih_new'); Swal.fire({ title: 'Thank You', text: 'You have signed up for this organization', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Register"); location.href = "../peserta/akaun_saya.php?org_id=" + peserta_kariah_id; }); } // ————————— Already registered in this kariah —————————— else if (dd.status_val == 1) { Swal.fire({ title: 'You Have Registered', text: 'Reviews show you signed up for ' + dd.kariah_fullname + (dd.peserta_email ? ' before this. Please log in using the email ' : ' before this. Please log in.') + dd.peserta_email, icon: 'error', showCancelButton: false, confirmButtonColor: '#258' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Register"); location.href = "../peserta/login.php?org_id=" + peserta_kariah_id; }); } // ————————— Account exists elsewhere; just add to this kariah —————————— else if (dd.status_val == 2) { register_save_custom_data(peserta_id, peserta_kariah_id); sendmailer_data_async(peserta_kariah_id, peserta_id, 'terima_kasih_new'); let respText = 'You have been registered with this organization. However, you have used this system before. Please log in using the email (%s) and password you previously registered. If you have forgotten your password, please use the Forgot Password function'.replace("%s", dd.peserta_email); Swal.fire({ title: 'Thank You', text: respText, icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Register"); // redirect logic here... location.href = "../peserta/login.php?org_id=" + peserta_kariah_id; }); } // ————————— Illegal / duplicate-email errors —————————— else if (dd.status_val == 4) { Swal.fire({ title: 'Error', text: 'Your Email Is Invalid', icon: 'error' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Register"); location.href = "index.php"; }); } }); } function download_file(file_id){ // get file name var filename = get_filename(file_id); window.open("dl.php?filename="+filename); } function get_filename(file_id){ var return_value = $.ajax({ url: 'get_filename_peserta.php', data: {"file_id":file_id}, async: false }).responseText; return return_value; } function get_org_id(){ var return_value = $.ajax({ url: 'get_kariah_from_cookie.php', async: false }).responseText; return return_value; } function bayaran_peserta(peserta_id, aktiviti_id=null){ var dialog = BootstrapDialog.show({ title:"Rekod Pembayaran Peserta", spinicon: 'fa fa-spinner', closable: true, closeByBackdrop: true, closeByKeyboard: true, message: $('
    ').load('bayaran_peserta.php?peserta_id='+peserta_id + (aktiviti_id === null ? '' : '&aktiviti_id='+aktiviti_id), function() { }), buttons: [{ id: 'view-popup-close-1', icon: 'fa fa-times-circle', label: 'Close', cssClass: 'btn-danger float-left', autospin: true, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $(document).off('focusin.modal'); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','100vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); $('[data-toggle="tooltip"]').tooltip(); }, }).setSize(BootstrapDialog.SIZE_EXTRAWIDE); dialog.getModalHeader().css('background-color', '#258'); } function sunting_maklumat_penyertaan(kap_id) { } function batal_penyertaan_aktiviti(id_kk_aktiviti_peserta) { // Show confirmation dialog first Swal.fire({ title: 'Are You Sure?', icon: 'warning', showCancelButton: true, confirmButtonText: 'Cancel Participation', cancelButtonText: 'No, I will attend after all' }).then((result) => { if (result.value === true) { // If confirmed, proceed with the AJAX request $.ajax({ url: 'batal_penyertaan_aktiviti.php', type: 'POST', data: { id_kk_aktiviti_peserta: id_kk_aktiviti_peserta }, success: function(response) { // success: show SweetAlert2 with live countdown and OK (x) button swal_ok_countdown(response.msg, '', 5, 'reload'); }, statusCode: { 403: function() { // not logged in: ask to go to login Swal.fire({ icon: 'warning', title: 'You are not logged in', text: 'Please log in first', confirmButtonText: 'OK' }).then(function() { window.location.href = '/peserta/login.php'; }); } }, error: function(xhr) { // all other errors var msg = 'Unknown Error'; try { var json = JSON.parse(xhr.responseText); if (json.msg) msg = json.msg; } catch (e) { /* ignore */ } Swal.fire({ icon: 'error', title: 'Error', text: msg }); } }); } }); } /* function batal_penyertaan_aktiviti(kap_id) { $.ajax({ url: '../event/change_participation_status.php', async: false, data: {"kap_id":kap_id,"newstatus":-3}, complete: function(d){ if(d.responseText==1) show_note_5sec("Information successfully updated","success"); else show_note_5sec("Update Failed: "+d.responseText,"error"); location.reload(); } }) } */ function search_box_submit(){ var q = $("#search_box").val(); var dialog = BootstrapDialog.show({ title: 'Search Result', message: $('
    ').load('search_result.php', {"search_term":q}, function() { }), buttons: [{ id: 'btn-popup-fullscreen-2', icon: 'fa fa-expand', label: 'Full Screen', cssClass: 'btn-primary btn-fullscreen ', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_EXTRAWIDE); $("#btn-popup-widescreen-2").show(); $("#btn-popup-fullscreen-2").hide(); } },{ id: 'btn-popup-widescreen-2', icon: 'fa fa-compress', label: 'Normal Screen', cssClass: 'btn-info btn-widescreen ', autospin: false, action: function(dialog){ dialog.setSize(BootstrapDialog.SIZE_WIDE); $("#btn-popup-fullscreen-2").show(); $("#btn-popup-widescreen-2").hide(); } },{ id: 'view-popup-close-2', icon: 'fa fa-exit', label: 'Close', cssClass: 'btn-danger float-left ', autospin: false, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','88vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); $("#btn-popup-fullscreen-2").show(); $("#btn-popup-widescreen-2").hide(); }, }).setSize(BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function share_full_link(link) { var fullLink = document.createElement('input'); document.body.appendChild(fullLink); fullLink.value = link; fullLink.select(); document.execCommand("copy", false); fullLink.remove(); var anchor = $("
    ", { href: fullLink.value, target: "_blank" }); anchor.html(fullLink.value + '  '); Swal.fire("Link copied successfully","" + anchor[0].outerHTML,"success"); } function popup(modalTitle, page, afterLoad, modalSize) { var dialog = BootstrapDialog.show({ title:modalTitle, spinicon: 'fa fa-spinner', closable: true, closeByBackdrop: true, closeByKeyboard: true, message: $('
    Loading...').load(page, afterLoad), buttons: [{ id: 'view-popup-close-2', icon: 'fa fa-times-circle', label: 'Close', cssClass: 'btn-danger float-left', autospin: true, action: function(dialog){ dialog.close(); } }], draggable: true, onshown: function(){ $(document).off('focusin.modal'); $('.modal-content').css('margin','5px 0'); $('.modal-content').css('max-height','100vh'); $('.modal-body').css('max-height','70vh'); $('.modal-body').css("overflow-y","scroll"); $('[data-toggle="tooltip"]').tooltip(); }, }).setSize(modalSize ?? BootstrapDialog.SIZE_WIDE); dialog.getModalHeader().css('background-color', '#258'); } function check_payment_is_allowed(fund_id, kariah_id){ var return_value = $.ajax({ url: 'check_payment_is_allowed.php', data: {"fund_id":fund_id,"kariah_id":kariah_id}, async: false }).responseText; return return_value; } function check_payment_is_allowed_for_peserta(fund_id, kariah_id, peserta_id){ var return_value = $.ajax({ url: 'check_payment_is_allowed_for_peserta.php', data: {"fund_id":fund_id,"kariah_id":kariah_id,"peserta_id":peserta_id}, async: false }).responseText; return return_value; } function bayaran_aktiviti_peserta(peserta_id, kariah_fund_id, fiscal_year, kariah_id, fund_rm, payment_type=1){ // must check if peserta_id is already a member of the kariah // if yes, allow renewal. otherwise, only allow new registration // no need to approve membership // read fund value var fund_value = fund_rm; console.log(fund_value); fund_value = fund_value ?? 0; console.log(fund_value); if(payment_type==1){ if (fund_value=="0.00" || fund_value=='' || fund_value=='0' || fund_value===null || fund_value=== undefined){ // check fund value.. if 0, ask for real value if (check_fund_value(kariah_fund_id)=="0"){ Swal.fire({ title: 'Value Must Be Entered', html: 'The value entered must be more or equal to RM2.00', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, cancelButtonText: 'Cancel', confirmButtonText: 'Save', showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { var fixed_value = parseFloat(result.value).toFixed(2); if (fixed_value<2) { Swal.fire('Value Must Be More Than RM2.00','Please enter a value greater than or equal to RM2.00',"warning"); $(".price-note").show(); } else { $("#fund_"+kariah_fund_id).html(fixed_value); $("#fund_value_"+kariah_fund_id).val(fixed_value); $("#fund_value_rm_"+kariah_fund_id).text(fixed_value); $(".price-note").show(); $("#real_value").html('Update') } } }); } else if (check_fund_value(kariah_fund_id)=="-1"){ Swal.fire('Error','The selected product/service does not exist',"error"); } else { location.href="bayar_kariah_list_selected.php?kk_fund_id="+kariah_fund_id+'&peserta_id='+peserta_id+'&kariah_tahun='+fiscal_year+'&kariah_id='+kariah_id; } } else { location.href="bayar_kariah_list_selected.php?kk_fund_id="+kariah_fund_id+'&peserta_id='+peserta_id+'&kariah_tahun='+fiscal_year+'&kariah_id='+kariah_id+'&fund_value='+fund_value; } }else{ $("#action_submit").load("kemaskini_tanpa_bayaran.php?kariah_fund_id="+kariah_fund_id+"&kariah_id="+kariah_id+"&peserta_id="+peserta_id+"&fiscal_year="+fiscal_year, function(data){ if (data==1){ Swal.fire({ title: 'Success', text: 'You successfully become an official member', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); location.href="akaun_saya.php"; } else if (data==2){ Swal.fire({ title: 'Success', text: 'You become an official member', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); } else { Swal.fire({ title: 'Technical Problem', text: 'Please try again', icon: 'warning', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); } }); } } function blinkElement(selector) { $(selector).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); } function reloadScript(url) { const oldScript = document.querySelector(`script[src="${url}"]`); if (oldScript) oldScript.remove(); // Remove the existing script // Create a new script element with a cache-busting parameter const newScript = document.createElement("script"); newScript.src = `${url}?t=${new Date().getTime()}`; // Cache-busting query parameter document.head.appendChild(newScript); } // for use with custom/php/custom.php setup_autocomplete_ajax() $(document).ready(function() { const MIN_CHARACTERS = 3; // Minimum characters before triggering AJAX const DEBOUNCE_DELAY = 300; // milliseconds // Function to escape HTML to prevent XSS function escapeHtml(text) { return $('
    ').text(text).html(); } // Function to display error messages function showErrorMessage(input, message) { // Remove existing message if any input.next('.error-message').remove(); // Append a new message input.after(`${message}`); } // Function to remove error messages function removeErrorMessage(input) { input.next('.error-message').remove(); } // Initialize autocomplete for all inputs with class 'autocomplete-ajax' $('.autocomplete-ajax').each(function() { const input = $(this); const datalistId = input.attr('list'); const datalist = $('#' + datalistId); const ajaxUrl = input.data('ajax-url'); const strict = input.data('strict') === '1'; const hiddenInputSelector = input.data('hidden-input') || null; const hiddenInput = hiddenInputSelector ? $(hiddenInputSelector) : null; const noRepeatValues = input.data('norepeatvalues') || null; // Note: data-noRepeatValues becomes data-norepeatvalues in jQuery let debounceTimeout = null; let isSelecting = false; // Flag to indicate selection from datalist // Function to fetch and populate datalist function fetchAutocompleteSuggestions(query, excludeValues=[]) { $.ajax({ url: ajaxUrl, method: 'POST', data: { search_str: query, exclude_values: excludeValues // Send values to exclude }, dataType: 'json', success: function(data) { datalist.empty(); // Clear previous options removeErrorMessage(input); // Remove any existing error message if (data.error) { console.error('Autocomplete Error:', data.error); return; } const entries = Object.entries(data); if (entries.length === 0) { // Optionally, handle no results without adding an option // For now, do nothing return; } entries.forEach(function([key, value]) { const escapedValue = escapeHtml(value); datalist.append(``); }); }, error: function(xhr, status, error) { console.error('AJAX Error:', status, error); } }); } // Function to get all selected values in the same group function getSelectedValuesInGroup(group) { if (!group) return []; const selectedValues = []; $(`.autocomplete-ajax[data-norepeatvalues="${group}"]`).each(function() { const val = $(this).val(); if (val) selectedValues.push(val); }); return selectedValues; } // Event listener for input events with debouncing input.on('input', function() { if (isSelecting) { // Skip AJAX call if the input change is due to a selection isSelecting = false; return; } const query = $(this).val(); // Get selected values in the same group to exclude from suggestions const excludeValues = noRepeatValues ? getSelectedValuesInGroup(noRepeatValues).filter(v => v !== query) : []; // Clear any existing debounce timeout if (debounceTimeout) { clearTimeout(debounceTimeout); } // Debounce the AJAX request debounceTimeout = setTimeout(function() { if (query.length >= MIN_CHARACTERS) { fetchAutocompleteSuggestions(query, excludeValues); } else { datalist.empty(); // Clear datalist if query is too short removeErrorMessage(input); // Remove any existing error message } }, DEBOUNCE_DELAY); }); // Event listener for selection from datalist input.on('change', function() { const selectedValue = $(this).val(); let matched = false; let selectedId = null; // Iterate through datalist options to find a match datalist.find('option').each(function() { if ($(this).val() === selectedValue) { matched = true; if (hiddenInput) { selectedId = $(this).attr('data-id'); } return false; // Break loop } }); if (matched) { if (hiddenInput && selectedId) { hiddenInput.val(selectedId); } removeErrorMessage(input); // Remove any existing error message } else { if (strict) { // Check if the value is already selected in the same group if (noRepeatValues) { const duplicate = getSelectedValuesInGroup(noRepeatValues).includes(selectedValue); if (duplicate) { // Clear input and hidden field if strict and duplicate found input.val(''); if (hiddenInput) { hiddenInput.val(''); } showErrorMessage(input, 'Cannot pick the same value.'); return; } } // Clear input and hidden field if strict and no match input.val(''); if (hiddenInput) { hiddenInput.val(''); } showErrorMessage(input, 'Please select a valid option from the list.'); } else { if (hiddenInput) { hiddenInput.val(''); } } } // Set the selection flag to prevent the next input event from triggering AJAX if (matched) { isSelecting = true; } }); // Optional: Handle form submission to ensure valid selection if strict if (strict) { input.closest('form').on('submit', function(e) { const selectedValue = input.val(); let matched = false; datalist.find('option').each(function() { if ($(this).val() === selectedValue) { matched = true; return false; // Break loop } }); if (!matched) { // Prevent form submission and notify user e.preventDefault(); alert('Please select a valid option from the list.'); } }); } }); }); function view_session(training_student_id, training_program_id) { if (!training_student_id || !training_program_id) { BootstrapDialog.alert('Invalid request. Missing student or training program ID.'); return; } lowerDialogInstance = BootstrapDialog.show({ title: 'Training Modules', size: BootstrapDialog.SIZE_WIDE, message: function(dialog) { var $message = $('
    Loading modules...
    '); $.ajax({ url: 'view_modules.php', type: 'GET', data: { training_student_id: training_student_id, training_program_id: training_program_id }, success: function(response) { $message.html(response); }, error: function() { $message.html('
    Error loading modules. Please try again.
    '); } }); return $('
    ').append($message); }, onshown: function(dialog) { $('.bootstrap-dialog-body').css({ "max-height": "70vh", // Set max height to prevent exceeding viewport "overflow-y": "auto" // Enables scrollbar when content exceeds height }); }, buttons: [{ label: 'Close', cssClass: 'btn-danger', action: function(dialogItself) { dialogItself.close(); lowerDialogInstance = null; // Reset reference when closed } }] }); } function view_session_batch(training_student_id, training_program_id, batch_id) { if (!training_student_id || !training_program_id || !batch_id) { BootstrapDialog.alert('Invalid request. Missing student, training program, or batch ID.'); return; } lowerDialogInstance = BootstrapDialog.show({ title: 'Training Modules for Batch #' + batch_id, size: BootstrapDialog.SIZE_WIDE, message: function(dialog) { var $message = $('
    Loading modules...
    '); $.ajax({ url: 'view_modules.php', type: 'GET', data: { training_student_id: training_student_id, training_program_id: training_program_id, batch_id: batch_id }, success: function(response) { $message.html(response); }, error: function() { $message.html('
    Error loading modules. Please try again.
    '); } }); return $('
    ').append($message); }, onshown: function(dialog) { $('.bootstrap-dialog-body').css({ "max-height": "70vh", "overflow-y": "auto" }); }, buttons: [{ label: 'Close', cssClass: 'btn-danger', action: function(dialogItself) { dialogItself.close(); lowerDialogInstance = null; } }] }); } /* function daftar_aktiviti_submit(fund_id = null) { $("#regButton") .addClass('disabled') .prop('disabled', true) .html(' Processing & Checking Records'); var query = $("#daftar_aktiviti_form").serializeArray(); var peserta_id = $("#daftar_aktiviti_form #peserta_id").val(); $.ajax({ type: "POST", url: "daftar_aktiviti_submit2.php", data: query, dataType: "json", autospin: true, async: false, success: function(d) { if (typeof d === "undefined") { alert("undefined response"); return; } let redir = '', title = '', text = ''; switch (d.status_val) { case -1: Swal.fire({ title: 'Error', text: 'Your Email Is Invalid', icon: 'error', confirmButtonColor: '#258' }); break; case -2: Swal.fire({ title: 'Error', text: 'Participant Registration Unsuccessful', icon: 'error', confirmButtonColor: '#258' }); break; case -3: Swal.fire({ title: 'Error', text: 'You have already registered for this event. If you wish to edit participation details, please login using the link given in your email.', icon: 'error', confirmButtonColor: '#258' }).then(() => { location.href = '../peserta/akaun_saya.php?aktiviti_id=' + $("#kk_aktiviti_id").val() + '&org_id=' + $("#org_id").val(); }); break; case -4: case 0: title = 'Thank You'; text = 'Your registration is successful. Please check your email (including your spam box) for instructions to make payment and confirm your registration.)'; if (fund_id > 0) { if (peserta_id>0) { redir = "../peserta/bayar_kariah_list_selected.php?kk_fund_id=" + fund_id; } else { redir = "../peserta/login.php?org_id=" + $("#org_id").val(); } } else { redir = "../peserta/login.php?org_id=" + $("#org_id").val(); } swal_ok_countdown(title, text, 5, redir); break; default: Swal.fire({ title: 'Error', text: d.msg, icon: 'error', confirmButtonColor: '#258' }); break; } } }); } */ // Main registration function function maskName(name) { if (!name) return '-'; // Split by space to mask each part of the name separately return name.split(' ').map(part => { if (part.length <= 2) { // For very short words, just mask the middle if possible return part.length === 2 ? part[0] + '*' : part; // 1 character, leave as is } // Keep the first and last character, mask the rest return part[0] + '*'.repeat(part.length - 2) + part[part.length - 1]; }).join(' '); } function daftar_aktiviti_submit(fund_id = null) { var email = $("#peserta_email").val().trim(); var phone = $("#peserta_notel_bimbit").val().trim(); // First, check if peserta already exists $.ajax({ type: "POST", url: "check_peserta_aktiviti.php", data: { email: email, phone: phone }, dataType: "json", success: function (res) { if (res.kk_peserta_id) { $("#peserta_id").val(res.kk_peserta_id); // set peserta ID if found // Mask the name for display var maskedName = maskName(res.peserta_nama); // Show confirmation alert with masked user info Swal.fire({ title: 'We found your record', html: `
    Name: ${maskedName}
    Phone: ${res.peserta_notel_bimbit || '-'}
    Email: ${res.peserta_email || '-'}

    Would you like to proceed with this information?

    `, icon: 'info', showCancelButton: true, confirmButtonText: 'Yes, proceed', cancelButtonText: 'No, cancel', confirmButtonColor: '#258', cancelButtonColor: '#d33' }).then((result) => { if (result.value) { proceed_registration(fund_id); } }); } else { // No record found, proceed directly proceed_registration(fund_id); } }, error: function () { Swal.fire({ title: 'Error', text: 'Unable to check participant record. Please try again.', icon: 'error', confirmButtonColor: '#258' }); } }); } function proceed_registration(fund_id) { $("#regButton") .addClass('disabled') .prop('disabled', true) .html(' Processing & Checking Records'); var query = $("#daftar_aktiviti_form").serializeArray(); var peserta_id = $("#daftar_aktiviti_form #peserta_id").val(); $.ajax({ type: "POST", url: "daftar_aktiviti_submit2.php", data: query, dataType: "json", autospin: true, async: false, success: function (d) { if (typeof d === "undefined") { alert("undefined response"); return; } let redir = '', title = '', text = ''; switch (d.status_val) { case -1: Swal.fire({ title: 'Error', text: 'Your Email Is Invalid', icon: 'error', confirmButtonColor: '#258' }); break; case -2: Swal.fire({ title: 'Error', text: 'Participant Registration Unsuccessful', icon: 'error', confirmButtonColor: '#258' }); break; case -3: Swal.fire({ title: 'Error', text: 'You have already registered for this event. If you wish to edit participation details, please login using the link given in your email.', icon: 'error', confirmButtonColor: '#258' }).then(() => { location.href = '../peserta/akaun_saya.php?aktiviti_id=' + $("#kk_aktiviti_id").val() + '&org_id=' + $("#org_id").val(); }); break; case -4: case 0: title = 'Thank You'; text = 'Your registration is successful. Please check your email (including your spam box) for instructions to make payment and confirm your registration.'; if (fund_id > 0) { if (peserta_id > 0) { redir = "../peserta/bayar_kariah_list_selected.php?kk_fund_id=" + fund_id; } else { redir = "../peserta/login.php?org_id=" + $("#org_id").val(); } } else { redir = "../peserta/login.php?org_id=" + $("#org_id").val(); } //console.log(redir); swal_ok_countdown(title, text, 5, redir); break; default: Swal.fire({ title: 'Error', text: d.msg, icon: 'error', confirmButtonColor: '#258' }); break; } } }); } function register_teammates_submit(){ var teammates_mykad = $("#kk_peserta_teammates_nokp").val(); var kk_peserta_teammates_relationship = $('input[name="kk_peserta_teammates_relationship"]:checked').val(); var kariah_id = $("#kk_peserta_teammates_kariah_id").val(); var kk_peserta_teammates_id = $("#kk_peserta_teammates_id").val(); if (check_teammates_limit(kk_peserta_teammates_id,kariah_id)=="0"){ // check teammates limit. if 0, proceed if (kk_peserta_teammates_relationship==9){ if (check_teammates_waris_limit(kk_peserta_teammates_id,kariah_id)=="0"){ var mykad = /(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))([0-9]{2})([0-9]{4})/g; if (teammates_mykad.match(mykad)){ var query = $("#register_teammates_form").serializeArray(), json={}; $("#list_teammates").load("daftar_teammates_list.php", query, function(data){ $("input.reset").val(""); }) } else { Swal.fire('Identity Card No. Format Error','Please enter the correct identity card number',"error"); } } else { Swal.fire('Already Reached the Limit of Heir Liability','You have reached the limit of the number of beneficiaries that have been set by your organization.',"error"); } } else { var mykad = /(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))([0-9]{2})([0-9]{4})/g; if (teammates_mykad.match(mykad)){ var query = $("#register_teammates_form").serializeArray(), json={}; $("#list_teammates").load("daftar_teammates_list.php", query, function(data){ $("input.reset").val(""); }) } else { Swal.fire('Identity Card No. Format Error','Please enter the correct identity card number',"error"); } } } else { Swal.fire('Already Reached the Limit of Heir Liability','You have reached the limit of the number of dependents that have been set by your organization.',"error"); } } function padam_teammates(teammates_id){ Swal.fire({ title: 'Are You Sure?', text: 'This action cannot be undone', icon: 'warning', showCancelButton: true, cancelButtonText: 'No', confirmButtonText: 'Yes', confirmButtonColor: '#258', cancelButtonColor: '#f00' }).then((result) => { $("#list_teammates").load("daftar_teammates_list.php", {"MM_delete_teammates":"padam_teammates","teammates_id":teammates_id}, function(data){ }) }) } function update_teammates_submit(){ var query = $("#register_teammates_form").serializeArray(), json={}; $("#list_teammates").load("daftar_teammates_list.php", query, function(data){ $("#register_teammates_div").load("register_teammates.php", function(){}) }) } function kemaskini_teammates(teammates_id){ $("#register_teammates_div").load("register_teammates.php", {"MM_update_teammates":"update_teammates","teammates_id":teammates_id}, function(data){ whatsex(); }) } function batal_teammates(){ $("#register_teammates_div").load("register_teammates.php", function(){}); } function check_teammates_limit(kk_peserta_teammates_id,kariah_id){ var return_value = $.ajax({ url: 'check_teammates_limit.php', data: {"kk_peserta_teammates_id":kk_peserta_teammates_id,"kariah_id":kariah_id}, async: false, method: 'post' }).responseText; return return_value; } function pilih_pakej(fund_id) { $("div.fund_divs").css("border", "none"); $("div#div_"+fund_id).css("border", "4px solid darkred"); $("div.fund_divs h3").css("background-color", "lightgray").css("color","black"); $("div#div_"+fund_id +" h3").css("background-color", "black").css("color","white"); $("div.fund_divs a").html("Select"); $("div#div_"+fund_id +" a").html("Selected"); $("input#chosen_package").val(fund_id); pakejInput = document.getElementById("chosen_package"); pakejInput.setCustomValidity(''); $("form#daftar_aktiviti_form").attr('action', "javascript:daftar_aktiviti_submit("+fund_id+")"); $('.form-control.required').trigger("change"); }