<?php
namespace App\Controllers;
SESSION_START();
use \Core\View;
use \Core\Inputs;
use \Core\Userlog;
use \Core\Menu;
use \Core\Form;
use App\Models\Homem;
use App\Email\Emails;
use App\Controllers\Extra;
class Sreports extends \Core\Controller
{
    public static function newadmissions()
    {
        $_SESSION["org_id"] = 1;
        $data = Homem::getdata("SELECT um.id, um.ano, um.no, um.name, um.fk_course_id, um.fk_dept_id, sn.feeamount AS fee1, sf.feeamount AS fee2, COALESCE(SUM(DISTINCT snf.amount), 0) AS paid1, COALESCE(SUM(DISTINCT snfee.amount), 0) AS paid2 FROM user_master um JOIN stdnt_feemaster sn ON um.id = sn.no AND sn.fk_feetype_id = 1 AND sn.year = 1 JOIN stdnt_feemaster sf ON um.id = sf.no AND sf.fk_feetype_id = 2 AND sf.year = 1 LEFT JOIN stdnt_normalfee snf ON um.id = snf.no AND snf.fk_feetype_id = 1 AND snf.year = 1 LEFT JOIN stdnt_normalfee snfee ON um.id = snfee.no AND snfee.fk_feetype_id = 2 AND snfee.year = 1 WHERE um.fk_course_id <> 4 AND um.fromyear = 2025 GROUP BY um.id, um.no, um.name, sn.feeamount, sf.feeamount ORDER BY um.id;");
        $a = '<table border="1px">';
        for($i=0; $i<sizeof($data); $i++)
        {
            $a .= '<tr>';
            $a .= '<td>'.$data[$i]["id"].'</td>';
            $a .= '<td>'.$data[$i]["no"].'</td>';
            $a .= '<td>'.$data[$i]["name"].'</td>';
            $a .= '<td>'.static::course($data[$i]["fk_course_id"]).'</td>';
            $a .= '<td>'.static::dept($data[$i]["fk_dept_id"]).'</td>';
            $a .= '<td>'.$data[$i]["fee1"].'</td>';
            $a .= '<td>'.$data[$i]["fee2"].'</td>';
            $a .= '<td>'.$data[$i]["paid1"].'</td>';
            $a .= '<td>'.$data[$i]["paid2"].'</td>';
            $a .= '</tr>';
        }
        $a .= '</table>';
        echo $a;
    }
    public static function image()
    {
        echo '
        <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/css/style.css">
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/sweetalert2/dist/sweetalert2.min.css" >
        ';
    }
    public static function test()
    {
        $_SESSION["org_id"] = 1;
        $query = "SELECT u.name, o.no FROM hinduengg_hindu_main_unaided.user_master AS u JOIN hinduengg_hindu_engg.user_master AS o ON u.id = o.id WHERE u.id='1';";
        $data = Homem::getdata($query);
        print_r($data);
    }
    public static function tablecount()
    {
        for($i=1; $i<6; $i++)
        {
            if($i!=2)
            {
                $_SESSION["org_id"] = $i;
                $dbname = static::dbname($i);
                $query = "SHOW TABLES FROM ".$dbname;
                $tables = Homem::getdata($query);
                $keys = array_keys($tables);
                // print_r($keys);
            }
        }
        // SHOW COLUMNS FROM stdnt_normalfee;
    }
    public static function dbname($id)
    {
        if($id == 1)
        {
            return "hinduengg_hindu_main_unaided";
        }
        if($id == 3)
        {
            return "hinduengg_hindu_engg";
        }
        if($id == 4)
        {
            return "hinduengg_hindu_mca";
        }
        if($id == 5)
        {
            return "hinduengg_hindu_management";
        }
    }
    public static function balaramreport()
    {
        echo '<form action="#" method="POST">
            <input type="date" name="date" id="date">
            <input type="text" name="year" id="year">
            <input type="submit">
        </form>';
        if(isset($_POST['date']))
        {
            $date=$_POST['date'];
        }
        else
        {
            $date=date('Y-m-d');
            
        }
        echo $date;
        // $date='2022-03-01';
        if(isset($_POST['year']))
        {
            $years = $_POST['year'];
        }
        else
        {
            $month = date('m');
            if($month > 8)
            {
                $years = date('Y')-1;
            }
            else
            {
                $years = date('Y')-1;
            }
        }
        echo '<table border="1px"><thead><tr><th>Org</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
        for($i=1; $i<=5; $i++)
        {
            if($i!=2)
            {
                $_SESSION['org_id'] = $i;
                $org_id = $i;
                $cdata = Homem::getdata("SELECT ddr.course_id as course, ddr.dept_id as dept, ddm.aided FROM `degree_dept_relation` ddr JOIN degree_dept_master ddm ON ddr.dept_id=ddm.id");
                $syear = 0;
                for($b=$years; $b>$years-7; $b--)
                {
                    // $syear++;
                    $syear = 4;
                    $year = $b;
                    for($a=0; $a<sizeof($cdata); $a++)
                    {
                        $course = $cdata[$a]['course'];
                        $dept = $cdata[$a]['dept'];
                        $aided = $cdata[$a]['aided'];
                        $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `user_role`='3' AND `toyear`='$year' AND `discontinued`!='1' AND `tc_given`!='1'");
                        $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.user_role='3' AND um.toyear='$year' AND sf.year<='$syear' AND um.discontinued!='1' AND um.tc_given!='1'");
                        $actual = $actualfee[0]['amount'];
                        if($actual == ''){$actual=0;}
                        $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.user_role='3' AND um.toyear='$year' AND sf.year<='$syear' AND um.discontinued!='1' AND um.tc_given!='1'");// AND sf.paid_date<'$date'
                        // $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                        // $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear'");
                        // $actual = $actualfee[0]['amount'];
                        // if($actual == ''){$actual=0;}
                        // $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear' AND sf.paid_date<'$date'");
                        // $paid = $paidfee[0]['amount'];
                        $paid = $paidfee[0]['amount'];
                        if($paid == ''){$paid=0;}
                        $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                        $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                        $due = $actual-$paid;
                        echo '<tr>';
                        echo '<td>'.static::org($org_id).'</td>';
                        echo '<td>'.static::course($course).'</td>';
                        echo '<td>'.static::dept($dept).'</td>';
                        echo '<td>'.$aided.'</td>';
                        echo '<td>'.$year.'</td>';
                        echo '<td>'.$syear.'</td>';
                        echo '<td>'.$studcount[0]['count'].'</td>';
                        echo '<td>'.$actual.'</td>';
                        echo '<td>'.$paid.'</td>';
                        echo '<td>'.$due.'</td>';
                        echo '</tr>';
                        
                    }
                }
            }
            
        }
        echo '</tbody></table>';
        
        
        
        //SELECT SUM(column_name) FROM table_name WHERE condition;
    }
    public static function balaramreportlatest()
    {
        echo '<form action="#" method="POST">
            <input type="date" name="date" id="date">
            <input type="text" name="year" id="year">
            <input type="submit">
        </form>';
        if(isset($_POST['date']))
        {
            $date=$_POST['date'];
        }
        else
        {
            $date=date('Y-m-d');
            
        }
        echo $date;
        // $date='2022-03-01';
        if(isset($_POST['year']))
        {
            $years = $_POST['year'];
        }
        else
        {
            $month = date('m');
            if($month > 8)
            {
                $years = date('Y')-1;
            }
            else
            {
                $years = date('Y')-1;
            }
        }
        echo '<table border="1px"><thead><tr><th>Org</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
        for($i=1; $i<=5; $i++)
        {
            if($i!=2)
            {
                $_SESSION['org_id'] = $i;
                $org_id = $i;
                $cdata = Homem::getdata("SELECT ddr.course_id as course, ddr.dept_id as dept, ddm.aided FROM `degree_dept_relation` ddr JOIN degree_dept_master ddm ON ddr.dept_id=ddm.id");
                $syear = 0;
                for($b=$years; $b>$years-7; $b--)
                {
                    // $syear++;
                    $syear = 4;
                    $year = $b;
                    for($a=0; $a<sizeof($cdata); $a++)
                    {
                        $course = $cdata[$a]['course'];
                        $dept = $cdata[$a]['dept'];
                        $aided = $cdata[$a]['aided'];
                        $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `user_role`='3' AND `toyear`='$year'");
                        $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.user_role='3' AND um.toyear='$year' AND sf.year<='$syear'");
                        $actual = $actualfee[0]['amount'];
                        if($actual == ''){$actual=0;}
                        $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.user_role='3' AND um.toyear='$year' AND sf.year<='$syear'");// AND sf.paid_date<'$date'
                        // $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                        // $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear'");
                        // $actual = $actualfee[0]['amount'];
                        // if($actual == ''){$actual=0;}
                        // $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear' AND sf.paid_date<'$date'");
                        // $paid = $paidfee[0]['amount'];
                        $paid = $paidfee[0]['amount'];
                        if($paid == ''){$paid=0;}
                        $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                        $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                        $due = $actual-$paid;
                        echo '<tr>';
                        echo '<td>'.static::org($org_id).'</td>';
                        echo '<td>'.static::course($course).'</td>';
                        echo '<td>'.static::dept($dept).'</td>';
                        echo '<td>'.$aided.'</td>';
                        echo '<td>'.$year.'</td>';
                        echo '<td>'.$syear.'</td>';
                        echo '<td>'.$studcount[0]['count'].'</td>';
                        echo '<td>'.$actual.'</td>';
                        echo '<td>'.$paid.'</td>';
                        echo '<td>'.$due.'</td>';
                        echo '</tr>';
                        
                    }
                }
            }
            
        }
        echo '</tbody></table>';
        
        
        
        //SELECT SUM(column_name) FROM table_name WHERE condition;
    }
    public static function balaram()
    {
        $year = 2022;
        $lyear = $year-6;
        $date1 = '1900-04-01';
        $date2 = date('Y-m-d');
        $_SESSION['org_id'] = 4;
        $sdata = Homem::getdata("SELECT um.id, um.no, um.name, um.fk_course_id, um.fk_dept_id, um.fromyear, um.toyear, ddm.aided FROM user_master um JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id where um.fromyear>='2000' AND um.toyear<='2024' AND um.user_role='3'");
        
        for($i=$lyear; $i<=$year; $i++)
        {
            $t = $year-$i+1;
            $t = 4;
            $adata = Homem::getdata("SELECT DISTINCT sf.no as id, um.no, SUM(sf.feeamount) as fee FROM user_master um JOIN stdnt_feemaster sf ON um.id=sf.no WHERE um.fromyear='$i' AND year<='$t' GROUP BY sf.no ORDER BY sf.no ASC");
            $pdata = Homem::getdata("SELECT DISTINCT sf.no as id, um.no, SUM(sf.amount) as fee FROM user_master um JOIN stdnt_normalfee sf ON um.id=sf.no WHERE um.fromyear='$i' AND sf.year<='$t' AND DATE(sf.entry_date) BETWEEN '$date1' AND '$date2' GROUP BY sf.no ORDER BY sf.no ASC");
        
            for($j=0; $j<sizeof($sdata); $j++)
            {
                if($sdata[$j]["fromyear"] == $i)
                {
                    $sdata[$j]["pyear"] = $t;
                }
                for($a=0; $a<sizeof($adata); $a++)
                {
                    if($sdata[$j]["id"] == $adata[$a]["id"] && $sdata[$j]["no"] == $adata[$a]["no"])
                    {
                        $sdata[$j]["actual"] = $adata[$a]["fee"];
                    }
                }
                for($a=0; $a<sizeof($pdata); $a++)
                {
                    if($sdata[$j]["id"] == $pdata[$a]["id"] && $sdata[$j]["no"] == $pdata[$a]["no"])
                    {
                        $sdata[$j]["paid"] = $pdata[$a]["fee"];
                    }
                }
            }
        }
        $a = '<table border="1px">';
        $a .= '<thead><tr><td>id</td><td>no</td><td>name</td><td>course</td><td>Dept.</td><td>Aided</td><td>From Year</td><td>To Year</td><td>Present year</td><td>Actual</td><td>Paid</td></tr></thead>';
        for($i=0; $i<sizeof($sdata); $i++)
        {
            $a .= '<tr>';
            $a .= '<td>'.$sdata[$i]["id"].'</td>';
            $a .= '<td>'.$sdata[$i]["no"].'</td>';
            $a .= '<td>'.$sdata[$i]["name"].'</td>';
            $a .= '<td>'.static::course($sdata[$i]["fk_course_id"]).'</td>';
            $a .= '<td>'.static::dept($sdata[$i]["fk_dept_id"]).'</td>';
            $a .= '<td>'.$sdata[$i]["aided"].'</td>';
            $a .= '<td>'.$sdata[$i]["fromyear"].'</td>';
            $a .= '<td>'.$sdata[$i]["toyear"].'</td>';
            if(isset($sdata[$i]["pyear"]))
            {
                $a .= '<td>'.$sdata[$i]["pyear"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            if(isset($sdata[$i]["actual"]))
            {
            $a .= '<td>'.$sdata[$i]["actual"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            if(isset($sdata[$i]["paid"]))
            {
            $a .= '<td>'.$sdata[$i]["paid"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            $a .= '</tr>';
        }
        $a .= '</table>';
        echo $a;
    }
    public static function chakravarthysirold()
    {
        $year = 2022;
        $lyear = $year-6;
        $date1 = '1900-04-01';
        $date2 = '2024-03-31';
        $_SESSION['org_id'] = 1;
        $sdata = Homem::getdata("SELECT um.id, um.no, um.name, um.fk_course_id, um.fk_dept_id, um.fromyear, ddm.aided FROM user_master um JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id where um.fromyear>='2016' AND um.fromyear<='2023' AND um.user_role='3'");
        
        for($i=$lyear; $i<=$year; $i++)
        {
            $t = $year-$i+1;
            $t =4;
            $adata = Homem::getdata("SELECT DISTINCT sf.no as id, um.no, SUM(sf.feeamount) as fee FROM user_master um JOIN stdnt_feemaster sf ON um.id=sf.no WHERE um.fromyear='$i' AND year<='$t' GROUP BY sf.no ORDER BY sf.no ASC");
            $pdata = Homem::getdata("SELECT DISTINCT sf.no as id, um.no, SUM(sf.amount) as fee FROM user_master um JOIN stdnt_normalfee sf ON um.id=sf.no WHERE um.fromyear='$i' AND sf.year<='$t' AND DATE(sf.entry_date) BETWEEN '$date1' AND '$date2' GROUP BY sf.no ORDER BY sf.no ASC");
        
            for($j=0; $j<sizeof($sdata); $j++)
            {
                if($sdata[$j]["fromyear"] == $i)
                {
                    $sdata[$j]["pyear"] = $t;
                }
                for($a=0; $a<sizeof($adata); $a++)
                {
                    if($sdata[$j]["id"] == $adata[$a]["id"] && $sdata[$j]["no"] == $adata[$a]["no"])
                    {
                        $sdata[$j]["actual"] = $adata[$a]["fee"];
                    }
                }
                for($a=0; $a<sizeof($pdata); $a++)
                {
                    if($sdata[$j]["id"] == $pdata[$a]["id"] && $sdata[$j]["no"] == $pdata[$a]["no"])
                    {
                        $sdata[$j]["paid"] = $pdata[$a]["fee"];
                    }
                }
            }
        }
        $a = '<table border="1px">';
        $a .= '<thead><tr><td>id</td><td>no</td><td>name</td><td>course</td><td>Dept.</td><td>Aided</td><td>From Year</td><td>Present year</td><td>Actual</td><td>Paid</td></tr></thead>';
        for($i=0; $i<sizeof($sdata); $i++)
        {
            $a .= '<tr>';
            $a .= '<td>'.$sdata[$i]["id"].'</td>';
            $a .= '<td>'.$sdata[$i]["no"].'</td>';
            $a .= '<td>'.$sdata[$i]["name"].'</td>';
            $a .= '<td>'.static::course($sdata[$i]["fk_course_id"]).'</td>';
            $a .= '<td>'.static::dept($sdata[$i]["fk_dept_id"]).'</td>';
            $a .= '<td>'.$sdata[$i]["aided"].'</td>';
            $a .= '<td>'.$sdata[$i]["fromyear"].'</td>';
            if(isset($sdata[$i]["pyear"]))
            {
                $a .= '<td>'.$sdata[$i]["pyear"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            if(isset($sdata[$i]["actual"]))
            {
            $a .= '<td>'.$sdata[$i]["actual"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            if(isset($sdata[$i]["paid"]))
            {
            $a .= '<td>'.$sdata[$i]["paid"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            $a .= '</tr>';
        }
        $a .= '</table>';
        echo $a;
    }
    public static function chakravarthysir()
    {
        $year = 2023;
        $lyear = $year-3;
        $date1 = '2021-04-01';
        $date2 = '2024-03-31';
        $_SESSION['org_id'] = 5;
        $sdata = Homem::getdata("SELECT um.id, um.no, um.name, um.fk_course_id, um.fk_dept_id, um.fromyear, ddm.aided FROM user_master um JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id where um.fromyear>='2020' AND um.fromyear<='2023' AND um.user_role='3'");
        
        for($i=$lyear; $i<=$year; $i++)
        {
            $t = $year-$i+1;
            $adata = Homem::getdata("SELECT DISTINCT sf.no as id, um.no, SUM(sf.feeamount) as fee FROM user_master um JOIN stdnt_feemaster sf ON um.id=sf.no WHERE um.fromyear='$i' AND year='$t' GROUP BY sf.no ORDER BY sf.no ASC");
            $pdata = Homem::getdata("SELECT DISTINCT sf.no as id, um.no, SUM(sf.amount) as fee FROM user_master um JOIN stdnt_normalfee sf ON um.id=sf.no WHERE um.fromyear='$i' AND sf.year='$t' AND DATE(sf.entry_date) BETWEEN '$date1' AND '$date2' GROUP BY sf.no ORDER BY sf.no ASC");
        
            for($j=0; $j<sizeof($sdata); $j++)
            {
                if($sdata[$j]["fromyear"] == $i)
                {
                    $sdata[$j]["pyear"] = $t;
                }
                for($a=0; $a<sizeof($adata); $a++)
                {
                    if($sdata[$j]["id"] == $adata[$a]["id"] && $sdata[$j]["no"] == $adata[$a]["no"])
                    {
                        $sdata[$j]["actual"] = $adata[$a]["fee"];
                    }
                }
                for($a=0; $a<sizeof($pdata); $a++)
                {
                    if($sdata[$j]["id"] == $pdata[$a]["id"] && $sdata[$j]["no"] == $pdata[$a]["no"])
                    {
                        $sdata[$j]["paid"] = $pdata[$a]["fee"];
                    }
                }
            }
        }
        $a = '<table border="1px">';
        $a .= '<thead><tr><td>id</td><td>no</td><td>name</td><td>course</td><td>Dept.</td><td>Aided</td><td>From Year</td><td>Present year</td><td>Actual</td><td>Paid</td></tr></thead>';
        for($i=0; $i<sizeof($sdata); $i++)
        {
            $a .= '<tr>';
            $a .= '<td>'.$sdata[$i]["id"].'</td>';
            $a .= '<td>'.$sdata[$i]["no"].'</td>';
            $a .= '<td>'.$sdata[$i]["name"].'</td>';
            $a .= '<td>'.static::course($sdata[$i]["fk_course_id"]).'</td>';
            $a .= '<td>'.static::dept($sdata[$i]["fk_dept_id"]).'</td>';
            $a .= '<td>'.$sdata[$i]["aided"].'</td>';
            $a .= '<td>'.$sdata[$i]["fromyear"].'</td>';
            $a .= '<td>'.$sdata[$i]["pyear"].'</td>';
            if(isset($sdata[$i]["actual"]))
            {
            $a .= '<td>'.$sdata[$i]["actual"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            if(isset($sdata[$i]["paid"]))
            {
            $a .= '<td>'.$sdata[$i]["paid"].'</td>';
            }
            else
            {
                $a .= '<td>0</td>';
            }
            $a .= '</tr>';
        }
        $a .= '</table>';
        echo $a;
    }
    public static function tcdata()
    {
        $_SESSION['org_id'] = 1;
        $data = Homem::getdata("SELECT um.id, um.no, um.name, um.fk_course_id, um.fk_dept_id, um.fromyear, dnm.code as course, ddm.code as dept, ddm.aided as aided, um.tc_given FROM user_master um JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE um.fromyear>='2018'");
        $actual = Homem::getdata("SELECT `no`, SUM(`feeamount`) as fee FROM `stdnt_feemaster` GROUP BY `no`");
        $paid = Homem::getdata("SELECT `no`, SUM(`amount`) as fee FROM `stdnt_normalfee` WHERE `fk_feemode_id`!='5' GROUP BY `no`");
        $conce = Homem::getdata("SELECT `no`, SUM(`amount`) as fee FROM `stdnt_normalfee` WHERE `fk_feemode_id`='5' GROUP BY `no`");
        for($i=0; $i<sizeof($data); $i++)
        {
            $data[$i]["actual"] = 0;
            for($j=0; $j<sizeof($actual); $j++)
            {
                if($data[$i]["id"] == $actual[$j]["no"])
                {
                    $data[$i]["actual"] = $actual[$j]["fee"];
                }
            }
        }
        for($i=0; $i<sizeof($data); $i++)
        {
            $data[$i]["paid"] = 0;
            for($j=0; $j<sizeof($paid); $j++)
            {
                if($data[$i]["id"] == $paid[$j]["no"])
                {
                    $data[$i]["paid"] = $paid[$j]["fee"];
                }
            }
        }
        for($i=0; $i<sizeof($data); $i++)
        {
            $data[$i]["conce"] = 0;
            for($j=0; $j<sizeof($conce); $j++)
            {
                if($data[$i]["id"] == $conce[$j]["no"])
                {
                    $data[$i]["conce"] = $conce[$j]["fee"];
                }
            }
        }
        $a = '<table border="1px">';
        for($i=0; $i<sizeof($data); $i++)
        {
            $diff = $data[$i]["actual"]-$data[$i]["paid"]-$data[$i]["conce"];
            $a .= '<tr>';
            $a .= '<td>'.$data[$i]["aided"].'</td>';
            $a .= '<td>'.$data[$i]["no"].'</td>';
            $a .= '<td>'.$data[$i]["name"].'</td>';
            $a .= '<td>'.$data[$i]["course"].'</td>';
            $a .= '<td>'.$data[$i]["dept"].'</td>';
            $a .= '<td>'.$data[$i]["fromyear"].'</td>';
            $a .= '<td>'.$data[$i]["actual"].'</td>';
            $a .= '<td>'.$data[$i]["paid"].'</td>';
            $a .= '<td>'.$data[$i]["conce"].'</td>';
            $a .= '<td>'.$diff.'</td>';
            $a .= '<td>'.$data[$i]["tc_given"].'</td>';
            $a .= '</tr>';
        }
        $a .= '</table>';
        echo $a;
    }
    public static function studentwisecollegereport()
    {
        $a ='';
        
        $u = Homem::getdata("SELECT id, no, name,fk_course_id, fk_dept_id, present_year FROM `user_master` WHERE `present_year`!='' AND `in_campus`='1'");
        $p = Homem::getdata("SELECT a.id, a.no, a.name, a.fk_course_id, a.fk_dept_id, a.present_year, sf.feeamount FROM stdnt_feemaster sf JOIN (SELECT id, no, name,fk_course_id, fk_dept_id, present_year FROM `user_master` WHERE `present_year`!='' AND `in_campus`='1') a ON sf.no=a.id WHERE sf.year<=a.present_year"); 
        $pa = Homem::getdata("");
    }
    public static function reportbwndateswithopnameconsolidatedaided()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id AND ddm.aided='1' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");
                $course = array();
                $opname = array();
                $feetype = array();
                $pdate = array();
                foreach ($data as $h) {
                    $feetype[] = $h['fk_feetype_id'];
                    $opname[] = $h['opname'];
                    $course[] = $h['fk_course_id'];
                    $pdate[] = $h['paid_date'];
                }
                $curse = array_values(array_unique($course));
                sort($curse);
                $name = array_values(array_unique($opname));
                sort($name);
                $ftype = array_values(array_unique($feetype));
                sort($ftype);
                $paiddate = array_values(array_unique($pdate));
                sort($paiddate);
                $acc = array();
                for($j=0; $j<sizeof($curse); $j++)
                {
                    for($k=0; $k<sizeof($ftype); $k++)
                    {
                        $acc[] = Extra::feeaccount($curse[$j], $ftype[$k]);
                    }
                }
                $accounts = array_values(array_unique($acc));
                sort($accounts);
                $accounts[] = 'Exam Fee';
                for($h=0; $h<sizeof($paiddate); $h++)
                {
                    for($i=0; $i<sizeof($name); $i++)
                    {
                        for($j=0; $j<sizeof($curse); $j++)
                        {
                            for($k=0; $k<sizeof($ftype); $k++)
                            {
                                if(!isset($uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]]))
                                {
                                    $uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]] = 0;
                                }
                                if(!isset($udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])]))
                                {
                                    
                                    $udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])] = 0;
                                }
                                for($l=0; $l<sizeof($data); $l++)
                                {
                                    if($paiddate[$h] == $data[$l]['paid_date'] && $name[$i] == $data[$l]['opname'] && $curse[$j] == $data[$l]['fk_course_id'] && $ftype[$k] == $data[$l]['fk_feetype_id'])
                                    {
                                        $uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]] = (int)$uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]]+(int)$data[$l]['amount'];
                                        $udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])] = (int)$udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])]+(int)$data[$l]['amount'];
                                        // echo $data[$l]['nid'];
                                    }
                                }
                            }
                        }
                    }
                }
                $data = Homem::getdata("SELECT se.*, um.name as opname FROM stdnt_examfee se JOIN user_master um ON um.id=se.entry_id WHERE DATE(se.entry_date) BETWEEN '$date1' AND '$date2'");
                $opname = array();
                $pdate = array();
                foreach ($data as $h) {
                    $opname[] = $h['opname'];
                    $pdate[] = $h['entry_date'];
                }
                $ename = array_values(array_unique($opname));
                sort($ename);
                $epaiddate = array_values(array_unique($pdate));
                sort($epaiddate);
                for($i=0; $i<sizeof($ename); $i++)
                {
                    for($j=0; $j<sizeof($epaiddate); $j++)
                    {
                        $udet[$epaiddate[$j]][$ename[$i]]['Exam Fee'] = 0;
                        $total = 0;
                        for($k=0; $k<sizeof($data); $k++)
                        {
                            if($ename[$i] == $data[$k]['opname'] && $epaiddate[$j] == $data[$k]['entry_date'])
                            {
                                $udet[$epaiddate[$j]][$ename[$i]]['Exam Fee'] = $udet[$epaiddate[$j]][$ename[$i]]['Exam Fee']+(int)$data[$k]['paidamount'];
                            }
                        }
                    }
                }
                $total = 0;
                $s=1;
                for($h=0; $h<sizeof($paiddate); $h++)
                {
                    for($i=0; $i<sizeof($name); $i++)
                    {
                        for($j=0; $j<sizeof($accounts); $j++)
                        {
                            if(isset($udet[$paiddate[$h]][$name[$i]][$accounts[$j]]))
                            {
                                if($udet[$paiddate[$h]][$name[$i]][$accounts[$j]] > 0)
                                {
                                    $a .= '<tr><td>'.$s.'</td><td>'.$paiddate[$h].'</td><td>'.$name[$i].'</td><td>'.$accounts[$j].'</td><td>'.$udet[$paiddate[$h]][$name[$i]][$accounts[$j]].'</td></tr>';
                                    $total = $total+(int)$udet[$paiddate[$h]][$name[$i]][$accounts[$j]];
                                    $s++;
                                }
                            }
                        }
                    }
                }
                // print_r($accounts);
                $head = '<thead>
                                <tr><th colspan="2">Date wise Fee Collection Report </th><th colspan="1">From: '.Extra::datem($_POST['fromdate']).'</th><th colspan="2">To: '.Extra::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Date</th>
                                    <th>Name of the operator</th>
                                    <th>Bank Account</th>
                                    <th>Amount</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$total.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                
            }
            // echo json_encode($udet);
            echo Menus::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Aided Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo Menus::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function reportbwndateswithopnameconsolidatedunaided()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id AND ddm.aided='0' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");
                $course = array();
                $opname = array();
                $feetype = array();
                $pdate = array();
                foreach ($data as $h) {
                    $feetype[] = $h['fk_feetype_id'];
                    $opname[] = $h['opname'];
                    $course[] = $h['fk_course_id'];
                    $pdate[] = $h['paid_date'];
                }
                $curse = array_values(array_unique($course));
                sort($curse);
                $name = array_values(array_unique($opname));
                sort($name);
                $ftype = array_values(array_unique($feetype));
                sort($ftype);
                $paiddate = array_values(array_unique($pdate));
                sort($paiddate);
                $acc = array();
                for($j=0; $j<sizeof($curse); $j++)
                {
                    for($k=0; $k<sizeof($ftype); $k++)
                    {
                        $acc[] = Extra::feeaccount($curse[$j], $ftype[$k]);
                    }
                }
                $accounts = array_values(array_unique($acc));
                sort($accounts);
                $accounts[] = 'Exam Fee';
                for($h=0; $h<sizeof($paiddate); $h++)
                {
                    for($i=0; $i<sizeof($name); $i++)
                    {
                        for($j=0; $j<sizeof($curse); $j++)
                        {
                            for($k=0; $k<sizeof($ftype); $k++)
                            {
                                if(!isset($uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]]))
                                {
                                    $uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]] = 0;
                                }
                                if(!isset($udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])]))
                                {
                                    
                                    $udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])] = 0;
                                }
                                for($l=0; $l<sizeof($data); $l++)
                                {
                                    if($paiddate[$h] == $data[$l]['paid_date'] && $name[$i] == $data[$l]['opname'] && $curse[$j] == $data[$l]['fk_course_id'] && $ftype[$k] == $data[$l]['fk_feetype_id'])
                                    {
                                        $uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]] = (int)$uind[$paiddate[$h]][$name[$i]][$curse[$j]][$ftype[$k]]+(int)$data[$l]['amount'];
                                        $udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])] = (int)$udet[$paiddate[$h]][$name[$i]][Extra::feeaccount($curse[$j], $ftype[$k])]+(int)$data[$l]['amount'];
                                        // echo $data[$l]['nid'];
                                    }
                                }
                            }
                        }
                    }
                }
                $data = Homem::getdata("SELECT se.*, um.name as opname FROM stdnt_examfee se JOIN user_master um ON um.id=se.entry_id WHERE DATE(se.entry_date) BETWEEN '$date1' AND '$date2'");
                $opname = array();
                $pdate = array();
                foreach ($data as $h) {
                    $opname[] = $h['opname'];
                    $pdate[] = $h['entry_date'];
                }
                $ename = array_values(array_unique($opname));
                sort($ename);
                $epaiddate = array_values(array_unique($pdate));
                sort($epaiddate);
                for($i=0; $i<sizeof($ename); $i++)
                {
                    for($j=0; $j<sizeof($epaiddate); $j++)
                    {
                        $udet[$epaiddate[$j]][$ename[$i]]['Exam Fee'] = 0;
                        $total = 0;
                        for($k=0; $k<sizeof($data); $k++)
                        {
                            if($ename[$i] == $data[$k]['opname'] && $epaiddate[$j] == $data[$k]['entry_date'])
                            {
                                $udet[$epaiddate[$j]][$ename[$i]]['Exam Fee'] = $udet[$epaiddate[$j]][$ename[$i]]['Exam Fee']+(int)$data[$k]['paidamount'];
                            }
                        }
                    }
                }
                $total = 0;
                $s=1;
                for($h=0; $h<sizeof($paiddate); $h++)
                {
                    for($i=0; $i<sizeof($name); $i++)
                    {
                        for($j=0; $j<sizeof($accounts); $j++)
                        {
                            if(isset($udet[$paiddate[$h]][$name[$i]][$accounts[$j]]))
                            {
                                if($udet[$paiddate[$h]][$name[$i]][$accounts[$j]] > 0)
                                {
                                    $a .= '<tr><td>'.$s.'</td><td>'.$paiddate[$h].'</td><td>'.$name[$i].'</td><td>'.$accounts[$j].'</td><td>'.$udet[$paiddate[$h]][$name[$i]][$accounts[$j]].'</td></tr>';
                                    $total = $total+(int)$udet[$paiddate[$h]][$name[$i]][$accounts[$j]];
                                    $s++;
                                }
                            }
                        }
                    }
                }
                // print_r($accounts);
                $head = '<thead>
                                <tr><th colspan="2">Date wise Fee Collection Report </th><th colspan="1">From: '.Extra::datem($_POST['fromdate']).'</th><th colspan="2">To: '.Extra::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Date</th>
                                    <th>Name of the operator</th>
                                    <th>Bank Account</th>
                                    <th>Amount</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$total.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                
            }
            // echo json_encode($udet);
            echo Menus::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Unaided Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo Menus::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function daywiseindividualworkreport()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 4)
        {
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="/Accounts/savedaywiseindividualworkreport" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Date Wise Work Summary Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">  
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <input placeholder="Date" class="form-control" name="rdate" id="rdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Time" class="form-control" name="fromtime" id="fromtime" onfocus="(this.type=`time`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Time" class="form-control" name="totime" id="totime" onfocus="(this.type=`time`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <div class="form-group">
                                                            <textarea id="report" name="report" class="form-control" placeholder="Day wise work summary"></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function savedaywiseindividualworkreport()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5 || $_SESSION['user_role'] == 4)
        {
            if(isset($_POST['rdate']))
            {
                date_default_timezone_set('Asia/Kolkata'); 
                $date = date('Y-m-d H:i:s A');
                $data = Homem::getdata("SELECT * FROM `daywiseindividualworkreport` WHERE `rdate`='$_POST[rdate]' AND `fk_user_id`='$_SESSION[user_id]'");
                if(sizeof($data) == 0)
                {
                    Homem::insert("INSERT INTO `daywiseindividualworkreport` (`rdate`, `fromtime`, `totime`, `report`, `fk_user_id`, `status`, `edate`) VALUES ('$_POST[rdate]', '$_POST[fromtime]', '$_POST[totime]', '$_POST[report]', '$_SESSION[user_id]', '1', '$date')");    
                    echo '<script>window.location = "/Accounts/daywiseindividualworkreport?status=1";</script>';
                }
                else
                {
                    Homem::insert("UPDATE `daywiseindividualworkreport` SET `fromtime`='$_POST[fromtime]', `totime`='$_POST[totime]', `report`='$_POST[report]' WHERE `rdate`='$_POST[rdate]' AND `fk_user_id`='$_SESSION[user_id]'");    
                    echo '<script>window.location = "/Accounts/daywiseindividualworkreport?status=2";</script>';
                }
            }
            else
            {
                echo '<script>window.location = "/Accounts/daywiseindividualworkreport?status=0";</script>';
            }
        }
    }
    /** Supporting functions started */
    private static function feetype($id)
    {
        if($id != '')
        {
            if($_SESSION['org_id'] == 1)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Add-on Course Fee';
                }
            }
            else if($_SESSION['org_id'] == 5)
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Processing Fee';
                }
                if($id == 3)
                {
                    return 'TC Fee';
                }
                if($id == 4)
                {
                    return 'Library Fee';
                }
                if($id == 5)
                {
                    return 'ANU Registration Fee';
                }
            }
            else
            {
                if($id == 1)
                {
                    return 'Tution Fee';
                }
                if($id == 2)
                {
                    return 'Bus Fee';
                }
                if($id == 3)
                {
                    return 'TC Fee';
                }
                if($id == 4)
                {
                    return 'Library Fee';
                }
            }
        }
    }
    private static function datem($id)
    {
        $data = explode('-', $id);
        $final = $data[2].'-'.$data[1].'-'.$data[0];
        return $final;
    }
    /** Supporting functions ended */
    
    /** Browser Checking code started */
    private static function checkbrower()
    {
        $mystring = $_SERVER['HTTP_USER_AGENT'];
        $word = 'Chrome';
        if(strpos($mystring, $word) !== false)
        {
            if(strpos($mystring, 'Mozilla') !== false)
            {
                return "1";
            } 
        }
        else if(strpos($mystring, 'Mozilla') !== false)
        {
            return "1";
        } 
        else
        {
            return "0";
        }
    }
    private static function checkiphone()
    {
        $iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
        $iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
        $iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
        $Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
        $webOS   = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
        if($iPod || $iPhone || $iPad || $Android || $webOS)
        {
            echo 1;
        }
        else
        {
            echo 0;
        }
    }
    /** Browser Checking code Ended */

    /** CSS, Script started */
    private static function css()
    {
        $css = 
        '<!DOCTYPE html>
        <html lang="en">
        <head>
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
            <title>Hindu College of Engineering & Technology || Guntur</title>
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
            <title>Hindu College of Engineering & Technology || Guntur</title>
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/css/style.css">
            <link rel="stylesheet" href="https://assets.hinduengg.com/hindu/assets/sweetalert2/dist/sweetalert2.min.css" >
            <style>
                @media print
                {
                    body * {
                        visibility: hidden;
                    }
                    .print-this, .print-this * {
                        visibility: visible;
                    }
                }
            </style>
            <script>
                function exportTableToExcel(tableID, filename = "")
                {
                    var downloadLink;
                    var dataType = "application/vnd.ms-excel";
                    var tableSelect = document.getElementById(tableID);
                    var tableHTML = tableSelect.outerHTML.replace(/ /g, "%20");
                    
                    // Specify file name
                    filename = filename?filename+".xls":"excel_data.xls";
                    
                    // Create download link element
                    downloadLink = document.createElement("a");
                    
                    document.body.appendChild(downloadLink);
                    
                    if(navigator.msSaveOrOpenBlob){
                        var blob = new Blob(["\ufeff", tableHTML], {
                            type: dataType
                        });
                        navigator.msSaveOrOpenBlob( blob, filename);
                    }else{
                        // Create a link to the file
                        downloadLink.href = "data:" + dataType + ", " + tableHTML;
                    
                        // Setting the file name
                        downloadLink.download = filename;
                        
                        //triggering the function
                        downloadLink.click();
                    }
                }
            </script>
        </head>';
        return $css;  
    }
    private static function script()
    {
        $script =
                '
                <div class="footer navbar-fixed-bottom text-center">        
                    <span class="text-muted text-center">Copyright &#169 2020. Hindu College of Engineering & Technology, Guntur</span>
                </div>
                <script src="https://assets.hinduengg.com/hindu/assets/word/jquery.min.js" ></script>
                <script src="https://assets.hinduengg.com/hindu/assets/js/bootstrap.min.js" ></script>
                <script src="https://assets.hinduengg.com/hindu/assets/vendor/sweetalert2/dist/sweetalert2.min.js" ></script>';
        return $script;  
    }
    private static function blockscript()
    {
        $script =
                '
                <div class="footer navbar-fixed-bottom text-center">        
                    <span class="text-muted text-center">Copyright &#169 2020. Hindu College of Engineering & Technology, Guntur</span>
                </div>
                <script src="https://assets.hinduengg.com/hindu/assets/word/jquery.min.js" ></script>
                <script src="https://assets.hinduengg.com/hindu/assets/js/bootstrap.min.js" ></script>
                <script src="https://assets.hinduengg.com/hindu/assets/sweetalert2/dist/sweetalert2.min.js" ></script>
                <!-- Script to stop mouse right click start-->
            <script>
                //Disable right click script
                var message = "";
                ///////////////////////////////////
                function clickIE() {
                    if (document.all) {
                        (message);
                        return false;
                    }
                }

                function clickNS(e) {
                    if (document.layers || (document.getElementById && !document.all)) {
                        if (e.which == 2 || e.which == 3) {
                            (message);
                            return false;
                        }
                    }
                }
                if (document.layers) {
                    document.captureEvents(Event.MOUSEDOWN);
                    document.onmousedown = clickNS;
                } else {
                    document.onmouseup = clickNS;
                    document.oncontextmenu = clickIE;
                }

                document.oncontextmenu = new Function("return false")
            </script>
            <!-- Script to stop mouse right click end-->

            <!-- Script to prevent selection start-->
            <script>
                $(document).ready(function () {
                    $("body").bind("cut copy", function (e) {
                        e.preventDefault();
                    });
                });
            </script>
            <!-- Script to prevent selection end-->
                ';
        return $script;  
    }
    /** CSS, Script Ended */
    
    // Supporting Functions for all
        // private static function course($id)
        // {
        //     if($id != '')
        //     {
        //         if($_SESSION['org_id'] == 1)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'B.Sc.';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'B.Com.';
        //             }
        //             if($id == 3)
        //             {
        //                 return 'B.A.';
        //             }
        //             if($id == 4)
        //             {
        //                 return 'Inter';
        //             }
        //             if($id == 5)
        //             {
        //                 return 'M.Sc.';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 2)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'B.Sc.';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'M.Sc.';
        //             }
        //             if($id == 3)
        //             {
        //                 return 'M.Sc. (Vocational)';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 3)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'Diploma';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'B.Tech.';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 4)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'MCA';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'M.Com';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 5)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'MBA';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 6)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'M.Com';
        //             }
        //         }
        //     }
        // }
        // private static function dept($id)
        // {
        //     if($id != '')
        //     {
        //         if($_SESSION['org_id'] == 1)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'MPCS';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'MSCS';
        //             }
        //             if($id == 3)
        //             {
        //                 return 'MECS';
        //             }
        //             if($id == 4)
        //             {
        //                 return 'General';
        //             }
        //             if($id == 5)
        //             {
        //                 return 'Computers';
        //             }
        //             if($id == 6)
        //             {
        //                 return 'MPC';
        //             }
        //             if($id == 7)
        //             {
        //                 return 'BZC';
        //             }
        //             if($id == 8)
        //             {
        //                 return 'GPC';
        //             }
        //             if($id == 9)
        //             {
        //                 return 'MiBC';
        //             }
        //             if($id == 10)
        //             {
        //                 return 'BiMC';
        //             }
        //             if($id == 11)
        //             {
        //                 return 'HS';
        //             }
        //             if($id == 12)
        //             {
        //                 return 'BS';
        //             }
        //             if($id == 13)
        //             {
        //                 return 'HEP';
        //             }
        //             if($id == 14)
        //             {
        //                 return 'EHP';
        //             }
        //             if($id == 15)
        //             {
        //                 return 'MES';
        //             }
        //             if($id == 16)
        //             {
        //                 return 'EPC';
        //             }
        //             if($id == 17)
        //             {
        //                 return 'MPC';
        //             }
        //             if($id == 18)
        //             {
        //                 return 'BiPC';
        //             }
        //             if($id == 19)
        //             {
        //                 return 'MEC';
        //             }
        //             if($id == 20)
        //             {
        //                 return 'CEC';
        //             }
        //             if($id == 21)
        //             {
        //                 return 'ABC';
        //             }
        //             if($id == 22)
        //             {
        //                 return 'HBZ';
        //             }
        //             if($id == 23)
        //             {
        //                 return 'FTM';
        //             }
        //             if($id == 24)
        //             {
        //                 return 'PHYSICS';
        //             }if($id == 25)
        //             {
        //                 return 'CHEMISTRY';
        //             }
        //             if($id == 26)
        //             {
        //                 return 'BOTANY';
        //             }
        //             if($id == 27)
        //             {
        //                 return 'FOOD';
        //             }
        //             if($id == 28)
        //             {
        //                 return 'HORT';
        //             }
        //             if($id == 29)
        //             {
        //                 return 'Unaided';
        //             }
        //             if($id == 30)
        //             {
        //                 return 'Soil';
        //             }
        //             if($id == 31)
        //             {
        //                 return 'Diplo';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 2)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'Agriculture';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'Horticulture';
        //             }
        //             if($id == 3)
        //             {
        //                 return 'Food Technology';
        //             }
        //             if($id == 4)
        //             {
        //                 return 'Physics';
        //             }
        //             if($id == 5)
        //             {
        //                 return 'Chemistry';
        //             }
        //             if($id == 6)
        //             {
        //                 return 'Botany';
        //             }
        //             if($id == 7)
        //             {
        //                 return 'Food Processing(Vocational)';
        //             }
        //             if($id == 8)
        //             {
        //                 return 'Horticultural(Vocational)';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 3)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'Civil';
        //             }
        //             else if($id == 2)
        //             {
        //                 return 'EEE';
        //             }
        //             else if($id == 3)
        //             {
        //                 return 'Mech';
        //             }
        //             else if($id == 4)
        //             {
        //                 return 'ECE';
        //             }
        //             else if($id == 5)
        //             {
        //                 return 'CSE';
        //             }
                    
        //             else if($id == 6)
        //             {
        //                 return 'S&H';
        //             }
        //             else if($id == 7)
        //             {
        //                 return 'Web';
        //             }
        //             else if($id == 8)
        //             {
        //                 return 'AI';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 4)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'Computers';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'Commerce';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 5)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'MBA';
        //             }
        //             if($id == 2)
        //             {
        //                 return 'Hos';
        //             }
        //         }
        //         if($_SESSION['org_id'] == 6)
        //         {
        //             if($id == 1)
        //             {
        //                 return 'M.Com';
        //             }
        //         }
        //     }
        // }
        private static function course($id)
        {
            if($id != '')
            {
                if($_SESSION['org_id'] == 1)
                {
                    if($id == 1)
                    {
                        return 'B.Sc.';
                    }
                    if($id == 2)
                    {
                        return 'B.Com.';
                    }
                    if($id == 3)
                    {
                        return 'B.A.';
                    }
                    if($id == 4)
                    {
                        return 'Inter';
                    }
                    if($id == 5)
                    {
                        return 'M.Sc.';
                    }
                    if($id == 6)
                    {
                        return 'BBA';
                    }
                    if($id == 7)
                    {
                        return 'BCA';
                    }
                }
                if($_SESSION['org_id'] == 2)
                {
                    if($id == 1)
                    {
                        return 'B.Sc.';
                    }
                    if($id == 2)
                    {
                        return 'M.Sc.';
                    }
                    if($id == 3)
                    {
                        return 'M.Sc. (Vocational)';
                    }
                }
                if($_SESSION['org_id'] == 3)
                {
                    if($id == 1)
                    {
                        return 'Diploma';
                    }
                    if($id == 2)
                    {
                        return 'B.Tech.';
                    }
                }
                if($_SESSION['org_id'] == 4)
                {
                    if($id == 1)
                    {
                        return 'MCA';
                    }
                    if($id == 2)
                    {
                        return 'M.Com';
                    }
                }
                if($_SESSION['org_id'] == 5)
                {
                    if($id == 1)
                    {
                        return 'MBA';
                    }
                }
                if($_SESSION['org_id'] == 6)
                {
                    if($id == 1)
                    {
                        return 'M.Com';
                    }
                }
            }
        }
        private static function dept($id)
        {
            if($id != '')
            {
                if($_SESSION['org_id'] == 1)
                {
                    if($id == 1)
                    {
                        return 'MPCS';
                    }
                    if($id == 2)
                    {
                        return 'MSCS';
                    }
                    if($id == 3)
                    {
                        return 'MECS';
                    }
                    if($id == 4)
                    {
                        return 'General';
                    }
                    if($id == 5)
                    {
                        return 'Computers';
                    }
                    if($id == 6)
                    {
                        return 'MPC';
                    }
                    if($id == 7)
                    {
                        return 'BZC';
                    }
                    if($id == 8)
                    {
                        return 'GPC';
                    }
                    if($id == 9)
                    {
                        return 'MiBC';
                    }
                    if($id == 10)
                    {
                        return 'BiMC';
                    }
                    if($id == 11)
                    {
                        return 'HS';
                    }
                    if($id == 12)
                    {
                        return 'BS';
                    }
                    if($id == 13)
                    {
                        return 'HEP';
                    }
                    if($id == 14)
                    {
                        return 'EHP';
                    }
                    if($id == 15)
                    {
                        return 'MES';
                    }
                    if($id == 16)
                    {
                        return 'EPC';
                    }
                    if($id == 17)
                    {
                        return 'MPC';
                    }
                    if($id == 18)
                    {
                        return 'BiPC';
                    }
                    if($id == 19)
                    {
                        return 'MEC';
                    }
                    if($id == 20)
                    {
                        return 'CEC';
                    }
                    if($id == 21)
                    {
                        return 'ABC';
                    }
                    if($id == 22)
                    {
                        return 'HBZ';
                    }
                    if($id == 23)
                    {
                        return 'FTM';
                    }
                    if($id == 24)
                    {
                        return 'PHY';
                    }if($id == 25)
                    {
                        return 'CHEM';
                    }
                    if($id == 26)
                    {
                        return 'BOT';
                    }
                    if($id == 27)
                    {
                        return 'FOOD';
                    }
                    if($id == 28)
                    {
                        return 'HORT';
                    }
                    if($id == 29)
                    {
                        return 'Gen(Un)';
                    }
                    if($id == 30)
                    {
                        return 'Soil';
                    }
                    if($id == 31)
                    {
                        return 'PGDip';
                    }
                    if($id == 32)
                    {
                        return 'CSDS';
                    }
                    if($id == 33)
                    {
                        return 'HEC';
                    }
                    if($id == 34)
                    {
                        return 'Economics';
                    }
                    if($id == 35)
                    {
                        return 'Maths';
                    }
                    if($id == 36)
                    {
                        return 'Political';
                    }
                    if($id == 37)
                    {
                        return 'SEnglish';
                    }
                    if($id == 38)
                    {
                        return 'Stat';
                    }
                    if($id == 39)
                    {
                        return 'Bot';
                    }
                    if($id == 40)
                    {
                        return 'Chemi';
                    }
                    if($id == 41)
                    {
                        return 'Geology';
                    }
                    if($id == 42)
                    {
                        return 'Math';
                    }
                    if($id == 43)
                    {
                        return 'Phy';
                    }
                    if($id == 44)
                    {
                        return 'Zoology';
                    }
                    if($id == 45)
                    {
                        return 'BCA';
                    }
                    if($id == 46)
                    {
                        return 'BBA';
                    }
                    if($id == 47)
                    {
                        return 'History';
                    }
                    if($id == 48)
                    {
                        return 'Political';
                    }
                    if($id == 49)
                    {
                        return 'Biotech';
                    }
                    if($id == 50)
                    {
                        return 'BioMed';
                    }
                    if($id == 51)
                    {
                        return 'MLT';
                    }
                    if($id == 52)
                    {
                        return 'Elect';
                    }
                    if($id == 53)
                    {
                        return 'Food';
                    }
                    if($id == 54)
                    {
                        return 'Aqua';
                    }
                    if($id == 55)
                    {
                        return 'Microbi';
                    }
                    if($id == 56)
                    {
                        return 'Homes';
                    }
                    if($id == 57)
                    {
                        return 'Nutrition';
                    }
                    if($id == 58)
                    {
                        return 'DataSci';
                    }
                    if($id == 59)
                    {
                        return 'AI';
                    }
                    if($id == 60)
                    {
                        return 'Multi';
                    }
                    if($id == 61)
                    {
                        return 'Comp';
                    }
                    if($id == 62)
                    {
                        return 'Indchem';
                    }
                    if($id == 63)
                    {
                        return 'Animation';
                    }
                    if($id == 64)
                    {
                        return 'Agricul';
                    }
                    if($id == 65)
                    {
                        return 'Horti';
                    }
                    if($id == 66)
                    {
                        return 'Economics';
                    }
                }
                if($_SESSION['org_id'] == 2)
                {
                    if($id == 1)
                    {
                        return 'Agriculture';
                    }
                    if($id == 2)
                    {
                        return 'Horticulture';
                    }
                    if($id == 3)
                    {
                        return 'Food Technology';
                    }
                    if($id == 4)
                    {
                        return 'Physics';
                    }
                    if($id == 5)
                    {
                        return 'Chemistry';
                    }
                    if($id == 6)
                    {
                        return 'Botany';
                    }
                    if($id == 7)
                    {
                        return 'Food Processing (Vocational)';
                    }
                    if($id == 8)
                    {
                        return 'Horticultural Landscaping (Vocational)';
                    }
                }
                if($_SESSION['org_id'] == 3)
                {
                    if($id == 1)
                    {
                        return 'Civil';
                    }
                    else if($id == 2)
                    {
                        return 'EEE';
                    }
                    else if($id == 3)
                    {
                        return 'Mech';
                    }
                    else if($id == 4)
                    {
                        return 'ECE';
                    }
                    else if($id == 5)
                    {
                        return 'CSE';
                    }
                    
                    else if($id == 6)
                    {
                        return 'S&H';
                    }
                    else if($id == 7)
                    {
                        return 'Web';
                    }
                    else if($id == 8)
                    {
                        return 'AIML';
                    }
                    else if($id == 9)
                    {
                        return 'AIDS';
                    }
                    else if($id == 10)
                    {
                        return 'CYBER';
                    }
                }
                if($_SESSION['org_id'] == 4)
                {
                    if($id == 1)
                    {
                        return 'Computers';
                    }
                    if($id == 2)
                    {
                        return 'Commerce';
                    }
                }
                if($_SESSION['org_id'] == 5)
                {
                    if($id == 1)
                    {
                        return 'MBA';
                    }
                    if($id == 2)
                    {
                        return 'HM';
                    }
                }
                if($_SESSION['org_id'] == 6)
                {
                    if($id == 1)
                    {
                        return 'M.Com';
                    }
                }
            }
        }
        private static function org($id)
        {
            if($id != '')
            {
                if($_SESSION['org_id'] == 1)
                {
                    return 'HINDU';
                }
                if($_SESSION['org_id'] == 3)
                {
                    return 'HCET';
                }
                if($_SESSION['org_id'] == 4)
                {
                    return 'PG';
                }
                if($_SESSION['org_id'] == 5)
                {
                    return 'HCMT';
                }
            }
        }
    // Supporting functions for all
    
    
    
    // To Secretary sir
        public static function incharge($course, $dept)
        {
            if($_SESSION["org_id"] == 1)
            {
                if($course == 4)
                {
                    if($dept == 17 || $dept == 18 || $dept == 19 || $dept == 20 || $dept == 33)
                    {
                        return "DP";
                    }
                }
                if($course == 1 || $course == 6 || $course == 7)
                {
                    if($dept == 9 || $dept == 10 || $dept == 11 || $dept == 12 || $dept == 21 || $dept == 22 || $dept == 23 || $dept == 32 || $dept == 45 || $dept == 46 || $dept == 49 || $dept == 50 || $dept == 51 || $dept == 52 || $dept == 53 || $dept == 54 || $dept == 55 || $dept == 56 || $dept == 57 || $dept == 58 || $dept == 59 || $dept == 60 || $dept == 61 || $dept == 62 || $dept == 63 || $dept == 64 || $dept == 65)
                    {
                        return "JUM";
                    }
                }
                if($course == 5)
                {
                    if($dept == 24 || $dept == 25 || $dept == 26 || $dept == 27 || $dept == 28 || $dept == 30 || $dept == 31)
                    {
                        return "JUMPG";
                    }
                }
                if($course == 1 || $course == 3)
                {
                    if($dept == 6 || $dept == 7 || $dept == 8 || $dept == 13 || $dept == 14 || $dept == 15 || $dept == 16 || $dept == 34 || $dept == 35 || $dept == 36 || $dept == 37 || $dept == 38 || $dept == 39 || $dept == 40 || $dept == 41 || $dept == 42 || $dept == 43 || $dept == 44 || $dept == 47 || $dept == 48 || $dept == 66)
                    {
                        return "PMP";
                    }
                    
                }
                if($course == 2)
                {
                    if($dept == 4 || $dept == 5 || $dept == 29)
                    {
                        return "SANTHILATHA";
                    }
                }
                if($course == 1)
                {
                    if($dept == 1 || $dept == 2 || $dept == 3)
                    {
                        return "SARATH";
                    }
                }
            }
            if($_SESSION["org_id"] == 3)
            {
                return "VNR";
            }
            if($_SESSION["org_id"] == 4)
            {
                return "MCA";
            }
            if($_SESSION["org_id"] == 5)
            {
                return "MBA";
            }
        }
        public static function monthlyreportlatestadmissions()
        {
            echo '<form action="#" method="POST">
                <input type="date" name="date" id="date">
                <input type="text" name="year" id="year">
                <input type="submit">
            </form>';
            if(isset($_POST['date']))
            {
                $date=$_POST['date'];
            }
            else
            {
                $date=date('Y-m-d');
                
            }
            echo $date;
            // $date='2022-03-01';
            if(isset($_POST['year']))
            {
                $years = $_POST['year'];
            }
            else
            {
                $month = date('m');
                if($month > 8)
                {
                    $years = date('Y');
                }
                else
                {
                    $years = date('Y')-1;
                }
            }
            echo '<table border="1px"><thead><tr><th>Org</th><th>Incharge</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
            for($i=1; $i<=5; $i++)
            {
                if($i!=2)
                {
                    $_SESSION['org_id'] = $i;
                    $org_id = $i;
                    $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                    $syear = 0;
                    for($b=$years; $b>$years-4; $b--)
                    {
                        $syear++;
                        $year = $b;
                        for($a=0; $a<sizeof($cdata); $a++)
                        {
                            $course = $cdata[$a]['course'];
                            $dept = $cdata[$a]['dept'];
                            $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `user_role`='3' AND `fromyear`='$year'");
                            $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<'$syear'");
                            $actual = $actualfee[0]['amount'];
                            if($actual == ''){$actual=0;}
                            $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<'$syear' AND sf.paid_date<'$date'");
                            $paid = $paidfee[0]['amount'];
                            if($paid == ''){$paid=0;}
                            $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                            $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                            $due = $actual-$paid;
                            echo '<tr>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::incharge($course, $dept).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$syear.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual.'</td>';
                            echo '<td>'.$paid.'</td>';
                            echo '<td>'.$due.'</td>';
                            echo '</tr>';
                            
                        }
                    }
                }
                
            }
            echo '</tbody></table>';
            
            
            
            //SELECT SUM(column_name) FROM table_name WHERE condition;
        }
        public static function monthlyreportlatestnew()
        {
            echo '<form action="#" method="POST">
                <input type="date" name="date" id="date">
                <input type="text" name="year" id="year">
                <input type="submit">
            </form>';
            if(isset($_POST['date']))
            {
                $date=$_POST['date'];
            }
            else
            {
                $date=date('Y-m-d');
                
            }
            echo $date;
            // $date='2022-03-01';
            if(isset($_POST['year']))
            {
                $years = $_POST['year'];
            }
            else
            {
                $month = date('m');
                if($month > 8)
                {
                    $years = date('Y');
                }
                else
                {
                    $years = date('Y')-1;
                }
            }
            echo '<table border="1px"><thead><tr><th>Org</th><th>Incharge</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
            for($i=1; $i<=5; $i++)
            {
                if($i!=2)
                {
                    $_SESSION['org_id'] = $i;
                    $org_id = $i;
                    $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                    $syear = 0;
                    for($b=$years; $b>$years-4; $b--)
                    {
                        $syear++;
                        $year = $b;
                        for($a=0; $a<sizeof($cdata); $a++)
                        {
                            $course = $cdata[$a]['course'];
                            $dept = $cdata[$a]['dept'];
                            $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                            $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<'$syear'");
                            $actual = $actualfee[0]['amount'];
                            if($actual == ''){$actual=0;}
                            $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<'$syear' AND sf.paid_date<'$date'");
                            $paid = $paidfee[0]['amount'];
                            if($paid == ''){$paid=0;}
                            $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                            $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                            $due = $actual-$paid;
                            echo '<tr>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::incharge($course, $dept).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$syear.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual.'</td>';
                            echo '<td>'.$paid.'</td>';
                            echo '<td>'.$due.'</td>';
                            echo '</tr>';
                            
                        }
                    }
                }
                
            }
            echo '</tbody></table>';
            
            
            
            //SELECT SUM(column_name) FROM table_name WHERE condition;
        }
        public static function monthlyreportlatest()
        {
            echo '<form action="#" method="POST">
                <input type="date" name="date" id="date">
                <input type="text" name="year" id="year">
                <input type="submit">
            </form>';
            if(isset($_POST['date']))
            {
                $date=$_POST['date'];
            }
            else
            {
                $date=date('Y-m-d');
                
            }
            echo $date;
            // $date='2022-03-01';
            if(isset($_POST['year']))
            {
                $years = $_POST['year'];
            }
            else
            {
                $month = date('m');
                if($month > 8)
                {
                    $years = date('Y');
                }
                else
                {
                    $years = date('Y')-1;
                }
            }
            echo '<table border="1px"><thead><tr><th>courseid</th><th>dept id</th><th>Org</th><th>Incharge</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
            for($i=1; $i<=5; $i++)
            {
                if($i!=2)
                {
                    $_SESSION['org_id'] = $i;
                    $org_id = $i;
                    $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                    $syear = 0;
                    for($b=$years; $b>$years-4; $b--)
                    {
                        $syear++;
                        $year = $b;
                        for($a=0; $a<sizeof($cdata); $a++)
                        {
                            $course = $cdata[$a]['course'];
                            $dept = $cdata[$a]['dept'];
                            $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                            $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear'");
                            $actual = $actualfee[0]['amount'];
                            if($actual == ''){$actual=0;}
                            $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear' AND sf.paid_date<'$date'");
                            $paid = $paidfee[0]['amount'];
                            if($paid == ''){$paid=0;}
                            $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                            $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                            $due = $actual-$paid;
                            echo '<tr>';
                            echo '<td>'.$course.'</td>';
                            echo '<td>'.$dept.'</td>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::incharge($course, $dept).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$syear.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual.'</td>';
                            echo '<td>'.$paid.'</td>';
                            echo '<td>'.$due.'</td>';
                            echo '</tr>';
                            
                        }
                    }
                }
                
            }
            echo '</tbody></table>';
            
            
            
            //SELECT SUM(column_name) FROM table_name WHERE condition;
        }
        public static function monthlyreport()
        {
            echo '<form action="#" method="POST">
            <input type="type" name="year" id="year" placeholder="year">
                <input type="date" name="date" id="date">
                <input type="submit">
            </form>';
            if(isset($_POST['date']))
            {
                $date=$_POST['date'];
            }
            else
            {
                $date=date('Y-m-d');
                
            }
            echo $date;
            // $date='2022-03-01';
            
            $month = date('m');
            if(!isset($_POST['year']))
            {
            if($month > 8)
            {
                $years = date('Y');
            }
            else
            {
                $years = date('Y')-1;
            }
            }
            else
            {
                $years = $_POST["year"];
            }
            echo '<table border="1px"><thead><tr><th>Org</th><th>Course</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
            for($i=1; $i<=5; $i++)
            {
                if($i!=2)
                {
                    $_SESSION['org_id'] = $i;
                    $org_id = $i;
                    $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                    $syear = 0;
                    for($b=$years; $b>$years-4; $b--)
                    {
                        $syear++;
                        $year = $b;
                        for($a=0; $a<sizeof($cdata); $a++)
                        {
                            $course = $cdata[$a]['course'];
                            $dept = $cdata[$a]['dept'];
                            $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                            $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear'");
                            $actual = $actualfee[0]['amount'];
                            if($actual == ''){$actual=0;}
                            $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear' AND sf.paid_date<'$date'");
                            $paid = $paidfee[0]['amount'];
                            if($paid == ''){$paid=0;}
                            $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                            $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                            $due = $actual-$paid;
                            echo '<tr>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::incharge($course, $dept).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$syear.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual.'</td>';
                            echo '<td>'.$paid.'</td>';
                            echo '<td>'.$due.'</td>';
                            echo '</tr>';
                            
                        }
                    }
                }
                
            }
            echo '</tbody></table>';
            
            
            
            //SELECT SUM(column_name) FROM table_name WHERE condition;
        }
        public static function monthlyreportnew()
        {
            echo '<form action="#" method="POST">
            <input type="type" name="year" id="year" placeholder="year">
                <input type="date" name="date" id="date">
                <input type="submit">
            </form>';
            if(isset($_POST['date']))
            {
                $date=$_POST['date'];
            }
            else
            {
                $date=date('Y-m-d');
                
            }
            echo $date;
            // $date='2022-03-01';
            
            $month = date('m');
            if(!isset($_POST['year']))
            {
            if($month > 8)
            {
                $years = date('Y');
            }
            else
            {
                $years = date('Y')-1;
            }
            }
            else
            {
                $years = $_POST["year"];
            }
            echo '<table border="1px"><thead><tr><th>Org</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th></tr></thead><tbody>';
            for($i=1; $i<=5; $i++)
            {
                if($i!=2)
                {
                    $_SESSION['org_id'] = $i;
                    $org_id = $i;
                    $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                    $syear = 0;
                    for($b=$years; $b>$years-4; $b--)
                    {
                        $syear++;
                        $year = $b;
                        for($a=0; $a<sizeof($cdata); $a++)
                        {
                            $course = $cdata[$a]['course'];
                            $dept = $cdata[$a]['dept'];
                            $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                            $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear'");
                            $actual = $actualfee[0]['amount'];
                            if($actual == ''){$actual=0;}
                            $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$syear' AND sf.paid_date<'$date'");
                            $paid = $paidfee[0]['amount'];
                            if($paid == ''){$paid=0;}
                            $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                            $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                            $due = $actual-$paid;
                            echo '<tr>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$syear.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual.'</td>';
                            echo '<td>'.$paid.'</td>';
                            echo '<td>'.$due.'</td>';
                            echo '</tr>';
                            
                        }
                    }
                }
                
            }
            echo '</tbody></table>';
            
            
            
            //SELECT SUM(column_name) FROM table_name WHERE condition;
        }
        public static function monthlyreporttest()
        {
            echo '<form action="#" method="POST">
                <input type="date" name="date" id="date">
                <input type="submit">
            </form>';
            if(isset($_POST['date']))
            {
                $date=$_POST['date'];
            }
            else
            {
                $date=date('Y-m-d');
                
            }
            echo $date;
            // $date='2022-03-01';
            
            $month = date('m');
            if($month > 8)
            {
                $years = date('Y');
            }
            else
            {
                $years = date('Y')-1;
            }
            echo '<table border="1px"><thead><tr><th>Org</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th><th>Due</th><th>Con Actual</th><th>Con</th><th>Man Actual</th><th>Man</th></tr></thead><tbody>';
            for($i=1; $i<=5; $i++)
            {
                if($i!=2)
                {
                    $_SESSION['org_id'] = $i;
                    $org_id = $i;
                    $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                    $syear = 0;
                    for($b=$years; $b>$years-4; $b--)
                    {
                        $syear++;
                        $year = $b;
                        for($a=0; $a<sizeof($cdata); $a++)
                        {
                            $course = $cdata[$a]['course'];
                            $dept = $cdata[$a]['dept'];
                            $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                            $actualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<='$syear'");
                            $actual = $actualfee[0]['amount'];
                            if($actual == ''){$actual=0;}
                            $cactualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<='$syear' AND um.squota='C'");
                            $mactualfee = Homem::getdata("SELECT SUM(sf.feeamount) as `amount`FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<='$syear' AND um.squota='M'");
                            $cactual = $cactualfee[0]['amount'];
                            if($cactual == ''){$cactual=0;}
                            $mactual = $mactualfee[0]['amount'];
                            if($mactual == ''){$mactual=0;}
                            $paidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<='$syear' AND sf.paid_date<'$date'");
                            $conpaidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<='$syear' AND sf.paid_date<'$date' AND um.squota='C'");
                            $manpaidfee = Homem::getdata("SELECT SUM(sf.amount) as `amount` FROM user_master um JOIN stdnt_normalfee sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year<='$syear' AND sf.paid_date<'$date' AND um.squota='M'");
                            $paid = $paidfee[0]['amount'];
                            if($paid == ''){$paid=0;}
                            $cpaid = $conpaidfee[0]['amount'];
                            if($cpaid == ''){$cpaid=0;}
                            $mpaid = $manpaidfee[0]['amount'];
                            if($mpaid == ''){$mpaid=0;}
                            $report[$org_id][$year][$course][$dept]['actual'] = $actual;
                            $report[$org_id][$year][$course][$dept]['paid'] = $paid;
                            $report[$org_id][$year][$course][$dept]['cpaid'] = $cpaid;
                            $report[$org_id][$year][$course][$dept]['mpaid'] = $mpaid;
                            $due = $actual-$paid;
                            echo '<tr>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$syear.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual.'</td>';
                            echo '<td>'.$paid.'</td>';
                            echo '<td>'.$due.'</td>';
                            echo '<td>'.$cactual.'</td>';
                            echo '<td>'.$cpaid.'</td>';
                            echo '<td>'.$mactual.'</td>';
                            echo '<td>'.$mpaid.'</td>';
                            echo '</tr>';
                            
                        }
                    }
                }
                
            }
            echo '</tbody></table>';
            
            
            
            //SELECT SUM(column_name) FROM table_name WHERE condition;
        }
        
        public static function monthlyattendance()
        {
            echo '<form action="#" method="POST">
                <input type="text" name="date1" id="date1" onfocus="this.type=`date`" onblur="this.type=`text`" placeholder="From Date" required>
                <input type="text" name="date2" id="date2" onfocus="this.type=`date`" onblur="this.type=`text`" placeholder="To Date" required>
                <input type="submit">
            </form>';
            if(isset($_POST['date1']))
            {
                $_SESSION["org_id"] = 1;
                $date1 = $_POST['date1'];
                $date2 = $_POST['date2'];
                $data = Homem::getdata("SELECT um.id, um.no, um.roll_no, um.name, um.fromyear, um.fk_course_id, um.fk_dept_id, a.edate, das.sid, das.status FROM (SELECT * FROM `dailyabsentsmsmaster` WHERE DATE(edate) BETWEEN '$date1' AND '$date2') a JOIN dailyabsentsmsid das ON das.daily_id=a.id JOIN user_master um ON um.id=das.sid");
                echo sizeof($data);
                 $sid = array();
                 $date = array();
                foreach ($data as $h) {
                    $sid[] = $h['sid'];
                    $date[] = $h['edate'];
                }
                $id = array_values(array_unique($sid));
                sort($id);
                $edate = array_values(array_unique($date));
                sort($edate);
                $a = '';
                echo '<table border="1px"><thead><tr><th>Roll No.</th><th>Ht. No.</th><th>Name</th><th>Course</th><th>Dept</th><th>From Year</th>';
                for($i=0; $i<sizeof($edate); $i++)
                {
                    echo '<th>'.static::datem($edate[$i]).'</th>';
                }
                echo '<th>Present</th><th>Absent</th><th>Total</th></thead><tbody>';
                for($i=0; $i<sizeof($id); $i++)
                {
                    $a.= '<tr>';
                    $b = '';
                    $count = 0;
                    $present = 0;
                    
                    for($k=0; $k<sizeof($edate); $k++)
                    {
                        $status = "-";
                        for($j=0; $j<sizeof($data); $j++)
                        {
                            
                            if($data[$j]["sid"] == $id[$i])
                            {
                                if($data[$j]["edate"] == $edate[$k])
                                {
                                    if($data[$j]["status"] == 1)
                                    {
                                        $status = "P";
                                    }
                                    if($data[$j]["status"] == 0)
                                    {
                                        $status = "A";
                                    }
                                }
                            }
                        }
                        $b .= '<td>'.$status.'</td>';
                    }
                    for($j=0; $j<sizeof($data); $j++)
                    {
                        
                        if($data[$j]["sid"] == $id[$i])
                        {
                            
                            if($count==0)
                            {
                                $a.= '<td>'.$data[$j]["roll_no"].'</td>';
                                $a.= '<td>'.$data[$j]["no"].'</td>';
                                $a.= '<td>'.$data[$j]["name"].'</td>';
                                $a.= '<td>'.static::course($data[$j]["fk_course_id"]).'</td>';
                                $a.= '<td>'.static::dept($data[$j]["fk_dept_id"]).'</td>';
                                $a.= '<td>'.$data[$j]["fromyear"].'</td>';
                            }
                            
                            $count++;
                            if($data[$j]["status"] == 1)
                            {
                                $present++;
                            }
                        }
                        if($j == sizeof($data)-1)
                        {
                            $absent = $count-$present;
                            $a .= $b;
                            $a.= '<td>'.$present.'</td>';
                            $a.= '<td>'.$absent.'</td>';
                            $a.= '<td>'.$count.'</td>';
                        }
                    }
                    $a.= '</tr>';
                }
                echo $a;
                echo '</tbody></table>';
            }
                
        }
    
    // To Prasad Sir
        //Supporting functions
            public static function checkaided($id)
            {
                $data = '{
                          "0": 4,
                          "1": 6,
                          "2": 7,
                          "3": 8,
                          "4": 13,
                          "5": 14,
                          "6": 15,
                          "7": 17,
                          "8": 18,
                          "9": 19,
                          "10": 20
                        }';
                $data = json_decode($data, true);
                $status = 0;
                for($i=0; $i<sizeof($data); $i++)
                {
                    if($data[$i] == $id)
                    {
                        $status = 1;
                    }
                }
                if($status == 1)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
    // To Prasad sir end
    public static function operatorwisedaysummary()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable='';
            if(isset($_POST['userid']))
            {
                $subtable = '<div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm" border="1px">
                                    <thead><tr><th>S. No.</th><th>Fee Type</th><th>Amount</th></tr></thead>
                                    <tbody>
                                    <tr><td>1</td><td>Degree Fee</td><td>'.static::degreefee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>2</td><td>Additional Fee</td><td>'.static::additionalfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>3</td><td>Monthly Fee</td><td>'.static::monthlyfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    </tbody>
                                </table>
                            </div>';
            }
            $data = Inputs::optionsdb(Homem::getdata("SELECT id, name FROM `user_master` WHERE (`user_role`='5')"), 'id', 'name');
            
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Date Wise Fee Collection Report By Name</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select id="userid" name="userid" class="form-control" required>
                                                            <option value="">Select Operator</option>
                                                            '.$data.'
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="Date" class="form-control" name="date" id="date" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" required>                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function degreefee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.amount) as amount FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE sn.paid_date='$date' AND sn.fk_feemode_id!='5' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }      
    public static function additionalfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(total) as amount FROM `stdnt_additionalfee` WHERE `fk_user_id`='$user' AND `paid_date`='$date'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function monthlyfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(amount) as amount FROM `stdnt_monthlyfee` WHERE `fk_user_id`='$user' AND `edate`='$date'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    
    public static function prasasirreport()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable='';
            if(isset($_POST['userid']))
            {
                $subtable = '<div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm" border="1px">
                                    <thead><tr><th>S. No.</th><th>Fee Type</th><th>Amount</th></tr></thead>
                                    <tbody>
                                    <tr><td>1</td><td>Degree Aided Tution Fee</td><td>'.static::degreeaidedfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>2</td><td>Degree Un-Aided Tution Fee</td><td>'.static::degreeundiadedtutionfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>3</td><td>Degree Un-Aided Add-on Course Fee</td><td>'.static::degreeundiadedaddoncoursefee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>4</td><td>Inter Tution Fee</td><td>'.static::interaiadedtutionfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>5</td><td>PG Tution Fee</td><td>'.static::pgtutionfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>6</td><td>Degree Aided Exam Fee</td><td>'.static::degreeaidedexamfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>6</td><td>Degree Un-Aided Exam Fee</td><td>'.static::degreeundiadedexamfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>6</td><td>Inter Exam Fee</td><td>'.static::interaidedexamfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    <tr><td>7</td><td>PG Exam Fee</td><td>'.static::pgexamfee($_POST['userid'], $_POST['date']).'</td></tr>
                                    </tbody>
                                </table>
                            </div>';
            }
            $data = Inputs::optionsdb(Homem::getdata("SELECT id, name FROM `user_master` WHERE (`user_role`='5')"), 'id', 'name');
            
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Date Wise Fee Collection Report By Name</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <select id="userid" name="userid" class="form-control" required>
                                                            <option value="">Select Operator</option>
                                                            '.$data.'
                                                            </select>
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="Date" class="form-control" name="date" id="date" onfocus="(this.type=`date`)" onblur="(this.type=`text`)" required>                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function degreeaidedfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.amount) as amount FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id<'4' AND ddm.aided='1' AND sn.paid_date='$date' AND sn.fk_feemode_id!='5' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function degreeundiadedtutionfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.amount) as amount FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id<'4' AND ddm.aided='0' AND sn.paid_date='$date' AND sn.fk_feemode_id!='5' AND sn.entry_id='$user' AND sn.fk_feetype_id='1'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function degreeundiadedaddoncoursefee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.amount) as amount FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id<'4' AND ddm.aided='0' AND sn.paid_date='$date' AND sn.fk_feemode_id!='5' AND sn.entry_id='$user' AND sn.fk_feetype_id='2'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function interaiadedtutionfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.amount) as amount FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id='4' AND ddm.aided='1' AND sn.paid_date='$date' AND sn.fk_feemode_id!='5' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function pgtutionfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.amount) as amount FROM stdnt_normalfee sn JOIN user_master um ON sn.no=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id='5' AND ddm.aided='0' AND sn.paid_date='$date' AND sn.fk_feemode_id!='5' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    
    public static function degreeaidedexamfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.paidamount) as amount FROM stdnt_examfee sn JOIN user_master um ON sn.id=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id<'4' AND ddm.aided='1' AND sn.entry_date='$date' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function degreeundiadedexamfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.paidamount) as amount FROM stdnt_examfee sn JOIN user_master um ON sn.id=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id<'4' AND ddm.aided='0' AND sn.entry_date='$date' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function interaidedexamfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.paidamount) as amount FROM stdnt_examfee sn JOIN user_master um ON sn.id=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id='4' AND ddm.aided='1' AND sn.entry_date='$date' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    public static function pgexamfee($user, $date)
    {
        $data = Homem::getdata("SELECT SUM(sn.paidamount) as amount FROM stdnt_examfee sn JOIN user_master um ON sn.id=um.id JOIN degree_dept_master ddm ON um.fk_dept_id=ddm.id WHERE um.fk_course_id='5' AND ddm.aided='0' AND sn.entry_date='$date' AND sn.entry_id='$user'");
        if(sizeof($data) == 1)
        {
            if($data[0]['amount'] == NULL)
            {
                return 0;
            }
            else
            {
                return $data[0]['amount'];
            }
        }
        else
        {
            return 0;
        }
    }
    
    public static function degreeaidedfeereportbwndateswithopname()
    {
        // Month & Year
        // $date = '2021-03-';
        // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'");
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2'");
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE  a.fk_feemode_id!='5' AND (um.fk_course_id='1' OR um.fk_course_id='2' OR um.fk_course_id='3') AND ddm.aided='1' ORDER BY a.paid_date ASC");
                if($_SESSION['user_role'] == 5)
                {
                    $data = Homem::getdata("SELECT * FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2') a JOIN user_master um ON um.id=a.no WHERE a.entry_id='$_SESSION[user_id]' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");    
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['ano'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['no'].'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.static::datem($data[$i]['paid_date']).'</td>
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'</td>
                                    <td>'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    <td>'.static::feetype($data[$i]['fk_feetype_id']).'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Admission Number</th>
                                    <th>Roll Number</th>
                                    <th>Hallticket Number</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                    <th>Paid Date</th>
                                    <th>Reciept Number</th>
                                    <th>Year</th>
                                    <th>Course</th>
                                    <th>Department</th>
                                    <th>Fee Type</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Aided Degree Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function degreeunaidedfeereportbwndateswithopname()
    {
        // Month & Year
        // $date = '2021-03-';
        // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'");
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2'");
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE  a.fk_feemode_id!='5' AND (um.fk_course_id='1' OR um.fk_course_id='2' OR um.fk_course_id='3') AND ddm.aided='0' ORDER BY a.paid_date ASC");
                if($_SESSION['user_role'] == 5)
                {
                    $data = Homem::getdata("SELECT * FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2') a JOIN user_master um ON um.id=a.no WHERE a.entry_id='$_SESSION[user_id]' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");    
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['ano'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['no'].'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.static::datem($data[$i]['paid_date']).'</td>
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'</td>
                                    <td>'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    <td>'.static::feetype($data[$i]['fk_feetype_id']).'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Admission Number</th>
                                    <th>Roll Number</th>
                                    <th>Hallticket Number</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                    <th>Paid Date</th>
                                    <th>Reciept Number</th>
                                    <th>Year</th>
                                    <th>Course</th>
                                    <th>Department</th>
                                    <th>Fee Type</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Un-Aided Degree Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function degreeunaidedtutionfeefeereportbwndateswithopname()
    {
        // Month & Year
        // $date = '2021-03-';
        // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'");
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2'");
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE  a.fk_feemode_id!='5' AND (um.fk_course_id='1' OR um.fk_course_id='2' OR um.fk_course_id='3') AND ddm.aided='0' AND a.fk_feetype_id='1' ORDER BY a.paid_date ASC");
                if($_SESSION['user_role'] == 5)
                {
                    $data = Homem::getdata("SELECT * FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2') a JOIN user_master um ON um.id=a.no WHERE a.entry_id='$_SESSION[user_id]' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");    
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['ano'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['no'].'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.static::datem($data[$i]['paid_date']).'</td>
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'</td>
                                    <td>'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    <td>'.static::feetype($data[$i]['fk_feetype_id']).'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Admission Number</th>
                                    <th>Roll Number</th>
                                    <th>Hallticket Number</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                    <th>Paid Date</th>
                                    <th>Reciept Number</th>
                                    <th>Year</th>
                                    <th>Course</th>
                                    <th>Department</th>
                                    <th>Fee Type</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Un-Aided Degree Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function degreeunaidedaddoncoursefeefeereportbwndateswithopname()
    {
        // Month & Year
        // $date = '2021-03-';
        // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'");
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2'");
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE  a.fk_feemode_id!='5' AND (um.fk_course_id='1' OR um.fk_course_id='2' OR um.fk_course_id='3' OR um.fk_course_id='4' OR um.fk_course_id='5') AND a.fk_feetype_id='2' ORDER BY a.paid_date ASC");
                if($_SESSION['user_role'] == 5)
                {
                    $data = Homem::getdata("SELECT * FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2') a JOIN user_master um ON um.id=a.no WHERE a.entry_id='$_SESSION[user_id]' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");    
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['ano'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['no'].'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.static::datem($data[$i]['paid_date']).'</td>
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'</td>
                                    <td>'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    <td>'.static::feetype($data[$i]['fk_feetype_id']).'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Admission Number</th>
                                    <th>Roll Number</th>
                                    <th>Hallticket Number</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                    <th>Paid Date</th>
                                    <th>Reciept Number</th>
                                    <th>Year</th>
                                    <th>Course</th>
                                    <th>Department</th>
                                    <th>Fee Type</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Un-Aided Degree Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function interaidedfeereportbwndateswithopname()
    {
        // Month & Year
        // $date = '2021-03-';
        // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'");
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2'");
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE  a.fk_feemode_id!='5' AND (um.fk_course_id='4') AND ddm.aided='1' ORDER BY a.paid_date ASC");
                if($_SESSION['user_role'] == 5)
                {
                    $data = Homem::getdata("SELECT * FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2') a JOIN user_master um ON um.id=a.no WHERE a.entry_id='$_SESSION[user_id]' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");    
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['ano'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['no'].'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.static::datem($data[$i]['paid_date']).'</td>
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'</td>
                                    <td>'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    <td>'.static::feetype($data[$i]['fk_feetype_id']).'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Admission Number</th>
                                    <th>Roll Number</th>
                                    <th>Hallticket Number</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                    <th>Paid Date</th>
                                    <th>Reciept Number</th>
                                    <th>Year</th>
                                    <th>Course</th>
                                    <th>Department</th>
                                    <th>Fee Type</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Inter Aided Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function pgfeereportbwndateswithopname()
    {
        // Month & Year
        // $date = '2021-03-';
        // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE `paid_date` LIKE '%$date%'");
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                // $data = Homem::getdata("SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2'");
                $data = Homem::getdata("SELECT a.*, um.*, u.name as opname FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' ) a JOIN user_master um ON um.id=a.no JOIN user_master u ON u.id=a.entry_id JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN degree_name_master dnm ON dnm.id=um.fk_course_id WHERE  a.fk_feemode_id!='5' AND (um.fk_course_id='5') AND ddm.aided='0' ORDER BY a.paid_date ASC");
                if($_SESSION['user_role'] == 5)
                {
                    $data = Homem::getdata("SELECT * FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2') a JOIN user_master um ON um.id=a.no WHERE a.entry_id='$_SESSION[user_id]' AND a.fk_feemode_id!='5' ORDER BY a.paid_date ASC");    
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $k = $i+1;
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['ano'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['no'].'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.static::datem($data[$i]['paid_date']).'</td>
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'</td>
                                    <td>'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    <td>'.static::feetype($data[$i]['fk_feetype_id']).'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Admission Number</th>
                                    <th>Roll Number</th>
                                    <th>Hallticket Number</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                    <th>Paid Date</th>
                                    <th>Reciept Number</th>
                                    <th>Year</th>
                                    <th>Course</th>
                                    <th>Department</th>
                                    <th>Fee Type</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-4"></div>
                            <div class="col-lg-4">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">PG Date Wise Fee Collection Report</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-6">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-6">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-4"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
            
    
    
    /** Fee breakup work starting */
     // Front CSS Not applied for this
    public static function feestractureforgenerationoffeebreakup()// Personal requeswt by sastri and prasad sir
    {

        if(isset($_POST['date']))
        {
            $date=$_POST['date'];
        }
        else
        {
            $date=date('Y-m-d');
            
        }
        echo $date;
        // $date='2022-03-01';
        
        $month = date('m');
        if($month > 6)
        {
            $years = date('Y');
        }
        else
        {
            $years = date('Y')-1;
        }
        echo '<table border="1px"><thead><tr><th>Org</th><th>Course</th><th>Dept</th><th>Join Year</th><th>Present Year</th><th>Student Count</th><th>Actual</th><th>Paid</th></tr></thead><tbody>';
        for($i=1; $i<=5; $i++)
        {
            if($i!=2)
            {
                $_SESSION['org_id'] = $i;
                $org_id = $i;
                $cdata = Homem::getdata("SELECT `course_id` as `course`, `dept_id` as `dept` FROM `degree_dept_relation`");
                $syear = 0;
                for($b=$years; $b>$years-4; $b--)
                {
                    $syear++;
                    $year = $b;
                    for($a=0; $a<sizeof($cdata); $a++)
                    {
                        $course = $cdata[$a]['course'];
                        $dept = $cdata[$a]['dept'];
                        for($j=1; $j<=$syear; $j++)
                        {
                           $actualfee1 = Homem::getdata("SELECT DISTINCT(sf.feeamount) as amount, COUNT(*) as `count` FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$j' AND sf.fk_feetype_id='1'"); 
                           $actualfee2 = Homem::getdata("SELECT DISTINCT(sf.feeamount) as amount, COUNT(*) as `count` FROM user_master um JOIN stdnt_feemaster sf ON sf.no=um.id WHERE um.fk_course_id='$course' AND um.fk_dept_id='$dept' AND um.discontinued!='1' AND um.tc_given!='1' AND um.user_role='3' AND um.fromyear='$year' AND sf.year='$j' AND sf.fk_feetype_id='2'"); 
                           $studcount = Homem::getdata("SELECT COUNT(*) as count FROM user_master WHERE `fk_course_id`='$course' AND `fk_dept_id`='$dept' AND `discontinued`!='1' AND `tc_given`!='1' AND `user_role`='3' AND `fromyear`='$year'");
                           $actual1 = $actualfee1[0]['amount'];
                            if($actual1 == ''){$actual1=0;}
                            $actual2 = $actualfee2[0]['amount'];
                            if($actual2 == ''){$actual2=0;}

                            echo '<tr>';
                            echo '<td>'.static::org($org_id).'</td>';
                            echo '<td>'.static::course($course).'</td>';
                            echo '<td>'.static::dept($dept).'</td>';
                            echo '<td>'.$year.'</td>';
                            echo '<td>'.$j.'</td>';
                            echo '<td>'.$studcount[0]['count'].'</td>';
                            echo '<td>'.$actual1.'</td>';
                            echo '<td>'.$actual2.'</td>';

                            echo '</tr>';
                        }
                    }
                }
            }
            
        }
        echo '</tbody></table>';
        
        
        
        //SELECT SUM(column_name) FROM table_name WHERE condition;
    }// Front CSS Not applied for this
    public static function feebreakupview()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable='';
            if($_SESSION['org_id'] ==1)
            {
                $a ='';
                $data = Homem::getdata("SELECT * FROM `feebreakup` WHERE `status`='1'");
                $fmaster = Homem::getdata("SELECT * FROM `feebreakupmaster`");
                $fchild = Homem::getdata("SELECT * FROM `feebreakupchild`");
                for($i=0; $i<sizeof($data); $i++)
                {
                    $sdata = json_decode($data[$i]['childsplit'], true);
                    $mdata = json_decode($data[$i]['mastersplit'], true);
                    $tdata = json_decode($data[$i]['totalfee'], true);
                    $b = '';
                    for($k=0; $k<sizeof($fchild); $k++)
                    {
                        $b .= '<td>'.$sdata[$fchild[$k]['id']].'</td>';
                    }
                    for($k=0; $k<sizeof($fmaster); $k++)
                    {
                        $b .= '<td>'.$mdata[$fmaster[$k]['id']].'</td>';
                    }
                    for($k=1; $k<=sizeof($tdata); $k++)
                    {
                        $b .= '<td>'.$tdata[$k].'</td>';
                    }
                    $j=$i+1;
                    $a .= '<tr><td>'.$j.'</td>';
                    $a .= '<td>'.static::course($data[$i]['fk_course_id']).'</td>';
                    $a .= '<td>'.static::dept($data[$i]['fk_dept_id']).'</td>';
                    $a .= '<td>'.$data[$i]['fk_course_id'].'</td>';
                    $a .= '<td>'.$data[$i]['fk_dept_id'].'</td>';
                    $a .= '<td>'.$data[$i]['joinyear'].'</td>';
                    $a .= '<td>'.$data[$i]['acyear'].'</td>';
                    $a .= '<td>'.$data[$i]['pyear'].'</td>';
                    $a .= $b;
                    $a .= '</tr>';
                }
                $b = '';
                for($k=0; $k<sizeof($fchild); $k++)
                {
                    $b .= '<th>'.$fchild[$k]['name'].'</th>';
                }
                for($k=0; $k<sizeof($fmaster); $k++)
                {
                    $b .= '<th>'.$fmaster[$k]['name'].'</th>';
                }
                $subtable = '<div class="table-responsive" id="exporttable">
                                <table class="table table-responsive-sm" border="1px">
                                    <thead><tr><th>S. No.</th><th>Course</th><th>Dept/Branch</th><th>Course</th><th>Dept/Branch</th><th>Join Year</th><th>Ac. Year</th><th>Year of study</th>'.$b.'<th>Total Tution Fee</th><th>Add- on Course Fee</th></tr></thead>
                                    <tbody>
                                    '.$a.'
                                    </tbody>
                                </table>
                            </div>';
                $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `breakup-data`)">Export</button>';
                
            }
            
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">View List of Fee Break-up Available</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                               
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function feebraeakupreportbwndates()
    {
        if($_SESSION['user_role'] == 6 || $_SESSION['user_role'] == 5)
        {
            $subtable = '';
            $a = '';
            if(isset($_POST['fromdate']))
            {
                $date1 = $_POST['fromdate'];
                $date2 = $_POST['todate'];
                if($_POST['type'] == 1)
                {
                    $data = Homem::getdata("SELECT u.name as opname, um.id as sid, a.*, um.*, fb.childsplit, fb.acyear FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' AND `fk_feemode_id`!='5' AND `fk_feetype_id`='1') a JOIN user_master um ON um.id=a.no JOIN feebreakup fb ON fb.fk_course_id=um.fk_course_id  JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id JOIN user_master u ON u.id=a.entry_id WHERE fb.fk_dept_id=um.fk_dept_id AND fb.joinyear=um.fromyear AND fb.pyear=a.year AND a.amount!=0 AND ddm.aided='1' AND um.fk_course_id<'8' AND um.fk_course_id!='4' AND um.fk_course_id!='5' ORDER BY a.paid_date ASC");
                    $data1 = Homem::getdata("SELECT u.name as opname, um.id as sid, a.*, um.* FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' AND `fk_feemode_id`!='5' AND `fk_feetype_id`='1') a JOIN user_master um ON um.id=a.no JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id  JOIN user_master u ON u.id=a.entry_id WHERE a.amount!=0 AND ddm.aided='1' AND um.fk_course_id<'8' AND um.fk_course_id!='4' AND um.fk_course_id!='5' ORDER BY a.paid_date ASC");
                }
                if($_POST['type'] == 2)
                {
                    $data = Homem::getdata("SELECT u.name as opname, um.id as sid, a.*, um.*, fb.childsplit, fb.acyear FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' AND `fk_feemode_id`!='5' AND `fk_feetype_id`='1') a JOIN user_master um ON um.id=a.no JOIN feebreakup fb ON fb.fk_course_id=um.fk_course_id  JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id  JOIN user_master u ON u.id=a.entry_id WHERE fb.fk_dept_id=um.fk_dept_id AND fb.joinyear=um.fromyear AND fb.pyear=a.year AND a.amount!=0 AND ddm.aided='0' AND um.fk_course_id<'8' AND um.fk_course_id!='4' AND um.fk_course_id!='5' ORDER BY a.paid_date ASC");
                    $data1 = Homem::getdata("SELECT u.name as opname, um.id as sid, a.*, um.* FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' AND `fk_feetype_id`='1' AND `fk_feemode_id`!='5') a JOIN user_master um ON um.id=a.no JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id  JOIN user_master u ON u.id=a.entry_id WHERE a.amount!=0 AND ddm.aided='0' AND um.fk_course_id<'8' AND um.fk_course_id!='4' AND um.fk_course_id!='5' ORDER BY a.paid_date ASC");
                }
                if($_POST['type'] == 3)
                {
                    $data = Homem::getdata("SELECT u.name as opname, um.id as sid, a.*, um.*, fb.childsplit, fb.acyear FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' AND `fk_feemode_id`!='5' AND `fk_feetype_id`='1') a JOIN user_master um ON um.id=a.no JOIN feebreakup fb ON fb.fk_course_id=um.fk_course_id  JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id  JOIN user_master u ON u.id=a.entry_id WHERE fb.fk_dept_id=um.fk_dept_id AND fb.joinyear=um.fromyear AND fb.pyear=a.year AND a.amount!=0 AND ddm.aided='1' AND um.fk_course_id='4' ORDER BY a.paid_date ASC");
                    $data1 = Homem::getdata("SELECT u.name as opname, um.id as sid, a.*, um.* FROM (SELECT * FROM `stdnt_normalfee` WHERE DATE(paid_date) BETWEEN '$date1' AND '$date2' AND `fk_feemode_id`!='5' AND `fk_feetype_id`='1') a JOIN user_master um ON um.id=a.no JOIN degree_dept_master ddm ON ddm.id=um.fk_dept_id  JOIN user_master u ON u.id=a.entry_id WHERE a.amount!=0 AND ddm.aided='1' AND um.fk_course_id='4' ORDER BY a.paid_date ASC");
                }
                if(sizeof($data) > 0)
                {
                    $tot = 0;
                    $fmaster = Homem::getdata("SELECT * FROM `feebreakupmaster`");
                    $fchild = Homem::getdata("SELECT * FROM `feebreakupchild`");
                    for($i=0; $i<sizeof($data); $i++)
                    {
                        $already = static::feepaiddetailsprevious($data[$i]['sid'], $data[$i]['nid'], $data[$i]['year'], $data[$i]['paid_date']);
                        // $oldcumsum = json_encode(static::cummulativesum(json_decode($data[$i]['childsplit'],true)));
                        $k = $i+1;
                        $actualbreakup = static::feebrekaupcalculator($data[$i]['childsplit'], $already, $data[$i]['amount']);
                        $actual = json_decode($actualbreakup, true);
                        $b = '';
                        $total = 0;
                        for($l=0; $l<sizeof($fmaster); $l++)
                        {
                            for($j=0; $j<sizeof($fchild); $j++)
                            {
                                if($fmaster[$l]['id'] == $fchild[$j]['fk_master_id'])
                                {
                                    $b .= '<td>'.$actual[$fchild[$j]['id']].'</td>';
                                    $total = $total + (int)$actual[$fchild[$j]['id']];
                                }
                                if($j == sizeof($fchild)-1)
                                {
                                    $b .= '<td>'.$total.'</td>';
                                    $total = 0;
                                }
                            }
                        }
                        
                        $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data[$i]['name'].'</td>
                                    
                                    <td>'.$data[$i]['recieptno'].'</td>
                                    <td>'.$data[$i]['paid_date'].'</td>
                                    <td>'.$data[$i]['roll_no'].'</td>
                                    <td>'.$data[$i]['fromyear'].'</td>
                                    <td>'.$data[$i]['year'].'</td>
                                    <td>'.$data[$i]['acyear'].'</td>
                                    <td>'.static::course($data[$i]['fk_course_id']).'-'.static::dept($data[$i]['fk_dept_id']).'</td>
                                    '.$b.'
                                    <td>'.$data[$i]['amount'].'</td>
                                    <td>'.$already.'</td>
                                    <td>'.$data[$i]['opname'].'</td>
                                </tr>';
                        $tot = $tot+$data[$i]['amount'];
                        
                    }
                    for($i=0; $i<sizeof($data1); $i++)
                    {
                        $show = 0;
                        for($j=0; $j<sizeof($data); $j++)
                        {
                            if($data1[$i]['nid'] == $data[$j]['nid'])
                            {
                                $show = 1;
                            }
                            if($j == sizeof($data)-1)
                            {
                                if($show == 0)
                                {
                                    $k++;
                                    $a .= '<tr>
                                    <td>'.$k.'</td>
                                    <td>'.$data1[$i]['name'].'</td>
                                    
                                    <td>'.$data1[$i]['recieptno'].'</td>
                                    <td>'.$data1[$i]['paid_date'].'</td>
                                    <td>'.$data1[$i]['roll_no'].'</td>
                                    <td>'.$data1[$i]['fromyear'].'</td>
                                    <td>'.$data1[$i]['year'].'</td>
                                    <td></td>
                                    <td>'.static::course($data1[$i]['fk_course_id']).'-'.static::dept($data1[$i]['fk_dept_id']).'</td>
                                    <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
                                    <td></td><td>'.$data1[$i]['amount'].'</td><td></td>
                                </tr>';
                                $tot = $tot+$data1[$i]['amount'];
                                }
                            }
                        }
                    }
                    
                    
                    $b = '';
                    for($i=0; $i<sizeof($fmaster); $i++)
                    {
                        for($j=0; $j<sizeof($fchild); $j++)
                        {
                            if($fmaster[$i]['id'] == $fchild[$j]['fk_master_id'])
                            {
                                $b .= '<th>'.$fchild[$j]['name'].'</th>';
                            }
                            if($j == sizeof($fchild)-1)
                            {
                                $b .= '<th>Total</th>';
                            }
                        }
                    }
                    $head = '<thead>
                                <tr><th colspan="3">Date wise Fee Collection Report</th><th colspan="3">From: '.static::datem($_POST['fromdate']).'</th><th colspan="3">To: '.static::datem($_POST['todate']).'</th></tr>
                                <tr>
                                    <th>S. No.</th>
                                    <th>Name in Full</th>
                                    <th>Reciept Number</th>
                                    <th>Date</th>
                                    <th>Roll Number</th>
                                    <th>Joining Year</th>
                                    <th>Fee Applicable Year</th>
                                    <th>Academic Year</th>
                                    <th>Group</th>
                                    '.$b.'
                                    <th>Grand Total</th>
                                    <th>Previous Paid</th>
                                    <th>Operator Name</th>
                                </tr>
                            </thead>';
                    $body = '<tbody>'; 
                    $body .= $a;
                    $body .= '<tr><td colspan="3">Total Amount Collected</td><td><b>'.$tot.'</b></td></tr>';
                    $body .= '</tbody>';
                    $table = '
                        <div class="table-responsive" id="exporttable">
                            <table class="table table-responsive-sm" border="1px">'.$head.'
                            '.$body.'
                            </table>
                        </div>
                    ';
                    $subtable .= $table;
                    $subtable .= '<button class="btn btn-primary" onclick="exportTableToExcel(`exporttable`, `results-data`)">Export</button>';
                }
            }
            echo static::css();
            echo '<body>';
            echo $_SESSION['menu'];
            echo '
                <div class="clearfix"></div>
                <form action="#" method="POST">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-lg-3"></div>
                            <div class="col-lg-6">                                       
                                <div class="row">
                                    <div class="col-lg-12">
                                        <section class="box" style="margin-top: 10px;">
                                            <header class="panel_header">
                                                <h5 class="title pull-left">Fee Collection Report with Break-up between two dates</h5>
                                                <div class="actions panel_actions pull-right">
                                                    <a class="fa fa-refresh" onclick="refreshClick()"></a>
                                                    <a class="box_toggle fa fa-chevron-down"></a>
                                                </div>
                                            </header>
                                            <div class="content-body">    
                                                <div class="row">
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <select class="form-control" name="type" id="type" required>
                                                            <option value="">Select Report Type</option>
                                                            <option value="1">Degree (Aided)</option>
                                                            <option value="2">Degree (Un-aided)</option>
                                                            <option value="3">Intermediate</option>
                                                            </select>
                                                        </div>
                                                    </div> 
                                                    <div class="col-lg-4">
                                                        <div class="form-group">                                            
                                                            <input placeholder="From Date" class="form-control" name="fromdate" id="fromdate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">
                                                        </div>
                                                    </div>    
                                                    <div class="col-lg-4">
                                                        <div class="form-group">             
                                                        <input placeholder="To Date" class="form-control" name="todate" id="todate" onfocus="(this.type=`date`)" onblur="(this.type=`text`)">                               
                                                        </div>
                                                    </div>                            
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">  
                                                        <div class="form-group">
                                                            <button id="btn_reg" class="btn btn-primary pull-right" type="submit" style="background-color: #002366 !important;">Submit</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>                        
                                        </section>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3"></div>
                        </div>
                        <div class="row print-this">
                            <div class="col-lg-1"></div>
                            <div class="col-lg-10">
                            '.$subtable.'
                            </div>
                            <div class="col-lg-1"></div>
                        </div>
                    </div>
                </form>
                ';
            echo '</body>';
            echo static::script();
            if(isset($_GET['status']))
            {
                if($_GET['status'] == 1)
                {
                    echo '<script>swal("", "Inserted Successfully", "success");</script>';
                }
                else if($_GET['status'] == 2)
                {
                    echo '<script>swal("", "Updated Successfully", "success");</script>';
                }
                else
                {
                    echo '<script>swal("", "Something went Wrong.. Please try again later..", "error");</script>';
                }
            }
        }
    }
    public static function feebrekaupcalculator($split, $already, $newpaid)
    {
        {
            $amount = $already;
            $split= json_decode($split, true);
            $csum = static::cummulativesum($split);
            for($i=1; $i<=sizeof($csum); $i++)
            {
                $diff = $csum[$i]-$already;
                if($diff < 0)
                {
                    $newcsum[$i] = 0;
                }
                else
                {
                    $newcsum[$i] = $diff;
                }
            }
            for($i=1; $i<=sizeof($split); $i++)
            {
                $diff = $split[$i]-$amount;
                if($diff < 0)
                {
                    $newsplit[$i] = 0;
                    $amount = $amount-$split[$i];
                }
                else
                {
                    $newsplit[$i] = $split[$i]-$amount;
                    $amount = 0;
                }
            }
            $amount = $newpaid;
            for($i=1; $i<=sizeof($newsplit); $i++)
            {
                $diff = $newsplit[$i]-$amount;
                if($diff <= 0 && $amount>0)
                {
                    $finalsplit[$i] = $newsplit[$i];
                    $amount = $amount-$newsplit[$i];
                }
                if($diff == 0 && $amount==0)
                {
                    $finalsplit[$i] = $newsplit[$i];
                }
                if($diff > 0)
                {
                    if($amount!=0)
                    {
                       $finalsplit[$i] = $amount;
                        $amount = 0; 
                    }
                    else
                    {
                        $finalsplit[$i] = 0;
                        $amount = 0;
                    }
                }
            }
            return json_encode($finalsplit);
        }
    }
    public static function feepaiddetailsprevious($id, $nid, $year, $date)
    {
        $data = Homem::getdata("SELECT SUM(amount) as paid FROM `stdnt_normalfee` WHERE `no`='$id' AND `year`='$year' AND `fk_feetype_id`='1' AND `nid`!='$nid' AND `paid_date`<='$date' AND `nid`<'$nid'");
        if($data[0]['paid'] != '')
        {
            return $data[0]['paid'];
        }
        else
        {
            return 0;
        }
    }
    public static function cummulativesum($data)
    {
        $a = 0;
        for($i=1; $i<=sizeof($data); $i++)
        {
            $b[$i] = $data[$i] + $a;
            $a = $b[$i];
        }
        return $b;
    }
}