From 56a957a3dc1399b8eb51eb3653172a1c49a8eb8d Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Wed, 20 Nov 2024 23:31:53 +0800 Subject: [PATCH 1/2] added function to detect customers that underage --- resources/views/customers/v2/index.blade.php | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/resources/views/customers/v2/index.blade.php b/resources/views/customers/v2/index.blade.php index b151aea..c96a8db 100644 --- a/resources/views/customers/v2/index.blade.php +++ b/resources/views/customers/v2/index.blade.php @@ -1222,6 +1222,31 @@ var id_type = $('#customerIDType').val(); var nokp = $('#noic').val(); if(id_type=='nokp'){ + const date = nokp.substring(0, 6); + const year = parseInt(date.substring(0, 2), 10); + const month = parseInt(date.substring(2, 4), 10) - 1; + const day = parseInt(date.substring(4, 6), 10); + + const cutofYear = 10; + + const fullYear = year < cutofYear ? 2000 + year : 1900 + year; + const dateconvert = new Date(fullYear, month, day); + const today = new Date(); + + const eighteenthBirthday = new Date(dateconvert); + + eighteenthBirthday.setFullYear(dateconvert.getFullYear() + 18); + + if (today < eighteenthBirthday) { + Swal.fire({ + icon: 'error', + title: 'Amaran!', + text: 'Pelanggan Ini Dibawah Umur!' + }); + event.preventDefault(); + return false; + } + if($.isNumeric(nokp) == false){ if(nokp.substr(-1) != '*') { From 9b23f52180bf68592d5caa0c8189cd34f0c7ecb0 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Thu, 21 Nov 2024 11:00:45 +0800 Subject: [PATCH 2/2] fix commit notification bawah umur --- resources/views/customers/v2/index.blade.php | 30 +++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/resources/views/customers/v2/index.blade.php b/resources/views/customers/v2/index.blade.php index c96a8db..28f9542 100644 --- a/resources/views/customers/v2/index.blade.php +++ b/resources/views/customers/v2/index.blade.php @@ -527,6 +527,34 @@ function newcustomer(){ var id_type = $('#customerIDType').val(); + var nokp = $('#noic').val(); + + const date = nokp.substring(0, 6); + const year = parseInt(date.substring(0, 2), 10); + const month = parseInt(date.substring(2, 4), 10) - 1; + const day = parseInt(date.substring(4, 6), 10); + + const cutofYear = 20; + + const fullYear = year < cutofYear ? 2000 + year : 1900 + year; + const dateconvert = new Date(fullYear, month, day); + const today = new Date(); + + const eighteenthBirthday = new Date(dateconvert); + + eighteenthBirthday.setFullYear(dateconvert.getFullYear() + 18); + console.log(today,eighteenthBirthday); + if (today < eighteenthBirthday) { + Swal.fire({ + icon: 'error', + title: 'Amaran!', + text: 'Pelanggan Ini Dibawah Umur!' + }); + event.preventDefault(); + return false; + } + + if(id_type=='nokp'){ $('#daftar_pelanggan').modal('show'); }else if(id_type=='passport'){ @@ -1227,7 +1255,7 @@ const month = parseInt(date.substring(2, 4), 10) - 1; const day = parseInt(date.substring(4, 6), 10); - const cutofYear = 10; + const cutofYear = 20; const fullYear = year < cutofYear ? 2000 + year : 1900 + year; const dateconvert = new Date(fullYear, month, day);