Hidayatmahar commited on
Commit
9e1bed1
·
verified ·
1 Parent(s): cb10757

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -0
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from reportlab.lib.pagesizes import A4
3
+ from reportlab.pdfgen import canvas
4
+ import datetime
5
+
6
+ # Function to create PDF Work Permit
7
+ def generate_pdf(data):
8
+ pdf_filename = "work_permit.pdf"
9
+ c = canvas.Canvas(pdf_filename, pagesize=A4)
10
+ c.setFont("Helvetica", 12)
11
+
12
+ # Title
13
+ c.drawString(200, 800, "WORK PERMIT FORM")
14
+
15
+ # Permit Details
16
+ y = 780
17
+ for key, value in data.items():
18
+ c.drawString(50, y, f"{key}: {value}")
19
+ y -= 20
20
+
21
+ c.save()
22
+ return pdf_filename
23
+
24
+ # Streamlit UI
25
+ st.title("🏗️ Work Permit System")
26
+
27
+ # Select permit type
28
+ permit_types = [
29
+ "Hot Work (Red)", "Cold Work (Blue)", "Electrical Work (Orange/Yellow)",
30
+ "Confined Space Entry (Green)", "Working at Heights (Yellow)",
31
+ "Lockout/Tagout (White/Red)", "Excavation/Trenching (Brown)",
32
+ "Radiation Work (Purple)", "Chemical Handling (Orange/Yellow)",
33
+ "Marine Work (Blue/Green)"
34
+ ]
35
+ permit_type = st.selectbox("Select Work Permit Type:", permit_types)
36
+
37
+ # Work Details
38
+ job_description = st.text_area("Job Description")
39
+ location = st.text_input("Work Location")
40
+ start_date = st.date_input("Start Date")
41
+ end_date = st.date_input("End Date")
42
+ equipment = st.text_input("Equipment/Machinery Used")
43
+
44
+ # Personnel Information
45
+ worker_name = st.text_input("Worker Name")
46
+ supervisor_name = st.text_input("Supervisor Name")
47
+ contact_number = st.text_input("Emergency Contact Number")
48
+
49
+ # Safety Checklist
50
+ st.subheader("✅ Safety Checklist")
51
+ ppe = st.checkbox("PPE Worn")
52
+ hazard_inspection = st.checkbox("Area Inspected for Hazards")
53
+ fire_extinguisher = st.checkbox("Fire Extinguisher Available")
54
+ loto = st.checkbox("Lockout/Tagout Applied (if needed)")
55
+ atmospheric_testing = st.checkbox("Atmospheric Testing Completed (for confined spaces)")
56
+
57
+ # Submit Button
58
+ if st.button("Generate Work Permit PDF"):
59
+ permit_data = {
60
+ "Permit Type": permit_type,
61
+ "Job Description": job_description,
62
+ "Work Location": location,
63
+ "Start Date": start_date,
64
+ "End Date": end_date,
65
+ "Equipment Used": equipment,
66
+ "Worker Name": worker_name,
67
+ "Supervisor Name": supervisor_name,
68
+ "Emergency Contact": contact_number,
69
+ "PPE Worn": "Yes" if ppe else "No",
70
+ "Hazard Inspection": "Yes" if hazard_inspection else "No",
71
+ "Fire Extinguisher Available": "Yes" if fire_extinguisher else "No",
72
+ "Lockout/Tagout Applied": "Yes" if loto else "No",
73
+ "Atmospheric Testing Done": "Yes" if atmospheric_testing else "No",
74
+ "Generated On": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
75
+ }
76
+
77
+ # Generate PDF
78
+ pdf_file = generate_pdf(permit_data)
79
+
80
+ # Provide Download Link
81
+ with open(pdf_file, "rb") as file:
82
+ st.download_button(label="📥 Download Work Permit", data=file, file_name="work_permit.pdf", mime="application/pdf")
83
+
84
+ st.success("Work Permit System Ready! ✅")