Spaces:
Running

File size: 29,977 Bytes
6ea020b
 
 
 
 
 
 
 
d6a2c70
6ea020b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6a2c70
6ea020b
 
 
d6a2c70
6ea020b
 
 
d6a2c70
6ea020b
 
d6a2c70
 
 
 
 
 
 
 
 
 
6ea020b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6a2c70
6ea020b
 
 
 
d6a2c70
6ea020b
 
 
d6a2c70
 
 
 
 
 
 
 
 
 
 
 
6ea020b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!-- templates/lab_info.html -->
{% extends "base.html" %}

{% block title %}Lab Information - NexLab{% endblock %}
{% block page_title %}Lab Information{% endblock %}

{% block content %}
<div class="bg-white rounded-xl shadow-sm border border-slate-200">
    <div class="p-4 sm:p-6 border-b border-slate-200 flex flex-wrap justify-between items-center gap-3">
        <div>
            <h3 class="text-lg font-semibold text-slate-800">Lab Information</h3>
            <p class="text-sm text-slate-500">Configure your laboratory details and branding</p>
        </div>
        {% if not edit_mode %}
        <a href="/lab-info/edit" 

           class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition duration-200">
            <svg class="w-5 h-5 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path></svg>
            Edit
        </a>
        {% else %}
        <a href="/lab-info" 

           class="bg-slate-600 hover:bg-slate-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition duration-200">
            <svg class="w-5 h-5 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
            Cancel
        </a>
        {% endif %}
    </div>

    {% if not edit_mode %}
    <!-- VIEW MODE - Read Only Display -->
    <div class="p-6">
        {% if lab_info %}
        <!-- Basic Information -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path></svg>
                Basic Information
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Name</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_name if lab_info.lab_name else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Title</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_title if lab_info.lab_title else '-' }}</p>
                </div>
                <div class="md:col-span-2 p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Welcome Message</label>
                    <p class="text-sm font-medium text-slate-800 whitespace-pre-wrap">{{ lab_info.welcome_message if lab_info.welcome_message else '-' }}</p>
                </div>
                <div class="md:col-span-2 p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Province</label>
                    <p class="text-sm font-medium text-slate-800">{{ province_name if province_name else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">First Doctor Name</label>
                    <p class="text-sm font-medium text-slate-800 whitespace-pre-wrap">{{ lab_info.first_doctor_name if lab_info.first_doctor_name else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Second Doctor Name</label>
                    <p class="text-sm font-medium text-slate-800 whitespace-pre-wrap">{{ lab_info.second_doctor_name if lab_info.second_doctor_name else '-' }}</p>
                </div>
                <div class="md:col-span-2 p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Address</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_address if lab_info.lab_address else '-' }}</p>
                </div>
            </div>
        </div>

        <!-- Contact Information -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"></path></svg>
                Contact Information
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Phone 1</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_phone_1 if lab_info.lab_phone_1 else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Phone 2</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_phone_2 if lab_info.lab_phone_2 else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab E-mail</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_email if lab_info.lab_email else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Website</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_website if lab_info.lab_website else '-' }}</p>
                </div>
                <div class="p-3 bg-amber-50 rounded-lg border border-amber-200">
                    <label class="block text-xs font-medium text-amber-600 mb-1">Tax Percentage</label>
                    <p class="text-sm font-medium text-amber-800">{{ lab_info.tax_percentage if lab_info.tax_percentage else '0' }}%</p>
                </div>
            </div>
        </div>

        <!-- Messaging APIs -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg>
                Messaging APIs
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div class="p-4 bg-green-50 rounded-lg border border-green-200">
                    <h5 class="text-sm font-semibold text-green-800 mb-3">WhatsApp</h5>
                    <div class="space-y-2">
                        <div>
                            <label class="block text-xs font-medium text-green-600 mb-1">WhatsApp API (UltraMsg Instance ID)</label>
                            <p class="text-sm text-green-800">{{ lab_info.whatsapp_api if lab_info.whatsapp_api else '-' }}</p>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-green-600 mb-1">WhatsApp Token (UltraMsg Token)</label>
                            <p class="text-sm text-green-800">{{ lab_info.whatsapp_token if lab_info.whatsapp_token else '-' }}</p>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-green-600 mb-1">WhatsApp Group ID</label>
                            <p class="text-sm text-green-800">{{ lab_info.whatsapp_group_id if lab_info.whatsapp_group_id else '-' }}</p>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-green-600 mb-1">Auto-Notifications</label>
                            <p class="text-sm font-medium {% if lab_info.whatsapp_notify_enabled %}text-emerald-700{% else %}text-red-500{% endif %}">
                                {{ 'Enabled ✓' if lab_info.whatsapp_notify_enabled else 'Disabled ✗' }}
                            </p>
                        </div>
                    </div>
                </div>
                <div class="p-4 bg-blue-50 rounded-lg border border-blue-200">
                    <h5 class="text-sm font-semibold text-blue-800 mb-3">Telegram</h5>
                    <div class="space-y-2">
                        <div>
                            <label class="block text-xs font-medium text-blue-600 mb-1">Telegram API</label>
                            <p class="text-sm text-blue-800">{{ lab_info.telegram_api if lab_info.telegram_api else '-' }}</p>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-blue-600 mb-1">Telegram Token</label>
                            <p class="text-sm text-blue-800">{{ lab_info.telegram_token if lab_info.telegram_token else '-' }}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Images & Branding -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>
                Images & Branding
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                {% set images = [
                    ('Lab Logo', lab_info.lab_logo),
                    ('Lab QR 1', lab_info.lab_qr_1),
                    ('Lab QR 2', lab_info.lab_qr_2),
                    ('Lab Stamp 1', lab_info.lab_stamp_1),
                    ('Lab Stamp 2', lab_info.lab_stamp_2),
                    ('Lab Signature 1', lab_info.lab_signature_1),
                    ('Lab Signature 2', lab_info.lab_signature_2),
                    ('Lab Image 1', lab_info.lab_image_1),
                    ('Lab Image 2', lab_info.lab_image_2)
                ] %}
                {% for label, image_path in images %}
                <div class="p-4 bg-slate-50 rounded-lg border border-slate-200">
                    <label class="block text-sm font-medium text-slate-700 mb-2">{{ label }}</label>
                    {% if image_path %}
                    <img src="/uploads/{{ image_path }}" alt="{{ label }}" class="w-full h-32 object-contain rounded">
                    {% else %}
                    <div class="w-full h-32 flex items-center justify-center bg-slate-200 rounded">
                        <span class="text-slate-400 text-sm">Not uploaded</span>
                    </div>
                    {% endif %}
                </div>
                {% endfor %}
            </div>
        </div>

        <!-- Notes -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
                Notes
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Note 1</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_note_1 if lab_info.lab_note_1 else '-' }}</p>
                </div>
                <div class="p-3 bg-slate-50 rounded-lg">
                    <label class="block text-xs font-medium text-slate-500 mb-1">Lab Note 2</label>
                    <p class="text-sm font-medium text-slate-800">{{ lab_info.lab_note_2 if lab_info.lab_note_2 else '-' }}</p>
                </div>
            </div>
        </div>

        {% if lab_info.edited_at %}
        <div class="text-xs text-slate-500 text-right">
            Last updated: {{ lab_info.edited_at.strftime('%Y-%m-%d %H:%M') }}
        </div>
        {% endif %}

        {% else %}
        <div class="text-center py-12">
            <svg class="mx-auto h-12 w-12 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path>
            </svg>
            <h3 class="mt-2 text-sm font-medium text-slate-900">No lab information configured</h3>
            <p class="mt-1 text-sm text-slate-500">Click Edit to add your laboratory details.</p>
        </div>
        {% endif %}
    </div>

    {% else %}
    <!-- EDIT MODE - Form -->
    <form method="POST" enctype="multipart/form-data" id="labInfoForm" action="/lab-info/update" class="p-6">
        
        <!-- Basic Information -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"></path></svg>
                Basic Information
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Name *</label>
                    <input type="text" id="lab_name" name="lab_name" value="{{ lab_info.lab_name if lab_info else '' }}" required

                           class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Title</label>
                    <input type="text" id="lab_title" name="lab_title" value="{{ lab_info.lab_title if lab_info else '' }}"

                           class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                </div>
                <div class="md:col-span-2">
                    <label class="block text-sm font-medium text-slate-700 mb-1">Welcome Message</label>
                    <textarea id="welcome_message" name="welcome_message" rows="3"

                              class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">{{ lab_info.welcome_message if lab_info else '' }}</textarea>
                </div>
                <div class="md:col-span-2">
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Province</label>
                    <select id="province_id" name="province_id" class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                        <option value="">Select Province</option>
                        {% for province in provinces %}
                        <option value="{{ province.id }}" {% if lab_info and lab_info.province_id == province.id %}selected{% endif %}>{{ province.province_name }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">First Doctor Name</label>
                    <textarea id="first_doctor_name" name="first_doctor_name" rows="2"

                              class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">{{ lab_info.first_doctor_name if lab_info else '' }}</textarea>
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Second Doctor Name</label>
                    <textarea id="second_doctor_name" name="second_doctor_name" rows="2"

                              class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">{{ lab_info.second_doctor_name if lab_info else '' }}</textarea>
                </div>
                <div class="md:col-span-2">
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Address</label>
                    <textarea id="lab_address" name="lab_address" rows="2"

                              class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">{{ lab_info.lab_address if lab_info else '' }}</textarea>
                </div>
            </div>
        </div>

        <!-- Contact Information -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"></path></svg>
                Contact Information
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Phone 1 *</label>
                    <input type="text" id="lab_phone_1" name="lab_phone_1" value="{{ lab_info.lab_phone_1 if lab_info else '' }}" required

                           class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Phone 2</label>
                    <input type="text" id="lab_phone_2" name="lab_phone_2" value="{{ lab_info.lab_phone_2 if lab_info else '' }}"

                           class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab E-mail</label>
                    <input type="email" id="lab_email" name="lab_email" value="{{ lab_info.lab_email if lab_info else '' }}"

                           class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Website</label>
                    <input type="text" id="lab_website" name="lab_website" value="{{ lab_info.lab_website if lab_info else '' }}"

                           class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Tax Percentage (%)</label>
                    <input type="number" id="tax_percentage" name="tax_percentage" value="{{ lab_info.tax_percentage if lab_info and lab_info.tax_percentage else '0' }}" step="0.01" min="0" max="100"

                           class="w-full border border-amber-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-amber-500 focus:outline-none bg-amber-50">
                </div>
            </div>
        </div>

        <!-- Messaging APIs -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg>
                Messaging APIs
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <!-- WhatsApp -->
                <div class="p-4 bg-green-50 rounded-lg border border-green-200">
                    <h5 class="text-sm font-semibold text-green-800 mb-3">WhatsApp</h5>
                    <div class="space-y-3">
                        <div>
                            <label class="block text-xs font-medium text-green-700 mb-1">WhatsApp API (UltraMsg Instance ID)</label>
                            <input type="text" id="whatsapp_api" name="whatsapp_api" value="{{ lab_info.whatsapp_api if lab_info else '' }}"

                                   class="w-full border border-green-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-green-500 focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-green-700 mb-1">WhatsApp Token (UltraMsg Token)</label>
                            <input type="text" id="whatsapp_token" name="whatsapp_token" value="{{ lab_info.whatsapp_token if lab_info else '' }}"

                                   class="w-full border border-green-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-green-500 focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-green-700 mb-1">WhatsApp Group ID</label>
                            <input type="text" id="whatsapp_group_id" name="whatsapp_group_id" value="{{ lab_info.whatsapp_group_id if lab_info else '' }}"

                                   class="w-full border border-green-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-green-500 focus:outline-none">
                            <p class="text-xs text-green-600 mt-1">Group JID from UltraMsg (format: 120363...@g.us)</p>
                        </div>
                        <div class="flex items-center gap-3 pt-1">
                            <input type="checkbox" id="whatsapp_notify_enabled" name="whatsapp_notify_enabled" value="1"

                                   {% if lab_info and lab_info.whatsapp_notify_enabled %}checked{% endif %}

                                   class="w-4 h-4 text-green-600 border-green-300 rounded focus:ring-green-500">
                            <label for="whatsapp_notify_enabled" class="text-xs font-medium text-green-700">Enable automatic group notifications (Pending 2h / Authorize 5m)</label>
                        </div>
                    </div>
                </div>
                <!-- Telegram -->
                <div class="p-4 bg-blue-50 rounded-lg border border-blue-200">
                    <h5 class="text-sm font-semibold text-blue-800 mb-3">Telegram</h5>
                    <div class="space-y-3">
                        <div>
                            <label class="block text-xs font-medium text-blue-700 mb-1">Telegram API</label>
                            <input type="text" id="telegram_api" name="telegram_api" value="{{ lab_info.telegram_api if lab_info else '' }}"

                                   class="w-full border border-blue-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:outline-none">
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-blue-700 mb-1">Telegram Token</label>
                            <input type="text" id="telegram_token" name="telegram_token" value="{{ lab_info.telegram_token if lab_info else '' }}"

                                   class="w-full border border-blue-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:outline-none">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Images & Branding -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>
                Images & Branding
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                {% set images = [
                    ('Lab Logo', 'lab_logo'),
                    ('Lab QR 1', 'lab_qr_1'),
                    ('Lab QR 2', 'lab_qr_2'),
                    ('Lab Stamp 1', 'lab_stamp_1'),
                    ('Lab Stamp 2', 'lab_stamp_2'),
                    ('Lab Signature 1', 'lab_signature_1'),
                    ('Lab Signature 2', 'lab_signature_2'),
                    ('Lab Image 1', 'lab_image_1'),
                    ('Lab Image 2', 'lab_image_2')
                ] %}
                {% for label, field_name in images %}
                <div class="p-4 bg-slate-50 rounded-lg border border-slate-200">
                    <label class="block text-sm font-medium text-slate-700 mb-2">{{ label }}</label>
                    {% if lab_info and lab_info[field_name] %}
                    <img src="/uploads/{{ lab_info[field_name] }}" alt="{{ label }}" class="w-full h-32 object-contain mb-2 rounded">
                    {% endif %}
                    <input type="file" id="{{ field_name }}" name="{{ field_name }}" accept="image/*"

                           class="w-full text-sm text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-indigo-50 file:text-indigo-700 hover:file:bg-indigo-100">
                </div>
                {% endfor %}
            </div>
        </div>

        <!-- Notes -->
        <div class="mb-8">
            <h4 class="text-md font-semibold text-slate-700 mb-4 flex items-center">
                <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
                Notes
            </h4>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Note 1</label>
                    <textarea id="lab_note_1" name="lab_note_1" rows="3"

                              class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">{{ lab_info.lab_note_1 if lab_info else '' }}</textarea>
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Lab Note 2</label>
                    <textarea id="lab_note_2" name="lab_note_2" rows="3"

                              class="w-full border border-slate-300 rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-500 focus:outline-none">{{ lab_info.lab_note_2 if lab_info else '' }}</textarea>
                </div>
            </div>
        </div>

        <div class="flex gap-2">
            <button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white px-6 py-3 rounded-lg text-sm font-medium">
                <svg class="w-5 h-5 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"></path></svg>
                Save Lab Information
            </button>
            <a href="/lab-info" class="bg-slate-600 hover:bg-slate-700 text-white px-6 py-3 rounded-lg text-sm font-medium">
                Cancel
            </a>
        </div>
    </form>
    {% endif %}
</div>
{% endblock %}