var org_id = kariah_id = 59; 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('Harap Maaf','Pelayar anda tidak membenarkan lokasi dikesan',"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('Pengesanan Lokasi Organisasi/Kariah','Sila benarkan lokasi anda dikesan untuk membolehkan sistem menyenaraikan surau atau masjid yang menganjurkan program Khairat Kematian. Sekiranya anda tidak mahu lokasi anda dikesan, sila masukkan poskod anda',"info"); }); } function GEOdeclined3(error){ $("#enter_poskod_div").load("enter_poskod.php?allow_poskod_search=1&ping=1", function(){ Swal.fire('Pengesanan Lokasi Organisasi/Kariah','Sila benarkan lokasi anda dikesan untuk membolehkan sistem menyenaraikan surau atau masjid yang menganjurkan program Khairat Kematian. Sekiranya anda tidak mahu lokasi anda dikesan, sila masukkan poskod anda',"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('Pengesanan Lokasi Organisasi/Kariah','Sila benarkan lokasi anda dikesan untuk membolehkan sistem menyenaraikan surau atau masjid yang menganjurkan program Khairat Kematian. Sekiranya anda tidak mahu lokasi anda dikesan, sila masukkan poskod anda',"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('Pengesanan Lokasi Organisasi/Kariah','Sila benarkan lokasi anda dikesan untuk membolehkan sistem menyenaraikan surau atau masjid yang menganjurkan program Khairat Kematian. Sekiranya anda tidak mahu lokasi anda dikesan, sila masukkan poskod anda',"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('Ralat','Katalaluan Tidak Sama',"error"); // } else { // var query = $("#register_form").serializeArray(), json={}; // $("#action_submit").load("daftar_submit_organisasi.php", query, function(data){ // if (data>5){ // Swal.fire({ // title: 'Tahniah', // html: 'Anda telah berjaya mendaftarkan organisasi anda sebagai ahli Maya.
Sila rujuk email anda untuk maklumat pengurusan keahlian organisasi anda.', // 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 = 'Anda pernah mendaftar sebelum ini pada %s. Sila daftar masuk.'; // Swal.fire({ // title: 'Anda Pernah Mendaftar', // 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: 'Selamat Kembali', // 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: 'Ralat', // text: 'Emel Anda Tidak Sah', // icon: 'error', // showCancelButton: false, // confirmButtonColor: '#258' // }).then((result) => { // if (result.value) { // // location.href="index.php"; // } // }); // } else if (data==5){ // Swal.fire({ // title: 'Ralat', // 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('Ralat Format No Kad Pengenalan','Sila masukkan nombor kad pengenalan yang betul',"error"); } } else { Swal.fire('Sudah Mencapai Had Tanggungan Waris','Anda telah mencapai had jumlah tanggungan waris yang telah ditetapkan oleh organisasi anda.',"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('Ralat Format No Kad Pengenalan','Sila masukkan nombor kad pengenalan yang betul',"error"); } } } else { Swal.fire('Sudah Mencapai Had Tanggungan Waris','Anda telah mencapai had jumlah tanggungan yang telah ditetapkan oleh organisasi anda.',"error"); } } function padam_tanggungan(tanggungan_id){ Swal.fire({ title: 'Adakah Anda Pasti?', text: 'Tindakan ini tidak boleh diundur', icon: 'warning', showCancelButton: true, cancelButtonText: 'Tidak', confirmButtonText: 'Ya', 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('Katalaluan Salah','Anda telah memasukkan katalaluan yang salah. Sila cuba sekali lagi.',"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('Belum mendaftar','Anda belum pernah mendaftar sebelum ini. Sila daftar terlebih dahulu.',"error"); } }); } else { // The person is not logged into this app or we are unable to tell. Swal.fire('Belum mendaftar','Anda belum pernah mendaftar sebelum ini. Sila daftar terlebih dahulu.',"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("
Sistem telah mendapatkan maklumat anda dari facebook. Walaubagaimanapun, anda perlu melengkapkan maklumat lain.
Bukan anda? Log Keluar dari 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("
Anda telah di log keluar. Sila log masuk semula di 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("
Terima kasih. Kami akan menghubungi anda sekiranya masjid / surau / organisasi yang anda daftarkan telah menjadi ahli Sistem Khairat Kematian
Anda juga boleh mendaftarkan masjid / surau / organisasi lain
").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: 'Pengesanan Lokasi', //text: "Sistem telah mengesan anda berada di poskod "+data.results[4].address_components[0].short_name, text: 'Sistem Mendapati Anda Berada di Koordinat ' +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('Terima kasih. Kami akan menghubungi anda sekiranya masjid / surau / organisasi yang anda daftarkan telah menjadi ahli Sistem Khairat Kematian','Pelayar anda tidak membenarkan lokasi dikesan',"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('Menunggu Kelulusan Keahlian','Keahlian anda mesti diluluskan oleh admin dahulu sebelum anda boleh membuat pembayaran.',"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); console.log(payment_type); 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: 'Nilai Perlu Dimasukkan', html: 'Nilai yang dimasukkan mesti lebih atau sama dengan RM2.00', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, cancelButtonText: 'Batal', confirmButtonText: 'Simpan', showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { var fixed_value = parseFloat(result.value).toFixed(2); if (fixed_value<2) { Swal.fire('Nilai Mesti Lebih RM2.00','Sila masukkan nilai yang lebih besar atau sama dengan 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('Kemaskini') } } }); } else if (check_fund_value(kariah_fund_id)=="-1"){ Swal.fire('Ralat','Produk/Perkhidmatan yang dipilih tidak wujud',"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: 'Berjaya', text: 'Anda telah berjaya menjadi ahli rasmi', 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: 'Berjaya', text: 'Anda telah menjadi ahli rasmi', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { //dialog.close(); } }); } else { Swal.fire({ title: 'Masalah Teknikal', text: 'Sila cuba kembali', 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: 'Sila Masukkan Nilai', html: 'Nilai yang dimasukkan mesti lebih atau sama dengan RM2.00', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, cancelButtonText: 'Batal', confirmButtonText: 'Simpan', showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { var fixed_value = parseFloat(result.value).toFixed(2); if (fixed_value<2) { Swal.fire('Nilai Mesti Lebih RM2.00','Sila masukkan nilai yang lebih besar atau sama dengan 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('Kemaskini') } } }) } 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('Masalah berlaku','Sila cuba kembali',"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('Tidak Lengkap','Sila Lengkapkan Maklumat Yang Diperlukan',"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: 'Maklumat Anda Dikemaskini', text: 'Maklumat peribadi anda telah dikemaskini', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }); } }); } function batal_kariah(peserta_kariah_id){ Swal.fire({ title: 'Adakah Anda Pasti?', text: 'Anda mahu membatalkan pendaftaran anda di organisasi yang dipilih', icon: 'warning', showCancelButton: true, confirmButtonColor: '#258', cancelButtonColor: '#f00', cancelButtonText: 'Tidak', confirmButtonText: 'Ya! Pasti' }).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: 'Hebahan', message: $('
').load('content_hebahan.php?hebahan_id='+content_id, function() { }), buttons: [{ id: 'btn-popup-fullscreen-1', icon: 'fa fa-expand', label: 'Skrin Penuh', 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: 'Skrin Biasa', 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: 'Tutup', 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('Pautan berjaya disalin', 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(" Sila tunggu sementara sistem mencari maklumat organisasi"); $("#geodeclined").fadeIn(); } function first_time_login(kariah_id){ var dialog = BootstrapDialog.show({ title: 'Login Kali Pertama', message: $('
').load('forgot_password.php?kariah_id='+kariah_id, function() { }), buttons: [{ id: 'btn-get-pwd-2', icon: 'fa fa-lock-open', label: 'Emelkan Saya Katalaluan Baharu', 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: 'Pendaftaran Baharu', 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: 'Tutup', 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: 'Lupa Katalaluan', message: $('
').load('forgot_password.php?kariah_id='+kariah_id, function() { }), buttons: [{ id: 'btn-get-pwd-2', icon: 'fa fa-lock-open', label: 'Reset Katalaluan', cssClass: 'btn-primary float-right ', autospin: true, action: function(dialog){ lupa_katalaluan_submit(dialog); } },{ id: 'view-popup-close-2', icon: 'fa fa-exit', label: 'Tutup', 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: 'Sila Tunggu', text: 'Kami sedang menukar kata laluan anda', 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: 'Katalaluan Baru Sudah Dihantar', text: 'Sistem telah menghantar katalaluan baharu kepada anda melalui emel. Sila semak emel anda termasuk Spam box', icon: 'success', showCancelButton: false, confirmButtonText: 'OK', confirmButtonColor: '#258' }).then((result) => { //$("#register_form_submit").html("Daftar"); if (result.value) { location.href="../peserta/login.php?org_id="+org_id; } }) /*Swal.fire({ title: 'Katalaluan Baru Sudah Dihantar', text: 'Sistem telah menghantar katalaluan baharu kepada anda melalui emel. Sila semak emel anda termasuk 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('Rekod Tidak Dijumpai','Sistem tidak menjumpai rekod anda berdasarkan maklumat yang dimasukkan. Sila cuba lagi.',"error"); } else if(data==-1) { Swal.fire('Ralat Emel','Emel anda tidak mengikut format yang betul. Sila betulkan dahulu.',"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('Ralat',data,"error"); } //Swal.close(); // Close the waiting alert } }).responseText; } else if(user_check == -2) { Swal.fire({ title: 'Email Sudah Wujud!', text: 'Harap maaf, emel telah wujud', 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('Ralat Emel','Emel anda tidak mengikut format yang betul. Sila betulkan dahulu.',"error"); } } else { Swal.fire('Ralat','Anda wajib memasukkan kedua-dua No Kad Pengenalan dan Emel',"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: 'Sila Tunggu', text: 'Kami sedang menukar kata laluan anda', 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: 'Katalaluan Baru Sudah Dihantar', text: 'Sistem telah menghantar katalaluan baharu kepada anda melalui emel. Sila semak emel anda termasuk Spam box', icon: 'success', showCancelButton: false, confirmButtonText: 'OK', confirmButtonColor: '#258' }).then((result) => { //$("#register_form_submit").html("Daftar"); if (result.value) { location.href="../peserta/login.php?org_id="+org_id; } }) /*Swal.fire({ title: 'Katalaluan Baru Sudah Dihantar', text: 'Sistem telah menghantar katalaluan baharu kepada anda melalui emel. Sila semak emel anda termasuk 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('Rekod Tidak Dijumpai','Sistem tidak menjumpai rekod anda berdasarkan maklumat yang dimasukkan. Sila cuba lagi.',"error"); } else if(data==-1) { Swal.fire('Ralat Emel','Emel anda tidak mengikut format yang betul. Sila betulkan dahulu.',"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('Ralat',data,"error"); } //Swal.close(); // Close the waiting alert } }).responseText; } else if(user_check == -2) { Swal.fire({ title: 'Email Sudah Wujud!', text: 'Harap maaf, emel telah wujud', 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('Ralat Emel','Emel anda tidak mengikut format yang betul. Sila betulkan dahulu.',"error"); } } else { Swal.fire('Ralat','Anda wajib memasukkan kedua-dua No Kad Pengenalan dan Emel',"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: 'Tukar Katalaluan', message: $('
').load('tukar_password.php?peserta_id='+peserta_id, function() { }), buttons: [{ id: 'btn-get-pwd-3', icon: 'fa fa-lock', label: 'Tetapkan Katalaluan', 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: 'Tutup', 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('Ralat','Katalaluan Tidak Sama',"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('Tukar Katalaluan','Anda telah berjaya menukar katalaluan. Sila gunakan katalaluan baharu apabila anda log masuk semula',"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('  Sedang Memproses...'); // 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: 'Pendaftaran Disekat', text: 'Anda tidak memilih organisasi untuk didaftarkan. Pendaftaran tidak dapat diteruskan.', 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('Ralat','Katalaluan Tidak Sama',"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 resolveSelectedFundId(currentFundId) { let candidate = currentFundId; if (candidate === undefined || candidate === null || candidate === '' || candidate === false) { candidate = $('#selected_fund_id').val() || $('input[name="kk_fund_id"]:checked').val(); } if (candidate === undefined || candidate === null || candidate === '' || candidate === false) { return null; } const parsed = parseInt(candidate, 10); return Number.isNaN(parsed) ? null : parsed; } function daftar_aktiviti_submit(fund_id = null) { fund_id = resolveSelectedFundId(fund_id); const allowRepeat = parseInt($("#kk_aktiviti_allow_repeat_purchase").val() || 0, 10) === 1; const $form = $("#daftar_aktiviti_form"); const $regButton = $("#regButton"); if (!$regButton.data("original-label")) { $regButton.data("original-label", $regButton.html()); } $regButton .addClass("disabled") .prop("disabled", true) .html(' Processing & Checking Records'); const resetButton = () => { const original = $regButton.data("original-label") || 'Register Now!'; $regButton.removeClass("disabled").prop("disabled", false).html(original); }; let pesertaId = parseInt($("#daftar_aktiviti_form #peserta_id").val() || "0", 10) || 0; let formData = $form.serializeArray(); const continueRegistration = () => { formData = $form.serializeArray(); pesertaId = parseInt($("#daftar_aktiviti_form #peserta_id").val() || "0", 10) || 0; proceed_registration(formData, fund_id, pesertaId, resetButton); }; if (allowRepeat) { continueRegistration(); return; } $.ajax({ type: "POST", url: "check_peserta_aktiviti.php", data: formData, dataType: "json", success: function(resp) { if (resp && resp.kk_peserta_id) { Swal.fire({ title: 'Participant already exists.', text: 'We found an existing record with this email or phone. Do you want to use it for this registration?', icon: 'warning', showCancelButton: true, confirmButtonColor: '#258', cancelButtonColor: '#f00', confirmButtonText: 'Yes, continue', cancelButtonText: 'No, cancel' }).then((result) => { if (result.isConfirmed) { if (resp.peserta_nama) $("#peserta_nama").val(resp.peserta_nama); if (resp.peserta_email) $("#peserta_email").val(resp.peserta_email); if (resp.peserta_notel_bimbit) $("#peserta_notel_bimbit").val(resp.peserta_notel_bimbit); $("#peserta_id").val(resp.kk_peserta_id); continueRegistration(); } else { resetButton(); } }); } else { continueRegistration(); } }, error: function() { Swal.fire({ title: 'Error', text: 'A technical issue occurred. Please try again.', icon: 'error', confirmButtonColor: '#258' }); resetButton(); } }); } function proceed_registration(formData, fund_id, peserta_id, resetButton) { $.ajax({ type: "POST", url: "daftar_aktiviti_submit2.php", data: formData, dataType: "json", autospin: true, async: false, success: function(d) { if (typeof d === "undefined") { alert("undefined response"); if (typeof resetButton === "function") resetButton(); return; } let redir = '', title = '', text = ''; switch (d.status_val) { case -1: Swal.fire({ title: 'Error', text: 'Emel Anda Tidak Sah', icon: 'error', confirmButtonColor: '#258' }).then(() => { if (typeof resetButton === "function") resetButton(); }); break; case -2: Swal.fire({ title: 'Error', text: 'Pendaftaran Peserta Tidak Berjaya', icon: 'error', confirmButtonColor: '#258' }).then(() => { if (typeof resetButton === "function") resetButton(); }); break; case -3: Swal.fire({ title: 'Error', text: 'Anda telah mendaftar untuk aktiviti ini sebelum ini. Jika anda ingin menyunting maklumat penyertaan, sila gunakan pautan dalam emel yang diterima.', icon: 'error', confirmButtonColor: '#258' }).then(() => { location.href = '../peserta/akaun_saya.php?aktiviti_id=' + $("#kk_aktiviti_id").val() + '&org_id=' + $("#org_id").val(); }); break; case 20: Swal.fire({ title: 'Participant already exists.', text: d.msg || 'Participant already exists.', icon: 'warning', confirmButtonColor: '#258' }).then(() => { if (typeof resetButton === "function") resetButton(); }); break; case 21: Swal.fire({ title: 'Duplicate Selection', text: d.msg || 'You have already registered for this package. Please choose another option.', icon: 'warning', confirmButtonColor: '#258' }).then(() => { if (typeof resetButton === "function") resetButton(); }); 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 (d.peserta_id > 0) { redir = "../peserta/bayar_kariah_list_selected.php?kk_fund_id=" + fund_id + "&peserta_id=" + d.peserta_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 || 'A technical issue occurred. Please try again.', icon: 'error', confirmButtonColor: '#258' }).then(() => { if (typeof resetButton === "function") resetButton(); }); break; } }, error: function() { Swal.fire({ title: 'Error', text: 'A technical issue occurred. Please try again.', icon: 'error', confirmButtonColor: '#258' }).then(() => { if (typeof resetButton === "function") resetButton(); }); } }); } 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: ' Skrin Penuh', 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: ' Skrin Biasa', 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: ' Tutup', 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: ' Skrin Penuh', 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: ' Skrin Biasa', 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: ' Tutup', 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: '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-6', icon: 'fa fa-expand', label: ' Skrin Penuh', 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: ' Skrin Biasa', 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: ' Tutup', 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: 'Adakah Anda Pasti?', text: 'Tindakan ini tidak boleh diundur', icon: 'warning', showCancelButton: true, cancelButtonText: 'Tidak', confirmButtonText: 'Ya', 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('Fail telah dipadam',"success"); }) }) } function padam_fail_custom(id,type,peserta_id,maya_file_page_id){ Swal.fire({ title: 'Adakah Anda Pasti?', text: 'Tindakan ini tidak boleh diundur', icon: 'warning', showCancelButton: true, cancelButtonText: 'Tidak', confirmButtonText: 'Ya', 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('Fail telah dipadam',"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: 'Maklumat Sijil', 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: 'Skrin Penuh', 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: 'Skrin Biasa', 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: 'Tutup', 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: 'Maklumat eCard', 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: 'Skrin Penuh', 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: 'Skrin Biasa', 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: 'Tutup', 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: 'Maklumat eCard', 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: 'Skrin Penuh', 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: 'Skrin Biasa', 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: 'Tutup', 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: 'Tutup', 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 Telah Ditambah',"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 Telah Dipadam',"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: 'Kemaskini Alamat', 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: 'Tutup', cssClass: 'btn-danger', autospin: false, action: function(dialog){ dialog.close(); } },{ id: 'kemaskini-alamat-1', icon: 'fa fa-edit', label: 'Kemaskini', 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: 'Rekod Alamat telah berjaya dikemaskini' }).show(); dialog.close(); } else { Swal.fire({ title: 'Masalah Teknikal', text: 'Rekod cuba dikemaskini tanpa melalui modul yang sah', 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('Anda Wajib Bersetuju','Kami mewajibkan anda bersetuju dengan terma dan syarat yang ditetapkan sebelum anda boleh mendaftar menjadi ahli',"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: 'Daftar Masuk ke ', 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+")"); $("form#daftar_aktiviti_form").attr('action', "javascript:daftar_aktiviti_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("Pilih"); $("div#div_"+fund_id +" a").html("Pilihan Anda"); $("input#chosen_package").val(fund_id); pakejInput = document.getElementById("chosen_package"); if (pakejInput) 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: 'Lihat Maklumat Ahli', 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: 'Tutup', 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("Emel","Emel Lama"); else return html.replace("Emel Lama","Emel"); }); } function swal_no_rec_found_reg_new(kariah_id) { if(!kariah_id) kariah_id = 59; Swal.fire({ title: 'Rekod Tidak Dijumpai', text: 'Tiada emel didaftar dibawah Nama/No KP/Telefon Bimbit berkenaan', icon: 'warning', showCancelButton: true, cancelButtonText: 'Tutup', confirmButtonText: 'Daftar Profil Baharu', 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('Maklumat Diperlukan','Perlu mengisi Nama Penuh atau No KP atau No Telefon Bimbit',"danger"); //alert("Perlu mengisi Nama Penuh atau No KP atau No Telefon Bimbit"); $('#forgot_mykad') //.attr('data-toggle', 'tooltip').attr('title', 'Perlu mengisi Nama Penuh atau No KP atau No Telefon Bimbit').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("Tiada emel didaftar dibawah Nama/No KP/Telefon Bimbit berkenaan"); 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', 'Alamat emel anda dikabui untuk menjaga privasi anda. Sila gantikan * dengan emel penuh anda').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('  Sedang Memproses...'); // 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: 'Terima Kasih', text: 'Anda telah mendaftar diri ke organisasi ini', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Daftar"); 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: 'Anda Pernah Mendaftar', text: 'Semakan menunjukkan anda pernah mendaftar ke ' + dd.kariah_fullname + (dd.peserta_email ? ' sebelum ini. Sila log masuk menggunakan emel ' : ' sebelum ini. Sila log masuk.') + dd.peserta_email, icon: 'error', showCancelButton: false, confirmButtonColor: '#258' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Daftar"); 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 = 'Anda telah didaftarkan ke organisasi ini. Walaubagaimanapun, anda pernah menggunakan sistem ini sebelum ini. Sila log masuk menggunakan emel (%s) dan kata laluan yang pernah didaftarkan. Sekiranya anda lupa katalaluan, sila gunakan fungsi Lupa Katalaluan'.replace("%s", dd.peserta_email); Swal.fire({ title: 'Terima Kasih', text: respText, icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Daftar"); // 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: 'Ralat', text: 'Emel Anda Tidak Sah', icon: 'error' }).then(() => { // Reset button state $submitButton.prop("disabled", false); $submitButton.html("Daftar"); 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: 'Batal Penyertaan', cancelButtonText: 'Tidak, saya akan hadir' }).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: 'Anda belum daftar masuk sistem', text: 'Sila daftar masuk dahulu', confirmButtonText: 'OK' }).then(function() { window.location.href = '/peserta/login.php'; }); } }, error: function(xhr) { // all other errors var msg = 'Ralat'; try { var json = JSON.parse(xhr.responseText); if (json.msg) msg = json.msg; } catch (e) { /* ignore */ } Swal.fire({ icon: 'error', title: 'Ralat', 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("Maklumat berjaya dikemaskini","success"); else show_note_5sec("Kemaskini Tidak Berjaya: "+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: 'Skrin Penuh', 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: 'Skrin Biasa', 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: 'Tutup', 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("Pautan berjaya disalin","" + 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: $('
    Sedang diproses...').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: 'Nilai Perlu Dimasukkan', html: 'Nilai yang dimasukkan mesti lebih atau sama dengan RM2.00', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, cancelButtonText: 'Batal', confirmButtonText: 'Simpan', showLoaderOnConfirm: true, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { var fixed_value = parseFloat(result.value).toFixed(2); if (fixed_value<2) { Swal.fire('Nilai Mesti Lebih RM2.00','Sila masukkan nilai yang lebih besar atau sama dengan 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('Kemaskini') } } }); } else if (check_fund_value(kariah_fund_id)=="-1"){ Swal.fire('Ralat','Produk/Perkhidmatan yang dipilih tidak wujud',"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: 'Berjaya', text: 'Anda telah berjaya menjadi ahli rasmi', 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: 'Berjaya', text: 'Anda telah menjadi ahli rasmi', icon: 'success', showCancelButton: false, confirmButtonColor: '#258' }).then((result) => { if (result.value) { dialog.close(); } }); } else { Swal.fire({ title: 'Masalah Teknikal', text: 'Sila cuba kembali', 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 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('Ralat Format No Kad Pengenalan','Sila masukkan nombor kad pengenalan yang betul',"error"); } } else { Swal.fire('Sudah Mencapai Had Tanggungan Waris','Anda telah mencapai had jumlah tanggungan waris yang telah ditetapkan oleh organisasi anda.',"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('Ralat Format No Kad Pengenalan','Sila masukkan nombor kad pengenalan yang betul',"error"); } } } else { Swal.fire('Sudah Mencapai Had Tanggungan Waris','Anda telah mencapai had jumlah tanggungan yang telah ditetapkan oleh organisasi anda.',"error"); } } function padam_teammates(teammates_id){ Swal.fire({ title: 'Adakah Anda Pasti?', text: 'Tindakan ini tidak boleh diundur', icon: 'warning', showCancelButton: true, cancelButtonText: 'Tidak', confirmButtonText: 'Ya', 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 toggleMembershipHistory(buttonElement, containerId) { const container = document.getElementById(containerId); if (!container) return; const hiddenEntries = container.querySelectorAll('.hidden-entry'); const icon = buttonElement.querySelector('i'); const labelTextSpan = buttonElement.querySelector('.label-text'); let isShowingMore = false; // Check the current state // Check the current state: if hidden entries are visible (not display:none), then we're showing more if (hiddenEntries.length > 0) { const computedStyle = window.getComputedStyle(hiddenEntries[0]); isShowingMore = computedStyle.display !== 'none'; } if (isShowingMore) { // HIDE extra entries hiddenEntries.forEach(entry => { entry.style.display = 'none'; }); if (icon) { icon.classList.remove('fa-chevron-up'); icon.classList.add('fa-chevron-down'); } if (labelTextSpan) labelTextSpan.textContent = 'more'; buttonElement.title = 'more_info_about_membership'; } else { // SHOW extra entries hiddenEntries.forEach(entry => { entry.style.display = 'block'; }); if (icon) { icon.classList.remove('fa-chevron-down'); icon.classList.add('fa-chevron-up'); } if (labelTextSpan) labelTextSpan.textContent = 'less'; buttonElement.title = 'less_info_about_membership'; } }