GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.188.63.71
Web Server : Apache
System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : jnclnmuac ( 1026)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/jnclnmuac/public_html/web/pdf/../../cas/application/language/../controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/pdf/../../cas/application/language/../controllers/admin/Reports.php
<?php

/**
 * Controller For Handling All Requests Related To Reporting
 *
 * @author Softpro India Pvt. Ltd..
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class Reports extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('admin/StudentManagement');
        $this->load->model('admin/BranchManagement');
        $this->load->model('admin/CourseManagement');
        $this->load->model('admin/StaffManagement');
        $this->load->model('admin/DocumentInfoManagement');
        $this->load->model('admin/DocumentManagement');
        $this->load->model('admin/RelationManagement');
        $this->load->model('admin/DesignationManagement');
        $this->load->model('admin/DepartmentManagement');
        $this->load->model('admin/StockAndPurchaseManagement');
        $this->load->model('admin/InventoryManagement');
        $this->load->model('admin/LocationManagement');
        $this->load->model('admin/AttendanceManagement');
        $this->load->model('admin/SessionManagement');
        $this->load->model('admin/SubjectManagement');
        $this->load->model('admin/FeeManagement');
        $this->load->model('admin/AllotmentManagement');
        $this->load->model('admin/AchievementManagement');
        $this->load->model('admin/ScholarshipManagement');
        $this->load->model('admin/LeaveManagement');
    }

    public function studentMiscellaneousReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $reqName = trim($this->input->post("stuName"));
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedGender = trim($this->input->post("stuGender"));
                $selectedCategory = trim($this->input->post("stuCategory"));
                $selectedReligion = trim($this->input->post("stuReligion"));
                $selectedDisability = trim($this->input->post("stuDisability"));
                $selectedOperator = trim($this->input->post("stuEntryOprtr"));
                $selectedStatus = trim($this->input->post("stuStatus"));
                $selectedEnrollSession = trim($this->input->post("enrollSession"));
                $selectedStartDate = (trim($this->input->post("entryStartDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("entryStartDate")))));
                $selectedEndDate = (trim($this->input->post("entryEndDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("entryEndDate")))));
                $selectedRangeAppliedWith = (trim($this->input->post("entryDateRangeAppliedWith")) == "") ? "" : trim($this->input->post("entryDateRangeAppliedWith"));
                $filteredRecords = $this->StudentManagement->getStudentMiscellaneousReport($reqName, $selectedCourse, $selectedSession, $selectedEntryType, $selectedGender, $selectedCategory, $selectedReligion, $selectedDisability, $selectedOperator, $selectedEnrollSession, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith, $selectedStatus)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result();
            $viewData['categories'] = json_decode(file_get_contents(base_url('assets/admin/json/categories.json')), true);
            $viewData['religions'] = json_decode(file_get_contents(base_url('assets/admin/json/religions.json')), true);
            $viewData['operators'] = $this->StaffManagement->getAllDistinctStudentEntryOperators()->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/student/studentMiscellaneousReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentDeficitDocsReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                if ($selectedCourse == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Course To Fetch Deficit Documents Report.");
                } else {
                    $this->session->set_flashdata('errorMessage', NULL);
                    $courseCategory = $this->CourseManagement->getCoursesBy($selectedCourse)->result()[0]->course_category;
                    $allApplicableDoumentsByCourseCategory = $this->DocumentManagement->getAllDocumentsUptoCategory($courseCategory)->result();
                    $filteredRecordsForDeficitDocsReport = $this->StudentManagement->getStudentPersonalInfoByCourseSessionAndEntryType($selectedCourse, $selectedSession, $selectedEntryType)->result();
                    for ($i = 0; $i < sizeof($filteredRecordsForDeficitDocsReport); $i++) {
                        $thisStudent = $filteredRecordsForDeficitDocsReport[$i];
                        $fatherRelId = $this->RelationManagement->getRelationInfoByName("FATHER")->result()[0]->rel_id;
                        $fatherName = $this->RelationManagement->getRelativeInfoBy($thisStudent->tspi_id, $fatherRelId, "S")->result()[0]->tfbi_name;
                        if ($thisStudent->tspi_status == 'CE') {
                            $ten_marks = 'N';
                            $ten_cert = 'N';
                            $twelve_marks = 'N';
                            $twelve_cert = 'N';
                            $tc = 'N';
                            $grad_marks = "N";
                            $mig = 'N';
                            $cc = 'N';
                            $ygc = ($thisStudent->tspi_ygap_applied == "T") ? "N" : "";
                            $enrlmtn_form = 'N';
                            for ($j = 0; $j < sizeof($allApplicableDoumentsByCourseCategory); $j++) {
                                $thisDocument = $allApplicableDoumentsByCourseCategory[$j];
                                if ($this->DocumentInfoManagement->isDocumentUploaded($thisStudent->tspi_id, $thisDocument->doc_id, "S")) {
                                    switch ($thisDocument->doc_flag) {
                                        case 'XM':
                                            $ten_marks = '';
                                            break;
                                        case 'XC':
                                            $ten_cert = '';
                                            break;
                                        case 'XIIM':
                                            $twelve_marks = '';
                                            break;
                                        case 'XIIC':
                                            $twelve_cert = '';
                                            break;
                                        case 'GM':
                                            $grad_marks = "";
                                            break;
                                        case 'TC':
                                            $tc = '';
                                            break;
                                        case 'MG':
                                            $mig = '';
                                            break;
                                        case 'CC':
                                            $cc = '';
                                            break;
                                        case 'YGC':
                                            $ygc = ($ygc == "N") ? "" : "Not Applicable";
                                            break;
                                        case 'SCE':
                                            $enrlmtn_form = '';
                                            break;
                                        default:break;
                                    }
                                }
                            }
                            $grad_marks = ($courseCategory == "UG") ? "" : $grad_marks;
                            if ($ten_marks == 'N' || $ten_cert == 'N' || $twelve_marks == 'N' || $twelve_cert == 'N' || $grad_marks == 'N' || $tc == 'N' || $mig == 'N' || $cc == 'N' || $ygc == 'N' || $enrlmtn_form == 'N') {
                                $grad_marks = ($courseCategory == "UG") ? "Not Applicable" : $grad_marks;
                                $thisStudentDeficitDocInfo = array(
                                    'stu_form_no' => stripslashes($thisStudent->tspi_form_no),
                                    'stu_enrollment_no' => stripslashes($thisStudent->tspi_enrollment_no),
                                    'stu_roll_no' => stripslashes($thisStudent->tspi_rollNumber),
                                    'stu_name' => stripslashes($thisStudent->tspi_name),
                                    'stu_mob' => $thisStudent->tspi_mobile,
                                    'stu_email' => stripslashes($thisStudent->tspi_email),
                                    'stu_gender' => $thisStudent->tspi_gender,
                                    'stu_father_name' => $fatherName,
                                    'stu_course' => stripslashes($thisStudent->course_name),
                                    'stu_session' => stripslashes($thisStudent->session_name),
                                    'stu_entry_type' => stripslashes($thisStudent->tcsm_course_type),
                                    'ten_marks' => $ten_marks,
                                    'ten_cert' => $ten_cert,
                                    'twelwe_marks' => $twelve_marks,
                                    'twelve_cert' => $twelve_cert,
                                    'tc' => $tc,
                                    'grad_marks' => $grad_marks,
                                    'mig' => $mig,
                                    'cc' => $cc,
                                    'ygc' => $ygc,
                                    'enrlmtn_form' => $enrlmtn_form
                                );
                                array_push($filteredRecords, $thisStudentDeficitDocInfo);
                            }
                        } else {
                            continue;
                        }
                    }
                }
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/student/studentDeficitDocsReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentTCReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedPattern = "";
            $selectedSession = "";
            $selectedEntryType = "";
            $tcReport = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $filterPattern = $this->input->post('filterPattern');
                $selectedPattern = $filterPattern;
                if ($filterPattern != "") {
                    if ($filterPattern == 'FNW') {
                        $reqFormNumber = trim($this->input->post('stuFormNo'));
                        if ($reqFormNumber == "") {
                            $this->session->set_flashdata('errorMessage', "Enter Form Number To Search.");
                        } else {
                            $this->session->set_flashdata('errorMessage', NULL);
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByFormNumber($reqFormNumber)->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentTCDocId = $this->DocumentManagement->getDocumentByFlag("TC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $tcInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentTCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($tcInfo)) {
                                        for ($j = 0; $j < sizeof($tcInfo); $j++) {
                                            array_push($tcReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_tc_issued' => true,
                                                'is_tc_duplicate' => ($tcInfo[$j]->tdii_duplicate_status == "F") ? 'Original' : 'Duplicate',
                                                'tc_id' => $tcInfo[$j]->tdii_id,
                                                'tc_issue_date' => date("d-m-Y", strtotime($tcInfo[$j]->tdii_doc_issued_on)),
                                                'tc_sr_no' => stripslashes($tcInfo[$j]->tdii_doc_unique_code),
                                                'tc_issued_by' => stripslashes($tcInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($tcReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_tc_issued' => false,
                                            'is_tc_duplicate' => "NA",
                                            'tc_id' => 0,
                                            'tc_issue_date' => "NA",
                                            'tc_sr_no' => "NA",
                                            'tc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "Invalid Form Number. No Student Record Is Available On This Form Number.");
                            }
                        }
                    } else if ($filterPattern == 'RNW') {
                        $reqRollNumber = trim($this->input->post('stuRollNo'));
                        if ($reqRollNumber == "") {
                            $this->session->set_flashdata('errorMessage', "Enter Roll Number/College Id To Search.");
                        } else {
                            $this->session->set_flashdata('errorMessage', NULL);
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByRollNumberOrEnrollmentNo($reqRollNumber)->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentTCDocId = $this->DocumentManagement->getDocumentByFlag("TC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $tcInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentTCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($tcInfo)) {
                                        for ($j = 0; $j < sizeof($tcInfo); $j++) {
                                            array_push($tcReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_tc_issued' => true,
                                                'is_tc_duplicate' => ($tcInfo[$j]->tdii_duplicate_status == "F") ? 'Original' : 'Duplicate',
                                                'tc_id' => $tcInfo[$j]->tdii_id,
                                                'tc_issue_date' => date("d-m-Y", strtotime($tcInfo[$j]->tdii_doc_issued_on)),
                                                'tc_sr_no' => stripslashes($tcInfo[$j]->tdii_doc_unique_code),
                                                'tc_issued_by' => stripslashes($tcInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($tcReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_tc_issued' => false,
                                            'is_tc_duplicate' => "NA",
                                            'tc_id' => 0,
                                            'tc_issue_date' => "NA",
                                            'tc_sr_no' => "NA",
                                            'tc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "Invalid College Id/Roll Number. No Student Record Is Available On This Roll Number.");
                            }
                        }
                    } else {
                        $reqCourse = trim($this->input->post('stuCourse'));
                        if ($reqCourse == "") {
                            $this->session->set_flashdata('errorMessage', "Please Select Course To Search Students.");
                        } else {
                            $selectedSession = $this->input->post('stuSession');
                            $selectedEntryType = $this->input->post('stuEntryType');
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByCourseSessionAndEntryType($reqCourse, trim($selectedSession), trim($selectedEntryType))->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentTCDocId = $this->DocumentManagement->getDocumentByFlag("TC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $tcInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentTCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($tcInfo)) {
                                        for ($j = 0; $j < sizeof($tcInfo); $j++) {
                                            array_push($tcReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_tc_issued' => true,
                                                'is_tc_duplicate' => ($tcInfo[$j]->tdii_duplicate_status == "F") ? 'Original' : 'Duplicate',
                                                'tc_id' => $tcInfo[$j]->tdii_id,
                                                'tc_issue_date' => date("d-m-Y", strtotime($tcInfo[$j]->tdii_doc_issued_on)),
                                                'tc_sr_no' => stripslashes($tcInfo[$j]->tdii_doc_unique_code),
                                                'tc_issued_by' => stripslashes($tcInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($tcReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_tc_issued' => false,
                                            'is_tc_duplicate' => "NA",
                                            'tc_id' => 0,
                                            'tc_issue_date' => "NA",
                                            'tc_sr_no' => "NA",
                                            'tc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "No Students Exists In The Selected Course/Session.");
                            }
                        }
                    }
                } else {
                    $tcReport = array();
                }
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['selectedPattern'] = $selectedPattern;
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['tcReport'] = $tcReport;
            $this->load->view('admin/reports/student/tcReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentCCReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedPattern = "";
            $selectedSession = "";
            $selectedEntryType = "";
            $ccReport = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $filterPattern = $this->input->post('filterPattern');
                $selectedPattern = $filterPattern;
                if ($filterPattern != "") {
                    if ($filterPattern == 'FNW') {
                        $reqFormNumber = trim($this->input->post('stuFormNo'));
                        if ($reqFormNumber == "") {
                            $this->session->set_flashdata('errorMessage', "Enter Form Number To Search.");
                        } else {
                            $this->session->set_flashdata('errorMessage', NULL);
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByFormNumber($reqFormNumber)->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentCCDocId = $this->DocumentManagement->getDocumentByFlag("CC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $ccInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentCCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($ccInfo)) {
                                        for ($j = 0; $j < sizeof($ccInfo); $j++) {
                                            array_push($ccReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_cc_issued' => true,
                                                'is_cc_duplicate' => ($ccInfo[$j]->tdii_duplicate_status == "F") ? 'Original' : 'Duplicate',
                                                'cc_id' => $ccInfo[$j]->tdii_id,
                                                'cc_issue_date' => date("d-m-Y", strtotime($ccInfo[$j]->tdii_doc_issued_on)),
                                                'cc_sr_no' => stripslashes($ccInfo[$j]->tdii_doc_unique_code),
                                                'cc_issued_by' => stripslashes($ccInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($ccReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_cc_issued' => false,
                                            'is_cc_duplicate' => "NA",
                                            'cc_id' => 0,
                                            'cc_issue_date' => "NA",
                                            'cc_sr_no' => "NA",
                                            'cc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "Invalid Form Number. No Student Record Is Available On This Form Number.");
                            }
                        }
                    } else if ($filterPattern == 'RNW') {
                        $reqRollNumber = trim($this->input->post('stuRollNo'));
                        if ($reqRollNumber == "") {
                            $this->session->set_flashdata('errorMessage', "Enter Roll Number/College Id To Search.");
                        } else {
                            $this->session->set_flashdata('errorMessage', NULL);
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByRollNumberOrEnrollmentNo($reqRollNumber)->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentCCDocId = $this->DocumentManagement->getDocumentByFlag("CC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $ccInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentCCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($ccInfo)) {
                                        for ($j = 0; $j < sizeof($ccInfo); $j++) {
                                            array_push($ccReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_cc_issued' => true,
                                                'is_cc_duplicate' => ($ccInfo[$j]->tdii_duplicate_status == "F") ? 'Original' : 'Duplicate',
                                                'cc_id' => $ccInfo[$j]->tdii_id,
                                                'cc_issue_date' => date("d-m-Y", strtotime($ccInfo[$j]->tdii_doc_issued_on)),
                                                'cc_sr_no' => stripslashes($ccInfo[$j]->tdii_doc_unique_code),
                                                'cc_issued_by' => stripslashes($ccInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($ccReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_cc_issued' => false,
                                            'is_cc_duplicate' => "NA",
                                            'cc_id' => 0,
                                            'cc_issue_date' => "NA",
                                            'cc_sr_no' => "NA",
                                            'cc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "Invalid College Id/Roll Number. No Student Record Is Available On This Roll Number.");
                            }
                        }
                    } else {
                        $reqCourse = trim($this->input->post('stuCourse'));
                        if ($reqCourse == "") {
                            $this->session->set_flashdata('errorMessage', "Please Select Course To Search Students.");
                        } else {
                            $selectedSession = $this->input->post('stuSession');
                            $selectedEntryType = $this->input->post('stuEntryType');
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByCourseSessionAndEntryType($reqCourse, trim($selectedSession), trim($selectedEntryType))->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentCCDocId = $this->DocumentManagement->getDocumentByFlag("CC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $ccInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentCCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($ccInfo)) {
                                        for ($j = 0; $j < sizeof($ccInfo); $j++) {
                                            array_push($ccReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_cc_issued' => true,
                                                'is_cc_duplicate' => ($ccInfo[$j]->tdii_duplicate_status == "F") ? 'Original' : 'Duplicate',
                                                'cc_id' => $ccInfo[$j]->tdii_id,
                                                'cc_issue_date' => date("d-m-Y", strtotime($ccInfo[$j]->tdii_doc_issued_on)),
                                                'cc_sr_no' => stripslashes($ccInfo[$j]->tdii_doc_unique_code),
                                                'cc_issued_by' => stripslashes($ccInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($ccReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_cc_issued' => false,
                                            'is_cc_duplicate' => "NA",
                                            'cc_id' => 0,
                                            'cc_issue_date' => "NA",
                                            'cc_sr_no' => "NA",
                                            'cc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "No Students Exists In The Selected Course/Session.");
                            }
                        }
                    }
                } else {
                    $ccReport = array();
                }
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['selectedPattern'] = $selectedPattern;
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['ccReport'] = $ccReport;
            $this->load->view('admin/reports/student/ccReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentBCReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedPattern = "";
            $selectedSession = "";
            $selectedEntryType = "";
            $bcReport = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $filterPattern = $this->input->post('filterPattern');
                $selectedPattern = $filterPattern;
                if ($filterPattern != "") {
                    if ($filterPattern == 'FNW') {
                        $reqFormNumber = trim($this->input->post('stuFormNo'));
                        if ($reqFormNumber == "") {
                            $this->session->set_flashdata('errorMessage', "Enter Form Number To Search.");
                        } else {
                            $this->session->set_flashdata('errorMessage', NULL);
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByFormNumber($reqFormNumber)->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentBCDocId = $this->DocumentManagement->getDocumentByFlag("BC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $bcInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentBCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($bcInfo)) {
                                        for ($j = 0; $j < sizeof($bcInfo); $j++) {
                                            array_push($bcReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_bc_issued' => true,
                                                'is_bc_duplicate' => '-',
                                                'bc_id' => $bcInfo[$j]->tdii_id,
                                                'bc_issue_date' => date("d-m-Y", strtotime($bcInfo[$j]->tdii_doc_issued_on)),
                                                'bc_sr_no' => stripslashes($bcInfo[$j]->tdii_doc_unique_code),
                                                'bc_issued_by' => stripslashes($bcInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($bcReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_bc_issued' => false,
                                            'is_bc_duplicate' => "-",
                                            'bc_id' => 0,
                                            'bc_issue_date' => "NA",
                                            'bc_sr_no' => "NA",
                                            'bc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "Invalid Form Number. No Student Record Is Available On This Form Number.");
                            }
                        }
                    } else if ($filterPattern == 'RNW') {
                        $reqRollNumber = trim($this->input->post('stuRollNo'));
                        if ($reqRollNumber == "") {
                            $this->session->set_flashdata('errorMessage', "Enter Roll Number/College Id To Search.");
                        } else {
                            $this->session->set_flashdata('errorMessage', NULL);
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByRollNumberOrEnrollmentNo($reqRollNumber)->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentBCDocId = $this->DocumentManagement->getDocumentByFlag("BC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $bcInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentBCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($bcInfo)) {
                                        for ($j = 0; $j < sizeof($bcInfo); $j++) {
                                            array_push($bcReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_bc_issued' => true,
                                                'is_bc_duplicate' => "-",
                                                'bc_id' => $bcInfo[$j]->tdii_id,
                                                'bc_issue_date' => date("d-m-Y", strtotime($bcInfo[$j]->tdii_doc_issued_on)),
                                                'bc_sr_no' => stripslashes($bcInfo[$j]->tdii_doc_unique_code),
                                                'bc_issued_by' => stripslashes($bcInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($bcReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_bc_issued' => false,
                                            'is_bc_duplicate' => "-",
                                            'bc_id' => 0,
                                            'bc_issue_date' => "NA",
                                            'bc_sr_no' => "NA",
                                            'bc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "Invalid College Id/Roll Number. No Student Record Is Available On This Roll Number.");
                            }
                        }
                    } else {
                        $reqCourse = trim($this->input->post('stuCourse'));
                        if ($reqCourse == "") {
                            $this->session->set_flashdata('errorMessage', "Please Select Course To Search Students.");
                        } else {
                            $selectedSession = $this->input->post('stuSession');
                            $selectedEntryType = $this->input->post('stuEntryType');
                            $studentInfo = $this->StudentManagement->getStudentPersonalInfoByCourseSessionAndEntryType($reqCourse, trim($selectedSession), trim($selectedEntryType))->result();
                            if (sizeof($studentInfo)) {
                                $studentFatherName = $this->StudentManagement->getStudentFatherInfoBy($studentInfo[0]->tspi_id)->result()[0]->tfbi_name;
                                $studentBCDocId = $this->DocumentManagement->getDocumentByFlag("BC")->result()[0]->doc_id;
                                for ($i = 0; $i < sizeof($studentInfo); $i++) {
                                    $thisRecord = $studentInfo[$i];
                                    $bcInfo = $this->DocumentInfoManagement->getIssuedDocumentInfoBy($studentBCDocId, $thisRecord->tspi_id)->result();
                                    if (sizeof($bcInfo)) {
                                        for ($j = 0; $j < sizeof($bcInfo); $j++) {
                                            array_push($bcReport, array(
                                                'stu_id' => $thisRecord->tspi_id,
                                                'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                                'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                                'stu_name' => stripslashes($thisRecord->tspi_name),
                                                'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                                'stu_father_name' => stripslashes($studentFatherName),
                                                'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                                'stu_status' => $thisRecord->tspi_status,
                                                'stu_course' => stripslashes($thisRecord->course_name),
                                                'stu_session' => stripslashes($thisRecord->session_name),
                                                'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                                'is_bc_issued' => true,
                                                'is_bc_duplicate' => "-",
                                                'bc_id' => $bcInfo[$j]->tdii_id,
                                                'bc_issue_date' => date("d-m-Y", strtotime($bcInfo[$j]->tdii_doc_issued_on)),
                                                'bc_sr_no' => stripslashes($bcInfo[$j]->tdii_doc_unique_code),
                                                'bc_issued_by' => stripslashes($bcInfo[$j]->issuedByAdmin)
                                            ));
                                        }
                                    } else {
                                        array_push($bcReport, array(
                                            'stu_id' => $thisRecord->tspi_id,
                                            'stu_roll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_rollNumber) ? "-" : stripslashes($thisRecord->tspi_rollNumber),
                                            'stu_enroll_number' => ($thisRecord->tspi_form_no == $thisRecord->tspi_enrollment_no) ? "-" : stripslashes($thisRecord->tspi_enrollment_no),
                                            'stu_name' => stripslashes($thisRecord->tspi_name),
                                            'stu_gender' => stripslashes($thisRecord->tspi_gender),
                                            'stu_father_name' => stripslashes($studentFatherName),
                                            'stu_dob' => date("d-m-Y", strtotime($thisRecord->tspi_dob)),
                                            'stu_status' => $thisRecord->tspi_status,
                                            'stu_course' => stripslashes($thisRecord->course_name),
                                            'stu_session' => stripslashes($thisRecord->session_name),
                                            'stu_entry_type' => stripslashes($thisRecord->tcsm_course_type),
                                            'is_bc_issued' => false,
                                            'is_bc_duplicate' => "-",
                                            'bc_id' => 0,
                                            'bc_issue_date' => "NA",
                                            'bc_sr_no' => "NA",
                                            'bc_issued_by' => "NA"
                                        ));
                                    }
                                }
                            } else {
                                $this->session->set_flashdata('errorMessage', "No Students Exists In The Selected Course/Session.");
                            }
                        }
                    }
                } else {
                    $bcReport = array();
                }
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['selectedPattern'] = $selectedPattern;
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['bcReport'] = $bcReport;
            $this->load->view('admin/reports/student/bcReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentAchievementReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedAchievementSession = trim($this->input->post("achvSession"));
                $selectedAchievementHead = trim($this->input->post("achvHead"));
                $filteredRecords = $this->AchievementManagement->getStudentAchievementReport($selectedCourse, $selectedSession, $selectedEntryType, $selectedAchievementSession, $selectedAchievementHead)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result();
            $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads('S')->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/student/studentAchievementReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentSemesterYearReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedCourse = "";
            $selectedSession = "";
            $selectedEntryType = "";
            $selectedStatus = "";
            $filteredRecords = array();
            $colHeads = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedStatus = trim($this->input->post("stuStatus"));
                if ($selectedCourse == "") {
                    $this->session->set_flashdata('errorMessage', "Course Selection Is Mandatory To Fetch Report.");
                } else if ($selectedSession == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Session.");
                } else {
                    $studentsList = $this->StudentManagement->getStudentMiscellaneousReport('', $selectedCourse, $selectedSession, $selectedEntryType, '', '', '', '', '', '', '', '', '', $selectedStatus)->result();
                    $courseInfo = $this->CourseManagement->getCoursesBy($selectedCourse)->result()[0];
                    $course_time_mgmt_flag = ($courseInfo->course_time_mgmt_flag == 'Y') ? "Yr." : "Sem.";
                    if (sizeof($studentsList)) {
                        $sem_year_start_from = $studentsList[0]->tcsm_sem_start_from;
                        for ($head = $sem_year_start_from; $head <= $courseInfo->course_no_of_sems; $head++) {
                            array_push($colHeads, $head . " " . $course_time_mgmt_flag);
                        }
                        $tspi_ids = array();
                        for ($i = 0; $i < sizeof($studentsList); $i++) {
                            array_push($tspi_ids, $studentsList[$i]->tspi_id);
                        }
                        $allStudentsSemesterInfo = $this->StudentManagement->getSemesterInfoOfStudentsBy($tspi_ids)->result();
                        if (sizeof($allStudentsSemesterInfo)) {
                            for ($i = 0; $i < sizeof($studentsList); $i++) {
                                $sem_or_year_marks = array();
                                $totalObtainedMarks = 0;
                                $totalMaxMarks = 0;
                                for ($j = $sem_year_start_from; $j <= $courseInfo->course_no_of_sems; $j++) {
                                    $ifFound = 0;
                                    for ($k = 0; $k < sizeof($allStudentsSemesterInfo); $k++) {
                                        if (($allStudentsSemesterInfo[$k]->tspi_id == $studentsList[$i]->tspi_id) && ($allStudentsSemesterInfo[$k]->tssi_semester == $j)) {
                                            $totalObtainedMarks += $allStudentsSemesterInfo[$k]->tssi_marks_obt;
                                            $totalMaxMarks += $allStudentsSemesterInfo[$k]->tssi_max_marks;
                                            array_push($sem_or_year_marks, $allStudentsSemesterInfo[$k]->tssi_marks_obt . "/" . $allStudentsSemesterInfo[$k]->tssi_max_marks);
                                            $ifFound = 1;
                                            break;
                                        }
                                    }
                                    if (!$ifFound) {
                                        array_push($sem_or_year_marks, "-");
                                    }
                                }
                                $thisArray = array(
                                    'tspi_id' => $studentsList[$i]->tspi_id,
                                    'tspi_rollNumber' => ($studentsList[$i]->tspi_rollNumber == $studentsList[$i]->tspi_form_no) ? "-" : "<a href='" . site_url("admin/Student/viewStudent/" . $studentsList[$i]->tspi_id) . "' target='_blank'>" . stripslashes($studentsList[$i]->tspi_rollNumber) . "</a>",
                                    'tspi_name' => "<a href='" . site_url("admin/Student/viewStudent/" . $studentsList[$i]->tspi_id) . "' target='_blank'>" . stripslashes($studentsList[$i]->tspi_name) . "</a>",
                                    'course_name' => stripslashes($studentsList[$i]->course_name),
                                    'session' => stripslashes($studentsList[$i]->session_name),
                                    'entry_type' => stripslashes($studentsList[$i]->tcsm_course_type),
                                    'tspi_status' => stripslashes($studentsList[$i]->status_text),
                                    'sem_year_marks' => $sem_or_year_marks,
                                    'grand_total' => ($totalMaxMarks == 0) ? "-" : $totalObtainedMarks . "/" . $totalMaxMarks,
                                    'percentage' => ($totalMaxMarks != 0) ? round((($totalObtainedMarks / $totalMaxMarks) * 100), 2) . "%" : "-"
                                );
                                array_push($filteredRecords, $thisArray);
                            }
                        } else {
                            $sem_or_year_marks = array();
                            for ($i = $sem_year_start_from; $i <= $courseInfo->course_no_of_sems; $i++) {
                                array_push($sem_or_year_marks, "-");
                            }
                            for ($i = 0; $i < sizeof($studentsList); $i++) {
                                $thisArray = array(
                                    'tspi_id' => $studentsList[$i]->tspi_id,
                                    'tspi_rollNumber' => ($studentsList[$i]->tspi_rollNumber == $studentsList[$i]->tspi_form_no) ? "-" : "<a href='" . site_url("admin/Student/viewStudent/" . $studentsList[$i]->tspi_id) . "' target='_blank'>" . stripslashes($studentsList[$i]->tspi_rollNumber) . "</a>",
                                    'tspi_name' => "<a href='" . site_url("admin/Student/viewStudent/" . $studentsList[$i]->tspi_id) . "' target='_blank'>" . stripslashes($studentsList[$i]->tspi_name) . "</a>",
                                    'course_name' => stripslashes($studentsList[$i]->course_name),
                                    'session' => stripslashes($studentsList[$i]->session_name),
                                    'entry_type' => stripslashes($studentsList[$i]->tcsm_course_type),
                                    'tspi_status' => stripslashes($studentsList[$i]->status_text),
                                    'sem_year_marks' => $sem_or_year_marks,
                                    'grand_total' => '-',
                                    'percentage' => '-',
                                );
                                array_push($filteredRecords, $thisArray);
                            }
                        }
                    }
                }
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['tableColumnFeeHeads'] = $colHeads;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/student/studentSemesterYearReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function studentScholarshipReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedAppliedForSession = trim($this->input->post("appliedForSession"));
                $selectedDeleteStatus = trim($this->input->post("schDeleteStatus"));
                $filteredRecords = $this->ScholarshipManagement->getStudentScholarshipReport($selectedCourse, $selectedSession, $selectedEntryType, $selectedAppliedForSession, $selectedDeleteStatus)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/student/studentScholarshipReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    /* Request Handlers For Staff & Related Reports */

    public function staffReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSubDept = "";
            $selectedDesig = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $empCodeId = trim($this->input->post("empCodeId"));
                $empFirstName = trim($this->input->post("empFirstName"));
                $empLastName = trim($this->input->post("empLastName"));
                $selectedEmpGender = trim($this->input->post("empGender"));
                $selectedDept = trim($this->input->post("empDept"));
                $selectedSubDept = trim($this->input->post("empSubDept"));
                $selectedDesigCat = trim($this->input->post("empDesigCat"));
                $selectedDesig = trim($this->input->post("empDesig"));
                $selectedUGCNETStatus = trim($this->input->post("empUGCNETStatus"));
                $selectedPHDStatus = trim($this->input->post("empPHDStatus"));
                $selectedAppntType = trim($this->input->post("empAppType"));
                $selectedStartDate = (trim($this->input->post("startDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("startDate")))));
                $selectedEndDate = (trim($this->input->post("endDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("endDate")))));
                $selectedRangeAppliedWith = (trim($this->input->post("dateRangeAppliedWith")) == "") ? "" : trim($this->input->post("dateRangeAppliedWith"));
                $filteredRecords = $this->StaffManagement->getStaffMiscellaneousReport($empCodeId, $empFirstName, $empLastName, $selectedEmpGender, $selectedDept, $selectedSubDept, $selectedDesigCat, $selectedDesig, $selectedUGCNETStatus, $selectedPHDStatus, $selectedAppntType, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result();
            $viewData['selectedSubDepartment'] = $selectedSubDept;
            $viewData['selectedDesignation'] = $selectedDesig;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/staff/staffReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function staffAchievementReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSubDept = "";
            $selectedDesig = "";
            $selectedEmp = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedDept = trim($this->input->post("empDept"));
                $selectedSubDept = trim($this->input->post("empSubDept"));
                $selectedDesigCat = trim($this->input->post("empDesigCat"));
                $selectedDesig = trim($this->input->post("empDesig"));
                $selectedSession = trim($this->input->post("session"));
                $selectedAchievementHead = (trim($this->input->post("achvHead")));
                $filteredRecords = $this->AchievementManagement->getStaffAchievementReport($selectedDept, $selectedSubDept, $selectedDesigCat, $selectedDesig, $selectedSession, $selectedAchievementHead)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result();
            $viewData['achievementHeads'] = $this->AchievementManagement->getNonDeletedActiveAchievementHeads('E')->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result();
            $viewData['selectedSubDepartment'] = $selectedSubDept;
            $viewData['selectedDesignation'] = $selectedDesig;
            $viewData['selectedEmployee'] = $selectedEmp;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/staff/staffAchievementReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    /* Request Handlers For Staff Reports */

    /* Request Handlers For Staff Leave Report */

    public function leaveReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedSubDept = "";
            $selectedDesig = "";
            $selectedEmployee = "";
            $filteredRecords = array();
            $leaveFilteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedSession = trim($this->input->post("appliedForSession"));
                $selectedLeaveType = trim($this->input->post("leaveType"));
                $selectedStatus = trim($this->input->post("leaveStatus"));
                $selectedStartDate = (trim($this->input->post("startDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("startDate")))));
                $selectedEndDate = (trim($this->input->post("endDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("endDate")))));
                $selectedRangeAppliedWith = trim($this->input->post("dateRangeAppliedWith"));
                $selectedDept = trim($this->input->post("empDept"));
                $selectedSubDept = trim($this->input->post("empSubDept"));
                $selectedDesigCat = trim($this->input->post("empDesigCat"));
                $selectedDesig = trim($this->input->post("empDesig"));
                $selectedGender = trim($this->input->post("empGender"));
                $selectedEmployee = trim($this->input->post("employee"));
                $leaveFilteredRecords = $this->LeaveManagement->getAppliedLeaveReport($selectedEmployee, $selectedDept, $selectedSubDept, $selectedDesigCat, $selectedDesig, $selectedGender, $selectedLeaveType, $selectedSession, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith, $selectedStatus)->result();
            }
            for ($i = 0; $i < sizeof($leaveFilteredRecords); $i++) {
                $adminActionBy = "-";
                if ($leaveFilteredRecords[$i]->slm_admin_updated_by != "" || $leaveFilteredRecords[$i]->slm_admin_updated_by != NULL) {
                    $adminInfo = $this->StaffManagement->getEmployeeInfoBy($leaveFilteredRecords[$i]->slm_admin_updated_by)->result()[0];
                    $adminActionBy = (stripslashes($adminInfo->tprfl_firstname . " " . $adminInfo->tprfl_lastname)) . " On " . date("d-m-Y h:i:s A", strtotime($leaveFilteredRecords[$i]->slm_admin_update_on));
                }
                array_push($filteredRecords, array(
                    'slm_id' => $leaveFilteredRecords[$i]->slm_id,
                    'smember_id' => $leaveFilteredRecords[$i]->smember_id,
                    'smember_code' => ($leaveFilteredRecords[$i]->smember_code == "") ? "-" : stripslashes($leaveFilteredRecords[$i]->smember_code),
                    'tprfl_firstname' => stripslashes($leaveFilteredRecords[$i]->tprfl_firstname),
                    'tprfl_lastname' => stripslashes($leaveFilteredRecords[$i]->tprfl_lastname),
                    'sub_dept_name' => stripslashes($leaveFilteredRecords[$i]->sub_dept_name),
                    'dept_name' => stripslashes($leaveFilteredRecords[$i]->dept_name),
                    'dcm_short_name' => stripslashes($leaveFilteredRecords[$i]->dcm_short_name),
                    'desig_name' => stripslashes($leaveFilteredRecords[$i]->desig_name),
                    'slm_from' => date("d-m-Y", strtotime($leaveFilteredRecords[$i]->slm_from)),
                    'slm_to' => date("d-m-Y", strtotime($leaveFilteredRecords[$i]->slm_to)),
                    'slm_no_of_days' => $leaveFilteredRecords[$i]->slm_no_of_days,
                    'tltm_name' => $leaveFilteredRecords[$i]->tltm_name,
                    'tltm_short_name' => $leaveFilteredRecords[$i]->tltm_short_name,
                    'slm_duration' => $leaveFilteredRecords[$i]->slm_duration,
                    'slm_status' => $leaveFilteredRecords[$i]->slm_status,
                    'slm_admin_remark_by' => $adminActionBy,
                    'slm_admin_remark_on' => ($leaveFilteredRecords[$i]->slm_admin_updated_by == "" || $leaveFilteredRecords[$i]->slm_admin_updated_by == NULL) ? "-" : date("d-m-Y h:i:s A", strtotime($leaveFilteredRecords[$i]->slm_admin_update_on)),
                    'slm_admin_remark' => ($leaveFilteredRecords[$i]->slm_admin_updated_by == "" || $leaveFilteredRecords[$i]->slm_admin_updated_by == NULL) ? "-" : stripslashes($leaveFilteredRecords[$i]->slm_admin_remarks),
                ));
            }
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result();
            $viewData['leaveTypes'] = $this->LeaveManagement->getNonDeletedActiveLeaveTypes()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedSubDepartment'] = $selectedSubDept;
            $viewData['selectedDesignation'] = $selectedDesig;
            $viewData['selectedEmployee'] = $selectedEmployee;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/leave/leaveReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    /* Request Handlers For Staff Leave Report */

    /* Request Handlers For Inventory & Payment Related Reports */

    public function pendingPayments() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['pendingPayments'] = $this->StockAndPurchaseManagement->pendingPaymentsReport()->result();
            $this->load->view('admin/reports/stockAndInventory/pendingPaymentsReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function issuedStock() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['purchaseHeads'] = $this->InventoryManagement->getNonDeletedActivePurchaseHeads()->result();
            $viewData['allPurchases'] = $this->StockAndPurchaseManagement->getAllPurchases()->result();
            $viewData['inventoryCategories'] = $this->InventoryManagement->getAllNonDeletedActiveInventoryCategories()->result();
            $viewData['allItems'] = $this->StockAndPurchaseManagement->getAllPurchaseItems()->result();
            $viewData['issuedStocks'] = $this->StockAndPurchaseManagement->issuedStocksReport()->result();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['locations'] = $this->LocationManagement->getNonDeletedActiveLocations()->result();
            $viewData['selectedSubDepartment'] = "";
            $viewData['selectedEmployee'] = "";
            $viewData['selectedAsset'] = "";
            if (isset($_POST['filterSubmitBtn'])) {
                $reqPurchaseHead = trim($this->input->post("pHead"));
                $reqInvoice = trim($this->input->post("invoice"));
                $reqDepartment = trim($this->input->post("dept"));
                $reqSubDepartment = trim($this->input->post("subDept"));
                $reqEmployee = trim($this->input->post('emp'));
                $reqInventoryCategory = trim($this->input->post("invCategory"));
                $reqAssetItem = trim($this->input->post("itemAssets"));
                $reqLocation = trim($this->input->post("location"));
                $reqStartDate = (trim($this->input->post("startIssueDate")) == "") ? "" : date("Y-m-d", strtotime(str_replace('/', '-', trim($this->input->post("startIssueDate")))));
                $reqEndDate = (trim($this->input->post("endIssueDate")) == "") ? "" : date("Y-m-d", strtotime(str_replace('/', '-', trim($this->input->post("endIssueDate")))));
                $reqUIDOrSrNo = trim($this->input->post("uidOrSrNo"));
                $viewData['selectedSubDepartment'] = $reqSubDepartment;
                $viewData['selectedEmployee'] = $reqEmployee;
                $viewData['issuedStocks'] = $this->StockAndPurchaseManagement->issuedStocksReport($reqUIDOrSrNo, $reqPurchaseHead, $reqInvoice, $reqDepartment, $reqSubDepartment, $reqEmployee, $reqInventoryCategory, $reqLocation, $reqAssetItem, $reqStartDate, $reqEndDate)->result();
                $this->load->view('admin/reports/stockAndInventory/issuedStockReport', $viewData);
            } else {
                $this->load->view('admin/reports/stockAndInventory/issuedStockReport', $viewData);
            }
        } else {
            redirect("admin/");
        }
    }

    public function stockVerificationReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['purchaseHeads'] = $this->InventoryManagement->getNonDeletedActivePurchaseHeads()->result();
            $viewData['allPurchases'] = $this->StockAndPurchaseManagement->getAllPurchases()->result();
            $viewData['inventoryCategories'] = $this->InventoryManagement->getAllNonDeletedActiveInventoryCategories()->result();
            $viewData['allItems'] = $this->StockAndPurchaseManagement->getAllPurchaseItems()->result();
            $viewData['verifiedStocks'] = array();
            $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result();
            $viewData['locations'] = $this->LocationManagement->getNonDeletedActiveLocations()->result();
            $viewData['verificationTitle'] = $this->StockAndPurchaseManagement->getNonDeletedActiveVerificationTitles()->result();
            $viewData['pageTitle'] = "Verified Stock/Item Report";
            $viewData['selectedSubDepartment'] = "";
            $viewData['selectedEmployee'] = "";
            if (isset($_POST['filterSubmitBtn'])) {
                $reqVerificationTitle = trim($this->input->post('verificationTitle'));
                if ($reqVerificationTitle != "") {
                    $reqPurchaseHead = trim($this->input->post("pHead"));
                    $reqInvoice = trim($this->input->post("invoice"));
                    $reqDepartment = trim($this->input->post("dept"));
                    $reqSubDepartment = trim($this->input->post("subDept"));
                    $reqEmployee = trim($this->input->post('emp'));
                    $reqInventoryCategory = trim($this->input->post("invCategory"));
                    $reqAssetItem = trim($this->input->post("itemAssets"));
                    $reqLocation = trim($this->input->post("location"));
                    $reqStartDate = (trim($this->input->post("startIssueDate")) == "") ? "" : date("Y-m-d", strtotime(str_replace('/', '-', trim($this->input->post("startIssueDate")))));
                    $reqEndDate = (trim($this->input->post("endIssueDate")) == "") ? "" : date("Y-m-d", strtotime(str_replace('/', '-', trim($this->input->post("endIssueDate")))));
                    $reqUIDOrSrNo = trim($this->input->post("uidOrSrNo"));
                    $viewData['selectedSubDepartment'] = $reqSubDepartment;
                    $viewData['selectedEmployee'] = $reqEmployee;
                    $viewData['pageTitle'] = stripslashes($this->StockAndPurchaseManagement->getVerificationTitleInfoBy($reqVerificationTitle)->result()[0]->svtm_name);
                    $viewData['verifiedStocks'] = $this->StockAndPurchaseManagement->verifiedStocksReport($reqVerificationTitle, $reqUIDOrSrNo, $reqPurchaseHead, $reqInvoice, $reqDepartment, $reqSubDepartment, $reqEmployee, $reqInventoryCategory, $reqLocation, $reqAssetItem, $reqStartDate, $reqEndDate)->result();
                    $this->session->set_flashdata('errorMessage', NULL);
                    $this->load->view('admin/reports/stockAndInventory/verifiedStockReport', $viewData);
                } else {
                    $this->session->set_flashdata('errorMessage', "Please Select Verification Title To Fetch Report.");
                    $this->load->view('admin/reports/stockAndInventory/verifiedStockReport', $viewData);
                }
            } else {
                $this->load->view('admin/reports/stockAndInventory/verifiedStockReport', $viewData);
            }
        } else {
            redirect("admin/");
        }
    }

    /* Request Handlers For Inventory & Payment Related Reports */

    /* Request Handlers For Attendance Related Report */

    public function attendanceReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $allotedCourse = $this->AllotmentManagement->getAllCourseAllotment($this->session->userdata("adminData")['smember_id'])->result();
            if (sizeof($allotedCourse)) {
                $viewData['courses'] = $allotedCourse;
            } else {
                $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            }
            $viewData["selectedCourse"] = "";
            $viewData["selectedSession"] = "";
            $viewData["selectedSemester"] = "";
            $viewData["selectedFrom"] = "";
            $viewData["selectedTo"] = "";
            $attendanceReportArray = array();
            if (isset($_POST["filterAttendanceBtn"])) {
                $session = $this->input->post("session");
                $course = $this->input->post("subjectCourse");
                $semester = $this->input->post("subjectCourseSemOrYear");
                $from = $this->input->post("from");
                $to = $this->input->post("to");
                $viewData["selectedCourse"] = $course;
                $viewData["selectedSession"] = $session;
                $viewData["selectedSemester"] = $semester;
                $viewData["selectedFrom"] = $from;
                $viewData["selectedTo"] = $to;
                $allDistinctAllottedSubjectToStudent = $this->SubjectManagement->getDistinctSubjectBy($semester, $course, $session)->result();
                $viewData["selectedCourseDetail"] = $this->CourseManagement->getCoursesBy($course)->result()[0];
                $viewData["selectedSessionDetails"] = $this->SessionManagement->getSessionInfoBy($session)->result()[0];
                if (sizeof($allDistinctAllottedSubjectToStudent)) {
                    $studentsSemesterWise = $this->StudentManagement->getAllEnrolledStudentsForSetAllotmentBy($course, $semester)->result();
                    for ($i = 0; $i < sizeof($studentsSemesterWise); $i++) {
                        $student = $studentsSemesterWise[$i];
                        $totalClassAttendedInSemester = 0;
                        $totalClassHeldInSemester = 0;
                        $subjectWiseAttendanceDetails = array();
                        for ($j = 0; $j < sizeof($allDistinctAllottedSubjectToStudent); $j++) {
                            $sub = $allDistinctAllottedSubjectToStudent[$j];
                            $teacherSubjectStudentAllotmentDetails = $this->SubjectManagement->getTeacherSubjectStudentAllotementDetailsBy($sub->sm_id, $student->tspi_id, $session)->result()[0];
                            $totalClasses = $this->AttendanceManagement->getTotalClasesCountBy($teacherSubjectStudentAllotmentDetails->sta_id, ($from == "" || $from == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $from))), ($to == "" || $to == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $to))))->result()[0];
                            $presentCount = $this->AttendanceManagement->getTotalAttendanceOfStudentBy($teacherSubjectStudentAllotmentDetails->stta_id, ($from == "" || $from == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $from))), ($to == "" || $to == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $to))))->result()[0];
                            $subjectWiseAttendanceArray = array(
                                'presentCount' => $presentCount->present_count,
                                'total_class_held' => $totalClasses->total_classes
                            );
                            array_push($subjectWiseAttendanceDetails, $subjectWiseAttendanceArray);
                            $totalClassAttendedInSemester = $totalClassAttendedInSemester + $presentCount->present_count;
                            $totalClassHeldInSemester = $totalClassHeldInSemester + $totalClasses->total_classes;
                        }
                        $studentData = array(
                            'tspi_name' => $student->tspi_name,
                            'tspi_rollNumber' => $student->tspi_enrollment_no,
                            'avgPercent' => ($totalClassHeldInSemester == 0 || $totalClassAttendedInSemester == 0) ? 0 : ceil(($totalClassAttendedInSemester / $totalClassHeldInSemester) * 100),
                            'subjectWiseAttendanceDetails' => $subjectWiseAttendanceDetails
                        );

                        array_push($attendanceReportArray, $studentData);
                    }
                }
                $viewData["subjects"] = $allDistinctAllottedSubjectToStudent;
                $viewData["attendanceData"] = $attendanceReportArray;
                $this->load->view("admin/reports/academics/attendanceReport", $viewData);
            } else {
                $viewData["selectedCourseDetail"] = "";
                $viewData["selectedSessionDetails"] = "";
                $viewData["attendanceData"] = array();
                $viewData["subjects"] = array();
                $this->load->view("admin/reports/academics/attendanceReport", $viewData);
            }
        } else {
            redirect("admin/");
        }
    }

    /* Request Hanlders For Fee Related Reports */

    public function miscellaneousFeeReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $reqFormEnrlRoll = trim($this->input->post("stuFormEnrlRoll"));
                $reqReceiptNo = trim($this->input->post("receiptNo"));
                $selectedMode = trim($this->input->post("paymentMode"));
                $selectedFeeHead = trim($this->input->post("feeHead"));
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedCollectedForSession = trim($this->input->post("collectionForSession"));
                $selectedOperator = trim($this->input->post("stuEntryOprtr"));
                $selectedStartDate = (trim($this->input->post("entryStartDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("entryStartDate")))));
                $selectedEndDate = (trim($this->input->post("entryEndDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("entryEndDate")))));
                $selectedRangeAppliedWith = (trim($this->input->post("entryDateRangeAppliedWith")) == "") ? "" : trim($this->input->post("entryDateRangeAppliedWith"));
                $filteredRecords = $this->FeeManagement->getMiscellaneousFeeReport($reqReceiptNo, $reqFormEnrlRoll, $selectedMode, $selectedFeeHead, $selectedCourse, $selectedSession, $selectedEntryType, $selectedCollectedForSession, $selectedOperator, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['feeHeads'] = $this->FeeManagement->getNonDeletedFeeHeads()->result();
            $viewData['feeModes'] = $this->FeeManagement->getNonDeletedActiveFeeModes()->result();
            $viewData['operators'] = $this->StaffManagement->getAllDistinctFeeEntryOperators()->result();
            $viewData['collectionSessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C', 'N'))->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/fee/feeMiscellaneousReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function miscellaneousDefaulterReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedPattern = "";
            $selectedSession = "";
            $selectedEntryType = "";
            $selectedSemester = "";
            $filteredRecords = array();
            $colHeads = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedSemester = trim($this->input->post("stuSemester"));
                $reqFormEnrlRoll = trim($this->input->post("stuFormEnrlRoll"));
                $selectedFeeHead = trim($this->input->post("feeHead"));
                if ($selectedCourse == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Any Course.");
                } else if ($selectedSession == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Any Session.");
                } else if ($selectedEntryType == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Any Entry Type.");
                } else if ($selectedSemester == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Any Semester/Year.");
                } else {
                    $this->session->set_flashdata('errorMessage', NULL);
                    if ($selectedFeeHead != "") {
                        $applicableStructureForHeads = $this->FeeManagement->getFeeStructureInfoBy($selectedFeeHead, $selectedSession, $selectedEntryType, $selectedSemester)->result();
                    } else {
                        $applicableStructureForHeads = $this->FeeManagement->getFeeStructureForFeePaymentBy($selectedSession, $selectedEntryType, $selectedSemester)->result();
                    }
                    for ($head = 0; $head < sizeof($applicableStructureForHeads); $head++) {
                        array_push($colHeads, stripslashes($applicableStructureForHeads[$head]->fhm_name));
                    }
                    $enrolledStudentInCourse = $this->StudentManagement->getEnrolledStudentPersonalInfoByCourseSessionAndEntryType($selectedCourse, $selectedSession, $selectedEntryType, $reqFormEnrlRoll)->result();
                    for ($i = 0; $i < sizeof($enrolledStudentInCourse); $i++) {
                        $dueFeeDetails = array();
                        $isCounsellingFeeAdjusted = FALSE;
                        /* Getting Student Wise Structure */
                        if ($selectedFeeHead != "") {
                            $applicableStructure = $this->FeeManagement->getFeeStructureDetailsOfStudentBy($enrolledStudentInCourse[$i]->tspi_id, $selectedFeeHead, $selectedSession, $selectedEntryType, $selectedSemester)->result();
                        } else {
                            $applicableStructure = $this->FeeManagement->getFeeStructureOfStudentForFeePaymentBy($enrolledStudentInCourse[$i]->tspi_id, $selectedSession, $selectedEntryType, $selectedSemester)->result();
                        }
                        /* Getting Student Wise Structure */
                        if (sizeof($applicableStructure)) {
                            $cousellingFeeInfo = $this->FeeManagement->getPaidCouncellingFeeDetailsByStudent($enrolledStudentInCourse[$i]->tspi_id)->result();
                            for ($j = 0; $j < sizeof($applicableStructure); $j++) {
                                $paidFeeDetails = $this->FeeManagement->getPaidFeeDetailsByStructure($enrolledStudentInCourse[$i]->tspi_id, $selectedSemester, $applicableStructure[$j]->fssm_id)->result();
                                if (sizeof($paidFeeDetails)) {
                                    $paidAmount = 0.0;
                                    for ($k = 0; $k < sizeof($paidFeeDetails); $k++) {
                                        $paidAmount += $paidFeeDetails[$k]->fcm_amount;
                                    }
                                    if (sizeof($cousellingFeeInfo) && ($isCounsellingFeeAdjusted == FALSE)) {
                                        if ($applicableStructure[$j]->fhm_type == "R") {
                                            array_push($dueFeeDetails, array(
                                                'fee_head' => stripslashes($applicableStructure[$j]->fhm_name),
                                                'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-",
                                                'paid_amount' => "<i class='fa fa-inr'></i>" . $paidAmount . "/- + <i class='fa fa-inr'></i>" . $cousellingFeeInfo[0]->fcnm_amount . "/- (C.F.)",
                                                'due_amount' => "<i class='fa fa-inr'></i>" . round((($applicableStructure[$j]->fssm_amount) - $paidAmount), 2) . "/-"
                                            ));
                                            $isCounsellingFeeAdjusted = TRUE;
                                        } else {
                                            array_push($dueFeeDetails, array(
                                                'fee_head' => stripslashes($applicableStructure[$j]->fhm_name),
                                                'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-",
                                                'paid_amount' => "<i class='fa fa-inr'></i>" . $paidAmount . "/-",
                                                'due_amount' => "<i class='fa fa-inr'></i>" . round((($applicableStructure[$j]->fssm_amount) - $paidAmount), 2) . "/-"
                                            ));
                                        }
                                    } else {
                                        array_push($dueFeeDetails, array(
                                            'fee_head' => stripslashes($applicableStructure[$j]->fhm_name),
                                            'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-",
                                            'paid_amount' => "<i class='fa fa-inr'></i>" . $paidAmount . "/-",
                                            'due_amount' => "<i class='fa fa-inr'></i>" . round((($applicableStructure[$j]->fssm_amount) - $paidAmount), 2) . "/-"
                                        ));
                                    }
                                } else {
                                    if (sizeof($cousellingFeeInfo) && ($isCounsellingFeeAdjusted == FALSE)) {
                                        if ($applicableStructure[$j]->fhm_type == "R") {
                                            array_push($dueFeeDetails, array(
                                                'fee_head' => stripslashes($applicableStructure[$j]->fhm_name),
                                                'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-",
                                                'paid_amount' => "<i class='fa fa-inr'></i>" . $cousellingFeeInfo[0]->fcnm_amount . "/- (C.F.)",
                                                'due_amount' => "<i class='fa fa-inr'></i>" . round((($applicableStructure[$j]->fssm_amount) - $cousellingFeeInfo[0]->fcnm_amount), 2) . "/-"
                                            ));
                                            $isCounsellingFeeAdjusted = TRUE;
                                        } else {
                                            array_push($dueFeeDetails, array(
                                                'fee_head' => stripslashes($applicableStructure[$j]->fhm_name),
                                                'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-",
                                                'paid_amount' => "<i class='fa fa-inr'></i>" . 0.0 . "/-",
                                                'due_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-"
                                            ));
                                        }
                                    } else {
                                        array_push($dueFeeDetails, array(
                                            'fee_head' => stripslashes($applicableStructure[$j]->fhm_name),
                                            'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-",
                                            'paid_amount' => "<i class='fa fa-inr'></i>" . 0.0 . "/-",
                                            'due_amount' => "<i class='fa fa-inr'></i>" . $applicableStructure[$j]->fssm_amount . "/-"
                                        ));
                                    }
                                }
                            }
                        } else {
                            for ($j = 0; $j < sizeof($applicableStructureForHeads); $j++) {
                                array_push($dueFeeDetails, array(
                                    'fee_head' => stripslashes($applicableStructureForHeads[$j]->fhm_name),
                                    'app_amount' => "<i class='fa fa-inr'></i>" . $applicableStructureForHeads[$j]->fsm_amount . "/-",
                                    'paid_amount' => "<i class='fa fa-inr'></i>" . 0.0 . "/-",
                                    'due_amount' => "<i class='fa fa-inr'></i>" . $applicableStructureForHeads[$j]->fsm_amount . "/-"
                                ));
                            }
                        }
                        $stuFatherName = $this->StudentManagement->getStudentFatherInfoBy($enrolledStudentInCourse[$i]->tspi_id)->result()[0]->tfbi_name;
                        array_push($filteredRecords, array(
                            'stu_id' => $enrolledStudentInCourse[$i]->tspi_id,
                            'stu_form_no' => "<a href='" . site_url("admin/Student/viewStudent/" . $enrolledStudentInCourse[$i]->tspi_id) . "' target='_blank'>" . stripslashes($enrolledStudentInCourse[$i]->tspi_form_no) . "</a>",
                            'stu_enroll_no' => ($enrolledStudentInCourse[$i]->tspi_enrollment_no == $enrolledStudentInCourse[$i]->tspi_form_no) ? "-" : "<a href='" . site_url("admin/Student/viewStudent/" . $enrolledStudentInCourse[$i]->tspi_id) . "' target='_blank'>" . stripslashes($enrolledStudentInCourse[$i]->tspi_enrollment_no) . "</a>",
                            'stu_roll_no' => ($enrolledStudentInCourse[$i]->tspi_rollNumber == $enrolledStudentInCourse[$i]->tspi_form_no) ? "-" : "<a href='" . site_url("admin/Student/viewStudent/" . $enrolledStudentInCourse[$i]->tspi_id) . "' target='_blank'>" . stripslashes($enrolledStudentInCourse[$i]->tspi_rollNumber) . "</a>",
                            'stu_name' => "<a href='" . site_url("admin/Student/viewStudent/" . $enrolledStudentInCourse[$i]->tspi_id) . "' target='_blank'>" . stripslashes($enrolledStudentInCourse[$i]->tspi_name) . "</a>",
                            'stu_father_name' => stripslashes($stuFatherName),
                            'stu_course' => stripslashes($enrolledStudentInCourse[$i]->course_name),
                            'stu_session' => stripslashes($enrolledStudentInCourse[$i]->session_name),
                            'stu_entry_type' => stripslashes($enrolledStudentInCourse[$i]->tcsm_course_type),
                            'fee_due_for' => ($enrolledStudentInCourse[$i]->course_time_mgmt_flag == 'Y') ? $selectedSemester . " Year" : $selectedSemester . " Sem.",
                            'due_fee_details' => $dueFeeDetails
                        ));
                    }
                }
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['feeHeads'] = $this->FeeManagement->getNonDeletedFeeHeads()->result();
            $viewData['tableColumnFeeHeads'] = $colHeads;
            $viewData['selectedPattern'] = $selectedPattern;
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['selectedSemester'] = $selectedSemester;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/fee/feeMiscellaneousDefaulterReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function feeReimbursementReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCollectedForSession = trim($this->input->post("collectionForSession"));
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedReceiptStatus = trim($this->input->post("frmStatus"));
                $selectedRmbStatus = trim($this->input->post("rmbStatus"));
                $filteredRecords = $this->FeeManagement->getReimbursementCounsellingFeeReport($selectedCollectedForSession, $selectedCourse, $selectedReceiptStatus, $selectedRmbStatus)->result();
            }
            $viewData['collectionSessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C', 'N'))->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/fee/feeReimbursementReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    /* Request Handlers For Hostel Fee Reports And Related Stuffs */

    public function miscellaneousHostelFeeReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $reqFormEnrlRoll = trim($this->input->post("stuFormEnrlRoll"));
                $reqReceiptNo = trim($this->input->post("receiptNo"));
                $selectedMode = trim($this->input->post("paymentMode"));
                $selectedFeeHead = trim($this->input->post("feeHead"));
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedCollectedForSession = trim($this->input->post("collectionForSession"));
                $selectedOperator = trim($this->input->post("stuEntryOprtr"));
                $selectedStartDate = (trim($this->input->post("entryStartDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("entryStartDate")))));
                $selectedEndDate = (trim($this->input->post("entryEndDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("entryEndDate")))));
                $selectedRangeAppliedWith = (trim($this->input->post("entryDateRangeAppliedWith")) == "") ? "" : trim($this->input->post("entryDateRangeAppliedWith"));
                $filteredRecords = $this->FeeManagement->getMiscellaneousHostelFeeReport($reqReceiptNo, $reqFormEnrlRoll, $selectedMode, $selectedFeeHead, $selectedCourse, $selectedSession, $selectedEntryType, $selectedCollectedForSession, $selectedOperator, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['feeHeads'] = $this->FeeManagement->getNonDeletedOptionalFeeHeadsBy('H')->result();
            $viewData['feeModes'] = $this->FeeManagement->getNonDeletedActiveFeeModes()->result();
            $viewData['operators'] = $this->StaffManagement->getAllDistinctFeeEntryOperators()->result();
            $viewData['collectionSessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C', 'N'))->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/fee/feeMiscellaneousHostelReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function miscellaneousHostelFeeDefaulterReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $selectedPattern = "";
            $selectedSession = "";
            $selectedEntryType = "";
            $selectedSemester = "";
            $filteredRecords = array();
            $colHeads = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post("stuCourse"));
                $selectedSession = trim($this->input->post("stuSession"));
                $selectedEntryType = trim($this->input->post("stuEntryType"));
                $selectedSemester = trim($this->input->post("stuSemester"));
                $reqFormEnrlRoll = trim($this->input->post("stuFormEnrlRoll"));
                $selectedFeeHead = trim($this->input->post("feeHead"));
                $filteredRecords = $this->FeeManagement->getHostelFeeDefaulterLIst($reqFormEnrlRoll, $selectedFeeHead, $selectedEntryType, $selectedSession, $selectedCourse)->result();
            }

            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['feeHeads'] = $this->FeeManagement->getNonDeletedOptionalFeeHeadsBy('H')->result();
            $viewData['tableColumnFeeHeads'] = $colHeads;
            $viewData['selectedPattern'] = $selectedPattern;
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['selectedSemester'] = $selectedSemester;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/fee/feeMiscellaneousHostelDefaulterReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    /* Request Hanlders For Course Profile Report & Related Stuffs */

    public function courseProfileReport() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $selectedSession = "";
            $selectedEntryType = "";
            $selectedSemOrYear = "";
            $filteredRecords = array();
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedCourse = trim($this->input->post('course'));
                $selectedSession = trim($this->input->post('session'));
                $selectedEntryType = trim($this->input->post('entryType'));
                $selectedSemOrYear = trim($this->input->post('semOrYear'));
                $filteredRecords = $this->CourseManagement->getCourseProfilesReport($selectedCourse, $selectedSession, $selectedEntryType, $selectedSemOrYear)->result();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedEntryType'] = $selectedEntryType;
            $viewData['selectedSemOrYear'] = $selectedSemOrYear;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/reports/academics/viewCourseProfiles', $viewData);
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023