?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec_old/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sec_old/application/models/studentmodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Studentmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); // $this->load->model('hrmodel'); } function search_student($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('student'); $this->db->join('master', 'master_id=student_id'); $this->db->order_by('student_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_student($postdata) { $data = array(); $this->db->trans_begin(); $studentid = $this->mastermodel->insertmasterdata(); $dob = $this->mastermodel->convertdateformat($postdata['dob']); $tblValues = array( 'student_id' => $studentid, 'reg_no' => $postdata['reg_no'], 'first_name' => $postdata['first_name'], 'last_name' => $postdata['last_name'], 'gender' => $postdata['gender'], 'dob' => $dob, 'admission_date' => $this->mastermodel->convertdateformat($postdata['admission_date']), 'nationality' => $postdata['nationality'], 'school_name' => $postdata['school_name'], 'grade_name' => $postdata['grade_name'], 'qatar_id' => $postdata['qatar_id'], 'blood_group' => $postdata['blood_group'], 'previous_medical_illness' => $postdata['previous_medical_illness'], 'address' => $postdata['address'], 'email' => $postdata['email'], 'photo' => $postdata['attach_photo'], ); $this->db->insert('student', $tblValues); if ($postdata['parentdiv'] == 0) { $parentid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'parent_id' => $parentid, 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->insert('parent', $tblValues); $tblValues = array( 'parent_id' => $parentid, 'student_id' => $studentid ); $this->db->insert('parent_student', $tblValues); } if ($postdata['parentdiv'] == 1) { $tblValues = array( 'parent_id' => $postdata['parent_id'], 'student_id' => $studentid ); $this->db->insert('parent_student', $tblValues); } $parent = $this->mastermodel->get_account_settings('student', 'finance_sub_account_settings'); if ($parent) { $chart_type_id = $this->mastermodel->get_single_field_value('finance_chart_master', 'chart_type_id', 'chart_master_id', $parent); if ($this->mastermodel->get_num_rows('finance_chart_master', 'chart_account_code', $postdata['reg_no']) == 0) { $tblValues = array('chart_account_code' => $postdata['reg_no'], 'chart_account_name' => $postdata['first_name'] . '-' . $postdata['last_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->insert('finance_chart_master', $tblValues); } else { $tblValues = array( 'chart_account_name' => $postdata['first_name'] . '-' . $postdata['last_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->where('chart_account_code', $postdata['reg_no']); $this->db->update('finance_chart_master', $tblValues); } } $data['resfunction'] = 'search_student'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_student($postdata) { $data = array(); $this->db->trans_begin(); $dob = $this->mastermodel->convertdateformat($postdata['dob']); $tblValues = array( 'first_name' => $postdata['first_name'], 'last_name' => $postdata['last_name'], 'gender' => $postdata['gender'], 'dob' => $dob, 'admission_date' => $this->mastermodel->convertdateformat($postdata['admission_date']), 'nationality' => $postdata['nationality'], 'school_name' => $postdata['school_name'], 'grade_name' => $postdata['grade_name'], 'qatar_id' => $postdata['qatar_id'], 'blood_group' => $postdata['blood_group'], 'previous_medical_illness' => $postdata['previous_medical_illness'], 'address' => $postdata['address'], 'email' => $postdata['email'], ); $this->db->where('student_id', $postdata['student_id']); $this->db->update('student', $tblValues); $tblValues = array( 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->where('parent_id', $postdata['parent_id']); $this->db->update('parent', $tblValues); if ($postdata['attach_photo'] != '') { $tblValues = array( 'photo' => $postdata['attach_photo'], ); $this->db->where('student_id', $postdata['student_id']); $this->db->update('student', $tblValues); } if ($postdata['parentdiv'] == 1) { $tblValues = array( 'parent_id' => $postdata['parent_id'], ); $this->db->where('student_id', $postdata['student_id']); $this->db->update('parent_student', $tblValues); } $parent = $this->mastermodel->get_account_settings('student', 'finance_sub_account_settings'); if ($parent) { $chart_type_id = $this->mastermodel->get_single_field_value('finance_chart_master', 'chart_type_id', 'chart_master_id', $parent); if ($this->mastermodel->get_num_rows('finance_chart_master', 'chart_account_code', $postdata['reg_no']) == 0) { $tblValues = array('chart_account_code' => $postdata['reg_no'], 'chart_account_name' => $postdata['first_name'] . '-' . $postdata['last_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->insert('finance_chart_master', $tblValues); } else { $tblValues = array( 'chart_account_name' => $postdata['first_name'] . '-' . $postdata['last_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->where('chart_account_code', $postdata['reg_no']); $this->db->update('finance_chart_master', $tblValues); } } $data['resfunction'] = 'search_student'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_parents($pagenum) { $data = array(); $this->db->select('*,GROUP_CONCAT(student.reg_no) as student_no,GROUP_CONCAT(CONCAT(first_name,last_name," ")) as student_list',false); $this->db->from('parent'); $this->db->join('parent_student', 'parent_student.parent_id=parent.parent_id'); $this->db->join('student', 'student.student_id=parent_student.student_id'); $this->db->join('master', 'master_id=parent.parent_id'); $this->db->group_by('parent.parent_id'); $this->db->order_by('parent.parent_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_parent($postdata) { $data = array(); $this->db->trans_begin(); $parentid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'parent_id' => $parentid, 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->insert('parent', $tblValues); $i = 1; while (isset($postdata['student_id' . $i])) { $this->db->where('student_id', $postdata['student_id' . $i]); $this->db->delete('parent_student'); $tblValues = array( 'parent_id' => $parentid, 'student_id' => $postdata['student_id' . $i], ); $this->db->insert('parent_student', $tblValues); $i++; } $data['resfunction'] = 'search_parents'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_parent($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'father_name' => $postdata['father_name'], 'father_qatar_id_no' => $postdata['father_qatar_id_no'], 'father_occupation' => $postdata['father_occupation'], 'father_mobile_no' => $postdata['father_mobile_no'], 'father_email' => $postdata['father_email'], 'father_ofc_no' => $postdata['father_ofc_no'], 'father_residence_no' => $postdata['father_residence_no'], 'mother_name' => $postdata['mother_name'], 'mother_qatar_id_no' => $postdata['mother_qatar_id_no'], 'mother_occupation' => $postdata['mother_occupation'], 'mother_mobile_no' => $postdata['mother_mobile_no'], 'mother_ofc_no' => $postdata['mother_ofc_no'], 'mother_residence_no' => $postdata['mother_residence_no'], 'mother_email' => $postdata['mother_email'], 'emergency_contact_no' => $postdata['emergency_contact_no'], ); $this->db->where('parent_id', $postdata['parent_id']); $this->db->update('parent', $tblValues); $data['resfunction'] = 'search_parents'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_student_batch() { $data = array(); $this->db->select('*'); $this->db->from('batch'); $this->db->join('course', 'course.course_id=batch.course_id'); $this->db->where('close', '0'); $this->db->order_by('batch_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_student_batch($postdata) { $data = array(); $this->db->trans_begin(); $course = $postdata['course_id']; $batch = $postdata['batch_id']; $batch_info = $this->mastermodel->get_data_srow('batch', $batch, 'batch_id'); $i = 1; $total_stud = $postdata['index']; while ($i <= $total_stud) { if (isset($postdata['select_student' . $i]) && $postdata['select_student' . $i] == "on") { $student_id = $postdata['student_id' . $i]; $student_info = $this->mastermodel->get_data_srow('student', $student_id, 'student_id'); $student_batch = $postdata['student_batch_id' . $i]; if ($student_batch == 0) { $student_batch = $this->studentmodel->get_student_batch_id($student_id, $course); } if ($student_batch == 0) { $student_batch_id = $this->mastermodel->insertmasterdata(); $tblValues = array( 'student_batch_id' => $student_batch_id, 'student_id' => $postdata['student_id' . $i], 'course_id' => $course, 'current_batch_id' => $batch, 'date' => $this->mastermodel->convertdateformat($postdata['date']), 'registration_fee' => $postdata['register_fee' . $i], 'course_fee' => $postdata['course_fee' . $i], 'books_fee' => $postdata['books_fee' . $i], 'no_sessions' => $postdata['session' . $i], 'session_amount' => $postdata['session_amount' . $i], 'remove_alert' => 0 ); $this->db->insert('student_batch', $tblValues); $remarks = "Added $student_info->first_name to $batch_info->batch_no"; } else { $student_batch_id = $student_batch; $tblValues = array( 'current_batch_id' => $batch, 'date' => $this->mastermodel->convertdateformat($postdata['date']), 'course_fee' => $postdata['course_fee' . $i], 'books_fee' => $postdata['books_fee' . $i], 'no_sessions' => $postdata['session' . $i], 'session_amount' => $postdata['session_amount' . $i] ); $this->db->where('student_batch_id', $student_batch_id); $this->db->update('student_batch', $tblValues); $remarks = "Updated $student_info->first_name's batch allocation details"; } $tblValues = array( 'student_batch_id' => $student_batch_id, 'batch_id' => $batch, 'allocation_date' => $this->mastermodel->convertdateformat($postdata['date']), 'remarks' => $remarks ); $this->db->insert('student_batch_details', $tblValues); } $i++; } $data['resfunction'] = 'search_student_batch'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_student_batch($postdata) { $data = array(); $this->db->trans_begin(); $course = $postdata['course_id']; $batch = $postdata['batch_id']; $i = 1; $total_stud = $postdata['index']; while ($i <= $total_stud) { if (isset($postdata['select_student' . $i]) && $postdata['select_student' . $i] == "on") { $student_id = $postdata['student_id' . $i]; $student_batch_id = $postdata['student_batch_id' . $i]; $student_info = $this->mastermodel->get_data_srow('student', $student_id, 'student_id'); if (isset($postdata['date']) && $postdata['date'] != "") { $date = $this->mastermodel->convertdateformat($postdata['date']); } else { $date = $this->mastermodel->get_single_field_value('student_batch', 'date', 'student_batch_id', $student_batch_id); } $tblValues = array( 'current_batch_id' => $batch, 'date' => $date, 'course_fee' => $postdata['course_fee' . $i], 'registration_fee' => $postdata['register_fee' . $i], 'books_fee' => $postdata['books_fee' . $i], 'no_sessions' => $postdata['session' . $i], 'session_amount' => $postdata['session_amount' . $i], 'remove_alert' => 0 ); $this->db->where('student_batch_id', $student_batch_id); $this->db->update('student_batch', $tblValues); $remarks = "Updated $student_info->first_name's batch allocation details"; $tblValues = array( 'student_batch_id' => $student_batch_id, 'batch_id' => $batch, 'allocation_date' => $this->mastermodel->convertdateformat($postdata['date']), 'remarks' => $remarks ); $this->db->insert('student_batch_details', $tblValues); } $i++; } $data['resfunction'] = 'search_student_batch'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function search_homework() { $data = array(); $this->db->select('*'); $this->db->from('homework'); $this->db->join('employee', 'employee.employee_id=homework.teacher_id'); $data['results'] = $this->db->get(); return $data; } function insert_homework($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array('homework_id' => $masterid, 'teacher_id' => $postdata['teacher_id'], 'batch_id' => $postdata['batch_id'], 'subject_id' => $postdata['subject_id'], 'remarks' => $postdata['remarks'], 'date' => $this->mastermodel->convertdateformat($postdata['date']), 'submission_date' => $this->mastermodel->convertdateformat($postdata['submission_date'])); $this->db->insert('homework', $tblValues); $data['resfunction'] = 'search_homework'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_homework($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'teacher_id' => $postdata['teacher_id'], 'batch_id' => $postdata['batch_id'], 'subject_id' => $postdata['subject_id'], 'remarks' => $postdata['remarks'], 'date' => $this->mastermodel->convertdateformat($postdata['date']), 'submission_date' => $this->mastermodel->convertdateformat($postdata['submission_date'])); $this->db->where('homework_id', $postdata['homework_id']); $this->db->update('homework', $tblValues); $data['resfunction'] = 'search_homework'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_performance() { $data = array(); $this->db->select('*'); $this->db->from('performance_exam'); $this->db->join('batch', 'batch.batch_id=performance_exam.batch_id'); $this->db->join('employee', 'batch.teacher_id=employee.employee_id', 'left'); $this->db->join('exammaster', 'exammaster.exammaster_id=performance_exam.exam_id', 'left'); $this->db->order_by('test_date', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_performance($postdata) { $data = array(); $this->db->trans_begin(); $performanceid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'performance_id' => $performanceid, 'batch_id' => $postdata['batch_id'], 'exam_id' => $postdata['exam_id'], 'test_date' => $this->mastermodel->convertdateformat($postdata['test_date']), 'remarks' => $postdata['remarks'], ); $this->db->insert('performance_exam', $tblValues); $j = 1; while (isset($postdata['student_id_' . $j])) { $std_id = $postdata['student_id_' . $j]; $i = 1; while (isset($postdata['subject_' . $i])) { $tblValues = array( 'performance_id' => $performanceid, 'student_id' => $std_id, 'marks' => $postdata['marks_' . $std_id . $i], 'remarks' => $postdata['remarks_' . $std_id . $i], 'course_subject_id' => $postdata['subject_' . $i], ); $this->db->insert('performance_exam_subject', $tblValues); $i++; } $j++; } $data['resfunction'] = 'search_performance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_performance($postdata) { $data = array(); $this->db->trans_begin(); $performanceid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'remarks' => $postdata['remarks'], ); $this->db->where('performance_id', $postdata['performance_id']); $this->db->update('performance_exam', $tblValues); $this->db->where('performance_id', $postdata['performance_id']); $this->db->delete('performance_exam_subject'); $j = 1; while (isset($postdata['student_id_' . $j])) { $std_id = $postdata['student_id_' . $j]; $i = 1; while (isset($postdata['subject_' . $i])) { $tblValues = array( 'performance_id' => $postdata['performance_id'], // 'student_id' => $std_id, // 'marks' => $postdata['marks_' . $std_id . $i], 'remarks' => $postdata['remarks_' . $std_id . $i], // 'course_subject_id' => $postdata['subject_' . $i], ); $this->db->insert('performance_exam_subject', $tblValues); $i++; } $j++; } $data['resfunction'] = 'search_performance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_attendance($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('attendance'); $this->db->join('master', 'master_id=attendance_id'); $this->db->join('batch', 'batch.batch_id=attendance.batch_id'); $this->db->join('course', 'course.course_id=batch.course_id'); $this->db->join('employee', 'employee.employee_id=attendance.teacher_id', 'left'); $this->db->join('class', 'class.class_id=attendance.class_id', 'left'); $this->db->order_by('attendance_date', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_attendance($postdata) { $data = array(); $this->db->trans_begin(); $attendanceid = $this->mastermodel->insertmasterdata(); $start_time = $postdata['start_time_hour'] . ":" . $postdata['start_time_minute']; $end_time = $postdata['end_time_hour'] . ":" . $postdata['end_time_minute']; $tblValues = array( 'attendance_id' => $attendanceid, 'batch_id' => $postdata['batch_id'], 'class_id' => $postdata['class_id'], 'attendance_date' => $this->mastermodel->convertdateformat($postdata['attendance_date']), 'start_time' => $start_time, 'end_time' => $end_time, 'remarks' => $postdata['remarks'], 'subject_id' => $postdata['subject_id'], 'teacher_id' => $postdata['teacher_id'], ); $this->db->insert('attendance', $tblValues); $j = 1; while (isset($postdata['student_id_' . $j])) { $attendan = 0; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'on') $attendan = 1; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'deactivate') $attendan = 2; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'unallocated') $attendan = 3; $std_id = $postdata['student_id_' . $j]; $tblValues = array( 'attendance_id' => $attendanceid, 'student_id' => $std_id, 'attendance' => $attendan, 'remarks' => $postdata['remarks' . $j], ); $this->db->insert('attendance_details', $tblValues); $j++; } $data['resfunction'] = 'search_attendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_attendance($postdata) { $data = array(); $this->db->trans_begin(); $start_time = $postdata['start_time_hour'] . ":" . $postdata['start_time_minute']; $end_time = $postdata['end_time_hour'] . ":" . $postdata['end_time_minute']; $tblValues = array( 'start_time' => $start_time, 'end_time' => $end_time, 'remarks' => $postdata['remarks'], 'subject_id' => $postdata['subject_id'], 'teacher_id' => $postdata['teacher_id'], ); $this->db->where('attendance_id', $postdata['attendance_id']); $this->db->update('attendance', $tblValues); $this->db->where('attendance_id', $postdata['attendance_id']); $this->db->delete('attendance_details'); $j = 1; while (isset($postdata['student_id_' . $j])) { $attendan = 0; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'on') $attendan = 1; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'deactivate') $attendan = 2; if (isset($postdata['attendance' . $j]) && $postdata['attendance' . $j] == 'unallocated') $attendan = 3; $std_id = $postdata['student_id_' . $j]; $tblValues = array( 'attendance_id' => $postdata['attendance_id'], 'student_id' => $std_id, 'attendance' => $attendan, 'remarks' => $postdata['remarks' . $j], ); $this->db->insert('attendance_details', $tblValues); $j++; } $data['resfunction'] = 'search_attendance'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_extra_class($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('extra_class'); $this->db->join('master', 'master_id=extra_class_id'); $this->db->join('batch', 'batch.batch_id=extra_class.batch_id'); $this->db->join('course', 'course.course_id=batch.course_id'); $this->db->join('employee', 'employee.employee_id=extra_class.teacher_id', 'left'); $this->db->join('class', 'class.class_id=extra_class.class_id', 'left'); $this->db->order_by('extra_class_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_extra_class($postdata) { $data = array(); $this->db->trans_begin(); $extra_classid = $this->mastermodel->insertmasterdata(); $start_time = $postdata['start_time_hour'] . ":" . $postdata['start_time_minute']; $end_time = $postdata['end_time_hour'] . ":" . $postdata['end_time_minute']; $tblValues = array( 'extra_class_id' => $extra_classid, 'batch_id' => $postdata['batch_id'], 'class_id' => $postdata['class_id'], 'extra_class_date' => $this->mastermodel->convertdateformat($postdata['extra_class_date']), 'start_time' => $start_time, 'end_time' => $end_time, 'teacher_id' => $postdata['teacher_id'], 'subject_id' => $postdata['subject_id'], 'remarks' => $postdata['remarks'], ); $this->db->insert('extra_class', $tblValues); $j = 1; while (isset($postdata['student_id_' . $j])) { if (isset($postdata['extra_class' . $j])) { $tblValues = array( 'extra_class_id' => $extra_classid, 'student_id' => $postdata['student_id_' . $j], 'extra_fee_amount' => $postdata['extra_fee_amount' . $j], ); $this->db->insert('extra_class_details', $tblValues); } $j++; } $data['resfunction'] = 'search_extra_class'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_extra_class($postdata) { $data = array(); $this->db->trans_begin(); $start_time = $postdata['start_time_hour'] . ":" . $postdata['start_time_minute']; $end_time = $postdata['end_time_hour'] . ":" . $postdata['end_time_minute']; $tblValues = array( 'extra_class_date' => $this->mastermodel->convertdateformat($postdata['extra_class_date']), 'start_time' => $start_time, 'end_time' => $end_time, 'teacher_id' => $postdata['teacher_id'], 'subject_id' => $postdata['subject_id'], 'remarks' => $postdata['remarks'], ); $this->db->where('extra_class_id', $postdata['extra_class_id']); $this->db->update('extra_class', $tblValues); $this->db->where('extra_class_id', $postdata['extra_class_id']); $this->db->delete('extra_class_details'); $j = 1; while (isset($postdata['student_id_' . $j])) { if (isset($postdata['extra_class' . $j])) { $tblValues = array( 'extra_class_id' => $postdata['extra_class_id'], 'student_id' => $postdata['student_id_' . $j], 'extra_fee_amount' => $postdata['extra_fee_amount' . $j], ); $this->db->insert('extra_class_details', $tblValues); } $j++; } $data['resfunction'] = 'search_extra_class'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_cancellation($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->join('master', 'master_id=cancellation_id'); $this->db->join('student', 'student.student_id=student_cancellation.student_id'); $this->db->join('batch', 'batch.batch_id=student_cancellation.batch_id'); $this->db->where('journal_id', 0); $this->db->order_by('cancellation_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function search_cancellation_posted($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->join('master', 'master_id=cancellation_id'); $this->db->join('student', 'student.student_id=student_cancellation.student_id'); $this->db->join('batch', 'batch.batch_id=student_cancellation.batch_id'); $this->db->where('journal_id >', 0); $this->db->order_by('cancellation_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function search_deactivate($pagenum) { $data = array(); $this->db->select('*,student_deactivate.start_date as start_date,student_deactivate.end_date as end_date'); $this->db->from('student_deactivate'); $this->db->join('master', 'master_id=deactivate_id'); $this->db->join('student', 'student.student_id=student_deactivate.student_id'); $this->db->join('batch', 'batch.batch_id=student_deactivate.batch_id'); $this->db->order_by('deactivate_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_deactivate($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'deactivate_id' => $masterid, 'batch_id' => $postdata['batch_id'], 'student_id' => $postdata['student_id'], // 'student_batch_id' =>$postdata['student_batch_id'], 'start_date' => $this->mastermodel->convertdateformat($postdata['start_date']), 'remarks' => $postdata['remarks'], ); $this->db->insert('student_deactivate', $tblValues); $data['resfunction'] = 'search_deactivate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_deactivate($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'start_date' => $this->mastermodel->convertdateformat($postdata['start_date']), 'remarks' => $postdata['remarks'], ); $this->db->where('deactivate_id', $postdata['deactivate_id']); $this->db->update('student_deactivate', $tblValues); $data['resfunction'] = 'search_deactivate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function activate_student($postdata) { $data = array(); $this->db->trans_begin(); $activate_date = ''; $activate = 0; if (isset($postdata['activate'])) { $activate_date = $this->mastermodel->convertdateformat($postdata['activate_date']); $activate = 1; } $tblValues = array( 'activate_date' => $activate_date, 'activate' => $activate, ); $this->db->where('deactivate_id', $postdata['deactivate_id']); $this->db->update('student_deactivate', $tblValues); $data['resfunction'] = 'search_deactivate'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function insert_cancellation($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'cancellation_id' => $masterid, 'student_batch_id' => $postdata['student_batch_id'], 'batch_id' => $postdata['batch_id'], 'student_id' => $postdata['student_id'], 'refund_amount' => $postdata['refund_amount'], 'cancellation_date' => $this->mastermodel->convertdateformat($postdata['cancellation_date']), 'remarks' => $postdata['remarks'], ); $this->db->insert('student_cancellation', $tblValues); $student_info = $this->mastermodel->get_data_srow('student', $postdata['student_id'], 'student_id'); $batch_info = $this->mastermodel->get_data_srow('batch', $postdata['batch_id'], 'batch_id'); $tblValues = array( 'student_batch_id' => $postdata['student_batch_id'], 'batch_id' => $postdata['batch_id'], 'allocation_date' => $this->mastermodel->convertdateformat($postdata['cancellation_date']), 'remarks' => "$student_info->first_name ($student_info->reg_no) is cancelled from batch - $batch_info->batch_no " ); $this->db->insert('student_batch_details', $tblValues); $data['resfunction'] = 'search_cancellation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_cancellation($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'refund_amount' => $postdata['refund_amount'], 'cancellation_date' => $this->mastermodel->convertdateformat($postdata['cancellation_date']), 'remarks' => $postdata['remarks'], ); $this->db->where('cancellation_id', $postdata['cancellation_id']); $this->db->update('student_cancellation', $tblValues); // $i = 1; // while (isset($postdata['inventory_id' . $i])) { // // $qty = $this->mastermodel->get_single_field_value('stock', 'stock_qty', 'inventory_type_id', $postdata['inventory_id' . $i]); //// $sale_qty=$this->mastermodel->get_single_field_value_two('sale_inventory','inventory_qty','sale_id',$postdata['sale_id'.$i],'inventory_type_id',$postdata['inventory_id'.$i]); // // $stk_qty = $postdata['inventory_qty' . $i] - $postdata['return_qty_old' . $i]; // $stk_qty_new = $stk_qty + $postdata['return_qty' . $i]; // $tblValues = array( // 'stock_qty' => $stk_qty_new, // ); // $this->db->where('inventory_type_id', $postdata['inventory_id' . $i]); // $this->db->update('stock', $tblValues); // $stock_qty = $postdata['inventory_qty' . $i] + $postdata['return_qty_old' . $i]; // $stock_qty_new = $stock_qty - $postdata['return_qty' . $i]; // $tblValues = array( // 'inventory_qty' => $stock_qty_new, // ); // $this->db->where('sale_id', $postdata['sale_id' . $i]); // $this->db->where('inventory_type_id', $postdata['inventory_id' . $i]); // $this->db->update('sale_inventory', $tblValues); // // $tblValues = array( // 'cancellation_id' => $postdata['cancellation_id'], // 'inventory_type_id' => $postdata['inventory_id' . $i], // 'return_qty' => $postdata['return_qty' . $i], // 'return_prize' => $postdata['return_prize' . $i], // 'sale_id' => $postdata['sale_id' . $i], // ); // $this->db->insert('student_cancellation_details', $tblValues); // $i++; // } $data['resfunction'] = 'search_cancellation'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } function search_fee($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('fee'); $this->db->join('student_batch', 'student_batch.student_batch_id=fee.student_batch_id'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id'); $this->db->join('student', 'student.student_id=student_batch.student_id'); $this->db->where('posted', 0); $this->db->order_by('fee_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function search_fee_posted($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('fee'); $this->db->join('student_batch', 'student_batch.student_batch_id=fee.student_batch_id'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id'); $this->db->join('student', 'student.student_id=student_batch.student_id'); $this->db->where('posted', 1); $this->db->order_by('fee_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function get_reciept_no($date) { $date_array = explode('-', $date); $data = "SELECT MAX(fee_id) as fee_id FROM fee where fee_date like '$date_array[2]%' "; $res = $this->db->query($data); $data = "SELECT MAX(fee_receipt_no) as code FROM fee where fee_id = '" . $res->row()->fee_id . "'"; $res = $this->db->query($data); $sql = "SELECT MAX(fee_payment_id) as fee_payment_id from fee_payment where fee_payment_date like '$date_array[2]%'"; $result = $this->db->query($sql); $sql = "SELECT MAX(fee_receipt_no) as code1 from fee_payment where fee_payment_id = '" . $result->row()->fee_payment_id . "'"; $result = $this->db->query($sql); if (!empty($res->row()->code)) { $code_array = explode('/', $res->row()->code); $code = $code_array[3]; } else $code = 0; if (!empty($result->row()->code1)) { $code_array = explode('/', $result->row()->code1); $code1 = $code_array[3]; } else $code1 = 0; $rec_code = $code; if ($code1 > $rec_code) $rec_code = $code1; $num = $rec_code + 1; return 'SEC/' . date("m", strtotime($date)) . '/' . date("Y", strtotime($date)) . '/' . str_pad($num, 4, '0', STR_PAD_LEFT); } function search_fee_payment($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('fee_payment'); $this->db->join('student', 'student.student_id=fee_payment.fee_student_id'); ; $this->db->order_by('fee_payment_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function allocate_fee_payment($postdata) { $data = array(); $fisc_year_id = $this->accountingmodel->getfiscalyearid(); $default_currency = $this->accountingmodel->getcurrency(); $data['resfunction'] = 'search_fee_payment'; $employee_fee_payable = $this->mastermodel->get_single_field_value('finance_sub_account_settings', 'employee_fee_payable', 'sub_account_settings_id', '1'); if ($fisc_year_id != 0 && $default_currency != 0 && $employee_fee_payable != 0) { $this->db->trans_begin(); $student_batch = $this->mastermodel->get_data_srow('student_batch', $postdata['student_batch_id'], 'student_batch_id'); $fee = $this->mastermodel->get_data_srow('fee_payment', $postdata['fee_payment_id'], 'fee_payment_id'); $fee_actual = $student_batch->registration_fee + $student_batch->course_fee; $batch_name = $this->mastermodel->get_single_field_value('batch', 'batch_no', 'batch_id', $student_batch->current_batch_id); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'fee_id' => $masterid, 'fee_receipt_no' => $fee->fee_receipt_no, 'fee_date' => $fee->fee_payment_date, 'payment_mode' => $fee->payment_mode, 'remarks' => $fee->fee_payment_remarks, 'student_batch_id' => $postdata['student_batch_id'], 'posted' => '1', ); $this->db->insert('fee', $tblValues); $toatal_amount = 0; if ($fee->fee_course_amount > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'course', 'amount_paid' => $fee->fee_course_amount, ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$fee->fee_course_amount; } if ($fee->fee_registration_amount > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'registration', 'amount_paid' => $fee->fee_registration_amount, ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$fee->fee_registration_amount; } $tblValues = array( 'total_amount' => $toatal_amount ); $this->db->where('fee_id', $masterid); $this->db->update('fee', $tblValues); if ($fee->book_fee_amount > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'books', 'amount_paid' => $fee->book_fee_amount, ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$fee->book_fee_amount; } if ($fee->payment_mode == 2) { $cheque = $this->mastemodel->get_data_srow('fee_payment_cheque_info', $fee->fee_payment_id, 'fee_payment_id'); $tblValues = array( 'fee_id' => $masterid, 'cheque_date' => $cheque->cheque_date, 'cheque_no ' => $cheque->cheque_no, 'cheque_info' => $cheque->cheque_info ); $this->db->insert('fee_cheque_info', $tblValues); } else if ($fee->payment_mode == 3) { $wire = $this->mastemodel->get_data_srow('fee_payment_wire_info', $fee->fee_payment_id, 'fee_payment_id'); $tblValues = array( 'fee_id' => $masterid, 'wire_info' => $wire->wire_info, ); $this->db->insert('fee_wire_info', $tblValues); } $chart_acc = $this->mastermodel->get_data_srow('finance_chart_master', $employee_fee_payable, 'chart_master_id'); $student_acc = $this->mastermodel->get_data_srow_joined('student', 'finance_chart_master', 'reg_no', 'chart_account_code', $student_batch->student_id, 'student_id'); $transaction_id = 3; $payment_type = 0; $reference = $this->accountingmodel->get_transaction_code($transaction_id, $payment_type); $journal_id = $this->mastermodel->insertmasterdata(); $description = "Fee paid by $student_acc->first_name $student_acc->last_name is allocated for batch - $batch_name"; $tblValues = array( 'journal_id' => $journal_id, 'journal_date' => date('Y-m-d'), 'description' => $description, 'reference' => $reference, 'currency_id' => $default_currency, 'payment_type_id' => '0', 'transaction_id' => '3', 'posted' => '0' ); $this->db->insert('finance_journal_refs', $tblValues); $tblValues = array( 'journal_id' => $journal_id, 'chart_account_code' => $student_acc->chart_account_code, 'debit' => $fee_actual, 'credit' => 0, 'description' => $description, 'fiscal_year_id' => $fisc_year_id, 'system_date' => date('Y-m-d') ); $this->db->insert('finance_journal', $tblValues); $tblValues = array( 'journal_id' => $journal_id, 'chart_account_code' => $chart_acc->chart_account_code, 'debit' => 0, 'credit' => $fee_actual, 'description' => $description, 'fiscal_year_id' => $fisc_year_id, 'system_date' => date('Y-m-d') ); $this->db->insert('finance_journal', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Fees allocated Successfully'; return $data; } } else { $data['res'] = 0; if ($fisc_year_id == 0) $data['msg'] = 'Fiscal Year Not Set.'; else if ($default_currency == 0) $data['msg'] = 'Default Currency Not Set.'; else $data['msg'] = 'Fiscal Year and Default Currency Not Set.'; return $data; } } function insert_fee_payment($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $reciept_no = $this->get_reciept_no($postdata['fee_date']); $tblValues = array( 'fee_payment_id' => $masterid, 'fee_student_id' => $postdata['student_id'], 'fee_receipt_no' => $reciept_no, 'fee_payment_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'fee_payment_remarks' => $postdata['fee_remarks'], 'fee_course_amount' => $postdata['fee_course_amount'], 'book_fee_amount' => $postdata['book_fee_amount'], 'fee_registration_amount' => $postdata['fee_registration_amount'], 'payment_mode' => $postdata['payment_mode'], ); $this->db->insert('fee_payment', $tblValues); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_payment_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('fee_payment_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_payment_id' => $masterid, 'wire_info' => $postdata['wire_info'], ); $this->db->insert('fee_payment_wire_info', $tblValues); } $data['resfunction'] = 'search_fee_payment'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_fee_payment($postdata) { $data = array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['fee_payment_id']); $tblValues = array( 'fee_payment_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'fee_payment_remarks' => $postdata['fee_remarks'], 'fee_course_amount' => $postdata['fee_course_amount'], 'fee_registration_amount' => $postdata['fee_registration_amount'], 'book_fee_amount' => $postdata['book_fee_amount'], 'payment_mode' => $postdata['payment_mode'], ); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->update('fee_payment', $tblValues); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->delete('fee_payment_cheque_info'); $this->db->where('fee_payment_id', $postdata['fee_payment_id']); $this->db->delete('fee_payment_wire_info'); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_payment_id' => $postdata['fee_payment_id'], 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('fee_payment_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_payment_id' => $postdata['fee_payment_id'], 'wire_info' => $postdata['wire_info'], ); $this->db->insert('fee_payment_wire_info', $tblValues); } $data['resfunction'] = 'search_fee_payment'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function insert_fee($postdata) { $data = array(); $this->db->trans_begin(); if ($postdata['course_amount'] > 0 || $postdata['reg_amount'] > 0 || $postdata['extra_amount'] > 0 || $postdata['book_amount'] > 0) { $masterid = $this->mastermodel->insertmasterdata(); $reciept_no = $this->get_reciept_no($postdata['fee_date']); $tblValues = array( 'fee_id' => $masterid, 'fee_receipt_no' => $reciept_no, 'fee_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'payment_mode' => $postdata['payment_mode'], 'remarks' => $postdata['remarks'], 'student_batch_id' => $postdata['student_batch_id'], 'posted' => '1', ); $this->db->insert('fee', $tblValues); $toatal_amount = 0; if ($postdata['course_amount'] > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'course', 'amount_paid' => $postdata['course_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['course_amount']; } if ($postdata['reg_amount'] > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'registration', 'amount_paid' => $postdata['reg_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['reg_amount']; } if ($postdata['extra_amount'] > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'extraclass', 'amount_paid' => $postdata['extra_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['extra_amount']; } if ($postdata['book_amount'] > 0) { $tblValues = array( 'fee_id' => $masterid, 'fee_type' => 'books', 'amount_paid' => $postdata['book_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['book_amount']; } $tblValues = array( 'total_amount' => $toatal_amount ); $this->db->where('fee_id', $masterid); $this->db->update('fee', $tblValues); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('fee_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_id' => $masterid, 'wire_info' => $postdata['wire_info'], ); $this->db->insert('fee_wire_info', $tblValues); } } $data['resfunction'] = 'search_fee_posted'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_fee($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'fee_date' => $this->mastermodel->convertdateformat($postdata['fee_date']), 'payment_mode' => $postdata['payment_mode'], 'remarks' => $postdata['remarks'] ); $this->db->where('fee_id', $postdata['fee_id']); $this->db->update('fee', $tblValues); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_cheque_info'); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_wire_info'); $this->db->where('fee_id', $postdata['fee_id']); $this->db->delete('fee_paid_details'); $toatal_amount = 0; if ($postdata['course_amount'] > 0) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'fee_type' => 'course', 'amount_paid' => $postdata['course_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['course_amount']; } if ($postdata['reg_amount'] > 0) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'fee_type' => 'registration', 'amount_paid' => $postdata['reg_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['reg_amount']; } if ($postdata['extra_amount'] > 0) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'fee_type' => 'extraclass', 'amount_paid' => $postdata['extra_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['extra_amount']; } if ($postdata['book_amount'] > 0) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'fee_type' => 'books', 'amount_paid' => $postdata['book_amount'], ); $this->db->insert('fee_paid_details', $tblValues); $toatal_amount+=$postdata['book_amount']; } $tblValues = array( 'total_amount' => $toatal_amount ); $this->db->where('fee_id', $postdata['fee_id']); $this->db->update('fee', $tblValues); if ($postdata['payment_mode'] == 2) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('fee_cheque_info', $tblValues); } else if ($postdata['payment_mode'] == 3) { $tblValues = array( 'fee_id' => $postdata['fee_id'], 'wire_info' => $postdata['wire_info'], ); $this->db->insert('fee_wire_info', $tblValues); } $data['resfunction'] = 'search_fee_posted'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function post_fee_settings($id) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'posted' => 1 ); $this->db->where('fee_id', $id); $this->db->update('fee', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Failed to post Fee Payment'; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Fee Setting Posted Successfully'; } return $data; } function reverse_fee_settings($id) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'posted' => 0 ); $this->db->where('fee_id', $id); $this->db->update('fee', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Failed to reverse Fee Payment'; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Fee Setting Reversed Successfully'; } return $data; } function post_student_cancellation($postdata) { $data = array(); $data['resfunction'] = 'search_cancellation'; $fisc_year_id = $this->accountingmodel->getfiscalyearid(); $default_currency = $this->accountingmodel->getcurrency(); if ($fisc_year_id != 0 && $default_currency != 0) { $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $account = explode("~", $postdata['bankacc_id']); $account_to_id = $account[0]; $account_to_code = $account[1]; $account_to_name = $account[2]; $description = "Student cancellation - Refund Fee to " . $postdata['student'] . " . Payment Received From " . $account_to_name . "-" . $account_to_code; $transaction_id = $postdata['transaction_id']; $payment_type = $postdata['payment_type_id']; $reference = $this->accountingmodel->get_transaction_code($transaction_id, $payment_type); $tblValues = array( 'journal_id' => $masterid, 'journal_date' => $this->mastermodel->convertdateformat($postdata['journal_date']), 'description' => $description, 'reference' => $reference, 'currency_id' => $default_currency, 'payment_type_id' => $postdata['payment_type_id'], 'transaction_id' => $postdata['transaction_id'], 'posted' => 1 ); $this->db->insert('finance_journal_refs', $tblValues); if ($postdata['payment_type_id'] == 2) { $tblValues = array( 'journal_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'chart_account_code' => $account_to_code, 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('finance_cheque_info', $tblValues); } else if ($postdata['payment_type_id'] == 3) { $tblValues = array( 'journal_id' => $masterid, 'wire_info' => $postdata['wire_info'], ); $this->db->insert('finance_wire_info', $tblValues); } $total_amount = 0; if ($postdata['payment_to_id'] != "") { $chart_account = $this->mastermodel->get_data_srow('finance_chart_master', $postdata['payment_to_id'], 'chart_master_id'); $chart_account_id = $postdata['payment_to_id']; $chart_account_code = $chart_account->chart_account_code; $chart_account_name = $chart_account->chart_account_name; $total_amount = $postdata['amount']; if (empty($postdata['description'])) $description = "Student cancellation - Refund Fee to " . $postdata['student'] . " . Payment Received From " . $account_to_name . "-" . $account_to_code; else $description = $postdata['description']; $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $chart_account_code, 'debit' => $postdata['amount'], 'credit' => 0, 'description' => $description, 'fiscal_year_id' => $fisc_year_id, ); $this->db->insert('finance_journal', $tblValues); } $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $account_to_code, 'debit' => 0, 'credit' => $total_amount, 'description' => "Student cancellation - Refund Fee . Payment Made to $chart_account_name - $chart_account_code", 'fiscal_year_id' => $fisc_year_id ); $this->db->insert('finance_journal', $tblValues); $tblValues = array( 'journal_id' => $masterid ); $this->db->where('cancellation_id', $postdata['cancellation_id']); $this->db->update('student_cancellation', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } else { $data['res'] = 0; if ($fisc_year_id == 0) $data['msg'] = 'Fiscal Year Not Set.'; else if ($default_currency == 0) $data['msg'] = 'Default Currency Not Set.'; else $data['msg'] = 'Fiscal Year and Default Currency Not Set.'; return $data; } } function set_receipt_voucher_fee_settings($postdata) { $data = array(); $course = $this->mastermodel->get_single_joined_value('course_name', 'course', 'batch', 'course_id', 'course_id', 'batch_id', $postdata['batch_id']); $student = $this->mastermodel->get_data_srow('student', $postdata['student_id'], 'student_id'); $fisc_year_id = $this->accountingmodel->getfiscalyearid(); $default_currency = $this->accountingmodel->getcurrency(); $data['resfunction'] = 'search_fee_posted'; if ($fisc_year_id != 0 && $default_currency != 0) { $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $account = explode("~", $postdata['bankacc_id']); $account_to_id = $account[0]; $account_to_code = $account[1]; $account_to_name = $account[2]; $description = "Fees Payment by " . $student->first_name . ' ' . $student->last_name . " for " . $course . ". Payment to " . $account_to_code . "-" . $account_to_name; $transaction_id = $postdata['transaction_id']; $payment_type = $postdata['payment_type_id']; $reference = $this->accountingmodel->get_transaction_code($transaction_id, $payment_type); $tblValues = array( 'journal_id' => $masterid, 'journal_date' => $this->mastermodel->convertdateformat($postdata['journal_date']), 'description' => $description, 'reference' => $reference, 'currency_id' => $default_currency, 'payment_type_id' => $postdata['payment_type_id'], 'transaction_id' => $postdata['transaction_id'], 'posted' => '1' ); $this->db->insert('finance_journal_refs', $tblValues); if ($postdata['payment_type_id'] == 2) { $tblValues = array( 'journal_id' => $masterid, 'cheque_date' => $this->mastermodel->convertdateformat($postdata['cheque_date']), 'cheque_no ' => $postdata['cheque_no'], 'chart_account_code' => $account_to_code, 'cheque_info' => $postdata['cheque_info'] ); $this->db->insert('finance_cheque_info', $tblValues); } else if ($postdata['payment_type_id'] == 3) { $tblValues = array( 'journal_id' => $masterid, 'wire_info' => $postdata['wire_info'], ); $this->db->insert('finance_wire_info', $tblValues); } $total_amount = 0; if ($postdata['payment_to_id'] != "") { $chart_account = explode("~", $postdata['payment_to_id']); $chart_account_id = $chart_account[0]; $chart_account_code = $chart_account[1]; $chart_account_name = $chart_account[2]; $total_amount = $postdata['amount']; if (empty($postdata['description'])) $description = "Fees Payment by " . $student->first_name . ' ' . $student->last_name . " for " . $course . ". Payment made to " . $account_to_name . "-" . $account_to_code; else $description = $postdata['description']; $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $chart_account_code, 'debit' => 0, 'credit' => $total_amount, 'description' => $description, 'fiscal_year_id' => $fisc_year_id, ); $this->db->insert('finance_journal', $tblValues); } $description = "Fees Payment by " . $student->first_name . ' ' . $student->last_name . " for " . $course . ". Payment Received From " . $chart_account_name . "-" . $chart_account_code; $tblValues = array( 'journal_id' => $masterid, 'chart_account_code' => $account_to_code, 'debit' => $total_amount, 'credit' => 0, 'description' => $description, 'fiscal_year_id' => $fisc_year_id ); $this->db->insert('finance_journal', $tblValues); $tblValues = array( 'journal_id' => $masterid, 'param_id' => $postdata['fee_id'], 'refs_type' => 'Student Fee Payment', 'param_table' => 'fee' ); $this->db->insert('finance_refs', $tblValues); $tblValues = array( 'journal_id' => $masterid ); $this->db->where('fee_id', $postdata['fee_id']); $this->db->update('fee', $tblValues); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } else { $data['res'] = 0; if ($fisc_year_id == 0) $data['msg'] = 'Fiscal Year Not Set.'; else if ($default_currency == 0) $data['msg'] = 'Default Currency Not Set.'; else $data['msg'] = 'Fiscal Year and Default Currency Not Set.'; return $data; } } function get_parents_details($father = '', $mother = '', $qatar = '') { $data = array(); $this->db->select('*'); $this->db->from('parent'); if ($father != '0') $this->db->where('father_name', $father); if ($mother != '0') $this->db->where('mother_name', $mother); if ($qatar != '0') $this->db->where('father_qatar_id_no', $qatar); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_batches($id) { $data = array(); $this->db->select('batch_no'); $this->db->from('batch'); $this->db->join('student_batch', 'student_batch.current_batch_id=batch.batch_id'); $this->db->where('student_id', $id); $this->db->order_by('student_batch.date', 'desc'); $this->db->limit('1'); $Q = $this->db->get(); $result = $Q->row(); if ($result) { return $result->batch_no; } else { return ""; } } function getStudentsNotCancelledFromBatch($batch_id) { $data = array(); $query = (" SELECT *,student.student_id as student_id ,if(student_cancellation.batch_id = $batch_id , 0,1) as batch FROM `student` LEFT JOIN student_cancellation ON student_cancellation.student_id= student.student_id having batch = 1"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /* To Get Detail of Batches of a student */ function get_student_batch_details($student_id) { $data = array(); $this->db->select('*,student_batch.student_batch_id as student_batch_id ,student_batch.student_id as student_id, student_batch.current_batch_id as batch_id,student_batch.course_id as course_id'); $this->db->from('student_batch'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id'); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); $this->db->where('student_batch.student_id', $student_id); $this->db->having('cancellation_id is null'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /* To Get Details of students Under a batch */ function get_batch_student_details($batch_id, $course_id) { $data = array(); $this->db->select('*,student_batch.student_batch_id as student_batch_id ,student_batch.student_id as student_id,student_batch.current_batch_id as batch_id'); $this->db->from('student_batch'); $this->db->join('student', 'student.student_id=student_batch.student_id'); // $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); $this->db->where('course_id', $course_id); $this->db->where('current_batch_id', $batch_id); // $this->db->where('date' <=date("Y-m-d")); // $this->db->having('cancellation_id is null'); $this->db->order_by('date'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /* To Get Student Batch Alocation Id */ function get_student_batch_id($student, $course) { $data = 0; $this->db->select('*'); $this->db->from('student_batch'); $this->db->where('course_id', $course); $this->db->where('student_id', $student); $this->db->where('cancelled', 0); $Q = $this->db->get(); $result = $Q->row(); if ($result) { $data = $result->student_batch_id; } else { $data = 0; } $Q->free_result(); return $data; } function get_student_extra_class_fee($student_id, $batch_id = "") { $data = 0; $where = ""; $join = ""; if ($batch_id != "") { $batch_info = $this->mastermodel->get_data_srow('batch', $batch_id, 'batch_id'); $join = 'JOIN batch on batch.batch_id=extra_class.batch_id '; $where = "AND course_id=" . $batch_info->course_id; } $query = ("SELECT IFNULL(sum(extra_fee_amount),0) as extraclass_fee from `extra_class` JOIN extra_class_details on extra_class_details.`extra_class_id`=extra_class.`extra_class_id` " . $join . " where student_id=$student_id $where"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { $result = $Q->row(); $data = $result; } else { $data = 0; } $Q->free_result(); return $data; } function get_student_fee_pending($student_id, $course) { $data = 0; $query = ("SELECT IFNULL(SUM(amount_paid),0) as paid_amount,IFNULL(MAX(fee_date),0) as fee_date FROM fee JOIN student_batch ON student_batch.student_batch_id=fee.student_batch_id JOIN fee_paid_details ON fee_paid_details.fee_id=fee.fee_id JOIN batch ON batch.batch_id=student_batch.current_batch_id WHERE student_id = $student_id AND student_batch.course_id=$course AND fee_paid_details.fee_type='course'"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { $result = $Q->row(); $data = $result; } else { $data = 0; } $Q->free_result(); return $data; } function get_student_reg_fee_pending($student_id, $course) { $data = 0; $query = ("SELECT IFNULL(SUM(amount_paid),0) as reg_paid_amount,IFNULL(MAX(fee_date),0) as reg_fee_date FROM fee JOIN student_batch ON student_batch.student_batch_id=fee.student_batch_id JOIN fee_paid_details ON fee_paid_details.fee_id=fee.fee_id JOIN batch ON batch.batch_id=student_batch.current_batch_id WHERE student_id = $student_id AND student_batch.course_id=$course AND fee_paid_details.fee_type='registration'"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { $result = $Q->row(); $data = $result; } else { $data = 0; } $Q->free_result(); return $data; } function get_student_books_fee_pending($student_id, $course) { $data = 0; $query = ("SELECT IFNULL(SUM(amount_paid),0) as books_paid_amount,IFNULL(MAX(fee_date),0) as books_fee_date FROM fee JOIN student_batch ON student_batch.student_batch_id=fee.student_batch_id JOIN fee_paid_details ON fee_paid_details.fee_id=fee.fee_id JOIN batch ON batch.batch_id=student_batch.current_batch_id WHERE student_id = $student_id AND student_batch.course_id=$course AND fee_paid_details.fee_type='books'"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { $result = $Q->row(); $data = $result; } else { $data = 0; } $Q->free_result(); return $data; } function get_student_extra_class_fee_pending($student_id, $course) { $data = 0; $query = ("SELECT IFNULL(SUM(amount_paid),0) as extra_class_fee_paid,IFNULL(MAX(fee_date),0) as extra_class_fee_date FROM fee JOIN student_batch ON student_batch.student_batch_id=fee.student_batch_id JOIN fee_paid_details ON fee_paid_details.fee_id=fee.fee_id JOIN batch ON batch.batch_id=student_batch.current_batch_id WHERE student_id = $student_id AND student_batch.course_id=$course AND fee_paid_details.fee_type='extraclass'"); $Q = $this->db->query($query); if ($Q->num_rows() > 0) { $result = $Q->row(); $data = $result; } else { $data = 0; } $Q->free_result(); return $data; } function get_marks($std_id, $performance_id) { $data = array(); $this->db->select('*'); $this->db->from('performance_exam_subject'); $this->db->where('student_id', $std_id); $this->db->where('performance_id', $performance_id); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_stock_details($sale_id) { $data = array(); $this->db->select('*'); $this->db->from('sale_inventory'); $this->db->where('sale_id', $sale_id); // $this->db->group_by('inventory_type_id'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_stock_details1($sale_id, $inventory_id) { $data = array(); $this->db->select('inventory_qty,inventory_amount', FALSE); $this->db->from('sale_inventory'); $this->db->where('sale_id', $sale_id); $this->db->where('inventory_type_id', $inventory_id); // $this->db->group_by('inventory_type_id'); $Q = $this->db->get(); $result = $Q->row(); if ($result) { $data['qty'] = $result->inventory_qty; $data['amount'] = $result->inventory_amount; } return $data; } function get_std_subjects($sub_id, $performance_id) { $data = array(); $this->db->select('*'); $this->db->from('performance_exam_subject'); $this->db->where('course_subject_id', $sub_id); $this->db->where('performance_id', $performance_id); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function check_student_cancell($student_id, $batch_id, $student_batch_id) { $this->db->from('student_cancellation'); $this->db->where('student_batch_id', $student_batch_id); $this->db->where('student_id', $student_id); $this->db->where('batch_id', $batch_id); $count = $this->db->count_all_results(); return $count; } function get_student_extra_class($student_id, $extra_class_id) { $data = array(); $this->db->where('extra_class_id', $extra_class_id); $this->db->where('student_id', $student_id); $Q = $this->db->get('extra_class_details'); $row = $Q->row(); return $row; } function check_student_cancelled($student_id, $batch_id) { $data = array(); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->where('batch_id', $batch_id); $this->db->where('student_id', $student_id); $Q = $this->db->get(); $data = $Q->num_rows(); $Q->free_result(); return $data; } function check_cancelled_student($batch_id, $student_id, $date) { $data = array(); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->where('batch_id', $batch_id); $this->db->where('student_id', $student_id); $this->db->where('cancellation_date <=', $date); $Q = $this->db->get(); $data = $Q->num_rows(); $Q->free_result(); return $data; } function get_cancelled_student($batch_id) { $data = array(); $date = date("Y-m-d"); $this->db->select('*'); $this->db->from('student_cancellation'); $this->db->where('batch_id', $batch_id); $this->db->where('cancellation_date <=', $date); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row['student_id']; } } $Q->free_result(); return $data; } function get_deactivate_student($batch_id) { $date = date("Y-m-d"); $data = array(); $where = "(activate_date > '$date' OR activate_date='0000-00-00')"; $this->db->from('student_deactivate'); $this->db->where('batch_id', $batch_id); $this->db->where('start_date <=', $date); $this->db->where($where); $this->db->where('activate_date !=', $date); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row['student_id']; } } $Q->free_result(); return $data; } function search_roll_over($pagenum) { $data = array(); $data['startpage'] = ''; $data['endpage'] = ''; $data['count'] = ''; $data['results'] = ''; return $data; } function check_deactivate($batch, $student_id, $date, $deactivate='') { $date = $this->mastermodel->convertdateformat($date); $where = "(activate_date > '$date' OR activate_date='0000-00-00')"; $this->db->from('student_deactivate'); $this->db->where('student_id', $student_id); $this->db->where('batch_id', $batch); $this->db->where('start_date <=', $date); $this->db->where($where); $this->db->where('activate_date !=', $date); // $this->db->where('activate !=', '1'); if ($deactivate != '') $this->db->where('deactivate_id !=', $deactivate); $count = $this->db->count_all_results(); return $count; // $Q = $this->db->get(); // $row = $Q->row(); // return $row; } function check_unallocated($batch, $student_id, $date) { $date = $this->mastermodel->convertdateformat($date); $this->db->from('student_batch'); $this->db->where('student_id', $student_id); $this->db->where('current_batch_id', $batch); $this->db->where('date >', $date); $count = $this->db->count_all_results(); return $count; } } ?>