diff --git a/church/church_finances/doctype/church_alms_request/church_alms_request.js b/church/church_finances/doctype/church_alms_request/church_alms_request.js index d7604a0..e8c5985 100644 --- a/church/church_finances/doctype/church_alms_request/church_alms_request.js +++ b/church/church_finances/doctype/church_alms_request/church_alms_request.js @@ -2,6 +2,12 @@ // For license information, please see license.txt frappe.ui.form.on('Church Alms Request', { + recipient_type: function(frm) { + // Dynamically update the Recipient field description based on the Recipient Type that is selected + if (frm.doc.recipient_type) { + frm.set_df_property('recipient', 'description', `Alms are requested for this ${frm.doc.recipient_type}.`); + } + }, refresh(frm) { // Add a custom button that creates an Expense from the Alms Request if (!frm.is_new()) { @@ -18,6 +24,17 @@ frappe.ui.form.on('Church Alms Request', { }); } }, + onload: function(frm) { + // Pre-populate the requestor field with the current user's name + if (frm.is_new()) { + frappe.db.get_value('Church Person', {'portal_user': frappe.session.user}, 'name') + .then(r => { + if (r && r.message) { + frm.set_value('requestor', r.message.name); + } + }); + } + } }); diff --git a/church/church_prayers/doctype/church_prayer_request/church_prayer_request.js b/church/church_prayers/doctype/church_prayer_request/church_prayer_request.js index 99ab1ed..e76af86 100644 --- a/church/church_prayers/doctype/church_prayer_request/church_prayer_request.js +++ b/church/church_prayers/doctype/church_prayer_request/church_prayer_request.js @@ -1,8 +1,16 @@ // Copyright (c) 2025, meichthys and contributors // For license information, please see license.txt -// frappe.ui.form.on("Church Prayer Request", { -// refresh(frm) { - -// }, -// }); +frappe.ui.form.on('Church Prayer Request', { + onload: function(frm) { + // Pre-populate the requestor field with the current user's name + if (frm.is_new()) { + frappe.db.get_value('Church Person', {'portal_user': frappe.session.user}, 'name') + .then(r => { + if (r && r.message) { + frm.set_value('requestor', r.message.name); + } + }); + } + } +}); \ No newline at end of file diff --git a/church/church_prayers/doctype/church_prayer_request/church_prayer_request.json b/church/church_prayers/doctype/church_prayer_request/church_prayer_request.json index 5dc6419..b003258 100644 --- a/church/church_prayers/doctype/church_prayer_request/church_prayer_request.json +++ b/church/church_prayers/doctype/church_prayer_request/church_prayer_request.json @@ -10,11 +10,12 @@ "field_order": [ "status", "type", + "is_private", "column_break_ynvf", - "related_person", + "requestor", + "recipient", "section_break_usaz", - "request", - "is_private" + "request" ], "fields": [ { @@ -35,19 +36,6 @@ "fieldtype": "Column Break", "placeholder": "If this request is for a specific person, select/add the person here." }, - { - "allow_in_quick_entry": 1, - "description": "If this request is for a specific person, select/add the person here.", - "fieldname": "related_person", - "fieldtype": "Link", - "in_filter": 1, - "in_list_view": 1, - "in_preview": 1, - "in_standard_filter": 1, - "label": "Related Person", - "options": "Church Person", - "search_index": 1 - }, { "fieldname": "section_break_usaz", "fieldtype": "Section Break" @@ -84,6 +72,29 @@ "label": "Type", "options": "Church Prayer Request Type", "reqd": 1 + }, + { + "description": "The person who made the request.", + "fieldname": "requestor", + "fieldtype": "Link", + "in_filter": 1, + "in_preview": 1, + "label": "Requestor", + "options": "Church Person", + "reqd": 1 + }, + { + "allow_in_quick_entry": 1, + "description": "The person for whom prayers will be prayed.", + "fieldname": "recipient", + "fieldtype": "Link", + "in_filter": 1, + "in_list_view": 1, + "in_preview": 1, + "in_standard_filter": 1, + "label": "Recipient", + "options": "Church Person", + "search_index": 1 } ], "grid_page_length": 50, @@ -94,7 +105,7 @@ "table_fieldname": "topics" } ], - "modified": "2025-11-15 00:58:11.484183", + "modified": "2026-02-19 23:26:19.972696", "modified_by": "Administrator", "module": "Church Prayers", "name": "Church Prayer Request", @@ -141,9 +152,8 @@ "write": 1 } ], - "quick_entry": 1, "row_format": "Dynamic", - "search_fields": "status,type,related_person", + "search_fields": "status,type,recipient", "show_preview_popup": 1, "show_title_field_in_link": 1, "sort_field": "modified",