Procházet zdrojové kódy

Use checkin/checkout times in template date substitution

ZiB před 4 měsíci
rodič
revize
1a1d8ddcbd
1 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 11 2
      room_cal/vue/calendar.html

+ 11 - 2
room_cal/vue/calendar.html

@@ -1575,8 +1575,13 @@ createApp({
       if (!raw) return;
       if (!raw) return;
       const sel   = selection.value;
       const sel   = selection.value;
       const dtFmt = chatTemplatesDtFmt.value;
       const dtFmt = chatTemplatesDtFmt.value;
-      const checkin  = sel?.checkin_date  ? parseLocal(sel.checkin_date)  : null;
-      const checkout = sel?.checkout_date ? parseLocal(sel.checkout_date) : null;
+      const parseWithTime = (dateStr, timeStr) => {
+        const d = parseLocal(dateStr);
+        if (timeStr) { const [h, m] = timeStr.split(':').map(Number); d.setHours(h, m); }
+        return d;
+      };
+      const checkin  = sel?.checkin_date  ? parseWithTime(sel.checkin_date,  sel.checkin_time)  : null;
+      const checkout = sel?.checkout_date ? parseWithTime(sel.checkout_date, sel.checkout_time) : null;
       const fmtDate_ = (d, fmt) => d ? _strftime(fmt || dtFmt, d) : '';
       const fmtDate_ = (d, fmt) => d ? _strftime(fmt || dtFmt, d) : '';
       const resId = [serviceName(sel?.service), sel?.reservation_id].filter(Boolean).join(' ');
       const resId = [serviceName(sel?.service), sel?.reservation_id].filter(Boolean).join(' ');
       chatReply.value = raw.replace(/\{(\w+)(?::([^}]*))?\}/g, (_, key, fmt) => {
       chatReply.value = raw.replace(/\{(\w+)(?::([^}]*))?\}/g, (_, key, fmt) => {
@@ -1999,6 +2004,8 @@ createApp({
         wifi_key:       span.wifi_key,
         wifi_key:       span.wifi_key,
         wifi_ssid:      span.wifi_ssid,
         wifi_ssid:      span.wifi_ssid,
         door_code:      span.door_code,
         door_code:      span.door_code,
+        checkin_time:   span.checkin_time,
+        checkout_time:  span.checkout_time,
       };
       };
     }
     }
 
 
@@ -2028,6 +2035,8 @@ createApp({
           wifi_key:       res.wifi_key ?? null,
           wifi_key:       res.wifi_key ?? null,
           wifi_ssid:      res.wifi_ssid ?? null,
           wifi_ssid:      res.wifi_ssid ?? null,
           door_code:      res.door_code ?? null,
           door_code:      res.door_code ?? null,
+          checkin_time:   res.checkin_time ?? null,
+          checkout_time:  res.checkout_time ?? null,
         });
         });
       }
       }
       return spans;
       return spans;