# -*- coding: utf-8 -*-
from __future__ import annotations
from datetime import datetime, date, time
import pandas as pd
import streamlit as st
from analysis import read_excel_safe, build, get_pivots_for_ppt
from ppt_fill import fill_ppt
st.set_page_config(page_title="Reports 940", layout="centered")
VISION_URL = "https://huggingface.co/spaces/DAM20/Etmam/resolve/main/assets/vision2030_logo.png"
AMANAH_URL = "https://huggingface.co/spaces/DAM20/Etmam/resolve/main/assets/amanah_logo.png"
CENTER_URL = "https://huggingface.co/spaces/DAM20/Etmam/resolve/main/assets/center_logo.png"
page_css = """
"""
st.markdown(page_css, unsafe_allow_html=True)
st.markdown(
f"""
""",
unsafe_allow_html=True,
)
st.markdown("Reports 940
", unsafe_allow_html=True)
uploaded_file = st.file_uploader("Upload file (Excel)", type=["xlsx"])
col1, col2 = st.columns(2)
with col1:
d_closed = st.date_input("Date", value=date.today())
with col2:
t_closed = st.time_input("Time", value=time(8, 0))
CLOSED_DT = pd.Timestamp(datetime.combine(d_closed, t_closed))
if uploaded_file is not None:
df0 = read_excel_safe(uploaded_file)
out_excel = build(df0, CLOSED_DT)
p_open_ar, p_sla_ar, p_urbi = get_pivots_for_ppt(df0, CLOSED_DT)
ppt_template = "templates/balady_template.pptx"
out_ppt = fill_ppt(ppt_template, p_open_ar, p_sla_ar, p_urbi, CLOSED_DT)
dl1, dl2 = st.columns(2)
with dl1:
st.download_button(
"Download Excel report",
data=out_excel.getvalue(),
file_name="report_balady.xlsx",
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)
with dl2:
st.download_button(
"Download PowerPoint",
data=out_ppt.getvalue(),
file_name="report_balady.pptx",
mime="application/vnd.openxmlformats-officedocument.presentationml.presentation",
)