File size: 5,698 Bytes
34cc38d
 
 
 
 
 
a4fd23d
 
 
 
 
 
34cc38d
 
 
 
 
 
a4fd23d
 
 
 
 
34cc38d
 
a4fd23d
 
 
34cc38d
 
 
a4fd23d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34cc38d
 
a4fd23d
 
 
 
 
34cc38d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a4fd23d
 
 
 
 
34cc38d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a4fd23d
34cc38d
 
a4fd23d
 
 
 
 
34cc38d
 
4fb54e3
 
 
 
a4fd23d
4fb54e3
 
 
 
a4fd23d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4fb54e3
a4fd23d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4fb54e3
a4fd23d
 
 
 
 
 
 
 
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import streamlit as st
import pandas as pd

from calculations import calculate_roi
from ai_synopsis import generate_synopsis
from pdf_generator import generate_pdf
from email_sender import send_email


# ====================================
# PAGE CONFIG
# ====================================

st.set_page_config(
    page_title="AI ROI Calculator",
    layout="wide"
)


# ====================================
# TITLE
# ====================================

st.title("AI ROI Calculator")

st.markdown(
    "Generate ROI savings reports with AI-powered synopsis"
)

st.divider()


# ====================================
# CUSTOMER DETAILS
# ====================================

st.subheader("Customer Details")

customer_name = st.text_input("Full Name")

customer_email = st.text_input("Email Address")

company_name = st.text_input("Company Name")

phone_number = st.text_input("Phone Number")

st.divider()


# ====================================
# MAIN LAYOUT
# ====================================

col1, col2 = st.columns(2)


# ====================================
# LEFT COLUMN
# ====================================

with col1:

    st.subheader("Business Inputs")

    industry = st.selectbox(
        "Select Industry",
        [
            "Retail",
            "Healthcare",
            "Manufacturing",
            "Logistics",
            "Education",
        ]
    )

    num_assets = st.number_input(
        "Number of Assets",
        min_value=1,
        value=1000,
    )

    asset_value = st.number_input(
        "Average Asset Value",
        min_value=1,
        value=150,
    )

    num_employees = st.number_input(
        "Number of Employees",
        min_value=1,
        value=10,
    )

    employee_salary = st.number_input(
        "Annual Employee Salary",
        min_value=1,
        value=32800,
    )

    productivity_gain_percent = st.slider(
        "Productivity Gain (%)",
        1,
        100,
        10,
    )

    audit_days = st.number_input(
        "Audit Days Per Year",
        min_value=1,
        value=2,
    )

    auditors = st.number_input(
        "Number of Auditors",
        min_value=1,
        value=3,
    )

    auditor_cost = st.number_input(
        "Daily Auditor Cost",
        min_value=1,
        value=1500,
    )


# ====================================
# RIGHT COLUMN
# ====================================

with col2:

    st.subheader("ROI Results")

    roi_data = calculate_roi(
        num_assets,
        asset_value,
        num_employees,
        employee_salary,
        productivity_gain_percent,
        audit_days,
        auditors,
        auditor_cost,
    )

    df = pd.DataFrame(
        roi_data.items(),
        columns=["Category", "Amount"]
    )

    st.dataframe(df)

    st.metric(
        label="Total Annual Savings",
        value=f"INR {roi_data['Total Savings']}"
    )


st.divider()


# ====================================
# GENERATE REPORT BUTTON
# ====================================

if st.button("Generate AI Report"):

    # ====================================
    # VALIDATION
    # ====================================

    if (
        not customer_name.strip()
        or not customer_email.strip()
        or not company_name.strip()
        or not phone_number.strip()
    ):

        st.error("Please fill all customer details.")

    else:

        with st.spinner("Generating AI Synopsis..."):

            # ====================================
            # USER DATA
            # ====================================

            user_data = {
                "Customer Name": customer_name,
                "Customer Email": customer_email,
                "Company Name": company_name,
                "Phone Number": phone_number,
                "Industry": industry,
                "Number of Assets": num_assets,
                "Average Asset Value": asset_value,
                "Employees": num_employees,
            }

            # ====================================
            # AI DATA
            # ====================================

            ai_data = {
                "industry": industry,
                "num_assets": num_assets,
                "asset_value": asset_value,
                "num_employees": num_employees,
                "total_savings": roi_data['Total Savings'],
            }

            # ====================================
            # GENERATE AI SYNOPSIS
            # ====================================

            synopsis = generate_synopsis(ai_data)

            st.subheader("AI Generated Synopsis")

            st.write(synopsis)

            # ====================================
            # GENERATE PDF
            # ====================================

            pdf = generate_pdf(
                user_data,
                roi_data,
                synopsis,
            )

            # ====================================
            # SEND EMAIL
            # ====================================

            email_status = send_email(
                user_data,
                roi_data
            )

            if email_status:

                st.success(
                    "Lead details sent successfully!"
                )

            else:

                st.error(
                    "Failed to send lead email."
                )

            # ====================================
            # DOWNLOAD PDF
            # ====================================

            st.download_button(
                label="Download Report",
                data=pdf,
                file_name="ai_roi_report.pdf",
                mime="application/pdf",
            )