File size: 3,113 Bytes
ba20008
 
5088752
ba20008
5088752
ba20008
 
7b81849
ba20008
 
 
 
 
ff3df29
 
 
6060b58
73b4a7f
ba20008
73b4a7f
ba20008
 
 
73b4a7f
 
ba20008
4c720a1
73b4a7f
 
ba20008
73b4a7f
 
ba20008
c9d336f
 
ba20008
4c720a1
73b4a7f
 
4c720a1
c9d336f
73b4a7f
 
ac39044
c9d336f
ac39044
4c720a1
 
73b4a7f
 
f486fb2
c9d336f
73b4a7f
 
4c720a1
c9d336f
73b4a7f
 
4c720a1
 
73b4a7f
 
4c720a1
73b4a7f
ba20008
 
c9d336f
73b4a7f
ac39044
ff3df29
359e3e4
 
73b4a7f
359e3e4
73b4a7f
 
359e3e4
ff3df29
 
 
 
ba20008
73b4a7f
359e3e4
ba20008
 
ff3df29
 
ac39044
ff3df29
ac39044
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ff3df29
ac39044
 
 
73b4a7f
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
# -*- 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 = """
<style>
.stAppViewContainer {
    position: relative;
    background: linear-gradient(to bottom, #043548 0%, #02141e 55%, #01080c 100%);
    background-attachment: fixed;
}
main .block-container {
    max-width: 900px;
    padding-top: 2rem !important;
}
[data-testid="stHeader"] {
    background-color: rgba(0, 0, 0, 0);
}
.top-logos-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.2rem;
}
.vision-logo {
    width: 280px;
    height: auto;
}
.bottom-logos-row {
    display: flex;
    align-items: center;
    justify-content: center;
    column-gap: 25px;
    margin-top: -5px;
}
.center-logo {
    width: 270px;
    height: auto;
}
.amanah-logo {
    width: 200px;
    height: auto;
}
h1 {
    margin-top: 0.5rem !important;
    color: white !important;
}
label, p, span {
    color: white !important;
}
</style>
"""

st.markdown(page_css, unsafe_allow_html=True)

st.markdown(
    f"""
    <div class="top-logos-wrapper">
        <img src="{VISION_URL}" class="vision-logo" />
        <div class="bottom-logos-row">
            <img src="{CENTER_URL}" class="center-logo" />
            <img src="{AMANAH_URL}" class="amanah-logo" />
        </div>
    </div>
    """,
    unsafe_allow_html=True,
)

st.markdown("<h1>Reports 940</h1>", 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",
        )