thank you for your quick reply sir
if (frappe.user.has_role('System Manager')) {
frappe.query_reports["Gate Clearance Report"] = {
"filters": [
{
"fieldname": "entry_end_date",
"label": __("Today"),
"fieldtype": "Date",
"default": frappe.datetime.get_today(),
"reqd": 0,
},
{
"fieldname": "gate",
"label": __("Filter By gate"),
"fieldtype": "Select",
"options": ["Gate 01", "Gate 02", "Gate 03"],
"default": "Gate 01"
}
]
}
}
and the python code
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
from frappe.utils import getdate, validate_email_address, today, add_years
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
data = get_requests(filters)
return columns, data
def get_columns():
return [
_("Full Name") + ":Data:150",_("Organization") + ":Data:150",_("End Date") + ":Data:150",
_("Gate") + ":Data:50", _("Approved By") + ":Data:100",
_("Mobile Telephone") + ":Data:70",_("Laptop Computer") + ":Data:70",_("Storage (USB, Hard disk)") + ":Data:50", _("Other Device") + ":Data:400", _("Reason") + ":Data:8000",
]
def get_conditions(filters):
conditions = ""
if filters.get("entry_end_date"):
if (filters.get("gate") == "Gate 01"):
conditions += "and entry_end_date >= %(entry_end_date)s and gate LIKE '%%Gate 01%%'"
if (filters.get("gate") == "Gate 02"):
conditions += "and entry_end_date >= %(entry_end_date)s and gate LIKE '%%Gate 02%%'"
if (filters.get("gate") == "Gate 03"):
conditions += "and entry_end_date >= %(entry_end_date)s and gate LIKE '%%Gate 03%%'"
# if (filters.get("gate") == "String"):
# conditions += "and entry_end_date >= %(entry_end_date)s and gate LIKE '%%String%%'"
return conditions
def get_requests(filters):
conditions = get_conditions(filters)
return frappe.db.sql("""select full_name,organization,entry_end_date,gate,approved_by
,mobile_telephone,laptop_computer,storage_usb_hard_disk,other_device,detailed_reason,idx from `tabGuest Information`
where docstatus=1 %s order by organization """ % conditions, filters, as_list=1)
- so the other thing is i didnt know how to query / join the parent table
'tabGate Clearance'
and the child table 'tabGuest Information'
because it doesn’t display the child table values (i just used the child table in the query).
i viewed the database and there seems to be no common data between them (as far as i noticed)