function fillData(r){ const docketNo = clean(r.docket_no || r.docket || r[“Docket No”]); const fromStation = clean(r.from_station || r.from || r[“FROM Station”]); const toStation = clean(r.to_station || r.to || r[“TO Station”]); const bookingDate = formatDate(r.booking_date || r.date || r[“Date”] || r[“Booking Date”]); const dispatchDate = formatDate(r.dispatch_date || r[“Dispatch Date”]); const status = clean(r.current_status || r.status || r[“Status”]); const expectedDelivery = formatDate(r.expected_delivery || r[“Expected Delivery”]); const deliveryDate = formatDate(r.delivery_date || r[“Delivery Date”]); const payMode = clean(r.payment_mode || r.mode_of_payment || r[“Mode of Payment”]); const freightAmount = clean(r.freight_amount || r.grand_total || r[“Freight Amount”] || r[“Grand Total”]); const officerNo = clean(r.delivery_officer_no || r.delivery_point_officer_no || r.officer_no || r[“Delivery Officer Number”]); const customerMobile = clean(r.consignee_mobile || r.customer_mobile || r.mobile || r[“Consignee Mobile”] || r[“Mobile”]); const routeText = fromStation + ” → ” + toStation; $(“v_docket”).textContent = docketNo; $(“v_route”).textContent = routeText; $(“v_booking”).textContent = bookingDate; $(“v_dispatch”).textContent = dispatchDate; $(“v_expected”).textContent = expectedDelivery; $(“v_delivery”).textContent = deliveryDate; $(“v_paymode”).textContent = payMode; $(“v_freight”).textContent = freightAmount; $(“v_officer”).textContent = officerNo; setStatusBadge(status); const payModeNorm = String(payMode || “”).toLowerCase().replace(/[\s\-]/g, “”); const statusNorm = String(status || “”).toLowerCase().trim(); const isToPay = (payModeNorm === “topay”); const isDelivered = (statusNorm === “delivered”); const hasMobile = !!digitsOnly(customerMobile); const hasOfficer = !!digitsOnly(officerNo); const hasDeliveryDate = deliveryDate && deliveryDate !== “-“; const hasFreight = freightAmount && freightAmount !== “-” && freightAmount !== “0”; // ToPay box only for ToPay $(“topayBox”).classList.toggle(“hidden”, !isToPay); const bookingMsg = `CTLink Cargo 🚚 Your shipment has been booked successfully. Docket No: ${docketNo} Route: ${routeText} Booking Date: ${bookingDate} Expected Delivery: ${expectedDelivery} Track your shipment with CTLink Cargo.`; const deliveryMsg = `CTLink Cargo ✅ Your shipment has been delivered. Docket No: ${docketNo} Route: ${routeText} Delivery Date: ${deliveryDate} Status: ${status} Delivery Contact: ${officerNo}`; const freightMsg = `CTLink Cargo Reminder 💰 Your shipment is ready for delivery. Docket No: ${docketNo} Route: ${routeText} Freight Amount: ${freightAmount} Payment Mode: ${payMode} For delivery assistance contact: ${officerNo}`; // booking button setWAButtonState( $(“wa_booking”), hasMobile, customerMobile, bookingMsg, hasMobile ? “” : “Customer mobile not available” ); // delivery button: only if Delivered + mobile + delivery date + officer no setWAButtonState( $(“wa_delivery”), (isDelivered && hasMobile && hasDeliveryDate && hasOfficer), customerMobile, deliveryMsg, !isDelivered ? “Delivery message only after Delivered status” : !hasDeliveryDate ? “Delivery date missing” : !hasOfficer ? “Delivery officer number missing” : !hasMobile ? “Customer mobile not available” : “” ); // freight button: only if ToPay + mobile + freight amount setWAButtonState( $(“wa_freight”), (isToPay && hasMobile && hasFreight), customerMobile, freightMsg, !isToPay ? “Freight reminder only for ToPay shipments” : !hasFreight ? “Freight amount missing” : !hasMobile ? “Customer mobile not available” : “” ); }
Scroll to Top