diff --git a/routes/adminPortal.js b/routes/adminPortal.js index 4d6eab7..9a7c751 100644 --- a/routes/adminPortal.js +++ b/routes/adminPortal.js @@ -3499,6 +3499,14 @@ router.post('/tickets/create', requireAdminSession, express.urlencoded({ extende const custPhone = cust ? cust.phone : '-'; const custAddr = cust ? cust.address : '-'; + const _waDigits = String(custPhone || '').replace(/\D/g, '').replace(/^0/, '62'); + const _mapQ = (cust && cust.lat && cust.lng) ? (cust.lat + ',' + cust.lng) : String(custAddr || ''); + const _base = (getSetting('public_base_url', '') || getSetting('app_url', '') || ('http://' + (req.get('host') || ''))).replace(/\/+$/, ''); + const _links = `\n๐Ÿ”— *Tautan Cepat:*\n` + + (_waDigits ? `โ€ข ๐Ÿ’ฌ Chat Pelanggan: https://wa.me/${_waDigits}\n` : '') + + (_mapQ ? `โ€ข ๐Ÿ“ Lokasi: https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(_mapQ)}\n` : '') + + `โ€ข ๐Ÿงพ Detail Pelanggan: ${_base}/admin/customers?search=${encodeURIComponent(custPhone || custName)}\n` + + `โ€ข ๐Ÿ› ๏ธ Pool Tiket Teknisi: ${_base}/tech/pool`; const waMsg = `๐Ÿ“Œ *TUGAS TEKNISI BARU DARI ADMIN*\n\n` + `๐ŸŽซ *ID Tiket:* #${ticketId}\n` + `๐Ÿ‘ค *Pelanggan/Objek:* ${custName}\n` + @@ -3506,7 +3514,7 @@ router.post('/tickets/create', requireAdminSession, express.urlencoded({ extende `๐Ÿ“ *Alamat:* ${custAddr}\n` + `๐Ÿ“ *Kendala/Tugas:* ${subject}\n` + `๐Ÿ’ฌ *Detail Pesan:* ${message}\n\n` + - `Silakan cek di portal teknisi/admin untuk menindaklanjuti.`; + `Silakan cek di portal teknisi/admin untuk menindaklanjuti.` + _links; // Send to assigned technician or broadcast to all active technicians if not assigned if (tech && tech.phone) { diff --git a/routes/customerPortal.js b/routes/customerPortal.js index 9e23f35..9ba7b6c 100644 --- a/routes/customerPortal.js +++ b/routes/customerPortal.js @@ -2945,13 +2945,21 @@ router.post('/tickets/create', uploadCustomer.array('photos', 5), async (req, re const photoCount = photoPaths.length; const photoText = photoCount > 0 ? `\n๐Ÿ“ธ *Foto Masalah:* ${photoCount} foto terlampir` : ''; + const _waDigits = normalizeWaDigits(customer ? customer.phone : ''); + const _mapQ = (customer && customer.lat && customer.lng) ? (customer.lat + ',' + customer.lng) : String(customer ? customer.address : ''); + const _base = (String(settings.public_base_url || '') || String(settings.app_url || '') || ('http://' + (req.get('host') || ''))).replace(/\/+$/, ''); + const _links = `\n๐Ÿ”— *Tautan Cepat:*\n` + + (_waDigits ? `โ€ข ๐Ÿ’ฌ Chat Pelanggan: https://wa.me/${_waDigits}\n` : '') + + (_mapQ ? `โ€ข ๐Ÿ“ Lokasi: https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(_mapQ)}\n` : '') + + `โ€ข ๐Ÿงพ Detail Pelanggan: ${_base}/admin/customers?search=${encodeURIComponent(customer ? (customer.phone || customer.name) : '')}\n` + + `โ€ข ๐Ÿ› ๏ธ Pool Tiket Teknisi: ${_base}/tech/pool`; const waMsg = `๐ŸŽซ *TIKET KELUHAN BARU*\n\n` + `๐Ÿ‘ค *Pelanggan:* ${customer ? customer.name : 'Unknown'}\n` + `๐Ÿ“ž *WhatsApp:* ${customer ? customer.phone : '-'}\n` + `๐Ÿ“ *Alamat:* ${customer ? customer.address : '-'}\n` + `๐Ÿ“ *Subjek:* ${subject}\n` + `๐Ÿ’ฌ *Pesan:* ${message}${photoText}\n\n` + - `Silakan cek di panel Admin/Teknisi untuk menindaklanjuti.`; + `Silakan cek di panel Admin/Teknisi untuk menindaklanjuti.` + _links; const recipients = new Set(); if (settings.whatsapp_admin_numbers && settings.whatsapp_admin_numbers.length > 0) {