commit
84694d0b0d
@ -54,13 +54,13 @@ def mark_attendance(students_present, students_absent, course_schedule=None, stu
|
||||
"""
|
||||
present = json.loads(students_present)
|
||||
absent = json.loads(students_absent)
|
||||
|
||||
for d in present:
|
||||
make_attendance_records(d["student"], d["student_name"], "Present", course_schedule, student_batch, date)
|
||||
|
||||
for d in absent:
|
||||
make_attendance_records(d["student"], d["student_name"], "Absent", course_schedule, student_batch, date)
|
||||
|
||||
frappe.db.commit()
|
||||
frappe.msgprint(_("Attendance has been marked successfully."))
|
||||
|
||||
def make_attendance_records(student, student_name, status, course_schedule=None, student_batch=None, date=None):
|
||||
@ -79,7 +79,6 @@ def make_attendance_records(student, student_name, status, course_schedule=None,
|
||||
student_attendance.date = date
|
||||
student_attendance.status = status
|
||||
student_attendance.submit()
|
||||
frappe.db.commit()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_student_batch_students(student_batch):
|
||||
@ -87,7 +86,7 @@ def get_student_batch_students(student_batch):
|
||||
|
||||
:param student_batch: Student Batch.
|
||||
"""
|
||||
students = frappe.get_list("Student Batch Student", fields=["student", "student_name"] , filters={"parent": student_batch}, order_by= "idx")
|
||||
students = frappe.get_list("Student Batch Student", fields=["student", "student_name", "idx"] , filters={"parent": student_batch}, order_by= "idx")
|
||||
return students
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -88,16 +88,23 @@ schools.StudentsEditor = Class.extend({
|
||||
});
|
||||
});
|
||||
|
||||
var get_student = function(idx) {
|
||||
return students.filter(function(s) {
|
||||
return s.idx === idx;
|
||||
})[0]
|
||||
}
|
||||
|
||||
student_toolbar.find(".btn-mark-att")
|
||||
.html(__('Mark Attendence'))
|
||||
.on("click", function() {
|
||||
var students_present = [];
|
||||
var students_absent = [];
|
||||
$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
|
||||
var idx = $(check).data().idx;
|
||||
if ($(check).is(":checked")) {
|
||||
students_present.push(students[i]);
|
||||
students_present.push(get_student(idx));
|
||||
} else {
|
||||
students_absent.push(students[i]);
|
||||
students_absent.push(get_student(idx));
|
||||
}
|
||||
});
|
||||
frappe.call({
|
||||
@ -118,9 +125,12 @@ schools.StudentsEditor = Class.extend({
|
||||
$.each(students, function(i, m) {
|
||||
$(repl('<div class="col-sm-6">\
|
||||
<div class="checkbox">\
|
||||
<label><input type="checkbox" class="students-check" student="%(student)s">\
|
||||
%(student)s</label>\
|
||||
</div></div>', { student: m.student_name })).appendTo(me.wrapper);
|
||||
<label><input data-idx="%(idx)s" type="checkbox" class="students-check" data-student="%(name)s">\
|
||||
%(idx)s - %(name)s</label>\
|
||||
</div></div>', {
|
||||
name: m.student_name,
|
||||
idx: m.idx
|
||||
})).appendTo(me.wrapper);
|
||||
});
|
||||
}
|
||||
});
|
@ -48,7 +48,7 @@ def get_columns(filters):
|
||||
|
||||
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)
|
||||
where enabled = 1 order by name""", as_dict=1)
|
||||
return active_student_batch
|
||||
|
||||
def get_student_batch_strength(student_batch):
|
||||
|
@ -31,7 +31,7 @@ def execute(filters=None):
|
||||
total_p += 1
|
||||
elif status == "Absent":
|
||||
total_a += 1
|
||||
|
||||
|
||||
row += [total_p, total_a]
|
||||
data.append(row)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user