Added Absent Student Report

This commit is contained in:
Neil Trini Lasrado 2016-11-28 16:57:02 +05:30
parent 14b27c5b42
commit 331361d03b
5 changed files with 98 additions and 0 deletions

View File

@ -70,6 +70,12 @@ def get_data():
"type": "doctype",
"name": "Student Batch Attendance Tool"
},
{
"type": "report",
"is_query_report": True,
"name": "Absent Student Report",
"doctype": "Attendance"
},
{
"type": "report",
"is_query_report": True,

View File

@ -0,0 +1,15 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.query_reports["Absent Student Report"] = {
"filters": [
{
"fieldname":"date",
"label": __("Date"),
"fieldtype": "Date",
"default": get_today(),
"reqd": 1
}
]
}

View File

@ -0,0 +1,17 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2013-05-13 14:04:03",
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2014-06-03 07:18:17.181332",
"modified_by": "Administrator",
"module": "Schools",
"name": "Absent Student Report",
"owner": "Administrator",
"ref_doctype": "Attendance",
"report_name": "Absent Student Report",
"report_type": "Script Report"
}

View File

@ -0,0 +1,60 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe import msgprint, _
def execute(filters=None):
if not filters: filters = {}
if not filters.get("date"):
msgprint(_("Please select date"), raise_exception=1)
columns = get_columns(filters)
absent_students = get_absent_students(filters.get("date"))
leave_applicants = get_leave_applications(filters.get("date"))
data = []
for student in absent_students:
if not student.student in leave_applicants:
row = [student.student, student.student_name, student.student_batch]
stud_details = frappe.db.get_value("Student", student.student, ['student_email_id', 'student_mobile_number'], as_dict=True)
if stud_details.student_email_id:
row+=[stud_details.student_email_id]
else:
row+= [""]
if stud_details.student_mobile_number:
row+=[stud_details.student_mobile_number]
else:
row+= [""]
data.append(row)
return columns, data
def get_columns(filters):
columns = [
_("Student") + ":Link/Student:90",
_("Student Name") + "::150",
_("Student Batch") + "::180",
_("Student Email ID") + "::180",
_("Student Mobile No.") + "::150",
]
return columns
def get_absent_students(date):
absent_students = frappe.db.sql("""select student, student_name, student_batch from `tabStudent Attendance`
where docstatus = 1 and date = %s order by student_batch, student_name""", date, as_dict=1)
return absent_students
def get_leave_applications(date):
leave_applicants = []
for student in frappe.db.sql("""select student from `tabStudent Leave Application`
where docstatus = 1 and date = %s""", date):
leave_applicants.append(student[0])
return leave_applicants