?
Current Path : /home1/savoy/public_html/savoyglobal.net/eduplus2/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/eduplus2/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 get_deactivated_students() { $data = array(); $data['student_class_id'] = array(0); $data['class'] = array(); $sql = "SELECT * from student_deactivate join student_class on student_class.student_id=student_deactivate.student_id AND student_class.student_class_id=student_deactivate.student_class_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_class_id'], $data['student_class_id']))) { $data['student_class_id'][] = $row['student_class_id']; } $data['class'][$row['class_name_id']][] = $row['student_id']; } } $result->free_result(); return $data; } 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_students_report($postdata) { $data = array(); $this->db->select('*,parent.parent_id as p_id,student.student_id as student_id'); $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_class', 'student_class.student_id=student.student_id', 'left'); $this->db->join('parent', 'parent.parent_id=parent_student.parent_id', 'left'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id', 'left'); 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['class_name_id'] != '') { $this->db->where('student_class.class_name_id', $postdata['class_name_id']); } if ($postdata['gender'] != '') { $this->db->where('gender', $postdata['gender']); } $this->db->order_by('student.student_id', 'desc'); $res = $this->db->get(); //echo $this->db->last_query(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_fee_report($postdata) { $data = array(); $data['result_list'] = array(); $data['result_count'] = array(); $data['rowspan'] = 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('*,fee_particular_name,student_class.student_id,IF(payment_type="term",SUM(fee_amount),SUM(amount)) as fee,student_class_fee.student_class_fee_id as student_class_fee_id', false); $this->db->from('student_class'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); $this->db->join('student_class_fee', 'student_class_fee.student_class_id=student_class.student_class_id', 'left'); $this->db->join('student_monthly_fee', 'student_monthly_fee.student_class_fee_id=student_class_fee.student_class_fee_id', 'left'); $this->db->join('fee_particular', 'fee_particular.fee_particular_id=student_class_fee.fee_particular_id '); $this->db->order_by('student_class.class_name_id,student_class.student_id,student_class_fee.student_class_fee_id', 'asc'); $this->db->group_by('student_class.class_name_id,student_class.student_id,student_class_fee.student_class_fee_id'); if ($postdata['student_id'] != '') { $this->db->where('student_class.student_id', $postdata['student_id']); } if ($postdata['class_name_id'] != '') { $this->db->where('student_class.class_name_id', $postdata['class_name_id']); } $Q = $this->db->get(); // echo $this->db->last_query(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { // echo $row['student_class_fee_id']; $data['result'][$row['student_class_fee_id']] = $row; if (isset($data['amount'][$row['student_class_fee_id']])) $data['amount'][$row['student_class_fee_id']]+=$row['fee']; else $data['amount'][$row['student_class_fee_id']] = $row['fee']; } } // if (isset($data['result'])) { // foreach ($data['result'] as $value) { // // $paid = 0; //// if (isset($data['amount_paid'][$value['student_class_fee_id']]['fee_paid'])) { //// $paid = $data['amount_paid'][$value['student_class_fee_id']]['fee_paid']; //// if ($paid < $data['amount'][$value['student_class_id']]) { // $data['result_list'][$value['student_class_fee_id']] = $value; // $data['result_list'][$value['student_class_fee_id']]['fee_paid'] = $paid; // $data['result_list'][$value['student_class_fee_id']]['fee'] = $data['amount'][$value['student_class_fee_id']]; //// if (isset($data['result_count'][$value['class_name_id']])) { //// $data['result_count'][$value['class_name_id']]+=1; //// } else { //// $data['result_count'][$value['class_name_id']] = 1; //// } //// if (isset($data['rowspan'][$value['class_name_id']][$value['student_id']])) //// $data['rowspan'][$value['class_name_id']][$value['student_id']]+=1; //// else //// $data['rowspan'][$value['class_name_id']][$value['student_id']] = 1; // //// } //// } // } // } $Q->free_result(); return $data; } function feereport_fee_paid_details($postdata) { $data = array(); $this->db->select('*,student_class.student_id as student_id,fee_paid_details.id as id', false); $this->db->from('student_class'); $this->db->join('fee', 'fee.student_class_id=student_class.student_class_id', 'left'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id', 'left'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id', 'left'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->join('student_class_fee', 'student_class_fee.student_class_fee_id=fee_paid_details.student_class_fee_id', 'left'); $this->db->join('fee_particular', 'fee_particular.fee_particular_id=student_class_fee.fee_particular_id '); $this->db->order_by('student_class.class_name_id,student_class.student_id,fee.fee_id', 'asc'); // $this->db->group_by('fee_paid_details.student_class_fee_id'); if ($postdata['student_id'] != '') { $this->db->where('student_class.student_id', $postdata['student_id']); } if ($postdata['class_name_id'] != '') { $this->db->where('student_class.class_name_id', $postdata['class_name_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'])); } $Q = $this->db->get(); // $output= $this->get_fee_report($postdata); // $data['fee_details']=$output['result']; if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data['result_list'][$row['id']] = $row; if (isset($data['rowspan'][$row['student_class_id']][$row['fee_id']])) $data['rowspan'][$row['student_class_id']][$row['fee_id']]+=1; else $data['rowspan'][$row['student_class_id']][$row['fee_id']] = 1; } } $Q->free_result(); return $data; } function get_student_monthly_fee_details() { $data = array(); $this->db->select('*'); $this->db->from('student_monthly_fee'); $this->db->order_by('fee_wef_date', 'asc'); $Q = $this->db->get(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[$row['student_class_fee_id']][] = $row; } } $Q->free_result(); return $data; } function get_student_fee_paid_details($postdata) { $data = array(); $this->db->select('*,sum(amount_paid) as amount_paid'); $this->db->from('fee'); $this->db->join('student_class', 'student_class.student_class_id=fee.student_class_id'); $this->db->join('fee_paid_details', 'fee_paid_details.fee_id=fee.fee_id'); if ($postdata['student_id'] != '') { $this->db->where('student_class.student_id', $postdata['student_id']); } if ($postdata['class_name_id'] != '') { $this->db->where('student_class.class_name_id', $postdata['class_name_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('fee.student_class_id,student_class_fee_id'); $this->db->group_by('fee.student_class_id,student_class_fee_id,payment_for'); $Q = $this->db->get(); // echo $this->db->last_query(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[$row['student_class_id']][$row['student_class_fee_id']][$row['payment_for']] = $row; } } $Q->free_result(); return $data; } function get_fee_pending_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('*', false); $this->db->from('student_class'); $this->db->join('student_class_fee', 'student_class_fee.student_class_id=student_class.student_class_id'); $this->db->join('fee_particular', 'fee_particular.fee_particular_id=student_class_fee.fee_particular_id'); $this->db->join('student', 'student.student_id=student_class.student_id'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id'); // $this->db->join('term', 'term.term_id=student_class.term_id'); if ($postdata['student_id'] != '') { $this->db->where('student_class.student_id', $postdata['student_id']); } if ($postdata['class_name_id'] != '') { $this->db->where('student_class.class_name_id', $postdata['class_name_id']); } $this->db->order_by('student_class.student_class_id', 'asc'); $res = $this->db->get(); $this->db->last_query(); die(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data['student_fee_details'][$row['student_class_id']][] = $row; $data['accademic_year'][$row['student_class_id']] = $row['class_name_academic_year_id']; $data['term'][$row['student_class_id']] = $row['class_term_id']; $count = 0; if (isset($data['rowspan'][$row['student_class_id']])) $count = $data['rowspan'][$row['student_class_id']]; $data['rowspan'][$row['student_class_id']] = $count + 1; } } $res->free_result(); return $data; } function get_business_summary_report($postdata) { $data = array(); $date = date("Y-m-d"); if ($postdata['student_type'] == 'Active') { $sql = '*,class_name_id as class, 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_class.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_class.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_class.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 = '*,class_name_id as class, SUM(student_class.registration_fee) as registration_fee, SUM(student_class.course_fee) as course_fee_total, SUM(student_class.books_fee) as books_fee, COUNT(*) as student_count1'; } else if ($postdata['student_type'] == 'Deactivated') { $sql = '*,class_name_id as class, SUM(IF((student_deactivate.activate_date > "' . $date . '" OR student_deactivate.activate_date = "0000-00-00") AND student_deactivate.start_date <= "' . $date . '",student_class.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_class.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_class.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 = '*,class_name_id as class, SUM(IF(cancellation_date <= "' . $date . '" ,student_class.registration_fee,0)) as registration_fee, SUM(IF(cancellation_date <= "' . $date . '" ,student_class.course_fee,0)) as course_fee_total, SUM(IF(cancellation_date <= "' . $date . '" ,student_class.books_fee,0)) as books_fee, SUM(IF(cancellation_date <="' . $date . '" ,1,0)) as student_count1'; } $this->db->select($sql, false); $this->db->from("student_class"); $this->db->join('course', 'course.course_id=student_class.course_id'); $this->db->join('class', 'class.class_id=student_class.class_name_id'); $this->db->join('student_cancellation', 'student_cancellation.student_class_id=student_class.student_class_id', 'left'); $this->db->join('student_deactivate', 'student_deactivate.student_id=student_class.student_id AND student_deactivate.class_id=student_class.class_name_id', 'left'); $this->db->group_by('class_name_id'); if ($postdata['course_id'] != '') { $this->db->where('class.course_id', $postdata['course_id']); } if ($postdata['class_status'] != '') { $this->db->where('class.close', $postdata['class_status']); } $this->db->order_by('course.course_id'); $res = $this->db->get(); 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 = ''; 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, false); $this->db->from("student_cancellation"); $this->db->join('student', 'student.student_id=student_cancellation.student_id'); $this->db->join('student_class', 'student_class.student_class_id=student_cancellation.student_class_id', 'left'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id', 'left'); 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['class_name_id'] != '') { $this->db->where('class_name.class_name_id', $postdata['class_name_id']); } if ($postdata['student_id'] != '') { $this->db->where('student_cancellation.student_id', $postdata['student_id']); } // 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_student_list_report($postdata) { // $data = array(); $this->db->select('*'); $this->db->from('student'); $this->db->join('student_class', 'student_class.student_id=student.student_id'); $this->db->join('class_name','class_name.class_name_id=student_class.class_name_id'); $this->db->join('class_room','class_room.class_room_id=class_name.class_room_name'); $this->db->join('session','session.session_id=class_session', 'left'); if(isset($postdata['class_room_id'])!='') $this->db->where('class_room.class_room_id', $postdata['class_room_id']); $this->db->where('cancelled', 0); $this->db->order_by('class_allocation_date','desc'); $this->db->order_by('session_name','asc'); $this->db->group_by('student.student_id'); $query = $this->db->get(); return $query->result(); } function get_class_allocation_report($postdata) { $output = $this->get_deactivated_students(); $deactivated_students = $output['student_class_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_class.student_id as student_id,cancellation_id,IFNULL(student_class.student_class_id ,0) as student_class_id, group_concat(class_name.class_name_code) as course,count(*) as count,group_concat(student_class.class_allocation_date) as allo_date', false); $this->db->from("student_class"); $this->db->join('student', 'student.student_id=student_class.student_id', 'left'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id', 'left'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->group_by("student_class.student_id"); $this->db->join('student_cancellation', 'student_cancellation.student_class_id=student_class.student_class_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_class.student_class_id', $deactivated_students); } if ($postdata['student_type'] == 'cancelled') { $this->db->having('cancellation_id is not null'); } if ($postdata['from_date'] != '') { $this->db->where('class_allocation_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('class_allocation_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['student_id'] != '') { $this->db->where('parent_student.student_id', $postdata['student_id']); } if ($postdata['class_name_id'] != '') { $this->db->where('class_name.class_name_id', $postdata['class_name_id']); } $this->db->order_by('student_class.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_class_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_class_id']; $data = array(); $this->db->select('*,parent.parent_id as p_id,cancellation_id,IFNULL(student_class.student_class_id,"0") as student_class_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_class', 'student_class.student_id=parent_student.student_id', 'left'); $this->db->join('class_name', 'class_name.class_name_id=student_class.class_name_id', 'left'); $this->db->join('student_cancellation', 'student_cancellation.student_class_id=student_class.student_class_id', 'left'); if ($postdata['student_type'] == 'active') { $this->db->having('cancellation_id is null'); } if ($postdata['student_type'] == 'deactivated') { $this->db->where_in('student_class.student_class_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['class_name_id'] != '') { $this->db->where('class_name.class_name_id', $postdata['class_name_id']); } $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_class_id'], $deactivated_students)) { $data[] = $row; } } else { $data[] = $row; } } } $res->free_result(); return $data; } function get_test_report($postdata) { $data = array(); $this->db->select('*'); $this->db->from("student_assessment"); $this->db->join('class_name', 'class_name.class_name_id=student_assessment.class_name_id'); $this->db->join('assessment_master', 'assessment_master.assessment_master_id=student_assessment.assessment_master_id'); $this->db->from('student', 'student.class_name_id=student_assessment.student_assessment_id'); $this->db->join('nationality', 'nationality.nationality_id=student.nationality_id'); if ($postdata['from_date'] != '') { $this->db->where('assessment_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('assessment_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } if ($postdata['class_name_id'] != '') { $this->db->where('class_name.class_name_id', $postdata['class_name_id']); } if ($postdata['assessment_master_id'] != '') { $this->db->where('student_assessment.assessment_master_id', $postdata['assessment_master_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_marks($std_id, $student_assessment_id) { $data = array(); $this->db->select('*'); $this->db->from('student_assessment_details'); $this->db->where('student_id', $std_id); $this->db->where('student_assessment_id', $student_assessment_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_class($std_id) { $data = array(); $this->db->select('class_name_code'); $this->db->from('class_name'); $this->db->join('student_class', 'student_class.class_name_id=class_name.class_name_id'); $this->db->where('student_id', $std_id); $this->db->order_by('student_class.class_allocation_date', 'desc'); $this->db->limit('1'); $Q = $this->db->get(); $result = $Q->row(); if ($result) { return $result->class_name_code; } else { return ""; } } function get_attendance_report($postdata) { $data = array(); $this->db->select("attendance_details.student_id,group_concat(attendance_date) as att_date , group_concat(TIMEDIFF(attendance_details.end_time,attendance_details.start_time) ) as att_time, 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('nationality', 'nationality.nationality_id=student.nationality_id'); $this->db->join('class_name', 'class_name.class_name_id=attendance.class_id'); $this->db->group_by("student_id"); 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['class_name_id'] != '') { $this->db->where('attendance.class_id', $postdata['class_name_id']); } $this->db->order_by('attendance_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } // echo $this->db->last_query(); $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('nationality', 'nationality.nationality_id=employee.employee_nationality_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_personal_summary_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, FALSE); $this->db->from("employee"); $this->db->join('nationality', 'nationality.nationality_id=employee.employee_nationality_id'); if ($postdata['sub_date'] != '') { $sub_date = $postdata['sub_date']; if ($postdata['start_date'] != '') { $this->db->where("$sub_date >=", $this->mastermodel->convertdateformat($postdata['start_date']), NULL, FALSE); } if ($postdata['end_date'] != '') { $this->db->where("$sub_date <=", $this->mastermodel->convertdateformat($postdata['end_date']), NULL, FALSE); } } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_monthly_statistics_report($postdata) { $data = array(); $this->db->from("student"); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_children($nationality_type, $gender, $age_lower, $age_upper, $postdata) { $max_dob = date('Y-m-d', strtotime(date("Y-m-d") . "-$age_upper year")); $min_dob = date('Y-m-d', strtotime(date("Y-m-d") . "-$age_lower year")); $this->db->from("student"); $this->db->join("nationality", "nationality.nationality_id=student.nationality_id"); $this->db->join("attendance_details", "attendance_details.student_id=student.student_id"); $this->db->join("attendance", "attendance.attendance_id=attendance_details.attendance_id"); if ($nationality_type == "Qatari") $this->db->where("nationality.nationality_type", $nationality_type); else $this->db->where("nationality.nationality_type != ", "Qatari"); $this->db->where("student.gender", $gender); $this->db->where("student.dob >", $max_dob); $this->db->where("student.dob <=", $min_dob); $this->db->where("attendance.attendance_date >=", $this->mastermodel->convertdateformat($postdata['from_date'])); $this->db->where("attendance.attendance_date <=", $this->mastermodel->convertdateformat($postdata['to_date'])); $res = $this->db->get(); return $res->num_rows(); } function get_employee($designation_id, $nationality_type) { $this->db->from("employee"); $this->db->join("nationality", "nationality.nationality_id=employee.employee_nationality_id"); $this->db->where("nationality.nationality_type", $nationality_type); $this->db->where("employee_designation_id", $designation_id); $res = $this->db->get(); return $res->num_rows(); } 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']), NULL, FALSE); } if ($postdata['end_date'] != '') { $this->db->where('salary_date <=', $this->mastermodel->convertdateformat($postdata['end_date']), NULL, FALSE); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $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; } function get_employee_attendance_report($postdata) { $data = array(); $this->db->select("*,group_concat(employee_attendance_date SEPARATOR '#') as att_details,group_concat(employee_attendance_status SEPARATOR '#') as att_stat", FALSE); $this->db->from('employee_attendance'); $this->db->join('employee_attendance_details', 'employee_attendance_details.employee_attendance_id=employee_attendance.employee_attendance_id'); $this->db->join('employee', 'employee.employee_id=employee_attendance_details.employee_id'); $this->db->group_by("employee_attendance_details.employee_id"); if ($postdata['from_date'] != '') { $this->db->where('employee_attendance_date >=', $this->mastermodel->convertdateformat($postdata['from_date']) . " 00:00:00"); } if ($postdata['to_date'] != '') { $this->db->where('employee_attendance_date <=', $this->mastermodel->convertdateformat($postdata['to_date']) . " 23:59:59"); } $this->db->order_by('employee_attendance_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } // echo $this->db->last_query(); $res->free_result(); return $data; } }