?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec/draft/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/draft/application/models/reportmodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Reportmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function search_report() { $data = array(); $this->db->select('*'); $this->db->from('report'); $this->db->where('report_module_id', $_SESSION['current_mode']); $this->db->order_by('report_sort', 'asc'); $data['results'] = $this->db->get(); return $data; } function get_deactivated_students() { $data = array(); $data['student_batch_id'] = array(); $data['batch'] = array(); $sql = "SELECT * from student_deactivate join student_batch on student_batch.student_id=student_deactivate.student_id AND student_batch.current_batch_id=student_deactivate.batch_id where start_date <= '" . date('Y-m-d') . "'AND (end_date >= '" . date('Y-m-d') . "' OR end_date='0000-00-00') "; $result = $this->db->query($sql); if ($result->num_rows() > 0) { foreach ($result->result_array() as $row) { if (!(in_array($row['student_batch_id'], $data['student_batch_id']))) { $data['student_batch_id'][] = $row['student_batch_id']; } $data['batch'][$row['current_batch_id']][] = $row['student_id']; } } $result->free_result(); return $data; } function get_students_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_batch_id']; $data = array(); $this->db->select('*,IFNULL(student_batch.student_batch_id ,0) as student_batch_id,parent.parent_id as p_id,student.student_id as std_id, cancellation_id', false); $this->db->from("student"); $this->db->join('master', 'master.master_id=student.student_id'); $this->db->join('parent_student', 'parent_student.student_id=student.student_id', 'left'); $this->db->join('student_batch', 'student_batch.student_id=student.student_id', 'left'); $this->db->join('parent', 'parent.parent_id=parent_student.parent_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); $this->db->join('course', 'course.course_id=student_batch.course_id', 'left'); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_batch.student_batch_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('admission_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('admission_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('student_batch.current_batch_id', $postdata['batch_id']); } if ($postdata['course_id'] != '') { $this->db->where('course.course_id', $postdata['course_id']); } if ($postdata['gender'] != '') { $this->db->where('gender', $postdata['gender']); } if($postdata['school_name'] !='') { $this->db->where('school_name', $postdata['school_name']); } $this->db->order_by('std_id', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_batch_id'], $deactivated_students)) { $data[] = $row; } } else { $data[] = $row; } } } $res->free_result(); return $data; } function get_fee_attendance_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['batch']; if (!isset($deactivated_students[$postdata['batch_id']])) { $deactivated_students[$postdata['batch_id']] = array(); } $data = array(); $this->db->select("student_batch.registration_fee as registration_fee,cancellation_id, student_batch.course_id as course_id, student_batch.course_fee as student_course_fee,student_batch.current_batch_id as batch_id, course.course_fee as course_fee,student_batch.books_fee as student_books_fee, attendance.batch_id as batch_id,student.reg_no,student.student_id as student_id, IFNULL(student_batch.student_batch_id,0) as student_batch_id , attendance_details.student_id,group_concat(attendance_date) as att_date , group_concat(TIMEDIFF(attendance.end_time,attendance.start_time) ) as att_time, group_concat(concat(attendance_date,'~',IFNULL(subject.subject_name,'no_sub'),'~',IFNULL(subject.subject_id,0))) as att_subject, group_concat(attendance)as att_status", FALSE); $this->db->from('attendance'); $this->db->join('attendance_details', 'attendance_details.attendance_id=attendance.attendance_id'); $this->db->join('student', 'student.student_id=attendance_details.student_id'); $this->db->join('student_batch', 'student_batch.student_id=student.student_id and student_batch.current_batch_id=attendance.batch_id'); $this->db->join('batch', 'batch.batch_id=attendance.batch_id'); $this->db->join('course', 'course.course_id=student_batch.course_id'); $this->db->join('subject', 'subject.subject_id=attendance.subject_id', "left"); $this->db->group_by("student.student_id"); $this->db->join('student_cancellation', 'student_cancellation.student_id=student.student_id AND student_cancellation.batch_id=' . $postdata['batch_id'], 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student.student_id', $deactivated_students[$postdata['batch_id']]); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('attendance_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('attendance_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('attendance.batch_id', $postdata['batch_id']); } if($postdata['school_name'] !='') { $this->db->where('school_name', $postdata['school_name']); } $this->db->order_by('attendance_date', 'desc'); $res = $this->db->get(); // echo $this->db->last_query(); // die(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_id'], $deactivated_students[$postdata['batch_id']])) { $data[] = $row; } } else { $data[] = $row; } } } // echo $this->db->last_query(); $res->free_result(); return $data; } function get_fee_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_batch_id']; $data = array(); $data['result'] = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('*,cancellation_id ,student.student_id as student_id, IFNULL(student_batch.student_batch_id,0) as student_batch_id ,IFNULL(fee.fee_id,0) as fee_id , student_batch.course_fee as student_course_fee, course.course_fee as course_fee,student_batch.books_fee as student_books_fee', false); $this->db->from("student"); $this->db->join('student_batch', 'student_batch.student_id=student.student_id'); $this->db->join('fee', 'fee.student_batch_id=student_batch.student_batch_id', 'left'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); $this->db->join('course', 'course.course_id=student_batch.course_id'); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_batch.student_batch_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['student_id'] != '') { $this->db->where('student_batch.student_id', $postdata['student_id']); } if ($postdata['batch_id'] != '') { $this->db->where('student_batch.current_batch_id', $postdata['batch_id']); } if ($postdata['course_id'] != '') { $this->db->where('student_batch.course_id', $postdata['course_id']); } if ($postdata['from_date'] != '') { $this->db->where('fee_date >=', $this->mastermodel->convertdateformat($postdata['from_date'])); } if ($postdata['to_date'] != '') { $this->db->where('fee_date <=', $this->mastermodel->convertdateformat($postdata['to_date'])); } $this->db->order_by('student.student_id', 'asc'); $this->db->order_by('fee.fee_id', 'asc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { // $data['result'][$row['student_id']][$row['course_id']][]=$row; if ($postdata['student_type'] == 'active') { if (!in_array($row['student_batch_id'], $deactivated_students)) { $data['result'][] = $row; $count = 0; if (isset($data['rowspan'][$row['fee_id']])) $count = $data['rowspan'][$row['fee_id']]; $data['rowspan'][$row['fee_id']] = $count + 1; } } else { $data['result'][] = $row; $count = 0; if (isset($data['rowspan'][$row['fee_id']])) $count = $data['rowspan'][$row['fee_id']]; $data['rowspan'][$row['fee_id']] = $count + 1; } } } $res->free_result(); return $data; } function get_fee_pending_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_batch_id']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('*,IFNULL(student_batch.student_batch_id,0) as student_batch_id,student.student_id as student_id, cancellation_id,IFNULL(fee.fee_id,0) as fee_id ,IFNULL(fee.total_amount,0) as total_amount , student_batch.course_fee as student_course_fee,student_batch.date as batch_allocation_date,fee.remarks as fee_remarks, course.course_fee as course_fee,student_batch.books_fee as student_books_fee', false); $this->db->from("student"); $this->db->join('student_batch', 'student_batch.student_id=student.student_id'); $this->db->join('fee', 'fee.student_batch_id=student_batch.student_batch_id', 'left'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); $this->db->join('course', 'course.course_id=student_batch.course_id'); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_batch.student_batch_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['student_id'] != '') { $this->db->where('student_batch.student_id', $postdata['student_id']); } if ($postdata['batch_id'] != '') { $this->db->where('student_batch.current_batch_id', $postdata['batch_id']); } if ($postdata['course_id'] != '') { $this->db->where('student_batch.course_id', $postdata['course_id']); } if ($postdata['from_date'] != '') { $this->db->where('fee_date >=', $this->mastermodel->convertdateformat($postdata['from_date'])); } if ($postdata['to_date'] != '') { $this->db->where('fee_date <=', $this->mastermodel->convertdateformat($postdata['to_date'])); } $this->db->order_by('student.student_id', 'asc'); $this->db->order_by('fee.fee_id', 'asc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_batch_id'], $deactivated_students)) { $data['result'][$row['student_id']][$row['course_id']][] = $row; $count = 0; if (isset($data['rowspan'][$row['fee_id']])) $count = $data['rowspan'][$row['fee_id']]; $data['rowspan'][$row['fee_id']] = $count + 1; } } else { $data['result'][$row['student_id']][$row['course_id']][] = $row; $count = 0; if (isset($data['rowspan'][$row['fee_id']])) $count = $data['rowspan'][$row['fee_id']]; $data['rowspan'][$row['fee_id']] = $count + 1; } } } $res->free_result(); return $data; } function get_business_summary_report($postdata) { $data = array(); $date = date("Y-m-d"); $sql = "select "; if ($postdata['student_type'] == 'Active') { $sql .= '*,current_batch_id as batch, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <= "' . $date . '" ,0,student_batch.registration_fee))) as registration_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <= "' . $date . '" ,0,student_batch.course_fee))) as course_fee_total, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <= "' . $date . '" ,0,student_batch.books_fee))) as books_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00")AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <="' . $date . '" ,0,1))) as student_count1'; } else if ($postdata['student_type'] == '') { $sql .= '*,current_batch_id as batch, SUM(student_batch.registration_fee) as registration_fee, SUM(student_batch.course_fee) as course_fee_total, SUM(student_batch.books_fee) as books_fee, COUNT(*) as student_count1'; } else if ($postdata['student_type'] == 'Deactivated') { $sql .= '*,current_batch_id as batch, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_batch.registration_fee,0)) as registration_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_batch.course_fee,0)) as course_fee_total, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_batch.books_fee,0)) as books_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00")AND student_deactivate.start_date <= "' . $date . '",1,0)) as student_count1'; } if ($postdata['student_type'] == 'Canceled') { $sql .= '*,current_batch_id as batch, SUM(IF(cancellation_date <= "' . $date . '" ,student_batch.registration_fee,0)) as registration_fee, SUM(IF(cancellation_date <= "' . $date . '" ,student_batch.course_fee,0)) as course_fee_total, SUM(IF(cancellation_date <= "' . $date . '" ,student_batch.books_fee,0)) as books_fee, SUM(IF(cancellation_date <="' . $date . '" ,1,0)) as student_count1'; } $where = " where student_batch.student_batch_id != ''"; if ($postdata['course_id'] != '') { $where .= "and batch.course_id = '".$postdata['course_id']."'"; } if ($postdata['main_course_id'] != '') { $where .= "and main_course.main_course_id = '".$postdata['main_course_id']."'"; } if ($postdata['batch_status'] != '') { $where .= "and batch.close = '".$postdata['batch_status']."'"; } $sql .= " FROM (`student_batch`) JOIN `course` ON `course`.`course_id`=`student_batch`.`course_id` JOIN `batch` ON `batch`.`batch_id`=`student_batch`.`current_batch_id` JOIN `main_course` ON `main_course`.`main_course_id`=`course`.`main_course_id` LEFT JOIN `student_cancellation` ON `student_cancellation`.`student_batch_id`=`student_batch`.`student_batch_id` LEFT JOIN `student_deactivate` ON `student_deactivate`.`deactivate_id` = (select sd1.deactivate_id from student_deactivate as sd1 where `sd1`.`student_id`=`student_batch`.`student_id` AND `sd1`.`batch_id`=`student_batch`.`current_batch_id` order by start_date desc limit 1)"; $sql .= $where; $sql .= " GROUP BY `current_batch_id` ORDER BY `main_course`.`main_course_id`"; $res = $this->db->query($sql); // echo $this->db->last_query(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data['result'][] = $row; if (isset($data[$row['course_id']])) $data[$row['course_id']]+=1; else { $data[$row['course_id']] = 1; } } } $res->free_result(); return $data; } function get_business_dashboard_report($postdata) { $data = array(); $date = $this->mastermodel->convertdateformat($postdata['at_date']); $sql = "select "; if ($postdata['student_type'] == 'Active') { $sql .= '*,current_batch_id as batch, (select max(teacher_date) from batch_teacher where batch_id = current_batch_id) as mdate, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <= "' . $date . '" ,0,student_batch.registration_fee))) as registration_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <= "' . $date . '" ,0,student_batch.course_fee))) as course_fee_total, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <= "' . $date . '" ,0,student_batch.books_fee))) as books_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00")AND student_deactivate.start_date <= "' . $date . '",0,IF(cancellation_date <="' . $date . '" ,0,1))) as student_count1'; } else if ($postdata['student_type'] == '') { $sql .= '*,current_batch_id as batch, (select max(teacher_date) from batch_teacher where batch_id = current_batch_id) as mdate, SUM(student_batch.registration_fee) as registration_fee, SUM(student_batch.course_fee) as course_fee_total, SUM(student_batch.books_fee) as books_fee, COUNT(*) as student_count1 '; } else if ($postdata['student_type'] == 'Deactivated') { $sql .= '*,current_batch_id as batch, (select max(teacher_date) from batch_teacher where batch_id = current_batch_id) as mdate, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_batch.registration_fee,0)) as registration_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_batch.course_fee,0)) as course_fee_total, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_batch.books_fee,0)) as books_fee, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00")AND student_deactivate.start_date <= "' . $date . '",1,0)) as student_count1'; } if ($postdata['student_type'] == 'Canceled') { $sql .= '*,current_batch_id as batch, (select max(teacher_date) from batch_teacher where batch_id = current_batch_id) as mdate, SUM(IF(cancellation_date <= "' . $date . '" ,student_batch.registration_fee,0)) as registration_fee, SUM(IF(cancellation_date <= "' . $date . '" ,student_batch.course_fee,0)) as course_fee_total, SUM(IF(cancellation_date <= "' . $date . '" ,student_batch.books_fee,0)) as books_fee, SUM(IF(cancellation_date <="' . $date . '" ,1,0)) as student_count1'; } $where = " where student_batch.student_batch_id != ''"; if ($postdata['course_id'] != '') { $where .= "and batch.course_id = '".$postdata['course_id']."'"; } if ($postdata['main_course_id'] != '') { $where .= "and main_course.main_course_id = '".$postdata['main_course_id']."'"; } if ($postdata['batch_status'] != '') { $where .= "and batch.close = '".$postdata['batch_status']."'"; } $sql .= ", IF(count(distinct batch_teacher.id) > 1,count(distinct batch_teacher.id),1) as teacher_count1"; $sql .= " from student_batch JOIN `course` ON `course`.`course_id`=`student_batch`.`course_id` JOIN `batch` ON `batch`.`batch_id`=`student_batch`.`current_batch_id` JOIN `main_course` ON `main_course`.`main_course_id`=`course`.`main_course_id` LEFT JOIN `student_cancellation` ON `student_cancellation`.`student_batch_id`=`student_batch`.`student_batch_id` LEFT JOIN `student_deactivate` ON `student_deactivate`.`deactivate_id` = (select sd1.deactivate_id from student_deactivate as sd1 where `sd1`.`student_id`=`student_batch`.`student_id` AND `sd1`.`batch_id`=`student_batch`.`current_batch_id` order by start_date desc limit 1) LEFT JOIN `batch_teacher` ON `batch_teacher`.`batch_id`=`batch`.`batch_id` LEFT JOIN `employee` ON `employee`.`employee_id`=`batch_teacher`.`teacher_id`"; $sql .= $where; $sql .= " GROUP BY `current_batch_id`, `teacher_date` HAVING `teacher_date` = mdate OR teacher_date is null ORDER BY `course`.`course_name`, `main_course`.`main_course_id`"; $res = $this->db->query($sql); // echo $this->db->last_query(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data['result'][] = $row; if (isset($data[$row['course_id']])) $data[$row['course_id']]+=1; else { $data[$row['course_id']] = 1; } } } $res->free_result(); return $data; } function get_cancellation_report($postdata) { $data = array(); $i = 1; $searchstr = 'cancellation_id,,'; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("student_cancellation"); $this->db->join('student', 'student.student_id=student_cancellation.student_id'); $this->db->join('batch', 'batch.batch_id=student_cancellation.batch_id'); $this->db->join('course', 'course.course_id=batch.course_id'); // $this->db->join('student_cancellation sc', 'sc.student_id=student.student_id', 'left'); // $this->db->join('student_deactivate', 'student_deactivate.student_id=student.student_id', 'left'); // if ($postdata['student_type'] == 'active') { // // $this->db->having('cancellation_id is null and deactivate_id is null'); // } // if ($postdata['student_type'] == 'deactivated') { // $this->db->having('cancellation_id is null and deactivate_id is not null'); // } // if ($postdata['student_type'] == 'cancelled') { // // $this->db->having('deactivate_id is null and cancellation_id is not null'); // } if ($postdata['from_date'] != '') { $this->db->where('cancellation_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('cancellation_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('batch.batch_id', $postdata['batch_id']); } if ($postdata['student_id'] != '') { $this->db->where('student_cancellation.student_id', $postdata['student_id']); } if($postdata['school_name'] !='') { $this->db->where('school_name', $postdata['school_name']); } // if ($postdata['gender'] != '') { // $this->db->where('gender', $postdata['gender']); // } $this->db->order_by('cancellation_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_homework_report($postdata) { $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("homework"); $this->db->join('employee', 'employee.employee_id=homework.teacher_id'); $this->db->join('batch', 'batch.batch_id=homework.batch_id'); $this->db->join('subject', 'subject.subject_id=homework.subject_id'); $this->db->join('course', 'course.course_id=batch.course_id'); if ($postdata['from_date'] != '') { $this->db->where('submission_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('submission_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('homework.batch_id', $postdata['batch_id']); } if ($postdata['subject_id'] != '') { $this->db->where('homework.subject_id', $postdata['subject_id']); } if ($postdata['teacher_id'] != '') { $this->db->where('homework.teacher_id', $postdata['teacher_id']); } // if ($postdata['gender'] != '') { // $this->db->where('gender', $postdata['gender']); // } $this->db->order_by('submission_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_batch_allocation_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_batch_id']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select(' * ,student_batch.student_id as student_id,cancellation_id,IFNULL(student_batch.student_batch_id ,0) as student_batch_id, group_concat(course.course_code) as course,group_concat(course.course_name) as course_name, group_concat(batch.batch_no) as batch,count(*) as count, group_concat(student_batch.date) as allo_date', false); $this->db->from("student_batch"); $this->db->join('student', 'student.student_id=student_batch.student_id', 'left'); $this->db->join('parent_student', 'parent_student.student_id=student.student_id', 'left'); $this->db->join('parent', 'parent.parent_id=parent_student.parent_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); $this->db->join('course', 'course.course_id=batch.course_id', 'left'); $this->db->group_by("student_batch.student_id"); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_batch.student_batch_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('batch.batch_id', $postdata['batch_id']); } if ($postdata['student_id'] != '') { $this->db->where('student_batch.student_id', $postdata['student_id']); } if($postdata['school_name']!='') { $this->db->where('school_name', $postdata['school_name']); } $this->db->order_by('student_batch.student_id', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_batch_id'], $deactivated_students)) { $data[] = $row; } } else { $data[] = $row; } } } $res->free_result(); return $data; } function get_parents_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_batch_id']; $data = array(); $this->db->select('*,student.student_id as student_id,parent.parent_id as p_id,cancellation_id', false); $this->db->from("parent"); $this->db->join('parent_student', 'parent_student.parent_id=parent.parent_id', 'left'); $this->db->join('student', 'student.student_id=parent_student.student_id', 'left'); $this->db->join('student_batch', 'student_batch.student_id=parent_student.student_id', 'left'); // $this->db->join("((SELECT * FROM student_batch sb1 WHERE sb1.date = // ( SELECT MAX( DATE ) FROM student_batch WHERE student_id = sb1.student_id ) GROUP BY student_id) AS T1 )", "T1.student_id = student.student_id ", 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); $this->db->join('course', 'course.course_id=student_batch.course_id', 'left'); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_batch.student_batch_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['student_id'] != '') { $this->db->where('parent_student.student_id', $postdata['student_id']); } if ($postdata['batch_id'] != '') { $this->db->where('batch.batch_id', $postdata['batch_id']); } if ($postdata['course_id'] != '') { $this->db->where('batch.course_id', $postdata['course_id']); } if($postdata) { $this->db->where('school_name', $postdata['school_name']); } $this->db->order_by('parent.parent_id', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_batch_id'], $deactivated_students)) { $data[] = $row; } } else { $data[] = $row; } } } $res->free_result(); return $data; } function get_test_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_batch_id']; $data = array(); $this->db->select('*,cancellation_id', false); $this->db->from("performance_exam"); $this->db->join('batch', 'batch.batch_id=performance_exam.batch_id'); $this->db->join('exammaster', 'exammaster.exammaster_id=performance_exam.exam_id'); $this->db->join('student', 'student.student_id=performance_exam.performance_id', 'left'); $this->db->join('student_batch', 'student_batch.student_id=student.student_id', 'left'); // $this->db->join('performance_exam', 'performance_exam.performance_id=performance_exam_subject.performance_id', 'left'); $this->db->join('course', 'course.course_id=student_batch.course_id', 'left'); $this->db->join('student_cancellation', 'student_cancellation.student_batch_id=student_batch.student_batch_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_batch.student_batch_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('test_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('test_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('batch.batch_id', $postdata['batch_id']); } if ($postdata['exammaster_id'] != '') { $this->db->where('performance_exam.exam_id', $postdata['exammaster_id']); } if($postdata['school_name'] !='') { $this->db->where('school_name', $postdata['school_name']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_batch_id'], $deactivated_students)) { $data[] = $row; } } else { $data[] = $row; } } } $res->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_batch($std_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', $std_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 get_extra_class_attendance($postdata) { $data = array(); $this->db->select("cancellation_id,deactivate_id,extra_class_details.student_id as student_id,group_concat(extra_class_date) as extra_att_date", FALSE); $this->db->from('extra_class'); $this->db->join('extra_class_details', 'extra_class_details.extra_class_id=extra_class.extra_class_id'); $this->db->join('student', 'student.student_id=extra_class_details.student_id'); $this->db->join('batch', 'batch.batch_id=extra_class.batch_id'); $this->db->group_by("student_id"); $this->db->join('student_cancellation', 'student_cancellation.student_id=student.student_id', 'left'); $this->db->join('student_deactivate', 'student_deactivate.student_id=student.student_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null and deactivate_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->having('cancellation_id is null and deactivate_id is not null'); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('deactivate_id is null and cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('extra_class_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('extra_class_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('extra_class.batch_id', $postdata['batch_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[$row['student_id']] = $row; } } $res->free_result(); return $data; } function get_attendance_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['batch']; if (!isset($deactivated_students[$postdata['batch_id']])) { $deactivated_students[$postdata['batch_id']] = array(); } $data = array(); $this->db->select("*,cancellation_id,attendance_details.student_id,group_concat(attendance_date) as att_date, group_concat(TIMEDIFF(attendance.end_time,attendance.start_time) ) as att_time, group_concat(concat(attendance_date,'~',IFNULL(subject.subject_name,'no_sub'),'~',IFNULL(subject.subject_id,0))) as att_subject, group_concat(attendance)as att_status", FALSE); $this->db->from('attendance'); $this->db->join('attendance_details', 'attendance_details.attendance_id=attendance.attendance_id'); $this->db->join('student', 'student.student_id=attendance_details.student_id'); $this->db->join('batch', 'batch.batch_id=attendance.batch_id'); $this->db->join('subject', 'subject.subject_id=attendance.subject_id', "left"); $this->db->group_by("attendance_details.student_id"); $this->db->join('student_cancellation', 'student_cancellation.student_id=student.student_id AND student_cancellation.batch_id=' . $postdata['batch_id'], 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student.student_id', $deactivated_students[$postdata['batch_id']]); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('attendance_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('attendance_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['batch_id'] != '') { $this->db->where('attendance.batch_id', $postdata['batch_id']); } $this->db->order_by('attendance_date', 'desc'); $res = $this->db->get(); // echo $this->db->last_query();die(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { if ($postdata['student_type'] == 'active') { if (!in_array($row['student_id'], $deactivated_students[$postdata['batch_id']])) { $data[] = $row; } } else { $data[] = $row; } } } $res->free_result(); return $data; } function get_leave_report($postdata) { $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("leave_application"); $this->db->join('employee', 'employee.employee_id=leave_application.employee_id'); $this->db->join('leave_type', 'leave_type.leave_type_id=leave_application.leave_type_id'); if ($postdata['start_date'] != '') { $this->db->where('from_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('to_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['employee_id'] != '') { $this->db->where('employee.employee_id', $postdata['employee_id']); } if ($postdata['leave_type_id'] != '') { $this->db->where('leave_type.leave_type_id', $postdata['leave_type_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_employee_details_report($postdata) { $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("employee"); $this->db->join('department', 'department.department_id=employee.employee_department_id'); $this->db->join('designation', 'designation.designation_id=employee.employee_designation_id'); $this->db->join('grade', 'grade.grade_id=employee.employee_grade_id'); $this->db->join('status', 'status.status_id=employee.employee_status_id'); $this->db->join('master', 'master.master_id=employee.employee_id'); $this->db->join('branch', 'branch.branch_id=employee.employee_branch_id'); if ($postdata['employee_name'] != '') { $this->db->where('employee_name', $postdata['employee_name']); } if ($postdata['employee_department_id'] != '') { $this->db->where('employee.employee_department_id', $postdata['employee_department_id']); } if ($postdata['employee_designation_id'] != '') { $this->db->where('employee.employee_designation_id', $postdata['employee_designation_id']); } if ($postdata['employee_grade_id'] != '') { $this->db->where('employee.employee_grade_id', $postdata['employee_grade_id']); } if ($postdata['employee_status'] != '') { $this->db->where('employee.employee_status_id', $postdata['employee_status']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_salary_report($postdata) { $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("employee_salary_slip"); $this->db->join('employee', 'employee.employee_id=employee_salary_slip.employee_id'); if ($postdata['employee_id'] != '') { $this->db->where('employee.employee_id', $postdata['employee_id']); } if ($postdata['start_date'] != '') { $this->db->where('salary_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('salary_date<=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_purchase_report($postdata) { $data = array(); $this->db->select('*'); $this->db->from("purchase"); $this->db->join('franchisee', 'franchisee.franchisee_id=purchase.purchase_franchisee_id'); // $this->db->join('purchase_inventory', 'purchase_inventory.purchase_id=purchase.purchase_id','left'); // $this->db->join('inventory', 'inventory.inventory_id=purchase_inventory.inventory_type_id','left'); if ($postdata['from_date'] != '') { $this->db->where('purchase_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('purchase_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['franchisee_id'] != '') { $this->db->where('purchase_franchisee_id', $postdata['franchisee_id']); } $this->db->order_by('purchase_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_stock_report($postdata) { $data = array(); $i = 1; $this->db->select('*'); $this->db->from("inventory"); if ($postdata['inventory_id'] != '') { $this->db->where('inventory_type_id', $postdata['inventory_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_stock_utilization_report($postdata) { $data = array(); $this->db->select('*'); $this->db->from("sale_inventory"); $this->db->join('sale', 'sale.sale_id=sale_inventory.sale_id'); $this->db->join('inventory', 'inventory.inventory_id=sale.sale_inventory_type_id'); $this->db->join('student', 'student.student_id=sale_inventory.student_id'); $this->db->join('student_batch', 'student_batch.student_id=student.student_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); if ($postdata['from_date'] != '') { $this->db->where('sale_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('sale_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['from_date'] != '') { $this->db->where('sale_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['batch_id'] != '') { $this->db->where('batch_id', $postdata['batch_id']); } if ($postdata['student_id'] != '') { $this->db->where('student.student_id', $postdata['student_id']); } $this->db->order_by('sale_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_stock_return_report($postdata) { $data = array(); $this->db->select('*'); $this->db->from("inventory_return"); $this->db->join('student', 'student.student_id=inventory_return.student_id'); $this->db->join('inventory', 'inventory_id=return_inventory_id'); $this->db->join('student_batch', 'student_batch.student_id=student.student_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); if ($postdata['from_date'] != '') { $this->db->where('return_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('return_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['student_id'] != '') { $this->db->where('inventory_return.student_id', $postdata['student_id']); } $this->db->order_by('return_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_franchisee_report($postdata) { $data = array(); $this->db->select('*'); $this->db->from("franchisee"); if ($postdata['franchisee_id'] != '') { $this->db->where('franchisee_id', $postdata['franchisee_id']); } $this->db->order_by('franchisee_id', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_franchisee_fee_report($postdata) { $data = array(); $this->db->select('*'); $this->db->from("franchisee_fee"); $this->db->join('batch', 'batch.batch_id=franchisee_fee.franchisee_fee_batch_id'); $this->db->join('course', 'course.course_id=batch.course_id', 'left'); $this->db->join('franchisee', 'franchisee.franchisee_id=franchisee_fee.franchisee_id', 'left'); $this->db->join('finance_journal_refs', 'finance_journal_refs.journal_id=franchisee_fee.journal_id','left'); if ($postdata['franchisee_id'] != '') { $this->db->where('franchisee_fee.franchisee_id', $postdata['franchisee_id']); } if ($postdata['batch_id'] != '') { $this->db->where('franchisee_fee_batch_id', $postdata['batch_id']); } if ($postdata['course_id'] != '') { $this->db->where('batch.course_id', $postdata['course_id']); } $this->db->order_by('franchisee_fee.franchisee_id', 'asc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_royalty_report($postdata) { $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('*,IFNULL(fee.fee_id,0) as fee_id ,IFNULL(fee.total_amount,0) as total_amount , student_batch.course_id as course_id, student_batch.course_fee as student_course_fee,student_batch.date as batch_allocation_date, fee.remarks as fee_remarks,course.course_fee as course_fee', false); $this->db->from("student"); $this->db->join('student_batch', 'student_batch.student_id=student.student_id'); $this->db->join('fee', 'fee.student_batch_id=student_batch.student_batch_id', 'left'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id', 'left'); $this->db->join('batch', 'batch.batch_id=student_batch.current_batch_id', 'left'); $this->db->join('course', 'course.course_id=student_batch.course_id'); $this->db->join('franchisee_course', 'franchisee_course.course_id=course.course_id', 'left'); if ($postdata['franchisee_id'] != '') { $this->db->where('franchisee_course.franchisee_id', $postdata['franchisee_id']); } if ($postdata['student_id'] != '') { $this->db->where('student_batch.student_id', $postdata['student_id']); } if ($postdata['batch_id'] != '') { $this->db->where('student_batch.current_batch_id', $postdata['batch_id']); } if ($postdata['course_id'] != '') { $this->db->where('student_batch.course_id', $postdata['course_id']); } if ($postdata['from_date'] != '') { $this->db->where('fee_date >=', $this->mastermodel->convertdateformat($postdata['from_date'])); } if ($postdata['to_date'] != '') { $this->db->where('fee_date <=', $this->mastermodel->convertdateformat($postdata['to_date'])); } $this->db->where('`course`.`course_id` IN (SELECT `course_id` FROM `franchisee_course`)', NULL, FALSE); $this->db->order_by('student.student_id', 'asc'); $this->db->order_by('fee.fee_id', 'asc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data['result'][$row['student_id']][$row['course_id']][] = $row; $count = 0; if (isset($data['rowspan'][$row['fee_id']])) $count = $data['rowspan'][$row['fee_id']]; $data['rowspan'][$row['fee_id']] = $count + 1; } } $res->free_result(); return $data; } function get_attendance_student($std_id, $date) { $date = $this->mastermodel->convertdateformat($date); $data = array(); $this->db->select('attendance'); $this->db->from('attendance_details'); $this->db->join('attendance', 'attendance.attendance_id=attendance.attendance_id'); $this->db->where('attendance_date', $date); $this->db->where('student_id', $std_id); $this->db->order_by('attendance_date', 'asc'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { $result = $Q->row(); if ($result) { if ($result->attendance == 1) return "A"; if ($result->attendance == 0) return "P"; } else { return " "; } } else { return " "; } } function get_paid_fee_details($batch_id, $student_type = '') { $data = array(); $date = date("Y-m-d"); $this->db->select('*'); $this->db->from('fee'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id'); $this->db->join('student_batch', 'student_batch.student_batch_id=fee.student_batch_id'); $this->db->where('current_batch_id', $batch_id); $res = $this->db->get(); $key = ''; $paid = ''; $crs = 0; $reg = 0; $extra = 0; $books = 0; if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $deactivate = $this->studentmodel->check_deactivate($row['current_batch_id'], $row['student_id'], $date); $cancell = $this->studentmodel->check_cancelled_student($row['current_batch_id'], $row['student_id'], $date); $flag = 0; if ($student_type == '') $flag = 1; else if ($student_type == 'Active' && $cancell == '0' && $deactivate == 0) $flag = 1; else if ($student_type == 'Deactivated' && $deactivate != '0') $flag = 1; else if ($student_type == 'Canceled' && $cancell != '0') $flag = 1; if ($flag == 1) { if ($row['fee_type'] == 'course') { $crs+=$row['amount_paid']; } if ($row['fee_type'] == 'registration') $reg+=$row['amount_paid']; if ($row['fee_type'] == 'extraclass') $extra+=$row['amount_paid']; if ($row['fee_type'] == 'books') $books+=$row['amount_paid']; } } } $data = array('course_paid_fee' => $crs, 'reg_fee_paid' => $reg, 'extra_fee_paid' => $extra, 'books_fee_paid' => $books); return $data; } }