Merge pull request #30004 from rmehta/student-attendance-fix
fix(minor): student attendance tool query fix
This commit is contained in:
commit
0c7037f004
@ -3,6 +3,10 @@
|
|||||||
frappe.provide("education");
|
frappe.provide("education");
|
||||||
|
|
||||||
frappe.ui.form.on('Student Attendance Tool', {
|
frappe.ui.form.on('Student Attendance Tool', {
|
||||||
|
setup: (frm) => {
|
||||||
|
frm.students_area = $('<div>')
|
||||||
|
.appendTo(frm.fields_dict.students_html.wrapper);
|
||||||
|
},
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
frm.set_query("student_group", function() {
|
frm.set_query("student_group", function() {
|
||||||
return {
|
return {
|
||||||
@ -34,6 +38,7 @@ frappe.ui.form.on('Student Attendance Tool', {
|
|||||||
|
|
||||||
student_group: function(frm) {
|
student_group: function(frm) {
|
||||||
if ((frm.doc.student_group && frm.doc.date) || frm.doc.course_schedule) {
|
if ((frm.doc.student_group && frm.doc.date) || frm.doc.course_schedule) {
|
||||||
|
frm.students_area.find('.student-attendance-checks').html(`<div style='padding: 2rem 0'>Fetching...</div>`);
|
||||||
var method = "erpnext.education.doctype.student_attendance_tool.student_attendance_tool.get_student_attendance_records";
|
var method = "erpnext.education.doctype.student_attendance_tool.student_attendance_tool.get_student_attendance_records";
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
@ -62,10 +67,6 @@ frappe.ui.form.on('Student Attendance Tool', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get_students: function(frm, students) {
|
get_students: function(frm, students) {
|
||||||
if (!frm.students_area) {
|
|
||||||
frm.students_area = $('<div>')
|
|
||||||
.appendTo(frm.fields_dict.students_html.wrapper);
|
|
||||||
}
|
|
||||||
students = students || [];
|
students = students || [];
|
||||||
frm.students_editor = new education.StudentsEditor(frm, frm.students_area, students);
|
frm.students_editor = new education.StudentsEditor(frm, frm.students_area, students);
|
||||||
}
|
}
|
||||||
@ -163,16 +164,26 @@ education.StudentsEditor = class StudentsEditor {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
var htmls = students.map(function(student) {
|
// make html grid of students
|
||||||
return frappe.render_template("student_button", {
|
let student_html = '';
|
||||||
student: student.student,
|
for (let student of students) {
|
||||||
student_name: student.student_name,
|
student_html += `<div class="col-sm-3">
|
||||||
group_roll_number: student.group_roll_number,
|
<div class="checkbox">
|
||||||
status: student.status
|
<label>
|
||||||
})
|
<input
|
||||||
});
|
type="checkbox"
|
||||||
|
data-group_roll_number="${student.group_roll_number}"
|
||||||
|
data-student="${student.student}"
|
||||||
|
data-student-name="${student.student_name}"
|
||||||
|
class="students-check"
|
||||||
|
${student.status==='Present' ? 'checked' : ''}>
|
||||||
|
${student.group_roll_number} - ${student.student_name}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
$(htmls.join("")).appendTo(me.wrapper);
|
$(`<div class='student-attendance-checks'>${student_html}</div>`).appendTo(me.wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_empty_state() {
|
show_empty_state() {
|
||||||
|
@ -24,24 +24,24 @@ def get_student_attendance_records(based_on, date=None, student_group=None, cour
|
|||||||
student_list = frappe.get_all("Student Group Student", fields=["student", "student_name", "group_roll_number"],
|
student_list = frappe.get_all("Student Group Student", fields=["student", "student_name", "group_roll_number"],
|
||||||
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
filters={"parent": student_group, "active": 1}, order_by= "group_roll_number")
|
||||||
|
|
||||||
table = frappe.qb.DocType("Student Attendance")
|
StudentAttendance = frappe.qb.DocType("Student Attendance")
|
||||||
|
|
||||||
if course_schedule:
|
if course_schedule:
|
||||||
student_attendance_list = (
|
student_attendance_list = (
|
||||||
frappe.qb.from_(table)
|
frappe.qb.from_(StudentAttendance)
|
||||||
.select(table.student, table.status)
|
.select(StudentAttendance.student, StudentAttendance.status)
|
||||||
.where(
|
.where(
|
||||||
(table.course_schedule == course_schedule)
|
(StudentAttendance.course_schedule == course_schedule)
|
||||||
)
|
)
|
||||||
).run(as_dict=True)
|
).run(as_dict=True)
|
||||||
else:
|
else:
|
||||||
student_attendance_list = (
|
student_attendance_list = (
|
||||||
frappe.qb.from_(table)
|
frappe.qb.from_(StudentAttendance)
|
||||||
.select(table.student, table.status)
|
.select(StudentAttendance.student, StudentAttendance.status)
|
||||||
.where(
|
.where(
|
||||||
(table.student_group == student_group)
|
(StudentAttendance.student_group == student_group)
|
||||||
& (table.date == date)
|
& (StudentAttendance.date == date)
|
||||||
& (table.course_schedule == "") | (table.course_schedule.isnull())
|
& ((StudentAttendance.course_schedule == "") | (StudentAttendance.course_schedule.isnull()))
|
||||||
)
|
)
|
||||||
).run(as_dict=True)
|
).run(as_dict=True)
|
||||||
|
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
<div class="col-sm-3">
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
data-group_roll_number="{{group_roll_number}}"
|
|
||||||
data-student="{{student}}"
|
|
||||||
data-student-name="{{student_name}}"
|
|
||||||
class="students-check"
|
|
||||||
{% if status === "Present" %}
|
|
||||||
checked
|
|
||||||
{% endif %}
|
|
||||||
>
|
|
||||||
{{ group_roll_number }} - {{ student_name }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -16,7 +16,6 @@ import "./templates/item_quick_entry.html";
|
|||||||
import "./utils/item_quick_entry";
|
import "./utils/item_quick_entry";
|
||||||
import "./utils/customer_quick_entry";
|
import "./utils/customer_quick_entry";
|
||||||
import "./utils/supplier_quick_entry";
|
import "./utils/supplier_quick_entry";
|
||||||
import "./education/student_button.html";
|
|
||||||
import "./education/assessment_result_tool.html";
|
import "./education/assessment_result_tool.html";
|
||||||
import "./call_popup/call_popup";
|
import "./call_popup/call_popup";
|
||||||
import "./utils/dimension_tree_filter";
|
import "./utils/dimension_tree_filter";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user