コード例 #1
0
def get_result(filters):
    user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
    res_list = []
    if user_id:
        request_data = json.dumps({
            "user_id": user_id,
            "property_id": filters.get("property_id")
        })
        if not filters.get("property_id"):
            response = get_agent_properties(request_data)
        else:
            response = get_property_of_given_id(request_data)
            response["data"] = [response.get("data")]
        for prop in response.get("data"):
            prop_id = prop.get("property_id")
            prop_visit_count = get_property_visit_count(prop_id)
            property_id = "<a onclick=get_on_click_trigger('{0}')>{0}</a>".format(
                prop_id)
            res_list.append([
                property_id,
                prop.get("property_title"),
                prop.get("property_type"),
                prop.get("property_subtype"),
                prop.get("property_subtype_option"),
                prop.get("location"),
                prop.get("status"), prop_visit_count
            ])

    return res_list
コード例 #2
0
def get_my_properties(doctype, txt, searchfield, start, page_len, filters):
	user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
	res_list = []
	if user_id:
		request_data = json.dumps({"user_id":user_id})
		response = get_agent_properties(request_data)
		for prop in response.get("data"):
			res_list.append([prop.get("property_id"),prop.get("property_title")])
	return res_list
コード例 #3
0
def get_results(filters):
	results = frappe.db.sql(""" select ag.name, group_concat(aop.location_name) as location, 
	 							ag.user_id ,ag.first_name, ag.package_name
	 							from `tabAgent` as ag  join `tabArea Of Operaation` as aop
	 							on ag.name = aop.parent
	 							group by ag.name	""",as_list=1)
	for agent in results:
		request_data = json.dumps({"user_id":agent[2]})
		agent_data = get_agent_properties(request_data)
		agent[2] = agent_data.get("total_records", 0)
	return results	
コード例 #4
0
def get_my_properties(doctype, txt, searchfield, start, page_len, filters):
    user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
    res_list = []
    if user_id:
        request_data = json.dumps({"user_id": user_id})
        response = get_agent_properties(request_data)
        for prop in response.get("data"):
            res_list.append(
                [prop.get("property_id"),
                 prop.get("property_title")])
    return res_list
コード例 #5
0
def get_conditions(filters):
    cond = ""
    if filters.get("property_id"):
        cond = "where sp.property_id='{0}' ".format(filters.get("property_id"))
    elif filters.get("agent") and not filters.get("property_id"):
        user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
        agent_properties = get_agent_properties(json.dumps({"user_id": user_id}))
        if agent_properties.get("data"):
            cond_build = ", ".join(['"{0}"'.format(prop.get("property_id")) for prop in agent_properties.get("data")])
            cond = "where sp.property_id in ({})".format(cond_build)
    return cond
コード例 #6
0
def get_results(filters):
    results = frappe.db.sql(
        """ select ag.name, group_concat(aop.location_name) as location, 
	 							ag.user_id ,ag.first_name, ag.package_name
	 							from `tabAgent` as ag  join `tabArea Of Operaation` as aop
	 							on ag.name = aop.parent
	 							group by ag.name	""",
        as_list=1)
    for agent in results:
        request_data = json.dumps({"user_id": agent[2]})
        agent_data = get_agent_properties(request_data)
        agent[2] = agent_data.get("total_records", 0)
    return results
コード例 #7
0
def get_conditions(filters):
    cond = ''
    if filters.get("property_id"):
        cond = "where sp.property_id='{0}' ".format(filters.get("property_id"))
    elif filters.get("agent") and not filters.get("property_id"):
        user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
        agent_properties = get_agent_properties(
            json.dumps({"user_id": user_id}))
        if agent_properties.get("data"):
            cond_build = ", ".join([
                '"{0}"'.format(prop.get("property_id"))
                for prop in agent_properties.get("data")
            ])
            cond = "where sp.property_id in ({})".format(cond_build)
    return cond
コード例 #8
0
def get_result(filters):
    res = ''
    if filters.get("agent"):
        user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
        agent_properties = get_agent_properties(
            json.dumps({"user_id": user_id}))
        if agent_properties.get("data"):
            res = frappe.db.sql(""" select 
									usr.name, usr.first_name, usr.last_name, 
									usr.mobile_no, sp.visiting_date ,sp.property_id, sp.property_title
									from `tabShow Contact Property` as sp join `tabUser` as usr  
									on sp.user_id = usr.user_id
									{0} order by sp.visiting_date desc			
								 """.format(get_conditions(filters)),
                                as_list=1)
    return res if res else [[]]
コード例 #9
0
def get_result(filters):
	user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
	res_list = []
	if user_id:
		request_data = json.dumps({"user_id":user_id, "property_id":filters.get("property_id")})
		if not filters.get("property_id"):
			response = get_agent_properties(request_data) 
		else: 
			response = get_property_of_given_id(request_data)
			response["data"] = [response.get("data")]
		for prop in response.get("data"):
			prop_id = prop.get("property_id")
			prop_visit_count = get_property_visit_count(prop_id)
			property_id = "<a onclick=get_on_click_trigger('{0}')>{0}</a>".format(prop_id)
			res_list.append([ property_id , prop.get("property_title"), prop.get("property_type"),
							prop.get("property_subtype"), prop.get("property_subtype_option"), prop.get("location"), 
							prop.get("status"),prop_visit_count])
			
	return res_list
コード例 #10
0
def get_result(filters):
    res = ""
    if filters.get("agent"):
        user_id = frappe.db.get_value("User", filters.get("agent"), "user_id")
        agent_properties = get_agent_properties(json.dumps({"user_id": user_id}))
        if agent_properties.get("data"):
            res = frappe.db.sql(
                """ select 
									usr.name, usr.first_name, usr.last_name, 
									usr.mobile_no, sp.visiting_date ,sp.property_id, sp.property_title
									from `tabShow Contact Property` as sp join `tabUser` as usr  
									on sp.user_id = usr.user_id
									{0} order by sp.visiting_date desc			
								 """.format(
                    get_conditions(filters)
                ),
                as_list=1,
            )
    return res if res else [[]]