From 225f6bf8d46120ac8382b76593df109a5b20cec5 Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Mon, 6 Oct 2025 18:42:16 +0530 Subject: [PATCH] Chnaged the pie chart colors for each cards --- mailling/dpr.html | 168 ++++++++++++++------------ mailling/project_statistics_report.py | 34 ++++-- 2 files changed, 118 insertions(+), 84 deletions(-) diff --git a/mailling/dpr.html b/mailling/dpr.html index c3d9b64..aefe0f8 100644 --- a/mailling/dpr.html +++ b/mailling/dpr.html @@ -57,6 +57,8 @@ } .card { + display: flex; + flex-direction: column; flex: 1; min-width: 200px; border: 1px solid #ddd; @@ -67,7 +69,7 @@ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); /* <-- added shadow */ transition: transform 0.2s ease, box-shadow 0.2s ease; - border-top: 1px solid #e63946; + border-top: 1px solid #49bf3c; } @@ -82,13 +84,24 @@ justify-content: center; border-radius: 6px; text-decoration: none; - color: #49bf3c; /* arrow color */ background: #f5f5f5; /* badge background */ box-shadow: 0 1px 3px rgba(0, 0, 0, .15); } + .card-link-success { + color: #49bf3c; + } + + .card-link-warning { + color: #ffc107; + } + + .card-link-primary { + color: #007bff; + } + .card-link:hover { background: #ececec; } @@ -207,7 +220,7 @@ .legend { margin-top: 10px; display: flex; - justify-content: center; + justify-content: flex-start; flex-wrap: wrap; gap: 8px; font-size: 12px; @@ -228,7 +241,7 @@ } .legend-red { - background: #49bf3c; + background: #e63946; } .legend-blue { @@ -243,6 +256,10 @@ background: #ccc; } + .legend-yellow { + background: #ffc107; + } + .donut { @@ -251,11 +268,11 @@ --danger: #e63946; --primary: #007bff; --warning: #ffc107; - --success: #198754; + --success: #28a745; /* Fill color */ --track: #e9ecef; /* Background track */ - --size: 120px; + --size: 200px; /* Default size */ --thickness: 20px; /* Default thickness */ @@ -288,6 +305,13 @@ .donut span { position: absolute; font-size: calc(var(--size) / 6); + width:80%; + box-sizing:border-box; + display:flex; + gap: 4px; + flex-wrap: wrap; + justify-content:center; + align-items:center; } /* Variants */ @@ -298,7 +322,7 @@ .donut.medium { --size: 120px; - --thickness: 25px; + --thickness: 15px; } .donut.large { @@ -310,25 +334,21 @@ .donut-success { background: conic-gradient(var(--success) calc(var(--percentage) * 1%), var(--track) 0); - color: var(--success) } .donut-warning { background: conic-gradient(var(--warning) calc(var(--percentage) * 1%), var(--track) 0); - color: var(--warning) } .donut-danger { background: conic-gradient(var(--danger) calc(var(--percentage) * 1%), var(--track) 0); - color: var(--danger) } .donut-primary { background: conic-gradient(var(--primary) calc(var(--percentage) * 1%), var(--track) 0); - color: var(--primary) } .values { @@ -353,7 +373,7 @@

Daily Progress Report

- Project:{{projectName}}
+ Project: {{projectName}}
Date: {{date}}
@@ -366,7 +386,7 @@
- @@ -376,9 +396,9 @@
-
- -

{{todaysAttendances}}

/

{{totalEmployees}}

+
+ +

{{todaysAttendances}}

/

{{totalEmployees}}

@@ -387,7 +407,7 @@
- Today's Attendance + Today's Attendance
@@ -400,7 +420,7 @@
- @@ -411,8 +431,8 @@
- -

{{totalCompletedTask}}

/

{{totalPlannedTask}}

+ +

{{totalCompletedTask}}

/

{{totalPlannedTask}}

@@ -430,23 +450,13 @@
-
-

*Today's total work

+
+

*Today's Total Work

-
- @@ -456,9 +466,9 @@
-
- -

{{totalCompletedWork}}

/

{{totalPlannedWork}}

+
+ +

{{totalCompletedWork}}

/

{{totalPlannedWork}}

@@ -468,7 +478,7 @@
- Completed Work + Completed Work
@@ -476,9 +486,29 @@
+
+

*Project's Total Work

+
+
+ +
+ + +
-

*Project's total work

+

Pending Attendance

+ + + + + + + + + +
Regularization Pending{{regularizationPending}}
Checkout Pending{{checkoutPending}}
@@ -486,45 +516,31 @@ rel="noopener"> -

Regularization Pending

-

{{regularizationPending}}

- -

Checkout Pending

-

{{checkoutPending}}

-
- -
- - - -

Activity Report Pending

-
- - -
- - -

{{reportPending}}

/

{{todaysAssignTasks}}

-
-
- - -
-
- Total Pending Tasks -
-
- Today's Assigned Tasks -
-
+
+

Activity Report Pending

+ + + + + + + + + + + + + +
Total Pending Tasks{{reportPending}}
Today's Assigned Tasks{{todaysAssignTasks}}
Today's Completed Tasks{{todaysCompletedTasks}}
{% if teamOnSite and teamOnSite|length > 0 %}
+ + +

Team Strength on Site

@@ -582,9 +598,9 @@
- | + Linkedin | - | + | | @@ -594,8 +610,8 @@
-
- You have received this email because it contains important information about your Marco PMS Account account. +
+ You have received this email because it contains important information about your {{websiteName}} Account account.
diff --git a/mailling/project_statistics_report.py b/mailling/project_statistics_report.py index 937b3fe..15bf3f0 100644 --- a/mailling/project_statistics_report.py +++ b/mailling/project_statistics_report.py @@ -62,6 +62,14 @@ def get_percentage(part, whole, decimals: int = 2): return 0.0 return round((part / whole) * 100.0, decimals) +def value_minization(minimize_value): + if minimize_value >= 1000: + minimized_value = round((minimize_value/1000),2) + result = f"{minimized_value}K" + else: + result = f"{minimize_value}" + return result + if __name__ == "__main__": template_name = "dpr.html" project_ids = [p.strip() for p in PROJECT_IDS.split(",") if p.strip()] @@ -69,23 +77,31 @@ if __name__ == "__main__": for project_id in project_ids: data = fetch_Project_report(project_id) - if data["attendancePercentage"]: + if "attendancePercentage" in data: attendance_percentage = data["attendancePercentage"] - print("from API") else: attendance_percentage = get_percentage(data["todaysAttendances"], data["totalEmployees"], 2) - if data["taskPercentage"]: + if "taskPercentage" in data: task_percentage = data["taskPercentage"] - print("from API") else: task_percentage = get_percentage(data["totalCompletedTask"], data["totalPlannedTask"], 2) + if "todaysCompletedTasks" in data: + todays_completed_tasks = data["todaysCompletedTasks"] + else: + todays_completed_tasks = 0 + web_url = f"{WEB_BASE_URL}/auth/login" dt = datetime.datetime.strptime(data["date"], "%Y-%m-%dT%H:%M:%SZ") api_formatted_date = dt.strftime("%d-%b-%Y") + total_planned_work = value_minization(data["totalPlannedWork"]) + total_completed_work = value_minization(data["totalCompletedWork"]) + total_planned_task = value_minization(data["totalPlannedTask"]) + total_completed_task = value_minization(data["totalCompletedTask"]) + context = { "webUrl":web_url, "date": api_formatted_date, @@ -97,13 +113,15 @@ if __name__ == "__main__": "taskPercentage":task_percentage, "regularizationPending": data["regularizationPending"], "checkoutPending": data["checkoutPending"], - "totalPlannedWork": round(data["totalPlannedWork"],2), - "totalCompletedWork": round(data["totalCompletedWork"],2), - "totalPlannedTask": round(data["totalPlannedTask"],2), - "totalCompletedTask": round(data["totalCompletedTask"],2), + "totalPlannedWork": total_planned_work, + "totalCompletedWork": total_completed_work, + "totalPlannedTask": total_planned_task, + "totalCompletedTask": total_completed_task, "completionStatus": round(data["completionStatus"],2), "reportPending": data["reportPending"], "todaysAssignTasks": data["todaysAssignTasks"], + "todaysCompletedTasks": todays_completed_tasks, + "websiteName":"OnFieldWork.com", "teamOnSite": data["teamOnSite"], "performedTasks": data["performedTasks"], "performedAttendance": data["performedAttendance"]