fix cleint portal employee-data, dashboard, hide notification

This commit is contained in:
Muhammad Fajar
2023-12-31 23:44:43 +07:00
parent ae884f8cd0
commit 96034d069a
26 changed files with 684 additions and 804 deletions

View File

@@ -13,17 +13,17 @@ use App\Models\Service;
class Helper
{
public static function genderNormalization($anyGenderCode)
public static function genderNormalization($anyGenderCode = '-')
{
if ($anyGenderCode == 'M') {
return 'Male';
return 'male';
} else if ($anyGenderCode == 'F') {
return 'Female';
return 'female';
} else if ($anyGenderCode == 'O') {
return 'Others';
return 'others';
} else if ($anyGenderCode == 'U') {
return 'Unknown';
return 'unknown';
} else {
return '-';
}
@@ -57,7 +57,8 @@ class Helper
}
}
public static function memberType($code){
public static function memberType($code)
{
if ($code == 'P') {
return 'Principal';
} else if ($code == 'D') {
@@ -67,30 +68,29 @@ class Helper
}
}
public static function relationWithPrincipal($code){
public static function relationWithPrincipal($code)
{
if ($code == 'H') {
return 'Husbund';
}
else if ($code == 'W') {
} else if ($code == 'W') {
return 'Wife';
}
else if ($code == 'S') {
} else if ($code == 'S') {
return 'Son';
}
else if ($code == 'D') {
} else if ($code == 'D') {
return 'Daughter';
}
else {
} else {
'-';
}
}
public static function principalName($code){
public static function principalName($code)
{
$principalName = Member::where('member_id', $code)->get()->first();
return $principalName->name;
}
public static function serviceName($code){
public static function serviceName($code)
{
$serviceName = Service::where('code', $code)->get()->first();
return $serviceName->name;
}
@@ -241,10 +241,11 @@ class Helper
], $statusCode);
}
public static function validatePhoneNumber($phoneNumber) {
public static function validatePhoneNumber($phoneNumber)
{
// Menghapus semua karakter selain angka dan +
$cleanedNumber = preg_replace('/[^0-9+]/', '', $phoneNumber);
// Memeriksa apakah nomor telepon hanya terdiri dari angka dan +
if ($cleanedNumber == $phoneNumber) {
// Nomor telepon valid
@@ -255,11 +256,13 @@ class Helper
}
}
public static function formatRupiah($angka) {
public static function formatRupiah($angka)
{
return "Rp " . number_format($angka, 0, ',', '.');
}
public static function sPaymentMethod($id) {
public static function sPaymentMethod($id)
{
$sPaymentMethod = [
1 => 'Pribadi',
2 => 'On-Site Payment',
@@ -268,17 +271,19 @@ class Helper
5 => 'Voucher',
6 => 'ASO'
];
return $sPaymentMethod[$id];
}
public static function formatDateDB($date){
public static function formatDateDB($date)
{
$convertedDate = Carbon::createFromFormat('d-m-Y', $date)->format('Y-m-d H:i:s');
return $convertedDate;
}
public static function formatDateOnly($date){
public static function formatDateOnly($date)
{
// Membuat objek Carbon dengan tanggal asli dan zona waktu UTC
$carbonDate = Carbon::createFromFormat('Y-m-d\TH:i:s.u\Z', $date, 'UTC');
@@ -289,7 +294,8 @@ class Helper
return $convertedDate;
}
public static function formatTimeOnly($date){
public static function formatTimeOnly($date)
{
// Membuat objek Carbon dengan tanggal asli dan zona waktu UTC
$carbonDate = Carbon::createFromFormat('Y-m-d\TH:i:s.u\Z', $date, 'UTC');
@@ -307,8 +313,7 @@ class Helper
DB::table('notifications')->insert($data);
DB::commit();
return true;
}
catch (\Exception $e) {
} catch (\Exception $e) {
DB::rollback();
return $e->getMessage();
}
@@ -320,28 +325,27 @@ class Helper
$mail = new PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = env('EMAIL');
$mail->Password = env('PW_EMAIL');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = env('EMAIL');
$mail->Password = env('PW_EMAIL');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
// Penerima email
$mail->setFrom(env('EMAIL'), env('NAME_EMAIL'));
$mail->addAddress($data['email'], $data['name']);
// Konten email
$mail->isHTML(true);
$mail->isHTML(true);
$mail->Subject = $data['subject'];
$mail->Body = $data['body'];
// Kirim email
$mail->send();
return true;
} catch (\Exception $e) {
dd($e);
return ($mail->ErrorInfo);
@@ -355,21 +359,21 @@ class Helper
$mail = new PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = env('EMAIL');
$mail->Password = env('PW_EMAIL');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = env('EMAIL');
$mail->Password = env('PW_EMAIL');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
// Penerima email
$mail->setFrom(env('EMAIL'), env('NAME_EMAIL'));
$mail->addAddress($data['email'], $data['name']);
// Konten email
$mail->isHTML(true);
$mail->isHTML(true);
$mail->Subject = $data['subject'];
$mail->Body = $data['body'];
$mail->addAttachment($data['attach'], 'e-card.pdf');
@@ -377,12 +381,10 @@ class Helper
// Kirim email
$mail->send();
return true;
} catch (\Exception $e) {
dd($mail->ErrorInfo);
return ($mail->ErrorInfo);
return false;
}
}
}