From 1682b0f11f7e85fb981655a65baa562233bee49d Mon Sep 17 00:00:00 2001 From: mariam454208 Date: Tue, 8 Oct 2024 21:16:19 +0200 Subject: [PATCH 1/3] Add CaseStatus.py file --- sa3ed_app/api/CaseStatus.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sa3ed_app/api/CaseStatus.py diff --git a/sa3ed_app/api/CaseStatus.py b/sa3ed_app/api/CaseStatus.py new file mode 100644 index 0000000..21def70 --- /dev/null +++ b/sa3ed_app/api/CaseStatus.py @@ -0,0 +1,17 @@ +import frappe + +@frappe.whitelist() +def follow_up_case(case_id): + + lost_person = frappe.db.get_value('Lost Person', {'name': case_id}, ['case_status'], as_dict=True) + + if lost_person: + return {'case_status': lost_person['case_status']} + + + founded_person = frappe.db.get_value('Founded Person', {'name': case_id}, ['case_status'], as_dict=True) + + if founded_person: + return {'case_status': founded_person['case_status']} + + return {'error': 'Case not found'} From 685f4f6c83931fb12454df2e076532a009f6094d Mon Sep 17 00:00:00 2001 From: mariam454208 Date: Tue, 8 Oct 2024 22:07:30 +0200 Subject: [PATCH 2/3] Add search folder with index.js, index.css, index.html and CaseStatus.py --- sa3ed_app/www/search/index.html | 28 ++++++++++++++++++++++++++++ sa3ed_app/www/search/index.js | 33 +++++++++++++++++++++++++++++++++ sa3ed_app/www/search/indext.css | 13 +++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 sa3ed_app/www/search/index.html create mode 100644 sa3ed_app/www/search/index.js create mode 100644 sa3ed_app/www/search/indext.css diff --git a/sa3ed_app/www/search/index.html b/sa3ed_app/www/search/index.html new file mode 100644 index 0000000..ffbebac --- /dev/null +++ b/sa3ed_app/www/search/index.html @@ -0,0 +1,28 @@ +{% extends base_template_path %} +{% block content %} +
+
+
+ +

من فضلك أدخل رقم الحالة للتحقق من حالتها

+ +
+
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+{% endblock %} diff --git a/sa3ed_app/www/search/index.js b/sa3ed_app/www/search/index.js new file mode 100644 index 0000000..3661354 --- /dev/null +++ b/sa3ed_app/www/search/index.js @@ -0,0 +1,33 @@ +function followUpCase() { + var caseID = document.getElementById('caseID').value; + + if (!caseID) { + document.getElementById('statusMessage').innerHTML = '

من فضلك أدخل رقم الحالة.

'; + return; + } + + document.getElementById("SearchCaseButton").disabled = true; + document.getElementById("ProgressBar").hidden = false; + + frappe.call({ + method: 'sa3ed_app.api.CaseStatus.follow_up_case', + args: { case_id: caseID }, + callback: function(response) { + document.getElementById("SearchCaseButton").disabled = false; + document.getElementById("ProgressBar").hidden = true; + + if (response.message && response.message.case_status) { + document.getElementById('statusMessage').innerHTML = '

الحالة: ' + response.message.case_status + '

'; + } else if (response.message && response.message.error) { + document.getElementById('statusMessage').innerHTML = '

' + response.message.error + '

'; + } else { + document.getElementById('statusMessage').innerHTML = '

لم يتم العثور على الحالة.

'; + } + }, + error: function(error) { + document.getElementById("SearchCaseButton").disabled = false; + document.getElementById("ProgressBar").hidden = true; + document.getElementById('statusMessage').innerHTML = '

حدث خطأ أثناء التحقق من الحالة.

'; + } + }); +} diff --git a/sa3ed_app/www/search/indext.css b/sa3ed_app/www/search/indext.css new file mode 100644 index 0000000..8b13c7c --- /dev/null +++ b/sa3ed_app/www/search/indext.css @@ -0,0 +1,13 @@ + +#statusMessage p { + font-size: 1.2em; + margin-top: 10px; +} + +.text-success { + color: green; +} + +.text-danger { + color: red; +} From 351739aa2bdd5974232819c2323e21399c5f2448 Mon Sep 17 00:00:00 2001 From: mariam454208 Date: Tue, 8 Oct 2024 22:36:59 +0200 Subject: [PATCH 3/3] Search Api --- sa3ed_app/hooks.py | 3 +++ sa3ed_app/www/home/index.html | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sa3ed_app/hooks.py b/sa3ed_app/hooks.py index c043ebf..284b363 100644 --- a/sa3ed_app/hooks.py +++ b/sa3ed_app/hooks.py @@ -17,6 +17,9 @@ web_include_css = "/assets/css/site.css" web_include_js = "/assets/js/site.js" + + + # include custom scss in every website theme (without file extension ".scss") # website_theme_scss = "sa3ed_app/public/scss/website" diff --git a/sa3ed_app/www/home/index.html b/sa3ed_app/www/home/index.html index 0a15718..2025e94 100644 --- a/sa3ed_app/www/home/index.html +++ b/sa3ed_app/www/home/index.html @@ -35,6 +35,15 @@

{{_('ساعد')}}


+ +