diff --git a/app/Http/Controllers/Admin/PesananFotoController.php b/app/Http/Controllers/Admin/PesananFotoController.php index 2c4be67..1fe3426 100644 --- a/app/Http/Controllers/Admin/PesananFotoController.php +++ b/app/Http/Controllers/Admin/PesananFotoController.php @@ -34,7 +34,7 @@ public function updateStatus(Request $request, $id) session()->flash('success', "Booking {$pesanan->no_invoice} telah diterima!"); } elseif ($request->jenis === 'selesai') { $status = 'selesai'; - session()->flash('success', "Pesanan {$pesanan->no_invoice} berhasil diselesaikan!"); + session()->flash('success', "Booking {$pesanan->no_invoice} berhasil diselesaikan!"); } else { $status = 'ditolak'; session()->flash('error', "Booking {$pesanan->no_invoice} telah ditolak!"); @@ -67,6 +67,7 @@ public function updateStatus(Request $request, $id) } // 6. Susun Pesan WA + $msg = null; if ($status === 'diterima') { $msg = "Halo Kak *{$nama}* ,\n\n" . "Booking foto Anda dengan Invoice: *{$invoice}* telah kami *TERIMA*. \n\n" . @@ -78,7 +79,7 @@ public function updateStatus(Request $request, $id) " Tanggal: {$tanggal}\n" . " Jam: {$jam_mulai} - {$jam_selesai} WIB\n\n" . "Mohon datang 15 menit sebelum jadwal dimulai ya Kak. Sampai jumpa di studio! "; - } else { + } elseif ($status === 'ditolak') { $msg = "Halo Kak *{$nama}*,\n\n" . "Mohon maaf, booking foto Anda dengan Invoice *{$invoice}* terpaksa kami *TOLAK* dikarenakan:\n\n" . "*[TULIS ALASAN DI SINI]*\n\n" . @@ -93,17 +94,24 @@ public function updateStatus(Request $request, $id) } // 7. Format Nomor WhatsApp (Sesuaikan kolom: no_hp / no_wa) - $no_wa = preg_replace('/[^0-9]/', '', $pesanan->pelanggan->no_wa); + $wa_url = null; - if (str_starts_with($no_wa, '0')) { - $no_wa = '62' . substr($no_wa, 1); - } elseif (str_starts_with($no_wa, '8')) { - $no_wa = '62' . $no_wa; + if ($msg) { + $no_wa = preg_replace('/[^0-9]/', '', $pesanan->pelanggan->no_wa); + + if (str_starts_with($no_wa, '0')) { + $no_wa = '62' . substr($no_wa, 1); + } elseif (str_starts_with($no_wa, '8')) { + $no_wa = '62' . $no_wa; + } + + $wa_url = "https://wa.me/{$no_wa}?text=" . urlencode($msg); } + return response()->json([ 'success' => true, - 'wa_url' => "https://wa.me/{$no_wa}?text=" . urlencode($msg) + 'wa_url' => $wa_url ]); } catch (\Exception $e) { return response()->json(['success' => false, 'message' => $e->getMessage()], 500); diff --git a/resources/views/admin/pesanan/partials/modal-foto.blade.php b/resources/views/admin/pesanan/partials/modal-foto.blade.php index 6176321..36765e1 100755 --- a/resources/views/admin/pesanan/partials/modal-foto.blade.php +++ b/resources/views/admin/pesanan/partials/modal-foto.blade.php @@ -1,10 +1,10 @@ -