File size: 5,566 Bytes
2402c18
c26a560
 
 
2402c18
83860b9
c26a560
 
 
 
83860b9
c26a560
 
 
 
83860b9
 
 
 
 
 
 
 
 
 
 
 
 
 
c26a560
 
83860b9
c26a560
83860b9
c26a560
 
 
83860b9
c26a560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83860b9
c26a560
 
83860b9
c26a560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83860b9
 
 
 
 
 
 
 
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
import streamlit as st
import requests
import streamlit_authenticator as stauth
import datetime

# ========================= LOGIN SETUP =========================
credentials = {
    "usernames": {
        "admin": {
            "name": "Admin",
            "password": "12345"  # Replace with hashed password for real use
        }
    }
}

authenticator = stauth.Authenticate(
    credentials,
    "app_home",
    "abcdef",
    cookie_expiry_days=1
)

fields = {
    "Form name": "Login",
    "Username": "Enter username",
    "Password": "Enter password"
}

name, auth_status, username = authenticator.login(fields=fields, location="main")

if auth_status is False:
    st.error("❌ Incorrect username or password")
elif auth_status is None:
    st.warning("πŸ”’ Please enter your credentials")
elif auth_status:
    authenticator.logout("Logout", "sidebar")

    st.title("πŸ“Š Boiler Production Tracking Form")

    with st.form("entry_form"):
        customer_name = st.text_input("CUSTOMER NAME")
        boiler_no = st.text_input("BOILER NO")
        capacity_tph = st.number_input("CAPACITY IN TPH", min_value=0.0, step=0.1)

        material_offer_planned = st.date_input("MATERIAL OFFER PLANNED")
        material_offer_actual = st.date_input("MATERIAL OFFER ACTUAL")
        cutting_planned = st.date_input("CUTTING PLANNED")
        cutting_actual = st.date_input("CUTTING ACTUAL")
        rolling_planned = st.date_input("ROLLING PLANNED")
        rolling_actual = st.date_input("ROLLING ACTUAL")
        l_seam_rt_planned = st.date_input("L-SEAM RT PLANNED")
        l_seam_rt_actual = st.date_input("L-SEAM RT ACTUAL")
        c_seam_planned = st.date_input("C-SEAM PLANNED")
        c_seam_actual = st.date_input("C-SEAM ACTUAL")
        shell_ready_planned = st.date_input("SHELL READY PLANNED")
        shell_ready_actual = st.date_input("SHELL READY ACTUAL")
        test_plate_testing_planned = st.date_input("TEST PLATE TESTING PLANNED")
        test_plate_testing_actual = st.date_input("TEST PLATE TESTING ACTUAL")
        tube_plate_drilling_planned = st.date_input("TUBE PLATE DRILLING PLANNED")
        tube_plate_drilling_actual = st.date_input("TUBE PLATE DRILLING ACTUAL")

        material_shortage = st.text_area("MATERIAL SHORTAGE DETAILS")

        ftp_setup_planned = st.date_input("FTP SETUP PLANNED")
        ftp_setup_actual = st.date_input("FTP SETUP ACTUAL")
        nozzle_setup_planned = st.date_input("NOZZLE SETUP PLANNED")
        nozzle_setup_actual = st.date_input("NOZZLE SETUP ACTUAL")
        final_setup_planned = st.date_input("FINAL SETUP PLANNED")
        final_setup_actual = st.date_input("FINAL SETUP ACTUAL")
        full_welding_planned = st.date_input("FULL WELDING PLANNED")
        full_welding_actual = st.date_input("FULL WELDING ACTUAL")
        hydro_planned = st.date_input("HYDRO DATE PLANNED")
        hydro_actual = st.date_input("HYDRO DATE ACTUAL")
        customer_hydro_planned = st.date_input("CUSTOMER HYDRO DATE PLANNED")
        customer_hydro_actual = st.date_input("CUSTOMER HYDRO DATE ACTUAL")

        remark = st.text_area("REMARK")

        submitted = st.form_submit_button("πŸ“₯ Submit Data")

    if submitted:
        url = "YOUR_GOOGLE_APPS_SCRIPT_WEB_APP_URL"  # Replace with your deployed Apps Script URL

        payload = {
            "customer_name": customer_name,
            "boiler_no": boiler_no,
            "capacity_tph": capacity_tph,
            "material_offer_planned": str(material_offer_planned),
            "material_offer_actual": str(material_offer_actual),
            "cutting_planned": str(cutting_planned),
            "cutting_actual": str(cutting_actual),
            "rolling_planned": str(rolling_planned),
            "rolling_actual": str(rolling_actual),
            "l_seam_rt_planned": str(l_seam_rt_planned),
            "l_seam_rt_actual": str(l_seam_rt_actual),
            "c_seam_planned": str(c_seam_planned),
            "c_seam_actual": str(c_seam_actual),
            "shell_ready_planned": str(shell_ready_planned),
            "shell_ready_actual": str(shell_ready_actual),
            "test_plate_testing_planned": str(test_plate_testing_planned),
            "test_plate_testing_actual": str(test_plate_testing_actual),
            "tube_plate_drilling_planned": str(tube_plate_drilling_planned),
            "tube_plate_drilling_actual": str(tube_plate_drilling_actual),
            "material_shortage": material_shortage,
            "ftp_setup_planned": str(ftp_setup_planned),
            "ftp_setup_actual": str(ftp_setup_actual),
            "nozzle_setup_planned": str(nozzle_setup_planned),
            "nozzle_setup_actual": str(nozzle_setup_actual),
            "final_setup_planned": str(final_setup_planned),
            "final_setup_actual": str(final_setup_actual),
            "full_welding_planned": str(full_welding_planned),
            "full_welding_actual": str(full_welding_actual),
            "hydro_planned": str(hydro_planned),
            "hydro_actual": str(hydro_actual),
            "customer_hydro_planned": str(customer_hydro_planned),
            "customer_hydro_actual": str(customer_hydro_actual),
            "remark": remark
        }

        try:
            r = requests.post(url, json=payload)
            if r.status_code == 200:
                st.success("βœ… Data successfully added to Google Sheet!")
            else:
                st.error(f"❌ Failed to send data. Status: {r.status_code}")
        except Exception as e:
            st.error(f"⚠ Error sending data: {e}")