Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
import streamlit_authenticator as stauth
|
| 4 |
+
import datetime
|
| 5 |
+
|
| 6 |
+
# ---------------- LOGIN SETUP ----------------
|
| 7 |
+
credentials = {
|
| 8 |
+
"usernames": {
|
| 9 |
+
"admin": {
|
| 10 |
+
"name": "Admin",
|
| 11 |
+
"password": "12345" # Replace with hashed password for security
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
authenticator = stauth.Authenticate(credentials, "app_home", "abcdef", cookie_expiry_days=1)
|
| 17 |
+
name, auth_status, username = authenticator.login("Login", "main")
|
| 18 |
+
|
| 19 |
+
if auth_status is False:
|
| 20 |
+
st.error("Incorrect username/password")
|
| 21 |
+
elif auth_status is None:
|
| 22 |
+
st.warning("Enter your credentials")
|
| 23 |
+
elif auth_status:
|
| 24 |
+
authenticator.logout("Logout", "sidebar")
|
| 25 |
+
|
| 26 |
+
st.title("Boiler Production Tracking")
|
| 27 |
+
|
| 28 |
+
with st.form("entry_form"):
|
| 29 |
+
customer_name = st.text_input("CUSTOMER NAME")
|
| 30 |
+
boiler_no = st.text_input("BOILER NO")
|
| 31 |
+
capacity_tph = st.number_input("CAPACITY IN TPH", min_value=0.0, step=0.1)
|
| 32 |
+
|
| 33 |
+
material_offer_planned = st.date_input("MATERIAL OFFER PLANNED")
|
| 34 |
+
material_offer_actual = st.date_input("MATERIAL OFFER ACTUAL")
|
| 35 |
+
cutting_planned = st.date_input("CUTTING PLANNED")
|
| 36 |
+
cutting_actual = st.date_input("CUTTING ACTUAL")
|
| 37 |
+
rolling_planned = st.date_input("ROLLING PLANNED")
|
| 38 |
+
rolling_actual = st.date_input("ROLLING ACTUAL")
|
| 39 |
+
l_seam_rt_planned = st.date_input("L-SEAM RT PLANNED")
|
| 40 |
+
l_seam_rt_actual = st.date_input("L-SEAM RT ACTUAL")
|
| 41 |
+
c_seam_planned = st.date_input("C-SEAM PLANNED")
|
| 42 |
+
c_seam_actual = st.date_input("C-SEAM ACTUAL")
|
| 43 |
+
shell_ready_planned = st.date_input("SHELL READY PLANNED")
|
| 44 |
+
shell_ready_actual = st.date_input("SHELL READY ACTUAL")
|
| 45 |
+
test_plate_testing_planned = st.date_input("TEST PLATE TESTING PLANNED")
|
| 46 |
+
test_plate_testing_actual = st.date_input("TEST PLATE TESTING ACTUAL")
|
| 47 |
+
tube_plate_drilling_planned = st.date_input("TUBE PLATE DRILLING PLANNED")
|
| 48 |
+
tube_plate_drilling_actual = st.date_input("TUBE PLATE DRILLING ACTUAL")
|
| 49 |
+
|
| 50 |
+
material_shortage = st.text_area("MATERIAL SHORTAGE DETAILS")
|
| 51 |
+
|
| 52 |
+
ftp_setup_planned = st.date_input("FTP SETUP PLANNED")
|
| 53 |
+
ftp_setup_actual = st.date_input("FTP SETUP ACTUAL")
|
| 54 |
+
nozzle_setup_planned = st.date_input("NOZZLE SETUP PLANNED")
|
| 55 |
+
nozzle_setup_actual = st.date_input("NOZZLE SETUP ACTUAL")
|
| 56 |
+
final_setup_planned = st.date_input("FINAL SETUP PLANNED")
|
| 57 |
+
final_setup_actual = st.date_input("FINAL SETUP ACTUAL")
|
| 58 |
+
full_welding_planned = st.date_input("FULL WELDING PLANNED")
|
| 59 |
+
full_welding_actual = st.date_input("FULL WELDING ACTUAL")
|
| 60 |
+
hydro_planned = st.date_input("HYDRO DATE PLANNED")
|
| 61 |
+
hydro_actual = st.date_input("HYDRO DATE ACTUAL")
|
| 62 |
+
customer_hydro_planned = st.date_input("CUSTOMER HYDRO DATE PLANNED")
|
| 63 |
+
customer_hydro_actual = st.date_input("CUSTOMER HYDRO DATE ACTUAL")
|
| 64 |
+
|
| 65 |
+
remark = st.text_area("REMARK")
|
| 66 |
+
|
| 67 |
+
submitted = st.form_submit_button("Submit Data")
|
| 68 |
+
|
| 69 |
+
if submitted:
|
| 70 |
+
url = "https://script.google.com/a/macros/forbesmarshall.com/s/AKfycbyPTwzYNsy8D2M27O8ZZ90G1UYHP1aPExA_FX7VLh3iQquOt16Cc14tF7-xp8SGd1bE/exec" # Replace with your deployment URL
|
| 71 |
+
|
| 72 |
+
payload = {
|
| 73 |
+
"customer_name": customer_name,
|
| 74 |
+
"boiler_no": boiler_no,
|
| 75 |
+
"capacity_tph": capacity_tph,
|
| 76 |
+
"material_offer_planned": str(material_offer_planned),
|
| 77 |
+
"material_offer_actual": str(material_offer_actual),
|
| 78 |
+
"cutting_planned": str(cutting_planned),
|
| 79 |
+
"cutting_actual": str(cutting_actual),
|
| 80 |
+
"rolling_planned": str(rolling_planned),
|
| 81 |
+
"rolling_actual": str(rolling_actual),
|
| 82 |
+
"l_seam_rt_planned": str(l_seam_rt_planned),
|
| 83 |
+
"l_seam_rt_actual": str(l_seam_rt_actual),
|
| 84 |
+
"c_seam_planned": str(c_seam_planned),
|
| 85 |
+
"c_seam_actual": str(c_seam_actual),
|
| 86 |
+
"shell_ready_planned": str(shell_ready_planned),
|
| 87 |
+
"shell_ready_actual": str(shell_ready_actual),
|
| 88 |
+
"test_plate_testing_planned": str(test_plate_testing_planned),
|
| 89 |
+
"test_plate_testing_actual": str(test_plate_testing_actual),
|
| 90 |
+
"tube_plate_drilling_planned": str(tube_plate_drilling_planned),
|
| 91 |
+
"tube_plate_drilling_actual": str(tube_plate_drilling_actual),
|
| 92 |
+
"material_shortage": material_shortage,
|
| 93 |
+
"ftp_setup_planned": str(ftp_setup_planned),
|
| 94 |
+
"ftp_setup_actual": str(ftp_setup_actual),
|
| 95 |
+
"nozzle_setup_planned": str(nozzle_setup_planned),
|
| 96 |
+
"nozzle_setup_actual": str(nozzle_setup_actual),
|
| 97 |
+
"final_setup_planned": str(final_setup_planned),
|
| 98 |
+
"final_setup_actual": str(final_setup_actual),
|
| 99 |
+
"full_welding_planned": str(full_welding_planned),
|
| 100 |
+
"full_welding_actual": str(full_welding_actual),
|
| 101 |
+
"hydro_planned": str(hydro_planned),
|
| 102 |
+
"hydro_actual": str(hydro_actual),
|
| 103 |
+
"customer_hydro_planned": str(customer_hydro_planned),
|
| 104 |
+
"customer_hydro_actual": str(customer_hydro_actual),
|
| 105 |
+
"remark": remark
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
r = requests.post(url, json=payload)
|
| 109 |
+
|
| 110 |
+
if r.status_code == 200:
|
| 111 |
+
st.success("✅ Data added to Google Sheet successfully!")
|
| 112 |
+
else:
|
| 113 |
+
st.error("❌ Failed to send data. Please check the script URL.")
|