Added Student Batch-Wise Attendance report

This commit is contained in:
Neil Trini Lasrado 2016-12-01 12:53:40 +05:30
parent 87edfef0bb
commit 2607898cde
5 changed files with 100 additions and 0 deletions

View File

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

View File

@ -0,0 +1,12 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.query_reports["Student Batch-Wise Attendance"] = {
"filters": [{
"fieldname": "date",
"label": __("Date"),
"fieldtype": "Date",
"default": get_today(),
"reqd": 1
}]
}

View File

@ -0,0 +1,18 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2016-11-28 22:07:03.859124",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2016-12-01 10:48:23.380837",
"modified_by": "Administrator",
"module": "Schools",
"name": "Student Batch-Wise Attendance",
"owner": "Administrator",
"ref_doctype": "Student Attendance",
"report_name": "Student Batch-Wise Attendance",
"report_type": "Script Report"
}

View File

@ -0,0 +1,64 @@
# 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)
active_student_batch = get_active_student_batch()
data = []
for student_batch in active_student_batch:
row = [student_batch.name]
present_students = 0
absent_students = 0
student_batch_strength = get_student_batch_strength(student_batch.name)
student_attendance = get_student_attendance(student_batch.name, filters.get("date"))
if student_attendance:
for attendance in student_attendance:
if attendance.status== "Present":
present_students = attendance.count
elif attendance.status== "Absent":
absent_students = attendance.count
unmarked_students = student_batch_strength - (present_students + absent_students)
row+= [student_batch_strength, present_students, absent_students, unmarked_students]
data.append(row)
return columns, data
def get_columns(filters):
columns = [
_("Student batch") + ":Link/Student Batch:250",
_("Student batch Strength") + "::170",
_("Present") + "::90",
_("Absent") + "::90",
_("Not Marked") + "::90"
]
return columns
def get_active_student_batch():
active_student_batch = frappe.db.sql("""select name from `tabStudent Batch`
where active = 1 order by name""", as_dict=1)
return active_student_batch
def get_student_batch_strength(student_batch):
student_batch_strength = frappe.db.sql("""select count(*) from `tabStudent Batch Student`
where parent = %s""", student_batch)[0][0]
return student_batch_strength
def get_student_attendance(student_batch, date):
student_attendance = frappe.db.sql("""select count(*) as count, status from `tabStudent Attendance` where \
student_batch= %s and date= %s and docstatus=1 and\
(course_schedule is Null or course_schedule='') group by status""",
(student_batch, date), as_dict=1)
return student_attendance