File size: 28,936 Bytes
5710055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5063c1f
5710055
5063c1f
 
5710055
5063c1f
 
 
 
 
 
 
 
5710055
5063c1f
5710055
 
5063c1f
 
5710055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5063c1f
 
 
 
 
 
 
 
 
 
 
 
5710055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5063c1f
5710055
 
 
 
 
 
 
 
 
5063c1f
 
 
 
 
 
 
5710055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5063c1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5710055
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Technician Materials Form</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* Custom styles for barcode scanner */
        .barcode-scanner {
            position: relative;
            display: inline-block;
        }
        .barcode-scanner-btn {
            background-color: #4F46E5;
            color: white;
            border: none;
            padding: 0.25rem 0.5rem;
            border-radius: 0.25rem;
            cursor: pointer;
            margin-left: 0.5rem;
        }
        .barcode-scanner-btn:hover {
            background-color: #4338CA;
        }
        .scanner-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.8);
            z-index: 1000;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        .scanner-video {
            width: 80%;
            max-width: 500px;
            border: 2px solid white;
            border-radius: 8px;
        }
        .scanner-close {
            margin-top: 1rem;
            background-color: #EF4444;
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 0.25rem;
            cursor: pointer;
        }
        /* Custom file upload button */
        .file-input-label {
            display: inline-block;
            padding: 0.5rem 1rem;
            background-color: #4F46E5;
            color: white;
            border-radius: 0.25rem;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        .file-input-label:hover {
            background-color: #4338CA;
        }
        .file-input {
            display: none;
        }
        /* Animation for form submission */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .fade-in {
            animation: fadeIn 0.5s ease-out forwards;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="container mx-auto px-4 py-8 max-w-4xl">
        <div class="bg-white rounded-lg shadow-lg overflow-hidden fade-in">
            <!-- Header -->
            <div class="bg-indigo-600 px-6 py-4">
                <h1 class="text-2xl font-bold text-white">Technician Materials Form</h1>
                <p class="text-indigo-200">Please fill out all required fields</p>
            </div>
            
            <!-- Form -->
            <form id="materialsForm" class="p-6 space-y-6">
                <!-- Basic Information Section -->
                <div class="space-y-4">
                    <h2 class="text-xl font-semibold text-gray-800 border-b pb-2">Basic Information</h2>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <!-- Date -->
                        <div>
                            <label for="date" class="block text-sm font-medium text-gray-700 mb-1">
                                Date <span class="text-red-500">*</span>
                            </label>
                            <input type="date" id="date" name="date" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
                        </div>
                        
                        <!-- Technician Name -->
                        <div>
                            <label for="technicianName" class="block text-sm font-medium text-gray-700 mb-1">
                                Technician Name <span class="text-red-500">*</span>
                            </label>
                            <input type="text" id="technicianName" name="technicianName" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter technician name">
                        </div>
                    </div>
                    
                    <!-- Plate Number -->
                    <div>
                        <label for="plateNumber" class="block text-sm font-medium text-gray-700 mb-1">
                            Plate # <span class="text-red-500">*</span>
                        </label>
                        <input type="text" id="plateNumber" name="plateNumber" required
                            class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                            placeholder="Enter plate number">
                    </div>
                </div>
                
                <!-- Materials Section -->
                <div class="space-y-4">
                    <h2 class="text-xl font-semibold text-gray-800 border-b pb-2">Materials Used</h2>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <!-- Mechanical Connector -->
                        <div>
                            <label for="mechanicalConnector" class="block text-sm font-medium text-gray-700 mb-1">
                                Mechanical Connector (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="mechanicalConnector" name="mechanicalConnector" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- NIU -->
                        <div>
                            <label for="niu" class="block text-sm font-medium text-gray-700 mb-1">
                                NIU (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="niu" name="niu" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Patchcord -->
                        <div>
                            <label for="patchcord" class="block text-sm font-medium text-gray-700 mb-1">
                                Patchcord (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="patchcord" name="patchcord" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- F17, S-Shape Anchor Clamp -->
                        <div>
                            <label for="anchorClamp" class="block text-sm font-medium text-gray-700 mb-1">
                                F17, S-Shape Anchor Clamp (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="anchorClamp" name="anchorClamp" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- House Bracket -->
                        <div>
                            <label for="houseBracket" class="block text-sm font-medium text-gray-700 mb-1">
                                House Bracket (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="houseBracket" name="houseBracket" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Mid Span -->
                        <div>
                            <label for="midSpan" class="block text-sm font-medium text-gray-700 mb-1">
                                Mid Span (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="midSpan" name="midSpan" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Cable Clip -->
                        <div>
                            <label for="cableClip" class="block text-sm font-medium text-gray-700 mb-1">
                                Cable Clip (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="cableClip" name="cableClip" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Cable Tie -->
                        <div>
                            <label for="cableTie" class="block text-sm font-medium text-gray-700 mb-1">
                                Cable Tie (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="cableTie" name="cableTie" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Adhesive Tape -->
                        <div>
                            <label for="adhesiveTape" class="block text-sm font-medium text-gray-700 mb-1">
                                Adhesive Tape (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="adhesiveTape" name="adhesiveTape" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Electrical Tape -->
                        <div>
                            <label for="electricalTape" class="block text-sm font-medium text-gray-700 mb-1">
                                Electrical Tape (per pc.) <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="electricalTape" name="electricalTape" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Labeler Tape -->
                        <div>
                            <label for="labelerTape" class="block text-sm font-medium text-gray-700 mb-1">
                                Labeler Tape <span class="text-red-500">*</span>
                            </label>
                            <input type="number" id="labelerTape" name="labelerTape" min="0" required
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter quantity">
                        </div>
                        
                        <!-- Others -->
                        <div class="md:col-span-2">
                            <label for="others" class="block text-sm font-medium text-gray-700 mb-1">
                                Others (Please Specify) <span class="text-red-500">*</span>
                            </label>
                            <textarea id="others" name="others" rows="2"
                                class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Specify other materials used"></textarea>
                        </div>
                    </div>
                </div>
                
                <!-- Serialized Materials Section -->
                <div class="space-y-4">
                    <h2 class="text-xl font-semibold text-gray-800 border-b pb-2">Serialized Materials</h2>
                    
                    <!-- DROP FOC, 2 Core Serial Number -->
                    <div>
                        <label for="dropFocSerial" class="block text-sm font-medium text-gray-700 mb-1">
                            DROP FOC, 2 Core Serial Number (per reel) <span class="text-red-500">*</span>
                        </label>
                        <input type="text" id="dropFocSerial" name="dropFocSerial" required
                            class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                            placeholder="Enter serial number">
                    </div>
                    
                    <!-- Modem Type -->
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">
                            Modem Type <span class="text-red-500">*</span>
                        </label>
                        <div class="grid grid-cols-2 md:grid-cols-3 gap-2">
                            <label class="inline-flex items-center">
                                <input type="radio" name="modemType" value="ZTE" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500" required>
                                <span class="ml-2 text-gray-700">ZTE</span>
                            </label>
                            <label class="inline-flex items-center">
                                <input type="radio" name="modemType" value="HUAWEI" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
                                <span class="ml-2 text-gray-700">HUAWEI</span>
                            </label>
                            <label class="inline-flex items-center">
                                <input type="radio" name="modemType" value="SKYWORTH" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
                                <span class="ml-2 text-gray-700">SKYWORTH</span>
                            </label>
                            <label class="inline-flex items-center">
                                <input type="radio" name="modemType" value="V2F" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
                                <span class="ml-2 text-gray-700">V2F</span>
                            </label>
                            <label class="inline-flex items-center">
                                <input type="radio" name="modemType" value="V2" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
                                <span class="ml-2 text-gray-700">V2</span>
                            </label>
                            <label class="inline-flex items-center">
                                <input type="radio" name="modemType" value="GAMECHANGER" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
                                <span class="ml-2 text-gray-700">GAMECHANGER</span>
                            </label>
                            <label class="inline-flex items-center md:col-span-3">
                                <input type="radio" name="modemType" value="Other" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
                                <span class="ml-2 text-gray-700">Other:</span>
                                <input type="text" name="modemTypeOther" class="ml-2 px-2 py-1 border border-gray-300 rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 flex-1" placeholder="Specify modem type">
                            </label>
                        </div>
                    </div>
                    
                    <!-- Modem Serial Number -->
                    <div>
                        <label for="modemSerial" class="block text-sm font-medium text-gray-700 mb-1">
                            Modem Serial Number
                        </label>
                        <div class="flex">
                            <input type="text" id="modemSerial" name="modemSerial"
                                class="w-full px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
                                placeholder="Enter modem serial number">
                            <button type="button" onclick="openScanner('modemSerial')" 
                                class="barcode-scanner-btn rounded-r-md">
                                <i class="fas fa-barcode"></i>
                            </button>
                        </div>
                        <div id="modemSerialsContainer" class="mt-2 space-y-1"></div>
                    </div>
                </div>
                    
                </div>
                
                <!-- Upload Picture Section -->
                <div class="space-y-4">
                    <h2 class="text-xl font-semibold text-gray-800 border-b pb-2">Upload Picture</h2>
                    
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">
                            Upload Picture (if any)
                        </label>
                        <label for="pictureUpload" class="file-input-label">
                            <i class="fas fa-upload mr-2"></i>Choose File
                        </label>
                        <input type="file" id="pictureUpload" name="pictureUpload" accept="image/*" class="file-input">
                        <span id="fileName" class="ml-2 text-sm text-gray-500">No file chosen</span>
                    </div>
                </div>
                
                <!-- Form Submission -->
                <div class="pt-4 border-t border-gray-200">
                    <div class="flex justify-between">
                        <button type="button" onclick="resetForm()" class="px-4 py-2 bg-gray-300 text-gray-700 rounded-md hover:bg-gray-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
                            <i class="fas fa-redo mr-2"></i>Reset
                        </button>
                        <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                            <i class="fas fa-paper-plane mr-2"></i>Submit
                        </button>
                    </div>
                </div>
            </form>
        </div>
        
        <!-- Success Modal -->
        <div id="successModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
            <div class="bg-white p-6 rounded-lg shadow-xl max-w-md w-full mx-4">
                <div class="text-center">
                    <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100">
                        <svg class="h-6 w-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                        </svg>
                    </div>
                    <h3 class="mt-3 text-lg font-medium text-gray-900">Form Submitted Successfully!</h3>
                    <div class="mt-2 text-sm text-gray-500">
                        <p>Your entry has been recorded in the sheet.</p>
                        <p class="mt-2">
                            <a href="https://docs.google.com/spreadsheets/d/1aArzBlDDI-ycUjn4kHRZl4GxorM-KZIpI244MwPaTLQ/edit?gid=0#gid=0" 
                               target="_blank" 
                               class="text-indigo-600 hover:text-indigo-500">
                                View Sheet <i class="fas fa-external-link-alt ml-1"></i>
                            </a>
                        </p>
                    </div>
                    <div class="mt-4">
                        <button type="button" onclick="closeSuccessModal()" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                            Close
                        </button>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Barcode Scanner Modal -->
        <div id="scannerModal" class="scanner-modal hidden">
            <video id="scannerVideo" class="scanner-video" autoplay playsinline></video>
            <button id="scannerClose" class="scanner-close">Close Scanner</button>
        </div>
    </div>

    <script>
        // File upload display
        document.getElementById('pictureUpload').addEventListener('change', function(e) {
            const fileName = document.getElementById('fileName');
            if (this.files.length > 0) {
                fileName.textContent = this.files[0].name;
            } else {
                fileName.textContent = 'No file chosen';
            }
        });
        
        // Form submission
        document.getElementById('materialsForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            // Collect form data including modem serial
            const formData = {
                date: document.getElementById('date').value,
                technicianName: document.getElementById('technicianName').value,
                plateNumber: document.getElementById('plateNumber').value,
                modemType: document.querySelector('input[name="modemType"]:checked').value,
                modemSerials: getModemSerials(),
                // ... other form fields ...
            };
            
            console.log('Form data:', formData);
            
            // Here you would normally send the form data to your server
            // For this demo, we'll just show the success modal
            document.getElementById('successModal').classList.remove('hidden');
        });
        
        // Reset form
        function resetForm() {
            document.getElementById('materialsForm').reset();
            document.getElementById('fileName').textContent = 'No file chosen';
        }
        
        // Close success modal
        function closeSuccessModal() {
            document.getElementById('successModal').classList.add('hidden');
            resetForm();
        }
        
        // Barcode scanner functionality
        function openScanner(fieldId) {
            const modal = document.getElementById('scannerModal');
            const video = document.getElementById('scannerVideo');
            
            modal.classList.remove('hidden');
            
            // For demo purposes, we'll simulate scanning after 2 seconds
            setTimeout(() => {
                // In a real implementation, you would use a barcode scanning library
                // Here we just simulate a scanned value
                const serialNumber = 'SN' + Math.floor(Math.random() * 1000000000).toString().padStart(9, '0');
                
                if (fieldId === 'modemSerial') {
                    addModemSerial(serialNumber);
                } else {
                    document.getElementById(fieldId).value = serialNumber;
                }
                closeScanner();
            }, 2000);
            
            // In a real implementation, you would access the device camera here
            // navigator.mediaDevices.getUserMedia({ video: { facingMode: "environment" } })
            //     .then(function(stream) {
            //         video.srcObject = stream;
            //     })
            //     .catch(function(err) {
            //         console.error("Error accessing camera: ", err);
            //     });
        }
        
        function closeScanner() {
            const modal = document.getElementById('scannerModal');
            const video = document.getElementById('scannerVideo');
            
            modal.classList.add('hidden');
            
            // In a real implementation, you would stop the camera stream here
            // if (video.srcObject) {
            //     video.srcObject.getTracks().forEach(track => track.stop());
            // }
        }
        
        document.getElementById('scannerClose').addEventListener('click', closeScanner);

        // Handle multiple modem serial numbers
        function addModemSerial(serialNumber) {
            const container = document.getElementById('modemSerialsContainer');
            const input = document.getElementById('modemSerial');
            
            // Check if this serial already exists
            const existingItems = container.querySelectorAll('.serial-item');
            for (const item of existingItems) {
                if (item.textContent.includes(serialNumber)) {
                    return; // Skip duplicates
                }
            }
            
            // Create new serial item
            const serialItem = document.createElement('div');
            serialItem.className = 'serial-item flex items-center justify-between bg-gray-100 px-3 py-2 rounded';
            
            const serialText = document.createElement('span');
            serialText.textContent = serialNumber;
            
            const deleteBtn = document.createElement('button');
            deleteBtn.innerHTML = '<i class="fas fa-times text-red-500"></i>';
            deleteBtn.className = 'ml-2';
            deleteBtn.onclick = function() {
                container.removeChild(serialItem);
            };
            
            serialItem.appendChild(serialText);
            serialItem.appendChild(deleteBtn);
            container.appendChild(serialItem);
            
            // Clear the input field for next scan
            input.value = '';
        }

        // Get all modem serials as array
        function getModemSerials() {
            const items = document.getElementById('modemSerialsContainer').querySelectorAll('.serial-item span');
            return Array.from(items).map(item => item.textContent);
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=royramirez20/materials-request" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>