Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -143,14 +143,21 @@ def process_equipment_utilization(equip, proj, use_h, idle_h, move_f, cost_h, la
|
|
| 143 |
if not rec_id:
|
| 144 |
raise ValueError("Salesforce record creation succeeded, but no record ID was returned.")
|
| 145 |
|
|
|
|
|
|
|
|
|
|
| 146 |
uid = uuid.uuid4().hex[:8]
|
| 147 |
-
pdf_path = Path(f"static/reports/report_{uid}.pdf")
|
| 148 |
pdf_path.parent.mkdir(parents=True, exist_ok=True)
|
| 149 |
|
|
|
|
| 150 |
c = canvas.Canvas(str(pdf_path), pagesize=letter)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
c.setFont("Helvetica", 12)
|
| 152 |
-
c.drawString(100,
|
| 153 |
-
c.drawString(100, 735, f"Record ID: {rec_id}")
|
| 154 |
y = 710
|
| 155 |
for k, v in summary.items():
|
| 156 |
c.drawString(100, y, f"{k}: {v}")
|
|
@@ -406,5 +413,3 @@ with gr.Blocks() as app:
|
|
| 406 |
"""
|
| 407 |
if __name__ == "__main__":
|
| 408 |
app.launch()
|
| 409 |
-
|
| 410 |
-
|
|
|
|
| 143 |
if not rec_id:
|
| 144 |
raise ValueError("Salesforce record creation succeeded, but no record ID was returned.")
|
| 145 |
|
| 146 |
+
# Create safe strings for filename
|
| 147 |
+
safe_equip = equip.replace(" ", "_")
|
| 148 |
+
safe_proj = proj.replace(" ", "_")
|
| 149 |
uid = uuid.uuid4().hex[:8]
|
| 150 |
+
pdf_path = Path(f"static/reports/report_{safe_equip}_{safe_proj}_{uid}.pdf")
|
| 151 |
pdf_path.parent.mkdir(parents=True, exist_ok=True)
|
| 152 |
|
| 153 |
+
# Create PDF with dynamic title
|
| 154 |
c = canvas.Canvas(str(pdf_path), pagesize=letter)
|
| 155 |
+
c.setFont("Helvetica-Bold", 14)
|
| 156 |
+
title_str = f"Equipment Utilization Report - {equip} ({proj})"
|
| 157 |
+
c.drawString(100, 750, title_str)
|
| 158 |
+
|
| 159 |
c.setFont("Helvetica", 12)
|
| 160 |
+
c.drawString(100, 730, f"Record ID: {rec_id}")
|
|
|
|
| 161 |
y = 710
|
| 162 |
for k, v in summary.items():
|
| 163 |
c.drawString(100, y, f"{k}: {v}")
|
|
|
|
| 413 |
"""
|
| 414 |
if __name__ == "__main__":
|
| 415 |
app.launch()
|
|
|
|
|
|