commit
84694d0b0d
@ -54,13 +54,13 @@ def mark_attendance(students_present, students_absent, course_schedule=None, stu
|
|||||||
"""
|
"""
|
||||||
present = json.loads(students_present)
|
present = json.loads(students_present)
|
||||||
absent = json.loads(students_absent)
|
absent = json.loads(students_absent)
|
||||||
|
|
||||||
for d in present:
|
for d in present:
|
||||||
make_attendance_records(d["student"], d["student_name"], "Present", course_schedule, student_batch, date)
|
make_attendance_records(d["student"], d["student_name"], "Present", course_schedule, student_batch, date)
|
||||||
|
|
||||||
for d in absent:
|
for d in absent:
|
||||||
make_attendance_records(d["student"], d["student_name"], "Absent", course_schedule, student_batch, date)
|
make_attendance_records(d["student"], d["student_name"], "Absent", course_schedule, student_batch, date)
|
||||||
|
|
||||||
|
frappe.db.commit()
|
||||||
frappe.msgprint(_("Attendance has been marked successfully."))
|
frappe.msgprint(_("Attendance has been marked successfully."))
|
||||||
|
|
||||||
def make_attendance_records(student, student_name, status, course_schedule=None, student_batch=None, date=None):
|
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.date = date
|
||||||
student_attendance.status = status
|
student_attendance.status = status
|
||||||
student_attendance.submit()
|
student_attendance.submit()
|
||||||
frappe.db.commit()
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_student_batch_students(student_batch):
|
def get_student_batch_students(student_batch):
|
||||||
@ -87,7 +86,7 @@ def get_student_batch_students(student_batch):
|
|||||||
|
|
||||||
:param student_batch: 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
|
return students
|
||||||
|
|
||||||
@frappe.whitelist()
|
@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")
|
student_toolbar.find(".btn-mark-att")
|
||||||
.html(__('Mark Attendence'))
|
.html(__('Mark Attendence'))
|
||||||
.on("click", function() {
|
.on("click", function() {
|
||||||
var students_present = [];
|
var students_present = [];
|
||||||
var students_absent = [];
|
var students_absent = [];
|
||||||
$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
|
$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
|
||||||
|
var idx = $(check).data().idx;
|
||||||
if ($(check).is(":checked")) {
|
if ($(check).is(":checked")) {
|
||||||
students_present.push(students[i]);
|
students_present.push(get_student(idx));
|
||||||
} else {
|
} else {
|
||||||
students_absent.push(students[i]);
|
students_absent.push(get_student(idx));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
frappe.call({
|
frappe.call({
|
||||||
@ -118,9 +125,12 @@ schools.StudentsEditor = Class.extend({
|
|||||||
$.each(students, function(i, m) {
|
$.each(students, function(i, m) {
|
||||||
$(repl('<div class="col-sm-6">\
|
$(repl('<div class="col-sm-6">\
|
||||||
<div class="checkbox">\
|
<div class="checkbox">\
|
||||||
<label><input type="checkbox" class="students-check" student="%(student)s">\
|
<label><input data-idx="%(idx)s" type="checkbox" class="students-check" data-student="%(name)s">\
|
||||||
%(student)s</label>\
|
%(idx)s - %(name)s</label>\
|
||||||
</div></div>', { student: m.student_name })).appendTo(me.wrapper);
|
</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():
|
def get_active_student_batch():
|
||||||
active_student_batch = frappe.db.sql("""select name from `tabStudent 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
|
return active_student_batch
|
||||||
|
|
||||||
def get_student_batch_strength(student_batch):
|
def get_student_batch_strength(student_batch):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user