Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -13855,29 +13855,29 @@ def page_cs():
|
|
| 13855 |
DB.update("assets", asset_id, {"checklist": bulk_template, "ppm_frequency": bulk_freq, "checklist_template": bulk_template})
|
| 13856 |
|
| 13857 |
if create_schedules:
|
| 13858 |
-
|
| 13859 |
-
|
| 13860 |
-
|
| 13861 |
-
|
| 13862 |
-
|
| 13863 |
-
|
| 13864 |
-
|
| 13865 |
-
|
| 13866 |
-
|
| 13867 |
-
|
| 13868 |
-
|
| 13869 |
-
|
| 13870 |
-
|
| 13871 |
-
|
| 13872 |
-
|
| 13873 |
-
|
| 13874 |
-
|
| 13875 |
-
|
| 13876 |
-
|
| 13877 |
-
|
| 13878 |
-
|
| 13879 |
-
|
| 13880 |
-
|
| 13881 |
|
| 13882 |
if "bulk_manual_dates" in st.session_state:
|
| 13883 |
st.session_state["bulk_manual_dates"] = []
|
|
|
|
| 13855 |
DB.update("assets", asset_id, {"checklist": bulk_template, "ppm_frequency": bulk_freq, "checklist_template": bulk_template})
|
| 13856 |
|
| 13857 |
if create_schedules:
|
| 13858 |
+
for date_idx, schedule_date in enumerate(dates_list_bulk):
|
| 13859 |
+
try:
|
| 13860 |
+
actual_date = schedule_date
|
| 13861 |
+
if staggered:
|
| 13862 |
+
offset = idx * stagger_days
|
| 13863 |
+
actual_date = (datetime.strptime(schedule_date, "%Y-%m-%d") + timedelta(days=offset)).strftime("%Y-%m-%d")
|
| 13864 |
+
|
| 13865 |
+
result = supabase.table("ppm_schedules").insert({
|
| 13866 |
+
"facility_code": fc,
|
| 13867 |
+
"asset_id": str(asset_id),
|
| 13868 |
+
"title": f"{asset.get('name','PPM')} - {bulk_template}",
|
| 13869 |
+
"frequency": bulk_freq,
|
| 13870 |
+
"status": "scheduled",
|
| 13871 |
+
"assigned_team": str(asset.get("department", "")),
|
| 13872 |
+
"next_due_date": actual_date,
|
| 13873 |
+
"created_at": datetime.now().isoformat()
|
| 13874 |
+
}).execute()
|
| 13875 |
+
|
| 13876 |
+
if result and result.data:
|
| 13877 |
+
schedule_count += 1
|
| 13878 |
+
except:
|
| 13879 |
+
pass
|
| 13880 |
+
enrolled += 1
|
| 13881 |
|
| 13882 |
if "bulk_manual_dates" in st.session_state:
|
| 13883 |
st.session_state["bulk_manual_dates"] = []
|