-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
915 lines (868 loc) · 37.4 KB
/
Copy pathindex.html
File metadata and controls
915 lines (868 loc) · 37.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>TLS Store Visit Summary</title>
<link rel="manifest" href="manifest.json">
<link rel="icon" href="icons/icon-512.png" type="image/png">
<link rel="apple-touch-icon" href="icons/icon-180.png">
<meta name="theme-color" content="#14532d">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="TLS Walk">
<style>
:root{
--ink:#1c2b26;
--ink-soft:#5a6b64;
--paper:#f5f4ef;
--card:#ffffff;
--line:#e2e1d9;
--green:#1f6f43;
--green-deep:#14532d;
--gold:#b8860b;
--gold-bg:#fdf3d7;
--ok:#1f6f43;
--ok-bg:#e3f1e8;
--warn:#c05d0e;
--warn-bg:#fdeadb;
--flag:#b91c1c;
--flag-bg:#fbe3e3;
--radius:14px;
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html{font-size:16px}
body{
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
background:var(--paper);color:var(--ink);
padding-bottom:110px;
}
/* ---------- header ---------- */
header{
position:sticky;top:0;z-index:50;
background:var(--green-deep);color:#fff;
padding:12px 16px 10px;
box-shadow:0 2px 8px rgba(0,0,0,.18);
}
.new-report-btn{
position:absolute;top:10px;right:14px;
background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.35);color:#fff;
border-radius:20px;padding:5px 10px;font-size:.68rem;font-weight:700;cursor:pointer;
}
header h1{font-size:1rem;font-weight:700;letter-spacing:.02em;padding-right:70px}
header .sub{font-size:.72rem;opacity:.75;margin-top:2px}
.progress-wrap{margin-top:8px;display:flex;align-items:center;gap:10px}
.progress-bar{flex:1;height:6px;background:rgba(255,255,255,.22);border-radius:3px;overflow:hidden}
.progress-fill{height:100%;width:0%;background:#facc15;border-radius:3px;transition:width .3s}
.progress-num{font-size:.72rem;font-variant-numeric:tabular-nums;opacity:.9;white-space:nowrap}
/* ---------- layout ---------- */
main{max-width:640px;margin:0 auto;padding:16px 14px}
.card{
background:var(--card);border:1px solid var(--line);border-radius:var(--radius);
padding:16px;margin-bottom:14px;
}
.card h2{font-size:1.05rem;font-weight:800;letter-spacing:.01em;display:flex;align-items:center;gap:8px}
.card h2 .badge{margin-left:auto;font-size:.68rem;font-weight:700;color:var(--ink-soft);background:var(--paper);border:1px solid var(--line);border-radius:20px;padding:3px 9px;font-variant-numeric:tabular-nums}
.hint{font-size:.78rem;color:var(--ink-soft);margin-top:4px;line-height:1.45}
label.field{display:block;font-size:.75rem;font-weight:700;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.05em;margin:14px 0 5px}
input[type=text],input[type=date],input[type=email],textarea{
width:100%;border:1.5px solid var(--line);border-radius:10px;background:#fff;
padding:11px 12px;font-size:1rem;font-family:inherit;color:var(--ink);
}
input:focus,textarea:focus{outline:none;border-color:var(--green)}
textarea{resize:vertical;min-height:74px;line-height:1.45}
/* format chips */
.chips{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:6px}
.chip{
border:1.5px solid var(--line);border-radius:10px;background:#fff;
padding:11px 8px;font-size:.9rem;font-weight:600;color:var(--ink);text-align:center;cursor:pointer;
}
.chip.sel{background:var(--green);border-color:var(--green);color:#fff}
/* ---------- rating legend ---------- */
.legend{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-top:10px}
.legend div{font-size:.68rem;text-align:center;color:var(--ink-soft);line-height:1.3}
.legend b{display:block;font-size:1.05rem}
/* ---------- department nav ---------- */
.dept-head{
background:var(--green-deep);color:#fff;border-radius:var(--radius);
padding:13px 16px;margin:20px 0 10px;display:flex;align-items:center;justify-content:space-between;cursor:pointer;
user-select:none;
}
.dept-head h2{font-size:1rem;font-weight:800;letter-spacing:.03em}
.dept-head .count{font-size:.72rem;background:rgba(255,255,255,.16);border-radius:20px;padding:3px 10px;font-variant-numeric:tabular-nums}
.dept-head .caret{margin-left:10px;transition:transform .2s}
.dept-head.open .caret{transform:rotate(180deg)}
.dept-body{display:none}
.dept-body.open{display:block}
.subsec{font-size:.85rem;font-weight:800;color:var(--green-deep);margin:16px 4px 8px;display:flex;align-items:center;gap:6px}
/* ---------- question ---------- */
.q{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:13px 13px 12px;margin-bottom:9px}
.q p{font-size:.92rem;line-height:1.4;font-weight:500}
.rate{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-top:10px}
.rate button{
border:1.5px solid var(--line);border-radius:10px;background:#fff;
padding:9px 0 7px;font-size:1.15rem;cursor:pointer;line-height:1;
display:flex;flex-direction:column;align-items:center;gap:3px;
}
.rate button small{font-size:.56rem;font-weight:700;letter-spacing:.03em;color:var(--ink-soft);text-transform:uppercase}
.rate button.sel small{color:inherit}
.rate button.sel[data-r="star"]{background:var(--gold-bg);border-color:var(--gold);color:var(--gold)}
.rate button.sel[data-r="good"]{background:var(--ok-bg);border-color:var(--ok);color:var(--ok)}
.rate button.sel[data-r="warn"]{background:var(--warn-bg);border-color:var(--warn);color:var(--warn)}
.rate button.sel[data-r="flag"]{background:var(--flag-bg);border-color:var(--flag);color:var(--flag)}
.notes{margin-top:9px;display:none}
.notes.show{display:block}
.notes textarea{min-height:58px;font-size:.9rem}
.notes .nl{font-size:.68rem;font-weight:700;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.05em;margin-bottom:4px;display:flex;justify-content:space-between}
.notes .req{color:var(--flag)}
.note-toggle{margin-top:8px;background:none;border:none;font-size:.75rem;font-weight:700;color:var(--green);cursor:pointer;padding:2px 0}
.photo-btn{margin-top:8px;background:none;border:1px dashed var(--green);border-radius:8px;font-size:.75rem;font-weight:700;color:var(--green);cursor:pointer;padding:8px 12px;width:100%}
.photo-strip{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.photo-thumb{position:relative;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid var(--line)}
.photo-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.photo-thumb .rm{position:absolute;top:2px;right:2px;width:20px;height:20px;border:none;border-radius:50%;background:rgba(0,0,0,.6);color:#fff;font-size:.7rem;line-height:20px;padding:0;cursor:pointer}
.share-photos-btn{background:#fff;border:1.5px solid var(--green);color:var(--green);border-radius:12px;padding:12px 10px;font-size:.8rem;font-weight:800;cursor:pointer;white-space:nowrap}
/* ---------- overview grid ---------- */
.grid-scroll{overflow-x:auto;margin:10px -4px 0}
table.ov{border-collapse:collapse;width:100%;min-width:520px}
table.ov th{font-size:.62rem;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-soft);padding:6px 4px;text-align:center}
table.ov th:first-child{text-align:left}
table.ov td{padding:3px}
table.ov td.dept{font-size:.78rem;font-weight:700;white-space:nowrap;padding-right:8px}
.cell{
display:flex;align-items:center;justify-content:center;
width:100%;height:38px;border:1.5px solid var(--line);border-radius:8px;background:#fff;
font-size:1rem;
}
.cell.star{background:var(--gold-bg);border-color:var(--gold)}
.cell.good{background:var(--ok-bg);border-color:var(--ok)}
.cell.warn{background:var(--warn-bg);border-color:var(--warn)}
.cell.flag{background:var(--flag-bg);border-color:var(--flag)}
.callout-row{margin-top:10px}
.callout-row label{font-size:.72rem;font-weight:700;color:var(--ink-soft)}
.callout-row textarea{margin-top:3px;font-size:.88rem;padding:10px 12px;min-height:52px;line-height:1.4}
/* ---------- footer bar ---------- */
.footbar{
position:fixed;bottom:0;left:0;right:0;z-index:60;
background:#fff;border-top:1px solid var(--line);
padding:10px 14px calc(10px + env(safe-area-inset-bottom));
}
.footbar-inner{max-width:640px;margin:0 auto;display:flex;gap:10px;align-items:center}
.attn-pill{font-size:.72rem;font-weight:700;color:var(--ink-soft);white-space:nowrap}
.attn-pill b{color:var(--warn)} .attn-pill b.f{color:var(--flag)}
.submit-btn{
flex:1;background:var(--green-deep);color:#fff;border:none;border-radius:12px;
padding:14px;font-size:1rem;font-weight:800;letter-spacing:.02em;cursor:pointer;
}
.submit-btn:active{transform:scale(.985)}
/* toast */
.toast{
position:fixed;left:50%;bottom:90px;transform:translateX(-50%);
background:var(--ink);color:#fff;font-size:.85rem;padding:10px 18px;border-radius:24px;
opacity:0;pointer-events:none;transition:opacity .25s;z-index:99;max-width:88%;text-align:center;
}
.toast.show{opacity:1}
/* confirmation modal */
.confirm-overlay{position:fixed;inset:0;background:rgba(15,30,20,.55);display:none;align-items:center;justify-content:center;z-index:100;padding:24px}
.confirm-overlay.show{display:flex}
.confirm-card{background:#fff;border-radius:16px;padding:26px 22px 20px;max-width:360px;width:100%;text-align:center;box-shadow:0 12px 40px rgba(0,0,0,.25)}
.confirm-icon{font-size:2.2rem;margin-bottom:8px}
.confirm-card h3{font-size:1.05rem;font-weight:800;color:var(--green-deep);margin-bottom:8px}
.confirm-card p{font-size:.88rem;line-height:1.5;color:var(--ink-soft)}
.confirm-ok{margin-top:18px;width:100%;background:var(--green-deep);color:#fff;border:none;border-radius:10px;padding:12px;font-size:.92rem;font-weight:800;cursor:pointer}
</style>
<script data-goatcounter="https://hderek22.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
</head>
<body>
<header>
<button class="new-report-btn" id="newReportBtn" type="button">↺ New</button>
<h1>TLS Store Visit Summary</h1>
<div class="sub">Operational Excellence • Sales • Inventory • Shrink • Food Safety • Personal Safety</div>
<div class="progress-wrap">
<div class="progress-bar"><div class="progress-fill" id="pfill"></div></div>
<div class="progress-num" id="pnum">0 / 0</div>
</div>
</header>
<main>
<!-- ============ COVER ============ -->
<div class="card" id="cover">
<h2>🏪 Visit Cover Page</h2>
<p class="hint">Fill this out first. Cover your summary with the Store Manager, PIC, and Dept. Heads before you leave.</p>
<label class="field">Store Format</label>
<div class="chips" id="fmtChips">
<button class="chip" data-v="Conventional">Conventional</button>
<button class="chip" data-v="Cost Plus">Cost Plus</button>
<button class="chip" data-v="SAL">SAL</button>
<button class="chip" data-v="Food Saver">Food Saver</button>
</div>
<label class="field" for="storeNum">HFG Store Number</label>
<input type="text" id="storeNum" inputmode="numeric" placeholder="e.g. 118">
<label class="field" for="regionNum">Region Number</label>
<input type="text" id="regionNum" inputmode="numeric" placeholder="e.g. 4">
<label class="field" for="mgrName">Store Manager Name</label>
<input type="text" id="mgrName" placeholder="Store manager">
<label class="field" for="tlsName">TLS Name</label>
<input type="text" id="tlsName" placeholder="Your name">
<label class="field" for="visitDate">Date of Visit</label>
<input type="date" id="visitDate">
<label class="field">Rating Scale</label>
<div class="legend">
<div><b>⭐</b>Excellent</div>
<div><b>✅</b>Good</div>
<div><b>⚠️</b>Attention Needed</div>
<div><b>🚩</b>Immediate Action</div>
</div>
</div>
<!-- departments injected here -->
<div id="depts"></div>
<!-- ============ OVERVIEW GRID ============ -->
<div class="card" id="overviewCard">
<h2>📋 High-Level Visit Overview <span class="badge" id="ovBadge"></span></h2>
<p class="hint">This grid fills in automatically from your detailed answers — each cell shows the lowest rating recorded in that area.</p>
<div class="grid-scroll">
<table class="ov">
<thead>
<tr><th>Department</th><th>Sales</th><th>Inventory</th><th>Shrink</th><th>Food Safety</th><th>Safety</th></tr>
</thead>
<tbody id="ovBody"></tbody>
</table>
</div>
<div id="callouts"></div>
</div>
<!-- ============ COACHING SUMMARY ============ -->
<div class="card">
<h2>🗣 Department & Store Coaching Summary</h2>
<p class="hint">Always cover with the Store Manager / PIC before leaving.</p>
<label class="field" for="bestPractices">Best Practices Observed — what is this management team doing well?</label>
<textarea id="bestPractices" placeholder="Wins worth recognizing…"></textarea>
<label class="field" for="opportunities">Opportunities for Improvement</label>
<textarea id="opportunities" placeholder="Key follow-ups and coaching points…"></textarea>
</div>
<!-- ============ SEND ============ -->
<div class="card">
<h2>📧 Send Completed Summary</h2>
<p class="hint">This opens the summary in your email app — you'll still need to tap Send there to deliver it.</p>
<label class="field" for="recipients">Recipients</label>
<input type="email" id="recipients" multiple value="DOusley@houchens.com, MMooney@houchens.com" placeholder="name@houchens.com, name@houchens.com">
</div>
</main>
<div class="footbar">
<div class="footbar-inner">
<div class="attn-pill" id="attnPill"></div>
<button class="share-photos-btn" id="sharePhotosBtn" style="display:none" title="Share attached photos">📷 0</button>
<button class="submit-btn" id="submitBtn">Submit Visit Report</button>
</div>
</div>
<div class="toast" id="toast"></div>
<div class="confirm-overlay" id="confirmOverlay">
<div class="confirm-card">
<div class="confirm-icon">📬</div>
<h3>Report Ready in Mail</h3>
<p id="confirmMsg"></p>
<button class="confirm-ok" id="confirmOk">Got it</button>
</div>
</div>
<script>
/* ================= DATA — from Total Loss Store Visit Workbook ================= */
const CATS = { sales:"📈 Sales Execution", inv:"📦 Inventory Management", shrink:"🗑 Shrink Control", food:"🛡 Food Safety", safety:"👷 Personal Safety" };
const DEPTS = [
{ id:"grocery", name:"GROCERY", sections:{
sales:[
"Shelves are stocked to meet customer satisfaction",
"Out-of-stocks acceptable",
"The Ad is brought to life — promotional displays merchandised to match promos",
"Endcaps support seasonal / promo business",
"Shelf tags accurate / match product"
],
inv:[
"Shelf inventory levels support the Groc. Inv. Reduction Plan (inv. on shelf matches tag movement)",
"Backroom inventory under control",
"Overstock levels being reduced / plan",
"TPRs are assigned where needed"
],
shrink:[
"Rotation followed",
"Damages processed daily",
"Reclaim current"
],
safety:[
"Slip, trip, and fall hazards"
]
}},
{ id:"produce", name:"PRODUCE", sections:{
sales:[
"Fresh appearance",
"Cut fruit quality / variety matches tags",
"Banana quality / SOP being followed",
"The Ad is brought to life"
],
inv:[
"Cooler inventory appropriate",
"Merchandising sales-to-space appropriately on the floor",
"Walk-in cooler inventory dated w/ received date"
],
shrink:[
"Markdown / repurpose policy followed",
"RHC / GOT utilized — markdowns / throwaways",
"Rotation standards followed"
],
food:[
"Prep room clean / organized",
"Cooler clean / organized"
],
safety:[
"Mesh gloves available / being used",
"Safe knife handling / storage"
]
}},
{ id:"meat", name:"MEAT", sections:{
sales:[
"Fresh case eye appeal",
"Ground beef production appropriate",
"The Ad is brought to life",
"Center isle, end of bunker cross-merchandising complements the meat products on display.",
"Must-Have fresh meat variety maintained"
],
inv:[
"Cooler inventory appropriate",
"Proper product rotation in walk-ins and retail cases",
"Freezer inventory appropriate",
"Product in walk-ins dated with date of receipt",
"Production matches demand / use of cutting lists"
],
shrink:[
"Ground beef dates within standards",
"Multiple grind times",
"Time stamp on GB scale labels",
"Markdown process followed",
"Signs of overproduction (excessive reduced items)",
"Short-date list maintained (smoked meat)",
"RHC / GOT utilized for markdowns / throwaways"
],
food:[
"Meat case clean — inside and out",
"Prep room / walk-ins and equipment cleaned and sanitized regularly",
"Grind logs are maintained",
"Case and walk-in temps"
],
safety:[
"PPE utilized (personal protection equipment)",
"Safe equipment operation observed — safety features working on equipment"
]
}},
{ id:"deli", name:"DELI / BAKERY", sections:{
sales:[
"Product levels appropriate",
"Thaw-and-sell bakery merchandising",
"Grab & Go attractive (hot and cold)",
"The Ad is brought to life"
],
inv:[
"Cooler inventory appropriate",
"Freezer inventory appropriate",
"Proper product rotation — walk-ins / retail cases",
"Build-to-orders followed"
],
shrink:[
"Dates acceptable",
"Markdown process followed — throwaways logged in RHC / GOT devices"
],
food:[
"Prep area clean and organized",
"Proper temps being maintained, hot and cold"
],
safety:[
"Safe equipment operation observed"
]
}},
{ id:"dairy", name:"DAIRY", sections:{
sales:[
"Out-of-stocks acceptable",
"Milk dates support sales",
"The Ad is brought to life"
],
inv:[
"Cooler inventory appropriate",
"Milk inventory controlled"
],
shrink:[
"Rotation followed",
"Short-date list maintained",
"Markdown process followed",
"Reclaim managed"
],
food:[
"Cases and cooler clean and organized"
],
safety:[
"Safe cooler conditions"
]
}},
{ id:"frozen", name:"FROZEN FOOD", sections:{
sales:[
"The Ad is brought to life",
"Out-of-stocks acceptable"
],
inv:[
"Freezer inventory appropriate",
"Overstock controlled"
],
shrink:[
"Short-date process followed — TPRs in place",
"RHC / GOT utilized for markdowns / throwaways"
],
food:[
"Product condition acceptable / no freezer burn"
],
safety:[
"No ice hazards observed"
]
}}
];
/* Overview grid departments (includes areas without detailed sections) */
const OV_DEPTS = [
{id:"grocery", name:"Grocery", linked:true},
{id:"produce", name:"Produce", linked:true},
{id:"meat", name:"Meat", linked:true},
{id:"deli", name:"Deli/Bakery", linked:true},
{id:"dairy", name:"Dairy", linked:true},
{id:"frozen", name:"Frozen", linked:true},
{id:"wic", name:"Walk-In Coolers", linked:false},
{id:"wif", name:"Walk-In Freezers", linked:false},
{id:"recv", name:"Receiving/Stockroom", linked:false}
];
const OV_CATS = ["sales","inv","shrink","food","safety"];
const RATINGS = [
{key:"star", sym:"⭐", label:"Excellent"},
{key:"good", sym:"✅", label:"Good"},
{key:"warn", sym:"⚠️", label:"Attention"},
{key:"flag", sym:"🚩", label:"Action"}
];
const RSYM = {star:"⭐", good:"✅", warn:"⚠️", flag:"🚩"};
const RLABEL = {star:"Excellent", good:"Good", warn:"Attention Needed", flag:"Immediate Action"};
const RANK = {flag:0, warn:1, good:2, star:3};
/* ================= STATE ================= */
const answers = {}; // qid -> {rating, note, photos}
const callouts = {}; // ovDeptId -> text
let totalQ = 0;
/* ================= BUILD DEPARTMENTS ================= */
const deptsEl = document.getElementById("depts");
DEPTS.forEach((d, di) => {
const head = document.createElement("div");
head.className = "dept-head" + (di === 0 ? " open" : "");
head.innerHTML = `<h2>${d.name}</h2><span style="display:flex;align-items:center"><span class="count" id="cnt-${d.id}"></span><span class="caret">▾</span></span>`;
const body = document.createElement("div");
body.className = "dept-body" + (di === 0 ? " open" : "");
head.addEventListener("click", () => { head.classList.toggle("open"); body.classList.toggle("open"); });
Object.entries(d.sections).forEach(([cat, qs]) => {
const sh = document.createElement("div");
sh.className = "subsec";
sh.textContent = CATS[cat];
body.appendChild(sh);
qs.forEach((text, qi) => {
const qid = `${d.id}.${cat}.${qi}`;
totalQ++;
const q = document.createElement("div");
q.className = "q";
q.innerHTML = `
<p>${text}</p>
<div class="rate" data-qid="${qid}">
${RATINGS.map(r=>`<button data-r="${r.key}"><span>${r.sym}</span><small>${r.label}</small></button>`).join("")}
</div>
<button class="note-toggle" data-qid="${qid}">+ Add coaching note</button>
<div class="notes" id="notes-${cssId(qid)}">
<div class="nl"><span>Coaching Notes</span><span class="req" id="req-${cssId(qid)}" style="display:none">Required</span></div>
<textarea data-qid="${qid}" placeholder="What did you observe, and what's the coaching point?"></textarea>
<button class="photo-btn" data-qid="${qid}">📷 Add photos</button>
<input type="file" accept="image/*" multiple hidden id="file-${cssId(qid)}" data-qid="${qid}">
<div class="photo-strip" id="strip-${cssId(qid)}"></div>
</div>`;
body.appendChild(q);
});
});
deptsEl.appendChild(head);
deptsEl.appendChild(body);
});
function cssId(qid){ return qid.replace(/\./g,"-"); }
/* rating buttons */
document.querySelectorAll(".rate").forEach(row => {
row.addEventListener("click", e => {
const btn = e.target.closest("button"); if(!btn) return;
const qid = row.dataset.qid;
const r = btn.dataset.r;
const cur = answers[qid]?.rating;
row.querySelectorAll("button").forEach(b=>b.classList.remove("sel"));
if (cur === r) {
delete answers[qid];
} else {
btn.classList.add("sel");
answers[qid] = answers[qid] || {};
answers[qid].rating = r;
const notesEl = document.getElementById("notes-"+cssId(qid));
if (r === "warn" || r === "flag") notesEl.classList.add("show");
}
syncNoteFlag(qid);
refresh();
scheduleSave();
});
});
/* note toggles + inputs */
document.querySelectorAll(".note-toggle").forEach(t => {
t.addEventListener("click", () => {
document.getElementById("notes-"+cssId(t.dataset.qid)).classList.toggle("show");
});
});
document.querySelectorAll(".notes textarea").forEach(ta => {
ta.addEventListener("input", () => {
const qid = ta.dataset.qid;
answers[qid] = answers[qid] || {};
answers[qid].note = ta.value.trim();
syncNoteFlag(qid);
scheduleSave();
});
});
/* photo attachments in coaching notes */
const PHOTO_MAX_DIM = 1600;
const PHOTO_QUALITY = 0.7;
async function compressImage(file, maxDim = PHOTO_MAX_DIM, quality = PHOTO_QUALITY){
try {
const bitmap = await createImageBitmap(file);
let {width, height} = bitmap;
if (width > maxDim || height > maxDim){
const scale = maxDim / Math.max(width, height);
width = Math.round(width * scale);
height = Math.round(height * scale);
}
const canvas = document.createElement("canvas");
canvas.width = width; canvas.height = height;
canvas.getContext("2d").drawImage(bitmap, 0, 0, width, height);
bitmap.close && bitmap.close();
const blob = await new Promise(res => canvas.toBlob(res, "image/jpeg", quality));
if (!blob) return file;
return new File([blob], file.name.replace(/\.\w+$/, "") + ".jpg", {type: "image/jpeg"});
} catch(e){
return file; // compression unsupported or failed — attach the original instead
}
}
document.querySelectorAll(".photo-btn").forEach(b => {
b.addEventListener("click", () => document.getElementById("file-"+cssId(b.dataset.qid)).click());
});
document.querySelectorAll('input[type="file"][data-qid]').forEach(inp => {
inp.addEventListener("change", async () => {
const qid = inp.dataset.qid;
const files = [...inp.files];
inp.value = "";
if (!files.length) return;
answers[qid] = answers[qid] || {};
answers[qid].photos = answers[qid].photos || [];
const compressed = await Promise.all(files.map(f => compressImage(f)));
compressed.forEach(f => answers[qid].photos.push({file:f, url:URL.createObjectURL(f)}));
renderStrip(qid);
updateShareBtn();
});
});
function renderStrip(qid){
const strip = document.getElementById("strip-"+cssId(qid));
const ph = (answers[qid] && answers[qid].photos) || [];
strip.innerHTML = ph.map((p,i) =>
`<div class="photo-thumb"><img src="${p.url}" alt="photo"><button class="rm" data-i="${i}">✕</button></div>`).join("");
strip.querySelectorAll(".rm").forEach(btn => btn.addEventListener("click", () => {
const i = +btn.dataset.i;
URL.revokeObjectURL(ph[i].url);
ph.splice(i, 1);
renderStrip(qid);
updateShareBtn();
}));
}
function allPhotos(){ return Object.values(answers).flatMap(a => a.photos || []); }
function updateShareBtn(){
const n = allPhotos().length;
const b = document.getElementById("sharePhotosBtn");
b.style.display = n ? "block" : "none";
b.textContent = "📷 " + n;
}
document.getElementById("sharePhotosBtn").addEventListener("click", async () => {
const files = allPhotos().map(p => p.file);
if (navigator.canShare && navigator.canShare({files})){
try { await navigator.share({files, title:"TLS Store Visit Photos"}); } catch(e){}
} else {
toast("Photo sharing isn't supported on this device — attach photos from your camera roll instead.");
}
});
function syncNoteFlag(qid){
const a = answers[qid];
const req = document.getElementById("req-"+cssId(qid));
const needs = a && (a.rating==="warn"||a.rating==="flag") && !(a.note && a.note.length);
req.style.display = needs ? "inline" : "none";
}
/* ================= OVERVIEW GRID ================= */
const ovBody = document.getElementById("ovBody");
const OV_GRID = OV_DEPTS.filter(od => od.linked);
OV_GRID.forEach(od => {
const tr = document.createElement("tr");
tr.innerHTML = `<td class="dept">${od.name}</td>` + OV_CATS.map(c =>
`<td><span class="cell" data-cell="${od.id}.${c}"></span></td>`).join("");
ovBody.appendChild(tr);
});
const calloutsEl = document.getElementById("callouts");
OV_DEPTS.forEach(od => {
const row = document.createElement("div");
row.className = "callout-row";
row.innerHTML = `<label>High Level Callouts — ${od.name}</label>
<textarea rows="2" data-callout="${od.id}" placeholder="Optional notes"></textarea>`;
calloutsEl.appendChild(row);
});
calloutsEl.addEventListener("input", e => {
const k = e.target.dataset.callout; if(!k) return;
callouts[k] = e.target.value.trim();
scheduleSave();
});
function autoRating(deptId, cat){
// worst rating among answered questions in that dept/category
let worst = null;
Object.entries(answers).forEach(([qid, a]) => {
if (!a.rating) return;
const [d, c] = qid.split(".");
if (d===deptId && c===cat) {
if (worst===null || RANK[a.rating] < RANK[worst]) worst = a.rating;
}
});
return worst;
}
function cellRating(od, cat){
return od.linked ? autoRating(od.id, cat) : null; // auto from detailed answers only
}
function paintOverview(){
let filled = 0;
document.querySelectorAll(".cell").forEach(cell => {
const [dId, cat] = cell.dataset.cell.split(".");
const od = OV_DEPTS.find(o=>o.id===dId);
const r = cellRating(od, cat);
cell.classList.remove("star","good","warn","flag");
if (r){ cell.classList.add(r); cell.textContent = RSYM[r]; filled++; }
else cell.textContent = "";
});
document.getElementById("ovBadge").textContent = filled + " / " + (OV_GRID.length * OV_CATS.length);
}
/* ================= COVER ================= */
let storeFormat = "";
document.getElementById("fmtChips").addEventListener("click", e => {
const c = e.target.closest(".chip"); if(!c) return;
document.querySelectorAll("#fmtChips .chip").forEach(x=>x.classList.remove("sel"));
if (storeFormat === c.dataset.v){ storeFormat=""; }
else { c.classList.add("sel"); storeFormat = c.dataset.v; }
scheduleSave();
});
document.getElementById("visitDate").value = new Date().toISOString().slice(0,10);
const COVER_FIELD_IDS = ["storeNum","regionNum","mgrName","tlsName","visitDate","bestPractices","opportunities","recipients"];
COVER_FIELD_IDS.forEach(id => {
document.getElementById(id).addEventListener("input", scheduleSave);
});
/* ================= DRAFT AUTOSAVE ================= */
const DRAFT_KEY = "tlsWalkDraft";
let saveTimer;
function scheduleSave(){ clearTimeout(saveTimer); saveTimer = setTimeout(saveDraft, 400); }
function saveDraft(){
const g = id => document.getElementById(id).value;
const savedAnswers = {};
Object.entries(answers).forEach(([qid,a]) => {
if (a.rating || a.note) savedAnswers[qid] = {rating:a.rating, note:a.note || ""};
});
const draft = {
savedAt: Date.now(),
answers: savedAnswers,
callouts,
storeFormat,
cover: Object.fromEntries(COVER_FIELD_IDS.map(id => [id, g(id)]))
};
try { localStorage.setItem(DRAFT_KEY, JSON.stringify(draft)); } catch(e){}
}
function applyDraft(draft){
const c = draft.cover || {};
COVER_FIELD_IDS.forEach(id => {
if (c[id] !== undefined) document.getElementById(id).value = c[id];
});
if (draft.storeFormat){
storeFormat = draft.storeFormat;
document.querySelectorAll("#fmtChips .chip").forEach(x => x.classList.toggle("sel", x.dataset.v === storeFormat));
}
Object.entries(draft.callouts || {}).forEach(([k,v]) => {
callouts[k] = v;
const ta = document.querySelector(`textarea[data-callout="${k}"]`);
if (ta) ta.value = v;
});
Object.entries(draft.answers || {}).forEach(([qid,a]) => {
if (!a.rating && !a.note) return;
answers[qid] = {rating:a.rating, note:a.note};
const notesEl = document.getElementById("notes-"+cssId(qid));
if (a.rating){
const row = document.querySelector(`.rate[data-qid="${qid}"]`);
if (row) row.querySelectorAll("button").forEach(b => b.classList.toggle("sel", b.dataset.r === a.rating));
if (notesEl && (a.rating === "warn" || a.rating === "flag")) notesEl.classList.add("show");
}
if (a.note){
const ta = document.querySelector(`.notes textarea[data-qid="${qid}"]`);
if (ta) ta.value = a.note;
if (notesEl) notesEl.classList.add("show");
}
syncNoteFlag(qid);
});
refresh();
}
function loadDraft(){
let raw;
try { raw = localStorage.getItem(DRAFT_KEY); } catch(e){ return; }
if (!raw) return;
try {
applyDraft(JSON.parse(raw));
toast("Restored your in-progress report from earlier.");
} catch(e){}
}
function clearDraft(){
try { localStorage.removeItem(DRAFT_KEY); } catch(e){}
}
document.getElementById("newReportBtn").addEventListener("click", () => {
if (confirm("Start a new report? This clears the current in-progress report (photos will need to be re-attached).")){
clearDraft();
location.reload();
}
});
/* ================= PROGRESS / COUNTS ================= */
function refresh(){
const done = Object.values(answers).filter(a=>a.rating).length;
document.getElementById("pfill").style.width = (done/totalQ*100) + "%";
document.getElementById("pnum").textContent = done + " / " + totalQ;
DEPTS.forEach(d => {
const t = Object.values(d.sections).reduce((s,q)=>s+q.length,0);
const dn = Object.entries(answers).filter(([qid,a])=>qid.startsWith(d.id+".") && a.rating).length;
document.getElementById("cnt-"+d.id).textContent = dn + " / " + t;
});
let w=0,f=0;
Object.values(answers).forEach(a=>{ if(a.rating==="warn")w++; if(a.rating==="flag")f++; });
document.getElementById("attnPill").innerHTML =
(w||f) ? `<b>⚠️ ${w}</b> <b class="f">🚩 ${f}</b>` : "";
paintOverview();
}
refresh();
loadDraft();
/* ================= SUBMIT ================= */
function toast(msg){
const t = document.getElementById("toast");
t.textContent = msg; t.classList.add("show");
setTimeout(()=>t.classList.remove("show"), 3200);
}
function showConfirm(msg){
document.getElementById("confirmMsg").textContent = msg;
document.getElementById("confirmOverlay").classList.add("show");
}
document.getElementById("confirmOk").addEventListener("click", () => {
document.getElementById("confirmOverlay").classList.remove("show");
});
document.getElementById("confirmOverlay").addEventListener("click", e => {
if (e.target.id === "confirmOverlay") e.target.classList.remove("show");
});
document.getElementById("submitBtn").addEventListener("click", () => {
const storeNum = document.getElementById("storeNum").value.trim();
const tlsName = document.getElementById("tlsName").value.trim();
if (!storeNum || !tlsName){
toast("Fill in the HFG Store Number and TLS Name on the cover page first.");
document.getElementById("cover").scrollIntoView({behavior:"smooth"});
return;
}
// missing required notes?
const missing = Object.entries(answers).filter(([qid,a]) =>
(a.rating==="warn"||a.rating==="flag") && !(a.note && a.note.length));
if (missing.length){
toast(`${missing.length} item(s) marked ⚠️/🚩 still need a coaching note.`);
const first = document.getElementById("notes-"+cssId(missing[0][0]));
first.classList.add("show");
first.scrollIntoView({behavior:"smooth", block:"center"});
return;
}
sendEmail();
});
async function sendEmail(){
const g = id => document.getElementById(id).value.trim();
const line = "----------------------------------------";
const done = Object.values(answers).filter(a=>a.rating).length;
let w=0,f=0;
Object.values(answers).forEach(a=>{ if(a.rating==="warn")w++; if(a.rating==="flag")f++; });
let b = [];
b.push("TLS STORE VISIT SUMMARY");
b.push(line);
b.push("Store Format: " + (storeFormat || "—"));
b.push("HFG Store Number: " + g("storeNum"));
b.push("Region Number: " + (g("regionNum") || "—"));
b.push("Store Manager: " + (g("mgrName") || "—"));
b.push("TLS: " + g("tlsName"));
b.push("Date of Visit: " + g("visitDate"));
b.push("");
b.push(`Items assessed: ${done} / ${totalQ} | Attention Needed: ${w} | Immediate Action: ${f}`);
b.push("");
b.push("HIGH-LEVEL VISIT OVERVIEW");
b.push(line);
const catNames = {sales:"Sales", inv:"Inventory", shrink:"Shrink", food:"Food Safety", safety:"Safety"};
OV_DEPTS.forEach(od => {
const parts = OV_CATS.map(c => {
const r = cellRating(od, c);
return r ? `${catNames[c]}: ${RSYM[r]}` : null;
}).filter(Boolean);
const co = callouts[od.id];
if (parts.length || co){
b.push(od.name + " — " + (parts.join(" ") || "—"));
if (co) b.push(" Callout: " + co);
}
});
b.push("");
DEPTS.forEach(d => {
const has = Object.keys(answers).some(qid => qid.startsWith(d.id+".") && answers[qid].rating);
if (!has) return;
b.push(d.name);
b.push(line);
Object.entries(d.sections).forEach(([cat, qs]) => {
const items = qs.map((text,qi)=>({text, a:answers[`${d.id}.${cat}.${qi}`]})).filter(x=>x.a && x.a.rating);
if (!items.length) return;
b.push(CATS[cat].replace(/^[^\s]+\s/,"").toUpperCase());
items.forEach(x=>{
b.push(` ${RSYM[x.a.rating]} ${RLABEL[x.a.rating]} — ${x.text}`);
if (x.a.note) b.push(` Note: ${x.a.note}`);
if (x.a.photos && x.a.photos.length) b.push(` Photos: ${x.a.photos.length} (sent separately)`);
});
});
b.push("");
});
b.push("COACHING SUMMARY — covered with Store Manager / PIC");
b.push(line);
b.push("Best Practices Observed:");
b.push(g("bestPractices") || "—");
b.push("");
b.push("Opportunities for Improvement:");
b.push(g("opportunities") || "—");
b.push("");
b.push("Submitted via TLS Store Visit app");
const subject = `TLS Store Visit — Store ${g("storeNum")} — ${g("visitDate")}`;
const to = g("recipients") || "DOusley@houchens.com, MMooney@houchens.com";
const bodyText = b.join("\n");
const url = `mailto:${encodeURIComponent(to)}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(bodyText)}`;
const photoFiles = allPhotos().map(p => p.file);
if (photoFiles.length && navigator.canShare && navigator.canShare({files: photoFiles})){
try {
await navigator.share({files: photoFiles, title: subject, text: bodyText});
clearDraft();
showConfirm(`Your report and ${photoFiles.length} photo(s) have been handed off to Mail. Review it there, then tap Send to deliver it.`);
return;
} catch(e){
if (e.name === "AbortError") return; // user cancelled the share sheet
// sharing failed for another reason — fall back to mailto below
}
}
window.location.href = url;
clearDraft();
showConfirm(photoFiles.length
? `Your report has been handed off to Mail, but the ${photoFiles.length} photo(s) couldn't be attached automatically. Attach them from your camera roll, or tap the 📷 button to share them separately — then tap Send to deliver everything.`
: "Your report has been handed off to Mail. Review it there, then tap Send to deliver it.");
}
</script>
</body>
</html>