Merge pull request #8227 from manassolanki/contact_report
Addition of few more fields in student contact report
This commit is contained in:
commit
d00218ece3
@ -22,11 +22,13 @@ def execute(filters=None):
|
|||||||
if not student_list:
|
if not student_list:
|
||||||
return columns, []
|
return columns, []
|
||||||
|
|
||||||
student_mobile_map = get_student_mobile_no(student_list)
|
student_map = get_student_details(student_list)
|
||||||
guardian_map = get_guardian_map(student_list)
|
guardian_map = get_guardian_map(student_list)
|
||||||
|
|
||||||
for d in program_enrollments:
|
for d in program_enrollments:
|
||||||
row = [d.student, d.student_name, student_mobile_map.get(d.student)]
|
student_details = student_map.get(d.student)
|
||||||
|
row = [d.student, d.student_name, student_details.get("student_mobile_number"), student_details.get("student_email_id"),
|
||||||
|
student_details.get("address")]
|
||||||
|
|
||||||
student_guardians = guardian_map.get(d.student)
|
student_guardians = guardian_map.get(d.student)
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ def execute(filters=None):
|
|||||||
for i in xrange(2):
|
for i in xrange(2):
|
||||||
if i < len(student_guardians):
|
if i < len(student_guardians):
|
||||||
g = student_guardians[i]
|
g = student_guardians[i]
|
||||||
row += [g.guardian_name, g.relation, g.mobile_number]
|
row += [g.guardian_name, g.relation, g.mobile_number, g.email_address]
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
@ -46,23 +48,31 @@ def get_columns():
|
|||||||
_("Student ID") + ":Link/Student:90",
|
_("Student ID") + ":Link/Student:90",
|
||||||
_("Student Name") + "::150",
|
_("Student Name") + "::150",
|
||||||
_("Student Mobile No.") + "::110",
|
_("Student Mobile No.") + "::110",
|
||||||
|
_("Student Email ID") + "::125",
|
||||||
|
_("Student Address") + "::175",
|
||||||
_("Guardian1 Name") + "::150",
|
_("Guardian1 Name") + "::150",
|
||||||
_("Relation with Guardian1") + "::80",
|
_("Relation with Guardian1") + "::80",
|
||||||
_("Guardian1 Mobile No") + "::125",
|
_("Guardian1 Mobile No") + "::125",
|
||||||
|
_("Guardian1 Email ID") + "::125",
|
||||||
_("Guardian2 Name") + "::150",
|
_("Guardian2 Name") + "::150",
|
||||||
_("Relation with Guardian2") + "::80",
|
_("Relation with Guardian2") + "::80",
|
||||||
_("Guardian2 Mobile No") + "::125",
|
_("Guardian2 Mobile No") + "::125",
|
||||||
|
_("Guardian2 Email ID") + "::125",
|
||||||
]
|
]
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
def get_student_mobile_no(student_list):
|
def get_student_details(student_list):
|
||||||
student_mobile_map = frappe._dict()
|
student_map = frappe._dict()
|
||||||
student_mobile_no = frappe.db.sql('''
|
student_details = frappe.db.sql('''
|
||||||
select name, student_mobile_number from `tabStudent` where name in (%s)''' %
|
select name, student_mobile_number, student_email_id, address_line_1, address_line_2, city, state from `tabStudent` where name in (%s)''' %
|
||||||
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1)
|
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1)
|
||||||
for s in student_mobile_no:
|
for s in student_details:
|
||||||
student_mobile_map[s.name] = s.student_mobile_number
|
student = frappe._dict()
|
||||||
return student_mobile_map
|
student["student_mobile_number"] = s.student_mobile_number
|
||||||
|
student["student_email_id"] = s.student_email_id
|
||||||
|
student["address"] = ', '.join([d for d in [s.address_line_1, s.address_line_2, s.city, s.state] if d])
|
||||||
|
student_map[s.name] = student
|
||||||
|
return student_map
|
||||||
|
|
||||||
def get_guardian_map(student_list):
|
def get_guardian_map(student_list):
|
||||||
guardian_map = frappe._dict()
|
guardian_map = frappe._dict()
|
||||||
@ -75,8 +85,12 @@ def get_guardian_map(student_list):
|
|||||||
guardian_mobile_no = dict(frappe.db.sql("""select name, mobile_number from `tabGuardian`
|
guardian_mobile_no = dict(frappe.db.sql("""select name, mobile_number from `tabGuardian`
|
||||||
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
|
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
|
||||||
|
|
||||||
|
guardian_email_id = dict(frappe.db.sql("""select name, email_address from `tabGuardian`
|
||||||
|
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
|
||||||
|
|
||||||
for guardian in guardian_details:
|
for guardian in guardian_details:
|
||||||
guardian["mobile_number"] = guardian_mobile_no.get(guardian.guardian)
|
guardian["mobile_number"] = guardian_mobile_no.get(guardian.guardian)
|
||||||
|
guardian["email_address"] = guardian_email_id.get(guardian.guardian)
|
||||||
guardian_map.setdefault(guardian.parent, []).append(guardian)
|
guardian_map.setdefault(guardian.parent, []).append(guardian)
|
||||||
|
|
||||||
return guardian_map
|
return guardian_map
|
Loading…
x
Reference in New Issue
Block a user