import streamlit as st import pandas as pd import requests from datetime import datetime import pytz # SheetDB API Endpoint for Timecard Data SHEETDB_API_URL_TIMECARD = "https://sheetdb.io/api/v1/jsh4nri7t8rko" # Replace with your SheetDB API URL for timecard # Define password PASSWORD = "ma_12345" # Replace with your desired password # Hardcoded Metadata METADATA = { "Employee Names": [ "Ubaid Bashir", "Shoaib Ahmad", "Rumaan Hassan Alamgeer", "Sana Sanaullah", "Aafreen Mushtaq", "Andleeb Gul", "Irtika", "Sahil" ], "Project Names": [ "ICCL", "Reston", "Clermont", "Dale", "Pulaski", "NISA", "BAC", "Church", "Bishop", "Paramount", "Preng", "Misc.", "Marketing", "Ridge road", "Irving Street", "Bayfield road", "Bishops road", "Dale Dr", "Brook Dr", "Cpmi Church", "Dual Hwy", "Rhode Island Ave", "College plaza redevelopment", "Pulaski hwy", "Sonoma road", "Ridge PI", "Broad Street", "Hardy Dr", "22nd street N", "Clue Dr", "Clermont Ave" ], "Project Codes": [ "US 001", "US 003", "US 004", "US 005", "US 006", "US 007", "US 008", "US 009", "US 010", "IND 001", "IND 007", "IND 008", "US 011", "USA_01", "USA_02", "USA_03", "USA_04", "USA_05", "USA_06", "USA_07", "USA_08", "USA_09", "USA_10", "USA_11", "USA_12", "USA_13", "USA_14", "USA_15", "USA_16", "USA_17", "USA_18" ] } # Load timecard data from SheetDB def load_data(): response = requests.get(SHEETDB_API_URL_TIMECARD) if response.status_code == 200: return pd.DataFrame(response.json()) else: return pd.DataFrame(columns=["Employee Name", "Project Name", "Project Code", "Date", "Hours", "Notes"]) # Save timecard data to SheetDB def save_data(employee_name, project_name, project_code, hours, notes): # Automatically set the date to the current date ist = pytz.timezone('Asia/Kolkata') ist_now = datetime.now(ist) # Format to get only the date formatted_date = ist_now.date().isoformat() new_entry = { "Employee Name": employee_name, "Project Name": project_name, "Project Code": project_code, "Date": formatted_date, "Hours": hours, "Notes": notes } response = requests.post(SHEETDB_API_URL_TIMECARD, json=new_entry) if response.status_code == 201: st.success("Entry added successfully!") else: st.error("Failed to add entry. Please try again.") # Custom Cyberpunk CSS (Less Glowy) st.markdown( """ """, unsafe_allow_html=True ) # Password authentication if "authenticated" not in st.session_state: st.session_state.authenticated = False if not st.session_state.authenticated: st.markdown("
Please enter the password to access the application.
", unsafe_allow_html=True) password = st.text_input("Password", type="password") if st.button("Login"): if password == PASSWORD: st.session_state.authenticated = True st.success("Login successful!") else: st.error("Incorrect password. Please try again.") else: # Display company logo and title in the sidebar st.sidebar.image("ma_logo.png") # Replace with your logo st.sidebar.markdown("Employee Timecard Management System
", unsafe_allow_html=True) # Main section st.markdown("Welcome to the Munshi Associates Time Card Management System
", unsafe_allow_html=True) # Load metadata (hardcoded) employee_names = METADATA["Employee Names"] project_names = METADATA["Project Names"] project_codes = METADATA["Project Codes"] # Form for adding timecard entries st.markdown("Fill out the form below to add a new entry.
", unsafe_allow_html=True) col1, col2 = st.columns(2) with col1: employee_name = st.selectbox("Select Employee Name", employee_names) project_name = st.selectbox("Select Project Name", project_names) project_code = st.selectbox("Select Project Code", project_codes) with col2: hours = st.number_input("Hours Worked", min_value=0.0, step=0.5) notes = st.text_area("Notes", placeholder="Add any relevant notes here...") submitted = st.form_submit_button("Add Entry") if submitted: save_data(employee_name, project_name, project_code, hours, notes) # Display existing timecard data st.markdown("